From 8e882268f92fc9eac5605b60938b1aa9f28a5713 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Wed, 19 Apr 2023 10:40:44 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B3=E6=8A=A5=E9=A1=B9=E7=9B=AE=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=20=E7=BB=99=E7=AC=AC=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=AE=A1=E6=A0=B8=E4=BA=BA=20=E5=8F=91=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manage/DeclaredProjectManage.java | 11 +++--- .../manage/DefaultDeclaredProjectManage.java | 39 ++++++++++++++++++++-- .../utils/GenerateProjectCodeUtil.java | 12 +++---- 3 files changed, 49 insertions(+), 13 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java index 285f6ce..4db7861 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java @@ -131,6 +131,8 @@ public class DeclaredProjectManage { projectInfo.setId(null); } +// defaultDeclaredProjectManage.startProcess(projectInfo,user,ProjectProcessStageEnum.ORG_INTERNAL_APPROVAL_PROCESS.getCode()); + String regionCode = user.getRegionCode(); WflowModels model = processModelService.getOne(Wrappers.lambdaQuery(WflowModels.class) @@ -163,13 +165,14 @@ public class DeclaredProjectManage { log.info("申报项目成功 【{}】", instanceId); //如果是重新提交的话 判断下 项目是否存在 - if(saveOrUpdateProject(projectInfo, instanceId,employeeCode) && Objects.nonNull(projectInfo.getDraftId())){ + Project buildProject = saveOrUpdateProject(projectInfo, instanceId,employeeCode); + if(Objects.nonNull(projectInfo.getDraftId())){ //如果是草稿箱提交 删除对应的草稿箱 projectDraftService.removeById(projectInfo.getDraftId()); } //发送给第一个审批人消息 - noticeManage.sendFirtUser(project,model.getFormName(),instanceId, + noticeManage.sendFirtUser(buildProject,model.getFormName(),instanceId, WorkNoticeContant.PASS_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW); return instanceId; @@ -249,7 +252,7 @@ public class DeclaredProjectManage { * @param projectDto * @param instanceId */ - private Boolean saveOrUpdateProject(ProjectDTO projectDto, String instanceId, + private Project saveOrUpdateProject(ProjectDTO projectDto, String instanceId, String employeeCode) { //流程启动之后 入库项目 重要业务信息 用于列表查询 展示 try { @@ -288,11 +291,11 @@ public class DeclaredProjectManage { projectInst.setUpdateOn(LocalDateTime.now()); projectInst.setInstType(ProjectProcessStageEnum.ORG_INTERNAL_APPROVAL_PROCESS.getCode()); projectInstService.save(projectInst); + return project; } catch (Exception e) { log.error("项目信息入库错误 " + e); throw new BusinessException("项目信息入库错误 :" + e); } - return Boolean.TRUE; } public PageVo pageDraft(DeclaredProjectListParamDTO params) { diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java index ed0bcc5..27405d1 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java @@ -3,11 +3,12 @@ package com.ningdatech.pmapi.projectdeclared.manage; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Maps; import com.ningdatech.basic.function.VUtils; +import com.ningdatech.pmapi.common.constant.BizConst; import com.ningdatech.pmapi.common.constant.RegionConst; +import com.ningdatech.pmapi.common.enumeration.ProjectProcessStageEnum; import com.ningdatech.pmapi.common.helper.UserInfoHelper; -import com.ningdatech.pmapi.organization.model.entity.DingOrganization; -import com.ningdatech.pmapi.organization.service.IDingOrganizationService; import com.ningdatech.pmapi.projectdeclared.model.dto.DefaultDeclaredDTO; import com.ningdatech.pmapi.projectdeclared.model.dto.ProjectConditionDTO; import com.ningdatech.pmapi.projectdeclared.model.po.DeclaredProjectStatisticsPO; @@ -17,13 +18,16 @@ import com.ningdatech.pmapi.projectlib.model.entity.Project; import com.ningdatech.pmapi.projectlib.service.IProjectService; import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; import com.ningdatech.pmapi.user.util.LoginUserUtil; +import com.wflow.bean.entity.WflowModels; import com.wflow.bean.entity.WflowOrgModels; import com.wflow.enums.OrgTypeEnum; import com.wflow.enums.ProcessDefTypeEnum; +import com.wflow.exception.BusinessException; import com.wflow.service.OrgProcdefService; import com.wflow.workflow.bean.dto.OrgInfoDTO; import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; import com.wflow.workflow.bean.vo.ProcessStartParamsVo; +import com.wflow.workflow.service.ProcessModelService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; @@ -48,11 +52,40 @@ public class DefaultDeclaredProjectManage { private final UserInfoHelper userInfoHelper; - private final IDingOrganizationService dingOrganizationService; + private final ProcessModelService processModelService; private final OrgProcdefService orgProcdefService; private final IDeclaredStatisticsService statisticsService; + /** + * 公共的发起流程方法 + */ + public void startProcess(ProjectDTO projectDTO,UserFullInfoDTO user,Integer processType){ + WflowModels model = processModelService.getOne(Wrappers.lambdaQuery(WflowModels.class) + .eq(WflowModels::getRegionCode, user.getRegionCode()) + .eq(WflowModels::getProcessType, processType) + .last(BizConst.LIMIT_1)); + + if (Objects.isNull(model)) { + log.error("此 【{}】区域找不到对应流程配置", user.getRegionCode()); + throw new BusinessException(String.format("此 【%s】区域找不到对应流程配置", user.getRegionCode())); + } + + ProcessStartParamsVo params = new ProcessStartParamsVo(); + params.setUser(buildUser(user.getEmployeeCode())); + params.setProcessUsers(Collections.emptyMap()); + //放入条件判断的项目字段 + ProjectConditionDTO conditionDto = new ProjectConditionDTO(); + BeanUtils.copyProperties(projectDTO, conditionDto); + Map formData = Maps.newHashMap(); + formData.putAll( + JSON.parseObject(JSON.toJSONString(conditionDto), new TypeReference>() { + }) + ); + params.setFormData(formData); + + } + //项目名称去重 public void checkDuplication(ProjectDTO project){ VUtils.isTrue(projectService.count(Wrappers.lambdaQuery(Project.class) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java index d897895..b65fa87 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java @@ -31,15 +31,15 @@ public class GenerateProjectCodeUtil { @Autowired private IProjectService projectService; - public String generateProjectCode(ProjectDTO projectInfo){ + public String generateProjectCode(ProjectDTO project){ // 获取所属行政区划代码(6位) - String areaCode = projectInfo.getAreaCode(); + String areaCode = project.getAreaCode(); // 获取建设年度后两位 - String year = String.valueOf(projectInfo.getProjectYear() % DeclaredProjectContant.Project.YEAR_DRAW_SURPLUS); + String year = String.valueOf(project.getProjectYear() % DeclaredProjectContant.Project.YEAR_DRAW_SURPLUS); // 9-12位固定 String fixedNumber = DeclaredProjectContant.Project.FIXED_NUMBER; // 获取公司的财政编码 - CompanyFiscalCode companyFiscalCode = companyFiscalCodeService.getByOrganizationCode(projectInfo.getBuildOrgCode()); + CompanyFiscalCode companyFiscalCode = companyFiscalCodeService.getByOrganizationCode(project.getBuildOrgCode()); // 从表中查出单位配置的财政编码 if (Objects.isNull(companyFiscalCode)){ @@ -51,8 +51,8 @@ public class GenerateProjectCodeUtil { String projectIdStr; // 获取项目库当前最大项目序号 List projectList = projectService.list(Wrappers.lambdaQuery(Project.class).orderByDesc(Project::getId)); - Project project = CollUtil.isEmpty(projectList) ? null : projectList.get(0); - Long projectId = Objects.isNull(project) ? DeclaredProjectContant.Project.MIN_PROJECT_ID : project.getId() + 1; + Project maxProject = CollUtil.isEmpty(projectList) ? null : projectList.get(0); + Long projectId = Objects.isNull(maxProject) ? DeclaredProjectContant.Project.MIN_PROJECT_ID : maxProject.getId() + 1; if (projectId > DeclaredProjectContant.Project.MAX_PROJECT_ID){ // 超过999的项目号从1开始 1 Long newProjectId = projectId % DeclaredProjectContant.Project.MAX_PROJECT_ID;