代码调整
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
package com.njcn.harmonic.api;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.constant.ServerInfo;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.harmonic.api.fallback.UploadGwDataFallbackFactory;
|
||||||
|
import com.njcn.harmonic.pojo.param.UploadParam;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xuyang
|
||||||
|
*/
|
||||||
|
@FeignClient(
|
||||||
|
value = ServerInfo.HARMONIC,
|
||||||
|
path = "/upload",
|
||||||
|
fallbackFactory = UploadGwDataFallbackFactory.class,
|
||||||
|
contextId = "upload")
|
||||||
|
public interface UploadGwDataFeignClient {
|
||||||
|
|
||||||
|
@PostMapping("/uploadPointStatisticalData")
|
||||||
|
HttpResult<String> uploadPointStatisticalData(@RequestBody UploadParam param);
|
||||||
|
|
||||||
|
@PostMapping("/uploadSubstationStatisticalData")
|
||||||
|
HttpResult<String> uploadSubstationStatisticalData(@RequestBody UploadParam param);
|
||||||
|
|
||||||
|
@PostMapping("/uploadEvaluationData")
|
||||||
|
HttpResult<String> uploadEvaluationData(@RequestBody UploadParam param);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package com.njcn.harmonic.api.fallback;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.harmonic.api.UploadGwDataFeignClient;
|
||||||
|
import com.njcn.harmonic.pojo.param.UploadParam;
|
||||||
|
import com.njcn.harmonic.utils.HarmonicEnumUtil;
|
||||||
|
import feign.hystrix.FallbackFactory;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @date 2023年12月15日 13:50
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class UploadGwDataFallbackFactory implements FallbackFactory<UploadGwDataFeignClient> {
|
||||||
|
@Override
|
||||||
|
public UploadGwDataFeignClient create(Throwable throwable) {
|
||||||
|
//判断抛出异常是否为解码器抛出的业务异常
|
||||||
|
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||||
|
if (throwable.getCause() instanceof BusinessException) {
|
||||||
|
BusinessException businessException = (BusinessException) throwable.getCause();
|
||||||
|
exceptionEnum = HarmonicEnumUtil.getExceptionEnum(businessException.getResult());
|
||||||
|
}
|
||||||
|
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||||
|
return new UploadGwDataFeignClient() {
|
||||||
|
@Override
|
||||||
|
public HttpResult<String> uploadPointStatisticalData(UploadParam param) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}", "国网上送-主配网监测点统计数据", throwable.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<String> uploadSubstationStatisticalData(UploadParam param) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}", "国网上送-变电站监测统计数据", throwable.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<String> uploadEvaluationData(UploadParam param) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}", "国网上送-母线基准水平评估数据", throwable.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,6 +55,7 @@ public class PointStatisticalDataServiceImpl extends ServiceImpl<RUploadPointSta
|
|||||||
pageVo.setPages(page.getPages());
|
pageVo.setPages(page.getPages());
|
||||||
pageVo.setSize(page.getSize());
|
pageVo.setSize(page.getSize());
|
||||||
pageVo.setRecords(voList);
|
pageVo.setRecords(voList);
|
||||||
|
pageVo.setCurrent(page.getCurrent());
|
||||||
return pageVo;
|
return pageVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +63,7 @@ public class PointStatisticalDataServiceImpl extends ServiceImpl<RUploadPointSta
|
|||||||
public String uploadPointStatisticalData(UploadParam param) {
|
public String uploadPointStatisticalData(UploadParam param) {
|
||||||
List<RUploadPointStatisticalDataD> list;
|
List<RUploadPointStatisticalDataD> list;
|
||||||
//指定数据上送,不管之前有没有上送,都重新上送一次
|
//指定数据上送,不管之前有没有上送,都重新上送一次
|
||||||
//(预防之前送上过,修改数据后需要再次上送)
|
//(预防之前上送过,修改数据后需要再次上送)
|
||||||
if (CollectionUtil.isNotEmpty(param.getList())){
|
if (CollectionUtil.isNotEmpty(param.getList())){
|
||||||
list = this.lambdaQuery()
|
list = this.lambdaQuery()
|
||||||
.eq(RUploadPointStatisticalDataD::getStatisticalDate,param.getTime())
|
.eq(RUploadPointStatisticalDataD::getStatisticalDate,param.getTime())
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.apache.commons.collections4.ListUtils;
|
import org.apache.commons.collections4.ListUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -61,6 +62,7 @@ public class REvaluationDataServiceImpl extends ServiceImpl<RUploadEvaluationDat
|
|||||||
pageVo.setPages(page.getPages());
|
pageVo.setPages(page.getPages());
|
||||||
pageVo.setSize(page.getSize());
|
pageVo.setSize(page.getSize());
|
||||||
pageVo.setRecords(voList);
|
pageVo.setRecords(voList);
|
||||||
|
pageVo.setCurrent(page.getCurrent());
|
||||||
return pageVo;
|
return pageVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +70,7 @@ public class REvaluationDataServiceImpl extends ServiceImpl<RUploadEvaluationDat
|
|||||||
public String uploadEvaluationData(UploadParam param) {
|
public String uploadEvaluationData(UploadParam param) {
|
||||||
List<RUploadEvaluationDataD> list;
|
List<RUploadEvaluationDataD> list;
|
||||||
//指定数据上送,不管之前有没有上送,都重新上送一次
|
//指定数据上送,不管之前有没有上送,都重新上送一次
|
||||||
//(预防之前送上过,修改数据后需要再次上送)
|
//(预防之前上送过,修改数据后需要再次上送)
|
||||||
if (CollectionUtil.isNotEmpty(param.getList())){
|
if (CollectionUtil.isNotEmpty(param.getList())){
|
||||||
list = this.lambdaQuery()
|
list = this.lambdaQuery()
|
||||||
.eq(RUploadEvaluationDataD::getStatisticalDate,param.getTime())
|
.eq(RUploadEvaluationDataD::getStatisticalDate,param.getTime())
|
||||||
@@ -91,10 +93,17 @@ public class REvaluationDataServiceImpl extends ServiceImpl<RUploadEvaluationDat
|
|||||||
List<PqEvaluationCreateDTO> l1 = pendingIds.get(i).stream().peek(item->{
|
List<PqEvaluationCreateDTO> l1 = pendingIds.get(i).stream().peek(item->{
|
||||||
if (Objects.equals(item.getAvgValue(),3.1415926)){
|
if (Objects.equals(item.getAvgValue(),3.1415926)){
|
||||||
item.setAvgValue(0d);
|
item.setAvgValue(0d);
|
||||||
|
} else {
|
||||||
|
BigDecimal four = BigDecimal.valueOf(item.getAvgValue());
|
||||||
|
double value = four.setScale(4,BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||||
|
item.setAvgValue(value);
|
||||||
}
|
}
|
||||||
if (Objects.equals(item.getStandardDeviation(),3.1415926)){
|
if (Objects.equals(item.getStandardDeviation(),3.1415926)){
|
||||||
item.setStandardDeviation(0d);
|
item.setStandardDeviation(0d);
|
||||||
}
|
}
|
||||||
|
BigDecimal four = BigDecimal.valueOf(item.getMonitorBusRate());
|
||||||
|
double value = four.setScale(4,BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||||
|
item.setMonitorBusRate(value);
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
//组装数据
|
//组装数据
|
||||||
SendParam sp = new SendParam();
|
SendParam sp = new SendParam();
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ public class RSubstationStatisticalDataServiceImpl extends ServiceImpl<RUploadSu
|
|||||||
pageVo.setPages(page.getPages());
|
pageVo.setPages(page.getPages());
|
||||||
pageVo.setSize(page.getSize());
|
pageVo.setSize(page.getSize());
|
||||||
pageVo.setRecords(voList);
|
pageVo.setRecords(voList);
|
||||||
|
pageVo.setCurrent(page.getCurrent());
|
||||||
return pageVo;
|
return pageVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +69,7 @@ public class RSubstationStatisticalDataServiceImpl extends ServiceImpl<RUploadSu
|
|||||||
|
|
||||||
List<RUploadSubstationStatisticalDataD> list;
|
List<RUploadSubstationStatisticalDataD> list;
|
||||||
//指定数据上送,不管之前有没有上送,都重新上送一次
|
//指定数据上送,不管之前有没有上送,都重新上送一次
|
||||||
//(预防之前送上过,修改数据后需要再次上送)
|
//(预防之前上送过,修改数据后需要再次上送)
|
||||||
if (CollectionUtil.isNotEmpty(param.getList())){
|
if (CollectionUtil.isNotEmpty(param.getList())){
|
||||||
list = this.lambdaQuery()
|
list = this.lambdaQuery()
|
||||||
.eq(RUploadSubstationStatisticalDataD::getStatisticalDate,param.getTime())
|
.eq(RUploadSubstationStatisticalDataD::getStatisticalDate,param.getTime())
|
||||||
|
|||||||
@@ -68,6 +68,11 @@
|
|||||||
<artifactId>process-api</artifactId>
|
<artifactId>process-api</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.njcn</groupId>
|
||||||
|
<artifactId>harmonic-api</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class deviceTaskRunner implements TimerTaskRunner {
|
public class DeviceTaskRunner implements TimerTaskRunner {
|
||||||
|
|
||||||
private final LiteFlowFeignClient liteFlowFeignClient;
|
private final LiteFlowFeignClient liteFlowFeignClient;
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class generaTrixTaskRunner implements TimerTaskRunner {
|
public class GeneraTrixTaskRunner implements TimerTaskRunner {
|
||||||
|
|
||||||
private final LiteFlowFeignClient liteFlowFeignClient;
|
private final LiteFlowFeignClient liteFlowFeignClient;
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class measurementTaskRunner implements TimerTaskRunner {
|
public class MeasurementTaskRunner implements TimerTaskRunner {
|
||||||
|
|
||||||
private final LiteFlowFeignClient liteFlowFeignClient;
|
private final LiteFlowFeignClient liteFlowFeignClient;
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class orgTaskRunner implements TimerTaskRunner {
|
public class OrgTaskRunner implements TimerTaskRunner {
|
||||||
|
|
||||||
private final LiteFlowFeignClient liteFlowFeignClient;
|
private final LiteFlowFeignClient liteFlowFeignClient;
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class pmsDimTaskRunner implements TimerTaskRunner {
|
public class PmsDimTaskRunner implements TimerTaskRunner {
|
||||||
|
|
||||||
private final LiteFlowFeignClient liteFlowFeignClient;
|
private final LiteFlowFeignClient liteFlowFeignClient;
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ import java.util.Objects;
|
|||||||
@Component
|
@Component
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class pmsStatisticsSpecialMonitorTaskRunner implements TimerTaskRunner {
|
public class PmsStatisticsSpecialMonitorTaskRunner implements TimerTaskRunner {
|
||||||
|
|
||||||
private final PmsStatisticsSpecialMonitorFeignClient pmsStatisticsSpecialMonitorFeignClient;
|
private final PmsStatisticsSpecialMonitorFeignClient pmsStatisticsSpecialMonitorFeignClient;
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ import java.time.format.DateTimeFormatter;
|
|||||||
@Component
|
@Component
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class statisticReportTaskRunner implements TimerTaskRunner {
|
public class StatisticReportTaskRunner implements TimerTaskRunner {
|
||||||
private final SupvStatisticReportMFeignClient supvStatisticReportMFeignClient;
|
private final SupvStatisticReportMFeignClient supvStatisticReportMFeignClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class substationTaskRunner implements TimerTaskRunner {
|
public class SubstationTaskRunner implements TimerTaskRunner {
|
||||||
|
|
||||||
private final LiteFlowFeignClient liteFlowFeignClient;
|
private final LiteFlowFeignClient liteFlowFeignClient;
|
||||||
|
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.njcn.system.timer.tasks;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.njcn.harmonic.api.UploadGwDataFeignClient;
|
||||||
|
import com.njcn.harmonic.pojo.param.UploadParam;
|
||||||
|
import com.njcn.system.timer.TimerTaskRunner;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:国网数据每日上送定时任务
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2023/12/15 13:45
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class UploadGwTaskRunner implements TimerTaskRunner {
|
||||||
|
|
||||||
|
private final UploadGwDataFeignClient uploadGwDataFeignClient;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void action() {
|
||||||
|
UploadParam param = new UploadParam();
|
||||||
|
param.setTime(DateUtil.yesterday().toString(DatePattern.NORM_DATE_PATTERN));
|
||||||
|
uploadGwDataFeignClient.uploadPointStatisticalData(param);
|
||||||
|
uploadGwDataFeignClient.uploadSubstationStatisticalData(param);
|
||||||
|
uploadGwDataFeignClient.uploadEvaluationData(param);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user