From b7951bdbb8925131cbc76be4902fcef0e88d0506 Mon Sep 17 00:00:00 2001
From: ytfl <ytfl@qq.com>
Date: 星期二, 19 八月 2025 18:22:03 +0800
Subject: [PATCH] #自动获取电视机配置信息

---
 src/main/java/com/zy/asrs/controller/CrnController.java |  209 ++++++++++++++++++++++++++++++++-------------------
 1 files changed, 131 insertions(+), 78 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/CrnController.java b/src/main/java/com/zy/asrs/controller/CrnController.java
index 0c202b1..dd358b1 100644
--- a/src/main/java/com/zy/asrs/controller/CrnController.java
+++ b/src/main/java/com/zy/asrs/controller/CrnController.java
@@ -14,16 +14,18 @@
 import com.zy.asrs.domain.vo.CrnStateTableVo;
 import com.zy.asrs.entity.BasCrnError;
 import com.zy.asrs.entity.BasCrnp;
+import com.zy.asrs.entity.LocMast;
 import com.zy.asrs.entity.WrkMast;
 import com.zy.asrs.mapper.BasCrnErrorMapper;
 import com.zy.asrs.service.BasCrnpService;
+import com.zy.asrs.service.LocMastService;
 import com.zy.asrs.service.WrkMastService;
 import com.zy.asrs.service.impl.MainServiceImpl;
+import com.zy.asrs.utils.VersionUtils;
 import com.zy.core.CrnThread;
 import com.zy.core.cache.MessageQueue;
 import com.zy.core.cache.OutputQueue;
 import com.zy.core.cache.SlaveConnection;
-import com.zy.core.enums.CrnLiftPosType;
 import com.zy.core.enums.CrnModeType;
 import com.zy.core.enums.CrnTaskModeType;
 import com.zy.core.enums.SlaveType;
@@ -33,14 +35,19 @@
 import com.zy.core.model.protocol.CrnProtocol;
 import com.zy.core.properties.SlaveProperties;
 import com.zy.core.properties.SystemProperties;
+import com.zy.system.entity.Config;
+import com.zy.system.service.ConfigService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 鍫嗗灈鏈烘帴鍙�
@@ -61,6 +68,10 @@
     private BasCrnpService basCrnpService;
     @Autowired
     private MainServiceImpl mainService;
+    @Autowired
+    private LocMastService locMastService;
+    @Autowired
+    private ConfigService configService;
 
 
     @ManagerAuth(memo = "杩涜涓殑鍛戒护")
@@ -110,31 +121,20 @@
                 continue;
             }
             vo.setWorkNo(crnProtocol.getTaskNo());  //  浠诲姟鍙�
-//            if (crnProtocol.getTaskNo()>0) {
-//                WrkMast wrkMast = wrkMastService.selectById(crnProtocol.getTaskNo());
-//                if (wrkMast != null) {
-//                    vo.setStatusType(CrnStatusType.process(wrkMast.getIoType()).getDesc());   //  妯″紡鐘舵��
-//                }
-//            } else {
-//
-//            }
             vo.setStatusType(crnProtocol.modeType.desc);   //  妯″紡鐘舵��
-            if (crnProtocol.getTaskFinish() == 1) {
-                vo.setStatus("绛夊緟纭");
-            } else {
-                vo.setStatus(crnProtocol.getStatusType().desc);     //  鐘舵��
-            }
+            vo.setStatus(crnProtocol.getStatusType().desc);     //  鐘舵��
             vo.setLoading(crnProtocol.getLoaded()==1?"鏈夌墿":"鏃犵墿");  //  鏈夌墿
             vo.setBay(crnProtocol.getBay());    //  鍒�
             vo.setLev(crnProtocol.getLevel());  //  灞�
