技术监督用户信息迁移
This commit is contained in:
@@ -27,6 +27,12 @@
|
||||
<artifactId>pqs-influx</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>supervision-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.njcn.device.pq.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.pq.api.fallback.UserLedgerFeignClientFallbackFactory;
|
||||
import com.njcn.supervision.pojo.param.SensitiveUserParam;
|
||||
import com.njcn.supervision.pojo.param.user.UserReportParam;
|
||||
import com.njcn.supervision.pojo.po.user.UserReportPO;
|
||||
import com.njcn.supervision.pojo.vo.user.NewUserReportVO;
|
||||
import com.njcn.supervision.pojo.vo.user.UserLedgerVO;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* 流程实例 Api 接口
|
||||
*
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.DEVICE, path = "/userReport", fallbackFactory = UserLedgerFeignClientFallbackFactory.class)
|
||||
public interface UserLedgerFeignClient {
|
||||
|
||||
|
||||
@PostMapping("/selectUserList")
|
||||
HttpResult<List<UserLedgerVO>> selectUserList(@RequestBody UserReportParam userReportParam);
|
||||
|
||||
@GetMapping("/selectUserInfo")
|
||||
HttpResult<UserLedgerVO> selectUserInfo(@RequestParam("id") String id);
|
||||
|
||||
@PostMapping(value = "/bindUserStation")
|
||||
HttpResult<List<UserLedgerVO>> bindUserStation(@RequestParam("userId")String userId,@RequestParam("stationId")String stationId);
|
||||
|
||||
@PostMapping("/getUserReportByIds")
|
||||
HttpResult<List<NewUserReportVO>> getUserReportByIds(@RequestBody List<String> ids);
|
||||
|
||||
@PostMapping("/getSensitiveUserByDept")
|
||||
@ApiOperation("根据部门获取敏感用户信息")
|
||||
HttpResult<List<UserReportPO>> getSensitiveUserByDept(@RequestBody @Validated SensitiveUserParam param) ;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.njcn.device.pq.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.pq.api.UserLedgerFeignClient;
|
||||
import com.njcn.supervision.pojo.param.SensitiveUserParam;
|
||||
import com.njcn.supervision.pojo.param.user.UserReportParam;
|
||||
import com.njcn.supervision.pojo.po.user.UserReportPO;
|
||||
import com.njcn.supervision.pojo.vo.user.NewUserReportVO;
|
||||
import com.njcn.supervision.pojo.vo.user.UserLedgerVO;
|
||||
import com.njcn.supervision.utils.SupervisionEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class UserLedgerFeignClientFallbackFactory implements FallbackFactory<UserLedgerFeignClient> {
|
||||
@Override
|
||||
public UserLedgerFeignClient create(Throwable throwable) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (throwable.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) throwable.getCause();
|
||||
exceptionEnum = SupervisionEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new UserLedgerFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<List<UserLedgerVO>> selectUserList(UserReportParam userReportParam) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "查询用户台账", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<UserLedgerVO> selectUserInfo(String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "查询用户台账详情", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<UserLedgerVO>> bindUserStation(String userId, String stationId) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "用户电站信息绑定", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<NewUserReportVO>> getUserReportByIds(List<String> ids) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "根据ids获取非电网侧用户信息", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<UserReportPO>> getSensitiveUserByDept(SensitiveUserParam param) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "根据部门获取敏感用户信息异常", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user