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

View File

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

View File

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

View File

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

View File

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