-            vo.setXOrigin(crnProtocol.getBay()==1?"鏄�":"鍚�");     //  璧拌鍘熺偣
-            vo.setYOrigin(crnProtocol.getLevel()==1?"鏄�":"鍚�");     // 鍗囬檷鍘熺偣
-            vo.setForkOffset(crnProtocol.getForkPosType().desc);    // 璐у弶浣嶇疆
-            vo.setXLocation(crnProtocol.getWalkPos() == 1?"鏄�":"鍚�");      // 璧拌瀹氫綅
-            vo.setYLocation(crnProtocol.getLiftPosType().equals(CrnLiftPosType.NONE)?"鍚�":"鏄�");      // 鍗囬檷瀹氫綅
-//            vo.setStop(crnProtocol.getCrnError1().controlStop||crnProtocol.getCrnError1().mainStop||crnProtocol.getCrnError1().remoteStop?"鏄�":"鍚�");       //  鎬ュ仠
-            vo.setWarnCode(String.valueOf(crnProtocol.getAlarm1()));  //  寮傚父鐮�
 
+            vo.setForkOffset(crnProtocol.getForkPosType().desc);    // 璐у弶浣嶇疆
+            vo.setLiftPos(crnProtocol.getLiftPosType().desc);
+            vo.setWalkPos(crnProtocol.getWalkPos()==1?"涓嶅湪瀹氫綅":"鍦ㄥ畾浣�");
+            vo.setWarnCode(String.valueOf(crnProtocol.getAlarm()));
+            if (crnProtocol.getAlarm() > 0) {
+                BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm());
+                vo.setAlarm(crnError==null?"鏈煡寮傚父":crnError.getErrName());
+            }
         }
         return R.ok().add(list);
     }
@@ -142,6 +142,16 @@
     @PostMapping("/table/crn/msg")
     @ManagerAuth(memo = "鍫嗗灈鏈烘暟鎹〃")
     public R crnMsgTable(){
+        Config crnSearchDetectTaskCountConfig = configService.selectOne(new EntityWrapper<Config>()
+                .eq("code", "crnSearchDetectTaskCount")
+        );
+        int crnSearchDetectTaskCount = Integer.parseInt(crnSearchDetectTaskCountConfig.getValue());
+
+        Config applyInTaskTotalCountConfig = configService.selectOne(new EntityWrapper<Config>()
+                .eq("code", "applyInTaskTotalCount")
+        );
+        int applyInTaskTotalCount = Integer.parseInt(applyInTaskTotalCountConfig.getValue());
+
         List<CrnMsgTableVo> list = new ArrayList<>();
         List<BasCrnp> crnps = basCrnpService.selectList(new EntityWrapper<BasCrnp>().orderBy("crn_no"));
         for (BasCrnp basCrnp : crnps) {
@@ -160,10 +170,6 @@
             }
 
             vo.setWorkNo(crnProtocol.getTaskNo());  //  浠诲姟鍙�
-            BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm1());
-            if (null != crnError) {
-                vo.setError(crnError.getErrName());
-            }
             if (crnProtocol.getTaskNo()>0) {
                 WrkMast wrkMast = wrkMastService.selectById(crnProtocol.getTaskNo());
                 if (wrkMast != null) {
@@ -183,6 +189,20 @@
             vo.setYdistance(crnProtocol.getYDistance());  //  鍗囬檷璺濈(Km)
             vo.setXduration(crnProtocol.getXDuration());    //  璧拌鏃堕暱(H)
             vo.setYduration(crnProtocol.getYDuration());    //  鍗囬檷鏃堕暱(H)
+            vo.setCrnSearchDetectTaskCount(crnSearchDetectTaskCount);
+            vo.setApplyInTaskTotalCount(applyInTaskTotalCount);
+
+            List<WrkMast> inWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
+                    .eq("crn_no", basCrnp.getCrnNo())
+                    .in("io_type", 1, 10, 53, 57)
+            );
+            vo.setCurrentInTask(inWrkMasts.size());
+
+            List<WrkMast> wrkMastsList = wrkMastService.selectList(new EntityWrapper<WrkMast>()
+                    .eq("crn_no", basCrnp.getCrnNo())
+                    .in("io_type", 1, 10, 53, 57, 101, 103, 107, 110)
+            );
+            vo.setCurrentTotalTask(wrkMastsList.size());
         }
         return R.ok().add(list);
     }
@@ -200,6 +220,20 @@
         return R.ok().add(str.toString());
     }
 
