合并代码

This commit is contained in:
2022-11-21 17:58:18 +08:00
parent a4c225d067
commit a81a815636
65 changed files with 3828 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
package com.njcn.harmonic.service.distribution;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.harmonic.pojo.param.RMpBenchmarkLevelParam;
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelM;
import com.njcn.harmonic.pojo.vo.PwRMpBenchmarkLevelVO;
import java.util.List;
/**
* @author jianghf
* @description 针对表【r_mp_benchmark_level_m】的数据库操作Service
* @createDate 2022-10-11 10:32:18
*/
public interface PwRMpBenchmarkLevelMService extends IService<RMpBenchmarkLevelM> {
/***
* 配网-全网基准水平
* @author jianghaifei
* @date 2022-11-04 10:30
* @param rMpBenchmarkLevelParam
* @return java.util.List<com.njcn.harmonic.pojo.vo.RMpBenchmarkLevelVO>
*/
Page<PwRMpBenchmarkLevelVO> getPwRMpBenchmarkLevelList(RMpBenchmarkLevelParam rMpBenchmarkLevelParam);
}

View File

@@ -0,0 +1,25 @@
package com.njcn.harmonic.service.distribution;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.harmonic.pojo.param.RMpBenchmarkLevelParam;
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelQ;
import com.njcn.harmonic.pojo.vo.PwRMpBenchmarkLevelVO;
import java.util.List;
/**
* @author jianghf
* @description 针对表【r_mp_benchmark_level_q】的数据库操作Service
* @createDate 2022-10-11 10:32:18
*/
public interface PwRMpBenchmarkLevelQService extends IService<RMpBenchmarkLevelQ> {
/***
* 配网-全网基准水平
* @author jianghaifei
* @date 2022-11-04 10:31
* @param rMpBenchmarkLevelParam
* @return java.util.List<com.njcn.harmonic.pojo.vo.RMpBenchmarkLevelVO>
*/
Page<PwRMpBenchmarkLevelVO> getPwRMpBenchmarkLevelList(RMpBenchmarkLevelParam rMpBenchmarkLevelParam);
}

View File

@@ -0,0 +1,26 @@
package com.njcn.harmonic.service.distribution;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.harmonic.pojo.param.RMpBenchmarkLevelParam;
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelY;
import com.njcn.harmonic.pojo.vo.PwRMpBenchmarkLevelVO;
import java.util.List;
/**
* @author jianghf
* @description 针对表【r_mp_benchmark_level_y】的数据库操作Service
* @createDate 2022-10-11 10:32:18
*/
public interface PwRMpBenchmarkLevelYService extends IService<RMpBenchmarkLevelY> {
/***
* 配网-全网基准水平
* @author jianghaifei
* @date 2022-11-04 10:30
* @param rMpBenchmarkLevelParam
* @return java.util.List<com.njcn.harmonic.pojo.vo.RMpBenchmarkLevelVO>
*/
Page<PwRMpBenchmarkLevelVO> getPwRMpBenchmarkLevelList(RMpBenchmarkLevelParam rMpBenchmarkLevelParam);
}

View File

@@ -0,0 +1,27 @@
package com.njcn.harmonic.service.distribution;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.harmonic.pojo.param.RStatPwPermeabilityMParam;
import com.njcn.harmonic.pojo.po.RStatPwPermeabilityM;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.harmonic.pojo.vo.RStatPwPermeabilityMVO;
import java.util.List;
/**
* 各渗透率光伏台区基准水平
* @author jianghf
* @description 针对表【r_stat_pw_permeability_m】的数据库操作Service
* @createDate 2022-11-07 10:35:21
*/
public interface RStatPwPermeabilityMService extends IService<RStatPwPermeabilityM> {
/***
* 获取各渗透率光伏台区基准水平
* @author jianghaifei
* @date 2022-11-07 14:38
* @param rStatPwPermeabilityMParam
* @return java.util.List<com.njcn.harmonic.pojo.vo.RStatPwPermeabilityMVO>
*/
Page<RStatPwPermeabilityMVO> getPwPermeabilityList(RStatPwPermeabilityMParam rStatPwPermeabilityMParam);
}

View File

