From 70ff4954fec4483883e2485bc8c0ed59054b91a9 Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期二, 26 八月 2025 17:08:12 +0800
Subject: [PATCH] 1

---
 zy-acs-manager/src/main/java/com/zy/acs/manager/core/third/ReportThirdScheduler.java |   55 +++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 41 insertions(+), 14 deletions(-)

diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/third/ReportThirdScheduler.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/third/ReportThirdScheduler.java
index c394e79..1587c85 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/third/ReportThirdScheduler.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/third/ReportThirdScheduler.java
@@ -2,6 +2,9 @@
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zy.acs.framework.common.Cools;
+import com.zy.acs.manager.core.third.dto.TaskEvent;
 import com.zy.acs.manager.core.utils.HttpHandler;
 import com.zy.acs.manager.manager.entity.TaskReport;
 import com.zy.acs.manager.manager.entity.TaskReportLog;
@@ -16,6 +19,7 @@
 import org.springframework.transaction.annotation.Transactional;
 
 import java.io.IOException;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 
@@ -34,32 +38,55 @@
     private ConfigService configService;
 
 
-    @Scheduled(fixedDelay = 1000)
+    @Scheduled(fixedDelay = 3000)
     public void execute() {
         Boolean report = configService.getVal("REPORT", Boolean.class, false);
         if (report) {
             String wmsUrl = configService.getVal("WMS_URL", String.class);
             String wmsPath = configService.getVal("WMS_PATH", String.class);
-            Integer times = configService.getVal("REPORT_TIMES", Integer.class, 3);
-            List<TaskReport> list = taskReportService.list();
+            List<TaskReport> list = taskReportService.list(new LambdaQueryWrapper<TaskReport>().eq(TaskReport::getCompleted, 0).le(TaskReport::getReportTimes, 3));
             for (TaskReport taskReport : list) {
-                if (taskReport.getReportTimes() > times) {
-                    toLog(taskReport);
-                    continue;
-                }
-                if (report(taskReport, wmsUrl, wmsPath)) {
-                    toLog(taskReport);
-                } else {
-                    taskReport.setReportTimes(taskReport.getReportTimes() + 1);
+                log.info("寮�濮嬩笂鎶ワ細{}", taskReport);
+                if (report(new TaskEvent(taskReport.getSeqNum(), taskReport.getEventType()), wmsUrl, wmsPath)) {
+                    taskReport.setReportTimes((Cools.isEmpty(taskReport.getReportTimes()) ? 0 : taskReport.getReportTimes()) + 1);
                     taskReport.setUpdateTime(new Date());
-                    taskReportService.updateById(taskReport);
+                    taskReport.setCompleted(1);
+                } else {
+                    taskReport.setReportTimes((Cools.isEmpty(taskReport.getReportTimes()) ? 0 : taskReport.getReportTimes()) + 1);
+                    taskReport.setUpdateTime(new Date());
+                }
+                taskReportService.updateById(taskReport);
+            }
+        }
+    }
+
+    /**
+     * 鍒犻櫎瓒呰繃涓�澶╃殑涓婃姤鍘嗗彶璁板綍
+     */
+    @Scheduled(fixedDelay = 3000)
+    public void execute2() {
+        Boolean report = configService.getVal("REPORT", Boolean.class, false);
+        if (report) {
+            Calendar instance = Calendar.getInstance();
+            instance.add(Calendar.DATE, 1);
+            List<TaskReport> list = taskReportService.list(new LambdaQueryWrapper<TaskReport>().eq(TaskReport::getCompleted, 1).ge(TaskReport::getUpdateTime, instance.getTime()));
+            Integer times = configService.getVal("REPORT_TIMES", Integer.class, 3);
+            for (TaskReport taskReport : list) {
+                if ((Cools.isEmpty(taskReport.getReportTimes()) ? 0 : taskReport.getReportTimes()) > times) {
+                    toLog(taskReport);
+                }
+            }
+            list = taskReportService.list(new LambdaQueryWrapper<TaskReport>().eq(TaskReport::getReportTimes, 4).ge(TaskReport::getUpdateTime, instance.getTime()));
+            for (TaskReport taskReport : list) {
+                if ((Cools.isEmpty(taskReport.getReportTimes()) ? 0 : taskReport.getReportTimes()) > times) {
+                    toLog(taskReport);
                 }
             }
         }
     }
 
     @Transactional
-    public boolean report(TaskReport taskReport, String wmsUrl, String wmsPath) {
+    public boolean report(TaskEvent taskReport, String wmsUrl, String wmsPath) {
         String response = null;
         try {
             response = new HttpHandler.Builder()
@@ -68,13 +95,13 @@
                     .setJson(JSON.toJSONString(taskReport))
                     .build()
                     .doPost();
+            log.info("杩斿洖鍙傛暟锛歿}", response);
             JSONObject jsonObject = JSON.parseObject(response);
             if (jsonObject.getInteger("code").equals(200)) {
                 return true;
             }
         } catch (IOException e) {
             log.info("鎶ラ敊浜嗭紝{}", e);
-            taskReport.setMemo(e.getMessage());
             e.printStackTrace();
         }
 

--
Gitblit v1.9.1