bug修改

This commit is contained in:
2023-04-27 13:52:29 +08:00
parent a009f21d61
commit abab034523
3 changed files with 31 additions and 213 deletions

View File

@@ -14,7 +14,7 @@ import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
/** /**
* (influxdb 转 mysql 专用)实体类 * 暂降明细实体类
* *
* @author yzh * @author yzh
* @since 2022-10-12 18:34:55 * @since 2022-10-12 18:34:55

View File

@@ -132,6 +132,7 @@ public class ReportServiceImpl implements ReportService {
private final PmsGeneralDeviceInfoClient pmsGeneralDeviceInfoClient; private final PmsGeneralDeviceInfoClient pmsGeneralDeviceInfoClient;
private final MonitorClient monitorClient; private final MonitorClient monitorClient;
private final EventDetailService eventDetailService; private final EventDetailService eventDetailService;
private final FreemarkerUtil freemarkerUtil; private final FreemarkerUtil freemarkerUtil;
@@ -152,24 +153,6 @@ public class ReportServiceImpl implements ReportService {
throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY); throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
} }
// QueryResult queryResult = new QueryResult();
// List<String> ids = new ArrayList<>();
// List<GeneralDeviceDTO> deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData();
// List<List<String>> collect = deviceDTOList.stream().map(x -> x.getLineIndexes()).collect(Collectors.toList());
// collect.stream().forEach(a -> a.forEach(x -> ids.add(x)));
// StringBuilder stringBuilder = new StringBuilder(Param.SELECT + Param.EVENT_DETAIL);
// stringBuilder.append(Param.WHERE);
// for (String id : ids) {
// stringBuilder.append("line_id = '").append(id + "' ").append("or ");
// }
// String substring = stringBuilder.substring(0, stringBuilder.length() - 3);
// queryResult = influxDbUtils.query(substring.toString());
// //结果集映射到对象中
// InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
// List<EventDetail> eventDetailList = influxDBResultMapper.toPOJO(queryResult, EventDetail.class);
// eventDetailList.stream().forEach(a -> {
// info.add(a);
// });
return info; return info;
} }
@@ -189,24 +172,6 @@ public class ReportServiceImpl implements ReportService {
throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY); throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
} }
// QueryResult queryResult = new QueryResult();
// for (GeneralDeviceDTO dto : deviceDTOList) {
// StringBuilder stringBuilder = new StringBuilder(Param.SELECT + Param.EVENT_DETAIL);
// if (dto.getLineIndexes().size() > 0) {
// stringBuilder.append(Param.WHERE);
// dto.getLineIndexes().stream().forEach(line -> {
// stringBuilder.append("line_id = '").append(line + "' ").append("or ");
// });
// String substring = stringBuilder.substring(0, stringBuilder.length() - 3);
// queryResult = influxDbUtils.query(substring.toString());
// //结果集映射到对象中
// InfluxDBResultMapperCn influxDBResultMapper = new InfluxDBResultMapperCn();
// List<EventDetailNew> eventDetailList = influxDBResultMapper.toPOJO(queryResult, EventDetailNew.class);
// eventDetailList.stream().forEach(a -> {
// info.add(a);
// });
// }
// }
return info; return info;
} }
@@ -249,15 +214,6 @@ public class ReportServiceImpl implements ReportService {
); );
List<EventDetail> eventDetailList= BeanUtil.copyToList(eventDetails,EventDetail.class); List<EventDetail> eventDetailList= BeanUtil.copyToList(eventDetails,EventDetail.class);
// stringBuilder.append(Param.WHERE);
// lineIndexes.stream().forEach(line -> {
// stringBuilder.append("line_id = '").append(line + "' ").append("or ");
// });
// String substring = stringBuilder.substring(0, stringBuilder.length() - 3);
// queryResult = influxDbUtils.query(substring.toString());
// //结果集映射到对象中
// InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
// List<EventDetail> eventDetailList = influxDBResultMapper.toPOJO(queryResult, EventDetail.class);
map.put(dto.getName(), eventDetailList); map.put(dto.getName(), eventDetailList);
} else { } else {
List<EventDetail> eventDetailList = new ArrayList<>(); List<EventDetail> eventDetailList = new ArrayList<>();
@@ -523,54 +479,6 @@ public class ReportServiceImpl implements ReportService {
page.setRecords(result); page.setRecords(result);
return page; return page;
// List<EventDetailNew> count = getED2(waveTypeParam);
// StringBuilder stringBuilder = new StringBuilder(Param.SELECT + Param.EVENT_DETAIL + Param.WHERE + " ");
// List<GeneralDeviceDTO> deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(waveTypeParam).getData();
// List<String> lineIds = deviceDTOList.stream().flatMap(list -> list.getLineIndexes().stream()).collect(Collectors.toList());
// if (CollectionUtil.isEmpty(lineIds)) {
// throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
// }
// StringBuilder lineSting = InfluxDBCommUtils.assToInfluxParam(lineIds);
// Integer s = (waveTypeParam.getPageNum() - 1) * waveTypeParam.getPageSize();
// stringBuilder.append(lineSting).append("limit ").append(waveTypeParam.getPageSize() + " offset " + s + Param.TZ_ASIA_SHANGHAI);
// QueryResult query = influxDbUtils.query(stringBuilder.toString());
// InfluxDBResultMapperCn influxDBResultMapper = new InfluxDBResultMapperCn();
//
// List<EventDetailNew> info = influxDBResultMapper.toPOJO(query, EventDetailNew.class);
// if (CollectionUtil.isNotEmpty(info)) {
// ArrayList<String> idlist = new ArrayList<>();
// for (EventDetailNew eventDetail : info) {
// DetailVO vo = new DetailVO();
// BeanUtils.copyProperties(eventDetail, vo);
// result.add(vo);
// idlist.add(eventDetail.getLineId());
// }
// HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
// List<AreaLineInfoVO> data = AreaInfo.getData();
// for (DetailVO detailVO : result) {
// for (AreaLineInfoVO vo : data) {
// if (vo.getLineId().equals(detailVO.getLineId())) {
// BeanUtils.copyProperties(vo, detailVO);
// }
// }
// }
// HttpResult<List<DictData>> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName());
// List<DictData> type = reason.getData();
// for (DetailVO detailVO : result) {
// for (DictData dictData : type) {
// if (dictData.getId().equals(detailVO.getEventType())) {
// detailVO.setEventType(dictData.getName());
// }
// }
// }
// }
// Page<DetailVO> page = new Page<>();
// page.setTotal(count.size());
// page.setRecords(result);
// page.setCurrent(waveTypeParam.getPageNum());
// page.setSize(waveTypeParam.getPageSize());
// return page;
} }
/** /**
@@ -633,62 +541,6 @@ public class ReportServiceImpl implements ReportService {
return page; return page;
// List<EventDetailNew> count = getED2(waveTypeParam);
// StringBuilder stringBuilder = new StringBuilder(Param.SELECT + Param.EVENT_DETAIL + Param.WHERE + " 1=1 ");
// List<GeneralDeviceDTO> deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(waveTypeParam).getData();
// String substring = "";
// for (GeneralDeviceDTO dto : deviceDTOList) {
// if (dto.getLineIndexes().size() > 0) {
// stringBuilder.append(" or ");
// dto.getLineIndexes().stream().forEach(line -> {
// stringBuilder.append("line_id = '").append(line + "' ").append("or ");
// });
// stringBuilder.delete(stringBuilder.length() - 3, stringBuilder.length() + 1);
// }
// }
// Integer i = (waveTypeParam.getPageNum() - 1) * waveTypeParam.getPageSize();
// substring = stringBuilder.toString() + "limit " + waveTypeParam.getPageSize() + " offset " + i + Param.TZ_ASIA_SHANGHAI;
// QueryResult query = influxDbUtils.query(substring);
// InfluxDBResultMapperCn influxDBResultMapper = new InfluxDBResultMapperCn();
// List<EventDetailNew> info = influxDBResultMapper.toPOJO(query, EventDetailNew.class);
// HashMap<String, Integer> countMap = new HashMap<>();
// for (EventDetailNew eventDetail : info) {
// countMap.put(eventDetail.getLineId(), 0);
// }
// Set<String> keySet = countMap.keySet();
// //id集合
// ArrayList<String> idlist = new ArrayList<>();
// for (EventDetailNew eventDetail : info) {
// for (String s : keySet) {
// if (eventDetail.getLineId().equals(s) && eventDetail.getWaveType() == "1") {
// countMap.put(s, countMap.get(s) + 1);
// }
// }
// DetailVO vo = new DetailVO();
// BeanUtils.copyProperties(eventDetail, vo);
// result.add(vo);
// idlist.add(eventDetail.getLineId());
// }
// HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
// List<AreaLineInfoVO> data = AreaInfo.getData();
// for (DetailVO detailVO : result) {
// for (AreaLineInfoVO vo : data) {
// if (vo.getLineId().equals(detailVO.getLineId())) {
// BeanUtils.copyProperties(vo, detailVO);
// }
// }
// for (String s : keySet) {
// if (s.equals(detailVO.getLineId())) {
// detailVO.setTimes(countMap.get(s));
// }
// }
// }
// Page<DetailVO> page = new Page<>();
// page.setTotal(count.size());
// page.setRecords(result);
// page.setCurrent(waveTypeParam.getPageNum());
// page.setSize(waveTypeParam.getPageSize());
// return page;
} }
/** /**
@@ -703,15 +555,18 @@ public class ReportServiceImpl implements ReportService {
//获取暂升字典信息 //获取暂升字典信息
DictData dictdata = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_RISE.getCode()).getData(); DictData dictdata = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_RISE.getCode()).getData();
List<GeneralDeviceDTO> deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(waveTypeParam).getData(); List<GeneralDeviceDTO> deviceDTOList = generalDeviceInfoClient.getPracticalRunDeviceInfo(waveTypeParam).getData();
List<String> lineIds = deviceDTOList.stream().flatMap(list -> list.getLineIndexes().stream()).collect(Collectors.toList()); List<String> lineIds = deviceDTOList.stream().flatMap(list -> list.getLineIndexes().stream()).collect(Collectors.toList());
if (CollectionUtil.isEmpty(lineIds)) { if (CollectionUtil.isEmpty(lineIds)) {
throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY); throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
} }
Page<RmpEventDetailPO> pageInfo = eventDetailService.page(new Page<>(waveTypeParam.getPageNum(), waveTypeParam.getPageSize()), new LambdaQueryWrapper<RmpEventDetailPO>() Page<RmpEventDetailPO> pageInfo = eventDetailService.page(
new Page<>(waveTypeParam.getPageNum(), waveTypeParam.getPageSize()),
new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId, lineIds) .in(RmpEventDetailPO::getMeasurementPointId, lineIds)
.ge(StringUtils.isNotBlank(waveTypeParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(waveTypeParam.getSearchBeginTime()))) .ge(StringUtils.isNotBlank(waveTypeParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(waveTypeParam.getSearchBeginTime())))
.le(StringUtils.isNotBlank(waveTypeParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(waveTypeParam.getSearchEndTime()))) .le(StringUtils.isNotBlank(waveTypeParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(waveTypeParam.getSearchEndTime())))
.eq(RmpEventDetailPO::getEventType,dictdata.getId())
); );
List<EventDetailNew> info =BeanUtil.copyToList(pageInfo.getRecords(),EventDetailNew.class); List<EventDetailNew> info =BeanUtil.copyToList(pageInfo.getRecords(),EventDetailNew.class);
HashMap<String, Integer> countMap = new HashMap<>(); HashMap<String, Integer> countMap = new HashMap<>();
@@ -750,62 +605,7 @@ public class ReportServiceImpl implements ReportService {
page.setRecords(result); page.setRecords(result);
return page; return page;
// List<EventDetailNew> count = getED2(waveTypeParam);
// StringBuilder stringBuilder = new StringBuilder(Param.SELECT + Param.EVENT_DETAIL + Param.WHERE + " 1=1 ");
// List<GeneralDeviceDTO> deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(waveTypeParam).getData();
// String substring = "";
// for (GeneralDeviceDTO dto : deviceDTOList) {
// if (dto.getLineIndexes().size() > 0) {
// stringBuilder.append(" or ");
// dto.getLineIndexes().stream().forEach(line -> {
// stringBuilder.append("line_id = '").append(line + "' ").append("or ");
// });
// stringBuilder.delete(stringBuilder.length() - 3, stringBuilder.length() + 1);
// }
// }
// Integer i = (waveTypeParam.getPageNum() - 1) * waveTypeParam.getPageSize();
// substring = stringBuilder.toString() + "limit " + waveTypeParam.getPageSize() + " offset " + i + Param.TZ_ASIA_SHANGHAI;
// QueryResult query = influxDbUtils.query(substring);
// InfluxDBResultMapperCn influxDBResultMapper = new InfluxDBResultMapperCn();
// List<EventDetailNew> info = influxDBResultMapper.toPOJO(query, EventDetailNew.class);
// HashMap<String, Integer> countMap = new HashMap<>();
// for (EventDetailNew eventDetail : info) {
// countMap.put(eventDetail.getLineId(), 0);
// }
// Set<String> keySet = countMap.keySet();
// //id集合
// ArrayList<String> idlist = new ArrayList<>();
// for (EventDetailNew eventDetail : info) {
// for (String s : keySet) {
// if (eventDetail.getLineId().equals(s) && eventDetail.getWaveType() == "2") {
// countMap.put(s, countMap.get(s) + 1);
// }
// }
// DetailVO vo = new DetailVO();
// BeanUtils.copyProperties(eventDetail, vo);
// result.add(vo);
// idlist.add(eventDetail.getLineId());
// }
// HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
// List<AreaLineInfoVO> data = AreaInfo.getData();
// for (DetailVO detailVO : result) {
// for (AreaLineInfoVO vo : data) {
// if (vo.getLineId().equals(detailVO.getLineId())) {
// BeanUtils.copyProperties(vo, detailVO);
// }
// }
// for (String s : keySet) {
// if (s.equals(detailVO.getLineId())) {
// detailVO.setTimes(countMap.get(s));
// }
// }
// }
// Page<DetailVO> page = new Page<>();
// page.setTotal(count.size());
// page.setRecords(result);
// page.setCurrent(waveTypeParam.getPageNum());
// page.setSize(waveTypeParam.getPageSize());
// return page;
} }
/** /**

View File

@@ -196,7 +196,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
pollutionVO.setId (detpid); pollutionVO.setId (detpid);
pollutionVO.setName (name); pollutionVO.setName (name);
pollutionVO.setData (-1.0); pollutionVO.setData (-1.0);
setData(harmonicPublicParam, pollutionType, searchBeginTime, pollutionVO, detpid); setData(harmonicPublicParam, pollutionType, searchBeginTime,harmonicPublicParam.getSearchEndTime(), pollutionVO, detpid);
if(CollectionUtil.isNotEmpty(powers)) { if(CollectionUtil.isNotEmpty(powers)) {
//子集变电站 //子集变电站
List<PollutionVO> powersVO = new ArrayList<>(); List<PollutionVO> powersVO = new ArrayList<>();
@@ -239,7 +239,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
pollutionVO.setId(detpid); pollutionVO.setId(detpid);
pollutionVO.setName(name); pollutionVO.setName(name);
pollutionVO.setData(-1.0); pollutionVO.setData(-1.0);
setData(harmonicPublicParam, pollutionType, searchBeginTime, pollutionVO, detpid); setData(harmonicPublicParam, pollutionType, searchBeginTime,harmonicPublicParam.getSearchEndTime(), pollutionVO, detpid);
List<PollutionVO> subPollutionVO = new ArrayList<>(); List<PollutionVO> subPollutionVO = new ArrayList<>();
subIndexes.forEach(subIndex -> { subIndexes.forEach(subIndex -> {
PollutionVO pollutionsubVO = new PollutionVO(); PollutionVO pollutionsubVO = new PollutionVO();
@@ -249,7 +249,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
pollutionsubVO.setName(pollutionSubstationDTO.getName()); pollutionsubVO.setName(pollutionSubstationDTO.getName());
pollutionsubVO.setPid(temp.getIndex()); pollutionsubVO.setPid(temp.getIndex());
pollutionsubVO.setData(-1.0); pollutionsubVO.setData(-1.0);
setSubData(harmonicPublicParam, pollutionType, searchBeginTime, pollutionsubVO, id); setSubData(harmonicPublicParam, pollutionType, searchBeginTime,harmonicPublicParam.getSearchEndTime(), pollutionsubVO, id);
subPollutionVO.add(pollutionsubVO); subPollutionVO.add(pollutionsubVO);
}); });
pollutionVO.setChildren(subPollutionVO); pollutionVO.setChildren(subPollutionVO);
@@ -297,7 +297,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
return null; return null;
} }
private void setSubData(HarmonicPublicParam harmonicPublicParam, String pollutionType, String searchBeginTime, PollutionVO pollutionsubVO, String id) { private void setSubData(HarmonicPublicParam harmonicPublicParam, String pollutionType, String searchBeginTime,String searchEndTime, PollutionVO pollutionsubVO, String id) {
//harmonicPublicParam.setReportFlag("5"); //harmonicPublicParam.setReportFlag("5");
if(Objects.equals (harmonicPublicParam.getReportFlag (), BizParamConstant.STAT_BIZ_YEAR) ){ if(Objects.equals (harmonicPublicParam.getReportFlag (), BizParamConstant.STAT_BIZ_YEAR) ){
QueryWrapper<RStatPollutionSubstationYPO> wrapper = new QueryWrapper<> (); QueryWrapper<RStatPollutionSubstationYPO> wrapper = new QueryWrapper<> ();
@@ -332,10 +332,19 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
RStatPollutionSubstationDPO rStatPollutionSubstationDPO = pollutionSubstationDPOMapper.selectOne (wrapper); RStatPollutionSubstationDPO rStatPollutionSubstationDPO = pollutionSubstationDPOMapper.selectOne (wrapper);
Optional.ofNullable (rStatPollutionSubstationDPO).ifPresent (t->pollutionsubVO.setData (t.getValue ())); Optional.ofNullable (rStatPollutionSubstationDPO).ifPresent (t->pollutionsubVO.setData (t.getValue ()));
}else if(Objects.equals (harmonicPublicParam.getReportFlag (),BizParamConstant.STAT_BIZ_WEEK)){
QueryWrapper<RStatPollutionSubstationDPO> wrapper = new QueryWrapper<> ();
wrapper.eq ("substation_id",id).
eq ("pollution_type", pollutionType).
between("DATE_FORMAT( data_date ,'%Y-%m-%d')",searchBeginTime,searchEndTime)
.orderByDesc("value").last(" limit 1");
RStatPollutionSubstationDPO rStatPollutionSubstationDPO = pollutionSubstationDPOMapper.selectOne (wrapper);
Optional.ofNullable (rStatPollutionSubstationDPO).ifPresent (t->pollutionsubVO.setData (t.getValue ()));
} }
} }
private void setData(HarmonicPublicParam harmonicPublicParam, String pollutionType, String searchBeginTime, PollutionVO pollutionVO, String detpid) { private void setData(HarmonicPublicParam harmonicPublicParam, String pollutionType, String searchBeginTime,String searchEndTime, PollutionVO pollutionVO, String detpid) {
//harmonicPublicParam.setReportFlag("5"); //harmonicPublicParam.setReportFlag("5");
if(Objects.equals (harmonicPublicParam.getReportFlag (), BizParamConstant.STAT_BIZ_YEAR) ) { if(Objects.equals (harmonicPublicParam.getReportFlag (), BizParamConstant.STAT_BIZ_YEAR) ) {
QueryWrapper<RStatPollutionOrgYPO> rStatPollutionOrgYPOQueryWrapper = new QueryWrapper<> (); QueryWrapper<RStatPollutionOrgYPO> rStatPollutionOrgYPOQueryWrapper = new QueryWrapper<> ();
@@ -365,6 +374,15 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
eq("DATE_FORMAT( data_date ,'%Y-%m-%d')",searchBeginTime); eq("DATE_FORMAT( data_date ,'%Y-%m-%d')",searchBeginTime);
RStatPollutionOrgDPO rStatPollutionOrgDPO = rStatPollutionOrgDPOMapper.selectOne (rStatPollutionOrgDPOQueryWrapper); RStatPollutionOrgDPO rStatPollutionOrgDPO = rStatPollutionOrgDPOMapper.selectOne (rStatPollutionOrgDPOQueryWrapper);
Optional.ofNullable (rStatPollutionOrgDPO).ifPresent (a->pollutionVO.setData (a.getValue ())); Optional.ofNullable (rStatPollutionOrgDPO).ifPresent (a->pollutionVO.setData (a.getValue ()));
}else if(Objects.equals (harmonicPublicParam.getReportFlag (),BizParamConstant.STAT_BIZ_WEEK)){
QueryWrapper<RStatPollutionOrgDPO> rStatPollutionOrgDPOQueryWrapper = new QueryWrapper<> ();
rStatPollutionOrgDPOQueryWrapper.eq ("org_id", detpid).
eq ("pollution_type", pollutionType).
between("DATE_FORMAT( data_date ,'%Y-%m-%d')",searchBeginTime,searchEndTime)
.orderByDesc("value").last(" limit 1");
RStatPollutionOrgDPO rStatPollutionOrgDPO = rStatPollutionOrgDPOMapper.selectOne (rStatPollutionOrgDPOQueryWrapper);
Optional.ofNullable (rStatPollutionOrgDPO).ifPresent (a->pollutionVO.setData (a.getValue ()));
} }
} }