优化振动数据展示,移除无用代码

This commit is contained in:
zhanghan11 2024-04-12 11:10:44 +08:00
parent 2559b597f5
commit 7e3e34e2b9
5 changed files with 78 additions and 115 deletions

View File

@ -74,15 +74,6 @@ public class IPCDataSyncTask implements ApplicationRunner {
threadPoolTaskExecutor.execute(new IPCPlcDataSyncThread(null, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS").format(new Date())));
}
}, 1000, 1000);
//
// final Timer timer2 = new Timer();
// timer2.schedule(new TimerTask() {
// @Override
// public void run() {
// threadPoolTaskExecutor.execute(new IPCSensorDataSyncThread(null, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS").format(new Date())));
// }
// }, 1000, 1000*60*10);
//
final Timer timer3 = new Timer();
timer3.schedule(new TimerTask() {
@Override

View File

@ -1,86 +0,0 @@
package com.inspur.datasyn.modbus;
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;
import com.inspur.ipc.utils.IpcUtil;
import com.inspur.system.service.influx.InfluxDBService;
import com.serotonin.modbus4j.ModbusMaster;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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);
private ModbusMaster master;
private String time;
public IPCSensorDataSyncThread(ModbusMaster master, String time) {
this.master = master;
this.time = time;
}
@Override
public void run() {
try {
// 获取service
IIpcMonitorFieldService iIpcMonitorFieldService = SpringUtils.getBean(IIpcMonitorFieldService.class);
// 获取当前时间
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
String format = simpleDateFormat.format(new Date());
// 温振数据
List<IpcMonitorField> partList = iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.MONITOR_PART_KEY);
List<IpcMonitorField> sensorList = iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.SENSOR_MONITOR_PARAMS_KEY);
// 字典数据列表集合
for (IpcMonitorField part : partList) {
Map<String, String> tags = new TreeMap();
tags.put("part", part.getFieldValue());
Map<String, Object> fields = new TreeMap();
for (IpcMonitorField field : sensorList) {
// 可以配置源字段获取时通过源字段获取数据
// field.getSourceField()
if(field.getFieldValue().equals("ssat")) {
fields.put(field.getFieldValue(), Math.random()+"");
}else{
fields.put(field.getFieldValue(), getData());
}
}
fields.put("insertTime", format);
InfluxDBService i = SpringUtils.getBean(InfluxDBService.class);
i.insert(IpcConstant.SENSOR_MEASUREMENT, tags, fields);
}
} catch (Exception e) {
logger.info("数据处理失败,时间{}{}", new Date(), e.getMessage());
e.printStackTrace();
}
}
private String getData() {
List<String> list = new ArrayList<>();
for (int i = 0; i < 60; i++) {
list.add(Math.random()+"");
}
return list.stream().map(String::valueOf).collect(Collectors.joining(IpcConstant.DATA_SEPARATOR));
}
private String getDate() {
List<String> list = new ArrayList<>();
for (int i = 0; i < 60; i++) {
list.add(LocalDateTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss:SSS")));
}
return list.stream().map(String::valueOf).collect(Collectors.joining(IpcConstant.DATA_SEPARATOR));
}
}

View File

