传感器数据接收接口
This commit is contained in:
parent
d66484f149
commit
9beb7275ba
@ -2,6 +2,8 @@ package com.inspur.web.controller.ipc;
|
|||||||
|
|
||||||
import com.inspur.common.core.domain.AjaxResult;
|
import com.inspur.common.core.domain.AjaxResult;
|
||||||
import com.inspur.common.core.redis.RedisCache;
|
import com.inspur.common.core.redis.RedisCache;
|
||||||
|
import com.inspur.ipc.domain.IpcBg4gszhp01tempdata;
|
||||||
|
import com.inspur.ipc.service.IIpcDataReceiveService;
|
||||||
import com.inspur.ipc.service.IIpcMonitorFieldService;
|
import com.inspur.ipc.service.IIpcMonitorFieldService;
|
||||||
import com.inspur.ipc.utils.IpcConstant;
|
import com.inspur.ipc.utils.IpcConstant;
|
||||||
import com.serotonin.modbus4j.BatchRead;
|
import com.serotonin.modbus4j.BatchRead;
|
||||||
@ -35,7 +37,8 @@ public class IpcDataReceiveController {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IIpcMonitorFieldService iIpcMonitorFieldService;
|
private IIpcMonitorFieldService iIpcMonitorFieldService;
|
||||||
|
@Autowired
|
||||||
|
private IIpcDataReceiveService iIpcDataReceiveService;
|
||||||
/**
|
/**
|
||||||
* 工厂。
|
* 工厂。
|
||||||
*/
|
*/
|
||||||
@ -51,39 +54,39 @@ public class IpcDataReceiveController {
|
|||||||
* 接收PLC数据
|
* 接收PLC数据
|
||||||
*/
|
*/
|
||||||
@PostMapping("/plcData")
|
@PostMapping("/plcData")
|
||||||
public AjaxResult plcData(@RequestBody Map<String, List<String>> map) throws ModbusInitException, ModbusTransportException, ErrorResponseException {
|
public AjaxResult plcData(@RequestBody Map<String, Object> map) throws ModbusInitException, ModbusTransportException, ErrorResponseException {
|
||||||
// 如果是工控机端,接收plc数据;如果是云端,接收传感器数据
|
// 如果是工控机端,接收plc数据;如果是云端,接收传感器数据
|
||||||
if (model.equals(IpcConstant.MODEL_CLIENT)) {
|
if (model.equals(IpcConstant.MODEL_CLIENT)) {
|
||||||
// {
|
// {
|
||||||
// "children":["123","222"]
|
// "children":["123","222"]
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
IpParameters params = new IpParameters();
|
// IpParameters params = new IpParameters();
|
||||||
params.setHost("");
|
// params.setHost("");
|
||||||
params.setPort(Integer.parseInt(""));
|
// params.setPort(Integer.parseInt(""));
|
||||||
ModbusMaster master = modbusFactory.createTcpMaster(params, true);// TCP 协议
|
// ModbusMaster master = modbusFactory.createTcpMaster(params, true);// TCP 协议
|
||||||
master.init();
|
// master.init();
|
||||||
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, 2, 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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.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);
|
||||||
System.out.println(results);
|
// System.out.println(results);
|
||||||
return AjaxResult.success(1);
|
return AjaxResult.success(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,12 +94,7 @@ public class IpcDataReceiveController {
|
|||||||
* 接收温振传感器数据
|
* 接收温振传感器数据
|
||||||
*/
|
*/
|
||||||
@PostMapping("/sensorData")
|
@PostMapping("/sensorData")
|
||||||
public AjaxResult sensorData(@RequestBody Map<String, List<String>> map) {
|
public AjaxResult sensorData(@RequestBody IpcBg4gszhp01tempdata ipcBg4gszhp01tempdata) {
|
||||||
// 如果是工控机端,接收plc数据;如果是云端,接收传感器数据
|
return AjaxResult.success(iIpcDataReceiveService.dealSensorData(ipcBg4gszhp01tempdata));
|
||||||
if (model.equals(IpcConstant.MODEL_CLOUD)) {
|
|
||||||
|
|
||||||
}
|
|
||||||
System.out.println(map.toString());
|
|
||||||
return AjaxResult.success(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,11 +74,30 @@ public class CacheConstants
|
|||||||
/**
|
/**
|
||||||
* 运行状态
|
* 运行状态
|
||||||
*/
|
*/
|
||||||
public static final String RUNNING_STATUS = "running_status:";
|
public static final String RUNNING_STATUS = "running_status";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ipc前缀
|
* ipc前缀
|
||||||
*/
|
*/
|
||||||
public static final String IPC_PREFIX = "ipc:";
|
public static final String IPC_PREFIX = "ipc:";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 传感器数据缓存
|
||||||
|
*/
|
||||||
|
public static final String SENSOR_DATA_CACHE = "sensor_data:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通道号X
|
||||||
|
*/
|
||||||
|
public static final String SENSOR_CHN_X = "X";
|
||||||
|
/**
|
||||||
|
* 通道号Y
|
||||||
|
*/
|
||||||
|
public static final String SENSOR_CHN_Y = "Y";
|
||||||
|
/**
|
||||||
|
* 通道号Z
|
||||||
|
*/
|
||||||
|
public static final String SENSOR_CHN_Z = "Z";
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ public class IPCDataSyncTask implements ApplicationRunner {
|
|||||||
public void run() {
|
public void run() {
|
||||||
threadPoolTaskExecutor.execute(new IPCSensorDataSyncThread(null, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS").format(new Date())));
|
threadPoolTaskExecutor.execute(new IPCSensorDataSyncThread(null, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS").format(new Date())));
|
||||||
}
|
}
|
||||||
}, 1000, 1000*60);
|
}, 1000, 1000*60*10);
|
||||||
|
|
||||||
final Timer timer3 = new Timer();
|
final Timer timer3 = new Timer();
|
||||||
timer3.schedule(new TimerTask() {
|
timer3.schedule(new TimerTask() {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.inspur.datasyn.modbus;
|
package com.inspur.datasyn.modbus;
|
||||||
|
|
||||||
import com.inspur.common.constant.CacheConstants;
|
import com.inspur.common.constant.CacheConstants;
|
||||||
|
import com.inspur.common.core.redis.RedisCache;
|
||||||
import com.inspur.common.utils.StringUtils;
|
import com.inspur.common.utils.StringUtils;
|
||||||
import com.inspur.common.utils.spring.SpringUtils;
|
import com.inspur.common.utils.spring.SpringUtils;
|
||||||
import com.inspur.ipc.domain.IpcAlarmRecord;
|
import com.inspur.ipc.domain.IpcAlarmRecord;
|
||||||
@ -46,7 +47,6 @@ public class IPCPlcDataSyncThread implements Runnable {
|
|||||||
IIpcAlarmRulesConfigService iIpcAlarmRulesConfigService = SpringUtils.getBean(IIpcAlarmRulesConfigService.class);
|
IIpcAlarmRulesConfigService iIpcAlarmRulesConfigService = SpringUtils.getBean(IIpcAlarmRulesConfigService.class);
|
||||||
InfluxDBService i = SpringUtils.getBean(InfluxDBService.class);
|
InfluxDBService i = SpringUtils.getBean(InfluxDBService.class);
|
||||||
IIpcRunningStatusRecordService iIpcRunningStatusRecordService = SpringUtils.getBean(IIpcRunningStatusRecordService.class);
|
IIpcRunningStatusRecordService iIpcRunningStatusRecordService = SpringUtils.getBean(IIpcRunningStatusRecordService.class);
|
||||||
|
|
||||||
/* 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, 2, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 进油油液温度,float
|
batch.addLocator(1, BaseLocator.holdingRegister(1, 2, DataType.FOUR_BYTE_FLOAT_SWAPPED));// 进油油液温度,float
|
||||||
@ -69,12 +69,15 @@ public class IPCPlcDataSyncThread implements Runnable {
|
|||||||
BatchResults<Integer> results = master.send(batch);*/
|
BatchResults<Integer> results = master.send(batch);*/
|
||||||
// 获取运行状态,不一致则新增运行状态
|
// 获取运行状态,不一致则新增运行状态
|
||||||
String status = iIpcRunningStatusRecordService.selectLatestStatus();
|
String status = iIpcRunningStatusRecordService.selectLatestStatus();
|
||||||
if(StringUtils.isNull(status) || !status.equals("4")){
|
String sss = iIpcRunningStatusRecordService.getSSS();
|
||||||
status="4";
|
if(sss==null){sss="4";}
|
||||||
|
if (StringUtils.isNull(status) || !status.equals(sss)) {
|
||||||
|
status = sss;
|
||||||
iIpcRunningStatusRecordService.insertIpcRunningStatusRecord(new IpcRunningStatusRecord(status));
|
iIpcRunningStatusRecordService.insertIpcRunningStatusRecord(new IpcRunningStatusRecord(status));
|
||||||
|
System.out.println("状态更新"+status);
|
||||||
}
|
}
|
||||||
// 如果不是停机数据,进行处理
|
// 如果不是停机数据,进行处理
|
||||||
if(!IpcConstant.RUNNING_STATUS_SHUTDOWN.equals(status)) {
|
if (!IpcConstant.RUNNING_STATUS_SHUTDOWN.equals(status)) {
|
||||||
// 温压数据
|
// 温压数据
|
||||||
List<IpcMonitorField> partList = iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.MONITOR_PART_KEY);
|
List<IpcMonitorField> partList = iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.MONITOR_PART_KEY);
|
||||||
List<IpcMonitorField> plcList = iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.PLC_MONITOR_PARAMS_KEY);
|
List<IpcMonitorField> plcList = iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.PLC_MONITOR_PARAMS_KEY);
|
||||||
@ -87,8 +90,12 @@ public class IPCPlcDataSyncThread implements Runnable {
|
|||||||
for (IpcMonitorField field : plcList) {
|
for (IpcMonitorField field : plcList) {
|
||||||
// 可以配置源字段,获取时通过源字段获取数据
|
// 可以配置源字段,获取时通过源字段获取数据
|
||||||
// field.getSourceField()
|
// field.getSourceField()
|
||||||
|
if(field.getFieldValue().equals("rstatus")){
|
||||||
|
fields.put(field.getFieldValue(), status);
|
||||||
|
}else{
|
||||||
fields.put(field.getFieldValue(), Math.random());
|
fields.put(field.getFieldValue(), Math.random());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// //颗粒度4μm
|
// //颗粒度4μm
|
||||||
// fields.put("pz4", (float) 0 + Math.random());
|
// fields.put("pz4", (float) 0 + Math.random());
|
||||||
// //颗粒度6μm
|
// //颗粒度6μm
|
||||||
@ -103,30 +110,24 @@ public class IPCPlcDataSyncThread implements Runnable {
|
|||||||
// fields.put("ov", (float) 0 + Math.random());
|
// fields.put("ov", (float) 0 + Math.random());
|
||||||
// //回油温度
|
// //回油温度
|
||||||
// fields.put("rot", (float) 0 + Math.random());
|
// fields.put("rot", (float) 0 + Math.random());
|
||||||
// //轴套区温度
|
|
||||||
// fields.put("ssat", (float) 0 + Math.random());
|
|
||||||
// //进油压力
|
// //进油压力
|
||||||
// fields.put("oip", (float) 0 + Math.random());
|
// fields.put("oip", (float) 0 + Math.random());
|
||||||
// //振动温度
|
// //油液密度
|
||||||
// fields.put("ssat", (float) 0 + Math.random());
|
// fields.put("od", (float) 0 + Math.random());
|
||||||
// //振动x轴
|
// // 运行状态
|
||||||
// fields.put("vx", (float) 0 + Math.random());
|
// fields.put("rstatus", (float) 0 + Math.random());
|
||||||
// //振动y轴
|
|
||||||
// fields.put("vy", (float) 0 + Math.random());
|
|
||||||
// //振动z轴
|
|
||||||
// fields.put("vz", (float) 0 + Math.random());
|
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
|
||||||
String format = simpleDateFormat.format(new Date());
|
String format = simpleDateFormat.format(new Date());
|
||||||
fields.put("insertTime", format);
|
fields.put("insertTime", format);
|
||||||
// 根据运行状态获取规则
|
// 根据运行状态获取规则
|
||||||
List<IpcAlarmRulesConfig> rulesConfigList = iIpcAlarmRulesConfigService.selectIpcAlarmRulesConfigList(tags.get("part"));
|
List<IpcAlarmRulesConfig> rulesConfigList = iIpcAlarmRulesConfigService.selectIpcAlarmRulesConfigList(tags.get("part"));
|
||||||
if(IpcConstant.RUNNING_STATUS_RUNNING.equals(status)){
|
if (IpcConstant.RUNNING_STATUS_RUNNING.equals(status)) {
|
||||||
rulesConfigList = rulesConfigList.stream().filter(ipcAlarmRulesConfig -> ipcAlarmRulesConfig.getType().equals(IpcConstant.RULE_TYPE_IN_RUNNING)).collect(Collectors.toList());
|
rulesConfigList = rulesConfigList.stream().filter(ipcAlarmRulesConfig -> ipcAlarmRulesConfig.getType().equals(IpcConstant.RULE_TYPE_IN_RUNNING)).collect(Collectors.toList());
|
||||||
}else{
|
} else {
|
||||||
rulesConfigList = rulesConfigList.stream().filter(ipcAlarmRulesConfig -> ipcAlarmRulesConfig.getType().equals(IpcConstant.RULE_TYPE_TRIAL_RUN)).collect(Collectors.toList());
|
rulesConfigList = rulesConfigList.stream().filter(ipcAlarmRulesConfig -> ipcAlarmRulesConfig.getType().equals(IpcConstant.RULE_TYPE_TRIAL_RUN)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
// 根据报警规则校验
|
// 根据报警规则校验
|
||||||
alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields, tags, CacheConstants.PLC_MONITOR_PARAMS_KEY, rulesConfigList));
|
alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields, tags, rulesConfigList));
|
||||||
i.insert(IpcConstant.PLC_MEASUREMENT, tags, fields);
|
i.insert(IpcConstant.PLC_MEASUREMENT, tags, fields);
|
||||||
}
|
}
|
||||||
// 批量保存报警数据
|
// 批量保存报警数据
|
||||||
|
@ -51,9 +51,9 @@ public class IPCSensorDataSyncThread implements Runnable {
|
|||||||
for (IpcMonitorField field : sensorList) {
|
for (IpcMonitorField field : sensorList) {
|
||||||
// 可以配置源字段,获取时通过源字段获取数据
|
// 可以配置源字段,获取时通过源字段获取数据
|
||||||
// field.getSourceField()
|
// field.getSourceField()
|
||||||
if (field.getFieldValue().equals("stime")) {
|
if(field.getFieldValue().equals("ssat")) {
|
||||||
fields.put(field.getFieldValue(), getDate());
|
fields.put(field.getFieldValue(), Math.random()+"");
|
||||||
} else {
|
}else{
|
||||||
fields.put(field.getFieldValue(), getData());
|
fields.put(field.getFieldValue(), getData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,162 @@
|
|||||||
|
package com.inspur.ipc.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.inspur.common.annotation.Excel;
|
||||||
|
import com.inspur.common.core.domain.BaseEntity;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BG-4G-SZHP01传感器临时数据对象 phm_bg4gszhp01tempdata
|
||||||
|
*
|
||||||
|
* @author inspur
|
||||||
|
* @date 2024-01-09
|
||||||
|
*/
|
||||||
|
public class IpcBg4gszhp01tempdata extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 主键 */
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/** 传感器唯一标识 */
|
||||||
|
@Excel(name = "传感器唯一标识")
|
||||||
|
@JsonProperty(value="DevID")
|
||||||
|
private String devID;
|
||||||
|
|
||||||
|
/** 通道号 */
|
||||||
|
@Excel(name = "通道号")
|
||||||
|
@JsonProperty(value="Chn")
|
||||||
|
private String Chn;
|
||||||
|
|
||||||
|
/** 电池电量 */
|
||||||
|
@Excel(name = "电池电量")
|
||||||
|
@JsonProperty(value="Bat")
|
||||||
|
private String Bat;
|
||||||
|
|
||||||
|
/** 频率 */
|
||||||
|
@Excel(name = "频率")
|
||||||
|
@JsonProperty(value="Fre")
|
||||||
|
private String Fre;
|
||||||
|
|
||||||
|
/** 温度 */
|
||||||
|
@Excel(name = "温度")
|
||||||
|
@JsonProperty(value="Temp")
|
||||||
|
private String Temp;
|
||||||
|
|
||||||
|
/** 包数 */
|
||||||
|
@Excel(name = "包数")
|
||||||
|
@JsonProperty(value="PakNum")
|
||||||
|
private Integer PakNum;
|
||||||
|
|
||||||
|
/** 包总数 */
|
||||||
|
@Excel(name = "包总数")
|
||||||
|
@JsonProperty(value="PakCount")
|
||||||
|
private Integer PakCount;
|
||||||
|
|
||||||
|
/** 包长度 */
|
||||||
|
@Excel(name = "包长度")
|
||||||
|
@JsonProperty(value="PakLength")
|
||||||
|
private Integer PakLength;
|
||||||
|
|
||||||
|
/** 源数据 */
|
||||||
|
@Excel(name = "源数据")
|
||||||
|
@JsonProperty(value="WData")
|
||||||
|
private String WData;
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDevID() {
|
||||||
|
return devID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDevID(String devID) {
|
||||||
|
this.devID = devID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChn() {
|
||||||
|
return Chn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChn(String chn) {
|
||||||
|
Chn = chn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBat() {
|
||||||
|
return Bat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBat(String bat) {
|
||||||
|
Bat = bat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFre() {
|
||||||
|
return Fre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFre(String fre) {
|
||||||
|
Fre = fre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTemp() {
|
||||||
|
return Temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTemp(String temp) {
|
||||||
|
Temp = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPakNum() {
|
||||||
|
return PakNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPakNum(Integer pakNum) {
|
||||||
|
PakNum = pakNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPakCount() {
|
||||||
|
return PakCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPakCount(Integer pakCount) {
|
||||||
|
PakCount = pakCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPakLength() {
|
||||||
|
return PakLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPakLength(Integer pakLength) {
|
||||||
|
PakLength = pakLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWData() {
|
||||||
|
return WData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWData(String WData) {
|
||||||
|
this.WData = WData;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "IpcBg4gszhp01tempdata{" +
|
||||||
|
"id=" + id +
|
||||||
|
", devID='" + devID + '\'' +
|
||||||
|
", Chn='" + Chn + '\'' +
|
||||||
|
", Bat='" + Bat + '\'' +
|
||||||
|
", Fre='" + Fre + '\'' +
|
||||||
|
", Temp='" + Temp + '\'' +
|
||||||
|
", PakNum=" + PakNum +
|
||||||
|
", PakCount=" + PakCount +
|
||||||
|
", PakLength=" + PakLength +
|
||||||
|
", WData='" + WData + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.inspur.ipc.service;
|
||||||
|
|
||||||
|
import com.inspur.ipc.domain.IpcBg4gszhp01tempdata;
|
||||||
|
|
||||||
|
public interface IIpcDataReceiveService {
|
||||||
|
/**
|
||||||
|
* 振动数据处理
|
||||||
|
*/
|
||||||
|
String dealSensorData(IpcBg4gszhp01tempdata ipcBg4gszhp01tempdata);
|
||||||
|
}
|
@ -65,4 +65,5 @@ public interface IIpcRunningStatusRecordService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
String selectLatestStatus();
|
String selectLatestStatus();
|
||||||
|
String getSSS();
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ public class IpcAlarmRulesConfigServiceImpl implements IIpcAlarmRulesConfigServi
|
|||||||
List<IpcAlarmRulesConfig> list = ipcAlarmRulesConfigMapper.selectIpcAlarmRulesConfigList(new IpcAlarmRulesConfig());
|
List<IpcAlarmRulesConfig> list = ipcAlarmRulesConfigMapper.selectIpcAlarmRulesConfigList(new IpcAlarmRulesConfig());
|
||||||
for (IpcMonitorField field : partList) {
|
for (IpcMonitorField field : partList) {
|
||||||
List<IpcAlarmRulesConfig> redisList = list.stream().filter(ipcAlarmRulesConfig -> ipcAlarmRulesConfig.getPartKey().equals(field.getFieldValue())).collect(Collectors.toList());
|
List<IpcAlarmRulesConfig> redisList = list.stream().filter(ipcAlarmRulesConfig -> ipcAlarmRulesConfig.getPartKey().equals(field.getFieldValue())).collect(Collectors.toList());
|
||||||
redisCache.setCacheObject(CacheConstants.IPC_PREFIX+CacheConstants.RULE_CONFIG + field.getFieldValue(), redisList,CacheConstants.IPC_EXPIRATION_TIME, TimeUnit.HOURS);
|
redisCache.setCacheObject(CacheConstants.IPC_PREFIX+CacheConstants.RULE_CONFIG + field.getFieldValue(), redisList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,6 @@ public class IpcDataLogServiceImpl implements IIpcDataLogService {
|
|||||||
sql += " and time <= '" + endTime + "'";
|
sql += " and time <= '" + endTime + "'";
|
||||||
}
|
}
|
||||||
sql += " order by time desc limit " + pageSize + " offset " + (pageNum - 1) * pageSize;
|
sql += " order by time desc limit " + pageSize + " offset " + (pageNum - 1) * pageSize;
|
||||||
System.out.println(sql);
|
|
||||||
return influxDBService.queryResultProcess(influxDBService.query(sql));
|
return influxDBService.queryResultProcess(influxDBService.query(sql));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +164,6 @@ public class IpcDataLogServiceImpl implements IIpcDataLogService {
|
|||||||
sql += " and time <= '" + endTime + "'";
|
sql += " and time <= '" + endTime + "'";
|
||||||
}
|
}
|
||||||
List<Map<String, Object>> list = influxDBService.queryResultProcess(influxDBService.query(sql));
|
List<Map<String, Object>> list = influxDBService.queryResultProcess(influxDBService.query(sql));
|
||||||
System.out.println(sql);
|
|
||||||
return list.size() == 0 ? 0 : ((Double) list.get(0).get("count")).intValue();
|
return list.size() == 0 ? 0 : ((Double) list.get(0).get("count")).intValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,99 @@
|
|||||||
|
package com.inspur.ipc.service.impl;
|
||||||
|
|
||||||
|
import com.inspur.common.constant.CacheConstants;
|
||||||
|
import com.inspur.common.core.redis.RedisCache;
|
||||||
|
import com.inspur.common.utils.spring.SpringUtils;
|
||||||
|
import com.inspur.ipc.domain.IpcBg4gszhp01tempdata;
|
||||||
|
import com.inspur.ipc.domain.IpcMonitorField;
|
||||||
|
import com.inspur.ipc.service.IIpcDataReceiveService;
|
||||||
|
import com.inspur.ipc.service.IIpcMonitorFieldService;
|
||||||
|
import com.inspur.ipc.utils.IpcConstant;
|
||||||
|
import com.inspur.system.service.influx.InfluxDBService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class IpcDataReceiveServiceImpl implements IIpcDataReceiveService {
|
||||||
|
@Autowired
|
||||||
|
private IIpcMonitorFieldService iIpcMonitorFieldService;
|
||||||
|
@Autowired
|
||||||
|
private InfluxDBService influxDBService;
|
||||||
|
@Autowired
|
||||||
|
private RedisCache redisCache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 振动数据处理
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String dealSensorData(IpcBg4gszhp01tempdata ipcBg4gszhp01tempdata) {
|
||||||
|
// 获取设备列表
|
||||||
|
List<IpcMonitorField> fieldList = iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.MONITOR_PART_KEY);
|
||||||
|
// 判断设备id是否存在,不存在则返回error
|
||||||
|
Optional<IpcMonitorField> ipcMonitorField = fieldList.stream().filter(field -> field.getSourceField().equals(ipcBg4gszhp01tempdata.getDevID())).findAny();
|
||||||
|
if (!ipcMonitorField.isPresent()) {
|
||||||
|
return "error";
|
||||||
|
}
|
||||||
|
// 将数据保存到缓存中,过期时间1分钟
|
||||||
|
String keyPrefix = CacheConstants.IPC_PREFIX + CacheConstants.SENSOR_DATA_CACHE + ipcMonitorField.get().getFieldValue() + CacheConstants.REDIS_KEY_SEPARATOR;
|
||||||
|
switch (ipcBg4gszhp01tempdata.getChn()) {
|
||||||
|
case CacheConstants.SENSOR_CHN_X:
|
||||||
|
redisCache.setCacheObject(keyPrefix + CacheConstants.SENSOR_CHN_X, ipcBg4gszhp01tempdata, CacheConstants.IPC_EXPIRATION_TIME, TimeUnit.MINUTES);
|
||||||
|
break;
|
||||||
|
case CacheConstants.SENSOR_CHN_Y:
|
||||||
|
redisCache.setCacheObject(keyPrefix + CacheConstants.SENSOR_CHN_Y, ipcBg4gszhp01tempdata, CacheConstants.IPC_EXPIRATION_TIME, TimeUnit.MINUTES);
|
||||||
|
break;
|
||||||
|
case CacheConstants.SENSOR_CHN_Z:
|
||||||
|
redisCache.setCacheObject(keyPrefix + CacheConstants.SENSOR_CHN_Z, ipcBg4gszhp01tempdata, CacheConstants.IPC_EXPIRATION_TIME, TimeUnit.MINUTES);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// 通道号不存在则返回error
|
||||||
|
return "error";
|
||||||
|
}
|
||||||
|
CompletableFuture<String> result = CompletableFuture.supplyAsync(() -> saveData(keyPrefix, ipcMonitorField.get().getFieldValue()));
|
||||||
|
try {
|
||||||
|
return result.get();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return "error";
|
||||||
|
} catch (ExecutionException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return "error";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String saveData(String keyPrefix, String part) {
|
||||||
|
try {
|
||||||
|
// 通道号X,Y,Z均已传输
|
||||||
|
if (redisCache.getCacheObject(keyPrefix + CacheConstants.SENSOR_CHN_X) != null && redisCache.getCacheObject(keyPrefix + CacheConstants.SENSOR_CHN_Y) != null && redisCache.getCacheObject(keyPrefix + CacheConstants.SENSOR_CHN_Z) != null) {
|
||||||
|
IpcBg4gszhp01tempdata ipcBg4gszhp01tempdataX = redisCache.getCacheObject(keyPrefix + CacheConstants.SENSOR_CHN_X);
|
||||||
|
IpcBg4gszhp01tempdata ipcBg4gszhp01tempdataY = redisCache.getCacheObject(keyPrefix + CacheConstants.SENSOR_CHN_Y);
|
||||||
|
IpcBg4gszhp01tempdata ipcBg4gszhp01tempdataZ = redisCache.getCacheObject(keyPrefix + CacheConstants.SENSOR_CHN_Z);
|
||||||
|
|
||||||
|
Map<String, String> tags = new TreeMap();
|
||||||
|
tags.put("part", part);
|
||||||
|
Map<String, Object> fields = new TreeMap();
|
||||||
|
fields.put("ssat", ipcBg4gszhp01tempdataX.getTemp());
|
||||||
|
fields.put("vx", ipcBg4gszhp01tempdataX.getWData());
|
||||||
|
fields.put("vy", ipcBg4gszhp01tempdataY.getWData());
|
||||||
|
fields.put("vz", ipcBg4gszhp01tempdataZ.getWData());
|
||||||
|
|
||||||
|
// 获取当前时间
|
||||||
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
|
||||||
|
String format = simpleDateFormat.format(new Date());
|
||||||
|
fields.put("insertTime", format);
|
||||||
|
influxDBService.insert(IpcConstant.SENSOR_MEASUREMENT, tags, fields);
|
||||||
|
redisCache.deleteObject(Arrays.asList(new String[]{keyPrefix + CacheConstants.SENSOR_CHN_X, keyPrefix + CacheConstants.SENSOR_CHN_Y, keyPrefix + CacheConstants.SENSOR_CHN_Z}));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return "error";
|
||||||
|
}
|
||||||
|
return "success";
|
||||||
|
}
|
||||||
|
}
|
@ -31,19 +31,20 @@ public class IpcDataShowServiceImpl implements IIpcDataShowService {
|
|||||||
private InfluxDBService influxDBService;
|
private InfluxDBService influxDBService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IIpcAlarmRecordService ipcAlarmRecordService;
|
private IIpcAlarmRecordService ipcAlarmRecordService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 展示数据获取
|
* 展示数据获取
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getShowData(String[] parts) {
|
public Map<String, Object> getShowData(String[] parts) {
|
||||||
Map<String, Object> dataMap = new HashMap<>();
|
Map<String, Object> dataMap = new HashMap<>();
|
||||||
CompletableFuture<Map<String, Map<String,Object>>> plcDataMap = CompletableFuture.supplyAsync(() -> dealPlcData(parts));
|
CompletableFuture<Map<String, Map<String, Object>>> plcDataMap = CompletableFuture.supplyAsync(() -> dealPlcData(parts));
|
||||||
CompletableFuture<Map<String, Map<String,Object>>> sensorDataMap = CompletableFuture.supplyAsync(() -> dealSensorData(parts));
|
CompletableFuture<Map<String, Map<String, Object>>> sensorDataMap = CompletableFuture.supplyAsync(() -> dealSensorData(parts));
|
||||||
try {
|
try {
|
||||||
plcDataMap.get().get(IpcConstant.OPERATION_NAME).putAll(sensorDataMap.get().get(IpcConstant.OPERATION_NAME));
|
plcDataMap.get().get(IpcConstant.OPERATION_NAME).putAll(sensorDataMap.get().get(IpcConstant.OPERATION_NAME));
|
||||||
plcDataMap.get().get(IpcConstant.DRIVE_NAME).putAll(sensorDataMap.get().get(IpcConstant.DRIVE_NAME));
|
plcDataMap.get().get(IpcConstant.DRIVE_NAME).putAll(sensorDataMap.get().get(IpcConstant.DRIVE_NAME));
|
||||||
dataMap.put(IpcConstant.OPERATION_NAME,plcDataMap.get().get(IpcConstant.OPERATION_NAME));
|
dataMap.put(IpcConstant.OPERATION_NAME, plcDataMap.get().get(IpcConstant.OPERATION_NAME));
|
||||||
dataMap.put(IpcConstant.DRIVE_NAME,plcDataMap.get().get(IpcConstant.DRIVE_NAME));
|
dataMap.put(IpcConstant.DRIVE_NAME, plcDataMap.get().get(IpcConstant.DRIVE_NAME));
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
@ -54,11 +55,12 @@ public class IpcDataShowServiceImpl implements IIpcDataShowService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* plc数据处理
|
* plc数据处理
|
||||||
|
*
|
||||||
* @param parts
|
* @param parts
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Map<String,Map<String,Object>> dealPlcData(String[] parts){
|
private Map<String, Map<String, Object>> dealPlcData(String[] parts) {
|
||||||
Map<String, Map<String,Object>> dataMap = new HashMap<>();
|
Map<String, Map<String, Object>> dataMap = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
for (String part : parts) {
|
for (String part : parts) {
|
||||||
// 数据获取
|
// 数据获取
|
||||||
@ -97,7 +99,7 @@ public class IpcDataShowServiceImpl implements IIpcDataShowService {
|
|||||||
oip.add(plcObj.get("oip") == null ? 0 : plcObj.get("oip"));
|
oip.add(plcObj.get("oip") == null ? 0 : plcObj.get("oip"));
|
||||||
od.add(plcObj.get("od") == null ? 0 : plcObj.get("od"));
|
od.add(plcObj.get("od") == null ? 0 : plcObj.get("od"));
|
||||||
if (plcObj.containsKey("insertTime") && null != plcObj.get("insertTime")) {
|
if (plcObj.containsKey("insertTime") && null != plcObj.get("insertTime")) {
|
||||||
xPlcData.add(this.dateTimeDeal(plcObj.get("insertTime"),"minute"));
|
xPlcData.add(this.dateTimeDeal(plcObj.get("insertTime"), "minute"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
@ -120,9 +122,9 @@ public class IpcDataShowServiceImpl implements IIpcDataShowService {
|
|||||||
ipcAlarmRecord.setAlarmStatus("0");
|
ipcAlarmRecord.setAlarmStatus("0");
|
||||||
List<IpcAlarmRecord> list = ipcAlarmRecordService.selectIpcAlarmRecordList(ipcAlarmRecord);
|
List<IpcAlarmRecord> list = ipcAlarmRecordService.selectIpcAlarmRecordList(ipcAlarmRecord);
|
||||||
// 颗粒度报警
|
// 颗粒度报警
|
||||||
map.put("pzAlarmStr", String.join(IpcConstant.DATA_SEPARATOR,list.stream().filter(ipcAlarmRecord1 -> ipcAlarmRecord1.getNameKey().startsWith("pz")).map(IpcAlarmRecord::getAlarmDetail).collect(Collectors.toList())));
|
map.put("pzAlarmStr", String.join(IpcConstant.DATA_SEPARATOR, list.stream().filter(ipcAlarmRecord1 -> ipcAlarmRecord1.getNameKey().startsWith("pz")).map(IpcAlarmRecord::getAlarmDetail).collect(Collectors.toList())));
|
||||||
// 其他报警
|
// 其他报警
|
||||||
map.put("otherAlarmStr", String.join(IpcConstant.DATA_SEPARATOR,list.stream().filter(ipcAlarmRecord1 -> !ipcAlarmRecord1.getNameKey().startsWith("pz")).map(IpcAlarmRecord::getAlarmDetail).collect(Collectors.toList())));
|
map.put("otherAlarmStr", String.join(IpcConstant.DATA_SEPARATOR, list.stream().filter(ipcAlarmRecord1 -> !ipcAlarmRecord1.getNameKey().startsWith("pz")).map(IpcAlarmRecord::getAlarmDetail).collect(Collectors.toList())));
|
||||||
// 根据位置处理
|
// 根据位置处理
|
||||||
if (part.endsWith(IpcConstant.OPERATION_PROFILE)) {
|
if (part.endsWith(IpcConstant.OPERATION_PROFILE)) {
|
||||||
// 操作侧
|
// 操作侧
|
||||||
@ -137,13 +139,15 @@ public class IpcDataShowServiceImpl implements IIpcDataShowService {
|
|||||||
}
|
}
|
||||||
return dataMap;
|
return dataMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 传感器温振数据处理
|
* 传感器温振数据处理
|
||||||
|
*
|
||||||
* @param parts
|
* @param parts
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Map<String,Map<String,Object>> dealSensorData(String[] parts){
|
private Map<String, Map<String, Object>> dealSensorData(String[] parts) {
|
||||||
Map<String, Map<String,Object>> dataMap = new HashMap<>();
|
Map<String, Map<String, Object>> dataMap = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
for (String part : parts) {
|
for (String part : parts) {
|
||||||
// 数据获取
|
// 数据获取
|
||||||
@ -153,28 +157,25 @@ public class IpcDataShowServiceImpl implements IIpcDataShowService {
|
|||||||
// 横轴时间轴
|
// 横轴时间轴
|
||||||
List<String> xSensorData = new ArrayList<>();
|
List<String> xSensorData = new ArrayList<>();
|
||||||
//振动温度
|
//振动温度
|
||||||
List<Object> ssat = new ArrayList<>();
|
Object ssat;
|
||||||
//振动x轴
|
//振动x轴
|
||||||
List<Object> vx = new ArrayList<>();
|
List<Object> vx = new ArrayList<>();
|
||||||
//振动y轴
|
//振动y轴
|
||||||
List<Object> vy = new ArrayList<>();
|
List<Object> vy = new ArrayList<>();
|
||||||
//振动z轴
|
//振动z轴
|
||||||
List<Object> vz = new ArrayList<>();
|
List<Object> vz = new ArrayList<>();
|
||||||
Map<String, Object> sensorMap=sensorMaps.get(0);
|
Map<String, Object> sensorMap = sensorMaps.get(0);
|
||||||
xSensorData.addAll(sensorMap.get("stime") == null ? new ArrayList<>() : Arrays.asList(String.valueOf(sensorMap.get("stime")).split(IpcConstant.DATA_SEPARATOR)));
|
ssat = sensorMap.get("ssat") == null ? "0" : String.valueOf(sensorMap.get("ssat"));
|
||||||
ssat.addAll(sensorMap.get("ssat") == null ? new ArrayList<>() : Arrays.asList(String.valueOf(sensorMap.get("ssat")).split(IpcConstant.DATA_SEPARATOR)));
|
|
||||||
vx.addAll(sensorMap.get("vx") == null ? new ArrayList<>() : Arrays.asList(String.valueOf(sensorMap.get("vx")).split(IpcConstant.DATA_SEPARATOR)));
|
vx.addAll(sensorMap.get("vx") == null ? new ArrayList<>() : Arrays.asList(String.valueOf(sensorMap.get("vx")).split(IpcConstant.DATA_SEPARATOR)));
|
||||||
vy.addAll(sensorMap.get("vy") == null ? new ArrayList<>() : Arrays.asList(String.valueOf(sensorMap.get("vy")).split(IpcConstant.DATA_SEPARATOR)));
|
vy.addAll(sensorMap.get("vy") == null ? new ArrayList<>() : Arrays.asList(String.valueOf(sensorMap.get("vy")).split(IpcConstant.DATA_SEPARATOR)));
|
||||||
vz.addAll(sensorMap.get("stime") == null ? new ArrayList<>() : Arrays.asList(String.valueOf(sensorMap.get("vz")).split(IpcConstant.DATA_SEPARATOR)));
|
vz.addAll(sensorMap.get("stime") == null ? new ArrayList<>() : Arrays.asList(String.valueOf(sensorMap.get("vz")).split(IpcConstant.DATA_SEPARATOR)));
|
||||||
|
// 返回数据
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
if (!xSensorData.isEmpty()) {
|
|
||||||
int sensorIndex = xSensorData.size() - 1;
|
|
||||||
map.put("xSensorData", xSensorData);
|
map.put("xSensorData", xSensorData);
|
||||||
map.put("ssat", ssat.get(sensorIndex));
|
map.put("ssat", ssat);
|
||||||
map.put("vx", vx);
|
map.put("vx", vx);
|
||||||
map.put("vy", vy);
|
map.put("vy", vy);
|
||||||
map.put("vz", vz);
|
map.put("vz", vz);
|
||||||
}
|
|
||||||
// 根据位置处理
|
// 根据位置处理
|
||||||
if (part.endsWith(IpcConstant.OPERATION_PROFILE)) {
|
if (part.endsWith(IpcConstant.OPERATION_PROFILE)) {
|
||||||
// 操作侧
|
// 操作侧
|
||||||
@ -205,11 +206,11 @@ public class IpcDataShowServiceImpl implements IIpcDataShowService {
|
|||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.setTime(time);
|
calendar.setTime(time);
|
||||||
int y = calendar.get(Calendar.YEAR);
|
int y = calendar.get(Calendar.YEAR);
|
||||||
String month = calendar.get(Calendar.MONTH) > 9 ? ""+calendar.get(Calendar.MONTH) : "0"+calendar.get(Calendar.MONTH);
|
String month = calendar.get(Calendar.MONTH) > 9 ? "" + calendar.get(Calendar.MONTH) : "0" + calendar.get(Calendar.MONTH);
|
||||||
String d = calendar.get(Calendar.DAY_OF_MONTH) > 9 ? ""+calendar.get(Calendar.DAY_OF_MONTH) : "0"+calendar.get(Calendar.DAY_OF_MONTH);
|
String d = calendar.get(Calendar.DAY_OF_MONTH) > 9 ? "" + calendar.get(Calendar.DAY_OF_MONTH) : "0" + calendar.get(Calendar.DAY_OF_MONTH);
|
||||||
String h = calendar.get(Calendar.HOUR_OF_DAY) > 9 ? ""+calendar.get(Calendar.HOUR_OF_DAY) : "0"+calendar.get(Calendar.HOUR_OF_DAY);
|
String h = calendar.get(Calendar.HOUR_OF_DAY) > 9 ? "" + calendar.get(Calendar.HOUR_OF_DAY) : "0" + calendar.get(Calendar.HOUR_OF_DAY);
|
||||||
String m = calendar.get(Calendar.MINUTE) > 9 ? ""+calendar.get(Calendar.MINUTE) : "0"+calendar.get(Calendar.MINUTE);
|
String m = calendar.get(Calendar.MINUTE) > 9 ? "" + calendar.get(Calendar.MINUTE) : "0" + calendar.get(Calendar.MINUTE);
|
||||||
String s = calendar.get(Calendar.SECOND) > 9 ? ""+calendar.get(Calendar.SECOND) : "0"+calendar.get(Calendar.SECOND);
|
String s = calendar.get(Calendar.SECOND) > 9 ? "" + calendar.get(Calendar.SECOND) : "0" + calendar.get(Calendar.SECOND);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "year":
|
case "year":
|
||||||
dateTime = y + "-" + month + "-" + d + " " + h + ":" + m + ":" + s;
|
dateTime = y + "-" + month + "-" + d + " " + h + ":" + m + ":" + s;
|
||||||
|
@ -99,10 +99,10 @@ public class IpcMonitorFieldServiceImpl implements IIpcMonitorFieldService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<IpcMonitorField> selectFieldDataByType(String type) {
|
public List<IpcMonitorField> selectFieldDataByType(String type) {
|
||||||
List<IpcMonitorField> list = redisCache.getCacheObject(CacheConstants.IPC_PREFIX+type + CacheConstants.REDIS_KEY_SEPARATOR);
|
List<IpcMonitorField> list = redisCache.getCacheObject(CacheConstants.IPC_PREFIX+type);
|
||||||
if (list == null || list.isEmpty()) {
|
if (list == null || list.isEmpty()) {
|
||||||
list = ipcMonitorFieldMapper.selectFieldDataByType(type);
|
list = ipcMonitorFieldMapper.selectFieldDataByType(type);
|
||||||
redisCache.setCacheObject(CacheConstants.IPC_PREFIX+type + CacheConstants.REDIS_KEY_SEPARATOR, list,CacheConstants.IPC_EXPIRATION_TIME, TimeUnit.HOURS);
|
redisCache.setCacheObject(CacheConstants.IPC_PREFIX+type, list);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,8 @@ public class IpcRunningStatusRecordServiceImpl implements IIpcRunningStatusRecor
|
|||||||
public int insertIpcRunningStatusRecord(IpcRunningStatusRecord ipcRunningStatusRecord)
|
public int insertIpcRunningStatusRecord(IpcRunningStatusRecord ipcRunningStatusRecord)
|
||||||
{
|
{
|
||||||
int num = ipcRunningStatusRecordMapper.insertIpcRunningStatusRecord(ipcRunningStatusRecord);
|
int num = ipcRunningStatusRecordMapper.insertIpcRunningStatusRecord(ipcRunningStatusRecord);
|
||||||
selectLatestStatus();
|
// 更新缓存
|
||||||
|
redisCache.setCacheObject(CacheConstants.IPC_PREFIX+CacheConstants.RUNNING_STATUS,ipcRunningStatusRecord.getRunningStatus());
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,8 +109,12 @@ public class IpcRunningStatusRecordServiceImpl implements IIpcRunningStatusRecor
|
|||||||
String status = redisCache.getCacheObject(CacheConstants.IPC_PREFIX+CacheConstants.RUNNING_STATUS);
|
String status = redisCache.getCacheObject(CacheConstants.IPC_PREFIX+CacheConstants.RUNNING_STATUS);
|
||||||
if(StringUtils.isNull(status) || StringUtils.isEmpty(status)){
|
if(StringUtils.isNull(status) || StringUtils.isEmpty(status)){
|
||||||
status = ipcRunningStatusRecordMapper.selectLatestStatus();
|
status = ipcRunningStatusRecordMapper.selectLatestStatus();
|
||||||
redisCache.setCacheObject(CacheConstants.IPC_PREFIX+CacheConstants.RUNNING_STATUS,status,CacheConstants.IPC_EXPIRATION_TIME, TimeUnit.HOURS);
|
redisCache.setCacheObject(CacheConstants.IPC_PREFIX+CacheConstants.RUNNING_STATUS,status);
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public String getSSS(){
|
||||||
|
return redisCache.getCacheObject("status_test");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,11 +39,11 @@ public class IpcConstant {
|
|||||||
/**
|
/**
|
||||||
* plc数据表名
|
* plc数据表名
|
||||||
*/
|
*/
|
||||||
public static final String PLC_MEASUREMENT = "tz_ipc_plc_monitor_data_list1";
|
public static final String PLC_MEASUREMENT = "tz_ipc_plc_monitor_data_list2";
|
||||||
/**
|
/**
|
||||||
* 温振传感器数据表名
|
* 温振传感器数据表名
|
||||||
*/
|
*/
|
||||||
public static final String SENSOR_MEASUREMENT = "tz_ipc_sensor_monitor_data_list1";
|
public static final String SENSOR_MEASUREMENT = "tz_ipc_sensor_monitor_data_list2";
|
||||||
/**
|
/**
|
||||||
* 操作侧简写
|
* 操作侧简写
|
||||||
*/
|
*/
|
||||||
|
@ -71,12 +71,10 @@ public class IpcUtil {
|
|||||||
/**
|
/**
|
||||||
* 批量处理实时数据
|
* 批量处理实时数据
|
||||||
*/
|
*/
|
||||||
public List<IpcAlarmRecord> dealRealTimeData(Map<String, Object> map, Map<String, String> tags, String type, List<IpcAlarmRulesConfig> rulesConfigList) {
|
public List<IpcAlarmRecord> dealRealTimeData(Map<String, Object> map, Map<String, String> tags, List<IpcAlarmRulesConfig> rulesConfigList) {
|
||||||
List<IpcAlarmRecord> returnList = new ArrayList<>();
|
List<IpcAlarmRecord> returnList = new ArrayList<>();
|
||||||
String isAlarm = "0";
|
String isAlarm = "0";
|
||||||
for (IpcAlarmRulesConfig rulesConfig : rulesConfigList) {
|
for (IpcAlarmRulesConfig rulesConfig : rulesConfigList) {
|
||||||
// 判断是否当前参数类型
|
|
||||||
if (type.equals(rulesConfig.getType())) {
|
|
||||||
if (judgeAlarm(map.get(rulesConfig.getNameKey()), rulesConfig.getReferenceValue1(), rulesConfig.getReferenceValue2(), rulesConfig.getReferenceCon())) {
|
if (judgeAlarm(map.get(rulesConfig.getNameKey()), rulesConfig.getReferenceValue1(), rulesConfig.getReferenceValue2(), rulesConfig.getReferenceCon())) {
|
||||||
// 报警数据
|
// 报警数据
|
||||||
isAlarm = "1";
|
isAlarm = "1";
|
||||||
@ -84,7 +82,6 @@ public class IpcUtil {
|
|||||||
returnList.add(ipcAlarmRecord);
|
returnList.add(ipcAlarmRecord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
tags.put("isAlarm", isAlarm);
|
tags.put("isAlarm", isAlarm);
|
||||||
return returnList;
|
return returnList;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
<el-select
|
<el-select
|
||||||
v-model="queryParams.part"
|
v-model="queryParams.part"
|
||||||
placeholder="请选择监测部位"
|
placeholder="请选择监测部位"
|
||||||
@change="getList()"
|
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="field in monitorPartList"
|
v-for="field in monitorPartList"
|
||||||
@ -327,6 +326,8 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 查询列表 */
|
/** 查询列表 */
|
||||||
getList() {
|
getList() {
|
||||||
|
this.queryParams.startTime = null;
|
||||||
|
this.queryParams.endTime = null;
|
||||||
if (this.queryParams.datetimerange && this.queryParams.datetimerange[0]) {
|
if (this.queryParams.datetimerange && this.queryParams.datetimerange[0]) {
|
||||||
this.queryParams.startTime = this.dateToStr(
|
this.queryParams.startTime = this.dateToStr(
|
||||||
this.queryParams.datetimerange[0]
|
this.queryParams.datetimerange[0]
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
<el-select
|
<el-select
|
||||||
v-model="queryParams.part"
|
v-model="queryParams.part"
|
||||||
placeholder="请选择监测部位"
|
placeholder="请选择监测部位"
|
||||||
@change="getList()"
|
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="field in monitorPartList"
|
v-for="field in monitorPartList"
|
||||||
@ -96,13 +95,6 @@
|
|||||||
width="200"
|
width="200"
|
||||||
show-overflow-tooltip
|
show-overflow-tooltip
|
||||||
/>
|
/>
|
||||||
<el-table-column
|
|
||||||
label="振动时间"
|
|
||||||
align="center"
|
|
||||||
key="stime"
|
|
||||||
prop="stime"
|
|
||||||
show-overflow-tooltip
|
|
||||||
/>
|
|
||||||
<el-table-column
|
<el-table-column
|
||||||
label="轴套区温度"
|
label="轴套区温度"
|
||||||
align="center"
|
align="center"
|
||||||
@ -257,6 +249,9 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
if (this.$route.query.partKey) {
|
||||||
|
this.queryParams.part = this.$route.query.partKey;
|
||||||
|
}
|
||||||
this.getMonitorPartList();
|
this.getMonitorPartList();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -286,14 +281,18 @@ export default {
|
|||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
resetQuery() {
|
resetQuery() {
|
||||||
this.resetForm("queryForm");
|
this.resetForm("queryForm");
|
||||||
|
if (this.$route.query.partKey) {
|
||||||
|
this.queryParams.part = this.$route.query.partKey;
|
||||||
|
} else {
|
||||||
this.queryParams.part = this.monitorPartList[0].fieldValue;
|
this.queryParams.part = this.monitorPartList[0].fieldValue;
|
||||||
|
}
|
||||||
this.handleQuery();
|
this.handleQuery();
|
||||||
},
|
},
|
||||||
// 查看图谱
|
// 查看图谱
|
||||||
handleView(data) {
|
handleView(data) {
|
||||||
this.open = true;
|
this.open = true;
|
||||||
this.initChart(
|
this.initChart(
|
||||||
data.stime.split(","),
|
[],
|
||||||
data.vx.split(","),
|
data.vx.split(","),
|
||||||
data.vy.split(","),
|
data.vy.split(","),
|
||||||
data.vz.split(",")
|
data.vz.split(",")
|
||||||
@ -495,7 +494,11 @@ export default {
|
|||||||
getFields("monitor_part")
|
getFields("monitor_part")
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.monitorPartList = res.data;
|
this.monitorPartList = res.data;
|
||||||
|
if (this.$route.query.partKey) {
|
||||||
|
this.queryParams.part = this.$route.query.partKey;
|
||||||
|
} else {
|
||||||
this.queryParams.part = this.monitorPartList[0].fieldValue;
|
this.queryParams.part = this.monitorPartList[0].fieldValue;
|
||||||
|
}
|
||||||
this.getList();
|
this.getList();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
@ -504,6 +507,8 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 查询列表 */
|
/** 查询列表 */
|
||||||
getList() {
|
getList() {
|
||||||
|
this.queryParams.startTime = null;
|
||||||
|
this.queryParams.endTime = null;
|
||||||
if (this.queryParams.datetimerange && this.queryParams.datetimerange[0]) {
|
if (this.queryParams.datetimerange && this.queryParams.datetimerange[0]) {
|
||||||
this.queryParams.startTime = this.dateToStr(
|
this.queryParams.startTime = this.dateToStr(
|
||||||
this.queryParams.datetimerange[0]
|
this.queryParams.datetimerange[0]
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<div class="card-big-title">{{ title1 }}数据监控</div>
|
<div class="card-big-title">{{ title1 }}数据监控</div>
|
||||||
<div
|
<div
|
||||||
class="card-sub-title"
|
class="card-sub-title"
|
||||||
@click="jumpSensorDataLog"
|
@click="jumpSensorDataLog(queryParams[0])"
|
||||||
>油膜轴承振动监测</div>
|
>油膜轴承振动监测</div>
|
||||||
<div
|
<div
|
||||||
class="card-main-item-wrapper"
|
class="card-main-item-wrapper"
|
||||||
@ -32,7 +32,7 @@
|
|||||||
<div class="card-big-title">{{ title2 }}数据监控</div>
|
<div class="card-big-title">{{ title2 }}数据监控</div>
|
||||||
<div
|
<div
|
||||||
class="card-sub-title"
|
class="card-sub-title"
|
||||||
@click="jumpSensorDataLog"
|
@click="jumpSensorDataLog(queryParams[1])"
|
||||||
>油膜轴承振动监测</div>
|
>油膜轴承振动监测</div>
|
||||||
<div
|
<div
|
||||||
class="card-main-item-wrapper"
|
class="card-main-item-wrapper"
|
||||||
@ -161,7 +161,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
style="font-family: 'BiaoTi';"
|
style="font-family: 'BiaoTi';"
|
||||||
@click="jumpSensorDataLog"
|
@click="jumpSensorDataLog(queryParams[0])"
|
||||||
>轴套区温度</div>
|
>轴套区温度</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -204,7 +204,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
style="font-family: 'BiaoTi';"
|
style="font-family: 'BiaoTi';"
|
||||||
@click="jumpSensorDataLog"
|
@click="jumpSensorDataLog(queryParams[0])"
|
||||||
>轴套区温度</div>
|
>轴套区温度</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="bottom-grid-item">
|
<div class="bottom-grid-item">
|
||||||
@ -1201,8 +1201,11 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 跳转温振数据记录页面
|
// 跳转温振数据记录页面
|
||||||
jumpSensorDataLog() {
|
jumpSensorDataLog(param) {
|
||||||
this.$router.push("/dataLog/sensor");
|
this.$router.push({
|
||||||
|
path: "/dataLog/sensor",
|
||||||
|
query: { partKey: param },
|
||||||
|
});
|
||||||
},
|
},
|
||||||
// 跳转报警记录页面
|
// 跳转报警记录页面
|
||||||
jumpAlarmRecord(param) {
|
jumpAlarmRecord(param) {
|
||||||
|
Loading…
Reference in New Issue
Block a user