From 6c3cc6842009f3897c3fb18bef8a6634fe653818 Mon Sep 17 00:00:00 2001
From: 1 <1@123>
Date: 星期三, 04 三月 2026 19:59:11 +0800
Subject: [PATCH] lsh#

---
 rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskSchedules.java |  181 +++++++++++++++++++++++---------------------
 1 files changed, 94 insertions(+), 87 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 d8e85b2..64c43bd 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
@@ -134,7 +134,7 @@
                 taskInstanceNode.setStatus(flowInstance.getStatus());
                 TaskInstance taskInstance = taskInstanceService.getById(flowInstance.getTaskId());
                 if (Cools.isEmpty(taskInstance)) { continue;}
-                Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskCode, taskInstance.getTaskNo()));
+                Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskCode, taskInstance.getTaskNo()).last("limit 1"),false);
                 if (Cools.isEmpty(task)) { continue;}
                 if (!task.getTaskStatus().equals(flowStepInstance.getWmsNowTaskStatus())) {
                     log.error("浠诲姟鍙凤細"+task.getTaskCode()+"鐨勪换鍔$姸鎬佷笌鎵ц妗f浠诲姟鐘舵�侊細"+flowStepInstance.getWmsNowTaskStatus()+"涓嶄竴鑷达紒锛侊紒");
@@ -156,7 +156,7 @@
                                     .eq(FlowStepInstance::getStatus, (short)0)
                                     .eq(FlowStepInstance::getTaskNo, flowStepInstance.getTaskNo())
                                     .eq(FlowStepInstance::getStepOrder, flowStepInstance.getStepOrder() + 1)
-                                    .eq(FlowStepInstance::getWmsNowTaskStatus, flowStepInstance.getWmsNextTaskStatus()));
+                                    .eq(FlowStepInstance::getWmsNowTaskStatus, flowStepInstance.getWmsNextTaskStatus()).last("limit 1"));
                             if (Cools.isEmpty(nextFlowStepInstance)) {
                                 throw new CoolException("浠诲姟鍙�"+task.getTaskCode()+"浠诲姟姝ラ涓㈠け锛侊紒锛�");
                             }
@@ -179,44 +179,18 @@
                     MissionTaskIssueParam missionTaskIssueParam = new MissionTaskIssueParam(flowStepInstance,subsystemFlowTemplate,flowStepTemplate);
 
                     missionTaskIssueParam.setType(RcsTaskType.getTypeDesc(task.getTaskType()));
-                    if (missionTaskIssueParam.getType().equals(RcsTaskType.RCS_TASK_TYPE_ENUM_IN.type)){
-                        boolean souSign = taskInstance.getSourceCode().matches("\\d+");
-                        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()));
-                                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());
-                            }
-                        } else {
-                            BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, taskInstance.getSourceCode()));
+                    boolean souSign = taskInstance.getSourceCode().matches("\\d+");
+                    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"));                            }
+                                        .last("LIMIT 1"));
+                            }
                             if (Cools.isEmpty(basStation)){
                                 flowStepInstance.setRetryTimes(flowStepInstance.getRetryTimes() + 1);
                                 if (flowStepInstance.getRetryTimes()>5){
@@ -231,44 +205,43 @@
                             } else {
                                 missionTaskIssueParam.setSourceCode(basStation.getStationName());
                             }
-                        }
-                        boolean endSign = taskInstance.getTargetCode().matches("\\d+");
-                        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()));
-                                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());
-                            }
                         } else {
-                            BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, taskInstance.getTargetCode()));
+                            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"));                            }
+                        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());
+                        }
+                    }
+                    boolean endSign = taskInstance.getTargetCode().matches("\\d+");
+                    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"));                                  }
+                                        .last("LIMIT 1"));                                }
                             if (Cools.isEmpty(basStation)){
                                 flowStepInstance.setRetryTimes(flowStepInstance.getRetryTimes() + 1);
                                 if (flowStepInstance.getRetryTimes()>5){
@@ -283,23 +256,57 @@
                             } else {
                                 missionTaskIssueParam.setTargetCode(basStation.getStationName());
                             }
-                        }
 