@ -154,8 +154,6 @@ public class IpcDataShowServiceImpl implements IIpcDataShowService {
QueryResult sensorQuery = influxDBService.query("select * from " + IpcConstant.SENSOR_MEASUREMENT + " where part = '" + part + "' order by time desc limit 1");
List<Map<String, Object>> sensorMaps = influxDBService.queryResultProcess(sensorQuery);
// 传感器温振数据处理
// 横轴时间轴
List<String> xSensorData = new ArrayList<>();
//振动温度
Object ssat;
//振动x轴
@ -168,10 +166,9 @@ public class IpcDataShowServiceImpl implements IIpcDataShowService {
ssat = sensorMap.get("ssat") == null ? "0" : String.valueOf(sensorMap.get("ssat"));
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("stime") == null ? new ArrayList<>() : Arrays.asList(String.valueOf(sensorMap.get("vz")).split(IpcConstant.DATA_SEPARATOR)));
vz.addAll(sensorMap.get("vz") == null ? new ArrayList<>() : Arrays.asList(String.valueOf(sensorMap.get("vz")).split(IpcConstant.DATA_SEPARATOR)));
// 返回数据
Map<String, Object> map = new HashMap<>();
map.put("xSensorData", xSensorData);
map.put("ssat", ssat);
map.put("vx", vx);
map.put("vy", vy);

View File

@ -25,23 +25,18 @@
curImageIndex = 1
handleTypeChange(['rtd', 'rto'])
}"></div>
<div
@click="() => {
<div @click="() => {
curImageIndex = 2
handleTypeChange(['ftd', 'fto'])
}"
></div>
<div
@click="() => {
}"></div>
<div @click="() => {
curImageIndex = 3
handleTypeChange(['rbd', 'rbo'])
}"></div>
<div
@click="() => {
<div @click="() => {
curImageIndex = 4
handleTypeChange(['fbd', 'fbo'])
}"
></div>
}"></div>
</div>
</div>
<div class="grid-item-wrapper">
@ -407,6 +402,8 @@ export default {
fbd: "F下辊传动侧",
fbo: "F下辊操作侧",
},
xSensorData: [],
//
//
loading: true,
@ -469,10 +466,11 @@ export default {
],
},
curImageIndex: 1
curImageIndex: 1,
};
},
mounted() {
this.getXSensorData();
this.timer = setInterval(() => {
this.initData(this.queryParams);
}, 1000);
@ -482,6 +480,12 @@ export default {
clearInterval(this.timer);
},
methods: {
//** */
getXSensorData() {
for (let i = 1; i <= 1024; i++) {
this.xSensorData.push(i);
}
},
//
handleViewTendency(partKey, part, nameKey, name, unit) {
this.open = true;
@ -640,8 +644,8 @@ export default {
const { drive, operation } = data;
//
if (drive) {
const { xSensorData, vx, vy, vz } = drive;
this.initChart2(xSensorData, vx, vy, vz);
const { vx, vy, vz } = drive;
this.initChart2(this.xSensorData, vx, vy, vz);
const { xPlcData, pz4, pz6, pz14, pz21 } = drive;
this.initChart4(xPlcData, pz4, pz6, pz14, pz21);
@ -660,8 +664,8 @@ export default {
}
//
if (operation) {
const { xSensorData, vx, vy, vz } = operation;
this.initChart1(xSensorData, vx, vy, vz);
const { vx, vy, vz } = operation;
this.initChart1(this.xSensorData, vx, vy, vz);
const { xPlcData, pz4, pz6, pz14, pz21 } = operation;
this.initChart3(xPlcData, pz4, pz6, pz14, pz21);
@ -719,6 +723,30 @@ export default {
grid: {
bottom: "20%",
},
dataZoom: [
{
show: true,
type: "slider",
xAxisIndex: 0,
filterMode: "none",
start: 0,
end: xAxis.length,
bottom: "1%",
fillerColor: "rgba(167,183,204,0.4)", //
borderColor: "#3C506B",
},
{
show: true,
type: "inside",
xAxisIndex: 0,
filterMode: "none",
start: 0,
end: 10,
bottom: "1%",
fillerColor: "rgba(167,183,204,0.4)", //
borderColor: "#E0E6F3",
},
],
}),
true,
true
@ -767,6 +795,30 @@ export default {
grid: {
bottom: "20%",
},
dataZoom: [
{
show: true,
type: "slider",
xAxisIndex: 0,
filterMode: "none",
start: 0,
end: xAxis.length,
bottom: "1%",
fillerColor: "rgba(167,183,204,0.4)", //
borderColor: "#3C506B",
},
{
show: true,
type: "inside",
xAxisIndex: 0,
filterMode: "none",
start: 0,
end: 10,
bottom: "1%",
fillerColor: "rgba(167,183,204,0.4)", //
borderColor: "#E0E6F3",
},
],
}),
true,
true

View File

@ -192,6 +192,8 @@ export default {
startTime: null,
endTime: null,
},
//
xData: [],
//
monitorPartList: [],
part: "",
@ -249,12 +251,19 @@ export default {
};
},
created() {
this.getXData();
if (this.$route.query.partKey) {
this.queryParams.part = this.$route.query.partKey;
}
this.getMonitorPartList();
},
methods: {
/** 图谱横轴默认数据 */
getXData() {
for (let i = 1; i <= 1024; i++) {
this.xData.push(i);
}
},
/** 导出数据 */
exportData() {
this.queryParams.pageNum = 1;
@ -312,7 +321,7 @@ export default {
handleView(data) {
this.open = true;
this.initChart(
[],
this.xData,
data.vx.split(","),
data.vy.split(","),
data.vz.split(",")