Commit f3a598ab authored by wujiang's avatar wujiang

添加自定义告警类型

parent ccdf94f2
...@@ -69,4 +69,12 @@ public class EventController { ...@@ -69,4 +69,12 @@ public class EventController {
resultsData = equipAlarmEventServiceImpl.getEquipEvent(current, size, fanGatewayId, equipIndex, frontModule); resultsData = equipAlarmEventServiceImpl.getEquipEvent(current, size, fanGatewayId, equipIndex, frontModule);
return ResponseHelper.buildResponse(resultsData); return ResponseHelper.buildResponse(resultsData);
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "刷新字典API")
@GetMapping("/dic/refresh")
public ResponseModel<String> refresh() {
alarmEventServiceImpl.init();
return ResponseHelper.buildResponse("success");
}
} }
...@@ -47,4 +47,7 @@ public class EquipAlarmEvent { ...@@ -47,4 +47,7 @@ public class EquipAlarmEvent {
@TableField(exist = false) @TableField(exist = false)
private String time; private String time;
@TableField("alarm_group_name")
private String alarmGroupName;
} }
package com.yeejoin.amos.boot.module.jxiop.biz.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
@Data
@Accessors(chain = true)
@TableName("wl_equipment_specific_index_alarm_dic")
public class EquipmentSpecificIndexAlarmDic {
@TableField("value")
private int value;
@TableField("name")
private String name;
}
package com.yeejoin.amos.boot.module.jxiop.biz.mapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.EquipmentSpecificIndexAlarmDic;
public interface EquipmentSpecificIndexAlarmDicMapper extends BaseMapper<EquipmentSpecificIndexAlarmDic> {
}
...@@ -19,7 +19,6 @@ import org.typroject.tyboot.core.rdbms.service.BaseService; ...@@ -19,7 +19,6 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
...@@ -31,6 +30,8 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.ResultsData; ...@@ -31,6 +30,8 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.ResultsData;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.AlarmEvent; import com.yeejoin.amos.boot.module.jxiop.biz.entity.AlarmEvent;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.EquipAlarmEvent; import com.yeejoin.amos.boot.module.jxiop.biz.entity.EquipAlarmEvent;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.EquipmentSpecificIndex; import com.yeejoin.amos.boot.module.jxiop.biz.entity.EquipmentSpecificIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.EquipmentSpecificIndexAlarmDic;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.EquipmentSpecificIndexAlarmDicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.EquipmentSpecificIndexMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.EquipmentSpecificIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.AlarmEventMapper; import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.AlarmEventMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.EquipAlarmEventMapper; import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.EquipAlarmEventMapper;
...@@ -45,11 +46,17 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent ...@@ -45,11 +46,17 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent
private EquipmentSpecificIndexMapper equipmentSpecificIndexMapper; private EquipmentSpecificIndexMapper equipmentSpecificIndexMapper;
@Autowired @Autowired
private EquipmentSpecificIndexAlarmDicMapper equipmentSpecificIndexAlarmDicMapper;
@Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
@Autowired @Autowired
private static Map<String, EquipmentSpecificIndex> map; private static Map<String, EquipmentSpecificIndex> map;
@Autowired
private static Map<Integer, String> typeMap;
@PostConstruct @PostConstruct
public void init() { public void init() {
QueryWrapper<EquipmentSpecificIndex> wrapper = new QueryWrapper<>(); QueryWrapper<EquipmentSpecificIndex> wrapper = new QueryWrapper<>();
...@@ -57,12 +64,16 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent ...@@ -57,12 +64,16 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent
List<EquipmentSpecificIndex> list = equipmentSpecificIndexMapper.selectList(wrapper); List<EquipmentSpecificIndex> list = equipmentSpecificIndexMapper.selectList(wrapper);
map = list.stream().collect(Collectors.toMap(EquipmentSpecificIndex::getEquipmentSpecificName, map = list.stream().collect(Collectors.toMap(EquipmentSpecificIndex::getEquipmentSpecificName,
Function.identity(), (key1, key2) -> key2)); Function.identity(), (key1, key2) -> key2));
List<EquipmentSpecificIndexAlarmDic> typelist = equipmentSpecificIndexAlarmDicMapper.selectList(null);
typeMap = typelist.stream().collect(
Collectors.toMap(EquipmentSpecificIndexAlarmDic::getValue, EquipmentSpecificIndexAlarmDic::getName));
} }
@Async("jxiopAsyncExecutor") @Async("jxiopAsyncExecutor")
public void handleMessage(List<ConsumerRecord<String, String>> record) { public void handleMessage(List<ConsumerRecord<String, String>> record) {
List<AlarmEvent> alarmEvents = new ArrayList<>(); List<AlarmEvent> alarmEvents = new ArrayList<>();
List<EquipAlarmEvent> equipAlarmEvents = new ArrayList<>(); List<EquipAlarmEvent> equipAlarmEvents = new ArrayList<>();
String group = null;
for (ConsumerRecord<String, String> one : record) { for (ConsumerRecord<String, String> one : record) {
JSONObject obj = JSONObject.parseObject(one.value()); JSONObject obj = JSONObject.parseObject(one.value());
String objName = obj.getString("equipmentSpecificName"); String objName = obj.getString("equipmentSpecificName");
...@@ -70,13 +81,19 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent ...@@ -70,13 +81,19 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent
String gatewayId = obj.getString("gatewayId"); String gatewayId = obj.getString("gatewayId");
String value = obj.getString("value"); String value = obj.getString("value");
String valueLabel = obj.getString("valueLabel"); String valueLabel = obj.getString("valueLabel");
Integer isAlarm = Integer.valueOf(obj.getString("isAlarm"));
if (!typeMap.containsKey(isAlarm)) {
continue;
} else {
group=typeMap.get(isAlarm);
}
if ("升压站".equals(objName)) { if ("升压站".equals(objName)) {
AlarmEvent alarmEvent = new AlarmEvent(); AlarmEvent alarmEvent = new AlarmEvent();
alarmEvent.setEventDesc(indexName); alarmEvent.setEventDesc(indexName);
// alarmEvent.setStationId(""); // alarmEvent.setStationId("");
// alarmEvent.setStationName(""); // alarmEvent.setStationName("");
alarmEvent.setGatewayId(gatewayId); alarmEvent.setGatewayId(gatewayId);
alarmEvent.setAlarmGroupName("运行告警"); alarmEvent.setAlarmGroupName(group);
alarmEvent.setValue(value); alarmEvent.setValue(value);
alarmEvents.add(alarmEvent); alarmEvents.add(alarmEvent);
} else { } else {
...@@ -102,6 +119,7 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent ...@@ -102,6 +119,7 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent
equipAlarmEvent.setEventDesc(indexName); equipAlarmEvent.setEventDesc(indexName);
equipAlarmEvent.setGatewayId(gatewayId); equipAlarmEvent.setGatewayId(gatewayId);
equipAlarmEvent.setValue(warn); equipAlarmEvent.setValue(warn);
equipAlarmEvent.setAlarmGroupName(group);
equipAlarmEvents.add(equipAlarmEvent); equipAlarmEvents.add(equipAlarmEvent);
} }
} }
...@@ -113,6 +131,7 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent ...@@ -113,6 +131,7 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent
// equipAlarmEvent.setFrontModule(value); // equipAlarmEvent.setFrontModule(value);
equipAlarmEvent.setGatewayId(gatewayId); equipAlarmEvent.setGatewayId(gatewayId);
equipAlarmEvent.setValue(value); equipAlarmEvent.setValue(value);
equipAlarmEvent.setAlarmGroupName(group);
equipAlarmEvents.add(equipAlarmEvent); equipAlarmEvents.add(equipAlarmEvent);
} }
} }
...@@ -154,7 +173,7 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent ...@@ -154,7 +173,7 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent
ColModel colModelStationName = new ColModel("stationName", "stationName", "名称", "名称", "dataGrid", ColModel colModelStationName = new ColModel("stationName", "stationName", "名称", "名称", "dataGrid",
"stationName"); "stationName");
ColModel colModelEventDesc = new ColModel("eventDesc", "eventDesc", "事件描述", "事件描述", "dataGrid", "eventDesc"); ColModel colModelEventDesc = new ColModel("eventDesc", "eventDesc", "事件描述", "事件描述", "dataGrid", "eventDesc");
ColModel colModelAlarmGroupName = new ColModel("alarmGroupName", "alarmGroupName", "事件告警组", "事件告警组", "dataGrid", ColModel colModelAlarmGroupName = new ColModel("alarmGroupName", "alarmGroupName", "事件类型", "事件类型", "dataGrid",
"alarmGroupName"); "alarmGroupName");
ColModel colModelEventTime = new ColModel("time", "time", "事件发生时间", "事件发生时间", "dataGrid", "time"); ColModel colModelEventTime = new ColModel("time", "time", "事件发生时间", "事件发生时间", "dataGrid", "time");
ColModel colModelEventMovement = new ColModel("value", "value", "事件值", "事件值", "dataGrid", "value"); ColModel colModelEventMovement = new ColModel("value", "value", "事件值", "事件值", "dataGrid", "value");
......
...@@ -43,7 +43,7 @@ public class EquipAlarmEventServiceImpl ...@@ -43,7 +43,7 @@ public class EquipAlarmEventServiceImpl
equipName = s[0] + "子阵/逆变器" + s[1]; equipName = s[0] + "子阵/逆变器" + s[1];
} else if ("汇流箱".equals(frontModule)) { } else if ("汇流箱".equals(frontModule)) {
String[] s = equipIndex.split("-"); String[] s = equipIndex.split("-");
if (s[2].indexOf("0")==0) { if (s[2].indexOf("0") == 0) {
s[2] = s[2].substring(1); s[2] = s[2].substring(1);
} }
equipName = s[0] + "子阵/逆变器" + s[1] + "/#" + s[2] + "汇流箱"; equipName = s[0] + "子阵/逆变器" + s[1] + "/#" + s[2] + "汇流箱";
...@@ -64,12 +64,12 @@ public class EquipAlarmEventServiceImpl ...@@ -64,12 +64,12 @@ public class EquipAlarmEventServiceImpl
} else if ("false".equals(i.getValue())) { } else if ("false".equals(i.getValue())) {
i.setValue("分"); i.setValue("分");
} }
long mills = i.getCreatedTime()/1000000; long mills = i.getCreatedTime() / 1000000;
car.setTimeInMillis(mills); car.setTimeInMillis(mills);
//System.out.println(sdf.format(car.getTime())); // System.out.println(sdf.format(car.getTime()));
i.setTime(sdf.format(car.getTime())); i.setTime(sdf.format(car.getTime()));
//car.add(Calendar.HOUR, 12); // car.add(Calendar.HOUR, 12);
//System.out.println(sdf.format(car.getTime())); // System.out.println(sdf.format(car.getTime()));
}); });
PageInfo<EquipAlarmEvent> page = new PageInfo(alarmEventList); PageInfo<EquipAlarmEvent> page = new PageInfo(alarmEventList);
...@@ -79,11 +79,12 @@ public class EquipAlarmEventServiceImpl ...@@ -79,11 +79,12 @@ public class EquipAlarmEventServiceImpl
ColModel colModelEventMovement = new ColModel("equipName", "equipName", "设备名称", "设备名称", "dataGrid", ColModel colModelEventMovement = new ColModel("equipName", "equipName", "设备名称", "设备名称", "dataGrid",
"equipName"); "equipName");
ColModel colModelStationName = new ColModel("eventDesc", "eventDesc", "事件描述", "事件描述", "dataGrid", "eventDesc"); ColModel colModelStationName = new ColModel("eventDesc", "eventDesc", "事件描述", "事件描述", "dataGrid", "eventDesc");
ColModel colModelEventDesc = new ColModel("time", "time", "事件发生时间", "事件发生时间", "dataGrid", ColModel colModelAlarmGroupName = new ColModel("alarmGroupName", "alarmGroupName", "事件类型", "事件类型", "dataGrid",
"time"); "alarmGroupName");
ColModel colModelEventDesc = new ColModel("time", "time", "事件发生时间", "事件发生时间", "dataGrid", "time");
ColModel colModelValueDesc = new ColModel("value", "value", "事件值", "事件值", "dataGrid", "value"); ColModel colModelValueDesc = new ColModel("value", "value", "事件值", "事件值", "dataGrid", "value");
List<ColModel> listColModel = Arrays.asList(colModelEventMovement, colModelStationName, colModelEventDesc, List<ColModel> listColModel = Arrays.asList(colModelEventMovement, colModelStationName, colModelAlarmGroupName,
colModelValueDesc); colModelEventDesc, colModelValueDesc);
ResultsData resultsData = new ResultsData(DataGridMock, listColModel); ResultsData resultsData = new ResultsData(DataGridMock, listColModel);
return resultsData; return resultsData;
} }
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.mapper2.EquipmentSpecificIndexAlarmDicMapper">
</mapper>
...@@ -22,10 +22,10 @@ ...@@ -22,10 +22,10 @@
</select> </select>
<insert id="save"> <insert id="save">
INSERT INTO INSERT INTO
equip_alarm_event(created_time,staion_name,staion_id,gateway_id,equip_index,event_desc,equip_name,front_module,value) equip_alarm_event(created_time,staion_name,staion_id,gateway_id,equip_index,event_desc,equip_name,front_module,value,alarm_group_name)
VALUES VALUES
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
(NOW(),#{item.stationName},#{item.stationId},#{item.gatewayId},#{item.equipIndex},'#{item.eventDesc}','#{item.equipName}',#{item.frontModule},'#{item.value}') (NOW(),#{item.stationName},#{item.stationId},#{item.gatewayId},#{item.equipIndex},'#{item.eventDesc}','#{item.equipName}',#{item.frontModule},'#{item.value}','#{item.alarmGroupName}')
</foreach> </foreach>
</insert> </insert>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment