1.谐波溯源算法

2.北京暂降平台
This commit is contained in:
2025-10-11 11:06:40 +08:00
parent 90b2589641
commit f587c11b98
10 changed files with 89 additions and 74 deletions

View File

@@ -34,7 +34,7 @@ public class UpHarmonicDetail implements Serializable {
/**
* 事件id
*/
@TableField(value = "id")
@TableId(value = "id")
private String id;
/**

View File

@@ -80,8 +80,14 @@ public class RespDataResultServiceImpl extends ServiceImpl<RespDataResultMapper,
String respStr = IoUtil.readUtf8(respStream);
List<CustomerResponsibility> respData = JSONArray.parseArray(respStr, CustomerResponsibility.class);
if(Objects.nonNull(respDataQuery.getType()) && respDataQuery.getType().equals(CalculationType.SYSTEM_TYPE.getCode())){
customerData.forEach(item->item.setCustomerName(item.getCustomerName().substring(0,item.getCustomerName().indexOf("("))));
respData.forEach(item->item.setCustomerName(item.getCustomerName().substring(0,item.getCustomerName().indexOf("("))));
customerData.forEach(item->{if(item.getCustomerName().contains("(")) {
item.setCustomerName(item.getCustomerName().substring(0,item.getCustomerName().indexOf("(")));
}
});
respData.forEach(item->{if(item.getCustomerName().contains("(")) {
item.setCustomerName(item.getCustomerName().substring(0,item.getCustomerName().indexOf("(")));
}
});
}
responsibilityResult.setResponsibilities(respData);
responsibilityResult.setDatas(customerData);

View File

@@ -622,10 +622,6 @@ public class RespDataServiceImpl extends ServiceImpl<RespDataMapper, RespData> i
}
}
if(Objects.nonNull(responsibilityCalculateParam.getSystemType()) && responsibilityCalculateParam.getSystemType()==CalculationType.SYSTEM_TYPE.getCode()){
customerData.forEach(item->item.setCustomerName(item.getCustomerName().substring(0,item.getCustomerName().indexOf("("))));
customerResponsibilities.forEach(item->item.setCustomerName(item.getCustomerName().substring(0,item.getCustomerName().indexOf("("))));
}
result.setDatas(customerData);
result.setTimeDatas(timeDatas);
@@ -719,6 +715,12 @@ public class RespDataServiceImpl extends ServiceImpl<RespDataMapper, RespData> i
String customerResPath = fileStorageUtil.uploadStream(customerResStream, OssPath.RESPONSIBILITY_USER_RESULT_DATA, FileUtil.generateFileName("json"));
respDataResult.setUserResponsibility(customerResPath);
respDataResultService.save(respDataResult);
}
if (Objects.nonNull(responsibilityCalculateParam.getSystemType()) && responsibilityCalculateParam.getSystemType() == CalculationType.SYSTEM_TYPE.getCode()) {
customerData.forEach(item -> item.setCustomerName(item.getCustomerName().substring(0, item.getCustomerName().indexOf("("))));
customerResponsibilities.forEach(item -> item.setCustomerName(item.getCustomerName().substring(0, item.getCustomerName().indexOf("("))));
}
//防止过程中创建了大量的对象主动调用下GC处理
System.gc();

View File

@@ -42,10 +42,10 @@ public class EasyPoiWordExportController extends BaseController {
@OperateInfo
@PostMapping("/get")
@ApiOperation("")
public void test(HttpServletResponse response, @RequestBody ReportExportParam param) {
String methodDescribe = getMethodDescribe("test");
public void exportWordReport(HttpServletResponse response, @RequestBody ReportExportParam param) {
String methodDescribe = getMethodDescribe("exportWordReport");
try {
easyPoiWordExportService.test(response,param);
easyPoiWordExportService.exportWordReport(response,param);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -56,10 +56,8 @@ public class EasyPoiWordExportController extends BaseController {
@PostMapping("/getDept")
public HttpResult<List<PqsDepts>> getDept() {
String methodDescribe = getMethodDescribe("getDept");
List<PqsDepts> list = pqsDeptsService.lambdaQuery().eq(PqsDepts::getState, 1).list();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
List<PqsDepts> list = pqsDeptsService.lambdaQuery().eq(PqsDepts::getState, 1).list();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
}

View File

@@ -27,19 +27,19 @@ public class BjCustomReportDTO {
// 统计日期范围如“2025年09月17日16:46-16:53”
private String dateRange;
// 北京地区总事件数
private Integer bjTotalEvent;
private Integer bjTotalEvent = 0;
// 北京地区涉及变电站数
private Integer totalEventSubstation;
private Integer totalEventSubstation = 0;
// 北京地区涉及母线数
private Integer bjTotalBus;
private Integer bjTotalBus = 0;
// 变电站电压等级说明如“220kV变电站X座、110kV变电站X座、10kV变电站X座”
private String stationVoltage;
// 发生暂降的母线数
private Integer busEventNum;
private Integer busEventNum = 0;
// 残余电压范围如“16.48%-86.99%”)
private String residualVoltageRange;
private String residualVoltageRange = "-% - -%";
// 持续时间范围如“0.05s-0.086s”)
private String durationRange;
private String durationRange = "-s - -s";
// 受影响用户类型(如“半导体企业、地铁、医院、政府机关”)
private String objTypeList;
// 受影响用户总数

View File

@@ -12,5 +12,5 @@ import javax.servlet.http.HttpServletResponse;
*/
public interface EasyPoiWordExportService {
void test(HttpServletResponse response, ReportExportParam param);
void exportWordReport(HttpServletResponse response, ReportExportParam param);
}

View File

@@ -70,7 +70,7 @@ public class EasyPoiWordExportServiceImpl implements EasyPoiWordExportService {
// private String wordTemplatePath;
@Override
public void test(HttpServletResponse response, ReportExportParam param) {
public void exportWordReport(HttpServletResponse response, ReportExportParam param) {
try {
List<Integer> deptIds = commGeneralService.getLineIdsByRedis(param.getDeptId());
@@ -109,58 +109,60 @@ public class EasyPoiWordExportServiceImpl implements EasyPoiWordExportService {
}
List<PqsEventdetail> pqsEventdetailList = pqsEventdetailMapper.selectList(lambdaQueryWrapper);
List<Map<String,Object>> eventTemplateList = new ArrayList<>();
for (int i = 0; i < pqsEventdetailList.size(); i++) {
PqsEventdetail pqsEventdetail = pqsEventdetailList.get(i);
EventTemplate eventTemplate = new EventTemplate();
eventTemplate.setSno(i+1);
eventTemplate.setTimeId(pqsEventdetail.getTimeid().format(DatePattern.NORM_DATETIME_FORMATTER)+"."+pqsEventdetail.getMs());
List<LedgerBaseInfoDTO> baseLineInfo = pqLineMapper.getBaseLineInfo(Stream.of(pqsEventdetailList.get(i).getLineid()).collect(Collectors.toList()));
eventTemplate.setOrgName(baseLineInfo.get(0).getGdName());
eventTemplate.setSubName(baseLineInfo.get(0).getStationName());
eventTemplate.setBusName(baseLineInfo.get(0).getBusBarName());
eventTemplate.setScale(pqsDicDataMap.get(baseLineInfo.get(0).getScale()).getDicName());
eventTemplate.setDuration(String.format("%.3f",pqsEventdetail.getPersisttime()/1000));
eventTemplate.setResidualVoltage(String.format("%.2f",pqsEventdetail.getEventvalue()*100));
eventTemplate.setUserName(baseLineInfo.get(0).getObjName());
Map<String,Object> eventMap = mapper.convertValue(eventTemplate,Map.class);
if(CollUtil.isNotEmpty(pqsEventdetailList)) {
List<Map<String, Object>> eventTemplateList = new ArrayList<>();
for (int i = 0; i < pqsEventdetailList.size(); i++) {
PqsEventdetail pqsEventdetail = pqsEventdetailList.get(i);
EventTemplate eventTemplate = new EventTemplate();
eventTemplate.setSno(i + 1);
eventTemplate.setTimeId(pqsEventdetail.getTimeid().format(DatePattern.NORM_DATETIME_FORMATTER) + "." + pqsEventdetail.getMs());
List<LedgerBaseInfoDTO> baseLineInfo = pqLineMapper.getBaseLineInfo(Stream.of(pqsEventdetailList.get(i).getLineid()).collect(Collectors.toList()));
eventTemplate.setOrgName(baseLineInfo.get(0).getGdName());
eventTemplate.setSubName(baseLineInfo.get(0).getStationName());
eventTemplate.setBusName(baseLineInfo.get(0).getBusBarName());
eventTemplate.setScale(pqsDicDataMap.get(baseLineInfo.get(0).getScale()).getDicName());
eventTemplate.setDuration(String.format("%.3f", pqsEventdetail.getPersisttime() / 1000));
eventTemplate.setResidualVoltage(String.format("%.2f", pqsEventdetail.getEventvalue() * 100));
eventTemplate.setUserName(baseLineInfo.get(0).getObjName());
Map<String, Object> eventMap = mapper.convertValue(eventTemplate, Map.class);
eventTemplateList.add(eventMap);
eventTemplateList.add(eventMap);
}
bjReportDTO.setEvent(eventTemplateList);
bjReportDTO.setBjTotalEvent(pqsEventdetailList.size());
List<Integer> lineIds = pqsEventdetailList.stream().map(PqsEventdetail::getLineid).distinct().collect(Collectors.toList());
if (CollectionUtils.isEmpty(lineIds)) {
//如果lineIds为空添加一个不是监测点的监测点id避免后边查询错误
lineIds.add(99999999);
}
List<LedgerBaseInfoDTO> ledgerBaseInfoDTOList = pqLineMapper.getBaseLedger(lineIds, null);
long stationCount = ledgerBaseInfoDTOList.stream().map(LedgerBaseInfoDTO::getStationId).distinct().count();
bjReportDTO.setTotalEventSubstation((int) stationCount);
long busCount = ledgerBaseInfoDTOList.stream().map(LedgerBaseInfoDTO::getBusBarId).distinct().count();
bjReportDTO.setBjTotalBus((int) busCount);
String busVoltageStr = busVoltageDeal(ledgerBaseInfoDTOList, pqsDicDataMap);
bjReportDTO.setStationVoltage(busVoltageStr);
//double容易精度缺失
double min = Math.round(pqsEventdetailList.stream().mapToDouble(PqsEventdetail::getEventvalue).min().getAsDouble() * 100 * 100) * 0.01d;
double max = Math.round(pqsEventdetailList.stream().mapToDouble(PqsEventdetail::getEventvalue).max().getAsDouble() * 100 * 100) * 0.01d;
bjReportDTO.setResidualVoltageRange(min + "%-" + max + "%");
double minPersisTime = pqsEventdetailList.stream().mapToDouble(PqsEventdetail::getPersisttime).min().getAsDouble() / 1000;
double maxPersisTime = pqsEventdetailList.stream().mapToDouble(PqsEventdetail::getPersisttime).max().getAsDouble() / 1000;
bjReportDTO.setDurationRange(minPersisTime + "s-" + maxPersisTime + "s");
List<PqUserLineAssPO> pqUserLineAssPOS = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().in(PqUserLineAssPO::getLineIndex, lineIds));
List<String> userIds = pqUserLineAssPOS.stream().map(PqUserLineAssPO::getUserIndex).distinct().collect(Collectors.toList());
List<PqUserLedgerPO> pqUserLedgerPOList = pqUserLedgerMapper.selectList(new LambdaQueryWrapper<PqUserLedgerPO>().in(PqUserLedgerPO::getId, userIds));
Map<String, List<PqUserLedgerPO>> stringListMap = pqUserLedgerPOList.stream().collect(Collectors.groupingBy(PqUserLedgerPO::getSmallObjType));
String treeStr = userToStr(stringListMap, treePOMap);
bjReportDTO.setObjTypeList(treeStr);
bjReportDTO.setAffectedUserCount(pqUserLedgerPOList.size());
areaAssemble(bjReportDTO, param, pqsDicDataMap);
}
bjReportDTO.setEvent(eventTemplateList);
bjReportDTO.setBjTotalEvent(pqsEventdetailList.size());
List<Integer> lineIds = pqsEventdetailList.stream().map(PqsEventdetail::getLineid).distinct().collect(Collectors.toList());
if(CollectionUtils.isEmpty(lineIds)){
//如果lineIds为空添加一个不是监测点的监测点id避免后边查询错误
lineIds.add(99999999);
}
List<LedgerBaseInfoDTO> ledgerBaseInfoDTOList = pqLineMapper.getBaseLedger(lineIds,null);
long stationCount = ledgerBaseInfoDTOList.stream().map(LedgerBaseInfoDTO::getStationId).distinct().count();
bjReportDTO.setTotalEventSubstation((int)stationCount);
long busCount = ledgerBaseInfoDTOList.stream().map(LedgerBaseInfoDTO::getBusBarId).distinct().count();
bjReportDTO.setBjTotalBus((int)busCount);
String busVoltageStr = busVoltageDeal(ledgerBaseInfoDTOList,pqsDicDataMap);
bjReportDTO.setStationVoltage(busVoltageStr);
//double容易精度缺失
double min =Math.round(pqsEventdetailList.stream().mapToDouble(PqsEventdetail::getEventvalue).min().getAsDouble()*100*100)*0.01d ;
double max = Math.round(pqsEventdetailList.stream().mapToDouble(PqsEventdetail::getEventvalue).max().getAsDouble()*100*100)*0.01d;
bjReportDTO.setResidualVoltageRange(min+"%-"+max+"%");
double minPersisTime = pqsEventdetailList.stream().mapToDouble(PqsEventdetail::getPersisttime).min().getAsDouble()/1000;
double maxPersisTime = pqsEventdetailList.stream().mapToDouble(PqsEventdetail::getPersisttime).max().getAsDouble()/1000;
bjReportDTO.setDurationRange(minPersisTime+"s-"+maxPersisTime+"s");
List<PqUserLineAssPO> pqUserLineAssPOS = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().in(PqUserLineAssPO::getLineIndex,lineIds));
List<String> userIds = pqUserLineAssPOS.stream().map(PqUserLineAssPO::getUserIndex).distinct().collect(Collectors.toList());
List<PqUserLedgerPO> pqUserLedgerPOList = pqUserLedgerMapper.selectList(new LambdaQueryWrapper<PqUserLedgerPO>().in(PqUserLedgerPO::getId,userIds));
Map<String,List<PqUserLedgerPO>> stringListMap = pqUserLedgerPOList.stream().collect(Collectors.groupingBy(PqUserLedgerPO::getSmallObjType));
String treeStr = userToStr(stringListMap,treePOMap);
bjReportDTO.setObjTypeList(treeStr);
bjReportDTO.setAffectedUserCount(pqUserLedgerPOList.size());
areaAssemble(bjReportDTO,param,pqsDicDataMap);
Map<String,Object> map = mapper.convertValue(bjReportDTO,Map.class);

View File

@@ -15,8 +15,7 @@ import java.util.Date;
@Data
@TableName(value = "PQS_DICTREE")
public class PqsDicTreePO {
@TableId // 标记主键字段
@TableField(value ="ID") // 显式指定列名(默认按字段名映射,可省略)
@TableId(value ="ID") // 显式指定列名(默认按字段名映射,可省略)
private String id;
@TableField(value ="NAME")

View File

@@ -1312,6 +1312,12 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
List<PqUserLineAssPO> assLastList = pqUserLedgerMapper.getUserByParam(pageLineIds, null);
Map<Integer, List<String>> mapObj = assLastList.stream().collect(Collectors.groupingBy(PqUserLineAssPO::getLineIndex, Collectors.mapping(PqUserLineAssPO::getUserName, Collectors.toList())));
//字典信息
PqsDicType pqsDicType = pqsDicTypeMapper.selectOne(new LambdaQueryWrapper<PqsDicType>().eq(PqsDicType::getDicTypeName, DicTypeEnum.VOLTAGE.getDicName()));
List<PqsDicData> pqsDicDataList = pqsDicDataMapper.selectList(new LambdaQueryWrapper<PqsDicData>().eq(PqsDicData::getDicType, pqsDicType.getDicTypeIndex()));
Map<String, PqsDicData> pqsDicDataMap = pqsDicDataList.stream().collect(Collectors.toMap(PqsDicData::getDicIndex, dic -> dic));
pqsEventdetailPage = list.stream().map(temp -> {
EventDetailVO eventDetailVO = new EventDetailVO();
eventDetailVO.setEventdetail_index(temp.getEventdetailIndex());
@@ -1330,6 +1336,8 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
eventDetailVO.setGdName(ledgerBaseInfoDTO.getGdName());
eventDetailVO.setBusName(ledgerBaseInfoDTO.getBusBarName());
eventDetailVO.setObjName(ledgerBaseInfoDTO.getObjName());
eventDetailVO.setBusVoltageLevel(pqsDicDataMap.get(ledgerBaseInfoDTO.getScale()).getDicName());
}
String objName = "/";
if (mapObj.containsKey(eventDetailVO.getLineid())) {