歧义值管理 全局规则和测站规则缓存修改, 规则修改缓存清理修改,测站规则绑定缓存清理修改,歧异值判断接口测试修改, 规则查询修改
parent
cdd4f29989
commit
ac7e31bc23
|
|
@ -30,8 +30,8 @@ public class Knife4jConfiguration {
|
||||||
|
|
||||||
private ApiInfo getApiInfoBuilder() {
|
private ApiInfo getApiInfoBuilder() {
|
||||||
return new ApiInfoBuilder()
|
return new ApiInfoBuilder()
|
||||||
.title("奇异值管理api")
|
.title("歧义数据管理api")
|
||||||
.description("# 奇异值管理api RESTful APIs")
|
.description("# 歧义数据管理api RESTful APIs")
|
||||||
.termsOfServiceUrl("http://219.138.108.99:19000/jszx")
|
.termsOfServiceUrl("http://219.138.108.99:19000/jszx")
|
||||||
.contact(new Contact("湖北纬皓端成", null, null))
|
.contact(new Contact("湖北纬皓端成", null, null))
|
||||||
.version("1.0")
|
.version("1.0")
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package com.whdc.controller;
|
package com.whdc.controller;
|
||||||
|
|
||||||
|
|
||||||
import com.whdc.model.bean.ItemType;
|
|
||||||
import com.whdc.model.dto.FindRuleDto;
|
import com.whdc.model.dto.FindRuleDto;
|
||||||
import com.whdc.model.entity.ERule;
|
import com.whdc.model.entity.ERule;
|
||||||
import com.whdc.model.entity.EStationRules;
|
import com.whdc.model.entity.EStationRules;
|
||||||
|
|
@ -10,11 +9,11 @@ import com.whdc.model.group.Update;
|
||||||
import com.whdc.service.IERuleService;
|
import com.whdc.service.IERuleService;
|
||||||
import com.whdc.service.IEStationRulesService;
|
import com.whdc.service.IEStationRulesService;
|
||||||
import com.whdc.utils.ResultJson;
|
import com.whdc.utils.ResultJson;
|
||||||
|
import com.whdc.valid.bean.ItemType;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
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.*;
|
||||||
|
|
@ -28,7 +27,7 @@ import java.util.Objects;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Api(tags = "规则管理 - Controller")
|
@Api(tags = "规则管理 - Controller")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/v2/eRule")
|
@RequestMapping("/eRule")
|
||||||
public class ERuleController {
|
public class ERuleController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
@ -68,9 +67,12 @@ public class ERuleController {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
StringUtils.isBlank(model.getDiffMax())
|
Objects.isNull(model.getDiffMax())
|
||||||
&& StringUtils.isBlank(model.getMin())
|
&& Objects.isNull(model.getMin())
|
||||||
&& StringUtils.isBlank(model.getMax())
|
&& Objects.isNull(model.getMax())
|
||||||
|
&& Objects.isNull(model.getDuration())
|
||||||
|
&& Objects.isNull(model.getLagTime())
|
||||||
|
&& Objects.isNull(model.getLeadingTime())
|
||||||
){
|
){
|
||||||
return ResultJson.error("请设置规则");
|
return ResultJson.error("请设置规则");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.whdc.controller;
|
package com.whdc.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.whdc.model.dto.ERuleDtoTest;
|
||||||
import com.whdc.model.dto.FindStationDto;
|
import com.whdc.model.dto.FindStationDto;
|
||||||
import com.whdc.model.entity.EStationRules;
|
import com.whdc.model.entity.EStationRules;
|
||||||
import com.whdc.model.group.Insert;
|
import com.whdc.model.group.Insert;
|
||||||
|
|
@ -8,6 +9,7 @@ import com.whdc.model.group.Update;
|
||||||
import com.whdc.service.IERuleService;
|
import com.whdc.service.IERuleService;
|
||||||
import com.whdc.service.IEStationRulesService;
|
import com.whdc.service.IEStationRulesService;
|
||||||
import com.whdc.utils.ResultJson;
|
import com.whdc.utils.ResultJson;
|
||||||
|
import com.whdc.valid.service.ValidateService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
|
@ -23,7 +25,7 @@ import java.util.Objects;
|
||||||
*/
|
*/
|
||||||
@Api(tags = "站点规则管理 - Controller")
|
@Api(tags = "站点规则管理 - Controller")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/v2/eStationRule")
|
@RequestMapping("/eStationRule")
|
||||||
public class EStationRulesController {
|
public class EStationRulesController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
@ -109,4 +111,13 @@ public class EStationRulesController {
|
||||||
return ResultJson.ok(ieStationRulesService.removeById(id,model));
|
return ResultJson.ok(ieStationRulesService.removeById(id,model));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ValidateService validateService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "规则测试 ")
|
||||||
|
@PostMapping(value = "testRule")
|
||||||
|
public ResultJson testRule(@RequestBody ERuleDtoTest test) {
|
||||||
|
return ResultJson.ok(validateService.validate(test.getStr() ,test.getOldStr()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import javax.validation.constraints.Max;
|
import javax.validation.constraints.Max;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
@ -59,7 +60,7 @@ public class ERule extends Model<ERule> {
|
||||||
*/
|
*/
|
||||||
@ApiParam(value = "规则类型", required = true, example = "")
|
@ApiParam(value = "规则类型", required = true, example = "")
|
||||||
@ApiModelProperty(value = "规则类型", required = true, dataType = "String")
|
@ApiModelProperty(value = "规则类型", required = true, dataType = "String")
|
||||||
@TableField(value = "ITEM", updateStrategy = FieldStrategy.NOT_EMPTY)
|
@TableField(value = "ITEM", updateStrategy = FieldStrategy.IGNORED)
|
||||||
@NotEmpty(message = "规则类型不能为空", groups = {Insert.class,Update.class})
|
@NotEmpty(message = "规则类型不能为空", groups = {Insert.class,Update.class})
|
||||||
@Max(50)
|
@Max(50)
|
||||||
private String item;
|
private String item;
|
||||||
|
|
@ -77,34 +78,34 @@ public class ERule extends Model<ERule> {
|
||||||
* 最小值
|
* 最小值
|
||||||
*/
|
*/
|
||||||
@ApiParam(value = "最小值", required = false, example = "")
|
@ApiParam(value = "最小值", required = false, example = "")
|
||||||
@ApiModelProperty(value = "最小值", required = false, dataType = "String")
|
@ApiModelProperty(value = "最小值", required = false, dataType = "Numeric")
|
||||||
@TableField(value = "MIN", updateStrategy = FieldStrategy.NOT_EMPTY)
|
@TableField(value = "MIN", updateStrategy = FieldStrategy.IGNORED)
|
||||||
@Max(50)
|
@Max(50)
|
||||||
private String min;
|
private BigDecimal min;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最大值
|
* 最大值
|
||||||
*/
|
*/
|
||||||
@ApiParam(value = "最大值", required = false, example = "")
|
@ApiParam(value = "最大值", required = false, example = "")
|
||||||
@ApiModelProperty(value = "最大值", required = false, dataType = "String")
|
@ApiModelProperty(value = "最大值", required = false, dataType = "Numeric")
|
||||||
@TableField(value = "MAX", updateStrategy = FieldStrategy.NOT_EMPTY)
|
@TableField(value = "MAX", updateStrategy = FieldStrategy.IGNORED)
|
||||||
@Max(50)
|
@Max(50)
|
||||||
private String max;
|
private BigDecimal max;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最大值
|
* 最大值
|
||||||
*/
|
*/
|
||||||
@ApiParam(value = "两条数据之间的最大差值", required = false, example = "")
|
@ApiParam(value = "两条数据之间的最大差值", required = false, example = "")
|
||||||
@ApiModelProperty(value = "两条数据之间的最大差值", required = false, dataType = "String")
|
@ApiModelProperty(value = "两条数据之间的最大差值", required = false, dataType = "Numeric")
|
||||||
@TableField(value = "DIFF_MAX", updateStrategy = FieldStrategy.NOT_EMPTY)
|
@TableField(value = "DIFF_MAX", updateStrategy = FieldStrategy.IGNORED)
|
||||||
private String diffMax;
|
private BigDecimal diffMax;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最大值
|
* 最大值
|
||||||
*/
|
*/
|
||||||
@ApiParam(value = "时间段, 单位 s", required = false, example = "")
|
@ApiParam(value = "时间段, 单位 s", required = false, example = "")
|
||||||
@ApiModelProperty(value = "时间段, 单位 s", required = false, dataType = "Integer")
|
@ApiModelProperty(value = "时间段, 单位 s", required = false, dataType = "Numeric")
|
||||||
@TableField(value = "DURATION", updateStrategy = FieldStrategy.NOT_EMPTY)
|
@TableField(value = "DURATION", updateStrategy = FieldStrategy.IGNORED)
|
||||||
@Max(10)
|
@Max(10)
|
||||||
private Integer duration;
|
private Integer duration;
|
||||||
|
|
||||||
|
|
@ -112,8 +113,8 @@ public class ERule extends Model<ERule> {
|
||||||
* 接收超出时间,单位: s ,指接收时间超前范围
|
* 接收超出时间,单位: s ,指接收时间超前范围
|
||||||
*/
|
*/
|
||||||
@ApiParam(value = "接收超前时间,单位: s ,指接收时间超前范围", required = false, example = "")
|
@ApiParam(value = "接收超前时间,单位: s ,指接收时间超前范围", required = false, example = "")
|
||||||
@ApiModelProperty(value = "接收超前时间,单位: s ,指接收时间超前范围", required = false, dataType = "Integer")
|
@ApiModelProperty(value = "接收超前时间,单位: s ,指接收时间超前范围", required = false, dataType = "Numeric")
|
||||||
@TableField(value = "LEADING_TIME", updateStrategy = FieldStrategy.NOT_EMPTY)
|
@TableField(value = "LEADING_TIME", updateStrategy = FieldStrategy.IGNORED)
|
||||||
@Max(10)
|
@Max(10)
|
||||||
private Integer leadingTime;
|
private Integer leadingTime;
|
||||||
|
|
||||||
|
|
@ -121,8 +122,8 @@ public class ERule extends Model<ERule> {
|
||||||
* 接收滞后时间,单位: s ,指接收时间滞后范围
|
* 接收滞后时间,单位: s ,指接收时间滞后范围
|
||||||
*/
|
*/
|
||||||
@ApiParam(value = "接收滞后时间,单位: s ,指接收时间滞后范围", required = false, example = "")
|
@ApiParam(value = "接收滞后时间,单位: s ,指接收时间滞后范围", required = false, example = "")
|
||||||
@ApiModelProperty(value = "接收滞后时间,单位: s ,指接收时间滞后范围", required = false, dataType = "Integer")
|
@ApiModelProperty(value = "接收滞后时间,单位: s ,指接收时间滞后范围", required = false, dataType = "Numeric")
|
||||||
@TableField(value = "LAG_TIME", updateStrategy = FieldStrategy.NOT_EMPTY)
|
@TableField(value = "LAG_TIME", updateStrategy = FieldStrategy.IGNORED)
|
||||||
@Max(10)
|
@Max(10)
|
||||||
private Integer lagTime;
|
private Integer lagTime;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
package com.whdc.valid.bean;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author xusan
|
||||||
|
* @date 2023年3月22日10:32:54
|
||||||
|
* @description: 雨量值时间规则
|
||||||
|
*/
|
||||||
|
public enum IntvType {
|
||||||
|
|
||||||
|
IT001(300, "0.05"),
|
||||||
|
IT002(300, "0.08"),
|
||||||
|
IT003(3600, "1");
|
||||||
|
|
||||||
|
private Integer name;
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
public Integer getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(Integer name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
IntvType(Integer name, String value) {
|
||||||
|
this.name = name;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<JSONObject> list() {
|
||||||
|
List<JSONObject> list = new ArrayList<>();
|
||||||
|
IntvType[] values = IntvType.values();
|
||||||
|
for (IntvType type : values) {
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
obj.put("name", type.getName());
|
||||||
|
obj.put("value", type.getValue());
|
||||||
|
list.add(obj);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, IntvType> map() {
|
||||||
|
Map<String, IntvType> map = new HashMap<>();
|
||||||
|
IntvType[] values = IntvType.values();
|
||||||
|
for (IntvType e : values) {
|
||||||
|
map.put(e.getValue(), e);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IntvType getByValue(String value) {
|
||||||
|
if (StringUtils.isEmpty(value)) return null;
|
||||||
|
return map().get(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.whdc.model.bean;
|
package com.whdc.valid.bean;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
@ -18,7 +18,8 @@ public enum ItemType {
|
||||||
|
|
||||||
YU_LIANG("雨量", "P"),
|
YU_LIANG("雨量", "P"),
|
||||||
SHUI_WEI("水位", "Z"),
|
SHUI_WEI("水位", "Z"),
|
||||||
LIU_LIANG("流量", "Q");
|
LIU_LIANG("流量", "Q"),
|
||||||
|
TONG_YONG("通用", "ALL");
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private String value;
|
private String value;
|
||||||
|
|
@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
@ -26,7 +27,9 @@ public class RuleRedisService {
|
||||||
|
|
||||||
public List<ValidateVo> getRule(String stcd,ValidateMapper validateMapper) {
|
public List<ValidateVo> getRule(String stcd,ValidateMapper validateMapper) {
|
||||||
|
|
||||||
log.info("获取规则: " + stcd);
|
List<ValidateVo> rules = null;
|
||||||
|
|
||||||
|
log.info("获取规则: {}" , stcd);
|
||||||
|
|
||||||
String key = VALIDATE_REDIS_KEY + stcd;
|
String key = VALIDATE_REDIS_KEY + stcd;
|
||||||
|
|
||||||
|
|
@ -35,29 +38,48 @@ public class RuleRedisService {
|
||||||
List<String> json = ruleRedisTemplate.opsForList().range(key, 0, -1);
|
List<String> json = ruleRedisTemplate.opsForList().range(key, 0, -1);
|
||||||
|
|
||||||
if (CollectionUtils.isNotEmpty(json)) {
|
if (CollectionUtils.isNotEmpty(json)) {
|
||||||
return
|
|
||||||
json.stream()
|
rules = json.stream()
|
||||||
.filter(StringUtils::isNotBlank)
|
.filter(StringUtils::isNotBlank)
|
||||||
.map(s -> JSON.toJavaObject(JSON.parseObject(s), ValidateVo.class))
|
.map(s -> JSON.toJavaObject(JSON.parseObject(s), ValidateVo.class))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ValidateVo> rules = validateMapper.getRuleByStcd(stcd);
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
rules = validateMapper.getRuleByStcd(stcd);
|
||||||
|
|
||||||
log.info("保存规则: " + rules.size());
|
log.info("保存规则: " + rules.size());
|
||||||
|
|
||||||
if (CollectionUtils.isNotEmpty(rules)) {
|
if (CollectionUtils.isEmpty(rules)) {
|
||||||
|
rules = new ArrayList<>();
|
||||||
|
|
||||||
|
// 添加空号缓存
|
||||||
|
rules.add(new ValidateVo());
|
||||||
|
}
|
||||||
|
|
||||||
Long aLong = ruleRedisTemplate.opsForList().rightPushAll(key, rules.stream().map(JSON::toJSONString).collect(Collectors.toList()));
|
Long aLong = ruleRedisTemplate.opsForList().rightPushAll(key, rules.stream().map(JSON::toJSONString).collect(Collectors.toList()));
|
||||||
|
|
||||||
if (aLong != rules.size()) {
|
if (aLong != rules.size()) {
|
||||||
log.info("保存规则失败: " + key + "_" + rules.size());
|
log.info("保存规则失败: " + key + "_" + rules.size());
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
ruleRedisTemplate.opsForList().rightPushAll(key, "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (CollectionUtils.isNotEmpty(rules) && JSON.parseObject(JSON.toJSONString(rules.get(0))).isEmpty()){
|
||||||
|
rules.remove(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (CollectionUtils.isEmpty(rules)) {
|
||||||
|
// 查询通用规则
|
||||||
|
return this.getRule("ALL", validateMapper);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("获取规则条数: {}" , rules.size());
|
||||||
|
|
||||||
|
|
||||||
return rules;
|
return rules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,4 +21,5 @@ public interface ValidateMapper {
|
||||||
List<ValidateVo> getRuleByStcd(String stcd);
|
List<ValidateVo> getRuleByStcd(String stcd);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@ public class ValidateDto implements Serializable {
|
||||||
@ApiModelProperty(value = "监测时间", dataType = "java.lang.Date")
|
@ApiModelProperty(value = "监测时间", dataType = "java.lang.Date")
|
||||||
private Date tm;
|
private Date tm;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "累计时间", dataType = "java.lang.Date")
|
||||||
|
private String intv;
|
||||||
|
|
||||||
private Data data;
|
private Data data;
|
||||||
|
|
||||||
@lombok.Data
|
@lombok.Data
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ public class ValidateVo implements Serializable {
|
||||||
private BigDecimal max;
|
private BigDecimal max;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最大值
|
* 差值
|
||||||
*/
|
*/
|
||||||
@ApiParam(value = "两条数据之间的最大差值", required = false, example = "")
|
@ApiParam(value = "两条数据之间的最大差值", required = false, example = "")
|
||||||
@ApiModelProperty(value = "两条数据之间的最大差值", required = false, dataType = "String")
|
@ApiModelProperty(value = "两条数据之间的最大差值", required = false, dataType = "String")
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,8 @@ package com.whdc.valid.service;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONException;
|
import com.alibaba.fastjson.JSONException;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.whdc.model.bean.ItemType;
|
import com.whdc.valid.bean.IntvType;
|
||||||
|
import com.whdc.valid.bean.ItemType;
|
||||||
import com.whdc.valid.component.RuleRedisService;
|
import com.whdc.valid.component.RuleRedisService;
|
||||||
import com.whdc.valid.mapper.ValidateMapper;
|
import com.whdc.valid.mapper.ValidateMapper;
|
||||||
import com.whdc.valid.model.ValidateDto;
|
import com.whdc.valid.model.ValidateDto;
|
||||||
|
|
@ -20,7 +21,7 @@ import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.whdc.model.bean.ItemType.getByValue;
|
import static com.whdc.valid.bean.ItemType.getByValue;
|
||||||
import static com.whdc.valid.error.MyException.getException;
|
import static com.whdc.valid.error.MyException.getException;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -128,7 +129,7 @@ public class ValidateServiceImpl implements ValidateService {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Objects.isNull(min) && Objects.isNull(max) && Objects.isNull(leadingTime) && Objects.isNull(lagTime)) {
|
if (Objects.isNull(min) && Objects.isNull(max)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -208,6 +209,9 @@ public class ValidateServiceImpl implements ValidateService {
|
||||||
prevDto = getValidateDto(prevJson); // 老差值
|
prevDto = getValidateDto(prevJson); // 老差值
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String intv = dto.getIntv();
|
||||||
|
|
||||||
ValidateDto.Data data = dto.getData();
|
ValidateDto.Data data = dto.getData();
|
||||||
BigDecimal p = data.getP();
|
BigDecimal p = data.getP();
|
||||||
BigDecimal z = data.getZ();
|
BigDecimal z = data.getZ();
|
||||||
|
|
@ -235,6 +239,8 @@ public class ValidateServiceImpl implements ValidateService {
|
||||||
|
|
||||||
for (ValidateVo vo : rule) {
|
for (ValidateVo vo : rule) {
|
||||||
|
|
||||||
|
Integer duration = vo.getDuration();
|
||||||
|
|
||||||
BigDecimal min = vo.getMin();
|
BigDecimal min = vo.getMin();
|
||||||
BigDecimal max = vo.getMax();
|
BigDecimal max = vo.getMax();
|
||||||
Integer leadingTime = vo.getLeadingTime();
|
Integer leadingTime = vo.getLeadingTime();
|
||||||
|
|
@ -242,7 +248,6 @@ public class ValidateServiceImpl implements ValidateService {
|
||||||
String item = vo.getItem();
|
String item = vo.getItem();
|
||||||
ItemType itemType = getByValue(item);
|
ItemType itemType = getByValue(item);
|
||||||
|
|
||||||
if (Objects.nonNull(min) && Objects.nonNull(max) && Objects.nonNull(leadingTime) && Objects.nonNull(lagTime)) {
|
|
||||||
if (Objects.nonNull(leadingTime)) {
|
if (Objects.nonNull(leadingTime)) {
|
||||||
long time = currentTime + (leadingTime * 1000);
|
long time = currentTime + (leadingTime * 1000);
|
||||||
if (tm.getTime() > time) {
|
if (tm.getTime() > time) {
|
||||||
|
|
@ -259,6 +264,8 @@ public class ValidateServiceImpl implements ValidateService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Objects.nonNull(min) || Objects.nonNull(max)) {
|
||||||
|
|
||||||
|
|
||||||
if (StringUtils.isBlank(item)) {
|
if (StringUtils.isBlank(item)) {
|
||||||
log.info("规则类型为空");
|
log.info("规则类型为空");
|
||||||
|
|
@ -272,9 +279,24 @@ public class ValidateServiceImpl implements ValidateService {
|
||||||
|
|
||||||
switch (itemType) {
|
switch (itemType) {
|
||||||
case YU_LIANG: { // 雨量判断 P
|
case YU_LIANG: { // 雨量判断 P
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(intv) && Objects.nonNull(duration)){
|
||||||
|
IntvType intvType = IntvType.getByValue(intv);
|
||||||
|
|
||||||
|
if (Objects.nonNull(intvType)){
|
||||||
|
if (Objects.equals(intvType.getName(), duration)) {
|
||||||
if (!rangeRuleValidate(p, min, max)) {
|
if (!rangeRuleValidate(p, min, max)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
|
||||||
|
if (!rangeRuleValidate(p, min, max)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -321,7 +343,7 @@ public class ValidateServiceImpl implements ValidateService {
|
||||||
Date oldTm = prevDto.getTm();
|
Date oldTm = prevDto.getTm();
|
||||||
|
|
||||||
BigDecimal diffMax = vo.getDiffMax();
|
BigDecimal diffMax = vo.getDiffMax();
|
||||||
Integer duration = vo.getDuration();
|
|
||||||
|
|
||||||
if (Objects.nonNull(duration)) {
|
if (Objects.nonNull(duration)) {
|
||||||
|
|
||||||
|
|
@ -334,6 +356,10 @@ public class ValidateServiceImpl implements ValidateService {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Objects.isNull(diffMax)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
switch (itemType) {
|
switch (itemType) {
|
||||||
case YU_LIANG: { // 雨量判断 P
|
case YU_LIANG: { // 雨量判断 P
|
||||||
if (Objects.nonNull(p) && Objects.nonNull(oldP) && Math.abs(p.subtract(oldP).doubleValue()) > diffMax.doubleValue()) {
|
if (Objects.nonNull(p) && Objects.nonNull(oldP) && Math.abs(p.subtract(oldP).doubleValue()) > diffMax.doubleValue()) {
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,12 @@ spring:
|
||||||
datasource:
|
datasource:
|
||||||
type: com.alibaba.druid.pool.DruidDataSource
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
driver-class-name: dm.jdbc.driver.DmDriver
|
driver-class-name: dm.jdbc.driver.DmDriver
|
||||||
# url: jdbc:dm://127.0.0.1:5236?schema=SYSDBA
|
url: jdbc:dm://127.0.0.1:5236?schema=SYSDBA
|
||||||
# username: SYSDBA
|
username: SYSDBA
|
||||||
# password: 199999999
|
password: 199999999
|
||||||
url: jdbc:dm://10.42.6.247:5236?schema=SHZH
|
# url: jdbc:dm://10.42.6.247:5236?schema=SHZH
|
||||||
username: SHZH
|
# username: SHZH
|
||||||
password: Shzh_890
|
# password: Shzh_890
|
||||||
druid:
|
druid:
|
||||||
initialSize: 5
|
initialSize: 5
|
||||||
minIdle: 5
|
minIdle: 5
|
||||||
|
|
@ -35,17 +35,17 @@ spring:
|
||||||
# Redis
|
# Redis
|
||||||
redis:
|
redis:
|
||||||
database: 5
|
database: 5
|
||||||
host: 10.42.6.75
|
# host: 10.42.6.75
|
||||||
# host: 127.0.0.1
|
host: 127.0.0.1
|
||||||
port: 6379
|
port: 6379
|
||||||
# password:
|
password:
|
||||||
password: Whdc_890
|
# password: Whdc_890
|
||||||
|
|
||||||
# 数据清洗专用redis
|
# 数据清洗专用redis
|
||||||
redisRules:
|
redisRules:
|
||||||
database: 6
|
database: 6
|
||||||
host: 10.42.6.75
|
# host: 10.42.6.75
|
||||||
# host: 127.0.0.1
|
host: 127.0.0.1
|
||||||
port: 6379
|
port: 6379
|
||||||
# password: Whdc_890
|
# password: Whdc_890
|
||||||
password:
|
password:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue