表名修改提交

This commit is contained in:
zhanghan11 2024-04-09 09:43:34 +08:00
parent d8213832ed
commit defad5d8c2
16 changed files with 699 additions and 77 deletions

View File

@ -2,14 +2,14 @@ package com.inspur.web.controller.ipc;
import com.inspur.common.core.controller.BaseController;
import com.inspur.common.core.domain.AjaxResult;
import com.inspur.ipc.domain.IpcQueryParams;
import com.inspur.ipc.service.IIpcDataLogService;
import com.inspur.ipc.service.IIpcDataShowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
/**
* 数据展示界面
@ -25,18 +25,47 @@ public class IpcDataLogController extends BaseController {
* 查询plc数据记录
*/
@PreAuthorize("@ss.hasPermi('ipc:dataLog:query')")
@GetMapping(value = "/plc/{part}")
public AjaxResult queryPlcDataLog(@PathVariable String part)
@GetMapping(value = "/plc")
public AjaxResult queryPlcDataLog(@RequestBody IpcQueryParams ipcQueryParams)
{
return AjaxResult.success(iIpcDataLogService.queryPlcDataLog(part));
return AjaxResult.success(iIpcDataLogService.queryPlcDataLog(ipcQueryParams));
}
/**
* 查询传感器温振数据记录
*/
@PreAuthorize("@ss.hasPermi('ipc:dataLog:query')")
@GetMapping(value = "/sensor/{part}")
public AjaxResult querySensorDataLog(@PathVariable String part)
@GetMapping(value = "/sensor")
public AjaxResult querySensorDataLog(@RequestBody IpcQueryParams ipcQueryParams)
{
return AjaxResult.success(iIpcDataLogService.querySensorDataLog(part));
return AjaxResult.success(iIpcDataLogService.querySensorDataLog(ipcQueryParams));
}
/**
* 导出plc数据记录
*/
@PreAuthorize("@ss.hasPermi('ipc:dataLog:query')")
@GetMapping(value = "/plcExport")
public AjaxResult exportPlcDataLog(HttpServletResponse response, @RequestBody IpcQueryParams ipcQueryParams)
{
return AjaxResult.success(iIpcDataLogService.queryPlcDataLog(ipcQueryParams));
}
/**
* 导出传感器温振数据记录
*/
@PreAuthorize("@ss.hasPermi('ipc:dataLog:query')")
@GetMapping(value = "/sensorExport")
public AjaxResult exportSensorDataLog(HttpServletResponse response,@RequestBody IpcQueryParams ipcQueryParams)
{
return AjaxResult.success(iIpcDataLogService.querySensorDataLog(ipcQueryParams));
}
/**
* 获取趋势图数据
*/
@PreAuthorize("@ss.hasPermi('ipc:dataShow:query')")
@GetMapping(value = "/getTendencyData")
public AjaxResult getTendencyData(@RequestBody IpcQueryParams ipcQueryParams)
{
return AjaxResult.success(iIpcDataLogService.getTendencyData(ipcQueryParams));
}
}

View File

@ -2,6 +2,7 @@ package com.inspur.web.controller.ipc;
import com.inspur.common.core.controller.BaseController;
import com.inspur.common.core.domain.AjaxResult;
import com.inspur.ipc.domain.IpcQueryParams;
import com.inspur.ipc.service.IIpcDataShowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
@ -29,13 +30,5 @@ public class IpcDataShowController extends BaseController {
return AjaxResult.success(iIpcDataShowService.getShowData(parts));
}
/**
* 获取趋势图数据
*/
@PreAuthorize("@ss.hasPermi('ipc:dataShow:query')")
@GetMapping(value = "/getTendencyData")
public AjaxResult getTendencyData(@RequestBody Map<String,Object> params)
{
return AjaxResult.success(iIpcDataShowService.getTendencyData(params));
}
}

View File

