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 8bdc2bc..fbfe8dd 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 @@ -1,46 +1,27 @@ package com.ningdatech.pmapi.projectdeclared.manage; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.TypeReference; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ningdatech.basic.function.VUtils; -import com.ningdatech.pmapi.common.enumeration.ProjectProcessStageEnum; import com.ningdatech.pmapi.common.helper.UserInfoHelper; -import com.ningdatech.pmapi.datascope.model.DataScopeDTO; -import com.ningdatech.pmapi.datascope.utils.DataScopeUtil; import com.ningdatech.pmapi.organization.model.entity.DingOrganization; import com.ningdatech.pmapi.organization.service.IDingOrganizationService; -import com.ningdatech.pmapi.projectdeclared.model.dto.ProjectConditionDTO; import com.ningdatech.pmapi.projectdeclared.model.po.DeclaredProjectStatisticsPO; import com.ningdatech.pmapi.projectdeclared.service.IDeclaredStatisticsService; -import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO; 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.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; -import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; 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.ProcessInstanceService; -import com.wflow.workflow.service.ProcessModelService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Component; - import java.math.BigDecimal; -import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; @@ -63,12 +44,6 @@ public class DefaultDeclaredProjectManage { private final IDingOrganizationService dingOrganizationService; private final OrgProcdefService orgProcdefService; - private final ProcessModelService processModelService; - - private final ProcessInstanceService processService; - - private final IProjectInstService projectInstService; - private final IDeclaredStatisticsService statisticsService; //项目名称去重 @@ -186,70 +161,6 @@ public class DefaultDeclaredProjectManage { return orgMap; } - //直接提交预审方法 提取 在省级联审通过的时候 也可以用 - public String directStartProcess(Project projectInfo,String employeeCode){ - VUtils.isTrue(Objects.isNull(employeeCode)) - .throwMessage("发起人 员工code 不能为空!"); - - ProcessStartParamsVo params = new ProcessStartParamsVo(); - params.setUser(buildUser(employeeCode)); - params.setProcessUsers(Collections.emptyMap()); - //放入条件判断的项目字段 - ProjectConditionDTO conditionDto = new ProjectConditionDTO(); - BeanUtils.copyProperties(projectInfo, conditionDto); - params.setFormData(JSON.parseObject(JSON.toJSONString(conditionDto), new TypeReference>() { - })); - - String regionCode = projectInfo.getAreaCode(); - - WflowModels model = processModelService.getOne(Wrappers.lambdaQuery(WflowModels.class) - .eq(WflowModels::getRegionCode, regionCode) - .eq(WflowModels::getProcessType, ProjectProcessStageEnum.PROJECT_PREQUALIFICATION_APPROVAL_PROCESS.getCode()) - .last("limit 1")); - - if (Objects.isNull(model)) { - log.error("此 【{}】区域找不到 预审流程配置", regionCode); - throw new BusinessException(String.format("此 【%s】区域找不到 预审流程配置", regionCode)); - } - - // 获取发起单位、发起单位主管单位、发起单位上级主管条线单位信息 - Map orgModelMap = buildOrgModelMap(employeeCode,projectInfo); - String instanceId = processService.newStartProcess(model.getProcessDefId(),model.getFormId(), params,orgModelMap); - log.info("提交预审项目成功 【{}】", instanceId); - - //保存预审项目 - preModifyProject(projectInfo, instanceId); - - return instanceId; - } - - /** - * 提交预审项目 时 更新信息 - * - * @param project - * @param instanceId - */ - private void preModifyProject(Project project, String instanceId) { - //流程启动之后 入库项目 重要业务信息 用于列表查询 展示 - try { - project.setUpdateOn(LocalDateTime.now()); - project.setInstCode(instanceId); - projectService.updateById(project); - - //保存项目和实例的关系 - ProjectInst projectInst = new ProjectInst(); - projectInst.setProjectId(project.getId()); - projectInst.setInstCode(instanceId); - projectInst.setCreatOn(LocalDateTime.now()); - projectInst.setUpdateOn(LocalDateTime.now()); - projectInst.setInstType(ProjectProcessStageEnum.PROJECT_PREQUALIFICATION_APPROVAL_PROCESS.getCode()); - projectInstService.save(projectInst); - } catch (Exception e) { - log.error("提交预审 项目信息修改 错误 ", e); - throw new BusinessException("提交预审 项目信息修改 错误 :" + e.getMessage()); - } - } - //根据提交者的单位 public DeclaredProjectStatisticsPO declaredProjectOrgStatistics(Integer year){ UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PrequalificationDeclaredProjectManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PrequalificationDeclaredProjectManage.java index 809fd76..f8a3e9e 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PrequalificationDeclaredProjectManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PrequalificationDeclaredProjectManage.java @@ -2,16 +2,20 @@ package com.ningdatech.pmapi.projectdeclared.manage; import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ningdatech.basic.function.VUtils; import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.util.NdDateUtils; +import com.ningdatech.pmapi.common.enumeration.ProjectProcessStageEnum; import com.ningdatech.pmapi.common.helper.UserInfoHelper; import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; import com.ningdatech.pmapi.common.util.ExcelDownUtil; import com.ningdatech.pmapi.common.util.ExcelExportStyle; import com.ningdatech.pmapi.projectdeclared.model.dto.DefaultDeclaredDTO; import com.ningdatech.pmapi.projectdeclared.model.dto.PretrialDeclaredExportDTO; +import com.ningdatech.pmapi.projectdeclared.model.dto.ProjectConditionDTO; import com.ningdatech.pmapi.projectdeclared.model.req.PrequalificationDeclaredListReq; import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; @@ -19,13 +23,21 @@ import com.ningdatech.pmapi.projectlib.helper.ProjectHelper; import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage; import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO; import com.ningdatech.pmapi.projectlib.model.entity.Project; +import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; +import com.ningdatech.pmapi.projectlib.service.IProjectInstService; import com.ningdatech.pmapi.projectlib.service.IProjectService; import com.ningdatech.pmapi.staging.service.IProjectStagingService; +import com.ningdatech.pmapi.todocenter.constant.TodoCenterContant; 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.exception.BusinessException; +import com.wflow.workflow.bean.dto.OrgInfoDTO; +import com.wflow.workflow.bean.vo.ProcessStartParamsVo; +import com.wflow.workflow.service.ProcessInstanceService; +import com.wflow.workflow.service.ProcessModelService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; @@ -34,7 +46,9 @@ import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.time.LocalDateTime; +import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; @@ -59,10 +73,14 @@ public class PrequalificationDeclaredProjectManage { private final UserInfoHelper userInfoHelper; - private final DefaultDeclaredProjectManage declaredProjectManage; + private final ProcessModelService processModelService; private final DefaultDeclaredProjectManage defaultDeclaredProjectManage; + private final ProcessInstanceService processInstanceService; + + private final IProjectInstService projectInstService; + /** * 提交预审 * @@ -102,6 +120,8 @@ public class PrequalificationDeclaredProjectManage { projectInfo.setUpdateOn(LocalDateTime.now()); //保存一下 当前的主管单位发起人 projectInfo.setPreStartUserId(employeeCode); + //当前实例置为空 + projectInfo.setInstCode(TodoCenterContant.Declared.NULL_INST_CODE); if(projectStagingService.addByProject(projectInfo,"省级部门联审") && projectService.updateById(projectInfo)){ return "提交省级部门联审成功"; @@ -110,7 +130,7 @@ public class PrequalificationDeclaredProjectManage { }else if(ProjectStatusEnum.PRE_APPLYING .getCode().equals(projectInfo.getStatus())){ //如果是非省级联审的项目 直接提交 预审 - instanceId = defaultDeclaredProjectManage.directStartProcess(projectInfo,employeeCode); + instanceId = directStartProcess(projectInfo,employeeCode); }else{ throw new BusinessException("项目状态 错误 project :" + JSON.toJSONString(projectInfo)); } @@ -140,6 +160,70 @@ public class PrequalificationDeclaredProjectManage { return startTheProcess(dto); } + //直接提交预审方法 提取 在省级联审通过的时候 也可以用 + public String directStartProcess(Project projectInfo,String employeeCode){ + VUtils.isTrue(Objects.isNull(employeeCode)) + .throwMessage("发起人 员工code 不能为空!"); + + ProcessStartParamsVo params = new ProcessStartParamsVo(); + params.setUser(defaultDeclaredProjectManage.buildUser(employeeCode)); + params.setProcessUsers(Collections.emptyMap()); + //放入条件判断的项目字段 + ProjectConditionDTO conditionDto = new ProjectConditionDTO(); + BeanUtils.copyProperties(projectInfo, conditionDto); + params.setFormData(JSON.parseObject(JSON.toJSONString(conditionDto), new TypeReference>() { + })); + + String regionCode = projectInfo.getAreaCode(); + + WflowModels model = processModelService.getOne(Wrappers.lambdaQuery(WflowModels.class) + .eq(WflowModels::getRegionCode, regionCode) + .eq(WflowModels::getProcessType, ProjectProcessStageEnum.PROJECT_PREQUALIFICATION_APPROVAL_PROCESS.getCode()) + .last("limit 1")); + + if (Objects.isNull(model)) { + log.error("此 【{}】区域找不到 预审流程配置", regionCode); + throw new BusinessException(String.format("此 【%s】区域找不到 预审流程配置", regionCode)); + } + + // 获取发起单位、发起单位主管单位、发起单位上级主管条线单位信息 + Map orgModelMap = defaultDeclaredProjectManage.buildOrgModelMap(employeeCode,projectInfo); + String instanceId = processInstanceService.newStartProcess(model.getProcessDefId(),model.getFormId(), params,orgModelMap); + log.info("提交预审项目成功 【{}】", instanceId); + + //保存预审项目 + preModifyProject(projectInfo, instanceId); + + return instanceId; + } + + /** + * 提交预审项目 时 更新信息 + * + * @param project + * @param instanceId + */ + private void preModifyProject(Project project, String instanceId) { + //流程启动之后 入库项目 重要业务信息 用于列表查询 展示 + try { + project.setUpdateOn(LocalDateTime.now()); + project.setInstCode(instanceId); + projectService.updateById(project); + + //保存项目和实例的关系 + ProjectInst projectInst = new ProjectInst(); + projectInst.setProjectId(project.getId()); + projectInst.setInstCode(instanceId); + projectInst.setCreatOn(LocalDateTime.now()); + projectInst.setUpdateOn(LocalDateTime.now()); + projectInst.setInstType(ProjectProcessStageEnum.PROJECT_PREQUALIFICATION_APPROVAL_PROCESS.getCode()); + projectInstService.save(projectInst); + } catch (Exception e) { + log.error("提交预审 项目信息修改 错误 ", e); + throw new BusinessException("提交预审 项目信息修改 错误 :" + e.getMessage()); + } + } + /** * 查询项目库 * @param preReq