From e711c834aec2293c53b07efe53e81e3573c289b6 Mon Sep 17 00:00:00 2001
From: 1 <1@123>
Date: 星期三, 01 四月 2026 11:42:44 +0800
Subject: [PATCH] lsh#

---
 rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskSchedules.java |  156 ++++++++++++++++++++++-----------------------------
 1 files changed, 67 insertions(+), 89 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 64c43bd..914d8d2 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
@@ -26,6 +26,7 @@
 import com.vincent.rsf.server.manager.entity.*;
 import com.vincent.rsf.server.manager.service.*;
 import com.vincent.rsf.server.manager.service.impl.LocServiceImpl;
+import com.vincent.rsf.server.manager.utils.WarehouseLocationRetrievalUtil;
 import com.vincent.rsf.server.system.constant.GlobalConfigCode;
 import com.vincent.rsf.server.system.constant.SerialRuleCode;
 import com.vincent.rsf.server.system.entity.*;
@@ -122,7 +123,7 @@
     public synchronized void missionTaskEXECUTE() {
         try{
             List<FlowStepInstance> flowStepInstanceList = flowStepInstanceService.list(new LambdaQueryWrapper<FlowStepInstance>()
-                    .eq(FlowStepInstance::getStatus, 1).in(FlowStepInstance::getStepType,MissionStepType.getTaskISSUE()));
+                    .eq(FlowStepInstance::getStatus,  (short) 1).in(FlowStepInstance::getStepType,MissionStepType.getTaskISSUE()));
             for (FlowStepInstance flowStepInstance : flowStepInstanceList) {
                 FlowInstance flowInstance = flowInstanceService.getById(flowStepInstance.getFlowInstanceId());
                 if (Cools.isEmpty(flowInstance)) { continue;}
@@ -179,43 +180,11 @@
                     MissionTaskIssueParam missionTaskIssueParam = new MissionTaskIssueParam(flowStepInstance,subsystemFlowTemplate,flowStepTemplate);
 
                     missionTaskIssueParam.setType(RcsTaskType.getTypeDesc(task.getTaskType()));
-                    boolean souSign = taskInstance.getSourceCode().matches("\\d+");
+                    boolean souSign = new WarehouseLocationRetrievalUtil().retrieveMissionmMergeReservoirAreaIsItAvailable(taskInstance.getSourceCode());
                     if (souSign){
-                        WarehouseAreas warehouseAreas = warehouseAreasService.getById(Long.parseLong(taskInstance.getSourceCode()));
-                        if (Cools.isEmpty(warehouseAreas)){
-                            BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, taskInstance.getSourceCode()).last("limit 1"));
-                            if (Cools.isEmpty(basStation)){
-                                basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
-                                        .apply("station_alias != '[]'")  // 涓嶆槸绌烘暟缁�
-                                        .apply("JSON_CONTAINS(station_alias, '\"{0}\"') = 1", taskInstance.getSourceCode())
-                                        .eq(BasStation::getDeleted, 0)  // 閫氬父闇�瑕佸姞涓婃湭鍒犻櫎鏉′欢
-                                        .last("LIMIT 1"));
-                            }
-                            if (Cools.isEmpty(basStation)){
-                                flowStepInstance.setRetryTimes(flowStepInstance.getRetryTimes() + 1);
-                                if (flowStepInstance.getRetryTimes()>5){
-                                    flowStepInstance.setStatus((short)4);
-                                    flowStepInstanceService.updateById(flowStepInstance);
-                                    log.error("浠诲姟涓嬪彂澶辫触,婧愮偣鏈煡璇㈠埌锛岄噸璇曟鏁板ぇ浜庣瓑浜庝簲娆★紝鏍囪涓哄け璐ワ紒锛侊紒");
-                                } else {
-                                    flowStepInstanceService.updateById(flowStepInstance);
-                                    log.error("浠诲姟涓嬪彂澶辫触,婧愮偣鏈煡璇㈠埌鐩爣鐐规湭鏌ヨ鍒帮紝绛夊緟閲嶈瘯....");
-                                }
-                                return;
-                            } else {
-                                missionTaskIssueParam.setSourceCode(basStation.getStationName());
-                            }
-                        } else {
-                            missionTaskIssueParam.setSourceCode(taskInstance.getSourceCode());
-                        }
+                        missionTaskIssueParam.setSourceCode(taskInstance.getSourceCode());
                     } else {
-                        BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, taskInstance.getSourceCode()).last("limit 1"));
-                        if (Cools.isEmpty(basStation)){
-                            basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
-                                    .apply("station_alias != '[]'")  // 涓嶆槸绌烘暟缁�
-                                    .apply("JSON_CONTAINS(station_alias, '\"{0}\"') = 1", taskInstance.getSourceCode())
-                                    .eq(BasStation::getDeleted, 0)  // 閫氬父闇�瑕佸姞涓婃湭鍒犻櫎鏉′欢
-                                    .last("LIMIT 1"));                            }
+                        BasStation basStation = new WarehouseLocationRetrievalUtil().retrieveMissionmMergeSizeIsItAvailable(taskInstance.getSourceCode());
                         if (Cools.isEmpty(basStation)){
                             flowStepInstance.setRetryTimes(flowStepInstance.getRetryTimes() + 1);
                             if (flowStepInstance.getRetryTimes()>5){
@@ -226,59 +195,27 @@
                                 flowStepInstanceService.updateById(flowStepInstance);
                                 log.error("浠诲姟涓嬪彂澶辫触,婧愮偣鏈煡璇㈠埌鐩爣鐐规湭鏌ヨ鍒帮紝绛夊緟閲嶈瘯....");
                             }
-                            return;
+                            continue;
                         } else {
                             missionTaskIssueParam.setSourceCode(basStation.getStationName());
                         }
                     }
