From 03b5b8a480fb201e288486299eb385a00d2aac66 Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期一, 13 十月 2025 09:25:16 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/ycawdasrs-2' into ycawdasrs-2

---
 src/main/java/com/zy/third/task/OrderScheduler.java |   99 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 99 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/zy/third/task/OrderScheduler.java b/src/main/java/com/zy/third/task/OrderScheduler.java
new file mode 100644
index 0000000..77e3c3d
--- /dev/null
+++ b/src/main/java/com/zy/third/task/OrderScheduler.java
@@ -0,0 +1,99 @@
+package com.zy.third.task;
+
+import com.zy.third.entity.ExdInstockSource;
+import com.zy.third.entity.ExdOutstockSource;
+import com.zy.third.mapper.ExdInstockSourceMapper;
+import com.zy.third.mapper.ExdOutstockSourceMapper;
+import com.zy.third.task.handler.OrderHandler;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+import java.util.List;
+
+@Component
+@Slf4j
+public class OrderScheduler {
+
+
+    @Autowired
+    private OrderHandler orderHandler;
+
+    @Autowired
+    private ExdInstockSourceMapper exdInstockSourceMapper;
+
+
+    @Autowired
+    private ExdOutstockSourceMapper exdOutstockSourceMapper;
+
+
+    /**
+     * 璇诲彇鍏ュ簱鍗曟嵁
+     */
+    @Scheduled(cron = "0/10 * * * * ? ")
+    public void readInOrder() {
+        log.info("璇诲彇鍏ュ簱鍗曟嵁");
+        List<String> orderNos = exdInstockSourceMapper.listOrderNo();
+        for (String orderNo : orderNos) {
+            List<ExdInstockSource> exdInstockSources = exdInstockSourceMapper.listAll(orderNo);
+            try {
+                boolean success = orderHandler.readInOrder(exdInstockSources).isSuccess();
+                for (ExdInstockSource exdInstockSource : exdInstockSources) {
+                    if (success) {
+                        exdInstockSource.setReadtime(new Date());
+                        exdInstockSource.setStatus(1);
+                        exdInstockSourceMapper.updateById(exdInstockSource);
+                    } else {
+                        exdInstockSource.setReadtime(new Date());
+                        exdInstockSource.setStatus(2);
+                        exdInstockSourceMapper.updateById(exdInstockSource);
+                    }
+                }
+            } catch (Exception e) {
+                log.error("璇诲彇鍏ュ簱鍗曟嵁淇℃伅澶辫触锛歿},{}", exdInstockSources, e.getMessage());
+                for (ExdInstockSource exdInstockSource : exdInstockSources) {
+                    exdInstockSource.setReadormsg(e.getMessage());
+                    exdInstockSource.setStatus(2);
+                    exdInstockSourceMapper.updateById(exdInstockSource);
+                }
+            }
+        }
+    }
+
+    /**
+     * 璇诲彇鍑哄簱鍗曟嵁
+     */
+    @Scheduled(cron = "0/10 * * * * ? ")
+    public void readOutOrder() {
+        log.info("璇诲彇鍑哄簱鍗曟嵁");
+        List<String> orderNos = exdOutstockSourceMapper.listOrderNo();
+        for (String orderNo : orderNos) {
+            List<ExdOutstockSource> exdOutstockSources = exdOutstockSourceMapper.listAll(orderNo);
+            try {
+                boolean success = orderHandler.readOutOrder(exdOutstockSources).isSuccess();
+                for (ExdOutstockSource exdOutstockSource : exdOutstockSources) {
+                    if (success) {
+                        exdOutstockSource.setReadtime(new Date());
+                        exdOutstockSource.setStatus(1);
+                        exdOutstockSourceMapper.updateById(exdOutstockSource);
+                    } else {
+                        exdOutstockSource.setReadtime(new Date());
+                        exdOutstockSource.setStatus(2);
+                        exdOutstockSourceMapper.updateById(exdOutstockSource);
+                    }
+
+                }
+            } catch (Exception e) {
+                log.error("璇诲彇鍑哄簱鍗曟嵁淇℃伅澶辫触锛歿},{}", exdOutstockSources, e.getMessage());
+                for (ExdOutstockSource exdOutstockSource : exdOutstockSources) {
+                    exdOutstockSource.setStatus(2);
+                    exdOutstockSource.setReadormsg(e.getMessage());
+                    exdOutstockSourceMapper.updateById(exdOutstockSource);
+                }
+            }
+        }
+    }
+
+}

--
Gitblit v1.9.1