From f25949443a6e59eda90b47ab4c423668bcb690a6 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期一, 03 七月 2023 11:21:03 +0800
Subject: [PATCH] 中段码根据规则进行更新 行走少于五个库位,不传中断码 行走少于十个库位,中断码给倒数第二个 行走大于十个库位,中断码给倒数第三个

---
 src/main/java/com/zy/asrs/controller/ShuttleController.java |   70 +++++++++++++++++++++--------------
 1 files changed, 42 insertions(+), 28 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/ShuttleController.java b/src/main/java/com/zy/asrs/controller/ShuttleController.java
index 4288d5e..f7df68a 100644
--- a/src/main/java/com/zy/asrs/controller/ShuttleController.java
+++ b/src/main/java/com/zy/asrs/controller/ShuttleController.java
@@ -23,7 +23,6 @@
 import com.zy.core.model.ShuttleSlave;
 import com.zy.core.model.Task;
 import com.zy.core.model.command.ShuttleAssignCommand;
-import com.zy.core.model.command.ShuttleCommand;
 import com.zy.core.model.protocol.ShuttleProtocol;
 import com.zy.core.properties.SlaveProperties;
 import com.zy.core.thread.ShuttleThread;
@@ -65,6 +64,8 @@
             // 鑾峰彇鍥涘悜绌挎杞︿俊鎭�
             ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, basShuttle.getShuttleNo());
             if (shuttleThread == null) {
+                vo.setStatus(ShuttleProtocolStatusType.OFFLINE.id);//璁惧绂荤嚎
+                vo.setBusyStatus(ShuttleProtocolStatusType.OFFLINE.desc);
                 continue;
             }
             ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
@@ -73,7 +74,7 @@
             }
             vo.setTaskNo(shuttleProtocol.getTaskNo().intValue());  //  浠诲姟鍙�
             vo.setBusyStatus(shuttleProtocol.getBusyStatusType().desc); //鍥涘悜绌挎杞︾姸鎬�
-            vo.setStatus(shuttleProtocol.getProtocolStatusType().desc);//褰撳墠浠诲姟鐘舵��
+            vo.setStatus(shuttleProtocol.getProtocolStatusType().id);//褰撳墠浠诲姟鐘舵��
             vo.setCurrentCode(shuttleProtocol.getCurrentCode());//褰撳墠浜岀淮鐮�
             LocMast currentLocMast = locMastService.queryByQrCode(shuttleProtocol.getCurrentCode().toString());
             if (currentLocMast == null) {
@@ -142,6 +143,9 @@
             if (shuttleProtocol == null) {
                 continue;
             }
+            if (shuttleProtocol.getShuttleNo() == null) {
+                continue;
+            }
 
             vo.setWorkNo(shuttleProtocol.getTaskNo().intValue());//浠诲姟鍙�
             if (shuttleProtocol.getTaskNo() > 0) {
@@ -163,6 +167,10 @@
             vo.setCurrentLiftServoLoad(shuttleProtocol.getCurrentLiftServoLoad() == null ? "" : shuttleProtocol.getCurrentLiftServoLoad() + "%");//褰撳墠鐨勫崌闄嶄己鏈嶈礋杞界巼
             vo.setCurrentLiftServoSpeed(shuttleProtocol.getCurrentLiftServoSpeed());//褰撳墠鐨勫崌闄嶄己鏈嶉�熷害
             vo.setPakMk(shuttleProtocol.getPakMk()?"Y" : "N");    // 浣滀笟鏍囪
+            vo.setLocNo(shuttleProtocol.getLocNo());//鍥涘悜绌挎杞﹀綋鍓嶅簱浣嶅彿
+            vo.setLev(shuttleProtocol.getLocNo() == null ? 0 : Utils.getLev(shuttleProtocol.getLocNo()));//鍥涘悜绌挎杞﹀綋鍓嶅眰楂�
+            vo.setRunSpeed(basShuttle.getRunSpeed());//鍥涘悜绌挎杞﹁繍琛岄�熷害(璁剧疆)
+            vo.setChargeLine(basShuttle.getChargeLine());//鍏呯數闃堝��
         }
         return R.ok().add(list);
     }
@@ -232,35 +240,41 @@
     }
 
     @PostMapping("/detl/update")
-    @ManagerAuth
-    public R steUpdate(ShuttleDataVo vo){
-        BasShuttle basShuttle = basShuttleService.selectById(vo.getShuttleNo());
-        if (basShuttle == null) {
-            return R.error();
+    @ManagerAuth(memo = "淇敼鏁版嵁")
+    public R liftUpdate(@RequestParam Integer shuttleNo,
+                        @RequestParam Short workNo,
+                        @RequestParam String pakMk){
+        for (ShuttleSlave shuttleSlave : slaveProperties.getShuttle()) {
+            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleSlave.getId());
+            if (shuttleThread == null) {
+                return R.error("plc宸叉帀绾�");
+            }
+            ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
+            if (shuttleProtocol == null) {
+                return R.error("plc宸叉帀绾�");
+            }
+            if (workNo != null) {
+                shuttleProtocol.setTaskNo(workNo);
+            }
+            if (pakMk != null) {
+                shuttleProtocol.setPakMk(pakMk.equals("Y"));
+            }
         }
-        // 鑾峰彇鍥涘悜绌挎杞︿俊鎭�
-        ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, vo.getShuttleNo());
-        ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
-        if (shuttleProtocol == null) {
-            throw new CoolException(vo.getShuttleNo() + "鍙峰洓鍚戠┛姊溅涓嶅湪绾匡紝鏃犳硶淇濆瓨");
-        }
-//        if (!Cools.isEmpty(vo.getRow(), vo.getBay(), vo.getLev())) {
-//            if (!shuttleThread.modifyPosHandle(vo.getRow(), vo.getBay(), vo.getLev())) {
-//                throw new CoolException("鏈嶅姟鍣ㄩ敊璇�");
-//            }
-//        }
-        ShuttleCommand shuttleCommand = new ShuttleCommand();
-        shuttleCommand.setTaskNo(vo.getWorkNo().shortValue());
-        if (MessageQueue.offer(SlaveType.Shuttle, vo.getShuttleNo(), new Task(2, shuttleCommand))) {
-        } else {
-            throw new CoolException("鍛戒护涓嬪彂澶辫触");
-        }
+        return R.error("plc宸叉帀绾�");
+    }
 
-        basShuttle.setPakMk(vo.getPakMk());
-        basShuttle.setWrkNo(vo.getWorkNo());
-        basShuttle.setUpdateTime(new Date());
+    @PostMapping("/runSpeed/{shuttleNo}")
+    @ManagerAuth
+    public R setRunSpeed(@PathVariable("shuttleNo") String shuttleNo, @RequestParam("runSpeed") Integer runSpeed, @RequestParam("chargeLine") Integer chargeLine) {
+
+        BasShuttle basShuttle = basShuttleService.selectById(shuttleNo);
+        if (basShuttle == null) {
+            return R.error("鍥涘悜绌挎杞︿笉瀛樺湪");
+        }
+        basShuttle.setRunSpeed(runSpeed);
+        basShuttle.setChargeLine(chargeLine);
         if (!basShuttleService.updateById(basShuttle)) {
-            throw new CoolException("淇敼澶辫触");
+            return R.error();
         }
         return R.ok();
     }

--
Gitblit v1.9.1