From 1e11a6e2f3a39018ef0879b85cf53f5bd5a12fcb Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Fri, 30 Jun 2023 13:59:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=AE=A1=E4=BA=BA=E5=91=98=20?= =?UTF-8?q?=E5=92=8C=20=E8=87=AA=E5=8A=A8=E4=B8=8B=E4=B8=80=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/projectlib/manage/ProjectLibManage.java | 18 +++++ .../pmapi/projectlib/model/vo/ProjectDetailVO.java | 5 ++ .../scheduler/listener/ProcessStartListener.java | 88 ++++++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/ProcessStartListener.java diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java index 1f2833c..55f692f 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java @@ -32,10 +32,13 @@ import com.ningdatech.pmapi.organization.model.entity.DingOrganization; import com.ningdatech.pmapi.organization.service.IDingOrganizationService; import com.ningdatech.pmapi.projectdeclared.model.dto.DelayedApplyDTO; import com.ningdatech.pmapi.projectdeclared.model.entity.Contract; +import com.ningdatech.pmapi.projectdeclared.model.entity.PreInsAcceptancePerson; import com.ningdatech.pmapi.projectdeclared.model.entity.Purchase; import com.ningdatech.pmapi.projectdeclared.model.vo.ContractVO; +import com.ningdatech.pmapi.projectdeclared.model.vo.PreInsAcceptancePersonVO; import com.ningdatech.pmapi.projectdeclared.model.vo.PurchaseVO; import com.ningdatech.pmapi.projectdeclared.service.IContractService; +import com.ningdatech.pmapi.projectdeclared.service.IPreInsAcceptancePersonService; import com.ningdatech.pmapi.projectdeclared.service.IPurchaseService; import com.ningdatech.pmapi.projectdeclared.utils.GenerateProjectCodeUtil; import com.ningdatech.pmapi.projectlib.enumeration.InstTypeEnum; @@ -97,6 +100,8 @@ public class ProjectLibManage { private final IPurchaseService purchaseService; + private final IPreInsAcceptancePersonService acceptancePersonService; + public PageVo projectLibList(ProjectListReq req) { LambdaQueryWrapper query = ProjectHelper.projectQuery(req); query.eq(Project::getNewest,Boolean.TRUE); @@ -538,6 +543,11 @@ public class ProjectLibManage { vo.setContract(BeanUtil.copyProperties(contract, ContractVO.class)); //查询初验信息 + List acceptancePersons = acceptancePersonService.list(Wrappers.lambdaQuery(PreInsAcceptancePerson.class) + .eq(PreInsAcceptancePerson::getProjectId, projectId) + .orderByAsc(PreInsAcceptancePerson::getCreateOn)); + vo.setAcceptancePersons(convertPersons(acceptancePersons)); + //查询终验信息 //查询年度投资金额 要是已验收的项目 @@ -771,4 +781,12 @@ public class ProjectLibManage { return PageVo.of(res,page.getTotal()); } + + private List convertPersons(List acceptancePersons) { + if(CollUtil.isEmpty(acceptancePersons)){ + return Collections.emptyList(); + } + + return acceptancePersons.stream().map(u -> BeanUtil.copyProperties(u,PreInsAcceptancePersonVO.class)).collect(Collectors.toList()); + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectDetailVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectDetailVO.java index 547a6af..2a9e516 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectDetailVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectDetailVO.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.ningdatech.pmapi.common.util.BizUtils; import com.ningdatech.pmapi.projectdeclared.model.entity.Contract; import com.ningdatech.pmapi.projectdeclared.model.vo.ContractVO; +import com.ningdatech.pmapi.projectdeclared.model.vo.PreInsAcceptancePersonVO; import com.ningdatech.pmapi.projectdeclared.model.vo.PurchaseVO; import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; import io.swagger.annotations.ApiModel; @@ -363,6 +364,10 @@ public class ProjectDetailVO { @ApiModelProperty("采购信息") private PurchaseVO purchase; + @ApiModelProperty("初审人员") + private List acceptancePersons; + + public String getProjectTypeName() { if (Objects.nonNull(this.projectType)) { Optional.ofNullable(ProjectTypeEnum.getDesc(this.projectType)) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/ProcessStartListener.java b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/ProcessStartListener.java new file mode 100644 index 0000000..4847e67 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/ProcessStartListener.java @@ -0,0 +1,88 @@ +package com.ningdatech.pmapi.scheduler.listener; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ningdatech.pmapi.common.constant.BizConst; +import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; +import com.ningdatech.pmapi.projectlib.model.entity.Project; +import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; +import com.ningdatech.pmapi.projectlib.service.IProjectInstService; +import com.ningdatech.pmapi.projectlib.service.IProjectService; +import com.wflow.workflow.notify.event.ProcessStartEvent; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.HistoryService; +import org.flowable.engine.TaskService; +import org.flowable.task.api.Task; +import org.flowable.task.api.history.HistoricTaskInstance; +import org.springframework.context.event.EventListener; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Objects; + +/** + * 工作流开始 事件监听 + * + * @author ZPF + * @return + * @since 2023/04/14 14:19 + */ +@Slf4j +@Component +@RequiredArgsConstructor +public class ProcessStartListener { + private final TaskService taskService; + private final HistoryService historyService; + private final IProjectInstService projectInstService; + + private final IProjectService projectService; + + private final StateMachineUtils stateMachineUtils; + + @Async + @EventListener + public void onApplicationEvent(ProcessStartEvent event) { + log.info("进入工作流开始 事件监听!{}", event.getInstCode()); + String instCode = event.getInstCode(); + + log.info("instCode:{}", instCode); + + //休息3秒 + try { + Thread.sleep(3000); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + + //1.去查找 项目实例关系表 + ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class) + .eq(ProjectInst::getInstCode, instCode) + .last(BizConst.LIMIT_1)); + + if (Objects.isNull(projectInst)) { + return; + } + + List tasks = taskService.createTaskQuery() + .processInstanceId(instCode) + .active() + .list(); + + List historyTasks = historyService.createHistoricTaskInstanceQuery() + .processInstanceId(instCode) + .finished() + .list(); + + if (CollUtil.isEmpty(tasks) && CollUtil.isEmpty(historyTasks)) { + //如果真的没有实时任务和历史任务 那么说明 该项目没有人审批 需要去调用状态机 + Long projectId = projectInst.getProjectId(); + Project project = projectService.getNewProject(projectId); + stateMachineUtils.pass(project); + project.setUpdateOn(LocalDateTime.now()); + projectService.updateById(project); + } + } +} \ No newline at end of file