@@ -0,0 +1,103 @@
package com.njcn.harmonic.service.distribution.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.pms.api.PwMonitorClient;
import com.njcn.device.pms.pojo.dto.PwPmsMonitorDTO;
import com.njcn.device.pms.pojo.param.PwPmsMonitorParam;
import com.njcn.harmonic.mapper.distribution.PwRMpBenchmarkLevelMMapper;
import com.njcn.harmonic.pojo.param.RMpBenchmarkLevelParam;
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelM;
import com.njcn.harmonic.pojo.vo.PwRMpBenchmarkLevelVO;
import com.njcn.harmonic.service.distribution.PwRMpBenchmarkLevelMService;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author jianghf
* @description 针对表【r_mp_benchmark_level_m】的数据库操作Service实现
* @createDate 2022-10-11 10:32:18
*/
@Service
@RequiredArgsConstructor
public class PwRMpBenchmarkLevelMServiceImpl extends ServiceImpl<PwRMpBenchmarkLevelMMapper, RMpBenchmarkLevelM>
implements PwRMpBenchmarkLevelMService {
private final PwMonitorClient pwMonitorClient;
/***
* 配网-全网基准水平
* @author jianghaifei
* @date 2022-11-04 10:30
* @param rMpBenchmarkLevelParam
* @return java.util.List<com.njcn.harmonic.pojo.vo.RMpBenchmarkLevelVO>
*/
@Override
public Page<PwRMpBenchmarkLevelVO> getPwRMpBenchmarkLevelList(RMpBenchmarkLevelParam rMpBenchmarkLevelParam) {
//提取查询条件
String id = rMpBenchmarkLevelParam.getId(); //单位id
if (StringUtils.isBlank(id)) {
throw new BusinessException(CommonResponseEnum.NO_DATA, "单位id不可为空");
}
String startTime = rMpBenchmarkLevelParam.getStartTime(); //开始时间
String endTime = rMpBenchmarkLevelParam.getEndTime(); //截止时间
List <String> voltageLevelParamList = StringUtils.isNotBlank(rMpBenchmarkLevelParam.getVoltageLevel()) ? Arrays.asList(rMpBenchmarkLevelParam.getVoltageLevel().split(",")) : null; //电压等级
Integer pageNum = rMpBenchmarkLevelParam.getPageNum() != null && rMpBenchmarkLevelParam.getPageNum() != 0 ? rMpBenchmarkLevelParam.getPageNum() : 1; //页码
Integer pageSize = rMpBenchmarkLevelParam.getPageSize() != null && rMpBenchmarkLevelParam.getPageSize() != 0 ? rMpBenchmarkLevelParam.getPageSize() : 10; //页面尺寸
//根据条件查询单位下面的所有配网监测点
PwPmsMonitorParam pwPmsMonitorParam = new PwPmsMonitorParam();
pwPmsMonitorParam.setOrgId(id); //单位id
pwPmsMonitorParam.setVoltageLevels(voltageLevelParamList); //电压等级
List<PwPmsMonitorDTO> pwMonitorList = pwMonitorClient.getPwMonitorList(pwPmsMonitorParam).getData();
if (CollUtil.isEmpty(pwMonitorList)) {
return new Page<>();
}
//监测点id集合
List<String> monitorIdList = pwMonitorList.stream().map(PwPmsMonitorDTO::getMonitorId).collect(Collectors.toList());
//监测点map key:监测点id value:监测点实体
Map<String, PwPmsMonitorDTO> monitorMap = pwMonitorList.stream().collect(Collectors.toMap(PwPmsMonitorDTO::getMonitorId, monitor -> monitor));
//查询【基准水平-月】数据
/*组装条件where measurement_point_id in (monitorIdList) and data_date >= startTime
and data_date <= endTime and voltage_level
*/
LambdaQueryWrapper<RMpBenchmarkLevelM> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(CollUtil.isNotEmpty(monitorIdList), RMpBenchmarkLevelM::getMeasurementPointId, monitorIdList)
.ge(StringUtils.isNotBlank(startTime), RMpBenchmarkLevelM::getDataDate, startTime)
.le(StringUtils.isNotBlank(endTime), RMpBenchmarkLevelM::getDataDate, endTime);
Page<RMpBenchmarkLevelM> listPage = this.page(new Page<>(pageNum, pageSize), lambdaQueryWrapper);
List<PwRMpBenchmarkLevelVO> resultList = listPage.getRecords().stream().map(item -> {
//封装前端需要的对象
PwRMpBenchmarkLevelVO rMpBenchmarkLevelVO = new PwRMpBenchmarkLevelVO();
BeanUtils.copyProperties(item, rMpBenchmarkLevelVO);
//单位信息
rMpBenchmarkLevelVO.setOrgNo(monitorMap.get(item.getMeasurementPointId()).getOrgId()); //单位id
rMpBenchmarkLevelVO.setOrgName(monitorMap.get(item.getMeasurementPointId()).getOrgName()); //单位名称
//监测点信息
rMpBenchmarkLevelVO.setMeasurementPointName(monitorMap.get(item.getMeasurementPointId()).getMonitorName()); //监测点名称
//电压等级
rMpBenchmarkLevelVO.setVoltageLevel(monitorMap.get(item.getMeasurementPointId()).getVoltageLevel());
return rMpBenchmarkLevelVO;
}).collect(Collectors.toList());
Page<PwRMpBenchmarkLevelVO> resultPage = new Page<>();
BeanUtils.copyProperties(listPage, resultPage);
resultPage.setRecords(resultList);
return resultPage;
}
}

View File

@@ -0,0 +1,103 @@
package com.njcn.harmonic.service.distribution.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.pms.api.PwMonitorClient;
import com.njcn.device.pms.pojo.dto.PwPmsMonitorDTO;
import com.njcn.device.pms.pojo.param.PwPmsMonitorParam;
import com.njcn.harmonic.mapper.distribution.PwRMpBenchmarkLevelQMapper;
import com.njcn.harmonic.pojo.param.RMpBenchmarkLevelParam;
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelM;
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelQ;
import com.njcn.harmonic.pojo.vo.PwRMpBenchmarkLevelVO;
import com.njcn.harmonic.service.distribution.PwRMpBenchmarkLevelQService;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author jianghf
* @description 针对表【r_mp_benchmark_level_q】的数据库操作Service实现
* @createDate 2022-10-11 10:32:18
*/
@Service
@RequiredArgsConstructor
public class PwRMpBenchmarkLevelQServiceImpl extends ServiceImpl<PwRMpBenchmarkLevelQMapper, RMpBenchmarkLevelQ>
implements PwRMpBenchmarkLevelQService {
private final PwMonitorClient pwMonitorClient;
/***
* 配网-全网基准水平
* @author jianghaifei
* @date 2022-11-04 10:31
* @param rMpBenchmarkLevelParam
* @return java.util.List<com.njcn.harmonic.pojo.vo.RMpBenchmarkLevelVO>
*/
@Override
public Page<PwRMpBenchmarkLevelVO> getPwRMpBenchmarkLevelList(RMpBenchmarkLevelParam rMpBenchmarkLevelParam) {
//提取查询条件
String id = rMpBenchmarkLevelParam.getId(); //单位id
if (StringUtils.isBlank(id)) {
throw new BusinessException(CommonResponseEnum.NO_DATA, "单位id不可为空");
}
String startTime = rMpBenchmarkLevelParam.getStartTime(); //开始时间
String endTime = rMpBenchmarkLevelParam.getEndTime(); //截止时间
List <String> voltageLevelParamList = StringUtils.isNotBlank(rMpBenchmarkLevelParam.getVoltageLevel()) ? Arrays.asList(rMpBenchmarkLevelParam.getVoltageLevel().split(",")) : null; //电压等级
Integer pageNum = rMpBenchmarkLevelParam.getPageNum() != null && rMpBenchmarkLevelParam.getPageNum() != 0 ? rMpBenchmarkLevelParam.getPageNum() : 1; //页码
Integer pageSize = rMpBenchmarkLevelParam.getPageSize() != null && rMpBenchmarkLevelParam.getPageSize() != 0 ? rMpBenchmarkLevelParam.getPageSize() : 10; //页面尺寸
//根据条件查询单位下面的所有配网监测点
PwPmsMonitorParam pwPmsMonitorParam = new PwPmsMonitorParam();
pwPmsMonitorParam.setOrgId(id); //单位id
pwPmsMonitorParam.setVoltageLevels(voltageLevelParamList); //电压等级
List<PwPmsMonitorDTO> pwMonitorList = pwMonitorClient.getPwMonitorList(pwPmsMonitorParam).getData();
if (CollUtil.isEmpty(pwMonitorList)) {
return new Page<>();
}
//监测点id集合
List<String> monitorIdList = pwMonitorList.stream().map(PwPmsMonitorDTO::getMonitorId).collect(Collectors.toList());
//监测点map key:监测点id value:监测点实体
Map<String, PwPmsMonitorDTO> monitorMap = pwMonitorList.stream().collect(Collectors.toMap(PwPmsMonitorDTO::getMonitorId, monitor -> monitor));
//查询【基准水平-季】数据
/*组装条件where measurement_point_id in (monitorIdList) and data_date >= startTime
and data_date <= endTime and voltage_level
*/
LambdaQueryWrapper<RMpBenchmarkLevelQ> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(CollUtil.isNotEmpty(monitorIdList), RMpBenchmarkLevelQ::getMeasurementPointId, monitorIdList)
.ge(StringUtils.isNotBlank(startTime), RMpBenchmarkLevelQ::getDataDate, startTime)
.le(StringUtils.isNotBlank(endTime), RMpBenchmarkLevelQ::getDataDate, endTime);
Page<RMpBenchmarkLevelQ> listPage = this.page(new Page<>(pageNum, pageSize), lambdaQueryWrapper);
List<PwRMpBenchmarkLevelVO> resultList = listPage.getRecords().stream().map(item -> {
//封装前端需要的对象
PwRMpBenchmarkLevelVO rMpBenchmarkLevelVO = new PwRMpBenchmarkLevelVO();
BeanUtils.copyProperties(item, rMpBenchmarkLevelVO);
//单位信息
rMpBenchmarkLevelVO.setOrgNo(monitorMap.get(item.getMeasurementPointId()).getOrgId()); //单位id
rMpBenchmarkLevelVO.setOrgName(monitorMap.get(item.getMeasurementPointId()).getOrgName()); //单位名称
//监测点信息
rMpBenchmarkLevelVO.setMeasurementPointName(monitorMap.get(item.getMeasurementPointId()).getMonitorName()); //监测点名称
//电压等级
rMpBenchmarkLevelVO.setVoltageLevel(monitorMap.get(item.getMeasurementPointId()).getVoltageLevel());
return rMpBenchmarkLevelVO;
}).collect(Collectors.toList());
Page<PwRMpBenchmarkLevelVO> resultPage = new Page<>();
BeanUtils.copyProperties(listPage, resultPage);
resultPage.setRecords(resultList);
return resultPage;
}
}

