修改 预警/告警事务的数据生成策略
This commit is contained in:
@@ -12,10 +12,17 @@ import java.util.List;
|
|||||||
public class SourceSteadyIndicator {
|
public class SourceSteadyIndicator {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
|
/**
|
||||||
|
* 干扰源数据字典Id
|
||||||
|
*/
|
||||||
private String interferenceSource;
|
private String interferenceSource;
|
||||||
|
/**
|
||||||
|
* 0 是与 ,1 是或
|
||||||
|
*/
|
||||||
private Integer operation;
|
private Integer operation;
|
||||||
|
/**
|
||||||
|
* 指标参数数据字典Id集合
|
||||||
|
*/
|
||||||
private List<String> steadyIndicator;
|
private List<String> steadyIndicator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,4 +37,8 @@ public class SourceSteadyIndicator {
|
|||||||
* 类型(0:预警;1:告警)
|
* 类型(0:预警;1:告警)
|
||||||
*/
|
*/
|
||||||
private Integer type;
|
private Integer type;
|
||||||
|
/**
|
||||||
|
* 监测点id
|
||||||
|
*/
|
||||||
|
private String monitorId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,5 +51,10 @@ public class ThsStrategyVo {
|
|||||||
* 干扰源类型id
|
* 干扰源类型id
|
||||||
*/
|
*/
|
||||||
private List<String> interferenceSource;
|
private List<String> interferenceSource;
|
||||||
|
/**
|
||||||
|
* 监测点id
|
||||||
|
*/
|
||||||
|
private String monitorId;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.njcn.prepare.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum BigTypeEnum {
|
||||||
|
COMMON(0, "通用策略"),
|
||||||
|
CUSTOM(1, "定制策略");
|
||||||
|
|
||||||
|
private final Integer code;
|
||||||
|
|
||||||
|
private final String message;
|
||||||
|
|
||||||
|
BigTypeEnum(Integer code, String message) {
|
||||||
|
this.code = code;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@ import lombok.Getter;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public enum TypeEnum {
|
public enum TypeEnum {
|
||||||
MONITOR_TYPE(0, "指标类型"),
|
MONITOR_TYPE(0, "监测点表类型"),
|
||||||
INTERFERENCE_TYPE(1, "指标类型"),
|
INTERFERENCE_TYPE(1, "指标类型"),
|
||||||
SOURCE_TYPE(2, "干扰源类型");
|
SOURCE_TYPE(2, "干扰源类型");
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
package com.njcn.prepare.harmonic.controller.line;
|
package com.njcn.prepare.harmonic.controller.line;
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ package com.njcn.prepare.harmonic.controller.line;
|
|||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.prepare.harmonic.service.mysql.line.ThsSuperviseService;
|
import com.njcn.prepare.harmonic.service.mysql.line.ThsSuperviseService;
|
||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -20,6 +21,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
* @author lxp
|
* @author lxp
|
||||||
* @since 2023-03-16
|
* @since 2023-03-16
|
||||||
*/
|
*/
|
||||||
|
@Api(tags = "预警-告警事务数据生成")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/thsSupervise")
|
@RequestMapping("/thsSupervise")
|
||||||
public class ThsSuperviseController extends BaseController {
|
public class ThsSuperviseController extends BaseController {
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ package com.njcn.prepare.harmonic.mapper.mysql.line;
|
|||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.njcn.device.pms.pojo.po.Monitor;
|
import com.njcn.device.pms.pojo.po.Monitor;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yzh
|
* @author yzh
|
||||||
@@ -11,5 +14,11 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface PmsMonitorMapper extends BaseMapper<Monitor> {
|
public interface PmsMonitorMapper extends BaseMapper<Monitor> {
|
||||||
|
/**
|
||||||
|
* 查询所有干扰源类型的监测点
|
||||||
|
* @param monitorIdList
|
||||||
|
* @param codeList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Monitor> queryConfigMonitor(@Param("monitorIdList") List<String> monitorIdList, @Param("codeList") List<String> codeList);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.njcn.prepare.harmonic.mapper.mysql.line.PmsMonitorMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<select id="queryConfigMonitor" resultType="com.njcn.device.pms.pojo.po.Monitor">
|
||||||
|
select pm.* from pms_monitor pm left join sys_dict_data sdd on pm.Monitor_Tag =sdd.Id
|
||||||
|
<where>
|
||||||
|
<if test="codeList != null and codeList.size() >0">
|
||||||
|
AND sdd.code IN
|
||||||
|
<foreach collection="codeList" item="item" open="(" close=")" separator=",">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="monitorIdList != null and monitorIdList.size() >0">
|
||||||
|
AND pm.id IN
|
||||||
|
<foreach collection="monitorIdList" item="item" open="(" close=")" separator=",">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
@@ -10,10 +10,11 @@
|
|||||||
tws.grade,
|
tws.grade,
|
||||||
tws.operation,
|
tws.operation,
|
||||||
tws.type,
|
tws.type,
|
||||||
|
Monitor_Id as monitorId,
|
||||||
tda.dept_Id as deptId
|
tda.dept_Id as deptId
|
||||||
from
|
from
|
||||||
ths_warn_strategy tws
|
ths_warn_strategy tws
|
||||||
left join ths_dept_alarm tda on
|
INNER join ths_dept_alarm tda on
|
||||||
tws.Id = tda.Alarm_Id
|
tws.Id = tda.Alarm_Id
|
||||||
<where>
|
<where>
|
||||||
<choose>
|
<choose>
|
||||||
@@ -24,6 +25,7 @@
|
|||||||
tws.State = 1 and tws.Grade in(1,2)
|
tws.State = 1 and tws.Grade in(1,2)
|
||||||
</when>
|
</when>
|
||||||
</choose>
|
</choose>
|
||||||
|
and tws.Big_Type=1
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -19,12 +19,11 @@ import com.njcn.harmonic.pojo.vo.ThsStrategyVo;
|
|||||||
import com.njcn.prepare.enums.*;
|
import com.njcn.prepare.enums.*;
|
||||||
import com.njcn.prepare.harmonic.mapper.mysql.line.*;
|
import com.njcn.prepare.harmonic.mapper.mysql.line.*;
|
||||||
import com.njcn.prepare.harmonic.service.mysql.line.ThsSuperviseService;
|
import com.njcn.prepare.harmonic.service.mysql.line.ThsSuperviseService;
|
||||||
import com.njcn.process.pojo.po.LimitRate;
|
import com.njcn.process.pojo.po.*;
|
||||||
import com.njcn.process.pojo.po.ThsOverRunLog;
|
|
||||||
import com.njcn.process.pojo.po.ThsSupervise;
|
|
||||||
import com.njcn.process.pojo.po.ThsWarnStrategyAss;
|
|
||||||
import com.njcn.system.api.DicDataFeignClient;
|
import com.njcn.system.api.DicDataFeignClient;
|
||||||
import com.njcn.system.pojo.po.DictData;
|
import com.njcn.system.pojo.po.DictData;
|
||||||
|
import com.njcn.user.api.DeptFeignClient;
|
||||||
|
import com.njcn.user.pojo.vo.PvTerminalTreeVO;
|
||||||
import org.apache.commons.collections.map.HashedMap;
|
import org.apache.commons.collections.map.HashedMap;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -61,6 +60,8 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
|
|||||||
private ThsSuperviseMapper thsSuperviseMapper;
|
private ThsSuperviseMapper thsSuperviseMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ThsOverRunLogMapper thsOverRunLogMapper;
|
private ThsOverRunLogMapper thsOverRunLogMapper;
|
||||||
|
@Autowired
|
||||||
|
private DeptFeignClient deptFeignClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HttpResult<Boolean> initSupervise(Integer initType) {
|
public HttpResult<Boolean> initSupervise(Integer initType) {
|
||||||
@@ -72,15 +73,14 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
|
|||||||
if (CollectionUtil.isNotEmpty(thsStrategyList)) {
|
if (CollectionUtil.isNotEmpty(thsStrategyList)) {
|
||||||
Map<String, List<ThsStrategyVo>> deptMap = thsStrategyList.stream().collect(Collectors.groupingBy(ThsStrategyVo::getDeptId));
|
Map<String, List<ThsStrategyVo>> deptMap = thsStrategyList.stream().collect(Collectors.groupingBy(ThsStrategyVo::getDeptId));
|
||||||
for (Map.Entry<String, List<ThsStrategyVo>> entry : deptMap.entrySet()) {
|
for (Map.Entry<String, List<ThsStrategyVo>> entry : deptMap.entrySet()) {
|
||||||
String deptId = entry.getKey();
|
|
||||||
List<ThsStrategyVo> deptList = entry.getValue();
|
List<ThsStrategyVo> deptList = entry.getValue();
|
||||||
List<ThsStrategyVo> oneLevel = deptList.stream().filter(r -> r.getGrade().equals(GradeEnum.ONE_LEVEL.getCode())).collect(Collectors.toList());//一级策略集合
|
List<ThsStrategyVo> oneLevel = deptList.stream().filter(r -> !GradeEnum.THREE_LEVEL.getCode().equals(r.getGrade())).collect(Collectors.toList());//一级或二级策略集合
|
||||||
List<SourceSteadyIndicator> oneSourceSteadyIndicatorList = new ArrayList<>();
|
List<SourceSteadyIndicator> oneSourceSteadyIndicatorList = new ArrayList<>();
|
||||||
if (CollectionUtil.isNotEmpty(oneLevel)) {
|
if (CollectionUtil.isNotEmpty(oneLevel)) {
|
||||||
for (ThsStrategyVo oneStrategyVo : oneLevel) {
|
for (ThsStrategyVo oneStrategyVo : oneLevel) {
|
||||||
List<ThsWarnStrategyAss> oneInterferenceSourceAsses = this.queryWarnStrategyAss(oneStrategyVo, TypeEnum.SOURCE_TYPE);//干扰源列表
|
List<ThsWarnStrategyAss> oneInterferenceSourceAsses = this.queryWarnStrategyAss(oneStrategyVo.getId(), TypeEnum.SOURCE_TYPE);//干扰源列表
|
||||||
List<ThsWarnStrategyAss> oneSteadyIndicatorAsses = this.queryWarnStrategyAss(oneStrategyVo, TypeEnum.INTERFERENCE_TYPE);//干扰源列表
|
List<ThsWarnStrategyAss> oneSteadyIndicatorAsses = this.queryWarnStrategyAss(oneStrategyVo.getId(), TypeEnum.INTERFERENCE_TYPE);//干扰源列表
|
||||||
List<String> oneSteadyIndicatorAssesIds = oneSteadyIndicatorAsses.stream().map(r -> r.getAssId()).collect(Collectors.toList());
|
List<String> oneSteadyIndicatorAssesIds = oneSteadyIndicatorAsses.stream().map(ThsWarnStrategyAss::getAssId).collect(Collectors.toList());
|
||||||
//封装每一种干扰源和对应的指标
|
//封装每一种干扰源和对应的指标
|
||||||
for (ThsWarnStrategyAss oneWarnStrategyAss : oneInterferenceSourceAsses) {
|
for (ThsWarnStrategyAss oneWarnStrategyAss : oneInterferenceSourceAsses) {
|
||||||
SourceSteadyIndicator build = SourceSteadyIndicator.builder().id(oneStrategyVo.getId()).operation(oneStrategyVo.getOperation())
|
SourceSteadyIndicator build = SourceSteadyIndicator.builder().id(oneStrategyVo.getId()).operation(oneStrategyVo.getOperation())
|
||||||
@@ -88,36 +88,34 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
|
|||||||
.steadyIndicator(oneSteadyIndicatorAssesIds)
|
.steadyIndicator(oneSteadyIndicatorAssesIds)
|
||||||
.deptId(oneStrategyVo.getDeptId())
|
.deptId(oneStrategyVo.getDeptId())
|
||||||
.type(oneStrategyVo.getType())
|
.type(oneStrategyVo.getType())
|
||||||
|
.monitorId(oneStrategyVo.getMonitorId())
|
||||||
.build();
|
.build();
|
||||||
oneSourceSteadyIndicatorList.add(build);
|
oneSourceSteadyIndicatorList.add(build);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<ThsStrategyVo> threeLevel = deptList.stream().filter(r -> r.getGrade().equals(GradeEnum.THREE_LEVEL.getCode())).collect(Collectors.toList());//三级策略集合
|
List<ThsStrategyVo> threeLevel = deptList.stream().filter(r -> GradeEnum.THREE_LEVEL.getCode().equals(r.getGrade())).collect(Collectors.toList());//三级策略集合
|
||||||
if (CollectionUtil.isNotEmpty(threeLevel)) {
|
if (CollectionUtil.isNotEmpty(threeLevel)) {
|
||||||
for (ThsStrategyVo threeStrategyVo : threeLevel) {
|
for (ThsStrategyVo threeStrategyVo : threeLevel) {
|
||||||
List<ThsWarnStrategyAss> interferenceSourceAsses = this.queryWarnStrategyAss(threeStrategyVo, TypeEnum.SOURCE_TYPE);
|
|
||||||
//干扰源类型id
|
|
||||||
List<String> threeInterferenceSourceIds = interferenceSourceAsses.stream().map(p -> p.getAssId()).collect(Collectors.toList());
|
|
||||||
List<ThsWarnStrategyAss> threeSteadyIndicatorAsses = this.queryWarnStrategyAss(threeStrategyVo, TypeEnum.INTERFERENCE_TYPE);
|
|
||||||
//指标类型id
|
|
||||||
List<String> steadyIndicatorIds = threeSteadyIndicatorAsses.stream().map(p -> p.getAssId()).collect(Collectors.toList());
|
|
||||||
for (String threeInterferenceSourceId : threeInterferenceSourceIds) {
|
|
||||||
if (OperationEnum.AND.getCode().equals(threeStrategyVo.getOperation())) {//处理三级策略的与
|
|
||||||
Iterator<SourceSteadyIndicator> iterator = oneSourceSteadyIndicatorList.iterator();
|
Iterator<SourceSteadyIndicator> iterator = oneSourceSteadyIndicatorList.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
SourceSteadyIndicator sourceSteady = iterator.next();
|
SourceSteadyIndicator sourceSteady = iterator.next();
|
||||||
|
if (StringUtils.equals(threeStrategyVo.getMonitorId(), sourceSteady.getMonitorId())) {
|
||||||
|
List<ThsWarnStrategyAss> interferenceSourceAsses = this.queryWarnStrategyAss(threeStrategyVo.getId(), TypeEnum.SOURCE_TYPE);
|
||||||
|
//干扰源类型id
|
||||||
|
List<String> threeInterferenceSourceIds = interferenceSourceAsses.stream().map(ThsWarnStrategyAss::getAssId).collect(Collectors.toList());
|
||||||
|
List<ThsWarnStrategyAss> threeSteadyIndicatorAsses = this.queryWarnStrategyAss(threeStrategyVo.getId(), TypeEnum.INTERFERENCE_TYPE);
|
||||||
|
//指标类型id
|
||||||
|
List<String> steadyIndicatorIds = threeSteadyIndicatorAsses.stream().map(ThsWarnStrategyAss::getAssId).collect(Collectors.toList());
|
||||||
|
for (String threeInterferenceSourceId : threeInterferenceSourceIds) {
|
||||||
|
if (OperationEnum.AND.getCode().equals(threeStrategyVo.getOperation())) {//处理三级策略的与
|
||||||
if (OperationEnum.AND.getCode().equals(sourceSteady.getOperation())) {
|
if (OperationEnum.AND.getCode().equals(sourceSteady.getOperation())) {
|
||||||
if (StringUtils.equals(threeInterferenceSourceId, sourceSteady.getInterferenceSource()) &&
|
if (StringUtils.equals(threeInterferenceSourceId, sourceSteady.getInterferenceSource()) &&
|
||||||
steadyIndicatorIds.containsAll(sourceSteady.getSteadyIndicator())) {
|
steadyIndicatorIds.containsAll(sourceSteady.getSteadyIndicator())) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {//处理三级策略的或
|
} else {//处理三级策略的或
|
||||||
Iterator<SourceSteadyIndicator> iterator = oneSourceSteadyIndicatorList.iterator();
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
SourceSteadyIndicator sourceSteady = iterator.next();
|
|
||||||
if (StringUtils.equals(threeInterferenceSourceId, sourceSteady.getInterferenceSource())) {
|
if (StringUtils.equals(threeInterferenceSourceId, sourceSteady.getInterferenceSource())) {
|
||||||
if (steadyIndicatorIds.containsAll(sourceSteady.getSteadyIndicator())) {
|
if (steadyIndicatorIds.containsAll(sourceSteady.getSteadyIndicator())) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
@@ -131,19 +129,11 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//查询部门下所有监测点基本信息
|
}
|
||||||
PmsDeviceInfoParam pmsDeviceInfoParam = new PmsDeviceInfoParam();
|
if (CollectionUtil.isNotEmpty(oneSourceSteadyIndicatorList)) {
|
||||||
pmsDeviceInfoParam.setDeptIndex(deptId);
|
|
||||||
pmsDeviceInfoParam.setStatisticalType(new SimpleDTO());
|
|
||||||
HttpResult<List<PmsGeneralDeviceDTO>> listHttpResult = pmsGeneralDeviceInfoClient.getPmsDeviceInfoWithInOrg(pmsDeviceInfoParam);
|
|
||||||
List<PmsGeneralDeviceDTO> dataList = listHttpResult.getData();
|
|
||||||
if (CollectionUtil.isNotEmpty(dataList) && CollectionUtil.isNotEmpty(oneSourceSteadyIndicatorList)) {
|
|
||||||
dataList.forEach(r -> {
|
|
||||||
List<String> monitorIdList = r.getMonitorIdList();
|
|
||||||
//查询所有监测点详细信息集合
|
|
||||||
List<Monitor> monitors = pmsMonitorMapper.selectList(new LambdaQueryWrapper<Monitor>().in(Monitor::getId, monitorIdList));
|
|
||||||
monitors.forEach(monitor -> {
|
|
||||||
oneSourceSteadyIndicatorList.forEach(steady -> {
|
oneSourceSteadyIndicatorList.forEach(steady -> {
|
||||||
|
Monitor monitor = pmsMonitorMapper.selectById(steady.getMonitorId());
|
||||||
|
if (monitor != null) {
|
||||||
if (StringUtils.equals(monitor.getMonitorTag(), steady.getInterferenceSource())) {//匹配该监测点属于的干扰源类型
|
if (StringUtils.equals(monitor.getMonitorTag(), steady.getInterferenceSource())) {//匹配该监测点属于的干扰源类型
|
||||||
//查询该监测点的检测数据
|
//查询该监测点的检测数据
|
||||||
LimitRate limitRate = this.queryLimitTargetData(monitor.getId());
|
LimitRate limitRate = this.queryLimitTargetData(monitor.getId());
|
||||||
@@ -152,17 +142,93 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
|
|||||||
//生成监督数据
|
//生成监督数据
|
||||||
this.creatSuperviseData(steady, limitBoolMap, monitor, limitRate);
|
this.creatSuperviseData(steady, limitBoolMap, monitor, limitRate);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//部门没有绑定策略的走通用策略
|
||||||
|
this.initCommonStrategy(thsStrategyList);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, "");
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门没有绑定策略的走通用策略
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void initCommonStrategy(List<ThsStrategyVo> thsStrategyList) {
|
||||||
|
//查询通用策略
|
||||||
|
ThsWarnStrategy thsWarnStrategy = thsWarnStrategyMapper.selectOne(new LambdaQueryWrapper<ThsWarnStrategy>()
|
||||||
|
.eq(ThsWarnStrategy::getBigType, BigTypeEnum.COMMON.getCode())
|
||||||
|
.last("limit 1"));
|
||||||
|
if (null != thsWarnStrategy) {
|
||||||
|
List<String> haveDepIdList = new ArrayList<>();
|
||||||
|
if (CollectionUtil.isNotEmpty(thsStrategyList)) {
|
||||||
|
List<ThsStrategyVo> verifyList = thsStrategyList.stream().filter(r -> !GradeEnum.THREE_LEVEL.getCode().equals(r.getGrade()))
|
||||||
|
.collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(ThsStrategyVo::getDeptId))), ArrayList::new));
|
||||||
|
haveDepIdList = verifyList.stream().map(ThsStrategyVo::getDeptId).collect(Collectors.toList());
|
||||||
|
|
||||||
|
}
|
||||||
|
//获取所有部门信息
|
||||||
|
HttpResult<List<PvTerminalTreeVO>> listHttpResult = deptFeignClient.allDeptList();
|
||||||
|
List<String> allDepIdList = listHttpResult.getData().stream().distinct().map(PvTerminalTreeVO::getId).collect(Collectors.toList());
|
||||||
|
allDepIdList.removeAll(haveDepIdList);
|
||||||
|
//部门没有配置定制策略的走通用策略
|
||||||
|
if (CollectionUtil.isNotEmpty(allDepIdList)) {
|
||||||
|
List<ThsWarnStrategyAss> thsWarnStrategyAsses = thsWarnStrategyAssMapper.selectList(new LambdaQueryWrapper<ThsWarnStrategyAss>()
|
||||||
|
.eq(ThsWarnStrategyAss::getWarnId, thsWarnStrategy.getId()));
|
||||||
|
List<ThsWarnStrategyAss> sourceAssList = thsWarnStrategyAsses.stream().filter(source -> TypeEnum.SOURCE_TYPE.getCode().equals(source.getType()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
List<ThsWarnStrategyAss> interAssList = thsWarnStrategyAsses.stream().filter(inter -> TypeEnum.INTERFERENCE_TYPE.getCode().equals(inter.getType()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
//封装每一种干扰源和对应的指标
|
||||||
|
List<SourceSteadyIndicator> verifySteadylist = new ArrayList<>();
|
||||||
|
for (ThsWarnStrategyAss oneWarnStrategyAss : sourceAssList) {
|
||||||
|
SourceSteadyIndicator build = SourceSteadyIndicator.builder().id(thsWarnStrategy.getId()).operation(thsWarnStrategy.getOperation())
|
||||||
|
.interferenceSource(oneWarnStrategyAss.getAssId())
|
||||||
|
.steadyIndicator(interAssList.stream().map(ThsWarnStrategyAss::getAssId).collect(Collectors.toList()))
|
||||||
|
.type(thsWarnStrategy.getType())
|
||||||
|
.build();
|
||||||
|
verifySteadylist.add(build);
|
||||||
|
}
|
||||||
|
allDepIdList.forEach(depId -> {
|
||||||
|
//查询部门下所有监测点基本信息
|
||||||
|
PmsDeviceInfoParam pmsDeviceInfoParam = new PmsDeviceInfoParam();
|
||||||
|
pmsDeviceInfoParam.setDeptIndex(depId);
|
||||||
|
pmsDeviceInfoParam.setStatisticalType(new SimpleDTO());
|
||||||
|
HttpResult<List<PmsGeneralDeviceDTO>> httpResult = pmsGeneralDeviceInfoClient.getPmsDeviceInfoWithInOrg(pmsDeviceInfoParam);
|
||||||
|
List<PmsGeneralDeviceDTO> dataList = httpResult.getData();
|
||||||
|
if (CollectionUtil.isNotEmpty(dataList)) {
|
||||||
|
dataList.forEach(r -> {
|
||||||
|
List<String> monitorIdList = r.getMonitorIdList();
|
||||||
|
//查询所有监测点详细信息集合
|
||||||
|
if (CollectionUtil.isNotEmpty(monitorIdList)) {
|
||||||
|
List<Monitor> monitors = pmsMonitorMapper.queryConfigMonitor(monitorIdList, Arrays.stream(InterferenceTypeEnum.values()).map(InterferenceTypeEnum::getCode).collect(Collectors.toList()));
|
||||||
|
monitors.forEach(monitor -> verifySteadylist.forEach(steady -> {
|
||||||
|
if (StringUtils.equals(monitor.getMonitorTag(), steady.getInterferenceSource())) {//匹配该监测点属于的干扰源类型
|
||||||
|
steady.setDeptId(depId);
|
||||||
|
//查询该监测点的检测数据
|
||||||
|
LimitRate limitRate = this.queryLimitTargetData(monitor.getId());
|
||||||
|
//判断指标是否超标
|
||||||
|
Map<String, Boolean> limitBoolMap = this.verifyLimit(limitRate, steady);
|
||||||
|
//生成监督数据
|
||||||
|
this.creatSuperviseData(steady, limitBoolMap, monitor, limitRate);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询策略列表
|
||||||
|
*
|
||||||
|
* @param initType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@DS("process")
|
@DS("process")
|
||||||
@Override
|
@Override
|
||||||
public List<ThsStrategyVo> selectStrategyList(Integer initType) {
|
public List<ThsStrategyVo> selectStrategyList(Integer initType) {
|
||||||
@@ -170,12 +236,18 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
|
|||||||
return thsStrategyList;
|
return thsStrategyList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询策略绑定的干扰源列表或指标参数列表
|
||||||
|
*
|
||||||
|
* @param warnId
|
||||||
|
* @param typeEnum
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@DS("process")
|
@DS("process")
|
||||||
@Override
|
@Override
|
||||||
public List<ThsWarnStrategyAss> queryWarnStrategyAss(ThsStrategyVo strategyVo, TypeEnum typeEnum) {
|
public List<ThsWarnStrategyAss> queryWarnStrategyAss(String warnId, TypeEnum typeEnum) {
|
||||||
List<ThsWarnStrategyAss> thsWarnStrategyAss = thsWarnStrategyAssMapper.selectList(new LambdaQueryWrapper<ThsWarnStrategyAss>()
|
List<ThsWarnStrategyAss> thsWarnStrategyAss = thsWarnStrategyAssMapper.selectList(new LambdaQueryWrapper<ThsWarnStrategyAss>()
|
||||||
.eq(ThsWarnStrategyAss::getWarnId, strategyVo.getId())
|
.eq(ThsWarnStrategyAss::getWarnId, warnId)
|
||||||
.eq(ThsWarnStrategyAss::getType, typeEnum.getCode()));
|
.eq(ThsWarnStrategyAss::getType, typeEnum.getCode()));
|
||||||
return thsWarnStrategyAss;
|
return thsWarnStrategyAss;
|
||||||
}
|
}
|
||||||
@@ -197,8 +269,8 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
|
|||||||
//判断今日是否已经生成了监督数据
|
//判断今日是否已经生成了监督数据
|
||||||
LambdaQueryWrapper<ThsSupervise> superviseQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<ThsSupervise> superviseQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
superviseQueryWrapper.between(ThsSupervise::getCreateTime,
|
superviseQueryWrapper.between(ThsSupervise::getCreateTime,
|
||||||
DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), -1)),
|
DateUtil.beginOfDay(new Date()),
|
||||||
DateUtil.endOfDay(DateUtil.offsetDay(new Date(), -1)))
|
DateUtil.endOfDay(new Date()))
|
||||||
.eq(ThsSupervise::getDeptId, steady.getDeptId())
|
.eq(ThsSupervise::getDeptId, steady.getDeptId())
|
||||||
.eq(ThsSupervise::getType, steady.getType())
|
.eq(ThsSupervise::getType, steady.getType())
|
||||||
.last("limit 1");
|
.last("limit 1");
|
||||||
@@ -217,6 +289,7 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
|
|||||||
ThsSupervise thsSupervise = this.insertSuperviseData(steady, monitor, limitRate);
|
ThsSupervise thsSupervise = this.insertSuperviseData(steady, monitor, limitRate);
|
||||||
//生成告警/预警监测点列表数据
|
//生成告警/预警监测点列表数据
|
||||||
this.insertOverRunLog(steady, thsSupervise, monitor, limitRate);
|
this.insertOverRunLog(steady, thsSupervise, monitor, limitRate);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,12 +316,14 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
|
|||||||
@DS("process")
|
@DS("process")
|
||||||
@Override
|
@Override
|
||||||
public void insertOverRunLog(SourceSteadyIndicator steady, ThsSupervise thsSupervise, Monitor monitor, LimitRate limitRate) {
|
public void insertOverRunLog(SourceSteadyIndicator steady, ThsSupervise thsSupervise, Monitor monitor, LimitRate limitRate) {
|
||||||
|
//判断今日是否已经生成了监督数据
|
||||||
ThsOverRunLog thsOverRunLog = new ThsOverRunLog();
|
ThsOverRunLog thsOverRunLog = new ThsOverRunLog();
|
||||||
thsOverRunLog.setId(IdUtil.simpleUUID());
|
thsOverRunLog.setId(IdUtil.simpleUUID());
|
||||||
thsOverRunLog.setSupIndex(thsSupervise.getSupIndex());
|
thsOverRunLog.setSupIndex(thsSupervise.getSupIndex());
|
||||||
thsOverRunLog.setLineIndex(monitor.getId());
|
thsOverRunLog.setLineIndex(monitor.getId());
|
||||||
thsOverRunLog.setName(monitor.getPowerrName() + "_" + monitor.getName() + "_" + DateUtil.today() + "_" + monitor.getId());
|
thsOverRunLog.setName(monitor.getPowerrName() + "_" + monitor.getName() + "_" + DateUtil.today() + "_" + monitor.getId());
|
||||||
thsOverRunLog.setUpdateTime(limitRate.getCreatTime());
|
thsOverRunLog.setUpdateTime(limitRate.getCreatTime());
|
||||||
|
thsOverRunLog.setCreateTime(new Date());
|
||||||
thsOverRunLogMapper.insert(thsOverRunLog);
|
thsOverRunLogMapper.insert(thsOverRunLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,7 +331,7 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
|
|||||||
@Override
|
@Override
|
||||||
@DS("pms")
|
@DS("pms")
|
||||||
public LimitRate queryLimitTargetData(String monitorId) {
|
public LimitRate queryLimitTargetData(String monitorId) {
|
||||||
LimitRate limitRate = limitRateMapper.selectOne(new LambdaQueryWrapper<LimitRate>().eq(LimitRate::getMyindex, monitorId)
|
LimitRate limitRate = limitRateMapper.selectOne(new LambdaQueryWrapper<LimitRate>().eq(LimitRate::getLineId, monitorId)
|
||||||
.between(LimitRate::getCreatTime,
|
.between(LimitRate::getCreatTime,
|
||||||
DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), -1)),
|
DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), -1)),
|
||||||
DateUtil.endOfDay(DateUtil.offsetDay(new Date(), -1))).last("limit 1"));
|
DateUtil.endOfDay(DateUtil.offsetDay(new Date(), -1))).last("limit 1"));
|
||||||
@@ -277,6 +352,7 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
|
|||||||
HttpResult<DictData> dicDataById = dicDataFeignClient.getDicDataById(id);
|
HttpResult<DictData> dicDataById = dicDataFeignClient.getDicDataById(id);
|
||||||
if (CommonResponseEnum.SUCCESS.getCode().equals(dicDataById.getCode()) && dicDataById.getData() != null) {
|
if (CommonResponseEnum.SUCCESS.getCode().equals(dicDataById.getCode()) && dicDataById.getData() != null) {
|
||||||
SteadyIndicatorEnum steadyIndicatorEnum = SteadyIndicatorEnum.getSteadyIndicatorEnumByCode(dicDataById.getData().getCode());
|
SteadyIndicatorEnum steadyIndicatorEnum = SteadyIndicatorEnum.getSteadyIndicatorEnumByCode(dicDataById.getData().getCode());
|
||||||
|
if (null != steadyIndicatorEnum) {
|
||||||
switch (steadyIndicatorEnum) {
|
switch (steadyIndicatorEnum) {
|
||||||
case Negative_Voltage://负序电压不平衡度
|
case Negative_Voltage://负序电压不平衡度
|
||||||
if (limitRate.getUbalanceOvertime() > 0) {
|
if (limitRate.getUbalanceOvertime() > 0) {
|
||||||
@@ -397,6 +473,7 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return limitBoolMap;
|
return limitBoolMap;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ public interface ThsSuperviseService extends IService<ThsSupervise> {
|
|||||||
*/
|
*/
|
||||||
void creatSuperviseData(SourceSteadyIndicator steady, Map<String, Boolean> limitBoolMap, Monitor monitor, LimitRate limitRate);
|
void creatSuperviseData(SourceSteadyIndicator steady, Map<String, Boolean> limitBoolMap, Monitor monitor, LimitRate limitRate);
|
||||||
|
|
||||||
List<ThsWarnStrategyAss> queryWarnStrategyAss(ThsStrategyVo strategyVo, TypeEnum typeEnum);
|
List<ThsWarnStrategyAss> queryWarnStrategyAss(String id, TypeEnum typeEnum);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成监督数据
|
* 生成监督数据
|
||||||
*
|
*
|
||||||
@@ -61,4 +62,6 @@ public interface ThsSuperviseService extends IService<ThsSupervise> {
|
|||||||
* @param monitor
|
* @param monitor
|
||||||
*/
|
*/
|
||||||
void insertOverRunLog(SourceSteadyIndicator steady, ThsSupervise thsSupervise, Monitor monitor, LimitRate limitRate);
|
void insertOverRunLog(SourceSteadyIndicator steady, ThsSupervise thsSupervise, Monitor monitor, LimitRate limitRate);
|
||||||
|
|
||||||
|
void initCommonStrategy(List<ThsStrategyVo> thsStrategyList);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ public class LimitRate {
|
|||||||
/**
|
/**
|
||||||
* 监测点ID合格率的变电站/装置/母线/线路序号
|
* 监测点ID合格率的变电站/装置/母线/线路序号
|
||||||
*/
|
*/
|
||||||
@TableField(value = "myindex")
|
@TableField(value = "line_id")
|
||||||
private Integer myindex;
|
private String lineId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 总计算次数
|
* 总计算次数
|
||||||
|
|||||||
@@ -72,6 +72,10 @@ public class ThsOverRunLog {
|
|||||||
* 越限时间(yyyy-MM-dd)
|
* 越限时间(yyyy-MM-dd)
|
||||||
*/
|
*/
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
package com.njcn.process.pojo.po;
|
package com.njcn.process.pojo.po;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import com.njcn.db.bo.BaseEntity;
|
import com.njcn.db.bo.BaseEntity;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
@@ -21,7 +20,7 @@ import lombok.EqualsAndHashCode;
|
|||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@TableName("ths_warn_strategy")
|
@TableName("ths_warn_strategy")
|
||||||
@ApiModel(value="ThsWarnStrategy对象", description="")
|
@ApiModel(value = "ThsWarnStrategy对象", description = "")
|
||||||
public class ThsWarnStrategy extends BaseEntity implements Serializable {
|
public class ThsWarnStrategy extends BaseEntity implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -47,7 +46,7 @@ public class ThsWarnStrategy extends BaseEntity implements Serializable {
|
|||||||
|
|
||||||
@ApiModelProperty(value = "0.删除 1.正常")
|
@ApiModelProperty(value = "0.删除 1.正常")
|
||||||
@TableField("State")
|
@TableField("State")
|
||||||
@TableLogic
|
@TableLogic(value = "1",delval = "0")
|
||||||
private Integer state;
|
private Integer state;
|
||||||
|
|
||||||
@TableField("Create_By")
|
@TableField("Create_By")
|
||||||
@@ -55,6 +54,11 @@ public class ThsWarnStrategy extends BaseEntity implements Serializable {
|
|||||||
|
|
||||||
@TableField("Update_By")
|
@TableField("Update_By")
|
||||||
private String updateBy;
|
private String updateBy;
|
||||||
|
/**
|
||||||
|
* 0.通用策略 1.定值策略
|
||||||
|
*/
|
||||||
|
@TableField("Big_Type")
|
||||||
|
private String bigType;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user