diff --git a/hzims-service-api/hzims-ecological-api/pom.xml b/hzims-service-api/hzims-ecological-api/pom.xml new file mode 100644 index 0000000..71cf5e4 --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/pom.xml @@ -0,0 +1,31 @@ + + + 4.0.0 + + com.hnac.hzims + hzims-service-api + 4.0.0-SNAPSHOT + + + hzims-ecological-api + + + 8 + 8 + UTF-8 + + + + + + com.alibaba + easyexcel + 3.0.5 + + + + + + \ No newline at end of file diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/entity/Demo.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/entity/Demo.java new file mode 100644 index 0000000..f6aa071 --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/entity/Demo.java @@ -0,0 +1,10 @@ +package com.hnac.hzims.suichang.entity; + +/** + * @Author: liangfan + * @Date: 2024-03-08 15:06 + * @Description: + */ + +public class Demo { +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/feign/ISuichangClient.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/feign/ISuichangClient.java new file mode 100644 index 0000000..fd61e11 --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/feign/ISuichangClient.java @@ -0,0 +1,29 @@ +package com.hnac.hzims.suichang.feign; + +import com.hnac.hzims.suichang.vo.StationQueryReq; +import com.hnac.hzims.suichang.vo.StationVo; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Map; + +@FeignClient( + value = "suichang" +) +public interface ISuichangClient { + String API_PREFIX = "/suichangClient"; + + String GET_STATION_BY_REQ = API_PREFIX + "/getStationListByReq"; + + String GET_DATA = API_PREFIX + "/getData"; + + @GetMapping(GET_STATION_BY_REQ) + List getStationListByReq(StationQueryReq req); + + @GetMapping(GET_DATA) + List> getData(String stcd, Integer accessRules, Integer saveTimeType, Integer timeInterval, + LocalDateTime startTime, LocalDateTime endTime); + +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/util/DateUtil.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/util/DateUtil.java new file mode 100644 index 0000000..b09590e --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/util/DateUtil.java @@ -0,0 +1,138 @@ +package com.hnac.hzims.suichang.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.Month; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +public class DateUtil { + public static Map getStartEnd(String yearMonth) { + Map data = new HashMap<>(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try { + Date begin = sdf.parse(yearMonth + "-01 00:00:00"); + // 最大天数 + Date endSt = sdf.parse(yearMonth + "-" + getMaxDayByYearMonth(begin) + " 23:59:59"); + data.put("start", begin); + data.put("end", endSt); + } catch (ParseException e) { + e.printStackTrace(); + } + return data; + } + + public static int getMaxDayByYearMonth(Date start) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(start); + return calendar.getActualMaximum(Calendar.DAY_OF_MONTH); + } + + public static LocalDateTime getStartOfLastQuarter(LocalDateTime dateTime) { + int currentMonth = dateTime.getMonthValue(); + int currentYear = dateTime.getYear(); + + // 计算上个季度的开始月份 + int startMonthOfLastQuarter = (currentMonth - 1) / 3 * 3 + 1; + if (startMonthOfLastQuarter > currentMonth) { + // 如果当前月份在上个季度之后,则回到上一年的相应季度 + startMonthOfLastQuarter -= 3; + currentYear--; + } + + // 获取上个季度的开始时间(该季度的第一个月的第一天午夜) + return LocalDateTime.of(currentYear, startMonthOfLastQuarter, 1, 0, 0); + } + + public static LocalDateTime getEndOfLastQuarter(LocalDateTime dateTime) { + LocalDateTime startOfLastQuarter = getStartOfLastQuarter(dateTime); + + // 获取上个季度的结束时间(该季度的最后一个月的最后一天午夜) + int endMonthOfLastQuarter = startOfLastQuarter.getMonthValue() + 2; + int endYearOfLastQuarter = startOfLastQuarter.getYear(); + if (endMonthOfLastQuarter > 12) { + // 如果结束月份超过12,则回到下一年的相应月份 + endMonthOfLastQuarter -= 12; + endYearOfLastQuarter++; + } + + return LocalDateTime.of(endYearOfLastQuarter, endMonthOfLastQuarter, 1, 0, 0); + } + + public static LocalDateTime getStartOfHalfYear(LocalDateTime dateTime) { + int month = dateTime.getMonthValue(); + int year = dateTime.getYear(); + if (month <= 6) { + // 如果是上半年,则获取去年下半年的开始时间(7月1日) + year--; + return LocalDateTime.of(year, Month.JULY, 1, 0, 0); + } else { + return LocalDateTime.of(year, Month.JANUARY, 1, 0, 0); + } + } + + + public static LocalDateTime getEndOfHalfYear(LocalDateTime dateTime) { + int month = dateTime.getMonthValue(); + int year = dateTime.getYear(); + if (month <= 6) { + // 如果是上半年,则获取去年下半年的结束时间(1月1日) + return LocalDateTime.of(year, Month.JANUARY, 1, 0, 0, 0); + } else { + return LocalDateTime.of(year, Month.JULY, 1, 0, 0, 0); + } + + } + + public static long getHoursPassedToday() { + // 获取当前时间 + LocalTime currentTime = LocalTime.now(); + // 获取今天的开始时间(午夜0点) + LocalTime midnight = LocalTime.MIDNIGHT; + // 计算时间差,单位为小时 + return ChronoUnit.HOURS.between(midnight, currentTime); + } + + public static LocalDateTime getEndTime(String time) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + java.time.LocalDate timeDate = java.time.LocalDate.parse(time, formatter); + LocalDateTime resultTime = LocalDateTime.of(timeDate, LocalTime.MIDNIGHT); + // 比较两个时间的大小 + LocalDateTime now = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0).withNano(0); + if (now.compareTo(resultTime) > 0) { + resultTime = LocalDateTime.of(timeDate, LocalTime.MAX); + } else { + resultTime = LocalDateTime.now().withMinute(0).withSecond(0).withNano(0); + } + return resultTime; + } + + public static LocalDateTime getEndTimeByDay(String time) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + java.time.LocalDate timeDate = java.time.LocalDate.parse(time, formatter); + return LocalDateTime.of(timeDate, LocalTime.MIDNIGHT).plusDays(1); + } + + public static LocalDateTime getStartTime(String time) { + // 创建一个 DateTimeFormatter 对象来解析日期字符串 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + java.time.LocalDate startDate = java.time.LocalDate.parse(time, formatter); + // 结合 LocalDate 和 LocalTime 创建 LocalDateTime 对象 + LocalDateTime startTime = LocalDateTime.of(startDate, LocalTime.MIDNIGHT); + return startTime; + } + + public static String getStringTime(LocalDateTime time) { + // 创建一个 DateTimeFormatter 对象,用于定义你想要的格式 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + // 使用 formatter 将 LocalDateTime 转换为 String + return time.format(formatter); + } +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/util/MemoryPagination.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/util/MemoryPagination.java new file mode 100644 index 0000000..82d5ee4 --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/util/MemoryPagination.java @@ -0,0 +1,39 @@ +package com.hnac.hzims.suichang.util; + +import org.springframework.util.CollectionUtils; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author tanghaihao + * @date 2023年07月12日 17:15 + */ +public class MemoryPagination { + /** + * 内存分页 + * + * @param records 待分页的数据 + * @param pageNum 当前页码 + * @param pageSize 每页显示的条数 + * @return 分页之后的数据 + */ + public static List pagination(List records, int pageNum, int pageSize) { + if (CollectionUtils.isEmpty(records)) { + return Collections.emptyList(); + } + int totalCount = records.size() ; + int remainder = totalCount % pageSize; + int pageCount = (remainder > 0) ? totalCount / pageSize + 1 : totalCount / pageSize; + if (remainder == 0) { + return records.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); + } else { + if (pageNum == pageCount) { + return records.stream().skip((pageNum - 1) * pageSize).limit(totalCount).collect(Collectors.toList()); + } else { + return records.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); + } + } + } +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/AvgMonitorCountVo.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/AvgMonitorCountVo.java new file mode 100644 index 0000000..d21ef16 --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/AvgMonitorCountVo.java @@ -0,0 +1,43 @@ +package com.hnac.hzims.suichang.vo; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/8/31 9:37 + */ +@Data +public class AvgMonitorCountVo { + + /** + * 电站名称 + */ + private String name; + /** + * 核定下限流量 + */ + private BigDecimal flowValue; + /** + * 考核天数 + */ + private Long count; + /** + * 合格天数 + */ + private Integer passCount; + /** + * 合格率 + */ + private String passPre; + + + private List infos; + + + +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/AvgMonitorReq.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/AvgMonitorReq.java new file mode 100644 index 0000000..2f08a77 --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/AvgMonitorReq.java @@ -0,0 +1,29 @@ +package com.hnac.hzims.suichang.vo; + +import lombok.Data; +import org.springblade.core.mp.support.Query; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/8/31 9:37 + */ +@Data +public class AvgMonitorReq extends Query { + + /** + * 电站名称 + */ + private String name; + /** + * 开始时间 + */ + private String startTime; + /** + * 结束时间 + */ + private String endTime; + + +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/AvgMonitorVo.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/AvgMonitorVo.java new file mode 100644 index 0000000..c17ebd5 --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/AvgMonitorVo.java @@ -0,0 +1,54 @@ +package com.hnac.hzims.suichang.vo; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/8/31 9:37 + */ +@Data +public class AvgMonitorVo { + + /** + * 电站名称 + */ + private String name; + /** + * 核定下限流量 + */ + private BigDecimal flowValue; + /** + * 日均流量 + */ + private String avgFlow; + /** + * 实时流量 + */ + private String realFlow; + /** + * 现在的时间 + */ + private String dateNow; + + /** + * 经度(东经) + */ + private BigDecimal lgtd; + /** + * 纬度(北纬) + */ + private BigDecimal lttd; + /** + * 类型 1无节制电站 2流量计电站 + */ + private String stationType; + /** + * 上报率 + */ + private String passPre; + +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/EcologicalFlowVo.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/EcologicalFlowVo.java new file mode 100644 index 0000000..028e033 --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/EcologicalFlowVo.java @@ -0,0 +1,80 @@ +package com.hnac.hzims.suichang.vo; + +import lombok.Data; + +import java.math.BigDecimal; +import java.math.RoundingMode; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/8/31 9:37 + */ +@Data +public class EcologicalFlowVo { + + /** + * 电站数 + */ + private Integer allStationListSize; + /** + * 无节制电站 + */ + private Integer noLimitStationListSize; + /** + * 流量计电站 + */ + private Integer flowStationListSize; + /** + * 昨日达标率 + */ + private String yesterdayFinishPer; + /** + * 昨日达标数量 + */ + private Integer yesterdayFinishCount; + /** + * 上月达标数量 + */ + private Integer monthFinishCount; + /** + * 上月达标率 + */ + private String monthFinishPer; + + /** + * 周达标率 + */ + private String weekFinishPer; + /** + * 季达标率 + */ + private String quarterFinishPer; + /** + * 半年达标率 + */ + private String halfYearFinishPer; + /** + * 年达标率 + */ + private String yearFinishPer; + /** + * 今天上报率 + */ + private String reportTodayPre; + /** + * 今天预警数 + */ + private Integer warnTodayCount; + /** + * 昨天上报率 + */ + private String reportYesTerdayPre; + /** + * 昨天预警数 + */ + private Integer warnYesTerdayCount; + + +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/ExamStationFlowDataReq.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/ExamStationFlowDataReq.java new file mode 100644 index 0000000..e03806f --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/ExamStationFlowDataReq.java @@ -0,0 +1,37 @@ +package com.hnac.hzims.suichang.vo; + +import lombok.Data; +import org.springblade.core.mp.support.Query; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/8/31 9:37 + */ +@Data +public class ExamStationFlowDataReq extends Query { + + /** + * 电站名称 + */ + private String name; + /** + * 开始时间 + */ + private String startTime; + /** + * 结束时间 + */ + private String endTime; + + /** + * 1 无节制电站 2 流量计电站 + */ + private String stationType; + /** + * 是否达标 + */ + private String isPass; + +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/ExamStationFlowReportDayVo.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/ExamStationFlowReportDayVo.java new file mode 100644 index 0000000..1e94e57 --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/ExamStationFlowReportDayVo.java @@ -0,0 +1,60 @@ +package com.hnac.hzims.suichang.vo; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * @Author: liangfan + * @Date: 2024-03-15 18:33 + * @Description: + */ +@Data +public class ExamStationFlowReportDayVo { + + + /** + * 电站名称 + */ + private String name; + /** + * 所属区域 + */ + private String areaName; + + /** + * 状态 + */ + private String status; + /** + * 日泄放比 + */ + private String dayOutFlowPre; + /** + * 核定流量 + */ + private BigDecimal flowValue; + /** + * 前日日均流量 + */ + private BigDecimal yesTerDayAvgFlowValue; + /** + * 瞬时流量 + */ + private BigDecimal realFlowValue; + + /** + * 今日平均流量 + */ + private BigDecimal toDayAvgFlowValue; + + /** + * 实际下泄流量 + */ + private BigDecimal realOutFlow; + /** + * 核定下泄流量 + */ + private BigDecimal outFlow; +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/ExamStationFlowReportDetailVo.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/ExamStationFlowReportDetailVo.java new file mode 100644 index 0000000..9099ad6 --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/ExamStationFlowReportDetailVo.java @@ -0,0 +1,33 @@ +package com.hnac.hzims.suichang.vo; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @Author: liangfan + * @Date: 2024-03-15 18:41 + * @Description: + */ +@Data +public class ExamStationFlowReportDetailVo { + + /** + * 核定流量 + */ + private BigDecimal ecologicalFlowValue; + /** + * 日均流量 + */ + private BigDecimal flowValue; + + /** + * 时间 + */ + private String tm; + + /** + * 是否合格 + */ + private String isPass; +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/ExamStationFlowReportVo.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/ExamStationFlowReportVo.java new file mode 100644 index 0000000..8451be3 --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/ExamStationFlowReportVo.java @@ -0,0 +1,49 @@ +package com.hnac.hzims.suichang.vo; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * @Author: liangfan + * @Date: 2024-03-15 18:33 + * @Description: + */ +@Data +public class ExamStationFlowReportVo { + + + /** + * 电站名称 + */ + private String name; + /** + * 所属区域 + */ + private String areaName; + /** + * 核定下限流量 + */ + private BigDecimal flowValue; + /** + * 考核天数 + */ + private Long count; + /** + * 合格天数 + */ + private Integer passCount; + /** + * 合格率 + */ + private String passPre; + + /** + * 是否合格 + */ + private String isPass; + + + private List infos; +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/FlowWarnQueryDTO.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/FlowWarnQueryDTO.java new file mode 100644 index 0000000..07d9656 --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/FlowWarnQueryDTO.java @@ -0,0 +1,26 @@ +package com.hnac.hzims.suichang.vo; + +import lombok.Data; + +/** + * @Author: liangfan + * @Date: 2024-03-20 17:23 + * @Description: + */ +@Data +public class FlowWarnQueryDTO { + /** + * 开始时间 + */ + private String startTime; + + + /** + * 结束时间 + */ + private String endTime; + /** + * 站点id + */ + private String objectCode; +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/FlowWarnVo.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/FlowWarnVo.java new file mode 100644 index 0000000..629e5bf --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/FlowWarnVo.java @@ -0,0 +1,45 @@ +package com.hnac.hzims.suichang.vo; + +import lombok.Data; + +/** + * @Author: liangfan + * @Date: 2024-03-19 10:00 + * @Description: + */ +@Data +public class FlowWarnVo { + /** + * 站点名称 + */ + String name; + /** + * 消息内容 + */ + String content; + /** + * 发送时间 + */ + String sendTime; + + /** + * 发送人id + */ + String receiveUserId; + /** + * 发送人姓名 + */ + String receiveUserName; + /** + * 业务对象来源(数据平台、水库等) + */ + String objectSource; + + /** + * 业务对象编码 + */ + String objectCode; + + String alarmLevel; + +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/ImageReq.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/ImageReq.java new file mode 100644 index 0000000..7fd99e5 --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/ImageReq.java @@ -0,0 +1,33 @@ +package com.hnac.hzims.suichang.vo; + +import lombok.Data; + +/** + * @Author: liangfan + * @Date: 2024-03-21 19:04 + * @Description: + */ + +@Data +public class ImageReq { + /** + * 开始时间 + */ + private String startTime; + /** + * 结束时间 + */ + private String endTime; + /** + * 站点名称 + */ + private String name; + /** + * 设备编码 + */ + private String deviceCode; + /** + * 正常 异常 + */ + private String status; +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/ImageVo.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/ImageVo.java new file mode 100644 index 0000000..2d8533f --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/ImageVo.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.suichang.vo; + +import lombok.Data; + +/** + * @Author: liangfan + * @Date: 2024-03-21 19:04 + * @Description: + */ + +@Data +public class ImageVo { + + private Long id; + + private String stcd; + + private String time; + + private String data; + + private String manualpath; + + private String name; + + private String status; + +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/MissingImagesRes.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/MissingImagesRes.java new file mode 100644 index 0000000..10dfeaa --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/MissingImagesRes.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.suichang.vo; + +import lombok.Data; + +/** + * @Author: liangfan + * @Date: 2024-03-21 19:33 + * @Description: + */ +@Data +public class MissingImagesRes { + + String deviceCode; + + String name; + + String area; + + String month; + + String monthMissingPre; +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/RealMonitorExportDTO.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/RealMonitorExportDTO.java new file mode 100644 index 0000000..4e2c0b3 --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/RealMonitorExportDTO.java @@ -0,0 +1,46 @@ +package com.hnac.hzims.suichang.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/8/31 9:37 + */ +@Data +public class RealMonitorExportDTO { + + /** + * 电站名称 + */ + @ExcelProperty(value = "电站名称", index = 0) + private String name; + /** + * 核定下限流量 + */ + @ExcelProperty(value = "核定流量(m³/s)", index = 1) + private BigDecimal flowValue; + /** + * 监测流量 + */ + @ExcelProperty(value = "监测流量(m³/s)", index = 2) + private String realFlow; + + /** + * 上报个数 + */ + @ExcelProperty(value = "上报数(个)", index = 3) + private Integer reportCount; + + /** + * 时间 + */ + @ExcelProperty(value = "时间", index = 4) + private String dateNow; + + +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/RealMonitorRes.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/RealMonitorRes.java new file mode 100644 index 0000000..86e0c3c --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/RealMonitorRes.java @@ -0,0 +1,27 @@ +package com.hnac.hzims.suichang.vo; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/8/31 9:37 + */ +@Data +public class RealMonitorRes { + + /** + * 电站名称 + */ + private List realMonitorVos; + /** + * 应上报条数 + */ + private Long reportCount; + + +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/RealMonitorSingleInfoReq.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/RealMonitorSingleInfoReq.java new file mode 100644 index 0000000..07bafd9 --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/RealMonitorSingleInfoReq.java @@ -0,0 +1,27 @@ +package com.hnac.hzims.suichang.vo; + +import lombok.Data; +import org.springblade.core.mp.support.Query; + +/** + * @Author: liangfan + * @Date: 2024-03-14 09:56 + * @Description: + */ +@Data +public class RealMonitorSingleInfoReq extends Query { + + /** + * 设备编号 + */ + private String deviceCode; + + /** + * 开始时间 + */ + private String startTime; + /** + * 结束时间 + */ + private String endTime; +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/RealMonitorSingleInfoVo.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/RealMonitorSingleInfoVo.java new file mode 100644 index 0000000..80738ed --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/RealMonitorSingleInfoVo.java @@ -0,0 +1,25 @@ +package com.hnac.hzims.suichang.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +/** + * @Author: liangfan + * @Date: 2024-03-14 09:56 + * @Description: + */ +@Data +public class RealMonitorSingleInfoVo { + /** + * 实时值 + */ + @ExcelProperty(value = "流量值", index = 0) + private String value; + + /** + * 时间 + */ + @ExcelProperty(value = "监测时间", index = 1) + private String tm; + +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/RealMonitorVo.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/RealMonitorVo.java new file mode 100644 index 0000000..71505a7 --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/RealMonitorVo.java @@ -0,0 +1,47 @@ +package com.hnac.hzims.suichang.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/8/31 9:37 + */ +@Data +public class RealMonitorVo { + /** + * 设备编号 + */ + private String deviceCode; + + /** + * 电站名称 + */ + private String name; + /** + * 核定下限流量 + */ + private BigDecimal flowValue; + /** + * 监测流量 + */ + private String realFlow; + + /** + * 上报个数 + */ + private Integer reportCount; + + /** + * 时间 + */ + private String dateNow; + + private String areaName; + + +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/StationQueryReq.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/StationQueryReq.java new file mode 100644 index 0000000..98cc6dc --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/StationQueryReq.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.suichang.vo; + +import lombok.Data; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/8/31 9:37 + */ +@Data +public class StationQueryReq { + + /** + * 电站名称 + */ + private String name; + + private String stationType; + +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/StationTreeRes.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/StationTreeRes.java new file mode 100644 index 0000000..771346f --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/StationTreeRes.java @@ -0,0 +1,25 @@ +package com.hnac.hzims.suichang.vo; + +import lombok.Data; + +import java.util.List; + +/** + * @Author: liangfan + * @Date: 2024-03-25 17:21 + * @Description: + */ + +@Data +public class StationTreeRes { + StationVo stationVo; + /** + * 数量 + */ + int count; + /** + * 视频点位list + */ + List child; + +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/StationTypeVo.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/StationTypeVo.java new file mode 100644 index 0000000..a38aadd --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/StationTypeVo.java @@ -0,0 +1,70 @@ +package com.hnac.hzims.suichang.vo; + +import com.baomidou.mybatisplus.annotation.SqlCondition; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springblade.core.mp.support.QueryField; + +/** + * @Author: liangfan + * @Date: 2024-03-25 17:11 + * @Description: + */ + +@Data +public class StationTypeVo { + + @ApiModelProperty("主键ID") + private Long id; + + @ApiModelProperty("视频源配置名称") + private String name; + + @ApiModelProperty("站点ID") + private String stationId; + + @ApiModelProperty("机构ID") + private Long deptId; + + @ApiModelProperty("是否平台接入") + private Integer isHikvideo; + + @ApiModelProperty("类型") + private String type; + + @ApiModelProperty("视频类型;暂只包括清污机类型") + private String videoType; + + @ApiModelProperty("数据源地址") + private String liveSourceAddress; + + @ApiModelProperty("视频源编码") + private String pointCode; + + @ApiModelProperty("代理API网关nginx服务器ip端口") + private String videoHost; + + @ApiModelProperty("秘钥appkey") + private String appKey; + + @ApiModelProperty("秘钥appSecret") + private String appSecret; + + @ApiModelProperty("排序") + private Integer sort; + + @ApiModelProperty("站點排序") + private Integer stationSort; + + @ApiModelProperty("萤石云地址") + private String ysyUrl; + + @ApiModelProperty("视频归属类型 1代表防汛安全,2代表运行安全,3生态流量监视") + private Integer videoOwerType; + + @ApiModelProperty("拼音") + private String pingyin; + +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/StationVo.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/StationVo.java new file mode 100644 index 0000000..053b8e6 --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/StationVo.java @@ -0,0 +1,45 @@ +package com.hnac.hzims.suichang.vo; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/8/31 9:37 + */ +@Data +public class StationVo { + + /** + * 名称 + */ + private String name; + /** + * 设备编号 + */ + private String deviceCode; + + + /** + * 核定流量 + */ + private BigDecimal flowValue; + + /** + * 电站类型 1 无节制电站 2流量计电站 + */ + private String stationType; + + /** + * 经度(东经) + */ + private BigDecimal lgtd; + /** + * 纬度(北纬) + */ + private BigDecimal lttd; + +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/StatisticsFlowDataDetailVo.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/StatisticsFlowDataDetailVo.java new file mode 100644 index 0000000..c35d2ff --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/StatisticsFlowDataDetailVo.java @@ -0,0 +1,40 @@ +package com.hnac.hzims.suichang.vo; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/8/31 9:37 + */ +@Data +public class StatisticsFlowDataDetailVo { + + /** + * 电站名称 + */ + private String name; + + /** + * 核定流量 + */ + private String flowValue; + + /** + * 考核天数 + */ + private Integer examDays; + /** + * 合格天数 + */ + private Integer examPassDays = 0; + /** + * 合格率 + */ + private String examPassDayPre = "0.00%"; + + +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/StatisticsFlowDataReq.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/StatisticsFlowDataReq.java new file mode 100644 index 0000000..3f8bc28 --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/StatisticsFlowDataReq.java @@ -0,0 +1,29 @@ +package com.hnac.hzims.suichang.vo; + +import lombok.Data; +import org.springblade.core.mp.support.Query; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/8/31 9:37 + */ +@Data +public class StatisticsFlowDataReq extends Query { + + /** + * 电站名称 + */ + private String name; + /** + * 开始时间 + */ + private String startTime; + /** + * 结束时间 + */ + private String endTime; + + +} diff --git a/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/StatisticsFlowDataVo.java b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/StatisticsFlowDataVo.java new file mode 100644 index 0000000..5c22822 --- /dev/null +++ b/hzims-service-api/hzims-ecological-api/src/main/java/com/hnac/hzims/suichang/vo/StatisticsFlowDataVo.java @@ -0,0 +1,37 @@ +package com.hnac.hzims.suichang.vo; + +import lombok.Data; + +import java.util.List; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/8/31 9:37 + */ +@Data +public class StatisticsFlowDataVo { + /** + * 区域名称 + */ + private String areaName; + /** + * 考核电站个数 + */ + private Integer examCount; + /** + * 达标电站个数 + */ + private Integer passCount; + /** + * 达标率 + */ + private String passPre; + /** + * 报表数据 + */ + private List detail; + + +} diff --git a/hzims-service/hzims-ecological/pom.xml b/hzims-service/hzims-ecological/pom.xml new file mode 100644 index 0000000..56a114a --- /dev/null +++ b/hzims-service/hzims-ecological/pom.xml @@ -0,0 +1,75 @@ + + + 4.0.0 + + com.hnac.hzims + hzims-service + 4.0.0-SNAPSHOT + + + hzims-ecological + + + 8 + 8 + UTF-8 + + + + + + com.baomidou + dynamic-datasource-spring-boot-starter + + + com.hnac.hzinfo.data + hzinfo-data-sdk + + + com.hnac.hzims + hzims-ecological-api + ${hzims.project.version} + + + com.hnac.hzims + hzims-operational-api + ${hzims.project.version} + + + com.hnac.hzims + message-alarm-api + ${hzims.project.version} + + + + + ${project.name}-${project.version} + + + com.spotify + dockerfile-maven-plugin + + ${docker.username} + ${docker.password} + ${docker.registry.url}/${docker.namespace}/${project.artifactId} + ${project.version} + true + + target/${project.build.finalName}.jar + + false + + + + org.springframework.boot + spring-boot-maven-plugin + + + true + + + + + \ No newline at end of file diff --git a/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/SuiChangApplication.java b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/SuiChangApplication.java new file mode 100644 index 0000000..1230279 --- /dev/null +++ b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/SuiChangApplication.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.suichang; + +import org.mybatis.spring.annotation.MapperScan; +import org.springblade.core.cloud.feign.EnableBladeFeign; +import org.springblade.core.launch.BladeApplication; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.cloud.client.SpringCloudApplication; +import org.springframework.context.annotation.ComponentScan; + +@EnableBladeFeign(basePackages = {"org.springblade", "com.hnac"}) +@SpringCloudApplication +@MapperScan("com.hnac.hzims.**.mapper.**") +@ComponentScan(basePackages = {"com.hnac.hzims.*"}) +public class SuiChangApplication extends SpringBootServletInitializer { + public final static String APP_NAME = "hzims-ecological"; + + public static void main(String[] args) { + BladeApplication.run(APP_NAME, SuiChangApplication.class, args); + } + +} \ No newline at end of file diff --git a/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/controller/EcologicalFlowController.java b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/controller/EcologicalFlowController.java new file mode 100644 index 0000000..83dc86c --- /dev/null +++ b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/controller/EcologicalFlowController.java @@ -0,0 +1,111 @@ +package com.hnac.hzims.suichang.controller; + +import com.hnac.hzims.suichang.service.EcologicalFlowService; +import com.hnac.hzims.suichang.service.RealMonitorService; +import com.hnac.hzims.suichang.util.MemoryPagination; +import com.hnac.hzims.suichang.vo.*; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletResponse; +import java.util.HashMap; +import java.util.List; + +/** + * 遂昌生态流量 + * + * @author liangfan + */ +@RestController +@RequestMapping("/ecologicalFlow") +@Api(value = "遂昌生态流量", tags = "遂昌生态流量接口") +public class EcologicalFlowController { + + @Autowired + private EcologicalFlowService ecologicalFlowService; + + @Autowired + private RealMonitorService realMonitorService; + + @RequestMapping(value = "/getEcologicalFlowIndexInfo", method = {RequestMethod.POST}) + @ApiOperation(notes = "遂昌生态流量", value = "遂昌生态流量") + public R getEcologicalFlowIndexInfo() { + EcologicalFlowVo vo = ecologicalFlowService.getEcologicalFlowIndexInfo(); + return R.data(vo); + } + + @RequestMapping(value = "/getAvgMonitorInfo", method = {RequestMethod.POST}) + @ApiOperation(notes = "实时监测日均流量", value = "实时监测日均流量") + public R getAvgMonitorInfo() { + return R.data(realMonitorService.getAvgMonitorInfo()); + } + + @RequestMapping(value = "/getAvgMonitorCountInfo", method = {RequestMethod.POST}) + @ApiOperation(notes = "生态流量监管-日均流量", value = "生态流量监管-日均流量") + public R getAvgMonitorCountInfo(@RequestBody AvgMonitorReq req) { + List resultList = realMonitorService.getAvgMonitorCountInfo(req); + // 内存分页 + HashMap map = new HashMap<>(); + resultList = MemoryPagination.pagination(resultList, req.getCurrent(), req.getSize()); + map.put("records", resultList); + map.put("total", resultList.size()); + return R.data(map); + } + + @RequestMapping(value = "/getRealMonitorInfo", method = {RequestMethod.GET}) + @ApiOperation(notes = "实时流量页面", value = "实时流量页面") + public R getRealMonitorInfo(String name, Query query) { + RealMonitorRes res = realMonitorService.getRealMonitorInfo(name); + List resultList = res.getRealMonitorVos(); + HashMap map = new HashMap<>(); + resultList = MemoryPagination.pagination(resultList, query.getCurrent(), query.getSize()); + map.put("records", resultList); + map.put("total", resultList.size()); + map.put("reportCount", res.getReportCount()); + return R.data(map); + } + + @RequestMapping(value = "/getRealMonitorSingleInfo", method = {RequestMethod.POST}) + @ApiOperation(notes = "单个电站实时流量明细", value = "单个电站实时流量明细") + public R getRealMonitorSingleInfo(@RequestBody RealMonitorSingleInfoReq req) { + List resultList = realMonitorService.getRealMonitorSingleInfo(req); + HashMap map = new HashMap<>(); + resultList = MemoryPagination.pagination(resultList, req.getCurrent(), req.getSize()); + map.put("records", resultList); + map.put("total", resultList.size()); + return R.data(map); + } + + @RequestMapping(value = "/exportRealMonitorInfo", method = {RequestMethod.GET}) + @ApiOperation(notes = "导出实时流量页面数据", value = "导出实时流量页面数据") + public void exportRealMonitorInfo(HttpServletResponse response, String name) { + realMonitorService.exportRealMonitorInfo(response, name); + } + + @RequestMapping(value = "/exportRealMonitorSingleInfo", method = {RequestMethod.GET}) + @ApiOperation(notes = "导出单个电站实时流量明细", value = "导出单个电站实时流量明细") + public void exportRealMonitorSingleInfo(HttpServletResponse response, RealMonitorSingleInfoReq req) { + realMonitorService.exportRealMonitorSingleInfo(response, req); + } + + @RequestMapping(value = "/exportAvgMonitorCountInfo", method = {RequestMethod.GET}) + @ApiOperation(notes = "导出生态流量监管-日均流量", value = "导出生态流量监管-日均流量") + public void exportAvgMonitorCountInfo(HttpServletResponse response, AvgMonitorReq req) { + realMonitorService.exportAvgMonitorCountInfo(response, req); + } + + @RequestMapping(value = "/getRealData", method = {RequestMethod.GET}) + public R test(String deviceCode) { + return R.data(realMonitorService.getRealData(deviceCode)); + } + + + +} \ No newline at end of file diff --git a/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/controller/ExamController.java b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/controller/ExamController.java new file mode 100644 index 0000000..e42c01e --- /dev/null +++ b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/controller/ExamController.java @@ -0,0 +1,72 @@ +package com.hnac.hzims.suichang.controller; + +import com.hnac.hzims.common.logs.utils.StringUtils; +import com.hnac.hzims.suichang.service.ExamStationDataService; +import com.hnac.hzims.suichang.util.MemoryPagination; +import com.hnac.hzims.suichang.vo.ExamStationFlowDataReq; +import com.hnac.hzims.suichang.vo.ExamStationFlowReportDayVo; +import com.hnac.hzims.suichang.vo.ExamStationFlowReportVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springblade.core.tool.api.R; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletResponse; +import java.util.HashMap; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Author: liangfan + * @Date: 2024-03-15 15:08 + * @Description: + */ +@RestController +@RequestMapping("/exam") +@Api(value = "遂昌生态流量-考核管理", tags = "遂昌生态流量-考核管理") +public class ExamController { + + @Autowired + private ExamStationDataService examStationDataService; + + @RequestMapping(value = "/examStationFlowReportByTime", method = {RequestMethod.GET}) + @ApiOperation(notes = "电站月考核", value = "电站月考核") + public R examStatisticsFlowReportByTime(ExamStationFlowDataReq req) { + List resultList = + examStationDataService.examStationFlowReportByTime(req); + HashMap map = new HashMap<>(); + resultList = MemoryPagination.pagination(resultList, req.getCurrent(), req.getSize()); + map.put("records", resultList); + map.put("total", resultList.size()); + return R.data(map); + } + + + @RequestMapping(value = "/exportExamStationFlowReportByTime", method = {RequestMethod.GET}) + @ApiOperation(notes = "电站月考核", value = "电站月考核") + public void exportExamStationFlowReportByTime(HttpServletResponse response, ExamStationFlowDataReq req) { + examStationDataService.exportExamStationFlowReportByTime(response, req); + } + + + @RequestMapping(value = "/examStationFlowReportOfDay", method = {RequestMethod.GET}) + @ApiOperation(notes = "电站日考核", value = "电站日考核") + public R examStationFlowReportOfDay(ExamStationFlowDataReq req) { + List resultList = examStationDataService.examStationFlowReportOfDay(req); + String isPass = req.getIsPass(); + // 条件过滤 + if (StringUtils.isNotBlank(req.getIsPass())) { + resultList = + resultList.stream().filter(o -> o.getStatus().equals(isPass)).collect(Collectors.toList()); + } + HashMap map = new HashMap<>(); + resultList = MemoryPagination.pagination(resultList, req.getCurrent(), req.getSize()); + map.put("records", resultList); + map.put("total", resultList.size()); + return R.data(map); + } + +} diff --git a/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/controller/FlowWarnController.java b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/controller/FlowWarnController.java new file mode 100644 index 0000000..07113f3 --- /dev/null +++ b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/controller/FlowWarnController.java @@ -0,0 +1,41 @@ +package com.hnac.hzims.suichang.controller; + +import com.hnac.hzims.suichang.service.FlowWarnService; +import com.hnac.hzims.suichang.vo.FlowWarnQueryDTO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * 遂昌生态流量 + * + * @author liangfan + */ +@RestController +@RequestMapping("/flowWarn") +@Api(value = "遂昌生态流量预警信息", tags = "遂昌生态流量预警信息") +public class FlowWarnController { + @Autowired + private FlowWarnService flowWarnService; + + @RequestMapping(value = "/getFlowWarnList", method = {RequestMethod.GET}) + @ApiOperation(notes = "大屏遂昌生态流量预警信息", value = "大屏遂昌生态流量预警信息") + public R getFlowWarnList(FlowWarnQueryDTO dto, Query query) { + return R.data(flowWarnService.getFlowWarnList(dto, query)); + } + + + @RequestMapping(value = "/warningPush", method = {RequestMethod.GET}) + @ApiOperation(notes = "大屏遂昌生态流量预警信息", value = "大屏遂昌生态流量预警信息") + public R warningPush(FlowWarnQueryDTO dto) { + return R.data(flowWarnService.warningPush(dto)); + } + + +} \ No newline at end of file diff --git a/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/controller/ImageAndVideoController.java b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/controller/ImageAndVideoController.java new file mode 100644 index 0000000..4888796 --- /dev/null +++ b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/controller/ImageAndVideoController.java @@ -0,0 +1,69 @@ +package com.hnac.hzims.suichang.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.suichang.service.ImageAndVideoService; +import com.hnac.hzims.suichang.vo.ImageReq; +import com.hnac.hzims.suichang.vo.MissingImagesRes; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +/** + * @Author: liangfan + * @Date: 2024-03-15 15:08 + * @Description: + */ +@RestController +@RequestMapping("/imageAndVideo") +@Api(value = "图片和视频", tags = "图片和视频") +public class ImageAndVideoController { + + @Autowired + private ImageAndVideoService imageAndVideoService; + + @RequestMapping(value = "/getMissingImagesInfo", method = {RequestMethod.GET}) + @ApiOperation(notes = "照片缺失率", value = "照片缺失率") + public R> getMissingImagesInfo(ImageReq req, Query query) { + return R.data(imageAndVideoService.getMissingImagesInfo(req, query)); + } + + @RequestMapping(value = "/missingPush", method = {RequestMethod.GET}) + @ApiOperation(notes = "照片缺失日期及数据", value = "照片缺失日期及数据") + public R missingPush(ImageReq req) { + return R.data(imageAndVideoService.missingPush(req)); + } + + @RequestMapping(value = "/getImageInfoStatus", method = {RequestMethod.POST}) + @ApiOperation(notes = "照片缺失率详情", value = "照片缺失率详情") + public R getImageInfoStatus(@RequestBody ImageReq req) { + return R.data(imageAndVideoService.getImageInfoStatus(req)); + } + + @RequestMapping(value = "/getImageInfoByDeviceCode", method = {RequestMethod.GET}) + @ApiOperation(notes = "根据DeviceCode及时间查询照片", value = "根据DeviceCode及时间查询照片") + public R getImageInfoByDeviceCode(ImageReq req, Query query) { + return R.data(imageAndVideoService.getImageInfoByDeviceCode(req, query)); + } + + + @RequestMapping(value = "/selectNewestImage", method = {RequestMethod.GET}) + @ApiOperation(notes = "泄放照片", value = "泄放照片") + public R selectNewestImage(ImageReq req, Query query) { + return R.data(imageAndVideoService.selectNewestImage(req, query)); + } + + + @RequestMapping(value = "/getStationVideoType", method = {RequestMethod.GET, RequestMethod.POST}) + @ApiOperation(value = "获取视频byType", notes = "获取视频byType") + public R getStationTree(String videoType) { + return R.data(imageAndVideoService.getStationVideoType(videoType)); + } + + +} diff --git a/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/controller/StatisticsFlowDataController.java b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/controller/StatisticsFlowDataController.java new file mode 100644 index 0000000..d6477e7 --- /dev/null +++ b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/controller/StatisticsFlowDataController.java @@ -0,0 +1,56 @@ +package com.hnac.hzims.suichang.controller; + +import com.hnac.hzims.suichang.service.StatisticsDataService; +import com.hnac.hzims.suichang.util.MemoryPagination; +import com.hnac.hzims.suichang.vo.StatisticsFlowDataDetailVo; +import com.hnac.hzims.suichang.vo.StatisticsFlowDataReq; +import com.hnac.hzims.suichang.vo.StatisticsFlowDataVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springblade.core.tool.api.R; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletResponse; +import java.util.HashMap; +import java.util.List; + +/** + * @Author: liangfan + * @Date: 2024-03-14 16:18 + * @Description: + */ +@RestController +@RequestMapping("/statisticsData") +@Api(value = "遂昌生态流量-统计报表", tags = "遂昌生态流量-统计报表") +public class StatisticsFlowDataController { + + @Autowired + private StatisticsDataService statisticsDataService; + + @RequestMapping(value = "/statisticsFlowReportByTime", method = {RequestMethod.GET}) + @ApiOperation(notes = "", value = "") + public R statisticsFlowReportByTime(StatisticsFlowDataReq req) { + StatisticsFlowDataVo res = statisticsDataService.statisticsFlowReportByTime(req); + List resultList = res.getDetail(); + HashMap map = new HashMap<>(); + // 内存分页 + resultList = MemoryPagination.pagination(resultList, req.getCurrent(), req.getSize()); + map.put("areaName", res.getAreaName()); + map.put("examCount", res.getExamCount()); + map.put("passCount", res.getPassCount()); + map.put("passPre", res.getPassPre()); + map.put("records", resultList); + map.put("total", resultList.size()); + return R.data(map); + } + + @RequestMapping(value = "/exportStatisticsFlowReportByTime", method = {RequestMethod.GET}) + @ApiOperation(notes = "", value = "") + public void exportStatisticsFlowReportByTime(HttpServletResponse response, StatisticsFlowDataReq req) { + statisticsDataService.exportStatisticsFlowReportByTime(response, req); + } + +} diff --git a/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/feign/SuichangClient.java b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/feign/SuichangClient.java new file mode 100644 index 0000000..6997961 --- /dev/null +++ b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/feign/SuichangClient.java @@ -0,0 +1,43 @@ +package com.hnac.hzims.suichang.feign; + +import com.hnac.hzims.suichang.mapper.EcologicalFlowMapper; +import com.hnac.hzims.suichang.service.EcologicalFlowService; +import com.hnac.hzims.suichang.vo.StationQueryReq; +import com.hnac.hzims.suichang.vo.StationVo; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping("/suichangClient") +@Slf4j +@RequiredArgsConstructor +public class SuichangClient implements ISuichangClient { + + @Autowired + private EcologicalFlowMapper ecologicalFlowMapper; + @Autowired + private EcologicalFlowService ecologicalFlowService; + + @Override + @PostMapping(GET_STATION_BY_REQ) + public List getStationListByReq(StationQueryReq req) { + return ecologicalFlowMapper.getStationListByReq(req); + } + + @Override + @PostMapping(GET_DATA) + public List> getData(String stcd, Integer accessRules, Integer saveTimeType, Integer timeInterval, + LocalDateTime startTime, LocalDateTime endTime) { + return ecologicalFlowService.getData(stcd, accessRules, saveTimeType, timeInterval, + startTime, endTime); + } + +} diff --git a/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/mapper/EcologicalFlowMapper.java b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/mapper/EcologicalFlowMapper.java new file mode 100644 index 0000000..60a8c0f --- /dev/null +++ b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/mapper/EcologicalFlowMapper.java @@ -0,0 +1,33 @@ +package com.hnac.hzims.suichang.mapper; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.message_alarm.entity.MessageAlarmInfo; +import com.hnac.hzims.message_alarm.entity.MessageReceiveInfo; +import com.hnac.hzims.suichang.vo.*; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.springblade.system.user.entity.User; + +import java.util.List; + +/** + * 遂昌生态流量 + * + * @author liangfan + */ +@Mapper +public interface EcologicalFlowMapper { + + + List getStationListByName(String name); + + IPage getStationListByNamePage(StationQueryReq req, IPage page); + + List getStationListByReq(@Param("req") StationQueryReq req); + + IPage getFlowWarnList(FlowWarnQueryDTO dto, IPage page); + + List getFlowWarnCount(FlowWarnQueryDTO dto); + + +} \ No newline at end of file diff --git a/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/mapper/EcologicalFlowMapper.xml b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/mapper/EcologicalFlowMapper.xml new file mode 100644 index 0000000..83d6d7d --- /dev/null +++ b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/mapper/EcologicalFlowMapper.xml @@ -0,0 +1,104 @@ + + + + + SELECT + a.name as name, + a.code as deviceCode, + a.discharge as flowValue, + a.type as stationType, + a.LGTD as lgtd, + a.LTTD as lttd + FROM + hzims_station a + WHERE + a.IS_DELETED = '0' + + + + + + + + + + + + + + + diff --git a/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/mapper/ImageAndVideoMapper.java b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/mapper/ImageAndVideoMapper.java new file mode 100644 index 0000000..086770d --- /dev/null +++ b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/mapper/ImageAndVideoMapper.java @@ -0,0 +1,39 @@ +package com.hnac.hzims.suichang.mapper; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.suichang.vo.*; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 遂昌生态流量 + * + * @author liangfan + */ +@Mapper +public interface ImageAndVideoMapper { + + + IPage getImageInfo(ImageReq req, IPage page); + + + + /** + * 根据设备stcds查询各个设备最新图片信息 + * @param req + * @param page + * @return + */ + IPage selectNewestImage(ImageReq req, IPage page); + + /** + * 查询视频点位 + * @param videoType + * @return + */ + List selectStationTypeByOwerType(String videoType); + + +} \ No newline at end of file diff --git a/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/mapper/ImageAndVideoMapper.xml b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/mapper/ImageAndVideoMapper.xml new file mode 100644 index 0000000..9964604 --- /dev/null +++ b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/mapper/ImageAndVideoMapper.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + diff --git a/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/EcologicalFlowService.java b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/EcologicalFlowService.java new file mode 100644 index 0000000..bd458cb --- /dev/null +++ b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/EcologicalFlowService.java @@ -0,0 +1,36 @@ +package com.hnac.hzims.suichang.service; + +import com.hnac.hzims.suichang.vo.EcologicalFlowVo; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Map; + +/** + * @Author: liangfan + * @Date: 2024-03-08 15:06 + * @Description: + */ + +public interface EcologicalFlowService { + /** + * 首页生态流量 + * + * @return + */ + EcologicalFlowVo getEcologicalFlowIndexInfo(); + + /** + * 查询历史数据 + * @param stcd + * @param accessRules 取数规则:0=最早值、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值)6=最新值") + * @param saveTimeType 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时) 3->、d(天) 4->、w(周) 5->、n(自然月)、6->y(自然年) + * @param timeInterval + * @param startTime + * @param endTime + * @return + */ + List> getData(String stcd, Integer accessRules, Integer saveTimeType, Integer timeInterval, + LocalDateTime startTime, LocalDateTime endTime); + +} diff --git a/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/ExamStationDataService.java b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/ExamStationDataService.java new file mode 100644 index 0000000..ebcaa4f --- /dev/null +++ b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/ExamStationDataService.java @@ -0,0 +1,37 @@ +package com.hnac.hzims.suichang.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.suichang.vo.*; +import org.springblade.core.mp.support.Query; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * @Author: liangfan + * @Date: 2024-03-08 15:06 + * @Description: + */ + +public interface ExamStationDataService { + /** + * 电站月考核 + * @param req + * @return + */ + List examStationFlowReportByTime(ExamStationFlowDataReq req); + /** + * 电站月考核 导出 + * @param req + * @return + */ + void exportExamStationFlowReportByTime(HttpServletResponse response, ExamStationFlowDataReq req); + + /** + * 流量计电站日考核 + * @param req + * @return + */ + List examStationFlowReportOfDay(ExamStationFlowDataReq req); + +} diff --git a/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/FlowWarnService.java b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/FlowWarnService.java new file mode 100644 index 0000000..45a7ed8 --- /dev/null +++ b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/FlowWarnService.java @@ -0,0 +1,26 @@ +package com.hnac.hzims.suichang.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.hnac.hzims.suichang.vo.FlowWarnQueryDTO; +import com.hnac.hzims.suichang.vo.FlowWarnVo; +import org.springblade.core.mp.support.Query; + +import java.util.List; +import java.util.Map; + +/** + * @author liangfan + */ +public interface FlowWarnService { + + IPage getFlowWarnList(FlowWarnQueryDTO dto, Query query); + + /** + * 分页查询预警信息及告警信息 + * @param dto + * @return + */ + Map> warningPush(FlowWarnQueryDTO dto); + +} diff --git a/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/ImageAndVideoService.java b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/ImageAndVideoService.java new file mode 100644 index 0000000..62dbe65 --- /dev/null +++ b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/ImageAndVideoService.java @@ -0,0 +1,53 @@ +package com.hnac.hzims.suichang.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.hnac.hzims.suichang.vo.*; +import org.springblade.core.mp.support.Query; + +import java.util.List; +import java.util.Map; + +/** + * @Author: liangfan + * @Date: 2024-03-08 15:06 + * @Description: + */ + +public interface ImageAndVideoService { + /** + * 照片缺失率信息 + * @param req + * @param query + * @return + */ + IPage getMissingImagesInfo(ImageReq req, Query query); + + /** + * 照片条数 日期 + * @param req + * @return + */ + Map> missingPush(ImageReq req); + + /** + * 泄放照片详情 + * @param req + * @param query + * @return + */ + IPage getImageInfoByDeviceCode(ImageReq req, Query query); + + /** + * 照片缺失率详情 + * @param req + * @return + */ + List getImageInfoStatus(ImageReq req); + + IPage selectNewestImage(ImageReq req, Query query); + + List getStationVideoType(String videoType); + + +} diff --git a/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/RealMonitorService.java b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/RealMonitorService.java new file mode 100644 index 0000000..1c5dd28 --- /dev/null +++ b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/RealMonitorService.java @@ -0,0 +1,56 @@ +package com.hnac.hzims.suichang.service; + +import com.hnac.hzims.suichang.vo.*; +import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; + +/** + * @Author: liangfan + * @Date: 2024-03-13 16:37 + * @Description: + */ +public interface RealMonitorService { + /** + * 查询日均流量数据 + */ + List getAvgMonitorInfo(); + + /** + * 查询一段时间的日均流量数据 + * @param req + * @return + */ + List getAvgMonitorCountInfo(AvgMonitorReq req); + + + /** + * 实时流量列表页面 + * @return + */ + RealMonitorRes getRealMonitorInfo(String name); + + void exportRealMonitorInfo(HttpServletResponse response, String name); + + void exportRealMonitorSingleInfo(HttpServletResponse response, RealMonitorSingleInfoReq req); + + void exportAvgMonitorCountInfo(HttpServletResponse response, AvgMonitorReq req); + + /** + * 实时流量列表页面单个电站 + * @return + */ + List getRealMonitorSingleInfo(RealMonitorSingleInfoReq req); + + + /** + * 查询实时流量数据 + * @param stcd + * @return + */ + String getRealData(String stcd, String signage); + + String getRealData(String stcd); +} diff --git a/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/StatisticsDataService.java b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/StatisticsDataService.java new file mode 100644 index 0000000..acb547f --- /dev/null +++ b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/StatisticsDataService.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.suichang.service; + +import com.hnac.hzims.suichang.vo.StatisticsFlowDataReq; +import com.hnac.hzims.suichang.vo.StatisticsFlowDataVo; + +import javax.servlet.http.HttpServletResponse; + +/** + * @Author: liangfan + * @Date: 2024-03-08 15:06 + * @Description: + */ + +public interface StatisticsDataService { + + StatisticsFlowDataVo statisticsFlowReportByTime(StatisticsFlowDataReq req); + + void exportStatisticsFlowReportByTime(HttpServletResponse response, StatisticsFlowDataReq req); + +} diff --git a/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/impl/EcologicalFlowServiceImpl.java b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/impl/EcologicalFlowServiceImpl.java new file mode 100644 index 0000000..53b0bc2 --- /dev/null +++ b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/impl/EcologicalFlowServiceImpl.java @@ -0,0 +1,491 @@ +package com.hnac.hzims.suichang.service.impl; + +import com.hnac.hzims.entity.ReportData; +import com.hnac.hzims.suichang.mapper.EcologicalFlowMapper; +import com.hnac.hzims.suichang.service.EcologicalFlowService; +import com.hnac.hzims.suichang.util.DateUtil; +import com.hnac.hzims.suichang.vo.EcologicalFlowVo; +import com.hnac.hzims.suichang.vo.FlowWarnQueryDTO; +import com.hnac.hzims.suichang.vo.FlowWarnVo; +import com.hnac.hzims.suichang.vo.StationVo; +import com.hnac.hzims.util.CommonUtil; +import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO; +import com.hnac.hzinfo.datasearch.analyse.po.AnalyzeDataConditionPO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeInstanceFieldVO; +import com.hnac.hzinfo.sdk.analyse.AnalyseDataSearchClient; +import com.hnac.hzinfo.sdk.core.response.Result; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.time.*; +import java.time.temporal.ChronoUnit; +import java.time.temporal.TemporalAdjusters; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.stream.Collectors; + +/** + * @Author: liangfan + * @Date: 2024-03-08 15:06 + * @Description: + */ +@Slf4j +@Service +public class EcologicalFlowServiceImpl implements EcologicalFlowService { + @Autowired + AnalyseDataSearchClient analyseDataSearchClient; + + @Autowired + private EcologicalFlowMapper ecologicalFlowMapper; + + @Value("${suichang.signage}") + String signage; + + @Override + public EcologicalFlowVo getEcologicalFlowIndexInfo() { + LocalDateTime startTime = LocalDateTime.now(); + EcologicalFlowVo ecologicalFlowVo = new EcologicalFlowVo(); + // 监测电站数 无节制电站 流量计电站 1.无节制电站 2.流量计电站 + List stationInfoList = ecologicalFlowMapper.getStationListByName(null); + List noLimitStationListSize = stationInfoList.stream().filter(o -> "1".equals(o.getStationType())).collect(Collectors.toList()); + List flowStationListSize = stationInfoList.stream().filter(o -> "2".equals(o.getStationType())).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(stationInfoList)) { + return ecologicalFlowVo; + } + ecologicalFlowVo.setAllStationListSize(stationInfoList.size()); + ecologicalFlowVo.setNoLimitStationListSize(noLimitStationListSize.size()); + ecologicalFlowVo.setFlowStationListSize(flowStationListSize.size()); + + int yesterdayFinishCount = 0, weekCount = 0, monthFinishCount = 0, quarterCount = 0, halfYearCount = 0, yearCount = 0, + reportTodayCount = 0, reportYesTerdayCount = 0, warnTodayCount = 0, warnYesTerdayCount = 0; + // 得到所有设备实例code及核定下限流量 + log.info("站点信息list:{}", stationInfoList); + // 多线程优化 + List> yesterdayFinishCountList = new ArrayList<>(); + List> weekCountList = new ArrayList<>(); + List> monthFinishCountList = new ArrayList<>(); + List> quarterCountList = new ArrayList<>(); + List> halfYearCountList = new ArrayList<>(); + List> yearCountList = new ArrayList<>(); + List>> reportAndWarnTodayMapList = new ArrayList<>(); + List>> reportAndWarnYesTerdayMapList = new ArrayList<>(); + // 多线程 调用平台方法 + buildCompletableFutureList(stationInfoList, yesterdayFinishCountList, weekCountList, monthFinishCountList, + quarterCountList, halfYearCountList, yearCountList, reportAndWarnTodayMapList, reportAndWarnYesTerdayMapList); + try { + for (int i = 0; i < stationInfoList.size(); i++) { + // 1.昨日达标情况 达标率就是有没有达到核定下限流量 + yesterdayFinishCount = yesterdayFinishCountList.get(i).get() + yesterdayFinishCount; + // 2.上月达标情况 + weekCount = weekCountList.get(i).get() + weekCount; + // 3.上周达标情况 + monthFinishCount = monthFinishCountList.get(i).get() + monthFinishCount; + // 4.季度达标情况 + quarterCount = quarterCountList.get(i).get() + quarterCount; + // 5.半年达标情况 + halfYearCount = halfYearCountList.get(i).get() + halfYearCount; + // 6.年达标情况 + yearCount = yearCountList.get(i).get() + yearCount; + // 7.今日 预警数 上报率 + Map reportAndWarnTodayMap = reportAndWarnTodayMapList.get(i).get(); + reportTodayCount = reportTodayCount + reportAndWarnTodayMap.get("count"); + warnTodayCount = warnTodayCount + reportAndWarnTodayMap.get("warnCount"); + // 8.昨日 预警数 上报率 + Map reportAndWarnYesTerdayMap = reportAndWarnYesTerdayMapList.get(i).get(); + reportYesTerdayCount = reportYesTerdayCount + reportAndWarnYesTerdayMap.get("count"); + warnYesTerdayCount = warnYesTerdayCount + reportAndWarnYesTerdayMap.get("warnCount"); + } + } catch (Exception e) { + e.printStackTrace(); + } + log.info("yesterdayFinishCount = {}, weekCount = {}, monthFinishCount = {}, quarterCount = {}, halfYearCount = {}, yearCount = {}", + yesterdayFinishCount, weekCount, monthFinishCount, quarterCount, halfYearCount, yearCount); + // build返回信息 + buildRestultInfo(ecologicalFlowVo, stationInfoList.size(), + yesterdayFinishCount, monthFinishCount, weekCount, quarterCount, halfYearCount, + yearCount, reportTodayCount, warnTodayCount, reportYesTerdayCount, warnYesTerdayCount); + LocalDateTime endTime = LocalDateTime.now(); + log.info("耗时:{}", ChronoUnit.SECONDS.between(startTime, endTime)); + return ecologicalFlowVo; + } + + + @Override + public List> getData(String stcd, Integer accessRules, Integer saveTimeType, Integer timeInterval, + LocalDateTime startTime, LocalDateTime endTime) { + List> list = new ArrayList<>(); + List vos = getSignages(stcd); + if (vos == null || vos.isEmpty()) { + return null; + } + + Map> map = new HashMap<>(); + int count = 0; + for (AnalyzeInstanceFieldVO vo : vos) { + // accessRules 取数规则:0=最早值、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值)6=最新值") + // SaveTimeType 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时) 3->、d(天) 4->、w(周) 5->、n(自然月)、6->y(自然年) + List reportDataList = + getDataByDeviceCode(stcd, accessRules, saveTimeType, timeInterval, startTime, endTime, vo.getSignage()); + map.put(vo.getSignage(), reportDataList); + count = reportDataList.size(); + } + + + for (int i = 0; i < count; i++) { + Map res = new HashMap<>(); + for (AnalyzeInstanceFieldVO vo : vos) { + List reportDataList = map.get(vo.getSignage()); + ReportData reportData = reportDataList.get(i); + res.put("tm", reportData.getKeyStr()); + res.put(vo.getSignage(), reportData.getVal()); + } + list.add(res); + } + + return list; + } + + + List getDataByDeviceCode(String deviceCode, Integer accessRules, Integer saveTimeType, Integer timeInterval, + LocalDateTime start, LocalDateTime end, String col) { + List reportData = new ArrayList<>(); + AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); + po.setDeviceCode(deviceCode); + + List signboardConditions = new ArrayList<>(); + AnalyzeDataConditionPO conditionPO = new AnalyzeDataConditionPO(); + conditionPO.setBeginTime(start); + conditionPO.setEndTime(end); + conditionPO.setSignages(col); +// conditionPO.setKeepFigures(3); + conditionPO.setAccessRules(accessRules); + conditionPO.setSaveTimeType(saveTimeType); + conditionPO.setTimeInterval(timeInterval); + conditionPO.setFull(1); + signboardConditions.add(conditionPO); + po.setSignboardConditions(signboardConditions); + + Result> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po); + if (result == null || !result.isSuccess()) { + return reportData; + } + List datas = result.getData(); + if (datas == null || datas.isEmpty()) { + return reportData; + } + for (AnalyzeDataConditionVO vo : datas) { + List dataTaosVOs = vo.getList(); + for (AnalyseDataTaosVO vv : dataTaosVOs) { + if (vo.getSignage().equals(col)) { + ReportData data = new ReportData(); + data.setKeyStr(CommonUtil.getKeyBySaveTimeType(vv.getTs(), saveTimeType)); + String val = vv.getVal(); + data.setStcd(deviceCode); + data.setVal(val); + if (val != null && !"".equals(val)) { + data.setValue(Double.valueOf(vv.getVal())); + } else { + data.setValue(0.0); + } + data.setName(vo.getName()); + reportData.add(data); + } + } + } + return reportData; + } + + public List getSignages(String stcd) { + //查询列 + Result> result = + analyseDataSearchClient.getInstanceFieldByAnalyseCode(stcd, 1, ""); + if (result == null || !result.isSuccess()) { + return null; + } + + List analyzeInstanceFieldVOS = result.getData(); + return analyzeInstanceFieldVOS; + } + + int getDayInfo(String stcd, BigDecimal discharge) { + // 获取当前时间 + LocalDateTime now = LocalDateTime.now(); + // 获取昨天的日期 + LocalDateTime last = now.minusDays(1); + // 昨天的开始时间(00:00) 昨天的结束时间(00:00)yesterday: 2024-03-10 00:00:00 yesterday: 2024-03-11 00:00:00 + LocalDateTime startTime = last.withHour(0).withMinute(0).withSecond(0).withNano(0); + LocalDateTime endTime = last.plusDays(1).withHour(0).withMinute(0).withSecond(0).withNano(0); + // 昨日达标情况 达标率就是有没有达到核定下限流量 + // accessRules 取数规则:0=最早值、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值)6=最新值") + // SaveTimeType 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时) 3->、d(天) 4->、w(周) 5->、n(自然月)、6->y(自然年) + List> dataList = getData(stcd, 3, 3, 1, startTime, endTime); + log.info("昨日达标情况data: {}, 设备编码为:{}", dataList, stcd); + return getCount(dataList, discharge); + } + + + int getWeekInfo(String stcd, BigDecimal discharge) { + LocalDate today = LocalDate.now(); + // 获取上周的星期一(假设周一是周的开始) + LocalDate lastWeekMonday = today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)).minusWeeks(1); + // 上周的开始时间:上周星期一的00:00 + LocalDateTime startTime = LocalDateTime.of(lastWeekMonday, LocalTime.MIN); + LocalDateTime endTime = startTime.plusDays(7).withHour(0).withMinute(0).withSecond(0).withNano(0); + // 周达标情况 达标率就是有没有达到核定下限流量 + // accessRules 取数规则:0=最早值、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值)6=最新值") + // SaveTimeType 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时) 3->、d(天) 4->、w(周) 5->、n(自然月)、6->y(自然年) + List> dataList = getData(stcd, 3, 4, 1, startTime, endTime); + log.info("周达标情况data: {}, 设备编码为:{}", dataList, stcd); + return getCount(dataList, discharge); + } + + int getMouthInfo(String stcd, BigDecimal discharge) { + // 获取当前时间 + LocalDateTime now = LocalDateTime.now(); + // 获取上个月的开始日期 + LocalDateTime last = now.minusMonths(1); + // 上个月的开始时间(00:00) 上个月的结束时间(00:00) + LocalDateTime startTime = last.withHour(0).withDayOfMonth(1).withMinute(0).withSecond(0).withNano(0); + LocalDateTime endTime = last.plusMonths(1).withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0).withNano(0); + // 上月达标情况 达标率就是有没有达到核定下限流量 + // accessRules 取数规则:0=最早值、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值)6=最新值") + // SaveTimeType 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时) 3->、d(天) 4->、w(周) 5->、n(自然月)、6->y(自然年) + List> dataList = getData(stcd, 3, 5, 1, startTime, endTime); + log.info("月达标情况data: {}, 设备编码为:{}", dataList, stcd); + return getCount(dataList, discharge); + } + + int getQuarterInfo(String stcd, BigDecimal discharge) { + LocalDateTime now = LocalDateTime.now(); + LocalDateTime startTime = DateUtil.getStartOfLastQuarter(now); + LocalDateTime endTime = DateUtil.getEndOfLastQuarter(now); + // 周达标情况 达标率就是有没有达到核定下限流量 + // accessRules 取数规则:0=最早值、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值)6=最新值") + // SaveTimeType 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时) 3->、d(天) 4->、w(周) 5->、n(自然月)、6->y(自然年) + List> dataList = getData(stcd, 3, 5, 3, startTime, endTime); + log.info("季度达标情况data: {}, 设备编码为:{}", dataList, stcd); + return getCount(dataList, discharge); + } + + + int getHaltYearInfo(String stcd, BigDecimal discharge) { + LocalDateTime now = LocalDateTime.now(); + LocalDateTime startTime = DateUtil.getStartOfHalfYear(now); + LocalDateTime endTime = DateUtil.getEndOfHalfYear(now); + // 上月达标情况 达标率就是有没有达到核定下限流量 + // accessRules 取数规则:0=最早值、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值)6=最新值") + // SaveTimeType 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时) 3->、d(天) 4->、w(周) 5->、n(自然月)、6->y(自然年) + List> dataList = getData(stcd, 3, 5, 6, startTime, endTime); + log.info("半年达标情况data: {}, 设备编码为:{}", dataList, stcd); + return getCount(dataList, discharge); + } + + int getYearInfo(String stcd, BigDecimal discharge) { + LocalDateTime startTime = LocalDateTime.of(Year.now().getValue() - 1, Month.JANUARY, 1, 0, 0); + LocalDateTime endTime = LocalDateTime.of(Year.now().getValue(), Month.JANUARY, 1, 0, 0, 0); + // 上月达标情况 达标率就是有没有达到核定下限流量 + // accessRules 取数规则:0=最早值、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值)6=最新值") + // SaveTimeType 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时) 3->、d(天) 4->、w(周) 5->、n(自然月)、6->y(自然年) + + List> dataList = getData(stcd, 3, 6, 1, startTime, endTime); + log.info("去年达标情况data: {}, 设备编码为:{}", dataList, stcd); + return getCount(dataList, discharge); + } + + Map reportAndWarnToday(String stcd) { + // 获取当前时间 + LocalDateTime now = LocalDateTime.now(); + LocalDateTime startTime = now.withHour(0).withMinute(0).withSecond(0).withNano(0); + LocalDateTime endTime = now; + // accessRules 取数规则:0=最早值、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值)6=最新值") + // SaveTimeType 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时) 3->、d(天) 4->、w(周) 5->、n(自然月)、6->y(自然年) + List> dataList = getData(stcd, 3, 2, 1, startTime, endTime); + log.info("今天上报data: {}, 设备编码为:{}", dataList, stcd); + int count = 0; + if (!CollectionUtils.isEmpty(dataList)) { + for (Map info : dataList) { + String ecologicalFlowValue = null == info.get(signage) ? null : + info.get(signage).toString(); + log.info("ecologicalFlowValue的值: {}", ecologicalFlowValue); + if (StringUtils.isNotBlank(ecologicalFlowValue)) { + count++; + } + } + } + HashMap map = new HashMap<>(); + map.put("count", count); + FlowWarnQueryDTO dto = new FlowWarnQueryDTO(); + dto.setStartTime(DateUtil.getStringTime(startTime)); + dto.setEndTime(DateUtil.getStringTime(endTime)); + dto.setObjectCode(stcd); + List flowWarnList = ecologicalFlowMapper.getFlowWarnCount(dto); + if (CollectionUtils.isEmpty(flowWarnList)) { + map.put("warnCount", 0); + } else { + map.put("warnCount", flowWarnList.size()); + } + return map; + } + + + Map reportAndWarnYesTerday(String stcd) { + // 获取当前时间 + LocalDateTime now = LocalDateTime.now(); + // 获取昨天的日期 + LocalDateTime last = now.minusDays(1); + // 昨天的开始时间(00:00) 昨天的结束时间(00:00)yesterday: 2024-03-10 00:00:00 yesterday: 2024-03-11 00:00:00 + LocalDateTime startTime = last.withHour(0).withMinute(0).withSecond(0).withNano(0); + LocalDateTime endTime = last.plusDays(1).withHour(0).withMinute(0).withSecond(0).withNano(0); + // accessRules 取数规则:0=最早值、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值)6=最新值") + // SaveTimeType 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时) 3->、d(天) 4->、w(周) 5->、n(自然月)、6->y(自然年) + List> dataList = getData(stcd, 3, 2, 1, startTime, endTime); + log.info("昨天上报data: {}, 设备编码为:{}", dataList, stcd); + int count = 0; + if (!CollectionUtils.isEmpty(dataList)) { + for (Map info : dataList) { + String ecologicalFlowValue = null == info.get(signage) ? null : + info.get(signage).toString(); + log.info("ecologicalFlowValue的值: {}", ecologicalFlowValue); + if (StringUtils.isNotBlank(ecologicalFlowValue)) { + count++; + } + } + } + HashMap map = new HashMap<>(); + map.put("count", count); + FlowWarnQueryDTO dto = new FlowWarnQueryDTO(); + dto.setStartTime(DateUtil.getStringTime(startTime)); + dto.setEndTime(DateUtil.getStringTime(endTime)); + dto.setObjectCode(stcd); + Query query = new Query(); + query.setCurrent(1); + query.setSize(10000); + List flowWarnList = ecologicalFlowMapper.getFlowWarnList(dto, Condition.getPage(query)).getRecords(); + if (CollectionUtils.isEmpty(flowWarnList)) { + map.put("warnCount", 0); + } else { + map.put("warnCount", flowWarnList.size()); + } + return map; + } + + + + int getCount(List> dataList, BigDecimal discharge) { + int count = 0; + if (!CollectionUtils.isEmpty(dataList)) { + Map info = dataList.get(dataList.size() - 1); + String ecologicalFlowValue = null == info.get(signage) ? "0" : + info.get(signage).toString(); + log.info("ecologicalFlowValue的值: {}", ecologicalFlowValue); + if (new BigDecimal(ecologicalFlowValue).compareTo(discharge) >= 0) { + count++; + } + } + return count; + } + + + + + /** + * bulid info + * @param stationInfoList + * @param yesterdayFinishCountList + * @param weekCountList + * @param monthFinishCountList + * @param quarterCountList + * @param halfYearCountList + * @param yearCountList + * @param reportAndWarnTodayMapList + * @param reportAndWarnYesTerdayMapList + */ + void buildCompletableFutureList(List stationInfoList, + List> yesterdayFinishCountList , + List> weekCountList , + List> monthFinishCountList , + List> quarterCountList , + List> halfYearCountList , + List> yearCountList , + List>> reportAndWarnTodayMapList , + List>> reportAndWarnYesTerdayMapList ){ + for (int i = 0; i < stationInfoList.size(); i++) { + StationVo vo = stationInfoList.get(i); +// String stcd = "JSCZ001"; + // 设备编号 核定流量 + String stcd = vo.getDeviceCode(); + BigDecimal discharge = vo.getFlowValue(); + // 1.昨日达标情况 达标率就是有没有达到核定下限流量 + yesterdayFinishCountList.add(CompletableFuture.supplyAsync(() -> getDayInfo(stcd, discharge))); + // 2.上周达标情况 + weekCountList.add(CompletableFuture.supplyAsync(() -> getMouthInfo(stcd, discharge))); + // 3.上月达标情况 + monthFinishCountList.add(CompletableFuture.supplyAsync(() -> getWeekInfo(stcd, discharge))); + // 4.季度达标情况 + quarterCountList.add(CompletableFuture.supplyAsync(() -> getQuarterInfo(stcd, discharge))); + // 5.半年达标情况 + halfYearCountList.add(CompletableFuture.supplyAsync(() -> getHaltYearInfo(stcd, discharge))); + // 6.年达标情况 + yearCountList.add(CompletableFuture.supplyAsync(() -> getYearInfo(stcd, discharge))); + // 7.今日 预警数 上报率 + reportAndWarnTodayMapList.add(CompletableFuture.supplyAsync(() -> reportAndWarnToday(stcd))); + // 8.昨日 预警数 上报率 + reportAndWarnYesTerdayMapList.add(CompletableFuture.supplyAsync(() -> reportAndWarnYesTerday(stcd))); + } + } + + void buildRestultInfo(EcologicalFlowVo ecologicalFlowVo, Integer size, Integer yesterdayFinishCount, + Integer monthFinishCount, Integer weekCount, Integer quarterCount, Integer halfYearCount, + Integer yearCount, Integer reportTodayCount, Integer warnTodayCount, + Integer reportYesTerdayCount, Integer warnYesTerdayCount) { + // 昨日 + BigDecimal yesterdayFinishPer = BigDecimal.valueOf(yesterdayFinishCount).divide(BigDecimal.valueOf(size), 2, RoundingMode.HALF_UP); + ecologicalFlowVo.setYesterdayFinishPer(yesterdayFinishPer.multiply(BigDecimal.valueOf(100)) + "%"); + ecologicalFlowVo.setYesterdayFinishCount(yesterdayFinishCount); + // 上月 + BigDecimal monthFinishPer = BigDecimal.valueOf(monthFinishCount).divide(BigDecimal.valueOf(size), 2, RoundingMode.HALF_UP); + ecologicalFlowVo.setMonthFinishPer(monthFinishPer.multiply(BigDecimal.valueOf(100)) + "%"); + ecologicalFlowVo.setMonthFinishCount(monthFinishCount); + // 上周 + BigDecimal weekFinishPer = BigDecimal.valueOf(weekCount).divide(BigDecimal.valueOf(size), 2, RoundingMode.HALF_UP); + ecologicalFlowVo.setWeekFinishPer(weekFinishPer.multiply(BigDecimal.valueOf(100)) + "%"); + // 季度 + BigDecimal quarterFinishPer = BigDecimal.valueOf(quarterCount).divide(BigDecimal.valueOf(size), 2, RoundingMode.HALF_UP); + ecologicalFlowVo.setQuarterFinishPer(quarterFinishPer.multiply(BigDecimal.valueOf(100)) + "%"); + // 半年 + BigDecimal halfYearFinishPer = BigDecimal.valueOf(halfYearCount).divide(BigDecimal.valueOf(size), 2, RoundingMode.HALF_UP); + ecologicalFlowVo.setHalfYearFinishPer(halfYearFinishPer.multiply(BigDecimal.valueOf(100)) + "%"); + // 一年 + BigDecimal yearFinishPer = BigDecimal.valueOf(yearCount).divide(BigDecimal.valueOf(size), 2, RoundingMode.HALF_UP); + ecologicalFlowVo.setYearFinishPer(yearFinishPer.multiply(BigDecimal.valueOf(100)) + "%"); + // 今天预警数 上报率 + // 计算几天过了几个小时 + long hoursPassedToday = DateUtil.getHoursPassedToday() + 1; + BigDecimal reportTodayPre; + reportTodayPre = BigDecimal.valueOf(reportTodayCount).divide(BigDecimal.valueOf(hoursPassedToday * size), 2, RoundingMode.HALF_UP); + ecologicalFlowVo.setReportTodayPre(reportTodayPre.multiply(BigDecimal.valueOf(100)) + "%"); + ecologicalFlowVo.setWarnTodayCount(warnTodayCount); + // 昨天预警数 上报率 + BigDecimal reportYesTerdayPre = BigDecimal.valueOf(reportYesTerdayCount).divide(BigDecimal.valueOf(24L * size), 2, RoundingMode.HALF_UP); + ecologicalFlowVo.setReportYesTerdayPre(reportYesTerdayPre.multiply(BigDecimal.valueOf(100)) + "%"); + ecologicalFlowVo.setWarnYesTerdayCount(warnYesTerdayCount); + } + +} + + + + diff --git a/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/impl/ExamStationDataServiceImpl.java b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/impl/ExamStationDataServiceImpl.java new file mode 100644 index 0000000..9e012d1 --- /dev/null +++ b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/impl/ExamStationDataServiceImpl.java @@ -0,0 +1,274 @@ +package com.hnac.hzims.suichang.service.impl; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; +import com.hnac.hzims.suichang.mapper.EcologicalFlowMapper; +import com.hnac.hzims.suichang.service.EcologicalFlowService; +import com.hnac.hzims.suichang.service.ExamStationDataService; +import com.hnac.hzims.suichang.service.RealMonitorService; +import com.hnac.hzims.suichang.util.DateUtil; +import com.hnac.hzims.suichang.vo.*; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.net.URLEncoder; +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.stream.Collectors; + +/** + * @Author: liangfan + * @Date: 2024-03-14 16:19 + * @Description: + */ + +@Slf4j +@Service +public class ExamStationDataServiceImpl implements ExamStationDataService { + @Autowired + private EcologicalFlowMapper ecologicalFlowMapper; + + @Autowired + private EcologicalFlowService ecologicalFlowService; + + @Autowired + private RealMonitorService realMonitorService; + + @Value("${suichang.signage}") + String signage; + + @Value("${suichang.passPreValue}") + String passPreValue; + + @Value("${suichang.timeSignage}") + String timeSignage; + + @Override + public List examStationFlowReportByTime(ExamStationFlowDataReq req) { + StationQueryReq queryReq = new StationQueryReq(); + queryReq.setStationType(req.getStationType()); + queryReq.setName(req.getName()); + // 查询电站 + List list = ecologicalFlowMapper.getStationListByReq(queryReq); + List result = new ArrayList<>(); + // 根据电站查询日均流量 + for (StationVo stationRelationVo : list) { +// String stcd = "JSCZ001"; + String stcd = stationRelationVo.getDeviceCode(); + LocalDateTime startTime = DateUtil.getStartTime(req.getStartTime()); + LocalDateTime endTime = DateUtil.getEndTimeByDay(req.getEndTime()); + // accessRules 取数规则:0=最早值、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值)6=最新值") + // SaveTimeType 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时) 3->、d(天) 4->、w(周) 5->、n(自然月)、6->y(自然年) + List> dataList = ecologicalFlowService.getData(stcd, 3, 3, 1, startTime, endTime); + long days = ChronoUnit.DAYS.between(startTime, endTime); + log.info("dataList: {}, 设备编码为:{}, 天数:{}", dataList, stcd, days); + // 合格情况 + BigDecimal flowValue = stationRelationVo.getFlowValue(); + List infos = new ArrayList<>(); + int passCount = 0; + if (!CollectionUtils.isEmpty(dataList)) { + // 为了处理特殊返回情况 多查出一条数据的问题 + if (dataList.size() > days) { + dataList.remove(0); + } + for (Map info : dataList) { + ExamStationFlowReportDetailVo detailVo = new ExamStationFlowReportDetailVo(); + detailVo.setIsPass("不合格"); + String ecologicalFlowValue = null == info.get(signage) ? "0" : + info.get(signage).toString(); + log.info("ecologicalFlowValue的值: {}", ecologicalFlowValue); + if (new BigDecimal(ecologicalFlowValue).compareTo(flowValue) >= 0) { + passCount++; + detailVo.setIsPass("合格"); + } + detailVo.setFlowValue(flowValue); + detailVo.setEcologicalFlowValue(new BigDecimal(ecologicalFlowValue)); + detailVo.setTm(info.get(timeSignage).toString()); + infos.add(detailVo); + } + } + + ExamStationFlowReportVo examStationFlowReportVo = new ExamStationFlowReportVo(); + examStationFlowReportVo.setName(stationRelationVo.getName()); + examStationFlowReportVo.setAreaName("遂昌县"); + examStationFlowReportVo.setFlowValue(flowValue); + examStationFlowReportVo.setInfos(infos); + examStationFlowReportVo.setPassCount(passCount); + examStationFlowReportVo.setCount(days); + BigDecimal pre = BigDecimal.valueOf(passCount).divide(BigDecimal.valueOf(days), 2, RoundingMode.HALF_UP); + examStationFlowReportVo.setPassPre(pre.multiply(BigDecimal.valueOf(100)) + "%"); + String isPass = pre.compareTo(new BigDecimal(passPreValue)) >= 0 ? "合格" : "不合格"; + examStationFlowReportVo.setIsPass(isPass); + result.add(examStationFlowReportVo); + } + return result; + } + + @Override + public void exportExamStationFlowReportByTime(HttpServletResponse response, ExamStationFlowDataReq req) { + List examStationFlowReportVos = this.examStationFlowReportByTime(req); + // 动态生成的表头 + List firstHead = new ArrayList<>(Arrays.asList("电站名称", "所属区域", "核定流量")); + List endHead = new ArrayList<>(Arrays.asList("合格天数(天)", "考核天数(天)", "合格率", "是否合格")); + List allList = new ArrayList<>(); + allList.addAll(firstHead); + if (!CollectionUtils.isEmpty(examStationFlowReportVos)) { + ExamStationFlowReportVo examStationFlowReportVo = examStationFlowReportVos.get(0); + List infos = examStationFlowReportVo.getInfos(); + List mindHead = infos.stream().map(ExamStationFlowReportDetailVo::getTm).collect(Collectors.toList()); + allList.addAll(mindHead); + } + allList.addAll(endHead); + List> head = allList.stream().map(v -> { + List list = new ArrayList<>(); + list.add(v); + return list; + }).collect(Collectors.toList()); + + // 组合数据 + List> contentLists = new ArrayList<>(); + examStationFlowReportVos.forEach(o -> { + List list = new ArrayList<>(); + list.add(o.getName()); + list.add(o.getAreaName()); + list.add(o.getFlowValue().toString()); + List exVo = o.getInfos(); + exVo.forEach(k -> { + list.add(k.getIsPass()); + }); + list.add(o.getPassCount().toString()); + list.add(o.getCount().toString()); + list.add(o.getPassPre()); + list.add(o.getIsPass()); + contentLists.add(list); + }); + try { + //设置xlsx格式 + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("电站月考核" + ".xlsx", "UTF-8")); + + EasyExcel.write(response.getOutputStream()).autoCloseStream(Boolean.TRUE).head(head).autoTrim(true) + .sheet(1, "电站月考核").registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) + .doWrite(contentLists); + + response.getOutputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + @Override + public List examStationFlowReportOfDay(ExamStationFlowDataReq req) { + LocalDateTime startYesTodayTime = DateUtil.getStartTime(req.getStartTime()).minusDays(1); + LocalDateTime endYesTodayTime = DateUtil.getEndTimeByDay(req.getStartTime()).minusDays(1); + + LocalDateTime startTime = DateUtil.getStartTime(req.getStartTime()); + LocalDateTime endTime = DateUtil.getEndTimeByDay(req.getStartTime()); + + StationQueryReq queryReq = new StationQueryReq(); + queryReq.setStationType(req.getStationType()); + queryReq.setName(req.getName()); + // 查询电站 + List list = ecologicalFlowMapper.getStationListByReq(queryReq); + List result = new ArrayList<>(); + if (!CollectionUtils.isEmpty(list)) { + // 多线程优化 + List> yesTerDayAvgFlowValueList = new ArrayList<>(); + List> todayAvgFlowValueList = new ArrayList<>(); + List> realFlowValueList = new ArrayList<>(); + for (int i = 0; i < list.size(); i++) { + String stcd = list.get(i).getDeviceCode(); + yesTerDayAvgFlowValueList.add(CompletableFuture.supplyAsync(() -> getAvgOneDayData(stcd, startYesTodayTime, endYesTodayTime))); + todayAvgFlowValueList.add(CompletableFuture.supplyAsync(() -> getAvgOneDayData(stcd, startTime, endTime))); + realFlowValueList.add(CompletableFuture.supplyAsync(() -> realMonitorService.getRealData(stcd, signage))); + } + for (int i = 0; i < list.size(); i++) { + BigDecimal yesTerDayAvgFlowValue = null; + BigDecimal todayAvgFlowValue = null; + String realFlowValue = null; + try { + // 前日日均流量 + yesTerDayAvgFlowValue = yesTerDayAvgFlowValueList.get(i).get(); + // 当日日均流量 + todayAvgFlowValue = todayAvgFlowValueList.get(i).get(); + // 实时流量 + realFlowValue = realFlowValueList.get(i).get(); + } catch (Exception e) { + e.printStackTrace(); + } + result.add(buildVo(list.get(i), yesTerDayAvgFlowValue, realFlowValue, todayAvgFlowValue)); + } + } + return result; + } + + /** + * 计算单日日均流量 + * + * @param stcd + * @return + */ + BigDecimal getAvgOneDayData(String stcd, LocalDateTime startTime, LocalDateTime endTime) { + long days = ChronoUnit.DAYS.between(startTime, endTime); + // accessRules 取数规则:0=最早值、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值)6=最新值") + // SaveTimeType 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时) 3->、d(天) 4->、w(周) 5->、n(自然月)、6->y(自然年) + List> dataList = + ecologicalFlowService.getData(stcd, 3, 3, 1, startTime, endTime); + log.info("dataList: {}, 设备编码为:{}, 开始:{}, 结束 {}, 天数:{}", dataList, stcd, startTime, endTime, days); + if (!CollectionUtils.isEmpty(dataList)) { + // 为了处理特殊返回情况 多查出一条数据的问题 + if (dataList.size() > days) { + dataList.remove(0); + } + Map info = dataList.get(0); + String ecologicalFlowValue = null == info.get(signage) ? "0" : + info.get(signage).toString(); + log.info("ecologicalFlowValue的值: {}", ecologicalFlowValue); + return new BigDecimal(ecologicalFlowValue); + } + return BigDecimal.ZERO; + } + + /** + * build vo + * @param stationRelationVo + * @param yesTerDayAvgFlowValue + * @param realFlowValue + * @param todayAvgFlowValue + * @return + */ + ExamStationFlowReportDayVo buildVo(StationVo stationRelationVo, BigDecimal yesTerDayAvgFlowValue, String realFlowValue, BigDecimal todayAvgFlowValue) { + ExamStationFlowReportDayVo vo = new ExamStationFlowReportDayVo(); + vo.setName(stationRelationVo.getName()); + vo.setAreaName("遂昌县"); + vo.setFlowValue(stationRelationVo.getFlowValue()); + vo.setYesTerDayAvgFlowValue(yesTerDayAvgFlowValue); + vo.setRealFlowValue(new BigDecimal(realFlowValue)); + vo.setToDayAvgFlowValue(todayAvgFlowValue); + BigDecimal realOutFlow = todayAvgFlowValue.multiply(new BigDecimal(86400)); + BigDecimal outFlow = stationRelationVo.getFlowValue().multiply(new BigDecimal(86400)); + vo.setRealOutFlow(realOutFlow); + vo.setOutFlow(outFlow); + BigDecimal dayOutFlowPre = realOutFlow.divide(outFlow, 2, RoundingMode.HALF_UP); + String status = "未达标"; + if (dayOutFlowPre.compareTo(new BigDecimal(passPreValue)) >= 0) { + status = "达标"; + } + vo.setStatus(status); + vo.setDayOutFlowPre(dayOutFlowPre.multiply(new BigDecimal(100)) + "%"); + return vo; + } +} + diff --git a/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/impl/FlowWarnServiceImpl.java b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/impl/FlowWarnServiceImpl.java new file mode 100644 index 0000000..957d867 --- /dev/null +++ b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/impl/FlowWarnServiceImpl.java @@ -0,0 +1,75 @@ +package com.hnac.hzims.suichang.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.hnac.hzims.suichang.mapper.EcologicalFlowMapper; +import com.hnac.hzims.suichang.service.FlowWarnService; +import com.hnac.hzims.suichang.vo.FlowWarnQueryDTO; +import com.hnac.hzims.suichang.vo.FlowWarnVo; +import com.hnac.hzims.suichang.vo.StationQueryReq; +import com.hnac.hzims.suichang.vo.StationVo; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.utils.Func; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.stream.Collectors; + +@Slf4j +@Service +public class FlowWarnServiceImpl implements FlowWarnService { + + @Autowired + private EcologicalFlowMapper ecologicalFlowMapper; + + @Override + public IPage getFlowWarnList(FlowWarnQueryDTO dto, Query query) { + return ecologicalFlowMapper.getFlowWarnList(dto, Condition.getPage(query)); + } + + @Override + public Map> warningPush(FlowWarnQueryDTO dto) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + List stationList = ecologicalFlowMapper.getStationListByReq(new StationQueryReq()); + LocalDateTime startTime = LocalDateTime.parse(dto.getStartTime(), formatter); + LocalDateTime endTime = LocalDateTime.parse(dto.getEndTime(), formatter); + + List dayList = new ArrayList<>(); + while (!startTime.isAfter(endTime)) { + dayList.add(startTime); + startTime = startTime.plusDays(1); + } + Query query = new Query(); + query.setCurrent(1); + query.setSize(10000); + List list = ecologicalFlowMapper.getFlowWarnList(dto, Condition.getPage(query)).getRecords(); + + Map> stationMap = new HashMap<>(); + for (StationVo station : stationList) { + Map dayMap = new LinkedHashMap<>(); + List flowWarnVos = + list.stream().filter(var -> var.getObjectCode().equals(station.getDeviceCode())).collect(Collectors.toList()); + for (int i = 0; i < dayList.size() - 1; i++) { + int degree = 0; + for (FlowWarnVo flowWarnVo : flowWarnVos) { + LocalDateTime warningTime = + LocalDateTime.parse(flowWarnVo.getSendTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + if (Func.isEmpty(warningTime)) { + continue; + } + if (warningTime.isAfter(dayList.get(i)) && warningTime.isBefore(dayList.get(i + 1))) { + degree = degree + 1; + } + } + dayMap.put(dayList.get(i).format(formatter), degree); + } + stationMap.put(station.getDeviceCode(), dayMap); + } + return stationMap; + } +} diff --git a/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/impl/ImageAndVideoServiceImpl.java b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/impl/ImageAndVideoServiceImpl.java new file mode 100644 index 0000000..b20e69b --- /dev/null +++ b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/impl/ImageAndVideoServiceImpl.java @@ -0,0 +1,198 @@ +package com.hnac.hzims.suichang.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.hnac.hzims.suichang.mapper.EcologicalFlowMapper; +import com.hnac.hzims.suichang.mapper.ImageAndVideoMapper; +import com.hnac.hzims.suichang.service.ImageAndVideoService; +import com.hnac.hzims.suichang.util.DateUtil; +import com.hnac.hzims.suichang.vo.*; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Author: liangfan + * @Date: 2024-03-14 16:19 + * @Description: + */ + +@Slf4j +@Service +public class ImageAndVideoServiceImpl implements ImageAndVideoService { + + @Autowired + private EcologicalFlowMapper ecologicalFlowMapper; + + @Autowired + private ImageAndVideoMapper imageAndVideoMapper; + + @Override + public Page getMissingImagesInfo(ImageReq req, Query query) { + StationQueryReq stationQueryReq = new StationQueryReq(); + stationQueryReq.setName(req.getName()); + // 拿到电站列表 + IPage stationListByNamePage = + ecologicalFlowMapper.getStationListByNamePage(stationQueryReq, Condition.getPage(query)); + Page page = new Page<>(); + BeanUtils.copyProperties(stationListByNamePage, page); + List resultList = new ArrayList<>(); + DateTimeFormatter customFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LocalDateTime dateTime = LocalDateTime.parse(req.getStartTime(), customFormatter); + // 结合 LocalDate 和 LocalTime 创建 LocalDateTime 对象 + stationListByNamePage.getRecords().forEach(o -> { + MissingImagesRes res = new MissingImagesRes(); + res.setDeviceCode(o.getDeviceCode()); + res.setName(o.getName()); + res.setArea("遂昌县"); + res.setMonth(String.valueOf(dateTime.getMonthValue())); + resultList.add(res); + }); + page.setRecords(resultList); + return page; + } + + @Override + public Map> missingPush(ImageReq req) { + StationQueryReq stationQueryReq = new StationQueryReq(); + stationQueryReq.setName(req.getName()); + List stationList = ecologicalFlowMapper.getStationListByReq(stationQueryReq); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LocalDateTime startTime = LocalDateTime.parse(req.getStartTime(), formatter); + LocalDateTime endTime = LocalDateTime.parse(req.getEndTime(), formatter); + + List dayList = new ArrayList<>(); + while (!startTime.isAfter(endTime)) { + dayList.add(startTime); + startTime = startTime.plusDays(1); + } + + // 查询时间段内的所有照片数据 + Query query = new Query(); + query.setCurrent(1); + query.setSize(10000); + List imageInfoList = imageAndVideoMapper.getImageInfo(req, Condition.getPage(query)).getRecords(); + + Map> stationMap = new HashMap<>(); + for (StationVo station : stationList) { + Map dayMap = new LinkedHashMap<>(); + List infos = + imageInfoList.stream().filter(o -> o.getStcd().equals(station.getDeviceCode())).collect(Collectors.toList()); + for (int i = 0; i < dayList.size() - 1; i++) { + int degree = 0; + for (ImageVo info : infos) { + LocalDateTime warningTime = + LocalDateTime.parse(info.getTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + if (Func.isEmpty(warningTime)) { + continue; + } + if (!warningTime.isBefore(dayList.get(i)) && !warningTime.isAfter(dayList.get(i + 1))) { + degree = degree + 1; + } + } + dayMap.put(dayList.get(i).format(formatter), degree); + } + stationMap.put(station.getDeviceCode(), dayMap); + } + return stationMap; + } + + @Override + public IPage getImageInfoByDeviceCode(ImageReq req, Query query) { + // 根据deviceCode和时间段查询照片列表 + return imageAndVideoMapper.getImageInfo(req, Condition.getPage(query)); + } + + @Override + public List getImageInfoStatus(ImageReq req) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LocalDateTime startTime = LocalDateTime.parse(req.getStartTime(), formatter); + LocalDateTime endTime = LocalDateTime.parse(req.getEndTime(), formatter); + Query query = new Query(); + query.setCurrent(1); + query.setSize(10000); + List records = imageAndVideoMapper.getImageInfo(req, Condition.getPage(query)).getRecords(); + List hourList = new ArrayList<>(); + while (!startTime.isAfter(endTime)) { + hourList.add(startTime); + startTime = startTime.plusHours(1); + } + List resultList = new ArrayList<>(); + + for (int i = 0; i < hourList.size() - 1; i++) { + String stringTime = DateUtil.getStringTime(hourList.get(i)); + boolean notHasInfo = true; + for (ImageVo vo : records) { + LocalDateTime warningTime = + LocalDateTime.parse(vo.getTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + if (Func.isEmpty(warningTime)) { + continue; + } + if (warningTime.isAfter(hourList.get(i)) && warningTime.isBefore(hourList.get(i + 1))) { + vo.setTime(stringTime); + vo.setStatus("正常"); + resultList.add(vo); + notHasInfo = false; + } + + } + + if (notHasInfo) { + ImageVo imageVo = new ImageVo(); + imageVo.setTime(stringTime); + imageVo.setName("暂无图片详情"); + imageVo.setStatus("异常"); + resultList.add(imageVo); + } + + + } + // 筛选 + if (StringUtil.isNotBlank(req.getStatus())) { + resultList = resultList.stream().filter(o -> o.getStatus().equals(req.getStatus())).collect(Collectors.toList()); + } + return resultList; + } + + @Override + public IPage selectNewestImage(ImageReq req, Query query) { + return imageAndVideoMapper.selectNewestImage(req, Condition.getPage(query)); + } + + @Override + public List getStationVideoType(String videoType) { + // 查询所有站点 + List stationList = ecologicalFlowMapper.getStationListByReq(new StationQueryReq()); + // 根据类型查询所有视频点位 + List videoList = imageAndVideoMapper.selectStationTypeByOwerType(videoType); + // 组装数据 + List resultList = new ArrayList<>(); + for (StationVo stationVo : stationList) { + StationTreeRes stationTreeRes = new StationTreeRes(); + List child = videoList.stream().filter(o -> + o.getStationId().equals(stationVo.getDeviceCode()) + ).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(child)) { + continue; + } + stationTreeRes.setChild(child); + stationTreeRes.setCount(child.size()); + stationTreeRes.setStationVo(stationVo); + resultList.add(stationTreeRes); + } + return resultList; + } + +} + diff --git a/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/impl/RealMonitorServiceImpl.java b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/impl/RealMonitorServiceImpl.java new file mode 100644 index 0000000..8611716 --- /dev/null +++ b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/impl/RealMonitorServiceImpl.java @@ -0,0 +1,419 @@ +package com.hnac.hzims.suichang.service.impl; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; +import com.hnac.hzims.suichang.mapper.EcologicalFlowMapper; +import com.hnac.hzims.suichang.service.EcologicalFlowService; +import com.hnac.hzims.suichang.service.RealMonitorService; +import com.hnac.hzims.suichang.util.DateUtil; +import com.hnac.hzims.suichang.vo.*; +import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; +import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO; +import com.hnac.hzinfo.sdk.core.response.Result; +import com.hnac.hzinfo.sdk.real.RealDataSearchClient; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.net.URLEncoder; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Author: liangfan + * @Date: 2024-03-08 15:06 + * @Description: + */ +@Slf4j +@Service +public class RealMonitorServiceImpl implements RealMonitorService { + @Autowired + private EcologicalFlowService ecologicalFlowService; + + @Autowired + private EcologicalFlowMapper ecologicalFlowMapper; + + @Autowired + RealDataSearchClient realDataSearchClient; + + @Value("${suichang.signage}") + String signage; + + @Value("${suichang.timeSignage}") + String timeSignage; + + @Override + public List getAvgMonitorInfo() { + // 获取当前时间 + LocalDateTime now = LocalDateTime.now(); + // 昨天的开始时间(00:00) 昨天的结束时间(00:00)yesterday: 2024-03-12 00:00:00 yesterday: 2024-03-13 00:00:00 + LocalDateTime startTime = now.withHour(0).withMinute(0).withSecond(0).withNano(0); + LocalDateTime endTime = now.withMinute(0).withSecond(0).withNano(0); + int hours = (int)ChronoUnit.HOURS.between(startTime, endTime); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + String dateNow = now.format(formatter); + + List stationRelationList = ecologicalFlowMapper.getStationListByName(null); + + List resultList = new ArrayList<>(); + for (StationVo vo : stationRelationList) { + String stcd = vo.getDeviceCode(); + // accessRules 取数规则:0=最早值、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值)6=最新值") + // SaveTimeType 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时) 3->、d(天) 4->、w(周) 5->、n(自然月)、6->y(自然年) + List> dataList = ecologicalFlowService.getData( + stcd, 3, 2, hours, startTime, endTime); + String realFlowValue = getRealData(stcd, signage); + log.info("dataList: {}, 实时流量为:{},设备编码为:{}", dataList, realFlowValue, stcd); + Map info = new HashMap<>(); + if (!CollectionUtils.isEmpty(dataList)) { + // 为了处理特殊返回情况 多查出一条数据的问题 + if (dataList.size() > 1) { + dataList.remove(0); + } + info = dataList.get(0); + } + + AvgMonitorVo realMonitorVo = new AvgMonitorVo(); + BeanUtils.copyProperties(vo, realMonitorVo); + realMonitorVo.setRealFlow(realFlowValue); + String ecologicalFlowValue = null == info.get(signage) ? "0" : + info.get(signage).toString(); + log.info("info: {}, key:{}, 值:{}", info, signage, ecologicalFlowValue); + realMonitorVo.setAvgFlow(ecologicalFlowValue); + realMonitorVo.setDateNow(dateNow); + // 上报率 + List> reportList = ecologicalFlowService.getData( + stcd, 3, 2, 1, startTime, endTime); + int reportCount = 0; + if (!CollectionUtils.isEmpty(reportList)) { + // 为了处理特殊返回情况 多查出一条数据的问题 + if (reportList.size() > hours) { + reportList.remove(0); + } + for (Map map : reportList) { + if (null != map.get(signage)) { + reportCount++; + } + } + } + BigDecimal pre = BigDecimal.valueOf(reportCount).divide(BigDecimal.valueOf(hours), 2, RoundingMode.HALF_UP); + pre = pre.compareTo(BigDecimal.ONE) >= 1 ? BigDecimal.ONE : pre; + realMonitorVo.setPassPre(pre.multiply(new BigDecimal(100))+ "%"); + resultList.add(realMonitorVo); + } + return resultList; + } + + @Override + public List getAvgMonitorCountInfo(AvgMonitorReq req) { + // 昨日传2024-03-13 2024-03-13 时间段 2024-03-10 2024-03-13 + + String dateString = req.getStartTime() + " 00:00:00"; + String endString = req.getEndTime() + " 00:00:00"; + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LocalDateTime startTime = LocalDateTime.parse(dateString, formatter); + LocalDateTime endTime = LocalDateTime.parse(endString, formatter).plusDays(1); + + long days = ChronoUnit.DAYS.between(startTime, endTime); + log.info("开始结束时间: {}, {},相差天数:{}", startTime, endTime, days); + + List stationRelationList = ecologicalFlowMapper.getStationListByName(req.getName()); + + List resultList = new ArrayList<>(); + for (StationVo vo : stationRelationList) { +// String stcd = "JSCZ001"; + String stcd = vo.getDeviceCode(); + // accessRules 取数规则:0=最早值、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值)6=最新值") + // SaveTimeType 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时) 3->、d(天) 4->、w(周) 5->、n(自然月)、6->y(自然年) + List> dataList = ecologicalFlowService.getData( + stcd, 3, 3, 1, startTime, endTime); + log.info("dataList: {}, 设备编码为:{}", dataList, stcd); + if (!CollectionUtils.isEmpty(dataList)) { + int passCount = 0; + // 为了处理特殊返回情况 多查出一条数据的问题 + if (dataList.size() > days) { + dataList.remove(0); + } + List infos = new ArrayList<>(); + AvgMonitorCountVo realMonitorVo = new AvgMonitorCountVo(); + for (int j = 0 ; j < dataList.size(); j++) { + Map info = dataList.get(j); + log.info("info: {}, key:{}, 值:{}", info, signage, info.get(signage)); + String ecologicalFlowValue = null == info.get(signage) ? "0" : + info.get(signage).toString(); + if (vo.getFlowValue().compareTo(new BigDecimal(ecologicalFlowValue)) <= 0) { + passCount++; + } + RealMonitorSingleInfoVo realInfo = new RealMonitorSingleInfoVo(); + realInfo.setTm(info.get(timeSignage).toString()); + realInfo.setValue(ecologicalFlowValue); + infos.add(realInfo); + } + + realMonitorVo.setName(vo.getName()); + realMonitorVo.setFlowValue(vo.getFlowValue()); + realMonitorVo.setCount(days); + realMonitorVo.setPassCount(passCount); + BigDecimal pre = BigDecimal.valueOf(passCount).divide(BigDecimal.valueOf(days), 2, RoundingMode.HALF_UP); + + realMonitorVo.setPassPre(pre.multiply(BigDecimal.valueOf(100)) + "%"); + realMonitorVo.setInfos(infos); + resultList.add(realMonitorVo); + } + } + return resultList; + } + + + + + @Override + public RealMonitorRes getRealMonitorInfo(String name) { + // 创建一个 DateTimeFormatter 对象来指定输出格式 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + String dateNow = LocalDateTime.now().withMinute(0).withSecond(0).withNano(0).format(formatter); + // 查询所有站点 + List infos = ecologicalFlowMapper.getStationListByName(name); + // 查询每个站点的名称,核定流量,实时流量,上报个数 时间 + List resultList = new ArrayList<>(); + for (StationVo info : infos) { +// String stcd = "JSCZ001"; + String stcd = info.getDeviceCode(); + String stationName = info.getName(); + BigDecimal flowValue = info.getFlowValue(); + // 查询实时数据 + String realFlowValue = getRealData(stcd, signage); + // 查询历史条数(上报条数) + int historyDataCount = getHistoryDataCount(stcd); + RealMonitorVo realMonitorVo = new RealMonitorVo(); + realMonitorVo.setName(stationName); + realMonitorVo.setDeviceCode(stcd); + realMonitorVo.setFlowValue(flowValue); + realMonitorVo.setRealFlow(realFlowValue); + realMonitorVo.setReportCount(historyDataCount); + realMonitorVo.setDateNow(dateNow); + realMonitorVo.setAreaName("遂昌县"); + resultList.add(realMonitorVo); + } + // 应上报个数 + long hoursPassedToday = DateUtil.getHoursPassedToday() + 1; + RealMonitorRes realMonitorRes = new RealMonitorRes(); + realMonitorRes.setRealMonitorVos(resultList); + realMonitorRes.setReportCount(hoursPassedToday); + return realMonitorRes; + } + + @Override + public void exportRealMonitorInfo(HttpServletResponse response, String name) { + RealMonitorRes realMonitorInfo = this.getRealMonitorInfo(name); + List list = realMonitorInfo.getRealMonitorVos(); + List result = list.stream().map(o -> { + RealMonitorExportDTO dto = new RealMonitorExportDTO(); + BeanUtils.copyProperties(o, dto); + return dto; + }).collect(Collectors.toList()); + + // 下载导出 + String filename = "实时流量"; + // 设置头信息 + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/vnd.ms-excel"); + try { + //设置xlsx格式 + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".xlsx", "UTF-8")); + //创建一个输出流 + EasyExcel.write(response.getOutputStream(), RealMonitorExportDTO.class) + .autoCloseStream(Boolean.TRUE).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) + .sheet(1,"实时流量") + .doWrite(result); + response.getOutputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + @Override + public void exportRealMonitorSingleInfo(HttpServletResponse response, RealMonitorSingleInfoReq req) { + List realMonitorSingleInfos = getRealMonitorSingleInfo(req); + for (RealMonitorSingleInfoVo realMonitorSingleInfo : realMonitorSingleInfos) { + realMonitorSingleInfo.setTm(realMonitorSingleInfo.getTm() + ":00:00"); + } + // 下载导出 + String filename = "站点流量详情"; + // 设置头信息 + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/vnd.ms-excel"); + try { + //设置xlsx格式 + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".xlsx", "UTF-8")); + //创建一个输出流 + EasyExcel.write(response.getOutputStream(), RealMonitorSingleInfoVo.class) + .autoCloseStream(Boolean.TRUE) + .sheet(1,"站点流量详情").registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) + .doWrite(realMonitorSingleInfos); + response.getOutputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + + @Override + public List getRealMonitorSingleInfo(RealMonitorSingleInfoReq req) { + String stcd = req.getDeviceCode(); + LocalDateTime startTime = DateUtil.getStartTime(req.getStartTime()); + LocalDateTime endTime = DateUtil.getEndTime(req.getEndTime()); + log.info("开始时间结束时间: {}, {}", startTime, endTime); + // 昨日达标情况 达标率就是有没有达到核定下限流量 + // accessRules 取数规则:0=最早值、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值)6=最新值") + // SaveTimeType 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时) 3->、d(天) 4->、w(周) 5->、n(自然月)、6->y(自然年) + List> dataList = ecologicalFlowService.getData( + stcd, 3, 2, 1, startTime, endTime); + log.info("拿到getHistoryDataCount dataList: {}, 设备编码为:{}", dataList, stcd); + List resultList = new ArrayList<>(); + if (!CollectionUtils.isEmpty(dataList)) { + resultList = dataList.stream().map(info -> { + String value = null == info.get(signage) ? "0" : + info.get(signage).toString(); + + String time = null == info.get(timeSignage) ? "" : + info.get(timeSignage).toString() + ":00:00"; + RealMonitorSingleInfoVo vo = new RealMonitorSingleInfoVo(); + vo.setValue(value); + vo.setTm(time); + return vo; + }).collect(Collectors.toList()); + } + return resultList; + } + + @Override + public String getRealData(String stcd, String signage) { + RealDataSearchPO po = new RealDataSearchPO(); + po.setAnalyzeCode(stcd); + List signages = new ArrayList<>(); + signages.add(signage); + po.setSignages(signages); + Result> result = realDataSearchClient.getRealDataByDeviceCode(po); + log.info("result: {}, 设备编码为:{}", result, stcd); + if (result == null || !result.isSuccess()) { + return null; + } + String value = "0"; + List data = result.getData(); + if (!CollectionUtils.isEmpty(data)) { + value = data.get(0).getValue(); + } + return value; + } + + + @Override + public void exportAvgMonitorCountInfo(HttpServletResponse response, AvgMonitorReq req) { + List avgMonitorCountInfo = getAvgMonitorCountInfo(req); + // 动态生成的表头 + List firstHead = new ArrayList<>(Arrays.asList("电站名称", "核定流量")); + List endHead = new ArrayList<>(Arrays.asList("考核天数", "合格天数", "合格率")); + List allList = new ArrayList<>(); + allList.addAll(firstHead); + if (avgMonitorCountInfo.size() > 0) { + AvgMonitorCountVo avgMonitorCountVo = avgMonitorCountInfo.get(0); + List infos = avgMonitorCountVo.getInfos(); + List mindHead = infos.stream().map(RealMonitorSingleInfoVo::getTm).collect(Collectors.toList()); + allList.addAll(mindHead); + } + allList.addAll(endHead); + List> head = allList.stream().map(v -> { + List list = new ArrayList<>(); + list.add(v); + return list; + }).collect(Collectors.toList()); + // 组合数据 + List> contentLists = new ArrayList<>(); + avgMonitorCountInfo.forEach(o -> { + List list = new ArrayList<>(); + list.add(o.getName()); + list.add(o.getFlowValue().toString()); + List rsVo = o.getInfos(); + rsVo.forEach(k -> { + list.add(k.getValue()); + }); + list.add(o.getCount().toString()); + list.add(o.getPassCount().toString()); + list.add(o.getPassPre()); + contentLists.add(list); + }); + try { + //设置xlsx格式 + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("日均流量" + ".xlsx", "UTF-8")); + + EasyExcel.write(response.getOutputStream()).autoCloseStream(Boolean.TRUE).head(head) + .sheet(1,"日均流量").registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) + .doWrite(contentLists); + response.getOutputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + + int getHistoryDataCount(String stcd) { + // 获取当前时间 + LocalDateTime now = LocalDateTime.now(); + LocalDateTime startTime = now.withHour(0).withMinute(0).withSecond(0).withNano(0); + LocalDateTime endTime = now; + // 昨日达标情况 达标率就是有没有达到核定下限流量 + // accessRules 取数规则:0=最早值、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值)6=最新值") + // SaveTimeType 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时) 3->、d(天) 4->、w(周) 5->、n(自然月)、6->y(自然年) + List> dataList = ecologicalFlowService.getData( + stcd, 3, 2, 1, startTime, endTime); + log.info("拿到getHistoryDataCount dataList: {}, 设备编码为:{}", dataList, stcd); + int count = 0; + if (!CollectionUtils.isEmpty(dataList)) { + for (Map info : dataList) { + String ecologicalFlowValue = null == info.get(signage) ? null : + info.get(signage).toString(); + log.info("ecologicalFlowValue的值: {}", ecologicalFlowValue); + if (StringUtils.isNotBlank(ecologicalFlowValue)) { + count++; + } + } + } + return count; + } + + + @Override + public String getRealData(String stcd) { + RealDataSearchPO po = new RealDataSearchPO(); + po.setAnalyzeCode(stcd); + List signages = new ArrayList<>(); + signages.add(signage); + po.setSignages(signages); + Result> result = realDataSearchClient.getRealDataByDeviceCode(po); + log.info("result: {}, 设备编码为:{}", result, stcd); + if (result == null || !result.isSuccess()) { + return null; + } + String value = "0"; + List data = result.getData(); + if (!CollectionUtils.isEmpty(data)) { + value = data.get(0).getValue(); + } + return value; + } +} + diff --git a/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/impl/StatisticsDataServiceImpl.java b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/impl/StatisticsDataServiceImpl.java new file mode 100644 index 0000000..af54bf1 --- /dev/null +++ b/hzims-service/hzims-ecological/src/main/java/com/hnac/hzims/suichang/service/impl/StatisticsDataServiceImpl.java @@ -0,0 +1,172 @@ +package com.hnac.hzims.suichang.service.impl; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; +import com.hnac.hzims.suichang.mapper.EcologicalFlowMapper; +import com.hnac.hzims.suichang.service.EcologicalFlowService; +import com.hnac.hzims.suichang.service.StatisticsDataService; +import com.hnac.hzims.suichang.util.DateUtil; +import com.hnac.hzims.suichang.vo.StationVo; +import com.hnac.hzims.suichang.vo.StatisticsFlowDataDetailVo; +import com.hnac.hzims.suichang.vo.StatisticsFlowDataReq; +import com.hnac.hzims.suichang.vo.StatisticsFlowDataVo; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.net.URLEncoder; +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * @Author: liangfan + * @Date: 2024-03-14 16:19 + * @Description: + */ + +@Slf4j +@Service +public class StatisticsDataServiceImpl implements StatisticsDataService { + @Autowired + private EcologicalFlowMapper ecologicalFlowMapper; + + @Autowired + private EcologicalFlowService ecologicalFlowService; + + @Value("${suichang.signage}") + String signage; + + @Value("${suichang.passPreValue}") + String passPreValueInfo; + + @Override + public StatisticsFlowDataVo statisticsFlowReportByTime(StatisticsFlowDataReq req) { + // 查询所有站点 + List infos = ecologicalFlowMapper.getStationListByName(req.getName()); + // 电站信息 + List dataDetailVos = new ArrayList<>(); + // 构建detail 并返回达标数 + int stationPassCount = buildInfos(req, infos, dataDetailVos, passPreValueInfo); + // 总览信息 + StatisticsFlowDataVo result = new StatisticsFlowDataVo(); + result.setAreaName("遂昌县"); + result.setExamCount(infos.size()); + result.setPassCount(stationPassCount); + BigDecimal pre = BigDecimal.valueOf(stationPassCount).divide(BigDecimal.valueOf(infos.size()), 2, RoundingMode.HALF_UP); + result.setPassPre(pre.multiply(BigDecimal.valueOf(100)) + "%"); + result.setDetail(dataDetailVos); + return result; + } + + @Override + public void exportStatisticsFlowReportByTime(HttpServletResponse response, StatisticsFlowDataReq req) { + StatisticsFlowDataVo statisticsFlowDataVo = statisticsFlowReportByTime(req); + // 动态生成的表头 + String areaName = statisticsFlowDataVo.getAreaName(); + Integer examCount = statisticsFlowDataVo.getExamCount(); + Integer passCount = statisticsFlowDataVo.getPassCount(); + String passPre = statisticsFlowDataVo.getPassPre(); + + List firstHead = new ArrayList<>(Arrays.asList("区域名称:" + areaName, "考核电站数:" + examCount, + "达标电站数:" + passCount, "达标率(%):" + passPre, "安装流量计的电站数:" + examCount)); + List endHead = new ArrayList<>(Arrays.asList("电站名称", "核定生态流量", "考核天数", "合格天数", "合格率")); + // 构建表头 + List> head = new ArrayList<>(); + for (int i = 0; i < endHead.size(); i++) { + List list = new ArrayList<>(); + list.add(firstHead.get(i)); + list.add(endHead.get(i)); + head.add(list); + } + // 组合数据 + List> contentLists = new ArrayList<>(); + List detail = statisticsFlowDataVo.getDetail(); + detail.forEach(o -> { + List list = new ArrayList<>(); + list.add(o.getName()); + list.add(o.getFlowValue()); + list.add(o.getExamDays().toString()); + list.add(o.getExamPassDays().toString()); + list.add(o.getExamPassDayPre()); + contentLists.add(list); + }); + try { + //设置xlsx格式 + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("报表" + ".xlsx", "UTF-8")); + + EasyExcel.write(response.getOutputStream()).autoCloseStream(Boolean.TRUE).head(head).autoTrim(true) + .sheet(1, "报表").registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) + .doWrite(contentLists); + + response.getOutputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + int buildInfos(StatisticsFlowDataReq req, List infos, + List dataDetailVos, String passPreValue) { + int stationPassCount = 0; + for (StationVo stationRelationVo : infos) { +// String stcd = "JSCZ001"; + String stcd = stationRelationVo.getDeviceCode(); + BigDecimal flowValue = stationRelationVo.getFlowValue(); + LocalDateTime startTime = DateUtil.getStartTime(req.getStartTime()); + LocalDateTime endTime = DateUtil.getEndTimeByDay(req.getEndTime()); + int days = (int) ChronoUnit.DAYS.between(startTime, endTime); + + log.info("开始时间结束时间: {}, {},相差天数:{}", startTime, endTime, days); + // 查询单个站点一个时间段的日均数据 + // accessRules 取数规则:0=最早值、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值)6=最新值") + // SaveTimeType 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时) 3->、d(天) 4->、w(周) 5->、n(自然月)、6->y(自然年) + List> dataList = ecologicalFlowService.getData( + stcd, 3, 3, 1, startTime, endTime); + log.info("dataList: {}, 设备编码为:{}", dataList, stcd); + StatisticsFlowDataDetailVo detailVo = new StatisticsFlowDataDetailVo(); + if (!CollectionUtils.isEmpty(dataList)) { + int passCount = 0; + // 为了处理特殊返回情况 多查出一条数据的问题 跳过第一条 + if (dataList.size() > days) { + dataList.remove(0); + } + for (int j = 0; j < dataList.size(); j++) { + Map info = dataList.get(j); + log.info("info: {}, key:{}, 值:{}", info, signage, info.get(signage)); + String ecologicalFlowValue = null == info.get(signage) ? "0" : + info.get(signage).toString(); + if (flowValue.compareTo(new BigDecimal(ecologicalFlowValue)) <= 0) { + passCount++; + } + } + // 计算合格率 + BigDecimal singlePassPre = BigDecimal.valueOf(passCount).divide(BigDecimal.valueOf(days), 2, RoundingMode.HALF_UP); + if (new BigDecimal(passPreValue).compareTo(singlePassPre) <= 0) { + stationPassCount++; + } + detailVo.setExamPassDays(passCount); + detailVo.setExamPassDayPre(singlePassPre.multiply(BigDecimal.valueOf(100)) + "%"); + } + // 组装数据 + detailVo.setName(stationRelationVo.getName()); + if(ObjectUtil.isNotEmpty(stationRelationVo.getFlowValue())){ + detailVo.setFlowValue(stationRelationVo.getFlowValue().toString()); + } + detailVo.setExamDays(days); + dataDetailVos.add(detailVo); + + } + return stationPassCount; + } +} +