+                        } else {
+                            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"));                                  }
+                        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());
+                        }
+                    }
+                    missionTaskIssueParam.setTaskPri(task.getSort());
+                    missionTaskIssueParam.setBarcode(task.getBarcode());
+                    missionTaskIssueParam.setTaskNo(task.getTaskCode());
+                    if (missionTaskIssueParam.getType().equals(RcsTaskType.RCS_TASK_TYPE_ENUM_IN.type) && endSign){
                         missionTaskIssueParam.setLocNo(task.getTargLoc());
+                        missionTaskIssueParam.setSourcestaNo(missionTaskIssueParam.getSourcestaNo());
+                    } else if (missionTaskIssueParam.getType().equals(RcsTaskType.RCS_TASK_TYPE_ENUM_OUT.type) && souSign){
                         missionTaskIssueParam.setSourcelocNo(task.getOrgLoc());
-                        missionTaskIssueParam.setSourcestaNo(task.getOrgSite());
-                        missionTaskIssueParam.setStaNo(task.getTargSite());
-                        missionTaskIssueParam.setBarcode(task.getBarcode());
-                        missionTaskIssueParam.setTaskPri(task.getSort());
-                    } else if (missionTaskIssueParam.getType().equals(RcsTaskType.RCS_TASK_TYPE_ENUM_OUT.type)){
-                        missionTaskIssueParam.setSourceCode(taskInstance.getSourceCode());
-                        missionTaskIssueParam.setTargetCode(taskInstance.getTargetCode());
-                    } else if (missionTaskIssueParam.getType().equals(RcsTaskType.RCS_TASK_TYPE_ENUM_TRANSFER.type)){
-                        missionTaskIssueParam.setSourceCode(taskInstance.getSourceCode());
-                        missionTaskIssueParam.setTargetCode(taskInstance.getTargetCode());
-                    } else if (missionTaskIssueParam.getType().equals(RcsTaskType.RCS_TASK_TYPE_ENUM_STA.type)){
-                        missionTaskIssueParam.setSourceCode(taskInstance.getSourceCode());
-                        missionTaskIssueParam.setTargetCode(taskInstance.getTargetCode());
+                        missionTaskIssueParam.setStaNo(missionTaskIssueParam.getTargetCode());
+                    } else if (missionTaskIssueParam.getType().equals(RcsTaskType.RCS_TASK_TYPE_ENUM_TRANSFER.type) && souSign && endSign){
+                        missionTaskIssueParam.setSourcelocNo(task.getOrgLoc());
+                        missionTaskIssueParam.setLocNo(task.getTargLoc());
+                    } else if (missionTaskIssueParam.getType().equals(RcsTaskType.RCS_TASK_TYPE_ENUM_TRANSFER.type) && souSign && !endSign){
+                        missionTaskIssueParam.setType(RcsTaskType.RCS_TASK_TYPE_ENUM_TRANSFER.type);
+                        missionTaskIssueParam.setSourcelocNo(task.getOrgLoc());
+                        missionTaskIssueParam.setStaNo(missionTaskIssueParam.getTargetCode());
+                    }  else if (missionTaskIssueParam.getType().equals(RcsTaskType.RCS_TASK_TYPE_ENUM_TRANSFER.type) && !souSign && endSign){
+                        missionTaskIssueParam.setType(RcsTaskType.RCS_TASK_TYPE_ENUM_IN.type);
+                        missionTaskIssueParam.setSourcestaNo(missionTaskIssueParam.getSourcestaNo());
+                        missionTaskIssueParam.setLocNo(task.getTargLoc());
+                    } else if (missionTaskIssueParam.getType().equals(RcsTaskType.RCS_TASK_TYPE_ENUM_STA.type) || (!souSign && !endSign)){
+                        missionTaskIssueParam.setType(RcsTaskType.RCS_TASK_TYPE_ENUM_STA.type);
+                        missionTaskIssueParam.setSourcestaNo(missionTaskIssueParam.getSourcestaNo());
+                        missionTaskIssueParam.setStaNo(missionTaskIssueParam.getTargetCode());
                     }
 
                     /**浠诲姟涓嬪彂鎺ュ彛*/
@@ -338,7 +345,7 @@
                                             .eq(FlowStepInstance::getStatus, (short)0)
                                             .eq(FlowStepInstance::getTaskNo, flowStepInstance.getTaskNo())
                                             .eq(FlowStepInstance::getStepOrder, flowStepInstance.getStepOrder() + 1)
-                                            .eq(FlowStepInstance::getWmsNowTaskStatus, flowStepInstance.getWmsNextTaskStatus()));
+                                            .eq(FlowStepInstance::getWmsNowTaskStatus, flowStepInstance.getWmsNextTaskStatus()).last("limit 1"));
                                     if (Cools.isEmpty(nextFlowStepInstance)) {
                                         throw new CoolException("浠诲姟鍙�"+task.getTaskCode()+"浠诲姟姝ラ涓㈠け锛侊紒锛�");
                                     }
@@ -753,7 +760,7 @@
 
         BasStation station = null;
         if (!task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
-            station = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getTargSite()));
+            station = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getTargSite()).last("limit 1"));
             if (Objects.isNull(station)) {
                 throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
             }
@@ -764,7 +771,7 @@
         Loc locStart = null;
         if (task.getTaskType().equals(TaskType.TASK_TYPE_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_EMPTY_OUT.type)) {
-            locStart = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getOrgLoc()));
+            locStart = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getOrgLoc()).last("limit 1"));
             if (Objects.isNull(locStart)) {
                 throw new CoolException("婧愬簱浣嶄笉瀛樺湪锛侊紒");
             }
@@ -783,7 +790,7 @@
                     task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type) ||
                     task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)
             ) {
-                BasStation stationS = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getOrgSite()));
+                BasStation stationS = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getOrgSite()).last("limit 1"));
                 if (Objects.isNull(stationS)) {
                     throw new CoolException("婧愬簱浣嶄笉瀛樺湪锛侊紒");
                 }
@@ -791,7 +798,7 @@
                 if (stationS.getType().equals(StationTypeEnum.STATION_TYPE_MUTI.type)) {
                     taskParams.setSign(LocStsWcsOrOtherType.LOC_STS_TYPE_WCS.type);
                 } else {
-                    Loc locEnd = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getTargLoc()));
+                    Loc locEnd = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getTargLoc()).last("limit 1"));
                     if (Objects.isNull(locEnd)) {
                         throw new CoolException("婧愬簱浣嶄笉瀛樺湪锛侊紒");
                     }
@@ -851,7 +858,7 @@
             /**绔欑偣闂寸Щ搴撳弬鏁�*/
             itemParam.setOriSta(task.getOrgSite()).setDestSta(task.getTargSite());
 
-            BasStation curSta = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getOrgSite()));
+            BasStation curSta = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getOrgSite()).last("limit 1"));
             if (Objects.isNull(curSta)) {
                 throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
             }

--
Gitblit v1.9.1