From 53ae8e478f6034579303c51bdf881ffa526c942c Mon Sep 17 00:00:00 2001
From: taisheng <taisheng@qq.com>
Date: 星期六, 24 五月 2025 14:22:43 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/task/TaskLogScheduler.java |  183 ++++++++++++++++++++++++++++++++++++---------
 1 files changed, 146 insertions(+), 37 deletions(-)

diff --git a/src/main/java/com/zy/asrs/task/TaskLogScheduler.java b/src/main/java/com/zy/asrs/task/TaskLogScheduler.java
index d467c61..c54e0fb 100644
--- a/src/main/java/com/zy/asrs/task/TaskLogScheduler.java
+++ b/src/main/java/com/zy/asrs/task/TaskLogScheduler.java
@@ -1,19 +1,17 @@
 package com.zy.asrs.task;
 
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.core.exception.CoolException;
 import com.zy.asrs.domain.enums.TaskStatusType;
-import com.zy.asrs.entity.CommandInfo;
-import com.zy.asrs.entity.TaskWrk;
-import com.zy.asrs.entity.param.TaskStatusFeedbackParam;
-import com.zy.asrs.service.CommandInfoService;
-import com.zy.asrs.service.TaskWrkService;
-import com.zy.asrs.utils.PostMesDataUtils;
+import com.zy.asrs.entity.*;
+import com.zy.asrs.service.*;
+import com.zy.asrs.service.impl.TaskWrkLogServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -26,46 +24,157 @@
     @Autowired
     private TaskWrkService taskWrkService;
     @Autowired
-    private CommandInfoService commandInfoService;
-
-    @Value("${wms.url}")
-    private String wmsUrl;
-    @Value("${wms.movePath}")
-    private String movePath;
+    private LocMastService locMastService;
+    @Autowired
+    private TaskWrkLogServiceImpl taskWrkLogService;
 
     @Scheduled(cron = "0/3 * * * * ? ")
