From 0c4b48edb964d47a6db0e2f6a6073fade51c3c4d Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期四, 09 十一月 2023 09:27:54 +0800
Subject: [PATCH] # 显示器

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

diff --git a/src/main/java/com/zy/asrs/controller/ShuttleController.java b/src/main/java/com/zy/asrs/controller/ShuttleController.java
index 2135798..18777ea 100644
--- a/src/main/java/com/zy/asrs/controller/ShuttleController.java
+++ b/src/main/java/com/zy/asrs/controller/ShuttleController.java
@@ -2,7 +2,6 @@
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.core.annotations.ManagerAuth;
 import com.core.common.BaseRes;
 import com.core.common.Cools;
@@ -17,6 +16,7 @@
 import com.zy.asrs.service.WrkMastService;
 import com.zy.asrs.utils.Utils;
 import com.zy.common.model.NyShuttleOperaResult;
+import com.zy.common.model.enums.NavigationMapType;
 import com.zy.common.service.CommonService;
 import com.zy.common.utils.NyHttpUtils;
 import com.zy.common.utils.NyShuttleOperaUtils;
@@ -70,10 +70,13 @@
     @ManagerAuth(memo = "鍥涘悜绌挎杞︿俊鎭〃")
     public R shuttleStateTable(){
         ArrayList<JSONObject> list = new ArrayList<>();
-        List<BasShuttle> shuttles = basShuttleService.selectList(new EntityWrapper<BasShuttle>().orderBy("shuttle_no"));
-        for (BasShuttle basShuttle : shuttles) {
+        for (ShuttleSlave slave : slaveProperties.getShuttle()) {
+            // 琛ㄦ牸琛�
+            JSONObject baseObj = new JSONObject();
+            baseObj.put("shuttleNo", slave.getId());
+            list.add(baseObj);
             // 鑾峰彇鍥涘悜绌挎杞︿俊鎭�
-            NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, basShuttle.getShuttleNo());
+            NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId());
             if (shuttleThread == null) {
                 continue;
             }
@@ -81,7 +84,7 @@
             JSONObject shuttleData = JSON.parseObject(JSON.toJSONString(shuttleProtocol));
             if (shuttleProtocol == null || shuttleProtocol.getShuttleNo()==null) {
                 if (shuttleData != null) {
-                    list.add(shuttleData);
+                    baseObj.putAll(shuttleData);
                 }
                 continue;
             }
@@ -89,14 +92,20 @@
             shuttleData.put("moveAdvancePath", null);//绌挎杞﹂璁¤矾寰�
             if (shuttleProtocol.getTaskNo() != 0) {
                 //瀛樺湪浠诲姟锛岃幏鍙栨寚浠�
-                Object object = redisUtil.get("shuttle_wrk_no_" + shuttleProtocol.getTaskNo());
+                Object object = redisUtil.get(RedisKeyType.SHUTTLE.key + shuttleProtocol.getTaskNo());
                 if (object != null) {
                     ShuttleRedisCommand redisCommand = JSON.parseObject(object.toString(), ShuttleRedisCommand.class);
                     shuttleData.put("moveAdvancePath", redisCommand.getAssignCommand().getNodes());//绌挎杞﹂璁¤矾寰�
                 }
             }
 
-            list.add(shuttleData);
+            Integer chargeLine = basShuttleService.selectById(slave.getId()).getChargeLine();
+            String lowerPower = "N";
+            if (chargeLine != null && shuttleProtocol.getPowerPercent() != null) {
+                lowerPower = shuttleProtocol.getPowerPercent() <= chargeLine ? "Y" : "N";
+            }
+            shuttleData.put("lowerPower", lowerPower);//鏄惁浣庣數閲�
+            baseObj.putAll(shuttleData);
         }
         return R.ok().add(list);
     }
@@ -105,14 +114,13 @@
     @ManagerAuth(memo = "鍥涘悜绌挎杞︽暟鎹〃")
     public R steMsgTable(){
         List<ShuttleMsgTableVo> list = new ArrayList<>();
-        List<BasShuttle> shuttles = basShuttleService.selectList(new EntityWrapper<BasShuttle>().orderBy("shuttle_no"));
-        for (BasShuttle basShuttle : shuttles) {
+        for (ShuttleSlave slave : slaveProperties.getShuttle()) {
             // 琛ㄦ牸琛�
             ShuttleMsgTableVo vo = new ShuttleMsgTableVo();
-            vo.setShuttleNo(basShuttle.getShuttleNo());   //  鍥涘悜绌挎杞﹀彿
+            vo.setShuttleNo(slave.getId());   //  鍥涘悜绌挎杞﹀彿
             list.add(vo);
             // 鑾峰彇绌挎杞︿俊鎭�
-            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, basShuttle.getShuttleNo());
+            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId());
             if (shuttleThread == null) {
                 continue;
             }
@@ -146,8 +154,11 @@
             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());//鍏呯數闃堝��
