新增预警/告警技术监督数据
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package com.njcn.prepare.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum GradeEnum {
|
||||
ONE_LEVEL(0, "一级"),
|
||||
TWO_LEVEL(1, "二级"),
|
||||
THREE_LEVEL(2, "三级");
|
||||
|
||||
private final Integer code;
|
||||
|
||||
private final String message;
|
||||
|
||||
GradeEnum(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.njcn.prepare.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum InitTypeEnum {
|
||||
AUTO(0, "自动"),
|
||||
MANUAL(1, "手动");
|
||||
private final Integer code;
|
||||
|
||||
private final String message;
|
||||
|
||||
InitTypeEnum(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.njcn.prepare.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 干扰源类型枚举
|
||||
*/
|
||||
@Getter
|
||||
public enum InterferenceTypeEnum {
|
||||
Electric_Load("Electric_Load", "电加热负荷"),
|
||||
Electrolytic_Load("Electrolytic_Load", "电解负荷"),
|
||||
Transportation_Hubs("Transportation_Hubs", "交通枢纽"),
|
||||
Nonlinear_Loads("Nonlinear_Loads", "非线性负荷"),
|
||||
Electrified_Railways("Electrified_Railways", "电气化铁路"),
|
||||
Fre_Equipment("Fre_Equipment", "变频调速设备"),
|
||||
Mill("Mill", "轧机"),
|
||||
Medium_Furnace("Medium_Furnace", "中频炉"),
|
||||
Precision_Mach("Precision_Mach", "精密加工"),
|
||||
Com_Muni("Com_Muni", "商业/市政"),
|
||||
AC_DC_Inverter("AC_DC_Inverter", "交直流逆变器"),
|
||||
Shock_Loads("Shock_Loads", "冲击性负荷"),
|
||||
Electric_Weld_Load("Electric_Weld_Load", "电焊负荷"),
|
||||
dycs("dycs", "电压测试"),
|
||||
dlcs("dlcs", "电流测试"),
|
||||
Zlzz("Zlzz", "整流装置"),
|
||||
Hospital("Hospital", "医院"),
|
||||
Manufacturing("Manufacturing", "半导体制造");
|
||||
|
||||
private final String code;
|
||||
|
||||
private final String message;
|
||||
|
||||
InterferenceTypeEnum(String code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.njcn.prepare.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum OperationEnum {
|
||||
|
||||
AND(0, "与"),
|
||||
OR(1, "或");
|
||||
private final Integer code;
|
||||
|
||||
private final String message;
|
||||
|
||||
OperationEnum(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.njcn.prepare.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum ProgressEnum {
|
||||
|
||||
START(0, "开始");
|
||||
|
||||
private final Integer code;
|
||||
|
||||
private final String message;
|
||||
|
||||
ProgressEnum(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.njcn.prepare.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 指标参数类型枚举
|
||||
*/
|
||||
@Getter
|
||||
public enum SteadyIndicatorEnum {
|
||||
|
||||
Negative_Voltage("Negative_Voltage", "与负序电压不平衡度"),
|
||||
Interhar_Voltage("Interhar_Voltage", "间谐波电压"),
|
||||
Neg_Current("Neg_Current", "负序电流"),
|
||||
Fre_Deviation("Fre_Deviation", "频率偏差"),
|
||||
Voltage_Dev("Voltage_Dev", "电压偏差"),
|
||||
Har_Current("Har_Current", "谐波电流"),
|
||||
Voltage_Fluc("Voltage_Fluc", "电压波动与闪变"),
|
||||
Har_Voltage("Har_Voltage", "谐波电压");
|
||||
|
||||
private final String code;
|
||||
|
||||
private final String message;
|
||||
|
||||
SteadyIndicatorEnum(String code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public static SteadyIndicatorEnum getSteadyIndicatorEnumByCode(String code) {
|
||||
for (SteadyIndicatorEnum steadyIndicatorEnum : SteadyIndicatorEnum.values()) {
|
||||
if (StringUtils.equals(code, steadyIndicatorEnum.getCode())) {
|
||||
return steadyIndicatorEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.prepare.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum TypeEnum {
|
||||
MONITOR_TYPE(0, "指标类型"),
|
||||
INTERFERENCE_TYPE(1, "指标类型"),
|
||||
SOURCE_TYPE(2, "干扰源类型");
|
||||
|
||||
|
||||
private final Integer code;
|
||||
|
||||
private final String message;
|
||||
|
||||
TypeEnum(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,15 @@
|
||||
package com.njcn.prepare.harmonic.controller.line;
|
||||
|
||||
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.prepare.harmonic.service.mysql.line.ThsSuperviseService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
@@ -16,6 +23,14 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
@RequestMapping("/thsSupervise")
|
||||
public class ThsSuperviseController extends BaseController {
|
||||
@Autowired
|
||||
private ThsSuperviseService thsSuperviseService;
|
||||
|
||||
@ApiOperation("预警/告警事务生成")
|
||||
@ApiImplicitParam(name = "initType", value = "生成策略 0 自动;1 手动", required = true)
|
||||
@PostMapping("/initSupervise")
|
||||
public HttpResult<Boolean> initSupervise(@RequestParam("initType") Integer initType) {
|
||||
return thsSuperviseService.initSupervise(initType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.prepare.harmonic.mapper.mysql.line;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.process.pojo.po.LimitRate;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -11,6 +12,7 @@ import com.njcn.process.pojo.po.LimitRate;
|
||||
* @author lxp
|
||||
* @since 2023-03-16
|
||||
*/
|
||||
@Mapper
|
||||
public interface LimitRateMapper extends BaseMapper<LimitRate> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.njcn.prepare.harmonic.mapper.mysql.line;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.device.pms.pojo.po.Monitor;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author yzh
|
||||
* @date 2022/10/17
|
||||
*/
|
||||
|
||||
@Mapper
|
||||
public interface PmsMonitorMapper extends BaseMapper<Monitor> {
|
||||
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.njcn.prepare.harmonic.mapper.mysql.line;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.process.pojo.po.ThsOverRunLog;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -11,6 +13,8 @@ import com.njcn.process.pojo.po.ThsOverRunLog;
|
||||
* @author lxp
|
||||
* @since 2023-03-16
|
||||
*/
|
||||
@DS("process")
|
||||
@Mapper
|
||||
public interface ThsOverRunLogMapper extends BaseMapper<ThsOverRunLog> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.njcn.prepare.harmonic.mapper.mysql.line;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.process.pojo.po.ThsSupervise;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -11,6 +13,8 @@ import com.njcn.process.pojo.po.ThsSupervise;
|
||||
* @author lxp
|
||||
* @since 2023-03-16
|
||||
*/
|
||||
@DS("process")
|
||||
@Mapper
|
||||
public interface ThsSuperviseMapper extends BaseMapper<ThsSupervise> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.prepare.harmonic.mapper.mysql.line;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.process.pojo.po.ThsWarnStrategyAss;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2023-03-10
|
||||
*/
|
||||
@DS("process")
|
||||
@Mapper
|
||||
public interface ThsWarnStrategyAssMapper extends BaseMapper<ThsWarnStrategyAss> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.prepare.harmonic.mapper.mysql.line;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.harmonic.pojo.vo.ThsStrategyVo;
|
||||
import com.njcn.process.pojo.po.ThsWarnStrategy;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2023-03-10
|
||||
*/
|
||||
@DS("process")
|
||||
@Mapper
|
||||
public interface ThsWarnStrategyMapper extends BaseMapper<ThsWarnStrategy> {
|
||||
/**
|
||||
* 查询策略的集合
|
||||
*/
|
||||
List<ThsStrategyVo> selectStrategyList(@Param("initType") Integer initType);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?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.ThsWarnStrategyAssMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.njcn.process.pojo.po.ThsWarnStrategyAss">
|
||||
<id column="Warn_Id" property="warnId" />
|
||||
<result column="Ass_Id" property="assId" />
|
||||
<result column="Type" property="type" />
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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.ThsWarnStrategyMapper">
|
||||
|
||||
<!--查询策略的集合-->
|
||||
<select id="selectStrategyList" resultType="com.njcn.harmonic.pojo.vo.ThsStrategyVo">
|
||||
select
|
||||
tws.id,
|
||||
tws.name,
|
||||
tws.grade,
|
||||
tws.operation,
|
||||
tws.type,
|
||||
tda.dept_Id as deptId
|
||||
from
|
||||
ths_warn_strategy tws
|
||||
left join ths_dept_alarm tda on
|
||||
tws.Id = tda.Alarm_Id
|
||||
<where>
|
||||
<choose>
|
||||
<when test="initType==0">
|
||||
tws.State = 1 and tws.Grade in(0,2)
|
||||
</when>
|
||||
<when test="initType==1">
|
||||
tws.State = 1 and tws.Grade in(1,2)
|
||||
</when>
|
||||
</choose>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,11 +1,38 @@
|
||||
package com.njcn.prepare.harmonic.service.mysql.Impl.line;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.prepare.harmonic.mapper.mysql.line.ThsSuperviseMapper;
|
||||
import com.njcn.common.pojo.dto.SimpleDTO;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.device.pms.api.PmsGeneralDeviceInfoClient;
|
||||
import com.njcn.device.pms.pojo.dto.PmsGeneralDeviceDTO;
|
||||
import com.njcn.device.pms.pojo.param.PmsDeviceInfoParam;
|
||||
import com.njcn.device.pms.pojo.po.Monitor;
|
||||
import com.njcn.harmonic.pojo.vo.SourceSteadyIndicator;
|
||||
import com.njcn.harmonic.pojo.vo.ThsStrategyVo;
|
||||
import com.njcn.prepare.enums.*;
|
||||
import com.njcn.prepare.harmonic.mapper.mysql.line.*;
|
||||
import com.njcn.prepare.harmonic.service.mysql.line.ThsSuperviseService;
|
||||
import com.njcn.process.pojo.po.LimitRate;
|
||||
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.pojo.po.DictData;
|
||||
import org.apache.commons.collections.map.HashedMap;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
@@ -17,4 +44,363 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, ThsSupervise> implements ThsSuperviseService {
|
||||
|
||||
@Autowired
|
||||
private PmsGeneralDeviceInfoClient pmsGeneralDeviceInfoClient;
|
||||
|
||||
@Autowired
|
||||
private ThsWarnStrategyMapper thsWarnStrategyMapper;
|
||||
@Autowired
|
||||
private ThsWarnStrategyAssMapper thsWarnStrategyAssMapper;
|
||||
@Autowired
|
||||
private PmsMonitorMapper pmsMonitorMapper;
|
||||
@Autowired
|
||||
private LimitRateMapper limitRateMapper;
|
||||
@Autowired
|
||||
private DicDataFeignClient dicDataFeignClient;
|
||||
@Autowired
|
||||
private ThsSuperviseMapper thsSuperviseMapper;
|
||||
@Autowired
|
||||
private ThsOverRunLogMapper thsOverRunLogMapper;
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> initSupervise(Integer initType) {
|
||||
if (initType == null) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.INVALID_PARAMETER, false, "");
|
||||
}
|
||||
List<ThsStrategyVo> thsStrategyList = this.selectStrategyList(initType);
|
||||
//按部门进行分组
|
||||
if (CollectionUtil.isNotEmpty(thsStrategyList)) {
|
||||
Map<String, List<ThsStrategyVo>> deptMap = thsStrategyList.stream().collect(Collectors.groupingBy(ThsStrategyVo::getDeptId));
|
||||
for (Map.Entry<String, List<ThsStrategyVo>> entry : deptMap.entrySet()) {
|
||||
String deptId = entry.getKey();
|
||||
List<ThsStrategyVo> deptList = entry.getValue();
|
||||
List<ThsStrategyVo> oneLevel = deptList.stream().filter(r -> r.getGrade().equals(GradeEnum.ONE_LEVEL.getCode())).collect(Collectors.toList());//一级策略集合
|
||||
List<SourceSteadyIndicator> oneSourceSteadyIndicatorList = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(oneLevel)) {
|
||||
for (ThsStrategyVo oneStrategyVo : oneLevel) {
|
||||
List<ThsWarnStrategyAss> oneInterferenceSourceAsses = this.queryWarnStrategyAss(oneStrategyVo, TypeEnum.SOURCE_TYPE);//干扰源列表
|
||||
List<ThsWarnStrategyAss> oneSteadyIndicatorAsses = this.queryWarnStrategyAss(oneStrategyVo, TypeEnum.INTERFERENCE_TYPE);//干扰源列表
|
||||
List<String> oneSteadyIndicatorAssesIds = oneSteadyIndicatorAsses.stream().map(r -> r.getAssId()).collect(Collectors.toList());
|
||||
//封装每一种干扰源和对应的指标
|
||||
for (ThsWarnStrategyAss oneWarnStrategyAss : oneInterferenceSourceAsses) {
|
||||
SourceSteadyIndicator build = SourceSteadyIndicator.builder().id(oneStrategyVo.getId()).operation(oneStrategyVo.getOperation())
|
||||
.interferenceSource(oneWarnStrategyAss.getAssId())
|
||||
.steadyIndicator(oneSteadyIndicatorAssesIds)
|
||||
.deptId(oneStrategyVo.getDeptId())
|
||||
.type(oneStrategyVo.getType())
|
||||
.build();
|
||||
oneSourceSteadyIndicatorList.add(build);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<ThsStrategyVo> threeLevel = deptList.stream().filter(r -> r.getGrade().equals(GradeEnum.THREE_LEVEL.getCode())).collect(Collectors.toList());//三级策略集合
|
||||
if (CollectionUtil.isNotEmpty(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();
|
||||
while (iterator.hasNext()) {
|
||||
SourceSteadyIndicator sourceSteady = iterator.next();
|
||||
if (OperationEnum.AND.getCode().equals(sourceSteady.getOperation())) {
|
||||
if (StringUtils.equals(threeInterferenceSourceId, sourceSteady.getInterferenceSource()) &&
|
||||
steadyIndicatorIds.containsAll(sourceSteady.getSteadyIndicator())) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {//处理三级策略的或
|
||||
Iterator<SourceSteadyIndicator> iterator = oneSourceSteadyIndicatorList.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
SourceSteadyIndicator sourceSteady = iterator.next();
|
||||
if (StringUtils.equals(threeInterferenceSourceId, sourceSteady.getInterferenceSource())) {
|
||||
if (steadyIndicatorIds.containsAll(sourceSteady.getSteadyIndicator())) {
|
||||
iterator.remove();
|
||||
} else {
|
||||
List<String> steadyIndicator = sourceSteady.getSteadyIndicator();
|
||||
steadyIndicator.removeAll(steadyIndicatorIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//查询部门下所有监测点基本信息
|
||||
PmsDeviceInfoParam pmsDeviceInfoParam = new PmsDeviceInfoParam();
|
||||
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 -> {
|
||||
if (StringUtils.equals(monitor.getMonitorTag(), steady.getInterferenceSource())) {//匹配该监测点属于的干扰源类型
|
||||
//查询该监测点的检测数据
|
||||
LimitRate limitRate = this.queryLimitTargetData(monitor.getId());
|
||||
//判断指标是否超标
|
||||
Map<String, Boolean> limitBoolMap = this.verifyLimit(limitRate, steady);
|
||||
//生成监督数据
|
||||
this.creatSuperviseData(steady, limitBoolMap, monitor, limitRate);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, "");
|
||||
}
|
||||
|
||||
|
||||
@DS("process")
|
||||
@Override
|
||||
public List<ThsStrategyVo> selectStrategyList(Integer initType) {
|
||||
List<ThsStrategyVo> thsStrategyList = thsWarnStrategyMapper.selectStrategyList(initType);
|
||||
return thsStrategyList;
|
||||
}
|
||||
|
||||
|
||||
@DS("process")
|
||||
@Override
|
||||
public List<ThsWarnStrategyAss> queryWarnStrategyAss(ThsStrategyVo strategyVo, TypeEnum typeEnum) {
|
||||
List<ThsWarnStrategyAss> thsWarnStrategyAss = thsWarnStrategyAssMapper.selectList(new LambdaQueryWrapper<ThsWarnStrategyAss>()
|
||||
.eq(ThsWarnStrategyAss::getWarnId, strategyVo.getId())
|
||||
.eq(ThsWarnStrategyAss::getType, typeEnum.getCode()));
|
||||
return thsWarnStrategyAss;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成监督数据
|
||||
*
|
||||
* @param limitBoolMap
|
||||
*/
|
||||
@Override
|
||||
public void creatSuperviseData(SourceSteadyIndicator steady, Map<String, Boolean> limitBoolMap, Monitor monitor, LimitRate limitRate) {
|
||||
if (CollectionUtil.isNotEmpty(limitBoolMap)) {
|
||||
if (OperationEnum.AND.getCode().equals(steady.getOperation())) {
|
||||
for (Map.Entry<String, Boolean> entry : limitBoolMap.entrySet()) {
|
||||
if (!entry.getValue()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
//判断今日是否已经生成了监督数据
|
||||
LambdaQueryWrapper<ThsSupervise> superviseQueryWrapper = new LambdaQueryWrapper<>();
|
||||
superviseQueryWrapper.between(ThsSupervise::getCreateTime,
|
||||
DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), -1)),
|
||||
DateUtil.endOfDay(DateUtil.offsetDay(new Date(), -1)))
|
||||
.eq(ThsSupervise::getDeptId, steady.getDeptId())
|
||||
.eq(ThsSupervise::getType, steady.getType())
|
||||
.last("limit 1");
|
||||
ThsSupervise thsSupervise = thsSuperviseMapper.selectOne(superviseQueryWrapper);
|
||||
if (thsSupervise == null) {
|
||||
//生成监督数据
|
||||
thsSupervise = this.insertSuperviseData(steady, monitor, limitRate);
|
||||
}
|
||||
//生成告警/预警监测点列表数据
|
||||
this.insertOverRunLog(steady, thsSupervise, monitor, limitRate);
|
||||
}
|
||||
if (OperationEnum.OR.getCode().equals(steady.getOperation())) {
|
||||
for (Map.Entry<String, Boolean> entry : limitBoolMap.entrySet()) {
|
||||
if (entry.getValue()) {
|
||||
//生成监督数据
|
||||
ThsSupervise thsSupervise = this.insertSuperviseData(steady, monitor, limitRate);
|
||||
//生成告警/预警监测点列表数据
|
||||
this.insertOverRunLog(steady, thsSupervise, monitor, limitRate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DS("process")
|
||||
@Override
|
||||
public ThsSupervise insertSuperviseData(SourceSteadyIndicator steady, Monitor monitor, LimitRate limitRate) {
|
||||
ThsSupervise thsSupervise = new ThsSupervise();
|
||||
thsSupervise.setSupIndex(IdUtil.simpleUUID());
|
||||
thsSupervise.setName(monitor.getPowerrName() + "_" + monitor.getName() + "_" + DateUtil.today() + "_" + monitor.getId());
|
||||
thsSupervise.setDeptId(steady.getDeptId());
|
||||
thsSupervise.setCreateUser(steady.getCreateBy());
|
||||
thsSupervise.setCreateTime(new Date());
|
||||
thsSupervise.setType(steady.getType());
|
||||
thsSupervise.setCreateUser(steady.getCreateBy());
|
||||
thsSupervise.setProgress(ProgressEnum.START.getCode());
|
||||
thsSuperviseMapper.insert(thsSupervise);
|
||||
return thsSupervise;
|
||||
}
|
||||
|
||||
|
||||
@DS("process")
|
||||
@Override
|
||||
public void insertOverRunLog(SourceSteadyIndicator steady, ThsSupervise thsSupervise, Monitor monitor, LimitRate limitRate) {
|
||||
ThsOverRunLog thsOverRunLog = new ThsOverRunLog();
|
||||
thsOverRunLog.setId(IdUtil.simpleUUID());
|
||||
thsOverRunLog.setSupIndex(thsSupervise.getSupIndex());
|
||||
thsOverRunLog.setLineIndex(monitor.getId());
|
||||
thsOverRunLog.setName(monitor.getPowerrName() + "_" + monitor.getName() + "_" + DateUtil.today() + "_" + monitor.getId());
|
||||
thsOverRunLog.setUpdateTime(limitRate.getCreatTime());
|
||||
thsOverRunLogMapper.insert(thsOverRunLog);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@DS("pms")
|
||||
public LimitRate queryLimitTargetData(String monitorId) {
|
||||
LimitRate limitRate = limitRateMapper.selectOne(new LambdaQueryWrapper<LimitRate>().eq(LimitRate::getMyindex, monitorId)
|
||||
.between(LimitRate::getCreatTime,
|
||||
DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), -1)),
|
||||
DateUtil.endOfDay(DateUtil.offsetDay(new Date(), -1))).last("limit 1"));
|
||||
return limitRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断监测数据是否超标
|
||||
*
|
||||
* @param limitRate
|
||||
* @param steady
|
||||
*/
|
||||
private Map<String, Boolean> verifyLimit(LimitRate limitRate, SourceSteadyIndicator steady) {
|
||||
if (limitRate != null) {
|
||||
List<String> steadyIndicator = steady.getSteadyIndicator();
|
||||
Map<String, Boolean> limitBoolMap = new HashedMap();
|
||||
steadyIndicator.forEach(id -> {
|
||||
HttpResult<DictData> dicDataById = dicDataFeignClient.getDicDataById(id);
|
||||
if (CommonResponseEnum.SUCCESS.getCode().equals(dicDataById.getCode()) && dicDataById.getData() != null) {
|
||||
SteadyIndicatorEnum steadyIndicatorEnum = SteadyIndicatorEnum.getSteadyIndicatorEnumByCode(dicDataById.getData().getCode());
|
||||
switch (steadyIndicatorEnum) {
|
||||
case Negative_Voltage://负序电压不平衡度
|
||||
if (limitRate.getUbalanceOvertime() > 0) {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Negative_Voltage.getCode(), true);
|
||||
} else {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Negative_Voltage.getCode(), false);
|
||||
}
|
||||
break;
|
||||
case Interhar_Voltage://间谐波电压
|
||||
if (limitRate.getInuharm1Overtime() > 0 ||
|
||||
limitRate.getInuharm2Overtime() > 0 ||
|
||||
limitRate.getInuharm3Overtime() > 0 ||
|
||||
limitRate.getInuharm4Overtime() > 0 ||
|
||||
limitRate.getInuharm5Overtime() > 0 ||
|
||||
limitRate.getInuharm6Overtime() > 0 ||
|
||||
limitRate.getInuharm7Overtime() > 0 ||
|
||||
limitRate.getInuharm8Overtime() > 0 ||
|
||||
limitRate.getInuharm9Overtime() > 0 ||
|
||||
limitRate.getInuharm10Overtime() > 0 ||
|
||||
limitRate.getInuharm11Overtime() > 0 ||
|
||||
limitRate.getInuharm12Overtime() > 0 ||
|
||||
limitRate.getInuharm13Overtime() > 0 ||
|
||||
limitRate.getInuharm14Overtime() > 0 ||
|
||||
limitRate.getInuharm15Overtime() > 0 ||
|
||||
limitRate.getInuharm16Overtime() > 0) {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Interhar_Voltage.getCode(), true);
|
||||
} else {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Interhar_Voltage.getCode(), false);
|
||||
}
|
||||
break;
|
||||
case Neg_Current://负序电流
|
||||
if (limitRate.getINegOvertime() > 0) {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Neg_Current.getCode(), true);
|
||||
} else {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Neg_Current.getCode(), false);
|
||||
}
|
||||
break;
|
||||
case Fre_Deviation://频率偏差
|
||||
if (limitRate.getFreqDevOvertime() > 0) {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Fre_Deviation.getCode(), true);
|
||||
} else {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Fre_Deviation.getCode(), false);
|
||||
}
|
||||
break;
|
||||
case Voltage_Dev://电压偏差
|
||||
if (limitRate.getVoltageDevOvertime() > 0) {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Voltage_Dev.getCode(), true);
|
||||
} else {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Voltage_Dev.getCode(), false);
|
||||
}
|
||||
break;
|
||||
case Har_Current://谐波电流
|
||||
if (limitRate.getIharm2Overtime() > 0 ||
|
||||
limitRate.getIharm3Overtime() > 0 ||
|
||||
limitRate.getIharm4Overtime() > 0 ||
|
||||
limitRate.getIharm5Overtime() > 0 ||
|
||||
limitRate.getIharm6Overtime() > 0 ||
|
||||
limitRate.getIharm7Overtime() > 0 ||
|
||||
limitRate.getIharm8Overtime() > 0 ||
|
||||
limitRate.getIharm9Overtime() > 0 ||
|
||||
limitRate.getIharm10Overtime() > 0 ||
|
||||
limitRate.getIharm11Overtime() > 0 ||
|
||||
limitRate.getIharm12Overtime() > 0 ||
|
||||
limitRate.getIharm13Overtime() > 0 ||
|
||||
limitRate.getIharm14Overtime() > 0 ||
|
||||
limitRate.getIharm15Overtime() > 0 ||
|
||||
limitRate.getIharm16Overtime() > 0 ||
|
||||
limitRate.getIharm17Overtime() > 0 ||
|
||||
limitRate.getIharm18Overtime() > 0 ||
|
||||
limitRate.getIharm19Overtime() > 0 ||
|
||||
limitRate.getIharm20Overtime() > 0 ||
|
||||
limitRate.getIharm21Overtime() > 0 ||
|
||||
limitRate.getIharm22Overtime() > 0 ||
|
||||
limitRate.getIharm23Overtime() > 0 ||
|
||||
limitRate.getIharm24Overtime() > 0 ||
|
||||
limitRate.getIharm25Overtime() > 0) {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Har_Current.getCode(), true);
|
||||
} else {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Har_Current.getCode(), false);
|
||||
}
|
||||
break;
|
||||
case Voltage_Fluc://电压波动与闪变
|
||||
if (limitRate.getFlickerOvertime() > 0) {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Voltage_Fluc.getCode(), true);
|
||||
} else {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Voltage_Fluc.getCode(), false);
|
||||
}
|
||||
break;
|
||||
case Har_Voltage://谐波电压
|
||||
if (limitRate.getUharm2Overtime() > 0 ||
|
||||
limitRate.getUharm3Overtime() > 0 ||
|
||||
limitRate.getUharm4Overtime() > 0 ||
|
||||
limitRate.getUharm5Overtime() > 0 ||
|
||||
limitRate.getUharm6Overtime() > 0 ||
|
||||
limitRate.getUharm7Overtime() > 0 ||
|
||||
limitRate.getUharm8Overtime() > 0 ||
|
||||
limitRate.getUharm9Overtime() > 0 ||
|
||||
limitRate.getUharm10Overtime() > 0 ||
|
||||
limitRate.getUharm11Overtime() > 0 ||
|
||||
limitRate.getUharm12Overtime() > 0 ||
|
||||
limitRate.getUharm13Overtime() > 0 ||
|
||||
limitRate.getUharm14Overtime() > 0 ||
|
||||
limitRate.getUharm15Overtime() > 0 ||
|
||||
limitRate.getUharm16Overtime() > 0 ||
|
||||
limitRate.getUharm17Overtime() > 0 ||
|
||||
limitRate.getUharm18Overtime() > 0 ||
|
||||
limitRate.getUharm19Overtime() > 0 ||
|
||||
limitRate.getUharm20Overtime() > 0 ||
|
||||
limitRate.getUharm21Overtime() > 0 ||
|
||||
limitRate.getUharm22Overtime() > 0 ||
|
||||
limitRate.getUharm23Overtime() > 0 ||
|
||||
limitRate.getUharm24Overtime() > 0 ||
|
||||
limitRate.getUharm25Overtime() > 0) {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Har_Voltage.getCode(), true);
|
||||
} else {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Har_Voltage.getCode(), false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return limitBoolMap;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
package com.njcn.prepare.harmonic.service.mysql.line;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.pms.pojo.po.Monitor;
|
||||
import com.njcn.harmonic.pojo.vo.SourceSteadyIndicator;
|
||||
import com.njcn.harmonic.pojo.vo.ThsStrategyVo;
|
||||
import com.njcn.prepare.enums.TypeEnum;
|
||||
import com.njcn.process.pojo.po.LimitRate;
|
||||
import com.njcn.process.pojo.po.ThsSupervise;
|
||||
import com.njcn.process.pojo.po.ThsWarnStrategyAss;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -12,5 +22,43 @@ import com.njcn.process.pojo.po.ThsSupervise;
|
||||
* @since 2023-03-16
|
||||
*/
|
||||
public interface ThsSuperviseService extends IService<ThsSupervise> {
|
||||
/**
|
||||
* 初始化技术监督
|
||||
*/
|
||||
HttpResult<Boolean> initSupervise(Integer initType);
|
||||
|
||||
List<ThsStrategyVo> selectStrategyList(Integer initType);
|
||||
|
||||
/**
|
||||
* 查询LimitTarget数据
|
||||
*
|
||||
* @param monitorId
|
||||
*/
|
||||
LimitRate queryLimitTargetData(String monitorId);
|
||||
|
||||
/**
|
||||
* 生成监督数据
|
||||
*
|
||||
* @param limitBoolMap
|
||||
*/
|
||||
void creatSuperviseData(SourceSteadyIndicator steady, Map<String, Boolean> limitBoolMap, Monitor monitor, LimitRate limitRate);
|
||||
|
||||
List<ThsWarnStrategyAss> queryWarnStrategyAss(ThsStrategyVo strategyVo, TypeEnum typeEnum);
|
||||
/**
|
||||
* 生成监督数据
|
||||
*
|
||||
* @param steady
|
||||
* @param monitor
|
||||
* @return
|
||||
*/
|
||||
ThsSupervise insertSuperviseData(SourceSteadyIndicator steady, Monitor monitor, LimitRate limitRate);
|
||||
|
||||
/**
|
||||
* 生成 告警/预警监测点列表 数据
|
||||
*
|
||||
* @param steady
|
||||
* @param thsSupervise
|
||||
* @param monitor
|
||||
*/
|
||||
void insertOverRunLog(SourceSteadyIndicator steady, ThsSupervise thsSupervise, Monitor monitor, LimitRate limitRate);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user