解决规则缓存重复存储报错问题

This commit is contained in:
zhangjunwen 2024-06-03 15:57:35 +08:00
parent a2fddcc2d5
commit 43b6757722
3 changed files with 415 additions and 302 deletions

View File

@ -65,179 +65,187 @@ public class IpcDataProcess implements Runnable {
try { try {
BatchRead<Integer> batch = new BatchRead<Integer>(); BatchRead<Integer> batch = new BatchRead<Integer>();
// //
batch.addLocator(0, BaseLocator.holdingRegister(1, 0, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 进油压力,float // batch.addLocator(0, BaseLocator.holdingRegister(1, 0, DataType.FOUR_BYTE_FLOAT_SWAPPED));//系统电流,float
batch.addLocator(1, BaseLocator.holdingRegister(1, 20, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 进油油液温度,float // batch.addLocator(1, BaseLocator.holdingRegister(1, 2, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 系统流量,float
batch.addLocator(2, BaseLocator.holdingRegister(1, 22, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 回油油液温度,float // batch.addLocator(2, BaseLocator.holdingRegister(1, 4, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 传动侧软辊流量,float
batch.addLocator(3, BaseLocator.holdingRegister(1, 24, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 油水监测,float // batch.addLocator(3, BaseLocator.holdingRegister(1, 6, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 传动侧热辊流量,float
batch.addLocator(4, BaseLocator.holdingRegister(1, 26, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 油液粘度,float // batch.addLocator(4, BaseLocator.holdingRegister(1, 8, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 操作侧软辊流量float
batch.addLocator(5, BaseLocator.holdingRegister(1, 28, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 力传感器,float // batch.addLocator(5, BaseLocator.holdingRegister(1, 10, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 操作侧热辊流量,float
// batch.addLocator(6, BaseLocator.holdingRegister(1, 12, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 4um油液颗粒度,float
try{
batch.addLocator(6, BaseLocator.holdingRegister(1, 300, DataType.BINARY));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(7, BaseLocator.holdingRegister(1, 300, DataType.TWO_BYTE_INT_UNSIGNED));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(8, BaseLocator.holdingRegister(1, 300, DataType.TWO_BYTE_INT_SIGNED));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(9, BaseLocator.holdingRegister(1, 300, DataType.TWO_BYTE_INT_UNSIGNED_SWAPPED));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(10, BaseLocator.holdingRegister(1, 300, DataType.TWO_BYTE_INT_SIGNED_SWAPPED));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(11, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_INT_UNSIGNED));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(12, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_INT_SIGNED));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(13, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_INT_UNSIGNED_SWAPPED));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(14, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_INT_SIGNED_SWAPPED));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(15, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_INT_UNSIGNED_SWAPPED_SWAPPED));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(16, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_INT_SIGNED_SWAPPED_SWAPPED));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(17, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_FLOAT));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(18, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(19, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_FLOAT_SWAPPED_INVERTED));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(20, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_INT_UNSIGNED));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(21, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_INT_SIGNED));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(22, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_INT_UNSIGNED_SWAPPED));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(23, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_INT_SIGNED_SWAPPED));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(24, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_FLOAT));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(25, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_FLOAT_SWAPPED));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(26, BaseLocator.holdingRegister(1, 300, DataType.TWO_BYTE_BCD));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(27, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_BCD));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(28, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_BCD_SWAPPED));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(29, BaseLocator.holdingRegister(1, 300, DataType.CHAR));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(30, BaseLocator.holdingRegister(1, 300, DataType.VARCHAR));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(31, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_MOD_10K));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(32, BaseLocator.holdingRegister(1, 300, DataType.SIX_BYTE_MOD_10K));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(33, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_MOD_10K));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(34, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_MOD_10K_SWAPPED));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(35, BaseLocator.holdingRegister(1, 300, DataType.SIX_BYTE_MOD_10K_SWAPPED));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(36, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_MOD_10K_SWAPPED));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(37, BaseLocator.holdingRegister(1, 300, DataType.ONE_BYTE_INT_UNSIGNED_LOWER));// 速度传感器,float
}catch (Exception e){
}
try{
batch.addLocator(38, BaseLocator.holdingRegister(1, 300, DataType.ONE_BYTE_INT_UNSIGNED_UPPER));// 速度传感器,float
}catch (Exception e){
for(int id=0,addr=0; id <= 100; id++,addr+=2){
batch.addLocator(id, BaseLocator.holdingRegister(1, addr, DataType.FOUR_BYTE_FLOAT_SWAPPED));
} }
//状态值
batch.addLocator(101, BaseLocator.holdingRegister(1, 300, DataType.TWO_BYTE_INT_UNSIGNED));
batch.addLocator(102, BaseLocator.holdingRegister(1, 301, DataType.TWO_BYTE_INT_UNSIGNED));
batch.addLocator(103, BaseLocator.holdingRegister(1, 302, DataType.TWO_BYTE_INT_UNSIGNED));
//
// try{
// batch.addLocator(6, BaseLocator.holdingRegister(1, 300, DataType.BINARY));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(7, BaseLocator.holdingRegister(1, 300, DataType.TWO_BYTE_INT_UNSIGNED));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(8, BaseLocator.holdingRegister(1, 300, DataType.TWO_BYTE_INT_SIGNED));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(9, BaseLocator.holdingRegister(1, 300, DataType.TWO_BYTE_INT_UNSIGNED_SWAPPED));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(10, BaseLocator.holdingRegister(1, 300, DataType.TWO_BYTE_INT_SIGNED_SWAPPED));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(11, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_INT_UNSIGNED));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(12, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_INT_SIGNED));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(13, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_INT_UNSIGNED_SWAPPED));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(14, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_INT_SIGNED_SWAPPED));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(15, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_INT_UNSIGNED_SWAPPED_SWAPPED));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(16, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_INT_SIGNED_SWAPPED_SWAPPED));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(17, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_FLOAT));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(18, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(19, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_FLOAT_SWAPPED_INVERTED));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(20, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_INT_UNSIGNED));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(21, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_INT_SIGNED));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(22, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_INT_UNSIGNED_SWAPPED));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(23, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_INT_SIGNED_SWAPPED));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(24, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_FLOAT));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(25, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_FLOAT_SWAPPED));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(26, BaseLocator.holdingRegister(1, 300, DataType.TWO_BYTE_BCD));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(27, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_BCD));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(28, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_BCD_SWAPPED));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(29, BaseLocator.holdingRegister(1, 300, DataType.CHAR));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(30, BaseLocator.holdingRegister(1, 300, DataType.VARCHAR));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(31, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_MOD_10K));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(32, BaseLocator.holdingRegister(1, 300, DataType.SIX_BYTE_MOD_10K));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(33, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_MOD_10K));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(34, BaseLocator.holdingRegister(1, 300, DataType.FOUR_BYTE_MOD_10K_SWAPPED));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(35, BaseLocator.holdingRegister(1, 300, DataType.SIX_BYTE_MOD_10K_SWAPPED));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(36, BaseLocator.holdingRegister(1, 300, DataType.EIGHT_BYTE_MOD_10K_SWAPPED));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(37, BaseLocator.holdingRegister(1, 300, DataType.ONE_BYTE_INT_UNSIGNED_LOWER));// 速度传感器,float
// }catch (Exception e){
//
// }
// try{
// batch.addLocator(38, BaseLocator.holdingRegister(1, 300, DataType.ONE_BYTE_INT_UNSIGNED_UPPER));// 速度传感器,float
// }catch (Exception e){
//
// }
@ -255,68 +263,69 @@ public class IpcDataProcess implements Runnable {
// batch.addLocator(16, BaseLocator.holdingRegister(1, 29, DataType.TWO_BYTE_INT_UNSIGNED));// 颗粒度21um,int // batch.addLocator(16, BaseLocator.holdingRegister(1, 29, DataType.TWO_BYTE_INT_UNSIGNED));// 颗粒度21um,int
batch.setContiguousRequests(false); batch.setContiguousRequests(false);
BatchResults<Integer> results = master.send(batch); BatchResults<Integer> results = master.send(batch);
// for(int m=0; m<=103; m++){
// logger.info("#######################"+m+":"+results.getValue(m));
// }
// logger.info("#######################0:"+results.getValue(0));
// logger.info("#######################1:"+results.getValue(1));
// logger.info("#######################2:"+results.getValue(2));
// logger.info("#######################3:"+results.getValue(3));
// logger.info("#######################4:"+results.getValue(4));
// logger.info("#######################5:"+results.getValue(5));
// logger.info("#######################6:"+results.getValue(6));
// logger.info("#######################6:"+results.getValue(7));
// logger.info("#######################6:"+results.getValue(8));
// logger.info("#######################6:"+results.getValue(9));
// logger.info("#######################6:"+results.getValue(10));
// logger.info("#######################6:"+results.getValue(11));
// logger.info("#######################6:"+results.getValue(12));
// logger.info("#######################6:"+results.getValue(13));
// logger.info("#######################6:"+results.getValue(14));
// logger.info("#######################6:"+results.getValue(15));
// logger.info("#######################6:"+results.getValue(16));
// logger.info("#######################6:"+results.getValue(17));
// logger.info("#######################6:"+results.getValue(18));
// logger.info("#######################19:"+results.getValue(19));
// logger.info("#######################6:"+results.getValue(20));
// logger.info("#######################6:"+results.getValue(21));
// logger.info("#######################6:"+results.getValue(22));
// logger.info("#######################6:"+results.getValue(23));
// logger.info("#######################6:"+results.getValue(24));
// logger.info("#######################6:"+results.getValue(25));
// logger.info("#######################6:"+results.getValue(26));
// logger.info("#######################6:"+results.getValue(27));
// logger.info("#######################6:"+results.getValue(28));
// logger.info("#######################6:"+results.getValue(29));
// logger.info("#######################6:"+results.getValue(30));
// logger.info("#######################6:"+results.getValue(31));
// logger.info("#######################6:"+results.getValue(32));
// logger.info("#######################6:"+results.getValue(33));
// logger.info("#######################6:"+results.getValue(34));
// logger.info("#######################6:"+results.getValue(35));
// logger.info("#######################6:"+results.getValue(36));
// logger.info("#######################6:"+results.getValue(37));
// logger.info("#######################38:"+results.getValue(38));
String topScollerMeasurement = "zfipc_industrial_monitor_data2";
logger.info("#######################0:"+results.getValue(0)); String bottomScollerMeasurement = "zfipc_industrial_monitor_data3";
logger.info("#######################1:"+results.getValue(1)); List<IpcEquipInfo> equipList = equipInfoService.selectIpcEquipInfoList(null);
logger.info("#######################2:"+results.getValue(2)); if (equipList != null && equipList.size() > 0) {
logger.info("#######################3:"+results.getValue(3)); String bottomCylId = equipList.stream().filter(equip -> equip.getEquipName().equals("超压底缸")).collect(Collectors.toList()).get(0).getId();
logger.info("#######################4:"+results.getValue(4)); String topScollerId = equipList.stream().filter(equip -> equip.getEquipName().equals("可控中高辊顶辊")).collect(Collectors.toList()).get(0).getId();
logger.info("#######################5:"+results.getValue(5)); String bottomScollerId = equipList.stream().filter(equip -> equip.getEquipName().equals("可控中高辊底辊")).collect(Collectors.toList()).get(0).getId();
logger.info("#######################6:"+results.getValue(6)); saveRunningStatus("1");
logger.info("#######################6:"+results.getValue(7)); bottomCylinderDataProcess(results, bottomCylId, i, ipcUtil, alarmRulesService, alarmRecordService);
logger.info("#######################6:"+results.getValue(8)); topScollerDataProcess(results, topScollerId, topScollerMeasurement, i, ipcUtil, alarmRulesService, alarmRecordService);
logger.info("#######################6:"+results.getValue(9)); bottomScollerDataProcess(results, bottomScollerId, bottomScollerMeasurement, i, ipcUtil, alarmRulesService, alarmRecordService);
logger.info("#######################6:"+results.getValue(10));
logger.info("#######################6:"+results.getValue(11));
logger.info("#######################6:"+results.getValue(12));
logger.info("#######################6:"+results.getValue(13));
logger.info("#######################6:"+results.getValue(14));
logger.info("#######################6:"+results.getValue(15));
logger.info("#######################6:"+results.getValue(16));
logger.info("#######################6:"+results.getValue(17));
logger.info("#######################6:"+results.getValue(18));
logger.info("#######################19:"+results.getValue(19));
logger.info("#######################6:"+results.getValue(20));
logger.info("#######################6:"+results.getValue(21));
logger.info("#######################6:"+results.getValue(22));
logger.info("#######################6:"+results.getValue(23));
logger.info("#######################6:"+results.getValue(24));
logger.info("#######################6:"+results.getValue(25));
logger.info("#######################6:"+results.getValue(26));
logger.info("#######################6:"+results.getValue(27));
logger.info("#######################6:"+results.getValue(28));
logger.info("#######################6:"+results.getValue(29));
logger.info("#######################6:"+results.getValue(30));
logger.info("#######################6:"+results.getValue(31));
logger.info("#######################6:"+results.getValue(32));
logger.info("#######################6:"+results.getValue(33));
logger.info("#######################6:"+results.getValue(34));
logger.info("#######################6:"+results.getValue(35));
logger.info("#######################6:"+results.getValue(36));
logger.info("#######################6:"+results.getValue(37));
logger.info("#######################38:"+results.getValue(38));
// String topScollerMeasurement = "zfipc_industrial_monitor_data2";
// String bottomScollerMeasurement = "zfipc_industrial_monitor_data3";
// List<IpcEquipInfo> equipList = equipInfoService.selectIpcEquipInfoList(null);
// if (equipList != null && equipList.size() > 0) {
// String bottomCylId = equipList.stream().filter(equip -> equip.getEquipName().equals("超压底缸")).collect(Collectors.toList()).get(0).getId();
// String topScollerId = equipList.stream().filter(equip -> equip.getEquipName().equals("可控中高辊顶辊")).collect(Collectors.toList()).get(0).getId();
// String bottomScollerId = equipList.stream().filter(equip -> equip.getEquipName().equals("可控中高辊底辊")).collect(Collectors.toList()).get(0).getId();
// saveRunningStatus("1");
// bottomCylinderDataProcess(null, bottomCylId, i, ipcUtil, alarmRulesService, alarmRecordService);
// scollerDataProcess(null, topScollerId, topScollerMeasurement, i, ipcUtil, alarmRulesService, alarmRecordService);
// scollerDataProcess(null, bottomScollerId, bottomScollerMeasurement, i, ipcUtil, alarmRulesService, alarmRecordService);
//TODO 需要统一处理系统状态停机运维待机试运行正常生产 //TODO 需要统一处理系统状态停机运维待机试运行正常生产
//TODO 状态切换时候需要存储状态切换时间 //TODO 状态切换时候需要存储状态切换时间
//TODO 更新系统数据停机运维待机试运行正常生产时间 //TODO 更新系统数据停机运维待机试运行正常生产时间
// } }
} }
catch(Exception e){ catch(Exception e){
logger.error(e.getMessage()); logger.error(e.getMessage());
@ -330,7 +339,7 @@ public class IpcDataProcess implements Runnable {
*/ */
private void bottomCylinderDataProcess(BatchResults<Integer> results, String equipId, InfluxDBService i, IpcUtil ipcUtil, IIpcAlarmRulesService alarmRulesService, IIpcAlarmRecordService alarmRecordService) { private void bottomCylinderDataProcess(BatchResults<Integer> results, String equipId, InfluxDBService i, IpcUtil ipcUtil, IIpcAlarmRulesService alarmRulesService, IIpcAlarmRecordService alarmRecordService) {
String measurement = "zfipc_industrial_monitor_data1"; String measurement = "zfipc_industrial_monitor_data1";
List<IpcAlarmRecord> alarmRecordList = new ArrayList<>(); List<IpcAlarmRecord> alarmRecordList = new ArrayList<>();
@ -340,73 +349,75 @@ public class IpcDataProcess implements Runnable {
//TODO 停机运维状态数据不储存 //TODO 停机运维状态数据不储存
tags.put("status", "1");//正常运行 0停机 1正常运行 2待机 3试运行 tags.put("status", "1");//正常运行 0停机 1正常运行 2待机 3试运行
// 系统电流 // 系统电流
fields.put("sys_cur", (float) 0 + Math.random()); fields.put("sys_cur", results.getValue(0));
// 系统流量 // 系统流量
fields.put("sys_flw", (float) 0 + Math.random()); fields.put("sys_flw", results.getValue(1));
// 系统压力 // 系统压力
fields.put("sys_press", (float) 0 + Math.random()); fields.put("sys_press", results.getValue(15));
// 系统液位 // 系统液位
fields.put("sys_level", (float) 0 + Math.random()); fields.put("sys_level", results.getValue(24));
//液位最小和最大值通过报警参数设置获取 //液位最小和最大值通过报警参数设置获取
IpcAlarmRules levelRule = getLevelAlarmRule(equipId, Constant.RUNNING);//TODO 根据接收运行参数确定参数 IpcAlarmRules levelRule = getLevelAlarmRule(equipId, Constant.RUNNING);//TODO 根据接收运行参数确定参数
//正式需要放开 //正式需要放开
fields.put("level_min", levelRule == null ? 0.0 : levelRule.getAlertLowerBound().floatValue()); fields.put("level_min", levelRule == null ? (float)0.0 : levelRule.getAlertLowerBound().floatValue());
fields.put("level_max", levelRule == null ? 0.0 : levelRule.getAlertUpperBound().floatValue()); fields.put("level_max", levelRule == null ? (float)0.0 : levelRule.getAlertUpperBound().floatValue());
// 系统温度 // 系统温度
fields.put("sys_temp", (float) 0 + Math.random()); fields.put("sys_temp", results.getValue(25));
// 油液颗粒度 // 油液颗粒度
fields.put("gran4", (float) 0 + Math.random()); fields.put("gran4", results.getValue(6));
fields.put("gran6", (float) 0 + Math.random()); fields.put("gran6", results.getValue(7));
fields.put("gran14", (float) 0 + Math.random()); fields.put("gran14", results.getValue(8));
fields.put("gran21", (float) 0 + Math.random()); fields.put("gran21", results.getValue(9));
// 油水检测 // 油水检测
fields.put("oil_water", (float) 0 + Math.random()); fields.put("oil_water", results.getValue(10));
// 油品粘度 // 油品粘度
fields.put("visc", (float) 0 + Math.random()); fields.put("visc", results.getValue(11));
fields.put("visc_den", results.getValue(12));//密度
fields.put("visc_dc", results.getValue(13));//介电常数
fields.put("visc_temp", results.getValue(14));//温度
// 操作侧软辊流量 // 操作侧软辊流量
fields.put("opr_soft_flw", (float) 0 + Math.random()); fields.put("opr_soft_flw", results.getValue(4));
// 操作侧热辊流量 // 操作侧热辊流量
fields.put("opr_hot_flw", (float) 0 + Math.random()); fields.put("opr_hot_flw", results.getValue(5));
// 传动侧软辊流量 // 传动侧软辊流量
fields.put("driven_soft_flw", (float) 0 + Math.random()); fields.put("driven_soft_flw", results.getValue(2));
// 传动侧热辊流量 // 传动侧热辊流量
fields.put("driven_hot_flw", (float) 0 + Math.random()); fields.put("driven_hot_flw", results.getValue(3));
//操作侧底缸比例换向阀 //操作侧底缸比例换向阀
fields.put("opr_servo", (float) 0 + Math.random()); fields.put("opr_servo", results.getValue(16));
//传动侧比例换向阀 //传动侧比例换向阀
fields.put("driven_servo", (float) 0 + Math.random()); fields.put("driven_servo", results.getValue(17));
//操作侧底缸压力 //操作侧底缸压力
fields.put("opr_bottom_press", (float) 0 + Math.random()); fields.put("opr_bottom_press", results.getValue(18));
//传动侧底缸压力 //传动侧底缸压力
fields.put("driven_bottom_press", (float) 0 + Math.random()); fields.put("driven_bottom_press", results.getValue(19));
//操作侧底缸设定压力 //操作侧底缸设定压力
fields.put("opr_bottom_set_press", (float) 0 + Math.random()); fields.put("opr_bottom_set_press", (float)0.0);//TODO
//传动侧底缸设定压力 //传动侧底缸设定压力
fields.put("driven_bottom_set_press", (float) 0 + Math.random()); fields.put("driven_bottom_set_press", (float)0.0);//TODO
//操作侧软辊压力 //操作侧软辊压力
fields.put("opr_soft_real_press", (float) 0 + Math.random());//实际压力 fields.put("opr_soft_real_press", results.getValue(20));//实际压力
fields.put("opr_soft_bond_press", (float) 0 + Math.random());//合辊压力 fields.put("opr_soft_bond_press", (float)0.0);//TODO 合辊压力
fields.put("opr_soft_act_press", (float) 0 + Math.random());//加压压力 fields.put("opr_soft_act_press", (float)0.0);//TODO 加压压力
//操作侧热辊压力 //操作侧热辊压力
fields.put("opr_hot_real_press", (float) 0 + Math.random()); fields.put("opr_hot_real_press", results.getValue(21));
fields.put("opr_hot_bond_press", (float) 0 + Math.random()); fields.put("opr_hot_bond_press", (float)0.0);//TODO
fields.put("opr_hot_act_press", (float) 0 + Math.random()); fields.put("opr_hot_act_press", (float)0.0);//TODO
//传动侧软辊压力 //传动侧软辊压力
fields.put("driven_soft_real_press", (float) 0 + Math.random());//实际 fields.put("driven_soft_real_press", results.getValue(22));//实际
fields.put("driven_soft_bond_press", (float) 0 + Math.random());//合辊 fields.put("driven_soft_bond_press", (float)0.0);//TODO 合辊
fields.put("driven_soft_act_press", (float) 0 + Math.random());//加压 fields.put("driven_soft_act_press", (float)0.0);//TODO 加压
//传动侧热辊压力 //传动侧热辊压力
fields.put("driven_hot_real_press", (float) 0 + Math.random()); fields.put("driven_hot_real_press", results.getValue(23));
fields.put("driven_hot_bond_press", (float) 0 + Math.random()); fields.put("driven_hot_bond_press", (float) 0.0);//TODO
fields.put("driven_hot_act_press", (float) 0 + Math.random()); fields.put("driven_hot_act_press", (float) 0.0);//TODO
//操作侧底缸位移 //操作侧底缸位移
fields.put("opr_bottom_dis", (float) 0 + Math.random()); fields.put("opr_bottom_dis", results.getValue(26));
//传动侧底缸位移 //传动侧底缸位移
fields.put("driven_bottom_dis", (float) 0 + Math.random()); fields.put("driven_bottom_dis", results.getValue(27));
//报警处理 //报警处理
List<IpcAlarmRules> rulesList = alarmRulesService.selectIpcAlarmRulesConfigListByCache(equipId); List<IpcAlarmRules> rulesList = alarmRulesService.selectIpcAlarmRulesConfigListByCache(equipId);
alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields, tags, Constant.RUNNING, rulesList));//TODO 根据运行状态确定规则 alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields, tags, Constant.RUNNING, rulesList));//TODO 根据运行状态确定规则
@ -420,7 +431,7 @@ public class IpcDataProcess implements Runnable {
/** /**
* 中高顶辊 * 中高顶辊
*/ */
private void scollerDataProcess(BatchResults<Integer> results, String equipId, String measurement, InfluxDBService i, IpcUtil ipcUtil, IIpcAlarmRulesService alarmRulesService, IIpcAlarmRecordService alarmRecordService) { private void topScollerDataProcess(BatchResults<Integer> results, String equipId, String measurement, InfluxDBService i, IpcUtil ipcUtil, IIpcAlarmRulesService alarmRulesService, IIpcAlarmRecordService alarmRecordService) {
Map<String, String> tags = new TreeMap(); Map<String, String> tags = new TreeMap();
tags.put("equ_id", equipId); tags.put("equ_id", equipId);
Map<String, Object> fields = new TreeMap(); Map<String, Object> fields = new TreeMap();
@ -430,79 +441,181 @@ public class IpcDataProcess implements Runnable {
tags.put("status", "1");//正常运行 0停机 1正常运行 2待机 3试运行 tags.put("status", "1");//正常运行 0停机 1正常运行 2待机 3试运行
// 系统电流 // 系统电流
fields.put("sys_cur", (float) 0 + Math.random()); fields.put("sys_cur", results.getValue(32));
// 系统流量 // 系统流量
fields.put("sys_flw", (float) 0 + Math.random()); fields.put("sys_flw", results.getValue(33));
// 系统压力 // 系统压力
fields.put("sys_press", (float) 0 + Math.random()); fields.put("sys_press", results.getValue(42));
// 系统液位 // 系统液位
fields.put("sys_level", (float) 0 + Math.random()); fields.put("sys_level", results.getValue(40));
// fields.put("ywcsz",0.5); // fields.put("ywcsz",0.5);
// fields.put("ywmin",0.3); // fields.put("ywmin",0.3);
// fields.put("ywmax",1); // fields.put("ywmax",1);
//液位最小和最大值通过报警参数设置获取 //液位最小和最大值通过报警参数设置获取
IpcAlarmRules levelRule = getLevelAlarmRule(equipId, Constant.RUNNING);//TODO 根据接收运行参数确定参数 IpcAlarmRules levelRule = getLevelAlarmRule(equipId, Constant.RUNNING);//TODO 根据接收运行参数确定参数
//正式需要放开 //正式需要放开
fields.put("level_min", levelRule == null ? 0.0 : levelRule.getAlertLowerBound().floatValue()); fields.put("level_min", levelRule == null ? (float)0.0 : levelRule.getAlertLowerBound().floatValue());
fields.put("level_max", levelRule == null ? 0.0 : levelRule.getAlertUpperBound().floatValue()); fields.put("level_max", levelRule == null ? (float)0.0 : levelRule.getAlertUpperBound().floatValue());
// 系统温度 // 系统温度
fields.put("sys_temp", (float) 0 + Math.random()); fields.put("sys_temp", results.getValue(41));
// 油液颗粒度 // 油液颗粒度
fields.put("gran4", (float) 0 + Math.random()); fields.put("gran4", results.getValue(28));
fields.put("gran6", (float) 0 + Math.random()); fields.put("gran6", results.getValue(29));
fields.put("gran14", (float) 0 + Math.random()); fields.put("gran14", results.getValue(30));
fields.put("gran21", (float) 0 + Math.random()); fields.put("gran21", results.getValue(31));
//产线车速 //产线车速
fields.put("line_speed", (float) 0 + Math.random()); fields.put("line_speed", results.getValue(39));
// 油水检测 // 油水检测
fields.put("oil_water", (float) 0 + Math.random()); fields.put("oil_water", results.getValue(34));
// 油品粘度 // 油品粘度
fields.put("visc", (float) 0 + Math.random()); fields.put("visc", results.getValue(35));
fields.put("visc_den", results.getValue(36));//密度
fields.put("visc_dc", results.getValue(37));//介电常数
fields.put("visc_temp", results.getValue(38));//温度
// 一压区比例减压阀 // 一压区比例减压阀
fields.put("press1", (float) 0 + Math.random()); fields.put("press1", results.getValue(54));
// 二压区比例减压阀 // 二压区比例减压阀
fields.put("press2", (float) 0 + Math.random()); fields.put("press2", results.getValue(55));
// 三压区比例减压阀 // 三压区比例减压阀
fields.put("press3", (float) 0 + Math.random()); fields.put("press3", results.getValue(56));
// 四压区比例减压阀 // 四压区比例减压阀
fields.put("press4", (float) 0 + Math.random()); fields.put("press4", results.getValue(57));
// 五压区比例减乐阀 // 五压区比例减乐阀
fields.put("press5", (float) 0 + Math.random()); fields.put("press5", results.getValue(58));
// 六压区比例减压阀 // 六压区比例减压阀
fields.put("press6", (float) 0 + Math.random()); fields.put("press6", results.getValue(59));
// 七压区比例减压阀 // 七压区比例减压阀
fields.put("press7", (float) 0 + Math.random()); fields.put("press7", results.getValue(60));
// 八压区比例减压阀 // 八压区比例减压阀
fields.put("press8", (float) 0 + Math.random()); fields.put("press8", results.getValue(61));
// 九压区比例减压阀 // 九压区比例减压阀
fields.put("press9", (float) 0 + Math.random()); fields.put("press9", results.getValue(62));
// 十压区比例减乐阀 // 十压区比例减乐阀
fields.put("press10", (float) 0 + Math.random()); fields.put("press10", results.getValue(63));
// 十一压区比例减压阀 // 十一压区比例减压阀
fields.put("press11", (float) 0 + Math.random()); fields.put("press11", results.getValue(64));
// 一压区流量 // 一压区流量
fields.put("flw1", (float) 0 + Math.random()); fields.put("flw1", results.getValue(43));
// 二压区流量 // 二压区流量
fields.put("flw2", (float) 0 + Math.random()); fields.put("flw2", results.getValue(44));
// 三压区流量 // 三压区流量
fields.put("flw3", (float) 0 + Math.random()); fields.put("flw3", results.getValue(45));
// 四压区流量 // 四压区流量
fields.put("flw4", (float) 0 + Math.random()); fields.put("flw4", results.getValue(46));
// 五压区流量 // 五压区流量
fields.put("flw5", (float) 0 + Math.random()); fields.put("flw5", results.getValue(47));
// 六压区流量 // 六压区流量
fields.put("flw6", (float) 0 + Math.random()); fields.put("flw6", results.getValue(48));
// 七压区流量 // 七压区流量
fields.put("flw7", (float) 0 + Math.random()); fields.put("flw7", results.getValue(49));
// 八压区流量 // 八压区流量
fields.put("flw8", (float) 0 + Math.random()); fields.put("flw8", results.getValue(50));
// 九压区流量 // 九压区流量
fields.put("flw9", (float) 0 + Math.random()); fields.put("flw9", results.getValue(51));
// 十压区流量 // 十压区流量
fields.put("flw10", (float) 0 + Math.random()); fields.put("flw10", results.getValue(52));
// 十一压区流量 // 十一压区流量
fields.put("flw11", (float) 0 + Math.random()); fields.put("flw11", results.getValue(53));
//报警处理
List<IpcAlarmRules> rulesList = alarmRulesService.selectIpcAlarmRulesConfigListByCache(equipId);
alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields, tags, Constant.RUNNING, rulesList));//TODO 根据运行状态确定规则
if (!alarmRecordList.isEmpty()) {//运行需放开
// alarmRecordService.batchInsertIpcAlarmRecord(alarmRecordList);
}
i.insert(measurement, tags, fields);
}
/**
* 中高顶辊
*/
private void bottomScollerDataProcess(BatchResults<Integer> results, String equipId, String measurement, InfluxDBService i, IpcUtil ipcUtil, IIpcAlarmRulesService alarmRulesService, IIpcAlarmRecordService alarmRecordService) {
Map<String, String> tags = new TreeMap();
tags.put("equ_id", equipId);
Map<String, Object> fields = new TreeMap();
List<IpcAlarmRecord> alarmRecordList = new ArrayList<>();
//TODO 停机运维状态数据不储存
tags.put("status", "1");//正常运行 0停机 1正常运行 2待机 3试运行
// 系统电流
fields.put("sys_cur", results.getValue(69));
// 系统流量
fields.put("sys_flw", results.getValue(70));
// 系统压力
fields.put("sys_press", results.getValue(78));
// 系统液位
fields.put("sys_level", results.getValue(76));
// fields.put("ywcsz",0.5);
// fields.put("ywmin",0.3);
// fields.put("ywmax",1);
//液位最小和最大值通过报警参数设置获取
IpcAlarmRules levelRule = getLevelAlarmRule(equipId, Constant.RUNNING);//TODO 根据接收运行参数确定参数
//正式需要放开
fields.put("level_min", levelRule == null ? (float)0.0 : levelRule.getAlertLowerBound().floatValue());
fields.put("level_max", levelRule == null ? (float)0.0 : levelRule.getAlertUpperBound().floatValue());
// 系统温度
fields.put("sys_temp", results.getValue(77));
// 油液颗粒度
fields.put("gran4", results.getValue(65));
fields.put("gran6", results.getValue(66));
fields.put("gran14", results.getValue(67));
fields.put("gran21", results.getValue(68));
//产线车速
fields.put("line_speed", results.getValue(39));
// 油水检测
fields.put("oil_water", results.getValue(71));
// 油品粘度
fields.put("visc", results.getValue(72));
fields.put("visc_den", results.getValue(73));//密度
fields.put("visc_dc", results.getValue(74));//介电常数
fields.put("visc_temp", results.getValue(75));//温度
// 一压区比例减压阀
fields.put("press1", results.getValue(90));
// 二压区比例减压阀
fields.put("press2", results.getValue(91));
// 三压区比例减压阀
fields.put("press3", results.getValue(92));
// 四压区比例减压阀
fields.put("press4", results.getValue(93));
// 五压区比例减乐阀
fields.put("press5", results.getValue(94));
// 六压区比例减压阀
fields.put("press6", results.getValue(95));
// 七压区比例减压阀
fields.put("press7", results.getValue(96));
// 八压区比例减压阀
fields.put("press8", results.getValue(97));
// 九压区比例减压阀
fields.put("press9", results.getValue(98));
// 十压区比例减乐阀
fields.put("press10", results.getValue(99));
// 十一压区比例减压阀
fields.put("press11", results.getValue(100));
// 一压区流量
fields.put("flw1", results.getValue(79));
// 二压区流量
fields.put("flw2", results.getValue(80));
// 三压区流量
fields.put("flw3", results.getValue(81));
// 四压区流量
fields.put("flw4", results.getValue(82));
// 五压区流量
fields.put("flw5", results.getValue(83));
// 六压区流量
fields.put("flw6", results.getValue(84));
// 七压区流量
fields.put("flw7", results.getValue(85));
// 八压区流量
fields.put("flw8", results.getValue(86));
// 九压区流量
fields.put("flw9", results.getValue(87));
// 十压区流量
fields.put("flw10", results.getValue(88));
// 十一压区流量
fields.put("flw11", results.getValue(89));
//报警处理 //报警处理
List<IpcAlarmRules> rulesList = alarmRulesService.selectIpcAlarmRulesConfigListByCache(equipId); List<IpcAlarmRules> rulesList = alarmRulesService.selectIpcAlarmRulesConfigListByCache(equipId);

View File

@ -134,7 +134,7 @@ public class IpcAlarmRulesServiceImpl implements IIpcAlarmRulesService
int num = ipcAlarmRulesMapper.updateIpcAlarmRules(ipcAlarmRules); int num = ipcAlarmRulesMapper.updateIpcAlarmRules(ipcAlarmRules);
if (num > 0){ if (num > 0){
List<IpcAlarmRules> rules = selectIpcAlarmRulesByEquipId(ipcAlarmRules.getEquipId()); List<IpcAlarmRules> rules = selectIpcAlarmRulesByEquipId(ipcAlarmRules.getEquipId());
redisCache.setCacheObject(CacheConstants.IPC_RULES_KEY + ipcAlarmRules.getEquipId(),rules); redisCache.setCacheList(CacheConstants.IPC_RULES_KEY + ipcAlarmRules.getEquipId(),rules);
} }
return num; return num;
} }

View File

@ -79,7 +79,7 @@ public class IpcUtil {
ipcAlarmRecord.setEquipId(rule.getEquipId()); ipcAlarmRecord.setEquipId(rule.getEquipId());
ipcAlarmRecord.setSensorId(rule.getSensorId()); ipcAlarmRecord.setSensorId(rule.getSensorId());
String name = rule.getAlarmNameKey(); String name = rule.getAlarmNameKey();
double value = (double) map.get(name); float value = (float)map.get(name);
ipcAlarmRecord.setAlarmValue(BigDecimal.valueOf(value)); ipcAlarmRecord.setAlarmValue(BigDecimal.valueOf(value));
ipcAlarmRecord.setNameKey(name); ipcAlarmRecord.setNameKey(name);
ipcAlarmRecord.setContent(type == 0 ? "(开机监测)" + rule.getReferenceName() : rule.getReferenceName()); ipcAlarmRecord.setContent(type == 0 ? "(开机监测)" + rule.getReferenceName() : rule.getReferenceName());