From 72c06d5800d3a99dbd7002a6946be749d9264b15 Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期四, 26 六月 2025 10:44:26 +0800
Subject: [PATCH] 1

---
 src/main/java/com/zy/asrs/task/TaskLogScheduler.java |   55 ++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 40 insertions(+), 15 deletions(-)

diff --git a/src/main/java/com/zy/asrs/task/TaskLogScheduler.java b/src/main/java/com/zy/asrs/task/TaskLogScheduler.java
index 27bac8f..71ad90a 100644
--- a/src/main/java/com/zy/asrs/task/TaskLogScheduler.java
+++ b/src/main/java/com/zy/asrs/task/TaskLogScheduler.java
@@ -1,15 +1,20 @@
 package com.zy.asrs.task;
 
-import com.baomidou.mybatisplus.mapper.EntityWrapper;
-import com.zy.asrs.entity.CommandInfo;
+import com.core.exception.CoolException;
 import com.zy.asrs.entity.TaskWrk;
-import com.zy.asrs.entity.WaitPakin;
-import com.zy.asrs.service.CommandInfoService;
+import com.zy.asrs.entity.TaskWrkLog;
+import com.zy.asrs.entity.TaskWrkReport;
+import com.zy.asrs.service.TaskWrkReportService;
 import com.zy.asrs.service.TaskWrkService;
+import com.zy.asrs.service.impl.TaskWrkLogServiceImpl;
+import com.zy.common.utils.Synchro;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.io.IOException;
 
 /**
  * 瀹氭椂灏嗕换鍔�(瀹屾垚銆佸彇娑�)杞垚鏃ュ織
@@ -20,22 +25,42 @@
 
     @Autowired
     private TaskWrkService taskWrkService;
+
     @Autowired
-    private CommandInfoService commandInfoService;
+    private TaskWrkLogServiceImpl wrkLogService;
 
-    @Scheduled(cron = "0/3 * * * * ? ")
-    public void execute() {
+
+    @Autowired
+    private TaskWrkReportService taskWrkReportService;
+
+
+    @Scheduled(cron = "0/5 * * * * ? ")
+    public synchronized void execute() throws IOException {
         for (TaskWrk taskWrk : taskWrkService.selectToBeHistoryData()) {
-            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()));
+            switch (taskWrk.getStatus()) {
+                case 4:
+                    break;
+                case 5:
+                    break;
             }
+            exe(taskWrk);
         }
     }
 
+    @Transactional
+    public void exe(TaskWrk taskWrk) {
+        TaskWrkReport taskWrkReport = new TaskWrkReport();
+        TaskWrkLog taskWrkLog = new TaskWrkLog();
+        Synchro.Copy(taskWrk, taskWrkReport);
+        Synchro.Copy(taskWrk, taskWrkLog);
+        if (!wrkLogService.insert(taskWrkLog)) {
+            throw new CoolException("杞巻鍙叉。澶辫触" + taskWrk);
+        }
+        if (!taskWrkService.deleteById(taskWrk)) {
+            throw new CoolException("浠诲姟妗e垹闄ゅけ璐�" + taskWrk);
+        }
+        if (!taskWrkReportService.insert(taskWrkReport)) {
+            throw new CoolException("杞Щ鑷充笂鎶ヨ〃" + taskWrk);
+        }
+    }
 }

--
Gitblit v1.9.1