From a729e71aa06080bbd6a80cb801e502f85d16496e Mon Sep 17 00:00:00 2001
From: 1 <1@123>
Date: 星期四, 22 一月 2026 09:43:20 +0800
Subject: [PATCH] lsh#

---
 rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskCacheLocSchedules.java |  125 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 125 insertions(+), 0 deletions(-)

diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskCacheLocSchedules.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskCacheLocSchedules.java
new file mode 100644
index 0000000..4892e43
--- /dev/null
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskCacheLocSchedules.java
@@ -0,0 +1,125 @@
+package com.vincent.rsf.server.manager.schedules;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.vincent.rsf.framework.common.Cools;
+import com.vincent.rsf.framework.exception.CoolException;
+import com.vincent.rsf.server.manager.controller.params.LocToTaskParams;
+import com.vincent.rsf.server.manager.entity.Loc;
+import com.vincent.rsf.server.manager.entity.WarehouseAreas;
+import com.vincent.rsf.server.manager.enums.LocStsType;
+import com.vincent.rsf.server.manager.service.*;
+import com.vincent.rsf.server.manager.service.impl.WarehouseAreasServiceImpl;
+import com.vincent.rsf.server.system.constant.GlobalConfigCode;
+import com.vincent.rsf.server.system.entity.Config;
+import com.vincent.rsf.server.system.service.ConfigService;
+import lombok.extern.slf4j.Slf4j;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+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.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * @author Munch D. Luffy
+ * @date 2026/01/15
+ * 缂撳瓨鍖哄煙浠诲姟鑷姩瑙﹀彂
+ */
+@Slf4j
+@Component
+public class TaskCacheLocSchedules {
+
+    public static Logger logger = LoggerFactory.getLogger(TaskCacheLocSchedules.class);
+
+    @Autowired
+    private TaskService taskService;
+    @Autowired
+    private ConfigService configService;
+    @Autowired
+    private WarehouseAreasServiceImpl warehouseAreasService;
+    @Autowired
+    private LocService locService;
+    @Autowired
+    private LocItemService locItemService;
+
+    /**
+     * @author Munch D. Luffy
+     * @date 2026/01/15
+     * @description: 缂撳瓨鍖哄煙鑷姩鐢熸垚绉诲簱浠诲姟
+     * @version 1.0
+     */
+    @Scheduled(cron = "0/15 * * * * ?")
+    @Transactional(rollbackFor = Exception.class)
+    public void startCacheInLocStock() throws Exception {
+        Config config = configService.getOne(new LambdaQueryWrapper<Config>().eq(Config::getFlag, GlobalConfigCode.AUTO_RUN_CHECK_ORDERS_YZ));
+        if (!Boolean.parseBoolean(config.getVal())) {
+            return;
+        }
+
+        String autoRunAreaStartYz = configService.getVal("AUTO_RUN_AREA_START_YZ", String.class);
+        if (Cools.isEmpty(autoRunAreaStartYz)) {
+            return;
+        }
+
+        String autoRunAreaEndYz = configService.getVal("AUTO_RUN_AREA_END_YZ", String.class);
+        if (Cools.isEmpty(autoRunAreaEndYz)) {
+            return;
+        }
+        String curLoc = null;
+        String deepLoc = null;
+        try{
+            String[] split = autoRunAreaStartYz.split(";");
+            for (String c : split) {
+                WarehouseAreas byId = warehouseAreasService.getById(Integer.parseInt(c));
+                if (!Cools.isEmpty(byId)) {
+                    Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getWarehouseId, byId.getWarehouseId()).eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type),false);
+                    if (!Objects.isNull(loc)) {
+                        curLoc = loc.getCode();
+                        break;
+                    }
+                }
+            }
+        } catch (Exception e){
+            log.error("閰嶇疆鍙傛暟AUTO_RUN_AREA_START_YZ瑙f瀽澶辫触锛岃妫�鏌ワ紒锛侊紒");
+        }
+        try{
+            String[] split = autoRunAreaEndYz.split(";");
+            for (String c : split) {
+                WarehouseAreas byId = warehouseAreasService.getById(Integer.parseInt(c));
+                if (!Cools.isEmpty(byId)) {
+                    Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getWarehouseId, byId.getWarehouseId()).eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type),false);
+                    if (!Objects.isNull(loc)) {
+                        deepLoc = loc.getCode();
+                        break;
+                    }
+                }
+            }
+        } catch (Exception e){
+            log.error("閰嶇疆鍙傛暟AUTO_RUN_AREA_START_YZ瑙f瀽澶辫触锛岃妫�鏌ワ紒锛侊紒");
+        }
+
+        if (curLoc == null ||  deepLoc == null) {
+            return;
+        }
+        LocToTaskParams params = new LocToTaskParams();
+        params.setOrgLoc(curLoc).setTarLoc(deepLoc);
+        //鐢熸垚绉诲簱浣嶄换鍔�
+        locItemService.genMoveTask(params, 9999L);
+    }
+
+    /**
+     * @author Munch D. Luffy
+     * @date 2026/01/15
+     * @description: 缂撳瓨鍖哄煙鑷姩鐢熸垚绌鸿揣鏋跺嚭搴撲换鍔�
+     * @version 1.0
+     */
+    @Scheduled(cron = "0/5 * * * * ?  ")
+    @Transactional(rollbackFor = Exception.class)
+    public void complateOutStock() throws Exception {
+        System.out.println("缂撳瓨鍖哄煙鑷姩鐢熸垚绌鸿揣鏋跺嚭搴撲换鍔�");
+    }
+}

--
Gitblit v1.9.1