敏感用户污染值统计

This commit is contained in:
xy
2025-12-13 20:33:08 +08:00
parent 3a97f01383
commit 12cfecac7e
12 changed files with 235 additions and 9 deletions

View File

@@ -185,4 +185,17 @@ public class PollutionSubstationController extends BaseController {
List<AreaPollution> areaPollution = pollutionSubstationService.getAreaPollution(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, areaPollution, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation(value ="敏感用户谐波污染值列表")
@PostMapping(value ="/downPollutionSensitiveUser")
public HttpResult<List<SubstationPollution>> downPollutionSensitiveUser(@RequestBody StatSubstationBizBaseParam param) {
String methodDescribe = getMethodDescribe("downPollutionSensitiveUser");
param.setStartTime(DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())).toString());
param.setEndTime(DateUtil.endOfDay(DateUtil.parse(param.getEndTime())).toString());
List<SubstationPollution> linePollutions = pollutionSubstationService.downPollutionSensitiveUser(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, linePollutions, methodDescribe);
}
}

View File

@@ -2,8 +2,8 @@ package com.njcn.harmonic.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.device.pq.pojo.dto.PollutionGridDiagramDTO;
import com.njcn.device.biz.pojo.dto.PollutionLineDTO;
import com.njcn.device.pq.pojo.dto.PollutionGridDiagramDTO;
import com.njcn.device.pq.pojo.dto.PollutionSubstationDTO;
import com.njcn.device.pq.pojo.param.GridDiagramParam;
import com.njcn.device.pq.pojo.param.OnlineRateParam;
@@ -131,4 +131,6 @@ public interface PollutionSubstationService extends IService<RStatPollutionSubst
* @Date: 2025/12/10 17:53
*/
List<AreaPollution> getAreaPollution(StatSubstationBizBaseParam param);
List<SubstationPollution> downPollutionSensitiveUser(StatSubstationBizBaseParam param);
}

View File

@@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.config.GeneralInfo;
import com.njcn.common.pojo.constant.BizParamConstant;
import com.njcn.common.pojo.dto.SimpleDTO;
import com.njcn.common.pojo.enums.common.ServerEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.PubUtils;
@@ -57,12 +58,14 @@ import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO;
import com.njcn.harmonic.pojo.vo.PollutionSubstationVO;
import com.njcn.harmonic.pojo.vo.PollutionVO;
import com.njcn.harmonic.pojo.vo.SubstationVo;
import com.njcn.harmonic.pojo.vo.hebeinorth.AssessVo;
import com.njcn.harmonic.rstatlimitrate.mapper.RStatLimitRateDMapper;
import com.njcn.harmonic.service.PollutionSubstationService;
import com.njcn.poi.excel.ExcelUtil;
import com.njcn.supervision.api.UserLedgerFeignClient;
import com.njcn.supervision.api.UserReportManageFeignClient;
import com.njcn.supervision.pojo.param.SensitiveUserParam;
import com.njcn.supervision.pojo.param.user.UserReportParam;
import com.njcn.supervision.pojo.po.user.UserReportPO;
import com.njcn.supervision.pojo.vo.user.UserLedgerVO;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
@@ -70,6 +73,12 @@ import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.dto.DeptDTO;
import com.njcn.user.pojo.po.Dept;
import com.njcn.web.utils.RequestUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
@@ -79,13 +88,6 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
/**
* Description:
@@ -131,6 +133,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
private final UserLedgerFeignClient userLedgerFeignClient;
private final RmpEventDetailFeignClient detailFeignClient;
private final CommLineClient commLineClient;
private final UserReportManageFeignClient userReportManageFeignClient;
/**
* @param pollutionSubstationQuryParam
@@ -1216,6 +1219,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
PowerFlagPollution pollution1;
for (PollutionLineInfoDTO lineDetail : lineDetails) {
pollution1 = new PowerFlagPollution();
pollution1.setSubName(lineDetail.getSubStationName());
pollution1.setLineName(lineDetail.getLineName());
pollution1.setDevName(lineDetail.getDevName());
pollution1.setManufacturer(lineDetail.getManufacturer());
@@ -1235,6 +1239,68 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
return info;
}
@Override
public List<SubstationPollution> downPollutionSensitiveUser(StatSubstationBizBaseParam param) {
List<SubstationPollution> result = new ArrayList<>();
DeptGetLineParam deptGetLineParam = new DeptGetLineParam();
deptGetLineParam.setDeptId(param.getDeptId());
deptGetLineParam.setLineRunFlag(0);
deptGetLineParam.setServerName(ServerEnum.HARMONIC.getName());
List<DeptGetChildrenMoreDTO> list = commTerminalGeneralClient.deptGetLine(deptGetLineParam).getData();
List<String> lineList = list.stream()
.flatMap(dto -> dto.getLineBaseList().stream().map(LineDevGetDTO::getPointId))
.distinct()
.collect(Collectors.toList());
//全部监测点污染值
List<LinePollution> finalLinePollutionList = pollutionCalcList(param,lineList);
//根据变电站分组
Map<String, List<LinePollution>> linePollutionMap = finalLinePollutionList.stream().collect(Collectors.groupingBy(LinePollution::getSubStationName));
//获取部门id
SensitiveUserParam sensitiveUserParam = new SensitiveUserParam();
sensitiveUserParam.setDeptId(param.getDeptId());
sensitiveUserParam.setProjectName(param.getSearchValue());
List<UserReportPO> userReportPOList = userReportManageFeignClient.getSensitiveUserByDept(sensitiveUserParam).getData();
if (CollectionUtil.isNotEmpty(userReportPOList)) {
userReportPOList.forEach(item -> {
if (ObjectUtil.isNotNull(item.getSubstation()) && !Objects.equals(item.getSubstation(), "")) {
List<BigDecimal> value = new ArrayList<>();
List<PowerFlagPollution> ll = new ArrayList<>();
String[] parts = item.getSubstation().split("");
for (String part : parts) {
// 移除数字+kV和"变电站"
String name = part.replaceAll("\\d+kV", "").replace("变电站", "");
//根据变电站名称获取污染值
for (Map.Entry<String, List<LinePollution>> entry : linePollutionMap.entrySet()) {
if (entry.getKey().contains(name)) {
BigDecimal v = BigDecimal.valueOf(entry.getValue().stream().mapToDouble(LinePollution::getHarmonicValue).average().getAsDouble());
value.add(v);
for (LinePollution pojo : entry.getValue()) {
PowerFlagPollution lineItemPollution = new PowerFlagPollution();
BeanUtil.copyProperties(pojo, lineItemPollution, true);
lineItemPollution.setVHarmonicValue(pojo.getHarmonicValue());
ll.add(lineItemPollution);
}
}
}
}
SubstationPollution linePollution = new SubstationPollution();
linePollution.setGdName(item.getCity());
linePollution.setSubStationName(item.getSubstation());
linePollution.setProjectName(item.getProjectName());
linePollution.setSubVStationValue(String.valueOf(BigDecimal.valueOf(value.stream()
.mapToDouble(BigDecimal::doubleValue)
.average()
.orElse(0.0)).setScale(2, RoundingMode.HALF_UP).doubleValue()));
result.add(linePollution);
linePollution.setPowerFlagPollutionList(ll);
}
});
}
return result;
}
private List<String> addList(List<RMpPollutionDPO> pollLinelist, List<SubGetBase> notNum) {
List<String> info = new ArrayList<>();