From 0800daaeefdc7761ace0ae895f5a0273eb023e46 Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期四, 27 十一月 2025 11:10:34 +0800
Subject: [PATCH] 相同票号入收货区判断

---
 rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskSchedules.java |  401 +++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 234 insertions(+), 167 deletions(-)

diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskSchedules.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskSchedules.java
index b9b3f16..db94bf4 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskSchedules.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskSchedules.java
@@ -7,6 +7,8 @@
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.cfg.CoercionAction;
 import com.fasterxml.jackson.databind.cfg.CoercionInputShape;
+import com.vincent.rsf.framework.common.Cools;
+import com.vincent.rsf.framework.common.DateUtils;
 import com.vincent.rsf.framework.common.R;
 import com.vincent.rsf.framework.exception.CoolException;
 import com.vincent.rsf.server.api.config.RemotesInfoProperties;
@@ -22,7 +24,9 @@
 import com.vincent.rsf.server.manager.enums.*;
 import com.vincent.rsf.server.manager.entity.*;
 import com.vincent.rsf.server.manager.service.*;
+import com.vincent.rsf.server.manager.service.impl.LocItemWorkingServiceImpl;
 import com.vincent.rsf.server.manager.service.impl.LocServiceImpl;
+import com.vincent.rsf.server.manager.service.impl.WaveOrderRelaServiceImpl;
 import com.vincent.rsf.server.system.constant.GlobalConfigCode;
 import com.vincent.rsf.server.system.constant.SerialRuleCode;
 import com.vincent.rsf.server.system.entity.Config;
@@ -94,6 +98,11 @@
     private BasStationService basStationService;
     @Autowired
     private ReportMsgService reportMsgService;
+    @Autowired
+    private WaveOrderRelaService waveOrderRelaService;
+    @Autowired
+    private LocItemWorkingService locItemWorkingService;
+
 
     /**
      * @param
@@ -240,7 +249,7 @@
     /**
      * 闈炲厜鐢电珯鐐逛换鍔′笅鍙�
      */
-    @Scheduled(cron = "0/锛�5 * * * * ?  ")
+    @Scheduled(cron = "0/55 * * * * ?  ")
     @Transactional(rollbackFor = Exception.class)
     public void pubTaskToWcs() {
         Long loginUserId = SystemAuthUtils.getLoginUserId();
@@ -252,19 +261,28 @@
                 .in(Task::getTaskType, list)
                 .in(Task::getTaskStatus, integers)
                 .orderByDesc(Task::getSort));
-        for (Task task : tasks) {
-            /**绉诲簱涓嶅仛绔欑偣鎿嶄綔*/
-            if (!task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
-                BasStation station = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
-                        .eq(BasStation::getStationName,
-                                task.getTaskStatus().equals(TaskStsType.GENERATE_IN.id) ? task.getOrgSite() : task.getTargSite()));
-                if (station.getType().equals(StationTypeEnum.STATION_TYPE_MUTI.type)) {
-                    continue;
-                }
-            }
-            /**涓嬪彂鏅�氱珯鐐逛换鍔★紝鎶ラ敊鍥炴粴锛屼笉鍐嶅線涓嬫墽琛�*/
-            pubTaskToWcs(tasks);
+        if (tasks.isEmpty()) {
+            return;
         }
+        Config config = configService.getOne(new LambdaQueryWrapper<Config>().eq(Config::getFlag, GlobalConfigCode.AUTO_RUN_CHECK_ORDERS));
+        if (!Objects.isNull(config) && !Objects.isNull(config.getVal())) {
+            if (Boolean.parseBoolean(config.getVal())) {
+               return;
+            }
+        }
+//        for (Task task : tasks) {
+//            /**绉诲簱涓嶅仛绔欑偣鎿嶄綔*/
+//            if (!task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
+//                BasStation station = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
+//                        .eq(BasStation::getStationName,
+//                                task.getTaskStatus().equals(TaskStsType.GENERATE_IN.id) ? task.getOrgSite() : task.getTargSite()));
+//                if (station.getType().equals(StationTypeEnum.STATION_TYPE_MUTI.type)) {
+//                    continue;
+//                }
+//            }
+//        }
+        /**涓嬪彂鏅�氱珯鐐逛换鍔★紝鎶ラ敊鍥炴粴锛屼笉鍐嶅線涓嬫墽琛�*/
+        taskService.pubTaskToWcs(tasks);
     }
 
     /**
@@ -330,7 +348,7 @@
         }
         /**涓嬪彂浠诲姟*/
         try {
-            pubTaskToWcs(tasks);
+            taskService.pubTaskToWcs(tasks);
         } catch (Exception e) {
             log.error("浠诲姟涓嬪彂澶辫触锛侊紒", e);
         }
