From f305e5244e059c5e43566412f69b180e2e790026 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期四, 05 三月 2026 19:11:43 +0800
Subject: [PATCH] #双工位堆垛机任务下发控制优化

---
 src/main/java/com/zy/asrs/domain/param/DualCrnUpdateTaskNoParam.java |   10 +
 src/main/java/com/zy/asrs/controller/DualCrnController.java          |   38 ++++++
 src/main/java/com/zy/core/network/fake/ZyDualCrnFakeConnect.java     |   88 +++++++++----
 src/main/java/com/zy/asrs/domain/vo/DualCrnStateTableVo.java         |    4 
 src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java      |   30 ++++
 src/main/java/com/zy/core/model/protocol/DualCrnProtocol.java        |   50 +++++++-
 src/main/webapp/components/WatchDualCrnCard.js                       |   68 +++++++++++
 src/main/java/com/zy/core/enums/RedisKeyType.java                    |    9 -
 src/main/java/com/zy/core/thread/impl/ZySiemensDualCrnThread.java    |   61 ++++++++-
 9 files changed, 303 insertions(+), 55 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/DualCrnController.java b/src/main/java/com/zy/asrs/controller/DualCrnController.java
index 6fffffa..48cb7b8 100644
--- a/src/main/java/com/zy/asrs/controller/DualCrnController.java
+++ b/src/main/java/com/zy/asrs/controller/DualCrnController.java
@@ -5,11 +5,14 @@
 import com.core.common.Cools;
 import com.core.common.R;
 import com.zy.asrs.domain.param.DualCrnCommandParam;
+import com.zy.asrs.domain.param.DualCrnUpdateTaskNoParam;
 import com.zy.asrs.domain.vo.DualCrnStateTableVo;
 import com.zy.asrs.entity.BasDualCrnp;
 import com.zy.asrs.service.BasDualCrnpService;
+import com.zy.common.utils.RedisUtil;
 import com.zy.core.cache.MessageQueue;
 import com.zy.core.cache.SlaveConnection;
+import com.zy.core.enums.RedisKeyType;
 import com.zy.core.enums.SlaveType;
 import com.zy.core.model.Task;
 import com.zy.core.model.command.DualCrnCommand;
@@ -31,6 +34,8 @@
 
     @Autowired
     private BasDualCrnpService basDualCrnpService;
+    @Autowired
+    private RedisUtil redisUtil;
 
     @PostMapping("/dualcrn/table/crn/state")
     @ManagerAuth(memo = "鍙屽伐浣嶅爢鍨涙満淇℃伅琛�")
@@ -51,6 +56,8 @@
             }
             vo.setTaskNo(p.getTaskNo());
             vo.setTaskNoTwo(p.getTaskNoTwo());
+            vo.setDeviceTaskNo(p.getDeviceTaskNo());
+            vo.setDeviceTaskNoTwo(p.getDeviceTaskNoTwo());
             vo.setMode(p.getModeType() == null ? "-" : p.getModeType().desc);
             vo.setStatus(p.getStatusType() == null ? "-" : p.getStatusType().desc);
             vo.setStatusTwo(p.getStatusTypeTwo() == null ? "-" : p.getStatusTypeTwo().desc);
@@ -181,4 +188,35 @@
         MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(3, command));
         return R.ok();
     }
+
+    @PostMapping("/dualcrn/command/updateTaskNo")
+    @ManagerAuth(memo = "鍙屽伐浣嶅爢鍨涙満缂栬緫浠诲姟鍙�")
+    public R dualCrnUpdateTaskNo(@RequestBody DualCrnUpdateTaskNoParam param) {
+        if (Cools.isEmpty(param) || param.getCrnNo() == null || param.getStation() == null || param.getTaskNo() == null) {
+            return R.error("缂哄皯鍙傛暟");
+        }
+        Integer station = param.getStation();
+        if (station != 1 && station != 2) {
+            return R.error("宸ヤ綅鍙傛暟閿欒");
+        }
+        Integer taskNo = param.getTaskNo();
+        if (taskNo < 0) {
+            return R.error("浠诲姟鍙蜂笉鑳藉皬浜�0");
+        }
+        Integer crnNo = param.getCrnNo();
+        DualCrnThread crnThread = (DualCrnThread) SlaveConnection.get(SlaveType.DualCrn, crnNo);
+        if (crnThread == null) {
+            return R.error("绾跨▼涓嶅瓨鍦�");
+        }
+        DualCrnProtocol protocol = crnThread.getStatus();
+        if (protocol == null) {
+            return R.error("璁惧鐘舵�佷笉瀛樺湪");
+        }
+        if (station == 1) {
+            redisUtil.set(RedisKeyType.DUAL_CRN_STATION1_FLAG.key + crnNo, taskNo, 60 * 60 * 24);
+        } else {
+            redisUtil.set(RedisKeyType.DUAL_CRN_STATION2_FLAG.key + crnNo, taskNo, 60 * 60 * 24);
+        }
+        return R.ok();
+    }
 }
