From 196eb317e56e2307a638a5f8cf6268933e4653e2 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Wed, 15 May 2024 08:07:35 +0800 Subject: [PATCH] =?UTF-8?q?#=E5=8F=91=E7=94=B5=E9=87=8F=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E6=9C=80=E5=90=8E=E5=80=BC=E5=87=8F=E6=9C=80=E5=88=9D=E5=80=BC?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/alarm/config/entity/AlarmEntity.java | 5 ++ .../source/service/impl/VideoAlarmServiceImpl.java | 10 ++-- .../scheduled/scheduled/AlarmScheduledTask.java | 1 + .../operation/monitor/impl/MonitorServiceImpl.java | 5 +- .../service/operation/plate/DataService.java | 2 + .../operation/plate/impl/DataServiceImpl.java | 53 +++++++++++++++++++++- 6 files changed, 66 insertions(+), 10 deletions(-) diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmEntity.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmEntity.java index a938a80..ebb82d2 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmEntity.java +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmEntity.java @@ -1,11 +1,14 @@ package com.hnac.hzims.alarm.config.entity; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.springblade.core.tenant.mp.TenantEntity; +import org.springblade.core.tool.utils.DateUtil; +import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; import java.util.Date; @@ -68,6 +71,8 @@ public class AlarmEntity extends TenantEntity { private Integer alarmCount; @ApiModelProperty(value = "告警时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.sss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.sss") private Date alarmTime; @ApiModelProperty(value = "监测点") diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/VideoAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/VideoAlarmServiceImpl.java index 16a7a37..0ddbaa9 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/VideoAlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/VideoAlarmServiceImpl.java @@ -68,7 +68,7 @@ public class VideoAlarmServiceImpl implements VideoAlarmService { return records; } return records; - }).filter(s -> CollectionUtil.isNotEmpty(s)).collect(Collectors.toList()); + }).filter(CollectionUtil::isNotEmpty).collect(Collectors.toList()); List res =new ArrayList<>(); if (CollectionUtil.isNotEmpty(collect)) { res= collect.stream().flatMap(List::stream).collect(Collectors.toList()); @@ -76,7 +76,7 @@ public class VideoAlarmServiceImpl implements VideoAlarmService { // 转换平台视频预警信息 List alarmEntities =new ArrayList<>(); if (CollectionUtil.isNotEmpty(res)) { - alarmEntities= res.stream().filter(s->ObjectUtils.isNotEmpty(s)).map(s -> getAlarmEntity(s)).collect(Collectors.toList()); + alarmEntities= res.stream().filter(ObjectUtils::isNotEmpty).map(this::getAlarmEntity).collect(Collectors.toList()); } return alarmEntities; } @@ -93,11 +93,7 @@ public class VideoAlarmServiceImpl implements VideoAlarmService { if (CollectionUtil.isEmpty(alarms)) { return new ArrayList<>(); } - List res = alarms.stream().map(s -> { - AlarmEntity entity = getAlarmEntity(s); - return entity; - }).collect(Collectors.toList()); - return res; + return alarms.stream().map(this::getAlarmEntity).collect(Collectors.toList()); } private AlarmEntity getAlarmEntity(DeviceSoeVO item) { 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 f84fcb2..8d89a72 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 @@ -69,4 +69,5 @@ public class AlarmScheduledTask { alarmService.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/operation/monitor/impl/MonitorServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java index 029080c..13b41ce 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java @@ -385,15 +385,16 @@ public class MonitorServiceImpl implements MonitorService { for (RealDeviceVo item : devices) { List attributes = item.getAttbtList(); if (CollectionUtil.isEmpty(attributes)) { - return; + continue; } List powerList = attributes.stream().filter(o -> StringUtil.isNoneBlank(o.getValue()) && !"-".equals(o.getValue()) && HomePageConstant.powerList.contains(o.getName())).collect(Collectors.toList()); if (CollectionUtil.isEmpty(powerList)) { - return; + continue; } // 获取设备中属性为P/p的value值总和 powerSum += BigDecimal.valueOf(powerList.stream().mapToDouble(m -> Double.parseDouble(m.getValue())).sum()).setScale(2, RoundingMode.HALF_UP).doubleValue(); } + realStation.setPowerSum(powerSum); } /** diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/DataService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/DataService.java index b397b5d..d08cab2 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/DataService.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/DataService.java @@ -29,5 +29,7 @@ public interface DataService { List> lastFirstBySignage(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signages); + Float lastFirstByFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, Double ride ,String signages); + Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, Double ride ,String signages); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/impl/DataServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/impl/DataServiceImpl.java index ffd6086..4d3fede 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/impl/DataServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/impl/DataServiceImpl.java @@ -168,7 +168,7 @@ public class DataServiceImpl implements DataService { @Override public List> lastFirstBySignage(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signage) { ReductionDataDTO reduction = new ReductionDataDTO(); - reduction.setFull(1); + reduction.setFull(0); reduction.setDeviceCode(deviceCode); reduction.setSaveTimeType(cycleType); reduction.setTimeInterval(1); @@ -201,6 +201,57 @@ public class DataServiceImpl implements DataService { * @param cycleType 间隔周期 : 0-> 秒 1-> 分 2-> 小时 3->天 4-> 周 5-> 月 6-> 年 * @param deviceCode 设备编号 * @param ride 配电比 + * @param signage 指标 + * @return + */ + @Override + public Float lastFirstByFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode,Double ride,String signage) { + ReductionDataDTO reduction = new ReductionDataDTO(); + reduction.setFull(0); + reduction.setDeviceCode(deviceCode); + reduction.setSaveTimeType(cycleType); + reduction.setTimeInterval(1); + reduction.setNeedPage(false); + reduction.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + reduction.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + // 属性列表 + List atts = new ArrayList<>(); + ReductionAttrDataDTO attr = new ReductionAttrDataDTO(); + attr.setAccessRules(accessRules); + attr.setKeepFigures(4); + attr.setSignage(signage); + atts.add(attr); + reduction.setDtos(atts); + Result result = deviceDataClient.pageDeviceCodeAndSignages(reduction); + if (!result.isSuccess() || ObjectUtil.isEmpty(result.getData())) { + return 0f; + } + if(MapUtils.isEmpty(result.getData().getFieldMap()) || CollectionUtil.isEmpty(result.getData().getDataList())){ + return 0f; + } + List> dataList = result.getData().getDataList(); + if (CollectionUtil.isEmpty(dataList)) { + return 0f; + } + Map data = dataList.get(0); + if(MapUtils.isEmpty(data)){ + return 0f; + } + String val = data.get(signage); + if(StringUtil.isEmpty(val)){ + return 0f; + } + return Float.parseFloat(String.valueOf(Double.parseDouble(val) * ride)); + } + + /*** + * 指标数据列表查询 + * @param startTime 开始时间 + * @param endTime 结束时间 + * @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值 + * @param cycleType 间隔周期 : 0-> 秒 1-> 分 2-> 小时 3->天 4-> 周 5-> 月 6-> 年 + * @param deviceCode 设备编号 + * @param ride 配电比 * @param signages 指标 * @return */