1.提交场站评估代码
This commit is contained in:
@@ -10,6 +10,7 @@ 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.harmonic.pojo.excel.pollution.LinePollution;
|
||||
import com.njcn.harmonic.pojo.excel.pollution.SubstationPollution;
|
||||
import com.njcn.harmonic.pojo.param.HarmonicPublicParam;
|
||||
import com.njcn.harmonic.pojo.param.PollutionSubstationQuryParam;
|
||||
import com.njcn.harmonic.pojo.param.StatSubstationBizBaseParam;
|
||||
@@ -146,15 +147,14 @@ public class PollutionSubstationController extends BaseController {
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation(value ="导出变电站谐波电压污染值",produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
@GetMapping(value ="/downPollutionSubCalc",produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
public void downPollutionSubCalc(@RequestParam(value = "startTime") String startTime,
|
||||
@RequestParam(value = "endTime") String endTime) {
|
||||
StatSubstationBizBaseParam param=new StatSubstationBizBaseParam();
|
||||
param.setStartTime(startTime);
|
||||
param.setEndTime(endTime);
|
||||
pollutionSubstationService.downPollutionSubCalc(param);
|
||||
@ApiOperation(value ="变电站谐波污染值列表")
|
||||
@PostMapping(value ="/downPollutionSubCalc")
|
||||
public HttpResult<List<SubstationPollution>> downPollutionSubCalc(@RequestBody StatSubstationBizBaseParam param) {
|
||||
String methodDescribe = getMethodDescribe("downPollutionSubCalc");
|
||||
param.setStartTime(DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())).toString());
|
||||
param.setEndTime(DateUtil.endOfDay(DateUtil.parse(param.getEndTime())).toString());
|
||||
List<SubstationPollution> gdPollutions = pollutionSubstationService.downPollutionSubCalc(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, gdPollutions, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.njcn.device.pq.pojo.dto.PollutionSubstationDTO;
|
||||
import com.njcn.device.pq.pojo.param.GridDiagramParam;
|
||||
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.param.HarmonicPublicParam;
|
||||
import com.njcn.harmonic.pojo.param.PollutionSubstationQuryParam;
|
||||
import com.njcn.harmonic.pojo.param.StatSubstationBizBaseParam;
|
||||
@@ -108,5 +109,5 @@ public interface PollutionSubstationService extends IService<RStatPollutionSubst
|
||||
* 变电站谐波电压污染值
|
||||
* @param param
|
||||
*/
|
||||
void downPollutionSubCalc(StatSubstationBizBaseParam param);
|
||||
List<SubstationPollution> downPollutionSubCalc(StatSubstationBizBaseParam param);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.njcn.device.biz.commApi.CommLineClient;
|
||||
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
||||
import com.njcn.device.biz.pojo.dto.*;
|
||||
import com.njcn.device.biz.pojo.param.DeptGetLineParam;
|
||||
import com.njcn.device.biz.pojo.po.Overlimit;
|
||||
import com.njcn.device.pms.api.MonitorClient;
|
||||
import com.njcn.device.pms.api.PmsGeneralDeviceInfoClient;
|
||||
import com.njcn.device.pms.api.StatationStatClient;
|
||||
@@ -63,8 +62,6 @@ import com.njcn.supervision.pojo.param.user.UserReportParam;
|
||||
import com.njcn.supervision.pojo.vo.user.UserLedgerVO;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.pojo.po.Dept;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
@@ -908,21 +905,18 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
|
||||
@Override
|
||||
public List<SubstationVo> getSubstationInfo(String deptIndex, String searchValue, String startTime, String endTime) {
|
||||
List<SubstationVo> result = new ArrayList<>();
|
||||
|
||||
DeptGetLineParam deptGetLineParam = new DeptGetLineParam();
|
||||
deptGetLineParam.setDeptId(deptIndex);
|
||||
deptGetLineParam.setLineRunFlag(0);
|
||||
List<DeptGetChildrenMoreDTO> list = commTerminalGeneralClient.deptGetLine(deptGetLineParam).getData();
|
||||
//获取所有监测信息
|
||||
List<LineDevGetDTO> lineNameList = list.stream().flatMap(x -> x.getLineBaseList().stream()).distinct().collect(Collectors.toList());
|
||||
Map<String, String> lineOrgName = lineNameList.stream().collect(Collectors.toMap(LineDevGetDTO::getPointId, LineDevGetDTO::getUnitName));
|
||||
deptGetLineParam.setMonitorStateRunning(false);
|
||||
List<DeptGetSubStationDTO.Info> deptGetChildrenMoreDTOS = commTerminalGeneralClient.deptGetSubStationInfo(deptGetLineParam).getData();
|
||||
List<String> lineIds = deptGetChildrenMoreDTOS.stream().flatMap(x -> x.getStationIds().stream()).flatMap(x -> x.getUnitChildrenList().stream()).distinct().collect(Collectors.toList());
|
||||
|
||||
//获取监测点集合
|
||||
LineBaseQueryParam param = new LineBaseQueryParam();
|
||||
param.setLineIds(new ArrayList<>(lineOrgName.keySet()));
|
||||
param.setSearchValue(searchValue);
|
||||
param.setLineIds(lineIds);
|
||||
List<LineDetail> data = lineFeignClient.getByName(param).getData();
|
||||
List<String> lineList = data.stream().map(LineDetail::getId).distinct().collect(Collectors.toList());
|
||||
|
||||
if (CollUtil.isNotEmpty(lineList)) {
|
||||
//获取监测点的超标数据
|
||||
List<RStatLimitRateDPO> limitRateList = rStatLimitRateDMapper.getAllOverTimes(lineList, startTime, endTime);
|
||||
@@ -941,31 +935,30 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
|
||||
String i = dicDataFeignClient.getDicDataByCode(DicDataEnum.I_ALL.getCode()).getData().getId();
|
||||
List<RMpPollutionDPO> harmonicI = lineData.stream().filter(x -> i.equals(x.getPollutionType())).collect(Collectors.toList());
|
||||
|
||||
//获取监测点详细信息
|
||||
Map<String, List<LineDetail>> lineDetailMap = data.stream().filter(x -> StrUtil.isNotBlank(x.getPowerSubstationName())).collect(Collectors.groupingBy(LineDetail::getPowerSubstationName));
|
||||
lineDetailMap.forEach((key, value) -> {
|
||||
List<SubGetBase> subNameMap = deptGetChildrenMoreDTOS.stream().flatMap(x -> x.getStationIds().stream()).distinct().collect(Collectors.toList());
|
||||
for (SubGetBase subGetBase : subNameMap) {
|
||||
AtomicInteger alarmTime = new AtomicInteger();
|
||||
SubstationVo vo = new SubstationVo();
|
||||
vo.setDeptName(lineOrgName.get(value.get(0).getId()));
|
||||
vo.setSubstationName(key);
|
||||
List<String> gridSide = value.stream().filter(t -> Objects.equals(t.getPowerFlag(), 0)).map(LineDetail::getId).collect(Collectors.toList());
|
||||
List<String> notGridSide = value.stream().filter(t -> Objects.equals(t.getPowerFlag(), 1)).map(LineDetail::getId).collect(Collectors.toList());
|
||||
vo.setDwLineList(lineNameList.stream().filter(x -> gridSide.contains(x.getPointId())).map(LineDevGetDTO::getPointName).sorted().collect(Collectors.toList()));
|
||||
vo.setYhLineList(lineNameList.stream().filter(x -> notGridSide.contains(x.getPointId())).map(LineDevGetDTO::getPointName).sorted().collect(Collectors.toList()));
|
||||
value.forEach(item -> {
|
||||
if (monitorMap.containsKey(item.getId())) {
|
||||
alarmTime.set(alarmTime.get() + monitorMap.get(item.getId()).getAllTime());
|
||||
vo.setDeptName(subGetBase.getOrgName());
|
||||
vo.setSubstationName(subGetBase.getName());
|
||||
List<String> unitChildrenList = subGetBase.getUnitChildrenList();
|
||||
List<LineDetail> lineDetails = data.stream().filter((x -> unitChildrenList.contains(x.getId()))).collect(Collectors.toList());
|
||||
List<String> gridSide = lineDetails.stream().filter(t -> Objects.equals(t.getPowerFlag(), 0)).map(LineDetail::getId).collect(Collectors.toList());
|
||||
List<String> notGridSide = lineDetails.stream().filter(t -> Objects.equals(t.getPowerFlag(), 1)).map(LineDetail::getId).collect(Collectors.toList());
|
||||
vo.setDwLineList(lineDetails.stream().filter(x -> gridSide.contains(x.getId())).map(LineDetail::getMonitorName).sorted().collect(Collectors.toList()));
|
||||
vo.setYhLineList(lineDetails.stream().filter(x -> notGridSide.contains(x.getId())).map(LineDetail::getMonitorName).sorted().collect(Collectors.toList()));
|
||||
unitChildrenList.forEach(item -> {
|
||||
if (monitorMap.containsKey(item)) {
|
||||
alarmTime.set(alarmTime.get() + monitorMap.get(item).getAllTime());
|
||||
}
|
||||
});
|
||||
vo.setAlarmFreq(NumberUtil.round(alarmTime.get() * 1.0 / value.size(), 2).doubleValue());
|
||||
//监测点id集合
|
||||
List<String> ids = value.stream().map(LineDetail::getId).collect(Collectors.toList());
|
||||
OptionalDouble maxV = harmonicV.stream().filter(x -> ids.contains(x.getLineId())).mapToDouble(RMpPollutionDPO::getValue).max();
|
||||
vo.setAlarmFreq(NumberUtil.round(alarmTime.get() * 1.0 / unitChildrenList.size(), 2).doubleValue());
|
||||
OptionalDouble maxV = harmonicV.stream().filter(x -> unitChildrenList.contains(x.getLineId())).mapToDouble(RMpPollutionDPO::getValue).max();
|
||||
vo.setVPollutionData(maxV.isPresent() ? maxV.getAsDouble() : 0.0D);
|
||||
OptionalDouble maxI = harmonicI.stream().filter(x -> ids.contains(x.getLineId())).mapToDouble(RMpPollutionDPO::getValue).max();
|
||||
OptionalDouble maxI = harmonicI.stream().filter(x -> unitChildrenList.contains(x.getLineId())).mapToDouble(RMpPollutionDPO::getValue).max();
|
||||
vo.setIPollutionData(maxI.isPresent() ? maxV.getAsDouble() : 0.0D);
|
||||
result.add(vo);
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1089,121 +1082,36 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downPollutionSubCalc(StatSubstationBizBaseParam param) {
|
||||
public List<SubstationPollution> downPollutionSubCalc(StatSubstationBizBaseParam param) {
|
||||
List<SubstationPollution> substationPollutions = new ArrayList<>();
|
||||
// 处理干扰源用户的报告
|
||||
List<LinePollution> linePollutionList = pollutionCalcList(param);
|
||||
// 整合变电站待导出的数据
|
||||
List<GdPollution> gdPollutionList = new ArrayList<>();
|
||||
// 以供电公司分组
|
||||
Map<String, List<LinePollution>> gdMap = linePollutionList.stream()
|
||||
.collect(Collectors.groupingBy(LinePollution::getGdName));
|
||||
// 同一供电公司以变电站分组
|
||||
Set<String> gdNameSet = gdMap.keySet();
|
||||
for (String gdName : gdNameSet) {
|
||||
// 初始化gd实体
|
||||
GdPollution gdPollution = new GdPollution();
|
||||
gdPollution.setGdName(gdName);
|
||||
List<LinePollution> gdLinePollution = gdMap.get(gdName);
|
||||
// 以变电站分组
|
||||
Map<String, List<LinePollution>> subMap = gdLinePollution.stream()
|
||||
.collect(Collectors.groupingBy(LinePollution::getSubStationName));
|
||||
Set<String> subNameMap = subMap.keySet();
|
||||
List<SubstationPollution> substationPollutions = new ArrayList<>();
|
||||
for (String subName : subNameMap) {
|
||||
// 初始化变电站实体
|
||||
SubstationPollution substationPollution = new SubstationPollution();
|
||||
substationPollution.setSubStationName(subName);
|
||||
List<LinePollution> subLinePollution = subMap.get(subName);
|
||||
// 需要区分电网侧、非电网侧
|
||||
Map<String, List<LinePollution>> powerFlagLinePollution = subLinePollution.stream().collect(Collectors.groupingBy(LinePollution::getPowerFlag));
|
||||
|
||||
List<PowerFlagPollution> powerFlagPollutionList = new ArrayList<>();
|
||||
// 电网侧
|
||||
List<LinePollution> temp = powerFlagLinePollution.get("电网侧");
|
||||
PowerFlagPollution powerFlagPollution1 = new PowerFlagPollution();
|
||||
powerFlagPollution1.setPowerFlag("电网侧");
|
||||
List<LineItemPollution> lineItemPollutionList1 = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(temp)) {
|
||||
// 计算电网侧下所有监测点谐波电压平均污染值
|
||||
double subVValue = temp.stream()
|
||||
.mapToDouble(o -> o.getHarmonicValue())
|
||||
.average()
|
||||
.orElse(0.0);
|
||||
// 电网侧污染值
|
||||
powerFlagPollution1.setPowerVValue(PubUtils.doubleRound(2, subVValue) + "");
|
||||
|
||||
|
||||
|
||||
// 设备信息
|
||||
for (LinePollution linePollution : temp) {
|
||||
LineItemPollution lineItemPollution = new LineItemPollution();
|
||||
BeanUtil.copyProperties(linePollution, lineItemPollution, true);
|
||||
lineItemPollutionList1.add(lineItemPollution);
|
||||
}
|
||||
} else {
|
||||
// 仅有非电网侧时,电网侧赋予空置
|
||||
LineItemPollution lineItemPollution = new LineItemPollution();
|
||||
lineItemPollutionList1.add(lineItemPollution);
|
||||
}
|
||||
// 设备信息注入监测位置对象中
|
||||
powerFlagPollution1.setLineItemPollutionList(lineItemPollutionList1);
|
||||
powerFlagPollutionList.add(powerFlagPollution1);
|
||||
|
||||
|
||||
// 非电网侧
|
||||
List<LinePollution> temp1 = powerFlagLinePollution.get("非电网侧");
|
||||
PowerFlagPollution powerFlagPollution2 = new PowerFlagPollution();
|
||||
powerFlagPollution2.setPowerFlag("非电网侧");
|
||||
List<LineItemPollution> lineItemPollutionList2 = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(temp1)) {
|
||||
// 计算电网侧下所有监测点谐波电压平均污染值
|
||||
double subVValue = temp1.stream()
|
||||
.mapToDouble(o -> o.getHarmonicValue())
|
||||
.average()
|
||||
.orElse(0.0);
|
||||
// 电网侧污染值
|
||||
powerFlagPollution2.setPowerVValue(PubUtils.doubleRound(2, subVValue) + "");
|
||||
|
||||
// 电网侧污染值
|
||||
for (LinePollution linePollution : temp1) {
|
||||
LineItemPollution lineItemPollution = new LineItemPollution();
|
||||
BeanUtil.copyProperties(linePollution, lineItemPollution, true);
|
||||
lineItemPollutionList2.add(lineItemPollution);
|
||||
}
|
||||
} else {
|
||||
// 仅有非电网侧时,电网侧赋予空置
|
||||
LineItemPollution lineItemPollution = new LineItemPollution();
|
||||
lineItemPollutionList2.add(lineItemPollution);
|
||||
}
|
||||
// 设备信息注入监测位置对象中
|
||||
powerFlagPollution2.setLineItemPollutionList(lineItemPollutionList2);
|
||||
powerFlagPollutionList.add(powerFlagPollution2);
|
||||
|
||||
substationPollution.setPowerFlagPollutionList(powerFlagPollutionList);
|
||||
// 如果电网侧有污染值,就作为变电站的污染值,否则就用非电网侧的污染值作为该变电站污染值
|
||||
if (Objects.nonNull(powerFlagPollution1.getPowerVValue())) {
|
||||
substationPollution.setSubVStationValue(powerFlagPollution1.getPowerVValue());
|
||||
} else {
|
||||
substationPollution.setSubVStationValue(powerFlagPollution2.getPowerVValue());
|
||||
}
|
||||
if (Objects.nonNull(powerFlagPollution1.getPowerIValue())) {
|
||||
substationPollution.setSubIStationValue(powerFlagPollution1.getPowerIValue());
|
||||
} else {
|
||||
substationPollution.setSubIStationValue(powerFlagPollution2.getPowerIValue());
|
||||
}
|
||||
substationPollutions.add(substationPollution);
|
||||
// 以变电站分组
|
||||
Map<String, List<LinePollution>> subMap = linePollutionList.stream()
|
||||
.collect(Collectors.groupingBy(x->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]);
|
||||
double subVValue = value.stream()
|
||||
.mapToDouble(o -> o.getHarmonicValue())
|
||||
.average()
|
||||
.orElse(0.0);
|
||||
substationPollution.setSubVStationValue(PubUtils.doubleRound(2, subVValue) + "");
|
||||
List<PowerFlagPollution> lineItemPollutionList = new ArrayList<>();
|
||||
for (LinePollution linePollution : value) {
|
||||
PowerFlagPollution lineItemPollution = new PowerFlagPollution();
|
||||
BeanUtil.copyProperties(linePollution, lineItemPollution, true);
|
||||
lineItemPollutionList.add(lineItemPollution);
|
||||
}
|
||||
|
||||
// 针对这个供电公司下的变电站污染值排序
|
||||
substationPollutions.sort(Comparator.comparingDouble(o -> Double.parseDouble(o.getSubVStationValue())));
|
||||
Collections.reverse(substationPollutions);
|
||||
// List<SubstationPollution> finalSubstation = substationPollutions.stream().sorted((Comparator.comparingDouble(SubstationPollution::getSubStationValue))
|
||||
// .reversed())
|
||||
// .collect(Collectors.toList());
|
||||
gdPollution.setSubstationPollutionList(substationPollutions);
|
||||
gdPollutionList.add(gdPollution);
|
||||
}
|
||||
ExcelUtil.exportExcel("变电站谐波电压污染值" + param.getEndTime() + ".xlsx", GdPollution.class, gdPollutionList);
|
||||
substationPollution.setPowerFlagPollutionList(lineItemPollutionList);
|
||||
substationPollutions.add(substationPollution);
|
||||
});
|
||||
substationPollutions.sort(Comparator.comparingDouble(o -> Double.parseDouble(o.getSubVStationValue())));
|
||||
Collections.reverse(substationPollutions);
|
||||
return substationPollutions;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user