完成暂态算法和调整部分逻辑
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package com.njcn.dataProcess.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.dataProcess.api.fallback.EventDetailFeignClientClientFallbackFactory;
|
||||
import com.njcn.dataProcess.param.LineCountEvaluateParam;
|
||||
import com.njcn.dataProcess.pojo.dto.DataEventDetailDto;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: wr
|
||||
* @Date: 2025/3/7 9:30
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.PLATFORM_DATA_PROCESSING_BOOT, path = "/eventDetailCount", fallbackFactory = EventDetailFeignClientClientFallbackFactory.class, contextId = "eventDetailCount")
|
||||
public interface EventDetailFeignClient {
|
||||
|
||||
@PostMapping("/batchInsertionD")
|
||||
HttpResult<String> batchInsertionD(@RequestBody List<DataEventDetailDto> eventDetailDto);
|
||||
|
||||
@PostMapping("/batchInsertionM")
|
||||
HttpResult<String> batchInsertionM(@RequestBody List<DataEventDetailDto> eventDetailDto);
|
||||
|
||||
@PostMapping("/batchInsertionQ")
|
||||
HttpResult<String> batchInsertionQ(@RequestBody List<DataEventDetailDto> eventDetailDto);
|
||||
|
||||
@PostMapping("/batchInsertionY")
|
||||
HttpResult<String> batchInsertionY(@RequestBody List<DataEventDetailDto> eventDetailDto);
|
||||
|
||||
@PostMapping("/getRawDataD")
|
||||
HttpResult<List<DataEventDetailDto>> getRawDataD(@RequestBody LineCountEvaluateParam lineParam);
|
||||
|
||||
@PostMapping("/getRawDataM")
|
||||
HttpResult<List<DataEventDetailDto>> getRawDataM(@RequestBody LineCountEvaluateParam lineParam);
|
||||
|
||||
@PostMapping("/getRawDataQ")
|
||||
HttpResult<List<DataEventDetailDto>> getRawDataQ(@RequestBody LineCountEvaluateParam lineParam);
|
||||
}
|
||||
@@ -5,10 +5,13 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
|
||||
import com.njcn.dataProcess.api.fallback.RmpEventFeignClientFallbackFactory;
|
||||
import com.njcn.dataProcess.dto.RmpEventDetailDTO;
|
||||
import com.njcn.dataProcess.param.LineCountEvaluateParam;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
@@ -17,9 +20,9 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
@FeignClient(value = ServerInfo.PLATFORM_DATA_PROCESSING_BOOT, path = "/rmpEventDetail", fallbackFactory = RmpEventFeignClientFallbackFactory.class, contextId = "rmpEventDetail")
|
||||
public interface RmpEventDetailFeignClient {
|
||||
|
||||
|
||||
|
||||
@PostMapping("/batchInsertion")
|
||||
HttpResult<String> batchInsertion(@RequestBody RmpEventDetailDTO rmpEventDetailDTO);
|
||||
|
||||
@PostMapping("/getRawData")
|
||||
HttpResult<List<RmpEventDetailDTO>> getRawData(@RequestBody LineCountEvaluateParam lineParam);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.njcn.dataProcess.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.dataProcess.api.EventDetailFeignClient;
|
||||
import com.njcn.dataProcess.api.PqDataVerifyFeignClient;
|
||||
import com.njcn.dataProcess.param.LineCountEvaluateParam;
|
||||
import com.njcn.dataProcess.pojo.dto.DataEventDetailDto;
|
||||
import com.njcn.dataProcess.pojo.po.PqDataVerify;
|
||||
import com.njcn.dataProcess.util.DataProcessingEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
* @version 1.0.0
|
||||
* @date 2025年02月13日 20:13
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class EventDetailFeignClientClientFallbackFactory implements FallbackFactory<EventDetailFeignClient> {
|
||||
|
||||
/**
|
||||
* 输出远程请求接口异常日志
|
||||
* @param cause RPC请求异常
|
||||
*/
|
||||
@Override
|
||||
public EventDetailFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if(cause.getCause() instanceof BusinessException){
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
exceptionEnum = DataProcessingEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new EventDetailFeignClient() {
|
||||
|
||||
|
||||
@Override
|
||||
public HttpResult<String> batchInsertionD(List<DataEventDetailDto> eventDetailDto) {
|
||||
log.error("{}异常,降级处理,异常为:{}","暂态事件(天)统计批量插入",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<String> batchInsertionM(List<DataEventDetailDto> eventDetailDto) {
|
||||
log.error("{}异常,降级处理,异常为:{}","暂态事件(月)统计批量插入",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<String> batchInsertionQ(List<DataEventDetailDto> eventDetailDto) {
|
||||
log.error("{}异常,降级处理,异常为:{}","暂态事件(季)统计批量插入",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<String> batchInsertionY(List<DataEventDetailDto> eventDetailDto) {
|
||||
log.error("{}异常,降级处理,异常为:{}","暂态事件(年)统计批量插入",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<DataEventDetailDto>> getRawDataD(LineCountEvaluateParam lineParam) {
|
||||
log.error("{}异常,降级处理,异常为:{}","获取(天)原始数据",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<DataEventDetailDto>> getRawDataM(LineCountEvaluateParam lineParam) {
|
||||
log.error("{}异常,降级处理,异常为:{}","获取(月)原始数据",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<DataEventDetailDto>> getRawDataQ(LineCountEvaluateParam lineParam) {
|
||||
log.error("{}异常,降级处理,异常为:{}","获取(季)原始数据",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,14 @@ import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.dataProcess.api.RmpEventDetailFeignClient;
|
||||
import com.njcn.dataProcess.dto.RmpEventDetailDTO;
|
||||
import com.njcn.dataProcess.param.LineCountEvaluateParam;
|
||||
import com.njcn.dataProcess.util.DataProcessingEnumUtil;
|
||||
import com.njcn.system.utils.SystemEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
@@ -42,6 +44,12 @@ public class RmpEventFeignClientFallbackFactory implements FallbackFactory<RmpEv
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<RmpEventDetailDTO>> getRawData(LineCountEvaluateParam lineParam) {
|
||||
log.error("{}异常,降级处理,异常为:{}","获取时间范围数据",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ public class RmpEventDetailDTO implements Serializable {
|
||||
@ApiModelProperty(value = "暂时事件ID")
|
||||
private String eventId;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "监测点ID(复制)")
|
||||
private String measurementPointId;
|
||||
|
||||
|
||||
@@ -105,4 +105,45 @@ public class TimeUtils {
|
||||
DateUtil.parse(time, DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATETIME_PATTERN);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据日期获取当月零点时间
|
||||
* String类型的yyyy-MM-dd转成yyyy-MM-dd HH:mm:ss
|
||||
*/
|
||||
public static String getBeginOfQuarter(String time) {
|
||||
return DateUtil.format(
|
||||
DateUtil.beginOfQuarter(
|
||||
DateUtil.parse(time, DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATETIME_PATTERN);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据日期获取当月结束时间
|
||||
* String类型的yyyy-MM-dd转成yyyy-MM-dd HH:mm:ss
|
||||
*/
|
||||
public static String getEndOfQuarter(String time) {
|
||||
return DateUtil.format(
|
||||
DateUtil.endOfQuarter(
|
||||
DateUtil.parse(time, DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATETIME_PATTERN);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据日期获取当月零点时间
|
||||
* String类型的yyyy-MM-dd转成yyyy-MM-dd HH:mm:ss
|
||||
*/
|
||||
public static String getBeginOfYear(String time) {
|
||||
return DateUtil.format(
|
||||
DateUtil.beginOfYear(
|
||||
DateUtil.parse(time, DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATETIME_PATTERN);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据日期获取当月结束时间
|
||||
* String类型的yyyy-MM-dd转成yyyy-MM-dd HH:mm:ss
|
||||
*/
|
||||
public static String getEndOfYear(String time) {
|
||||
return DateUtil.format(
|
||||
DateUtil.endOfYear(
|
||||
DateUtil.parse(time, DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATETIME_PATTERN);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user