状态统一管理,舍弃单独监听器

This commit is contained in:
2024-06-13 16:57:04 +08:00
parent 7b58ec02bb
commit 146e2ca5a1
43 changed files with 147 additions and 996 deletions

View File

@@ -0,0 +1,28 @@
package com.njcn.supervision.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.supervision.api.fallback.BusinessCommonFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* 流程实例 Api 接口
*
* @author 芋道源码
*/
@FeignClient(value = ServerInfo.SUPERVISION, path = "/supervision", fallbackFactory = BusinessCommonFeignClientFallbackFactory.class)
public interface BusinessCommonFeignClient {
/**
* 根据流程key,业务id去实时更新流程状态
* @param processKey 流程定义key
* @param businessId 业务id
* @param status 目标状态
*/
@GetMapping("/updateProcessStatus")
HttpResult<Object> updateProcessStatus(@RequestParam("processKey") String processKey,@RequestParam("businessId") String businessId, @RequestParam("status")Integer status);
}

View File

@@ -1,22 +0,0 @@
package com.njcn.supervision.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.supervision.api.fallback.DeVReportManageFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* 流程实例 Api 接口
*
* @author 芋道源码
*/
@FeignClient(value = ServerInfo.SUPERVISION, path = "/deVReport", fallbackFactory = DeVReportManageFeignClientFallbackFactory.class)
public interface DeVReportManageFeignClient {
@GetMapping("/updateStatus")
HttpResult<Object> updateStatus(@RequestParam("businessKey") String businessKey, @RequestParam("status")Integer status);
}

View File

@@ -1,22 +0,0 @@
package com.njcn.supervision.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.supervision.api.fallback.GeneralSurveyFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* 流程实例 Api 接口
*
* @author 芋道源码
*/
@FeignClient(value = ServerInfo.SUPERVISION, path = "/generalSurvey", fallbackFactory = GeneralSurveyFeignClientFallbackFactory.class)
public interface GeneralSurveyFeignClient {
@GetMapping("/updateStatus")
HttpResult<Object> updateStatus(@RequestParam("businessKey") String businessKey, @RequestParam("status")Integer status);
}

View File

@@ -1,22 +0,0 @@
package com.njcn.supervision.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.supervision.api.fallback.QuitRunningDeviceFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* 流程实例 Api 接口
*
* @author hongawen
*/
@FeignClient(value = ServerInfo.SUPERVISION, path = "/quitRunningDevice", fallbackFactory = QuitRunningDeviceFeignClientFallbackFactory.class)
public interface QuitRunningDeviceFeignClient {
@GetMapping("/updateDeviceStatus")
HttpResult<Object> updateDeviceStatus(@RequestParam("businessKey") String businessKey, @RequestParam("status")Integer status);
}

View File

@@ -1,22 +0,0 @@
package com.njcn.supervision.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.supervision.api.fallback.SupervisionPlanFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* 流程实例 Api 接口
*
* @author hongawen
*/
@FeignClient(value = ServerInfo.SUPERVISION, path = "/superPlan", fallbackFactory = SupervisionPlanFeignClientFallbackFactory.class)
public interface SupervisionPlanFeignClient {
@GetMapping("/updateStatus")
HttpResult<Object> updateStatus(@RequestParam("businessKey") String businessKey, @RequestParam("status")Integer status);
}

View File

@@ -1,22 +0,0 @@
package com.njcn.supervision.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.supervision.api.fallback.SurveyPlanFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* 流程实例 Api 接口
*
* @author 芋道源码
*/
@FeignClient(value = ServerInfo.SUPERVISION, path = "/surveyPlan", fallbackFactory = SurveyPlanFeignClientFallbackFactory.class)
public interface SurveyPlanFeignClient {
@GetMapping("/updateSurveyPlanStatus")
HttpResult<Object> updateStatus(@RequestParam("businessKey") String businessKey, @RequestParam("status")Integer status);
}

View File