-                    boolean endSign = taskInstance.getTargetCode().matches("\\d+");
+                    boolean endSign = new WarehouseLocationRetrievalUtil().retrieveMissionmMergeReservoirAreaIsItAvailable(taskInstance.getTargetCode());
                     if (endSign){
-                        WarehouseAreas warehouseAreas = warehouseAreasService.getById(Long.parseLong(taskInstance.getTargetCode()));
-                        if (Cools.isEmpty(warehouseAreas)){
-                            BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, taskInstance.getTargetCode()).last("limit 1"));
-                            if (Cools.isEmpty(basStation)){
-                                basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
-                                        .apply("station_alias != '[]'")  // 涓嶆槸绌烘暟缁�
-                                        .apply("JSON_CONTAINS(station_alias, '\"{0}\"') = 1", taskInstance.getTargetCode())
-                                        .eq(BasStation::getDeleted, 0)  // 閫氬父闇�瑕佸姞涓婃湭鍒犻櫎鏉′欢
-                                        .last("LIMIT 1"));                                }
-                            if (Cools.isEmpty(basStation)){
-                                flowStepInstance.setRetryTimes(flowStepInstance.getRetryTimes() + 1);
-                                if (flowStepInstance.getRetryTimes()>5){
-                                    flowStepInstance.setStatus((short)4);
-                                    flowStepInstanceService.updateById(flowStepInstance);
-                                    log.error("浠诲姟涓嬪彂澶辫触,鐩爣鐐规湭鏌ヨ鍒帮紝閲嶈瘯娆℃暟澶т簬绛変簬浜旀锛屾爣璁颁负澶辫触锛侊紒锛�");
-                                } else {
-                                    flowStepInstanceService.updateById(flowStepInstance);
-                                    log.error("浠诲姟涓嬪彂澶辫触,鐩爣鐐规湭鏌ヨ鍒帮紝绛夊緟閲嶈瘯....");
-                                }
-                                return;
-                            } else {
-                                missionTaskIssueParam.setTargetCode(basStation.getStationName());
-                            }
-
-                        } else {
-                            missionTaskIssueParam.setTargetCode(taskInstance.getTargetCode());
-                        }
+                        missionTaskIssueParam.setTargetCode(taskInstance.getTargetCode());
                     } else {
-                        BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, taskInstance.getTargetCode()).last("limit 1"));
-                        if (Cools.isEmpty(basStation)){
-                            basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
-                                    .apply("station_alias != '[]'")  // 涓嶆槸绌烘暟缁�
-                                    .apply("JSON_CONTAINS(station_alias, '\"{0}\"') = 1", taskInstance.getTargetCode())
-                                    .eq(BasStation::getDeleted, 0)  // 閫氬父闇�瑕佸姞涓婃湭鍒犻櫎鏉′欢
-                                    .last("LIMIT 1"));                                  }
+                        BasStation basStation = new WarehouseLocationRetrievalUtil().retrieveMissionmMergeSizeIsItAvailable(taskInstance.getTargetCode());
                         if (Cools.isEmpty(basStation)){
                             flowStepInstance.setRetryTimes(flowStepInstance.getRetryTimes() + 1);
                             if (flowStepInstance.getRetryTimes()>5){
                                 flowStepInstance.setStatus((short)4);
                                 flowStepInstanceService.updateById(flowStepInstance);
-                                log.error("浠诲姟涓嬪彂澶辫触,鐩爣鐐规湭鏌ヨ鍒帮紝閲嶈瘯娆℃暟澶т簬绛変簬浜旀锛屾爣璁颁负澶辫触锛侊紒锛�");
+                                log.error("浠诲姟涓嬪彂澶辫触,婧愮偣鏈煡璇㈠埌锛岄噸璇曟鏁板ぇ浜庣瓑浜庝簲娆★紝鏍囪涓哄け璐ワ紒锛侊紒");
                             } else {
                                 flowStepInstanceService.updateById(flowStepInstance);
-                                log.error("浠诲姟涓嬪彂澶辫触,鐩爣鐐规湭鏌ヨ鍒帮紝绛夊緟閲嶈瘯....");
+                                log.error("浠诲姟涓嬪彂澶辫触,婧愮偣鏈煡璇㈠埌鐩爣鐐规湭鏌ヨ鍒帮紝绛夊緟閲嶈瘯....");
                             }
-                            return;
+                            continue;
                         } else {
                             missionTaskIssueParam.setTargetCode(basStation.getStationName());
                         }