View File

@@ -0,0 +1,105 @@
package com.njcn.harmonic.service.distribution.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.pms.api.PwMonitorClient;
import com.njcn.device.pms.pojo.dto.PwPmsMonitorDTO;
import com.njcn.device.pms.pojo.param.PwPmsMonitorParam;
import com.njcn.harmonic.mapper.distribution.PwRMpBenchmarkLevelYMapper;
import com.njcn.harmonic.pojo.param.RMpBenchmarkLevelParam;
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelQ;
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelY;
import com.njcn.harmonic.pojo.vo.PwRMpBenchmarkLevelVO;
import com.njcn.harmonic.service.distribution.PwRMpBenchmarkLevelYService;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author jianghf
* @description 针对表【r_mp_benchmark_level_y】的数据库操作Service实现
* @createDate 2022-10-11 10:32:18
*/
@Service
@RequiredArgsConstructor
public class PwRMpBenchmarkLevelYServiceImpl extends ServiceImpl<PwRMpBenchmarkLevelYMapper, RMpBenchmarkLevelY>
implements PwRMpBenchmarkLevelYService {
private final PwMonitorClient pwMonitorClient;
/***
* 配网-全网基准水平
* @author jianghaifei
* @date 2022-11-04 10:32
* @param rMpBenchmarkLevelParam
* @return java.util.List<com.njcn.harmonic.pojo.vo.RMpBenchmarkLevelVO>
*/
@Override
public Page<PwRMpBenchmarkLevelVO> getPwRMpBenchmarkLevelList(RMpBenchmarkLevelParam rMpBenchmarkLevelParam) {
//提取查询条件
String id = rMpBenchmarkLevelParam.getId(); //单位id
if (StringUtils.isBlank(id)) {
throw new BusinessException(CommonResponseEnum.NO_DATA, "单位id不可为空");
}
String startTime = rMpBenchmarkLevelParam.getStartTime(); //开始时间
String endTime = rMpBenchmarkLevelParam.getEndTime(); //截止时间
List <String> voltageLevelParamList = StringUtils.isNotBlank(rMpBenchmarkLevelParam.getVoltageLevel()) ? Arrays.asList(rMpBenchmarkLevelParam.getVoltageLevel().split(",")) : null; //电压等级
Integer pageNum = rMpBenchmarkLevelParam.getPageNum() != null && rMpBenchmarkLevelParam.getPageNum() != 0 ? rMpBenchmarkLevelParam.getPageNum() : 1; //页码
Integer pageSize = rMpBenchmarkLevelParam.getPageSize() != null && rMpBenchmarkLevelParam.getPageSize() != 0 ? rMpBenchmarkLevelParam.getPageSize() : 10; //页面尺寸
//根据条件查询单位下面的所有配网监测点
PwPmsMonitorParam pwPmsMonitorParam = new PwPmsMonitorParam();
pwPmsMonitorParam.setOrgId(id); //单位id
pwPmsMonitorParam.setVoltageLevels(voltageLevelParamList); //电压等级
List<PwPmsMonitorDTO> pwMonitorList = pwMonitorClient.getPwMonitorList(pwPmsMonitorParam).getData();
if (CollUtil.isEmpty(pwMonitorList)) {
return new Page<>();
}
//监测点id集合
List<String> monitorIdList = pwMonitorList.stream().map(PwPmsMonitorDTO::getMonitorId).collect(Collectors.toList());
//监测点map key:监测点id value:监测点实体
Map<String, PwPmsMonitorDTO> monitorMap = pwMonitorList.stream().collect(Collectors.toMap(PwPmsMonitorDTO::getMonitorId, monitor -> monitor));
//查询【基准水平-年】数据
/*组装条件where measurement_point_id in (monitorIdList) and data_date >= startTime
and data_date <= endTime and voltage_level
*/
LambdaQueryWrapper<RMpBenchmarkLevelY> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(CollUtil.isNotEmpty(monitorIdList), RMpBenchmarkLevelY::getMeasurementPointId, monitorIdList)
.ge(StringUtils.isNotBlank(startTime), RMpBenchmarkLevelY::getDataDate, startTime)
.le(StringUtils.isNotBlank(endTime), RMpBenchmarkLevelY::getDataDate, endTime);
Page<RMpBenchmarkLevelY> listPage = this.page(new Page<>(pageNum, pageSize), lambdaQueryWrapper);
List<PwRMpBenchmarkLevelVO> resultList = listPage.getRecords().stream().map(item -> {
//封装前端需要的对象
PwRMpBenchmarkLevelVO rMpBenchmarkLevelVO = new PwRMpBenchmarkLevelVO();
BeanUtils.copyProperties(item, rMpBenchmarkLevelVO);
//单位信息
rMpBenchmarkLevelVO.setOrgNo(monitorMap.get(item.getMeasurementPointId()).getOrgId()); //单位id
rMpBenchmarkLevelVO.setOrgName(monitorMap.get(item.getMeasurementPointId()).getOrgName()); //单位名称
//监测点信息
rMpBenchmarkLevelVO.setMeasurementPointName(monitorMap.get(item.getMeasurementPointId()).getMonitorName()); //监测点名称
//电压等级
rMpBenchmarkLevelVO.setVoltageLevel(monitorMap.get(item.getMeasurementPointId()).getVoltageLevel());
return rMpBenchmarkLevelVO;
}).collect(Collectors.toList());
Page<PwRMpBenchmarkLevelVO> resultPage = new Page<>();
BeanUtils.copyProperties(listPage, resultPage);
resultPage.setRecords(resultList);
return resultPage;
}
}

