From c8052ffa7242b0cd8a12bc82d9c0aff10edeb453 Mon Sep 17 00:00:00 2001 From: zhangjunwen Date: Mon, 30 Sep 2024 17:09:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E8=AD=A6=E5=A4=84=E7=90=86=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E5=A2=9E=E5=8A=A0=E5=8F=AF=E9=80=89=E6=8A=A5=E8=AD=A6?= =?UTF-8?q?=E8=B6=8B=E5=8A=BF=E6=9F=A5=E8=AF=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/query/DataQueryController.java | 10 +-- .../module/data/service/InfluxDBService.java | 42 ++++----- .../GatewayCardInfoController.java | 8 ++ .../gatewayinfo/vo/GatewayCardInfoRespVO.java | 4 + .../admin/gatewayinfo/vo/TreeSelect.java | 50 +++++++++++ .../gatewayinfo/GatewayCardInfoService.java | 6 ++ .../GatewayCardInfoServiceImpl.java | 27 ++++++ imt-ui/src/utils/dict.js | 1 + .../data/monitordatadashboard/index.vue | 85 +++++++++++++------ .../system/gatewayinfo/GatewayCardForm.vue | 53 ++++++++++++ 10 files changed, 235 insertions(+), 51 deletions(-) create mode 100644 imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/TreeSelect.java diff --git a/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/controller/admin/query/DataQueryController.java b/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/controller/admin/query/DataQueryController.java index 81e82aa..6865416 100644 --- a/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/controller/admin/query/DataQueryController.java +++ b/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/controller/admin/query/DataQueryController.java @@ -64,12 +64,12 @@ public class DataQueryController { @PreAuthorize("@ss.hasPermission('data:query:list')") public CommonResult> getFieldList(String equipId,String nameKey,String tableName, String startTime, String endTime){ Map resMap = new HashMap<>(); - Map mappingMap = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get("alarmKey2MeasurementMapping"),Map.class); - if (!mappingMap.containsKey(nameKey)){ - return CommonResult.error(800,"找不到给参数匹配名对应的表名!"); - } +// Map mappingMap = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get("alarmKey2MeasurementMapping"),Map.class); +// if (!mappingMap.containsKey(nameKey)){ +// return CommonResult.error(800,"找不到给参数匹配名对应的表名!"); +// } try { - resMap = dataQueryService.queryDataListByColumnNameandDate(equipId,mappingMap.get(nameKey),nameKey,startTime,endTime); + resMap = dataQueryService.queryDataListByColumnNameandDate(equipId,tableName,nameKey,startTime,endTime); } catch (ParseException e) { e.printStackTrace(); return CommonResult.error(800,"时间格式错误"); diff --git a/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/service/InfluxDBService.java b/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/service/InfluxDBService.java index a8f7319..dadaeec 100644 --- a/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/service/InfluxDBService.java +++ b/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/service/InfluxDBService.java @@ -43,7 +43,7 @@ public class InfluxDBService { @PostConstruct public void initInfluxDb() { - alarmKey2MeasurementMapping();//influxDB报警键值与表名映射 + //alarmKey2MeasurementMapping();//influxDB报警键值与表名映射 LOGGER.info("-->>开始连接influxDB数据库"); this.retentionPolicy = retentionPolicy == null || "".equals(retentionPolicy) ? "autogen" : retentionPolicy; this.influxDB = influxDbBuild(); @@ -59,26 +59,26 @@ public class InfluxDBService { // insert(measurement, tags, fields); // } - public void alarmKey2MeasurementMapping(){ - Map alarmKey2MeasurementMapping = new HashMap<>(); - alarmKey2MeasurementMapping.put("x_push_temp", "gateway_channel_current_data"); - alarmKey2MeasurementMapping.put("y_push_temp", "gateway_channel_current_data"); - alarmKey2MeasurementMapping.put("x_lube_press", "gateway_channel_hydra_data"); - alarmKey2MeasurementMapping.put("y_lube_press", "gateway_channel_hydra_data"); - alarmKey2MeasurementMapping.put("z_lube_press", "gateway_channel_hydra_data"); - alarmKey2MeasurementMapping.put("at_temp", "gateway_channel_temp_data"); - alarmKey2MeasurementMapping.put("x_bear_temp", "gateway_channel_temp_data"); - alarmKey2MeasurementMapping.put("y_bear_temp", "gateway_channel_temp_data"); - alarmKey2MeasurementMapping.put("z_bear_temp", "gateway_channel_temp_data"); - alarmKey2MeasurementMapping.put("x_debris_temp", "gateway_channel_temp_data"); - alarmKey2MeasurementMapping.put("z_debris_temp", "gateway_channel_temp_data"); - alarmKey2MeasurementMapping.put("x_entropy", "gateway_channel_vibr_data"); - alarmKey2MeasurementMapping.put("on_time", "gateway_channel_work_data"); - alarmKey2MeasurementMapping.put("work_items", "gateway_channel_work_data"); - alarmKey2MeasurementMapping.put("work_time", "gateway_channel_work_data"); - alarmKey2MeasurementMapping.put("work_total", "gateway_channel_work_data"); - stringRedisTemplate.opsForValue().set("alarmKey2MeasurementMapping", JsonUtils.toJsonString(alarmKey2MeasurementMapping)); - } +// public void alarmKey2MeasurementMapping(){ +// Map alarmKey2MeasurementMapping = new HashMap<>(); +// alarmKey2MeasurementMapping.put("x_push_temp", "gateway_channel_current_data"); +// alarmKey2MeasurementMapping.put("y_push_temp", "gateway_channel_current_data"); +// alarmKey2MeasurementMapping.put("x_lube_press", "gateway_channel_hydra_data"); +// alarmKey2MeasurementMapping.put("y_lube_press", "gateway_channel_hydra_data"); +// alarmKey2MeasurementMapping.put("z_lube_press", "gateway_channel_hydra_data"); +// alarmKey2MeasurementMapping.put("at_temp", "gateway_channel_temp_data"); +// alarmKey2MeasurementMapping.put("x_bear_temp", "gateway_channel_temp_data"); +// alarmKey2MeasurementMapping.put("y_bear_temp", "gateway_channel_temp_data"); +// alarmKey2MeasurementMapping.put("z_bear_temp", "gateway_channel_temp_data"); +// alarmKey2MeasurementMapping.put("x_debris_temp", "gateway_channel_temp_data"); +// alarmKey2MeasurementMapping.put("z_debris_temp", "gateway_channel_temp_data"); +// alarmKey2MeasurementMapping.put("x_entropy", "gateway_channel_vibr_data"); +// alarmKey2MeasurementMapping.put("on_time", "gateway_channel_work_data"); +// alarmKey2MeasurementMapping.put("work_items", "gateway_channel_work_data"); +// alarmKey2MeasurementMapping.put("work_time", "gateway_channel_work_data"); +// alarmKey2MeasurementMapping.put("work_total", "gateway_channel_work_data"); +// stringRedisTemplate.opsForValue().set("alarmKey2MeasurementMapping", JsonUtils.toJsonString(alarmKey2MeasurementMapping)); +// } /** * 设置数据保存策略 defalut 策略名 /database 数据库名/ 30d 数据保存时限30天/ 1 副本个数为1/ 结尾DEFAULT diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/GatewayCardInfoController.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/GatewayCardInfoController.java index 19d9bd2..ec9d3fb 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/GatewayCardInfoController.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/GatewayCardInfoController.java @@ -71,6 +71,14 @@ public class GatewayCardInfoController { return success(BeanUtils.toBean(gatewayCardInfo, GatewayCardInfoRespVO.class)); } + @GetMapping("/getCardTree") + @Operation(summary = "获得机床网关采集卡") + @Parameter(name = "id", description = "编号", required = true, example = "1024") +// @PreAuthorize("@ss.hasPermission('imt:gateway-info:create')") + public CommonResult> getGatewayCardTree(@RequestParam("equipId") String equipId) { + return success(gatewayCardInfoService.getGatewayCardInfoTreeByEquipId(equipId)); + } + @GetMapping("/page") @Operation(summary = "获得机床网关采集卡分页") @PreAuthorize("@ss.hasPermission('imt:gateway-info:create')") diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/GatewayCardInfoRespVO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/GatewayCardInfoRespVO.java index 203359f..8f8774c 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/GatewayCardInfoRespVO.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/GatewayCardInfoRespVO.java @@ -30,6 +30,10 @@ public class GatewayCardInfoRespVO { @ExcelProperty("采集卡名称") private String cardName; + @Schema(description = "采集卡别名") + @ExcelProperty("采集卡别名") + private String cardAlias; + @Schema(description = "采集卡与influxdb映射表名") @ExcelProperty("采集卡与influxdb映射表名") private String cardTableMapping; diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/TreeSelect.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/TreeSelect.java new file mode 100644 index 0000000..0f47d43 --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/TreeSelect.java @@ -0,0 +1,50 @@ +package com.inspur.module.system.controller.admin.gatewayinfo.vo; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayCardInfoDO; +import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayCardParamsDO; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author zhangjunwen + * @create 2024/9/30 + */ +@Data +@NoArgsConstructor +public class TreeSelect { + /** + * 节点ID + */ + private String id; + + /** + * 节点名称 + */ + private String label; + + /** + * 选择的节点值 + */ + private String value; + + + /** + * 子节点 + */ + private List children; + + public TreeSelect(GatewayCardInfoDO gatewayCardInfoDO){ + this.id = gatewayCardInfoDO.getCardId(); + this.label = gatewayCardInfoDO.getCardAlias(); + this.value = "gateway_" +gatewayCardInfoDO.getCardTableMapping() + "_data"; + } + + public TreeSelect(GatewayCardParamsDO gatewayCardParamsDO){ + this.id = gatewayCardParamsDO.getChannelId(); + this.label = gatewayCardParamsDO.getChannelAlias(); + this.value = gatewayCardParamsDO.getParamMappingName(); + } +} diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayCardInfoService.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayCardInfoService.java index d514bca..a108e4d 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayCardInfoService.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayCardInfoService.java @@ -56,4 +56,10 @@ public interface GatewayCardInfoService { * 通过网关id获取采集卡列表 */ List getGatewayCardInfoListByGatewayId(String gatewayId); + + /** + * 通过设备id获取采集卡网关下拉树数据 + */ + List getGatewayCardInfoTreeByEquipId(String equipId); + } \ No newline at end of file diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayCardInfoServiceImpl.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayCardInfoServiceImpl.java index 7982c16..a1584d5 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayCardInfoServiceImpl.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayCardInfoServiceImpl.java @@ -1,5 +1,7 @@ package com.inspur.module.system.service.gatewayinfo; +import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayCardParamsDO; +import com.inspur.module.system.dal.mysql.gatewayinfo.GatewayCardParamsMapper; import org.springframework.stereotype.Component; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -7,6 +9,8 @@ import org.springframework.validation.annotation.Validated; import org.springframework.transaction.annotation.Transactional; import java.util.*; +import java.util.stream.Collectors; + import com.inspur.module.system.controller.admin.gatewayinfo.vo.*; import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayCardInfoDO; import com.inspur.framework.common.pojo.PageResult; @@ -30,6 +34,9 @@ public class GatewayCardInfoServiceImpl implements GatewayCardInfoService { @Resource private GatewayCardInfoMapper gatewayCardInfoMapper; + @Resource + private GatewayCardParamsMapper gatewayCardParamsMapper; + @Override public String createGatewayCardInfo(GatewayCardInfoSaveReqVO createReqVO) { // 插入 @@ -79,4 +86,24 @@ public class GatewayCardInfoServiceImpl implements GatewayCardInfoService { public List getGatewayCardInfoListByGatewayId(String gatewayId){ return gatewayCardInfoMapper.selectList(GatewayCardInfoDO::getGatewayId, gatewayId); } + + /** + * 通过设备id获取采集卡网关下拉树数据 + */ + public List getGatewayCardInfoTreeByEquipId(String equipId){ + List resList = new ArrayList<>(); + //根据设备id查询采集卡列表 + List cardList = gatewayCardInfoMapper.selectList(GatewayCardInfoDO::getEquipId, equipId); + + //根据设备id查询采集卡参数列表 + List paramsList = gatewayCardParamsMapper.selectList(GatewayCardParamsDO::getEquipId, equipId); + + for (GatewayCardInfoDO gatewayCardInfoDO : cardList) { + TreeSelect treeSelect = new TreeSelect(gatewayCardInfoDO); + List paramsTreeList = paramsList.stream().filter(params -> params.getCardId().equals(gatewayCardInfoDO.getCardId())).map(TreeSelect::new).collect(Collectors.toList()); + treeSelect.setChildren(paramsTreeList); + resList.add(treeSelect); + } + return resList; + } } \ No newline at end of file diff --git a/imt-ui/src/utils/dict.js b/imt-ui/src/utils/dict.js index 0f8f965..317011c 100644 --- a/imt-ui/src/utils/dict.js +++ b/imt-ui/src/utils/dict.js @@ -33,6 +33,7 @@ export const DICT_TYPE = { ALARM_TYPE: "equip_alarm_type", CARD_TYPE: "card_type", MSG_TYPE: "msg_type", + CARD_ALIAS: "card_alias", EQUIP_RUN_STATUS: "equip_run_status", // ========== SYSTEM 模块 ========== SYSTEM_USER_SEX: "system_user_sex", diff --git a/imt-ui/src/views/system/data/monitordatadashboard/index.vue b/imt-ui/src/views/system/data/monitordatadashboard/index.vue index 861655e..edee068 100644 --- a/imt-ui/src/views/system/data/monitordatadashboard/index.vue +++ b/imt-ui/src/views/system/data/monitordatadashboard/index.vue @@ -296,42 +296,78 @@ export default { }, getEchartData1(data, info) { if (data == null) { - this.initchart1([], "", ""); + this.initchart1( + { + time: [], + }, + "", + "" + ); } else { this.initchart1(data, info.name, info.unit); } }, getEchartData2(data, info) { if (data == null) { - this.initchart2([], "", ""); + this.initchart2( + { + time: [], + }, + "", + "" + ); } else { this.initchart2(data, info.name, info.unit); } }, getEchartData3(data, info) { if (data == null) { - this.initchart3([], "", ""); + this.initchart3( + { + time: [], + }, + "", + "" + ); } else { this.initchart3(data, info.name, info.unit); } }, getEchartData4(data, info) { if (data == null) { - this.initchart4([], "", ""); + this.initchart4( + { + time: [], + }, + "", + "" + ); } else { this.initchart4(data, info.name, info.unit); } }, getEchartData5(data, info) { if (data == null) { - this.initchart5([], "", ""); + this.initchart5( + { + time: [], + }, + "", + "" + ); } else { this.initchart5(data, info.name, info.unit); } }, getEchartData6(data, info) { if (data == null) { - this.initchart6([], "", ""); + this.initchart6( + { + time: [], + }, + "", + "" + ); } else { let work_time = []; let power_time = []; @@ -428,10 +464,10 @@ export default { name: "单位: " + unit, type: "value", nameLocation: "end", - nameTextStyle: { - color: "#fff", - fontSize: "9", - }, + // nameTextStyle: { + // color: "#fff", + // fontSize: "9", + // }, axisLine: { show: false, }, @@ -467,7 +503,6 @@ export default { xAxisIndex: 0, filterMode: "none", start: 0, - end: data.time.length, bottom: "1%", fillerColor: "rgba(167,183,204,0.4)", //选中范围的填充颜色。 borderColor: "#3C506B", @@ -478,7 +513,7 @@ export default { xAxisIndex: 0, filterMode: "none", start: 0, - end: 10, + end: 100, bottom: "1%", fillerColor: "rgba(167,183,204,0.4)", //选中范围的填充颜色。 borderColor: "#E0E6F3", @@ -586,10 +621,10 @@ export default { name: "单位: " + unit, type: "value", nameLocation: "end", - nameTextStyle: { - color: "#fff", - fontSize: "9", - }, + // nameTextStyle: { + // color: "#fff", + // fontSize: "9", + // }, axisLine: { show: false, }, @@ -625,7 +660,7 @@ export default { xAxisIndex: 0, filterMode: "none", start: 0, - end: data.time.length, + end: 100, bottom: "1%", fillerColor: "rgba(167,183,204,0.4)", //选中范围的填充颜色。 borderColor: "#3C506B", @@ -762,10 +797,10 @@ export default { name: "单位: " + unit, type: "value", nameLocation: "end", - nameTextStyle: { - color: "#fff", - fontSize: "9", - }, + // nameTextStyle: { + // color: "#fff", + // fontSize: "9", + // }, axisLine: { show: false, }, @@ -801,7 +836,7 @@ export default { xAxisIndex: 0, filterMode: "none", start: 0, - end: data.time.length, + end: 100, bottom: "1%", fillerColor: "rgba(167,183,204,0.4)", //选中范围的填充颜色。 borderColor: "#3C506B", @@ -1023,7 +1058,7 @@ export default { xAxisIndex: 0, filterMode: "none", start: 0, - end: data.time.length, + end: 100, bottom: "1%", fillerColor: "rgba(167,183,204,0.4)", //选中范围的填充颜色。 borderColor: "#3C506B", @@ -1245,7 +1280,7 @@ export default { xAxisIndex: 0, filterMode: "none", start: 0, - end: data.time.length, + end: 100, bottom: "1%", fillerColor: "rgba(167,183,204,0.4)", //选中范围的填充颜色。 borderColor: "#3C506B", @@ -1449,7 +1484,7 @@ export default { xAxisIndex: 0, filterMode: "none", start: 0, - end: data.time.length, + end: 100, bottom: "1%", fillerColor: "rgba(167,183,204,0.4)", //选中范围的填充颜色。 borderColor: "#3C506B", diff --git a/imt-ui/src/views/system/gatewayinfo/GatewayCardForm.vue b/imt-ui/src/views/system/gatewayinfo/GatewayCardForm.vue index 49c4dc0..474876c 100644 --- a/imt-ui/src/views/system/gatewayinfo/GatewayCardForm.vue +++ b/imt-ui/src/views/system/gatewayinfo/GatewayCardForm.vue @@ -91,6 +91,25 @@ + + + + + + +
+ + +