From a0d07de9b231471698fa9a6e0d8f151949bb992a Mon Sep 17 00:00:00 2001 From: zjj <3272660260@qq.com> Date: 星期六, 25 十一月 2023 19:10:57 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/thread/SiemensDevpThread.java | 53 ++++++++++++++++++++++++++++++++++------------------- 1 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java index 32873e4..1c4f054 100644 --- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java +++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java @@ -9,6 +9,7 @@ import com.core.common.DateUtils; import com.core.common.SpringUtils; import com.core.exception.CoolException; +import com.zy.asrs.domain.enums.TaskStatusType; import com.zy.asrs.entity.BasDevp; import com.zy.asrs.entity.CommandInfo; import com.zy.asrs.entity.CommandInfoLog; @@ -245,23 +246,23 @@ // // } - //RGV鍙拌溅浣嶇疆 - Thread.sleep(200); - OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB100.0",(short)4); - if (result3.IsSuccess) { - for (int i = 0; i < 2; i++) { - Integer siteId = i==0 ? 112 : 212; // 绔欑偣缂栧彿 - StaProtocol staProtocol = station.get(siteId); - if (null == staProtocol) { - staProtocol = new StaProtocol(); - staProtocol.setSiteId(siteId); - station.put(siteId, staProtocol); - } - staProtocol.setNearbySta(String.valueOf(siemensS7Net.getByteTransform().TransInt16(result3.Content, i*2))); -// String aa = staProtocol.getNearbySta(); -// System.out.println(siteId + "===>>" + staProtocol.getNearbySta()); - } - } +// //RGV鍙拌溅浣嶇疆 +// Thread.sleep(200); +// OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB100.0",(short)4); +// if (result3.IsSuccess) { +// for (int i = 0; i < 2; i++) { +// Integer siteId = i==0 ? 1 : 2; // 绔欑偣缂栧彿 +// StaProtocol staProtocol = station.get(siteId); +// if (null == staProtocol) { +// staProtocol = new StaProtocol(); +// staProtocol.setSiteId(siteId); +// station.put(siteId, staProtocol); +// } +// staProtocol.setNearbySta(String.valueOf(siemensS7Net.getByteTransform().TransInt16(result3.Content, i*2))); +//// String aa = staProtocol.getNearbySta(); +//// System.out.println(siteId + "===>>" + staProtocol.getNearbySta()); +// } +// } // OperateResultExOne<Short> result2 = siemensS7Net.ReadInt16("DB200.0"); // if (result2.IsSuccess) { @@ -319,8 +320,22 @@ CommandInfoLogService commandInfoLogService = SpringUtils.getBean(CommandInfoLogService.class); CommandInfoService commandInfoService = SpringUtils.getBean(CommandInfoService.class); CommandInfo commandInfo = commandInfoService.selectById(staProtocol.getCommandId()); - 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; //浠诲姟涓嬪彂娆℃暟 -- Gitblit v1.9.1