From cf003e1db03d869ac0289fcddfc75fb94d700256 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 22 Apr 2024 15:27:47 +0800 Subject: [PATCH] =?UTF-8?q?#=E5=BC=80=E5=85=B3=E6=9C=BA=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/operational/main/vo/ActivePowerVo.java | 3 ++ .../mapper/alarm/AlarmDefaulConfigMapper.java | 11 +++++ .../service/alarm/AlarmDefaulConfigService.java | 11 +++++ .../alarm/impl/AlarmDefaulConfigServiceImpl.java | 21 +++++++++ .../service/alarm/impl/AlarmServiceImpl.java | 55 +++++++++++++++------- .../operation/home/impl/RealTargetServiceImpl.java | 11 +++-- .../mapper/alarm/AlarmDefaulConfigMapper.xml | 5 ++ 7 files changed, 98 insertions(+), 19 deletions(-) create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/AlarmDefaulConfigMapper.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmDefaulConfigService.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmDefaulConfigServiceImpl.java create mode 100644 hzims-service/hzims-scheduled/src/main/resources/mapper/alarm/AlarmDefaulConfigMapper.xml diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/ActivePowerVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/ActivePowerVo.java index 9de2b1b..e1c16f7 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/ActivePowerVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/ActivePowerVo.java @@ -12,6 +12,9 @@ import lombok.Data; @ApiModel(value = "当日机组有功功率") public class ActivePowerVo { + @ApiModelProperty(value = "字符串时间") + private String strHour; + @ApiModelProperty(value = "小时") private Integer hour; diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/AlarmDefaulConfigMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/AlarmDefaulConfigMapper.java new file mode 100644 index 0000000..0c72ee8 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/AlarmDefaulConfigMapper.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.scheduled.mapper.alarm; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.alarm.config.entity.AlarmDefaultConfigEntity; + +/** + * @author ysj + */ +public interface AlarmDefaulConfigMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmDefaulConfigService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmDefaulConfigService.java new file mode 100644 index 0000000..6ad4b2a --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmDefaulConfigService.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.scheduled.service.alarm; + +import com.hnac.hzims.alarm.config.entity.AlarmDefaultConfigEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * @author ysj + */ +public interface AlarmDefaulConfigService extends BaseService { + +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmDefaulConfigServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmDefaulConfigServiceImpl.java new file mode 100644 index 0000000..2cd8f08 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmDefaulConfigServiceImpl.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.scheduled.service.alarm.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.hnac.hzims.alarm.config.entity.AlarmDefaultConfigEntity; +import com.hnac.hzims.scheduled.mapper.alarm.AlarmDefaulConfigMapper; +import com.hnac.hzims.scheduled.service.alarm.AlarmDefaulConfigService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @author ysj + */ +@AllArgsConstructor +@Service +@Slf4j +@DS("alarm") +public class AlarmDefaulConfigServiceImpl extends BaseServiceImpl implements AlarmDefaulConfigService { + +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java index 616374e..dba937a 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java @@ -3,12 +3,14 @@ package com.hnac.hzims.scheduled.service.alarm.impl; 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.AlarmDefaultConfigEntity; 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.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.vo.HydropowerUnitRealVo; import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.scheduled.service.alarm.AlarmDefaulConfigService; import com.hnac.hzims.scheduled.service.alarm.AlarmQueryService; import com.hnac.hzims.scheduled.service.alarm.AlarmService; import com.hnac.hzims.scheduled.service.operation.station.StationService; @@ -42,6 +44,8 @@ public class AlarmServiceImpl implements AlarmService { private final AlarmQueryService alarmQueryService; + private final AlarmDefaulConfigService defaulConfigService; + private final InterruptionAlarmServiceImpl interruptionAlarmService; private final ISoeClient soeClient; @@ -68,13 +72,20 @@ public class AlarmServiceImpl implements AlarmService { if(CollectionUtil.isEmpty(stations)){ return; } - + // 查询开关机默认告警配置 + AlarmDefaultConfigEntity start = defaulConfigService.getOne(Wrappers.lambdaQuery() + .eq(AlarmDefaultConfigEntity::getSource,5) + .eq(AlarmDefaultConfigEntity::getAlarmChiledType,50) + ); + AlarmDefaultConfigEntity stop = defaulConfigService.getOne(Wrappers.lambdaQuery() + .eq(AlarmDefaultConfigEntity::getSource,5) + .eq(AlarmDefaultConfigEntity::getAlarmChiledType,51) + ); // 获取站点设备实时数据 List reals = (List) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); if(CollectionUtil.isEmpty(reals)){ return; } - Map refresh = new HashMap<>(); // 实时设备遍历 reals.forEach(real->{ @@ -96,24 +107,25 @@ public class AlarmServiceImpl implements AlarmService { return; } // 比对开机状态 - if(Math.abs(real.getActivePower()) > 0){ + if(real.getActivePower() > 0){ if(startStopMap.get(real.getDeviceCode()) == 0){ refresh.put(real.getDeviceCode(),1); // 记录开机告警 - this.saveStartStopAlarm(station,real,1); + this.saveStartStopAlarm(station,real,start,1); }else{ - refresh.put(real.getDeviceCode(),0); + refresh.put(real.getDeviceCode(),1); } }else{ if(startStopMap.get(real.getDeviceCode()) == 1){ refresh.put(real.getDeviceCode(),0); // 记录关机告警 - this.saveStartStopAlarm(station,real,0); + this.saveStartStopAlarm(station,real,stop,0); }else{ - refresh.put(real.getDeviceCode(),1); + refresh.put(real.getDeviceCode(),0); } } }); + log.error("start_stop_alarm : {}",refresh); redisTemplate.opsForValue().set(start_stop_cache_final,refresh); } @@ -132,7 +144,7 @@ public class AlarmServiceImpl implements AlarmService { * @param real * @param state */ - private void saveStartStopAlarm(StationEntity station, HydropowerUnitRealVo real, int state) { + private void saveStartStopAlarm(StationEntity station, HydropowerUnitRealVo real,AlarmDefaultConfigEntity defaultConfig, int state) { AlarmEntity alarm = new AlarmEntity(); alarm.setStationId(station.getCode()); alarm.setStationName(station.getName()); @@ -148,14 +160,25 @@ public class AlarmServiceImpl implements AlarmService { } alarm.setStatus(0); alarm.setAlarmTime(new Date()); - alarm.setIsRightTabulation(0); - alarm.setIsShowAlert(1); - alarm.setIsSmallBell(1); - alarm.setIsMask(1); - alarm.setIsBroadcast(1); - alarm.setIsPlatformMessage(1); - alarm.setIsShortMessage(1); - alarm.setIsWxMessage(1); + if(ObjectUtil.isEmpty(defaultConfig)){ + alarm.setIsRightTabulation(0); + alarm.setIsShowAlert(1); + alarm.setIsSmallBell(1); + alarm.setIsMask(1); + alarm.setIsBroadcast(1); + alarm.setIsPlatformMessage(1); + alarm.setIsShortMessage(1); + alarm.setIsWxMessage(1); + }else{ + alarm.setIsRightTabulation(defaultConfig.getIsRightTabulation()); + alarm.setIsShowAlert(defaultConfig.getIsShowAlert()); + alarm.setIsSmallBell(defaultConfig.getIsSmallBell()); + alarm.setIsMask(defaultConfig.getIsMask()); + alarm.setIsBroadcast(defaultConfig.getIsBroadcast()); + alarm.setIsPlatformMessage(defaultConfig.getIsPlatformMessage()); + alarm.setIsShortMessage(defaultConfig.getIsShortMessage()); + alarm.setIsWxMessage(defaultConfig.getIsWxMessage()); + } alarm.setTenantId(station.getTenantId()); alarm.setCreateDept(station.getRefDept()); alarm.setCreateUser(station.getCreateUser()); diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java index 26b56ec..d6e87bc 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java @@ -1379,8 +1379,12 @@ public class RealTargetServiceImpl implements RealTargetService { * @return */ private List getLoadsByDay(EminfoAndEmParamVo device) { - String start = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00"; - String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); + // 结束日期 + Calendar calendar = Calendar.getInstance(); + String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); + // 开始日期 + calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - 24); + String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; List records = dataService.periodTargetData(start, end, 3, 2, device.getEmCode(), HomePageConstant.PV_LOAD); if (CollectionUtil.isEmpty(records)) { return new ArrayList<>(); @@ -1388,10 +1392,11 @@ public class RealTargetServiceImpl implements RealTargetService { return records.stream().map(record -> { ActivePowerVo load = new ActivePowerVo(); Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + load.setStrHour(DateUtil.format(time,"yyyy-MM-dd HH")); load.setHour(time.getHours()); load.setActivePower(Optional.ofNullable(record.getVal()).orElse("0")); return load; - }).sorted(Comparator.comparing(ActivePowerVo::getHour)).collect(Collectors.toList()); + }).sorted(Comparator.comparing(ActivePowerVo::getStrHour)).sorted(Comparator.comparing(ActivePowerVo::getHour)).collect(Collectors.toList()); } /** diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/alarm/AlarmDefaulConfigMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/alarm/AlarmDefaulConfigMapper.xml new file mode 100644 index 0000000..b8876c6 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/alarm/AlarmDefaulConfigMapper.xml @@ -0,0 +1,5 @@ + + + + +