移动代码
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package com.njcn.csdevice.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.fallback.AppProjectClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.po.AppProjectPO;
|
||||
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 xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/project", fallbackFactory = AppProjectClientFallbackFactory.class,contextId = "approject")
|
||||
public interface AppProjectFeignClient {
|
||||
|
||||
|
||||
@PostMapping("/queryProjectById")
|
||||
HttpResult<List<AppProjectPO>> queryProjectById(@RequestParam("ids") List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.csdevice.api;
|
||||
|
||||
import com.njcn.csdevice.api.fallback.CsEdDataFeignClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.dto.CsDictDTO;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/dict", fallbackFactory = CsEdDataFeignClientFallbackFactory.class,contextId = "edData")
|
||||
public interface CsDictFeignClient {
|
||||
|
||||
@PostMapping("/getOwnAndFatherData")
|
||||
HttpResult<CsDictDTO> getOwnAndFatherData(@RequestParam("name")String name);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.njcn.csdevice.api;
|
||||
|
||||
import com.njcn.csdevice.api.fallback.CsEdDataFeignClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.po.CsEdDataPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsEdDataVO;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
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 xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/edData", fallbackFactory = CsEdDataFeignClientFallbackFactory.class,contextId = "edData")
|
||||
public interface CsEdDataFeignClient {
|
||||
|
||||
@PostMapping("/findByDevTypeId")
|
||||
HttpResult<CsEdDataVO> findByDevTypeId(@RequestParam("devType") String devType);
|
||||
|
||||
@PostMapping("/getAll")
|
||||
HttpResult<List<CsEdDataPO>> getAll(@RequestParam("devType") String devType);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.csdevice.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.fallback.CsLineClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
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 xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/csline", fallbackFactory = CsLineClientFallbackFactory.class,contextId = "csline")
|
||||
public interface CsLineFeignClient {
|
||||
|
||||
|
||||
@PostMapping("/queryLineById")
|
||||
public HttpResult<List<CsLinePO>> queryLineById(@RequestParam("ids") List<String> ids );
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.njcn.csdevice.api;
|
||||
|
||||
import com.njcn.csdevice.api.fallback.DevModelFeignClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.param.CsDevModelAddParm;
|
||||
import com.njcn.csdevice.pojo.param.CsDevModelQueryListParm;
|
||||
import com.njcn.csdevice.pojo.po.CsDevModelPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsDevModelPageVO;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/devmodel", fallbackFactory = DevModelFeignClientFallbackFactory.class,contextId = "devmodel")
|
||||
|
||||
public interface DevModelFeignClient {
|
||||
|
||||
@PostMapping("/addDevModel")
|
||||
HttpResult<CsDevModelPO> addDevModel(@RequestBody @Validated CsDevModelAddParm csDevModelAddParm);
|
||||
|
||||
@PostMapping("/queryDevModelOne")
|
||||
HttpResult<CsDevModelPageVO> queryDevModelOne(@RequestBody CsDevModelQueryListParm csDevModelQueryListParm);
|
||||
|
||||
@PostMapping("/findModel")
|
||||
HttpResult<CsDevModelPO> findModel(@RequestParam("devType") String devType, @RequestParam("version") String version, @RequestParam("time") String time);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.njcn.csdevice.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.fallback.EquipmentFeignClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
||||
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 xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/EquipmentDelivery", fallbackFactory = EquipmentFeignClientFallbackFactory.class,contextId = "EquipmentDelivery")
|
||||
public interface EquipmentFeignClient {
|
||||
|
||||
@PostMapping("/queryEquipmentByndid")
|
||||
HttpResult<CsEquipmentDeliveryVO> queryEquipmentByndid(@RequestParam("ndid") String ndid);
|
||||
|
||||
@PostMapping("/updateStatusBynDid")
|
||||
HttpResult<Boolean> updateStatusBynDid(@RequestParam("nDId") String nDid,@RequestParam("status") Integer status);
|
||||
@PostMapping("/queryEquipmentById")
|
||||
HttpResult<List<CsEquipmentDeliveryPO>> queryDeviceById(@RequestParam("ids") List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.njcn.csdevice.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.csdevice.api.AppProjectFeignClient;
|
||||
import com.njcn.csdevice.pojo.po.AppProjectPO;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AppProjectClientFallbackFactory implements FallbackFactory<AppProjectFeignClient> {
|
||||
@Override
|
||||
public AppProjectFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new AppProjectFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<List<AppProjectPO>> queryProjectById(List<String> ids) {
|
||||
log.error("{}异常,降级处理,异常为:{}","获取项目详情接口异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.njcn.csdevice.api.fallback;
|
||||
|
||||
import com.njcn.csdevice.api.CsDictFeignClient;
|
||||
import com.njcn.csdevice.pojo.dto.CsDictDTO;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CsDictFeignClientFallbackFactory implements FallbackFactory<CsDictFeignClient> {
|
||||
@Override
|
||||
public CsDictFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new CsDictFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<CsDictDTO> getOwnAndFatherData(String name) {
|
||||
log.error("{}异常,降级处理,异常为:{}","获取指标自身和父级信息",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.njcn.csdevice.api.fallback;
|
||||
|
||||
import com.njcn.csdevice.api.CsEdDataFeignClient;
|
||||
import com.njcn.csdevice.pojo.po.CsEdDataPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsEdDataVO;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CsEdDataFeignClientFallbackFactory implements FallbackFactory<CsEdDataFeignClient> {
|
||||
@Override
|
||||
public CsEdDataFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new CsEdDataFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<CsEdDataVO> findByDevTypeId(String devType) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据装置型号获取装置类型",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<CsEdDataPO>> getAll(String devType) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据装置型号获取装置类型",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.njcn.csdevice.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.csdevice.api.CsLineFeignClient;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CsLineClientFallbackFactory implements FallbackFactory<CsLineFeignClient> {
|
||||
@Override
|
||||
public CsLineFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new CsLineFeignClient() {
|
||||
|
||||
|
||||
@Override
|
||||
public HttpResult<List<CsLinePO>> queryLineById(List<String> ids) {
|
||||
log.error("{}异常,降级处理,异常为:{}","查询监测点详情异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.njcn.csdevice.api.fallback;
|
||||
|
||||
import com.njcn.csdevice.api.DevModelFeignClient;
|
||||
import com.njcn.csdevice.pojo.param.CsDevModelAddParm;
|
||||
import com.njcn.csdevice.pojo.param.CsDevModelQueryListParm;
|
||||
import com.njcn.csdevice.pojo.po.CsDevModelPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsDevModelPageVO;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/4/10 20:09
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DevModelFeignClientFallbackFactory implements FallbackFactory<DevModelFeignClient> {
|
||||
@Override
|
||||
public DevModelFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
// exceptionEnum = UserEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new DevModelFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<CsDevModelPO> addDevModel(CsDevModelAddParm csDevModelAddParm) {
|
||||
log.error("{}异常,降级处理,异常为:{}","新增装置模板版本信息",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<CsDevModelPageVO> queryDevModelOne(CsDevModelQueryListParm csDevModelQueryListParm) {
|
||||
log.error("{}异常,降级处理,异常为:{}","查询模板版本信息",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<CsDevModelPO> findModel(String devType, String version, String time) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据条件查询模板",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.njcn.csdevice.api.fallback;
|
||||
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class EquipmentFeignClientFallbackFactory implements FallbackFactory<EquipmentFeignClient> {
|
||||
@Override
|
||||
public EquipmentFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
// exceptionEnum = UserEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new EquipmentFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<CsEquipmentDeliveryVO> queryEquipmentByndid(String ndid) {
|
||||
log.error("{}异常,降级处理,异常为:{}","通过ndid查询出厂设备异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> updateStatusBynDid(String nDid, Integer status) {
|
||||
log.error("{}异常,降级处理,异常为:{}","通过ndid修改装置的状态",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<CsEquipmentDeliveryPO>> queryDeviceById(List<String> ids) {
|
||||
log.error("{}异常,降级处理,异常为:{}","查询出厂设备详情",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user