1.国网上送代码调整
2.技术监督模块策略添加类型判断
This commit is contained in:
@@ -1,11 +1,13 @@
|
|||||||
package com.njcn.prepare.harmonic.controller.dim;
|
package com.njcn.prepare.harmonic.controller.dim;
|
||||||
|
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.common.utils.HttpResultUtil;
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
import com.njcn.common.utils.LogUtil;
|
import com.njcn.common.utils.LogUtil;
|
||||||
@@ -32,10 +34,7 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.HashSet;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pqs
|
* pqs
|
||||||
@@ -212,4 +211,58 @@ public class IRDimBusGlobalDController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增重算月数据
|
||||||
|
* @author cdf
|
||||||
|
* @date 2024/3/22
|
||||||
|
*/
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@GetMapping("/reCalMonthUploadAlgorithm")
|
||||||
|
@ApiOperation("重新计算四个算法")
|
||||||
|
@ApiImplicitParam(name = "statisticDate", value = "重新计算的月份", required = true)
|
||||||
|
public HttpResult<String> reCalUploadAlgorithmAllMonth(@DateTimeStrValid(format = "yyyy-MM") @RequestParam("statisticDate") String statisticDate,@RequestParam("type") String type) {
|
||||||
|
String methodDescribe = getMethodDescribe("reCalUploadAlgorithmAllMonth");
|
||||||
|
Set<String> set = new HashSet<>();
|
||||||
|
|
||||||
|
String startDate = DateUtil.format(DateUtil.beginOfDay(DateUtil.parse(statisticDate,DatePattern.NORM_MONTH_PATTERN)),DatePattern.NORM_DATE_PATTERN);
|
||||||
|
String endDate = DateUtil.format(new Date(),DatePattern.NORM_DATE_PATTERN);
|
||||||
|
|
||||||
|
BaseParam baseParam = new BaseParam();
|
||||||
|
baseParam.setFullChain(false);
|
||||||
|
baseParam.setRepair(true);
|
||||||
|
baseParam.setBeginTime(startDate);
|
||||||
|
baseParam.setEndTime(endDate);
|
||||||
|
|
||||||
|
if(StrUtil.isBlank(type)){
|
||||||
|
throw new BusinessException("请选择需要重新计算的类型");
|
||||||
|
}else if("0".equals(type)){
|
||||||
|
//基准
|
||||||
|
set.add("r_upload_evaluation_data_d");
|
||||||
|
baseParam.setTagNames(set);
|
||||||
|
liteFlowFeignClient.uploadOrgExecutor(baseParam);
|
||||||
|
}else if("1".equals(type)){
|
||||||
|
//主配网
|
||||||
|
set.add("r_upload_point_statistical_data_d");
|
||||||
|
baseParam.setTagNames(set);
|
||||||
|
liteFlowFeignClient.uploadOrgExecutor(baseParam);
|
||||||
|
}else if("2".equals(type)){
|
||||||
|
//电站
|
||||||
|
baseParam.setFullChain(false);
|
||||||
|
baseParam.setRepair(false);
|
||||||
|
baseParam.setDataDate(endDate);
|
||||||
|
set.add("r_upload_substation_statistical_data_m");
|
||||||
|
baseParam.setTagNames(set);
|
||||||
|
liteFlowFeignClient.substationExecutor(baseParam);
|
||||||
|
}else if("3".equals(type)){
|
||||||
|
//典型
|
||||||
|
set.add("pq_typical_source_create_d");
|
||||||
|
baseParam.setDataDate(statisticDate);
|
||||||
|
baseParam.setTagNames(set);
|
||||||
|
liteFlowFeignClient.uploadOrgExecutor(baseParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -637,42 +637,26 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
|
|||||||
|
|
||||||
List<ThsStrategyVo> threeLevel = thsStrategyList.stream().filter(r -> GradeEnum.THREE_LEVEL.getCode().equals(r.getGrade())).collect(Collectors.toList());//三级策略集合
|
List<ThsStrategyVo> threeLevel = thsStrategyList.stream().filter(r -> GradeEnum.THREE_LEVEL.getCode().equals(r.getGrade())).collect(Collectors.toList());//三级策略集合
|
||||||
//获取排他策略集合
|
//获取排他策略集合
|
||||||
assBindList(threeLevel, thsStrategyBindDTOList);
|
if(CollectionUtil.isNotEmpty(threeLevel)){
|
||||||
|
threeLevel.forEach(i->assBindList(i, thsStrategyBindDTOList));
|
||||||
|
}
|
||||||
Map<String, ThsStrategyBindDTO> deleteMap = thsStrategyBindDTOList.stream().collect(Collectors.toMap(ThsStrategyBindDTO::getKeyId, Function.identity()));
|
Map<String, ThsStrategyBindDTO> deleteMap = thsStrategyBindDTOList.stream().collect(Collectors.toMap(ThsStrategyBindDTO::getKeyId, Function.identity()));
|
||||||
|
|
||||||
|
|
||||||
List<ThsStrategyVo> oneLevel = thsStrategyList.stream().filter(r -> !GradeEnum.THREE_LEVEL.getCode().equals(r.getGrade())).collect(Collectors.toList());//一级或二级策略集合
|
List<ThsStrategyVo> oneLevel = thsStrategyList.stream().filter(r -> !GradeEnum.THREE_LEVEL.getCode().equals(r.getGrade())).collect(Collectors.toList());//一级或二级策略集合
|
||||||
|
|
||||||
Map<String, List<ThsStrategyVo>> deptMap = oneLevel.stream().collect(Collectors.groupingBy(ThsStrategyVo::getDeptId));
|
Map<String, List<ThsStrategyVo>> deptMap = oneLevel.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 depId = entry.getKey();
|
String depId = entry.getKey();
|
||||||
Dept dept = deptFeignClient.getDeptById(depId).getData();
|
Dept dept = deptFeignClient.getDeptById(depId).getData();
|
||||||
|
|
||||||
List<ThsOverRunLog> thsOverRunLogList = new ArrayList<>();
|
List<ThsOverRunLog> thsOverRunLogList = new ArrayList<>();
|
||||||
|
|
||||||
ThsSupervise thsSupervise = null;
|
ThsSupervise thsSupervise = null;
|
||||||
List<ThsStrategyVo> deptStrategyList = entry.getValue();
|
List<ThsStrategyVo> deptStrategyList = entry.getValue();
|
||||||
if (CollectionUtil.isNotEmpty(deptStrategyList)) {
|
if (CollectionUtil.isNotEmpty(deptStrategyList)) {
|
||||||
|
|
||||||
|
|
||||||
//遍历当前部门下面的所有策略
|
//遍历当前部门下面的所有策略
|
||||||
for (ThsStrategyVo oneStrategyVo : deptStrategyList) {
|
for (ThsStrategyVo oneStrategyVo : deptStrategyList) {
|
||||||
List<ThsStrategyBindDTO> useBindDTOList = new ArrayList<>();
|
List<ThsStrategyBindDTO> useBindDTOList = new ArrayList<>();
|
||||||
List<ThsWarnStrategyAss> oneInterferenceSourceAsses = this.queryWarnStrategyAss(oneStrategyVo.getId(), TypeEnum.SOURCE_TYPE);//干扰源列表
|
assBindList(oneStrategyVo,useBindDTOList);
|
||||||
List<ThsWarnStrategyAss> oneSteadyIndicatorAsses = this.queryWarnStrategyAss(oneStrategyVo.getId(), TypeEnum.INTERFERENCE_TYPE);//指标类型列表
|
|
||||||
List<ThsWarnStrategyAss> oneMonitorAsses = this.queryWarnStrategyAss(oneStrategyVo.getId(), TypeEnum.MONITOR_TYPE);//监测点列表
|
|
||||||
|
|
||||||
List<String> tagIds = oneInterferenceSourceAsses.stream().map(ThsWarnStrategyAss::getAssId).distinct().collect(Collectors.toList());
|
|
||||||
List<String> targetIds = oneSteadyIndicatorAsses.stream().map(ThsWarnStrategyAss::getAssId).distinct().collect(Collectors.toList());
|
|
||||||
List<String> monitorIds = oneMonitorAsses.stream().map(ThsWarnStrategyAss::getAssId).collect(Collectors.toList());
|
|
||||||
for (String tagId : tagIds) {
|
|
||||||
ThsStrategyBindDTO strategyBindDTO = ThsStrategyBindDTO.builder().keyId(tagId).targetIds(targetIds).operation(oneStrategyVo.getOperation()).type(0).build();
|
|
||||||
useBindDTOList.add(strategyBindDTO);
|
|
||||||
}
|
|
||||||
for (String monitorId : monitorIds) {
|
|
||||||
ThsStrategyBindDTO strategyBindDTO = ThsStrategyBindDTO.builder().keyId(monitorId).targetIds(targetIds).operation(oneStrategyVo.getOperation()).type(1).build();
|
|
||||||
useBindDTOList.add(strategyBindDTO);
|
|
||||||
}
|
|
||||||
//根据排他策略过滤12级策略
|
//根据排他策略过滤12级策略
|
||||||
Iterator<ThsStrategyBindDTO> iterator = useBindDTOList.iterator();
|
Iterator<ThsStrategyBindDTO> iterator = useBindDTOList.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
@@ -694,7 +678,6 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
|
|||||||
List<String> useMonitorIds = monitorObj.stream().map(ThsStrategyBindDTO::getKeyId).collect(Collectors.toList());
|
List<String> useMonitorIds = monitorObj.stream().map(ThsStrategyBindDTO::getKeyId).collect(Collectors.toList());
|
||||||
Map<String, ThsStrategyBindDTO> monitorMap = monitorObj.stream().collect(Collectors.toMap(ThsStrategyBindDTO::getKeyId, Function.identity()));
|
Map<String, ThsStrategyBindDTO> monitorMap = monitorObj.stream().collect(Collectors.toMap(ThsStrategyBindDTO::getKeyId, Function.identity()));
|
||||||
|
|
||||||
|
|
||||||
MonitorGetParam monitorGetParam = new MonitorGetParam();
|
MonitorGetParam monitorGetParam = new MonitorGetParam();
|
||||||
monitorGetParam.setTagList(useTagIds);
|
monitorGetParam.setTagList(useTagIds);
|
||||||
monitorGetParam.setMonitorIds(useMonitorIds);
|
monitorGetParam.setMonitorIds(useMonitorIds);
|
||||||
@@ -704,11 +687,9 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
|
|||||||
Map<String, CommMonitorInfoDTO> monitorInfoDTOMap = commMonitorInfoDTOList.stream().collect(Collectors.toMap(CommMonitorInfoDTO::getId, Function.identity()));
|
Map<String, CommMonitorInfoDTO> monitorInfoDTOMap = commMonitorInfoDTOList.stream().collect(Collectors.toMap(CommMonitorInfoDTO::getId, Function.identity()));
|
||||||
|
|
||||||
List<String> temIds = commMonitorInfoDTOList.stream().map(CommMonitorInfoDTO::getId).distinct().collect(Collectors.toList());
|
List<String> temIds = commMonitorInfoDTOList.stream().map(CommMonitorInfoDTO::getId).distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
List<RStatLimitRateDPO> rStatLimitRateDPOList = rStatLimitRateDClient.monitorIdsGetLimitInfo(RStatLimitQueryParam.builder().ids(temIds).date(yesterday).build()).getData();
|
List<RStatLimitRateDPO> rStatLimitRateDPOList = rStatLimitRateDClient.monitorIdsGetLimitInfo(RStatLimitQueryParam.builder().ids(temIds).date(yesterday).build()).getData();
|
||||||
|
|
||||||
//TODO 数据中心和pms这边稳态指标没用一个需要考虑兼容问题
|
//TODO 数据中心和pms这边稳态指标没用一个需要考虑兼容问题
|
||||||
|
|
||||||
//判断指标是否在策略中
|
//判断指标是否在策略中
|
||||||
if (CollectionUtil.isNotEmpty(rStatLimitRateDPOList)) {
|
if (CollectionUtil.isNotEmpty(rStatLimitRateDPOList)) {
|
||||||
for (RStatLimitRateDPO rStatLimitRateDPO : rStatLimitRateDPOList) {
|
for (RStatLimitRateDPO rStatLimitRateDPO : rStatLimitRateDPOList) {
|
||||||
@@ -728,7 +709,6 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Boolean> limitBoolMap = verifyLimit(rStatLimitRateDPO, dictDataList, descriptionList, count);
|
Map<String, Boolean> limitBoolMap = verifyLimit(rStatLimitRateDPO, dictDataList, descriptionList, count);
|
||||||
|
|
||||||
boolean shouldContinue;
|
boolean shouldContinue;
|
||||||
if (oneStrategyVo.getOperation().equals(OperationEnum.AND.getCode())) {
|
if (oneStrategyVo.getOperation().equals(OperationEnum.AND.getCode())) {
|
||||||
//与
|
//与
|
||||||
@@ -772,10 +752,8 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -832,9 +810,8 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
|
|||||||
* @author cdf
|
* @author cdf
|
||||||
* @date 2024/3/19
|
* @date 2024/3/19
|
||||||
*/
|
*/
|
||||||
private void assBindList(List<ThsStrategyVo> levelList, List<ThsStrategyBindDTO> thsStrategyBindDTOList) {
|
private void assBindList(ThsStrategyVo thsStrategyVo, List<ThsStrategyBindDTO> thsStrategyBindDTOList) {
|
||||||
if (CollectionUtil.isNotEmpty(levelList)) {
|
|
||||||
for (ThsStrategyVo thsStrategyVo : levelList) {
|
|
||||||
List<ThsWarnStrategyAss> tagIdsAss = this.queryWarnStrategyAss(thsStrategyVo.getId(), TypeEnum.SOURCE_TYPE);//干扰源列表
|
List<ThsWarnStrategyAss> tagIdsAss = this.queryWarnStrategyAss(thsStrategyVo.getId(), TypeEnum.SOURCE_TYPE);//干扰源列表
|
||||||
List<ThsWarnStrategyAss> targetIdsAss = this.queryWarnStrategyAss(thsStrategyVo.getId(), TypeEnum.INTERFERENCE_TYPE);//指标类型列表
|
List<ThsWarnStrategyAss> targetIdsAss = this.queryWarnStrategyAss(thsStrategyVo.getId(), TypeEnum.INTERFERENCE_TYPE);//指标类型列表
|
||||||
List<ThsWarnStrategyAss> monitorIdsAss = this.queryWarnStrategyAss(thsStrategyVo.getId(), TypeEnum.MONITOR_TYPE);//监测点列表
|
List<ThsWarnStrategyAss> monitorIdsAss = this.queryWarnStrategyAss(thsStrategyVo.getId(), TypeEnum.MONITOR_TYPE);//监测点列表
|
||||||
@@ -852,8 +829,6 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
|
|||||||
thsStrategyBindDTOList.add(strategyBindDTO);
|
thsStrategyBindDTOList.add(strategyBindDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import com.njcn.user.api.DeptFeignClient;
|
|||||||
import com.njcn.user.pojo.dto.DeptDTO;
|
import com.njcn.user.pojo.dto.DeptDTO;
|
||||||
import com.njcn.web.utils.RequestUtil;
|
import com.njcn.web.utils.RequestUtil;
|
||||||
import com.njcn.web.utils.WebUtil;
|
import com.njcn.web.utils.WebUtil;
|
||||||
|
import liquibase.pro.packaged.S;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.math3.random.RandomDataGenerator;
|
import org.apache.commons.math3.random.RandomDataGenerator;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -49,6 +50,8 @@ import java.util.stream.Collectors;
|
|||||||
public class ThsWarnStrategyServiceImpl extends ServiceImpl<ThsWarnStrategyMapper, ThsWarnStrategy> implements ThsWarnStrategyService {
|
public class ThsWarnStrategyServiceImpl extends ServiceImpl<ThsWarnStrategyMapper, ThsWarnStrategy> implements ThsWarnStrategyService {
|
||||||
|
|
||||||
private final ThsWarnStrategyAssServiceImpl thsWarnStrategyAssService;
|
private final ThsWarnStrategyAssServiceImpl thsWarnStrategyAssService;
|
||||||
|
|
||||||
|
private final ThsWarnStrategyMapper thsWarnStrategyMapper;
|
||||||
private final MonitorClient monitorClient;
|
private final MonitorClient monitorClient;
|
||||||
private final DeptFeignClient deptFeignClient;
|
private final DeptFeignClient deptFeignClient;
|
||||||
private final ThsDeptAlarmService thsDeptAlarmService;
|
private final ThsDeptAlarmService thsDeptAlarmService;
|
||||||
@@ -107,6 +110,8 @@ public class ThsWarnStrategyServiceImpl extends ServiceImpl<ThsWarnStrategyMappe
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = {Exception.class})
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
public Boolean bindStrategy(StrategyParam.BindParam param) {
|
public Boolean bindStrategy(StrategyParam.BindParam param) {
|
||||||
|
checkBind(param);
|
||||||
|
|
||||||
List<ThsWarnStrategyAss> assList = new ArrayList<>();
|
List<ThsWarnStrategyAss> assList = new ArrayList<>();
|
||||||
|
|
||||||
ThsWarnStrategy thsWarnStrategy = new ThsWarnStrategy();
|
ThsWarnStrategy thsWarnStrategy = new ThsWarnStrategy();
|
||||||
@@ -141,6 +146,38 @@ public class ThsWarnStrategyServiceImpl extends ServiceImpl<ThsWarnStrategyMappe
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验
|
||||||
|
*/
|
||||||
|
private boolean checkBind(StrategyParam.BindParam param){
|
||||||
|
|
||||||
|
LambdaQueryWrapper<ThsWarnStrategy> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
lambdaQueryWrapper.select(ThsWarnStrategy::getId).eq(ThsWarnStrategy::getDeptId,param.getDeptId())
|
||||||
|
.eq(ThsWarnStrategy::getType,param.getStrategyType()).eq(ThsWarnStrategy::getGrade,param.getGrade());
|
||||||
|
|
||||||
|
if (StrUtil.isNotBlank(param.getId())) {
|
||||||
|
lambdaQueryWrapper.ne(ThsWarnStrategy::getId,param.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ThsWarnStrategy> thsWarnStrategyList = thsWarnStrategyMapper.selectList(lambdaQueryWrapper);
|
||||||
|
List<String> strategyIds = thsWarnStrategyList.stream().map(ThsWarnStrategy::getId).collect(Collectors.toList());
|
||||||
|
if(CollectionUtil.isEmpty(strategyIds)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断标签和监测点是否已经存在
|
||||||
|
List<ThsWarnStrategyAss> thsWarnStrategyAssList = thsWarnStrategyAssService.lambdaQuery().select(ThsWarnStrategyAss::getAssId).in(ThsWarnStrategyAss::getWarnId,strategyIds).list();
|
||||||
|
long tagCount = thsWarnStrategyAssList.stream().filter(item->param.getMonitorTag().contains(item.getAssId())).count();
|
||||||
|
if(tagCount>0){
|
||||||
|
throw new BusinessException("所选干扰源已经存在策略!");
|
||||||
|
}
|
||||||
|
long monitorCount = thsWarnStrategyAssList.stream().filter(item->param.getMonitorIds().contains(item.getAssId())).count();
|
||||||
|
if(monitorCount>0){
|
||||||
|
throw new BusinessException("所选监测点已经存在策略!");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StrategyParam.StrategyUpdateParam getUpdateStrategy(String id) {
|
public StrategyParam.StrategyUpdateParam getUpdateStrategy(String id) {
|
||||||
return this.baseMapper.selectUpdateStrategy(id);
|
return this.baseMapper.selectUpdateStrategy(id);
|
||||||
|
|||||||
Reference in New Issue
Block a user