Commit ad2e73e8 authored by wanghao's avatar wanghao

1 测试 上电后通信 和 最终完成 定时任务功能

parent 18c191c4
...@@ -110,13 +110,9 @@ public class DeviceStatusReaderAndTimeSetter { ...@@ -110,13 +110,9 @@ public class DeviceStatusReaderAndTimeSetter {
log.info("当前 设备ip:{} port:{} device:{}的数据条件未满足,等待重试...", ip,port,deviceId); log.info("当前 设备ip:{} port:{} device:{}的数据条件未满足,等待重试...", ip,port,deviceId);
Thread.sleep(RETRY_DELAY); Thread.sleep(RETRY_DELAY);
} }
} catch (Exception e) { } catch (Throwable e) {
alarmData = new TEquipmentAlarmData(); log.error("设备{}: 第{}次读取异常", deviceId, attempt, e);
alarmData.setfAlarmType("04"); //01.老化柜 02.机械臂 03.老化层 04.点位 recordAlarm("04", "ip:" + ip + ",port:" + port + ",deviceId:" + deviceId, "第" + attempt + "次读取失败");
alarmData.setfEquipmentCode("ip:" + ip + ",port:" + port + ",deviceId:" + deviceId);
alarmData.setfAlarmData("读取失败");
alarmDataService.insertTEquipmentAlarmData(alarmData);
if (attempt <= MAX_RETRIES) { if (attempt <= MAX_RETRIES) {
Thread.sleep(RETRY_DELAY); Thread.sleep(RETRY_DELAY);
} }
...@@ -179,18 +175,11 @@ public class DeviceStatusReaderAndTimeSetter { ...@@ -179,18 +175,11 @@ public class DeviceStatusReaderAndTimeSetter {
DeviceStatusReaderDto deviceStatusReaderDto = new DeviceStatusReaderDto(ip, port, devId, result); DeviceStatusReaderDto deviceStatusReaderDto = new DeviceStatusReaderDto(ip, port, devId, result);
// 3 设置回调数据 // 3 设置回调数据
resultHandler.accept(deviceStatusReaderDto); resultHandler.accept(deviceStatusReaderDto);
} catch (ModbusInitException e) { } catch (Throwable e) {
TEquipmentAlarmData alarmData = new TEquipmentAlarmData(); log.error("设备{}: 监控任务异常", devId, e);
alarmData.setfAlarmType("03"); //01.老化柜 02.机械臂 03.老化层 04.点位 // 记录告警(区分Error类型)
alarmData.setfEquipmentCode("ip:" + ip + ",port:" + port); String alarmMsg = e instanceof OutOfMemoryError ? "内存溢出:" + e.getMessage() : "监控任务异常:" + e.getMessage();
alarmData.setfAlarmData("定时任务巡检:Modbus初始化失败"); recordAlarm("03", "ip:" + ip + ",port:" + port + ",deviceId:" + devId, alarmMsg);
alarmDataService.insertTEquipmentAlarmData(alarmData);
} catch (Exception e) {
TEquipmentAlarmData alarmData = new TEquipmentAlarmData();
alarmData.setfAlarmType("03"); //01.老化柜 02.机械臂 03.老化层 04.点位
alarmData.setfEquipmentCode("ip:" + ip + ",port:" + port);
alarmData.setfAlarmData("监控任务异常:" + e.getMessage());
alarmDataService.insertTEquipmentAlarmData(alarmData);
} finally { } finally {
if (threadMaster != null) threadMaster.destroy(); if (threadMaster != null) threadMaster.destroy();
latch.countDown(); latch.countDown();
......
...@@ -126,6 +126,8 @@ public class DeviceCommunicationJob implements Job { ...@@ -126,6 +126,8 @@ public class DeviceCommunicationJob implements Job {
log.error("=== 告警记录失败(不影响触发器) ===", alarmEx); log.error("=== 告警记录失败(不影响触发器) ===", alarmEx);
} }
// 绝对禁止抛出任何异常!!! // 绝对禁止抛出任何异常!!!
} finally {
log.info("=== DeviceCommunicationJob 执行结束:fStoreyId={} ===", fStoreyIdStr);
} }
} }
} }
...@@ -159,6 +159,8 @@ public class FinalExecutionJob implements Job { ...@@ -159,6 +159,8 @@ public class FinalExecutionJob implements Job {
log.error("=== 告警记录失败 ===", alarmEx); log.error("=== 告警记录失败 ===", alarmEx);
} }
// 禁止抛出任何异常!!! // 禁止抛出任何异常!!!
} finally {
log.error("=== FinalExecutionJob finally:fStoreyId={} ===", fStoreyIdStr);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment