From d02e56502c1e40dcb08dde8b1588ac3b17c6c16f Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 26 Mar 2024 19:30:07 +0800 Subject: [PATCH] =?UTF-8?q?#FDP=E5=91=8A=E8=AD=A6=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E6=97=A0=E6=95=88=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alarm/config/constants/AlarmConstants.java | 2 + .../operational/main/constant/MainConstants.java | 3 ++ .../com/hnac/hzims/alarm/mqtt/FdpMqttConsumer.java | 8 +++- .../source/service/impl/FdpAlarmServiceImpl.java | 8 ++-- .../scheduled/mapper/alarm/AlarmQueryMapper.java | 3 +- .../scheduled/scheduled/AlarmScheduledTask.java | 23 +++++++++- .../scheduled/service/alarm/AlarmQueryService.java | 3 +- .../service/alarm/impl/AlarmQueryServiceImpl.java | 9 ++++ .../operation/home/impl/ShowServiceImpl.java | 50 +++++++++++++++------ .../resources/mapper/alarm/AlarmQueryMapper.xml | 7 ++- .../controller/OperAccessLibraryController.java | 4 +- .../access/service/IOperAccessLibraryService.java | 2 +- .../service/impl/OperAccessLibraryServiceImpl.java | 24 +++++++--- .../template/excel/access_import_template.xlsx | Bin 22528 -> 22528 bytes 14 files changed, 114 insertions(+), 32 deletions(-) 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 0a05c3f..1177139 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 @@ -64,4 +64,6 @@ public interface AlarmConstants { List 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"; } 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 7c079bf..a080158 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 @@ -70,6 +70,9 @@ public interface MainConstants { // 集中监控数据处理 String CENTRALIZED_MONITORING = "centralizedMonitoring"; + // 清理历史告警数据 + String CLEAR_HISTORY_ALARM = "clearHistoryAlarm"; + // 开停机告警 String START_STOP_ALARM = "startStopAlarm"; 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 ca67dc9..e1513dd 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 @@ -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 data) { - log.error("监听Fdp消息 : {}" ,data.toString()); String s = JSONObject.toJSONString(data); //消费代码 List alarmEntities = fdpAlarmService.receiveMessage(s); + if(CollectionUtil.isEmpty(alarmEntities)){ + return; + } + log.error("监听Fdp有效消息 : {}" ,alarmEntities); //统一数据处理 try { alarmSaveService.save(alarmEntities); 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 930e4fa..b16c48e 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 @@ -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()); diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/AlarmQueryMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/AlarmQueryMapper.java index ea13388..feba1f3 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/AlarmQueryMapper.java +++ b/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 { - + void clear(@Param("alarmTime") String param); } \ 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 af12a59..b3e21d2 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 @@ -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 + */ + @XxlJob(CLEAR_HISTORY_ALARM) + //@Scheduled(cron = "0/40 * * * * ? ") + public ReturnT 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 @@ -45,6 +59,11 @@ public class AlarmScheduledTask { return new ReturnT<>("SUCCESS"); } + /** + * 数据通讯中断 + * @param param + * @return + */ @XxlJob(INTERRUPT_ALARM) //@Scheduled(cron = "0/40 * * * * ? ") public ReturnT interruption(String param) { 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 a8ea132..cfd3520 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 @@ -12,8 +12,9 @@ public interface AlarmQueryService extends BaseService { void startStopAlarm(String param); + void clearHistoryAlarm(String param); + List bells(List codes); List aborts(List codes); - } \ 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 a11c587..f38975f 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 @@ -108,6 +108,15 @@ public class AlarmQueryServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper() {{ - 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 list = powerService.list(queryWrapper); - if(CollectionUtil.isEmpty(list)){ + // 计划发电量 + List plans = planService.planGeneration(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()),null, DateUtil.format(new Date(),"yyyy")); + // 填报信息 + List winds = windService.list(Wrappers.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 devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), new TypeReference>() {}); // 装机容量 - 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> result = sysClient.getDeptList(); + List 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 stations = stationService.list(Wrappers.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 overs = overService.list(new QueryWrapper() {{ 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 solves = solveService.list(new QueryWrapper() {{ 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 others = otherService.list(new QueryWrapper() {{ 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 stationList = this.stationByParams(list,deptId,typeList,serveType); diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/alarm/AlarmQueryMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/alarm/AlarmQueryMapper.xml index 3fd4b39..0433bed 100644 --- a/hzims-service/hzims-scheduled/src/main/resources/mapper/alarm/AlarmQueryMapper.xml +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/alarm/AlarmQueryMapper.xml @@ -1,5 +1,10 @@ - + + + + delete from hzims_alarm + where alarm_time < #{alarmTime} + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessLibraryController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessLibraryController.java index c0f6e98..092ee87 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessLibraryController.java +++ b/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)); } } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessLibraryService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessLibraryService.java index 9d83439..8d94f2c 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessLibraryService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessLibraryService.java @@ -30,5 +30,5 @@ public interface IOperAccessLibraryService extends BaseService 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 0){ + return "导入完成,序号:" + failBuilder.substring(0,failBuilder.toString().length()-1) + "数据未填写或者必传项未填写,未导入成功!"; + } + return "导入完成"; } /** 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 c8a46a2327b2ebe20a303de1fb5f0c2914274351..0bb642a05911ef011bd030bff694950aa46eb3de 100644 GIT binary patch delta 124 zcmZqJz}T>XaYGIZTf*eM%yIRTi&)wiYc~I6xo*R_b@D|=SH|wi;!b5^EDVeXGT!-D z&UjY_Wwr+HjGnyN$%=9B=66m`?A)9T91IK$j0~I%oSUt^jxtX+U=i5lC&|is#t&%j XX1U;H%&aC1h79JLFNWze0%bV>0_G^y delta 136 zcmZqJz}T>XaYGIZo5E?!t+#V07qPT4_H6#ia@~gU=;Vuzu8gxMi#wI6aWF6*$av>p zIpbZK2E)<#>