Commit ade18623 authored by zhangsen's avatar zhangsen

Merge remote-tracking branch 'origin/developer' into developer

parents 8e86c1fc 0ba5b730
......@@ -1907,7 +1907,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
}
}
List<Map<String, String>> maps = new ArrayList<>();
Set<String> nums = new HashSet<>();
List<String> nums = new ArrayList<>();
//此处组装数据 每一个Map代表一个逆变器
for (ESEquipments esEquipments : listData1) {
int num = Integer.parseInt(esEquipments.getEquipmentNumber().substring(0, 2));
......@@ -1945,6 +1945,8 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
});
}
statusMaps.sort(Comparator.comparingInt(o->Integer.parseInt(o.get("titie").toString())));
IPage<Map<String, String>> result = new Page<>();
result.setRecords(statusMaps);
result.setCurrent(1);
......
......@@ -23,7 +23,7 @@ public class AlarmKafkaConsumer {
AlarmEventServiceImpl alarmEventServiceImpl;
// 消费者来处理消息
//@KafkaListener(id="user1" , topics ={"${kafka.alarm.topic}"},groupId = "messageConsumerGroup")
@KafkaListener(id="user1" , topics ={"${kafka.alarm.topic}"},groupId = "messageConsumerGroup")
public void message1(List<ConsumerRecord<String, String>> consumerRecords, Acknowledgment ack){
// 异步触发预警
alarmEventServiceImpl.handleMessage(consumerRecords);
......
......@@ -32,4 +32,7 @@ public class AlarmEvent {
@TableField("value")
private String value;
@TableField(exist = false)
private String time;
}
......@@ -44,4 +44,7 @@ public class EquipAlarmEvent {
@TableField("value")
private String value;
@TableField(exist = false)
private String time;
}
package com.yeejoin.amos.boot.module.jxiop.biz.entity;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
@TableName("wl_equipment_specific_index")
public class EquipmentSpecificIndex {
@TableField("id")
private Long id;
@TableField("equipment_specific_id")
private Long address;
@TableField("value")
private String value;
@TableField("create_date")
private Date createDate;
@TableField("equipment_index_id")
private Long equipmentIndexId;
@TableField("update_date")
private Date updateDate;
@TableField("equipment_specific_name")
private String equipmentSpecificName;
@TableField("equipment_index_name")
private String equipmentIndexName;
@TableField("equipment_index_key")
private String equipmentIndexKey;
@TableField("value_label")
private String valueLabel;
@TableField("value_enum")
private String valueEnum;
@TableField("emergency_level_color")
private String emergencyLevelColor;
@TableField("is_alarm")
private boolean isAlarm;
@TableField("emergency_level")
private String emergencyLevel;
@TableField("emergency_level_describe")
private String emergencyLevelDescribe;
@TableField("trace_id")
private String traceId;
@TableField("index_address")
private String indexAddress;
@TableField("station")
private String station;
@TableField("quality")
private boolean quality;
@TableField("data_type")
private String dataType;
@TableField("time_stamp")
private String timeStamp;
@TableField("gateway_id")
private String gatewayId;
@TableField("unit")
private String unit;
}
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.EquipmentSpecificIndex;
public interface EquipmentSpecificIndexMapper extends BaseMapper<EquipmentSpecificIndex>{
}
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.AlarmEventDto;
......@@ -19,6 +24,8 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.DataGridMock;
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.EquipAlarmEvent;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.EquipmentSpecificIndex;
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.EquipAlarmEventMapper;
......@@ -28,6 +35,10 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent
@Autowired
private EquipAlarmEventMapper equipAlarmEventMapper;
@Autowired
private EquipmentSpecificIndexMapper equipmentSpecificIndexMapper;
@Async("jxiopAsyncExecutor")
public void handleMessage(List<ConsumerRecord<String, String>> record) {
List<AlarmEvent> alarmEvents = new ArrayList<>();
List<EquipAlarmEvent> equipAlarmEvents = new ArrayList<>();
......@@ -49,22 +60,43 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent
alarmEvents.add(alarmEvent);
} else {
EquipAlarmEvent equipAlarmEvent = new EquipAlarmEvent();
//equipAlarmEvent.setEquipIndex(value);
if (indexName.contains("实时故障") && objName.contains("风机")) {
LambdaQueryWrapper<EquipmentSpecificIndex> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(EquipmentSpecificIndex::getEquipmentSpecificName, objName);
EquipmentSpecificIndex equipmentSpecificIndex = equipmentSpecificIndexMapper.selectOne(wrapper);
String valueEnum = equipmentSpecificIndex.getValueEnum();
JSONArray arr = JSONObject.parseArray(valueEnum);
for(Object o:arr)
{
JSONObject json = JSONObject.parseObject(JSONObject.toJSONString(o));
if (json.containsKey(value)) {
String warn = json.getString(value);
if (warn.indexOf("备留") == -1) {
equipAlarmEvent.setEquipName(objName);
equipAlarmEvent.setEventDesc(indexName);
equipAlarmEvent.setGatewayId(gatewayId);
equipAlarmEvent.setValue(warn);
equipAlarmEvents.add(equipAlarmEvent);
}
}
}
} else {
// equipAlarmEvent.setEquipIndex(value);
equipAlarmEvent.setEquipName(objName);
equipAlarmEvent.setEventDesc(indexName);
//equipAlarmEvent.setFrontModule(value);
// equipAlarmEvent.setFrontModule(value);
equipAlarmEvent.setGatewayId(gatewayId);
equipAlarmEvent.setValue(value);
equipAlarmEvents.add(equipAlarmEvent);
}
}
}
if(alarmEvents.size()>0)
{
if (alarmEvents.size() > 0) {
this.baseMapper.save(alarmEvents);
}
if(equipAlarmEvents.size()>0)
{
if (equipAlarmEvents.size() > 0) {
this.equipAlarmEventMapper.save(equipAlarmEvents);
}
......@@ -76,6 +108,8 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH, -2);
List<AlarmEvent> alarmEventList = this.baseMapper.getEventList(gatewayId, calendar.getTime());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
alarmEventList.forEach(i -> {
if ("true".equals(i.getValue())) {
i.setValue("合");
......@@ -83,19 +117,19 @@ public class AlarmEventServiceImpl extends BaseService<AlarmEventDto, AlarmEvent
i.setValue("分");
}
i.setStationName("升压站");
i.setTime(sdf.format(new Date(i.getCreatedTime())));
});
PageInfo<EquipAlarmEvent> page = new PageInfo(alarmEventList);
// 构建平台数据
DataGridMock DataGridMock = new DataGridMock(current, (int)page.getTotal(), false, current, alarmEventList);
DataGridMock DataGridMock = new DataGridMock(current, (int) page.getTotal(), false, current, alarmEventList);
ColModel colModelStationName = new ColModel("stationName", "stationName", "名称", "名称", "dataGrid",
"stationName");
ColModel colModelEventDesc = new ColModel("eventDesc", "eventDesc", "事件描述", "事件描述", "dataGrid", "eventDesc");
ColModel colModelAlarmGroupName = new ColModel("alarmGroupName", "alarmGroupName", "事件告警组", "事件告警组", "dataGrid",
"alarmGroupName");
ColModel colModelEventTime = new ColModel("createdTime", "createdTime", "事件发生时间", "事件发生时间", "dataGrid",
"createdTime");
ColModel colModelEventMovement = new ColModel("value", "value", "事件值", "事件值", "dataGrid",
"value");
ColModel colModelEventTime = new ColModel("time", "time", "事件发生时间", "事件发生时间", "dataGrid",
"time");
ColModel colModelEventMovement = new ColModel("value", "value", "事件值", "事件值", "dataGrid", "value");
List<ColModel> listColModel = Arrays.asList(colModelStationName, colModelEventDesc, colModelAlarmGroupName,
colModelEventTime, colModelEventMovement);
ResultsData resultsData = new ResultsData(DataGridMock, listColModel);
......
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -32,6 +34,7 @@ public class EquipAlarmEventServiceImpl
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH, -2);
String equipName = null;
if (equipIndex != null && frontModule != null) {
if ("箱变".equals(frontModule)) {
equipName = equipIndex + "子阵/箱变";
} else if ("逆变器".equals(frontModule)) {
......@@ -47,15 +50,19 @@ public class EquipAlarmEventServiceImpl
equipName = equipIndex + "风机";
}
equipName = '%' + equipName + '%';
}
List<EquipAlarmEvent> alarmEventList = this.baseMapper.getEventList(gatewayId, equipName, null,
calendar.getTime());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
alarmEventList.forEach(i -> {
if ("true".equals(i.getValue())) {
i.setValue("合");
} else if ("false".equals(i.getValue())) {
i.setValue("分");
}
i.setTime(sdf.format(new Date(i.getCreatedTime())));
});
PageInfo<EquipAlarmEvent> page = new PageInfo(alarmEventList);
......@@ -65,8 +72,8 @@ public class EquipAlarmEventServiceImpl
ColModel colModelEventMovement = new ColModel("equipName", "equipName", "设备名称", "设备名称", "dataGrid",
"equipName");
ColModel colModelStationName = new ColModel("eventDesc", "eventDesc", "事件描述", "事件描述", "dataGrid", "eventDesc");
ColModel colModelEventDesc = new ColModel("createdTime", "createdTime", "事件发生时间", "事件发生时间", "dataGrid",
"createdTime");
ColModel colModelEventDesc = new ColModel("time", "time", "事件发生时间", "事件发生时间", "dataGrid",
"time");
ColModel colModelValueDesc = new ColModel("value", "value", "事件值", "事件值", "dataGrid", "value");
List<ColModel> listColModel = Arrays.asList(colModelEventMovement, colModelStationName, colModelEventDesc,
colModelValueDesc);
......
......@@ -7,7 +7,7 @@ spring.db1.datasource.password=Yeejoin@2020
spring.db1.datasource.driver-class-name: com.mysql.cj.jdbc.Driver
## db2-sync_data
spring.db2.datasource.type: com.alibaba.druid.pool.DruidDataSource
spring.db2.datasource.url=jdbc:mysql://139.9.173.44:3306/jxiop_sync_data?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.db2.datasource.url=jdbc:mysql://139.9.173.44:3306/equipment?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.db2.datasource.username=root
spring.db2.datasource.password=Yeejoin@2020
spring.db2.datasource.driver-class-name: com.mysql.cj.jdbc.Driver
......
spring.application.name=AMOS-JXIOP-WARN
server.servlet.context-path=/jxiop-warn
server.port=33400
server.port=33500
server.uri-encoding=UTF-8
spring.profiles.active=dev
spring.jackson.time-zone=GMT+8
......
<?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.AlarmEventMapper">
<select id="getAlarmEventList" resultType="com.yeejoin.amos.boot.module.jxiop.biz.dto.AlarmEventDto">
select
station_name as stationName,
event_desc as eventDesc,
alarm_group_name as alarmGroupName,
event_time as eventTime,
(case event_movement
WHEN 'true' then '告警'
WHEN 'false' then '恢复'
ELSE event_movement end ) as eventMovement
from
fault_alarm_event
<where>
<if test="gatewayId != null and gatewayId != ''">
gateway_id = #{gatewayId}
</if>
<if test="stationId != null and stationId != ''">
station_id = #{stationId}
</if>
AND #{time} &lt;= event_time
</where>
ORDER BY event_time DESC LIMIT #{current}, #{size}
</select>
<select id="getLastDataBySort" resultType="java.lang.String">
select
sort
from
fault_alarm_event
<where>
<if test="gatewayId != null and gatewayId != ''">
gateway_id = #{gatewayId}
</if>
</where>
order by sort desc limit 1
</select>
<select id="getOldAlarmsBySort" resultType="java.lang.String">
select
event_desc
from
fault_alarm_event
where
gateway_id = #{gatewayId} and sort = #{sort}
</select>
</mapper>
<?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.EquipAlarmEventMapper">
<select id="getAlarmEventList" resultType="com.yeejoin.amos.boot.module.jxiop.biz.dto.EquipAlarmEventDto">
SELECT
*
FROM
equip_alarm_event a
JOIN ( SELECT sequence_nbr FROM equip_alarm_event
<where>
<if test="gatewayId != null and gatewayId != ''">
AND gateway_id = #{gatewayId}
</if>
<if test="equipIndex!= null and equipIndex != ''">
AND equip_index = #{equipIndex}
</if>
<if test="frontModule!= null and frontModule != ''">
AND front_module = #{frontModule}
</if>
AND #{time} &lt;= created_time
</where>
ORDER BY created_time DESC LIMIT #{current}, #{size} ) b ON a.sequence_nbr = b.sequence_nbr
</select>
<select id="getLastDataBySort" resultType="java.lang.String">
select
sort
from
equip_alarm_event
<where>
<if test="gatewayId != null and gatewayId != ''">
gateway_id = #{gatewayId}
</if>
</where>
order by sort desc limit 1
</select>
<select id="getOldDataBySort" resultType="com.yeejoin.amos.boot.module.jxiop.biz.entity.EquipAlarmEvent">
select
*
from
equip_alarm_event
<where>
<if test="sort != null and sort != ''">
sort = #{sort}
</if>
AND gateway_id = #{gatewayId}
</where>
</select>
</mapper>
<?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.EquipmentSpecificIndexMapper">
</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