From 03e68b2be24ea024eae645c47da1d4cb1773302a Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期五, 13 十月 2023 19:47:13 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/controller/ShuttleController.java | 83 +++++++++++++++++++++++++++++++++++++++-- 1 files changed, 78 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/ShuttleController.java b/src/main/java/com/zy/asrs/controller/ShuttleController.java index dcc006d..509ed36 100644 --- a/src/main/java/com/zy/asrs/controller/ShuttleController.java +++ b/src/main/java/com/zy/asrs/controller/ShuttleController.java @@ -17,10 +17,12 @@ 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; import com.zy.common.utils.RedisUtil; +import com.zy.common.utils.ShuttleDispatchUtils; import com.zy.core.cache.MessageQueue; import com.zy.core.cache.OutputQueue; import com.zy.core.cache.SlaveConnection; @@ -62,6 +64,8 @@ private CommonService commonService; @Autowired private RedisUtil redisUtil; + @Autowired + private ShuttleDispatchUtils shuttleDispatchUtils; @PostMapping("/table/shuttle/state") @ManagerAuth(memo = "鍥涘悜绌挎杞︿俊鎭〃") @@ -69,16 +73,23 @@ ArrayList<JSONObject> list = new ArrayList<>(); List<BasShuttle> shuttles = basShuttleService.selectList(new EntityWrapper<BasShuttle>().orderBy("shuttle_no")); for (BasShuttle basShuttle : shuttles) { + // 琛ㄦ牸琛� + JSONObject baseObj = new JSONObject(); + baseObj.put("shuttleNo", basShuttle.getShuttleNo()); + list.add(baseObj); // 鑾峰彇鍥涘悜绌挎杞︿俊鎭� NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, basShuttle.getShuttleNo()); if (shuttleThread == null) { continue; } NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); + JSONObject shuttleData = JSON.parseObject(JSON.toJSONString(shuttleProtocol)); if (shuttleProtocol == null || shuttleProtocol.getShuttleNo()==null) { + if (shuttleData != null) { + baseObj.putAll(shuttleData); + } continue; } - JSONObject shuttleData = JSON.parseObject(JSON.toJSONString(shuttleProtocol)); shuttleData.put("moveAdvancePath", null);//绌挎杞﹂璁¤矾寰� if (shuttleProtocol.getTaskNo() != 0) { @@ -90,7 +101,7 @@ } } - list.add(shuttleData); + baseObj.putAll(shuttleData); } return R.ok().add(list); } @@ -293,7 +304,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("璺緞璁$畻澶辫触"); } @@ -314,15 +329,33 @@ assignCommand.setCommands(commands); } else if (shuttleTaskModeType == ShuttleTaskModeType.CHARGE) { //鍏呯數寮�鍏� - NyShuttleHttpCommand command = NyHttpUtils.getChargeCommand(shuttleSlave.getId(), assignCommand.getTaskNo().intValue(), true); + boolean charge = false; + if (shuttleProtocol.getChargState() == 1) { + //宸插厖鐢碉紝鍏抽棴鍏呯數 + charge = false; + }else { + //寮�鍚厖鐢� + charge = true; + } + NyShuttleHttpCommand command = NyHttpUtils.getChargeCommand(shuttleSlave.getId(), assignCommand.getTaskNo().intValue(), charge); ArrayList<NyShuttleHttpCommand> commands = new ArrayList<>(); commands.add(command); assignCommand.setCommands(commands); } else if (shuttleTaskModeType == ShuttleTaskModeType.RESET) { //澶嶄綅 shuttleProtocol.setTaskNo(0);//宸ヤ綔鍙锋竻绌� + shuttleProtocol.setToken(0);//浠ょ墝娓呯┖ shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE);//浠诲姟鐘舵��-绌洪棽 - shuttleProtocol.setPakMk(true);//浣滀笟鏍囪澶嶄綅 + shuttleProtocol.setPakMk(false);//浣滀笟鏍囪澶嶄綅 + + shuttleProtocol.setMoveLoc(false); + shuttleProtocol.setMoveType(0); + shuttleProtocol.setXStart(0); + shuttleProtocol.setXTarget(0); + shuttleProtocol.setXCurrent(0); + shuttleProtocol.setYStart(0); + shuttleProtocol.setYTarget(0); + shuttleProtocol.setYCurrent(0); return R.ok(); } else if (shuttleTaskModeType == ShuttleTaskModeType.SHUTTLE_CONTROL) { //灏忚溅绠″埗 @@ -336,6 +369,10 @@ ArrayList<NyShuttleHttpCommand> commands = new ArrayList<>(); commands.add(suspendCommand); assignCommand.setCommands(commands); + } else if (shuttleTaskModeType == ShuttleTaskModeType.MOVE_LOC_NO_WRK_MAST) { + //绉诲姩鍒扮洰鏍囧簱浣�(鐢熸垚绉诲姩浠诲姟) + shuttleDispatchUtils.dispatchShuttle(commonService.getWorkNo(3), param.getDistLocNo(), param.getShuttleNo()); + return R.ok(); } else { throw new CoolException("鏈煡鍛戒护"); } @@ -391,4 +428,40 @@ return R.ok(); } + /** + * 璺戝簱绋嬪簭 + */ + @PostMapping("/moveLoc") + @ManagerAuth + public R moveLoc(@RequestParam Integer shuttleNo, + @RequestParam Integer moveType, + @RequestParam Integer xStart, + @RequestParam Integer xTarget, + @RequestParam Integer yStart, + @RequestParam Integer yTarget) { + NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); + if (shuttleThread == null) { + return R.error(); + } + + NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); + if (shuttleProtocol == null) { + return R.error(); + } + + if (!shuttleProtocol.isIdle()) { + return R.error("灏忚溅蹇欑涓�"); + } + + shuttleProtocol.setMoveLoc(true);//寮�鍚窇搴� + shuttleProtocol.setMoveType(moveType); + shuttleProtocol.setXStart(xStart); + shuttleProtocol.setXTarget(xTarget); + shuttleProtocol.setXCurrent(xStart); + shuttleProtocol.setYStart(yStart); + shuttleProtocol.setYTarget(yTarget); + shuttleProtocol.setYCurrent(yStart); + return R.ok(); + } + } -- Gitblit v1.9.1