From 4b79d529958435a201762a8813a521ae8932b506 Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期四, 30 三月 2023 10:44:14 +0800 Subject: [PATCH] 提升机配置文件更新 --- src/main/java/com/zy/core/thread/ShuttleThread.java | 73 +++++++++++++++++++++++++++++++++--- 1 files changed, 67 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/zy/core/thread/ShuttleThread.java b/src/main/java/com/zy/core/thread/ShuttleThread.java index e2ee80d..db733ce 100644 --- a/src/main/java/com/zy/core/thread/ShuttleThread.java +++ b/src/main/java/com/zy/core/thread/ShuttleThread.java @@ -8,8 +8,11 @@ import com.core.common.DateUtils; import com.core.common.SpringUtils; import com.core.exception.CoolException; +import com.zy.asrs.entity.BasShuttle; import com.zy.asrs.entity.BasShuttleOpt; +import com.zy.asrs.mapper.BasShuttleMapper; import com.zy.asrs.service.BasShuttleOptService; +import com.zy.asrs.service.BasShuttleService; import com.zy.common.model.NavigateNode; import com.zy.common.utils.CommonUtils; import com.zy.common.utils.NavigatePositionConvert; @@ -160,9 +163,6 @@ ///璇诲彇鍥涘悜绌挎杞︾姸鎬�-end - OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛",DateUtils.convert(new Date()), slave.getId())); - log.info(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛",DateUtils.convert(new Date()), slave.getId())); - //灏忚溅澶勪簬蹇欑鐘舵�侊紝灏嗘爣璁扮疆涓簍rue if (shuttleProtocol.getBusyStatusType() == ShuttleStatusType.BUSY) { shuttleProtocol.setPakMk(true); @@ -172,6 +172,62 @@ if (shuttleProtocol.getBusyStatusType() == ShuttleStatusType.IDLE && shuttleProtocol.getTaskNo() != 0 && shuttleProtocol.getPakMk()) { //鎵ц涓嬩竴姝ユ寚浠� executeWork(shuttleProtocol.getAssignCommand()); + } + + //灏嗗洓鍚戠┛姊溅鐘舵�佷繚瀛樿嚦鏁版嵁搴� + BasShuttleService shuttleService = SpringUtils.getBean(BasShuttleService.class); + BasShuttle basShuttle = shuttleService.selectById(shuttleProtocol.getShuttleNo()); + if (basShuttle == null) { + basShuttle = new BasShuttle(); + //鍥涘悜绌挎杞﹀彿 + basShuttle.setShuttleNo(slave.getId()); + shuttleService.insert(basShuttle); + } + //灏忚溅蹇欑姸鎬佷綅 + basShuttle.setBusyStatus(shuttleProtocol.getBusyStatus().intValue()); + //褰撳墠浜岀淮鐮� + basShuttle.setCurrentCode(shuttleProtocol.getCurrentCode().intValue()); + //鐢垫睜鐢甸噺鐧惧垎姣� + basShuttle.setBatteryPower(shuttleProtocol.getBatteryPower().intValue()); + //鐢垫睜娓╁害 + basShuttle.setBatteryTemp(shuttleProtocol.getBatteryTemp().intValue()); + //閿欒缂栧彿 + basShuttle.setErrorCode(shuttleProtocol.getErrorCode().intValue()); + //Plc杈撳嚭鐘舵�両O + basShuttle.setPlcOutputStatusIo(shuttleProtocol.getPlcOutputStatusIO().intValue()); + //閿欒淇℃伅鐮� + basShuttle.setStatusErrorCode(shuttleProtocol.getStatusErrorCode().intValue()); + //PLC杈撳叆鐘舵�� + basShuttle.setPlcInputStatus(shuttleProtocol.getPlcInputStatus().intValue()); + //褰撳墠鎴栬�呬箣鍓嶈鍒扮殑浜岀淮鐮佸�� + basShuttle.setCurrentOrBeforeCode(shuttleProtocol.getCurrentOrBeforeCode().intValue()); + //璇诲埌鐨勪簩缁寸爜X鏂瑰悜鍋忕Щ閲� + basShuttle.setCodeOffsetX(shuttleProtocol.getCodeOffsetX().intValue()); + //璇诲埌鐨勪簩缁寸爜Y鏂瑰悜鍋忕Щ閲� + basShuttle.setCodeOffsetY(shuttleProtocol.getCodeOffsetY().intValue()); + //褰撳墠鐨勭數鍘嬪�� + basShuttle.setCurrentVoltage(shuttleProtocol.getCurrentVoltage().intValue()); + //褰撳墠鐨勬ā鎷熼噺鍊� + basShuttle.setCurrentAnalogValue(shuttleProtocol.getCurrentAnalogValue().intValue()); + //褰撳墠鐨勫崌闄嶄己鏈嶉�熷害 + basShuttle.setCurrentLiftServoSpeed(shuttleProtocol.getCurrentLiftServoSpeed().intValue()); + //褰撳墠鐨勮璧颁己鏈嶉�熷害 + basShuttle.setCurrentMoveServoSpeed(shuttleProtocol.getCurrentMoveServoSpeed().intValue()); + //褰撳墠鐨勫崌闄嶄己鏈嶈礋杞界巼 + basShuttle.setCurrentLiftServoLoad(shuttleProtocol.getCurrentLiftServoLoad().intValue()); + //褰撳墠鐨勮璧颁己鏈嶈礋杞界巼 + basShuttle.setCurrentMoveServoLoad(shuttleProtocol.getCurrentMoveServoLoad().intValue()); + //褰撳墠灏忚溅鐘舵�侊紙鍐呴儴鑷垜缁存姢锛� + basShuttle.setShuttleStatus(shuttleProtocol.getProtocolStatus()); + //浠诲姟鍙� + basShuttle.setWrkNo(shuttleProtocol.getTaskNo().intValue()); + //淇敼鏃堕棿 + basShuttle.setUpdateTime(new Date()); + //浣滀笟鏍囪 + basShuttle.setPakMk(shuttleProtocol.getPakMk()); + if (shuttleService.updateById(basShuttle)) { + OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛",DateUtils.convert(new Date()), slave.getId())); +// log.info(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛",DateUtils.convert(new Date()), slave.getId())); } }else { @@ -292,7 +348,7 @@ HashMap<String, Object> map = new HashMap<>(); //璁$畻璺緞 - List<NavigateNode> calc = NavigateUtils.calc(assignCommand.getSourceLocNo(), assignCommand.getDistLocNo(), assignCommand.getTaskMode().intValue()); + List<NavigateNode> calc = NavigateUtils.calc(assignCommand.getSourceLocNo(), assignCommand.getLocNo(), assignCommand.getTaskMode().intValue()); if (calc != null) { //鑾峰彇鍒嗘璺緞 ArrayList<ArrayList<NavigateNode>> data = NavigateUtils.getSectionPath(calc); @@ -324,8 +380,11 @@ } //鎵ц涓嬪彂鐨勬寚浠� - private void executeWork(ShuttleAssignCommand assignCommand) { + private boolean executeWork(ShuttleAssignCommand assignCommand) { //璇诲彇redis鏁版嵁 + if (assignCommand == null) { + return false; + } Object o = redisUtil.get("wrk_no_" + assignCommand.getTaskNo()); HashMap map = JSON.parseObject(o.toString(), HashMap.class); //褰撳墠姝ュ簭 @@ -402,6 +461,7 @@ //涓嬪彂鍛戒护 if (!write(command)) { News.error("鍥涘悜绌挎杞﹀懡浠や笅鍙戝け璐ワ紝绌挎杞﹀彿={}锛屼换鍔℃暟鎹�={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command)); + return false; } else { News.info("鍥涘悜绌挎杞﹀懡浠や笅鍙戞垚鍔燂紝绌挎杞﹀彿={}锛屼换鍔℃暟鎹�={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command)); @@ -427,7 +487,7 @@ new Date(), ShuttleTaskModeType.get(assignCommand.getTaskMode()).desc, assignCommand.getSourceLocNo(), - assignCommand.getDistLocNo(), + assignCommand.getLocNo(), null, null, null, @@ -445,6 +505,7 @@ } } + return true; } /******************************************************************************************/ -- Gitblit v1.9.1