+
+    @GetMapping("/demo/status")
+    public R demoStatus(){
+        List<Map<String, Object>> res = new ArrayList<>();
+        for (CrnSlave crnSlave : slaveProperties.getCrn()) {
+            Map<String, Object> map = new HashMap<>();
+            map.put("crnNo", crnSlave.getId());
+            map.put("demo", crnSlave.getDemo());
+            res.add(map);
+        }
+        return R.ok().add(res);
+    }
+
+
     @PostMapping("/demo/switch")
     @ManagerAuth(memo = "鍫嗗灈鏈烘紨绀�")
     public R crnDemo(CrnDemoParam param) throws InterruptedException {
@@ -213,9 +247,15 @@
             return R.error("鍙d护閿欒");
         }
         Thread.sleep(200L);
-        mainService.crnDemoOfLocMove(param.getCrnId());
+        for (CrnSlave crnSlave : slaveProperties.getCrn()) {
+            if (crnSlave.getId().equals(param.getCrnId())) {
+                crnSlave.setDemo(param.getOpt());
+            }
+        }
+//        mainService.crnDemoOfLocMove(param.getCrnId());
         return R.ok();
     }
+
 
 
     /****************************************************************/
@@ -236,7 +276,6 @@
         command.setDestinationPosX(param.getRow());     // 鐩爣搴撲綅鎺�
         command.setDestinationPosY(param.getBay());     // 鐩爣搴撲綅鍒�
         command.setDestinationPosZ(param.getLev());     // 鐩爣搴撲綅灞�
-        staNoProcess(param, command);
         return crnControl(command)?R.ok():R.error();
     }
 
@@ -254,7 +293,6 @@
         command.setDestinationPosX(param.getRow());     // 鐩爣搴撲綅鎺�
         command.setDestinationPosY(param.getBay());     // 鐩爣搴撲綅鍒�
         command.setDestinationPosZ(param.getLev());     // 鐩爣搴撲綅灞�
-        staNoProcess(param, command);
         return crnControl(command)?R.ok():R.error();
     }
 
@@ -272,7 +310,11 @@
         command.setDestinationPosX(param.getRow());     // 鐩爣搴撲綅鎺�
         command.setDestinationPosY(param.getBay());     // 鐩爣搴撲綅鍒�
         command.setDestinationPosZ(param.getLev());     // 鐩爣搴撲綅灞�
-        staNoProcess(param, command);
+        LocMast sourceLoc = locMastService.selectOne(new EntityWrapper<LocMast>().eq("row1", command.getSourcePosX())
+                .eq("bay1", command.getSourcePosY()).eq("lev1", command.getSourcePosZ()));
+        LocMast loc = locMastService.selectOne(new EntityWrapper<LocMast>().eq("row1", command.getDestinationPosX())
+                .eq("bay1", command.getDestinationPosY()).eq("lev1", command.getDestinationPosZ()));
+        VersionUtils.locMoveCheckLocType(sourceLoc, loc);
         return crnControl(command)?R.ok():R.error();
     }
 
@@ -283,68 +325,68 @@
         command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙�
         command.setTaskNo((short) 0); // 宸ヤ綔鍙�
         command.setAckFinish((short) 0);  // 浠诲姟瀹屾垚纭浣�
-        command.setTaskMode(CrnTaskModeType.SITE_MOVE); // 浠诲姟妯″紡
+        command.setTaskMode(CrnTaskModeType.LOC_MOVE); // 浠诲姟妯″紡
         command.setSourcePosX(param.getSourceStaNo());     // 婧愬簱浣嶆帓
         command.setSourcePosY((short) 0);     // 婧愬簱浣嶅垪
         command.setSourcePosZ((short) 1);     // 婧愬簱浣嶅眰
         command.setDestinationPosX(param.getStaNo());     // 鐩爣搴撲綅鎺�
         command.setDestinationPosY((short) 0);     // 鐩爣搴撲綅鍒�
         command.setDestinationPosZ((short) 1);     // 鐩爣搴撲綅灞�
-        staNoProcess(param, command);
         return crnControl(command)?R.ok():R.error();
     }
 
