Browse Source

debug 方案申报 没有进入下一状态

master
PoffyZhang 1 year ago
parent
commit
9b234b35b9
3 changed files with 61 additions and 11 deletions
  1. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionPlanManage.java
  2. +13
    -9
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PurchaseManage.java
  3. +46
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java

+ 2
- 2
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionPlanManage.java View File

@@ -139,8 +139,8 @@ public class ConstructionPlanManage {
if(dto.getRestart()){
modifyProject(projectInfo, instanceId, projectInfo.getConstructionPlanFile());
}else{
//生成新版本
projectInfo = projectLibManage.saveProjectWithVersion(projectInfo,instanceId,InstTypeEnum.CONSTRUCTION_PLAN_REVIEW.getCode());
//生成新版本 并且进入下一状态
projectInfo = projectLibManage.saveProjectWithVersionAndPass(projectInfo,instanceId,InstTypeEnum.CONSTRUCTION_PLAN_REVIEW.getCode());
}

//发送给第一个审批人消息


+ 13
- 9
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PurchaseManage.java View File

@@ -10,27 +10,23 @@ import com.ningdatech.basic.model.PageVo;
import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.basic.util.NdDateUtils;
import com.ningdatech.pmapi.common.constant.BizConst;
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.*;
import com.ningdatech.pmapi.projectdeclared.model.entity.Purchase;
import com.ningdatech.pmapi.projectdeclared.model.vo.PurchaseVO;
import com.ningdatech.pmapi.projectdeclared.service.IProjectDraftService;
import com.ningdatech.pmapi.projectdeclared.service.IPurchaseService;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum;
import com.ningdatech.pmapi.projectlib.helper.ProjectHelper;
import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq;
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO;
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.exception.BusinessException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@@ -60,6 +56,8 @@ public class PurchaseManage {

private final IPurchaseService purchaseService;

private final StateMachineUtils stateMachineUtils;

/**
* 待采购的-项目列表
* @param req
@@ -158,12 +156,12 @@ public class PurchaseManage {

Long projectId = dto.getProjectId();
VUtils.isTrue(Objects.isNull(projectId)).throwMessage("提交失败 缺少项目ID!");
Project projectInfo = projectService.getById(projectId);
VUtils.isTrue(Objects.isNull(projectInfo)).throwMessage("提交失败 此项目不存在!");
Project project = projectService.getById(projectId);
VUtils.isTrue(Objects.isNull(project)).throwMessage("提交失败 此项目不存在!");

//首先要判断 项目当前状态 是不是 采购结果备案
VUtils.isTrue(!ProjectStatusEnum.TO_BE_PURCHASED.getCode().equals(projectInfo.getStatus()) ||
!ProjectStatusEnum.PROJECT_APPROVED.getCode().equals(projectInfo.getStage()))
VUtils.isTrue(!ProjectStatusEnum.TO_BE_PURCHASED.getCode().equals(project.getStatus()) ||
!ProjectStatusEnum.PROJECT_APPROVED.getCode().equals(project.getStage()))
.throwMessage("提交失败 该项目不是 待采购备案状态或者已立项阶段");

Purchase purchaseEntity = new Purchase();
@@ -180,6 +178,12 @@ public class PurchaseManage {
}
purchaseEntity.setProjectId(projectId);
purchaseService.saveOrUpdate(purchaseEntity);

//进入到下一状态
stateMachineUtils.pass(project);
project.setUpdateOn(LocalDateTime.now());
projectService.updateById(project);

return "填写成功";
}
}

+ 46
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java View File

@@ -427,6 +427,52 @@ public class ProjectLibManage {

return project;
}
public Project saveProjectWithVersionAndPass(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());
stateMachineUtils.pass(project);

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<ProjectApplication> applicationList = projectApplicationService.list(Wrappers.lambdaQuery(ProjectApplication.class)
.eq(ProjectApplication::getProjectId,oldProject.getId()));
if(CollUtil.isNotEmpty(applicationList)){
List<ProjectApplication> 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 项目详情


Loading…
Cancel
Save