From d69fe57d244b8ff608cc263a5ceb89ff1e363671 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Fri, 8 Mar 2024 14:20:31 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=90=E6=82=A3=E4=BB=A3=E7=A0=81=E8=BF=81?= =?UTF-8?q?=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/constant/TicketProcessConstant.java | 10 ++++ .../safeproduct/feign/ISafeInnerDangerClient.java | 31 +++++++++++ .../feign/ISafeInnerDangerClientFallback.java | 21 +++++++ .../serviceimpl/HazardRiskServiceImpl.java | 52 +++++++++++++++++ .../serviceimpl/HiddenDangerFlowServiceImpl.java | 65 ++++++++++++++++++++++ 5 files changed, 179 insertions(+) create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/feign/ISafeInnerDangerClient.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/feign/ISafeInnerDangerClientFallback.java create mode 100644 hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/HazardRiskServiceImpl.java create mode 100644 hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/HiddenDangerFlowServiceImpl.java diff --git a/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/constant/TicketProcessConstant.java b/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/constant/TicketProcessConstant.java index e4a7222..d0b79d3 100644 --- a/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/constant/TicketProcessConstant.java +++ b/hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/constant/TicketProcessConstant.java @@ -64,4 +64,14 @@ public class TicketProcessConstant { * 线下工作票 */ public static final String OFFLINE_WORK_TICKET = "offlineWorkTicket"; + /** + * 隐患流程标识 + */ + public static final String HIDDEN_DANGER_CHECK = "hiddenDangerCheck"; + + + /** + * 风险排查标识 + */ + public static final String HAZARD_RISK = "hazard_risk"; } diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/feign/ISafeInnerDangerClient.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/feign/ISafeInnerDangerClient.java new file mode 100644 index 0000000..c2aa068 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/feign/ISafeInnerDangerClient.java @@ -0,0 +1,31 @@ +package com.hnac.hzims.safeproduct.feign; + +import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import com.hnac.hzims.safeproduct.Constants; +import org.springblade.core.tool.api.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + + +/** + * @author xiashandong + * @created 2021/6/10 15:21 + **/ +@FeignClient( + value = Constants.APP_NAME, + fallback = ISafeInnerDangerClientFallback.class +) +public interface ISafeInnerDangerClient { + + String API_PREFIX = "/feign/hiddenDangerStart"; + + String SAVE_HIDDENDANGER = API_PREFIX + "/saveHiddenDanger"; + + + @PostMapping(SAVE_HIDDENDANGER) + R saveDefect(@RequestBody ProcessWorkFlowResponse processWorkFlowResponse); + + + +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/feign/ISafeInnerDangerClientFallback.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/feign/ISafeInnerDangerClientFallback.java new file mode 100644 index 0000000..b5a84ad --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/feign/ISafeInnerDangerClientFallback.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.safeproduct.feign; + +import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springframework.stereotype.Component; + + +/** + * @author ysj + */ +@Slf4j +@Component +public class ISafeInnerDangerClientFallback implements ISafeInnerDangerClient { + + @Override + public R saveDefect(ProcessWorkFlowResponse processWorkFlowResponse) { + log.error("远程调用失败,接口:" + SAVE_HIDDENDANGER); + return null; + } +} diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/HazardRiskServiceImpl.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/HazardRiskServiceImpl.java new file mode 100644 index 0000000..640b8a7 --- /dev/null +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/HazardRiskServiceImpl.java @@ -0,0 +1,52 @@ +package com.hnac.hzims.middle.processflow.strategy.serviceimpl; + +import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import com.hnac.hzims.middle.processflow.service.ProcessDictService; +import com.hnac.hzims.middle.processflow.strategy.abstracts.ProcessAbstractService; +import com.hnac.hzims.middle.processflow.strategy.entity.WorkflowQueue; +import com.hnac.hzims.safeproduct.risk.feign.IHazardRiskClient; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.api.R; +import org.springframework.stereotype.Service; + +import static com.hnac.hzims.middle.process.constant.TicketProcessConstant.HAZARD_RISK; + +/** + * @author ysj + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class HazardRiskServiceImpl extends ProcessAbstractService { + + private final IHazardRiskClient hazardRiskClient; + + private final ProcessDictService processDictService; + + + /** + * 消息确认 + * @param flowQueue + * @return + */ + @Override + public Boolean isWorkflowProcess(WorkflowQueue flowQueue) { + String dictValue = processDictService.selectDictValueByKey(HAZARD_RISK); + return dictValue.equals(flowQueue.getProcessDefinitionKey()); + } + + /** + * 调用检修业务处理 + * @param response + */ + @Override + public void calculate(ProcessWorkFlowResponse response) { + R defect = hazardRiskClient.listener(response); + if (!defect.isSuccess()) { + throw new ServiceException("检修任务业务执行异常!"); + + } + } +} diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/HiddenDangerFlowServiceImpl.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/HiddenDangerFlowServiceImpl.java new file mode 100644 index 0000000..c3c6d28 --- /dev/null +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/HiddenDangerFlowServiceImpl.java @@ -0,0 +1,65 @@ +package com.hnac.hzims.middle.processflow.strategy.serviceimpl; + +import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import com.hnac.hzims.middle.processflow.service.ProcessDictService; +import com.hnac.hzims.middle.processflow.strategy.abstracts.ProcessAbstractService; +import com.hnac.hzims.middle.processflow.strategy.entity.WorkflowQueue; +import com.hnac.hzims.safeproduct.feign.ISafeInnerDangerClient; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.api.R; +import org.springframework.stereotype.Service; + +import static com.hnac.hzims.middle.process.constant.TicketProcessConstant.HIDDEN_DANGER_CHECK; + +/** + * 隐患排查 + * + * @Author ty + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/9/18 9:04 + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class HiddenDangerFlowServiceImpl extends ProcessAbstractService { + + + private final ProcessDictService processDictService; + + + private final ISafeInnerDangerClient iSafeInnerDangerClient; + + /** + * 设置执行那种实现类 + * + * @param flowQueue + * @return + */ + @Override + public Boolean isWorkflowProcess(WorkflowQueue flowQueue) { + String dictValue = processDictService.selectDictValueByKey(HIDDEN_DANGER_CHECK); + if (dictValue.equals(flowQueue.getProcessDefinitionKey())) { + log.info("已执行隐患排查工作流程环节操作~~~~"); + return true; + } + log.error("未执行隐患排查流程环节操作,请联系管理员~~~~"); + return false; + } + + + /** + * 隐患排查业务方法 + * + * @param response + */ + @Override + public void calculate(ProcessWorkFlowResponse response) { + R dealtDutyRecFlow = iSafeInnerDangerClient.saveDefect(response); + if (!dealtDutyRecFlow.isSuccess()){ + throw new ServiceException("隐患排查流程失败"); + } + } +}