补充新更新

This commit is contained in:
2022-06-22 09:14:52 +08:00
parent 59da3376c1
commit 6870c2ccc3
323 changed files with 18518 additions and 441 deletions

View File

@@ -0,0 +1,27 @@
package com.njcn.quality.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.quality.api.fallback.EleOnlineRateFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* pqs
*
* @author cdf
* @date 2022/4/22
*/
@FeignClient(value = ServerInfo.ENERGY,path = "/air",fallbackFactory = EleOnlineRateFallbackFactory.class)
public interface EleAirStrategyFeignClient {
/**
* 获取策略下的监测点
* @author cdf
* @date 2022/4/22
*/
@GetMapping("dealAirStrategyId")
HttpResult<Boolean> dealAirStrategyId(@RequestParam("id") String id,@RequestParam("operation") String operation);
}

View File

@@ -0,0 +1,27 @@
package com.njcn.quality.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.quality.api.fallback.EleIntegrityFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import java.util.List;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2022/4/20 15:08
*/
@FeignClient(value = ServerInfo.ENERGY,path = "/integrity",fallbackFactory = EleIntegrityFallbackFactory.class)
public interface EleIntegrityFeignClient {
@PostMapping("/getPowerLineId")
HttpResult<List<String>> getPowerLineId();
@PostMapping("/getAirLineId")
HttpResult<List<String>> getAirLineId();
}

View File

@@ -0,0 +1,26 @@
package com.njcn.quality.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.quality.api.fallback.EleOnlineRateFallbackFactory;
import com.njcn.quality.pojo.dto.OnlineRateDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2022/4/20 15:08
*/
@FeignClient(value = ServerInfo.ENERGY,path = "/onlineRate",fallbackFactory = EleOnlineRateFallbackFactory.class)
public interface EleOnlineRateFeignClient {
@PostMapping("/getDeviceTime")
HttpResult<List<OnlineRateDTO>> getDeviceTime(@RequestParam("startTime") String startTime, @RequestParam("endTime") String endTime);
}

View File

@@ -0,0 +1,41 @@
package com.njcn.quality.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.quality.api.EleAirStrategyFeignClient;
import com.njcn.quality.utils.EnergyEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2022/4/20 15:09
*/
@Slf4j
@Component
public class EleAirStrategyFallbackFactory implements FallbackFactory<EleAirStrategyFeignClient> {
@Override
public EleAirStrategyFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if(cause.getCause() instanceof BusinessException){
BusinessException businessException = (BusinessException) cause.getCause();
exceptionEnum = EnergyEnumUtil.getExceptionEnum(businessException.getResult());
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new EleAirStrategyFeignClient() {
@Override
public HttpResult<Boolean> dealAirStrategyId(String id,String operation) {
log.error("{}异常,降级处理,异常为:{}","空调控制策略数据",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,48 @@
package com.njcn.quality.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.quality.api.EleIntegrityFeignClient;
import com.njcn.quality.utils.EnergyEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2022/4/20 15:09
*/
@Slf4j
@Component
public class EleIntegrityFallbackFactory implements FallbackFactory<EleIntegrityFeignClient> {
@Override
public EleIntegrityFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if(cause.getCause() instanceof BusinessException){
BusinessException businessException = (BusinessException) cause.getCause();
exceptionEnum = EnergyEnumUtil.getExceptionEnum(businessException.getResult());
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new EleIntegrityFeignClient() {
@Override
public HttpResult<List<String>> getPowerLineId() {
log.error("{}异常,降级处理,异常为:{}","获取在线用采监测点",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<String>> getAirLineId() {
log.error("{}异常,降级处理,异常为:{}","获取在线空调监测点",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,44 @@
package com.njcn.quality.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.quality.api.EleOnlineRateFeignClient;
import com.njcn.quality.pojo.dto.OnlineRateDTO;
import com.njcn.quality.utils.EnergyEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2022/4/20 15:09
*/
@Slf4j
@Component
public class EleOnlineRateFallbackFactory implements FallbackFactory<EleOnlineRateFeignClient> {
@Override
public EleOnlineRateFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if(cause.getCause() instanceof BusinessException){
BusinessException businessException = (BusinessException) cause.getCause();
exceptionEnum = EnergyEnumUtil.getExceptionEnum(businessException.getResult());
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new EleOnlineRateFeignClient() {
@Override
public HttpResult<List<OnlineRateDTO>> getDeviceTime(String startTime, String endTime) {
log.error("{}异常,降级处理,异常为:{}","装置在线率数据",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}