监测点污染值、用户污染值、变电站污染值导出功能

This commit is contained in:
wr
2025-07-29 16:35:22 +08:00
parent 9f9baa9991
commit 4f66c4833f
20 changed files with 937 additions and 36 deletions

View File

@@ -68,11 +68,13 @@ public class SubstationServiceImpl extends ServiceImpl<SubstationMapper, Substat
List<DictData> dictDataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE_STAND.getCode()).getData(); List<DictData> dictDataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE_STAND.getCode()).getData();
Map<String,DictData> dictDataMap = dictDataList.stream().collect(Collectors.toMap(DictData::getId,Function.identity())); Map<String,DictData> dictDataMap = dictDataList.stream().collect(Collectors.toMap(DictData::getId,Function.identity()));
stationList.forEach(item->{ stationList.forEach(item->{
LedgerSelectVO ledgerSelectVO = new LedgerSelectVO(); if(stationMap.containsKey(item.getId())){
BeanUtil.copyProperties(item,ledgerSelectVO); LedgerSelectVO ledgerSelectVO = new LedgerSelectVO();
ledgerSelectVO.setVoltageLevel(stationMap.get(item.getId()).getScale()); BeanUtil.copyProperties(item,ledgerSelectVO);
ledgerSelectVO.setVoltageName(dictDataMap.get(ledgerSelectVO.getVoltageLevel()).getName()); ledgerSelectVO.setVoltageLevel(stationMap.get(item.getId()).getScale());
result.add(ledgerSelectVO); ledgerSelectVO.setVoltageName(dictDataMap.get(ledgerSelectVO.getVoltageLevel()).getName());
result.add(ledgerSelectVO);
}
}); });
return result; return result;
} }

View File

@@ -7,8 +7,10 @@ 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.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.pq.pojo.param.GridDiagramParam;
import com.njcn.event.api.fallback.EventDetailFeignClientFallbackFactory; import com.njcn.event.api.fallback.EventDetailFeignClientFallbackFactory;
import com.njcn.event.api.fallback.RmpEventDetailFeignClientFallbackFactory; import com.njcn.event.api.fallback.RmpEventDetailFeignClientFallbackFactory;
import com.njcn.event.pojo.dto.EventCount;
import com.njcn.event.pojo.po.EventDetail; import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.RmpEventDetailPO; import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.AdvanceEventDetailVO; import com.njcn.event.pojo.vo.AdvanceEventDetailVO;
@@ -41,4 +43,7 @@ public interface RmpEventDetailFeignClient {
*/ */
@GetMapping("/queryEventDetailByEventId") @GetMapping("/queryEventDetailByEventId")
HttpResult<RmpEventDetailPO> queryEventDetailByEventId(@RequestParam("eventId")String eventId); HttpResult<RmpEventDetailPO> queryEventDetailByEventId(@RequestParam("eventId")String eventId);
@PostMapping("/getEventCount")
HttpResult<List<EventCount>> getEventCount(@RequestBody GridDiagramParam param);
} }

View File

@@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.device.pq.pojo.param.GridDiagramParam;
import com.njcn.event.api.EventDetailFeignClient; import com.njcn.event.api.EventDetailFeignClient;
import com.njcn.event.api.RmpEventDetailFeignClient; import com.njcn.event.api.RmpEventDetailFeignClient;
import com.njcn.event.pojo.dto.EventCount;
import com.njcn.event.pojo.po.EventDetail; import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.RmpEventDetailPO; import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.AdvanceEventDetailVO; import com.njcn.event.pojo.vo.AdvanceEventDetailVO;
@@ -41,6 +43,12 @@ public class RmpEventDetailFeignClientFallbackFactory implements FallbackFactory
log.error("{}异常,降级处理,异常为:{}", "查询暂降明细", throwable.toString()); log.error("{}异常,降级处理,异常为:{}", "查询暂降明细", throwable.toString());
throw new BusinessException(finalExceptionEnum); throw new BusinessException(finalExceptionEnum);
} }
@Override
public HttpResult<List<EventCount>> getEventCount(GridDiagramParam param) {
log.error("{}异常,降级处理,异常为:{}", "根据特征幅值进行统计", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
}; };
} }
} }

View File

@@ -8,6 +8,8 @@ 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.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.pq.pojo.param.GridDiagramParam;
import com.njcn.event.pojo.dto.EventCount;
import com.njcn.event.pojo.param.EventBaseParam; import com.njcn.event.pojo.param.EventBaseParam;
import com.njcn.event.pojo.param.UniversalFrontEndParam; import com.njcn.event.pojo.param.UniversalFrontEndParam;
import com.njcn.event.pojo.po.RmpEventDetailPO; import com.njcn.event.pojo.po.RmpEventDetailPO;
@@ -146,4 +148,12 @@ public class RmpEventDetailController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getEventCount")
@ApiOperation("根据特征幅值进行统计")
public HttpResult<List<EventCount>> getEventCount(@RequestBody GridDiagramParam param) {
String methodDescribe = getMethodDescribe("getEventCount");
List<EventCount> eventCount = rmpEventDetailService.getEventCount(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventCount, methodDescribe);
}
} }

View File

@@ -1,6 +1,8 @@
package com.njcn.event.mapper.majornetwork; package com.njcn.event.mapper.majornetwork;
import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.event.pojo.dto.EventCount;
import com.njcn.event.pojo.po.RmpEventDetailPO; import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.RmpEventDetailVO; import com.njcn.event.pojo.vo.RmpEventDetailVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@@ -53,4 +55,6 @@ public interface RmpEventDetailMapper extends BaseMapper<RmpEventDetailPO> {
* @return * @return
*/ */
RmpEventDetailPO getByEventId(@Param("id") String id); RmpEventDetailPO getByEventId(@Param("id") String id);
List<EventCount> getEventCount(@Param("startTime")String startTime,@Param("endTime")String endTime);
} }

View File

@@ -74,4 +74,15 @@
r_mp_event_detail r_mp_event_detail
where event_id=#{id} where event_id=#{id}
</select> </select>
<select id="getEventCount" resultType="com.njcn.event.pojo.dto.EventCount">
SELECT
measurement_point_id lineId,
SUM(CASE WHEN feature_amplitude &gt;= 0 AND feature_amplitude &lt; 0.1 THEN 1 ELSE 0 END) AS breakCounts,
SUM(CASE WHEN feature_amplitude &gt;= 0.1 AND feature_amplitude &lt; 0.9 THEN 1 ELSE 0 END) AS downCounts,
SUM(CASE WHEN feature_amplitude &gt;= 1.1 THEN 1 ELSE 0 END) AS upCounts
FROM
r_mp_event_detail
where start_time between #{startTime} and #{endTime}
GROUP BY measurement_point_id
</select>
</mapper> </mapper>

View File

@@ -3,6 +3,7 @@ package com.njcn.event.service.majornetwork.Impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
@@ -37,6 +38,7 @@ import com.njcn.device.pq.pojo.vo.GridDiagramVO;
import com.njcn.event.enums.EventResponseEnum; import com.njcn.event.enums.EventResponseEnum;
import com.njcn.event.mapper.majornetwork.RMpEventDetailMMapper; import com.njcn.event.mapper.majornetwork.RMpEventDetailMMapper;
import com.njcn.event.mapper.majornetwork.RmpEventDetailMapper; import com.njcn.event.mapper.majornetwork.RmpEventDetailMapper;
import com.njcn.event.pojo.dto.EventCount;
import com.njcn.event.pojo.param.EventBaseParam; import com.njcn.event.pojo.param.EventBaseParam;
import com.njcn.event.pojo.param.UniversalFrontEndParam; import com.njcn.event.pojo.param.UniversalFrontEndParam;
import com.njcn.event.pojo.po.RmpEventDetailPO; import com.njcn.event.pojo.po.RmpEventDetailPO;
@@ -435,6 +437,21 @@ public class RmpEventDetailServiceImpl extends ServiceImpl<RmpEventDetailMapper,
return mapList; return mapList;
} }
@Override
public List<EventCount> getEventCount(GridDiagramParam param) {
List<EventCount> eventCounts = rmpEventDetailMapper.getEventCount(param.getSearchBeginTime(), param.getSearchEndTime());
Map<String, EventCount> eventMap = eventCounts.stream().collect(Collectors.toMap(EventCount::getLineId, pojo -> pojo));
List<EventCount> eventCountList = new ArrayList<>();
for (String id : param.getIds()) {
EventCount eventCountTemp = eventMap.get(id);
if (Objects.isNull(eventCountTemp)) {
eventCountTemp = new EventCount(id);
}
eventCountList.add(eventCountTemp);
}
return eventCountList;
}
private List<Double> setData(List<String> gwLineAllIds, List<RmpEventDetailPO> list) { private List<Double> setData(List<String> gwLineAllIds, List<RmpEventDetailPO> list) {
List<Double> info=new ArrayList<>(); List<Double> info=new ArrayList<>();

View File

@@ -6,6 +6,7 @@ import com.njcn.common.pojo.param.StatisticsBizBaseParam;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.device.pq.pojo.param.GridDiagramParam; import com.njcn.device.pq.pojo.param.GridDiagramParam;
import com.njcn.device.pq.pojo.vo.GridDiagramVO; import com.njcn.device.pq.pojo.vo.GridDiagramVO;
import com.njcn.event.pojo.dto.EventCount;
import com.njcn.event.pojo.param.EventBaseParam; import com.njcn.event.pojo.param.EventBaseParam;
import com.njcn.event.pojo.param.UniversalFrontEndParam; import com.njcn.event.pojo.param.UniversalFrontEndParam;
import com.njcn.event.pojo.po.RmpEventDetailPO; import com.njcn.event.pojo.po.RmpEventDetailPO;
@@ -80,4 +81,7 @@ public interface RmpEventDetailService extends IService<RmpEventDetailPO> {
List<Map<String,Object>> getImMonitorEvents(EventBaseParam param); List<Map<String,Object>> getImMonitorEvents(EventBaseParam param);
List<EventCount> getEventCount(GridDiagramParam param);
} }

View File

@@ -0,0 +1,27 @@
package com.njcn.harmonic.pojo.excel.pollution;
import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class GdPollution implements Serializable {
/**
* 供电公司名称
*/
@Excel(name = "供电公司", width = 30, needMerge = true)
private String gdName;
/**
* 变电站集合
* name不要赋值
*/
@ExcelCollection(name = "")
private List<SubstationPollution> substationPollutionList;
}

View File

@@ -0,0 +1,84 @@
package com.njcn.harmonic.pojo.excel.pollution;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.io.Serializable;
@Data
public class LineItemPollution implements Serializable {
/**
* 终端名称
*/
@Excel(name = "终端名称", width = 30, replace = "/_null")
private String devName;
/**
* 终端厂家
*/
@Excel(name = "终端厂家", width = 30, replace = "/_null")
private String manufacturer;
/**
* 终端型号
*/
@Excel(name = "终端型号", width = 30, replace = "/_null")
private String devType;
/**
* 终端投运时间
*/
@Excel(name = "投运时间", width = 30, replace = "/_null")
private String loginTime;
/**
* 监测点名称
*/
@Excel(name = "监测点名称", width = 35, replace = "/_null")
private String lineName;
/**
* 统计间隔
*/
@Excel(name = "统计间隔", width = 30, replace = "/_null")
private Integer interval;
/**
* 谐波电压污染值
*/
@Excel(name = "谐波电压污染值", width = 35, replace = "/_null")
private Double vHarmonicValue;
@Excel(name = "谐波电压污染值", width = 35, replace = "/_null")
private Double iHarmonicValue;
/**
* 暂升次数 1.1~1.8
* 10ms ~ 1min
*/
// @Excel(name = "暂升次数(次)", width = 32, replace = "/_null")
private Integer upCounts;
/**
* 暂降次数 0.1~0.9
* 10ms ~ 1min
*/
// @Excel(name = "电压暂降(次)", width = 32, replace = "/_null")
private Integer downCounts;
/**
* 短时中断 0~0.1
* 10ms ~ 1min
*/
// @Excel(name = "短时中断(次)", width = 32, replace = "/_null")
private Integer breakCounts;
/**
* 备注
*/
@Excel(name = "备注", width = 30, replace = "/_null")
private String remark;
}

View File

@@ -0,0 +1,152 @@
package com.njcn.harmonic.pojo.excel.pollution;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.io.Serializable;
@Data
public class LinePollution implements Serializable {
/**
* 供电公司名称
*/
@Excel(name = "供电公司", width = 30)
private String gdName;
/**
* 所属变电站
*/
@Excel(name = "变电站", width = 30)
private String subStationName;
/**
* 终端名称
*/
@Excel(name = "终端名称", width = 30)
private String devName;
/**
* 终端厂家
*/
@Excel(name = "终端厂家", width = 30)
private String manufacturer;
/**
* 终端型号
*/
@Excel(name = "终端型号", width = 30)
private String devType;
/**
* 终端投运时间
*/
@Excel(name = "投运时间", width = 30)
private String loginTime;
/**
* 监测点索引
*/
private String lineId;
/**
* 监测点名称
*/
@Excel(name = "监测点名称", width = 30)
private String lineName;
/**
* 位置,电网侧&非电网侧
*/
@Excel(name = "监测位置", width = 30)
private String powerFlag;
/**
* 新增
* 监测点电压等级
*/
@Excel(name = "监测点电压等级", width = 30)
private String lineVoltage;
/**
* 干扰源类型
*/
@Excel(name = "干扰源类型", width = 30)
private String loadType;
/**
* 监测对象
*/
@Excel(name = "监测对象名称", width = 30)
private String objName;
/**
* 统计间隔
*/
@Excel(name = "统计间隔", width = 30)
private Integer interval;
/**
* 新增
* 在线率
*/
@Excel(name = "在线率(%)", width = 30)
private Double onlineRate;
/**
* 新增
* 完整性
*/
@Excel(name = "完整率(%)", width = 30)
private Double integrity;
/**
* 谐波电压污染值
*/
@Excel(name = "谐波电压污染值", width = 20)
private Double vHarmonicValue;
/**
* 谐波电压污染值
*/
@Excel(name = "谐波电流污染值", width = 20)
private Double iHarmonicValue;
/**
* 暂升次数 1.1~1.8
* 10ms ~ 1min
*/
@Excel(name = "暂升次数(次)", width = 20)
private Integer upCounts;
/**
* 暂降次数 0.1~0.9
* 10ms ~ 1min
*/
@Excel(name = "电压暂降(次)", width = 20)
private Integer downCounts;
/**
* 短时中断 0~0.1
* 10ms ~ 1min
*/
@Excel(name = "短时中断(次)", width = 20)
private Integer breakCounts;
@Excel(name = "是否关联敏感用户", width = 30, replace = "/_null")
private String isMg;
@Excel(name = "敏感及重要用户", width = 30,replace = "/_null")
private String importUser;
@Excel(name = "一类监测点", width = 30,replace = "/_null")
private String monitorId;
// /**
// * 备注
// */
// @Excel(name = "备注", width = 30, replace = "/_null")
// private String remark;
}

View File

@@ -0,0 +1,92 @@
package com.njcn.harmonic.pojo.excel.pollution;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.io.Serializable;
@Data
public class LoadTypeLineItemPollution implements Serializable {
/**
* 所属变电站
*/
@Excel(name = "变电站", width = 30, needMerge = true)
private String subStationName;
/**
* 终端名称
*/
@Excel(name = "终端名称", width = 30, replace = "/_null")
private String devName;
/**
* 终端厂家
*/
@Excel(name = "终端厂家", width = 30, replace = "/_null")
private String manufacturer;
/**
* 终端型号
*/
@Excel(name = "终端型号", width = 30, replace = "/_null")
private String devType;
/**
* 终端投运时间
*/
@Excel(name = "投运时间", width = 30, replace = "/_null")
private String loginTime;
/**
* 监测点名称
*/
@Excel(name = "监测点名称", width = 30, replace = "/_null")
private String lineName;
/**
* 统计间隔
*/
@Excel(name = "统计间隔", width = 30, replace = "/_null")
private Integer interval;
/**
* 谐波电压污染值
*/
@Excel(name = "测点谐波电压污染值", width = 20, replace = "/_null")
private Double vHarmonicValue;
/**
* 谐波电压污染值
*/
@Excel(name = "测点谐波电流污染值", width = 20, replace = "/_null")
private Double iHarmonicValue;
/**
* 暂升次数 1.1~1.8
* 10ms ~ 1min
*/
// @Excel(name = "暂升次数(次)", width = 20, replace = "/_null")
private Integer upCounts;
/**
* 暂降次数 0.1~0.9
* 10ms ~ 1min
*/
// @Excel(name = "电压暂降(次)", width = 20, replace = "/_null")
private Integer downCounts;
/**
* 短时中断 0~0.1
* 10ms ~ 1min
*/
// @Excel(name = "短时中断(次)", width = 20, replace = "/_null")
private Integer breakCounts;
/**
* 备注
*/
@Excel(name = "备注", width = 30, replace = "/_null")
private String remark;
}

View File

@@ -0,0 +1,46 @@
package com.njcn.harmonic.pojo.excel.pollution;
import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class ObjPollution implements Serializable {
/**
* 对象名称
*/
@Excel(name = "用户名称", width = 30, needMerge = true)
private String objName;
/**
* 干扰源类型
*/
@Excel(name = "干扰源类型", width = 30, needMerge = true)
private String loadType;
/**
* 行业类型
*/
@Excel(name = "行业类型", width = 30, needMerge = true)
private String businessType;
/**
* 用户污染值
*/
@Excel(name = "用户谐波电压污染值", width = 30, needMerge = true)
private String objVValue;
@Excel(name = "用户谐波电流污染值", width = 30, needMerge = true)
private String objIValue;
/**
* 下面监测点详细污染值
*/
@ExcelCollection(name = "")
private List<LoadTypeLineItemPollution> lineItemPollutionList;
}

View File

@@ -0,0 +1,35 @@
package com.njcn.harmonic.pojo.excel.pollution;
import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class PowerFlagPollution implements Serializable {
/**
* 监测位置
*/
@Excel(name = "监测位置", width = 30, needMerge = true)
private String powerFlag;
/**
* 监测污染值
*/
@Excel(name = "监测谐波电压污染值", width = 40, needMerge = true, replace = "/_null")
private String powerVValue;
@Excel(name = "监测谐波电流污染值", width = 40, needMerge = true, replace = "/_null")
private String powerIValue;
/**
* 当前位置下,各测点的污染数据
*/
@ExcelCollection(name = "")
private List<LineItemPollution> lineItemPollutionList;
}

View File

@@ -0,0 +1,40 @@
package com.njcn.harmonic.pojo.excel.pollution;
import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class SubstationPollution implements Serializable {
/**
* 所属变电站
*/
@Excel(name = "变电站", width = 30, needMerge = true)
private String subStationName;
/**
* 电站污染值
*/
@Excel(name = "电站谐波电压污染值", width = 25, needMerge = true)
private String subVStationValue;
/**
* 电站污染值
*/
@Excel(name = "电站谐波电流污染值", width = 25, needMerge = true)
private String subIStationValue;
/**
* 电网侧&非电网侧
* name不要赋值
*/
@ExcelCollection(name = "")
private List<PowerFlagPollution> powerFlagPollutionList;
}

View File

@@ -10,6 +10,7 @@ import com.njcn.device.biz.pojo.dto.PollutionLineDTO;
import com.njcn.device.pq.pojo.dto.PollutionSubstationDTO; import com.njcn.device.pq.pojo.dto.PollutionSubstationDTO;
import com.njcn.harmonic.pojo.param.HarmonicPublicParam; import com.njcn.harmonic.pojo.param.HarmonicPublicParam;
import com.njcn.harmonic.pojo.param.PollutionSubstationQuryParam; import com.njcn.harmonic.pojo.param.PollutionSubstationQuryParam;
import com.njcn.harmonic.pojo.param.StatSubstationBizBaseParam;
import com.njcn.harmonic.pojo.vo.PollutionSubstationVO; import com.njcn.harmonic.pojo.vo.PollutionSubstationVO;
import com.njcn.harmonic.pojo.vo.PollutionVO; import com.njcn.harmonic.pojo.vo.PollutionVO;
import com.njcn.harmonic.pojo.vo.SubstationVo; import com.njcn.harmonic.pojo.vo.SubstationVo;
@@ -21,6 +22,7 @@ import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -119,4 +121,36 @@ public class PollutionSubstationController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation(value ="导出监测点谐波污染值",produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
@GetMapping(value ="/downPollutionLineCalc",produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
public void downPollutionLineCalc(@RequestParam(value = "startTime") String startTime,
@RequestParam(value = "endTime") String endTime) {
StatSubstationBizBaseParam param=new StatSubstationBizBaseParam();
param.setStartTime(startTime);
param.setEndTime(endTime);
pollutionSubstationService.downPollutionLineCalc(param);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation(value ="导出用户谐波电压污染值",produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
@GetMapping(value ="/downPollutionUserCalc",produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
public void downPollutionUserCalc(@RequestParam(value = "startTime") String startTime,
@RequestParam(value = "endTime") String endTime) {
StatSubstationBizBaseParam param=new StatSubstationBizBaseParam();
param.setStartTime(startTime);
param.setEndTime(endTime);
pollutionSubstationService.downPollutionUserCalc(param);
}
@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);
}
} }

View File

@@ -33,4 +33,9 @@ public interface RMpPollutionDPOMapper extends BaseMapper<RMpPollutionDPO> {
@Param("start") DateTime searchBeginTime, @Param("start") DateTime searchBeginTime,
@Param("end") DateTime searchEndTime, @Param("end") DateTime searchEndTime,
@Param("pollutionType") String id); @Param("pollutionType") String id);
List<RMpPollutionDPO> selectSumList(@Param("ids") List<String> line,
@Param("pollutionType") List<String> pollutionType,
@Param("statTime") String statTime,
@Param("endTime") String endTime);
} }

