移动代码

This commit is contained in:
huangzj
2023-05-25 15:08:25 +08:00
parent 9e0d40b6fa
commit bc9e54d56f
4 changed files with 34 additions and 10 deletions

View File

@@ -4,6 +4,8 @@ import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.fallback.CsLineClientFallbackFactory;
import com.njcn.csdevice.pojo.po.CsLinePO;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
@@ -18,5 +20,8 @@ public interface CsLineFeignClient {
@PostMapping("/queryLineById")
public HttpResult<List<CsLinePO>> queryLineById(@RequestParam("ids") List<String> ids );
HttpResult<List<CsLinePO>> queryLineById(@RequestParam("ids") List<String> ids );
@PostMapping("/queryLineByDevId")
HttpResult<List<CsLinePO>> queryLineByDevId(@RequestParam("id") String id);
}

View File

@@ -33,6 +33,11 @@ public class CsLineClientFallbackFactory implements FallbackFactory<CsLineFeignC
log.error("{}异常,降级处理,异常为:{}","查询监测点详情异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<CsLinePO>> queryLineByDevId(String id) {
log.error("{}异常,降级处理,异常为:{}","查询监测点详情异常",cause.toString());
throw new BusinessException(finalExceptionEnum); }
};
}
}

View File

@@ -45,4 +45,14 @@ public class CslineController extends BaseController {
List<CsLinePO> csLinePOS = csLinePOService.listByIds(ids);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csLinePOS, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryLineByDevId")
@ApiOperation("项目查询通过id获取")
@ApiImplicitParam(name = "id", value = "项目id集合", required = true)
public HttpResult<List<CsLinePO>> queryLineByDevId(@RequestParam String id){
String methodDescribe = getMethodDescribe("queryLineByDevId");
List<CsLinePO> csLinePOS = csLinePOService.queryByDevId(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csLinePOS, methodDescribe);
}
}

View File

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