Bladeren bron

完善设备报警

zhifei 1 jaar geleden
bovenliggende
commit
0f9490ee56

+ 4 - 4
warewms-system/src/main/java/com/warewms/hailiang/connect/CodeReader3Connect.java

@@ -170,14 +170,14 @@ public class CodeReader3Connect implements TCPConnectBase {
             if (CodeReadProperties.failureReturnInstruction.equals(message)) {
                 plcConnectServiceRunner.getPlcServer(DeviceNameEnum.DAOJIAOPLC.getDeviceName()).writeInt32(DaoJiaoPlcEnum.RETURNOUTCOME.getMetadata(), 19);
                 //读码失败
-                SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaoJia_DMQ-1-27.3", deviceName, "未识别到码", "2"));
+                SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaoJiao_DMQ-1-27.3", deviceName, "未识别到码", "2"));
                 return;
             }
             //修改数据库信息
             RetroactiveNow retroactiveNow = new RetroactiveNow();
             retroactiveNow.setBatchNo(message);
             retroactiveNow.setStatus("2");
-            retroactiveNow.setDeviceId("Z1_DaoJia_DMQ-1-27.3");
+            retroactiveNow.setDeviceId("Z1_DaoJiao_DMQ-1-27.3");
             retroactiveNowService.updateData(retroactiveNow);
             //上传MES系统
             mesService.getBatchNoResult(message, true);
@@ -185,11 +185,11 @@ public class CodeReader3Connect implements TCPConnectBase {
             plcConnectServiceRunner.getPlcServer(DeviceNameEnum.DAOJIAOPLC.getDeviceName()).writeInt32(DaoJiaoPlcEnum.RETURNOUTCOME.getMetadata(), 18);
             plcConnectServiceRunner.getPlcServer(DeviceNameEnum.DAOJIAOPLC.getDeviceName()).writeInt32(DaoJiaoPlcEnum.READCODE.getMetadata(), 0);
             //添加日志
-            SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaoJia_DMQ-1-27.3", deviceName, "识别到码:" + message, "1"));
+            SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaoJiao_DMQ-1-27.3", deviceName, "识别到码:" + message, "1"));
         } catch (Exception e) {
             e.printStackTrace();
             log.error("倒角读码任务执行异常,msg:{}", e.getMessage());
-            SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaoJia_DMQ-1-27.3", deviceName, "读码任务出错,msg:" + StringUtils.substring(e.getMessage(), 0, 2000), "2"));
+            SpringUtil.getApplicationContext().publishEvent(new DeviceLog("Z1_DaoJiao_DMQ-1-27.3", deviceName, "读码任务出错,msg:" + StringUtils.substring(e.getMessage(), 0, 2000), "2"));
         }
     }
 

+ 7 - 2
warewms-system/src/main/java/com/warewms/hailiang/service/impl/DeviceServiceImpl.java

@@ -1,6 +1,8 @@
 package com.warewms.hailiang.service.impl;
 
+import cn.hutool.extra.spring.SpringUtil;
 import com.warewms.hailiang.domain.Device;
+import com.warewms.hailiang.domain.DeviceLog;
 import com.warewms.hailiang.service.DeviceService;
 import org.springframework.context.event.EventListener;
 import org.springframework.scheduling.annotation.Async;
@@ -16,9 +18,9 @@ public class DeviceServiceImpl implements DeviceService {
 
     {
         devices.add(new Device("Z1_ChengZhong_PLC-1-52.21", "ChengZhongPlc", "称重辊道PLC", "Z1", "172.20.52.21", 102, "S7", "2"));
-        devices.add(new Device("Z1_Daojiao_PLC-1-27.2", "DaoJiaoJiPlc", "倒角机", "Z1", "172.20.27.2", 102, "S7", "2"));
+        devices.add(new Device("Z1_DaoJiao_PLC-1-27.2", "DaoJiaoJiPlc", "倒角机", "Z1", "172.20.27.2", 102, "S7", "2"));
         devices.add(new Device("Z1_DaoJiao_PMQ-1-27.4", "InkjetPrinters", "喷码器", "Z1", "172.20.27.4", 102, "TCP", "2"));
-        devices.add(new Device("Z1_DaoJia_DMQ-1-27.3", "CodeReader3", "倒角读码器", "Z1", "172.20.27.3", 51236, "TCP", "2"));
+        devices.add(new Device("Z1_DaoJiao_DMQ-1-27.3", "CodeReader3", "倒角读码器", "Z1", "172.20.27.3", 51236, "TCP", "2"));
         devices.add(new Device("Z1_Ximian_PLC-1-52.22", "XiMianPlc", "铣面辊道PLC", "Z1", "172.20.52.22", 102, "S7", "2"));
         devices.add(new Device("Z1_XiMian_DMQ-1-27.5", "CodeReader5", "铣面读码器", "Z1", "172.20.27.5", 51236, "TCP", "2"));
         devices.add(new Device("Z1_Zhazhi_PLC-1-52.24", "ZhaZhiPlc", "轧制辊道PLC", "Z1", "172.20.52.24", 102, "S7", "2"));
@@ -56,6 +58,9 @@ public class DeviceServiceImpl implements DeviceService {
         for (Device device : devices) {
             if(device.getDeviceName().equals(d.getDeviceName())){
                 device.setStatus(d.getStatus());
+                if ("2".equals(d.getStatus())){
+                    SpringUtil.getApplicationContext().publishEvent(new DeviceLog(device.getDeviceId(), device.getDeviceName(), "连接中断,请联系管理员!",d.getStatus() ));
+                }
             }
         }
     }