1.解决变电站数量不统一问题

2.替换最新污染值
3.解决终端数量不一致问题
This commit is contained in:
wr
2025-12-10 16:19:35 +08:00
parent 6d833678a6
commit 0fdc3edb89
37 changed files with 358 additions and 94 deletions

View File

@@ -13,6 +13,8 @@ public class PollutionLineInfoDTO {
/**
* 所属变电站
*/
private String subStationId;
private String subStationName;
/**

View File

@@ -32,7 +32,6 @@ public class DeptGetLineParam {
private Boolean monitorStateRunning=true;
@ApiModelProperty(name = "isUpToGrid",value = "0.非送国网 1.需要送国网的")
private Integer isUpToGrid;
/**
* 0-电网侧

View File

@@ -70,6 +70,16 @@ public interface GeneralDeviceInfoClient {
HttpResult<List<GeneralDeviceDTO>> getPracticalRunDeviceInfoAsSubstation(@RequestBody DeviceInfoParam deviceInfoParam);
/**
* 获取变电站分类的所有终端综合信息
*
* @param deviceInfoParam 查询终端条件
* @return 获取变电站分类的所有终端综合信息
*/
@PostMapping("/getPracticalAllDeviceInfoAsSubstation")
HttpResult<List<GeneralDeviceDTO>> getPracticalAllDeviceInfoAsSubstation(@RequestBody DeviceInfoParam deviceInfoParam);
/**
* 获取实际运行终端综合信息
*

View File

@@ -59,6 +59,12 @@ public class GeneralDeviceInfoClientFallbackFactory implements FallbackFactory<G
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<GeneralDeviceDTO>> getPracticalAllDeviceInfoAsSubstation(DeviceInfoParam deviceInfoParam) {
log.error("{}异常,降级处理,异常为:{}", "获取变电站分类的所有终端综合信息", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<GeneralDeviceDTO>> getPracticalRunDeviceInfo(DeviceInfoParam deviceInfoParam) {
log.error("{}异常,降级处理,异常为:{}", "获取实际运行终端综合信息", throwable.toString());

View File

@@ -105,6 +105,14 @@ public class DeviceInfoParam implements Serializable {
@Range(min = 0, max = 2, message = "监测点运行状态" + ValidMessage.PARAM_FORMAT_ERROR)
private Integer lineRunFlag;
@ApiModelProperty("0按照监测点搜索 1按照装置搜索")
private Integer lineOrDevice;
/**
* 搜索值
*/
@ApiModelProperty("搜索值")
private String searchValue;
/**
* 默认全部监测点
*
@@ -207,6 +215,9 @@ public class DeviceInfoParam implements Serializable {
@ApiModelProperty("是否是冀北电网一张图树 0:否 1:是")
private Integer type = 0;
@ApiModelProperty("指标")
private List<String> dicData;
}
public Boolean isUserLedger() {

View File

@@ -13,7 +13,6 @@ import java.util.List;
* @createTime: 2023-04-03
*/
@Data
@ApiModel
public class OnlineRateParam {
@ApiModelProperty(name = "ids", value = "设备id")
@@ -27,4 +26,10 @@ public class OnlineRateParam {
@ApiModelProperty(name = "type", value = "区分类型0topid搜索 1devid搜索")
private Integer type;
@Data
public static class Info extends OnlineRateParam {
@ApiModelProperty(name = "dicData", value = "字典id")
private List<String> dicData;
}
}

View File

@@ -5,6 +5,7 @@ import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
/**
* 监测点详细信息
@@ -131,4 +132,17 @@ public class AreaLineInfoVO implements Serializable {
@ApiModelProperty(name = "objId",value = "对象id")
private String objId;
private Double vHarmonicValue; ;
private List<User> userList;
@Data
public static class User{
private String id;
private String projectName;
private String stationId;
private String lineId;
private String city;
}
}

View File

@@ -81,6 +81,7 @@ public class DeviceRunEvaluateController extends BaseController {
@ApiOperation("终端评价列表(冀北)")
public HttpResult<List<DeviceRunEvaluateVO.Detail>> getRunEvaluateInfo(@RequestBody DeviceInfoParam.BusinessParam businessParam) {
String methodDescribe = getMethodDescribe("getRunEvaluateInfo");
businessParam.setLineOrDevice(1);
List<DeviceRunEvaluateVO.Detail> runEvaluate = deviceRunEvaluateService.getRunEvaluate(businessParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, runEvaluate, methodDescribe);
}

View File

@@ -136,6 +136,22 @@ public class GeneralDeviceInfoController extends BaseController {
}
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getPracticalAllDeviceInfoAsSubstation")
@ApiOperation("获取按变电站分类的所有终端综合信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "deviceInfoParam", value = "查询终端条件", required = true)
})
public HttpResult<List<GeneralDeviceDTO>> getPracticalAllDeviceInfoAsSubstation(@RequestBody @Validated DeviceInfoParam deviceInfoParam) {
String methodDescribe = getMethodDescribe("getPracticalAllDeviceInfoAsSubstation");
List<GeneralDeviceDTO> substationDeviceInfos = generalDeviceService.getDeviceInfoAsSubstation(deviceInfoParam, null, Stream.of(1).collect(Collectors.toList()));
if (CollectionUtil.isEmpty(substationDeviceInfos)) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, new ArrayList<>(), methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, substationDeviceInfos, methodDescribe);
}
}
/**
* 获取实际运行终端综合信息
*/

View File

@@ -56,7 +56,6 @@ public class GridDiagramController extends BaseController {
@ApiOperation("变电站趋势分析")
public HttpResult<Map<String, Long>> getGridDiagramSubTendency(@RequestBody GridDiagramParam param){
String methodDescribe = getMethodDescribe("getGridDiagramSubTendency");
param.getDeviceInfoParam().setPowerFlag(0);
Map<String, Long> gridDiagramDevTendency = gridDiagramService.getGridDiagramDevTendency(param,3);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, gridDiagramDevTendency, methodDescribe);
}
@@ -91,6 +90,7 @@ public class GridDiagramController extends BaseController {
@ApiOperation("监测点趋势分析")
public HttpResult<Map<String, Long>> getGridDiagramLineTendency(@RequestBody GridDiagramParam param){
String methodDescribe = getMethodDescribe("getGridDiagramLineTendency");
param.getDeviceInfoParam().setLineRunFlag(0);
Map<String, Long> gridDiagramDevTendency = gridDiagramService.getGridDiagramDevTendency(param,6);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, gridDiagramDevTendency, methodDescribe);
}

View File

@@ -153,6 +153,7 @@ public class LineIntegrityDataController extends BaseController {
@ApiOperation("监测点数据完整性(冀北)")
@ApiImplicitParam(name = "param", value = "参数实体", required = true)
public HttpResult<DeviceOnlineRate> getData(@RequestBody DeviceInfoParam.BusinessParam param) {
param.setLineOrDevice(0);
String methodDescribe = getMethodDescribe("getData");
DeviceOnlineRate rate = irStatIntegrityDService.getData(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rate, methodDescribe);

View File

@@ -227,7 +227,7 @@ public class CommTerminalServiceImpl implements CommTerminalService {
public List<DeptGetSubStationDTO.Info> deptSubStationInfo(DeptGetLineParam deptGetLineParam) {
List<DeptGetSubStationDTO.Info> result = new ArrayList<>();
List<DeptGetBase> temDept = getDeptChildrenByParent(deptGetLineParam);
List<TerminalGetBase.Extend> anExtends = deptLineService.orgSubStationInfoGet(filterDataTypeNew(deptGetLineParam.getServerName()),deptGetLineParam.getPowerFlag(),deptGetLineParam.getLineRunFlag());
List<TerminalGetBase.Extend> anExtends = deptLineService.orgSubStationInfoGet(filterDataTypeNew(deptGetLineParam.getServerName()),deptGetLineParam.getPowerFlag(),deptGetLineParam.getLineRunFlag(),deptGetLineParam.getIsUpToGrid());
Map<String, List<TerminalGetBase.Extend>> orgSub = anExtends.stream().collect(Collectors.groupingBy(TerminalGetBase::getUnitId));
Map<String, String> deptNameMap = temDept.stream().collect(Collectors.toMap(DeptGetBase::getUnitId, DeptGetBase::getUnitName));
temDept.forEach(item -> {

View File

@@ -82,7 +82,6 @@ public class GridDiagramServiceImpl implements GridDiagramService {
}
GridDiagramVO gridDiagramVO = new GridDiagramVO();
List<GridDiagramVO.LineStatistics> info = new ArrayList<>();
List<GridDiagramVO.LineStatistics> gwInfo = new ArrayList<>();
@@ -295,11 +294,11 @@ public class GridDiagramServiceImpl implements GridDiagramService {
@Override
public Map<String, Long> getGridDiagramDevTendency(GridDiagramParam param, Integer type) {
param.getDeviceInfoParam().setLineRunFlag(0);
if (type == 3) {
param.getDeviceInfoParam().setPowerFlag(0);
List<Integer> runFlag = new ArrayList<>();
if (3 != type) {
runFlag.add(0);
}
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(param.getDeviceInfoParam(), Stream.of(0).collect(Collectors.toList()), Stream.of(1).collect(Collectors.toList()));
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(param.getDeviceInfoParam(), runFlag, Stream.of(1).collect(Collectors.toList()));
Map<String, Long> map = new LinkedHashMap<>();
DateField dateField;
DateTime parse;
@@ -359,7 +358,6 @@ public class GridDiagramServiceImpl implements GridDiagramService {
@Override
public List<GridDiagramVO.DeviceData> getGridDiagramDevData(GridDiagramParam param) {
param.getDeviceInfoParam().setLineRunFlag(0);
// 获取所有数据
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(param.getDeviceInfoParam(), Stream.of(0).collect(Collectors.toList()), Stream.of(1).collect(Collectors.toList()));
List<String> devIDs = generalDeviceDTOList.stream().flatMap(x -> x.getDeviceIndexes().stream()).distinct().collect(Collectors.toList());
@@ -399,9 +397,8 @@ public class GridDiagramServiceImpl implements GridDiagramService {
@Override
public List<GridDiagramVO.DevData> getGridDiagramDevDataList(GridDiagramParam param) {
param.getDeviceInfoParam().setLineRunFlag(0);
List<GridDiagramVO.DevData> info = new ArrayList<>();
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfoAsDept(param.getDeviceInfoParam(), null, Stream.of(1).collect(Collectors.toList()));
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfoAsDept(param.getDeviceInfoParam(), Arrays.asList(0), Stream.of(1).collect(Collectors.toList()));
List<String> devIds = generalDeviceDTOList.stream().flatMap(x -> x.getDeviceIndexes().stream()).collect(Collectors.toList());
//终端信息
List<Device> devList = new ArrayList<>();

View File

@@ -428,7 +428,7 @@ public class GeneralDeviceService {
//2.筛选出终端id理论上监测点的pids中第五个id为终端id
List<String> devIds = voltages.stream().map(Line::getPid).distinct().collect(Collectors.toList());
// 再根据终端条件筛选合法终端信息 联查pq_line t1,pq_device t2
List<Line> devices = terminalBaseService.getDeviceByCondition(devIds, deviceType, deviceInfoParam.getManufacturer());
List<Line> devices = terminalBaseService.getDeviceByCondition(devIds, deviceType, deviceInfoParam);
//3.筛选出变电站id理论上监测点的pids中第四个id为变电站id 联查: pq_line t1 ,pq_substation t2
List<String> subIds = devices.stream().map(Line::getPid).distinct().collect(Collectors.toList());

View File

@@ -129,7 +129,7 @@ public interface TerminalBaseService {
* @param deviceType 终端筛选条件
* @param manufacturer 终端厂家
*/
List<Line> getDeviceByCondition(List<String> devIds, DeviceType deviceType, List<SimpleDTO> manufacturer);
List<Line> getDeviceByCondition(List<String> devIds, DeviceType deviceType, DeviceInfoParam manufacturer);
/**
* 查询母线信息

View File

@@ -1627,7 +1627,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
}
@Override
public List<Line> getDeviceByCondition(List<String> devIds, DeviceType deviceType, List<SimpleDTO> manufacturer) {
public List<Line> getDeviceByCondition(List<String> devIds, DeviceType deviceType, DeviceInfoParam manufacturer) {
return this.baseMapper.getDeviceByCondition(devIds, deviceType, manufacturer);
}

View File

@@ -41,6 +41,7 @@ public class OnLineRateController extends BaseController {
@ApiOperation("终端在线率列表(冀北)")
public HttpResult<DeviceOnlineRate> deviceOnlineRateInfo(@RequestBody DeviceInfoParam.BusinessParam deviceInfoParam) {
String methodDescribe = getMethodDescribe("deviceOnlineRateInfo");
deviceInfoParam.setLineOrDevice(1);
DeviceOnlineRate rate = onLineRateService.deviceOnlineRateInfo(deviceInfoParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rate, methodDescribe);
}

View File

@@ -355,6 +355,7 @@
line.id lineId,
line.name lineName,
gdinfo.NAME AS gdName,
substation.id AS subStationId,
substation.NAME AS subStationName,
device.NAME AS devName,
deviceDetail.Com_Flag AS comFlag,

View File

@@ -76,9 +76,17 @@ public interface DeptLineMapper extends BaseMapper<DeptLine> {
List<TerminalGetBase> orgSubStationGet(@Param("list")List<Integer> devType);
List<TerminalGetBase.Extend> orgSubStationInfoGet(@Param("list")List<Integer> devType,@Param("powerFlag")Integer powerFlag,@Param("lineRunFlag") Integer lineRunFlag);
List<TerminalGetBase.Extend> orgSubStationInfoGet(@Param("list")List<Integer> devType,
@Param("powerFlag")Integer powerFlag,
@Param("lineRunFlag") Integer lineRunFlag,
@Param("monitorFlag") Integer monitorFlag
);
List<String> getLineIdByDeptIds(@Param("deptIds")List<String> deptIds,@Param("manufacturer")String manufacturer,@Param("runFlag")List<Integer> runFlag,@Param("dataType")List<Integer> dataType,@Param("objType")String objType);
List<String> getLineIdByDeptIds(@Param("deptIds")List<String> deptIds,
@Param("manufacturer")String manufacturer,
@Param("runFlag")List<Integer> runFlag,
@Param("dataType")List<Integer> dataType,
@Param("objType")String objType);
List<SubGetBase> selectSubStationList(@Param("param") SubstationParam substationParam);

View File

@@ -155,7 +155,7 @@ public interface LineMapper extends BaseMapper<Line> {
* @param deviceType 终端筛选条件
* @param manufacturer 终端厂家
*/
List<Line> getDeviceByCondition(@Param("devIds") List<String> devIds, @Param("deviceType") DeviceType deviceType, @Param("manufacturer") List<SimpleDTO> manufacturer);
List<Line> getDeviceByCondition(@Param("devIds") List<String> devIds, @Param("deviceType") DeviceType deviceType, @Param("deviceInfoParam") DeviceInfoParam manufacturer);
/**
* 查询母线信息

View File

@@ -124,7 +124,10 @@
and lineDetail.Power_Flag = #{powerFlag}
</if>
<if test="lineRunFlag!=null ">
and device.Run_Flag = 0 and lineDetail.Run_Flag = #{lineRunFlag}
and lineDetail.Run_Flag = #{lineRunFlag}
</if>
<if test="monitorFlag!=null ">
and lineDetail.Monitor_Flag = #{monitorFlag}
</if>
</select>
<select id="getLineIdByDeptIds" resultType="string">
@@ -142,8 +145,8 @@
<foreach collection="dataType" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
<if test="runFlag!=null and runFlag!=''">
and device.run_flag in
<if test="runFlag!=null and runFlag.size() > 0">
and lineDetail.run_flag in
<foreach collection="runFlag" item="item" open="(" close=")" separator=",">
#{item}
</foreach>

View File

@@ -294,6 +294,9 @@
#{item.id}
</foreach>
</if>
<if test="deviceInfoParam.searchValue!=null and deviceInfoParam.lineOrDevice==0">
AND t1.name like CONCAT(CONCAT('%', #{deviceInfoParam.searchValue}), '%')
</if>
<!-- xy -->
<choose>
<when test="deviceInfoParam.statFlag">
@@ -335,12 +338,15 @@
#{item}
</foreach>
</if>
<if test="manufacturer!=null and manufacturer.size()!=0">
<if test="deviceInfoParam.manufacturer!=null and deviceInfoParam.manufacturer.size()!=0">
AND t2.manufacturer in
<foreach collection="manufacturer" open="(" close=")" item="item" separator=",">
<foreach collection="deviceInfoParam.manufacturer" open="(" close=")" item="item" separator=",">
#{item.id}
</foreach>
</if>
<if test="deviceInfoParam.searchValue!=null and deviceInfoParam.lineOrDevice==1">
AND t1.name like CONCAT(CONCAT('%', #{deviceInfoParam.searchValue}), '%')
</if>
<if test="devIds!=null and devIds.size()!=0">
AND t1.id IN
<foreach collection="devIds" open="(" close=")" item="item" separator=",">

View File

@@ -115,7 +115,7 @@ public interface DeptLineService extends IService<DeptLine> {
Map<String, List<TerminalGetBase>> orgSubStationGet(List<Integer> devType);
List<TerminalGetBase.Extend> orgSubStationInfoGet(List<Integer> devType,Integer powerFlag,Integer lineRunFlag);
List<TerminalGetBase.Extend> orgSubStationInfoGet(List<Integer> devType,Integer powerFlag,Integer lineRunFlag,Integer monitorFlag);
List<SubGetBase> getSubStationList(SubstationParam substationParam);

View File

@@ -176,8 +176,8 @@ public class DeptLineServiceImpl extends ServiceImpl<DeptLineMapper, DeptLine> i
}
@Override
public List<TerminalGetBase.Extend> orgSubStationInfoGet(List<Integer> devType, Integer powerFlag, Integer lineRunFlag) {
return deptLineMapper.orgSubStationInfoGet(devType, powerFlag, lineRunFlag);
public List<TerminalGetBase.Extend> orgSubStationInfoGet(List<Integer> devType, Integer powerFlag, Integer lineRunFlag,Integer monitorFlag) {
return deptLineMapper.orgSubStationInfoGet(devType, powerFlag, lineRunFlag,monitorFlag);
}
@Override

View File

@@ -8,18 +8,22 @@ import com.njcn.device.pq.api.GeneralDeviceInfoClient;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.device.pq.pojo.param.OnlineRateParam;
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
import com.njcn.event.pojo.po.EventDetailNew;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.AreaSubLineVO;
import com.njcn.event.service.majornetwork.AreaInfoService;
import com.njcn.event.service.majornetwork.EventDetailService;
import com.njcn.harmonic.api.PollutionSubstationClient;
import com.njcn.harmonic.pojo.excel.pollution.UserLinePollution;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
@@ -41,11 +45,12 @@ public class AreaInfoServiceImpl implements AreaInfoService {
private final GeneralDeviceInfoClient generalDeviceInfoClient;
private final LineFeignClient lineFeignClient;
private final EventDetailService eventDetailService;
private final PollutionSubstationClient pollutionSubstationClient;
@Override
public List<AreaSubLineVO> getAreaLineInfo(DeviceInfoParam.GridDiagram deviceInfoParam) {
List<AreaSubLineVO> resultVOList = new ArrayList<>();
List<String> lineIds =new ArrayList<>();
Map<String, UserLinePollution> userMap = new HashMap<>();
if(1==deviceInfoParam.getType()){
if(CollectionUtil.isNotEmpty(deviceInfoParam.getCoutList())){
lineIds.addAll(deviceInfoParam.getCoutList());
@@ -61,6 +66,15 @@ public class AreaInfoServiceImpl implements AreaInfoService {
if (CollectionUtil.isNotEmpty(lineIds)) {
List<AreaLineInfoVO> resList = lineFeignClient.getBaseLineAreaInfo(lineIds).getData();
if(1==deviceInfoParam.getType()){
OnlineRateParam.Info param=new OnlineRateParam.Info();
param.setIds(resList.stream().map(AreaLineInfoVO::getLineId).distinct().collect(Collectors.toList()));
param.setDicData(deviceInfoParam.getDicData());
param.setStartTime(deviceInfoParam.getSearchBeginTime());
param.setEndTime(deviceInfoParam.getSearchEndTime());
userMap = pollutionSubstationClient.getSumList(param).getData();
}
//设置冀北告警监测点类型
if(CollectionUtil.isNotEmpty(deviceInfoParam.getCoutList())){
resList.stream().filter(x->deviceInfoParam.getCoutList().contains(x.getLineId())).forEach(x->x.setType(0));
@@ -86,6 +100,11 @@ public class AreaInfoServiceImpl implements AreaInfoService {
areaLineInfoVO.setNoDealCount(Math.toIntExact(aLong));
}
}
if(userMap.containsKey(areaLineInfoVO.getLineId())){
UserLinePollution userLinePollution = userMap.get(areaLineInfoVO.getLineId());
areaLineInfoVO.setVHarmonicValue(userLinePollution.getVHarmonicValue());
areaLineInfoVO.setUserList(BeanUtil.copyToList(userLinePollution.getUserList(),AreaLineInfoVO.User.class));
}
}
//组装成变电站

View File

@@ -458,13 +458,11 @@ public class RmpEventDetailServiceImpl extends ServiceImpl<RmpEventDetailMapper,
long count90 = list.stream()
.filter(x -> ObjectUtil.isNotNull(x.getSeverity()))
.filter(x -> gwLineAllIds.contains(x.getMeasurementPointId()))
.filter(x -> 0.9 > x.getFeatureAmplitude())
.map(RmpEventDetailPO::getFeatureAmplitude).count();
.filter(x -> 0.9 > x.getSeverity()).count();
long count50 = list.stream()
.filter(x -> ObjectUtil.isNotNull(x.getSeverity()))
.filter(x -> gwLineAllIds.contains(x.getMeasurementPointId()))
.filter(x -> 0.5 > x.getFeatureAmplitude())
.map(RmpEventDetailPO::getFeatureAmplitude).count();
.filter(x -> 0.5 > x.getSeverity()).count();
if(count90>0){
info.add(NumberUtil.round(count90*100.0/list.size(),2).doubleValue());
}else {

View File

@@ -0,0 +1,24 @@
package com.njcn.harmonic.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.device.pq.pojo.param.OnlineRateParam;
import com.njcn.harmonic.api.fallback.RStatLimitRateDFeignClientFallbackFactory;
import com.njcn.harmonic.pojo.excel.pollution.UserLinePollution;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.Map;
@FeignClient(
value = ServerInfo.HARMONIC,
path = "/PollutionSubstation",
fallbackFactory = RStatLimitRateDFeignClientFallbackFactory.class,
contextId = "PollutionSubstation")
public interface PollutionSubstationClient {
@PostMapping(value ="/getSumList")
HttpResult<Map<String, UserLinePollution>> getSumList(@RequestBody OnlineRateParam.Info param);
}

View File

@@ -0,0 +1,43 @@
package com.njcn.harmonic.api.fallback;
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.device.biz.utils.DeviceEnumUtil;
import com.njcn.device.pq.pojo.param.OnlineRateParam;
import com.njcn.harmonic.api.PollutionSubstationClient;
import com.njcn.harmonic.pojo.excel.pollution.UserLinePollution;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
* @author hongawen
* @version 1.0.0
* @date 2023年07月21日 14:31
*/
@Slf4j
@Component
public class PollutionSubstationClientFactory implements FallbackFactory<PollutionSubstationClient> {
@Override
public PollutionSubstationClient create(Throwable throwable) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (throwable.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) throwable.getCause();
exceptionEnum = DeviceEnumUtil.getExceptionEnum(businessException.getResult());
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new PollutionSubstationClient() {
@Override
public HttpResult<Map<String, UserLinePollution>> getSumList(OnlineRateParam.Info param) {
log.error("{}异常,降级处理,异常为:{}", "国网上送-典型源荷指标统计数据", throwable.toString());
return new HttpResult<>(CommonResponseEnum.FAIL.getCode(),CommonResponseEnum.FAIL.getMessage());
}
};
}
}

View File

@@ -24,6 +24,8 @@ public class LinePollution implements Serializable {
@ApiModelProperty("变电站")
private String subStationName;
private String subStationId;
/**
* 终端名称
*/

View File

@@ -0,0 +1,27 @@
package com.njcn.harmonic.pojo.excel.pollution;
import lombok.Data;
import java.util.List;
/**
* @author wr
* @description
* @date 2025/12/9 21:12
*/
@Data
public class UserLinePollution {
private String lineId;
private Double vHarmonicValue;
private List<User> userList;
@Data
public static class User{
private String id;
private String projectName;
private String stationId;
private String lineId;
private String city;
}
}

View File

@@ -9,8 +9,10 @@ import com.njcn.common.utils.HttpResultUtil;
import com.njcn.common.utils.LogUtil;
import com.njcn.device.biz.pojo.dto.PollutionLineDTO;
import com.njcn.device.pq.pojo.dto.PollutionSubstationDTO;
import com.njcn.device.pq.pojo.param.OnlineRateParam;
import com.njcn.harmonic.pojo.excel.pollution.LinePollution;
import com.njcn.harmonic.pojo.excel.pollution.SubstationPollution;
import com.njcn.harmonic.pojo.excel.pollution.UserLinePollution;
import com.njcn.harmonic.pojo.param.HarmonicPublicParam;
import com.njcn.harmonic.pojo.param.PollutionSubstationQuryParam;
import com.njcn.harmonic.pojo.param.StatSubstationBizBaseParam;
@@ -30,6 +32,9 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* Description:
@@ -157,4 +162,16 @@ public class PollutionSubstationController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, gdPollutions, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation(value = "监测点和敏感用户谐波污染值列表")
@PostMapping(value = "/getSumList")
public HttpResult<Map<String, UserLinePollution>> getSumList(@RequestBody OnlineRateParam.Info param) {
String methodDescribe = getMethodDescribe("getSumList");
param.setStartTime(DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())).toString());
param.setEndTime(DateUtil.endOfDay(DateUtil.parse(param.getEndTime())).toString());
List<UserLinePollution> sumList = pollutionSubstationService.getSumList(param);
Map<String, UserLinePollution> sumMap = sumList.stream().collect(Collectors.toMap(UserLinePollution::getLineId, Function.identity()));
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, sumMap, methodDescribe);
}
}

View File

@@ -6,9 +6,11 @@ import com.njcn.device.pq.pojo.dto.PollutionGridDiagramDTO;
import com.njcn.device.biz.pojo.dto.PollutionLineDTO;
import com.njcn.device.pq.pojo.dto.PollutionSubstationDTO;
import com.njcn.device.pq.pojo.param.GridDiagramParam;
import com.njcn.device.pq.pojo.param.OnlineRateParam;
import com.njcn.device.pq.pojo.vo.GridDiagramVO;
import com.njcn.harmonic.pojo.excel.pollution.LinePollution;
import com.njcn.harmonic.pojo.excel.pollution.SubstationPollution;
import com.njcn.harmonic.pojo.excel.pollution.UserLinePollution;
import com.njcn.harmonic.pojo.param.HarmonicPublicParam;
import com.njcn.harmonic.pojo.param.PollutionSubstationQuryParam;
import com.njcn.harmonic.pojo.param.StatSubstationBizBaseParam;
@@ -110,4 +112,7 @@ public interface PollutionSubstationService extends IService<RStatPollutionSubst
* @param param
*/
List<SubstationPollution> downPollutionSubCalc(StatSubstationBizBaseParam param);
List<UserLinePollution> getSumList(OnlineRateParam.Info param);
}

View File

@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.PubUtils;
@@ -34,6 +35,7 @@ import com.njcn.device.pq.api.SubstationFeignClient;
import com.njcn.device.pq.enums.LineBaseEnum;
import com.njcn.device.pq.enums.PowerFlagEnum;
import com.njcn.device.pq.pojo.dto.*;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.device.pq.pojo.param.GridDiagramParam;
import com.njcn.device.pq.pojo.param.LineBaseQueryParam;
import com.njcn.device.pq.pojo.param.OnlineRateParam;
@@ -128,7 +130,6 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
private final RmpEventDetailFeignClient detailFeignClient;
private final CommLineClient commLineClient;
/**
* @param pollutionSubstationQuryParam
* @Description: getPollutionSubstationData
@@ -758,8 +759,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
public GridDiagramVO getPollutionAlarmData(StatSubstationBizBaseParam param) {
DeptGetLineParam deptGetLineParam = new DeptGetLineParam();
deptGetLineParam.setDeptId(param.getId());
deptGetLineParam.setPowerFlag(0);
deptGetLineParam.setLineRunFlag(0);
deptGetLineParam.setIsUpToGrid(param.getIsUpToGrid());
List<DeptGetSubStationDTO.Info> deptGetChildrenMoreDTOS = commTerminalGeneralClient.deptGetSubStationInfo(deptGetLineParam).getData();
//获取全部变电站信息
List<SubGetBase> collect = deptGetChildrenMoreDTOS.stream().flatMap(x -> x.getStationIds().stream()).collect(Collectors.toList());
@@ -880,26 +880,28 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
@Override
public List<List<String>> getPollutionAlarmList(GridDiagramParam param) {
List<List<String>> info = new ArrayList<>();
param.getDeviceInfoParam().setPowerFlag(0);
param.getDeviceInfoParam().setLineRunFlag(0);
List<GeneralDeviceDTO> data = generalDeviceInfoClient.getPracticalRunDeviceInfo(param.getDeviceInfoParam()).getData();
List<String> subIds = data.stream().flatMap(x -> x.getSubIndexes().stream()).collect(Collectors.toList());
List<RStatPollutionSubstationM> substationMlist = pollutionSubstationMMapper.selectList(new LambdaQueryWrapper<RStatPollutionSubstationM>()
.select(RStatPollutionSubstationM::getSubstationId, RStatPollutionSubstationM::getValue)
.in(CollUtil.isNotEmpty(subIds), RStatPollutionSubstationM::getSubstationId, subIds)
.in(CollUtil.isNotEmpty(param.getIds()), RStatPollutionSubstationM::getPollutionType, param.getIds())
.ge(StrUtil.isNotBlank(param.getSearchBeginTime()), RStatPollutionSubstationM::getDataDate, DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime())))
.le(StrUtil.isNotBlank(param.getSearchEndTime()), RStatPollutionSubstationM::getDataDate, DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime())))
);
DeptGetLineParam deptGetLineParam = new DeptGetLineParam();
deptGetLineParam.setDeptId(param.getOrgId());
deptGetLineParam.setIsUpToGrid(param.getDeviceInfoParam().getMonitorFlag());
List<DeptGetSubStationDTO.Info> deptSub = commTerminalGeneralClient.deptGetSubStationInfo(deptGetLineParam).getData();
List<String> lineIdList = deptSub.stream()
.flatMap(x -> x.getStationIds().stream().flatMap(d -> d.getUnitChildrenList().stream()))
.distinct()
.collect(Collectors.toList());
List<RMpPollutionDPO> rMpPollutionDPOS = rMpPollutionDPOMapper.selectSumList(lineIdList,
Arrays.asList("b33a2946cb2d4f2641f485cf7720ecc7"),
DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime())).toString(),
DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime())).toString());
List<String> dept;
for (GeneralDeviceDTO datum : data) {
List<RStatPollutionSubstationM> collect = substationMlist.stream().filter(x -> datum.getSubIndexes().contains(x.getSubstationId())).collect(Collectors.toList());
for (DeptGetSubStationDTO.Info datum : deptSub) {
if(!datum.getUnitId().equals(param.getOrgId())){
dept = new ArrayList<>();
dept.add(datum.getName());
dept.add(String.valueOf(datum.getSubIndexes().size()));
dept.addAll(addList(collect));
dept.add(datum.getUnitName());
dept.add(String.valueOf(datum.getStationIds().size()));
dept.addAll(addList(rMpPollutionDPOS, datum.getStationIds()));
info.add(dept);
}
}
return info;
}
@@ -966,7 +968,13 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
@Override
public List<LinePollution> downPollutionLineCalc(StatSubstationBizBaseParam param) {
List<LinePollution> finalLinePollutionList = pollutionCalcList(param);
DeviceInfoParam deviceInfoParam=new DeviceInfoParam();
deviceInfoParam.setLineRunFlag(0);
deviceInfoParam.setDeptIndex(param.getId());
deviceInfoParam.setStatisticalType(new SimpleDTO());
List<GeneralDeviceDTO> data1 = generalDeviceInfoClient.getPracticalRunDeviceInfo(deviceInfoParam).getData();
List<String> lineIdList = data1.stream().flatMap(x -> x.getLineIndexes().stream()).distinct().collect(Collectors.toList());
List<LinePollution> finalLinePollutionList = pollutionCalcList(param,lineIdList);
// 全部监测点计算完毕后根据污染值从大到小进行排序
finalLinePollutionList = finalLinePollutionList.stream()
.sorted(Comparator.comparing(LinePollution::getHarmonicValue).reversed())
@@ -975,14 +983,11 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
}
private List<LinePollution> pollutionCalcList(StatSubstationBizBaseParam param) {
private List<LinePollution> pollutionCalcList(StatSubstationBizBaseParam param,List<String> lineIdList) {
String startDate = param.getStartTime();
String endDate = param.getEndTime();
List<LinePollution> linePollutionList = new ArrayList<>();
GridDiagramParam eventParam = new GridDiagramParam();
List<String> lineIdList = generalDeviceInfoClient.deptGetRunLine(param.getId()).getData();
eventParam.setIds(lineIdList);
eventParam.setSearchBeginTime(param.getStartTime());
@@ -1028,7 +1033,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
//获取监测点数据完整性
linePollution.setIntegrity(Objects.isNull(integrityMap.get(lineId)) ? 0.0 : integrityMap.get(lineId).doubleValue() > 100 ? 100.0 : integrityMap.get(lineId).doubleValue());
// 计算谐波的污染值
linePollution.setHarmonicValue(calcMap.containsKey(lineId)?calcMap.get(lineId)>100?100.0:integrityMap.get(lineId).doubleValue():0.0);
linePollution.setHarmonicValue(calcMap.containsKey(lineId) ? calcMap.get(lineId).doubleValue() : 0.0);
linePollution.setInterval(data.getTimeInterval());
linePollutionList.add(linePollution);
}
@@ -1040,7 +1045,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
@Override
public void downPollutionUserCalc(StatSubstationBizBaseParam param) {
// 处理干扰源用户的报告
List<LinePollution> loadTypeLineList = pollutionCalcList(param);
List<LinePollution> loadTypeLineList = pollutionCalcList(param,null);
/**
* 1、首先过滤重要变电站、一类变电站、跨省计量关点 todo...待优化
* 2、过滤后以监测对象分组统计数据有多个测点的需要出结果
@@ -1064,7 +1069,6 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
objPollution.setObjVValue(PubUtils.doubleRound(2, objVValue) + "");
// 处理该监测对象下面监测点的信息
List<LoadTypeLineItemPollution> loadTypeLineItemPollutions = new ArrayList<>();
for (LinePollution linePollution : linePollutions) {
@@ -1084,27 +1088,33 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
@Override
public List<SubstationPollution> downPollutionSubCalc(StatSubstationBizBaseParam param) {
DeviceInfoParam deviceInfoParam=new DeviceInfoParam();
deviceInfoParam.setDeptIndex(param.getId());
deviceInfoParam.setStatisticalType(new SimpleDTO());
List<GeneralDeviceDTO> data1 = generalDeviceInfoClient.getPracticalAllDeviceInfoAsSubstation(deviceInfoParam).getData();
List<String> lineIdList = data1.stream().flatMap(x -> x.getLineIndexes().stream()).distinct().collect(Collectors.toList());
List<SubstationPollution> substationPollutions = new ArrayList<>();
// 处理干扰源用户的报告
List<LinePollution> linePollutionList = pollutionCalcList(param);
List<LinePollution> linePollutionList = pollutionCalcList(param,lineIdList);
// 以变电站分组
Map<String, List<LinePollution>> subMap = linePollutionList.stream()
.collect(Collectors.groupingBy(x->x.getGdName()+"_"+x.getSubStationName()+"_"+x.getSubVoltage()));
.collect(Collectors.groupingBy(x -> x.getSubStationId()+"_"+ x.getGdName() + "_" +x.getSubStationName() + "_" + x.getSubVoltage()));
subMap.forEach((key, value) -> {
String[] name = key.split("_");
SubstationPollution substationPollution = new SubstationPollution();
substationPollution.setGdName(name[0]);
substationPollution.setSubStationName(name[1]);
substationPollution.setSubVoltage(name[2]);
substationPollution.setGdName(name[1]);
substationPollution.setSubStationName(name[2]);
substationPollution.setSubVoltage(name[3]);
double subVValue = value.stream()
.mapToDouble(o -> o.getHarmonicValue())
.average()
.orElse(0.0);
.sum();
substationPollution.setSubVStationValue(PubUtils.doubleRound(2, subVValue) + "");
List<PowerFlagPollution> lineItemPollutionList = new ArrayList<>();
for (LinePollution linePollution : value) {
PowerFlagPollution lineItemPollution = new PowerFlagPollution();
BeanUtil.copyProperties(linePollution, lineItemPollution, true);
lineItemPollution.setVHarmonicValue(linePollution.getHarmonicValue());
lineItemPollutionList.add(lineItemPollution);
}
substationPollution.setPowerFlagPollutionList(lineItemPollutionList);
@@ -1115,34 +1125,70 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
return substationPollutions;
}
@Override
public List<UserLinePollution> getSumList(OnlineRateParam.Info param) {
List<UserLinePollution> info = new ArrayList<>();
UserReportParam userReportParam = new UserReportParam();
userReportParam.setUserType(6);
List<UserLedgerVO> userLedgerVOList = userLedgerFeignClient.selectUserList(userReportParam).getData();
Map<String, List<UserLedgerVO>> userMap = userLedgerVOList.stream().filter(x -> StrUtil.isNotBlank(x.getLineId())).collect(Collectors.groupingBy(UserLedgerVO::getLineId));
List<RMpPollutionDPO> rMpPollutionDPOS = rMpPollutionDPOMapper.selectSumList(param.getIds(), param.getDicData(), param.getStartTime(), param.getEndTime());
Map<String, Double> pollutionMap = rMpPollutionDPOS.stream().collect(Collectors.toMap(RMpPollutionDPO::getLineId, RMpPollutionDPO::getValue));
UserLinePollution user;
for (String id : param.getIds()) {
user = new UserLinePollution();
user.setLineId(id);
if (pollutionMap.containsKey(id)) {
user.setVHarmonicValue(pollutionMap.get(id));
} else {
user.setVHarmonicValue(0.0);
}
List<UserLinePollution.User> userList = new ArrayList<>();
if (userMap.containsKey(id)) {
List<UserLedgerVO> userLedgerVOS = userMap.get(id);
userList.addAll(BeanUtil.copyToList(userLedgerVOS, UserLinePollution.User.class));
}
user.setUserList(userList);
info.add(user);
}
return info;
}
private List<String> addList(List<RStatPollutionSubstationM> substationMlist) {
private List<String> addList(List<RMpPollutionDPO> pollLinelist, List<SubGetBase> notNum) {
List<String> info = new ArrayList<>();
Integer num1 = 0;
Integer num2 = 0;
Integer num3 = 0;
Integer num4 = 0;
Integer num5 = 0;
for (RStatPollutionSubstationM x : substationMlist) {
Double value = x.getValue();
//无污染 轻微污染 轻度污染 中度污染 重度污染
if (0 <= value && value < 1) {
Integer num6 = 0;
for (SubGetBase subGetBase : notNum) {
List<RMpPollutionDPO> linePoll = pollLinelist.stream().filter(x -> subGetBase.getUnitChildrenList().contains(x.getLineId())).collect(Collectors.toList());
if(CollUtil.isNotEmpty(linePoll)){
Double value = linePoll.stream().mapToDouble(RMpPollutionDPO::getValue).sum();
//无污染 轻微污染0-100 轻度污染100-1000 中度污染1000-10000 重度污染10000
if (0 == value) {
num1++;
} else if (1 <= value && value < 1.2) {
} else if (0 < value && value < 100) {
num2++;
} else if (1.2 <= value && value < 1.6) {
} else if (100 <= value && value < 1000) {
num3++;
} else if (1.6 <= value && value < 2) {
} else if (1000 <= value && value < 10000) {
num4++;
} else if (2 <= value) {
} else if (10000 <= value) {
num5++;
}
}else{
num6++;
}
}
info.add(String.valueOf(num1));
info.add(String.valueOf(num2));
info.add(String.valueOf(num3));
info.add(String.valueOf(num4));
info.add(String.valueOf(num5));
info.add(String.valueOf(num6));
return info;
}
}

View File

@@ -72,8 +72,6 @@ public class RMpTargetWarnDServiceImpl extends ServiceImpl<RMpTargetWarnDMapper,
List<Dept> data = deptFeignClient.getDirectSonSelf(param.getId()).getData();
DeptGetLineParam deptGetLineParam = new DeptGetLineParam();
deptGetLineParam.setDeptId(param.getId());
deptGetLineParam.setPowerFlag(0);
deptGetLineParam.setLineRunFlag(0);
List<DeptGetSubStationDTO.Info> deptGetChildrenMoreDTOS = commTerminalGeneralClient.deptGetSubStationInfo(deptGetLineParam).getData();
List<String> lineIDS = deptGetChildrenMoreDTOS.stream()

View File

@@ -167,7 +167,6 @@ public class RStatLimitServiceImpl implements RStatLimitService {
//监测点总数
List<GeneralDeviceDTO> data = generalDeviceInfoClient.getPracticalRunDeviceInfo(param).getData();
//在线
param.setComFlagStatus(1);
List<GeneralDeviceDTO> onData = generalDeviceInfoClient.getPracticalRunDeviceInfo(param).getData();
List<String> onLine = onData.stream().flatMap(x -> x.getLineIndexes().stream()).distinct().collect(Collectors.toList());

View File

@@ -19,6 +19,8 @@ public class UserLedgerVO implements Serializable {
private String stationId;
private String lineId;
private String city;
}

View File

@@ -1165,6 +1165,9 @@ public class UserReportPOServiceImpl extends ServiceImpl<UserReportPOMapper, Use
if(StrUtil.isNotBlank(userReportParam.getStationId())){
lambdaQueryWrapper.eq(UserReportPO::getStationId,userReportParam.getStationId());
}
if (ObjectUtil.isNotNull(userReportParam.getUserType())) {
lambdaQueryWrapper.eq(UserReportPO::getUserType, userReportParam.getUserType());
}
lambdaQueryWrapper.eq(UserReportPO::getState,DataStateEnum.ENABLE.getCode());