Commit 5778d12a authored by xinglei's avatar xinglei

科技处告警跑马灯展示

parent 6ab4d9c7
......@@ -114,8 +114,8 @@ public class EquipmentListener extends EmqxListener implements InitializingBean
JSONObject metricJson = JSONObject.parseObject(string);
String communication = metricJson.get("communication").toString();
int status = communication.equals("正常") ? 0 : 1;
int sourceIdStatus = bankInfoMapper.findBySourceId(eqpId);
if (status != sourceIdStatus) {
String sourceIdStatus = bankInfoMapper.findBySourceId(eqpId);
if (!ObjectUtils.isEmpty(sourceIdStatus) && status != Integer.valueOf(sourceIdStatus).intValue()) {
bankInfoMapper.updateBySourceId(status, eqpId);
Map<String, Object> resultMap = bankInfoMapper.selectBankInfoBySourceId(eqpId);
......@@ -153,15 +153,12 @@ public class EquipmentListener extends EmqxListener implements InitializingBean
// 获取ip
String ipAddress = getEqpConfigMapValueByKey(eqpConfigMap, "IP");
// 所属楼层
String lou = getEqpConfigMapValueByKey(eqpConfigMap, "所属楼层");
// 三维位置
String sanwei = getEqpConfigMapValueByKey(eqpConfigMap, "三维位置");
// 资源ID
String sourceId = getEqpConfigMapValueByKey(eqpConfigMap, "设备ID");
String eqpName = parseObject.getString("eqpName");
// orgcode
String orgcode = parseObject.getString("orgCode");
......@@ -172,7 +169,9 @@ public class EquipmentListener extends EmqxListener implements InitializingBean
// 告警信息
String metricKey = "";
// 默认状态为正常
int statusByName = 0;
Object communication = JSONObject.parseObject(((JSONObject) jsonArray.get(0)).getString("metricJson")).get("communication");
int statusByName = !ObjectUtils.isEmpty(communication) && communication.equals("异常") ? 1 : 0;
for (Object e : jsonArray) {
JSONObject object = (JSONObject) e;
String string = object.getString("metricJson");
......@@ -190,18 +189,14 @@ public class EquipmentListener extends EmqxListener implements InitializingBean
System.out.println("----start chuli ip equipment state : " + entry);
String remark = entry.getKey().toString();
String statusName = entry.getValue().toString();
if (remark.equals("communication")) {
// 触发风险合格不合格
statusByName = riskAlarm(eqpId, remark, statusName);
//拓扑闪烁
topographyAlarm(sourceId, statusByName);
// 触发风险合格不合格
riskAlarm(eqpId, remark, statusName);
}
}
}
;
// 增加报警(跑马灯,首页)
addAlarmMethod(eqpId, statusByName, eqpName, ipAddress, metricKey, orgcode, sanwei, lou);
......@@ -216,8 +211,9 @@ public class EquipmentListener extends EmqxListener implements InitializingBean
}
private Integer riskAlarm(Long eqpId, String remark, String statusName) {
int statusByName = 0;;
int statusByName = 0;
EquipmentQualityVo queryEquipmentPoint = equipmentMapper.queryEquipmentPoint(eqpId, remark);
if (!ObjectUtils.isEmpty(queryEquipmentPoint)) {
Long equipmentsPointId = queryEquipmentPoint.getId();
List<Long> riskFactorId = equipmentMapper.judgeEquipmentExists(equipmentsPointId);
if ("异常".equals(statusName)) {
......@@ -238,6 +234,7 @@ public class EquipmentListener extends EmqxListener implements InitializingBean
logger.error("update rpn fail " + e1.getMessage());
}
}
}
return statusByName;
}
......@@ -246,7 +243,7 @@ public class EquipmentListener extends EmqxListener implements InitializingBean
TopographyNode node = equipmentMapper.queryNodeBySourceId(sourceId);
// 拓扑闪烁
if (null != node) {
if (null != node && node.getState() != statusByName) {
node.setNumber(statusByName);
node.setState(statusByName);
equipmentMapper.updateNodeState(node);
......@@ -264,6 +261,7 @@ public class EquipmentListener extends EmqxListener implements InitializingBean
/**
* 根据eqpConfigMap中的key获取value
*
* @param eqpConfigMap
* @param key
* @return
......@@ -285,6 +283,7 @@ public class EquipmentListener extends EmqxListener implements InitializingBean
/**
* 增加告警记录
*
* @param eqpId
* @param metricKey
* @param statusByName
......@@ -292,7 +291,7 @@ public class EquipmentListener extends EmqxListener implements InitializingBean
* @param ipAddress
* @param eqpName
*/
public void addAlarmRecord(Long eqpId,String metricKey,Integer statusByName,String orgCode1,String ipAddress,String eqpName) {
public void addAlarmRecord(Long eqpId, String metricKey, Integer statusByName, String orgCode1, String ipAddress, String eqpName) {
List<Alarm> curAlarmList = alarmService.findByQueryColumn(eqpId + metricKey);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if (curAlarmList != null && curAlarmList.size() > 0) {
......@@ -335,7 +334,7 @@ public class EquipmentListener extends EmqxListener implements InitializingBean
}
}
public void addAlarmMethod(Long eqpId,Integer statusByName,String eqpName,String ipAddress,String metricKey,String orgCode,String sanwei,String lou) throws IOException {
public void addAlarmMethod(Long eqpId, Integer statusByName, String eqpName, String ipAddress, String metricKey, String orgCode, String sanwei, String lou) throws IOException {
List<AlarmPoint> alarmPoint = alarmPointService.selectPointTypeAndPointId(AlarmPointTypeEnum.设备.getCode(),
eqpId);
if (alarmPoint != null && alarmPoint.size() > 0) {
......@@ -343,7 +342,9 @@ public class EquipmentListener extends EmqxListener implements InitializingBean
if (statusByName == 0) {
// 删除告警
alarmPointService.delete(alarmPoint.get(0));
pushAlarmPoint("alarmPoint", alarmPointService.findAll());
}
return;
} else {
// 不存在,判断当前状态是不是合格,不合格新增,合格不做任何操作
if (statusByName != 0) {
......@@ -364,13 +365,16 @@ public class EquipmentListener extends EmqxListener implements InitializingBean
alarmPoint1.setPointAttrs(JSON.toJSONString(map));
alarmPointService.save(alarmPoint1);
// 推送告警
List<AlarmPoint> list = alarmPointService.findAll();
WebsocketParam param = new WebsocketParam("alarmPoint", JSON.toJSONString(list));
Properties props = PropertiesLoaderUtils.loadAllProperties("application.properties");
String url = (String) props.get("params.remoteWebsocketUrl") + "/generic/sendMessage";
HttpUtil.PostJson(url, JSON.toJSONString(param));
pushAlarmPoint("alarmPoint", alarmPointService.findAll());
}
}
}
/**
* 发送跑马灯告警
*/
public void pushAlarmPoint(String WS, Object object) {
WebsocketParam param = new WebsocketParam(WS, JSON.toJSONString(object));
client.sendMessage(param);
}
}
......@@ -234,7 +234,6 @@ public class SelfSupportListener extends EmqxListener implements InitializingBea
Properties props = PropertiesLoaderUtils.loadAllProperties("application.properties");
String url = (String) props.get("params.remoteWebsocketUrl") + "/generic/sendMessage";
HttpUtil.PostJson(url, JSON.toJSONString(param));
}
}
......
......@@ -16,7 +16,7 @@ public interface BankInfoMapper extends BaseMapper {
List<BankInfoDTO> selectBankInfoList();
int findBySourceId(@Param("sourceId")Long sourceId);
String findBySourceId(@Param("sourceId")Long sourceId);
void updateBySourceId(@Param("status") int status, @Param("sourceId")Long sourceId);
......
......@@ -40,5 +40,4 @@ public interface IEquipmentService {
List<PointParam> handlePatrolPointData(Long factorId) throws InnerInvokException;
Map<String, List> handlePointDatas(Long factorId) throws InnerInvokException;
}
......@@ -24,7 +24,7 @@
from b_bank_info Bi left join b_bank_equipment Be on Bi.id = Be.bank_id group by Bi.id
</select>
<select id="findBySourceId" resultType="int">
<select id="findBySourceId" resultType="String">
select status from b_bank_equipment where 1=1 and source_id = #{sourceId}
</select>
......
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