| | |
| | | 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())) { |
| | |
| | | if (agvLocDetl.getAnfme() < agvWrkDetl.getAnfme()) { |
| | | throw new CoolException("拣料数量不能大于库存数量"); |
| | | } |
| | | }else { |
| | | } else { |
| | | throw new CoolException("拣料数量不能大于库存数量,存库不存在"); |
| | | } |
| | | |
| | |
| | | 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()); |
| | | } |
| | | } |