View File

@@ -67,6 +67,36 @@
GROUP BY GROUP BY
l.line_id; l.line_id;
</select> </select>
<select id="selectSumList" resultType="com.njcn.harmonic.pojo.po.RMpPollutionDPO">
SELECT
l.line_id,
l.pollution_type,
sum( l.VALUE ) AS value
FROM
r_mp_pollution_d l
<where>
<if test=" pollutionType != null and pollutionType.size > 0">
AND l.pollution_type IN
<foreach collection='pollutionType' item='item' index="index" open='(' separator=',' close=')'>
#{item}
</foreach>
</if>
<if test=" ids != null and ids.size > 0">
AND line_id IN
<foreach collection='ids' item='item' index="index" open='(' separator=',' close=')'>
#{item}
</foreach>
</if>
<if test=" statTime != null and statTime !=''">
AND data_date >= #{statTime}
</if>
<if test="endTime != null and endTime != ''">
AND data_date &lt;= #{endTime}
</if>
</where>
GROUP BY
l.line_id,l.pollution_type;
</select>
<insert id="batchInsert" parameterType="map"> <insert id="batchInsert" parameterType="map">

View File

@@ -89,4 +89,23 @@ public interface PollutionSubstationService extends IService<RStatPollutionSubst
List<List<String>> getPollutionAlarmList(GridDiagramParam param); List<List<String>> getPollutionAlarmList(GridDiagramParam param);
List<SubstationVo> getSubstationInfo(String deptIndex, String searchValue, String startTime, String endTime); List<SubstationVo> getSubstationInfo(String deptIndex, String searchValue, String startTime, String endTime);
/**
* 导出监测点谐波污染值
* @param param
*/
void downPollutionLineCalc(StatSubstationBizBaseParam param);
/**
* 导出用户谐波电压污染值
*/
void downPollutionUserCalc(StatSubstationBizBaseParam param);
/**
* 变电站谐波电压污染值
* @param param
*/
void downPollutionSubCalc(StatSubstationBizBaseParam param);
} }