View File

@@ -0,0 +1,91 @@
package com.njcn.harmonic.service.distribution.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.device.pms.api.PwMonitorClient;
import com.njcn.device.pms.pojo.dto.PwPmsMonitorDTO;
import com.njcn.device.pms.pojo.param.PwPmsMonitorParam;
import com.njcn.harmonic.mapper.distribution.RStatPwPermeabilityMMapper;
import com.njcn.harmonic.pojo.param.RStatPwPermeabilityMParam;
import com.njcn.harmonic.pojo.po.RStatPwPermeabilityM;
import com.njcn.harmonic.pojo.vo.RStatPwPermeabilityMVO;
import com.njcn.harmonic.service.distribution.RStatPwPermeabilityMService;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 各渗透率光伏台区基准水平
* @author jianghf
* @description 针对表【r_stat_pw_permeability_m】的数据库操作Service实现
* @createDate 2022-11-07 10:35:21
*/
@Service
@RequiredArgsConstructor
public class RStatPwPermeabilityMServiceImpl extends ServiceImpl<RStatPwPermeabilityMMapper, RStatPwPermeabilityM>
implements RStatPwPermeabilityMService{
private final PwMonitorClient pwMonitorClient;
private final DicDataFeignClient dicDataFeignClient;
/***
* 获取各渗透率光伏台区基准水平
* @author jianghaifei
* @date 2022-11-07 14:38
* @param rStatPwPermeabilityMParam
* @return java.util.List<com.njcn.harmonic.pojo.vo.RStatPwPermeabilityMVO>
*/
@Override
public Page<RStatPwPermeabilityMVO> getPwPermeabilityList(RStatPwPermeabilityMParam rStatPwPermeabilityMParam) {
//提起参数
String id = rStatPwPermeabilityMParam.getId(); //单位id
String psrName = rStatPwPermeabilityMParam.getPsrName(); //台区名称
String startTime = rStatPwPermeabilityMParam.getStartTime(); //开始时间
String endTime = rStatPwPermeabilityMParam.getEndTime(); //结束时间
Integer pageNum = rStatPwPermeabilityMParam.getPageNum() != null && rStatPwPermeabilityMParam.getPageNum() != 0 ? rStatPwPermeabilityMParam.getPageNum() : 1; //页码
Integer pageSize = rStatPwPermeabilityMParam.getPageSize() != null && rStatPwPermeabilityMParam.getPageSize() != 0 ? rStatPwPermeabilityMParam.getPageSize() : 10; //页面尺寸
//根据条件查询单位下面的所有配网监测点
PwPmsMonitorParam pwPmsMonitorParam = new PwPmsMonitorParam();
pwPmsMonitorParam.setOrgId(id); //单位id
pwPmsMonitorParam.setMonitorName(psrName); //台区名称(监测点名称)
List<PwPmsMonitorDTO> pwMonitorList = pwMonitorClient.getPwMonitorList(pwPmsMonitorParam).getData();
if (CollUtil.isEmpty(pwMonitorList)) {
return new Page<>();
}
//监测点id集合
List<String> monitorIdList = pwMonitorList.stream().map(PwPmsMonitorDTO::getMonitorId).collect(Collectors.toList());
//监测点map key:监测点id value:监测点实体
Map<String, PwPmsMonitorDTO> monitorMap = pwMonitorList.stream().collect(Collectors.toMap(PwPmsMonitorDTO::getMonitorId, monitor -> monitor));
//获取各渗透率字典
List<DictData> rateList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.PERMEABILITY_TYPE.getCode()).getData();
Map<String, Object> condMap = rateList.stream().collect(Collectors.toMap(DictData::getCode, DictData::getId));
condMap.put("startTime", startTime);
condMap.put("endTime", endTime);
condMap.put("idList", monitorIdList);
Page<RStatPwPermeabilityMVO> listPage = this.baseMapper.getPwPermeabilityList(new Page<>(pageNum, pageSize), condMap);
List<RStatPwPermeabilityMVO> list = listPage.getRecords().stream().peek(item -> {
item.setOrgName(monitorMap.get(item.getPsrId()).getOrgName()); //单位名称
item.setPsrName(monitorMap.get(item.getPsrId()).getMonitorName()); //台区名称
}).collect(Collectors.toList());
listPage.setRecords(list);
return listPage;
}
}

View File

@@ -0,0 +1,25 @@
package com.njcn.harmonic.service.majornetwork;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.harmonic.pojo.param.RMpBenchmarkLevelParam;
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelM;
import com.njcn.harmonic.pojo.vo.RMpBenchmarkLevelVO;
import java.util.List;
/**
* @author jianghf
* @description 针对表【r_mp_benchmark_level_m】的数据库操作Service
* @createDate 2022-10-11 10:32:18
*/
public interface RMpBenchmarkLevelMService extends IService<RMpBenchmarkLevelM> {
/***
* 查询区域稳态电能质量水平(月)
* @author jianghaifei
* @date 2022-10-11 11:26
* @param rMpBenchmarkLevelParam
* @return java.util.List<com.njcn.device.pms.pojo.po.RMpBenchmarkLevelM>
*/
List<RMpBenchmarkLevelVO> getRMpBenchmarkLevelList(RMpBenchmarkLevelParam rMpBenchmarkLevelParam);
}

