From 5e3cd26eb7038849be8d4429ac844389587a6728 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期一, 03 七月 2023 10:23:27 +0800
Subject: [PATCH] 手动操作提升机四向车状态

---
 src/main/java/com/zy/asrs/controller/ShuttleController.java |   55 ++++++++++++++++++++++---------------------------------
 1 files changed, 22 insertions(+), 33 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/ShuttleController.java b/src/main/java/com/zy/asrs/controller/ShuttleController.java
index 0f428b9..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;
@@ -115,7 +114,7 @@
             vo.setCurrentOrBeforeCode(shuttleProtocol.getCurrentOrBeforeCode());//褰撳墠鎴栬�呬箣鍓嶈鍒扮殑浜岀淮鐮佸��
             vo.setCodeOffsetX(shuttleProtocol.getCodeOffsetX());//璇诲埌鐨勪簩缁寸爜X鏂瑰悜鍋忕Щ閲�
             vo.setCodeOffsetY(shuttleProtocol.getCodeOffsetY());//璇诲埌鐨勪簩缁寸爜Y鏂瑰悜鍋忕Щ閲�
-            vo.setCurrentVoltage(shuttleProtocol.getCurrentVoltage() * 0.1);//褰撳墠鐨勭數鍘嬪��
+            vo.setCurrentVoltage(shuttleProtocol.getCurrentVoltage());//褰撳墠鐨勭數鍘嬪��
             vo.setCurrentAnalogValue(shuttleProtocol.getCurrentAnalogValue());//褰撳墠鐨勬ā鎷熼噺鍊�
             vo.setCurrentLiftServoSpeed(shuttleProtocol.getCurrentLiftServoSpeed());//褰撳墠鐨勫崌闄嶄己鏈嶉�熷害
             vo.setCurrentMoveServoSpeed(shuttleProtocol.getCurrentMoveServoSpeed());//褰撳墠鐨勮璧颁己鏈嶉�熷害
@@ -169,7 +168,7 @@
             vo.setCurrentLiftServoSpeed(shuttleProtocol.getCurrentLiftServoSpeed());//褰撳墠鐨勫崌闄嶄己鏈嶉�熷害
             vo.setPakMk(shuttleProtocol.getPakMk()?"Y" : "N");    // 浣滀笟鏍囪
             vo.setLocNo(shuttleProtocol.getLocNo());//鍥涘悜绌挎杞﹀綋鍓嶅簱浣嶅彿
-            vo.setLev(Utils.getLev(shuttleProtocol.getLocNo()));//鍥涘悜绌挎杞﹀綋鍓嶅眰楂�
+            vo.setLev(shuttleProtocol.getLocNo() == null ? 0 : Utils.getLev(shuttleProtocol.getLocNo()));//鍥涘悜绌挎杞﹀綋鍓嶅眰楂�
             vo.setRunSpeed(basShuttle.getRunSpeed());//鍥涘悜绌挎杞﹁繍琛岄�熷害(璁剧疆)
             vo.setChargeLine(basShuttle.getChargeLine());//鍏呯數闃堝��
         }
@@ -241,37 +240,27 @@
     }
 
     @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("鍛戒护涓嬪彂澶辫触");
-        }
-
-        basShuttle.setPakMk(vo.getPakMk());
-        basShuttle.setWrkNo(vo.getWorkNo());
-        basShuttle.setUpdateTime(new Date());
-        if (!basShuttleService.updateById(basShuttle)) {
-            throw new CoolException("淇敼澶辫触");
-        }
-        return R.ok();
+        return R.error("plc宸叉帀绾�");
     }
 
     @PostMapping("/runSpeed/{shuttleNo}")

--
Gitblit v1.9.1