| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | if (!Cools.isEmpty(agvWrkMastService.selectByContainerCode(param.getBarcode()))) { |
| | | throw new CoolException(param.getBarcode() + "货架码已存在AGV工作档中"); |
| | | } |
| | | //判断是否有相同明细 |
| | | List<CombParam.CombMat> combMats = param.getCombMats(); |
| | | Map<String, String> data = new HashMap<>(); |
| | | for (CombParam.CombMat combMat : combMats) { |
| | | String matnr = combMat.getMatnr(); |
| | | String csocode = combMat.getCsocode(); |
| | | if (data.get(matnr + csocode) != null) { |
| | | throw new CoolException("明细中存在相同物料号和订单号"); |
| | | } |
| | | data.put(matnr + csocode, matnr + csocode); |
| | | } |
| | | |
| | | if (Cools.isEmpty(param.getOrderNo())) { |
| | | //无单组托 |
| | |
| | | AgvWrkDetl agvWrkDetl = agvWrkDetlService.selectOne(new EntityWrapper<AgvWrkDetl>().eq("matnr", pick.getMatnr()).eq("three_code", pick.getThreeCode()).eq("supp_code", pick.getSuppCode())); |
| | | |
| | | if (Cools.isEmpty(agvWrkDetl)) { |
| | | AgvWrkDetl wrkDetl = new AgvWrkDetl(); |
| | | agvWrkDetl = new AgvWrkDetl(); |
| | | Mat mat = matService.selectByMatnr(pick.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException(pick.getMatnr() + "商品不存在"); |
| | | } |
| | | wrkDetl.sync(mat); |
| | | wrkDetl.setWrkNo(pickParams.getWrkNo()); |
| | | wrkDetl.setOrderNo(pick.getOrderNo()); |
| | | wrkDetl.setIoTime(agvWrkMast.getIoTime()); |
| | | wrkDetl.setAnfme(pick.getCount()); // 数量 |
| | | wrkDetl.setSuppCode(pick.getSuppCode()); // 货架条码 |
| | | wrkDetl.setAppeUser(userId); |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setModiUser(userId); |
| | | wrkDetl.setModiTime(now); |
| | | wrkDetl.setThreeCode(pick.getThreeCode()); |
| | | agvWrkDetlService.insert(wrkDetl); |
| | | agvWrkDetl.sync(mat); |
| | | agvWrkDetl.setWrkNo(pickParams.getWrkNo()); |
| | | agvWrkDetl.setOrderNo(pick.getOrderNo()); |
| | | agvWrkDetl.setIoTime(agvWrkMast.getIoTime()); |
| | | agvWrkDetl.setAnfme(pick.getCount()); // 数量 |
| | | agvWrkDetl.setSuppCode(pick.getSuppCode()); // 货架条码 |
| | | agvWrkDetl.setAppeUser(userId); |
| | | agvWrkDetl.setAppeTime(now); |
| | | agvWrkDetl.setModiUser(userId); |
| | | agvWrkDetl.setModiTime(now); |
| | | agvWrkDetl.setThreeCode(pick.getThreeCode()); |
| | | agvWrkDetlService.insert(agvWrkDetl); |
| | | } else { |
| | | Double anfme = agvWrkDetl.getAnfme() + pick.getCount(); |
| | | agvWrkDetl.setIoTime(agvWrkMast.getIoTime()); |
| | |
| | | if (agvLocDetl.getAnfme() < agvWrkDetl.getAnfme()) { |
| | | throw new CoolException("拣料数量不能大于库存数量"); |
| | | } |
| | | } else { |
| | | throw new CoolException("拣料数量不能大于库存数量,存库不存在"); |
| | | } |
| | | |
| | | // 更新订单 |
| | | OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("order_no", pick.getOrderNo()).eq("matnr", pick.getMatnr()).eq("three_code", pick.getThreeCode())); |
| | | orderDetl.setQty(orderDetl.getQty() + pick.getCount()); |
| | | orderDetl.setUpdateTime(new Date()); |
| | | if (!orderDetlService.update(orderDetl, new EntityWrapper<OrderDetl>().eq("order_no", pick.getOrderNo()).eq("matnr", pick.getMatnr()).eq("three_code", pick.getThreeCode()))) { |
| | | throw new CoolException("修改订单明细失败,请联系管理员" + pick.getOrderNo() + pick.getMatnr()); |
| | | } |
| | |
| | | |
| | | AgvBasDevp agvBasDevp = agvBasDevpService.selectOne(new EntityWrapper<AgvBasDevp>().eq("dev_no", stationCode)); |
| | | |
| | | if (agvBasDevp == null) { |
| | | throw new CoolException(stationCode + "站点信息错误"); |
| | | } |
| | | |
| | | if (Cools.eq(agvBasDevp.getBarcode(), barcode)) { |
| | | return; |
| | | } |
| | |
| | | throw new CoolException(barcode + "已经绑定在" + agvBasDevp.getDevNo() + "站点"); |
| | | } |
| | | |
| | | if (agvBasDevp == null) { |
| | | throw new CoolException(stationCode + "站点信息错误"); |
| | | } |
| | | |
| | | if (!"O".equals(agvBasDevp.getLocSts())) { |
| | | throw new CoolException(stationCode + "该站点货位状态非空"); |
| | | } |
| | |
| | | throw new CoolException("请输入货架码"); |
| | | } |
| | | AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("source_loc_no", param.getDevNo())); |
| | | if (agvWrkMast == null) { |
| | | throw new CoolException("当前货架码没有任务"); |
| | | } |
| | | Integer oldWrkNo = agvWrkMast.getWrkNo(); |
| | | if (Cools.isEmpty(agvWrkMast)) { |
| | | throw new CoolException("工作档中没有此站点任务"); |
| | |
| | | public String handBack(AgvMobileStartPakin param, Long userId) { |
| | | Date now = new Date(); |
| | | AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("source_loc_no", param.getDevNo())); |
| | | if (agvWrkMast == null){ |
| | | throw new CoolException("工作档中没有此站点任务"); |
| | | } |
| | | agvWrkMast.setIoType(113); |
| | | agvWrkMast.setModiUser(userId); |
| | | agvWrkMast.setModiTime(now); |
| | |
| | | agvWrkDetlLogService.save(agvWrkMast.getWrkNo()); |
| | | String sourceLocNo = agvWrkMast.getSourceLocNo(); |
| | | AgvLocMast newLocMast = agvCommonService.getLocNo(3, 1, false, false); |
| | | if (newLocMast==null){ |
| | | throw new CoolException("无可用库位"); |
| | | } |
| | | agvWrkMast.setSourceLocNo(agvWrkMast.getLocNo()); |
| | | agvWrkMast.setLocNo(newLocMast.getLocNo()); |
| | | agvWrkMast.setIoType(57); |
| | |
| | | throw new CoolException("保存工作明细失败"); |
| | | } |
| | | // 同步订单数量 |
| | | OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("matnr", agvWrkDetl.getMatnr()).eq("three_code", agvWrkDetl.getThreeCode()).eq("order_no", agvWrkDetl.getOrderNo()).in("source", 18, 31, 34)); |
| | | //OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("matnr", agvWrkDetl.getMatnr()).eq("three_code", agvWrkDetl.getThreeCode()).eq("order_no", agvWrkDetl.getOrderNo()).in("source", 18, 31, 34)); |
| | | List<OrderDetl> orderDetls = orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("matnr", agvWrkDetl.getMatnr()).eq("three_code", agvWrkDetl.getThreeCode()).eq("order_no", agvWrkDetl.getOrderNo())); |
| | | OrderDetl orderDetl = null; |
| | | if (orderDetls.isEmpty()) { |
| | | throw new CoolException("订单明细不存在"); |
| | | } else if (orderDetls.size() > 1) { |
| | | for (OrderDetl detl : orderDetls) { |
| | | if (Cools.isEmpty(agvWrkDetl.getBatch()) && Cools.isEmpty(detl.getBatch())) { |
| | | orderDetl = detl; |
| | | } else if (!Cools.isEmpty(agvWrkDetl.getBatch()) && !Cools.isEmpty(detl.getBatch()) && agvWrkDetl.getBatch().equals(detl.getBatch())) { |
| | | orderDetl = detl; |
| | | } |
| | | } |
| | | if (orderDetl == null) { |
| | | throw new CoolException("订单明细不匹配"); |
| | | } |
| | | } else { |
| | | orderDetl = orderDetls.get(0); |
| | | } |
| | | orderDetl.setQty(orderDetl.getQty() - agvWrkDetl.getAnfme()); |
| | | if (!orderDetlService.update(orderDetl, new EntityWrapper<OrderDetl>().eq("order_no", orderDetl.getOrderNo()).eq("matnr", orderDetl.getMatnr()).eq("three_code", orderDetl.getThreeCode()))) { |
| | | if (!orderDetlService.updateById(orderDetl)) { |
| | | throw new CoolException("修改订单明细失败,请联系管理员" + orderDetl.getOrderNo() + orderDetl.getMatnr()); |
| | | } |
| | | } |