From 517966d4dbed6ef6e5d591720b971af427e6b63a Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期四, 04 十二月 2025 15:25:47 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/task/WrkMastScheduler.java |   65 +++++++++++++++++++++++---------
 1 files changed, 46 insertions(+), 19 deletions(-)

diff --git a/src/main/java/com/zy/asrs/task/WrkMastScheduler.java b/src/main/java/com/zy/asrs/task/WrkMastScheduler.java
index 4f1b40b..649b2f4 100644
--- a/src/main/java/com/zy/asrs/task/WrkMastScheduler.java
+++ b/src/main/java/com/zy/asrs/task/WrkMastScheduler.java
@@ -1,11 +1,16 @@
 package com.zy.asrs.task;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.zy.asrs.domain.enums.NotifyMsgType;
 import com.zy.asrs.entity.LocMast;
 import com.zy.asrs.entity.WrkMast;
 import com.zy.asrs.service.LocMastService;
 import com.zy.asrs.service.WrkMastLogService;
 import com.zy.asrs.service.WrkMastService;
+import com.zy.asrs.utils.NotifyUtils;
+import com.zy.core.enums.LocStsType;
+import com.zy.core.enums.WrkIoType;
 import com.zy.core.enums.WrkStsType;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -27,6 +32,8 @@
     private WrkMastLogService wrkMastLogService;
     @Autowired
     private LocMastService locMastService;
+    @Autowired
+    private NotifyUtils notifyUtils;
 
     @Scheduled(cron = "0/1 * * * * ? ")
     @Transactional
@@ -50,6 +57,7 @@
             }
 
             locMast.setLocSts("F");
+            locMast.setBarcode(wrkMast.getBarcode());
             locMast.setModiTime(new Date());
             boolean result = locMastService.updateById(locMast);
             if (!result) {
@@ -65,6 +73,9 @@
             if (!wrkMastService.deleteById(wrkMast)) {
                 log.info("鍒犻櫎宸ヤ綔涓绘。[workNo={}]澶辫触", wrkMast.getWrkNo());
             }
+
+            //涓婃姤
+            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast));
         }
     }
 
@@ -90,6 +101,7 @@
             }
 
             locMast.setLocSts("O");
+            locMast.setBarcode("");
             locMast.setModiTime(new Date());
             boolean result = locMastService.updateById(locMast);
             if (!result) {
@@ -105,6 +117,9 @@
             if (!wrkMastService.deleteById(wrkMast)) {
                 log.info("鍒犻櫎宸ヤ綔涓绘。[workNo={}]澶辫触", wrkMast.getWrkNo());
             }
+
+            //涓婃姤
+            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast));
         }
     }
 
@@ -165,13 +180,16 @@
             if (!wrkMastService.deleteById(wrkMast)) {
                 log.info("鍒犻櫎宸ヤ綔涓绘。[workNo={}]澶辫触", wrkMast.getWrkNo());
             }
+
+            //涓婃姤
+            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast));
         }
     }
 
     @Scheduled(cron = "0/1 * * * * ? ")
     @Transactional
-    public void executeMove(){
-        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.COMPLETE_MOVE.sts));
+    public void executeCancelTask(){
+        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("mk", "taskCancel"));
         if (wrkMasts.isEmpty()) {
             return;
         }
@@ -185,26 +203,35 @@
             if (!wrkMastService.deleteById(wrkMast)) {
                 log.info("鍒犻櫎宸ヤ綔涓绘。[workNo={}]澶辫触", wrkMast.getWrkNo());
             }
-        }
-    }
 
-    @Scheduled(cron = "0/1 * * * * ? ")
-    @Transactional
-    public void executeCharge(){
-        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.COMPLETE_CHARGE.sts));
-        if (wrkMasts.isEmpty()) {
-            return;
-        }
+            if (wrkMast.getIoType() == WrkIoType.IN.id) {
+                LocMast locMast = locMastService.queryByLoc(wrkMast.getLocNo());
+                locMast.setLocSts(String.valueOf(LocStsType.O));
+                locMast.setModiTime(new Date());
+                locMastService.updateById(locMast);
+            } else if (wrkMast.getIoType() == WrkIoType.OUT.id) {
+                LocMast locMast = locMastService.queryByLoc(wrkMast.getSourceLocNo());
+                locMast.setLocSts(String.valueOf(LocStsType.F));
+                locMast.setModiTime(new Date());
+                locMastService.updateById(locMast);
+            } else if (wrkMast.getIoType() == WrkIoType.LOC_MOVE.id) {
+                LocMast sourceLocMast = locMastService.queryByLoc(wrkMast.getSourceLocNo());
+                LocMast locMast = locMastService.queryByLoc(wrkMast.getLocNo());
+                if (sourceLocMast.getLocSts().equals(String.valueOf(LocStsType.R))) {
+                    sourceLocMast.setLocSts(String.valueOf(LocStsType.F));
+                    sourceLocMast.setModiTime(new Date());
+                    locMastService.updateById(sourceLocMast);
+                }
 
-        for (WrkMast wrkMast : wrkMasts) {
-            // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗�
-            if (!wrkMastLogService.save(wrkMast.getWrkNo())) {
-                log.info("淇濆瓨宸ヤ綔鍘嗗彶妗workNo={}]澶辫触", wrkMast.getWrkNo());
+                if (locMast.getLocSts().equals(String.valueOf(LocStsType.S))) {
+                    locMast.setLocSts(String.valueOf(LocStsType.O));
+                    locMast.setModiTime(new Date());
+                    locMastService.updateById(locMast);
+                }
             }
-            // 鍒犻櫎宸ヤ綔涓绘。
-            if (!wrkMastService.deleteById(wrkMast)) {
-                log.info("鍒犻櫎宸ヤ綔涓绘。[workNo={}]澶辫触", wrkMast.getWrkNo());
-            }
+
+            //涓婃姤
+            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.TASK_CANCEL, JSON.toJSONString(wrkMast));
         }
     }
 

--
Gitblit v1.9.1