diff --git a/tzipc-server/tzipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IPCDataSyncTask.java b/tzipc-server/tzipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IPCDataSyncTask.java index 9b9d211..11d3219 100644 --- a/tzipc-server/tzipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IPCDataSyncTask.java +++ b/tzipc-server/tzipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IPCDataSyncTask.java @@ -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 diff --git a/tzipc-server/tzipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IPCSensorDataSyncThread.java b/tzipc-server/tzipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IPCSensorDataSyncThread.java deleted file mode 100644 index 4327c5a..0000000 --- a/tzipc-server/tzipc-datasyn/src/main/java/com/inspur/datasyn/modbus/IPCSensorDataSyncThread.java +++ /dev/null @@ -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 partList = iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.MONITOR_PART_KEY); - List sensorList = iIpcMonitorFieldService.selectFieldDataByType(CacheConstants.SENSOR_MONITOR_PARAMS_KEY); - // 字典数据列表集合 - for (IpcMonitorField part : partList) { - Map tags = new TreeMap(); - tags.put("part", part.getFieldValue()); - Map 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 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 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)); - } - -} diff --git a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/service/impl/IpcDataShowServiceImpl.java b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/service/impl/IpcDataShowServiceImpl.java index d0736ad..c3720a3 100644 --- a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/service/impl/IpcDataShowServiceImpl.java +++ b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/service/impl/IpcDataShowServiceImpl.java @@ -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> sensorMaps = influxDBService.queryResultProcess(sensorQuery); // 传感器温振数据处理 - // 横轴时间轴 - List 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 map = new HashMap<>(); - map.put("xSensorData", xSensorData); map.put("ssat", ssat); map.put("vx", vx); map.put("vy", vy); diff --git a/tzipc-ui/src/views/ipc/bigscreen/index.vue b/tzipc-ui/src/views/ipc/bigscreen/index.vue index 602e5e9..7272bf7 100644 --- a/tzipc-ui/src/views/ipc/bigscreen/index.vue +++ b/tzipc-ui/src/views/ipc/bigscreen/index.vue @@ -25,23 +25,18 @@ curImageIndex = 1 handleTypeChange(['rtd', 'rto']) }"> -
{ curImageIndex = 2 handleTypeChange(['ftd', 'fto']) - }" - >
-
+
-
{ curImageIndex = 4 handleTypeChange(['fbd', 'fbo']) - }" - >
+ }">
@@ -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 diff --git a/tzipc-ui/src/views/ipc/dataLog/sensorDataLog.vue b/tzipc-ui/src/views/ipc/dataLog/sensorDataLog.vue index c33f4ec..eca739c 100644 --- a/tzipc-ui/src/views/ipc/dataLog/sensorDataLog.vue +++ b/tzipc-ui/src/views/ipc/dataLog/sensorDataLog.vue @@ -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(",")