From e6d9118e6c9083ae4c1f1dc18f34b23ed3da2581 Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期日, 13 七月 2025 19:41:26 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java | 20 +++++ src/main/java/com/zy/asrs/domain/param/ShuttleDemoParam.java | 14 +++ src/main/java/com/zy/core/thread/impl/NyShuttleThread.java | 47 +++++++---- src/main/java/com/zy/asrs/controller/OpenController.java | 29 ++++++ src/main/webapp/static/js/basShuttle/basShuttle.js | 69 +++++++++++++++- src/main/resources/application.yml | 2 src/main/webapp/views/admin/basShuttle/basShuttle.html | 14 --- 7 files changed, 155 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/OpenController.java b/src/main/java/com/zy/asrs/controller/OpenController.java index a207073..17b89b6 100644 --- a/src/main/java/com/zy/asrs/controller/OpenController.java +++ b/src/main/java/com/zy/asrs/controller/OpenController.java @@ -375,7 +375,7 @@ , null , null , null - , null + , JSON.toJSONString(param) , JSON.toJSONString(shuttleGather) , null , null @@ -386,6 +386,31 @@ )); return R.ok().add(shuttleGather); + } + + @PostMapping("/shuttleDemo") + @OpenApiLog(memo = "灏忚溅婕旂ず") + public R shuttleDemo(@RequestBody ShuttleDemoParam param) { + shuttleDispatchUtils.shuttleDemo(param); + + apiLogService.insert(new ApiLog( + null + , "灏忚溅婕旂ず" + , "/shuttleDemo" + , null + , null + , null + , JSON.toJSONString(param) + , null + , null + , null + , 1 + , new Date() + , null + , null + )); + + return R.ok(); } @PostMapping("/queryTask") @@ -411,7 +436,7 @@ , null , null , null - , null + , JSON.toJSONString(param) , JSON.toJSONString(wrkMasts) , null , null diff --git a/src/main/java/com/zy/asrs/domain/param/ShuttleDemoParam.java b/src/main/java/com/zy/asrs/domain/param/ShuttleDemoParam.java new file mode 100644 index 0000000..e4f1aa5 --- /dev/null +++ b/src/main/java/com/zy/asrs/domain/param/ShuttleDemoParam.java @@ -0,0 +1,14 @@ +package com.zy.asrs.domain.param; + +import lombok.Data; + +import java.util.List; + +@Data +public class ShuttleDemoParam { + + private List<Integer> shuttleNos; + + private Integer status; + +} diff --git a/src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java b/src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java index d0a2602..9062069 100644 --- a/src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java +++ b/src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java @@ -5,6 +5,7 @@ import com.core.common.Cools; import com.core.exception.CoolException; import com.zy.asrs.domain.ShuttleGatherResult; +import com.zy.asrs.domain.param.ShuttleDemoParam; import com.zy.asrs.domain.param.ShuttleGatherParam; import com.zy.asrs.entity.BasShuttle; import com.zy.asrs.entity.DeviceConfig; @@ -333,6 +334,25 @@ } /** + * 灏忚溅婕旂ず + */ + public void shuttleDemo(ShuttleDemoParam param) { + List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() + .eq("device_type", String.valueOf(SlaveType.Shuttle)) + .in("device_no", param.getShuttleNos()) + ); + + for (DeviceConfig device : shuttleList) { + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getDeviceNo()); + if (shuttleThread == null) { + continue; + } + + shuttleThread.enableDemo(param.getStatus() == 1); + } + } + + /** * 妫�娴嬬洰鏍囨ゼ灞傝溅鏁伴噺鏄惁灏忎簬鍏佽鐨勬渶澶ф暟閲� * true: 灏忎簬鏈�澶ф暟閲� false: 澶т簬鎴栫瓑浜庢渶澶ф暟閲� */ diff --git a/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java b/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java index 68771e5..e8a72d4 100644 --- a/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java +++ b/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java @@ -78,6 +78,22 @@ listenInit();//鐩戝惉鍒濆鍖栦簨浠� readStatus(); Thread.sleep(100); + + ShuttleAction shuttleAction = null; + try { + shuttleAction = SpringUtils.getBean(ShuttleAction.class); + }catch (Exception e){ + continue; + } + + if (shuttleAction == null) { + continue; + } + //婕旂ず妯″紡 + shuttleAction.demo(deviceConfig.getDeviceNo()); + +// //灏忚溅绌洪棽涓旀湁璺戝簱绋嬪簭 +// shuttleAction.moveLoc(deviceConfig.getDeviceNo()); } catch (Exception e) { log.error("ShuttleThread Fail", e); } @@ -110,14 +126,7 @@ //瀛樺湪浠诲姟闇�瑕佹墽琛� boolean result = shuttleAction.executeWork(deviceConfig.getDeviceNo(), taskNo); } - -// //灏忚溅绌洪棽涓旀湁璺戝簱绋嬪簭 -// shuttleAction.moveLoc(deviceConfig.getDeviceNo()); - - //婕旂ず妯″紡 - shuttleAction.demo(deviceConfig.getDeviceNo()); - - Thread.sleep(200); + Thread.sleep(100); } catch (Exception e) { e.printStackTrace(); } @@ -125,17 +134,17 @@ }); executeThread.start(); - //鍏朵粬浠诲姟 - Thread otherThread = new Thread(() -> { - while (true) { - try { - saveLog();//淇濆瓨鏁版嵁 - } catch (Exception e) { - e.printStackTrace(); - } - } - }); - otherThread.start(); +// //鍏朵粬浠诲姟 +// Thread otherThread = new Thread(() -> { +// while (true) { +// try { +// saveLog();//淇濆瓨鏁版嵁 +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// }); +// otherThread.start(); } private void saveLog() { diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index c20a4eb..5e984ee 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -17,7 +17,7 @@ mvc: static-path-pattern: /** redis: - host: 192.168.4.77 + host: 127.0.0.1 port: 6379 database: 0 # password: 123456 diff --git a/src/main/webapp/static/js/basShuttle/basShuttle.js b/src/main/webapp/static/js/basShuttle/basShuttle.js index 081a4a1..ca1c240 100644 --- a/src/main/webapp/static/js/basShuttle/basShuttle.js +++ b/src/main/webapp/static/js/basShuttle/basShuttle.js @@ -26,19 +26,14 @@ ,{field: 'status$', align: 'center',title: '鐘舵��'} // ,{field: 'shuttleStatus', align: 'center',title: '浣滀笟鎬�'} ,{field: 'wrkNo', align: 'center',title: '浠诲姟鍙�'} - ,{field: 'idleLoc', align: 'center',title: '鏆傚瓨搴撲綅'} - // ,{field: 'autoCharge', align: 'center',title: '鑷姩鍏呯數'} + // ,{field: 'idleLoc', align: 'center',title: '鏆傚瓨搴撲綅'} ,{field: 'chargeLine', align: 'center',title: '鐢甸噺绾�'} - ,{field: 'busyStatus$', align: 'center',title: '灏忚溅蹇欑姸鎬�'} ,{field: 'currentCode', align: 'center',title: '浜岀淮鐮�'} - ,{field: 'batteryPower$', align: 'center',title: '鐢甸噺'} - ,{field: 'batteryTemp$', align: 'center',title: '鐢垫睜娓╁害'} // ,{field: 'createBy$', align: 'center',title: '娣诲姞浜哄憳'} // ,{field: 'createTime$', align: 'center',title: '娣诲姞鏃堕棿'} // ,{field: 'updateBy$', align: 'center',title: '淇敼浜哄憳'} // ,{field: 'updateTime$', align: 'center',title: '淇敼鏃堕棿'} ,{field: 'memo', align: 'center',title: '澶囨敞'} - ,{field: 'liftNo', align: 'center',title: '鎻愬崌鏈哄彿'} ,{field: 'pakMk$', align: 'center',title: '鏍囪'} ,{fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:120} @@ -130,6 +125,68 @@ }); }); break; + case 'demoOpen': + shuttleNos = [] + checkStatus.map(function (d) { + shuttleNos.push(d.shuttleNo) + }) + + admin.confirm('纭畾寮�鍚紨绀烘ā寮忓悧锛�', {shadeClose: true}, function(){ + $.ajax({ + url: baseUrl+"/openapi/shuttleDemo", + headers: {'token': localStorage.getItem('token')}, + dataType:'json', + data: JSON.stringify({ + shuttleNos: shuttleNos, + status: 1 + }), + contentType:'application/json;charset=UTF-8', + method: 'POST', + success: function (res) { + layer.closeAll(); + if (res.code === 200) { + layer.msg("璇锋眰鎴愬姛", {icon: 1}); + tableReload(); + } else if (res.code === 403) { + top.location.href = baseUrl+"/"; + } else { + layer.msg(res.msg, {icon: 2}) + } + } + }); + }); + break; + case 'demoClose': + shuttleNos = [] + checkStatus.map(function (d) { + shuttleNos.push(d.shuttleNo) + }) + + admin.confirm('纭畾鍏抽棴婕旂ず妯″紡鍚楋紵', {shadeClose: true}, function(){ + $.ajax({ + url: baseUrl+"/openapi/shuttleDemo", + headers: {'token': localStorage.getItem('token')}, + dataType:'json', + data: JSON.stringify({ + shuttleNos: shuttleNos, + status: 0 + }), + contentType:'application/json;charset=UTF-8', + method: 'POST', + success: function (res) { + layer.closeAll(); + if (res.code === 200) { + layer.msg("璇锋眰鎴愬姛", {icon: 1}); + tableReload(); + } else if (res.code === 403) { + top.location.href = baseUrl+"/"; + } else { + layer.msg(res.msg, {icon: 2}) + } + } + }); + }); + break; case 'exportData': admin.confirm('纭畾瀵煎嚭Excel鍚�', {shadeClose: true}, function(){ var titles=[]; diff --git a/src/main/webapp/views/admin/basShuttle/basShuttle.html b/src/main/webapp/views/admin/basShuttle/basShuttle.html index 9405603..fa5c78c 100644 --- a/src/main/webapp/views/admin/basShuttle/basShuttle.html +++ b/src/main/webapp/views/admin/basShuttle/basShuttle.html @@ -48,6 +48,8 @@ <button class="layui-btn layui-btn-sm layui-btn-danger" id="btn-delete" lay-event="deleteData">鍒犻櫎</button> <button class="layui-btn layui-btn-sm" lay-event="oneUpdateCharge">涓�閿慨鏀圭數閲忕嚎</button> <button class="layui-btn layui-btn-sm" lay-event="shuttleGather">灏忚溅闆嗗悎</button> + <button class="layui-btn layui-btn-sm" lay-event="demoOpen">婕旂ず-寮�</button> + <button class="layui-btn layui-btn-sm" lay-event="demoClose">婕旂ず-鍏�</button> <button class="layui-btn layui-btn-primary layui-btn-sm" id="btn-export" lay-event="exportData" style="float: right">瀵煎嚭</button> </div> </script> @@ -91,12 +93,6 @@ <input class="layui-input" name="wrkNo" placeholder="璇疯緭鍏ヤ换鍔″彿"> </div> </div> - <div class="layui-form-item"> - <label class="layui-form-label">鏆傚瓨搴撲綅: </label> - <div class="layui-input-block"> - <input class="layui-input" name="idleLoc" placeholder="璇疯緭鍏ユ殏瀛樺簱浣�"> - </div> - </div> <!-- <div class="layui-form-item">--> <!-- <label class="layui-form-label">鑷姩鍏呯數: </label>--> <!-- <div class="layui-input-block">--> @@ -113,12 +109,6 @@ <label class="layui-form-label">澶囨敞: </label> <div class="layui-input-block"> <input class="layui-input" name="memo" placeholder="璇疯緭鍏ュ娉�"> - </div> - </div> - <div class="layui-form-item"> - <label class="layui-form-label">鎻愬崌鏈哄彿: </label> - <div class="layui-input-block"> - <input class="layui-input" name="liftNo" placeholder="璇疯緭鍏ユ彁鍗囨満鍙�"> </div> </div> <div class="layui-form-item"> -- Gitblit v1.9.1