@@ -1,23 +0,0 @@
package com.njcn.supervision.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.supervision.api.fallback.SurveyPlanFeignClientFallbackFactory;
import com.njcn.supervision.api.fallback.SurveyTestFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* 流程实例 Api 接口
*
* @author 芋道源码
*/
@FeignClient(value = ServerInfo.SUPERVISION, path = "/surveyTest", fallbackFactory = SurveyTestFeignClientFallbackFactory.class)
public interface SurveyTestFeignClient {
@GetMapping("/updateSurveyTestStatus")
HttpResult<Object> updateStatus(@RequestParam("businessKey") String businessKey, @RequestParam("status")Integer status);
}

View File

@@ -1,22 +0,0 @@
package com.njcn.supervision.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.supervision.api.fallback.TempLineDebugFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* 流程实例 Api 接口
*
* @author 芋道源码
*/
@FeignClient(value = ServerInfo.SUPERVISION, path = "/tempLinedebug", fallbackFactory = TempLineDebugFeignClientFallbackFactory.class)
public interface TempLineDebugFeignClient {
@GetMapping("/updateStatus")
HttpResult<Object> updateStatus(@RequestParam("businessKey") String businessKey, @RequestParam("status")Integer status);
}

View File

@@ -1,22 +0,0 @@
package com.njcn.supervision.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.supervision.api.fallback.TempLineFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* 流程实例 Api 接口
*
* @author 芋道源码
*/
@FeignClient(value = ServerInfo.SUPERVISION, path = "/tempLine", fallbackFactory = TempLineFeignClientFallbackFactory.class)
public interface TempLineFeignClient {
@GetMapping("/updateStatus")
HttpResult<Object> updateStatus(@RequestParam("businessKey") String businessKey, @RequestParam("status")Integer status);
}

View File

