app功能合并
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package com.njcn.csharmonic.api;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.fallback.CsAlarmFeignClientFallbackFactory;
|
||||
import com.njcn.csharmonic.pojo.po.CsAlarm;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_HARMONIC_BOOT, path = "/csAlarm", fallbackFactory = CsAlarmFeignClientFallbackFactory.class,contextId = "csAlarm")
|
||||
public interface CsAlarmFeignClient {
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/addList")
|
||||
@ApiOperation("批量写入数据")
|
||||
@ApiImplicitParam(name = "list", value = "参数", required = true)
|
||||
HttpResult<Boolean> addList(@RequestBody List<CsAlarm> list);
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryListByTime")
|
||||
@ApiOperation("按日期查询数据")
|
||||
@ApiImplicitParam(name = "time", value = "时间", required = true)
|
||||
HttpResult<List<CsAlarm>> queryListByTime(@RequestParam("time") String time);
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/deleteListByTime")
|
||||
@ApiOperation("按日期删除数据")
|
||||
@ApiImplicitParam(name = "time", value = "时间", required = true)
|
||||
HttpResult<Boolean> deleteListByTime(@RequestParam("time") String time);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.njcn.csharmonic.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.fallback.CsHarmonicFeignClientFallbackFactory;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonic;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_HARMONIC_BOOT, path = "/csHarmonic", fallbackFactory = CsHarmonicFeignClientFallbackFactory.class,contextId = "csHarmonic")
|
||||
public interface CsHarmonicFeignClient {
|
||||
|
||||
@PostMapping("/addList")
|
||||
@ApiOperation("批量写入数据")
|
||||
HttpResult<Boolean> addList(@RequestBody List<CsHarmonic> list);
|
||||
|
||||
@PostMapping("/queryListByTime")
|
||||
@ApiOperation("按日期查询数据")
|
||||
HttpResult<List<CsHarmonic>> queryListByTime(@RequestParam(value = "time") String time);
|
||||
|
||||
|
||||
@PostMapping("/deleteListByTime")
|
||||
@ApiOperation("按日期删除数据")
|
||||
HttpResult<Boolean> deleteListByTime(@RequestParam(value = "time") String time);
|
||||
|
||||
}
|
||||
@@ -1,19 +1,13 @@
|
||||
package com.njcn.csharmonic.api;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.pojo.vo.DataGroupEventVO;
|
||||
import com.njcn.csharmonic.api.fallback.EventFeignClientFallbackFactory;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryPage;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -40,4 +34,11 @@ public interface EventFeignClient {
|
||||
|
||||
@PostMapping("/getEventByTime")
|
||||
HttpResult<List<CsEventPO>> getEventByTime(@RequestParam(name = "lineList", required = false) List<String> lineList,@RequestParam("startTime") String startTime,@RequestParam("endTime") String endTime);
|
||||
|
||||
@PostMapping("/getDevAlarmList")
|
||||
HttpResult<List<CsEventPO>> getDevAlarmList(@RequestBody CsEventUserQueryParam param);
|
||||
|
||||
@PostMapping("/getEventByIdList")
|
||||
HttpResult<List<CsEventPO>> getEventByIdList(@RequestBody List<String> list);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.fallback.EventUserFeignClientFallbackFactory;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
||||
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -20,4 +21,10 @@ public interface EventUserFeignClient {
|
||||
|
||||
@PostMapping("/queryEventList")
|
||||
HttpResult<List<EventDetailVO>> queryEventList(@RequestBody CsEventUserQueryParam csEventUserQueryParam) ;
|
||||
|
||||
@PostMapping("/addUserEventList")
|
||||
HttpResult<Boolean> addUserEventList(@RequestBody List<CsEventUserPO> list);
|
||||
|
||||
@PostMapping("/deleteByIds")
|
||||
HttpResult<Boolean> deleteByIds(@RequestBody List<String> eventList);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.njcn.csharmonic.api;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.fallback.EventUserFeignClientFallbackFactory;
|
||||
import com.njcn.csharmonic.pojo.po.PqSensitiveUser;
|
||||
import com.njcn.device.biz.pojo.po.PqSensitiveUser;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.njcn.csharmonic.api;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csharmonic.api.fallback.RStatLimitRateDClientFallbackFactory;
|
||||
import com.njcn.csharmonic.pojo.param.RStatLimitQueryParam;
|
||||
import com.njcn.csharmonic.pojo.param.StatSubstationBizBaseParam;
|
||||
import com.njcn.csharmonic.pojo.po.RStatLimitRateDPO;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
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 xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_HARMONIC_BOOT, path = "", fallbackFactory = RStatLimitRateDClientFallbackFactory.class,contextId = "")
|
||||
|
||||
public interface RStatLimitRateDFeignClient {
|
||||
|
||||
@PostMapping("/limitRateD/monitorIdsGetLimitRateInfo")
|
||||
HttpResult<List<RStatLimitRateDPO>> monitorIdsGetLimitRateInfo(@RequestBody RStatLimitQueryParam rStatLimitQueryParam);
|
||||
|
||||
@PostMapping("/harmonic/getLinesRate")
|
||||
HttpResult<List<RStatLimitRateDPO>> getLinesRate(@RequestBody StatSubstationBizBaseParam param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.njcn.csharmonic.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.fallback.SysExcelClientFallbackFactory;
|
||||
import com.njcn.harmonic.pojo.po.excel.SysExcel;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_HARMONIC_BOOT, path = "/sysExcel", fallbackFactory = SysExcelClientFallbackFactory.class,contextId = "sysExcel")
|
||||
|
||||
public interface SysExcelFeignClient {
|
||||
|
||||
@PostMapping("/querySysExcel")
|
||||
@ApiOperation("查询")
|
||||
HttpResult<List<SysExcel>> querySysExcel();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.njcn.csharmonic.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.fallback.SysExcelRelationClientFallbackFactory;
|
||||
import com.njcn.harmonic.common.pojo.vo.ReportTemplateVO;
|
||||
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_HARMONIC_BOOT, path = "/sysExcelRelation", fallbackFactory = SysExcelRelationClientFallbackFactory.class,contextId = "sysExcelRelation")
|
||||
|
||||
public interface SysExcelRelationFeignClient {
|
||||
|
||||
@PostMapping("/queryList")
|
||||
HttpResult<List<ReportTemplateVO>> queryList(@RequestParam("id") String id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.njcn.csharmonic.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.csharmonic.api.CsAlarmFeignClient;
|
||||
import com.njcn.csharmonic.pojo.po.CsAlarm;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CsAlarmFeignClientFallbackFactory implements FallbackFactory<CsAlarmFeignClient> {
|
||||
@Override
|
||||
public CsAlarmFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new CsAlarmFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> addList(List<CsAlarm> list) {
|
||||
log.error("{}异常,降级处理,异常为:{}","批量写入数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<CsAlarm>> queryListByTime(String time) {
|
||||
log.error("{}异常,降级处理,异常为:{}","按日期查询数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> deleteListByTime(String time) {
|
||||
log.error("{}异常,降级处理,异常为:{}","按日期删除数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.njcn.csharmonic.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.csharmonic.api.CsHarmonicFeignClient;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonic;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CsHarmonicFeignClientFallbackFactory implements FallbackFactory<CsHarmonicFeignClient> {
|
||||
@Override
|
||||
public CsHarmonicFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new CsHarmonicFeignClient() {
|
||||
@Override
|
||||
public HttpResult<Boolean> addList(List<CsHarmonic> list) {
|
||||
log.error("{}异常,降级处理,异常为:{}","批量写入数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<CsHarmonic>> queryListByTime(String time) {
|
||||
log.error("{}异常,降级处理,异常为:{}","按日期查询数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> deleteListByTime(String time) {
|
||||
log.error("{}异常,降级处理,异常为:{}","按日期删除数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.pojo.vo.DataGroupEventVO;
|
||||
import com.njcn.csharmonic.api.EventFeignClient;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryPage;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -58,6 +59,18 @@ public class EventFeignClientFallbackFactory implements FallbackFactory<EventFei
|
||||
log.error("{}异常,降级处理,异常为:{}","根据时间获取无波形的暂态事件",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<CsEventPO>> getDevAlarmList(CsEventUserQueryParam param) {
|
||||
log.error("{}异常,降级处理,异常为:{}","获取设备运行告警事件数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<CsEventPO>> getEventByIdList(List<String> list) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据事件id集合获取事件详情异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.EventUserFeignClient;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
||||
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -32,6 +33,18 @@ public class EventUserFeignClientFallbackFactory implements FallbackFactory<Even
|
||||
log.error("{}异常,降级处理,异常为:{}","获取当天事件未读消息未读消息",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> addUserEventList(List<CsEventUserPO> list) {
|
||||
log.error("{}异常,降级处理,异常为:{}","新增数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> deleteByIds(List<String> eventList) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据id删除数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ 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.csharmonic.api.PqSensitiveUserFeignClient;
|
||||
import com.njcn.csharmonic.pojo.po.PqSensitiveUser;
|
||||
import com.njcn.device.biz.pojo.po.PqSensitiveUser;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.njcn.csharmonic.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.csharmonic.api.RStatLimitRateDFeignClient;
|
||||
import com.njcn.csharmonic.pojo.param.RStatLimitQueryParam;
|
||||
import com.njcn.csharmonic.pojo.param.StatSubstationBizBaseParam;
|
||||
import com.njcn.csharmonic.pojo.po.RStatLimitRateDPO;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class RStatLimitRateDClientFallbackFactory implements FallbackFactory<RStatLimitRateDFeignClient> {
|
||||
@Override
|
||||
public RStatLimitRateDFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new RStatLimitRateDFeignClient() {
|
||||
@Override
|
||||
public HttpResult<List<RStatLimitRateDPO>> monitorIdsGetLimitRateInfo(RStatLimitQueryParam rStatLimitQueryParam) {
|
||||
log.error("{}异常,降级处理,异常为:{}","获取指定日期超标监测点详细信息数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<RStatLimitRateDPO>> getLinesRate(StatSubstationBizBaseParam param) {
|
||||
log.error("{}异常,降级处理,异常为:{}","获取越限监测点越限次数异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.njcn.csharmonic.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.csharmonic.api.SysExcelFeignClient;
|
||||
import com.njcn.harmonic.pojo.po.excel.SysExcel;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SysExcelClientFallbackFactory implements FallbackFactory<SysExcelFeignClient> {
|
||||
@Override
|
||||
public SysExcelFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new SysExcelFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<List<SysExcel>> querySysExcel() {
|
||||
log.error("{}异常,降级处理,异常为:{}","查询模板信息异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.njcn.csharmonic.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.csharmonic.api.SysExcelRelationFeignClient;
|
||||
import com.njcn.harmonic.common.pojo.vo.ReportTemplateVO;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SysExcelRelationClientFallbackFactory implements FallbackFactory<SysExcelRelationFeignClient> {
|
||||
@Override
|
||||
public SysExcelRelationFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new SysExcelRelationFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<List<ReportTemplateVO>> queryList(String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}","查询模板关系数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user