1.pms3.0主网基准水平和统计报表代码调整

This commit is contained in:
wr
2024-02-01 16:31:39 +08:00
parent 40e881d91f
commit e8e0572485
17 changed files with 188 additions and 98 deletions

View File

@@ -300,7 +300,7 @@
pdm.Terminal_Wiring_Method AS terminalWiringMethod
FROM
pms_distribution_monitor pdm
INNER JOIN pms_statation_stat ps ON ps.Power_Id = pdm.Power_Station_Id
LEFT JOIN pms_statation_stat ps ON ps.Power_Id = pdm.Power_Station_Id
<where>
<if test="ids!=null and ids.size()!=0">
pdm.Monitor_Id IN

View File

@@ -19,6 +19,7 @@ import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.dto.DeptDTO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.ListUtils;
import org.springframework.stereotype.Service;
import java.util.*;
@@ -100,7 +101,11 @@ public class IPwMonitorServiceImpl implements IPwMonitorService {
List<String> orgCodeList= deptInfos.stream().map(DeptDTO::getCode).collect(Collectors.toList());
List<PwPmsMonitorDTO> pwPmsMonitorDTOS = pwMonitorMapper.getPwMonitorDataNewList(orgCodeList,pwPmsMonitorParam.getIds(),pwPmsMonitorParam.getMonitorTag(), pwPmsMonitorParam);
List<String> ids = pwPmsMonitorDTOS.stream().map(PwPmsMonitorDTO::getMonitorId).collect(Collectors.toList());
List<PwPmsMonitorDTO> pwMonitorName = pwMonitorMapper.getPwMonitorName(ids, pwPmsMonitorParam.getMonitorName());
List<List<String>> pendingIds = ListUtils.partition(ids, 50000);
List<PwPmsMonitorDTO> pwMonitorName=new ArrayList<>();
for (List<String> pendingId : pendingIds) {
pwMonitorName.addAll(pwMonitorMapper.getPwMonitorName(pendingId, pwPmsMonitorParam.getMonitorName()));
}
Map<String, PwPmsMonitorDTO> monitorMap = pwPmsMonitorDTOS.stream().collect(Collectors.toMap(PwPmsMonitorDTO::getMonitorId, Function.identity()));
pwMonitorName.stream().forEach(x->{
if(monitorMap.containsKey(x.getMonitorId())){

View File

@@ -108,8 +108,8 @@ implements PwRMpMonitorAlarmCountMService {
lambdaQueryWrapper
.in(RMpMonitorAlarmCountM::getMeasurementPointId, pwMonitorIds)
.ge(RMpMonitorAlarmCountM::getDataDate, startTime)
.le(RMpMonitorAlarmCountM::getDataDate, endTime)
.eq(RMpMonitorAlarmCountM::getDataType, dataType);
.le(RMpMonitorAlarmCountM::getDataDate, endTime);
// .eq(RMpMonitorAlarmCountM::getDataType, dataType);
Page<RMpMonitorAlarmCountM> page = this.page(new Page<>(PageFactory.getPageNum(rMpMonitorAlarmCountMParam),PageFactory.getPageSize(rMpMonitorAlarmCountMParam)),lambdaQueryWrapper);
List<RMpMonitorAlarmCountM> alarmCountMList = page.getRecords();
List<PwRMpMonitorAlarmCountMVO> resultList;

View File

@@ -83,7 +83,7 @@ implements RMpPwAlarmDetailDService{
//获取配网监测点
PwPmsMonitorParam pwPmsMonitorParam = new PwPmsMonitorParam();
pwPmsMonitorParam.setOrgId(deptIndex); //单位id
List<PwPmsMonitorDTO> pwMonitorList = iPwMonitorService.getPwMonitorList(pwPmsMonitorParam);
List<PwPmsMonitorDTO> pwMonitorList = iPwMonitorService.getPwNewMonitorList(pwPmsMonitorParam);
//配网监测点id集合
List<String> pwMonitorIds = pwMonitorList.stream().map(PwPmsMonitorDTO::getMonitorId).collect(Collectors.toList());
//配网监测点Map集合

View File

@@ -243,10 +243,10 @@ public class StatationStatServiceImpl extends ServiceImpl<StatationStatMapper, S
@Override
public List<StatationStat> getPowerInfo(PmsStatationStatInfoParam param) {
LambdaQueryWrapper<StatationStat> lqw = new LambdaQueryWrapper<>();
lqw.in(param.getOrgIds() != null, StatationStat::getOrgId, param.getOrgIds());
lqw.in(param.getPowerIds() != null, StatationStat::getPowerId, param.getPowerIds());
lqw.like(param.getPowerName() != null, StatationStat::getPowerName, param.getPowerName());
lqw.in(param.getPowerVoltageLevel() != null, StatationStat::getVoltageLevel, param.getPowerVoltageLevel());
lqw.in(CollUtil.isNotEmpty(param.getOrgIds()) , StatationStat::getOrgId, param.getOrgIds());
lqw.in(CollUtil.isNotEmpty(param.getPowerIds()), StatationStat::getPowerId, param.getPowerIds());
lqw.like(StrUtil.isNotBlank(param.getPowerName()), StatationStat::getPowerName, param.getPowerName());
lqw.in(CollUtil.isNotEmpty(param.getPowerVoltageLevel()), StatationStat::getVoltageLevel, param.getPowerVoltageLevel());
return this.list(lqw);
}

View File

@@ -40,5 +40,25 @@ public class RStatEventMVO {
@ApiModelProperty(value = "累计发生暂态监测点数占比")
private Float eventMeasurementRatioAccrued;
@Data
public static class Vo{
@ApiModelProperty(value = "单位id")
private String orgId;
@ApiModelProperty(value = "单位名称")
private String orgName;
@ApiModelProperty(value = "指标类型")
private String eventType;
@ApiModelProperty(value = "暂降发生次数")
private Integer eventCount;
@ApiModelProperty(value = "暂升发生次数")
private Integer riseCount;
@ApiModelProperty(value = "短时中断次数")
private Integer interruptCount;
}
}

View File

@@ -9,6 +9,7 @@ import com.njcn.common.pojo.param.StatisticsBizBaseParam;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.event.pojo.param.REventMParam;
import com.njcn.event.pojo.param.StatSubstationBizBaseParam;
import com.njcn.event.pojo.vo.*;
import com.njcn.event.service.majornetwork.RStatEventMService;
import com.njcn.event.service.majornetwork.RStatEventQService;
@@ -18,6 +19,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -96,6 +98,17 @@ public class RStatEventController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rStatHarmonicIcon, methodDescribe);
}
/**
* 区域暂态电能质量水平评估
*/
@PostMapping("/getEventBenchmarkLevelList")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("区域暂态电能质量水平评估")
public HttpResult<List<RStatEventMVO.Vo>> getEventBenchmarkLevelList(StatSubstationBizBaseParam param) {
String methodDescribe = getMethodDescribe("getEventBenchmarkLevelList");
List<RStatEventMVO.Vo> eventBenchmarkLevelList = rStatEventYService.getEventBenchmarkLevelList(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventBenchmarkLevelList, methodDescribe);
}
}

View File

@@ -3,9 +3,11 @@ package com.njcn.event.mapper.majornetwork;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.event.pojo.param.StatSubstationBizBaseParam;
import com.njcn.event.pojo.po.RStatEventY;
import com.njcn.event.pojo.vo.RStatEventMVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* <p>
@@ -26,4 +28,20 @@ public interface RStatEventYMapper extends BaseMapper<RStatEventY> {
List<RStatEventY> selectInfoList(@Param("param") StatSubstationBizBaseParam param,
@Param("dataType") String dataType);
/**
* 监测点数据查询
*
* @param ids
* @param param
* @param map
* @param dataType
* @return
*/
List<RStatEventMVO.Vo> selectEventBenchmarkLevel(@Param("ids")List<String> ids,
@Param("param") StatSubstationBizBaseParam param,
@Param("map")Map<String, String> map,
@Param("dataType") String dataType);
}

View File

@@ -89,8 +89,8 @@
FROM
(
SELECT
duration,
feature_amplitude
duration * 1000 as duration,
feature_amplitude * 100 as feature_amplitude
FROM
r_mp_event_detail
WHERE
@@ -140,7 +140,7 @@
(
SELECT
measurement_point_id,
duration
duration*1000 as duration
FROM
r_mp_event_detail
WHERE
@@ -184,7 +184,7 @@
(
SELECT
measurement_point_id,
feature_amplitude
feature_amplitude * 100 as feature_amplitude
FROM
r_mp_event_detail
WHERE
@@ -383,8 +383,8 @@
FROM
(
SELECT
duration,
feature_amplitude
duration * 1000 as duration,
feature_amplitude * 100 as feature_amplitude
FROM
r_mp_event_detail
WHERE 1 = 1
@@ -403,7 +403,6 @@
<if test="startTime != null and startTime != ''">
AND DATE_FORMAT(start_time, '%Y-%m') &gt;= SUBSTRING(#{startTime}, 1, 7)
</if>
-- 没写错就是start_time SUBSTRING第二个参数代表第一个字符开始取7个字符
<if test="endTime != null and endTime != ''">
AND DATE_FORMAT(start_time, '%Y-%m') &lt;= SUBSTRING(#{endTime}, 1, 7)
</if>
@@ -435,8 +434,8 @@
FROM
(
SELECT
duration,
feature_amplitude
duration * 1000 as duration,
feature_amplitude * 100 as feature_amplitude
FROM
r_mp_event_detail
WHERE 1 = 1
@@ -444,7 +443,6 @@
<foreach collection="monitorIdList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
AND event_type IN
<foreach collection="eventTypeList" item="type" open="(" close=")" separator=",">
#{type}

View File

@@ -47,5 +47,46 @@
measurement_type_class,
event_type
</select>
<select id="selectEventBenchmarkLevel" resultType="com.njcn.event.pojo.vo.RStatEventMVO$Vo">
SELECT
org_no as orgId,
measurement_type_class,
SUM(IF(`event_type`=#{map.dip},event_count,0)) as eventCount,
SUM(IF(`event_type`=#{map.rise},event_count,0)) as riseCount,
SUM(IF(`event_type`=#{map.interrupt},event_count,0)) as interruptCount
FROM
<if test="param != null and param.type == 1">
r_stat_event_y
</if>
<if test="param != null and param.type == 2">
r_stat_event_q
</if>
<if test="param != null and param.type == 3">
r_stat_event_m
</if>
<where>
<if test="ids != null and ids.size > 0">
AND org_no IN
<foreach collection='ids' item='item' index="index" open='(' separator=',' close=')'>
#{item}
</foreach>
</if>
<if test="param != null and param.ids != null and param.ids.size > 0">
AND measurement_type_class IN
<foreach collection='param.ids' item='item' index="index" open='(' separator=',' close=')'>
#{item}
</foreach>
</if>
<if test="param!=null and param.startTime != null and param.startTime !=''">
AND data_date >= #{param.startTime}
</if>
<if test="param!=null and param.endTime != null and param.endTime != ''">
AND data_date &lt;= #{param.endTime}
</if>
</where>
GROUP BY
org_no,monitoring_object
</select>
</mapper>

View File

@@ -65,6 +65,7 @@
<if test="endTime != null and endTime != ''">
AND DATE_FORMAT(start_time, '%Y-%m') &lt;= SUBSTRING(#{endTime}, 1, 7)
</if>
order by start_time desc
</select>
<select id="getByEventId" resultType="com.njcn.event.pojo.po.RmpEventDetailPO">
SELECT

View File

@@ -422,7 +422,6 @@ public class EventMonitorReportServiceImpl implements EventMonitorReportService
pmsMonitorParam.setMonitorName(monitorName); //监测点名称
pmsMonitorParam.setOrgIds(orgCodeList); //单位codes
List<PmsMonitorDTO> monitorList = monitorClient.getMonitorInfoListByCond(pmsMonitorParam).getData(); //监测点信息
return monitorList;
}
}

View File

@@ -2,12 +2,10 @@ package com.njcn.event.service.majornetwork.Impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.param.StatisticsBizBaseParam;
import com.njcn.event.mapper.majornetwork.RStatEventYMapper;
import com.njcn.event.pojo.param.StatSubstationBizBaseParam;
import com.njcn.event.pojo.po.RStatEventM;
import com.njcn.event.pojo.po.RStatEventY;
import com.njcn.event.pojo.vo.RArrayVO;
import com.njcn.event.pojo.vo.RStatEventMVO;
@@ -18,7 +16,6 @@ import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.dto.DeptDTO;
import com.njcn.web.utils.RequestUtil;
import com.njcn.web.utils.WebUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@@ -209,6 +206,39 @@ public class RStatEventYServiceImpl extends ServiceImpl<RStatEventYMapper, RStat
return arrayVOList;
}
@Override
public List<RStatEventMVO.Vo> getEventBenchmarkLevelList(StatSubstationBizBaseParam param) {
//获取暂态信息
Map<String, String> map = new HashMap<>(3);
//获取主网监测点
DictData data = dicDataFeignClient.getDicDataByCode(DicDataEnum.MAINNET_POINT.getCode()).getData();
List<DictData> dictDataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
//获取所有子部门信息
List<DeptDTO> deptDTOList = deptFeignClient.getDeptDescendantIndexes(param.getId(), WebUtil.filterDeptType()).getData();
List<String> ids = deptDTOList.stream().map(DeptDTO::getCode).collect(Collectors.toList());
//根据字典Code取出字典id拼入sql中
dictDataList.stream().forEach(dictData -> {
if (DicDataEnum.VOLTAGE_DIP.getCode().equals(dictData.getCode())) {
map.put("dip", dictData.getId());
}
if (DicDataEnum.VOLTAGE_RISE.getCode().equals(dictData.getCode())) {
map.put("rise", dictData.getId());
}
if (DicDataEnum.SHORT_INTERRUPTIONS.getCode().equals(dictData.getCode())) {
map.put("interrupt", dictData.getId());
}
});
//数据分页查询
List<RStatEventMVO.Vo> vos = this.baseMapper.selectEventBenchmarkLevel(ids, param, map, data.getId());
Map<String, String> deptDTOMap = deptDTOList.stream().collect(Collectors.toMap(DeptDTO::getCode, DeptDTO::getName));
vos.forEach(vo -> {
if (deptDTOMap.containsKey(vo.getOrgId())) {
vo.setOrgName(deptDTOMap.get(vo.getOrgId()));
}
});
return vos;
}
/**
* 便利赋值
*

View File

@@ -2,8 +2,10 @@ package com.njcn.event.service.majornetwork;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.common.pojo.param.StatisticsBizBaseParam;
import com.njcn.event.pojo.param.StatSubstationBizBaseParam;
import com.njcn.event.pojo.po.RStatEventY;
import com.njcn.event.pojo.vo.RArrayVO;
import com.njcn.event.pojo.vo.RStatEventMVO;
import java.util.List;
@@ -32,4 +34,13 @@ public interface RStatEventYService extends IService<RStatEventY> {
* @return
*/
List<RArrayVO> getPwRStatEventYAll(StatisticsBizBaseParam param);
/**
* 区域暂态电能质量水平评估
*
* @param param
* @return
*/
List<RStatEventMVO.Vo> getEventBenchmarkLevelList(StatSubstationBizBaseParam param);
}

View File

@@ -127,9 +127,9 @@ implements RMpBenchmarkLevelMService {
return rMpBenchmarkLevelVO;
}).collect(Collectors.toList());
/*添加type在区分接口返回值*/
List<RMpBenchmarkLevelVO> finalList= new ArrayList<> ();
if(Objects.equals (rMpBenchmarkLevelParam.getReturnType (), "1")){
Map<String, List<RMpBenchmarkLevelVO>> collect = resultList.stream ( ).collect (Collectors.groupingBy (temp -> temp.getOrgName ( ) + temp.getVoltageLevel ()));
List<RMpBenchmarkLevelVO> finalList= new ArrayList<> ();
collect.forEach ((k, v) ->{
RMpBenchmarkLevelVO rMpBenchmarkLevelVO = new RMpBenchmarkLevelVO();
rMpBenchmarkLevelVO.setOrgName (v.get (0).getOrgName ());
@@ -172,27 +172,11 @@ implements RMpBenchmarkLevelMService {
finalList.add (rMpBenchmarkLevelVO);
});
}
if(CollUtil.isNotEmpty(finalList)){
finalList.sort(Comparator.comparing(x->x.getOrgName()+";"+x.getVoltageLevelName()));
}
return finalList;
}else if(
Objects.equals (rMpBenchmarkLevelParam.getReturnType (), "2")
){
Map<String, List<RMpBenchmarkLevelVO>> collect = resultList.stream ( ).collect (Collectors.groupingBy (temp -> temp.getOrgName ( ) + temp.getMonitorTag ()));
List<RMpBenchmarkLevelVO> finalList= new ArrayList<> ();
collect.forEach ((k, v) ->{
RMpBenchmarkLevelVO rMpBenchmarkLevelVO = new RMpBenchmarkLevelVO();
rMpBenchmarkLevelVO.setOrgName (v.get (0).getOrgName ());
rMpBenchmarkLevelVO.setMonitorTag (v.get (0).getMonitorTag ());
rMpBenchmarkLevelVO.setEventAvg (v.stream ().mapToDouble (RMpBenchmarkLevelVO::getEventAvg).sum ());
rMpBenchmarkLevelVO.setRiseAvg (v.stream ().mapToDouble (RMpBenchmarkLevelVO::getRiseAvg).sum ());
rMpBenchmarkLevelVO.setInterruptAvg (v.stream ().mapToDouble (RMpBenchmarkLevelVO::getInterruptAvg).sum ());
finalList.add (rMpBenchmarkLevelVO);
});
return finalList;
}
return resultList;
}
}

View File

@@ -127,9 +127,9 @@ implements RMpBenchmarkLevelQService {
return rMpBenchmarkLevelVO;
}).collect(Collectors.toList());
/*添加type在区分接口返回值*/
List<RMpBenchmarkLevelVO> finalList= new ArrayList<> ();
if(Objects.equals (rMpBenchmarkLevelParam.getReturnType (), "1")){
Map<String, List<RMpBenchmarkLevelVO>> collect = resultList.stream ( ).collect (Collectors.groupingBy (temp -> temp.getOrgName ( ) + temp.getVoltageLevel ()));
List<RMpBenchmarkLevelVO> finalList= new ArrayList<> ();
collect.forEach ((k, v) ->{
RMpBenchmarkLevelVO rMpBenchmarkLevelVO = new RMpBenchmarkLevelVO();
rMpBenchmarkLevelVO.setOrgName (v.get (0).getOrgName ());
@@ -173,26 +173,11 @@ implements RMpBenchmarkLevelQService {
finalList.add (rMpBenchmarkLevelVO);
});
return finalList;
}else if(
Objects.equals (rMpBenchmarkLevelParam.getReturnType (), "2")
){
Map<String, List<RMpBenchmarkLevelVO>> collect = resultList.stream ( ).collect (Collectors.groupingBy (temp -> temp.getOrgName ( ) + temp.getMonitorTag ()));
List<RMpBenchmarkLevelVO> finalList= new ArrayList<> ();
collect.forEach ((k, v) ->{
RMpBenchmarkLevelVO rMpBenchmarkLevelVO = new RMpBenchmarkLevelVO();
rMpBenchmarkLevelVO.setOrgName (v.get (0).getOrgName ());
rMpBenchmarkLevelVO.setMonitorTag (v.get (0).getMonitorTag ());
rMpBenchmarkLevelVO.setEventAvg (v.stream ().mapToDouble (RMpBenchmarkLevelVO::getEventAvg).sum ());
rMpBenchmarkLevelVO.setRiseAvg (v.stream ().mapToDouble (RMpBenchmarkLevelVO::getRiseAvg).sum ());
rMpBenchmarkLevelVO.setInterruptAvg (v.stream ().mapToDouble (RMpBenchmarkLevelVO::getInterruptAvg).sum ());
finalList.add (rMpBenchmarkLevelVO);
});
}
if(CollUtil.isNotEmpty(finalList)){
finalList.sort(Comparator.comparing(x->x.getOrgName()+";"+x.getVoltageLevelName()));
}
return finalList;
}
return resultList;
}
}

View File

@@ -128,9 +128,9 @@ implements RMpBenchmarkLevelYService {
return rMpBenchmarkLevelVO;
}).collect(Collectors.toList());
/*添加type在区分接口返回值*/
List<RMpBenchmarkLevelVO> finalList= new ArrayList<> ();
if(Objects.equals (rMpBenchmarkLevelParam.getReturnType (), "1")){
Map<String, List<RMpBenchmarkLevelVO>> collect = resultList.stream ( ).collect (Collectors.groupingBy (temp -> temp.getOrgName ( ) + temp.getVoltageLevel ()));
List<RMpBenchmarkLevelVO> finalList= new ArrayList<> ();
collect.forEach ((k, v) ->{
RMpBenchmarkLevelVO rMpBenchmarkLevelVO = new RMpBenchmarkLevelVO();
rMpBenchmarkLevelVO.setOrgName (v.get (0).getOrgName ());
@@ -174,26 +174,11 @@ implements RMpBenchmarkLevelYService {
finalList.add (rMpBenchmarkLevelVO);
});
return finalList;
}else if(
Objects.equals (rMpBenchmarkLevelParam.getReturnType (), "2")
){
Map<String, List<RMpBenchmarkLevelVO>> collect = resultList.stream ( ).collect (Collectors.groupingBy (temp -> temp.getOrgName ( ) + temp.getMonitorTag ()));
List<RMpBenchmarkLevelVO> finalList= new ArrayList<> ();
collect.forEach ((k, v) ->{
RMpBenchmarkLevelVO rMpBenchmarkLevelVO = new RMpBenchmarkLevelVO();
rMpBenchmarkLevelVO.setOrgName (v.get (0).getOrgName ());
rMpBenchmarkLevelVO.setMonitorTag (v.get (0).getMonitorTag ());
rMpBenchmarkLevelVO.setEventAvg (v.stream ().mapToDouble (RMpBenchmarkLevelVO::getEventAvg).sum ());
rMpBenchmarkLevelVO.setRiseAvg (v.stream ().mapToDouble (RMpBenchmarkLevelVO::getRiseAvg).sum ());
rMpBenchmarkLevelVO.setInterruptAvg (v.stream ().mapToDouble (RMpBenchmarkLevelVO::getInterruptAvg).sum ());
finalList.add (rMpBenchmarkLevelVO);
});
}
if(CollUtil.isNotEmpty(finalList)){
finalList.sort(Comparator.comparing(x->x.getOrgName()+";"+x.getVoltageLevelName()));
}
return finalList;
}
return resultList;
}
}