@@ -286,6 +223,7 @@
                     missionTaskIssueParam.setTaskPri(task.getSort());
                     missionTaskIssueParam.setBarcode(task.getBarcode());
                     missionTaskIssueParam.setTaskNo(task.getTaskCode());
+                    missionTaskIssueParam.setStaNoArea(task.getTargSiteAreaNow());
                     if (missionTaskIssueParam.getType().equals(RcsTaskType.RCS_TASK_TYPE_ENUM_IN.type) && endSign){
                         missionTaskIssueParam.setLocNo(task.getTargLoc());
                         missionTaskIssueParam.setSourcestaNo(missionTaskIssueParam.getSourcestaNo());
@@ -453,13 +391,45 @@
                         || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type)
                         || task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
                     task.setTaskStatus(TaskStsType.COMPLETE_IN.id);
-                } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)
-                        || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)
+                } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)){
+                    if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_WAVE_TYPE.val)
+                            || task.getResource().equals(TaskResouceType.TASK_RESOUCE_STOCK_UP.val)
+                            || task.getResource().equals(TaskResouceType.TASK_RESOUCE_STOCK_NOT_OUT.val)
+                    ){
+                        task.setTaskStatus(TaskStsType.AWAIT.id);
+                    } else {
+                        task.setTaskStatus(TaskStsType.COMPLETE_OUT.id);
+                    }
+                    BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getTargSite()));
+                    basStation.setUseStatus(LocStsType.LOC_STS_TYPE_F.type);
+                    basStation.setBarcode(task.getBarcode());
+                    basStationService.updateById(basStation);
+                } else if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)
                         || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type)
