Browse Source

#数据中断告警移植

zhongwei
yang_shj 11 months ago
parent
commit
970d2d16a9
  1. 12
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/interruption/constants/InterruptionConstants.java
  2. 6
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java
  3. 12
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/InterruptionAlrmMapper.java
  4. 12
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java
  5. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmQueryService.java
  6. 12
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/InterruptionAlarmService.java
  7. 23
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmQueryServiceImpl.java
  8. 87
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/InterruptionAlarmServiceImpl.java

12
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<String> INTERRUPTION_TYPE = Arrays.asList("13","14");
}

6
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";

12
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<InterruptionEntity> {
}

12
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<String> interruptAlarm(String param) {
public ReturnT<String> interruption(String param) {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
}
service.interruptAlarm(param);
interruptionService.interruption(param);
return new ReturnT<>("SUCCESS");
}
}

2
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<AlarmEntity> {
// 开停机告警
void startStopAlarm(String param);
List<String> bells(List<String> codes);
List<String> aborts(List<String> codes);
void interruptAlarm(String param);
}

12
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<InterruptionEntity> {
void interruption(String param);
}

23
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<AlarmQueryMapper, Ala
return "";
}).filter(StringUtil::isBlank).distinct().collect(Collectors.toList());
}
/**
* 数据中断告警
* @param param
*/
@Override
public void interruptAlarm(String param) {
}
}

87
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/InterruptionAlarmServiceImpl.java

@ -0,0 +1,87 @@
package com.hnac.hzims.scheduled.service.alarm.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.business.interruption.constants.InterruptionConstants;
import com.hnac.hzims.business.interruption.entity.InterruptionEntity;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.scheduled.mapper.alarm.InterruptionAlrmMapper;
import com.hnac.hzims.scheduled.service.alarm.InterruptionAlarmService;
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.ObjectUtil;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author ysj
*/
@AllArgsConstructor
@Service
@Slf4j
@DS("alarm")
public class InterruptionAlarmServiceImpl extends BaseServiceImpl<InterruptionAlrmMapper, InterruptionEntity> implements InterruptionAlarmService {
private final StationService stationService;
private final ISoeClient soeClient;
/**
* 数据中断告警
* @param param
*/
@Override
public void interruption(String param) {
// 查询接入站点
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>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<HzPage<SoeData>> result = soeClient.getByStationsAndTime(query);
// 未查询到告警信息
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())) {
return;
}
// 中断告警数据
List<SoeData> soes = result.getData().getRecords();
// 查询当天数据中断告警记录
List<InterruptionEntity> saves = this.saveInterruptions(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
}
/**
* 查询当天数据中断告警记录
* @param stations
* @return
*/
private List<InterruptionEntity> saveInterruptions(List<String> stations) {
this.list(Wrappers.<InterruptionEntity>lambdaQuery());
return new ArrayList<>();
}
}
Loading…
Cancel
Save