View File

@@ -0,0 +1,26 @@
package com.njcn.harmonic.service.majornetwork;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.harmonic.pojo.param.RMpBenchmarkLevelParam;
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelQ;
import com.njcn.harmonic.pojo.vo.RMpBenchmarkLevelVO;
import java.util.List;
/**
* @author jianghf
* @description 针对表【r_mp_benchmark_level_q】的数据库操作Service
* @createDate 2022-10-11 10:32:18
*/
public interface RMpBenchmarkLevelQService extends IService<RMpBenchmarkLevelQ> {
/***
* 主网-区域稳态电能质量水平评估
* @author jianghaifei
* @date 2022-11-04 10:30
* @param rMpBenchmarkLevelParam
* @return java.util.List<com.njcn.harmonic.pojo.vo.RMpBenchmarkLevelVO>
*/
List<RMpBenchmarkLevelVO> getRMpBenchmarkLevelList(RMpBenchmarkLevelParam rMpBenchmarkLevelParam);
}

View File

@@ -0,0 +1,26 @@
package com.njcn.harmonic.service.majornetwork;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.harmonic.pojo.param.RMpBenchmarkLevelParam;
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelY;
import com.njcn.harmonic.pojo.vo.RMpBenchmarkLevelVO;
import java.util.List;
/**
* @author jianghf
* @description 针对表【r_mp_benchmark_level_y】的数据库操作Service
* @createDate 2022-10-11 10:32:18
*/
public interface RMpBenchmarkLevelYService extends IService<RMpBenchmarkLevelY> {
/***
* 主网-区域稳态电能质量水平评估
* @author jianghaifei
* @date 2022-11-04 10:30
* @param rMpBenchmarkLevelParam
* @return java.util.List<com.njcn.harmonic.pojo.vo.RMpBenchmarkLevelVO>
*/
List<RMpBenchmarkLevelVO> getRMpBenchmarkLevelList(RMpBenchmarkLevelParam rMpBenchmarkLevelParam);
}

View File

@@ -0,0 +1,133 @@
package com.njcn.harmonic.service.majornetwork.impl;
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.dto.SimpleDTO;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.pms.api.MonitorClient;
import com.njcn.device.pms.api.PmsGeneralDeviceInfoClient;
import com.njcn.device.pms.api.PwMonitorClient;
import com.njcn.device.pms.pojo.dto.PmsGeneralDeviceDTO;
import com.njcn.device.pms.pojo.dto.PmsMonitorInfoDTO;
import com.njcn.device.pms.pojo.param.PmsDeviceInfoParam;
import com.njcn.device.pms.pojo.param.PmsMonitorInfoParam;
import com.njcn.harmonic.mapper.majornetwork.RMpBenchmarkLevelMMapper;
import com.njcn.harmonic.pojo.param.RMpBenchmarkLevelParam;
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelM;
import com.njcn.harmonic.pojo.vo.RMpBenchmarkLevelVO;
import com.njcn.harmonic.service.majornetwork.RMpBenchmarkLevelMService;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author jianghf
* @description 针对表【r_mp_benchmark_level_m】的数据库操作Service实现
* @createDate 2022-10-11 10:32:18
*/
@Service
@RequiredArgsConstructor
public class RMpBenchmarkLevelMServiceImpl extends ServiceImpl<RMpBenchmarkLevelMMapper, RMpBenchmarkLevelM>
implements RMpBenchmarkLevelMService {
private final DicDataFeignClient dicDataFeignClient;
private final PmsGeneralDeviceInfoClient pmsGeneralDeviceInfoClient;
private final MonitorClient monitorClient;
private final PwMonitorClient pwMonitorClient;
@Override
public List<RMpBenchmarkLevelVO> getRMpBenchmarkLevelList(RMpBenchmarkLevelParam rMpBenchmarkLevelParam) {
//提取查询条件
String id = rMpBenchmarkLevelParam.getId(); //单位id
if (StringUtils.isBlank(id)) {
throw new BusinessException(CommonResponseEnum.NO_DATA, "单位id不可为空");
}
String startTime = rMpBenchmarkLevelParam.getStartTime(); //开始时间
String endTime = rMpBenchmarkLevelParam.getEndTime(); //截止时间
String benchmarkIndicator = rMpBenchmarkLevelParam.getBenchmarkIndicator(); //评价指标
List <String> voltageLevelParamList = StringUtils.isNotBlank(rMpBenchmarkLevelParam.getVoltageLevel()) ? Arrays.asList(rMpBenchmarkLevelParam.getVoltageLevel().split(",")) : null; //电压等级
//获取电压等级的字典
List<DictData> voltageLevelList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
//将电压信息转成mapkeyid valuename
Map<String, String> voltageLevelMap = voltageLevelList.stream().collect(Collectors.toMap(DictData::getId, DictData::getName));
//获取基准水平评价指标字典
List<DictData> benchmarkIndicatorList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.BENCHMARK_INDICATORS.getCode()).getData();
//将基准水平评价指标信息转成mapkeyid valuename
Map<String, String> benchmarkIndicatorMap = benchmarkIndicatorList.stream().collect(Collectors.toMap(DictData::getId, DictData::getName));
//查询所有子单位下的所有监测点
PmsDeviceInfoParam pmsDeviceInfoParam = new PmsDeviceInfoParam(id);
pmsDeviceInfoParam.setStatisticalType(new SimpleDTO());
if (CollUtil.isNotEmpty(voltageLevelParamList)) {
//查询条件电压等级筛选电压等级为voltageLevel的监测点
List<SimpleDTO> simpleDTOList = voltageLevelParamList.stream().map(item -> {
SimpleDTO simpleDTO = new SimpleDTO();
simpleDTO.setId(item);
return simpleDTO;
}).collect(Collectors.toList());
pmsDeviceInfoParam.setVoltageLevel(simpleDTOList);
}
//获取到该部门的所有子部门的监测点idList
List<PmsGeneralDeviceDTO> pmsDeviceInfoWithInOrg = pmsGeneralDeviceInfoClient.getPmsDeviceInfoWithInOrg(pmsDeviceInfoParam).getData();
//过滤出业务需要的监测点id集合
List<String> firstMonitorIdList = new ArrayList<>(); //只用于合并多个部门的监测点id
pmsDeviceInfoWithInOrg.forEach(item -> firstMonitorIdList.addAll(item.getMonitorIdList()));
List<String> lastMonitorIdList = firstMonitorIdList.stream().distinct().collect(Collectors.toList()); //最终的监测点id集合
//如果没有监测点id信息直接返回空集合
if (CollUtil.isEmpty(lastMonitorIdList)) {
return new ArrayList<>();
}
//查询对应的监测点完整信息 并转为key监测点id value监测点实体的map集合
// LambdaQueryWrapper<Monitor> monitorWrapper = new LambdaQueryWrapper<>();
// monitorWrapper.in(Monitor::getId, lastMonitorIdList);
PmsMonitorInfoParam pmsMonitorInfoParam = new PmsMonitorInfoParam();
pmsMonitorInfoParam.setMonitorIds(lastMonitorIdList);
Map<String, PmsMonitorInfoDTO> monitorMap = monitorClient.getMonitorInfo(pmsMonitorInfoParam).getData().stream().collect(Collectors.toMap(PmsMonitorInfoDTO::getMonitorId, monitor -> monitor));
//查询【基准水平-月】数据
/*组装条件where measurement_point_id in (monitorIdList) and data_date >= startTime
and data_date <= endTime and voltage_level
*/
LambdaQueryWrapper<RMpBenchmarkLevelM> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(CollUtil.isNotEmpty(lastMonitorIdList), RMpBenchmarkLevelM::getMeasurementPointId, lastMonitorIdList)
.ge(StringUtils.isNotBlank(startTime), RMpBenchmarkLevelM::getDataDate, startTime)
.le(StringUtils.isNotBlank(endTime), RMpBenchmarkLevelM::getDataDate, endTime);
List<RMpBenchmarkLevelM> list = this.list(lambdaQueryWrapper);
List<RMpBenchmarkLevelVO> resultList = list.stream().map(item -> {
//封装前端需要的对象
RMpBenchmarkLevelVO rMpBenchmarkLevelVO = new RMpBenchmarkLevelVO();
BeanUtils.copyProperties(item, rMpBenchmarkLevelVO);
PmsGeneralDeviceDTO pmsGeneralDeviceDTO = pmsDeviceInfoWithInOrg.stream().filter(dto -> dto.getMonitorIdList().contains(item.getMeasurementPointId()))
.collect(Collectors.toList()).get(0);
//单位信息
rMpBenchmarkLevelVO.setOrgNo(pmsGeneralDeviceDTO.getIndex()); //单位id
rMpBenchmarkLevelVO.setOrgName(pmsGeneralDeviceDTO.getName()); //单位名称
//基准水平评价指标
rMpBenchmarkLevelVO.setBenchmarkIndicator(benchmarkIndicator); //基准水平评价指标id
rMpBenchmarkLevelVO.setBenchmarkIndicatorName(benchmarkIndicatorMap.get(benchmarkIndicator)); //基准水平评价指标
//监测点信息
rMpBenchmarkLevelVO.setMeasurementPointName(monitorMap.get(item.getMeasurementPointId()).getMonitorName()); //监测点名称
//电压等级
rMpBenchmarkLevelVO.setVoltageLevel(monitorMap.get(item.getMeasurementPointId()).getMonitorVoltageLevel());
rMpBenchmarkLevelVO.setVoltageLevelName(voltageLevelMap.get(monitorMap.get(item.getMeasurementPointId()).getMonitorVoltageLevel()));
return rMpBenchmarkLevelVO;
}).collect(Collectors.toList());
return resultList;
}
}