diff --git a/src/main/java/com/zy/asrs/domain/param/DualCrnUpdateTaskNoParam.java b/src/main/java/com/zy/asrs/domain/param/DualCrnUpdateTaskNoParam.java
new file mode 100644
index 0000000..8c0d879
--- /dev/null
+++ b/src/main/java/com/zy/asrs/domain/param/DualCrnUpdateTaskNoParam.java
@@ -0,0 +1,10 @@
+package com.zy.asrs.domain.param;
+
+import lombok.Data;
+
+@Data
+public class DualCrnUpdateTaskNoParam {
+    private Integer crnNo;
+    private Integer station;
+    private Integer taskNo;
+}
diff --git a/src/main/java/com/zy/asrs/domain/vo/DualCrnStateTableVo.java b/src/main/java/com/zy/asrs/domain/vo/DualCrnStateTableVo.java
index 9a16fa3..189150c 100644
--- a/src/main/java/com/zy/asrs/domain/vo/DualCrnStateTableVo.java
+++ b/src/main/java/com/zy/asrs/domain/vo/DualCrnStateTableVo.java
@@ -15,6 +15,10 @@
 
     private Integer taskNoTwo = 0;
 
+    private Integer deviceTaskNo = 0;
+
+    private Integer deviceTaskNoTwo = 0;
+
     private String status = "-";
 
     private String statusTwo = "-";
