Browse Source

#FDP告警过滤无效数据

zhongwei
yang_shj 8 months ago
parent
commit
d02e56502c
  1. 2
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmConstants.java
  2. 3
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java
  3. 8
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/FdpMqttConsumer.java
  4. 8
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/FdpAlarmServiceImpl.java
  5. 3
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/AlarmQueryMapper.java
  6. 23
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java
  7. 3
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmQueryService.java
  8. 9
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmQueryServiceImpl.java
  9. 50
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ShowServiceImpl.java
  10. 7
      hzims-service/hzims-scheduled/src/main/resources/mapper/alarm/AlarmQueryMapper.xml
  11. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessLibraryController.java
  12. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessLibraryService.java
  13. 24
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessLibraryServiceImpl.java
  14. BIN
      hzims-service/operational/src/main/resources/template/excel/access_import_template.xlsx

2
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmConstants.java

@ -64,4 +64,6 @@ public interface AlarmConstants {
List<String> HZ3000_TYPES = Arrays.asList("0","1","2","3","4","5","6","7","8","9","10","11","12");
String SMS_MESSAGE_TEMPLATE_CODE = "aliyun-alert-push";
String FDP_INVALID_STATUS = "0.0";
}

3
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java

@ -70,6 +70,9 @@ public interface MainConstants {
// 集中监控数据处理
String CENTRALIZED_MONITORING = "centralizedMonitoring";
// 清理历史告警数据
String CLEAR_HISTORY_ALARM = "clearHistoryAlarm";
// 开停机告警
String START_STOP_ALARM = "startStopAlarm";

8
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/FdpMqttConsumer.java

@ -2,11 +2,12 @@ package com.hnac.hzims.alarm.mqtt;
import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.alarm.config.entity.AlarmEntity;
import com.hnac.hzims.alarm.source.service.FdpAlarmService;
import com.hnac.hzims.alarm.monitor.service.AlarmSaveService;
import com.hnac.hzims.alarm.source.service.FdpAlarmService;
import com.hnac.hzinfo.subscribe.SubscribeCallBack;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -27,11 +28,14 @@ public class FdpMqttConsumer implements SubscribeCallBack {
private AlarmSaveService alarmSaveService;
@Override
public void onMessage(Map<String, Object> data) {
log.error("监听Fdp消息 : {}" ,data.toString());
String s = JSONObject.toJSONString(data);
//消费代码
List<AlarmEntity> alarmEntities = fdpAlarmService.receiveMessage(s);
if(CollectionUtil.isEmpty(alarmEntities)){
return;
}
log.error("监听Fdp有效消息 : {}" ,alarmEntities);
//统一数据处理
try {
alarmSaveService.save(alarmEntities);

8
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/FdpAlarmServiceImpl.java

@ -26,8 +26,7 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import static com.hnac.hzims.alarm.config.constants.AlarmConstants.EARLY;
import static com.hnac.hzims.alarm.config.constants.AlarmConstants.EARLY_WARNING;
import static com.hnac.hzims.alarm.config.constants.AlarmConstants.*;
/**
* 等级告警实现类
@ -73,6 +72,9 @@ public class FdpAlarmServiceImpl implements FdpAlarmService {
if (ObjectUtils.isEmpty(alarms)) {
return new ArrayList<>();
}
if(FDP_INVALID_STATUS.equals(alarms.getStatus())){
return new ArrayList();
}
AlarmEntity entity = getAlarmEntity(alarms);
return Collections.singletonList(entity);
}
@ -87,7 +89,7 @@ public class FdpAlarmServiceImpl implements FdpAlarmService {
entity.setAlarmType(EARLY);
entity.setDeviceCode(item.getDeviceId());
entity.setDeviceName(item.getDeviceName());
entity.setAlarmStatus(0);
entity.setAlarmStatus(Integer.valueOf(item.getStatus()));
entity.setAlarmValue(item.getInfo());
entity.setStationId(item.getStation());
entity.setDiagReason(item.getDiagReason());

3
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/AlarmQueryMapper.java

@ -2,11 +2,12 @@ package com.hnac.hzims.scheduled.mapper.alarm;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.alarm.config.entity.AlarmEntity;
import org.apache.ibatis.annotations.Param;
/**
* @author ysj
*/
public interface AlarmQueryMapper extends BaseMapper<AlarmEntity> {
void clear(@Param("alarmTime") String param);
}

23
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java

@ -13,8 +13,7 @@ import org.springframework.stereotype.Component;
import java.util.Date;
import static com.hnac.hzims.operational.main.constant.MainConstants.INTERRUPT_ALARM;
import static com.hnac.hzims.operational.main.constant.MainConstants.START_STOP_ALARM;
import static com.hnac.hzims.operational.main.constant.MainConstants.*;
/**
@ -31,6 +30,21 @@ public class AlarmScheduledTask {
@Autowired
private InterruptionAlarmService interruptionService;
/**
* 实时告警数据清除
* @return ReturnT<String>
*/
@XxlJob(CLEAR_HISTORY_ALARM)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> clearHistoryAlarm(String param) {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00");
}
alarmQueryService.clearHistoryAlarm(param);
return new ReturnT<>("SUCCESS");
}
/**
* 开停机告警
* @return ReturnT<String>
@ -45,6 +59,11 @@ public class AlarmScheduledTask {
return new ReturnT<>("SUCCESS");
}
/**
* 数据通讯中断
* @param param
* @return
*/
@XxlJob(INTERRUPT_ALARM)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> interruption(String param) {

3
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmQueryService.java

@ -12,8 +12,9 @@ public interface AlarmQueryService extends BaseService<AlarmEntity> {
void startStopAlarm(String param);
void clearHistoryAlarm(String param);
List<String> bells(List<String> codes);
List<String> aborts(List<String> codes);
}

9
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmQueryServiceImpl.java

@ -108,6 +108,15 @@ public class AlarmQueryServiceImpl extends BaseServiceImpl<AlarmQueryMapper, Ala
}
/**
* 清理历史告警数据
* @param param
*/
@Override
public void clearHistoryAlarm(String param) {
this.baseMapper.clear(param);
}
/**
* 保存站点设备开关机告警
* @param station
* @param real

50
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ShowServiceImpl.java

@ -24,7 +24,10 @@ import com.hnac.hzims.operational.report.vo.DutyDefectVO;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.scheduled.service.equipment.PlanService;
import com.hnac.hzims.scheduled.service.inspect.TaskService;
import com.hnac.hzims.scheduled.service.operation.business.*;
import com.hnac.hzims.scheduled.service.operation.business.AccessService;
import com.hnac.hzims.scheduled.service.operation.business.DutyService;
import com.hnac.hzims.scheduled.service.operation.business.MaintenanceService;
import com.hnac.hzims.scheduled.service.operation.business.PhenomenonService;
import com.hnac.hzims.scheduled.service.operation.fill.*;
import com.hnac.hzims.scheduled.service.operation.home.ShowService;
import com.hnac.hzims.scheduled.service.operation.plate.DataService;
@ -77,6 +80,7 @@ public class ShowServiceImpl implements ShowService {
private final OverService overService;
private final PlanService planService;
private final PowerService powerService;
private final WindService windService;
private final SolveService solveService;
private final OtherService otherService;
private final AccessService accessService;
@ -319,27 +323,35 @@ public class ShowServiceImpl implements ShowService {
if(CollectionUtil.isEmpty(stations)){
return target;
}
QueryWrapper<PowerEntity> queryWrapper = new QueryWrapper<PowerEntity>() {{
in("create_dept", stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()));
eq("type", HomePageConstant.WIND_POWER_TYPE);
likeRight("mon", DateUtil.format(new Date(),"yyyy"));
}};
List<PowerEntity> list = powerService.list(queryWrapper);
if(CollectionUtil.isEmpty(list)){
// 计划发电量
List<PlanGenerationEntity> plans = planService.planGeneration(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()),null, DateUtil.format(new Date(),"yyyy"));
// 填报信息
List<WindEntity> winds = windService.list(Wrappers.<WindEntity>lambdaQuery()
.in(WindEntity::getStationCode, stations.stream().map(StationEntity::getCode).collect(Collectors.toList()))
.likeRight(WindEntity::getFillDate, DateUtil.format(new Date(),"yyyy")));
if(CollectionUtil.isEmpty(winds)){
return target;
}
double plan = list.stream().mapToDouble(PowerEntity::getPlannedPowerMon).sum();
double pass = list.stream().mapToDouble(power -> Double.parseDouble(power.getDoubleQualifyRate())).sum();
double plan = plans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum();
double power = winds.stream().mapToDouble(WindEntity::getPower).sum();
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {});
// 装机容量
target.setTaget_one(list.stream().map(PowerEntity::getInstalledCapacity).collect(Collectors.toSet()).stream().mapToDouble(Double::valueOf).sum());
target.setTaget_one(devices.stream().filter(o->stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getCreateDept())).mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum());
// 发电量
target.setTaget_two(list.stream().mapToDouble(PowerEntity::getPowerMon).sum());
target.setTaget_two(power);
if(Math.abs(plan) > 0){
// 发电完成率
target.setTaget_three(BigDecimal.valueOf(target.getTaget_two() / plan * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
target.setTaget_three(BigDecimal.valueOf(power / plan * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
}
// 双票合格率
target.setTaget_four(BigDecimal.valueOf(pass / list.size()).setScale(2, RoundingMode.HALF_UP).doubleValue());
LocalDate firstDay = LocalDate.now().withDayOfYear(1);
LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN);
R<List<Dept>> result = sysClient.getDeptList();
List<Long> areas = result.getData().stream().filter(dept -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(dept.getId())).map(Dept::getParentId).collect(Collectors.toList());
DoublePassRateVO pass = ticketService.doublePassRate(areas, firstDateTime, LocalDateTime.now());
if (ObjectUtil.isNotEmpty(pass)) {
target.setTaget_four(Double.valueOf(pass.getDoublePassRate()));
}
return target;
}
@ -433,6 +445,12 @@ public class ShowServiceImpl implements ShowService {
TargetVo target = new TargetVo();
target.setType(HomePageConstant.DISTRIBUTION_NETWORK);
target.setTypeName(DictCache.getValue("stationType", HomePageConstant.DISTRIBUTION_NETWORK));
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE)
.eq(StationEntity::getType,HomePageConstant.DISTRIBUTION_NETWORK));
if(CollectionUtil.isEmpty(stations)){
return target;
}
// 线程池
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("network-taget-pool-%d").build();
ScheduledExecutorService exe = new ScheduledThreadPoolExecutor(3, namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
@ -446,6 +464,7 @@ public class ShowServiceImpl implements ShowService {
List<OverEntity> overs = overService.list(new QueryWrapper<OverEntity>() {{
ge("create_time", firstDateTime);
le("create_time", LocalDateTime.now());
in("create_dept",stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()));
}});
if(CollectionUtil.isEmpty(overs)){
countDownLatch.countDown();
@ -468,6 +487,7 @@ public class ShowServiceImpl implements ShowService {
List<SolveEntity> solves = solveService.list(new QueryWrapper<SolveEntity>() {{
ge("create_time", firstDateTime);
le("create_time", LocalDateTime.now());
in("create_dept",stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()));
}});
if(CollectionUtil.isEmpty(solves)){
countDownLatch.countDown();
@ -481,6 +501,7 @@ public class ShowServiceImpl implements ShowService {
List<OtherEntity> others = otherService.list(new QueryWrapper<OtherEntity>() {{
ge("create_time", firstDateTime);
le("create_time", LocalDateTime.now());
in("create_dept",stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()));
}});
if(CollectionUtil.isEmpty(others)){
countDownLatch.countDown();
@ -648,6 +669,7 @@ public class ShowServiceImpl implements ShowService {
return null;
}
list = R.getData();
}
// 根据参数查询有效站点
List<StationEntity> stationList = this.stationByParams(list,deptId,typeList,serveType);

7
hzims-service/hzims-scheduled/src/main/resources/mapper/alarm/AlarmQueryMapper.xml

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.alarm.show.mapper.AlarmMapper">
<mapper namespace="com.hnac.hzims.scheduled.mapper.alarm.AlarmQueryMapper">
<delete id="clear">
delete from hzims_alarm
where alarm_time &lt; #{alarmTime}
</delete>
</mapper>

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessLibraryController.java

@ -114,7 +114,7 @@ public class OperAccessLibraryController extends BladeController {
@ApiOperationSupport(order = 7)
@PostMapping(value = "/import")
@Operate(label = "检修库导入",type = com.hnac.hzinfo.log.contants.BusinessType.IMPORT,risk = Risk.LOW,ignore = false)
public void libraryImport(@RequestParam MultipartFile file) {
service.libraryImport(file);
public R libraryImport(@RequestParam MultipartFile file) {
return R.data(service.libraryImport(file));
}
}

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessLibraryService.java

@ -30,5 +30,5 @@ public interface IOperAccessLibraryService extends BaseService<OperAccessLibrary
void downLoad();
void libraryImport(MultipartFile file);
String libraryImport(MultipartFile file);
}

24
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessLibraryServiceImpl.java

@ -32,6 +32,7 @@ import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.system.cache.DictCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
@ -149,7 +150,7 @@ public class OperAccessLibraryServiceImpl extends BaseServiceImpl<OperAccessLibr
* @param file
*/
@Override
public void libraryImport(MultipartFile file){
public String libraryImport(MultipartFile file){
// 文件名检查
String fileName = file.getOriginalFilename();
if(!fileName.endsWith(PdfUtils.XLS_SUFFIX) && !fileName.endsWith(PdfUtils.XLSX_SUFFIX)){
@ -169,6 +170,7 @@ public class OperAccessLibraryServiceImpl extends BaseServiceImpl<OperAccessLibr
throw new ServiceException("请填写导入检修库数据!");
}
List<OperAccessLibraryDetailEntity> details = new ArrayList<>();
StringBuilder failBuilder = new StringBuilder();
Long libraryId = null;
for (int i = 2; i <= rows + 1; i++) {
// 读取左上端单元格
@ -178,19 +180,27 @@ public class OperAccessLibraryServiceImpl extends BaseServiceImpl<OperAccessLibr
continue;
}
if( (i - 1) % 4 == 1){
if(StringUtils.isEmpty(row.getCell(1).getStringCellValue())){
if(StringUtils.isEmpty(row.getCell(1).getStringCellValue())
|| StringUtils.isEmpty(row.getCell(2).getStringCellValue())
|| ObjectUtil.isEmpty(row.getCell(3).getDateCellValue())){
failBuilder.append((int)row.getCell(0).getNumericCellValue()).append(",");
continue;
}
OperAccessLibraryEntity library = new OperAccessLibraryEntity();
library.setEmName(row.getCell(1).getStringCellValue());
library.setGradeCode(DictCache.getValue("gradeCode",row.getCell(2).getStringCellValue()));
library.setLastServiceTime(row.getCell(3).getDateCellValue());
library.setPeriod((int)row.getCell(4).getNumericCellValue());
library.setStopHours((int)row.getCell(5).getNumericCellValue());
if(!ObjectUtil.isEmpty(row.getCell(4).getNumericCellValue())){
library.setPeriod((int)row.getCell(4).getNumericCellValue());
}
if(!ObjectUtil.isEmpty(row.getCell(5).getNumericCellValue())){
library.setPeriod((int)row.getCell(5).getNumericCellValue());
}
this.save(library);
libraryId = library.getId();
}
if(StringUtils.isNotEmpty(row.getCell(6).getStringCellValue())){
if(StringUtils.isNotEmpty(row.getCell(6).getStringCellValue())
&& StringUtils.isNotEmpty(row.getCell(7).getStringCellValue())){
OperAccessLibraryDetailEntity detail = new OperAccessLibraryDetailEntity();
detail.setName(row.getCell(6).getStringCellValue());
detail.setContent(row.getCell(7).getStringCellValue());
@ -199,6 +209,10 @@ public class OperAccessLibraryServiceImpl extends BaseServiceImpl<OperAccessLibr
}
}
this.libraryDetailService.saveBatch(details);
if(failBuilder.length() > 0){
return "导入完成,序号:" + failBuilder.substring(0,failBuilder.toString().length()-1) + "数据未填写或者必传项未填写,未导入成功!";
}
return "导入完成";
}
/**

BIN
hzims-service/operational/src/main/resources/template/excel/access_import_template.xlsx

Binary file not shown.
Loading…
Cancel
Save