修改FeignClient接口名称和服务降级处理类名称及路径

This commit is contained in:
wr
2025-03-25 20:29:59 +08:00
parent 3ced1ce287
commit 92aa6063eb
5 changed files with 28 additions and 20 deletions

View File

@@ -2,7 +2,7 @@ package com.njcn.algorithm.pojo.liteflow;
import com.njcn.algorithm.pojo.bo.BaseParam;
import com.njcn.algorithm.pojo.liteflow.fallback.LiteFlowFeignClientFallbackFactory;
import com.njcn.algorithm.pojo.liteflow.fallback.LiteFlowAlgorithmFeignClientFallbackFactory;
import com.njcn.common.pojo.constant.ServerInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
@@ -13,11 +13,11 @@ import org.springframework.web.bind.annotation.RequestBody;
* @author xuyang
*/
@FeignClient(
value = ServerInfo.DATA_PLATFORM,//对应模块名
path = "/executor",//对应controller请求类
fallbackFactory = LiteFlowFeignClientFallbackFactory.class//服务降级处理类
value = ServerInfo.ALGORITHM_BOOT,//对应模块名
path = "/algorithmExecutor",//对应controller请求类
fallbackFactory = LiteFlowAlgorithmFeignClientFallbackFactory.class//服务降级处理类
)
public interface LiteFlowFeignClient {
public interface LiteFlowAlgorithmFeignClient {
@ApiOperation("监测点算法执行链")
@PostMapping("/measurementPointExecutor")

View File

@@ -1,7 +1,7 @@
package com.njcn.algorithm.pojo.liteflow.fallback;
import com.njcn.algorithm.pojo.bo.BaseParam;
import com.njcn.algorithm.pojo.liteflow.LiteFlowFeignClient;
import com.njcn.algorithm.pojo.liteflow.LiteFlowAlgorithmFeignClient;
import com.njcn.algorithm.pojo.util.PrepareEnumUtil;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
@@ -11,9 +11,9 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
public class LiteFlowFeignClientFallbackFactory implements FallbackFactory<LiteFlowFeignClient> {
public class LiteFlowAlgorithmFeignClientFallbackFactory implements FallbackFactory<LiteFlowAlgorithmFeignClient> {
@Override
public LiteFlowFeignClient create(Throwable throwable) {
public LiteFlowAlgorithmFeignClient create(Throwable throwable) {
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (throwable.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException)throwable.getCause();
@@ -21,7 +21,7 @@ public class LiteFlowFeignClientFallbackFactory implements FallbackFactory<LiteF
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new LiteFlowFeignClient() {
return new LiteFlowAlgorithmFeignClient() {
@Override
public void measurementPointExecutor(BaseParam baseParam) {
log.error("{}异常,降级处理,异常为:{}", "监测点算法执行链: ", throwable.toString());

View File

@@ -50,7 +50,7 @@ import java.util.stream.Collectors;
@Slf4j
@Api(tags = "算法执行中心")
@RestController
@RequestMapping("/executor")
@RequestMapping("/algorithmExecutor")
@RequiredArgsConstructor
public class ExecutionCenter extends BaseController {

View File

@@ -147,12 +147,16 @@ public class InfluxdbDataFlickerImpl extends MppServiceImpl<RStatDataFlickerRela
List<DataFlicker> list = dataFlickerMapper.selectByQueryWrapper(influxQueryWrapper);
if (CollUtil.isNotEmpty(list)) {
Map<String, List<String>> abnormalTime = lineParam.getAbnormalTime();
if (abnormalTime.containsKey(lineParam.getLineId().get(0))) {
List<String> timeList = abnormalTime.get(lineParam.getLineId().get(0));
//有异常数据,当前监测点自身的异常数据
if (CollectionUtil.isNotEmpty(timeList)) {
result.addAll(list.stream().filter(item -> !timeList.contains(DATE_TIME_FORMATTER.format(item.getTime()))).collect(Collectors.toList()));
if (CollUtil.isNotEmpty(abnormalTime)){
if (abnormalTime.containsKey(lineParam.getLineId().get(0))) {
List<String> timeList = abnormalTime.get(lineParam.getLineId().get(0));
//有异常数据,当前监测点自身的异常数据
if (CollectionUtil.isNotEmpty(timeList)) {
result.addAll(list.stream().filter(item -> !timeList.contains(DATE_TIME_FORMATTER.format(item.getTime()))).collect(Collectors.toList()));
}
}
}else{
result.addAll(list);
}
}
return result.size();

View File

@@ -185,12 +185,16 @@ public class InfluxdbDataVImpl extends MppServiceImpl<RStatDataVRelationMapper,
List<DataV> list = dataVMapper.selectByQueryWrapper(influxQueryWrapper);
if (CollUtil.isNotEmpty(list)) {
Map<String, List<String>> abnormalTime = lineParam.getAbnormalTime();
if (abnormalTime.containsKey(lineParam.getLineId().get(0))) {
List<String> timeList = abnormalTime.get(lineParam.getLineId().get(0));
//有异常数据,当前监测点自身的异常数据
if (CollectionUtil.isNotEmpty(timeList)) {
result.addAll(list.stream().filter(item -> !timeList.contains(DATE_TIME_FORMATTER.format(item.getTime()))).collect(Collectors.toList()));
if(CollUtil.isNotEmpty(abnormalTime)){
if (abnormalTime.containsKey(lineParam.getLineId().get(0))) {
List<String> timeList = abnormalTime.get(lineParam.getLineId().get(0));
//有异常数据,当前监测点自身的异常数据
if (CollectionUtil.isNotEmpty(timeList)) {
result.addAll(list.stream().filter(item -> !timeList.contains(DATE_TIME_FORMATTER.format(item.getTime()))).collect(Collectors.toList()));
}
}
}else{
result.addAll(list);
}
}
return result.size();