根据设备状态显示
This commit is contained in:
parent
f33a9612f4
commit
564b0af8ab
@ -149,7 +149,7 @@ public class IPCData2SyncThread implements Runnable {
|
||||
// 十一压区比例减压阀
|
||||
fields.put("press11",(float) 0 + Math.random());
|
||||
// 一压区流量
|
||||
fields.put("pre",(float) 0 + Math.random());
|
||||
fields.put("flw1",(float) 0 + Math.random());
|
||||
// 二压区流量
|
||||
fields.put("flw2",(float) 0 + Math.random());
|
||||
// 三压区流量
|
||||
|
@ -1,9 +1,22 @@
|
||||
package com.inspur.datasyn.modbus;
|
||||
|
||||
import com.inspur.common.utils.spring.SpringUtils;
|
||||
import com.inspur.equip.domain.IpcEquipInfo;
|
||||
import com.inspur.equip.service.IIpcEquipInfoService;
|
||||
import com.inspur.industrial.domain.IpcAlarmRecord;
|
||||
import com.inspur.industrial.domain.IpcAlarmRules;
|
||||
import com.inspur.industrial.service.IIpcAlarmRecordService;
|
||||
import com.inspur.industrial.service.IIpcAlarmRulesService;
|
||||
import com.inspur.industrial.utils.Constant;
|
||||
import com.inspur.industrial.utils.IpcUtil;
|
||||
import com.inspur.system.service.influx.InfluxDBService;
|
||||
import com.serotonin.modbus4j.BatchRead;
|
||||
import com.serotonin.modbus4j.BatchResults;
|
||||
import com.serotonin.modbus4j.ModbusFactory;
|
||||
import com.serotonin.modbus4j.ModbusMaster;
|
||||
import com.serotonin.modbus4j.code.DataType;
|
||||
import com.serotonin.modbus4j.ip.IpParameters;
|
||||
import com.serotonin.modbus4j.locator.BaseLocator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -15,9 +28,8 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component()
|
||||
@Order(value = 1)
|
||||
@ -28,8 +40,8 @@ public class IPCDataSyncTask implements ApplicationRunner {
|
||||
@Autowired
|
||||
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
||||
|
||||
// @Autowired
|
||||
// private IIpcAlarmRulesService ipcAlarmRulesService;
|
||||
@Autowired
|
||||
private IIpcEquipInfoService equipInfoService;
|
||||
|
||||
@Value("${datasyn.modbus.host}")
|
||||
private String host;
|
||||
@ -39,9 +51,10 @@ public class IPCDataSyncTask implements ApplicationRunner {
|
||||
private String model;
|
||||
|
||||
/**
|
||||
* 工厂。
|
||||
* 工厂
|
||||
*/
|
||||
static ModbusFactory modbusFactory;
|
||||
|
||||
static {
|
||||
if (modbusFactory == null) {
|
||||
modbusFactory = new ModbusFactory();
|
||||
@ -50,38 +63,294 @@ public class IPCDataSyncTask implements ApplicationRunner {
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
if("client".equals(model)){
|
||||
/*IpParameters params = new IpParameters();
|
||||
params.setHost(host);
|
||||
params.setPort(Integer.parseInt(port));
|
||||
ModbusMaster master = modbusFactory.createTcpMaster(params, true);// TCP 协议
|
||||
master.init();*/
|
||||
if ("client".equals(model)) {
|
||||
// IpParameters params = new IpParameters();
|
||||
// params.setHost(host);
|
||||
// params.setPort(Integer.parseInt(port));
|
||||
// ModbusMaster master = modbusFactory.createTcpMaster(params, true);// TCP 协议
|
||||
// master.init();
|
||||
|
||||
final Timer timer1 = new Timer();
|
||||
timer1.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
threadPoolTaskExecutor.execute(new IPCDataSyncThread(null,new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS").format(new Date())));
|
||||
threadPoolTaskExecutor.execute(new IpcDataProcess(null));
|
||||
}
|
||||
},1000,1000);
|
||||
|
||||
final Timer timer2 = new Timer();
|
||||
timer2.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
threadPoolTaskExecutor.execute(new IPCData2SyncThread(null,new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS").format(new Date())));
|
||||
}
|
||||
},1000,1000);
|
||||
|
||||
final Timer timer3 = new Timer();
|
||||
timer3.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
threadPoolTaskExecutor.execute(new IPCData3SyncThread(null,new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS").format(new Date())));
|
||||
}
|
||||
},1000,1000);
|
||||
}, 1000, 1000);
|
||||
//
|
||||
// final Timer timer2 = new Timer();
|
||||
// timer2.schedule(new TimerTask() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// threadPoolTaskExecutor.execute(new IPCData2SyncThread(null, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS").format(new Date())));
|
||||
// }
|
||||
// }, 1000, 1000);
|
||||
//
|
||||
// final Timer timer3 = new Timer();
|
||||
// timer3.schedule(new TimerTask() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// threadPoolTaskExecutor.execute(new IPCData3SyncThread(null, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS").format(new Date())));
|
||||
// }
|
||||
// }, 1000, 1000);
|
||||
|
||||
// ipcAlarmRulesService.tran();
|
||||
|
||||
// dataProcess(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void dataProcess(ModbusMaster master) {
|
||||
|
||||
InfluxDBService i = SpringUtils.getBean(InfluxDBService.class);
|
||||
IpcUtil ipcUtil = SpringUtils.getBean(IpcUtil.class);
|
||||
IIpcAlarmRulesService alarmRulesService = SpringUtils.getBean(IIpcAlarmRulesService.class);
|
||||
IIpcAlarmRecordService alarmRecordService = SpringUtils.getBean(IIpcAlarmRecordService.class);
|
||||
|
||||
|
||||
// 1.modbus接收数据
|
||||
try {
|
||||
// BatchRead<Integer> batch = new BatchRead<Integer>();
|
||||
//
|
||||
// batch.addLocator(0, BaseLocator.holdingRegister(1, 0, 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, 4, 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, 8, 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));// 速度传感器,float
|
||||
// batch.addLocator(7, BaseLocator.holdingRegister(1, 14, DataType.FOUR_BYTE_FLOAT_SWAPPED));// X1轴位置传感器一,float
|
||||
// batch.addLocator(8, BaseLocator.holdingRegister(1, 16, DataType.FOUR_BYTE_FLOAT_SWAPPED));// X2轴位置传感器二,float
|
||||
// batch.addLocator(9, BaseLocator.holdingRegister(1, 18, DataType.FOUR_BYTE_FLOAT_SWAPPED));// Y1轴位置传感器三,float
|
||||
// batch.addLocator(10, BaseLocator.holdingRegister(1, 20, DataType.FOUR_BYTE_FLOAT_SWAPPED));// Y2轴位置传感器四,float
|
||||
// batch.addLocator(11, BaseLocator.holdingRegister(1, 22, DataType.FOUR_BYTE_FLOAT_SWAPPED));// Z轴位置传感器五,float
|
||||
// batch.addLocator(12, BaseLocator.holdingRegister(1, 24, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 油液密度,float
|
||||
// batch.addLocator(13, BaseLocator.holdingRegister(1, 26, DataType.TWO_BYTE_INT_UNSIGNED));// 颗粒度4um,int
|
||||
// batch.addLocator(14, BaseLocator.holdingRegister(1, 27, DataType.TWO_BYTE_INT_UNSIGNED));// 颗粒度6um,int
|
||||
// batch.addLocator(15, BaseLocator.holdingRegister(1, 28, DataType.TWO_BYTE_INT_UNSIGNED));// 颗粒度14um,int
|
||||
// batch.addLocator(16, BaseLocator.holdingRegister(1, 29, DataType.TWO_BYTE_INT_UNSIGNED));// 颗粒度21um,int
|
||||
// batch.setContiguousRequests(false);
|
||||
// BatchResults<Integer> results = master.send(batch);
|
||||
|
||||
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();
|
||||
|
||||
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 更新系统数据,停机运维、待机、试运行、正常生产时间
|
||||
}
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 底缸数据存储
|
||||
*/
|
||||
private void bottomCylinderDataProcess(BatchResults<Integer> results, String equipId, InfluxDBService i, IpcUtil ipcUtil, IIpcAlarmRulesService alarmRulesService, IIpcAlarmRecordService alarmRecordService) {
|
||||
|
||||
String measurement = "zfipc_industrial_monitor_data1";
|
||||
|
||||
List<IpcAlarmRecord> alarmRecordList = new ArrayList<>();
|
||||
|
||||
Map<String, String> tags = new TreeMap();
|
||||
tags.put("equ_id", equipId);
|
||||
Map<String, Object> fields = new TreeMap();
|
||||
|
||||
// 系统电流
|
||||
fields.put("sys_cur", (float) 0 + Math.random());
|
||||
// 系统流量
|
||||
fields.put("sys_flw", (float) 0 + Math.random());
|
||||
// 系统压力
|
||||
fields.put("sys_press", (float) 0 + Math.random());
|
||||
// 系统液位
|
||||
fields.put("sys_level", (float) 0 + Math.random());
|
||||
|
||||
//液位最小和最大值通过报警参数设置获取
|
||||
IpcAlarmRules levelRule = getLevelAlarmRule(equipId);
|
||||
//正式需要放开
|
||||
fields.put("level_min", levelRule == null ? 0.0 : levelRule.getAlertLowerBound().floatValue());
|
||||
fields.put("level_max", levelRule == null ? 0.0 : levelRule.getAlertUpperBound().floatValue());
|
||||
|
||||
// 系统温度
|
||||
fields.put("sys_temp", (float) 0 + Math.random());
|
||||
// 油液颗粒度
|
||||
fields.put("gran4", (float) 0 + Math.random());
|
||||
fields.put("gran6", (float) 0 + Math.random());
|
||||
fields.put("gran14", (float) 0 + Math.random());
|
||||
fields.put("gran21", (float) 0 + Math.random());
|
||||
// 油水检测
|
||||
fields.put("oil_water", (float) 0 + Math.random());
|
||||
// 油品粘度
|
||||
fields.put("visc", (float) 0 + Math.random());
|
||||
// 操作侧软辊流量
|
||||
fields.put("opr_soft_flw", (float) 0 + Math.random());
|
||||
// 操作侧热辊流量
|
||||
fields.put("opr_hot_flw", (float) 0 + Math.random());
|
||||
// 传动侧软辊流量
|
||||
fields.put("driven_soft_flw", (float) 0 + Math.random());
|
||||
// 传动侧热辊流量
|
||||
fields.put("driven_hot_flw", (float) 0 + Math.random());
|
||||
//操作侧底缸比例换向阀
|
||||
fields.put("opr_servo", (float) 0 + Math.random());
|
||||
//传动侧比例换向阀
|
||||
fields.put("driven_servo", (float) 0 + Math.random());
|
||||
//操作侧底缸压力
|
||||
fields.put("opr_bottom_press", (float) 0 + Math.random());
|
||||
//传动侧底缸压力
|
||||
fields.put("driven_bottom_press", (float) 0 + Math.random());
|
||||
//操作侧底缸设定压力
|
||||
fields.put("opr_bottom_set_press", (float) 0 + Math.random());
|
||||
//传动侧底缸设定压力
|
||||
fields.put("driven_bottom_set_press", (float) 0 + Math.random());
|
||||
//操作侧软辊压力
|
||||
fields.put("opr_soft_real_press", (float) 0 + Math.random());//实际压力
|
||||
fields.put("opr_soft_bond_press", (float) 0 + Math.random());//合辊压力
|
||||
fields.put("opr_soft_act_press", (float) 0 + Math.random());//加压压力
|
||||
//操作侧热辊压力
|
||||
fields.put("opr_hot_real_press", (float) 0 + Math.random());
|
||||
fields.put("opr_hot_bond_press", (float) 0 + Math.random());
|
||||
fields.put("opr_hot_act_press", (float) 0 + Math.random());
|
||||
//传动侧软辊压力
|
||||
fields.put("driven_soft_real_press", (float) 0 + Math.random());//实际
|
||||
fields.put("driven_soft_bond_press", (float) 0 + Math.random());//合辊
|
||||
fields.put("driven_soft_act_press", (float) 0 + Math.random());//加压
|
||||
//传动侧热辊压力
|
||||
fields.put("driven_hot_real_press", (float) 0 + Math.random());
|
||||
fields.put("driven_hot_bond_press", (float) 0 + Math.random());
|
||||
fields.put("driven_hot_act_press", (float) 0 + Math.random());
|
||||
//操作侧底缸位移
|
||||
fields.put("opr_bottom_dis", (float) 0 + Math.random());
|
||||
//传动侧底缸位移
|
||||
fields.put("driven_bottom_dis", (float) 0 + Math.random());
|
||||
//报警处理
|
||||
List<IpcAlarmRules> rulesList = alarmRulesService.selectIpcAlarmRulesByEquipId(equipId);
|
||||
alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields, tags, Constant.RUNNING, rulesList));
|
||||
i.insert(measurement, tags, fields);
|
||||
|
||||
if (!alarmRecordList.isEmpty()) {//运行需放开
|
||||
// alarmRecordService.batchInsertIpcAlarmRecord(alarmRecordList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 中高顶辊
|
||||
*/
|
||||
private void scollerDataProcess(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<>();
|
||||
|
||||
// 系统电流
|
||||
fields.put("sys_cur", (float) 0 + Math.random());
|
||||
// 系统流量
|
||||
fields.put("sys_flw", (float) 0 + Math.random());
|
||||
// 系统压力
|
||||
fields.put("sys_press", (float) 0 + Math.random());
|
||||
// 系统液位
|
||||
fields.put("sys_level", (float) 0 + Math.random());
|
||||
// fields.put("ywcsz",0.5);
|
||||
// fields.put("ywmin",0.3);
|
||||
// fields.put("ywmax",1);
|
||||
//液位最小和最大值通过报警参数设置获取
|
||||
IpcAlarmRules levelRule = getLevelAlarmRule(equipId);
|
||||
//正式需要放开
|
||||
fields.put("level_min", levelRule == null ? 0.0 : levelRule.getAlertLowerBound().floatValue());
|
||||
fields.put("level_max", levelRule == null ? 0.0 : levelRule.getAlertUpperBound().floatValue());
|
||||
|
||||
// 系统温度
|
||||
fields.put("sys_temp", (float) 0 + Math.random());
|
||||
// 油液颗粒度
|
||||
fields.put("gran4", (float) 0 + Math.random());
|
||||
fields.put("gran6", (float) 0 + Math.random());
|
||||
fields.put("gran14", (float) 0 + Math.random());
|
||||
fields.put("gran21", (float) 0 + Math.random());
|
||||
//产线车速
|
||||
fields.put("line_speed", (float) 0 + Math.random());
|
||||
// 油水检测
|
||||
fields.put("oil_water", (float) 0 + Math.random());
|
||||
// 油品粘度
|
||||
fields.put("visc", (float) 0 + Math.random());
|
||||
// 一压区比例减压阀
|
||||
fields.put("press1", (float) 0 + Math.random());
|
||||
// 二压区比例减压阀
|
||||
fields.put("press2", (float) 0 + Math.random());
|
||||
// 三压区比例减压阀
|
||||
fields.put("press3", (float) 0 + Math.random());
|
||||
// 四压区比例减压阀
|
||||
fields.put("press4", (float) 0 + Math.random());
|
||||
// 五压区比例减乐阀
|
||||
fields.put("press5", (float) 0 + Math.random());
|
||||
// 六压区比例减压阀
|
||||
fields.put("press6", (float) 0 + Math.random());
|
||||
// 七压区比例减压阀
|
||||
fields.put("press7", (float) 0 + Math.random());
|
||||
// 八压区比例减压阀
|
||||
fields.put("press8", (float) 0 + Math.random());
|
||||
// 九压区比例减压阀
|
||||
fields.put("press9", (float) 0 + Math.random());
|
||||
// 十压区比例减乐阀
|
||||
fields.put("press10", (float) 0 + Math.random());
|
||||
// 十一压区比例减压阀
|
||||
fields.put("press11", (float) 0 + Math.random());
|
||||
// 一压区流量
|
||||
fields.put("flw1", (float) 0 + Math.random());
|
||||
// 二压区流量
|
||||
fields.put("flw2", (float) 0 + Math.random());
|
||||
// 三压区流量
|
||||
fields.put("flw3", (float) 0 + Math.random());
|
||||
// 四压区流量
|
||||
fields.put("flw4", (float) 0 + Math.random());
|
||||
// 五压区流量
|
||||
fields.put("flw5", (float) 0 + Math.random());
|
||||
// 六压区流量
|
||||
fields.put("flw6", (float) 0 + Math.random());
|
||||
// 七压区流量
|
||||
fields.put("flw7", (float) 0 + Math.random());
|
||||
// 八压区流量
|
||||
fields.put("flw8", (float) 0 + Math.random());
|
||||
// 九压区流量
|
||||
fields.put("flw9", (float) 0 + Math.random());
|
||||
// 十压区流量
|
||||
fields.put("flw10", (float) 0 + Math.random());
|
||||
// 十一压区流量
|
||||
fields.put("flw11", (float) 0 + Math.random());
|
||||
|
||||
//报警处理
|
||||
List<IpcAlarmRules> rulesList = alarmRulesService.selectIpcAlarmRulesByEquipId(equipId);
|
||||
alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields, tags, Constant.RUNNING, rulesList));
|
||||
if (!alarmRecordList.isEmpty()) {//运行需放开
|
||||
// alarmRecordService.batchInsertIpcAlarmRecord(alarmRecordList);
|
||||
}
|
||||
i.insert(measurement, tags, fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取液位的报警规则
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private IpcAlarmRules getLevelAlarmRule(String equipId) {
|
||||
IIpcAlarmRulesService ipcAlarmRulesService = SpringUtils.getBean(IIpcAlarmRulesService.class);
|
||||
IpcAlarmRules query = new IpcAlarmRules();
|
||||
query.setEquipId(equipId);
|
||||
query.setAlarmNameKey("sys_level");
|
||||
query.setType(Constant.RUNNING);//运行中
|
||||
return ipcAlarmRulesService.selectIpcAlarmRulesList(query).get(0) == null ? null : ipcAlarmRulesService.selectIpcAlarmRulesList(query).get(0);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,301 @@
|
||||
package com.inspur.datasyn.modbus;
|
||||
|
||||
import com.inspur.common.utils.spring.SpringUtils;
|
||||
import com.inspur.equip.domain.IpcEquipInfo;
|
||||
import com.inspur.equip.service.IIpcEquipInfoService;
|
||||
import com.inspur.industrial.domain.IpcAlarmRecord;
|
||||
import com.inspur.industrial.domain.IpcAlarmRules;
|
||||
import com.inspur.industrial.service.IIpcAlarmRecordService;
|
||||
import com.inspur.industrial.service.IIpcAlarmRulesService;
|
||||
import com.inspur.industrial.utils.Constant;
|
||||
import com.inspur.industrial.utils.IpcUtil;
|
||||
import com.inspur.system.service.influx.InfluxDBService;
|
||||
import com.serotonin.modbus4j.BatchResults;
|
||||
import com.serotonin.modbus4j.ModbusMaster;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 数据处理接口
|
||||
* @Author zhangjunwen
|
||||
* @create 2024/4/15
|
||||
*/
|
||||
public class IpcDataProcess implements Runnable {
|
||||
|
||||
private ModbusMaster master;
|
||||
|
||||
public IpcDataProcess(ModbusMaster master) {
|
||||
this.master = master;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
dataProcess();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void dataProcess() {
|
||||
|
||||
InfluxDBService i = SpringUtils.getBean(InfluxDBService.class);
|
||||
IpcUtil ipcUtil = SpringUtils.getBean(IpcUtil.class);
|
||||
IIpcAlarmRulesService alarmRulesService = SpringUtils.getBean(IIpcAlarmRulesService.class);
|
||||
IIpcAlarmRecordService alarmRecordService = SpringUtils.getBean(IIpcAlarmRecordService.class);
|
||||
IIpcEquipInfoService equipInfoService = SpringUtils.getBean(IIpcEquipInfoService.class);
|
||||
|
||||
// 1.modbus接收数据
|
||||
try {
|
||||
// BatchRead<Integer> batch = new BatchRead<Integer>();
|
||||
//
|
||||
// batch.addLocator(0, BaseLocator.holdingRegister(1, 0, 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, 4, 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, 8, 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));// 速度传感器,float
|
||||
// batch.addLocator(7, BaseLocator.holdingRegister(1, 14, DataType.FOUR_BYTE_FLOAT_SWAPPED));// X1轴位置传感器一,float
|
||||
// batch.addLocator(8, BaseLocator.holdingRegister(1, 16, DataType.FOUR_BYTE_FLOAT_SWAPPED));// X2轴位置传感器二,float
|
||||
// batch.addLocator(9, BaseLocator.holdingRegister(1, 18, DataType.FOUR_BYTE_FLOAT_SWAPPED));// Y1轴位置传感器三,float
|
||||
// batch.addLocator(10, BaseLocator.holdingRegister(1, 20, DataType.FOUR_BYTE_FLOAT_SWAPPED));// Y2轴位置传感器四,float
|
||||
// batch.addLocator(11, BaseLocator.holdingRegister(1, 22, DataType.FOUR_BYTE_FLOAT_SWAPPED));// Z轴位置传感器五,float
|
||||
// batch.addLocator(12, BaseLocator.holdingRegister(1, 24, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 油液密度,float
|
||||
// batch.addLocator(13, BaseLocator.holdingRegister(1, 26, DataType.TWO_BYTE_INT_UNSIGNED));// 颗粒度4um,int
|
||||
// batch.addLocator(14, BaseLocator.holdingRegister(1, 27, DataType.TWO_BYTE_INT_UNSIGNED));// 颗粒度6um,int
|
||||
// batch.addLocator(15, BaseLocator.holdingRegister(1, 28, DataType.TWO_BYTE_INT_UNSIGNED));// 颗粒度14um,int
|
||||
// batch.addLocator(16, BaseLocator.holdingRegister(1, 29, DataType.TWO_BYTE_INT_UNSIGNED));// 颗粒度21um,int
|
||||
// batch.setContiguousRequests(false);
|
||||
// BatchResults<Integer> results = master.send(batch);
|
||||
|
||||
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();
|
||||
|
||||
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 更新系统数据,停机运维、待机、试运行、正常生产时间
|
||||
}
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 底缸数据存储
|
||||
*/
|
||||
private void bottomCylinderDataProcess(BatchResults<Integer> results, String equipId, InfluxDBService i, IpcUtil ipcUtil, IIpcAlarmRulesService alarmRulesService, IIpcAlarmRecordService alarmRecordService) {
|
||||
|
||||
String measurement = "zfipc_industrial_monitor_data1";
|
||||
|
||||
List<IpcAlarmRecord> alarmRecordList = new ArrayList<>();
|
||||
|
||||
Map<String, String> tags = new TreeMap();
|
||||
tags.put("equ_id", equipId);
|
||||
Map<String, Object> fields = new TreeMap();
|
||||
|
||||
//TODO 停机运维状态数据不储存
|
||||
|
||||
tags.put("status", "1");//正常运行 0:停机 1:正常运行 2:待机 3:试运行
|
||||
|
||||
// 系统电流
|
||||
fields.put("sys_cur", (float) 0 + Math.random());
|
||||
// 系统流量
|
||||
fields.put("sys_flw", (float) 0 + Math.random());
|
||||
// 系统压力
|
||||
fields.put("sys_press", (float) 0 + Math.random());
|
||||
// 系统液位
|
||||
fields.put("sys_level", (float) 0 + Math.random());
|
||||
|
||||
//液位最小和最大值通过报警参数设置获取
|
||||
IpcAlarmRules levelRule = getLevelAlarmRule(equipId);
|
||||
//正式需要放开
|
||||
fields.put("level_min", levelRule == null ? 0.0 : levelRule.getAlertLowerBound().floatValue());
|
||||
fields.put("level_max", levelRule == null ? 0.0 : levelRule.getAlertUpperBound().floatValue());
|
||||
|
||||
// 系统温度
|
||||
fields.put("sys_temp", (float) 0 + Math.random());
|
||||
// 油液颗粒度
|
||||
fields.put("gran4", (float) 0 + Math.random());
|
||||
fields.put("gran6", (float) 0 + Math.random());
|
||||
fields.put("gran14", (float) 0 + Math.random());
|
||||
fields.put("gran21", (float) 0 + Math.random());
|
||||
// 油水检测
|
||||
fields.put("oil_water", (float) 0 + Math.random());
|
||||
// 油品粘度
|
||||
fields.put("visc", (float) 0 + Math.random());
|
||||
// 操作侧软辊流量
|
||||
fields.put("opr_soft_flw", (float) 0 + Math.random());
|
||||
// 操作侧热辊流量
|
||||
fields.put("opr_hot_flw", (float) 0 + Math.random());
|
||||
// 传动侧软辊流量
|
||||
fields.put("driven_soft_flw", (float) 0 + Math.random());
|
||||
// 传动侧热辊流量
|
||||
fields.put("driven_hot_flw", (float) 0 + Math.random());
|
||||
//操作侧底缸比例换向阀
|
||||
fields.put("opr_servo", (float) 0 + Math.random());
|
||||
//传动侧比例换向阀
|
||||
fields.put("driven_servo", (float) 0 + Math.random());
|
||||
//操作侧底缸压力
|
||||
fields.put("opr_bottom_press", (float) 0 + Math.random());
|
||||
//传动侧底缸压力
|
||||
fields.put("driven_bottom_press", (float) 0 + Math.random());
|
||||
//操作侧底缸设定压力
|
||||
fields.put("opr_bottom_set_press", (float) 0 + Math.random());
|
||||
//传动侧底缸设定压力
|
||||
fields.put("driven_bottom_set_press", (float) 0 + Math.random());
|
||||
//操作侧软辊压力
|
||||
fields.put("opr_soft_real_press", (float) 0 + Math.random());//实际压力
|
||||
fields.put("opr_soft_bond_press", (float) 0 + Math.random());//合辊压力
|
||||
fields.put("opr_soft_act_press", (float) 0 + Math.random());//加压压力
|
||||
//操作侧热辊压力
|
||||
fields.put("opr_hot_real_press", (float) 0 + Math.random());
|
||||
fields.put("opr_hot_bond_press", (float) 0 + Math.random());
|
||||
fields.put("opr_hot_act_press", (float) 0 + Math.random());
|
||||
//传动侧软辊压力
|
||||
fields.put("driven_soft_real_press", (float) 0 + Math.random());//实际
|
||||
fields.put("driven_soft_bond_press", (float) 0 + Math.random());//合辊
|
||||
fields.put("driven_soft_act_press", (float) 0 + Math.random());//加压
|
||||
//传动侧热辊压力
|
||||
fields.put("driven_hot_real_press", (float) 0 + Math.random());
|
||||
fields.put("driven_hot_bond_press", (float) 0 + Math.random());
|
||||
fields.put("driven_hot_act_press", (float) 0 + Math.random());
|
||||
//操作侧底缸位移
|
||||
fields.put("opr_bottom_dis", (float) 0 + Math.random());
|
||||
//传动侧底缸位移
|
||||
fields.put("driven_bottom_dis", (float) 0 + Math.random());
|
||||
//报警处理
|
||||
List<IpcAlarmRules> rulesList = alarmRulesService.selectIpcAlarmRulesByEquipId(equipId);
|
||||
alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields, tags, Constant.RUNNING, rulesList));
|
||||
i.insert(measurement, tags, fields);
|
||||
|
||||
if (!alarmRecordList.isEmpty()) {//运行需放开
|
||||
// alarmRecordService.batchInsertIpcAlarmRecord(alarmRecordList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 中高顶辊
|
||||
*/
|
||||
private void scollerDataProcess(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<>();
|
||||
|
||||
// 系统电流
|
||||
fields.put("sys_cur", (float) 0 + Math.random());
|
||||
// 系统流量
|
||||
fields.put("sys_flw", (float) 0 + Math.random());
|
||||
// 系统压力
|
||||
fields.put("sys_press", (float) 0 + Math.random());
|
||||
// 系统液位
|
||||
fields.put("sys_level", (float) 0 + Math.random());
|
||||
// fields.put("ywcsz",0.5);
|
||||
// fields.put("ywmin",0.3);
|
||||
// fields.put("ywmax",1);
|
||||
//液位最小和最大值通过报警参数设置获取
|
||||
IpcAlarmRules levelRule = getLevelAlarmRule(equipId);
|
||||
//正式需要放开
|
||||
fields.put("level_min", levelRule == null ? 0.0 : levelRule.getAlertLowerBound().floatValue());
|
||||
fields.put("level_max", levelRule == null ? 0.0 : levelRule.getAlertUpperBound().floatValue());
|
||||
|
||||
// 系统温度
|
||||
fields.put("sys_temp", (float) 0 + Math.random());
|
||||
// 油液颗粒度
|
||||
fields.put("gran4", (float) 0 + Math.random());
|
||||
fields.put("gran6", (float) 0 + Math.random());
|
||||
fields.put("gran14", (float) 0 + Math.random());
|
||||
fields.put("gran21", (float) 0 + Math.random());
|
||||
//产线车速
|
||||
fields.put("line_speed", (float) 0 + Math.random());
|
||||
// 油水检测
|
||||
fields.put("oil_water", (float) 0 + Math.random());
|
||||
// 油品粘度
|
||||
fields.put("visc", (float) 0 + Math.random());
|
||||
// 一压区比例减压阀
|
||||
fields.put("press1", (float) 0 + Math.random());
|
||||
// 二压区比例减压阀
|
||||
fields.put("press2", (float) 0 + Math.random());
|
||||
// 三压区比例减压阀
|
||||
fields.put("press3", (float) 0 + Math.random());
|
||||
// 四压区比例减压阀
|
||||
fields.put("press4", (float) 0 + Math.random());
|
||||
// 五压区比例减乐阀
|
||||
fields.put("press5", (float) 0 + Math.random());
|
||||
// 六压区比例减压阀
|
||||
fields.put("press6", (float) 0 + Math.random());
|
||||
// 七压区比例减压阀
|
||||
fields.put("press7", (float) 0 + Math.random());
|
||||
// 八压区比例减压阀
|
||||
fields.put("press8", (float) 0 + Math.random());
|
||||
// 九压区比例减压阀
|
||||
fields.put("press9", (float) 0 + Math.random());
|
||||
// 十压区比例减乐阀
|
||||
fields.put("press10", (float) 0 + Math.random());
|
||||
// 十一压区比例减压阀
|
||||
fields.put("press11", (float) 0 + Math.random());
|
||||
// 一压区流量
|
||||
fields.put("flw1", (float) 0 + Math.random());
|
||||
// 二压区流量
|
||||
fields.put("flw2", (float) 0 + Math.random());
|
||||
// 三压区流量
|
||||
fields.put("flw3", (float) 0 + Math.random());
|
||||
// 四压区流量
|
||||
fields.put("flw4", (float) 0 + Math.random());
|
||||
// 五压区流量
|
||||
fields.put("flw5", (float) 0 + Math.random());
|
||||
// 六压区流量
|
||||
fields.put("flw6", (float) 0 + Math.random());
|
||||
// 七压区流量
|
||||
fields.put("flw7", (float) 0 + Math.random());
|
||||
// 八压区流量
|
||||
fields.put("flw8", (float) 0 + Math.random());
|
||||
// 九压区流量
|
||||
fields.put("flw9", (float) 0 + Math.random());
|
||||
// 十压区流量
|
||||
fields.put("flw10", (float) 0 + Math.random());
|
||||
// 十一压区流量
|
||||
fields.put("flw11", (float) 0 + Math.random());
|
||||
|
||||
//报警处理
|
||||
List<IpcAlarmRules> rulesList = alarmRulesService.selectIpcAlarmRulesByEquipId(equipId);
|
||||
alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields, tags, Constant.RUNNING, rulesList));
|
||||
if (!alarmRecordList.isEmpty()) {//运行需放开
|
||||
// alarmRecordService.batchInsertIpcAlarmRecord(alarmRecordList);
|
||||
}
|
||||
i.insert(measurement, tags, fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取液位的报警规则
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private IpcAlarmRules getLevelAlarmRule(String equipId) {
|
||||
IIpcAlarmRulesService ipcAlarmRulesService = SpringUtils.getBean(IIpcAlarmRulesService.class);
|
||||
IpcAlarmRules query = new IpcAlarmRules();
|
||||
query.setEquipId(equipId);
|
||||
query.setAlarmNameKey("sys_level");
|
||||
query.setType(Constant.RUNNING);//运行中
|
||||
return ipcAlarmRulesService.selectIpcAlarmRulesList(query).get(0) == null ? null : ipcAlarmRulesService.selectIpcAlarmRulesList(query).get(0);
|
||||
}
|
||||
}
|
@ -17,6 +17,12 @@ public class IpcData {
|
||||
*/
|
||||
private String time;
|
||||
|
||||
/**
|
||||
* 系统状态
|
||||
*/
|
||||
@Excel(name = "系统状态", readConverterExp="0=停机维护,1=正常运行,2=待机,3=试运行")
|
||||
private String status;
|
||||
|
||||
@Excel(name = "系统流量")
|
||||
/**
|
||||
* 系统流量
|
||||
|
@ -43,6 +43,7 @@ public class DataQueryService implements IDataQueryService {
|
||||
return null;
|
||||
}
|
||||
Map<String, Object> resMap = new HashMap<>();
|
||||
resMap.put("sysstatus", list.get(0).get("status"));//系统状态
|
||||
resMap.put("sysflw", list.get(0).get("sys_flw"));//系统流量
|
||||
resMap.put("sysprs", list.get(0).get("sys_press"));//系统压力
|
||||
resMap.put("syslevel", list.get(0).get("sys_level"));//系统液位
|
||||
@ -264,6 +265,7 @@ public class DataQueryService implements IDataQueryService {
|
||||
list.forEach(data -> {
|
||||
BottomCylData ipcData = new BottomCylData();
|
||||
ipcData.setTime(InfluxdbTimeUtil.utcToCst(data.get("time").toString()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
ipcData.setStatus(data.get("status") == null ? "0" : (String) data.get("status"));
|
||||
ipcData.setSysCur(data.get("sys_cur") == null ? 0 : (double) data.get("sys_cur"));
|
||||
ipcData.setSysLevel(data.get("sys_level") == null ? 0 : (double) data.get("sys_level"));
|
||||
ipcData.setSysTemp(data.get("sys_temp") == null ? 0 : (double) data.get("sys_temp"));
|
||||
@ -535,6 +537,7 @@ public class DataQueryService implements IDataQueryService {
|
||||
list.forEach(data -> {
|
||||
ScollerData ipcData = new ScollerData();
|
||||
ipcData.setTime(InfluxdbTimeUtil.utcToCst(data.get("time").toString()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
ipcData.setStatus(data.get("status") == null ? "0" : (String) data.get("status"));
|
||||
ipcData.setSysCur(data.get("sys_cur") == null ? 0 : (double) data.get("sys_cur"));
|
||||
ipcData.setSysLevel(data.get("sys_level") == null ? 0 : (double) data.get("sys_level"));
|
||||
ipcData.setSysTemp(data.get("sys_temp") == null ? 0 : (double) data.get("sys_temp"));
|
||||
|
@ -79,6 +79,19 @@
|
||||
width="200"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column
|
||||
label="运行状态"
|
||||
align="center"
|
||||
prop="status"
|
||||
:show-overflow-tooltip="true"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<dict-tag
|
||||
:options="dict.type.equip_status"
|
||||
:value="scope.row.status"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="主电机电流(A)"
|
||||
align="center"
|
||||
@ -349,6 +362,19 @@
|
||||
width="200"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column
|
||||
label="运行状态"
|
||||
align="center"
|
||||
prop="status"
|
||||
:show-overflow-tooltip="true"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<dict-tag
|
||||
:options="dict.type.equip_status"
|
||||
:value="scope.row.status"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="主电机电流(A)"
|
||||
align="center"
|
||||
@ -625,6 +651,19 @@
|
||||
width="200"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column
|
||||
label="运行状态"
|
||||
align="center"
|
||||
prop="status"
|
||||
:show-overflow-tooltip="true"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<dict-tag
|
||||
:options="dict.type.equip_status"
|
||||
:value="scope.row.status"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="主电机电流(A)"
|
||||
align="center"
|
||||
@ -851,6 +890,7 @@ import {
|
||||
} from "@/api/data/query.js";
|
||||
export default {
|
||||
name: "dataLog",
|
||||
dicts: ["equip_status"],
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
|
Loading…
Reference in New Issue
Block a user