-    public void execute() {
-        for (TaskWrk taskWrk : taskWrkService.selectToBeHistoryData()) {
-            TaskStatusFeedbackParam taskStatusFeedbackParam = new TaskStatusFeedbackParam(taskWrk);
-            if (taskWrk.getStatus().equals(TaskStatusType.COMPLETE.id)) {//瀹屾垚
-                taskStatusFeedbackParam.setTaskStatus("done");
-                new PostMesDataUtils().postMesData("瀹屾垚涓婃姤",wmsUrl,movePath,taskWrk);
-            } else if (taskWrk.getStatus().equals(TaskStatusType.CANCEL.id)) {
-                taskStatusFeedbackParam.setTaskStatus("cancelled");
-                new PostMesDataUtils().postMesData("鍙栨秷浠诲姟瀹屾垚",wmsUrl,movePath,taskWrk);
+    public void executeIn() {
+        List<TaskWrk> taskWrkList = taskWrkService.selectList(new EntityWrapper<TaskWrk>().eq("wrk_sts", 8));
+        for (TaskWrk taskWrk : taskWrkList) {
+            Date now = new Date();
+            if (taskWrk.getIoType() == 1) {
+                if (taskWrk.getOriginStartPoint().equals("1")) {
+                    //鏇存柊婧愬簱浣嶇姸鎬佷负绌哄簱浣�
+                    LocMast locMast = locMastService.selectByLocNo("0900601");
+                    locMast.setLocSts("O");
+                    locMastService.updateById(locMast);
+                }
+
+                //鏇存柊鐩爣搴撶姸鎬佷负鍦ㄥ簱
+                LocMast locMast2 = locMastService.selectByLocNo(taskWrk.getTargetPoint());
+                locMast2.setLocSts("F");
+                locMastService.updateById(locMast2);
+
+                taskWrk.setModiTime(now);//鎿嶄綔鏃堕棿
+                taskWrk.setModiUser(9998L);//鎿嶄綔鍛�
+                taskWrkService.updateById(taskWrk);
+            } else if (taskWrk.getIoType() == 3) {
+                //鏇存柊婧愬簱浣嶇姸鎬佷负绌哄簱浣�
+                LocMast locMast = locMastService.selectByLocNo(taskWrk.getStartPoint());
+                locMast.setLocSts("O");
+                locMastService.updateById(locMast);
+
+                //鏇存柊鐩爣搴撶姸鎬佷负鍦ㄥ簱
+                LocMast locMast2 = locMastService.selectByLocNo(taskWrk.getTargetPoint());
+                locMast2.setLocSts("F");
+                locMastService.updateById(locMast2);
+
+                taskWrk.setModiTime(now);//鎿嶄綔鏃堕棿
+                taskWrk.setModiUser(9998L);//鎿嶄綔鍛�
+                taskWrkService.updateById(taskWrk);
+            }else {
+                throw new CoolException("浠诲姟绫诲瀷寮傚父");
             }
 
-            if (taskWrkService.saveToHistory(taskWrk.getTaskNo()) > 0) {
-                //浠诲姟宸茬粡杞棩蹇楋紝灏嗚浠诲姟涓嬮潰鐨勬寚浠よ浆鏃ュ織
-                commandInfoService.saveToHistory(taskWrk.getTaskNo());
-
-                //鍒犻櫎浠诲姟
-                taskWrkService.delete(new EntityWrapper<TaskWrk>().eq("task_no", taskWrk.getTaskNo()));
-                //鍒犻櫎鎸囦护
-                commandInfoService.delete(new EntityWrapper<CommandInfo>().eq("task_no", taskWrk.getTaskNo()));
+            TaskWrkLog taskWrkLog = new TaskWrkLog(taskWrk);
+            if (!taskWrkLogService.insert(taskWrkLog)) {
+                throw new CoolException("杞巻鍙叉。澶辫触" + taskWrkLog);
+            }
+            if (!taskWrkService.deleteById(taskWrk)) {
+                throw new CoolException("浠诲姟妗e垹闄ゅけ璐�" + taskWrkLog);
             }
         }
     }
 
-    //娓呯悊鎵嬪姩鍛戒护
     @Scheduled(cron = "0/3 * * * * ? ")
-    public void ManualCommandClean() {
-        List<CommandInfo> commandInfos = commandInfoService.selectCompleteManualCommand();
-        for (CommandInfo commandInfo : commandInfos) {
-            //鎸囦护杞棩蹇�
-            commandInfoService.saveToHistory(commandInfo.getId());
-        }
+    public void executeOut() {
+        List<TaskWrk> taskWrkList = taskWrkService.selectList(new EntityWrapper<TaskWrk>().eq("wrk_sts", 18));
+        for (TaskWrk taskWrk : taskWrkList) {
+            Date now = new Date();
+            if (taskWrk.getIoType() == 2) {
+                if (taskWrk.getTargetPoint().equals("101")) {
+                    //鏇存柊搴撲綅鐘舵�佷负鍦ㄥ簱
+                    LocMast locMast = locMastService.selectByLocNo("1100601");
+                    locMast.setLocSts("F");
+                    locMastService.updateById(locMast);
+                }
 
+                //鏇存柊婧愬簱鐘舵�佷负绌哄簱浣�
+                LocMast locMast2 = locMastService.selectByLocNo(taskWrk.getStartPoint());
+                locMast2.setLocSts("O");
+                locMastService.updateById(locMast2);
+
+                taskWrk.setModiTime(now);//鎿嶄綔鏃堕棿
+                taskWrk.setModiUser(9998L);//鎿嶄綔鍛�
+                taskWrkService.updateById(taskWrk);
+            }else {
+                throw new CoolException("浠诲姟绫诲瀷寮傚父");
+            }
+
+            TaskWrkLog taskWrkLog = new TaskWrkLog(taskWrk);
+            if (!taskWrkLogService.insert(taskWrkLog)) {
+                throw new CoolException("杞巻鍙叉。澶辫触" + taskWrkLog);
+            }
+            if (!taskWrkService.deleteById(taskWrk)) {
+                throw new CoolException("浠诲姟妗e垹闄ゅけ璐�" + taskWrkLog);
+            }
+        }
+    }
+
+    @Scheduled(cron = "0/3 * * * * ? ")
+    public void executeCancel() {
+        List<TaskWrk> taskWrkList = taskWrkService.selectList(new EntityWrapper<TaskWrk>().eq("status", TaskStatusType.CANCEL.id));
+        for (TaskWrk taskWrk : taskWrkList) {
+            Date now = new Date();
+            if(taskWrk.getIoType() == 1) {
+                if (taskWrk.getOriginStartPoint().equals("1")) {
+                    //鏇存柊婧愬簱浣嶇姸鎬佷负鍦ㄥ簱
+                    LocMast locMast = locMastService.selectByLocNo("0900601");
+                    locMast.setLocSts("F");
+                    locMastService.updateById(locMast);
+                }
+
+                //鏇存柊鐩爣搴撶姸鎬佷负绌哄簱
+                LocMast locMast2 = locMastService.selectByLocNo(taskWrk.getTargetPoint());
+                locMast2.setLocSts("O");
+                locMastService.updateById(locMast2);
+
+                taskWrk.setModiTime(now);//鎿嶄綔鏃堕棿
+                taskWrk.setModiUser(9998L);//鎿嶄綔鍛�
+                taskWrkService.updateById(taskWrk);
+            } else if (taskWrk.getIoType() == 2) {
+                if (taskWrk.getTargetPoint().equals("101")) {
+                    //鏇存柊搴撲綅鐘舵�佷负绌哄簱
+                    LocMast locMast = locMastService.selectByLocNo("1100601");
+                    locMast.setLocSts("O");
+                    locMastService.updateById(locMast);
+                }
+
+                //鏇存柊婧愬簱鐘舵�佷负鍦ㄥ簱
+                LocMast locMast2 = locMastService.selectByLocNo(taskWrk.getStartPoint());
+                locMast2.setLocSts("F");
+                locMastService.updateById(locMast2);
+
+                taskWrk.setModiTime(now);//鎿嶄綔鏃堕棿
+                taskWrk.setModiUser(9998L);//鎿嶄綔鍛�
+                taskWrkService.updateById(taskWrk);
+            } else if (taskWrk.getIoType() == 3) {
+                //鏇存柊婧愬簱浣嶇姸鎬佷负鍦ㄥ簱
+                LocMast locMast = locMastService.selectByLocNo(taskWrk.getStartPoint());
+                locMast.setLocSts("F");
+                locMastService.updateById(locMast);
+
+                //鏇存柊鐩爣搴撶姸鎬佷负绌哄簱浣�
+                LocMast locMast2 = locMastService.selectByLocNo(taskWrk.getTargetPoint());
+                locMast2.setLocSts("O");
+                locMastService.updateById(locMast2);
+
+                taskWrk.setModiTime(now);//鎿嶄綔鏃堕棿
+                taskWrk.setModiUser(9998L);//鎿嶄綔鍛�
+                taskWrkService.updateById(taskWrk);
+            } else {
+                throw new CoolException("浠诲姟绫诲瀷寮傚父");
+            }
+
+            TaskWrkLog taskWrkLog = new TaskWrkLog(taskWrk);
+            if (!taskWrkLogService.insert(taskWrkLog)) {
+                throw new CoolException("杞巻鍙叉。澶辫触" + taskWrkLog);
+            }
+            if (!taskWrkService.deleteById(taskWrk)) {
+                throw new CoolException("浠诲姟妗e垹闄ゅけ璐�" + taskWrkLog);
+            }
+        }
     }
 
 }

--
Gitblit v1.9.1