审批流程配置,预警规则,影响区联络信息

master
wany 2026-02-27 16:33:33 +08:00
parent a6e17a5154
commit eddb6d85c7
17 changed files with 347 additions and 141 deletions

View File

@ -16,7 +16,7 @@ import org.springframework.cache.annotation.EnableCaching;
description = "本地测试环境" description = "本地测试环境"
), ),
@Server( @Server(
url = "http://local.gunshiiot.com:18083/gunshiApp/ss", url = "http://223.75.53.141:83/gunshiApp/ss",
description = "线上测试环境" description = "线上测试环境"
) )
} }

View File

@ -20,7 +20,9 @@ public class OpenApiConfig {
"com.gunshi.project.ss.controller", "com.gunshi.project.ss.controller",
}; };
String[] pathsToMatch = { String[] pathsToMatch = {
"/screen/responsibility/**" "/impactZoneInfo/**",
"/auditProcess/**",
"/warningRule/**"
}; };
return GroupedOpenApi.builder() return GroupedOpenApi.builder()
.group("ss") .group("ss")

View File

@ -0,0 +1,72 @@
package com.gunshi.project.ss.controller;
import com.gunshi.core.result.R;
import com.gunshi.project.ss.common.validate.markers.Insert;
import com.gunshi.project.ss.common.validate.markers.Update;
import com.gunshi.project.ss.model.AuditProcess;
import com.gunshi.project.ss.service.AuditProcessService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;
@Tag(name = "审批流程配置")
@RestController
@RequestMapping(value="/auditProcess")
public class AuditProcessController {
@Autowired
private AuditProcessService service;
@Operation(summary = "新增")
@PostMapping("/insert")
public R<AuditProcess> insert(@Validated(Insert.class) @RequestBody AuditProcess dto) {
if (dto.getWarningLevel() != null){
if (service.lambdaQuery().eq(AuditProcess::getWarningLevel,dto.getAuditLevel()).count() > 0) {
throw new IllegalArgumentException("当前预警级别的审批流程已存在");
}
}
boolean result = service.save(dto);
return R.ok(result ? dto : null);
}
@Operation(summary = "修改")
@PostMapping("/update")
public R<AuditProcess> update(@Validated(Update.class) @RequestBody AuditProcess dto) {
if (Objects.isNull(service.getById(dto.getId()))) {
throw new IllegalArgumentException("当前数据不存在");
}
boolean result = service.updateById(dto);
return R.ok(result ? dto : null);
}
@Operation(summary = "删除")
@GetMapping("/del/{id}")
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id) {
if (Objects.isNull(service.getById(id))) {
throw new IllegalArgumentException("当前数据不存在");
}
boolean data = service.removeById(id);
return R.ok(data);
}
@Operation(summary = "列表")
@GetMapping("/list")
public R<List<AuditProcess>> list(@RequestParam(value = "warningLevel",required = false) @Parameter(description = "预警级别") Integer warningLevel) {
if (warningLevel != null){
return R.ok(service.lambdaQuery().eq(AuditProcess::getWarningLevel,warningLevel).list());
}
return R.ok(service.lambdaQuery().list());
}
}

View File

