Commit f52970d0 authored by zhengjiangtao's avatar zhengjiangtao

Merge branch 'develop_20200601' of http://172.16.10.76/bank/AmosBankRoot into develop_20200601

parents 6f3dd1bd a70d412b
...@@ -13,6 +13,7 @@ import com.yeejoin.amos.bank.dao.mapper.AlarmMapper; ...@@ -13,6 +13,7 @@ import com.yeejoin.amos.bank.dao.mapper.AlarmMapper;
import com.yeejoin.amos.bank.dao.mapper.BankInfoMapper; import com.yeejoin.amos.bank.dao.mapper.BankInfoMapper;
import com.yeejoin.amos.bank.dao.repository.IAlarmRepository; import com.yeejoin.amos.bank.dao.repository.IAlarmRepository;
import com.yeejoin.amos.bank.entity.EquipmentQualityVo; import com.yeejoin.amos.bank.entity.EquipmentQualityVo;
import com.yeejoin.amos.bank.remote.AmosWsService;
import com.yeejoin.amos.bank.remote.client.RiskModelRemoteClient; import com.yeejoin.amos.bank.remote.client.RiskModelRemoteClient;
import com.yeejoin.amos.bank.service.IAlarmPointService; import com.yeejoin.amos.bank.service.IAlarmPointService;
import com.yeejoin.amos.bank.service.IAlarmService; import com.yeejoin.amos.bank.service.IAlarmService;
...@@ -54,7 +55,7 @@ public class EquipmentListener extends EmqxListener implements InitializingBean ...@@ -54,7 +55,7 @@ public class EquipmentListener extends EmqxListener implements InitializingBean
private BankInfoMapper bankInfoMapper; private BankInfoMapper bankInfoMapper;
@Autowired @Autowired
private AmosWsClient client; private AmosWsService amosWsService;
@Autowired @Autowired
EquipmentMapper equipmentMapper; EquipmentMapper equipmentMapper;
...@@ -124,7 +125,7 @@ public class EquipmentListener extends EmqxListener implements InitializingBean ...@@ -124,7 +125,7 @@ public class EquipmentListener extends EmqxListener implements InitializingBean
Map<String, Object> resultMap = bankInfoMapper.selectBankInfoBySourceId(eqpId); Map<String, Object> resultMap = bankInfoMapper.selectBankInfoBySourceId(eqpId);
resultMap.put("eqpId", eqpId); resultMap.put("eqpId", eqpId);
pushAisleAlarm(resultMap); amosWsService.pushAlarmPoint("aisleAlarm", resultMap);
logger.info("=======aisle状态有变化====="); logger.info("=======aisle状态有变化=====");
} }
}); });
...@@ -139,14 +140,6 @@ public class EquipmentListener extends EmqxListener implements InitializingBean ...@@ -139,14 +140,6 @@ public class EquipmentListener extends EmqxListener implements InitializingBean
} }
} }
/**
* 发送通道刷新标识
*/
public void pushAisleAlarm(Map<String, Object> result) {
WebsocketParam param = new WebsocketParam("aisleAlarm", JSON.toJSONString(result));
client.sendMessage(param);
}
public void handleAlarmData(String jsonStr) { public void handleAlarmData(String jsonStr) {
try { try {
logger.info("start handle ip equipment alarm.."); logger.info("start handle ip equipment alarm..");
...@@ -204,7 +197,7 @@ public class EquipmentListener extends EmqxListener implements InitializingBean ...@@ -204,7 +197,7 @@ public class EquipmentListener extends EmqxListener implements InitializingBean
} }
String authOrgTemp = JsonUtil.arraysToString(JsonUtil.toStringArray(authOrg)); String authOrgTemp = JsonUtil.arraysToString(JsonUtil.toStringArray(authOrg));
if (!ObjectUtils.isEmpty(authOrgTemp)){ if (!ObjectUtils.isEmpty(authOrgTemp)) {
orgCode = authOrgTemp; orgCode = authOrgTemp;
} }
...@@ -304,34 +297,32 @@ public class EquipmentListener extends EmqxListener implements InitializingBean ...@@ -304,34 +297,32 @@ public class EquipmentListener extends EmqxListener implements InitializingBean
public void addAlarmRecord(Long eqpId, String metricKey, Integer statusByName, String orgCode, String ipAddress, String eqpName) { public void addAlarmRecord(Long eqpId, String metricKey, Integer statusByName, String orgCode, String ipAddress, String eqpName) {
List<Alarm> curAlarmList = alarmService.findByQueryColumn(eqpId + metricKey); List<Alarm> curAlarmList = alarmService.findByQueryColumn(eqpId + metricKey);
if (curAlarmList != null && curAlarmList.size() > 0) { if (curAlarmList != null && curAlarmList.size() > 0) {
// if("异常".equals(curAlarmList.get(0).getCurrentState())){
Alarm alarm = curAlarmList.get(0); Alarm alarm = curAlarmList.get(0);
alarm.setUpdateDate(DateTimeKit.now()); alarm.setUpdateDate(DateTimeKit.now());
alarm.setOrgCode(orgCode); alarm.setOrgCode(orgCode);
alarm.setClearPerson(CLEAR_PERSON); if (!ObjectUtils.isEmpty(alarm.getHappenDate())) {
if (!ObjectUtils.isEmpty(alarm.getHappenDate())){
String subtract = DateTimeKit.getSubtract(alarm.getHappenDate()); String subtract = DateTimeKit.getSubtract(alarm.getHappenDate());
alarm.setContinueDate(subtract); alarm.setContinueDate(subtract);
} }
if (ALARM_ABNORMAL_STATUS.equals(alarm.getCurrentState()) && statusByName != 0) { if (ALARM_ABNORMAL_STATUS.equals(alarm.getCurrentState()) && statusByName != 0) {
alarm.setCurrentState(ALARM_ABNORMAL_STATUS); alarm.setCurrentState(ALARM_ABNORMAL_STATUS);
} else { } else {
alarm.setClearDate(DateTimeKit.now());
alarm.setClearPerson(CLEAR_PERSON);
alarm.setCurrentState(ALARM_NORMAL_STATUS); alarm.setCurrentState(ALARM_NORMAL_STATUS);
} }
alarmMapper.updateAlarm(alarm); alarmMapper.updateAlarm(alarm);
// }
} else { } else {
Alarm alarm = new Alarm(); Alarm alarm = new Alarm();
alarm.setSourceId(eqpId + ""); alarm.setSourceId(eqpId + "");
alarm.setAlarmLevel(ALARM_LEVEL); alarm.setAlarmLevel(ALARM_LEVEL);
alarm.setAlarmReason(""); alarm.setAlarmReason(ALARM_CAUSE);
alarm.setAlarmSourceIp(ipAddress + ""); alarm.setAlarmSourceIp(ipAddress + "");
alarm.setAlarmSourceName(eqpName); alarm.setAlarmSourceName(eqpName);
alarm.setAlarmSourceType(metricKey); alarm.setAlarmSourceType(ALARM_TYPE);
alarm.setClearDate(""); alarm.setClearDate("");
alarm.setContinueDate(""); alarm.setContinueDate("");
alarm.setEnsureDate(""); alarm.setEnsureDate("");
alarm.setHappenDate("");
alarm.setEnsurePerson(""); alarm.setEnsurePerson("");
alarm.setOrgCode(orgCode); alarm.setOrgCode(orgCode);
alarm.setHappenDate(DateTimeKit.now()); alarm.setHappenDate(DateTimeKit.now());
...@@ -353,7 +344,7 @@ public class EquipmentListener extends EmqxListener implements InitializingBean ...@@ -353,7 +344,7 @@ public class EquipmentListener extends EmqxListener implements InitializingBean
if (statusByName == 0) { if (statusByName == 0) {
// 删除告警 // 删除告警
alarmPointService.delete(alarmPoint.get(0)); alarmPointService.delete(alarmPoint.get(0));
pushAlarmPoint("alarmPoint", alarmPointService.findAll()); amosWsService.pushAlarmPoint("alarmPoint", alarmPointService.findAll());
} }
return; return;
} else { } else {
...@@ -377,16 +368,8 @@ public class EquipmentListener extends EmqxListener implements InitializingBean ...@@ -377,16 +368,8 @@ public class EquipmentListener extends EmqxListener implements InitializingBean
alarmPoint1.setPointAttrs(JSON.toJSONString(map)); alarmPoint1.setPointAttrs(JSON.toJSONString(map));
alarmPointService.save(alarmPoint1); alarmPointService.save(alarmPoint1);
// 推送告警 // 推送告警
pushAlarmPoint("alarmPoint", alarmPointService.findAll()); amosWsService.pushAlarmPoint("alarmPoint", alarmPointService.findAll());
} }
} }
} }
/**
* 发送跑马灯告警
*/
public void pushAlarmPoint(String WS, Object object) {
WebsocketParam param = new WebsocketParam(WS, JSON.toJSONString(object));
client.sendMessage(param);
}
} }
...@@ -7,6 +7,9 @@ import java.util.List; ...@@ -7,6 +7,9 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import com.yeejoin.amos.bank.dao.mapper.AlarmMapper;
import com.yeejoin.amos.bank.remote.AmosWsService;
import com.yeejoin.amos.bank.utils.DateTimeKit;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.eclipse.paho.client.mqttv3.MqttMessage; import org.eclipse.paho.client.mqttv3.MqttMessage;
...@@ -46,6 +49,8 @@ import com.yeejoin.amos.spc.core.util.StringUtil; ...@@ -46,6 +49,8 @@ import com.yeejoin.amos.spc.core.util.StringUtil;
import liquibase.integration.commandline.Main; import liquibase.integration.commandline.Main;
import static com.yeejoin.amos.bank.constants.AlarmConstant.*;
@Component @Component
public class SelfSupportListener extends EmqxListener implements InitializingBean { public class SelfSupportListener extends EmqxListener implements InitializingBean {
...@@ -63,13 +68,13 @@ public class SelfSupportListener extends EmqxListener implements InitializingBea ...@@ -63,13 +68,13 @@ public class SelfSupportListener extends EmqxListener implements InitializingBea
@Autowired @Autowired
RiskModelRemoteClient riskModelRemoteClient; RiskModelRemoteClient riskModelRemoteClient;
@Autowired @Autowired
IDeviceRecord iDeviceRecord; IDeviceRecord iDeviceRecord;
@Autowired @Autowired
ITopographyLineRepository nodeDao; ITopographyLineRepository nodeDao;
@Autowired @Autowired
private RemoteWebSocketServer webSocketServer; private RemoteWebSocketServer webSocketServer;
@Autowired @Autowired
...@@ -79,6 +84,13 @@ public class SelfSupportListener extends EmqxListener implements InitializingBea ...@@ -79,6 +84,13 @@ public class SelfSupportListener extends EmqxListener implements InitializingBea
private IAlarmService alarmService; private IAlarmService alarmService;
@Autowired @Autowired
private IAlarmRepository iAlarmDao; private IAlarmRepository iAlarmDao;
@Autowired
private AmosWsService amosWsService;
@Autowired
private AlarmMapper alarmMapper;
/** /**
* 监听主题 * 监听主题
*/ */
...@@ -105,219 +117,211 @@ public class SelfSupportListener extends EmqxListener implements InitializingBea ...@@ -105,219 +117,211 @@ public class SelfSupportListener extends EmqxListener implements InitializingBea
private void blueprintMsgtransfer(MqttMessage mqttMessage) { private void blueprintMsgtransfer(MqttMessage mqttMessage) {
try { try {
String jsonStr = new String(mqttMessage.getPayload()); String jsonStr = new String(mqttMessage.getPayload());
System.out.println("----supprtmqtt received--jsonStr:" + jsonStr); System.out.println("----supprtmqtt received--jsonStr:" + jsonStr);
// logger.error("----supprtmqtt received--jsonStr",jsonStr); // logger.error("----supprtmqtt received--jsonStr",jsonStr);
JSONObject parseObject = JSON.parseObject(jsonStr); JSONObject parseObject = JSON.parseObject(jsonStr);
//logger.info("----supprtmqtt received sucess",parseObject); //logger.info("----supprtmqtt received sucess",parseObject);
System.out.println("----supprtmqtt received sucess :"+ parseObject); System.out.println("----supprtmqtt received sucess :" + parseObject);
Long eqpId = parseObject.getLong("eqpId"); Long eqpId = parseObject.getLong("eqpId");
JSONArray jsonArray = parseObject.getJSONArray("metricDatas"); JSONArray jsonArray = parseObject.getJSONArray("metricDatas");
JSONArray eqpConfigMap = parseObject.getJSONArray("eqpConfigMap"); JSONArray eqpConfigMap = parseObject.getJSONArray("eqpConfigMap");
//获取ip //获取ip
String ipAddress = getIpAddress(eqpConfigMap); String ipAddress = getIpAddress(eqpConfigMap);
//楼层 //楼层
String lou =getIpAddress1(eqpConfigMap,"所属楼层"); String lou = getIpAddress1(eqpConfigMap, "所属楼层");
//3为坐标 //3为坐标
String sanwei =getIpAddress1(eqpConfigMap,"三维位置"); String sanwei = getIpAddress1(eqpConfigMap, "三维位置");
String eqpName = parseObject.getString("eqpName"); String eqpName = parseObject.getString("eqpName");
//orgcode //orgcode
String orgCode1 = parseObject.getString("orgCode"); String orgCode1 = parseObject.getString("orgCode");
if (ObjectUtils.isEmpty(jsonArray)) { if (ObjectUtils.isEmpty(jsonArray)) {
return; return;
} }
//告警信息 //告警信息
String metricKey=""; String metricKey = "";
//默认状态为正常 //默认状态为正常
int statusByName=0 ; int statusByName = 0;
// jsonArray.forEach(e -> { // jsonArray.forEach(e -> {
for (Object e : jsonArray){ for (Object e : jsonArray) {
JSONObject object = (JSONObject) e; JSONObject object = (JSONObject) e;
String string = object.getString("metricJson"); String string = object.getString("metricJson");
metricKey = object.getString("metricKey"); metricKey = object.getString("metricKey");
if (!StringUtil.isNotEmpty(string)) { if (!StringUtil.isNotEmpty(string)) {
return; return;
} }
logger.error("---------shudu--string",string); logger.error("---------shudu--string", string);
System.out.println("----supprtmqtt chuli recording : "+ string); System.out.println("----supprtmqtt chuli recording : " + string);
//{\"maxTime\":\"1\",\"packetLossRate\":\"0\",\"avgTime\":\"0\",\"minTime\":\"0\",\"发包数\":\"\",\"icmpPackSize\":\"32\",\"status\":\"通\"} //{\"maxTime\":\"1\",\"packetLossRate\":\"0\",\"avgTime\":\"0\",\"minTime\":\"0\",\"发包数\":\"\",\"icmpPackSize\":\"32\",\"status\":\"通\"}
JSONObject metricJson = JSONObject.parseObject(string); JSONObject metricJson = JSONObject.parseObject(string);
for (Map.Entry entry : metricJson.entrySet()) { for (Map.Entry entry : metricJson.entrySet()) {
// 指标名 // 指标名
System.out.println("----start chuli device state : "+ entry); System.out.println("----start chuli device state : " + entry);
String remark = entry.getKey().toString(); String remark = entry.getKey().toString();
String statusName = entry.getValue().toString(); String statusName = entry.getValue().toString();
if (remark.equals("status")) { if (remark.equals("status")) {
DeviceRecord record = new DeviceRecord(); DeviceRecord record = new DeviceRecord();
record.setDeviceId(eqpId); record.setDeviceId(eqpId);
statusByName = DeviceStatusEnum.getStatusByName(statusName); statusByName = DeviceStatusEnum.getStatusByName(statusName);
record.setDeviceStatus(statusByName); record.setDeviceStatus(statusByName);
record.setMetricData(string); record.setMetricData(string);
record.setName(eqpName + " " + ipAddress); record.setName(eqpName + " " + ipAddress);
iDeviceRecord.save(record); iDeviceRecord.save(record);
TopographyNode node = equipmentMapper.queryNodeBySourceId(String.valueOf(eqpId)); TopographyNode node = equipmentMapper.queryNodeBySourceId(String.valueOf(eqpId));
//触发风险合格不合格 //触发风险合格不合格
EquipmentQualityVo queryEquipmentPoint = equipmentMapper.queryEquipmentPoint(eqpId, remark); EquipmentQualityVo queryEquipmentPoint = equipmentMapper.queryEquipmentPoint(eqpId, remark);
Long equipmentsPointId = queryEquipmentPoint.getId(); Long equipmentsPointId = queryEquipmentPoint.getId();
List<Long> riskFactorId = equipmentMapper.judgeEquipmentExists(equipmentsPointId); List<Long> riskFactorId = equipmentMapper.judgeEquipmentExists(equipmentsPointId);
if ("不通".equals(statusName)) { if ("不通".equals(statusName)) {
Integer value = DevicePointEnum.getValue("异常"); Integer value = DevicePointEnum.getValue("异常");
equipmentMapper.updateEquipmentPointStatus(value, queryEquipmentPoint.getId()); equipmentMapper.updateEquipmentPointStatus(value, queryEquipmentPoint.getId());
} else { } else {
Integer value = DevicePointEnum.getValue("正常"); Integer value = DevicePointEnum.getValue("正常");
equipmentMapper.updateEquipmentPointStatus(value, queryEquipmentPoint.getId()); equipmentMapper.updateEquipmentPointStatus(value, queryEquipmentPoint.getId());
} }
//修改rpn值 //修改rpn值
for (int j = 0; j < riskFactorId.size(); j++) { for (int j = 0; j < riskFactorId.size(); j++) {
try { try {
riskModelRemoteClient.updateEquipmentAlarmData(riskFactorId.get(j)); riskModelRemoteClient.updateEquipmentAlarmData(riskFactorId.get(j));
System.out.println("----udpate riskFactor sucess"); System.out.println("----udpate riskFactor sucess");
} catch (InnerInvokException e1) { } catch (InnerInvokException e1) {
logger.error("update rpn fail " + e1.getMessage()); logger.error("update rpn fail " + e1.getMessage());
} }
} }
if(null!=node) { if (null != node) {
node.setNumber(statusByName); node.setNumber(statusByName);
node.setState(statusByName); node.setState(statusByName);
equipmentMapper.updateNodeState(node); equipmentMapper.updateNodeState(node);
String nodeDetail = (statusByName== 0 ? "[{\"name\":\"通信状态\",\"value\":\"正常\"}]":"[{\"name\":\"通信状态\",\"value\":\"异常\"}]"); String nodeDetail = (statusByName == 0 ? "[{\"name\":\"通信状态\",\"value\":\"正常\"}]" : "[{\"name\":\"通信状态\",\"value\":\"异常\"}]");
equipmentMapper.updateNodeDetail(node.getId(), nodeDetail); equipmentMapper.updateNodeDetail(node.getId(), nodeDetail);
try { try {
webSocketServer.sendMessage("refresh", "self"); webSocketServer.sendMessage("refresh", "self");
} catch (Exception e1) { } catch (Exception e1) {
logger.error("webSocketServer send self! "); logger.error("webSocketServer send self! ");
} }
} }
} }
} }
}; }
;
// }); // });
//增加报警 //增加报警
List<AlarmPoint> alarmPoint= alarmPointService.selectPointTypeAndPointId(AlarmPointTypeEnum.设备.getCode(), eqpId); List<AlarmPoint> alarmPoint = alarmPointService.selectPointTypeAndPointId(AlarmPointTypeEnum.设备.getCode(), eqpId);
if(alarmPoint!=null&&alarmPoint.size()>0){ if (alarmPoint != null && alarmPoint.size() > 0) {
//存在报警,判断当前状态是不是合格,合格则删除上次的报警 //存在报警,判断当前状态是不是合格,合格则删除上次的报警
if(statusByName==0){ if (statusByName == 0) {
//删除告警 //删除告警
alarmPointService.delete(alarmPoint.get(0)); alarmPointService.delete(alarmPoint.get(0));
} amosWsService.pushAlarmPoint("alarmPoint", alarmPointService.findAll());
}else{ }
//不存在,判断当前状态是不是合格,不合格新增,合格不做任何操作 } else {
if(statusByName!=0){ //不存在,判断当前状态是不是合格,不合格新增,合格不做任何操作
//增加告警 if (statusByName != 0) {
AlarmPoint alarmPoint1=new AlarmPoint(); //增加告警
alarmPoint1.setPointId(eqpId); AlarmPoint alarmPoint1 = new AlarmPoint();
alarmPoint1.setPointType(AlarmPointTypeEnum.设备.getCode()); alarmPoint1.setPointId(eqpId);
alarmPoint1.setUpdateDate(new Date()); alarmPoint1.setPointType(AlarmPointTypeEnum.设备.getCode());
alarmPoint1.setIsAlarm(1);//不合格 alarmPoint1.setUpdateDate(new Date());
alarmPoint1.setContent(eqpName+"-"+ipAddress+"-"+metricKey); alarmPoint1.setIsAlarm(1);//不合格
alarmPoint1.setCode(orgCode1); alarmPoint1.setContent(eqpName + "-" + ipAddress + "-" + metricKey);
alarmPoint1.setPointName(eqpName); alarmPoint1.setCode(orgCode1);
Map<String, Object> map = new HashMap<>(); alarmPoint1.setPointName(eqpName);
map.put("position",sanwei); Map<String, Object> map = new HashMap<>();
map.put("storey", lou); map.put("position", sanwei);
map.put("levelStr", "impEqu_04"); map.put("storey", lou);
map.put("levelStr", "impEqu_04");
alarmPoint1.setPointAttrs(JSON.toJSONString(map));
alarmPointService.save(alarmPoint1); alarmPoint1.setPointAttrs(JSON.toJSONString(map));
//推送告警 alarmPointService.save(alarmPoint1);
List<AlarmPoint> list= alarmPointService.findAll(); //推送告警
WebsocketParam param=new WebsocketParam("alarmPoint", JSON.toJSONString(list)); amosWsService.pushAlarmPoint("alarmPoint", alarmPointService.findAll());
Properties props = PropertiesLoaderUtils.loadAllProperties("application.properties"); }
String url = (String) props.get("params.remoteWebsocketUrl") + "/generic/sendMessage"; }
HttpUtil.PostJson(url, JSON.toJSONString(param));
}
}
//增建告警记录表 //增建告警记录表
//告警记录 //告警记录
List<Alarm> curAlarmList = alarmService.findByQueryColumn(eqpId+metricKey); List<Alarm> curAlarmList = alarmService.findByQueryColumn(eqpId + metricKey);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if (curAlarmList != null && curAlarmList.size() > 0) { if (curAlarmList != null && curAlarmList.size() > 0) {
// if("异常".equals(curAlarmList.get(0).getCurrentState())){ Alarm alarm = curAlarmList.get(0);
Alarm alarm = curAlarmList.get(0); alarm.setUpdateDate(DateTimeKit.now());
alarm.setUpdateDate(df.format(new Date())); if (!ObjectUtils.isEmpty(alarm.getHappenDate())) {
if(statusByName!=0){ String subtract = DateTimeKit.getSubtract(alarm.getHappenDate());
alarm.setCurrentState("异常"); alarm.setContinueDate(subtract);
}else{ }
alarm.setCurrentState("正常"); if (ALARM_ABNORMAL_STATUS.equals(alarm.getCurrentState()) && statusByName != 0) {
} alarm.setCurrentState(ALARM_ABNORMAL_STATUS);
alarm.setQueryColumn(eqpId+metricKey); } else {
alarm.setAlarmSourceType(metricKey); alarm.setClearDate(DateTimeKit.now());
alarm.setClearPerson(metricKey); alarm.setClearPerson(CLEAR_PERSON);
iAlarmDao.save(alarm); alarm.setCurrentState(ALARM_NORMAL_STATUS);
// } }
alarmMapper.updateAlarm(alarm);
} else { } else {
Alarm alarm = new Alarm(); Alarm alarm = new Alarm();
alarm.setSourceId(eqpId+""); alarm.setSourceId(eqpId + "");
alarm.setAlarmLevel("紧急告警"); alarm.setAlarmLevel(ALARM_LEVEL);
alarm.setAlarmReason(""); alarm.setAlarmReason(ALARM_CAUSE);
alarm.setAlarmSourceIp(ipAddress+""); alarm.setAlarmSourceIp(ipAddress + "");
alarm.setAlarmSourceName(eqpName); alarm.setAlarmSourceName(eqpName);
alarm.setAlarmSourceType(metricKey); alarm.setAlarmSourceType(ALARM_TYPE);
alarm.setClearDate(""); alarm.setClearDate("");
alarm.setClearPerson(metricKey);
alarm.setContinueDate(""); alarm.setContinueDate("");
if(statusByName!=0){
alarm.setCurrentState("异常");
}else{
alarm.setCurrentState("正常");
}
alarm.setEnsureDate(""); alarm.setEnsureDate("");
alarm.setHappenDate("");
alarm.setEnsurePerson(""); alarm.setEnsurePerson("");
alarm.setOrgCode(orgCode1); alarm.setOrgCode(orgCode1);
alarm.setUpdateDate(df.format(new Date())); alarm.setQueryColumn(eqpId + metricKey);
alarm.setQueryColumn(eqpId+metricKey); alarm.setHappenDate(DateTimeKit.now());
iAlarmDao.save(alarm); if (statusByName != 0) {
} alarm.setCurrentState(ALARM_ABNORMAL_STATUS);
iAlarmDao.save(alarm);
} else {
alarm.setCurrentState(ALARM_NORMAL_STATUS);
}
}
} catch (Exception e) { } catch (Exception e) {
logger.error("消息流转报错."); logger.error("消息流转报错.");
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
e.printStackTrace(); e.printStackTrace();
} }
} }
public String getIpAddress1(JSONArray eqpConfigMap, String name) {
public String getIpAddress1(JSONArray eqpConfigMap,String name) { //配置信息
//配置信息 if (null != eqpConfigMap && eqpConfigMap.size() > 0) {
if(null != eqpConfigMap && eqpConfigMap.size() > 0) { for (Object object : eqpConfigMap) {
for (Object object : eqpConfigMap) { JSONObject obj = (JSONObject) object;
JSONObject obj = (JSONObject) object; String str = obj.getString("displayName");
String str = obj.getString("displayName"); if (str.contains(name)) {
if(str.contains(name)) { String ip = obj.getString("valueStr");
String ip = obj.getString("valueStr"); return ip;
return ip; }
} }
}
} }
return null; return null;
} }
public String getIpAddress(JSONArray eqpConfigMap) { public String getIpAddress(JSONArray eqpConfigMap) {
//配置信息 //配置信息
if(null != eqpConfigMap && eqpConfigMap.size() > 0) { if (null != eqpConfigMap && eqpConfigMap.size() > 0) {
for (Object object : eqpConfigMap) { for (Object object : eqpConfigMap) {
JSONObject obj = (JSONObject) object; JSONObject obj = (JSONObject) object;
String str = obj.getString("displayName"); String str = obj.getString("displayName");
if(str.contains("IP")) { if (str.contains("IP")) {
String ip = obj.getString("valueStr"); String ip = obj.getString("valueStr");
return ip; return ip;
} }
} }
} }
return null; return null;
} }
......
...@@ -10,6 +10,7 @@ public class AlarmConstant { ...@@ -10,6 +10,7 @@ public class AlarmConstant {
public static String ALARM_CAUSE = "设备Ping不通"; public static String ALARM_CAUSE = "设备Ping不通";
public static String CLEAR_PERSON = "自动清除"; public static String CLEAR_PERSON = "自动清除";
public static String ALARM_LEVEL = "紧急告警"; public static String ALARM_LEVEL = "紧急告警";
public static String ALARM_TYPE = "IP设备告警";
public static String ALARM_NORMAL_STATUS = "清除"; public static String ALARM_NORMAL_STATUS = "清除";
public static String ALARM_ABNORMAL_STATUS = "告警"; public static String ALARM_ABNORMAL_STATUS = "告警";
} }
...@@ -18,7 +18,7 @@ public interface IAlarmRepository extends IBaseRepository<Alarm, String> { ...@@ -18,7 +18,7 @@ public interface IAlarmRepository extends IBaseRepository<Alarm, String> {
@Query(value="select * from spc_alarm where query_column =?1 AND current_state in ('未确认未清除','已确认未清除','异常','告警')",nativeQuery=true ) @Query(value="select * from spc_alarm where query_column =?1 AND current_state in ('未确认未清除','已确认未清除','异常','告警')",nativeQuery=true )
public List<Alarm> selectByQueryColumn(String type); public List<Alarm> selectByQueryColumn(String type);
@Query(value="select COUNT(*) value,spc_alarm.alarm_level name from spc_alarm where spc_alarm.org_code like CONCAT(?1,'%' ) and spc_alarm.current_state in ('未确认未清除','已确认未清除','异常') GROUP BY spc_alarm.alarm_level ",nativeQuery=true ) @Query(value="select COUNT(*) value,spc_alarm.alarm_level name from spc_alarm where spc_alarm.org_code like CONCAT('%', ?1, '%' ) and spc_alarm.current_state in ('未确认未清除','已确认未清除','异常','告警') GROUP BY spc_alarm.alarm_level ",nativeQuery=true )
public List<Object[]> countnum(String code); public List<Object[]> countnum(String code);
} }
......
package com.yeejoin.amos.bank.remote;
import com.alibaba.fastjson.JSON;
import com.yeejoin.amos.bank.webSocket.AmosWsClient;
import com.yeejoin.amos.bank.webSocket.WebsocketParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @Author: xinglei
* @Description:
* @Date: 2020/6/11 8:56
*/
@Service
public class AmosWsService {
@Autowired
private AmosWsClient client;
/**
* 发送Websocket
*/
public void pushAlarmPoint(String WS, Object object) {
WebsocketParam param = new WebsocketParam(WS, JSON.toJSONString(object));
client.sendMessage(param);
}
}
...@@ -44,16 +44,11 @@ public class DateTimeKit { ...@@ -44,16 +44,11 @@ public class DateTimeKit {
sb.append(day).append("天"); sb.append(day).append("天");
} }
if (hour != 0) { if (hour != 0) {
sb.append(hour%24).append("小时"); sb.append(hour % 24).append("小时");
} }
if (minute != 0) { if (minute != 0) {
sb.append(minute%60).append("分"); sb.append(minute % 60).append("分");
} }
return sb.toString(); return sb.toString();
} }
public static void main(String[] args) {
String subtract = getSubtract("2020-06-09 17:38:59");
System.out.println(subtract);
}
} }
...@@ -14,5 +14,4 @@ public interface AmosWsClient { ...@@ -14,5 +14,4 @@ public interface AmosWsClient {
@PostMapping("/generic/sendDataList") @PostMapping("/generic/sendDataList")
CommonResponse sendDataList(@RequestBody WebsocketListParam param); CommonResponse sendDataList(@RequestBody WebsocketListParam param);
} }
...@@ -47,7 +47,7 @@ public class AlarmController extends BaseController { ...@@ -47,7 +47,7 @@ public class AlarmController extends BaseController {
//获取当前登录人的公司code //获取当前登录人的公司code
ReginParams reginParams = getSelectedOrgInfo(); ReginParams reginParams = getSelectedOrgInfo();
DaoCriteria criteria = new DaoCriteria(); DaoCriteria criteria = new DaoCriteria();
criteria.setValue(reginParams.getCompany().getOrgCode() + "%"); criteria.setValue("%" + reginParams.getCompany().getOrgCode() + "%");
criteria.setOperator(QueryOperatorEnum.LIKE.getName()); criteria.setOperator(QueryOperatorEnum.LIKE.getName());
criteria.setPropertyName("orgCode"); criteria.setPropertyName("orgCode");
......
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
<if test="updateDate != null"> <if test="updateDate != null">
update_date = #{updateDate}, update_date = #{updateDate},
</if> </if>
<if test="clearDate != null">
clear_date = #{clearDate},
</if>
<if test="clearPerson != null"> <if test="clearPerson != null">
clear_person = #{clearPerson}, clear_person = #{clearPerson},
</if> </if>
...@@ -22,6 +25,6 @@ ...@@ -22,6 +25,6 @@
continue_date = #{continueDate}, continue_date = #{continueDate},
</if> </if>
</set> </set>
where query_column = #{queryColumn} where id = #{id}
</update> </update>
</mapper> </mapper>
\ No newline at end of file
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