@@ -1,24 +1,18 @@
package com.njcn.supervision.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.supervision.api.fallback.TempLineDebugFeignClientFallbackFactory;
import com.njcn.supervision.api.fallback.TempLineRunTestFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* 流程实例 Api 接口
*
* @author 芋道源码
*/
@FeignClient(value = ServerInfo.SUPERVISION, path = "/supervisionTempLineRunTest", fallbackFactory = TempLineRunTestFeignClientFallbackFactory.class)
public interface TempLineRunTestFeignClient {
@GetMapping("/updateStatus")
HttpResult<Object> updateStatus(@RequestParam("businessKey") String businessKey, @RequestParam("status")Integer status);
@GetMapping("/isTestRunStartOrEnd")
void isTestRunStartOrEnd();

View File

@@ -1,23 +0,0 @@
package com.njcn.supervision.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.supervision.api.fallback.UserReportFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* 流程实例 Api 接口
*
* @author hongawen
*/
@FeignClient(value = ServerInfo.SUPERVISION, path = "/userReport", fallbackFactory = UserReportFeignClientFallbackFactory.class)
public interface UserReportFeignClient {
@GetMapping("/updateUserReportStatus")
HttpResult<Object> updateUserReportStatus(@RequestParam("businessKey") String businessKey, @RequestParam("status")Integer status);
}

View File

@@ -1,22 +0,0 @@
package com.njcn.supervision.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.supervision.api.fallback.UserReportNoramlFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* 流程实例 Api 接口
*
* @author hongawen
*/
@FeignClient(value = ServerInfo.SUPERVISION, path = "/userReportNormal", fallbackFactory = UserReportNoramlFeignClientFallbackFactory.class)
public interface UserReportNormalFeignClient {
@GetMapping("/updateUserReportNormalStatus")
HttpResult<Object> updateUserReportNormalStatus(@RequestParam("businessKey") String businessKey, @RequestParam("status")Integer status);
}

View File

@@ -1,23 +0,0 @@
package com.njcn.supervision.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.supervision.api.fallback.DeVReportManageFeignClientFallbackFactory;
import com.njcn.supervision.api.fallback.WarningLeafletFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* 流程实例 Api 接口
*
* @author 芋道源码
*/
@FeignClient(value = ServerInfo.SUPERVISION, path = "/warningLeaflet", fallbackFactory = WarningLeafletFeignClientFallbackFactory.class)
public interface WarningLeafletFeignClient {
@GetMapping("/updateStatus")
HttpResult<Object> updateStatus(@RequestParam("businessKey") String businessKey, @RequestParam("status")Integer status);
}

View File

@@ -3,17 +3,18 @@ package com.njcn.supervision.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.supervision.api.WarningLeafletFeignClient;
import com.njcn.supervision.api.BusinessCommonFeignClient;
import com.njcn.supervision.utils.SupervisionEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class WarningLeafletFeignClientFallbackFactory implements FallbackFactory<WarningLeafletFeignClient> {
public class BusinessCommonFeignClientFallbackFactory implements FallbackFactory<BusinessCommonFeignClient> {
@Override
public WarningLeafletFeignClient create(Throwable throwable) {
public BusinessCommonFeignClient create(Throwable throwable) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (throwable.getCause() instanceof BusinessException) {
@@ -21,9 +22,9 @@ public class WarningLeafletFeignClientFallbackFactory implements FallbackFactory
exceptionEnum = SupervisionEnumUtil.getExceptionEnum(businessException.getResult());
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new WarningLeafletFeignClient() {
return new BusinessCommonFeignClient() {
@Override
public HttpResult<Object> updateStatus(String businessKey, Integer status) {
public HttpResult<Object> updateProcessStatus(String processKey,String businessId, Integer status) {
log.error("{}异常,降级处理,异常为:{}", "更新流程状态", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}

View File

@@ -1,37 +0,0 @@
package com.njcn.supervision.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.supervision.api.DeVReportManageFeignClient;
import com.njcn.supervision.utils.SupervisionEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author denghuajun
* @version 1.0.0
* @date 2022/3/16
*/
@Slf4j
@Component
public class DeVReportManageFeignClientFallbackFactory implements FallbackFactory<DeVReportManageFeignClient> {
@Override
public DeVReportManageFeignClient 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 DeVReportManageFeignClient() {
@Override
public HttpResult<Object> updateStatus(String businessKey, Integer status) {
log.error("{}异常,降级处理,异常为:{}", "更新流程状态", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -1,37 +0,0 @@
package com.njcn.supervision.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.supervision.api.GeneralSurveyFeignClient;
import com.njcn.supervision.utils.SupervisionEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author denghuajun
* @version 1.0.0
* @date 2022/3/16
*/
@Slf4j
@Component
public class GeneralSurveyFeignClientFallbackFactory implements FallbackFactory<GeneralSurveyFeignClient> {
@Override
public GeneralSurveyFeignClient 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 GeneralSurveyFeignClient() {
@Override
public HttpResult<Object> updateStatus(String businessKey, Integer status) {
log.error("{}异常,降级处理,异常为:{}", "更新普测计划流程状态", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -1,37 +0,0 @@
package com.njcn.supervision.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.supervision.api.QuitRunningDeviceFeignClient;
import com.njcn.supervision.utils.SupervisionEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author denghuajun
* @version 1.0.0
* @date 2022/3/16
*/
@Slf4j
@Component
public class QuitRunningDeviceFeignClientFallbackFactory implements FallbackFactory<QuitRunningDeviceFeignClient> {
@Override
public QuitRunningDeviceFeignClient 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 QuitRunningDeviceFeignClient() {
@Override
public HttpResult<Object> updateDeviceStatus(String businessKey, Integer status) {
log.error("{}异常,降级处理,异常为:{}", "更新退运装置数据流程状态", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -1,37 +0,0 @@
package com.njcn.supervision.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.supervision.api.SupervisionPlanFeignClient;
import com.njcn.supervision.utils.SupervisionEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author denghuajun
* @version 1.0.0
* @date 2022/3/16
*/
@Slf4j
@Component
public class SupervisionPlanFeignClientFallbackFactory implements FallbackFactory<SupervisionPlanFeignClient> {
@Override
public SupervisionPlanFeignClient 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 SupervisionPlanFeignClient() {
@Override
public HttpResult<Object> updateStatus(String businessKey, Integer status) {
log.error("{}异常,降级处理,异常为:{}", "更新退运装置数据流程状态", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -1,37 +0,0 @@
package com.njcn.supervision.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.supervision.api.SurveyPlanFeignClient;
import com.njcn.supervision.utils.SupervisionEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author denghuajun
* @version 1.0.0
* @date 2022/3/16
*/
@Slf4j
@Component
public class SurveyPlanFeignClientFallbackFactory implements FallbackFactory<SurveyPlanFeignClient> {
@Override
public SurveyPlanFeignClient 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 SurveyPlanFeignClient() {
@Override
public HttpResult<Object> updateStatus(String businessKey, Integer status) {
log.error("{}异常,降级处理,异常为:{}", "更新普测计划流程状态", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -1,37 +0,0 @@
package com.njcn.supervision.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.supervision.api.SurveyTestFeignClient;
import com.njcn.supervision.utils.SupervisionEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author denghuajun
* @version 1.0.0
* @date 2022/3/16
*/
@Slf4j
@Component
public class SurveyTestFeignClientFallbackFactory implements FallbackFactory<SurveyTestFeignClient> {
@Override
public SurveyTestFeignClient 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 SurveyTestFeignClient() {
@Override
public HttpResult<Object> updateStatus(String businessKey, Integer status) {
log.error("{}异常,降级处理,异常为:{}", "更新退运装置数据流程状态", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -1,37 +0,0 @@
package com.njcn.supervision.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.supervision.api.TempLineDebugFeignClient;
import com.njcn.supervision.utils.SupervisionEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author denghuajun
* @version 1.0.0
* @date 2022/3/16
*/
@Slf4j
@Component
public class TempLineDebugFeignClientFallbackFactory implements FallbackFactory<TempLineDebugFeignClient> {
@Override
public TempLineDebugFeignClient 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 TempLineDebugFeignClient() {
@Override
public HttpResult<Object> updateStatus(String businessKey, Integer status) {
log.error("{}异常,降级处理,异常为:{}", "更新流程状态", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -1,37 +0,0 @@
package com.njcn.supervision.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.supervision.api.TempLineFeignClient;
import com.njcn.supervision.utils.SupervisionEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author denghuajun
* @version 1.0.0
* @date 2022/3/16
*/
@Slf4j
@Component
public class TempLineFeignClientFallbackFactory implements FallbackFactory<TempLineFeignClient> {
@Override
public TempLineFeignClient 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 TempLineFeignClient() {
@Override
public HttpResult<Object> updateStatus(String businessKey, Integer status) {
log.error("{}异常,降级处理,异常为:{}", "更新流程状态", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -3,18 +3,13 @@ package com.njcn.supervision.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.supervision.api.TempLineFeignClient;
import com.njcn.supervision.api.TempLineRunTestFeignClient;
import com.njcn.supervision.utils.SupervisionEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author denghuajun
* @version 1.0.0
* @date 2022/3/16
*/
@Slf4j
@Component
public class TempLineRunTestFeignClientFallbackFactory implements FallbackFactory<TempLineRunTestFeignClient> {
@@ -28,11 +23,6 @@ public class TempLineRunTestFeignClientFallbackFactory implements FallbackFactor
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new TempLineRunTestFeignClient() {
@Override
public HttpResult<Object> updateStatus(String businessKey, Integer status) {
log.error("{}异常,降级处理,异常为:{}", "更新流程状态", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public void isTestRunStartOrEnd() {

View File

@@ -1,38 +0,0 @@
package com.njcn.supervision.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.supervision.api.UserReportFeignClient;
import com.njcn.supervision.utils.SupervisionEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author denghuajun
* @version 1.0.0
* @date 2022/3/16
*/
@Slf4j
@Component
public class UserReportFeignClientFallbackFactory implements FallbackFactory<UserReportFeignClient> {
@Override
public UserReportFeignClient 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 UserReportFeignClient() {
@Override
public HttpResult<Object> updateUserReportStatus(String businessKey, Integer status) {
log.error("{}异常,降级处理,异常为:{}", "更新用户数据流程状态", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -1,37 +0,0 @@
package com.njcn.supervision.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.supervision.api.UserReportNormalFeignClient;
import com.njcn.supervision.utils.SupervisionEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author denghuajun
* @version 1.0.0
* @date 2022/3/16
*/
@Slf4j
@Component
public class UserReportNoramlFeignClientFallbackFactory implements FallbackFactory<UserReportNormalFeignClient> {
@Override
public UserReportNormalFeignClient 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 UserReportNormalFeignClient() {
@Override
public HttpResult<Object> updateUserReportNormalStatus(String businessKey, Integer status) {
log.error("{}异常,降级处理,异常为:{}", "更新用户数据流程状态", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -42,6 +42,7 @@ public enum SupervisionKeyEnum {
}
private static final String packagePrefix = "com.njcn.supervision.service.";
private static final String packageMiddle = ".impl.";
/**
* 根据流程key获取类的全路径用于获取spring中的对象
@@ -49,9 +50,22 @@ public enum SupervisionKeyEnum {
public static String getFullServicePathByKey(String key){
for (SupervisionKeyEnum superviceKeyEnum : SupervisionKeyEnum.values()) {
if (superviceKeyEnum.key.equalsIgnoreCase(key)) {
return packagePrefix.concat(superviceKeyEnum.servicePrefix).concat(StrPool.DOT).concat(superviceKeyEnum.clazzName);
return packagePrefix.concat(superviceKeyEnum.servicePrefix).concat(packageMiddle).concat(superviceKeyEnum.clazzName);
}
}
return null;
}
/**
* 判断流程key是否在当前枚举内
*/
public static boolean containBusinessKye(String key){
for (SupervisionKeyEnum superviceKeyEnum : SupervisionKeyEnum.values()) {
if (superviceKeyEnum.key.equalsIgnoreCase(key)) {
return true;
}
}
return false;
}
}

View File

@@ -17,6 +17,7 @@ public enum SupervisionResponseEnum {
*/
SUPERVISION_COMMON_ERROR("A00550","监督管理模块异常"),
IMPORT_SENSITIVE_USER_ERROR("A00550","导入敏感及重要用户失败"),
SUPERVISION_SERVICE_NOT_FOUND("A00550","业务实现类丢失,清查看类路径配置"),
DATA_NOT_EXISTS("A00550","数据不存在"),
NO_POWER("A00550","不能操作非自己创建的任务!")
;

View File

@@ -0,0 +1,58 @@
package com.njcn.supervision.controller;
import cn.hutool.extra.spring.SpringUtil;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
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.common.utils.HttpResultUtil;
import com.njcn.supervision.enums.SupervisionKeyEnum;
import com.njcn.supervision.enums.SupervisionResponseEnum;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import com.njcn.bpm.service.IBpmService;
@Slf4j
@RestController
@RequestMapping("/supervision")
@Api(tags = "所有业务流程公共方法管理")
@AllArgsConstructor
@ApiIgnore
public class BusinessCommonController extends BaseController {
@ApiIgnore
@GetMapping("/updateProcessStatus")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("更新流程状态")
public HttpResult<Object> updateProcessStatus(String processKey,String businessId, Integer status) {
String methodDescribe = getMethodDescribe("updateProcessStatus");
IBpmService iBpmService = getBpmServiceByBusinessKey(processKey);
iBpmService.updateProcessStatus(businessId, status);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
/**
* 根据业务流key获取实现类对象
* @param processKey 业务流key
*/
private IBpmService getBpmServiceByBusinessKey(String processKey) {
String fullServicePath = SupervisionKeyEnum.getFullServicePathByKey(processKey);
IBpmService executor;
try {
executor = (IBpmService) SpringUtil.getBean(Class.forName(fullServicePath));
} catch (ClassNotFoundException e) {
throw new BusinessException(SupervisionResponseEnum.SUPERVISION_SERVICE_NOT_FOUND);
}
return executor;
}
}

View File

@@ -72,7 +72,7 @@ public class SurveyPlanServiceImpl extends ServiceImpl<SurveyPlanMapper, SurveyP
QueryWrapper<SurveyPlanVO> surveyPlanVOQueryWrapper = new QueryWrapper<>();
if (Objects.nonNull(surveyPlanQueryParam)) {
//添加上时间范围
surveyPlanVOQueryWrapper.between("supervision_survey_plan.Create_Time",
surveyPlanVOQueryWrapper.between("supervision_survey_plan.plan_start_time",
DateUtil.beginOfDay(DateUtil.parse(surveyPlanQueryParam.getSearchBeginTime())),
DateUtil.endOfDay(DateUtil.parse(surveyPlanQueryParam.getSearchEndTime())));
//根据工程名称模糊搜索