| | |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.mapper.ManLocDetlMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.asrs.utils.MatUtils; |
| | | import com.zy.asrs.utils.PostMesDataUtils; |
| | | import com.zy.common.CodeRes; |
| | | import com.zy.common.constant.MesConstant; |
| | | import com.zy.common.entity.Parameter; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.model.LocTypeDto; |
| | | import com.zy.common.model.MesCombParam; |
| | | import com.zy.common.model.StartupDto; |
| | | import com.zy.common.model.enums.WorkNoType; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 移动端服务核心类 |
| | |
| | | private LocDetlRullUpDetailService locDetlRullUpDetailService; |
| | | @Autowired |
| | | private TagService tagService; |
| | | @Autowired |
| | | private BasBoxTypeService basBoxTypeService; |
| | | @Autowired |
| | | private WrkMastLogService wrkMastLogService; |
| | | |
| | | @Resource |
| | | private OpenServiceImpl openServiceImpl; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | } |
| | | List<String> orderBoxNoList = new ArrayList<>(); |
| | | for (OrderDetl orderDetl: orderDetls){ |
| | | if (orderDetl.getWorkQty()==0){ |
| | | if (orderDetl.getWorkQty().equals(0.0)){ |
| | | orderBoxNoList.add(orderDetl.getBatch()); |
| | | } |
| | | } |
| | |
| | | if (!orderBoxNoList.contains(matList.getBatch())){ |
| | | throw new CoolException("单号:"+param.getOrderNo()+" 箱号:"+matList.getBatch()+"不属于此订单或者已经入库"); |
| | | }else { |
| | | matListBoxNoList.add(matList.getBoxNo()); |
| | | matListBoxNoList.add(matList.getBatch()); |
| | | } |
| | | } |
| | | List<OrderDetl> orderDetlList = new ArrayList<>(); |
| | |
| | | waitPakin.setBatch(orderDetl.getBatch()); //木箱编码 |
| | | waitPakin.setBrand(orderDetl.getBrand()); //木箱类型 |
| | | waitPakin.setZpallet(param.getBarcode()); //托盘码 |
| | | waitPakin.setWeight(orderDetl.getWeight()); //净重 |
| | | waitPakin.setVolume(orderDetl.getVolume()); //毛重 |
| | | waitPakin.setPrice(orderDetl.getPrice()); //长度 |
| | | waitPakin.setSpecs(String.valueOf(orderDetl.getSpecs())); //接头 |
| | | waitPakin.setOrigin("1"); //木箱在托盘上的位置 |
| | | waitPakin.setIoStatus("Y"); // 入出状态 |
| | | waitPakin.setAnfme(orderDetl.getAnfme()); // 木箱中铜箔数量 |
| | |
| | | } else if (basDevp.getWrkNo()!=0){ |
| | | throw new CoolException("212站点有工作号"); |
| | | } |
| | | int workNo = 20211; |
| | | WrkMast wrkMast1 = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", 20211)); |
| | | WrkMast wrkMast1 = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("io_type", 212)); |
| | | if (!Cools.isEmpty(wrkMast1)){ |
| | | throw new CoolException("任务档案已存在!请等待..."); |
| | | } |
| | | int workNo = commonService.getWorkNo(6); |
| | | Date now = new Date(); |
| | | // 生成工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | |
| | | public void PalletizingCompleteTwoFloorParam(PalletizingCompleteTwoFloorParam param) { |
| | | Long userId = 7777L;//中控 |
| | | param.setPalletizingNo(212); |
| | | |
| | | WrkMast wrkMast1 = wrkMastService.selectOne(new EntityWrapper<WrkMast>() |
| | | .eq("io_type", 1).eq("wrk_sts", 1).eq("source_sta_no",212)); |
| | | if (!Cools.isEmpty(wrkMast1)){ |
| | | throw new CoolException("存在一笔工作档案,请先入库!"); |
| | | } |
| | | |
| | | //判断param参数 |
| | | if (Cools.isEmpty(param.getBarcode())){ |
| | | throw new CoolException("参数:托盘码 barcode为空"); |
| | |
| | | }else if (Cools.isEmpty(matList.getWeight()) || matList.getWeight().equals(0D)){ |
| | | throw new CoolException("规格:"+matList.getMatnr()+"、参数:净重 weight为空"); |
| | | }else if (Cools.isEmpty(matList.getRoughWeight()) || matList.getRoughWeight().equals(0D)){ |
| | | throw new CoolException("规格:"+matList.getMatnr()+"、参数:毛重 roughWeight"); |
| | | throw new CoolException("规格:"+matList.getMatnr()+"、参数:毛重 roughWeight为空"); |
| | | }else if (Cools.isEmpty(matList.getRollExtent()) || matList.getRollExtent().equals(0D)){ |
| | | throw new CoolException("规格:"+matList.getMatnr()+"、参数:卷长度 rollExtent"); |
| | | throw new CoolException("规格:"+matList.getMatnr()+"、参数:卷长度 rollExtent为空"); |
| | | } |
| | | |
| | | if (matList.getPosition().equals("1")){//1、左 2、右 |
| | |
| | | }else { |
| | | throw new CoolException("参数:木箱编号 boxNo:"+matList.getBatch()+",木箱编码存在重复"); |
| | | } |
| | | } |
| | | |
| | | if (locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("batch", matList.getBatch()))!=0 |
| | | || wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("batch", matList.getBatch()))!=0 |
| | | || waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("batch", matList.getBatch()))!=0){ |
| | | throw new CoolException("木箱编号:"+matList.getBatch()+"已存在,请勿重复入库"); |
| | | } |
| | | } |
| | | |
| | | if (locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", param.getBarcode()))!=0 |
| | | || wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet", param.getBarcode()))!=0 |
| | |
| | | waitPakin.setZpallet(param.getBarcode()); //托盘码 |
| | | waitPakin.setOrigin(matList.getPosition()); //木箱在托盘上的位置 |
| | | waitPakin.setWeight(matList.getWeight()); //净重 |
| | | // waitPakin.setRoughWeight(matList.getRoughWeight()); //毛重 |
| | | // waitPakin.setRollExtent(matList.getRollExtent()); //长度 |
| | | waitPakin.setVolume(matList.getRoughWeight()); //毛重 |
| | | waitPakin.setPrice(matList.getRollExtent()); //长度 |
| | | waitPakin.setSpecs(String.valueOf(matList.getJoint())); //接头 |
| | | waitPakin.setIoStatus("Y"); // 入出状态 |
| | | waitPakin.setAnfme(matList.getAnfme()); // 数量 |
| | | waitPakin.setStatus("Y"); // 状态 |
| | |
| | | throw new CoolException(locDetl.getLocNo() + "库位不是在库状态"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void pakoutFhqr(Integer workNo, Integer check) { |
| | | // 获取工作档 |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", workNo)); |
| | | if (wrkMast == null) { |
| | | throw new CoolException("工作档不存在:" + workNo); |
| | | } |
| | | |
| | | if (wrkMast.getWrkSts() != 20) { |
| | | throw new CoolException("工作档当前状态异常:" + workNo + ",状态:" + wrkMast.getWrkSts()); |
| | | } |
| | | |
| | | if (check == 1) { |
| | | // 复核确认,更新状态为15出库完成更新 |
| | | wrkMast.setWrkSts(14L); |
| | | wrkMastService.updateById(wrkMast); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public R pdckqr(PdckqrParam param) { |
| | | WrkMast wrkMast = wrkMastService.selectById(param.getWorkNo()); |
| | | if (wrkMast == null) { |
| | | throw new CoolException("工作档不存在:" + param.getWorkNo()); |
| | | } |
| | | if (wrkMast.getIoType() != 107 || wrkMast.getWrkSts() != 2) { |
| | | throw new CoolException(param.getWorkNo() + "工作档类型:" + wrkMast.getIoType() + "工作状态:" + wrkMast.getWrkSts() + ",不匹配"); |
| | | } |
| | | |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(param.getWorkNo()); |
| | | List<PdckqrParam.Material> materials = param.getMaterials(); |
| | | |
| | | boolean isFullyCancelled = compareAndCheckCancellation(wrkDetls, materials); |
| | | if (isFullyCancelled) { // 盘点物料确成功,工作档转换 盘点出库->盘点再入库,下发回库命令 |
| | | // 保存工作主档历史档 |
| | | if (!wrkMastLogService.save(wrkMast.getWrkNo())) { |
| | | throw new CoolException("保存工作主档历史档失败"); |
| | | } |
| | | // 获取目标站 |
| | | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | | .eq("type_no", wrkMast.getIoType() - 50) |
| | | .eq("stn_no", wrkMast.getStaNo()) // 作业站点 = 拣料出库的目标站 |
| | | .eq("crn_no", wrkMast.getCrnNo()); // 堆垛机号 |
| | | StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | if (Cools.isEmpty(staDesc)) { |
| | | throw new CoolException("入库路径不存在"); |
| | | } |
| | | Date now = new Date(); |
| | | // 堆垛机站点(目标站) |
| | | Integer staNo = staDesc.getCrnStn(); |
| | | // 更新工作档数据状态 |
| | | wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54,107->57 |
| | | wrkMast.setWrkSts(14L); // 工作状态: 14.已出库未确认 |
| | | wrkMast.setSourceStaNo(wrkMast.getStaNo()); // 源站 |
| | | wrkMast.setStaNo(staNo); // 目标站 |
| | | wrkMast.setLocNo(wrkMast.getSourceLocNo()); // 目标库位 = 出库时的源库位 |
| | | wrkMast.setSourceLocNo(""); // 源库位清空 |
| | | wrkMast.setModiTime(now); |
| | | if (!wrkMastService.updateById(wrkMast)) { |
| | | throw new CoolException("更新工作档数据状态失败"); |
| | | } |
| | | // 修改库位状态 Q.拣料/盘点/并板再入库 |
| | | LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); |
| | | locMast.setLocSts("Q"); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("修改库位状态失败"); |
| | | } |
| | | |
| | | // 推送给gwcs执行命令 |
| | | openServiceImpl.pushStaNoToGwcs(wrkMast.getSourceStaNo(),wrkMast.getStaNo(),wrkMast.getWrkNo()); |
| | | |
| | | return R.ok("盘点确认成功"); |
| | | |
| | | } else { // 物料不一致 |
| | | // todo 不一致的处理处理方法待定 |
| | | |
| | | } |
| | | |
| | | return R.error("盘点确认异常"); |
| | | } |
| | | |
| | | /** |
| | | * 比较两个集合的类的属性,相同则抵消,最后判断两个集合是否完全抵消 |
| | | */ |
| | | public boolean compareAndCheckCancellation(List<WrkDetl> list1, List<PdckqrParam.Material> list2) { |
| | | if (list1.size() != list2.size()) { |
| | | return false; // If lists are not of the same size, cancellation is not possible |
| | | } |
| | | |
| | | List<PdckqrParam.Material> remainingList2 = new ArrayList<>(list2); |
| | | |
| | | // Compare and cancel out elements |
| | | for (WrkDetl p1 : list1) { |
| | | boolean cancelled = false; |
| | | for (PdckqrParam.Material p2 : remainingList2) { |
| | | if (p1.getBatch().equals(p2.getBoxNo()) && p1.getModel().equals(p2.getRollNo())) { // 卷号和箱号相同 |
| | | remainingList2.remove(p2); |
| | | cancelled = true; |
| | | break; |
| | | } |
| | | } |
| | | if (!cancelled) { |
| | | return false; // If any element in list1 cannot be cancelled, return false |
| | | } |
| | | } |
| | | |
| | | return remainingList2.isEmpty(); // Return true if all elements in list1 were cancelled out |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public List<Map<String, Object>> boxTypeComb() { |
| | | EntityWrapper<BasBoxType> wrapper = new EntityWrapper<>(); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | List<BasBoxType> basBoxTypes = basBoxTypeService.selectList(wrapper.orderBy("id",true)); |
| | | for (BasBoxType basBoxType : basBoxTypes){ |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("boxType", basBoxType.getBoxType()); |
| | | map.put("boxSpecs", basBoxType.getBoxSpecs()); |
| | | result.add(map); |
| | | } |
| | | return result; |
| | | } |
| | | } |