From b6defdc0caf971dcaef9b6245801c6522a31c8a0 Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期三, 09 八月 2023 12:47:07 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/thread/SiemensCrnThread.java | 24 ++++++++++++++---------- 1 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/zy/core/thread/SiemensCrnThread.java b/src/main/java/com/zy/core/thread/SiemensCrnThread.java index 32c6cbc..70751fa 100644 --- a/src/main/java/com/zy/core/thread/SiemensCrnThread.java +++ b/src/main/java/com/zy/core/thread/SiemensCrnThread.java @@ -13,6 +13,7 @@ import com.zy.asrs.service.BasCrnOptService; import com.zy.asrs.service.BasCrnpService; import com.zy.asrs.service.CommandInfoService; +import com.zy.asrs.service.DeviceErrorService; import com.zy.core.CrnThread; import com.zy.core.cache.MessageQueue; import com.zy.core.cache.OutputQueue; @@ -51,7 +52,7 @@ this.connect(); while (true) { try { - int step = 3; + int step = 1; Task task = MessageQueue.poll(SlaveType.Crn, slave.getId()); if (task != null) { step = task.getStep(); @@ -124,6 +125,8 @@ } else { OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆戝爢鍨涙満plc杩炴帴澶辫触锛侊紒锛� ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot())); log.error("鍫嗗灈鏈簆lc杩炴帴澶辫触锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()); + DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); + deviceErrorService.addDeviceError("crn", slave.getId(), "鍫嗗灈鏈簆lc杩炴帴澶辫触"); } siemensNet.ConnectClose(); return result; @@ -338,9 +341,13 @@ } } catch (Exception ignore){} + DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); + deviceErrorService.deleteDeviceError("crn", slave.getId()); } else { OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆戣鍙栧爢鍨涙満plc鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot())); log.error("璇诲彇鍫嗗灈鏈簆lc鐘舵�佷俊鎭け璐� ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()); + DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); + deviceErrorService.addDeviceError("crn", slave.getId(), "璇诲彇鍫嗗灈鏈簆lc鐘舵�佷俊鎭け璐�"); } } @@ -355,15 +362,6 @@ if (command.getTaskNo() == 0 && command.getAckFinish() == 0) { command.setTaskNo((short) 9999); } - - CommandInfoService commandInfoService = SpringUtils.getBean(CommandInfoService.class); - CommandInfo commandInfo = new CommandInfo(); - commandInfo.setWrkNo(command.getTaskNo().intValue()); - commandInfo.setCommandStatus(1); - commandInfo.setStartTime(new Date()); - commandInfo.setDevice("crn"); - commandInfo.setCommand(JSON.toJSONString(command)); - commandInfoService.insert(commandInfo); command.setCrnNo(slave.getId()); short[] array = new short[9]; @@ -463,6 +461,12 @@ } catch (Exception ignore) {} if (result.IsSuccess && result1.IsSuccess) { + //鏇存柊鎸囦护鐘舵�� + CommandInfoService commandInfoService = SpringUtils.getBean(CommandInfoService.class); + CommandInfo commandInfo = command.getCommandInfo(); + commandInfo.setCommandStatus(2); + commandInfoService.updateById(commandInfo); + log.warn("鍫嗗灈鏈哄懡浠や笅鍙慬id:{},鏃堕棿锛歿}] >>>>> {}", slave.getId(), DateUtils.convert(new Date(), DateUtils.yyyyMMddHHmmsssss_F), JSON.toJSON(command)); OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> 鍛戒护涓嬪彂锛� {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command))); return true; -- Gitblit v1.9.1