@@ -365,157 +383,165 @@
      *
      * @param tasks
      */
-    @Transactional(rollbackFor = Exception.class)
-    public void pubTaskToWcs(List<Task> tasks) {
-        WcsTaskParams taskParams = new WcsTaskParams();
-        List<TaskItemParam> items = new ArrayList<>();
-        tasks.forEach(task -> {
-            TaskItemParam itemParam = new TaskItemParam();
-            //浠诲姟绫诲瀷锛屼换鍔$紪鐮�
-            itemParam.setTaskType(RcsTaskType.getTypeDesc(task.getTaskType()))
-                    .setSeqNum(task.getTaskCode());
-            //涓诲弬鏁�
-            taskParams.setBatch(task.getBarcode());
-
-            BasStation station = null;
-            if (!task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
-                station = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getTargSite()));
-                if (Objects.isNull(station)) {
-                    throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
-                }
-            }
-
-            /**鍒ゆ柇鏄惁鍏夌數绔欑偣锛岄潪鍏夊簵绔欑偣闇�绠℃帶绔欑偣鐘舵��*/
-            if (!Objects.isNull(station) && station.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
-                if (task.getTaskType() <= TaskType.TASK_TYPE_CHECK_IN.type && !task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
-                    station.setUseStatus(LocStsType.LOC_STS_TYPE_R.type);
-                    if (!basStationService.updateById(station)) {
-                        throw new CoolException("绔欑偣鐘舵�佹洿鏂板け璐ワ紒锛�");
-                    }
-                } else if (task.getTaskType() >= TaskType.TASK_TYPE_OUT.type) {
-                    station.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
-                    if (!basStationService.updateById(station)) {
-                        throw new CoolException("绔欑偣鐘舵�佹洿鏂板け璐ワ紒锛�");
-                    }
-                }
-            }
-
-            /**绉诲簱鍙傛暟*/
-            if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
-                itemParam.setOriLoc(task.getOrgLoc()).setDestLoc(task.getTargLoc());
-            } else if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)
-                    || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type)
-                    || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) {
-                /**鍏ㄦ澘鍏ュ簱鍙傛暟*/
-                itemParam.setDestLoc(task.getTargLoc())
-                        .setOriSta(task.getOrgSite());
-            } else if (task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type)) {
-                /**鎷f枡/鐩樼偣鍏ュ簱鍙傛暟*/
-                itemParam.setDestLoc(task.getTargLoc())
-                        .setOriSta(task.getTargSite());
-            } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)
-                    || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)
-                    || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type)
-                    || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)
-                    || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type)) {
-                /**鍑哄簱鍙傛暟*/
-                itemParam.setOriLoc(task.getOrgLoc())
-                        .setDestSta(task.getTargSite());
-            } else {
-                /**绔欑偣闂寸Щ搴撳弬鏁�*/
-                itemParam.setOriSta(task.getOrgSite()).setDestSta(task.getTargSite());
-
-                BasStation curSta = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getOrgSite()));
-                if (Objects.isNull(curSta)) {
-                    throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
-                }
-                if (curSta.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
-                    if (!curSta.getUseStatus().equals(LocStsType.LOC_STS_TYPE_F.type)) {
-                        throw new CoolException("褰撳墠绔欑偣涓嶆槸F.鍦ㄥ簱鐘舵�侊紒锛�");
-                    }
-                }
-                if (station.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
-                    if (!station.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) {
-                        throw new CoolException("鐩爣绔欑偣涓嶆槸O.绌洪棽鐘舵�侊紒锛�");
-                    }
-                }
-            }
-            items.add(itemParam);
-        });
-        taskParams.setTaskList(items);
-        /**浠诲姟涓嬪彂鎺ュ彛*/
-        String pubTakUrl = rcsApi.getHost() + ":" + rcsApi.getPort() + RcsConstant.pubTask;
-        /**RCS鍩虹閰嶇疆閾炬帴*/
-        log.info("浠诲姟涓嬪彂锛岃姹傚湴鍧�锛� {}锛� 璇锋眰鍙傛暟锛� {}", pubTakUrl, JSONObject.toJSONString(taskParams));
-        HttpHeaders headers = new HttpHeaders();
-        headers.add("Content-Type", "application/json");
-        headers.add("api-version", "v2.0");
-        HttpEntity httpEntity = new HttpEntity(taskParams, headers);
-        ResponseEntity<String> exchange = restTemplate.exchange(pubTakUrl, HttpMethod.POST, httpEntity, String.class);
-        log.info("浠诲姟涓嬪彂鍚庯紝鍝嶅簲缁撴灉锛� {}", exchange);
-        if (Objects.isNull(exchange.getBody())) {
-            throw new CoolException("浠诲姟涓嬪彂澶辫触锛侊紒");
-        } else {
-            try {
-                ObjectMapper objectMapper = new ObjectMapper();
-                objectMapper.coercionConfigDefaults()
-                        .setCoercion(CoercionInputShape.EmptyString, CoercionAction.AsEmpty);
-                CommonResponse result = objectMapper.readValue(exchange.getBody(), CommonResponse.class);
-                if (result.getCode() == 200) {
-                    tasks.forEach(task -> {
-                        BasStation curSta = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getOrgSite()));
-                        if (Objects.isNull(curSta)) {
-                            throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
-                        }
-                        if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)
-                                || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type)
-                                || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)
-                                || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)
-                                || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type)
-                                || task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
-                            if (!taskService.update(new LambdaUpdateWrapper<Task>().eq(Task::getTaskCode, task.getTaskCode())
-                                    .set(Task::getTaskStatus, TaskStsType.WCS_EXECUTE_IN.id))) {
-                                throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
-                            }
-                            /**鎺掗櫎绉诲簱鍔熻兘*/
-                            if (!task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
-                                /**濡傛灉鏄櫘閫氱珯鐐癸紝淇敼绔欑偣鐘舵�佷负鍑哄簱棰勭害*/
-                                if (curSta.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
-                                    curSta.setUseStatus(LocStsType.LOC_STS_TYPE_R.type);
-                                    if (!basStationService.updateById(curSta)) {
-                                        throw new CoolException("绔欑偣棰勭害澶辫触锛侊紒");
-                                    }
-                                }
-                            }
-                        } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)
-                                || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)
-                                || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type)
-                                || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type)
-                                || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)) {
-                            if (!taskService.update(new LambdaUpdateWrapper<Task>().eq(Task::getTaskCode, task.getTaskCode())
-                                    .set(Task::getTaskStatus, TaskStsType.WCS_EXECUTE_OUT.id))) {
-                                throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
-                            }
-                            /**濡傛灉鏄櫘閫氱珯鐐癸紝淇敼绔欑偣鐘舵�佷负鍏ュ簱棰勭害*/
-                            if (curSta.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
-                                curSta.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
-                                if (!basStationService.updateById(curSta)) {
-                                    throw new CoolException("绔欑偣棰勭害澶辫触锛侊紒");
-                                }
-                            }
-                        }
-                    });
-                } else {
-                    log.error(JSONObject.toJSONString(result));
-//                    throw new CoolException("浠诲姟涓嬪彂澶辫触锛侊紒");
-                }
-            } catch (JsonProcessingException e) {
-                throw new CoolException(e.getMessage());
-            }
-        }
-
-    }
-
+//    @Transactional(rollbackFor = Exception.class)
+//    public void pubTaskToWcs(List<Task> tasks) {
+//        WcsTaskParams taskParams = new WcsTaskParams();
+//        List<TaskItemParam> items = new ArrayList<>();
+//        tasks.forEach(task -> {
+//            TaskItemParam itemParam = new TaskItemParam();
+//            //浠诲姟绫诲瀷锛屼换鍔$紪鐮�
+//            itemParam.setTaskType(RcsTaskType.getTypeDesc(task.getTaskType()))
+//                    .setSeqNum(task.getTaskCode());
+//            //涓诲弬鏁�
+//            taskParams.setBatch(task.getBarcode());
+//
+//            BasStation station = null;
+//            if (!task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
+//                station = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getTargSite()));
+//                if (Objects.isNull(station)) {
+//                    throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
+//                }
+//            }
+//
+//            /**鍒ゆ柇鏄惁鍏夌數绔欑偣锛岄潪鍏夊簵绔欑偣闇�绠℃帶绔欑偣鐘舵��*/
+//            if (!Objects.isNull(station) && station.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
+//                if (task.getTaskType() <= TaskType.TASK_TYPE_CHECK_IN.type && !task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
+//                    station.setUseStatus(LocStsType.LOC_STS_TYPE_R.type);
+//                    if (!basStationService.updateById(station)) {
+//                        throw new CoolException("绔欑偣鐘舵�佹洿鏂板け璐ワ紒锛�");
+//                    }
+//                } else if (task.getTaskType() >= TaskType.TASK_TYPE_OUT.type) {
+//                    station.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
+//                    if (!basStationService.updateById(station)) {
+//                        throw new CoolException("绔欑偣鐘舵�佹洿鏂板け璐ワ紒锛�");
+//                    }
+//                }
+//            }
+//
+//            /**绉诲簱鍙傛暟*/
+//            if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
+//                itemParam.setOriLoc(task.getOrgLoc()).setDestLoc(task.getTargLoc());
+//            } else if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)
+//                    || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type)
+//                    || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) {
+//                /**鍏ㄦ澘鍏ュ簱鍙傛暟*/
+//                itemParam.setDestLoc(task.getTargLoc())
+//                        .setOriSta(task.getOrgSite());
+//            } else if (task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type)) {
+//                /**鎷f枡/鐩樼偣鍏ュ簱鍙傛暟*/
+//                itemParam.setDestLoc(task.getTargLoc())
+//                        .setOriSta(task.getTargSite());
+//            } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)
+//                    || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)
+//                    || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type)
+//                    || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)
+//                    || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type)) {
+//                /**鍑哄簱鍙傛暟*/
+//                itemParam.setOriLoc(task.getOrgLoc())
+//                        .setDestSta(task.getTargSite());
+//            } else {
+//                /**绔欑偣闂寸Щ搴撳弬鏁�*/
+//                itemParam.setOriSta(task.getOrgSite()).setDestSta(task.getTargSite());
+//
+//                BasStation curSta = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getOrgSite()));
+//                if (Objects.isNull(curSta)) {
+//                    throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
+//                }
+//                if (curSta.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
+//                    if (!curSta.getUseStatus().equals(LocStsType.LOC_STS_TYPE_F.type)) {
+//                        throw new CoolException("褰撳墠绔欑偣涓嶆槸F.鍦ㄥ簱鐘舵�侊紒锛�");
+//                    }
+//                }
+//                if (station.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
+//                    if (!station.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) {
+//                        throw new CoolException("鐩爣绔欑偣涓嶆槸O.绌洪棽鐘舵�侊紒锛�");
+//                    }
+//                }
+//            }
+//            items.add(itemParam);
+//        });
+//        taskParams.setTaskList(items);
+//        /**浠诲姟涓嬪彂鎺ュ彛*/
+//        String pubTakUrl = rcsApi.getHost() + ":" + rcsApi.getPort() + RcsConstant.pubTask;
+//        /**RCS鍩虹閰嶇疆閾炬帴*/
+//        log.info("浠诲姟涓嬪彂锛岃姹傚湴鍧�锛� {}锛� 璇锋眰鍙傛暟锛� {}", pubTakUrl, JSONObject.toJSONString(taskParams));
+//        HttpHeaders headers = new HttpHeaders();
+//        headers.add("Content-Type", "application/json");
+//        headers.add("api-version", "v2.0");
+//        HttpEntity httpEntity = new HttpEntity(taskParams, headers);
+//        ResponseEntity<String> exchange = restTemplate.exchange(pubTakUrl, HttpMethod.POST, httpEntity, String.class);
+//        log.info("浠诲姟涓嬪彂鍚庯紝鍝嶅簲缁撴灉锛� {}", exchange);
+//        if (Objects.isNull(exchange.getBody())) {
+//            throw new CoolException("浠诲姟涓嬪彂澶辫触锛侊紒");
+//        } else {
+//            try {
+//                ObjectMapper objectMapper = new ObjectMapper();
+//                objectMapper.coercionConfigDefaults()
+//                        .setCoercion(CoercionInputShape.EmptyString, CoercionAction.AsEmpty);
+//                CommonResponse result = objectMapper.readValue(exchange.getBody(), CommonResponse.class);
+//                if (result.getCode() == 200) {
+//                    tasks.forEach(task -> {
+//
+//                        if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)
+//                                || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type)
+//                                || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)
+//                                || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)
+//                                || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type)
+//                                || task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
+//
+//                            BasStation curSta = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getOrgSite()));
+//                            if (Objects.isNull(curSta)) {
+//                                throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
+//                            }
+//
+//                            if (!taskService.update(new LambdaUpdateWrapper<Task>().eq(Task::getTaskCode, task.getTaskCode())
+//                                    .set(Task::getTaskStatus, TaskStsType.WCS_EXECUTE_IN.id))) {
+//                                throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+//                            }
+//                            /**鎺掗櫎绉诲簱鍔熻兘*/
+//                            if (!task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
+//                                /**濡傛灉鏄櫘閫氱珯鐐癸紝淇敼绔欑偣鐘舵�佷负鍑哄簱棰勭害*/
+//                                if (curSta.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
+//                                    curSta.setUseStatus(LocStsType.LOC_STS_TYPE_R.type);
+//                                    if (!basStationService.updateById(curSta)) {
+//                                        throw new CoolException("绔欑偣棰勭害澶辫触锛侊紒");
+//                                    }
+//                                }
+//                            }
+//                        } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)
+//                                || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)
+//                                || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type)
+//                                || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type)
+//                                || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)) {
+//                            BasStation curSta = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getTargSite()));
+//                            if (Objects.isNull(curSta)) {
+//                                throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
+//                            }
+//
+//                            if (!taskService.update(new LambdaUpdateWrapper<Task>().eq(Task::getTaskCode, task.getTaskCode())
+//                                    .set(Task::getTaskStatus, TaskStsType.WCS_EXECUTE_OUT.id))) {
+//                                throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+//                            }
+//                            /**濡傛灉鏄櫘閫氱珯鐐癸紝淇敼绔欑偣鐘舵�佷负鍏ュ簱棰勭害*/
+//                            if (curSta.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
+//                                curSta.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
+//                                if (!basStationService.updateById(curSta)) {
+//                                    throw new CoolException("绔欑偣棰勭害澶辫触锛侊紒");
+//                                }
+//                            }
+//                        }
+//                    });
+//                } else {
+//                    log.error(JSONObject.toJSONString(result));
+////                    throw new CoolException("浠诲姟涓嬪彂澶辫触锛侊紒");
+//                }
+//            } catch (JsonProcessingException e) {
+//                throw new CoolException(e.getMessage());
+//            }
+//        }
+//
+//    }
+//
 
     /**
      * @param
@@ -551,7 +577,6 @@
                 throw new CoolException("浠诲姟鍘嗗彶妗d繚瀛樺け璐ワ紒锛�");
             }
             List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()));
-            //鍏ュ簱鍗曟嵁鏄庣粏涓婃姤
 
             if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) {
                 for (TaskItem taskItem : taskItems) {
@@ -572,7 +597,45 @@
                     /**鍏ュ簱鍗曟槑缁嗕笂鎶�*/
                     reportMsgService.reportOrderItem(wkOrderItem);
                 }