@ -20,6 +20,7 @@ import org.slf4j.LoggerFactory;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
public class IPCPlcDataSyncThread implements Runnable {
private static final Logger logger = LoggerFactory.getLogger(IPCPlcDataSyncThread.class);
@ -108,10 +109,11 @@ public class IPCPlcDataSyncThread implements Runnable {
// fields.put("vz", (float) 0 + Math.random());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
String format = simpleDateFormat.format(new Date());
fields.put("insertTime", format);
tags.put("insertTime", format);
// TODO 根据报警规则校验
// 根据运行状态获取规则
List<IpcAlarmRulesConfig> rulesConfigList = iIpcAlarmRulesConfigService.selectIpcAlarmRulesConfigList(tags.get("part"));
rulesConfigList = rulesConfigList.stream().filter(ipcAlarmRulesConfig -> ipcAlarmRulesConfig.getType().equals(IpcConstant.RULE_TYPE_IN_RUNNING)).collect(Collectors.toList());
alarmRecordList.addAll(ipcUtil.dealRealTimeData(fields, tags, CacheConstants.PLC_MONITOR_PARAMS_KEY,rulesConfigList));
i.insert(IpcConstant.PLC_MEASUREMENT, tags, fields);
}

View File

@ -4,6 +4,7 @@ import com.inspur.common.constant.CacheConstants;
import com.inspur.common.utils.spring.SpringUtils;
import com.inspur.ipc.domain.IpcAlarmRecord;
import com.inspur.ipc.domain.IpcMonitorField;
import com.inspur.ipc.domain.IpcQueryParams;
import com.inspur.ipc.service.IIpcAlarmRecordService;
import com.inspur.ipc.service.IIpcMonitorFieldService;
import com.inspur.ipc.utils.IpcConstant;
@ -17,6 +18,7 @@ import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
public class IPCSensorDataSyncThread implements Runnable {
private static final Logger logger = LoggerFactory.getLogger(IPCPlcDataSyncThread.class);
@ -41,7 +43,6 @@ public class IPCSensorDataSyncThread implements Runnable {
// 温振数据
List<IpcMonitorField> partList = iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.MONITOR_PART_KEY);
List<IpcMonitorField> sensorList = iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.SENSOR_MONITOR_PARAMS_KEY);
List<IpcAlarmRecord> alarmRecordList = new ArrayList<>();
// 字典数据列表集合
for (IpcMonitorField part : partList) {
Map<String, String> tags = new TreeMap();
@ -50,13 +51,13 @@ public class IPCSensorDataSyncThread implements Runnable {
for (IpcMonitorField field : sensorList) {
// 可以配置源字段获取时通过源字段获取数据
// field.getSourceField()
if (field.getFieldValue().equals("sensor_time")) {
if (field.getFieldValue().equals("stime")) {
fields.put(field.getFieldValue(), getDate());
} else {
fields.put(field.getFieldValue(), getData());
}
}
fields.put("insertTime", format);
tags.put("insertTime", format);
InfluxDBService i = SpringUtils.getBean(InfluxDBService.class);
i.insert(IpcConstant.SENSOR_MEASUREMENT, tags, fields);
}
@ -67,19 +68,19 @@ public class IPCSensorDataSyncThread implements Runnable {
}
private String getData() {
String str = "";
List<String> list = new ArrayList<>();
for (int i = 0; i < 60; i++) {
str += Math.random();
list.add(Math.random()+"");
}
return str;
return list.stream().map(String::valueOf).collect(Collectors.joining(IpcConstant.DATA_SEPARATOR));
}
private String getDate() {
String str = "";
List<String> list = new ArrayList<>();
for (int i = 0; i < 60; i++) {
str += LocalDateTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss:SSS"));
list.add(LocalDateTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss:SSS")));
}
return str;
return list.stream().map(String::valueOf).collect(Collectors.joining(IpcConstant.DATA_SEPARATOR));
}
}

View File

@ -0,0 +1,139 @@
package com.inspur.ipc.domain;
import com.inspur.common.annotation.Excel;
public class IpcPlcData {
@Excel(name = "运行状态")
private String rstatus ;
@Excel(name = "字段排序")
private String pz4 ;
@Excel(name = "颗粒度6μm")
private String pz6 ;
@Excel(name = "颗粒度14μm")
private String pz14 ;
@Excel(name = "颗粒度21μm")
private String pz21 ;
@Excel(name = "油水含量")
private String owc ;
@Excel(name = "油品粘度")
private String ov ;
@Excel(name = "回油温度")
private String rot ;
@Excel(name = "进油压力")
private String oip ;
@Excel(name = "油液密度")
private String od ;
public IpcPlcData() {
}
public IpcPlcData(String rstatus,String pz4, String pz6, String pz14, String pz21, String owc, String ov, String rot, String oip, String od) {
this.rstatus = rstatus;
this.pz4 = pz4;
this.pz6 = pz6;
this.pz14 = pz14;
this.pz21 = pz21;
this.owc = owc;
this.ov = ov;
this.rot = rot;
this.oip = oip;
this.od = od;
}
public String getRstatus() {
return rstatus;
}
public void setRstatus(String rstatus) {
this.rstatus = rstatus;
}
public String getPz4() {
return pz4;
}
public void setPz4(String pz4) {
this.pz4 = pz4;
}
public String getPz6() {
return pz6;
}
public void setPz6(String pz6) {
this.pz6 = pz6;
}
public String getPz14() {
return pz14;
}
public void setPz14(String pz14) {
this.pz14 = pz14;
}
public String getPz21() {
return pz21;
}
public void setPz21(String pz21) {
this.pz21 = pz21;
}
public String getOwc() {
return owc;
}
public void setOwc(String owc) {
this.owc = owc;
}
public String getOv() {
return ov;
}
public void setOv(String ov) {
this.ov = ov;
}
public String getRot() {
return rot;
}
public void setRot(String rot) {
this.rot = rot;
}
public String getOip() {
return oip;
}
public void setOip(String oip) {
this.oip = oip;
}
public String getOd() {
return od;
}
public void setOd(String od) {
this.od = od;
}
@Override
public String toString() {
return "IpcPlcData{" +
"rstatus='" + rstatus + '\'' +
", pz4='" + pz4 + '\'' +
", pz6='" + pz6 + '\'' +
", pz14='" + pz14 + '\'' +
", pz21='" + pz21 + '\'' +
", owc='" + owc + '\'' +
", ov='" + ov + '\'' +
", rot='" + rot + '\'' +
", oip='" + oip + '\'' +
", od='" + od + '\'' +
'}';
}
}

View File

@ -0,0 +1,89 @@
package com.inspur.ipc.domain;
public class IpcQueryParams {
/**
* 监测部位
*/
private String part;
/**
* 参数
*/
private String param;
/**
* 开始时间
*/
private String startTime;
/**
* 结束时间
*/
private String endTime;
/**
* 是否报警
*/
private String isAlarm;
/**
* 页数
*/
private int pageNum;
/**
* 每页数据
*/
private int pageSize;
public String getPart() {
return part;
}
public void setPart(String part) {
this.part = part;
}
public String getParam() {
return param;
}
public void setParam(String param) {
this.param = param;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public String getIsAlarm() {
return isAlarm;
}
public void setIsAlarm(String isAlarm) {
this.isAlarm = isAlarm;
}
public int getPageNum() {
return pageNum;
}
public void setPageNum(int pageNum) {
this.pageNum = pageNum;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
}

View File

@ -0,0 +1,78 @@
package com.inspur.ipc.domain;
import com.inspur.common.annotation.Excel;
public class IpcSensorData {
@Excel(name = "时间")
private String stime ;
@Excel(name = "轴套区温度")
private String ssat ;
@Excel(name = "振动x轴")
private String vx ;
@Excel(name = "振动y轴")
private String vy ;
@Excel(name = "振动z轴")
private String vz ;
public IpcSensorData() {
}
public IpcSensorData(String stime, String ssat, String vx, String vy, String vz) {
this.stime = stime;
this.ssat = ssat;
this.vx = vx;
this.vy = vy;
this.vz = vz;
}
public String getStime() {
return stime;
}
public void setStime(String stime) {
this.stime = stime;
}
public String getSsat() {
return ssat;
}
public void setSsat(String ssat) {
this.ssat = ssat;
}
public String getVx() {
return vx;
}
public void setVx(String vx) {
this.vx = vx;
}
public String getVy() {
return vy;
}
public void setVy(String vy) {
this.vy = vy;
}
public String getVz() {
return vz;
}
public void setVz(String vz) {
this.vz = vz;
}
@Override
public String toString() {
return "IpcSensorData{" +
"stime='" + stime + '\'' +
", ssat='" + ssat + '\'' +
", vx='" + vx + '\'' +
", vy='" + vy + '\'' +
", vz='" + vz + '\'' +
'}';
}
}

View File

@ -1,5 +1,9 @@
package com.inspur.ipc.service;
import com.inspur.ipc.domain.IpcPlcData;
import com.inspur.ipc.domain.IpcQueryParams;
import com.inspur.ipc.domain.IpcSensorData;
import java.util.List;
import java.util.Map;
@ -12,10 +16,15 @@ public interface IIpcDataLogService {
/**
* plc数据记录接口
*/
public List<Map<String,Object>> queryPlcDataLog(String part);
Map<String, Object> queryPlcDataLog(IpcQueryParams ipcQueryParams);
/**
* 温振传感器数据记录接口
*/
public List<Map<String,Object>> querySensorDataLog(String part);
Map<String, Object> querySensorDataLog(IpcQueryParams ipcQueryParams);
/**
* 趋势数据获取
*/
Map<String, Object> getTendencyData(IpcQueryParams ipcQueryParams);
}

View File

@ -1,5 +1,7 @@
package com.inspur.ipc.service;
import com.inspur.ipc.domain.IpcQueryParams;
import java.util.Map;
/**
@ -13,8 +15,4 @@ public interface IIpcDataShowService {
*/
public Map<String,Object> getShowData(String [] parts);
/**
* 趋势数据获取
*/
public Map<String,Object> getTendencyData(Map<String,Object> params);
}

View File

@ -1,12 +1,21 @@
package com.inspur.ipc.service.impl;
import com.alibaba.fastjson2.JSON;
import com.inspur.ipc.domain.IpcPlcData;
import com.inspur.ipc.domain.IpcQueryParams;
import com.inspur.ipc.domain.IpcSensorData;
import com.inspur.ipc.service.IIpcDataLogService;
import com.inspur.ipc.utils.InfluxdbTimeUtil;
import com.inspur.ipc.utils.IpcConstant;
import com.inspur.system.service.influx.InfluxDBService;
import org.influxdb.dto.QueryResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -19,19 +28,125 @@ public class IpcDataLogServiceImpl implements IIpcDataLogService {
* plc数据记录接口
*/
@Override
public List<Map<String, Object>> queryPlcDataLog(String part) {
QueryResult query = influxDBService.query("select * from "+ IpcConstant.PLC_MEASUREMENT +" where part = '" + part + "' order by time desc limit 20");
List<Map<String, Object>> maps = influxDBService.queryResultProcess(query);
return maps;
public Map<String, Object> queryPlcDataLog(IpcQueryParams ipcQueryParams) {
Map<String, Object> map = new HashMap<>();
String tableName = IpcConstant.PLC_MEASUREMENT;
String part = ipcQueryParams.getPart();
String startTime = InfluxdbTimeUtil.cstToUtc(ipcQueryParams.getStartTime());
String endTime = InfluxdbTimeUtil.cstToUtc(ipcQueryParams.getEndTime());
// 查询总数
int total = countInfluxdbList(IpcConstant.PLC_MEASUREMENT, ipcQueryParams.getPart(), ipcQueryParams.getIsAlarm(),startTime,endTime);
// 查询数据
List<Map<String, Object>> maps = selectAllDataByPart(IpcConstant.PLC_MEASUREMENT, ipcQueryParams.getPart(), ipcQueryParams.getIsAlarm(),startTime,endTime,ipcQueryParams.getPageSize(),ipcQueryParams.getPageNum());
List<IpcPlcData> list = JSON.parseArray(JSON.toJSONString(maps), IpcPlcData.class);
map.put("total",total);
map.put("rows",list);
return map;
}
/**
* 温振传感器数据记录接口
*/
@Override
public List<Map<String, Object>> querySensorDataLog(String part) {
QueryResult query = influxDBService.query("select * from "+ IpcConstant.SENSOR_MEASUREMENT +" where part = '" + part + "' order by time desc limit 20");
List<Map<String, Object>> maps = influxDBService.queryResultProcess(query);
return maps;
public Map<String, Object> querySensorDataLog(IpcQueryParams ipcQueryParams) {
Map<String, Object> map = new HashMap<>();
// 查询总数
int total = countInfluxdbList(IpcConstant.SENSOR_MEASUREMENT, ipcQueryParams.getPart(), ipcQueryParams.getIsAlarm(),ipcQueryParams.getStartTime(), ipcQueryParams.getEndTime());
// 查询数据
List<Map<String, Object>> maps = selectAllDataByPart(IpcConstant.SENSOR_MEASUREMENT, ipcQueryParams.getPart(), ipcQueryParams.getIsAlarm(),ipcQueryParams.getStartTime(), ipcQueryParams.getEndTime(),ipcQueryParams.getPageSize(),ipcQueryParams.getPageNum());
List<IpcPlcData> list = JSON.parseArray(JSON.toJSONString(maps), IpcPlcData.class);
map.put("total",total);
map.put("rows",list);
return map;
}
/**
* 趋势数据获取
*/
@Override
public Map<String,Object> getTendencyData(IpcQueryParams ipcQueryParams){
Map<String,Object> map = new HashMap<>();
String utcStartTime = InfluxdbTimeUtil.cstToUtc(ipcQueryParams.getStartTime());
String utcEndTime = InfluxdbTimeUtil.cstToUtc(ipcQueryParams.getEndTime());
//计算utcStartTime与utcEndTime的时间差
LocalDateTime stime = LocalDateTime.parse(ipcQueryParams.getStartTime());
LocalDateTime etime = LocalDateTime.parse(ipcQueryParams.getEndTime());
long intervalHours = ChronoUnit.HOURS.between(stime, etime);
List<Map<String, Object>> list = new ArrayList<>();
if(intervalHours <= 6){//6小时内全查
list = selectDataByParamNameandDate(IpcConstant.SENSOR_MEASUREMENT, ipcQueryParams.getPart(),ipcQueryParams.getParam(), utcStartTime, utcEndTime);
}else if(intervalHours <= 7*24 ){//7天内每30s一个
list = selectLongTimeDataByParamNameandDate(IpcConstant.SENSOR_MEASUREMENT, ipcQueryParams.getPart(),ipcQueryParams.getParam(), utcStartTime, utcEndTime, "30s");
}else if(intervalHours <= 30*24 ){//30天内每2min一个
list = selectLongTimeDataByParamNameandDate(IpcConstant.SENSOR_MEASUREMENT, ipcQueryParams.getPart(),ipcQueryParams.getParam(), utcStartTime, utcEndTime, "2m");
}else if (intervalHours <= 90*24){//90天以上每4h一个
list = selectLongTimeDataByParamNameandDate(IpcConstant.SENSOR_MEASUREMENT, ipcQueryParams.getPart(),ipcQueryParams.getParam(), utcStartTime, utcEndTime, "6m");
}
Map<String, Object> resMap = new HashMap<>();
if (list.size() == 0){
return null;
}
return map;
}
/**
* 根据字段名称和起止时间查询数据
* @param tableName 表名
* @param part 监测部位
* @param param 参数
* @param startTime 起始时间
* @param endTime 结束时间
* @return 数据
*/
private List<Map<String, Object>> selectDataByParamNameandDate(String tableName, String part,String param, String startTime, String endTime){
String sql = "select time," + param + " from " + tableName + " where part = '" + part + "' time >= '" + startTime + "' and time <= '" + endTime + "'";
return influxDBService.queryResultProcess(influxDBService.query(sql));
}
/**
* 查询长时间数据每分钟取一条展示最长3个月
* @return
*/
private List<Map<String, Object>> selectLongTimeDataByParamNameandDate(String tableName, String part,String param, String startTime, String endTime, String interval){
String sql = "select time, mean(" + param + ") from " + tableName + " where part = '" + part + "' time >= '" + startTime + "' and time <= '" + endTime + "' group by time(" + interval +")";
return influxDBService.queryResultProcess(influxDBService.query(sql));
}
/**
* 根据监测部位查询最近num条数据
* @param tableName 表名
* @param part 监测部位
* @return 数据
*/
private List<Map<String, Object>> selectAllDataByPart(String tableName, String part,String isAlarm,String startTime, String endTime, int pageSize, int pageNum){
String sql = "select * from " + tableName + " where equ_id = '" + part + "'";
if(isAlarm != null){
sql += " and isAlarm = '" + isAlarm + "'";
}
if(startTime != null){
sql += " and time >= '" + startTime + "'";
}
if(endTime != null){
sql += " and time <= '" + endTime + "'";
}
sql += " order by time desc limit " + pageSize + " offset " +(pageNum - 1)*pageSize;
return influxDBService.queryResultProcess(influxDBService.query(sql));
}
private int countInfluxdbList(String tableName, String part,String isAlarm,String startTime, String endTime){
String sql = "select count(isAlarm) from " + tableName + " where part = '" + part + "'";
if(isAlarm != null){
sql += " and isAlarm = '" + isAlarm + "'";
}
if(startTime != null){
sql += " and time >= '" + startTime + "'";
}
if(endTime != null){
sql += " and time <= '" + endTime + "'";
}
List<Map<String, Object>> list = influxDBService.queryResultProcess(influxDBService.query(sql));
return list.size() == 0 ? 0 : ((Double)list.get(0).get("count")).intValue();
}
}

View File

@ -1,5 +1,6 @@
package com.inspur.ipc.service.impl;
import com.inspur.ipc.domain.IpcQueryParams;
import com.inspur.ipc.service.IIpcDataShowService;
import com.inspur.ipc.utils.IpcConstant;
import com.inspur.system.service.influx.InfluxDBService;
@ -147,11 +148,11 @@ public class IpcDataShowServiceImpl implements IIpcDataShowService {
//振动z轴
List<Object> vz = new ArrayList<>();
Map<String, Object> sensorMap=sensorMaps.get(0);
xSensorData.addAll(sensorMap.get("sensor_time") == null ? new ArrayList<>() : Arrays.asList(String.valueOf(sensorMap.get("sensor_time")).split(IpcConstant.DATA_SEPARATOR)));
xSensorData.addAll(sensorMap.get("stime") == null ? new ArrayList<>() : Arrays.asList(String.valueOf(sensorMap.get("stime")).split(IpcConstant.DATA_SEPARATOR)));
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)));
vy.addAll(sensorMap.get("vy") == null ? new ArrayList<>() : Arrays.asList(String.valueOf(sensorMap.get("vy")).split(IpcConstant.DATA_SEPARATOR)));
vz.addAll(sensorMap.get("sensor_time") == 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<>();
if (!xSensorData.isEmpty()) {
int sensorIndex = xSensorData.size() - 1;
@ -222,12 +223,4 @@ public class IpcDataShowServiceImpl implements IIpcDataShowService {
return dateTime;
}
/**
* 趋势数据获取
*/
@Override
public Map<String,Object> getTendencyData(Map<String,Object> params){
Map<String,Object> map = new HashMap<>();
return map;
}
}

View File

@ -0,0 +1,40 @@
package com.inspur.ipc.utils;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
/**
*influxdb时间工具类
* @Author zhangjunwen
* @create 2024/4/1
*/
public class InfluxdbTimeUtil {
/**
* 将utc时间转北京时间
* @param date utc时间
* @return 北京时间
*/
public static LocalDateTime utcToCst(String date) {
DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME;
LocalDateTime localDateTime = LocalDateTime.parse(date, formatter);
return localDateTime.plusHours(8);
}
/**
* 将北京时间转utc时间
* @param date 北京时间
* @return utc时间
* 例如输入2020-04-01T08:00:00.000
* 返回2020-04-01T00:00:00.000Z
*/
public static String cstToUtc(String date){
LocalDateTime localDateTime = LocalDateTime.parse(date);
String utcTime = localDateTime.atZone(ZoneId.of("UTC+8")).withZoneSameInstant(ZoneId.of("UTC")).format(DateTimeFormatter.ISO_DATE_TIME);
return utcTime.substring(0, utcTime.indexOf("Z")+1);
}
}

View File

@ -39,11 +39,11 @@ public class IpcConstant {
/**
* plc数据表名
*/
public static final String PLC_MEASUREMENT = "tzipc_plc_monitor_data_list";
public static final String PLC_MEASUREMENT = "tz_ipc_plc_monitor_data_list";
/**
* 温振传感器数据表名
*/
public static final String SENSOR_MEASUREMENT = "tzipc_sensor_monitor_data_list";
public static final String SENSOR_MEASUREMENT = "tz_ipc_sensor_monitor_data_list";
/**
* 操作侧简写
*/
@ -99,4 +99,14 @@ public class IpcConstant {
*/
public static final String RUNNING_STATUS_RUNNING = "4";
/**
* 规则类型-试运行
*/
public static final String RULE_TYPE_TRIAL_RUN = "trial_run";
/**
* 规则类型-运行中
*/
public static final String RULE_TYPE_IN_RUNNING = "in_running";
}

View File

@ -71,22 +71,21 @@ 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, String type, List<IpcAlarmRulesConfig> rulesConfigList) {
List<IpcAlarmRecord> returnList = new ArrayList<>();
String isAlarm = "0";
for (IpcAlarmRulesConfig rulesConfig : rulesConfigList) {
// 判断是否当前参数类型
if (type.equals(rulesConfig.getType())) {
if (judgeAlarm(map.get(rulesConfig.getNameKey()), rulesConfig.getReferenceValue1(), rulesConfig.getReferenceValue2(), rulesConfig.getReferenceCon())) {
// 报警数据
tags.put("isAlarm", "1");
IpcAlarmRecord ipcAlarmRecord = new IpcAlarmRecord(IdUtils.fastSimpleUUID(),rulesConfig.getPartKey(), rulesConfig.getPart(), rulesConfig.getNameKey(), rulesConfig.getName(), String.valueOf(map.get(rulesConfig.getNameKey())), rulesConfig.getUnit(), rulesConfig.getAlarmLevel(), rulesConfig.getReferenceName(), rulesConfig.getAlarmDetail(),rulesConfig.getId());
isAlarm = "1";
IpcAlarmRecord ipcAlarmRecord = new IpcAlarmRecord(IdUtils.fastSimpleUUID(), rulesConfig.getPartKey(), rulesConfig.getPart(), rulesConfig.getNameKey(), rulesConfig.getName(), String.valueOf(map.get(rulesConfig.getNameKey())), rulesConfig.getUnit(), rulesConfig.getAlarmLevel(), rulesConfig.getReferenceName(), rulesConfig.getAlarmDetail(), rulesConfig.getId());
returnList.add(ipcAlarmRecord);
} else {
// 正常数据
tags.put("isAlarm", "0");
}
}
}
tags.put("isAlarm", isAlarm);
return returnList;
}
}

View File

@ -1,18 +1,64 @@
<template>
<div class="app-container image-background">
<el-select
v-model="part"
placeholder="请选择监测部位"
@change="getList()"
<el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-option
v-for="field in monitorPartList"
:key="field.fieldValue"
:label="field.fieldLabel"
:value="field.fieldValue"
/>
</el-select>
<div class="content-but">
<el-form-item
label="监测部位"
prop="part"
>
<el-select
v-model="queryParams.part"
placeholder="请选择监测部位"
@change="getList()"
>
<el-option
v-for="field in monitorPartList"
:key="field.fieldValue"
:label="field.fieldLabel"
:value="field.fieldValue"
/>
</el-select>
</el-form-item>
<el-form-item
label="是否报警"
prop="alarmLevel"
>
<el-select
v-model="queryParams.isAlarm"
placeholder="请选择是否报警"
clearable
>
<el-option
v-for="dict in dict.type.is_alarm"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item
label="时间范围"
prop="datetimerange"
>
<el-date-picker
class="picker"
v-model="queryParams.datetimerange"
type="datetimerange"
:picker-options="pickerOptions"
range-separator="至"
start-placeholder="开始时间"
end-placeholder="结束时间"
>
</el-date-picker>
</el-form-item>
</el-form>
<!-- <div class="content-but">
<div
v-if="refresh"
class="button-start"
@ -23,7 +69,7 @@
class="button-stop"
@click="startRefresh"
>自动刷新</div>
</div>
</div> -->
<el-table
class="tableCss"
v-loading="loading"
@ -48,6 +94,18 @@
width="200"
show-overflow-tooltip
/>
<el-table-column
label="颗粒度4μm"
align="center"
key="rstatus"
prop="rstatus"
show-overflow-tooltip
>
<dict-tag
:options="dict.type.running_status"
:value="scope.row.rstatus"
/>
</el-table-column>
<el-table-column
label="颗粒度4μm"
align="center"
@ -119,7 +177,13 @@
show-overflow-tooltip
/>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</div>
</template>
@ -129,6 +193,7 @@ import { getFields } from "@/api/ipc/monitorFields";
export default {
name: "plcDataLog",
dicts: ["is_alarm"],
data() {
return {
//
@ -139,12 +204,66 @@ export default {
queryParams: {
pageNum: 1,
pageSize: 10,
part: null,
isAlarm: null,
datetimerange: [],
startTime: null,
endTime: null,
},
//
monitorPartList: [],
part: "",
dataList: [],
refresh: false,
pickerOptions: {
shortcuts: [
{
text: "最近一小时",
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000);
picker.$emit("pick", [start, end]);
},
},
{
text: "最近一天",
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24);
picker.$emit("pick", [start, end]);
},
},
{
text: "最近一周",
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit("pick", [start, end]);
},
},
{
text: "最近一个月",
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
picker.$emit("pick", [start, end]);
},
},
{
text: "最近三个月",
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
picker.$emit("pick", [start, end]);
},
},
],
},
};
},
created() {
@ -165,6 +284,14 @@ export default {
},
/** 查询列表 */
getList() {
if (this.queryParams.datetimerange && this.queryParams.datetimerange[0]) {
this.queryParams.startTime = this.dateToStr(
this.queryParams.datetimerange[0]
);
this.queryParams.endTime = this.dateToStr(
this.queryParams.datetimerange[1]
);
}
this.loading = true;
getPlcDataLog(this.part).then((response) => {
this.dataList = response.data;
@ -191,7 +318,7 @@ export default {
};
</script>
<style lang="scss">
@import '@/theme/index.scss';
@import "@/theme/index.scss";
.color-row {
@include background_color(tableRowBackgroundColor);
}

View File

@ -13,7 +13,7 @@
prop="alarmLevel"
>
<el-select
v-model="queryParams.alarmLevel"
v-model="queryParams.type"
placeholder="请选择规则类型"
>
<el-option