From b7e291398b35cff752ffdb933d7cadd422301142 Mon Sep 17 00:00:00 2001 From: hongawen <83944980@qq.com> Date: Wed, 22 May 2024 16:30:22 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E5=91=8A=E8=AD=A6=E5=8D=95=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=97=AE=E9=A2=98=E8=AF=A6=E7=BB=86=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BpmWarningLeafletStatusListener.java | 28 ++++++++ .../api/WarningLeafletFeignClient.java | 23 +++++++ ...ningLeafletFeignClientFallbackFactory.java | 32 +++++++++ .../param/leaflet/WarningLeafletParam.java | 6 ++ .../pojo/vo/leaflet/WarningLeafletVO.java | 14 ++++ .../leaflet/WarningLeafletController.java | 39 +++++++++++ .../leaflet/IWarningLeafletService.java | 6 ++ .../impl/WarningLeafletServiceImpl.java | 67 ++++++++++++++++++- 8 files changed, 212 insertions(+), 3 deletions(-) create mode 100644 pqs-bpm/bpm-boot/src/main/java/com/njcn/bpm/listener/business/BpmWarningLeafletStatusListener.java create mode 100644 pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/api/WarningLeafletFeignClient.java create mode 100644 pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/api/fallback/WarningLeafletFeignClientFallbackFactory.java diff --git a/pqs-bpm/bpm-boot/src/main/java/com/njcn/bpm/listener/business/BpmWarningLeafletStatusListener.java b/pqs-bpm/bpm-boot/src/main/java/com/njcn/bpm/listener/business/BpmWarningLeafletStatusListener.java new file mode 100644 index 000000000..ee1395a0e --- /dev/null +++ b/pqs-bpm/bpm-boot/src/main/java/com/njcn/bpm/listener/business/BpmWarningLeafletStatusListener.java @@ -0,0 +1,28 @@ +package com.njcn.bpm.listener.business; + +import com.njcn.bpm.listener.BpmProcessInstanceStatusEvent; +import com.njcn.bpm.listener.BpmProcessInstanceStatusEventListener; +import com.njcn.supervision.api.DeVReportManageFeignClient; +import com.njcn.supervision.api.WarningLeafletFeignClient; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + + +@Component +public class BpmWarningLeafletStatusListener extends BpmProcessInstanceStatusEventListener { + + @Resource + private WarningLeafletFeignClient warningLeafletFeignClient; + + @Override + protected String getProcessDefinitionKey() { + return "warn_leaflet"; + } + + @Override + protected void onEvent(BpmProcessInstanceStatusEvent event) { + warningLeafletFeignClient.updateStatus(event.getBusinessKey(), event.getStatus()); + } + +} diff --git a/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/api/WarningLeafletFeignClient.java b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/api/WarningLeafletFeignClient.java new file mode 100644 index 000000000..a1e4a8442 --- /dev/null +++ b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/api/WarningLeafletFeignClient.java @@ -0,0 +1,23 @@ +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 updateStatus(@RequestParam("businessKey") String businessKey, @RequestParam("status")Integer status); + +} diff --git a/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/api/fallback/WarningLeafletFeignClientFallbackFactory.java b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/api/fallback/WarningLeafletFeignClientFallbackFactory.java new file mode 100644 index 000000000..74f3e31bb --- /dev/null +++ b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/api/fallback/WarningLeafletFeignClientFallbackFactory.java @@ -0,0 +1,32 @@ +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.utils.SupervisionEnumUtil; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Slf4j +@Component +public class WarningLeafletFeignClientFallbackFactory implements FallbackFactory { + @Override + public WarningLeafletFeignClient 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 WarningLeafletFeignClient() { + @Override + public HttpResult updateStatus(String businessKey, Integer status) { + log.error("{}异常,降级处理,异常为:{}", "更新流程状态", throwable.toString()); + throw new BusinessException(finalExceptionEnum); + } + }; + } +} diff --git a/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/param/leaflet/WarningLeafletParam.java b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/param/leaflet/WarningLeafletParam.java index 6579e07fc..7d8267e51 100644 --- a/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/param/leaflet/WarningLeafletParam.java +++ b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/param/leaflet/WarningLeafletParam.java @@ -11,6 +11,8 @@ import lombok.NoArgsConstructor; import javax.validation.constraints.NotBlank; import java.io.Serializable; +import java.util.List; +import java.util.Map; /** *

@@ -75,6 +77,8 @@ public class WarningLeafletParam extends BaseEntity implements Serializable{ @ApiModelProperty(value = "问题详细描述") private String issueDetail; + @ApiModelProperty("发起人自选审批人 Map") + private Map> startUserSelectAssignees; @Data @EqualsAndHashCode(callSuper = true) @@ -100,6 +104,8 @@ public class WarningLeafletParam extends BaseEntity implements Serializable{ @NotBlank(message = "处理成效报告不能为空") private String reportPath; + + } diff --git a/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/vo/leaflet/WarningLeafletVO.java b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/vo/leaflet/WarningLeafletVO.java index 1545f3854..e7d70c748 100644 --- a/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/vo/leaflet/WarningLeafletVO.java +++ b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/vo/leaflet/WarningLeafletVO.java @@ -59,12 +59,26 @@ public class WarningLeafletVO extends BaseEntity implements Serializable{ */ private String takeStep; + /** + * 问题文件 + */ + private String problemPath; + + /** + * 问题文件 + */ + private String problemName; /** * 处理成效报告 */ private String reportPath; + /** + * 处理成效报告 + */ + private String reportName; + /** * 流程实例的编号 */ diff --git a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/leaflet/WarningLeafletController.java b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/leaflet/WarningLeafletController.java index 0c5b6ab4d..fa35e7b44 100644 --- a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/leaflet/WarningLeafletController.java +++ b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/leaflet/WarningLeafletController.java @@ -3,10 +3,14 @@ package com.njcn.supervision.controller.leaflet; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.common.pojo.annotation.OperateInfo; +import com.njcn.common.pojo.constant.OperateType; 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.supervision.pojo.param.device.QuitRunningDeviceParam; +import com.njcn.supervision.pojo.vo.device.QuitRunningDeviceVO; +import com.njcn.supervision.pojo.vo.leaflet.WarningLeafletVO; import com.njcn.harmonic.pojo.dto.RMpPartHarmonicDetailDTO; import com.njcn.supervision.pojo.param.leaflet.WarningLeafletParam; import com.njcn.supervision.pojo.vo.leaflet.WarningLeafletVO; @@ -15,9 +19,14 @@ import com.njcn.web.controller.BaseController; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import com.njcn.web.controller.BaseController; +import springfox.documentation.annotations.ApiIgnore; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -71,5 +80,35 @@ public class WarningLeafletController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, out, methodDescribe); } + @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD) + @PostMapping("/addFeedback") + @ApiOperation("上传反馈单") + @ApiImplicitParam(name = "warningLeafletUpdateParam", value = "实体参数", required = true) + public HttpResult addFeedback(@RequestBody @Validated WarningLeafletParam.WarningLeafletUpdateParam warningLeafletUpdateParam) { + String methodDescribe = getMethodDescribe("addFeedback"); + warningLeafletService.addFeedback(warningLeafletUpdateParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } + + @GetMapping("/getById") + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @Operation(summary = "根据id获取预告警单的详细数据") + public HttpResult getById(String id) { + String methodDescribe = getMethodDescribe("getById"); + WarningLeafletVO warningLeafletVO = warningLeafletService.getVOById(id); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, warningLeafletVO, methodDescribe); + } + + @ApiIgnore + @GetMapping("/updateStatus") + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @Operation(summary = "更改表单状态") + public HttpResult updateStatus(String businessKey,Integer status) { + String methodDescribe = getMethodDescribe("updateStatus"); + warningLeafletService.updateStatus(businessKey,status); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } + + } diff --git a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/leaflet/IWarningLeafletService.java b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/leaflet/IWarningLeafletService.java index 172d0a5c3..00f137a9f 100644 --- a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/leaflet/IWarningLeafletService.java +++ b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/leaflet/IWarningLeafletService.java @@ -32,5 +32,11 @@ public interface IWarningLeafletService extends IService { Page warningPageData(WarningLeafletParam.WarningLeafletQueryParam warningLeafletQueryParam); + void addFeedback(WarningLeafletParam.WarningLeafletUpdateParam warningLeafletUpdateParam); + + WarningLeafletVO getVOById(String id); + + void updateStatus(String businessKey, Integer status); + String addLineOverLimitData(RMpPartHarmonicDetailDTO rMpPartHarmonicDetailDTO); } diff --git a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/leaflet/impl/WarningLeafletServiceImpl.java b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/leaflet/impl/WarningLeafletServiceImpl.java index b44dc2fb3..204788713 100644 --- a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/leaflet/impl/WarningLeafletServiceImpl.java +++ b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/leaflet/impl/WarningLeafletServiceImpl.java @@ -1,5 +1,6 @@ package com.njcn.supervision.service.leaflet.impl; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.LocalDateTimeUtil; @@ -7,6 +8,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.njcn.bpm.api.BpmProcessFeignClient; +import com.njcn.bpm.enums.BpmTaskStatusEnum; +import com.njcn.bpm.pojo.dto.BpmProcessInstanceCreateReqDTO; import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.harmonic.pojo.dto.RMpPartHarmonicDetailDTO; import com.njcn.supervision.enums.FlowStatusEnum; @@ -15,8 +19,10 @@ import com.njcn.supervision.enums.ProblemTypeEnum; import com.njcn.supervision.mapper.leaflet.WarningLeafletMapper; import com.njcn.supervision.pojo.param.leaflet.WarningLeafletParam; import com.njcn.supervision.pojo.po.leaflet.WarningLeaflet; +import com.njcn.supervision.pojo.po.survey.SupervisionGeneralSurveyPlanPO; import com.njcn.supervision.pojo.vo.leaflet.WarningLeafletVO; import com.njcn.supervision.service.leaflet.IWarningLeafletService; +import com.njcn.supervision.service.survey.SupervisionGeneralSurveyPlanPOService; import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.enums.DicDataTypeEnum; import com.njcn.system.pojo.po.DictData; @@ -24,10 +30,15 @@ import com.njcn.user.api.UserFeignClient; import com.njcn.web.factory.PageFactory; import com.njcn.web.utils.RequestUtil; import lombok.RequiredArgsConstructor; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; +import java.util.HashMap; import java.time.LocalDate; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; @@ -40,11 +51,22 @@ import java.util.stream.Collectors; * @since 2024-05-21 */ @Service -@RequiredArgsConstructor public class WarningLeafletServiceImpl extends ServiceImpl implements IWarningLeafletService { + @Resource + private UserFeignClient userFeignClient; + @Resource + private DicDataFeignClient dicDataFeignClient; + @Resource + private BpmProcessFeignClient bpmProcessFeignClient; - private final UserFeignClient userFeignClient; - private final DicDataFeignClient dicDataFeignClient; + @Lazy + @Resource + private SupervisionGeneralSurveyPlanPOService supervisionGeneralSurveyPlanPOService; + + /** + * 预告警单的反馈单对应的流程定义 KEY + */ + public static final String PROCESS_KEY = "warn_leaflet"; /** * 不创建工作流,只是创建一个告警单,需要待用户反馈后才会进入流程 @@ -81,6 +103,45 @@ public class WarningLeafletServiceImpl extends ServiceImpl(PageFactory.getPageNum(warningLeafletQueryParam), PageFactory.getPageSize(warningLeafletQueryParam)), warningLeafletVOQueryWrapper); } + @Override + @Transactional(rollbackFor = Exception.class) + public void addFeedback(WarningLeafletParam.WarningLeafletUpdateParam warningLeafletUpdateParam) { + WarningLeaflet warningLeaflet = this.baseMapper.selectById(warningLeafletUpdateParam.getId()); + warningLeaflet.setTakeStep(warningLeafletUpdateParam.getTakeStep()); + warningLeaflet.setReportPath(warningLeafletUpdateParam.getReportPath()); + warningLeaflet.setStatus(BpmTaskStatusEnum.RUNNING.getStatus()); + // 发起 BPM 流程 + Map processInstanceVariables = new HashMap<>(); + BpmProcessInstanceCreateReqDTO bpmProcessInstanceCreateReqDTO = new BpmProcessInstanceCreateReqDTO(); + bpmProcessInstanceCreateReqDTO.setProcessDefinitionKey(PROCESS_KEY); + bpmProcessInstanceCreateReqDTO.setBusinessKey(warningLeaflet.getId()); + bpmProcessInstanceCreateReqDTO.setStartUserSelectAssignees(warningLeafletUpdateParam.getStartUserSelectAssignees()); + bpmProcessInstanceCreateReqDTO.setVariables(processInstanceVariables); + String processInstanceId = bpmProcessFeignClient.createProcessInstance(RequestUtil.getUserIndex(), bpmProcessInstanceCreateReqDTO).getData(); + // 将工作流的编号,更新到流程单中 + warningLeaflet.setProcessInstanceId(processInstanceId); + this.baseMapper.updateById(warningLeaflet); + } + + @Override + public WarningLeafletVO getVOById(String id) { + WarningLeaflet warningLeaflet = this.getById(id); + WarningLeafletVO vo = new WarningLeafletVO(); + BeanUtil.copyProperties(warningLeaflet,vo); + if(warningLeaflet.getProblemType().equals(ProblemTypeEnum.SITE_TEST.getCode())){ + String problemId = warningLeaflet.getProblemId(); + //查询谐波普测,获取该普测计划上传的文件 + SupervisionGeneralSurveyPlanPO generalSurveyPlanPO = supervisionGeneralSurveyPlanPOService.getById(problemId); + vo.setProblemPath(generalSurveyPlanPO.getFilePath()); + } + return vo; + } + + @Override + public void updateStatus(String businessKey, Integer status) { + this.lambdaUpdate().set(WarningLeaflet::getStatus, status).eq(WarningLeaflet::getId, businessKey).update(); + } + @Override public Page alarmPageData(WarningLeafletParam.WarningLeafletQueryParam warningLeafletQueryParam) { QueryWrapper warningLeafletVOQueryWrapper = new QueryWrapper<>();