-    @ManagerAuth(memo = "鍥炲師鐐�")
-    @PostMapping("/operator/bacOrigin")
-    public R crnBacOrigin(CrnOperatorParam param){
-        CrnCommand command = new CrnCommand();
-        command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙�
-        command.setTaskNo((short) 0); // 宸ヤ綔鍙�
-        command.setAckFinish((short) 0);  // 浠诲姟瀹屾垚纭浣�
-        command.setTaskMode(CrnTaskModeType.GO_ORIGIN); // 浠诲姟妯″紡
-        command.setSourcePosX((short) 0);     // 婧愬簱浣嶆帓
-        command.setSourcePosY((short) 0);     // 婧愬簱浣嶅垪
-        command.setSourcePosZ((short) 0);     // 婧愬簱浣嶅眰
-        command.setDestinationPosX((short) 0);     // 鐩爣搴撲綅鎺�
-        command.setDestinationPosY((short) 0);     // 鐩爣搴撲綅鍒�
-        command.setDestinationPosZ((short) 0);     // 鐩爣搴撲綅灞�
-        return crnControl(command)?R.ok():R.error();
-    }
-
-    @ManagerAuth(memo = "鍙嶅師鐐�")
-    @PostMapping("/operator/reverseOrigin")
-    public R reverseOrigin(CrnOperatorParam param){
-        CrnCommand command = new CrnCommand();
-        command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙�
-        command.setTaskNo((short) 0); // 宸ヤ綔鍙�
-        command.setAckFinish((short) 0);  // 浠诲姟瀹屾垚纭浣�
-        command.setTaskMode(CrnTaskModeType.GO_ORIGIN); // 浠诲姟妯″紡
-        command.setSourcePosX((short) 0);     // 婧愬簱浣嶆帓
-        command.setSourcePosY((short) 0);     // 婧愬簱浣嶅垪
-        command.setSourcePosZ((short) 0);     // 婧愬簱浣嶅眰
-        command.setDestinationPosX((short) 0);     // 鐩爣搴撲綅鎺�
-        command.setDestinationPosY((short) 34);     // 鐩爣搴撲綅鍒�
-        command.setDestinationPosZ((short) 5);     // 鐩爣搴撲綅灞�
-        return crnControl(command)?R.ok():R.error();
-    }
-
-//    @ManagerAuth(memo = "鍧愭爣绉诲姩")
-//    @PostMapping("/operator/coorMove")
-//    public R crnCoorMove(CrnOperatorParam param){
+//    @ManagerAuth(memo = "鍥炲師鐐�")
+//    @PostMapping("/operator/bacOrigin")
+//    public R crnBacOrigin(CrnOperatorParam param){
 //        CrnCommand command = new CrnCommand();
 //        command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙�
 //        command.setTaskNo((short) 0); // 宸ヤ綔鍙�
 //        command.setAckFinish((short) 0);  // 浠诲姟瀹屾垚纭浣�
-//        command.setTaskMode(CrnTaskModeType.OFFSET_MOVE); // 浠诲姟妯″紡
-//        command.setSourcePosX(param.getSourceRow());     // 婧愬簱浣嶆帓
-//        command.setSourcePosY(param.getSourceBay());     // 婧愬簱浣嶅垪
-//        command.setSourcePosZ(param.getSourceLev());     // 婧愬簱浣嶅眰
-//        command.setDestinationPosX(param.getRow());     // 鐩爣搴撲綅鎺�
-//        command.setDestinationPosY(param.getBay());     // 鐩爣搴撲綅鍒�
-//        command.setDestinationPosZ(param.getLev());     // 鐩爣搴撲綅灞�
-//        staNoProcess(param, command);
+//        command.setTaskMode(CrnTaskModeType.GO_ORIGIN); // 浠诲姟妯″紡
+//        command.setSourcePosX((short) 0);     // 婧愬簱浣嶆帓
+//        command.setSourcePosY((short) 0);     // 婧愬簱浣嶅垪
+//        command.setSourcePosZ((short) 0);     // 婧愬簱浣嶅眰
+//        command.setDestinationPosX((short) 0);     // 鐩爣搴撲綅鎺�
+//        command.setDestinationPosY((short) 0);     // 鐩爣搴撲綅鍒�
+//        command.setDestinationPosZ((short) 0);     // 鐩爣搴撲綅灞�
 //        return crnControl(command)?R.ok():R.error();
 //    }