-                        || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)
-                        || task.getTaskType().equals(TaskType.TASK_TYPE_CROSS_DOCKING_OUT.type)
-                        || task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_OUT.type)) {
+                        || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) {
+                    if ((!Cools.isEmpty(task.getResource())
+                            && (task.getResource().equals(TaskResouceType.TASK_RESOUCE_WAVE_TYPE.val)
+                                || task.getResource().equals(TaskResouceType.TASK_RESOUCE_STOCK_UP.val)
+                                || task.getResource().equals(TaskResouceType.TASK_RESOUCE_STOCK_NOT_OUT.val)
+                           )
+                        )// 鐩樼偣鍑哄簱鍏堝埌 196(闈炴尝娆�)
+                        ||task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)
+                    ) {
+                        task.setTaskStatus(TaskStsType.AWAIT.id);
+                    } else {
+                        task.setTaskStatus(TaskStsType.WAVE_SEED.id);
+                    }
+                } else if (task.getTaskType().equals(TaskType.TASK_TYPE_CROSS_DOCKING_OUT.type)){//澶囪揣
                     task.setTaskStatus(TaskStsType.COMPLETE_OUT.id);
+                } else if (task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_OUT.type)){
+                    task.setTaskStatus(TaskStsType.COMPLETE_OUT.id);
+                    BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getTargSite()));
+                    basStation.setUseStatus(LocStsType.LOC_STS_TYPE_F.type);
+                    basStation.setBarcode(task.getBarcode());
+                    basStationService.updateById(basStation);
+                } else {
+                    log.error(task.getTaskCode()+":浠诲姟鏃犳硶瀹屾垚");
+                    continue;
                 }
                 taskService.updateById(task);
             }
@@ -482,7 +452,7 @@
 //    @Scheduled(cron = "0/3 * * * * ?")
     public void completeInStock() throws Exception {
         try{
-            List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getTaskStatus, TaskStsType.COMPLETE_IN.id).select(Task::getId));
+            List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().select(Task::getId).eq(Task::getTaskStatus, TaskStsType.COMPLETE_IN.id));
             if (tasks.isEmpty()) {
                 return;
             }
@@ -818,7 +788,9 @@
 //                if (!station.getUseStatus().equals(LocStsType.LOC_STS_TYPE_F.type)) {
 //                    throw new CoolException( "褰撳墠绔欑偣涓嶆槸F.鍦ㄥ簱鐘舵�佺姸鎬侊紒锛�");
 //                }
-                station.setUseStatus(LocStsType.LOC_STS_TYPE_R.type);
+                if (!station.getType().equals(0)){
+                    station.setUseStatus(LocStsType.LOC_STS_TYPE_R.type);
+                }
                 if (!basStationService.updateById(station)) {
                     throw new CoolException("绔欑偣鐘舵�佹洿鏂板け璐ワ紒锛�");
                 }
@@ -826,7 +798,9 @@
                 if (!station.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) {
                     throw new CoolException("鐩爣绔欑偣涓嶅O.绌洪棽鐘舵�侊紝鏃犳硶棰勭害鍑哄簱銆�");
                 }
-                station.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
+                if (!station.getType().equals(0)){
+                    station.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
+                }
                 if (!basStationService.updateById(station)) {
                     throw new CoolException("绔欑偣鐘舵�佹洿鏂板け璐ワ紒锛�");
                 }
@@ -904,15 +878,17 @@
                             || task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_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))) {
+                        task.setTaskStatus(TaskStsType.WCS_EXECUTE_IN.id);
+                        if (!taskService.updateById(task)) {
                             throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
                         }
                         /**鎺掗櫎绉诲簱鍔熻兘*/
                         if (!task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
                             /**濡傛灉鏄櫘閫氱珯鐐癸紝淇敼绔欑偣鐘舵�佷负鍑哄簱棰勭害*/
                             if (station.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
-                                station.setUseStatus(LocStsType.LOC_STS_TYPE_R.type);
+                                if (!station.getType().equals(0)){
+                                    station.setUseStatus(LocStsType.LOC_STS_TYPE_R.type);
+                                }
                                 if (!basStationService.updateById(station)) {
                                     throw new CoolException("绔欑偣棰勭害澶辫触锛侊紒");
                                 }
@@ -923,13 +899,15 @@
                             || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type)
                             || task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_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))) {
+                        task.setTaskStatus(TaskStsType.WCS_EXECUTE_OUT.id);
+                        if (!taskService.updateById(task)) {
                             throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
                         }
                         /**濡傛灉鏄櫘閫氱珯鐐癸紝淇敼绔欑偣鐘舵�佷负鍏ュ簱棰勭害*/
                         if (station.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
-                            station.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
+                            if (!station.getType().equals(0)){
+                                station.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
+                            }
                             if (!basStationService.updateById(station)) {
                                 throw new CoolException("绔欑偣棰勭害澶辫触锛侊紒");
                             }

--
Gitblit v1.9.1