+
+            BasShuttle basShuttle = basShuttleService.selectById(slave.getId());
+            if (basShuttle != null) {
+                vo.setChargeLine(basShuttle.getChargeLine());//鍏呯數闃堝��
+            }
         }
         return R.ok().add(list);
     }
@@ -173,7 +184,7 @@
 
     @RequestMapping(value = "/command/query")
     public R shuttleCommandQuery(@RequestParam("wrkNo") Integer wrkNo) {
-        Object o = redisUtil.get("shuttle_wrk_no_" + wrkNo);
+        Object o = redisUtil.get(RedisKeyType.SHUTTLE.key + wrkNo);
         if (o == null) {
             return R.error();
         }
@@ -185,13 +196,13 @@
     @RequestMapping(value = "/command/rollback")
     public R shuttleCommandRollback(@RequestParam("wrkNo") Integer wrkNo
             , @RequestParam("commandStep") Integer commandStep) {
-        Object o = redisUtil.get("shuttle_wrk_no_" + wrkNo);
+        Object o = redisUtil.get(RedisKeyType.SHUTTLE.key + wrkNo);
         if (o == null) {
             return R.error();
         }
         ShuttleRedisCommand redisCommand = JSON.parseObject(o.toString(), ShuttleRedisCommand.class);
         redisCommand.setCommandStep(commandStep);
-        redisUtil.set("shuttle_wrk_no_" + wrkNo, JSON.toJSONString(redisCommand));
+        redisUtil.set(RedisKeyType.SHUTTLE.key + wrkNo, JSON.toJSONString(redisCommand));
         return R.ok();
     }
 
@@ -200,7 +211,7 @@
     public R shuttleCommandCompleteSwitch(@RequestParam("wrkNo") Integer wrkNo
             , @RequestParam("commandStep") Integer commandStep
             , @RequestParam("complete") Integer complete) {
-        Object o = redisUtil.get("shuttle_wrk_no_" + wrkNo);
+        Object o = redisUtil.get(RedisKeyType.SHUTTLE.key + wrkNo);
         if (o == null) {
             return R.error();
         }
@@ -209,14 +220,14 @@
         List<NyShuttleHttpCommand> commands = assignCommand.getCommands();
         NyShuttleHttpCommand command = commands.get(commandStep);
         command.setComplete(complete != 0);
-        redisUtil.set("shuttle_wrk_no_" + wrkNo, JSON.toJSONString(redisCommand));
+        redisUtil.set(RedisKeyType.SHUTTLE.key + wrkNo, JSON.toJSONString(redisCommand));
         return R.ok();
     }
 
     //閲嶅惎浠诲姟(鍛戒护)
     @RequestMapping(value = "/command/restart")
     public R shuttleCommandCompleteSwitch(@RequestParam("wrkNo") Integer wrkNo) {
-        Object o = redisUtil.get("shuttle_wrk_no_" + wrkNo);
+        Object o = redisUtil.get(RedisKeyType.SHUTTLE.key + wrkNo);
         if (o == null) {
             return R.error();
         }
@@ -242,11 +253,11 @@
     //鍒犻櫎浠诲姟(鍛戒护)
     @RequestMapping(value = "/command/del")
     public R liftCommandDel(@RequestParam("wrkNo") Integer wrkNo) {
-        Object o = redisUtil.get("shuttle_wrk_no_" + wrkNo);
+        Object o = redisUtil.get(RedisKeyType.SHUTTLE.key + wrkNo);
         if (o == null) {
             return R.error();
         }
-        redisUtil.del("shuttle_wrk_no_" + wrkNo);
+        redisUtil.del(RedisKeyType.SHUTTLE.key + wrkNo);
         return R.ok();
     }
 
@@ -299,7 +310,11 @@
                     assignCommand.setNodes(result.getNodes());
                 } else if (shuttleTaskModeType == ShuttleTaskModeType.MOVE_LOC_NO) {
                     //绉诲姩鍒扮洰鏍囧簱浣�
-                    NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleSlave.getId(), assignCommand.getTaskNo().intValue(), shuttleProtocol.getCurrentLocNo(), param.getDistLocNo());
+                    Integer mapType = NavigationMapType.NORMAL.id;
+                    if (shuttleProtocol.getLiftPosition() == 2) {
+                        mapType = NavigationMapType.DFX.id;
+                    }
+                    NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleSlave.getId(), assignCommand.getTaskNo().intValue(), shuttleProtocol.getCurrentLocNo(), param.getDistLocNo(), mapType);
                     if (result == null) {
                         throw new CoolException("璺緞璁$畻澶辫触");
                     }

--
Gitblit v1.9.1