-            } else if (task.getTaskType() >= TaskType.TASK_TYPE_OUT.type && task.getTaskType() <= TaskType.TASK_TYPE_EMPITY_OUT.type) {
+            } else if ((task.getTaskType() >= TaskType.TASK_TYPE_OUT.type && task.getTaskType() <= TaskType.TASK_TYPE_EMPITY_OUT.type)
+                    || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type)) {
+                /**鍒ゆ柇鍗曟嵁鏄惁瀹屾垚**/
+                Set<Long> longSet = taskItems.stream().map(TaskItem::getSourceId).collect(Collectors.toSet());
+                List<WaveOrderRela> waveOrderRelas = waveOrderRelaService.list(new LambdaQueryWrapper<WaveOrderRela>()
+                        .in(WaveOrderRela::getWaveId, longSet));
+                if (Cools.isEmpty(waveOrderRelas)) {
+                    throw new CoolException("娉㈡瀵瑰簲鍏宠仈鍗曟湭鎵惧埌");
+                }
+                Set<Long> orderIds = waveOrderRelas.stream().map(WaveOrderRela::getOrderId).collect(Collectors.toSet());
+                List<WkOrder> wkOrders = asnOrderService.listByIds(orderIds);
+                if (wkOrders.isEmpty()) {
+                    throw new CoolException("鍗曟嵁涓嶅瓨鍦紒锛�");
+                }
+
+                Config allowChang = configService.getOne(new LambdaQueryWrapper<Config>().eq(Config::getFlag, GlobalConfigCode.ALLOW_OVER_CHANGE));
+
+                wkOrders.forEach(order -> {
+                    //鍒ゆ柇鏄惁鍏佽瓒呮敹锛屼笉鍏佽瓒呮敹娣诲姞鎷掓敹鍒ゆ柇
+                    if (!Objects.isNull(allowChang)) {
+                        if (!Boolean.parseBoolean(allowChang.getVal())) {
+                            if (order.getAnfme().compareTo(order.getQty()) == 0) {
+                                order.setExceStatus(AsnExceStatus.OUT_STOCK_STATUS_TASK_DONE.val);
+                                if (!asnOrderService.updateById(order)) {
+                                    throw new CoolException("鍑哄簱鍗曟洿鏂扮姸鎬佸け璐�");
+                                }
+                            }
+                        } else {
+                            if (order.getAnfme().compareTo(order.getQty()) <= 0) {
+                                order.setExceStatus(AsnExceStatus.OUT_STOCK_STATUS_TASK_DONE.val);
+                                if (!asnOrderService.updateById(order)) {
+                                    throw new CoolException("鍑哄簱鍗曟洿鏂扮姸鎬佸け璐�");
+                                }
+                            }
+                        }
+                    }
+                    //妫�鏌ュ崟鎹槸鍚﹀畬鎴�
+
+                });
                 //鍑哄簱鍗曚笂鎶CS淇敼搴撲綅鐘舵��
                 try {
                     reportStationStatus(task);
@@ -592,6 +655,9 @@
                 itemLogs.add(itemLog);
             }
 
+            locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId()));
+
+
             if (!taskService.removeById(task.getId())) {
                 throw new CoolException("鍘熷浠诲姟鍒犻櫎澶辫触锛侊紒");
             }
@@ -604,6 +670,7 @@
                     throw new CoolException("鍘熷浠诲姟鏄庣粏鍒犻櫎澶辫触锛侊紒");
                 }
             }
+
         });
     }
 

--
Gitblit v1.9.1