|
|
|
@@ -3,6 +3,7 @@ package com.njcn.harmonic.service.impl;
|
|
|
|
import com.alibaba.nacos.client.naming.utils.CollectionUtils;
|
|
|
|
import com.alibaba.nacos.client.naming.utils.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import com.njcn.common.pojo.exception.BusinessException;
|
|
|
|
import com.njcn.common.pojo.exception.BusinessException;
|
|
|
|
|
|
|
|
import com.njcn.csdevice.api.CsLineFeignClient;
|
|
|
|
import com.njcn.csdevice.constant.DataParam;
|
|
|
|
import com.njcn.csdevice.constant.DataParam;
|
|
|
|
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
|
|
|
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
|
|
|
import com.njcn.csdevice.pojo.po.CsLinePO;
|
|
|
|
import com.njcn.csdevice.pojo.po.CsLinePO;
|
|
|
|
@@ -14,7 +15,10 @@ import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import pojo.param.ThdDataQueryParm;
|
|
|
|
import pojo.param.ThdDataQueryParm;
|
|
|
|
import pojo.vo.ThdDataVO;
|
|
|
|
import pojo.vo.ThdDataVO;
|
|
|
|
|
|
|
|
import com.njcn.influx.pojo.po.HarmonicRatioData;
|
|
|
|
|
|
|
|
import com.njcn.influx.pojo.po.PowerQualityData;
|
|
|
|
|
|
|
|
import com.njcn.influx.service.HaronicRatioService;
|
|
|
|
|
|
|
|
import com.njcn.influx.service.PowerQualityService;
|
|
|
|
import java.time.ZoneId;
|
|
|
|
import java.time.ZoneId;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
@@ -33,14 +37,14 @@ import java.util.stream.Collectors;
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
public class StableDataServiceImpl implements StableDataService {
|
|
|
|
public class StableDataServiceImpl implements StableDataService {
|
|
|
|
|
|
|
|
|
|
|
|
private final CsLinePOService csLinePOService;
|
|
|
|
private final CsLineFeignClient csLineFeignClient;
|
|
|
|
private final PowerQualityService powerQualityService;
|
|
|
|
private final PowerQualityService powerQualityService;
|
|
|
|
private final HarmonicRatioService harmonicRatioService;
|
|
|
|
private final HaronicRatioService harmonicRatioService;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<ThdDataVO> queryThdData(String devId, String statisticalName) {
|
|
|
|
public List<ThdDataVO> queryThdData(String devId, String statisticalName) {
|
|
|
|
List<ThdDataVO> thdDataVOList = new ArrayList<>();
|
|
|
|
List<ThdDataVO> thdDataVOList = new ArrayList<>();
|
|
|
|
List<CsLinePO> csLinePOList = csLinePOService.queryByDevId(devId);
|
|
|
|
List<CsLinePO> csLinePOList = csLineFeignClient.queryLineByDevId(devId).getData();
|
|
|
|
Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR));
|
|
|
|
Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR));
|
|
|
|
List<String> collect = csLinePOList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
|
|
|
|
List<String> collect = csLinePOList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
|
|
|
|
List<PowerQualityData> firstPowerQuality = powerQualityService.getFirstPowerQuality(collect, statisticalName);
|
|
|
|
List<PowerQualityData> firstPowerQuality = powerQualityService.getFirstPowerQuality(collect, statisticalName);
|
|
|
|
@@ -74,7 +78,7 @@ public class StableDataServiceImpl implements StableDataService {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<ThdDataVO> queryThdDataByTime(ThdDataQueryParm thdDataQueryParm) {
|
|
|
|
public List<ThdDataVO> queryThdDataByTime(ThdDataQueryParm thdDataQueryParm) {
|
|
|
|
List<ThdDataVO> thdDataVOList = new ArrayList<>();
|
|
|
|
List<ThdDataVO> thdDataVOList = new ArrayList<>();
|
|
|
|
List<CsLinePO> csLinePOList = csLinePOService.queryByDevId(thdDataQueryParm.getDevId());
|
|
|
|
List<CsLinePO> csLinePOList = csLineFeignClient.queryLineByDevId(thdDataQueryParm.getDevId()).getData();
|
|
|
|
Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR));
|
|
|
|
Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR));
|
|
|
|
List<String> collect = csLinePOList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
|
|
|
|
List<String> collect = csLinePOList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
|
|
|
|
List<PowerQualityData> firstPowerQuality = powerQualityService.getPowerQuality(collect, thdDataQueryParm.getStatisticalName(), thdDataQueryParm.getStartTime(), thdDataQueryParm.getEndTime());
|
|
|
|
List<PowerQualityData> firstPowerQuality = powerQualityService.getPowerQuality(collect, thdDataQueryParm.getStatisticalName(), thdDataQueryParm.getStartTime(), thdDataQueryParm.getEndTime());
|
|
|
|
@@ -108,10 +112,10 @@ public class StableDataServiceImpl implements StableDataService {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<ThdDataVO> queryFisrtThdContent(String devId, String statisticalName) {
|
|
|
|
public List<ThdDataVO> queryFisrtThdContent(String devId, String statisticalName) {
|
|
|
|
List<ThdDataVO> thdDataVOList = new ArrayList<>();
|
|
|
|
List<ThdDataVO> thdDataVOList = new ArrayList<>();
|
|
|
|
List<CsLinePO> csLinePOList = csLinePOService.queryByDevId(devId);
|
|
|
|
List<CsLinePO> csLinePOList = csLineFeignClient.queryLineByDevId(devId).getData();
|
|
|
|
Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR));
|
|
|
|
Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR));
|
|
|
|
List<String> collect = csLinePOList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
|
|
|
|
List<String> collect = csLinePOList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
|
|
|
|
List<HarmonicRatioData> harmonicRatioList = haronicRatioService.getFirstHaronicRatio(collect, statisticalName);
|
|
|
|
List<HarmonicRatioData> harmonicRatioList = harmonicRatioService.getFirstHaronicRatio(collect, statisticalName);
|
|
|
|
harmonicRatioList.forEach(temp->{
|
|
|
|
harmonicRatioList.forEach(temp->{
|
|
|
|
ThdDataVO thdDataVO = new ThdDataVO();
|
|
|
|
ThdDataVO thdDataVO = new ThdDataVO();
|
|
|
|
BeanUtils.copyProperties(temp,thdDataVO);
|
|
|
|
BeanUtils.copyProperties(temp,thdDataVO);
|
|
|
|
@@ -133,10 +137,10 @@ public class StableDataServiceImpl implements StableDataService {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<ThdDataVO> queryThdContentByTime(ThdDataQueryParm thdDataQueryParm) {
|
|
|
|
public List<ThdDataVO> queryThdContentByTime(ThdDataQueryParm thdDataQueryParm) {
|
|
|
|
List<ThdDataVO> thdDataVOList = new ArrayList<>();
|
|
|
|
List<ThdDataVO> thdDataVOList = new ArrayList<>();
|
|
|
|
List<CsLinePO> csLinePOList = csLinePOService.queryByDevId(thdDataQueryParm.getDevId());
|
|
|
|
List<CsLinePO> csLinePOList = csLineFeignClient.queryLineByDevId(thdDataQueryParm.getDevId()).getData();
|
|
|
|
Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR));
|
|
|
|
Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR));
|
|
|
|
List<String> collect = csLinePOList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
|
|
|
|
List<String> collect = csLinePOList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
|
|
|
|
List<HarmonicRatioData> harmonicRatioList = haronicRatioService.getHaronicRatio(collect, thdDataQueryParm.getStatisticalName(),thdDataQueryParm.getStartTime(), thdDataQueryParm.getEndTime());
|
|
|
|
List<HarmonicRatioData> harmonicRatioList = harmonicRatioService.getHaronicRatio(collect, thdDataQueryParm.getStatisticalName(),thdDataQueryParm.getStartTime(), thdDataQueryParm.getEndTime());
|
|
|
|
harmonicRatioList.forEach(temp->{
|
|
|
|
harmonicRatioList.forEach(temp->{
|
|
|
|
ThdDataVO thdDataVO = new ThdDataVO();
|
|
|
|
ThdDataVO thdDataVO = new ThdDataVO();
|
|
|
|
BeanUtils.copyProperties(temp,thdDataVO);
|
|
|
|
BeanUtils.copyProperties(temp,thdDataVO);
|
|
|
|
|