diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/interruption/constants/InterruptionConstants.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/interruption/constants/InterruptionConstants.java new file mode 100644 index 0000000..3beabb5 --- /dev/null +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/interruption/constants/InterruptionConstants.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.business.interruption.constants; + +import java.util.Arrays; +import java.util.List; + +/** + * @author ysj + */ +public interface InterruptionConstants { + + List INTERRUPTION_TYPE = Arrays.asList("13","14"); +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java index 6fbd377..d0b2d43 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java @@ -64,9 +64,6 @@ public interface MainConstants { // 运行月报告 String RUM_MONTH_REPORT = "runMonthReport"; - // 站点数据统计 - String STATION_DATA_COUNT = "stationDataCount"; - // 集中监控数据处理 String CENTRALIZED_MONITORING = "centralizedMonitoring"; @@ -82,9 +79,6 @@ public interface MainConstants { // 站点实时数据 String REAL_TIME_DATA = "realTimeData"; - // 通讯中断数据处理 - String ALARM_DATA_HANDLE = "alarmDataHandle"; - // 光伏站-机组指标数据 String LOAD_PHOTOVOLTAIC_TARGET = "loadPhotovoltaicTarget"; diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/InterruptionAlrmMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/InterruptionAlrmMapper.java new file mode 100644 index 0000000..8112618 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/InterruptionAlrmMapper.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.scheduled.mapper.alarm; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.business.interruption.entity.InterruptionEntity; + +/** + * @author ysj + */ +public interface InterruptionAlrmMapper extends BaseMapper { + + +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java index dc3f1ea..af12a59 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java @@ -1,6 +1,7 @@ package com.hnac.hzims.scheduled.scheduled; import com.hnac.hzims.scheduled.service.alarm.AlarmQueryService; +import com.hnac.hzims.scheduled.service.alarm.InterruptionAlarmService; import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.handler.annotation.XxlJob; import lombok.extern.slf4j.Slf4j; @@ -25,7 +26,10 @@ import static com.hnac.hzims.operational.main.constant.MainConstants.START_STOP_ public class AlarmScheduledTask { @Autowired - private AlarmQueryService service; + private AlarmQueryService alarmQueryService; + + @Autowired + private InterruptionAlarmService interruptionService; /** * 开停机告警 @@ -37,17 +41,17 @@ public class AlarmScheduledTask { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } - service.startStopAlarm(param); + alarmQueryService.startStopAlarm(param); return new ReturnT<>("SUCCESS"); } @XxlJob(INTERRUPT_ALARM) //@Scheduled(cron = "0/40 * * * * ? ") - public ReturnT interruptAlarm(String param) { + public ReturnT interruption(String param) { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } - service.interruptAlarm(param); + interruptionService.interruption(param); return new ReturnT<>("SUCCESS"); } } \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmQueryService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmQueryService.java index ff85d1c..a8ea132 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmQueryService.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmQueryService.java @@ -10,12 +10,10 @@ import java.util.List; */ public interface AlarmQueryService extends BaseService { - // 开停机告警 void startStopAlarm(String param); List bells(List codes); List aborts(List codes); - void interruptAlarm(String param); } \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/InterruptionAlarmService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/InterruptionAlarmService.java new file mode 100644 index 0000000..f239e5e --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/InterruptionAlarmService.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.scheduled.service.alarm; + +import com.hnac.hzims.business.interruption.entity.InterruptionEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * @author ysj + */ +public interface InterruptionAlarmService extends BaseService { + + void interruption(String param); +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmQueryServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmQueryServiceImpl.java index a922504..e1d9868 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmQueryServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmQueryServiceImpl.java @@ -5,22 +5,28 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.alarm.config.constants.AlarmConstants; import com.hnac.hzims.alarm.config.entity.AlarmEntity; +import com.hnac.hzims.business.interruption.constants.InterruptionConstants; +import com.hnac.hzims.business.interruption.entity.InterruptionEntity; +import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.vo.HydropowerUnitRealVo; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.scheduled.mapper.alarm.AlarmQueryMapper; import com.hnac.hzims.scheduled.service.alarm.AlarmQueryService; import com.hnac.hzims.scheduled.service.operation.station.StationService; +import com.hnac.hzinfo.datasearch.soe.ISoeClient; +import com.hnac.hzinfo.datasearch.soe.domian.SoeData; +import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryConditionByStation; +import com.hnac.hzinfo.sdk.core.response.HzPage; +import com.hnac.hzinfo.sdk.core.response.Result; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.base.BaseServiceImpl; -import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.DateUtil; -import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.StringUtil; +import org.springblade.core.tool.utils.*; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; +import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; @@ -188,13 +194,4 @@ public class AlarmQueryServiceImpl extends BaseServiceImpl implements InterruptionAlarmService { + + private final StationService stationService; + + private final ISoeClient soeClient; + + /** + * 数据中断告警 + * @param param + */ + @Override + public void interruption(String param) { + // 查询接入站点 + List stations = stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getDataOrigin,"0") + ); + if(CollectionUtil.isEmpty(stations)){ + return; + } + // 查询告警数据: 间隔10分钟 + SoeQueryConditionByStation query = new SoeQueryConditionByStation(); + query.setTypes(InterruptionConstants.INTERRUPTION_TYPE); + query.setStationIds(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); + Calendar calendar = Calendar.getInstance(); + query.setEndTime(LocalDateTime.parse(DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME),DateUtil.DATETIME_FORMATTER)); + calendar.add(Calendar.MINUTE,-10); + query.setBeginTime(LocalDateTime.parse(DateUtil.format(calendar.getTime() , DateUtil.PATTERN_DATETIME),DateUtil.DATETIME_FORMATTER)); + query.setNeedPage(false); + query.setPage(1); + query.setLimit(1000); + Result> result = soeClient.getByStationsAndTime(query); + // 未查询到告警信息 + if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())) { + return; + } + // 中断告警数据 + List soes = result.getData().getRecords(); + // 查询当天数据中断告警记录 + List saves = this.saveInterruptions(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); + } + + /** + * 查询当天数据中断告警记录 + * @param stations + * @return + */ + private List saveInterruptions(List stations) { + this.list(Wrappers.lambdaQuery()); + return new ArrayList<>(); + } +} \ No newline at end of file