View File

@@ -0,0 +1,133 @@
package com.njcn.harmonic.service.majornetwork.impl;
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.dto.SimpleDTO;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.pms.api.MonitorClient;
import com.njcn.device.pms.api.PmsGeneralDeviceInfoClient;
import com.njcn.device.pms.api.PwMonitorClient;
import com.njcn.device.pms.pojo.dto.PmsGeneralDeviceDTO;
import com.njcn.device.pms.pojo.dto.PmsMonitorInfoDTO;
import com.njcn.device.pms.pojo.param.PmsDeviceInfoParam;
import com.njcn.device.pms.pojo.param.PmsMonitorInfoParam;
import com.njcn.harmonic.mapper.majornetwork.RMpBenchmarkLevelQMapper;
import com.njcn.harmonic.pojo.param.RMpBenchmarkLevelParam;
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelQ;
import com.njcn.harmonic.pojo.vo.RMpBenchmarkLevelVO;
import com.njcn.harmonic.service.majornetwork.RMpBenchmarkLevelQService;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author jianghf
* @description 针对表【r_mp_benchmark_level_q】的数据库操作Service实现
* @createDate 2022-10-11 10:32:18
*/
@Service
@RequiredArgsConstructor
public class RMpBenchmarkLevelQServiceImpl extends ServiceImpl<RMpBenchmarkLevelQMapper, RMpBenchmarkLevelQ>
implements RMpBenchmarkLevelQService {
private final DicDataFeignClient dicDataFeignClient;
private final PmsGeneralDeviceInfoClient pmsGeneralDeviceInfoClient;
private final MonitorClient monitorClient;
private final PwMonitorClient pwMonitorClient;
@Override
public List<RMpBenchmarkLevelVO> getRMpBenchmarkLevelList(RMpBenchmarkLevelParam rMpBenchmarkLevelParam) {
//提取查询条件
String id = rMpBenchmarkLevelParam.getId(); //单位id
if (StringUtils.isBlank(id)) {
throw new BusinessException(CommonResponseEnum.NO_DATA, "单位id不可为空");
}
String startTime = rMpBenchmarkLevelParam.getStartTime(); //开始时间
String endTime = rMpBenchmarkLevelParam.getEndTime(); //截止时间
String benchmarkIndicator = rMpBenchmarkLevelParam.getBenchmarkIndicator(); //评价指标
List <String> voltageLevelParamList = StringUtils.isNotBlank(rMpBenchmarkLevelParam.getVoltageLevel()) ? Arrays.asList(rMpBenchmarkLevelParam.getVoltageLevel().split(",")) : null; //电压等级
//获取电压等级的字典
List<DictData> voltageLevelList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
//将电压信息转成mapkeyid valuename
Map<String, String> voltageLevelMap = voltageLevelList.stream().collect(Collectors.toMap(DictData::getId, DictData::getName));
//获取基准水平评价指标字典
List<DictData> benchmarkIndicatorList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.BENCHMARK_INDICATORS.getCode()).getData();
//将基准水平评价指标信息转成mapkeyid valuename
Map<String, String> benchmarkIndicatorMap = benchmarkIndicatorList.stream().collect(Collectors.toMap(DictData::getId, DictData::getName));
//查询所有子单位下的所有监测点
PmsDeviceInfoParam pmsDeviceInfoParam = new PmsDeviceInfoParam(id);
pmsDeviceInfoParam.setStatisticalType(new SimpleDTO());
if (CollUtil.isNotEmpty(voltageLevelParamList)) {
//查询条件电压等级筛选电压等级为voltageLevel的监测点
List<SimpleDTO> simpleDTOList = voltageLevelParamList.stream().map(item -> {
SimpleDTO simpleDTO = new SimpleDTO();
simpleDTO.setId(item);
return simpleDTO;
}).collect(Collectors.toList());
pmsDeviceInfoParam.setVoltageLevel(simpleDTOList);
}
//获取到该部门的所有子部门的监测点idList
List<PmsGeneralDeviceDTO> pmsDeviceInfoWithInOrg = pmsGeneralDeviceInfoClient.getPmsDeviceInfoWithInOrg(pmsDeviceInfoParam).getData();
//过滤出业务需要的监测点id集合
List<String> firstMonitorIdList = new ArrayList<>(); //只用于合并多个部门的监测点id
pmsDeviceInfoWithInOrg.forEach(item -> firstMonitorIdList.addAll(item.getMonitorIdList()));
List<String> lastMonitorIdList = firstMonitorIdList.stream().distinct().collect(Collectors.toList()); //最终的监测点id集合
//如果没有监测点id信息直接返回空集合
if (CollUtil.isEmpty(lastMonitorIdList)) {
return new ArrayList<>();
}
//查询对应的监测点完整信息 并转为key监测点id value监测点实体的map集合
// LambdaQueryWrapper<Monitor> monitorWrapper = new LambdaQueryWrapper<>();
// monitorWrapper.in(Monitor::getId, lastMonitorIdList);
PmsMonitorInfoParam pmsMonitorInfoParam = new PmsMonitorInfoParam();
pmsMonitorInfoParam.setMonitorIds(lastMonitorIdList);
Map<String, PmsMonitorInfoDTO> monitorMap = monitorClient.getMonitorInfo(pmsMonitorInfoParam).getData().stream().collect(Collectors.toMap(PmsMonitorInfoDTO::getMonitorId, monitor -> monitor));
//查询【基准水平-月】数据
/*组装条件where measurement_point_id in (monitorIdList) and data_date >= startTime
and data_date <= endTime and voltage_level
*/
LambdaQueryWrapper<RMpBenchmarkLevelQ> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(CollUtil.isNotEmpty(lastMonitorIdList), RMpBenchmarkLevelQ::getMeasurementPointId, lastMonitorIdList)
.ge(StringUtils.isNotBlank(startTime), RMpBenchmarkLevelQ::getDataDate, startTime)
.le(StringUtils.isNotBlank(endTime), RMpBenchmarkLevelQ::getDataDate, endTime);
List<RMpBenchmarkLevelQ> list = this.list(lambdaQueryWrapper);
List<RMpBenchmarkLevelVO> resultList = list.stream().map(item -> {
//封装前端需要的对象
RMpBenchmarkLevelVO rMpBenchmarkLevelVO = new RMpBenchmarkLevelVO();
BeanUtils.copyProperties(item, rMpBenchmarkLevelVO);
PmsGeneralDeviceDTO pmsGeneralDeviceDTO = pmsDeviceInfoWithInOrg.stream().filter(dto -> dto.getMonitorIdList().contains(item.getMeasurementPointId()))
.collect(Collectors.toList()).get(0);
//单位信息
rMpBenchmarkLevelVO.setOrgNo(pmsGeneralDeviceDTO.getIndex()); //单位id
rMpBenchmarkLevelVO.setOrgName(pmsGeneralDeviceDTO.getName()); //单位名称
//基准水平评价指标
rMpBenchmarkLevelVO.setBenchmarkIndicator(benchmarkIndicator); //基准水平评价指标id
rMpBenchmarkLevelVO.setBenchmarkIndicatorName(benchmarkIndicatorMap.get(benchmarkIndicator)); //基准水平评价指标
//监测点信息
rMpBenchmarkLevelVO.setMeasurementPointName(monitorMap.get(item.getMeasurementPointId()).getMonitorName()); //监测点名称
//电压等级
rMpBenchmarkLevelVO.setVoltageLevel(monitorMap.get(item.getMeasurementPointId()).getMonitorVoltageLevel());
rMpBenchmarkLevelVO.setVoltageLevelName(voltageLevelMap.get(monitorMap.get(item.getMeasurementPointId()).getMonitorVoltageLevel()));
return rMpBenchmarkLevelVO;
}).collect(Collectors.toList());
return resultList;
}
}

