diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmConstants.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmConstants.java index 1177139..ca69964 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmConstants.java +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmConstants.java @@ -66,4 +66,6 @@ public interface AlarmConstants { String SMS_MESSAGE_TEMPLATE_CODE = "aliyun-alert-push"; String FDP_INVALID_STATUS = "0.0"; + + String FDP_INVALID_ZOME_STATUS = "0"; } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java index ba8d184..deed511 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java @@ -92,38 +92,32 @@ public class AlarmConfigDetailServiceImpl extends BaseServiceImpl> result = stationClient.querySatationByCodes(alarms.stream().map(AlarmEntity::getStationId).collect(Collectors.toList())); if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ - log.error("alarm query station is null : {}",alarms.stream().map(AlarmEntity::getAlarmId).collect(Collectors.toList())); + log.error("alarm_query_station_is_null : {}",alarms.stream().map(AlarmEntity::getAlarmId).collect(Collectors.toList())); return false; } // 步骤2.遍历保存告警数据 alarms.forEach(alarm->{ - List stations = result.getData().stream().filter(o->o.getCode().equals(alarm.getStationId())).collect(Collectors.toList()); if(CollectionUtil.isEmpty(stations)){ return; @@ -64,10 +63,9 @@ public class AlarmSaveServiceImpl implements AlarmSaveService { // 步骤4.根据站点查询配置标识 AlarmHandleMarkVo mark = alarmConfigService.mark(alarm.getStationId(),alarm.getAlarmSource(),alarm.getAlarmType()); if(ObjectUtil.isEmpty(mark)){ - log.error("alarm obtain mark is null : {}",alarm.getAlarmId()); + log.error("alarm_obtain_mark_is_null : {}",alarm.getAlarmId()); return; } - // 步骤5.告警处理标识赋值 alarm.setIsRightTabulation(mark.getIsRightTabulation()); alarm.setIsBroadcast(mark.getIsBroadcast()); @@ -77,11 +75,10 @@ public class AlarmSaveServiceImpl implements AlarmSaveService { alarm.setIsSmallBell(mark.getIsSmallBell()); alarm.setIsShortMessage(mark.getIsShortMessage()); alarm.setIsWxMessage(mark.getIsWxMessage()); - // 步骤6.保存当日告警数据 boolean isSave = alarmService.save(alarm); if(!isSave){ - log.error("alarm save fail : {}",alarm.getAlarmId()); + log.error("alarm_save_fail : {}",alarm.getAlarmId()); return; } @@ -90,4 +87,5 @@ public class AlarmSaveServiceImpl implements AlarmSaveService { }); return true; } + } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/FdpMqttConsumer.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/FdpMqttConsumer.java index e1513dd..c4c2d97 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/FdpMqttConsumer.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/FdpMqttConsumer.java @@ -29,13 +29,14 @@ public class FdpMqttConsumer implements SubscribeCallBack { @Override public void onMessage(Map data) { String s = JSONObject.toJSONString(data); + log.error("监听Fdp消息 : {}" ,s); //消费代码 List alarmEntities = fdpAlarmService.receiveMessage(s); if(CollectionUtil.isEmpty(alarmEntities)){ return; } - log.error("监听Fdp有效消息 : {}" ,alarmEntities); + log.error("监听Fdp有效消息 : {}" ,alarmEntities.get(0).getAlarmId()); //统一数据处理 try { alarmSaveService.save(alarmEntities); diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/HZ300MqttConsumer.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/HZ300MqttConsumer.java index 67c4895..82880ad 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/HZ300MqttConsumer.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/HZ300MqttConsumer.java @@ -6,6 +6,7 @@ import com.hnac.hzims.alarm.source.service.SystemAlarmService; import com.hnac.hzims.alarm.monitor.service.AlarmSaveService; import com.hnac.hzinfo.subscribe.SubscribeCallBack; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -31,11 +32,15 @@ public class HZ300MqttConsumer implements SubscribeCallBack { log.error("HZ3000队列监听到消息 : {}",data); //消费代码 List alarmEntities = systemAlarmService.receiveMessage(JSONObject.toJSONString(data)); + if(CollectionUtil.isEmpty(alarmEntities)){ + log.error("HZ3000消息转换数据异常"); + return; + } //统一数据处理 try { alarmSaveService.save(alarmEntities); }catch (Exception e){ - log.error("HZ3000告警数据处理报错(HZ300Alarm):"+e); + log.error("HZ3000告警数据处理报错(HZ300Alarm):{}" , e.getMessage()); } } } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/FdpAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/FdpAlarmServiceImpl.java index b16c48e..75e6d1e 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/FdpAlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/FdpAlarmServiceImpl.java @@ -72,7 +72,7 @@ public class FdpAlarmServiceImpl implements FdpAlarmService { if (ObjectUtils.isEmpty(alarms)) { return new ArrayList<>(); } - if(FDP_INVALID_STATUS.equals(alarms.getStatus())){ + if(FDP_INVALID_STATUS.equals(alarms.getStatus()) || FDP_INVALID_ZOME_STATUS.equals(alarms.getStatus())){ return new ArrayList(); } AlarmEntity entity = getAlarmEntity(alarms); @@ -89,7 +89,7 @@ public class FdpAlarmServiceImpl implements FdpAlarmService { entity.setAlarmType(EARLY); entity.setDeviceCode(item.getDeviceId()); entity.setDeviceName(item.getDeviceName()); - entity.setAlarmStatus(Integer.valueOf(item.getStatus())); + entity.setAlarmStatus(1); entity.setAlarmValue(item.getInfo()); entity.setStationId(item.getStation()); entity.setDiagReason(item.getDiagReason()); diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SystemAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SystemAlarmServiceImpl.java index b8f14b2..8f3bee4 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SystemAlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SystemAlarmServiceImpl.java @@ -74,7 +74,6 @@ public class SystemAlarmServiceImpl implements SystemAlarmService { public List receiveMessage(String message) { // 对象转换 SystemAlarmVo systemAlarm = JSONObject.parseObject(message, SystemAlarmVo.class); - log.error("HZ3000告警对象转换后:{}",systemAlarm); if (ObjectUtils.isEmpty(systemAlarm)) { return new ArrayList<>(); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/level/LevelAlarmRegular.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/level/LevelAlarmRegular.java deleted file mode 100644 index 1727c10..0000000 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/level/LevelAlarmRegular.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.hnac.hzims.alarm.ws.level; - -import com.hnac.hzims.alarm.source.service.LevelAlarmService; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springblade.core.tool.utils.StringUtil; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.EnableScheduling; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import java.net.URI; - -/** - * @author ysj - */ -@Slf4j -@Component -@EnableScheduling -public class LevelAlarmRegular { - - @Autowired - private LevelAlarmService levelService; - - private LevelAlarmWebSocket socket; - - @Value("${hzims.level.wss-url}") - private String level_wss_url; - - // 两分钟进行一次检查链接是否存活,不存活了重新建立链接 - @Scheduled(cron = "0 0/2 * * * ?") - private void regular(){ - // 检查链接存活状态 - if(ObjectUtil.isEmpty(socket) || !socket.isOpen()){ - log.error("level websocket survival check : {}","死亡"); - this.createSocket(); - if(ObjectUtil.isNotEmpty(socket) && socket.isOpen()){ - String message = levelService.message(); - if(!StringUtil.isEmpty(message)){ - socket.send(message); - } - } - log.error("level websocket survival check : {}","重新建立链接"); - }else{ - log.error("level websocket survival check : {}","存活"); - } - } - - // 创建websocket链接 - private void createSocket() { - try{ - socket = new LevelAlarmWebSocket(new URI(level_wss_url)); - socket.connectBlocking(); - }catch (Exception e){ - log.error("level create error : {}",e.getMessage()); - } - } -} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/level/LevelAlarmWebSocket.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/level/LevelAlarmWebSocket.java deleted file mode 100644 index 83f36a3..0000000 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/level/LevelAlarmWebSocket.java +++ /dev/null @@ -1,139 +0,0 @@ -package com.hnac.hzims.alarm.ws.level; - -import com.hnac.hzims.alarm.config.entity.AlarmEntity; -import com.hnac.hzims.alarm.source.service.LevelAlarmService; -import com.hnac.hzims.alarm.monitor.service.AlarmSaveService; -import lombok.extern.slf4j.Slf4j; -import org.java_websocket.client.WebSocketClient; -import org.java_websocket.handshake.ServerHandshake; -import org.springblade.core.log.exception.ServiceException; -import org.springblade.core.tool.utils.SpringUtil; -import org.springblade.core.tool.utils.StringUtil; - -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; -import java.net.Socket; -import java.net.URI; -import java.security.SecureRandom; -import java.security.cert.X509Certificate; -import java.util.List; -import java.util.Optional; - -/** - * @author ysj - */ -@Slf4j -public class LevelAlarmWebSocket extends WebSocketClient { - - - private final LevelAlarmService levelService; - - private AlarmSaveService alarmSaveService; - - /** - * 构造等级告警websocket - * @param uri - */ - public LevelAlarmWebSocket(URI uri) { - super(uri); - levelService = SpringUtil.getBean(LevelAlarmService.class); - connection(this); - } - - // 链接到服务器回调接口 - @Override - public void onOpen(ServerHandshake handshakedata) { - log.error("systemAlarm websocket open"); - } - - // 接收到服务器消息回调接口 - @Override - public void onMessage(String message) { - if(StringUtil.isEmpty(message)){ - log.error("level alarm on message is null"); - }else{ - - // 告警数据转化 - List alarmEntities = levelService.receiveMessage(message); - // 等级告警数据处理 - try { - //websocket 消息推送保存 - alarmSaveService.save(alarmEntities); - }catch (Exception e){ - throw new ServiceException("集中监控告警数据处理报错(levelAlarm):"+e); - } - } - } - - // 与服务器链接中断回调接口 - @Override - public void onClose(int code, String reason, boolean remote) { - log.error("level alarm websocket close"); - } - - // 与服务器通讯异常触发 - @Override - public void onError(Exception e) { - log.error("level alarm websocket error : {}",e.getMessage()); - } - - /** - * 建立链接 - * @param webSocket - */ - private void connection(LevelAlarmWebSocket webSocket) { - SSLContext context = init(); - if(Optional.ofNullable(context).isPresent()){ - Socket socket = create(context); - if(Optional.ofNullable(socket).isPresent()){ - webSocket.setSocket(socket); - } - } - } - - /** - * 创建Socket - * @param context - * @return - */ - private Socket create(SSLContext context) { - Socket socket = null; - try{ - socket = context.getSocketFactory().createSocket(); - }catch (Exception e){ - log.error("level alarm socket create error : {}",e.getMessage()); - } - return socket; - } - - /** - * 协议初始化 - * @return SSLContext - */ - private SSLContext init() { - SSLContext SSL = null; - try{ - SSL = SSLContext.getInstance("TLS"); - SSL.init(null, new TrustManager[]{new X509TrustManager() { - @Override - public void checkClientTrusted(X509Certificate[] chain, - String authType) { - } - - @Override - public void checkServerTrusted(X509Certificate[] chain, String authType) { - } - - @Override - public X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[0]; - } - }}, new SecureRandom()); - }catch (Exception e){ - log.error("level alarm SSL init error : {}",e.getMessage()); - } - return SSL; - } - -} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessLibraryServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessLibraryServiceImpl.java index 9f465c2..5c38cab 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessLibraryServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessLibraryServiceImpl.java @@ -202,8 +202,8 @@ public class OperAccessLibraryServiceImpl extends BaseServiceImpl weekWeather = this.weatherService.getWeekWeather(stations); return areas.entrySet().stream().map(entry -> { WindSubordinateVo subordinate = new WindSubordinateVo(); + subordinate.setGeneration(0.0); + subordinate.setGenerationRate(0.0); + subordinate.setGenerationComplete(0.0); + subordinate.setFanUse(0.0); + subordinate.setFactoryUse(0.0); // 获取第一个站点经纬度、行政编码信息 StationEntity station = entry.getValue().get(0); subordinate.setLttd(station.getLttd()); @@ -252,11 +257,6 @@ public class WindHomeServiceImpl implements WindHomeService { if(CollectionUtil.isNotEmpty(winds)){ List piece = winds.stream().filter(o->entry.getValue().stream().map(StationEntity::getCode).collect(Collectors.toList()).contains(o.getStationCode())).collect(Collectors.toList()); if(CollectionUtil.isEmpty(piece)){ - subordinate.setGeneration(0.0); - subordinate.setGenerationRate(0.0); - subordinate.setGenerationComplete(0.0); - subordinate.setFanUse(0.0); - subordinate.setFactoryUse(0.0); return subordinate; } // 发电量 @@ -294,8 +294,7 @@ public class WindHomeServiceImpl implements WindHomeService { } } return subordinate; - }).filter(o-> Math.abs(o.getGeneration()) > 0 || Math.abs(o.getGenerationRate()) > 0 || Math.abs(o.getGenerationComplete()) > 0 - || Math.abs(o.getFactoryUse()) > 0 || Math.abs(o.getFanUse()) > 0 ).sorted(Comparator.comparing(WindSubordinateVo::getGeneration).reversed()).collect(Collectors.toList()); + }).sorted(Comparator.comparing(WindSubordinateVo::getGeneration).reversed()).collect(Collectors.toList()); } /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/controller/OperMaintenanceTaskController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/controller/OperMaintenanceTaskController.java index 2ada029..8202694 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/controller/OperMaintenanceTaskController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/controller/OperMaintenanceTaskController.java @@ -124,6 +124,7 @@ public class OperMaintenanceTaskController extends BladeController { public R> list(@RequestBody OperMaintenanceTaskDTO req) { return taskService.list(req); } + @ApiLog @PostMapping("/exportMaintenance") @ApiOperationSupport(order = 2) diff --git a/hzims-service/operational/src/main/resources/template/excel/access_import_template.xlsx b/hzims-service/operational/src/main/resources/template/excel/access_import_template.xlsx index 0bb642a..737bd1e 100644 Binary files a/hzims-service/operational/src/main/resources/template/excel/access_import_template.xlsx and b/hzims-service/operational/src/main/resources/template/excel/access_import_template.xlsx differ