From 5cb7c5e59cdf22a16440730a46062b577b570db9 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Wed, 26 Apr 2023 09:21:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E7=8A=B6=E6=80=81=E9=83=BD=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=96=B0=E7=89=88=E6=9C=AC=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manage/ConstructionPlanManage.java | 8 +- .../PrequalificationDeclaredProjectManage.java | 13 ++- .../manage/ReviewByDeptJointManage.java | 9 ++- .../model/dto/DefaultDeclaredDTO.java | 3 + .../pmapi/projectlib/manage/ProjectLibManage.java | 93 ++++++++++++++++++++++ .../java/com/ningdatech/pmapi/provincial/Test.java | 2 +- 6 files changed, 120 insertions(+), 8 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionPlanManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionPlanManage.java index e7e70fd..c3cd461 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionPlanManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionPlanManage.java @@ -136,7 +136,12 @@ public class ConstructionPlanManage { log.info("建设方案项目申报成功 【{}】", instanceId); //保存建设项目 - modifyProject(projectInfo, instanceId, projectInfo.getConstructionPlanFile()); + if(dto.getRestart()){ + modifyProject(projectInfo, instanceId, projectInfo.getConstructionPlanFile()); + }else{ + //生成新版本 + projectInfo = projectLibManage.saveProjectWithVersion(projectInfo,instanceId,InstTypeEnum.CONSTRUCTION_PLAN_REVIEW.getCode()); + } //发送给第一个审批人消息 noticeManage.sendFirtUser(projectInfo,model.getFormName(),instanceId, @@ -166,6 +171,7 @@ public class ConstructionPlanManage { Project project = projectLibManage.saveProjectWithVersionAndStatus(projectDto,null, ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode()); dto.getProjectInfo().setId(project.getId()); + dto.setRestart(Boolean.TRUE); return startTheProcess(dto); } 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 359f9f5..3f968ba 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 @@ -136,7 +136,7 @@ public class PrequalificationDeclaredProjectManage { }else if(ProjectStatusEnum.PRE_APPLYING .getCode().equals(projectInfo.getStatus())){ //如果是非省级联审的项目 直接提交 预审 - instanceId = directStartProcess(projectInfo,employeeCode); + instanceId = directStartProcess(projectInfo,employeeCode,dto.getRestart()); }else{ throw new BusinessException("项目状态 错误 project :" + projectInfo.getId() + "," + projectInfo.getStatus()); } @@ -164,11 +164,12 @@ public class PrequalificationDeclaredProjectManage { Project project = projectLibManage.saveProjectWithVersionAndStatus(projectDto,null, ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode()); dto.getProjectInfo().setId(project.getId()); + dto.setRestart(Boolean.TRUE); return startTheProcess(dto); } //直接提交预审方法 提取 在省级联审通过的时候 也可以用 - public String directStartProcess(Project projectInfo,String employeeCode){ + public String directStartProcess(Project projectInfo,String employeeCode,Boolean restart){ VUtils.isTrue(Objects.isNull(employeeCode)) .throwMessage("发起人 员工code 不能为空!"); @@ -197,7 +198,13 @@ public class PrequalificationDeclaredProjectManage { log.info("提交预审项目成功 【{}】", instanceId); //保存预审项目 - preModifyProject(projectInfo, instanceId); + if(restart){ + //如果是重新提交 不用生成新版本 前面已经生成过了 + preModifyProject(projectInfo, instanceId); + }else{ + projectInfo = projectLibManage.saveProjectWithVersion(projectInfo, instanceId, + ProjectProcessStageEnum.PROJECT_PREQUALIFICATION_APPROVAL_PROCESS.getCode()); + } //发送给第一个审批人消息 noticeManage.sendFirtUser(projectInfo,model.getFormName(),instanceId, diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ReviewByDeptJointManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ReviewByDeptJointManage.java index d4b627e..ecc359a 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ReviewByDeptJointManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ReviewByDeptJointManage.java @@ -5,6 +5,7 @@ import com.google.common.collect.Maps; import com.ningdatech.basic.function.VUtils; import com.ningdatech.pmapi.common.enumeration.ProjectProcessStageEnum; import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; +import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage; import com.ningdatech.pmapi.projectlib.model.entity.Project; import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; import com.ningdatech.pmapi.projectlib.service.IProjectInstService; @@ -46,6 +47,7 @@ public class ReviewByDeptJointManage { private final IProjectInstService projectInstService; private final DefaultDeclaredProjectManage declaredProjectManage; + private final ProjectLibManage projectLibManage; private final DefaultDeclaredProjectManage defaultDeclaredProjectManage; private final NoticeManage noticeManage; @@ -99,9 +101,10 @@ public class ReviewByDeptJointManage { log.info("部门联审申报成功 【{}】", instanceId); //保存项目信息 - if(!modifyProject(projectInfo, instanceId)){ - return Boolean.FALSE; - } + projectInfo = projectLibManage.saveProjectWithVersion(projectInfo,instanceId,ProjectProcessStageEnum.DEPARTMENT_JOINT_APPROVAL_PROCESS.getCode()); +// if(!modifyProject(projectInfo, instanceId)){ +// return Boolean.FALSE; +// } //发送给第一个审批人消息 noticeManage.sendFirtUser(projectInfo,model.getFormName(),instanceId, diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/dto/DefaultDeclaredDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/dto/DefaultDeclaredDTO.java index b332d46..d3500ff 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/dto/DefaultDeclaredDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/dto/DefaultDeclaredDTO.java @@ -31,6 +31,9 @@ public class DefaultDeclaredDTO implements Serializable { @ApiModelProperty("表单信息 新增模块") private Map formData; + @ApiModelProperty("是否是重新提交 默认false") + private Boolean restart = Boolean.FALSE; + public Map getFormData(){ if(CollUtil.isEmpty(this.formData)){ this.formData = Maps.newHashMap(); 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 b4003e4..7418a5b 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 @@ -330,6 +330,99 @@ public class ProjectLibManage { return project; } + public Project saveProjectWithVersion(ProjectDTO projecDto,String instanceId,Integer instType){ + Project oldProject = projectService.getById(projecDto.getId()); + Project project = new Project(); + VUtils.isTrue(Objects.isNull(oldProject)) + .throwMessage("项目不存在!"); + BeanUtil.copyProperties(oldProject,project, CopyOptions.create() + .setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE)); + BeanUtil.copyProperties(projecDto,project, CopyOptions.create() + .setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE)); + project.setVersion(oldProject.getVersion() + 1); + project.setId(null); + project.setInstCode(instanceId); + project.setCreateOn(LocalDateTime.now()); + project.setUpdateOn(LocalDateTime.now()); + + if(projectService.save(project)){ + //保存项目和实例的关系 + ProjectInst projectInst = new ProjectInst(); + projectInst.setProjectId(project.getId()); + projectInst.setInstCode(instanceId); + projectInst.setCreatOn(LocalDateTime.now()); + projectInst.setUpdateOn(LocalDateTime.now()); + projectInst.setInstType(instType); + projectInstService.save(projectInst); + + projectService.update(Wrappers.lambdaUpdate(Project.class) + .set(Project::getNewest,Boolean.FALSE) + .ne(Project::getId,project.getId()) + .eq(Project::getProjectCode,project.getProjectCode())); + + //app + List applicationList = projecDto.getApplicationList(); + if(CollUtil.isNotEmpty(applicationList)){ + List apps = applicationList.stream() + .map(a -> { + ProjectApplication app = BeanUtil.copyProperties(a,ProjectApplication.class); + app.setId(null); + app.setProjectId(project.getId()); + return app; + }) + .collect(Collectors.toList()); + projectApplicationService.saveBatch(apps); + } + } + + return project; + } + public Project saveProjectWithVersion(Project oldProject,String instanceId,Integer instType){ + Project project = new Project(); + VUtils.isTrue(Objects.isNull(oldProject)) + .throwMessage("项目不存在!"); + BeanUtil.copyProperties(oldProject,project, CopyOptions.create() + .setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE)); + project.setVersion(oldProject.getVersion() + 1); + project.setId(null); + project.setInstCode(instanceId); + project.setCreateOn(LocalDateTime.now()); + project.setUpdateOn(LocalDateTime.now()); + + if(projectService.save(project)){ + //保存项目和实例的关系 + ProjectInst projectInst = new ProjectInst(); + projectInst.setProjectId(project.getId()); + projectInst.setInstCode(instanceId); + projectInst.setCreatOn(LocalDateTime.now()); + projectInst.setUpdateOn(LocalDateTime.now()); + projectInst.setInstType(instType); + projectInstService.save(projectInst); + + projectService.update(Wrappers.lambdaUpdate(Project.class) + .set(Project::getNewest,Boolean.FALSE) + .ne(Project::getId,project.getId()) + .eq(Project::getProjectCode,project.getProjectCode())); + + //app + List applicationList = projectApplicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) + .eq(ProjectApplication::getProjectId,oldProject.getId())); + if(CollUtil.isNotEmpty(applicationList)){ + List apps = applicationList.stream() + .map(a -> { + ProjectApplication app = BeanUtil.copyProperties(a,ProjectApplication.class); + app.setId(null); + app.setProjectId(project.getId()); + return app; + }) + .collect(Collectors.toList()); + projectApplicationService.saveBatch(apps); + } + } + + return project; + } + /** * @param projectId 项目详情 * @return com.ningdatech.pmapi.projectlib.model.entity.vo.ProjectDetailVO diff --git a/pmapi/src/test/java/com/ningdatech/pmapi/provincial/Test.java b/pmapi/src/test/java/com/ningdatech/pmapi/provincial/Test.java index 7e7c9ec..8ce4134 100644 --- a/pmapi/src/test/java/com/ningdatech/pmapi/provincial/Test.java +++ b/pmapi/src/test/java/com/ningdatech/pmapi/provincial/Test.java @@ -70,7 +70,7 @@ public class Test extends AppTests{// @org.junit.Test public void Test222(){ Project project = projectService.getById(340); - prequalificationDeclaredProjectManage.directStartProcess(project,project.getPreStartUserId()); + prequalificationDeclaredProjectManage.directStartProcess(project,project.getPreStartUserId(),Boolean.FALSE); } @org.junit.Test