|
|
|
|
@@ -17,6 +17,7 @@ import com.njcn.csharmonic.param.ThdDataQueryParm;
|
|
|
|
|
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
|
|
|
|
|
import com.njcn.csharmonic.service.StableDataService;
|
|
|
|
|
import com.njcn.influx.constant.InfluxDbSqlConstant;
|
|
|
|
|
import com.njcn.influx.pojo.bo.CommonQueryParam;
|
|
|
|
|
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
|
|
|
|
import com.njcn.influx.pojo.po.HarmonicRatioData;
|
|
|
|
|
import com.njcn.influx.pojo.po.PowerQualityData;
|
|
|
|
|
@@ -28,6 +29,7 @@ import com.njcn.system.api.CsStatisticalSetFeignClient;
|
|
|
|
|
import com.njcn.system.api.DicDataFeignClient;
|
|
|
|
|
import com.njcn.system.api.EpdFeignClient;
|
|
|
|
|
import com.njcn.system.enums.DicDataEnum;
|
|
|
|
|
import com.njcn.system.pojo.po.DictData;
|
|
|
|
|
import com.njcn.system.pojo.po.EleEpdPqd;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.influxdb.dto.QueryResult;
|
|
|
|
|
@@ -191,8 +193,7 @@ public class StableDataServiceImpl implements StableDataService {
|
|
|
|
|
String areaId = dicDataFeignClient.getDicDataByCode(DicDataEnum.OUTPUT_SIDE.getCode()).getData().getId();
|
|
|
|
|
|
|
|
|
|
Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR));
|
|
|
|
|
collect = csLinePOList.stream().filter(temp->Objects.equals(areaId,temp.getPosition())).map(CsLinePO::getLineId).distinct().collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
List<CsLinePO> csLinePOList1 = csLinePOList.stream().filter(temp -> Objects.equals(areaId, temp.getPosition())).distinct().collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EleEpdPqd data = epdFeignClient.selectById(commonStatisticalQueryParam.getStatisticalId()).getData();
|
|
|
|
|
@@ -203,7 +204,22 @@ public class StableDataServiceImpl implements StableDataService {
|
|
|
|
|
}else {
|
|
|
|
|
frequency = "_"+commonStatisticalQueryParam.getFrequency();
|
|
|
|
|
}
|
|
|
|
|
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtData(collect, data.getClassId(), data.getName()+frequency, data.getPhase(), commonStatisticalQueryParam.getValueType(),data1.get(0).getProcess()+"");
|
|
|
|
|
String finalFrequency1 = frequency;
|
|
|
|
|
List<CommonQueryParam> commonQueryParams = csLinePOList1.stream().map(temp -> {
|
|
|
|
|
CommonQueryParam commonQueryParam = new CommonQueryParam();
|
|
|
|
|
commonQueryParam.setLineId(temp.getLineId());
|
|
|
|
|
commonQueryParam.setTableName(getTableNameByClassId(data.getClassId()));
|
|
|
|
|
commonQueryParam.setColumnName(data.getName()+ finalFrequency1);
|
|
|
|
|
commonQueryParam.setPhasic(data.getPhase());
|
|
|
|
|
// commonQueryParam.setStartTime();
|
|
|
|
|
// commonQueryParam.setEndTime();
|
|
|
|
|
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType());
|
|
|
|
|
commonQueryParam.setProcess(data1.get(0).getProcess()+"");
|
|
|
|
|
commonQueryParam.setClDid(getClDidByLineId(temp.getLineId()));
|
|
|
|
|
|
|
|
|
|
return commonQueryParam;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtData(commonQueryParams);
|
|
|
|
|
List<CsLinePO> finalCsLinePOList = csLinePOList;
|
|
|
|
|
String finalFrequency = frequency;
|
|
|
|
|
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
|
|
|
|
|
@@ -246,24 +262,40 @@ public class StableDataServiceImpl implements StableDataService {
|
|
|
|
|
List<String> collect = csLinePOList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
|
|
|
|
|
String areaId = dicDataFeignClient.getDicDataByCode(DicDataEnum.OUTPUT_SIDE.getCode()).getData().getId();
|
|
|
|
|
Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR));
|
|
|
|
|
collect = csLinePOList.stream().filter(temp->Objects.equals(areaId,temp.getPosition())).map(CsLinePO::getLineId).collect(Collectors.toList());
|
|
|
|
|
List<CsLinePO> csLinePOList1 = csLinePOList.stream().filter(temp -> Objects.equals(areaId, temp.getPosition())).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
List<EleEpdPqd> data = csStatisticalSetFeignClient.queryStatisticalSelect(commonStatisticalQueryParam.getStatisticalId()).getData();
|
|
|
|
|
|
|
|
|
|
// EleEpdPqd data = epdFeignClient.selectById(commonStatisticalQueryParam.getStatisticalId()).getData();
|
|
|
|
|
// Optional.ofNullable(data).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.ELEEPDPQD_DATA_ERROR));
|
|
|
|
|
if(CollectionUtil.isNotEmpty(data)){
|
|
|
|
|
List<String> finalCollect = collect;
|
|
|
|
|
List<CsLinePO> finalCsLinePOList = csLinePOList;
|
|
|
|
|
data.forEach(epdPqd->{
|
|
|
|
|
String frequency = Optional.ofNullable(commonStatisticalQueryParam.getFrequency()).orElse("");
|
|
|
|
|
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtDataByTime(finalCollect, epdPqd.getClassId(), epdPqd.getName()+frequency, epdPqd.getPhase(), commonStatisticalQueryParam.getValueType(),commonStatisticalQueryParam.getStartTime(),commonStatisticalQueryParam.getEndTime(),data1.get(0).getProcess()+"");
|
|
|
|
|
|
|
|
|
|
String finalFrequency1 = frequency;
|
|
|
|
|
List<CommonQueryParam> commonQueryParams = csLinePOList1.stream().map(temp -> {
|
|
|
|
|
CommonQueryParam commonQueryParam = new CommonQueryParam();
|
|
|
|
|
commonQueryParam.setLineId(temp.getLineId());
|
|
|
|
|
commonQueryParam.setTableName(getTableNameByClassId(epdPqd.getClassId()));
|
|
|
|
|
commonQueryParam.setColumnName(epdPqd.getName()+ finalFrequency1);
|
|
|
|
|
commonQueryParam.setPhasic(epdPqd.getPhase());
|
|
|
|
|
commonQueryParam.setStartTime(commonStatisticalQueryParam.getStartTime());
|
|
|
|
|
commonQueryParam.setEndTime(commonStatisticalQueryParam.getEndTime());
|
|
|
|
|
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType());
|
|
|
|
|
commonQueryParam.setProcess(data1.get(0).getProcess()+"");
|
|
|
|
|
commonQueryParam.setClDid(getClDidByLineId(temp.getLineId()));
|
|
|
|
|
|
|
|
|
|
return commonQueryParam;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtDataByTime(commonQueryParams);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
|
|
|
|
|
ThdDataVO vo = new ThdDataVO();
|
|
|
|
|
vo.setLineId(temp.getLineId());
|
|
|
|
|
vo.setPhase(temp.getPhaseType());
|
|
|
|
|
String position = csLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
|
|
|
|
|
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
|
|
|
|
|
vo.setPosition(position);
|
|
|
|
|
vo.setTime(temp.getTime());
|
|
|
|
|
vo.setStatMethod(temp.getValueType());
|
|
|
|
|
@@ -282,65 +314,79 @@ public class StableDataServiceImpl implements StableDataService {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<ThdDataVO> queryLineCommonStatistical(CommonStatisticalQueryParam commonStatisticalQueryParam) {
|
|
|
|
|
List<ThdDataVO> result = new ArrayList();
|
|
|
|
|
if(CollectionUtil.isEmpty(commonStatisticalQueryParam.getLineList())){
|
|
|
|
|
throw new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR);
|
|
|
|
|
}
|
|
|
|
|
List<CsLinePO> csLinePOList = csLineFeignClient.queryLineById(commonStatisticalQueryParam.getLineList()).getData();
|
|
|
|
|
if(CollectionUtil.isEmpty(csLinePOList)){
|
|
|
|
|
throw new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LineParamDTO lineParamDTO = new LineParamDTO();
|
|
|
|
|
lineParamDTO.setLineId(commonStatisticalQueryParam.getLineList().get(0));
|
|
|
|
|
List<CsLedger> csLedgers = csLedgerFeignClient.queryLine(lineParamDTO).getData();
|
|
|
|
|
List<CsEquipmentDeliveryDTO> data1 = equipmentFeignClient.queryDeviceById(Stream.of(csLedgers.get(0).getPid()).collect(Collectors.toList())).getData();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> collect = csLinePOList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
|
|
|
|
|
String areaId = dicDataFeignClient.getDicDataByCode(DicDataEnum.OUTPUT_SIDE.getCode()).getData().getId();
|
|
|
|
|
Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR));
|
|
|
|
|
// collect = csLinePOList.stream().filter(temp->Objects.equals(areaId,temp.getPosition())).map(CsLinePO::getLineId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
List<EleEpdPqd> data = csStatisticalSetFeignClient.queryStatisticalSelect(commonStatisticalQueryParam.getStatisticalId()).getData();
|
|
|
|
|
|
|
|
|
|
// EleEpdPqd data = epdFeignClient.selectById(commonStatisticalQueryParam.getStatisticalId()).getData();
|
|
|
|
|
Optional.ofNullable(data).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.ELEEPDPQD_DATA_ERROR));
|
|
|
|
|
|
|
|
|
|
String frequency = Optional.ofNullable(commonStatisticalQueryParam.getFrequency()).orElse("");
|
|
|
|
|
if(CollectionUtil.isNotEmpty(data)){
|
|
|
|
|
List<String> finalCollect = collect;
|
|
|
|
|
data.forEach(epdPqd->{
|
|
|
|
|
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtDataByTime(finalCollect, epdPqd.getClassId(), epdPqd.getName()+frequency, epdPqd.getPhase(), commonStatisticalQueryParam.getValueType(),commonStatisticalQueryParam.getStartTime(),commonStatisticalQueryParam.getEndTime(),data1.get(0).getProcess()+"");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
|
|
|
|
|
ThdDataVO vo = new ThdDataVO();
|
|
|
|
|
vo.setLineId(temp.getLineId());
|
|
|
|
|
vo.setPhase(temp.getPhaseType());
|
|
|
|
|
String position = csLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
|
|
|
|
|
String lineName = csLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getName();
|
|
|
|
|
|
|
|
|
|
vo.setLineName(lineName);
|
|
|
|
|
vo.setPosition(position);
|
|
|
|
|
vo.setTime(temp.getTime());
|
|
|
|
|
vo.setStatMethod(temp.getValueType());
|
|
|
|
|
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
|
|
|
|
|
vo.setStatisticalIndex(epdPqd.getId());
|
|
|
|
|
vo.setUnit(epdPqd.getUnit());
|
|
|
|
|
vo.setStatisticalName(epdPqd.getName());
|
|
|
|
|
vo.setAnotherName(epdPqd.getShowName());
|
|
|
|
|
return vo;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
collect1 = collect1.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
result.addAll(collect1);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
// @Override
|
|
|
|
|
// public List<ThdDataVO> queryLineCommonStatistical(CommonStatisticalQueryParam commonStatisticalQueryParam) {
|
|
|
|
|
// List<ThdDataVO> result = new ArrayList();
|
|
|
|
|
// if(CollectionUtil.isEmpty(commonStatisticalQueryParam.getLineList())){
|
|
|
|
|
// throw new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR);
|
|
|
|
|
// }
|
|
|
|
|
// List<CsLinePO> csLinePOList = csLineFeignClient.queryLineById(commonStatisticalQueryParam.getLineList()).getData();
|
|
|
|
|
// if(CollectionUtil.isEmpty(csLinePOList)){
|
|
|
|
|
// throw new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// LineParamDTO lineParamDTO = new LineParamDTO();
|
|
|
|
|
// lineParamDTO.setLineId(commonStatisticalQueryParam.getLineList().get(0));
|
|
|
|
|
// List<CsLedger> csLedgers = csLedgerFeignClient.queryLine(lineParamDTO).getData();
|
|
|
|
|
// List<CsEquipmentDeliveryDTO> data1 = equipmentFeignClient.queryDeviceById(Stream.of(csLedgers.get(0).getPid()).collect(Collectors.toList())).getData();
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// List<String> collect = csLinePOList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
|
|
|
|
|
// String areaId = dicDataFeignClient.getDicDataByCode(DicDataEnum.OUTPUT_SIDE.getCode()).getData().getId();
|
|
|
|
|
// Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR));
|
|
|
|
|
//// collect = csLinePOList.stream().filter(temp->Objects.equals(areaId,temp.getPosition())).map(CsLinePO::getLineId).collect(Collectors.toList());
|
|
|
|
|
//
|
|
|
|
|
// List<EleEpdPqd> data = csStatisticalSetFeignClient.queryStatisticalSelect(commonStatisticalQueryParam.getStatisticalId()).getData();
|
|
|
|
|
//
|
|
|
|
|
//// EleEpdPqd data = epdFeignClient.selectById(commonStatisticalQueryParam.getStatisticalId()).getData();
|
|
|
|
|
// Optional.ofNullable(data).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.ELEEPDPQD_DATA_ERROR));
|
|
|
|
|
//
|
|
|
|
|
// String frequency = Optional.ofNullable(commonStatisticalQueryParam.getFrequency()).orElse("");
|
|
|
|
|
// if(CollectionUtil.isNotEmpty(data)){
|
|
|
|
|
// List<String> finalCollect = collect;
|
|
|
|
|
// data.forEach(epdPqd->{
|
|
|
|
|
// List<CommonQueryParam> commonQueryParams = finalCsLinePOList.stream().map(temp -> {
|
|
|
|
|
// CommonQueryParam commonQueryParam = new CommonQueryParam();
|
|
|
|
|
// commonQueryParam.setLineId(temp.getLineId());
|
|
|
|
|
// commonQueryParam.setTableName(getTableNameByClassId(epdPqd.getClassId()));
|
|
|
|
|
// commonQueryParam.setColumnName(epdPqd.getName()+ finalFrequency1);
|
|
|
|
|
// commonQueryParam.setPhasic(epdPqd.getPhase());
|
|
|
|
|
// commonQueryParam.setStartTime(commonStatisticalQueryParam.getStartTime());
|
|
|
|
|
// commonQueryParam.setEndTime(commonStatisticalQueryParam.getEndTime());
|
|
|
|
|
// commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType());
|
|
|
|
|
// commonQueryParam.setProcess(data1.get(0).getProcess()+"");
|
|
|
|
|
// commonQueryParam.setClDid(getClDidByLineId(temp.getLineId()));
|
|
|
|
|
//
|
|
|
|
|
// return commonQueryParam;
|
|
|
|
|
// }).collect(Collectors.toList());
|
|
|
|
|
// List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtDataByTime(finalCollect, epdPqd.getClassId(), epdPqd.getName()+frequency, epdPqd.getPhase(), commonStatisticalQueryParam.getValueType(),commonStatisticalQueryParam.getStartTime(),commonStatisticalQueryParam.getEndTime(),data1.get(0).getProcess()+"");
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
|
|
|
|
|
// ThdDataVO vo = new ThdDataVO();
|
|
|
|
|
// vo.setLineId(temp.getLineId());
|
|
|
|
|
// vo.setPhase(temp.getPhaseType());
|
|
|
|
|
// String position = csLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
|
|
|
|
|
// String lineName = csLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getName();
|
|
|
|
|
//
|
|
|
|
|
// vo.setLineName(lineName);
|
|
|
|
|
// vo.setPosition(position);
|
|
|
|
|
// vo.setTime(temp.getTime());
|
|
|
|
|
// vo.setStatMethod(temp.getValueType());
|
|
|
|
|
// vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
|
|
|
|
|
// vo.setStatisticalIndex(epdPqd.getId());
|
|
|
|
|
// vo.setUnit(epdPqd.getUnit());
|
|
|
|
|
// vo.setStatisticalName(epdPqd.getName());
|
|
|
|
|
// vo.setAnotherName(epdPqd.getShowName());
|
|
|
|
|
// return vo;
|
|
|
|
|
// }).collect(Collectors.toList());
|
|
|
|
|
// collect1 = collect1.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
// result.addAll(collect1);
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// return result;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
private String phaseReflection(String phase){
|
|
|
|
|
switch (phase) {
|
|
|
|
|
@@ -431,4 +477,29 @@ public class StableDataServiceImpl implements StableDataService {
|
|
|
|
|
return thdDataVOList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*表名换成了id本方法做转换*/
|
|
|
|
|
private String getTableNameByClassId(String classId){
|
|
|
|
|
DictData data = dicDataFeignClient.getDicDataById(classId).getData();
|
|
|
|
|
if(Objects.isNull(data)){
|
|
|
|
|
throw new BusinessException("数据缺失");
|
|
|
|
|
}
|
|
|
|
|
return data.getCode();
|
|
|
|
|
}
|
|
|
|
|
private String getClDidByLineId(String lineId){
|
|
|
|
|
String position = csLineFeignClient.getPositionById(lineId).getData();
|
|
|
|
|
if (Objects.isNull(position)){
|
|
|
|
|
throw new BusinessException(AlgorithmResponseEnum.POSITION_ERROR);
|
|
|
|
|
}
|
|
|
|
|
String clDid = null;
|
|
|
|
|
String areaCode = dicDataFeignClient.getDicDataById(position).getData().getCode();
|
|
|
|
|
if (Objects.equals(areaCode, DicDataEnum.OUTPUT_SIDE.getCode())){
|
|
|
|
|
clDid = "0";
|
|
|
|
|
} else if (Objects.equals(areaCode, DicDataEnum.GRID_SIDE.getCode())){
|
|
|
|
|
clDid = "1";
|
|
|
|
|
} else if (Objects.equals(areaCode, DicDataEnum.LOAD_SIDE.getCode())){
|
|
|
|
|
clDid = "2";
|
|
|
|
|
}
|
|
|
|
|
return clDid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|