From 56333a62273516214697f78e0f1202c728c73da0 Mon Sep 17 00:00:00 2001 From: yangzhe123 <2824096059@qq.com> Date: Fri, 19 Dec 2025 10:55:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E5=BE=88=E5=A4=9A?= =?UTF-8?q?=E5=BE=88=E5=A4=9ABUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hsz/common/mapper/StRiverRMapper.java | 3 +- .../hsz/common/mapper/StRsvrRMapper.java | 18 +- .../project/hsz/common/model/StRiverR.java | 9 + .../hsz/controller/AttCctvBaseController.java | 4 +- .../CurrentFormAnalysisController.java | 37 +++ .../hsz/controller/StFlowRController.java | 13 + .../controller/StWaterRRealController.java | 10 +- .../hsz/entity/so/RainfallAnalysisSo.java | 26 ++ .../project/hsz/entity/so/RealRainBaseSo.java | 25 ++ .../project/hsz/entity/vo/AiWarningVo.java | 28 +++ .../project/hsz/entity/vo/HomeWarnVo.java | 29 +-- .../project/hsz/entity/vo/OsmoticWarnVo.java | 6 + .../hsz/entity/vo/RainfallAnalysisVo.java | 29 +++ .../hsz/entity/vo/RealRainStatListVo.java | 44 ++++ .../project/hsz/entity/vo/RiverWarningVo.java | 28 +++ .../project/hsz/entity/vo/SKWarningVo.java | 31 +++ .../project/hsz/entity/vo/StStatusListVo.java | 29 ++- .../project/hsz/entity/vo/StStatusVo.java | 3 + .../project/hsz/mapper/AttResBaseMapper.java | 19 ++ .../project/hsz/mapper/RealRainMapper.java | 4 + .../gunshi/project/hsz/model/AttBasBase.java | 148 ++++++++++++ .../hsz/model/ForecastDispatchPlan.java | 11 + .../hsz/model/ForecastDispatchResult.java | 15 ++ .../hsz/schedule/TaskGroupHandler.java | 2 + .../service/CurrentFormAnalysisService.java | 106 ++++++++ .../hsz/service/DispatchRecordService.java | 21 ++ .../service/ForecastDispatchPlanService.java | 21 +- .../hsz/service/GateValveRealService.java | 2 +- .../project/hsz/service/RealRainService.java | 148 +++++++++++- .../project/hsz/service/ResBriefRService.java | 2 + .../hsz/service/ReservoirWaterService.java | 1 + .../project/hsz/service/StQxWarnRService.java | 226 +++++++++++------- .../project/hsz/service/StWaterRService.java | 4 + .../project/hsz/timetask/AlarmTask.java | 13 +- src/main/resources/mapper/RealRainMapper.xml | 147 ++++++++++++ 35 files changed, 1130 insertions(+), 132 deletions(-) create mode 100644 src/main/java/com/gunshi/project/hsz/controller/CurrentFormAnalysisController.java create mode 100644 src/main/java/com/gunshi/project/hsz/controller/StFlowRController.java create mode 100644 src/main/java/com/gunshi/project/hsz/entity/so/RainfallAnalysisSo.java create mode 100644 src/main/java/com/gunshi/project/hsz/entity/vo/AiWarningVo.java create mode 100644 src/main/java/com/gunshi/project/hsz/entity/vo/RainfallAnalysisVo.java create mode 100644 src/main/java/com/gunshi/project/hsz/entity/vo/RealRainStatListVo.java create mode 100644 src/main/java/com/gunshi/project/hsz/entity/vo/RiverWarningVo.java create mode 100644 src/main/java/com/gunshi/project/hsz/entity/vo/SKWarningVo.java create mode 100644 src/main/java/com/gunshi/project/hsz/model/AttBasBase.java create mode 100644 src/main/java/com/gunshi/project/hsz/service/CurrentFormAnalysisService.java create mode 100644 src/main/resources/mapper/RealRainMapper.xml diff --git a/module-common/src/main/java/com/gunshi/project/hsz/common/mapper/StRiverRMapper.java b/module-common/src/main/java/com/gunshi/project/hsz/common/mapper/StRiverRMapper.java index 6a4ace9..3e619a3 100644 --- a/module-common/src/main/java/com/gunshi/project/hsz/common/mapper/StRiverRMapper.java +++ b/module-common/src/main/java/com/gunshi/project/hsz/common/mapper/StRiverRMapper.java @@ -18,7 +18,8 @@ public interface StRiverRMapper extends BaseMapper { @Select(""" """) List querySttpList(); + + + List getRealRainStatList(@Param("adcd") String adcd, @Param("basCode") String basCode, @Param("source") String source, @Param("stm") String stm, @Param("etm") String etm); } diff --git a/src/main/java/com/gunshi/project/hsz/model/AttBasBase.java b/src/main/java/com/gunshi/project/hsz/model/AttBasBase.java new file mode 100644 index 0000000..2a43af2 --- /dev/null +++ b/src/main/java/com/gunshi/project/hsz/model/AttBasBase.java @@ -0,0 +1,148 @@ +package com.gunshi.project.hsz.model; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Size; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 流域基础信息表 + */ +@Schema(description="流域基础信息表") +@Data +@TableName(value = "public.att_bas_base") +public class AttBasBase implements Serializable { + /** + * 流域代码 + */ + @TableId(value = "bas_code", type = IdType.INPUT) + @Schema(description="流域代码") + @Size(max = 18,message = "流域代码最大长度要小于 18") + @NotBlank(message = "流域代码不能为空") + private String basCode; + + /** + * 流域名称 + */ + @TableField(value = "bas_name") + @Schema(description="流域名称") + @Size(max = 100,message = "流域名称最大长度要小于 100") + private String basName; + + /** + * 左下角经度 + */ + @TableField(value = "low_left_long") + @Schema(description="左下角经度") + private BigDecimal lowLeftLong; + + /** + * 左下角纬度 + */ + @TableField(value = "low_left_lat") + @Schema(description="左下角纬度") + private BigDecimal lowLeftLat; + + /** + * 右上角经度 + */ + @TableField(value = "up_right_long") + @Schema(description="右上角经度") + private BigDecimal upRightLong; + + /** + * 右上角纬度 + */ + @TableField(value = "up_right_lat") + @Schema(description="右上角纬度") + private BigDecimal upRightLat; + + /** + * 跨界类型 未知 0 跨国并跨省 1 跨国 2 跨省 3 跨市 4 跨县 5 县界内 6 + */ + @TableField(value = "cr_over_type") + @Schema(description="跨界类型 未知 0 跨国并跨省 1 跨国 2 跨省 3 跨市 4 跨县 5 县界内 6") + @Size(max = 1,message = "跨界类型 未知 0 跨国并跨省 1 跨国 2 跨省 3 跨市 4 跨县 5 县界内 6最大长度要小于 1") + private String crOverType; + + /** + * 流域所属行政区 填名称 + */ + @TableField(value = "bas_ad_name") + @Schema(description="流域所属行政区 填名称") + @Size(max = 100,message = "流域所属行政区 填名称最大长度要小于 100") + private String basAdName; + + /** + * 流域级别 一级流域 1 二级流域 2 三级流域 3 四级流域 4 五级流域 5 六级流域 6 七级流域 7 + */ + @TableField(value = "bas_grad") + @Schema(description="流域级别 一级流域 1 二级流域 2 三级流域 3 四级流域 4 五级流域 5 六级流域 6 七级流域 7") + @Size(max = 1,message = "流域级别 一级流域 1 二级流域 2 三级流域 3 四级流域 4 五级流域 5 六级流域 6 七级流域 7最大长度要小于 1") + private String basGrad; + + /** + * 流域面积 km2 + */ + @TableField(value = "bas_area") + @Schema(description="流域面积 km2") + private BigDecimal basArea; + + /** + * 备注 + */ + @TableField(value = "note") + @Schema(description="备注") + @Size(max = 256,message = "备注最大长度要小于 256") + private String note; + + /** + * 记录生效时间 + */ + @TableField(value = "eff_date") + @Schema(description="记录生效时间") + private Date effDate; + + /** + * 记录失效时间 + */ + @TableField(value = "expr_date") + @Schema(description="记录失效时间") + private Date exprDate; + + private static final long serialVersionUID = 1L; + + public static final String COL_BAS_CODE = "bas_code"; + + public static final String COL_BAS_NAME = "bas_name"; + + public static final String COL_LOW_LEFT_LONG = "low_left_long"; + + public static final String COL_LOW_LEFT_LAT = "low_left_lat"; + + public static final String COL_UP_RIGHT_LONG = "up_right_long"; + + public static final String COL_UP_RIGHT_LAT = "up_right_lat"; + + public static final String COL_CR_OVER_TYPE = "cr_over_type"; + + public static final String COL_BAS_AD_NAME = "bas_ad_name"; + + public static final String COL_BAS_GRAD = "bas_grad"; + + public static final String COL_BAS_AREA = "bas_area"; + + public static final String COL_NOTE = "note"; + + public static final String COL_EFF_DATE = "eff_date"; + + public static final String COL_EXPR_DATE = "expr_date"; +} \ No newline at end of file diff --git a/src/main/java/com/gunshi/project/hsz/model/ForecastDispatchPlan.java b/src/main/java/com/gunshi/project/hsz/model/ForecastDispatchPlan.java index d490607..5d800ab 100644 --- a/src/main/java/com/gunshi/project/hsz/model/ForecastDispatchPlan.java +++ b/src/main/java/com/gunshi/project/hsz/model/ForecastDispatchPlan.java @@ -58,6 +58,17 @@ public class ForecastDispatchPlan implements Serializable { @NotNull(message = "方案名称不能为空") private String forecastPlanName; + /** + * 调度规程id + */ + @TableField(value = "res_plan_b_id") + @Schema(description = "调度规程id") + @JsonSerialize(using = ToStringSerializer.class) + private Long resPlanBId; + + @TableField(exist = false) + private String resPlanBName; + /** * 开始时间 */ diff --git a/src/main/java/com/gunshi/project/hsz/model/ForecastDispatchResult.java b/src/main/java/com/gunshi/project/hsz/model/ForecastDispatchResult.java index 9e7425f..f4a1a02 100644 --- a/src/main/java/com/gunshi/project/hsz/model/ForecastDispatchResult.java +++ b/src/main/java/com/gunshi/project/hsz/model/ForecastDispatchResult.java @@ -11,6 +11,7 @@ import com.gunshi.project.hsz.common.validate.markers.Update; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; import lombok.Data; +import org.bouncycastle.cert.dane.DANEEntry; import java.io.Serializable; import java.time.LocalDateTime; @@ -47,6 +48,8 @@ public class ForecastDispatchResult implements Serializable { @JsonSerialize(using = ToStringSerializer.class) private Long planId; + + /** * 最大入库流量(m³/s) */ @@ -55,6 +58,13 @@ public class ForecastDispatchResult implements Serializable { @NotNull(message = "最大入库流量不能为空") private java.math.BigDecimal maxInflow; + @TableField(value = "max_inflow_date") + @Schema(description = "最大入库流量时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime maxInflowDate; + + + /** * 总入库水量(万m³) */ @@ -76,6 +86,11 @@ public class ForecastDispatchResult implements Serializable { @Schema(description = "最高库水位(m)") private java.math.BigDecimal maxReservoirLevel; + @TableField(value = "max_reservoir_level_date") + @Schema(description = "最高库水位时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime maxReservoirLevelDate; + /** * 超汛限水位值(m) */ diff --git a/src/main/java/com/gunshi/project/hsz/schedule/TaskGroupHandler.java b/src/main/java/com/gunshi/project/hsz/schedule/TaskGroupHandler.java index 1e4f14c..3c188dc 100644 --- a/src/main/java/com/gunshi/project/hsz/schedule/TaskGroupHandler.java +++ b/src/main/java/com/gunshi/project/hsz/schedule/TaskGroupHandler.java @@ -51,6 +51,8 @@ public class TaskGroupHandler { // 小于1,就是0.5小时,转为分钟 if(forecastTask.getTimeInterval().compareTo(BigDecimal.ONE) < 0){ cronExpression = "0 0/" + Integer.valueOf(forecastTask.getTimeInterval().multiply(new BigDecimal(60)).setScale(0).toString()) + " * * * ?"; + }else if(forecastTask.getTimeInterval().compareTo(new BigDecimal(24)) == 0){ + cronExpression = "0 0 0 * * ?"; // 每天0点执行 } else { cronExpression = "0 0 */" + Integer.valueOf(forecastTask.getTimeInterval().setScale(0).toString()) + " * * ?"; } diff --git a/src/main/java/com/gunshi/project/hsz/service/CurrentFormAnalysisService.java b/src/main/java/com/gunshi/project/hsz/service/CurrentFormAnalysisService.java new file mode 100644 index 0000000..f4490a8 --- /dev/null +++ b/src/main/java/com/gunshi/project/hsz/service/CurrentFormAnalysisService.java @@ -0,0 +1,106 @@ +package com.gunshi.project.hsz.service; + +import cn.hutool.core.bean.BeanUtil; +import com.gunshi.project.hsz.entity.so.RainfallAnalysisSo; +import com.gunshi.project.hsz.entity.so.RealRainBaseSo; +import com.gunshi.project.hsz.entity.vo.RainfallAnalysisVo; +import com.gunshi.project.hsz.entity.vo.RealRainListVo; +import com.gunshi.project.hsz.entity.vo.RealRainStatListVo; +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.compress.utils.Lists; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; + +/** + * TODO + * + * @ClassName CurrentFormAnalysisService + * @Author Huang Qianxiang + * @Date 2024/3/12 16:19 + */ +@Service +@Slf4j +public class CurrentFormAnalysisService { + @Resource + private RealRainService realRainService; + + + /** + * 当前形势分析-降雨分析 + * @param rainfallAnalysisSo + * @return + */ + public Map> rainfallAnalysis(RainfallAnalysisSo rainfallAnalysisSo){ + + Date etm = new Date(); + Date stm = new Date(etm.getTime() - rainfallAnalysisSo.getTimeType() * 60 * 60*1000); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String etmStr = df.format(etm); + String stmStr = df.format(stm); + + RealRainBaseSo realRainBaseSo = new RealRainBaseSo(); + realRainBaseSo.setStm(stmStr); + realRainBaseSo.setEtm(etmStr); + realRainBaseSo.setSource(rainfallAnalysisSo.getSource()); + realRainBaseSo.setTimeType(rainfallAnalysisSo.getTimeType()); + + List realRainList = realRainService.getRealRainList(realRainBaseSo); + + realRainList = realRainList.stream().filter(t -> Objects.nonNull(t.getRainTag())).collect(Collectors.toList()); + + List analysisVos = new ArrayList<>(); + for (RealRainListVo realRainListVo : realRainList) { + RainfallAnalysisVo rainfallAnalysisVo = new RainfallAnalysisVo(); + BeanUtil.copyProperties(realRainListVo,rainfallAnalysisVo); + // 4 + if (realRainListVo.getRainTag() >= 4){ + rainfallAnalysisVo.setLevel(realRainListVo.getRainTag()-4); + analysisVos.add(rainfallAnalysisVo); + } + } + + Map> map = realRainService.getRealRainStatLevel(realRainBaseSo); + + List realRainStatListVos = new ArrayList<>(); + if (map.get(4) != null){ + realRainStatListVos.addAll(map.get(4)); + } + if (map.get(5) != null){ + realRainStatListVos.addAll(map.get(5)); + } + + for (RealRainStatListVo realRainStatListVo : realRainStatListVos) { + RainfallAnalysisVo rainfallAnalysisVo = new RainfallAnalysisVo(); + BeanUtil.copyProperties(realRainStatListVo,rainfallAnalysisVo); + if (rainfallAnalysisSo.getTimeType() == 3) { + rainfallAnalysisVo.setLevel(realRainStatListVo.getFreqH3()); + } else if (rainfallAnalysisSo.getTimeType() == 6) { + rainfallAnalysisVo.setLevel(realRainStatListVo.getFreqH6()); + } else if (rainfallAnalysisSo.getTimeType() == 12) { + rainfallAnalysisVo.setLevel(realRainStatListVo.getFreqH12()); + } else if (rainfallAnalysisSo.getTimeType() == 24) { + rainfallAnalysisVo.setLevel(realRainStatListVo.getFreqH24()); + } else { + rainfallAnalysisVo.setLevel(realRainStatListVo.getFreqH1()); + } + analysisVos.add(rainfallAnalysisVo); + } + + Map> map1 = analysisVos.stream().collect( + Collectors.groupingBy(RainfallAnalysisVo::getLevel, Collectors.toList()) + ); + + for (int i = 0; i <= 4; i++) { + if (map1.get(i) == null){ + map1.put(i, Lists.newArrayList()); + } + } + return map1; + } + + +} diff --git a/src/main/java/com/gunshi/project/hsz/service/DispatchRecordService.java b/src/main/java/com/gunshi/project/hsz/service/DispatchRecordService.java index 3130370..cc6cccc 100644 --- a/src/main/java/com/gunshi/project/hsz/service/DispatchRecordService.java +++ b/src/main/java/com/gunshi/project/hsz/service/DispatchRecordService.java @@ -12,6 +12,8 @@ import com.gunshi.project.hsz.mapper.DispatchRecordMapper; import com.gunshi.project.hsz.model.DispatchRecord; import com.gunshi.project.hsz.util.ExcelUtil; import com.gunshi.project.hsz.util.MyBeanUtil; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.system.mapper.SysUserMapper; import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -36,10 +38,21 @@ public class DispatchRecordService extends ServiceImpl pageQuery(DispatchRecordPageSo page) { Page res = this.page(page.getPageSo().toPage(), commonWrapper(page)); if (res.getRecords() != null) { fillAttach(res.getRecords()); + for (DispatchRecord record : res.getRecords()) { + if(record.getOpUserId() != null){ + SysUser sysUser = sysUserMapper.selectUserById(record.getOpUserId()); + if(sysUser != null){ + record.setOpUserName(sysUser.getNickName()); + } + } + } } return res; } @@ -70,6 +83,14 @@ public class DispatchRecordService extends ServiceImpl list = this.list(commonWrapper(page)); + for (DispatchRecord record : list) { + if(record.getOpUserId() != null){ + SysUser sysUser = sysUserMapper.selectUserById(record.getOpUserId()); + if(sysUser != null){ + record.setOpUserName(sysUser.getNickName()); + } + } + } List dispatchRecordVos = MyBeanUtil.collectionCopy(list, DispatchRecordVo.class); ExcelUtil.exportExcel(dispatchRecordVos,"调度指令", DispatchRecordVo.class,response,"调度指令"); } diff --git a/src/main/java/com/gunshi/project/hsz/service/ForecastDispatchPlanService.java b/src/main/java/com/gunshi/project/hsz/service/ForecastDispatchPlanService.java index d77988c..9881577 100644 --- a/src/main/java/com/gunshi/project/hsz/service/ForecastDispatchPlanService.java +++ b/src/main/java/com/gunshi/project/hsz/service/ForecastDispatchPlanService.java @@ -9,6 +9,7 @@ import com.gunshi.project.hsz.mapper.ForecastDispatchPlanMapper; import com.gunshi.project.hsz.model.ForecastDispatchCommand; import com.gunshi.project.hsz.model.ForecastDispatchPlan; import com.gunshi.project.hsz.model.ForecastDispatchResult; +import com.gunshi.project.hsz.model.ResPlanB; import com.ruoyi.common.utils.StringUtils; import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; @@ -48,6 +49,9 @@ public class ForecastDispatchPlanService extends ServiceImpl pageDetail(ForecastDispatchPlanPageSo pageSo) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); if(!StringUtils.isBlank(pageSo.getPlanName())){ @@ -60,7 +64,14 @@ public class ForecastDispatchPlanService extends ServiceImpl> getRealRainStatLevel(RealRainBaseSo realRainBaseSo) { + + Map> map = new HashMap<>(); + for (int i = 1; i <= 5; i++) { + if (map.get(i) == null) { + map.put(i, Lists.newArrayList()); + } + } + + + if (realRainBaseSo.getSource().size() == 0) { + return map; + } + + List result = getRealRainStat(realRainBaseSo); + //判断result是否为空 + if (CollectionUtils.isEmpty(result)) { + return map; + } + + //按照降雨量级进行分组 + if (realRainBaseSo.getTimeType() == null) { + result = result.stream().filter(res -> res.getFreqH1() != 0).collect(Collectors.toList()); + map = result.stream().collect( + Collectors.groupingBy(RealRainStatListVo::getFreqH1, Collectors.toList()) + ); + } + if (realRainBaseSo.getTimeType() == 3) { + result = result.stream().filter(res -> res.getFreqH3() != 0).collect(Collectors.toList()); + map = result.stream().collect( + Collectors.groupingBy(RealRainStatListVo::getFreqH3, Collectors.toList()) + ); + } else if (realRainBaseSo.getTimeType() == 6) { + result = result.stream().filter(res -> res.getFreqH6() != 0).collect(Collectors.toList()); + map = result.stream().collect( + Collectors.groupingBy(RealRainStatListVo::getFreqH6, Collectors.toList()) + ); + } else if (realRainBaseSo.getTimeType() == 12) { + result = result.stream().filter(res -> res.getFreqH12() != 0).collect(Collectors.toList()); + map = result.stream().collect( + Collectors.groupingBy(RealRainStatListVo::getFreqH12, Collectors.toList()) + ); + } else if (realRainBaseSo.getTimeType() == 24) { + result = result.stream().filter(res -> res.getFreqH24() != 0).collect(Collectors.toList()); + map = result.stream().collect( + Collectors.groupingBy(RealRainStatListVo::getFreqH24, Collectors.toList()) + ); + } else { + result = result.stream().filter(res -> res.getFreqH1() != 0).collect(Collectors.toList()); + map = result.stream().collect( + Collectors.groupingBy(RealRainStatListVo::getFreqH1, Collectors.toList()) + ); + } + + for (int i = 1; i <= 5; i++) { + if (!map.containsKey(i)) { + map.put(i, Lists.newArrayList()); + } + } + + for (int i = 1; i <= 5; i++) { + if (map.get(i) == null) { + map.put(i, Lists.newArrayList()); + } + } + + return map; + + } + + /** + * 频率分析 + * + * @param realRainBaseSo + */ + public List getRealRainStat(RealRainBaseSo realRainBaseSo) { + List result = Lists.newArrayList(); + + if (realRainBaseSo.getSource().size() == 0) { + return result; + } + + checkParam(realRainBaseSo); + List source = realRainBaseSo.getSource(); + ExecutorService executorService = Executors.newFixedThreadPool(4); + for (String sourceStr : source) { + executorService.execute(() -> { + List realRainList = realRainMapper.getRealRainStatList( + realRainBaseSo.getAdcd(), realRainBaseSo.getBasCode(), sourceStr, + realRainBaseSo.getStm(), realRainBaseSo.getEtm() + ); + result.addAll(realRainList); + }); + } + executorService.shutdown(); + try { + executorService.awaitTermination(2, TimeUnit.MINUTES); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + log.error(e.getMessage(), e); + } + return result; + } + + /** + * 流域选择列表 + * + * @param + */ + public List queryBasNameList() { + return attBasBaseAutoDao.list(); + } + + + private void checkParam(RealRainBaseSo realRainBaseSo) { + if (Objects.nonNull(realRainBaseSo.getQueryType()) && realRainBaseSo.getQueryType() == 2 && realRainBaseSo.getTimeType() == null) { + throw new IllegalArgumentException("频率统计中时间段范围类型不能为空"); + } + //检查source是否为空 + if (realRainBaseSo.getSource() == null || realRainBaseSo.getSource().isEmpty()) { + throw new IllegalArgumentException("来源不能为空"); + } + //检查source字段是否合法 + for (String source : realRainBaseSo.getSource()) { + if (!"SH".equals(source) && !"SW".equals(source) && !"SK".equals(source) && !"QX".equals(source)) { + throw new IllegalArgumentException("来源只能是SH SW SK QX这4种"); + } + } + } } diff --git a/src/main/java/com/gunshi/project/hsz/service/ResBriefRService.java b/src/main/java/com/gunshi/project/hsz/service/ResBriefRService.java index 9517983..8ee40f8 100644 --- a/src/main/java/com/gunshi/project/hsz/service/ResBriefRService.java +++ b/src/main/java/com/gunshi/project/hsz/service/ResBriefRService.java @@ -77,6 +77,7 @@ public class ResBriefRService extends com.gunshi.project.hsz.model.ResBriefRAuto vo.setFlLowLimLev(flLowLimLev); ResBriefVo.PptnVo pptnDrp24Sum = pptnVos.stream() + .filter(o -> o.getDrp24Sum() != null) .max(Comparator.comparing( ResBriefVo.PptnVo::getDrp24Sum, Comparator.nullsLast(Comparator.naturalOrder()) // null 值排在最后 @@ -85,6 +86,7 @@ public class ResBriefRService extends com.gunshi.project.hsz.model.ResBriefRAuto vo.setDrp24Sum(pptnDrp24Sum != null ? pptnDrp24Sum.getDrp24Sum() : null); vo.setSumStnm(pptnDrp24Sum != null ? pptnDrp24Sum.getStnm() : null); ResBriefVo.PptnVo pptnDrp24Max = pptnVos.stream() + .filter(o -> o.getDrp24Max() != null) .max(Comparator.comparing( ResBriefVo.PptnVo::getDrp24Max, Comparator.nullsLast(Comparator.naturalOrder()) diff --git a/src/main/java/com/gunshi/project/hsz/service/ReservoirWaterService.java b/src/main/java/com/gunshi/project/hsz/service/ReservoirWaterService.java index 2a0e52f..1716c2b 100644 --- a/src/main/java/com/gunshi/project/hsz/service/ReservoirWaterService.java +++ b/src/main/java/com/gunshi/project/hsz/service/ReservoirWaterService.java @@ -146,6 +146,7 @@ public class ReservoirWaterService { if(tm != null && tm.before(currentHour)){ vo.setRz(null); + vo.setTm(null); }else if (tm != null && rz != null){ if (rz != null) { //BigDecimal w = stZvarlBService.getWFromZvarl(rz, null, zvarlList); diff --git a/src/main/java/com/gunshi/project/hsz/service/StQxWarnRService.java b/src/main/java/com/gunshi/project/hsz/service/StQxWarnRService.java index 7f6808f..ab7a5aa 100644 --- a/src/main/java/com/gunshi/project/hsz/service/StQxWarnRService.java +++ b/src/main/java/com/gunshi/project/hsz/service/StQxWarnRService.java @@ -6,10 +6,9 @@ import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.fasterxml.jackson.databind.ObjectMapper; import com.gunshi.db.dto.DateTimeRangeSo; -import com.gunshi.project.hsz.common.model.JcskByR; import com.gunshi.project.hsz.common.model.StRiverR; -import com.gunshi.project.hsz.common.model.StRiverRReal; import com.gunshi.project.hsz.entity.vo.*; +import com.gunshi.project.hsz.mapper.AttCctvBaseMapper; import com.gunshi.project.hsz.mapper.AttResBaseMapper; import com.gunshi.project.hsz.mapper.StQxWarnRMapper; import com.gunshi.project.hsz.model.*; @@ -31,10 +30,7 @@ import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.math.RoundingMode; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.Date; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; /** @@ -75,117 +71,175 @@ public class StQxWarnRService extends ServiceImpl { @Resource private JcskByRService jcskByRService; + @Resource + private AttCctvBaseService attCctvBaseService; + public HomeWarnVo homeWarn(DateTimeRangeSo dateTimeRangeSo) { HomeWarnVo vo = new HomeWarnVo(); - List attResBaseVos = attResBaseMapper.queryList(); - AttResBaseVo attResBaseVo = attResBaseVos.get(0); - Date tm = attResBaseVo.getTm(); - //水位的最新采集时间不在24小时内 - if (tm.before(dateTimeRangeSo.getStart())) { - vo.setRzWarn("-"); - } else { - BigDecimal rz = attResBaseVo.getRz(); - if (attResBaseVo.getCalState() == 1) { - BigDecimal aboveCal = rz.subtract(attResBaseVo.getCalFloodLev()); - vo.setRzWarn("超校核(" + aboveCal.setScale(2, RoundingMode.HALF_UP) + "m)"); - attResBaseVo.setDesState(0); - attResBaseVo.setFlState(0); - } else if (attResBaseVo.getDesState() == 1) { - BigDecimal aboveDes = rz.subtract(attResBaseVo.getDesFloodLev()); - vo.setRzWarn("超设计(" + aboveDes.setScale(2, RoundingMode.HALF_UP) + "m)"); - attResBaseVo.setFlState(0); - } else if (attResBaseVo.getFlState() == 1) { - vo.setRzWarn("超汛限(" + attResBaseVo.getAFsltdz().setScale(2, RoundingMode.HALF_UP) + "m)"); - } else if (rz.compareTo(attResBaseVo.getDeadLev()) < 0) { - BigDecimal aboveDead = rz.subtract(attResBaseVo.getDeadLev()); - vo.setRzWarn("低水位(" + aboveDead.setScale(1, RoundingMode.HALF_UP) + "m)"); - } else { - vo.setRzWarn("正常(" + attResBaseVo.getAFsltdz().setScale(2, RoundingMode.HALF_UP) + "m)"); + List attResBaseVos = attResBaseMapper.queryList2(); + + Map> skWarningVoMap = new HashMap<>(); + //超校核水位 + List cals = new ArrayList<>(); + //超设计水位 + List des = new ArrayList<>(); + //超汛限水位 + List fl = new ArrayList<>(); + for (AttResBaseVo attResBaseVo : attResBaseVos) { + Date tm = attResBaseVo.getTm(); + if(tm == null){ + continue; + } + //水位的最新采集时间不在24小时内 + if (tm.before(dateTimeRangeSo.getStart())) { + continue; + }else{ + BigDecimal rz = attResBaseVo.getRz(); + if(rz == null){ + continue; + } + SKWarningVo skWarningVo = new SKWarningVo(); + skWarningVo.setLttd(attResBaseVo.getLttd()); + skWarningVo.setLgtd(attResBaseVo.getLgtd()); + skWarningVo.setStnm(attResBaseVo.getStnm()); + skWarningVo.setStcd(attResBaseVo.getStcd()); + if (attResBaseVo.getCalState() == 1) { + BigDecimal aboveCal = rz.subtract(attResBaseVo.getCalFloodLev()); + skWarningVo.setRzWarn(rz + "(" + aboveCal.setScale(2, RoundingMode.HALF_EVEN) + ")" ); + cals.add(skWarningVo); + } else if (attResBaseVo.getDesState() == 1) { + BigDecimal aboveDes = rz.subtract(attResBaseVo.getDesFloodLev()); + skWarningVo.setRzWarn(rz + "(" + aboveDes.setScale(2, RoundingMode.HALF_EVEN) + ")" ); + des.add(skWarningVo); + } else if (attResBaseVo.getFlState() == 1) { + BigDecimal aboveFl = attResBaseVo.getAFsltdz().setScale(2, RoundingMode.HALF_UP); + skWarningVo.setRzWarn(rz + "(" + aboveFl.setScale(2, RoundingMode.HALF_UP) + ")" ); + fl.add(skWarningVo); + } } } - -// vo.setQxWarn(queryQxWarn()); - + skWarningVoMap.put("calState", cals); + skWarningVoMap.put("desState",des); + skWarningVoMap.put("flState",fl); + vo.setSkWarningVoMap(skWarningVoMap); List warnVos = baseMapper.queryOsmoticWarn(dateTimeRangeSo); - vo.setPressWarn(warnVos.stream().filter(o -> o.getType() == 1).collect(Collectors.toList())); - vo.setFlowWarn(warnVos.stream().filter(o -> o.getType() == 2).collect(Collectors.toList())); - vo.setShiftWarn(warnVos.stream().filter(o -> o.getType() == 3).collect(Collectors.toList())); - Long aiWarnCount = iscaiEventService.lambdaQuery() + List pressWarn = warnVos.stream().filter(o -> o.getType() == 1).collect(Collectors.toList()); + pressWarn.stream().forEach(o ->{ + if(o.getLevel() != null){ + if(o.getLevel() == 1){ + o.setWarnLevel("黄色"); + }else{ + o.setWarnLevel("红色"); + } + } + }); + List flowWarn = warnVos.stream().filter(o -> o.getType() == 2).collect(Collectors.toList()); + flowWarn.stream().forEach(o->{ + if(o.getLevel() != null){ + if(o.getLevel() == 1){ + o.setWarnLevel("黄色"); + }else{ + o.setWarnLevel("红色"); + } + } + }); + List shiftWarn = warnVos.stream().filter(o -> o.getType() == 3).collect(Collectors.toList()); + shiftWarn.stream().forEach(o ->{ + if(o.getLevel() != null){ + if(o.getLevel() == 1){ + o.setWarnLevel("黄色"); + }else{ + o.setWarnLevel("红色"); + } + } + }); + Map> osmoticWarnMaps = new HashMap<>(); + osmoticWarnMaps.put("pressWarn",pressWarn); + osmoticWarnMaps.put("flowWarn",flowWarn); + osmoticWarnMaps.put("shiftWarn",shiftWarn); + vo.setOsmoticWarnVoMap(osmoticWarnMaps); + List iscaiEvents = iscaiEventService.lambdaQuery() .ge(ISCAIEvent::getStartTime, dateTimeRangeSo.getStart()) - .le(ISCAIEvent::getStartTime,dateTimeRangeSo.getEnd()) - .count(); - vo.setAiWarnCount(aiWarnCount); + .le(ISCAIEvent::getStartTime, dateTimeRangeSo.getEnd()).orderByDesc(ISCAIEvent::getStartTime).list(); + List distinctResNames = iscaiEvents.stream() + .map(ISCAIEvent::getEventTypeName) + .filter(Objects::nonNull) // 过滤null值 + .distinct() // 去重 + .collect(Collectors.toList()); + Map> aiWarnVoMap = new HashMap<>(); + distinctResNames.forEach(resName -> { + aiWarnVoMap.put(resName, new ArrayList<>()); + }); + for (ISCAIEvent iscaiEvent : iscaiEvents) { + if(aiWarnVoMap.containsKey(iscaiEvent.getEventTypeName())){ + List aiWarningVos = aiWarnVoMap.get(iscaiEvent.getEventTypeName()); + List list = attCctvBaseService.lambdaQuery().eq(AttCctvBase::getIndexCode, iscaiEvent.getResIndexCode()).list(); + for (AttCctvBase attCctvBase : list) { + AiWarningVo aiWarningVo = new AiWarningVo(); + aiWarningVo.setWarningTime(iscaiEvent.getStartTime()); + aiWarningVo.setStnm(attCctvBase.getName()); + if(attCctvBase.getLgtd() !=null){ + aiWarningVo.setLgtd(new BigDecimal(attCctvBase.getLgtd())); + } + if(attCctvBase.getLttd() != null){ + aiWarningVo.setLttd(new BigDecimal(attCctvBase.getLttd())); + } + aiWarningVos.add(aiWarningVo); + + } + } + } + vo.setAiWarnVoMap(aiWarnVoMap); + Map> riverWarningVoMap = new HashMap<>(); + List overWarn = new ArrayList<>(); + List overPmis = new ArrayList<>(); //TODO 超河道上游 String upperStcd = "999999999";//固定的站点编码 - setUpAndDownOverRvUp(upperStcd,vo,dateTimeRangeSo); + setUpAndDownOverRvUpAndDown(upperStcd,dateTimeRangeSo,overWarn,overPmis); //TODO 超河道下游 String lowerStcd = "61610700";//固定的站点编码 - setUpAndDownOverRvDown(lowerStcd,vo,dateTimeRangeSo); + setUpAndDownOverRvUpAndDown(lowerStcd,dateTimeRangeSo,overWarn,overPmis); + riverWarningVoMap.put("overWarn",overWarn); + riverWarningVoMap.put("overPromise",overPmis); + vo.setRiverWarningVoMap(riverWarningVoMap); return vo; } - private void setUpAndDownOverRvUp(String stcd, HomeWarnVo vo, DateTimeRangeSo dateTimeRangeSo){ - //StRsvrRReal stRsvrRReal = stRsvrRRealService.getBaseMapper().queryRzByStcd(stcd); - //StRiverRReal stRiverRReal = stRiverRRealService.getBaseMapper().queryQByStcd(stcd); + private void setUpAndDownOverRvUpAndDown(String stcd, DateTimeRangeSo dateTimeRangeSo, List overWarn, List overPmis){ StRiverR stRiverR = stRiverRService.getBaseMapper().queryByOneByTimeRange(stcd,dateTimeRangeSo); + RiverWarningVo riverWarningVo = new RiverWarningVo(); if(stRiverR != null){ + riverWarningVo.setStcd(stcd); + riverWarningVo.setStnm(stRiverR.getStnm()); + riverWarningVo.setLgtd(stRiverR.getLgtd()); + riverWarningVo.setLgtd(stRiverR.getLgtd()); AlarmSet alarmSet = alarmSetService.getBaseMapper().queryByStcd(stcd); - //警告水位 - BigDecimal warnWaterLevel = alarmSet.getWarnWaterLevel(); - //保证水位 - BigDecimal promiseWaterLevel = alarmSet.getPromiseWaterLevel(); if(alarmSet == null){ - vo.setOverRvUp("告警设置未配置,请检查"); + riverWarningVo.setRzWarn("告警设置未配置,请检查"); }else{ + //警告水位 + BigDecimal warnWaterLevel = alarmSet.getWarnWaterLevel(); + //保证水位 + BigDecimal promiseWaterLevel = alarmSet.getPromiseWaterLevel(); BigDecimal rz = stRiverR.getZ(); if(rz == null){ - vo.setOverRvUp("无水位数据"); return; } - if(rz.compareTo(warnWaterLevel) >=0){ + if(rz.compareTo(warnWaterLevel) >=0 && rz.compareTo(promiseWaterLevel) <0){ BigDecimal gap = rz.subtract(warnWaterLevel); - vo.setOverRvUp("超警戒(" +gap.setScale(2, RoundingMode.HALF_UP)+")m"); - }else{ + riverWarningVo.setRzWarn(gap.toString()); + overWarn.add(riverWarningVo); + }else if (rz.compareTo(promiseWaterLevel) >=0){ BigDecimal gap = rz.subtract(warnWaterLevel); - vo.setOverRvUp("正常(" +gap.setScale(2, RoundingMode.HALF_UP)+")m"); + riverWarningVo.setRzWarn(gap.toString()); + overPmis.add(riverWarningVo); } } - }else{ - vo.setOverRvUp("-"); } } - private void setUpAndDownOverRvDown(String stcd, HomeWarnVo vo, DateTimeRangeSo dateTimeRangeSo){ - StRiverR stRiverR = stRiverRService.getBaseMapper().queryByOneByTimeRange(stcd,dateTimeRangeSo); - if(stRiverR != null){ - AlarmSet alarmSet = alarmSetService.getBaseMapper().queryByStcd(stcd); - //警告水位 - BigDecimal warnWaterLevel = alarmSet.getWarnWaterLevel(); - //保证水位 - BigDecimal promiseWaterLevel = alarmSet.getPromiseWaterLevel(); - if(alarmSet == null){ - vo.setOverRvDown("告警设置未配置,请检查"); - - }else{ - BigDecimal rz = stRiverR.getZ(); - if(rz == null){ - vo.setOverRvUp("无水位数据"); - return; - } - if(rz.compareTo(warnWaterLevel) >=0){ - BigDecimal gap = rz.subtract(warnWaterLevel); - vo.setOverRvDown("超警戒(" +gap.setScale(2, RoundingMode.HALF_UP)+")m"); - }else{ - BigDecimal gap = rz.subtract(warnWaterLevel); - vo.setOverRvDown("正常(" +gap.setScale(2, RoundingMode.HALF_UP)+")m"); - } - } - }else{ - vo.setOverRvDown("-"); - } - } private List queryQxWarn() { List list = new ArrayList<>(); diff --git a/src/main/java/com/gunshi/project/hsz/service/StWaterRService.java b/src/main/java/com/gunshi/project/hsz/service/StWaterRService.java index 58945f0..b597ed9 100644 --- a/src/main/java/com/gunshi/project/hsz/service/StWaterRService.java +++ b/src/main/java/com/gunshi/project/hsz/service/StWaterRService.java @@ -33,6 +33,10 @@ public class StWaterRService extends ServiceImpl public StWaterR selectNewDataByStcd(String stcd) { return this.baseMapper.selectNewDataByStcd(stcd); } + + public List queryDetail() { + return null; + } } diff --git a/src/main/java/com/gunshi/project/hsz/timetask/AlarmTask.java b/src/main/java/com/gunshi/project/hsz/timetask/AlarmTask.java index 8f29463..7d448a0 100644 --- a/src/main/java/com/gunshi/project/hsz/timetask/AlarmTask.java +++ b/src/main/java/com/gunshi/project/hsz/timetask/AlarmTask.java @@ -1,6 +1,7 @@ package com.gunshi.project.hsz.timetask; +import com.gunshi.project.hsz.common.model.StStbprpB; import com.gunshi.project.hsz.entity.enums.AlarmTypeEnum; import com.gunshi.project.hsz.entity.vo.AttResBaseVo; import com.gunshi.project.hsz.mapper.AlarmSetMapper; @@ -9,6 +10,8 @@ import com.gunshi.project.hsz.model.AlarmSet; import com.gunshi.project.hsz.common.model.StRiverRReal; import com.gunshi.project.hsz.model.WaterAlarm; import com.gunshi.project.hsz.service.StRiverRRealService; +import com.gunshi.project.hsz.service.StRsvrRService; +import com.gunshi.project.hsz.service.StStbprpBService; import com.gunshi.project.hsz.service.WaterAlarmService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -44,6 +47,9 @@ public class AlarmTask { @Autowired private StRiverRRealService stRiverRRealService; + @Autowired + private StStbprpBService stStbprpBService; + @Async @Scheduled(cron = "0 7 * * * *") public void updateAlarmSet(){ @@ -59,9 +65,10 @@ public class AlarmTask { @Async @Scheduled(cron = "0 7 * * * *") public void updateWaterAlarm(){ - List attResBaseVos = attResBaseMapper.queryList(); - AttResBaseVo attResBaseVo = attResBaseVos.get(0); - saveResStData(attResBaseVo); + List attResBaseVos = attResBaseMapper.queryList2(); + for (AttResBaseVo attResBaseVo : attResBaseVos) { + saveResStData(attResBaseVo); + } } private void saveResStData(AttResBaseVo entity){ diff --git a/src/main/resources/mapper/RealRainMapper.xml b/src/main/resources/mapper/RealRainMapper.xml new file mode 100644 index 0000000..ec84faa --- /dev/null +++ b/src/main/resources/mapper/RealRainMapper.xml @@ -0,0 +1,147 @@ + + + + + \ No newline at end of file