View File

@@ -0,0 +1,133 @@
package com.njcn.harmonic.service.majornetwork.impl;
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.dto.SimpleDTO;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.pms.api.MonitorClient;
import com.njcn.device.pms.api.PmsGeneralDeviceInfoClient;
import com.njcn.device.pms.api.PwMonitorClient;
import com.njcn.device.pms.pojo.dto.PmsGeneralDeviceDTO;
import com.njcn.device.pms.pojo.dto.PmsMonitorInfoDTO;
import com.njcn.device.pms.pojo.param.PmsDeviceInfoParam;
import com.njcn.device.pms.pojo.param.PmsMonitorInfoParam;
import com.njcn.harmonic.mapper.majornetwork.RMpBenchmarkLevelYMapper;
import com.njcn.harmonic.pojo.param.RMpBenchmarkLevelParam;
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelY;
import com.njcn.harmonic.pojo.vo.RMpBenchmarkLevelVO;
import com.njcn.harmonic.service.majornetwork.RMpBenchmarkLevelYService;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author jianghf
* @description 针对表【r_mp_benchmark_level_y】的数据库操作Service实现
* @createDate 2022-10-11 10:32:18
*/
@Service
@RequiredArgsConstructor
public class RMpBenchmarkLevelYServiceImpl extends ServiceImpl<RMpBenchmarkLevelYMapper, RMpBenchmarkLevelY>
implements RMpBenchmarkLevelYService {
private final DicDataFeignClient dicDataFeignClient;
private final PmsGeneralDeviceInfoClient pmsGeneralDeviceInfoClient;
private final MonitorClient monitorClient;
private final PwMonitorClient pwMonitorClient;
@Override
public List<RMpBenchmarkLevelVO> getRMpBenchmarkLevelList(RMpBenchmarkLevelParam rMpBenchmarkLevelParam) {
//提取查询条件
String id = rMpBenchmarkLevelParam.getId(); //单位id
if (StringUtils.isBlank(id)) {
throw new BusinessException(CommonResponseEnum.NO_DATA, "单位id不可为空");
}
String startTime = rMpBenchmarkLevelParam.getStartTime(); //开始时间
String endTime = rMpBenchmarkLevelParam.getEndTime(); //截止时间
String benchmarkIndicator = rMpBenchmarkLevelParam.getBenchmarkIndicator(); //评价指标
List <String> voltageLevelParamList = StringUtils.isNotBlank(rMpBenchmarkLevelParam.getVoltageLevel()) ? Arrays.asList(rMpBenchmarkLevelParam.getVoltageLevel().split(",")) : null; //电压等级
//获取电压等级的字典
List<DictData> voltageLevelList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
//将电压信息转成mapkeyid valuename
Map<String, String> voltageLevelMap = voltageLevelList.stream().collect(Collectors.toMap(DictData::getId, DictData::getName));
//获取基准水平评价指标字典
List<DictData> benchmarkIndicatorList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.BENCHMARK_INDICATORS.getCode()).getData();
//将基准水平评价指标信息转成mapkeyid valuename
Map<String, String> benchmarkIndicatorMap = benchmarkIndicatorList.stream().collect(Collectors.toMap(DictData::getId, DictData::getName));
//查询所有子单位下的所有监测点
PmsDeviceInfoParam pmsDeviceInfoParam = new PmsDeviceInfoParam(id);
pmsDeviceInfoParam.setStatisticalType(new SimpleDTO());
if (CollUtil.isNotEmpty(voltageLevelParamList)) {
//查询条件电压等级筛选电压等级为voltageLevel的监测点
List<SimpleDTO> simpleDTOList = voltageLevelParamList.stream().map(item -> {
SimpleDTO simpleDTO = new SimpleDTO();
simpleDTO.setId(item);
return simpleDTO;
}).collect(Collectors.toList());
pmsDeviceInfoParam.setVoltageLevel(simpleDTOList);
}
//获取到该部门的所有子部门的监测点idList
List<PmsGeneralDeviceDTO> pmsDeviceInfoWithInOrg = pmsGeneralDeviceInfoClient.getPmsDeviceInfoWithInOrg(pmsDeviceInfoParam).getData();
//过滤出业务需要的监测点id集合
List<String> firstMonitorIdList = new ArrayList<>(); //只用于合并多个部门的监测点id
pmsDeviceInfoWithInOrg.forEach(item -> firstMonitorIdList.addAll(item.getMonitorIdList()));
List<String> lastMonitorIdList = firstMonitorIdList.stream().distinct().collect(Collectors.toList()); //最终的监测点id集合
//如果没有监测点id信息直接返回空集合
if (CollUtil.isEmpty(lastMonitorIdList)) {
return new ArrayList<>();
}
//查询对应的监测点完整信息 并转为key监测点id value监测点实体的map集合
// LambdaQueryWrapper<Monitor> monitorWrapper = new LambdaQueryWrapper<>();
// monitorWrapper.in(Monitor::getId, lastMonitorIdList); e
PmsMonitorInfoParam pmsMonitorInfoParam = new PmsMonitorInfoParam();
pmsMonitorInfoParam.setMonitorIds(lastMonitorIdList);
Map<String, PmsMonitorInfoDTO> monitorMap = monitorClient.getMonitorInfo(pmsMonitorInfoParam).getData().stream().collect(Collectors.toMap(PmsMonitorInfoDTO::getMonitorId, monitor -> monitor));
//查询【基准水平-月】数据
/*组装条件where measurement_point_id in (monitorIdList) and data_date >= startTime
and data_date <= endTime and voltage_level
*/
LambdaQueryWrapper<RMpBenchmarkLevelY> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(CollUtil.isNotEmpty(lastMonitorIdList), RMpBenchmarkLevelY::getMeasurementPointId, lastMonitorIdList)
.ge(StringUtils.isNotBlank(startTime), RMpBenchmarkLevelY::getDataDate, startTime)
.le(StringUtils.isNotBlank(endTime), RMpBenchmarkLevelY::getDataDate, endTime);
List<RMpBenchmarkLevelY> list = this.list(lambdaQueryWrapper);
List<RMpBenchmarkLevelVO> resultList = list.stream().map(item -> {
//封装前端需要的对象
RMpBenchmarkLevelVO rMpBenchmarkLevelVO = new RMpBenchmarkLevelVO();
BeanUtils.copyProperties(item, rMpBenchmarkLevelVO);
PmsGeneralDeviceDTO pmsGeneralDeviceDTO = pmsDeviceInfoWithInOrg.stream().filter(dto -> dto.getMonitorIdList().contains(item.getMeasurementPointId()))
.collect(Collectors.toList()).get(0);
//单位信息
rMpBenchmarkLevelVO.setOrgNo(pmsGeneralDeviceDTO.getIndex()); //单位id
rMpBenchmarkLevelVO.setOrgName(pmsGeneralDeviceDTO.getName()); //单位名称
//基准水平评价指标
rMpBenchmarkLevelVO.setBenchmarkIndicator(benchmarkIndicator); //基准水平评价指标id
rMpBenchmarkLevelVO.setBenchmarkIndicatorName(benchmarkIndicatorMap.get(benchmarkIndicator)); //基准水平评价指标
//监测点信息
rMpBenchmarkLevelVO.setMeasurementPointName(monitorMap.get(item.getMeasurementPointId()).getMonitorName()); //监测点名称
//电压等级
rMpBenchmarkLevelVO.setVoltageLevel(monitorMap.get(item.getMeasurementPointId()).getMonitorVoltageLevel());
rMpBenchmarkLevelVO.setVoltageLevelName(voltageLevelMap.get(monitorMap.get(item.getMeasurementPointId()).getMonitorVoltageLevel()));
return rMpBenchmarkLevelVO;
}).collect(Collectors.toList());
return resultList;
}
}