View File

@@ -1,5 +1,6 @@
package com.njcn.harmonic.service.impl; package com.njcn.harmonic.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
@@ -14,10 +15,12 @@ import com.njcn.common.config.GeneralInfo;
import com.njcn.common.pojo.constant.BizParamConstant; import com.njcn.common.pojo.constant.BizParamConstant;
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.exception.BusinessException;
import com.njcn.common.utils.PubUtils;
import com.njcn.device.biz.commApi.CommLineClient;
import com.njcn.device.biz.commApi.CommTerminalGeneralClient; import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
import com.njcn.device.biz.enums.RunFlagEnum;
import com.njcn.device.biz.pojo.dto.*; import com.njcn.device.biz.pojo.dto.*;
import com.njcn.device.biz.pojo.param.DeptGetLineParam; 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.MonitorClient;
import com.njcn.device.pms.api.PmsGeneralDeviceInfoClient; import com.njcn.device.pms.api.PmsGeneralDeviceInfoClient;
import com.njcn.device.pms.api.StatationStatClient; import com.njcn.device.pms.api.StatationStatClient;
@@ -34,12 +37,17 @@ import com.njcn.device.pq.enums.PowerFlagEnum;
import com.njcn.device.pq.pojo.dto.*; import com.njcn.device.pq.pojo.dto.*;
import com.njcn.device.pq.pojo.param.GridDiagramParam; import com.njcn.device.pq.pojo.param.GridDiagramParam;
import com.njcn.device.pq.pojo.param.LineBaseQueryParam; import com.njcn.device.pq.pojo.param.LineBaseQueryParam;
import com.njcn.device.pq.pojo.param.OnlineRateParam;
import com.njcn.device.pq.pojo.po.Line; import com.njcn.device.pq.pojo.po.Line;
import com.njcn.device.pq.pojo.po.LineDetail; import com.njcn.device.pq.pojo.po.LineDetail;
import com.njcn.device.pq.pojo.vo.GridDiagramVO; import com.njcn.device.pq.pojo.vo.GridDiagramVO;
import com.njcn.harmonic.constant.Param; import com.njcn.device.pq.pojo.vo.RStatIntegrityVO;
import com.njcn.device.pq.pojo.vo.RStatOnlinerateVO;
import com.njcn.event.api.RmpEventDetailFeignClient;
import com.njcn.event.pojo.dto.EventCount;
import com.njcn.harmonic.mapper.*; import com.njcn.harmonic.mapper.*;
import com.njcn.harmonic.pojo.dto.PublicDTO; import com.njcn.harmonic.pojo.dto.PublicDTO;
import com.njcn.harmonic.pojo.excel.pollution.*;
import com.njcn.harmonic.pojo.param.HarmonicPublicParam; import com.njcn.harmonic.pojo.param.HarmonicPublicParam;
import com.njcn.harmonic.pojo.param.PollutionSubstationQuryParam; import com.njcn.harmonic.pojo.param.PollutionSubstationQuryParam;
import com.njcn.harmonic.pojo.param.StatSubstationBizBaseParam; import com.njcn.harmonic.pojo.param.StatSubstationBizBaseParam;
@@ -49,12 +57,14 @@ import com.njcn.harmonic.pojo.vo.PollutionSubstationVO;
import com.njcn.harmonic.pojo.vo.PollutionVO; import com.njcn.harmonic.pojo.vo.PollutionVO;
import com.njcn.harmonic.pojo.vo.SubstationVo; import com.njcn.harmonic.pojo.vo.SubstationVo;
import com.njcn.harmonic.service.PollutionSubstationService; import com.njcn.harmonic.service.PollutionSubstationService;
import com.njcn.poi.excel.ExcelUtil;
import com.njcn.supervision.api.UserLedgerFeignClient; import com.njcn.supervision.api.UserLedgerFeignClient;
import com.njcn.supervision.pojo.param.user.UserReportParam; import com.njcn.supervision.pojo.param.user.UserReportParam;
import com.njcn.supervision.pojo.vo.user.NewUserReportVO;
import com.njcn.supervision.pojo.vo.user.UserLedgerVO; import com.njcn.supervision.pojo.vo.user.UserLedgerVO;
import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum; 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.api.DeptFeignClient;
import com.njcn.user.pojo.po.Dept; import com.njcn.user.pojo.po.Dept;
import com.njcn.web.utils.RequestUtil; import com.njcn.web.utils.RequestUtil;
@@ -65,6 +75,7 @@ import java.util.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -102,9 +113,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
private final GeneralDeviceInfoClient generalDeviceInfoClient; private final GeneralDeviceInfoClient generalDeviceInfoClient;
private final LineFeignClient lineFeignClient; private final LineFeignClient lineFeignClient;
private final GeneralInfo generalInfo; private final GeneralInfo generalInfo;
@@ -114,12 +123,13 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
private final RStatPollutionOrgDPOMapper rStatPollutionOrgDPOMapper; private final RStatPollutionOrgDPOMapper rStatPollutionOrgDPOMapper;
private final RMpPollutionDPOMapper rMpPollutionDPOMapper; private final RMpPollutionDPOMapper rMpPollutionDPOMapper;
private final CommTerminalGeneralClient commTerminalGeneralClient; private final CommTerminalGeneralClient commTerminalGeneralClient;
private final DicDataFeignClient dicDataFeignClient; private final DicDataFeignClient dicDataFeignClient;
private final RStatLimitRateDMapper rStatLimitRateDMapper; private final RStatLimitRateDMapper rStatLimitRateDMapper;
private final UserLedgerFeignClient userLedgerFeignClient; private final UserLedgerFeignClient userLedgerFeignClient;
private final RmpEventDetailFeignClient detailFeignClient;
private final CommLineClient commLineClient;
/** /**
* @param pollutionSubstationQuryParam * @param pollutionSubstationQuryParam
@@ -322,7 +332,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
} }
} }
double exe = subPollutionVO.stream().mapToDouble(PollutionVO::getData).filter(it->it != 3.14159).max().orElse(3.14159); double exe = subPollutionVO.stream().mapToDouble(PollutionVO::getData).filter(it -> it != 3.14159).max().orElse(3.14159);
pollutionVO.setData(exe); pollutionVO.setData(exe);
pollutionVO.setChildren(subPollutionVO); pollutionVO.setChildren(subPollutionVO);
list.add(pollutionVO); list.add(pollutionVO);
@@ -648,12 +658,12 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
} }
} }
}); });
return commDataDeal(line,paramDTO,harmonicPublicParam); return commDataDeal(line, paramDTO, harmonicPublicParam);
} else { } else {
List<LineDetail> lineDetailList = lineFeignClient.getMonitorByObjId(harmonicPublicParam.getId()).getData(); List<LineDetail> lineDetailList = lineFeignClient.getMonitorByObjId(harmonicPublicParam.getId()).getData();
if (CollUtil.isNotEmpty(lineDetailList)) { if (CollUtil.isNotEmpty(lineDetailList)) {
List<String> ids = lineDetailList.stream().map(LineDetail::getId).collect(Collectors.toList()); List<String> ids = lineDetailList.stream().map(LineDetail::getId).collect(Collectors.toList());
return commDataDeal(ids,paramDTO,harmonicPublicParam); return commDataDeal(ids, paramDTO, harmonicPublicParam);
} }
} }
@@ -662,21 +672,21 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
} }
private List<PollutionLineDTO> commDataDeal(List<String> ids,PollutionParamDTO paramDTO,HarmonicPublicParam harmonicPublicParam){ private List<PollutionLineDTO> commDataDeal(List<String> ids, PollutionParamDTO paramDTO, HarmonicPublicParam harmonicPublicParam) {
paramDTO.setLineList(ids); paramDTO.setLineList(ids);
List<PollutionLineDTO> list = lineFeignClient.getLineInfo(paramDTO).getData(); List<PollutionLineDTO> list = lineFeignClient.getLineInfo(paramDTO).getData();
List<RMpPollutionDPO> lineData = rMpPollutionDPOMapper.selectMaxList(ids, harmonicPublicParam.getStatisticalType().getId(), harmonicPublicParam.getSearchBeginTime(), harmonicPublicParam.getSearchEndTime()); List<RMpPollutionDPO> lineData = rMpPollutionDPOMapper.selectMaxList(ids, harmonicPublicParam.getStatisticalType().getId(), harmonicPublicParam.getSearchBeginTime(), harmonicPublicParam.getSearchEndTime());
Map<String,RMpPollutionDPO> map = lineData.stream().collect(Collectors.toMap(RMpPollutionDPO::getLineId,Function.identity())); Map<String, RMpPollutionDPO> map = lineData.stream().collect(Collectors.toMap(RMpPollutionDPO::getLineId, Function.identity()));
if (!CollectionUtils.isEmpty(lineData)) { if (!CollectionUtils.isEmpty(lineData)) {
list.stream().sorted(Comparator.comparing(PollutionLineDTO::getData).reversed().thenComparing(PollutionLineDTO::getName)).forEach(item->{ list.stream().sorted(Comparator.comparing(PollutionLineDTO::getData).reversed().thenComparing(PollutionLineDTO::getName)).forEach(item -> {
if(map.containsKey(item.getId())){ if (map.containsKey(item.getId())) {
item.setData(map.get(item.getId()).getValue()); item.setData(map.get(item.getId()).getValue());
}else { } else {
item.setData(3.14159); item.setData(3.14159);
} }
}); });
} }
return list; return list;
} }
@@ -687,21 +697,21 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
param.setServerName(generalInfo.getMicroServiceName()); param.setServerName(generalInfo.getMicroServiceName());
PollutionParamDTO paramDTO = new PollutionParamDTO(); PollutionParamDTO paramDTO = new PollutionParamDTO();
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceInfoClient.getPracticalRunDeviceInfo(param).getData(); List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceInfoClient.getPracticalRunDeviceInfo(param).getData();
List<String> ids = generalDeviceDTOList.stream().filter(it->CollUtil.isNotEmpty(it.getLineIndexes())).flatMap(it->it.getLineIndexes().stream()).collect(Collectors.toList()); List<String> ids = generalDeviceDTOList.stream().filter(it -> CollUtil.isNotEmpty(it.getLineIndexes())).flatMap(it -> it.getLineIndexes().stream()).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(ids)) { if (!CollectionUtils.isEmpty(ids)) {
List<PublicDTO> result = rMpPollutionDPOMapper.getTop10Line(ids, DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime())), DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime())), param.getStatisticalType().getId()); List<PublicDTO> result = rMpPollutionDPOMapper.getTop10Line(ids, DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime())), DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime())), param.getStatisticalType().getId());
if (!CollectionUtils.isEmpty(result)) { if (!CollectionUtils.isEmpty(result)) {
List<String> monitorIds = result.stream().map(PublicDTO::getId).distinct().collect(Collectors.toList()); List<String> monitorIds = result.stream().map(PublicDTO::getId).distinct().collect(Collectors.toList());
paramDTO.setLineList(monitorIds); paramDTO.setLineList(monitorIds);
List<PollutionLineDTO> monitorList = lineFeignClient.getLineInfo(paramDTO).getData(); List<PollutionLineDTO> monitorList = lineFeignClient.getLineInfo(paramDTO).getData();
Map<String,PollutionLineDTO> monitorMap = monitorList.stream().collect(Collectors.toMap(PollutionLineDTO::getId,Function.identity())); Map<String, PollutionLineDTO> monitorMap = monitorList.stream().collect(Collectors.toMap(PollutionLineDTO::getId, Function.identity()));
list = result.stream().map(it->{ list = result.stream().map(it -> {
PollutionLineDTO pollutionLineDTO = new PollutionLineDTO(); PollutionLineDTO pollutionLineDTO = new PollutionLineDTO();
pollutionLineDTO.setData(NumberUtil.round(it.getData(),2).doubleValue()); pollutionLineDTO.setData(NumberUtil.round(it.getData(), 2).doubleValue());
PollutionLineDTO monitor = monitorMap.get(it.getId()); PollutionLineDTO monitor = monitorMap.get(it.getId());
pollutionLineDTO.setName(monitor.getSubstation()+"_"+monitor.getName()); pollutionLineDTO.setName(monitor.getSubstation() + "_" + monitor.getName());
return pollutionLineDTO; return pollutionLineDTO;
}).sorted(Comparator.comparing(PollutionLineDTO::getData,Comparator.reverseOrder())).collect(Collectors.toList()); }).sorted(Comparator.comparing(PollutionLineDTO::getData, Comparator.reverseOrder())).collect(Collectors.toList());
} }
} }
return list; return list;
@@ -960,6 +970,272 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
return result; return result;
} }
@Override
public void downPollutionLineCalc(StatSubstationBizBaseParam param) {
String startDate = DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())).toString();
String endDate = DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())).toString();
List<LinePollution> finalLinePollutionList = pollutionCalcList(startDate, endDate);
// 全部监测点计算完毕后根据污染值从大到小进行排序
finalLinePollutionList = finalLinePollutionList.stream()
.sorted(Comparator.comparing(LinePollution::getVHarmonicValue).reversed())
.collect(Collectors.toList());
ExcelUtil.exportExcel("监测点谐波电压污染值" + endDate + ".xlsx", LinePollution.class, finalLinePollutionList);
}
private List<LinePollution> pollutionCalcList(String startDate,String endDate) {
List<LinePollution> linePollutionList = new ArrayList<>();
List<String> lineIdList = commTerminalGeneralClient.getRunMonitorIds().getData();
GridDiagramParam eventParam = new GridDiagramParam();
eventParam.setIds(lineIdList);
eventParam.setSearchBeginTime(startDate);
eventParam.setSearchEndTime(endDate);
List<EventCount> eventCounts = detailFeignClient.getEventCount(eventParam).getData();
Map<String, EventCount> eventMap = new HashMap<>();
if (CollUtil.isNotEmpty(eventCounts)) {
eventMap.putAll(eventCounts.stream().collect(Collectors.toMap(EventCount::getLineId, Function.identity())));
}
// 获取所有监测点的元信息
List<PollutionLineInfoDTO> lineInfoDTOList = commLineClient.getPollutionLineInfo(lineIdList).getData();
//获取监测点的数据完整性
OnlineRateParam onlineRateParam = new OnlineRateParam();
onlineRateParam.setStartTime(startDate);
onlineRateParam.setEndTime(endDate);
List<RStatIntegrityVO> integrityVOS = lineFeignClient.getOnIntegrityByIds(onlineRateParam).getData();
Map<String, Double> integrityMap = integrityVOS.stream().collect(Collectors.toMap(RStatIntegrityVO::getLineIndex, RStatIntegrityVO::getIntegrityRate));
//获取装置在线率
List<RStatOnlinerateVO> onLineRateVOS = generalDeviceInfoClient.getOnlineRateByDevIds(onlineRateParam).getData();
Map<String, Float> onlineRateMap = onLineRateVOS.stream().collect(Collectors.toMap(RStatOnlinerateVO::getDevIndex, RStatOnlinerateVO::getOnlineRate));
List<DictData> dictDataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.POLLUTION_CALC.getCode()).getData();
Map<String, String> dictData = dictDataList.stream().collect(Collectors.toMap(DictData::getCode, DictData::getId));
String vHarmonicLimit = dictData.get(DicDataEnum.V_HARMONIC_LIMIT.getCode());
String iAllLimit = dictData.get(DicDataEnum.I_ALL_LIMIT.getCode());
List<RMpPollutionDPO> rMpPollutionDPOS = rMpPollutionDPOMapper.selectSumList(lineIdList, Arrays.asList(vHarmonicLimit, iAllLimit), startDate, endDate);
Map<String, Double> calcMap = new HashMap<>();
if (CollUtil.isNotEmpty(rMpPollutionDPOS)) {
calcMap.putAll(rMpPollutionDPOS.stream().collect(Collectors.toMap(x -> x.getLineId() + "_" + x.getPollutionType(), RMpPollutionDPO::getValue)));
}
if (CollUtil.isNotEmpty(lineIdList)) {
// 获取谐波电压数据&总畸变率&越限限值计算基础污染值
for (int i = 0; i < lineIdList.size(); i++) {
String lineId = lineIdList.get(i);
LinePollution linePollution = new LinePollution();
linePollution.setLineId(lineId);
//获取监测点数据完整性
linePollution.setIntegrity(Objects.isNull(integrityMap.get(lineId)) ? 0.0 : integrityMap.get(lineId));
//获取监测点限值
Overlimit overlimit = commTerminalGeneralClient.getOverLimitData(lineId).getData();
LineDevGetDTO lineDetailData = commTerminalGeneralClient.getMonitorDetail(lineId).getData();
if (Objects.isNull(overlimit) || Objects.isNull(lineDetailData)) {
// 如果没有查到限值跳过,后期需要记录这种异常
continue;
}
linePollution.setLineName(lineDetailData.getPointName());
linePollution.setInterval(lineDetailData.getInterval());
// 计算谐波电压的污染值
linePollution.setVHarmonicValue(calcMap.containsKey(lineId+"_"+vHarmonicLimit)?calcMap.get(lineId+"_"+vHarmonicLimit):0.0);
// 计算谐波电流的污染值
linePollution.setIHarmonicValue(calcMap.containsKey(lineId+"_"+iAllLimit )?calcMap.get(lineId+"_"+iAllLimit):0.0);
// 获取暂态数据
BeanUtil.copyProperties(eventMap.get(lineId), linePollution);
//获取该监测点其他元信息
Optional<PollutionLineInfoDTO> any = lineInfoDTOList.stream().filter(item -> item.getLineId().equals(lineId)).findAny();
if (any.isPresent()) {
PollutionLineInfoDTO data = any.get();
BeanUtil.copyProperties(data, linePollution, true);
Float vo2 = onlineRateMap.get(data.getDeviceId());
linePollution.setOnlineRate(Objects.isNull(vo2) ? 0.0 : vo2);
}
linePollutionList.add(linePollution);
}
}
return linePollutionList;
}
@Override
public void downPollutionUserCalc(StatSubstationBizBaseParam param) {
// 处理干扰源用户的报告
String startDate = DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())).toString();
String endDate = DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())).toString();
List<LinePollution> loadTypeLineList = pollutionCalcList(startDate, endDate);
/**
* 1、首先过滤重要变电站、一类变电站、跨省计量关点 todo...待优化
* 2、过滤后以监测对象分组统计数据有多个测点的需要出结果
*/
List<String> loadTypeSubStation = Stream.of("重要变电站", "一类变电站", "跨省计量关点").collect(Collectors.toList());
loadTypeLineList = loadTypeLineList.stream().filter(item -> !loadTypeSubStation.contains(item.getLoadType())).collect(Collectors.toList());
// 监测对象分组
Map<String, List<LinePollution>> loadTypeMap = loadTypeLineList.stream().collect(Collectors.groupingBy(LinePollution::getObjName));
List<ObjPollution> objPollutions = new ArrayList<>();
Set<String> objNameSet = loadTypeMap.keySet();
for (String objName : objNameSet) {
ObjPollution objPollution = new ObjPollution();
List<LinePollution> linePollutions = loadTypeMap.get(objName);
objPollution.setObjName(linePollutions.get(0).getObjName());
objPollution.setLoadType(linePollutions.get(0).getLoadType());
// objPollution.setBusinessType(linePollutions.get(0).getBusinessType());
// 求出平均污染值
double objVValue = linePollutions.stream()
.mapToDouble(o -> o.getVHarmonicValue())
.sum();
objPollution.setObjVValue(PubUtils.doubleRound(2, objVValue) + "");
double objIValue = linePollutions.stream()
.mapToDouble(o -> o.getIHarmonicValue())
.sum();
objPollution.setObjIValue(PubUtils.doubleRound(2, objIValue) + "");
// 处理该监测对象下面监测点的信息
List<LoadTypeLineItemPollution> loadTypeLineItemPollutions = new ArrayList<>();
for (LinePollution linePollution : linePollutions) {
LoadTypeLineItemPollution loadTypeLineItemPollution = new LoadTypeLineItemPollution();
BeanUtil.copyProperties(linePollution, loadTypeLineItemPollution, true);
loadTypeLineItemPollutions.add(loadTypeLineItemPollution);
}
objPollution.setLineItemPollutionList(loadTypeLineItemPollutions);
objPollutions.add(objPollution);
}
// 排序
objPollutions= objPollutions.stream()
.sorted(Comparator.comparing(ObjPollution::getObjVValue).reversed())
.collect(Collectors.toList());
ExcelUtil.exportExcel("用户谐波电压污染值" + endDate + ".xlsx", ObjPollution.class, objPollutions);
}
@Override
public void downPollutionSubCalc(StatSubstationBizBaseParam param) {
// 处理干扰源用户的报告
String startDate = DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())).toString();
String endDate = DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())).toString();
List<LinePollution> linePollutionList = pollutionCalcList(startDate, endDate);
// 整合变电站待导出的数据
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.getVHarmonicValue())
.average()
.orElse(0.0);
// 电网侧污染值
powerFlagPollution1.setPowerVValue(PubUtils.doubleRound(2, subVValue) + "");
// 计算电网侧下所有监测点谐波电流平均污染值
double subIValue = temp.stream()
.mapToDouble(o -> o.getIHarmonicValue())
.average()
.orElse(0.0);
// 电网侧污染值
powerFlagPollution1.setPowerIValue(PubUtils.doubleRound(2, subIValue) + "");
// 设备信息
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.getVHarmonicValue())
.average()
.orElse(0.0);
// 电网侧污染值
powerFlagPollution2.setPowerVValue(PubUtils.doubleRound(2, subVValue) + "");
// 计算电网侧下所有监测点谐波电流平均污染值
double subIValue = temp1.stream()
.mapToDouble(o -> o.getIHarmonicValue())
.average()
.orElse(0.0);
// 电网侧污染值
powerFlagPollution2.setPowerIValue(PubUtils.doubleRound(2, subIValue) + "");
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);
}
// 针对这个供电公司下的变电站污染值排序
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("变电站谐波电压污染值" + endDate + ".xlsx", GdPollution.class, gdPollutionList);
}
private List<String> addList(List<RStatPollutionSubstationM> substationMlist) { private List<String> addList(List<RStatPollutionSubstationM> substationMlist) {
List<String> info = new ArrayList<>(); List<String> info = new ArrayList<>();