diff --git a/src/main/java/com/letian/modules/production/service/impl/DailyPlanServiceImpl.java b/src/main/java/com/letian/modules/production/service/impl/DailyPlanServiceImpl.java index 1d16dbd..d31b433 100644 --- a/src/main/java/com/letian/modules/production/service/impl/DailyPlanServiceImpl.java +++ b/src/main/java/com/letian/modules/production/service/impl/DailyPlanServiceImpl.java @@ -604,14 +604,42 @@ public class DailyPlanServiceImpl implements DailyPlanService { } @Override + @Transactional(rollbackFor = Exception.class) public void changeScheduleCloseFlag(ChangeScheduleCloseFlagData inData){ List checkList= dailyPlanMapper.getScheduledRoutingData(inData); if(checkList.size()==0){ throw new RuntimeException("该订单已不存在请刷新页面!"); } - if(checkList.get(0).getQtyReported()==checkList.get(0).getQtyRequired()){ + SOScheduledRoutingData dbData = checkList.get(0); + if(inData.getClosedFlag() != null && inData.getClosedFlag().equalsIgnoreCase(dbData.getClosedFlag())){ + return; + } + long qtyRequired = dbData.getQtyRequired() == null ? 0L : dbData.getQtyRequired(); + long qtyReported = dbData.getQtyReported() == null ? 0L : dbData.getQtyReported(); + long diffQty = qtyRequired - qtyReported; + if(diffQty <= 0){ throw new RuntimeException("该订单已全部入库请刷新页面!"); } + // 派工单关闭/开启时按未入库差额执行移库:关闭回退(MAT-9->MAT-1),开启补发(MAT-1->MAT-9)。rqrq + SoScheduleRmMoveData move = new SoScheduleRmMoveData(); + move.setSite(dbData.getSite()); + move.setOrderNo(dbData.getOrderNo()); + move.setScheduleQty((float) diffQty); + move.setTransDate(new Date()); + String username = resolveRmUsername(); + move.setUserID(username); + move.setReceiver(username); + move.setPartnerID(RM_PARTNER_FIXED); + if ("Y".equalsIgnoreCase(inData.getClosedFlag())) { + move.setFromWarehouseID(RM_WH_MAT_LINE); + move.setToWarehouseID(RM_WH_MAT_RAW); + } else if ("N".equalsIgnoreCase(inData.getClosedFlag())) { + move.setFromWarehouseID(RM_WH_MAT_RAW); + move.setToWarehouseID(RM_WH_MAT_LINE); + } else { + throw new RuntimeException("关闭标记参数有误:" + inData.getClosedFlag()); + } + executeSoScheduleMoveRm(move); dailyPlanMapper.changeScheduleCloseFlag(inData); } diff --git a/src/main/resources/mapper/production/DailyPlanMapper.xml b/src/main/resources/mapper/production/DailyPlanMapper.xml index 59fa23d..32386a0 100644 --- a/src/main/resources/mapper/production/DailyPlanMapper.xml +++ b/src/main/resources/mapper/production/DailyPlanMapper.xml @@ -370,7 +370,7 @@