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