报警处理菜单增加可选报警趋势查询功能

This commit is contained in:
zhangjunwen 2024-09-30 17:09:54 +08:00
parent 118ad97a8d
commit c8052ffa72
10 changed files with 235 additions and 51 deletions

View File

@ -64,12 +64,12 @@ public class DataQueryController {
@PreAuthorize("@ss.hasPermission('data:query:list')") @PreAuthorize("@ss.hasPermission('data:query:list')")
public CommonResult<Map<String, Object>> getFieldList(String equipId,String nameKey,String tableName, String startTime, String endTime){ public CommonResult<Map<String, Object>> getFieldList(String equipId,String nameKey,String tableName, String startTime, String endTime){
Map<String,Object> resMap = new HashMap<>(); Map<String,Object> resMap = new HashMap<>();
Map<String,String> mappingMap = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get("alarmKey2MeasurementMapping"),Map.class); // Map<String,String> mappingMap = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get("alarmKey2MeasurementMapping"),Map.class);
if (!mappingMap.containsKey(nameKey)){ // if (!mappingMap.containsKey(nameKey)){
return CommonResult.error(800,"找不到给参数匹配名对应的表名!"); // return CommonResult.error(800,"找不到给参数匹配名对应的表名!");
} // }
try { try {
resMap = dataQueryService.queryDataListByColumnNameandDate(equipId,mappingMap.get(nameKey),nameKey,startTime,endTime); resMap = dataQueryService.queryDataListByColumnNameandDate(equipId,tableName,nameKey,startTime,endTime);
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
return CommonResult.error(800,"时间格式错误"); return CommonResult.error(800,"时间格式错误");

View File

@ -43,7 +43,7 @@ public class InfluxDBService {
@PostConstruct @PostConstruct
public void initInfluxDb() { public void initInfluxDb() {
alarmKey2MeasurementMapping();//influxDB报警键值与表名映射 //alarmKey2MeasurementMapping();//influxDB报警键值与表名映射
LOGGER.info("-->>开始连接influxDB数据库"); LOGGER.info("-->>开始连接influxDB数据库");
this.retentionPolicy = retentionPolicy == null || "".equals(retentionPolicy) ? "autogen" : retentionPolicy; this.retentionPolicy = retentionPolicy == null || "".equals(retentionPolicy) ? "autogen" : retentionPolicy;
this.influxDB = influxDbBuild(); this.influxDB = influxDbBuild();
@ -59,26 +59,26 @@ public class InfluxDBService {
// insert(measurement, tags, fields); // insert(measurement, tags, fields);
// } // }
public void alarmKey2MeasurementMapping(){ // public void alarmKey2MeasurementMapping(){
Map<String,String> alarmKey2MeasurementMapping = new HashMap<>(); // Map<String,String> alarmKey2MeasurementMapping = new HashMap<>();
alarmKey2MeasurementMapping.put("x_push_temp", "gateway_channel_current_data"); // alarmKey2MeasurementMapping.put("x_push_temp", "gateway_channel_current_data");
alarmKey2MeasurementMapping.put("y_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("x_lube_press", "gateway_channel_hydra_data");
alarmKey2MeasurementMapping.put("y_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("z_lube_press", "gateway_channel_hydra_data");
alarmKey2MeasurementMapping.put("at_temp", "gateway_channel_temp_data"); // alarmKey2MeasurementMapping.put("at_temp", "gateway_channel_temp_data");
alarmKey2MeasurementMapping.put("x_bear_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("y_bear_temp", "gateway_channel_temp_data");
alarmKey2MeasurementMapping.put("z_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("x_debris_temp", "gateway_channel_temp_data");
alarmKey2MeasurementMapping.put("z_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("x_entropy", "gateway_channel_vibr_data");
alarmKey2MeasurementMapping.put("on_time", "gateway_channel_work_data"); // alarmKey2MeasurementMapping.put("on_time", "gateway_channel_work_data");
alarmKey2MeasurementMapping.put("work_items", "gateway_channel_work_data"); // alarmKey2MeasurementMapping.put("work_items", "gateway_channel_work_data");
alarmKey2MeasurementMapping.put("work_time", "gateway_channel_work_data"); // alarmKey2MeasurementMapping.put("work_time", "gateway_channel_work_data");
alarmKey2MeasurementMapping.put("work_total", "gateway_channel_work_data"); // alarmKey2MeasurementMapping.put("work_total", "gateway_channel_work_data");
stringRedisTemplate.opsForValue().set("alarmKey2MeasurementMapping", JsonUtils.toJsonString(alarmKey2MeasurementMapping)); // stringRedisTemplate.opsForValue().set("alarmKey2MeasurementMapping", JsonUtils.toJsonString(alarmKey2MeasurementMapping));
} // }
/** /**
* 设置数据保存策略 defalut 策略名 /database 数据库名/ 30d 数据保存时限30天/ 1 副本个数为1/ 结尾DEFAULT * 设置数据保存策略 defalut 策略名 /database 数据库名/ 30d 数据保存时限30天/ 1 副本个数为1/ 结尾DEFAULT

View File

@ -71,6 +71,14 @@ public class GatewayCardInfoController {
return success(BeanUtils.toBean(gatewayCardInfo, GatewayCardInfoRespVO.class)); 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<List<TreeSelect>> getGatewayCardTree(@RequestParam("equipId") String equipId) {
return success(gatewayCardInfoService.getGatewayCardInfoTreeByEquipId(equipId));
}
@GetMapping("/page") @GetMapping("/page")
@Operation(summary = "获得机床网关采集卡分页") @Operation(summary = "获得机床网关采集卡分页")
@PreAuthorize("@ss.hasPermission('imt:gateway-info:create')") @PreAuthorize("@ss.hasPermission('imt:gateway-info:create')")

View File

@ -30,6 +30,10 @@ public class GatewayCardInfoRespVO {
@ExcelProperty("采集卡名称") @ExcelProperty("采集卡名称")
private String cardName; private String cardName;
@Schema(description = "采集卡别名")
@ExcelProperty("采集卡别名")
private String cardAlias;
@Schema(description = "采集卡与influxdb映射表名") @Schema(description = "采集卡与influxdb映射表名")
@ExcelProperty("采集卡与influxdb映射表名") @ExcelProperty("采集卡与influxdb映射表名")
private String cardTableMapping; private String cardTableMapping;

View File

@ -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<TreeSelect> 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();
}
}

View File

@ -56,4 +56,10 @@ public interface GatewayCardInfoService {
* 通过网关id获取采集卡列表 * 通过网关id获取采集卡列表
*/ */
List<GatewayCardInfoDO> getGatewayCardInfoListByGatewayId(String gatewayId); List<GatewayCardInfoDO> getGatewayCardInfoListByGatewayId(String gatewayId);
/**
* 通过设备id获取采集卡网关下拉树数据
*/
List<TreeSelect> getGatewayCardInfoTreeByEquipId(String equipId);
} }

View File

@ -1,5 +1,7 @@
package com.inspur.module.system.service.gatewayinfo; 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.Component;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -7,6 +9,8 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
import com.inspur.module.system.controller.admin.gatewayinfo.vo.*; import com.inspur.module.system.controller.admin.gatewayinfo.vo.*;
import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayCardInfoDO; import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayCardInfoDO;
import com.inspur.framework.common.pojo.PageResult; import com.inspur.framework.common.pojo.PageResult;
@ -30,6 +34,9 @@ public class GatewayCardInfoServiceImpl implements GatewayCardInfoService {
@Resource @Resource
private GatewayCardInfoMapper gatewayCardInfoMapper; private GatewayCardInfoMapper gatewayCardInfoMapper;
@Resource
private GatewayCardParamsMapper gatewayCardParamsMapper;
@Override @Override
public String createGatewayCardInfo(GatewayCardInfoSaveReqVO createReqVO) { public String createGatewayCardInfo(GatewayCardInfoSaveReqVO createReqVO) {
// 插入 // 插入
@ -79,4 +86,24 @@ public class GatewayCardInfoServiceImpl implements GatewayCardInfoService {
public List<GatewayCardInfoDO> getGatewayCardInfoListByGatewayId(String gatewayId){ public List<GatewayCardInfoDO> getGatewayCardInfoListByGatewayId(String gatewayId){
return gatewayCardInfoMapper.selectList(GatewayCardInfoDO::getGatewayId, gatewayId); return gatewayCardInfoMapper.selectList(GatewayCardInfoDO::getGatewayId, gatewayId);
} }
/**
* 通过设备id获取采集卡网关下拉树数据
*/
public List<TreeSelect> getGatewayCardInfoTreeByEquipId(String equipId){
List<TreeSelect> resList = new ArrayList<>();
//根据设备id查询采集卡列表
List<GatewayCardInfoDO> cardList = gatewayCardInfoMapper.selectList(GatewayCardInfoDO::getEquipId, equipId);
//根据设备id查询采集卡参数列表
List<GatewayCardParamsDO> paramsList = gatewayCardParamsMapper.selectList(GatewayCardParamsDO::getEquipId, equipId);
for (GatewayCardInfoDO gatewayCardInfoDO : cardList) {
TreeSelect treeSelect = new TreeSelect(gatewayCardInfoDO);
List<TreeSelect> paramsTreeList = paramsList.stream().filter(params -> params.getCardId().equals(gatewayCardInfoDO.getCardId())).map(TreeSelect::new).collect(Collectors.toList());
treeSelect.setChildren(paramsTreeList);
resList.add(treeSelect);
}
return resList;
}
} }

View File

@ -33,6 +33,7 @@ export const DICT_TYPE = {
ALARM_TYPE: "equip_alarm_type", ALARM_TYPE: "equip_alarm_type",
CARD_TYPE: "card_type", CARD_TYPE: "card_type",
MSG_TYPE: "msg_type", MSG_TYPE: "msg_type",
CARD_ALIAS: "card_alias",
EQUIP_RUN_STATUS: "equip_run_status", EQUIP_RUN_STATUS: "equip_run_status",
// ========== SYSTEM 模块 ========== // ========== SYSTEM 模块 ==========
SYSTEM_USER_SEX: "system_user_sex", SYSTEM_USER_SEX: "system_user_sex",

View File

@ -296,42 +296,78 @@ export default {
}, },
getEchartData1(data, info) { getEchartData1(data, info) {
if (data == null) { if (data == null) {
this.initchart1([], "", ""); this.initchart1(
{
time: [],
},
"",
""
);
} else { } else {
this.initchart1(data, info.name, info.unit); this.initchart1(data, info.name, info.unit);
} }
}, },
getEchartData2(data, info) { getEchartData2(data, info) {
if (data == null) { if (data == null) {
this.initchart2([], "", ""); this.initchart2(
{
time: [],
},
"",
""
);
} else { } else {
this.initchart2(data, info.name, info.unit); this.initchart2(data, info.name, info.unit);
} }
}, },
getEchartData3(data, info) { getEchartData3(data, info) {
if (data == null) { if (data == null) {
this.initchart3([], "", ""); this.initchart3(
{
time: [],
},
"",
""
);
} else { } else {
this.initchart3(data, info.name, info.unit); this.initchart3(data, info.name, info.unit);
} }
}, },
getEchartData4(data, info) { getEchartData4(data, info) {
if (data == null) { if (data == null) {
this.initchart4([], "", ""); this.initchart4(
{
time: [],
},
"",
""
);
} else { } else {
this.initchart4(data, info.name, info.unit); this.initchart4(data, info.name, info.unit);
} }
}, },
getEchartData5(data, info) { getEchartData5(data, info) {
if (data == null) { if (data == null) {
this.initchart5([], "", ""); this.initchart5(
{
time: [],
},
"",
""
);
} else { } else {
this.initchart5(data, info.name, info.unit); this.initchart5(data, info.name, info.unit);
} }
}, },
getEchartData6(data, info) { getEchartData6(data, info) {
if (data == null) { if (data == null) {
this.initchart6([], "", ""); this.initchart6(
{
time: [],
},
"",
""
);
} else { } else {
let work_time = []; let work_time = [];
let power_time = []; let power_time = [];
@ -428,10 +464,10 @@ export default {
name: "单位: " + unit, name: "单位: " + unit,
type: "value", type: "value",
nameLocation: "end", nameLocation: "end",
nameTextStyle: { // nameTextStyle: {
color: "#fff", // color: "#fff",
fontSize: "9", // fontSize: "9",
}, // },
axisLine: { axisLine: {
show: false, show: false,
}, },
@ -467,7 +503,6 @@ export default {
xAxisIndex: 0, xAxisIndex: 0,
filterMode: "none", filterMode: "none",
start: 0, start: 0,
end: data.time.length,
bottom: "1%", bottom: "1%",
fillerColor: "rgba(167,183,204,0.4)", // fillerColor: "rgba(167,183,204,0.4)", //
borderColor: "#3C506B", borderColor: "#3C506B",
@ -478,7 +513,7 @@ export default {
xAxisIndex: 0, xAxisIndex: 0,
filterMode: "none", filterMode: "none",
start: 0, start: 0,
end: 10, end: 100,
bottom: "1%", bottom: "1%",
fillerColor: "rgba(167,183,204,0.4)", // fillerColor: "rgba(167,183,204,0.4)", //
borderColor: "#E0E6F3", borderColor: "#E0E6F3",
@ -586,10 +621,10 @@ export default {
name: "单位: " + unit, name: "单位: " + unit,
type: "value", type: "value",
nameLocation: "end", nameLocation: "end",
nameTextStyle: { // nameTextStyle: {
color: "#fff", // color: "#fff",
fontSize: "9", // fontSize: "9",
}, // },
axisLine: { axisLine: {
show: false, show: false,
}, },
@ -625,7 +660,7 @@ export default {
xAxisIndex: 0, xAxisIndex: 0,
filterMode: "none", filterMode: "none",
start: 0, start: 0,
end: data.time.length, end: 100,
bottom: "1%", bottom: "1%",
fillerColor: "rgba(167,183,204,0.4)", // fillerColor: "rgba(167,183,204,0.4)", //
borderColor: "#3C506B", borderColor: "#3C506B",
@ -762,10 +797,10 @@ export default {
name: "单位: " + unit, name: "单位: " + unit,
type: "value", type: "value",
nameLocation: "end", nameLocation: "end",
nameTextStyle: { // nameTextStyle: {
color: "#fff", // color: "#fff",
fontSize: "9", // fontSize: "9",
}, // },
axisLine: { axisLine: {
show: false, show: false,
}, },
@ -801,7 +836,7 @@ export default {
xAxisIndex: 0, xAxisIndex: 0,
filterMode: "none", filterMode: "none",
start: 0, start: 0,
end: data.time.length, end: 100,
bottom: "1%", bottom: "1%",
fillerColor: "rgba(167,183,204,0.4)", // fillerColor: "rgba(167,183,204,0.4)", //
borderColor: "#3C506B", borderColor: "#3C506B",
@ -1023,7 +1058,7 @@ export default {
xAxisIndex: 0, xAxisIndex: 0,
filterMode: "none", filterMode: "none",
start: 0, start: 0,
end: data.time.length, end: 100,
bottom: "1%", bottom: "1%",
fillerColor: "rgba(167,183,204,0.4)", // fillerColor: "rgba(167,183,204,0.4)", //
borderColor: "#3C506B", borderColor: "#3C506B",
@ -1245,7 +1280,7 @@ export default {
xAxisIndex: 0, xAxisIndex: 0,
filterMode: "none", filterMode: "none",
start: 0, start: 0,
end: data.time.length, end: 100,
bottom: "1%", bottom: "1%",
fillerColor: "rgba(167,183,204,0.4)", // fillerColor: "rgba(167,183,204,0.4)", //
borderColor: "#3C506B", borderColor: "#3C506B",
@ -1449,7 +1484,7 @@ export default {
xAxisIndex: 0, xAxisIndex: 0,
filterMode: "none", filterMode: "none",
start: 0, start: 0,
end: data.time.length, end: 100,
bottom: "1%", bottom: "1%",
fillerColor: "rgba(167,183,204,0.4)", // fillerColor: "rgba(167,183,204,0.4)", //
borderColor: "#3C506B", borderColor: "#3C506B",

View File

@ -91,6 +91,25 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12">
<el-form-item
label="采集数据名"
prop="cardAlias"
>
<el-select
v-model="formData.cardAlias"
placeholder="请选择采集卡数据名"
style="width:100%"
>
<el-option
v-for="dict in this.getDictDatas(DICT_TYPE.CARD_ALIAS)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
</el-form> </el-form>
<div class="add-table"> <div class="add-table">
<el-form <el-form
@ -141,6 +160,20 @@
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column
prop="channelAlias"
label="参数名"
align="center"
>
<template slot-scope="scope">
<el-form-item
:prop="'paramsList['+scope.$index+'].channelAlias'"
:rules="paramsRules.channelAlias"
>
<el-input v-model="scope.row.channelAlias" />
</el-form-item>
</template>
</el-table-column>
<!-- <el-table-column <!-- <el-table-column
align="center" align="center"
v-for="(item,index) in dataList" v-for="(item,index) in dataList"
@ -265,6 +298,13 @@ export default {
trigger: "blur", trigger: "blur",
}, },
], ],
cardAlias: [
{
required: true,
message: "采集数据名类型不能为空",
trigger: "blur",
},
],
paramsList: { paramsList: {
channelName: [ channelName: [
{ {
@ -290,6 +330,18 @@ export default {
trigger: "blur", trigger: "blur",
}, },
], ],
channelAlias: [
{
required: true,
message: "参数名不能为空",
trigger: "blur",
},
{
max: 50,
message: "参数名长度不能超过50个字符",
trigger: "blur",
},
],
}, },
}, },
// //
@ -332,6 +384,7 @@ export default {
var addObj = { var addObj = {
channelName: "", channelName: "",
paramMappingName: "", paramMappingName: "",
channelAlias: "",
}; };
// this.dataList.forEach((el) => { // this.dataList.forEach((el) => {
// addObj[el.code] = ""; // addObj[el.code] = "";