初始化
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package com.njcn.device.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.api.fallback.DeptLineFeignClientFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @date 2022/2/11
|
||||
*
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.DEVICE,path = "/deptLine",fallbackFactory = DeptLineFeignClientFallbackFactory.class)
|
||||
public interface DeptLineFeignClient {
|
||||
@PostMapping("/getLineByDeptId")
|
||||
HttpResult<List<String>> getLineByDeptId(String id);
|
||||
|
||||
@PostMapping("/selectDeptBindLines")
|
||||
HttpResult<Boolean> selectDeptBindLines(@RequestParam("ids") List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.njcn.device.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.api.fallback.DeviceTreeClientFallbackFactory;
|
||||
import com.njcn.device.pojo.vo.TerminalTree;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2022/1/13
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.DEVICE,path = "/terminalTree",fallbackFactory = DeviceTreeClientFallbackFactory.class)
|
||||
public interface DeviceTreeClient {
|
||||
|
||||
/**
|
||||
* 获取5层终端树
|
||||
*/
|
||||
@GetMapping("/getTerminalTreeForFive")
|
||||
HttpResult<TerminalTree> getTerminalTreeForFive();
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.njcn.device.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.api.fallback.GeneralDeviceInfoClientFallbackFactory;
|
||||
import com.njcn.device.pojo.bo.BaseLineInfo;
|
||||
import com.njcn.device.pojo.dto.GeneralDeviceDTO;
|
||||
import com.njcn.device.pojo.param.DeviceInfoParam;
|
||||
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 hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2022年02月14日 14:02
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.DEVICE, path = "/deviceInfo", fallbackFactory = GeneralDeviceInfoClientFallbackFactory.class)
|
||||
public interface GeneralDeviceInfoClient {
|
||||
|
||||
|
||||
/**
|
||||
* 获取按部门分类的实际运行终端综合信息
|
||||
*
|
||||
* @param deviceInfoParam 查询终端条件
|
||||
* @return 按部门分类的实际运行终端综合信息
|
||||
*/
|
||||
@PostMapping("/getPracticalRunDeviceInfoAsDept")
|
||||
HttpResult<List<GeneralDeviceDTO>> getPracticalRunDeviceInfoAsDept(@RequestBody DeviceInfoParam deviceInfoParam);
|
||||
|
||||
|
||||
/**
|
||||
* 获取按部门分类的实际便携式终端综合信息
|
||||
*
|
||||
* @param deviceInfoParam 查询终端条件
|
||||
* @return 按部门分类的实际便携式终端综合信息
|
||||
*/
|
||||
@PostMapping("/getOfflineRunDeviceInfoAsDept")
|
||||
HttpResult<List<GeneralDeviceDTO>> getOfflineRunDeviceInfoAsDept(@RequestBody DeviceInfoParam deviceInfoParam);
|
||||
|
||||
|
||||
/**
|
||||
* 获取按部门分类的实际所有终端综合信息
|
||||
*
|
||||
* @param deviceInfoParam 查询终端条件
|
||||
* @return 按部门分类的实际所有终端综合信息
|
||||
*/
|
||||
@PostMapping("/getPracticalAllDeviceInfoAsDept")
|
||||
HttpResult<List<GeneralDeviceDTO>> getPracticalAllDeviceInfoAsDept(@RequestBody DeviceInfoParam deviceInfoParam);
|
||||
|
||||
/**
|
||||
* 获取变电站分类的实际运行终端综合信息
|
||||
*
|
||||
* @param deviceInfoParam 查询终端条件
|
||||
* @return 按部门分类的实际所有终端综合信息
|
||||
*/
|
||||
@PostMapping("/getPracticalRunDeviceInfoAsSubstation")
|
||||
HttpResult<List<GeneralDeviceDTO>> getPracticalRunDeviceInfoAsSubstation(@RequestBody DeviceInfoParam deviceInfoParam);
|
||||
|
||||
|
||||
/**
|
||||
* 获取实际运行终端综合信息
|
||||
*
|
||||
* @param deviceInfoParam 查询终端条件
|
||||
* @return 按部门分类的实际运行终端综合信息
|
||||
*/
|
||||
@PostMapping("/getPracticalRunDeviceInfo")
|
||||
HttpResult<List<GeneralDeviceDTO>> getPracticalRunDeviceInfo(@RequestBody DeviceInfoParam deviceInfoParam);
|
||||
|
||||
|
||||
/**
|
||||
* 获取实际便携式终端综合信息
|
||||
*
|
||||
* @param deviceInfoParam 查询终端条件
|
||||
* @return 按部门分类的实际便携式终端综合信息
|
||||
*/
|
||||
@PostMapping("/getOfflineRunDeviceInfo")
|
||||
HttpResult<List<GeneralDeviceDTO>> getOfflineRunDeviceInfo(@RequestBody DeviceInfoParam deviceInfoParam);
|
||||
|
||||
|
||||
/**
|
||||
* 获取实际所有终端综合信息
|
||||
*
|
||||
* @param deviceInfoParam 查询终端条件
|
||||
* @return 按部门分类的实际所有终端综合信息
|
||||
*/
|
||||
@PostMapping("/getPracticalAllDeviceInfo")
|
||||
HttpResult<List<GeneralDeviceDTO>> getPracticalAllDeviceInfo(@RequestBody DeviceInfoParam deviceInfoParam);
|
||||
|
||||
/**
|
||||
* 获取监测点及以上层的基础信息
|
||||
*/
|
||||
@PostMapping("/getBaseLineInfo")
|
||||
HttpResult<List<BaseLineInfo>> getBaseLineInfo(@RequestBody List<String> lineIndex);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
package com.njcn.device.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.api.fallback.LineFeignClientFallbackFactory;
|
||||
import com.njcn.device.pojo.dto.*;
|
||||
import com.njcn.device.pojo.po.Line;
|
||||
import com.njcn.device.pojo.po.Overlimit;
|
||||
import com.njcn.device.pojo.vo.*;
|
||||
import org.apache.commons.collections.map.MultiValueMap;
|
||||
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;
|
||||
|
||||
import javax.xml.transform.Result;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @date 2022/2/28
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.DEVICE, path = "/line", fallbackFactory = LineFeignClientFallbackFactory.class)
|
||||
public interface LineFeignClient {
|
||||
|
||||
/**
|
||||
* 获取终端状态信息
|
||||
*
|
||||
* @param id 监测点id
|
||||
* @param searchBeginTime 起始时间
|
||||
* @param searchEndTime 结束时间
|
||||
* @return 终端状态信息
|
||||
*/
|
||||
@PostMapping("/getComFlagInfoData")
|
||||
HttpResult<CommunicateVO> getComFlagInfoData(@RequestParam("id") String id,
|
||||
@RequestParam("searchBeginTime") String searchBeginTime,
|
||||
@RequestParam("searchEndTime") String searchEndTime);
|
||||
|
||||
/**
|
||||
* 根据监测点id获取 终端id
|
||||
*
|
||||
* @param id 监测点id
|
||||
* @return 终端id
|
||||
*/
|
||||
@PostMapping("getLineIdByDevId")
|
||||
HttpResult<String> getLineIdByDevId(@RequestParam("id") String id);
|
||||
|
||||
/**
|
||||
* 根据监测点id获取限值
|
||||
*
|
||||
* @param id 监测点id
|
||||
* @return 获取限值
|
||||
*/
|
||||
@PostMapping("getOverLimitData")
|
||||
HttpResult<Overlimit> getOverLimitData(@RequestParam("id") String id);
|
||||
|
||||
/**
|
||||
* 根据监测点id获取监测点详情
|
||||
*
|
||||
* @param id 监测点id
|
||||
* @return 监测点详情
|
||||
*/
|
||||
@PostMapping("getLineDetailData")
|
||||
HttpResult<LineDetailDataVO> getLineDetailData(@RequestParam("id") String id);
|
||||
|
||||
/**
|
||||
* 根据监测点id获取监测点越限
|
||||
*
|
||||
* @param id 监测点id
|
||||
* @return 监测点越限详情
|
||||
*/
|
||||
@PostMapping("getLineOverLimitData")
|
||||
HttpResult<LineOverLimitVO> getLineOverLimitData(@RequestParam("id") String id);
|
||||
|
||||
|
||||
/**
|
||||
* 获取投运在线的监测点的限值
|
||||
*
|
||||
* @param serverName 服务名称
|
||||
* @param deptId 部门id
|
||||
* @return 监测点越限详情
|
||||
*/
|
||||
@PostMapping("/getAllLineOverLimit")
|
||||
HttpResult<List<Overlimit>> getAllLineOverLimit(@RequestParam("serverName") String serverName, @RequestParam(value = "deptId", required = false) String deptId);
|
||||
|
||||
/**
|
||||
* 获取变电站详情
|
||||
*
|
||||
* @param id 变电站id
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("getSubstationData")
|
||||
HttpResult<List<SubstationDetailVO>> getSubstationData(@RequestParam("id") List<String> id);
|
||||
|
||||
/**
|
||||
* 根据变电站id获取子节数据
|
||||
*
|
||||
* @param id 变电站id
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("getSubIndexLineDetail")
|
||||
HttpResult<List<Line>> getSubIndexLineDetail(@RequestParam("id") String id);
|
||||
|
||||
/**
|
||||
* 获取所有监测点
|
||||
* @param id 监测点集合
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("getAllLine")
|
||||
HttpResult<List<LineDeviceStateVO>> getAllLine(@RequestBody List<String> id);
|
||||
|
||||
/**
|
||||
* 获取终端状态
|
||||
* @param id id
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("getDeviceState")
|
||||
HttpResult<Integer> getDeviceState(@RequestParam("id") String id);
|
||||
|
||||
/**
|
||||
* 获取变电站信息
|
||||
* @param id id
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("getSubstationInfo")
|
||||
HttpResult<PollutionSubstationDTO> getSubstationInfo(@RequestParam("id") String id);
|
||||
|
||||
/**
|
||||
* 获取监测点信息
|
||||
* @param pollutionParamDTO 监测点对象
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("getLineInfo")
|
||||
HttpResult<List<PollutionLineDTO>> getLineInfo(@RequestBody PollutionParamDTO pollutionParamDTO);
|
||||
|
||||
/**
|
||||
* 获取所有监测点
|
||||
* @param id 监测点集合
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("getLineSubGdDetail")
|
||||
HttpResult<LineDetailVO> getLineSubGdDetail(@RequestParam("id") String id);
|
||||
|
||||
/**
|
||||
* 获取告警变电站信息
|
||||
* @param list 变电站集合
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("getWarningSub")
|
||||
HttpResult<List<WarningSubstationDTO>> getWarningSub(@RequestParam("list") List<String> list);
|
||||
|
||||
/**
|
||||
* 获取监测点信息
|
||||
* @param pollutionParamDTO 实体
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("getOverLimitLineInfo")
|
||||
HttpResult<List<OverLimitLineDTO>> getOverLimitLineInfo(@RequestBody PollutionParamDTO pollutionParamDTO);
|
||||
|
||||
/**
|
||||
* 获取生成limitRate的监测点
|
||||
* @return 监测点id集合
|
||||
*/
|
||||
@PostMapping("getLineList")
|
||||
HttpResult<List<String>> getLineList();
|
||||
|
||||
/**
|
||||
* 获取监测点限值
|
||||
* @param pollutionParamDTO 监测点id集合
|
||||
* @return 监测点限值信息
|
||||
*/
|
||||
@PostMapping("getOverLimitByList")
|
||||
HttpResult<List<Overlimit>> getOverLimitByList(@RequestBody PollutionParamDTO pollutionParamDTO);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.njcn.device.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.api.fallback.GeneralDeviceInfoClientFallbackFactory;
|
||||
import com.njcn.device.api.fallback.TerminalBaseClientFallbackFactory;
|
||||
import com.njcn.device.pojo.dto.GeneralDeviceDTO;
|
||||
import com.njcn.device.pojo.po.Line;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2022年02月14日 14:02
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.DEVICE,path = "/device",fallbackFactory = TerminalBaseClientFallbackFactory.class)
|
||||
public interface TerminalBaseClient {
|
||||
|
||||
|
||||
/**
|
||||
* 功能描述:根据变电站id获取变电站详情
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
* @author xy
|
||||
* @date 2022/2/21 18:53
|
||||
*/
|
||||
@GetMapping("/getSubstationById")
|
||||
HttpResult<List<Line>> getSubstationById(@RequestParam("list") List<String> list);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.njcn.device.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.device.api.DeptLineFeignClient;
|
||||
import com.njcn.device.utils.DeviceEnumUtil;
|
||||
import com.njcn.web.pojo.param.DeptLineParam;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @date 2022/1/13
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DeptLineFeignClientFallbackFactory implements FallbackFactory<DeptLineFeignClient> {
|
||||
@Override
|
||||
public DeptLineFeignClient create(Throwable throwable) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (throwable.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) throwable.getCause();
|
||||
exceptionEnum = DeviceEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new DeptLineFeignClient()
|
||||
{
|
||||
|
||||
@Override
|
||||
public HttpResult<List<String>> getLineByDeptId(String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "部门Id获取绑定监测点", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> selectDeptBindLines(List<String> ids) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "部门Ids集合查询是否绑定", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.njcn.device.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.device.api.DeviceTreeClient;
|
||||
import com.njcn.device.pojo.vo.TerminalTree;
|
||||
import com.njcn.device.utils.DeviceEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2022/1/13
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DeviceTreeClientFallbackFactory implements FallbackFactory<DeviceTreeClient> {
|
||||
|
||||
@Override
|
||||
public DeviceTreeClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if(cause.getCause() instanceof BusinessException){
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
exceptionEnum = DeviceEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new DeviceTreeClient() {
|
||||
@Override
|
||||
public HttpResult<TerminalTree> getTerminalTreeForFive() {
|
||||
log.error("{}异常,降级处理,异常为:{}","获取终端五层树失败",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.njcn.device.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.device.api.DeptLineFeignClient;
|
||||
import com.njcn.device.api.GeneralDeviceInfoClient;
|
||||
import com.njcn.device.pojo.bo.BaseLineInfo;
|
||||
import com.njcn.device.pojo.dto.GeneralDeviceDTO;
|
||||
import com.njcn.device.pojo.param.DeviceInfoParam;
|
||||
import com.njcn.device.utils.DeviceEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2022年02月14日 14:03
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class GeneralDeviceInfoClientFallbackFactory implements FallbackFactory<GeneralDeviceInfoClient> {
|
||||
@Override
|
||||
public GeneralDeviceInfoClient create(Throwable throwable) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (throwable.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) throwable.getCause();
|
||||
exceptionEnum = DeviceEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new GeneralDeviceInfoClient()
|
||||
{
|
||||
@Override
|
||||
public HttpResult<List<GeneralDeviceDTO>> getPracticalRunDeviceInfoAsDept(DeviceInfoParam deviceInfoParam) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "获取按部门分类的实际运行终端综合信息", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
@Override
|
||||
public HttpResult<List<GeneralDeviceDTO>> getOfflineRunDeviceInfoAsDept(DeviceInfoParam deviceInfoParam) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "获取按部门分类的实际便携式终端综合信息", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
@Override
|
||||
public HttpResult<List<GeneralDeviceDTO>> getPracticalAllDeviceInfoAsDept(DeviceInfoParam deviceInfoParam) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "获取按部门分类的实际所有终端综合信息", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<GeneralDeviceDTO>> getPracticalRunDeviceInfoAsSubstation(DeviceInfoParam deviceInfoParam) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "获取按变电站分类的实际运行终端综合信息", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<GeneralDeviceDTO>> getPracticalRunDeviceInfo(DeviceInfoParam deviceInfoParam) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "获取实际运行终端综合信息", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<GeneralDeviceDTO>> getOfflineRunDeviceInfo(DeviceInfoParam deviceInfoParam) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "获取实际便携式终端综合信息", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<GeneralDeviceDTO>> getPracticalAllDeviceInfo(DeviceInfoParam deviceInfoParam) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "获取实际所有终端综合信息", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<BaseLineInfo>> getBaseLineInfo(List<String> lineIndex) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "获取监测点及以上层的基础信息", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.njcn.device.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.device.api.LineFeignClient;
|
||||
import com.njcn.device.pojo.dto.*;
|
||||
import com.njcn.device.pojo.po.Line;
|
||||
import com.njcn.device.pojo.po.Overlimit;
|
||||
import com.njcn.device.pojo.vo.*;
|
||||
import com.njcn.device.utils.DeviceEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @date 2022/2/28
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class LineFeignClientFallbackFactory implements FallbackFactory<LineFeignClient> {
|
||||
@Override
|
||||
public LineFeignClient create(Throwable throwable) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (throwable.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) throwable.getCause();
|
||||
exceptionEnum = DeviceEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new LineFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<CommunicateVO> getComFlagInfoData(String id, String searchBeginTime, String searchEndTime) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "根据监测点Id获取终端状态统计", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<String> getLineIdByDevId(String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "根据监测点Id获取终端id", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Overlimit> getOverLimitData(String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "根据监测点Id获取限值 ", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<LineDetailDataVO> getLineDetailData(String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "根据监测点Id获取监测点详情 ", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<LineOverLimitVO> getLineOverLimitData(String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "根据监测点Id获取监测点越限 ", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<Overlimit>> getAllLineOverLimit(String serverName, String deptId) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "获取投运在线的监测点的限值 ", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<SubstationDetailVO>> getSubstationData(List<String> id) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "获取变电站信息 ", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<Line>> getSubIndexLineDetail(String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "获取所有信息 ", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<LineDeviceStateVO>> getAllLine(List<String> id) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "获取终端信息 ", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Integer> getDeviceState(String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "获取终端状态 ", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<PollutionSubstationDTO> getSubstationInfo(String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "变电站信息 ", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<PollutionLineDTO>> getLineInfo(PollutionParamDTO pollutionParamDTO) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "监测点信息 ", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<LineDetailVO> getLineSubGdDetail(String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "监测点详细信息 ", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<WarningSubstationDTO>> getWarningSub(List<String> list) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "变电站集合为 ", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<OverLimitLineDTO>> getOverLimitLineInfo(PollutionParamDTO pollutionParamDTO) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "监测点集合为 ", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<String>> getLineList() {
|
||||
log.error("{}异常,降级处理,异常为:{}", "监测点集合为 ", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<Overlimit>> getOverLimitByList(PollutionParamDTO pollutionParamDTO) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "监测点集合为 ", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.njcn.device.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.device.api.GeneralDeviceInfoClient;
|
||||
import com.njcn.device.api.TerminalBaseClient;
|
||||
import com.njcn.device.pojo.dto.GeneralDeviceDTO;
|
||||
import com.njcn.device.pojo.po.Line;
|
||||
import com.njcn.device.utils.DeviceEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2022年02月14日 14:03
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class TerminalBaseClientFallbackFactory implements FallbackFactory<TerminalBaseClient> {
|
||||
@Override
|
||||
public TerminalBaseClient create(Throwable throwable) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (throwable.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) throwable.getCause();
|
||||
exceptionEnum = DeviceEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new TerminalBaseClient()
|
||||
{
|
||||
@Override
|
||||
public HttpResult<List<Line>> getSubstationById(List<String> list) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "根据变电站id获取变电站详情", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user