diff --git a/src/main/java/com/zy/core/enums/RedisKeyType.java b/src/main/java/com/zy/core/enums/RedisKeyType.java
index 516fbc9..916a7bb 100644
--- a/src/main/java/com/zy/core/enums/RedisKeyType.java
+++ b/src/main/java/com/zy/core/enums/RedisKeyType.java
@@ -2,13 +2,8 @@
 
 public enum RedisKeyType {
 
-    SHUTTLE_WORK_FLAG("shuttle_wrk_no_"),
-    SHUTTLE_FLAG("shuttle_"),
-    FORK_LIFT_WORK_FLAG("fork_lift_wrk_no_"),
-    FORK_LIFT_FLAG("fork_lift_"),
-    LIFT_WORK_FLAG("lift_wrk_no_"),
-    LIFT_FLAG("lift_"),
-
+    DUAL_CRN_STATION1_FLAG("dual_crn_station1_flag_"),
+    DUAL_CRN_STATION2_FLAG("dual_crn_station2_flag_"),
     DUAL_CRN_COMMAND_("dual_crn_command_"),
     DUAL_CRN_COMMAND_IDX("dual_crn_command_idx_"),
 
diff --git a/src/main/java/com/zy/core/model/protocol/DualCrnProtocol.java b/src/main/java/com/zy/core/model/protocol/DualCrnProtocol.java
index 66ff195..11e4e41 100644
--- a/src/main/java/com/zy/core/model/protocol/DualCrnProtocol.java
+++ b/src/main/java/com/zy/core/model/protocol/DualCrnProtocol.java
@@ -1,9 +1,9 @@
 package com.zy.core.model.protocol;
 
-import com.zy.core.enums.DualCrnForkPosType;
-import com.zy.core.enums.DualCrnLiftPosType;
-import com.zy.core.enums.DualCrnModeType;
-import com.zy.core.enums.DualCrnStatusType;
+import com.core.common.Cools;
+import com.core.common.SpringUtils;
+import com.zy.common.utils.RedisUtil;
+import com.zy.core.enums.*;
 
 import lombok.Data;
 
@@ -29,14 +29,24 @@
     public Integer alarm;
 
     /**
-     * 宸ヤ綅1浠诲姟鍙�
+     * WCS宸ヤ綅1浠诲姟鍙�
      */
     public Integer taskNo = 0;
 
     /**
-     * 宸ヤ綅2浠诲姟鍙�
+     * WCS宸ヤ綅2浠诲姟鍙�
      */
     public Integer taskNoTwo = 0;
+
+    /**
+     * 璁惧宸ヤ綅1浠诲姟鍙�
+     */
+    public Integer deviceTaskNo = 0;
+
+    /**
+     * 璁惧宸ヤ綅2浠诲姟鍙�
+     */
+    public Integer deviceTaskNoTwo = 0;
 
     /**
      * 宸ヤ綅1褰撳墠鐘舵��
@@ -296,4 +306,32 @@
         this.statusTwo = DualCrnStatusType.get(type).id;
     }
 
+    public Integer getTaskNo() {
+        RedisUtil redisUtil = null;
+        try {
+            redisUtil = SpringUtils.getBean(RedisUtil.class);
+        }catch (Exception e) {}
+        if (null != redisUtil) {
+            Object o = redisUtil.get(RedisKeyType.DUAL_CRN_STATION1_FLAG.key + this.crnNo);
+            if (!Cools.isEmpty(o)) {
+                this.taskNo = Integer.parseInt(String.valueOf(o));
+            }
+        }
+        return this.taskNo == null ? 0 : this.taskNo;
+    }
+
+    public Integer getTaskNoTwo() {
+        RedisUtil redisUtil = null;
+        try {
+            redisUtil = SpringUtils.getBean(RedisUtil.class);
+        }catch (Exception e) {}
+        if (null != redisUtil) {
+            Object o = redisUtil.get(RedisKeyType.DUAL_CRN_STATION2_FLAG.key + this.crnNo);
+            if (!Cools.isEmpty(o)) {
+                this.taskNoTwo = Integer.parseInt(String.valueOf(o));
+            }
+        }
+        return this.taskNoTwo == null ? 0 : this.taskNoTwo;
+    }
+
 }
diff --git a/src/main/java/com/zy/core/network/fake/ZyDualCrnFakeConnect.java b/src/main/java/com/zy/core/network/fake/ZyDualCrnFakeConnect.java
index d529843..79762ed 100644
--- a/src/main/java/com/zy/core/network/fake/ZyDualCrnFakeConnect.java
+++ b/src/main/java/com/zy/core/network/fake/ZyDualCrnFakeConnect.java
@@ -2,7 +2,7 @@
 
 import com.alibaba.fastjson.JSON;
 import com.zy.asrs.entity.DeviceConfig;
-import com.zy.core.enums.CrnStatusType;
+import com.zy.core.enums.DualCrnStatusType;
 import com.zy.core.enums.DualCrnTaskModeType;
 import com.zy.core.model.CommandResponse;
 import com.zy.core.model.command.DualCrnCommand;
@@ -20,6 +20,8 @@
     private final ExecutorService executor = Executors
             .newFixedThreadPool(9999);
     private int taskExecuteStation = 0;
+    private DualCrnCommand station1LastCommand = null;
+    private DualCrnCommand station2LastCommand = null;
 
     public ZyDualCrnFakeConnect(DeviceConfig deviceConfig) {
         this.deviceConfig = deviceConfig;
@@ -71,13 +73,29 @@
                 this.crnStatus.setTaskNo(0);
             }
             this.crnStatus.setTaskReceive(0);
-            this.crnStatus.setStatus(CrnStatusType.IDLE.id);
+            if (station1LastCommand == null) {
+                this.crnStatus.setStatus(DualCrnStatusType.IDLE.id);
+            }else {
+                if (station1LastCommand.getTaskMode().intValue() == DualCrnTaskModeType.PICK.id) {
+                    this.crnStatus.setStatus(DualCrnStatusType.FETCH_COMPLETE.id);
+                }else {
+                    this.crnStatus.setStatus(DualCrnStatusType.IDLE.id);
+                }
+            }
         }else {
             if (crnStatus.getLoadedTwo() == 0) {
                 this.crnStatus.setTaskNoTwo(0);
             }
             this.crnStatus.setTaskReceiveTwo(0);
-            this.crnStatus.setStatusTwo(CrnStatusType.IDLE.id);
+            if (station2LastCommand == null) {
+                this.crnStatus.setStatusTwo(DualCrnStatusType.IDLE.id);
+            }else {
+                if (station1LastCommand.getTaskMode().intValue() == DualCrnTaskModeType.PICK.id) {
+                    this.crnStatus.setStatusTwo(DualCrnStatusType.FETCH_COMPLETE.id);
+                }else {
+                    this.crnStatus.setStatusTwo(DualCrnStatusType.IDLE.id);
+                }
+            }
         }
     }
 
@@ -103,16 +121,16 @@
 
         if(command.getStation() == 1) {
             this.crnStatus.setTaskNo(taskNo);
-            this.crnStatus.setStatus(CrnStatusType.MOVING.id);
+            this.crnStatus.setStatus(DualCrnStatusType.PUT_MOVING.id);
             this.crnStatus.setTaskReceive(1);
             moveYZ(this.crnStatus.getBay(), destinationPosY, this.crnStatus.getLevel(), destinationPosZ, command.getStation());
-            this.crnStatus.setStatus(CrnStatusType.WAITING.id);
+            this.crnStatus.setStatus(DualCrnStatusType.WAITING.id);
         }else {
             this.crnStatus.setTaskNoTwo(taskNo);
-            this.crnStatus.setStatusTwo(CrnStatusType.MOVING.id);
+            this.crnStatus.setStatusTwo(DualCrnStatusType.PUT_MOVING.id);
             this.crnStatus.setTaskReceive(1);
             moveYZ(this.crnStatus.getBay(), destinationPosY, this.crnStatus.getLevel(), destinationPosZ, command.getStation());
-            this.crnStatus.setStatusTwo(CrnStatusType.WAITING.id);
+            this.crnStatus.setStatusTwo(DualCrnStatusType.WAITING.id);
         }
 
         taskExecuteStation = 0;
@@ -143,48 +161,52 @@
 
         if(command.getStation() == 1) {
             this.crnStatus.setTaskNo(taskNo);
-            this.crnStatus.setStatus(CrnStatusType.FETCH_MOVING.id);
+            this.crnStatus.setStatus(DualCrnStatusType.FETCH_MOVING.id);
             this.crnStatus.setTaskReceive(1);
 
             moveYZ(this.crnStatus.getBay(), sourcePosY,this.crnStatus.getLevel(), sourcePosZ,command.getStation());
-            this.crnStatus.setStatus(CrnStatusType.FETCHING.id);
+            this.crnStatus.setStatus(DualCrnStatusType.FETCHING.id);
             sleep(2000);
             if (Thread.currentThread().isInterrupted()) {
                 return;
             }
 
             this.crnStatus.setLoaded(1);
-            this.crnStatus.setStatus(CrnStatusType.PUT_MOVING.id);
+            this.crnStatus.setStatus(DualCrnStatusType.PUT_MOVING.id);
             moveYZ(this.crnStatus.getBay(), destinationPosY,this.crnStatus.getLevel(), destinationPosZ, command.getStation());
-            this.crnStatus.setStatus(CrnStatusType.PUTTING.id);
+            this.crnStatus.setStatus(DualCrnStatusType.PUTTING.id);
             sleep(2000);
             if (Thread.currentThread().isInterrupted()) {
                 return;
             }
             this.crnStatus.setLoaded(0);
-            this.crnStatus.setStatus(CrnStatusType.WAITING.id);
+            this.crnStatus.setStatus(DualCrnStatusType.WAITING.id);
+
+            this.station1LastCommand = command;
         }else {
             this.crnStatus.setTaskNoTwo(taskNo);
-            this.crnStatus.setStatusTwo(CrnStatusType.FETCH_MOVING.id);
+            this.crnStatus.setStatusTwo(DualCrnStatusType.FETCH_MOVING.id);
             this.crnStatus.setTaskReceiveTwo(1);
 
             moveYZ(this.crnStatus.getBay(), sourcePosY,this.crnStatus.getLevel(), sourcePosZ, command.getStation());
-            this.crnStatus.setStatusTwo(CrnStatusType.FETCHING.id);
+            this.crnStatus.setStatusTwo(DualCrnStatusType.FETCHING.id);
             sleep(2000);
             if (Thread.currentThread().isInterrupted()) {
                 return;
             }
 
             this.crnStatus.setLoadedTwo(1);
-            this.crnStatus.setStatusTwo(CrnStatusType.PUT_MOVING.id);
+            this.crnStatus.setStatusTwo(DualCrnStatusType.PUT_MOVING.id);
             moveYZ(this.crnStatus.getBay(), destinationPosY,this.crnStatus.getLevel(), destinationPosZ, command.getStation());
-            this.crnStatus.setStatusTwo(CrnStatusType.PUTTING.id);
+            this.crnStatus.setStatusTwo(DualCrnStatusType.PUTTING.id);
             sleep(2000);
             if (Thread.currentThread().isInterrupted()) {
                 return;
             }
             this.crnStatus.setLoadedTwo(0);
-            this.crnStatus.setStatusTwo(CrnStatusType.WAITING.id);
+            this.crnStatus.setStatusTwo(DualCrnStatusType.WAITING.id);
+
+            this.station2LastCommand = command;
         }
 
         taskExecuteStation = 0;
@@ -212,30 +234,34 @@
 
         if(command.getStation() == 1) {
             this.crnStatus.setTaskNo(taskNo);
-            this.crnStatus.setStatus(CrnStatusType.FETCH_MOVING.id);
+            this.crnStatus.setStatus(DualCrnStatusType.FETCH_MOVING.id);
             this.crnStatus.setTaskReceive(1);
 
             moveYZ(this.crnStatus.getBay(), destinationPosY,this.crnStatus.getLevel(), destinationPosZ, command.getStation());
-            this.crnStatus.setStatus(CrnStatusType.FETCHING.id);
+            this.crnStatus.setStatus(DualCrnStatusType.FETCHING.id);
             sleep(3000);
             if (Thread.currentThread().isInterrupted()) {
                 return;
             }
             this.crnStatus.setLoaded(1);
-            this.crnStatus.setStatus(CrnStatusType.WAITING.id);
+            this.crnStatus.setStatus(DualCrnStatusType.WAITING.id);
+
+            this.station1LastCommand = command;
         }else {
             this.crnStatus.setTaskNoTwo(taskNo);
-            this.crnStatus.setStatusTwo(CrnStatusType.FETCH_MOVING.id);
+            this.crnStatus.setStatusTwo(DualCrnStatusType.FETCH_MOVING.id);
             this.crnStatus.setTaskReceiveTwo(1);
 
             moveYZ(this.crnStatus.getBay(), destinationPosY,this.crnStatus.getLevel(), destinationPosZ, command.getStation());
-            this.crnStatus.setStatusTwo(CrnStatusType.FETCHING.id);
+            this.crnStatus.setStatusTwo(DualCrnStatusType.FETCHING.id);
             sleep(3000);
             if (Thread.currentThread().isInterrupted()) {
                 return;
             }
             this.crnStatus.setLoadedTwo(1);
-            this.crnStatus.setStatusTwo(CrnStatusType.WAITING.id);
+            this.crnStatus.setStatusTwo(DualCrnStatusType.WAITING.id);
+
+            this.station2LastCommand = command;
         }
 
         taskExecuteStation = 0;
@@ -263,30 +289,34 @@
 
         if(command.getStation() == 1) {
             this.crnStatus.setTaskNo(taskNo);
-            this.crnStatus.setStatus(CrnStatusType.PUT_MOVING.id);
+            this.crnStatus.setStatus(DualCrnStatusType.PUT_MOVING.id);
             this.crnStatus.setTaskReceive(1);
 
             moveYZ(this.crnStatus.getBay(), destinationPosY,this.crnStatus.getLevel(), destinationPosZ, command.getStation());
-            this.crnStatus.setStatus(CrnStatusType.PUTTING.id);
+            this.crnStatus.setStatus(DualCrnStatusType.PUTTING.id);
             sleep(3000);
             if (Thread.currentThread().isInterrupted()) {
                 return;
             }
             this.crnStatus.setLoaded(0);
-            this.crnStatus.setStatus(CrnStatusType.WAITING.id);
+            this.crnStatus.setStatus(DualCrnStatusType.WAITING.id);
+
+            this.station1LastCommand = command;
         }else {
             this.crnStatus.setTaskNoTwo(taskNo);
-            this.crnStatus.setStatusTwo(CrnStatusType.PUT_MOVING.id);
+            this.crnStatus.setStatusTwo(DualCrnStatusType.PUT_MOVING.id);
             this.crnStatus.setTaskReceiveTwo(1);
 
             moveYZ(this.crnStatus.getBay(), destinationPosY,this.crnStatus.getLevel(), destinationPosZ, command.getStation());
-            this.crnStatus.setStatusTwo(CrnStatusType.PUTTING.id);
+            this.crnStatus.setStatusTwo(DualCrnStatusType.PUTTING.id);
             sleep(3000);
             if (Thread.currentThread().isInterrupted()) {
                 return;
             }
             this.crnStatus.setLoadedTwo(0);
-            this.crnStatus.setStatusTwo(CrnStatusType.WAITING.id);
+            this.crnStatus.setStatusTwo(DualCrnStatusType.WAITING.id);
+
+            this.station2LastCommand = command;
         }
 
         taskExecuteStation = 0;
diff --git a/src/main/java/com/zy/core/thread/impl/ZySiemensDualCrnThread.java b/src/main/java/com/zy/core/thread/impl/ZySiemensDualCrnThread.java
index 41941f5..ab72c7b 100644
--- a/src/main/java/com/zy/core/thread/impl/ZySiemensDualCrnThread.java
+++ b/src/main/java/com/zy/core/thread/impl/ZySiemensDualCrnThread.java
@@ -88,9 +88,13 @@
                         for (SendDualCrnCommandParam sendDualCrnCommandParam : commandList) {
                             DualCrnCommand dualCrnCommand = sendDualCrnCommandParam.getCommands().get(0);
                             redisUtil.set(RedisKeyType.DUAL_CRN_COMMAND_IDX.key + dualCrnCommand.getTaskNo(), 0, 60 * 60 * 24);
+                            redisUtil.set(RedisKeyType.DUAL_CRN_COMMAND_.key + dualCrnCommand.getTaskNo(), JSON.toJSONString(sendDualCrnCommandParam, SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24);
+                            if (sendDualCrnCommandParam.getStation() == 1) {
+                                redisUtil.set(RedisKeyType.DUAL_CRN_STATION1_FLAG.key + crnProtocol.getCrnNo(), dualCrnCommand.getTaskNo(), 60 * 60 * 24);
+                            }else {
+                                redisUtil.set(RedisKeyType.DUAL_CRN_STATION2_FLAG.key + crnProtocol.getCrnNo(), dualCrnCommand.getTaskNo(), 60 * 60 * 24);
+                            }
                         }
-
-                        redisUtil.set(RedisKeyType.DUAL_CRN_COMMAND_.key + crnProtocol.getCrnNo(), JSON.toJSONString(commandList, SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24);
                     } else if (step == 3) {
                         sendCommand((DualCrnCommand) task.getData());
                     }
@@ -120,11 +124,7 @@
                         continue;
                     }
 
-                    Object commandListObj = redisUtil.get(RedisKeyType.DUAL_CRN_COMMAND_.key + crnProtocol.getCrnNo());
-                    if (commandListObj == null) {
-                        continue;
-                    }
-                    List<SendDualCrnCommandParam> commandList = JSON.parseArray(commandListObj.toString(), SendDualCrnCommandParam.class);
+                    List<SendDualCrnCommandParam> commandList = getDualCrnCommandList();
                     for (SendDualCrnCommandParam commandParam : commandList) {
                         processStation(commandParam);
                     }
@@ -246,6 +246,7 @@
 
         //宸ヤ綅1
         crnProtocol.setTaskNo(0);
+        crnProtocol.setDeviceTaskNo(0);
         crnProtocol.setStatus(-1);
         crnProtocol.setBay(0);
         crnProtocol.setLevel(0);
@@ -256,6 +257,7 @@
 
         //宸ヤ綅2
         crnProtocol.setTaskNoTwo(0);
+        crnProtocol.setDeviceTaskNoTwo(0);
         crnProtocol.setStatusTwo(-1);
         crnProtocol.setBayTwo(0);
         crnProtocol.setLevelTwo(0);
@@ -315,7 +317,7 @@
         crnProtocol.setMode(crnStatus.getMode());
 
         //宸ヤ綅1
-        crnProtocol.setTaskNo(crnStatus.getTaskNo());
+        crnProtocol.setDeviceTaskNo(crnStatus.getTaskNo());
         crnProtocol.setStatus(crnStatus.getStatus());
         crnProtocol.setForkPos(crnStatus.getForkPos());
         crnProtocol.setLoaded(crnStatus.getLoaded());
@@ -323,7 +325,7 @@
         crnProtocol.setTaskSend(crnStatus.getTaskSend());
 
         //宸ヤ綅2
-        crnProtocol.setTaskNoTwo(crnStatus.getTaskNoTwo());
+        crnProtocol.setDeviceTaskNoTwo(crnStatus.getTaskNoTwo());
         crnProtocol.setStatusTwo(crnStatus.getStatusTwo());
         crnProtocol.setForkPosTwo(crnStatus.getForkPosTwo());
         crnProtocol.setLoadedTwo(crnStatus.getLoadedTwo());
@@ -539,4 +541,45 @@
             }
         }
     }
+
+    public List<SendDualCrnCommandParam> getDualCrnCommandList() {
+        List<SendDualCrnCommandParam> commandList = new ArrayList<>();
+        SendDualCrnCommandParam command1 = getDualCrnCommandList(1);
+        SendDualCrnCommandParam command2 = getDualCrnCommandList(2);
+        if (command1 != null) {
+            commandList.add(command1);
+        }
+
+        if (command2 != null) {
+            commandList.add(command2);
+        }
+
+        return commandList;
+    }
+
+    public SendDualCrnCommandParam getDualCrnCommandList(int station) {
+        SendDualCrnCommandParam sendDualCrnCommandParam = null;
+        String key = null;
+        if (station == 1 && crnProtocol.getTaskNo() > 0) {
+            key = RedisKeyType.DUAL_CRN_COMMAND_.key + crnProtocol.getTaskNo();
+        } else if (station == 2 && crnProtocol.getTaskNoTwo() > 0) {
+            key = RedisKeyType.DUAL_CRN_COMMAND_.key + crnProtocol.getTaskNoTwo();
+        }
+
+        if (key == null) {
+            return null;
+        }
+
+        Object commandObj = redisUtil.get(key);
+        if (commandObj == null) {
+            return null;
+        }
+
+        sendDualCrnCommandParam = JSON.parseObject(commandObj.toString(), SendDualCrnCommandParam.class);
+        if (sendDualCrnCommandParam == null) {
+            return null;
+        }
+
+        return sendDualCrnCommandParam;
+    }
 }
diff --git a/src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java b/src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java
index 760f80d..ff01d85 100644
--- a/src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java
+++ b/src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java
@@ -465,6 +465,10 @@
 
         Integer station = inStationObjModel.getDualCrnExecuteStation();
         if (station == 1) {
+            if (dualCrnProtocol.getTaskNo() > 0) {
+                News.taskInfo(wrkMast.getWrkNo(), "宸ヤ綅1绯荤粺鍐呴儴璁板綍鏈変换鍔�");
+                return null;
+            }
             List<Integer> basList = basDualCrnp.getDisableStationOneBays$();
             if (basList.contains(Utils.getBay(wrkMast.getLocNo()))) {
                 //绂佹鏀捐揣鍒楋紝鐢宠閲嶆柊鍒嗛厤
@@ -472,6 +476,10 @@
                 return null;
             }
         }else {
+            if (dualCrnProtocol.getTaskNoTwo() > 0) {
+                News.taskInfo(wrkMast.getWrkNo(), "宸ヤ綅2绯荤粺鍐呴儴璁板綍鏈変换鍔�");
+                return null;
+            }
             List<Integer> basList = basDualCrnp.getDisableStationTwoBays$();
             if (basList.contains(Utils.getBay(wrkMast.getLocNo()))) {
                 //绂佹鏀捐揣鍒楋紝鐢宠閲嶆柊鍒嗛厤
@@ -520,6 +528,18 @@
         if (outStationList.isEmpty()) {
             News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍑哄簱绔欑偣鏈缃�", basDualCrnp.getCrnNo());
             return null;
+        }
+
+        if (station == 1) {
+            if (dualCrnProtocol.getTaskNo() > 0) {
+                News.taskInfo(wrkMast.getWrkNo(), "宸ヤ綅1绯荤粺鍐呴儴璁板綍鏈変换鍔�");
+                return null;
+            }
+        }else {
+            if (dualCrnProtocol.getTaskNoTwo() > 0) {
+                News.taskInfo(wrkMast.getWrkNo(), "宸ヤ綅2绯荤粺鍐呴儴璁板綍鏈変换鍔�");
+                return null;
+            }
         }
 
         Integer crnNo = basDualCrnp.getCrnNo();
@@ -688,12 +708,12 @@
                 continue;
             }
 
-            if(dualCrnProtocol.getTaskNo() > 0 && dualCrnProtocol.getTaskSend() == 0 && dualCrnProtocol.getStatus() == DualCrnStatusType.WAITING.id) {
+            if((dualCrnProtocol.getTaskNo() > 0 && dualCrnProtocol.getDeviceTaskNo() > 0) && dualCrnProtocol.getTaskSend() == 0 && dualCrnProtocol.getStatus().equals(DualCrnStatusType.WAITING.id)) {
                 executeFinish(basDualCrnp, dualCrnThread, dualCrnProtocol, dualCrnProtocol.getTaskNo(), 1);
                 continue;
             }
 
-            if(dualCrnProtocol.getTaskNoTwo() > 0 && dualCrnProtocol.getTaskSendTwo() == 0 && dualCrnProtocol.getStatusTwo() == DualCrnStatusType.WAITING.id) {
+            if((dualCrnProtocol.getTaskNoTwo() > 0 && dualCrnProtocol.getDeviceTaskNoTwo() > 0) && dualCrnProtocol.getTaskSendTwo() == 0 && dualCrnProtocol.getStatusTwo().equals(DualCrnStatusType.WAITING.id)) {
                 executeFinish(basDualCrnp, dualCrnThread, dualCrnProtocol, dualCrnProtocol.getTaskNoTwo(), 2);
                 continue;
             }
@@ -762,6 +782,12 @@
             DualCrnCommand resetCommand = dualCrnThread.getResetCommand(taskNo, dualCrnProtocol.getCrnNo(), station);
             boolean offer = MessageQueue.offer(SlaveType.DualCrn, dualCrnProtocol.getCrnNo(), new Task(3, resetCommand));
             if (offer) {
+                if (station == 1) {
+                    redisUtil.set(RedisKeyType.DUAL_CRN_STATION1_FLAG.key + basDualCrnp.getCrnNo(), 0, 60 * 60 * 24);
+                }else {
+                    redisUtil.set(RedisKeyType.DUAL_CRN_STATION2_FLAG.key + basDualCrnp.getCrnNo(), 0, 60 * 60 * 24);
+                }
+
                 wrkMast.setWrkSts(updateWrkSts);
                 wrkMast.setSystemMsg("");
                 wrkMast.setIoTime(new Date());
diff --git a/src/main/webapp/components/WatchDualCrnCard.js b/src/main/webapp/components/WatchDualCrnCard.js
index 25182be..6845338 100644
--- a/src/main/webapp/components/WatchDualCrnCard.js
+++ b/src/main/webapp/components/WatchDualCrnCard.js
@@ -47,8 +47,28 @@
               <el-descriptions border direction="vertical">
                 <el-descriptions-item label="妯″紡">{{ item.mode }}</el-descriptions-item>
                 <el-descriptions-item label="寮傚父鐮�">{{ item.warnCode }}</el-descriptions-item>
-                <el-descriptions-item label="宸ヤ綅1浠诲姟鍙�">{{ item.taskNo }}</el-descriptions-item>
-                <el-descriptions-item label="宸ヤ綅2浠诲姟鍙�">{{ item.taskNoTwo }}</el-descriptions-item>
+                <el-descriptions-item label="宸ヤ綅1浠诲姟鍙�">
+                  <span v-if="readOnly">{{ item.taskNo }}</span>
+                  <el-button
+                    v-else
+                    type="text"
+                    size="mini"
+                    style="padding:0;"
+                    @click.stop="editTaskNo(item, 1)"
+                  >{{ item.taskNo }}</el-button>
+                </el-descriptions-item>
+                <el-descriptions-item label="宸ヤ綅2浠诲姟鍙�">
+                  <span v-if="readOnly">{{ item.taskNoTwo }}</span>
+                  <el-button
+                    v-else
+                    type="text"
+                    size="mini"
+                    style="padding:0;"
+                    @click.stop="editTaskNo(item, 2)"
+                  >{{ item.taskNoTwo }}</el-button>
+                </el-descriptions-item>
+                <el-descriptions-item label="璁惧宸ヤ綅1浠诲姟鍙�">{{ item.deviceTaskNo }}</el-descriptions-item>
+                <el-descriptions-item label="璁惧宸ヤ綅2浠诲姟鍙�">{{ item.deviceTaskNoTwo }}</el-descriptions-item>
                 <el-descriptions-item label="宸ヤ綅1鐘舵��">{{ item.status }}</el-descriptions-item>
                 <el-descriptions-item label="宸ヤ綅2鐘舵��">{{ item.statusTwo }}</el-descriptions-item>
                 <el-descriptions-item label="宸ヤ綅1鏄惁鏈夌墿">{{ item.loading }}</el-descriptions-item>
@@ -163,6 +183,50 @@
     openControl() {
       this.showControl = !this.showControl;
     },
+    editTaskNo(item, station) {
+      let that = this;
+      const isStationOne = station === 1;
+      const fieldName = isStationOne ? "taskNo" : "taskNoTwo";
+      const stationName = isStationOne ? "宸ヤ綅1" : "宸ヤ綅2";
+      const currentTaskNo = item[fieldName] == null ? "" : String(item[fieldName]);
+      that.$prompt("璇疯緭鍏�" + stationName + "浠诲姟鍙�", "缂栬緫浠诲姟鍙�", {
+        confirmButtonText: "纭畾",
+        cancelButtonText: "鍙栨秷",
+        inputValue: currentTaskNo,
+        inputPattern: /^\d+$/,
+        inputErrorMessage: "浠诲姟鍙峰繀椤绘槸闈炶礋鏁存暟",
+      }).then(({ value }) => {
+        const taskNo = Number(value);
+        $.ajax({
+          url: baseUrl + "/dualcrn/command/updateTaskNo",
+          headers: {
+            token: localStorage.getItem("token"),
+          },
+          contentType: "application/json",
+          method: "post",
+          data: JSON.stringify({
+            crnNo: item.crnNo,
+            station: station,
+            taskNo: taskNo,
+          }),
+          success: (res) => {
+            if (res.code == 200) {
+              item[fieldName] = taskNo;
+              that.$message({
+                message: stationName + "浠诲姟鍙锋洿鏂版垚鍔�",
+                type: "success",
+              });
+              that.getDualCrnStateInfo();
+            } else {
+              that.$message({
+                message: res.msg,
+                type: "warning",
+              });
+            }
+          },
+        });
+      }).catch(() => {});
+    },
     getDualCrnStateInfo() {
       if (this.$root.sendWs) {
         this.$root.sendWs(JSON.stringify({

--
Gitblit v1.9.1