From 39d84984a674ead4ce589c292565c5cef2631fda Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期三, 29 十一月 2023 15:18:23 +0800 Subject: [PATCH] #指令更新 --- src/main/java/com/zy/core/thread/SiemensDevpThread.java | 65 ++++++++++++++++++++++---------- 1 files changed, 44 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java index 30e8f67..d803b8b 100644 --- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java +++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java @@ -19,6 +19,7 @@ import com.zy.core.cache.MessageQueue; import com.zy.core.cache.OutputQueue; import com.zy.core.cache.SlaveConnection; +import com.zy.core.enums.CommandStatusType; import com.zy.core.enums.IoModeType; import com.zy.core.enums.SlaveType; import com.zy.core.model.DevpSlave; @@ -223,7 +224,7 @@ staProtocol.setOutEnable(status[3]);// 鍙嚭 staProtocol.setEmptyMk(status[4]); // 绌烘澘淇″彿 staProtocol.setFullPlt(status[5]); // 婊℃墭鐩� - staProtocol.setHigh(status[6]); // 楂樺簱浣� + staProtocol.setCar(status[6]); // 鏄惁鏈夎溅 staProtocol.setLow(status[7]); // 浣庡簱浣� if (!staProtocol.isPakMk() && !staProtocol.isLoading()) { @@ -239,7 +240,7 @@ OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.102",(short)60); if (result2.IsSuccess) { for (int i = 0; i < 6; i++) { - String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*8,8, "UTF-8"); + String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*10,8, "UTF-8"); BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1); if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { barcodeThread.setBarcode(barcode); @@ -423,22 +424,24 @@ CommandInfoLogService commandInfoLogService = SpringUtils.getBean(CommandInfoLogService.class); CommandInfoService commandInfoService = SpringUtils.getBean(CommandInfoService.class); CommandInfo commandInfo = commandInfoService.selectById(staProtocol.getCommandId()); - CommandInfoLog commandInfoLog = new CommandInfoLog(); - if (commandInfo != null) { - commandInfoLog = JSON.parseObject(JSON.toJSONString(commandInfo), CommandInfoLog.class); - commandInfoLog.setId(null); - }else { - Date now = new Date(); - commandInfoLog.setCommand(JSON.toJSONString(staProtocol)); - commandInfoLog.setCommandStatus(3); - commandInfoLog.setStartTime(now); - commandInfoLog.setExecuteTime(now); - commandInfoLog.setCompleteTime(now); - commandInfoLog.setDevice(SlaveType.Devp.toString()); - commandInfoLog.setWrkNo(9999); - commandInfoLog.setTaskNo("9999"); - commandInfoLog.setCommandDesc("鎵嬪姩鍛戒护"); - } + CommandInfoLog commandInfoLog = JSON.parseObject(JSON.toJSONString(commandInfo), CommandInfoLog.class); + commandInfoLog.setId(null); +// CommandInfoLog commandInfoLog = new CommandInfoLog(); +// if (commandInfo != null) { +// commandInfoLog = JSON.parseObject(JSON.toJSONString(commandInfo), CommandInfoLog.class); +// commandInfoLog.setId(null); +// }else { +// Date now = new Date(); +// commandInfoLog.setCommand(JSON.toJSONString(staProtocol)); +// commandInfoLog.setCommandStatus(3); +// commandInfoLog.setStartTime(now); +// commandInfoLog.setExecuteTime(now); +// commandInfoLog.setCompleteTime(now); +// commandInfoLog.setDevice(SlaveType.Devp.toString()); +// commandInfoLog.setWrkNo(9999); +// commandInfoLog.setTaskNo("9999"); +// commandInfoLog.setCommandDesc("鎵嬪姩鍛戒护"); +// } OperateResult writeResult; //浠诲姟涓嬪彂娆℃暟 @@ -447,9 +450,6 @@ boolean writeFlag = false; while(writeCount < 5){ writeResult = siemensS7Net.Write("DB100." + index*4, array); // 宸ヤ綔鍙枫�佺洰鏍囩珯 - //鏇存柊鎸囦护鏃ュ織 - commandInfoLog.setDeviceLog("鎸囦护涓嬪彂鎴愬姛"); - commandInfoLogService.insert(commandInfoLog); if(writeResult.IsSuccess){ Thread.sleep(200); @@ -461,12 +461,35 @@ //浠诲姟鍛戒护鍐欏叆鎴愬姛 writeFlag = true; log.info("鍐欏叆杈撻�佺嚎鍛戒护鍚庤繑鍥炴垚鍔燂紝骞朵笖鍥炶鎴愬姛銆傝緭閫佺嚎plc缂栧彿={}锛寋}锛屽啓鍏ユ鏁�={}", slave.getId(), JSON.toJSON(staProtocol), writeCount); + + Date now = new Date(); + + //鏇存柊鎸囦护鐘舵�� + commandInfo.setCommandStatus(CommandStatusType.COMPLETE.id);//杈撻�佺嚎鐩存帴瀹屾垚鐘舵�� + commandInfo.setCompleteTime(now); + commandInfoService.updateById(commandInfo); + + //鏇存柊鎸囦护鏃ュ織 + commandInfoLog.setDeviceLog("鎸囦护涓嬪彂鎴愬姛"); + commandInfoLogService.insert(commandInfoLog); + + //鏇存柊浠诲姟姝ュ簭 + TaskWrkService taskWrkService = SpringUtils.getBean(TaskWrkService.class); + TaskWrk taskWrk = taskWrkService.selectByWrkNo(staProtocol.getWorkNo().intValue()); + if (taskWrk != null) { + taskWrk.setCommandStep(taskWrk.getCommandStep() + 1);//鏇存柊鎸囦护姝ュ簭 + taskWrkService.updateById(taskWrk); + } + break; } else {//杩斿洖缁撴灉鏄垚鍔熶簡锛屼絾鏄湡瀹炲�间笉鐩稿悓 writeCount++; OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎鍛戒护鍚庤繑鍥炴垚鍔燂紝浣嗘槸璇诲彇浠诲姟鍊间笉涓�鑷淬�傝緭閫佺嚎plc缂栧彿={1}锛岀珯鐐规暟鎹�={2},鍐欏叆娆℃暟={3}", slave.getId(), JSON.toJSON(staProtocol),writeCount)); log.error("鍐欏叆杈撻�佺嚎鍛戒护鍚庤繑鍥炴垚鍔燂紝浣嗘槸璇诲彇浠诲姟鍊间笉涓�鑷淬�傝緭閫佺嚎plc缂栧彿={}锛寋}锛屽啓鍏ユ鏁�={}", slave.getId(), JSON.toJSON(staProtocol), writeCount); + //鏇存柊鎸囦护鏃ュ織 + commandInfoLog.setDeviceLog("鎸囦护涓嬪彂澶辫触"); + commandInfoLogService.insert(commandInfoLog); } } else { writeCount++; -- Gitblit v1.9.1