+
+//    @ManagerAuth(memo = "鍙嶅師鐐�")
+//    @PostMapping("/operator/reverseOrigin")
+//    public R reverseOrigin(CrnOperatorParam param){
+//        CrnCommand command = new CrnCommand();
+//        command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙�
+//        command.setTaskNo((short) 0); // 宸ヤ綔鍙�
+//        command.setAckFinish((short) 0);  // 浠诲姟瀹屾垚纭浣�
+//        command.setTaskMode(CrnTaskModeType.GO_ORIGIN); // 浠诲姟妯″紡
+//        command.setSourcePosX((short) 0);     // 婧愬簱浣嶆帓
+//        command.setSourcePosY((short) 0);     // 婧愬簱浣嶅垪
+//        command.setSourcePosZ((short) 0);     // 婧愬簱浣嶅眰
+//        command.setDestinationPosX((short) 0);     // 鐩爣搴撲綅鎺�
+//        command.setDestinationPosY((short) 34);     // 鐩爣搴撲綅鍒�
+//        command.setDestinationPosZ((short) 5);     // 鐩爣搴撲綅灞�
+//        return crnControl(command)?R.ok():R.error();
+//    }
+
+    @ManagerAuth(memo = "鍧愭爣绉诲姩")
+    @PostMapping("/operator/crnMove")
+    public R crnCoorMove(CrnOperatorParam param){
+        CrnCommand command = new CrnCommand();
+        command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙�
+        command.setTaskNo((short) 9999); // 宸ヤ綔鍙�
+        command.setAckFinish((short) 0);  // 浠诲姟瀹屾垚纭浣�
+        command.setTaskMode(CrnTaskModeType.CRN_MOVE); // 浠诲姟妯″紡
+        command.setSourcePosX(param.getSourceRow());     // 婧愬簱浣嶆帓
+        command.setSourcePosY(param.getSourceBay());     // 婧愬簱浣嶅垪
+        command.setSourcePosZ(param.getSourceLev());     // 婧愬簱浣嶅眰
+        command.setDestinationPosX(param.getRow());     // 鐩爣搴撲綅鎺�
+        command.setDestinationPosY(param.getBay());     // 鐩爣搴撲綅鍒�
+        command.setDestinationPosZ(param.getLev());     // 鐩爣搴撲綅灞�
+        staNoProcess(param, command);
+
+        return crnControl(command)?R.ok():R.error();
+    }
 
     @ManagerAuth(memo = "浠诲姟瀹屾垚")
     @PostMapping("/operator/taskComplete")
@@ -381,8 +423,18 @@
         if (param.getCrnNo() == null) {
             throw new CoolException("璇烽�夋嫨鍫嗗灈鏈�");
         }
-        MessageQueue.clear(SlaveType.Crn, param.getCrnNo());
-        return R.ok("娓呴櫎鍛戒护鎴愬姛");
+        CrnCommand command = new CrnCommand();
+        command.setCrnNo(param.getCrnNo()); // 鍫嗗灈鏈虹紪鍙�
+        command.setTaskNo((short) 0); // 宸ヤ綔鍙�
+        command.setAckFinish((short) 0);  // 浠诲姟瀹屾垚纭浣�
+        command.setTaskMode(CrnTaskModeType.NONE); // 浠诲姟妯″紡
+        command.setSourcePosX((short) 0);     // 婧愬簱浣嶆帓
+        command.setSourcePosY((short) 0);     // 婧愬簱浣嶅垪
+        command.setSourcePosZ((short) 0);     // 婧愬簱浣嶅眰
+        command.setDestinationPosX((short) 0);     // 鐩爣搴撲綅鎺�
+        command.setDestinationPosY((short) 0);     // 鐩爣搴撲綅鍒�
+        command.setDestinationPosZ((short) 0);     // 鐩爣搴撲綅灞�
+        return crnControl(command)?R.ok():R.error();
     }
 
     @ManagerAuth(memo = "鎵嬪姩澶嶄綅")
@@ -407,6 +459,7 @@
                 crnCommand.setCrnNo(crn.getId()); // 鍫嗗灈鏈虹紪鍙�
                 crnCommand.setTaskMode(CrnTaskModeType.CLEAR);
                 crnCommand.setAckFinish((short) 0);  // 浠诲姟瀹屾垚纭浣�
+                crnCommand.setCommand((short) 0);  // 浠诲姟瀹屾垚纭浣�
                 // 寤舵椂鍙戦��
                 Thread.sleep(1000L);
                 if (MessageQueue.offer(SlaveType.Crn, crn.getId(), new Task(2, crnCommand))) {

--
Gitblit v1.9.1