diff --git a/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderMapper.java b/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderMapper.java index 3b04b30c..f025f1cb 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderMapper.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderMapper.java @@ -168,4 +168,11 @@ public interface ProOrderMapper { * @return */ int updateProOrderByOrderCode(ProOrder order); + + /** + * 通过木订单code查询子订单code + * @param orderCode + * @return + */ + public String selectChildProOrderCodeByCode(String orderCode); } diff --git a/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java b/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java index 7655bc86..01b485ec 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java @@ -155,6 +155,33 @@ public class ProOrderServiceImpl implements IProOrderService { run = false; } } + + // 关闭订单,判断是否拆分完成 + ProOrder order = proOrderMapper.selectProOrderById(splitOrderDTO.getProduct().getId()); + Long quantitySplit = order.getQuantitySplit(); + Long quantity1 = order.getQuantity(); + if (quantity1.equals(quantitySplit)) { + // 需要关闭订单的codeList + List orderCodes = new ArrayList<>(); + // 临时存放code + StringBuilder orderCode = new StringBuilder(); + orderCode.append(order.getOrderCode()); + while(true) { + orderCodes.add(orderCode.toString()); + String selectOrderCode = proOrderMapper.selectChildProOrderCodeByCode(orderCode.toString()); + if (selectOrderCode == null) { + break; + } + orderCode.setLength(0); + orderCode.append(selectOrderCode); + } + + // 关闭订单 + for (String code : orderCodes) { + remoteSapService.sapCloseOrder(code); + } + + } return success(); } diff --git a/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderMapper.xml b/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderMapper.xml index b0d603be..ea02f7da 100644 --- a/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderMapper.xml +++ b/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderMapper.xml @@ -137,7 +137,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where order_code = #{orderCode} - + + + insert into pro_order id,