@ -21,7 +21,7 @@ import java.util.Objects;
@Tag(name = "影响区联络信息管理") @Tag(name = "影响区联络信息管理")
@RestController @RestController
@RequestMapping(value="/ImpactZoneInfo") @RequestMapping(value="/impactZoneInfo")
public class ImpactZoneInfoController{ public class ImpactZoneInfoController{
@Autowired @Autowired

View File

@ -8,14 +8,12 @@ import com.gunshi.project.ss.common.validate.markers.Update;
import com.gunshi.project.ss.entity.so.WarningRulePageSo; import com.gunshi.project.ss.entity.so.WarningRulePageSo;
import com.gunshi.project.ss.model.WarningRule; import com.gunshi.project.ss.model.WarningRule;
import com.gunshi.project.ss.model.WarningRuleInfo; import com.gunshi.project.ss.model.WarningRuleInfo;
import com.gunshi.project.ss.service.HisWaterDataService;
import com.gunshi.project.ss.service.StStbprpBService; import com.gunshi.project.ss.service.StStbprpBService;
import com.gunshi.project.ss.service.WarningRuleInfoService; import com.gunshi.project.ss.service.WarningRuleInfoService;
import com.gunshi.project.ss.service.WarningRuleService; import com.gunshi.project.ss.service.WarningRuleService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -26,12 +24,20 @@ import java.util.List;
@Tag(name = "预警规则") @Tag(name = "预警规则")
@RestController @RestController
@RequestMapping(value="/warningRule") @RequestMapping(value="/warningRule")
public class WarningRuleController extends AbstractCommonFileController { public class WarningRuleController{
@Autowired @Autowired
private WarningRuleService warningRuleService; private WarningRuleService warningRuleService;
@Autowired
private StStbprpBService stStbprpBService;
@Autowired
private WarningRuleInfoService warningRuleInfoService;
@Operation(summary = "分页") @Operation(summary = "分页")
@PostMapping("/page") @PostMapping("/page")
public R<Page<WarningRule>> page(@RequestBody @Validated WarningRulePageSo page) { public R<Page<WarningRule>> page(@RequestBody @Validated WarningRulePageSo page) {
@ -41,13 +47,7 @@ public class WarningRuleController extends AbstractCommonFileController {
@Operation(summary = "新增") @Operation(summary = "新增")
@PostMapping("/insert") @PostMapping("/insert")
public R<WarningRule> insert(@RequestBody @Validated WarningRule dto, HttpServletRequest request) { public R<WarningRule> insert(@RequestBody @Validated WarningRule dto) {
// SessionUser sessionUser = checkLogin(request);
// if(sessionUser == null){
// throw new IllegalArgumentException("未登录");
// }
// Long userId = sessionUser.getUserId();
// dto.setCreateName(userId.toString());
return R.ok(warningRuleService.saveData(dto)); return R.ok(warningRuleService.saveData(dto));
} }
@ -66,10 +66,6 @@ public class WarningRuleController extends AbstractCommonFileController {
return R.ok(b); return R.ok(b);
} }
@Autowired
private WarningRuleInfoService warningRuleInfoService;
@Operation(summary = "预警信息分页") @Operation(summary = "预警信息分页")
@PostMapping("/info/page") @PostMapping("/info/page")
public R<Page<WarningRuleInfo>> infoPage(@RequestBody @Validated WarningRulePageSo page) { public R<Page<WarningRuleInfo>> infoPage(@RequestBody @Validated WarningRulePageSo page) {
@ -84,27 +80,17 @@ public class WarningRuleController extends AbstractCommonFileController {
} }
//获取降雨量测点 //获取降雨量测点
@Autowired
private StStbprpBService stStbprpBService;
@Operation(summary = "获取降雨量测点") @Operation(summary = "获取降雨量测点")
@GetMapping("/getRainStcd") @GetMapping("/getRainStcd")
public R<List<StStbprpB>> gerRainStcd(){ public R<List<StStbprpB>> getRainStcd(){
return R.ok(stStbprpBService.getPptnStations()); return R.ok(stStbprpBService.getPptnStations());
} }
@Autowired @Operation(summary = "获取流量测点")
private HisWaterDataService hisWaterDataService; @GetMapping("/getFlowStcd")
public R<List<StStbprpB>> getFlowStcd(){
@Operation(summary = "获取年份") return R.ok(stStbprpBService.getFlowStations());
@GetMapping("/getYear")
public R<List<Integer>> getYear(){
return R.ok(hisWaterDataService.getYearList());
} }
@Override
public String getGroupId() {
return "warningRule";
}
} }

View File

@ -1,6 +1,7 @@
package com.gunshi.project.ss.entity.so; package com.gunshi.project.ss.entity.so;
import com.baomidou.mybatisplus.annotation.TableField;
import com.gunshi.db.dto.DateTimeRangeSo; import com.gunshi.db.dto.DateTimeRangeSo;
import com.gunshi.db.dto.PageSo; import com.gunshi.db.dto.PageSo;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
@ -14,9 +15,25 @@ public class WarningRulePageSo {
@Schema(description = "分页参数") @Schema(description = "分页参数")
private PageSo pageSo; private PageSo pageSo;
private String ruleName; /**
* MONITOR-FORE-
*/
@Schema(description="预警类型MONITOR-监测预警FORE-预报预警")
private String warningType; private String warningType;
private DateTimeRangeSo dateTimeRangeSo;
/**
* (1- 2- 3- 4- 5- 5- 6- 7- 8- 9-)
*/
@Schema(description="预警对象(1-库水位 2-累计雨量 3-出入库流量 4-位移 5-渗压 5-渗流 6-预报最高库水位 7-预报累计雨量 8-预报入库洪峰流量 9-预报渗压)")
private Integer warningObj;
/**
* (1 2 3 4)
*/
@Schema(description="预警级别(1蓝色 2黄色 3橙色 4红色)")
private Integer warningLevel;
@Schema(description="状态0-未启用1-启用")
private Integer status;
} }

View File

@ -0,0 +1,10 @@
package com.gunshi.project.ss.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gunshi.project.ss.model.AuditProcess;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface AuditProcessMapper extends BaseMapper<AuditProcess> {
}

View File

@ -0,0 +1,75 @@
package com.gunshi.project.ss.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 com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.gunshi.project.ss.common.validate.markers.Update;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
@Schema(description="审批流程配置")
@Data
@TableName("public.audit_process")
public class AuditProcess implements Serializable {
public final static String thisTableName = "AuditProcess";
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(value="id", type= IdType.AUTO)
@Schema(description="主键")
@NotNull(message = "id不能为空",groups = { Update.class})
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
/**
* (1 2 3 4)
*/
@TableField(value="warning_level")
@Schema(description="预警级别(1蓝色 2黄色 3橙色 4红色)")
private Integer warningLevel;
/**
* (1 2)
*/
@TableField(value="audit_level")
@Schema(description="审批层级(1一级 2二级)")
private Integer auditLevel;
@TableField(value="first_audit_user_id")
@Schema(description="一级审批人id")
@JsonSerialize(using = ToStringSerializer.class)
private Long firstAuditUserId;
@TableField(value="first_audit_user_name")
@Schema(description="一级审批人")
private String firstAuditUserName;
@TableField(value="second_audit_user_id")
@Schema(description="二级审批人id")
@JsonSerialize(using = ToStringSerializer.class)
private Long secondAuditUserId;
@TableField(value="second_audit_user_name")
@Schema(description="二级审批人")
private String secondAuditUserName;
@TableField("update_time")
@Schema(description = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime updateTime;
}

View File

@ -28,7 +28,7 @@ public class ReservoirDemarcationInfo {
@TableField("management_scope_area_explain") @TableField("management_scope_area_explain")
@Schema(description = "管理范围km²说明") @Schema(description = "管理范围km²说明")
private BigDecimal managementScopeAreaExplain; private String managementScopeAreaExplain;
@TableField(exist = false) @TableField(exist = false)
@Schema(description = "管理范围km²文件") @Schema(description = "管理范围km²文件")
@ -40,7 +40,7 @@ public class ReservoirDemarcationInfo {
@TableField("protection_scope_area_explain") @TableField("protection_scope_area_explain")
@Schema(description = "保护范围km²说明") @Schema(description = "保护范围km²说明")
private BigDecimal protectionScopeAreaExplain; private String protectionScopeAreaExplain;
@TableField(exist = false) @TableField(exist = false)
@Schema(description = "保护范围km²文件") @Schema(description = "保护范围km²文件")
@ -53,7 +53,7 @@ public class ReservoirDemarcationInfo {
@TableField("total_use_area_explain") @TableField("total_use_area_explain")
@Schema(description = "用地总面积(万亩)说明") @Schema(description = "用地总面积(万亩)说明")
private BigDecimal totalUseAreaExplain; private String totalUseAreaExplain;
@TableField(exist = false) @TableField(exist = false)
@Schema(description = "用地总面积(万亩)文件") @Schema(description = "用地总面积(万亩)文件")

View File

@ -1,7 +1,14 @@
package com.gunshi.project.ss.model; package com.gunshi.project.ss.model;
import com.baomidou.mybatisplus.annotation.*; 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 com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
/** /**
@ -15,12 +22,16 @@ public class WarningCondition {
* ID * ID
*/ */
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)
@Schema(description="主键")
@JsonSerialize(using = ToStringSerializer.class)
private Long id; private Long id;
/** /**
* ID * ID
*/ */
@TableField("rule_id") @TableField("rule_id")
@Schema(description="规则ID")
@JsonSerialize(using = ToStringSerializer.class)
private Long ruleId; private Long ruleId;
/** /**
@ -29,59 +40,41 @@ public class WarningCondition {
@TableField("_order") @TableField("_order")
private Integer order; private Integer order;
/**
*
* REAL_WATER_LEVEL
* PEAK_FLOW
* RAINFALL
* WATER_STORAGE
* FORECAST_RAINFALL
*/
@TableField("indicator_type")
private String indicatorType;
/**
* FLOOD-DROUGHT-
*/
@TableField("warning_type")
private String warningType;
/**
*
*/
@TableField("stcd")
private String stcd;
/** /**
* *
*/ */
@TableField("_operator") @TableField("_operator")
@Schema(description="比较运算符")
private String operator; private String operator;
/** /**
* *
*/ */
@TableField("threshold_value") @TableField("threshold_value")
@Schema(description="阈值")
private BigDecimal thresholdValue; private BigDecimal thresholdValue;
/** /**
* / *
*/ */
@TableField("duration_hours") @TableField("duration_hours")
@Schema(description="预报时长")
private Integer durationHours; private Integer durationHours;
/**
*
*/
@TableField("direction")
@Schema(description="位移方向")
private String direction;
/** /**
* AND-OR- * AND-OR-
*/ */
@TableField("relation_type") @TableField("relation_type")
private String relationType; private String relationType;
@TableField("warning_level")
private Integer warningLevel;
@TableField("year")
private String year;
@TableField(exist = false) @TableField(exist = false)
private Boolean isEnjoy = false;//该预警规则是否满足条件,默认不满足 private Boolean isEnjoy = false;//该预警规则是否满足条件,默认不满足
} }

View File

@ -2,6 +2,11 @@ package com.gunshi.project.ss.model;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.gunshi.project.ss.common.validate.markers.Update;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data; import lombok.Data;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
@ -16,45 +21,65 @@ public class WarningRule {
/** /**
* ID * ID
*/ */
@TableId(type = IdType.AUTO) @TableId(value="id", type= IdType.AUTO)
@Schema(description="主键")
@NotNull(message = "id不能为空",groups = { Update.class})
@JsonSerialize(using = ToStringSerializer.class)
private Long id; private Long id;
/** /**
* * MONITOR-FORE-
*/
@TableField("rule_name")
private String ruleName;
/**
* FLOOD-DROUGHT-
*/ */
@TableField("warning_type") @TableField("warning_type")
@Schema(description="预警类型MONITOR-监测预警FORE-预报预警")
private String warningType; private String warningType;
/**
* (1- 2- 3- 4- 5- 5- 6- 7- 8- 9-)
*/
@TableField("warning_obj")
@Schema(description="预警对象(1-库水位 2-累计雨量 3-出入库流量 4-位移 5-渗压 5-渗流 6-预报最高库水位 7-预报累计雨量 8-预报入库洪峰流量 9-预报渗压)")
private Integer warningObj;
/**
* (1 2 3 4)
*/
@TableField("warning_level")
@Schema(description="预警级别(1蓝色 2黄色 3橙色 4红色)")
private Integer warningLevel;
/**
*
*/
@TableField("rel_stcd")
@Schema(description="关联测点")
private String relStcd;
/** /**
* 0-1- * 0-1-
*/ */
@TableField("status") @TableField("status")
@Schema(description="状态0-未启用1-启用")
private Integer status; private Integer status;
/** /**
* *
*/ */
@TableField("create_name") @TableField("solution")
private String createName; @Schema(description="应对措施")
private String solution;
/** /**
* *
*/ */
@TableField("create_time") @TableField("create_time")
@Schema(description="创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime; private LocalDateTime createTime;
@TableField("warning_level")
private Integer warningLevel;
/** /**
* *
*/ */

View File

@ -6,6 +6,11 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.gunshi.project.ss.common.validate.markers.Update;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data; import lombok.Data;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -19,29 +24,42 @@ public class WarningRuleInfo {
* ID * ID
*/ */
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)
@Schema(description="主键")
@JsonSerialize(using = ToStringSerializer.class)
private Long id; private Long id;
@TableField("rule_id") @TableField("rule_id")
@Schema(description="规则主键")
@JsonSerialize(using = ToStringSerializer.class)
private Long ruleId; private Long ruleId;
/** /**
* * MONITOR-FORE-
*/
@TableField("rule_name")
private String ruleName;
/**
* FLOOD-DROUGHT-
*/ */
@TableField("warning_type") @TableField("warning_type")
@Schema(description="预警类型MONITOR-监测预警FORE-预报预警")
private String warningType; private String warningType;
/**
* (1- 2- 3- 4- 5- 5- 6- 7- 8- 9-)
*/
@TableField("warning_obj")
@Schema(description="预警对象(1-库水位 2-累计雨量 3-出入库流量 4-位移 5-渗压 5-渗流 6-预报最高库水位 7-预报累计雨量 8-预报入库洪峰流量 9-预报渗压)")
private Integer warningObj;
/** /**
* * (1 2 3 4)
*/ */
@TableField("create_name") @TableField("warning_level")
private String createName; @Schema(description="预警级别(1蓝色 2黄色 3橙色 4红色)")
private Integer warningLevel;
/**
*
*/
@TableField("rel_stcd")
@Schema(description="关联测点")
private String relStcd;
/** /**
* *
@ -53,15 +71,12 @@ public class WarningRuleInfo {
@TableField("rule_info") @TableField("rule_info")
private String ruleInfo; private String ruleInfo;
@TableField("warning_level") @TableField("status")
private Integer warningLevel; private Integer status;
/** /**
* *
*/ */
@TableField(exist = false) @TableField(exist = false)
private List<WarningCondition> conditions; private List<WarningCondition> conditions;
@TableField("status")
private Integer status;
} }

View File

@ -0,0 +1,19 @@
package com.gunshi.project.ss.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gunshi.project.ss.mapper.AuditProcessMapper;
import com.gunshi.project.ss.model.AuditProcess;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Slf4j
@Transactional(rollbackFor = Exception.class)
public class AuditProcessService extends ServiceImpl<AuditProcessMapper, AuditProcess>
{
}

View File

@ -31,18 +31,6 @@ public class WarningConditionService extends ServiceImpl<WarningConditionMapper,
if(dto.getId() != null){ if(dto.getId() != null){
queryWrapper.ne(WarningCondition::getId, dto.getId()); queryWrapper.ne(WarningCondition::getId, dto.getId());
} }
if(dto.getIndicatorType() != null){
//预警指标类型
queryWrapper.eq(WarningCondition::getIndicatorType,dto.getIndicatorType());
}
if(dto.getWarningLevel() != null){
//预警等级
queryWrapper.eq(WarningCondition::getWarningLevel,dto.getWarningLevel());
}
if(dto.getWarningType() != null){
//预警类型
queryWrapper.eq(WarningCondition::getWarningType,dto.getWarningType());
}
if(dto.getOperator() != null){ if(dto.getOperator() != null){
//比较符 //比较符
queryWrapper.eq(WarningCondition::getOperator,dto.getOperator()); queryWrapper.eq(WarningCondition::getOperator,dto.getOperator());

View File

@ -26,16 +26,16 @@ public class WarningRuleInfoService extends ServiceImpl<WarningRuleInfoMapper,Wa
public Page<WarningRuleInfo> pageQuery(WarningRulePageSo page) { public Page<WarningRuleInfo> pageQuery(WarningRulePageSo page) {
LambdaQueryWrapper<WarningRuleInfo> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<WarningRuleInfo> queryWrapper = new LambdaQueryWrapper<>();
if(!StringUtils.isBlank(page.getRuleName())){ // if(!StringUtils.isBlank(page.getRuleName())){
queryWrapper.like(WarningRuleInfo::getRuleName, page.getRuleName()); // queryWrapper.like(WarningRuleInfo::getRuleName, page.getRuleName());
} // }
if(!StringUtils.isBlank(page.getWarningType())){ if(!StringUtils.isBlank(page.getWarningType())){
queryWrapper.eq(WarningRuleInfo::getWarningType, page.getWarningType()); queryWrapper.eq(WarningRuleInfo::getWarningType, page.getWarningType());
} }
if(page.getDateTimeRangeSo() != null){ // if(page.getDateTimeRangeSo() != null){
queryWrapper.ge(WarningRuleInfo::getCreateTime,page.getDateTimeRangeSo().getStart()); // queryWrapper.ge(WarningRuleInfo::getCreateTime,page.getDateTimeRangeSo().getStart());
queryWrapper.le(WarningRuleInfo::getCreateTime,page.getDateTimeRangeSo().getEnd()); // queryWrapper.le(WarningRuleInfo::getCreateTime,page.getDateTimeRangeSo().getEnd());
} // }
queryWrapper.orderByDesc(WarningRuleInfo::getCreateTime); queryWrapper.orderByDesc(WarningRuleInfo::getCreateTime);
Page<WarningRuleInfo> warningRuleInfoPage = this.baseMapper.selectPage(page.getPageSo().toPage(), queryWrapper); Page<WarningRuleInfo> warningRuleInfoPage = this.baseMapper.selectPage(page.getPageSo().toPage(), queryWrapper);
List<WarningRuleInfo> records = warningRuleInfoPage.getRecords(); List<WarningRuleInfo> records = warningRuleInfoPage.getRecords();

View File

@ -28,12 +28,18 @@ public class WarningRuleService extends ServiceImpl<WarningRuleMapper, WarningRu
public Page<WarningRule> pageQuery(WarningRulePageSo page) { public Page<WarningRule> pageQuery(WarningRulePageSo page) {
LambdaQueryWrapper<WarningRule> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<WarningRule> queryWrapper = new LambdaQueryWrapper<>();
if(!StringUtils.isBlank(page.getRuleName())){
queryWrapper.like(WarningRule::getRuleName, page.getRuleName());
}
if(!StringUtils.isBlank(page.getWarningType())){ if(!StringUtils.isBlank(page.getWarningType())){
queryWrapper.eq(WarningRule::getWarningType, page.getWarningType()); queryWrapper.eq(WarningRule::getWarningType, page.getWarningType());
} }
if(page.getWarningObj() != null){
queryWrapper.eq(WarningRule::getWarningObj, page.getWarningObj());
}
if(page.getWarningLevel() != null){
queryWrapper.eq(WarningRule::getWarningLevel, page.getWarningLevel());
}
if(page.getStatus() != null){
queryWrapper.eq(WarningRule::getStatus, page.getStatus());
}
queryWrapper.orderByDesc(WarningRule::getCreateTime); queryWrapper.orderByDesc(WarningRule::getCreateTime);
Page<WarningRule> warningRulePage = this.baseMapper.selectPage(page.getPageSo().toPage(), queryWrapper); Page<WarningRule> warningRulePage = this.baseMapper.selectPage(page.getPageSo().toPage(), queryWrapper);
@ -62,13 +68,7 @@ public class WarningRuleService extends ServiceImpl<WarningRuleMapper, WarningRu
save(dto); save(dto);
List<WarningCondition> conditions = dto.getConditions(); List<WarningCondition> conditions = dto.getConditions();
for (WarningCondition condition : conditions) { for (WarningCondition condition : conditions) {
// WarningCondition warningCondition = warningConditionService.checkConditionExists(condition);
// if(warningCondition != null){
// throw new IllegalArgumentException("对不起,该预警规则已配置");
// }
condition.setRuleId(dto.getId()); condition.setRuleId(dto.getId());
condition.setWarningType(dto.getWarningType());
condition.setWarningLevel(dto.getWarningLevel());
} }
warningConditionService.saveBatch(conditions); warningConditionService.saveBatch(conditions);
return dto; return dto;

View File

@ -96,15 +96,15 @@ public class WarningRuleTask {
// 这里可以根据 isRuleSatisfied 进行后续处理,比如触发预警等 // 这里可以根据 isRuleSatisfied 进行后续处理,比如触发预警等
if (isRuleSatisfied) { if (isRuleSatisfied) {
log.info("预警规则 {} 满足条件,触发预警", warningRule.getRuleName()); log.info("预警规则 {} 满足条件,触发预警", warningRule.getId());
// 生成规则信息 // 生成规则信息
String ruleInfo = generateRuleInfo(conditions); String ruleInfo = generateRuleInfo(conditions);
WarningRuleInfo warningRuleInfo = new WarningRuleInfo(); WarningRuleInfo warningRuleInfo = new WarningRuleInfo();
warningRuleInfo.setCreateName(warningRule.getCreateName()); // warningRuleInfo.setCreateName(warningRule.getCreateName());
warningRuleInfo.setRuleId(warningRule.getId()); warningRuleInfo.setRuleId(warningRule.getId());
warningRuleInfo.setRuleName(warningRule.getRuleName()); // warningRuleInfo.setRuleName(warningRule.getRuleName());
warningRuleInfo.setConditions(conditions); warningRuleInfo.setConditions(conditions);
warningRuleInfo.setCreateTime(LocalDateTime.now()); warningRuleInfo.setCreateTime(LocalDateTime.now());
warningRuleInfo.setRuleInfo(ruleInfo); warningRuleInfo.setRuleInfo(ruleInfo);
@ -141,8 +141,10 @@ public class WarningRuleTask {
* - * -
*/ */
private String generateSingleConditionInfo(WarningCondition condition) { private String generateSingleConditionInfo(WarningCondition condition) {
String indicatorType = condition.getIndicatorType(); // String indicatorType = condition.getIndicatorType();
String stcd = condition.getStcd(); // String stcd = condition.getStcd();
String indicatorType = null;
String stcd = null;
String stnm=""; String stnm="";
List<StStbprpB> stStbprpBS = stStbprpBService.lambdaQuery().eq(StStbprpB::getStcd, stcd).last("limit 1").list(); List<StStbprpB> stStbprpBS = stStbprpBService.lambdaQuery().eq(StStbprpB::getStcd, stcd).last("limit 1").list();
if(stStbprpBS != null && !stStbprpBS.isEmpty()){ if(stStbprpBS != null && !stStbprpBS.isEmpty()){
@ -167,10 +169,10 @@ public class WarningRuleTask {
stnm, durationHours != null ? durationHours : 24, stnm, durationHours != null ? durationHours : 24,
currentRainfall, condition.getOperator(), thresholdValue); currentRainfall, condition.getOperator(), thresholdValue);
case "WATER_STORAGE": // case "WATER_STORAGE":
BigDecimal currentStoragePercent = getWaterStorage(condition.getYear()); // BigDecimal currentStoragePercent = getWaterStorage(condition.getYear());
return String.format("蓄水量 %s 同期%s%%", // return String.format("蓄水量 %s 同期%s%%",
condition.getOperator(), thresholdValue); // condition.getOperator(), thresholdValue);
case "FORECAST_RAINFALL": case "FORECAST_RAINFALL":
return String.format("%s测点未来%dh降雨量 %s %smm", return String.format("%s测点未来%dh降雨量 %s %smm",
@ -186,8 +188,10 @@ public class WarningRuleTask {
* *
*/ */
private BigDecimal calculateActualValue(WarningCondition condition, String warningType) { private BigDecimal calculateActualValue(WarningCondition condition, String warningType) {
String indicatorType = condition.getIndicatorType(); // String indicatorType = condition.getIndicatorType();
String stcd = condition.getStcd(); // String stcd = condition.getStcd();
String indicatorType = null;
String stcd = null;
Integer durationHours = condition.getDurationHours(); Integer durationHours = condition.getDurationHours();
switch (indicatorType) { switch (indicatorType) {
@ -198,7 +202,7 @@ public class WarningRuleTask {
case "RAINFALL": case "RAINFALL":
return getRealRainFall(stcd, durationHours); return getRealRainFall(stcd, durationHours);
case "WATER_STORAGE": case "WATER_STORAGE":
return getWaterStorage(condition.getYear()); // return getWaterStorage(condition.getYear());
case "FORECAST_RAINFALL": case "FORECAST_RAINFALL":
return getForecastRainFall(stcd, durationHours); return getForecastRainFall(stcd, durationHours);
default: default: