PoffyZhang 1 год назад
Родитель
Сommit
e6640e5e56
19 измененных файлов: 531 добавлений и 202 удалений
  1. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/contants/DeclaredProjectContant.java
  2. +8
    -3
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/ConstructionPlanController.java
  3. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/DeclaredProjectController.java
  4. +8
    -3
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/PrequalificationDeclaredController.java
  5. +61
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/ProjectAdjustmentController.java
  6. +0
    -45
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/entity/dto/ConstructionPlanDTO.java
  7. +4
    -6
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/entity/dto/DefaultDeclaredDTO.java
  8. +0
    -42
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/entity/dto/PreDeclaredProjectDTO.java
  9. +44
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/entity/req/AdjustmentListReq.java
  10. +38
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/entity/req/ConstrctionPlanListReq.java
  11. +38
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/entity/req/PrequalificationDeclaredListReq.java
  12. +23
    -7
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionPlanManage.java
  13. +83
    -12
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java
  14. +49
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java
  15. +52
    -17
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PrequalificationDeclaredProjectManage.java
  16. +79
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ProjectAdjustmentManage.java
  17. +22
    -18
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/helper/ProjectHelper.java
  18. +11
    -47
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectInst.java
  19. +6
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/req/ProjectListReq.java

+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/contants/DeclaredProjectContant.java Просмотреть файл

@@ -14,4 +14,7 @@ public interface DeclaredProjectContant {
public static final String PROJECT_STAGE_5 = "验收申报审批流程";
}

class Instance {
public static final String PROVINCE_INSTANCE_ID = "PROVINCE_AUDIT";
}
}

+ 8
- 3
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/ConstructionPlanController.java Просмотреть файл

@@ -1,7 +1,8 @@
package com.ningdatech.pmapi.projectdeclared.controller;

import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.projectdeclared.entity.dto.ConstructionPlanDTO;
import com.ningdatech.pmapi.projectdeclared.entity.dto.DefaultDeclaredDTO;
import com.ningdatech.pmapi.projectdeclared.entity.req.ConstrctionPlanListReq;
import com.ningdatech.pmapi.projectdeclared.manage.ConstructionPlanManage;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage;
@@ -11,6 +12,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@@ -34,7 +36,10 @@ public class ConstructionPlanController {

@ApiOperation(value = "可申报建设方案项目列表", notes = "可申报建设方案项目列表")
@GetMapping("/list")
public PageVo<ProjectLibListItemVO> list(@Validated @ModelAttribute ProjectListReq req) {
public PageVo<ProjectLibListItemVO> list(@Validated @ModelAttribute ConstrctionPlanListReq planReq) {
//限定参数 复制bean
ProjectListReq req = new ProjectListReq();
BeanUtils.copyProperties(planReq,req);
//项目阶段 状态 已定 方案待申报
req.setStage(ProjectStatusEnum.NOT_APPROVED.getCode());
req.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode());
@@ -43,7 +48,7 @@ public class ConstructionPlanController {

@ApiOperation(value = "建设方案申报", notes = "建设方案申报")
@PostMapping("/start")
public String startTheProcess(@Validated @RequestBody ConstructionPlanDTO dto) {
public String startTheProcess(@Validated @RequestBody DefaultDeclaredDTO dto) {
String instanceId = constructionPlanManage.startTheProcess(dto);
return "建设方案申报 【" + instanceId + "】 成功";
}


+ 2
- 2
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/DeclaredProjectController.java Просмотреть файл

@@ -1,8 +1,8 @@
package com.ningdatech.pmapi.projectdeclared.controller;

import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.projectdeclared.entity.dto.DeclaredProjectDTO;
import com.ningdatech.pmapi.projectdeclared.entity.dto.DeclaredProjectListParamDTO;
import com.ningdatech.pmapi.projectdeclared.entity.dto.DefaultDeclaredDTO;
import com.ningdatech.pmapi.projectdeclared.entity.dto.ProjectDraftSaveDTO;
import com.ningdatech.pmapi.projectdeclared.entity.vo.ProjectDraftVO;
import com.ningdatech.pmapi.projectdeclared.manage.DeclaredProjectManage;
@@ -59,7 +59,7 @@ public class DeclaredProjectController {

@ApiOperation(value = "申报项目", notes = "申报项目")
@PostMapping("/start")
public String startTheProcess(@Validated @RequestBody DeclaredProjectDTO dto) {
public String startTheProcess(@Validated @RequestBody DefaultDeclaredDTO dto) {
String instanceId = declaredProjectManage.startTheProcess(dto);
return "启动流程实例 【" + instanceId + "】 成功";
}


+ 8
- 3
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/PrequalificationDeclaredController.java Просмотреть файл

@@ -1,7 +1,8 @@
package com.ningdatech.pmapi.projectdeclared.controller;

import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.projectdeclared.entity.dto.PreDeclaredProjectDTO;
import com.ningdatech.pmapi.projectdeclared.entity.dto.DefaultDeclaredDTO;
import com.ningdatech.pmapi.projectdeclared.entity.req.PrequalificationDeclaredListReq;
import com.ningdatech.pmapi.projectdeclared.manage.PrequalificationDeclaredProjectManage;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage;
@@ -11,6 +12,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@@ -34,7 +36,10 @@ public class PrequalificationDeclaredController {

@ApiOperation(value = "可预审申报项目列表", notes = "可预审申报项目列表")
@GetMapping("/list")
public PageVo<ProjectLibListItemVO> list(@Validated @ModelAttribute ProjectListReq req) {
public PageVo<ProjectLibListItemVO> list(@Validated @ModelAttribute PrequalificationDeclaredListReq preReq) {
//限定参数 复制bean
ProjectListReq req = new ProjectListReq();
BeanUtils.copyProperties(preReq,req);
//项目阶段 状态 已定 待预审
req.setStage(ProjectStatusEnum.NOT_APPROVED.getCode());
req.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
@@ -43,7 +48,7 @@ public class PrequalificationDeclaredController {

@ApiOperation(value = "申报预审", notes = "申报预审")
@PostMapping("/start")
public String startTheProcess(@Validated @RequestBody PreDeclaredProjectDTO dto) {
public String startTheProcess(@Validated @RequestBody DefaultDeclaredDTO dto) {
String instanceId = prequalificationDeclaredProjectManage.startTheProcess(dto);
return "提交预审 【" + instanceId + "】 成功";
}


+ 61
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/ProjectAdjustmentController.java Просмотреть файл

@@ -0,0 +1,61 @@
package com.ningdatech.pmapi.projectdeclared.controller;

import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.projectdeclared.entity.dto.DefaultDeclaredDTO;
import com.ningdatech.pmapi.projectdeclared.entity.req.AdjustmentListReq;
import com.ningdatech.pmapi.projectdeclared.manage.ProjectAdjustmentManage;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage;
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq;
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
* @Classname ConstructionPlanController
* @Description 建设方案申报
* @Date 2023/2/13 9:53
* @Author PoffyZhang
*/
@Slf4j
@Validated
@RestController
@RequestMapping("/api/v1/project/adjustment")
@Api(value = "ProjectAdjustment", tags = "申报管理-项目内容调整")
@RequiredArgsConstructor
public class ProjectAdjustmentController {

private final ProjectAdjustmentManage projectAdjustmentManage;

private final ProjectLibManage projectLibManage;

@ApiOperation(value = "可做项目内容调整的列表", notes = "可做项目内容调整的列表")
@GetMapping("/list")
public PageVo<ProjectLibListItemVO> list(@Validated @ModelAttribute AdjustmentListReq preReq) {
//限定参数 复制bean
ProjectListReq req = new ProjectListReq();
BeanUtils.copyProperties(preReq,req);
//项目阶段 状态 已定 方案待申报
req.setStageList(Arrays.asList(ProjectStatusEnum.NOT_APPROVED.getCode()));
//只有 单位内部审核不通过 省级联审不通过 预审不通过 建设方案不通过 4种状态
req.setStatusList(Arrays.asList(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS.getCode(),
ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode(),
ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED.getCode(),
ProjectStatusEnum.SCHEME_REVIEW_FAILED.getCode()));
return projectLibManage.projectLibList(req);
}

@ApiOperation(value = "项目内容调整", notes = "项目内容调整")
@PostMapping
public String startTheProcess(@Validated @RequestBody DefaultDeclaredDTO dto) {
String instanceId = projectAdjustmentManage.adjustment(dto);
return "建设方案申报 【" + instanceId + "】 成功";
}
}

+ 0
- 45
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/entity/dto/ConstructionPlanDTO.java Просмотреть файл

@@ -1,45 +0,0 @@
package com.ningdatech.pmapi.projectdeclared.entity.dto;

import cn.hutool.core.collection.CollUtil;
import com.google.common.collect.Maps;
import com.wflow.workflow.bean.dto.ProcessInstanceUserDto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Map;

/**
* @Classname DeclaredProjectDto
* @Description 申报项目
* @Date 2023/2/1 14:52
* @Author PoffyZhang
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ConstructionPlanDTO implements Serializable {

@NotNull
private Long projectId;

//建设方案文件
private String constructionPlanFile;

private Map<String,Object> formData;

@NotNull
private ProcessInstanceUserDto user;

public Map<String,Object> getFormData(){
if(CollUtil.isEmpty(this.formData)){
this.formData = Maps.newHashMap();
return this.formData;
}
return this.formData;
}
}

pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/entity/dto/DeclaredProjectDTO.java → pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/entity/dto/DefaultDeclaredDTO.java Просмотреть файл

@@ -5,7 +5,6 @@ import com.google.common.collect.Maps;
import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO;
import com.wflow.workflow.bean.dto.ProcessInstanceUserDto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@@ -14,16 +13,15 @@ import java.io.Serializable;
import java.util.Map;

/**
* @Classname DeclaredProjectDto
* @Description 申报项目
* @Date 2023/2/1 14:52
* @Classname DefaultDeclaredDTO
* @Description
* @Date 2023/2/14 17:16
* @Author PoffyZhang
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DeclaredProjectDTO implements Serializable {
public class DefaultDeclaredDTO implements Serializable {

@NotNull
private ProjectDTO projectInfo;

+ 0
- 42
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/entity/dto/PreDeclaredProjectDTO.java Просмотреть файл

@@ -1,42 +0,0 @@
package com.ningdatech.pmapi.projectdeclared.entity.dto;

import cn.hutool.core.collection.CollUtil;
import com.google.common.collect.Maps;
import com.wflow.workflow.bean.dto.ProcessInstanceUserDto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Map;

/**
* @Classname DeclaredProjectDto
* @Description 申报项目
* @Date 2023/2/1 14:52
* @Author PoffyZhang
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PreDeclaredProjectDTO implements Serializable {

@NotNull
private Long projectId;

private Map<String,Object> formData;

@NotNull
private ProcessInstanceUserDto user;

public Map<String,Object> getFormData(){
if(CollUtil.isEmpty(this.formData)){
this.formData = Maps.newHashMap();
return this.formData;
}
return this.formData;
}
}

+ 44
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/entity/req/AdjustmentListReq.java Просмотреть файл

@@ -0,0 +1,44 @@
package com.ningdatech.pmapi.projectdeclared.entity.req;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

/**
* @Classname AdjustmentListReq
* @Description
* @Date 2023/2/14 11:42
* @Author PoffyZhang
*/
@Data
public class AdjustmentListReq {

@ApiModelProperty("项目名称")
private String projectName;

@ApiModelProperty("申报单位")
private String buildOrg;

@ApiModelProperty("项目类型")
private Integer projectType;

@ApiModelProperty("预算年度")
private Integer projectYear;

@ApiModelProperty("创建时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createOnMin;

@ApiModelProperty("创建时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createOnMax;

@ApiModelProperty("项目阶段")
private Integer stage;

@ApiModelProperty("项目状态")
private Integer status;

}

+ 38
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/entity/req/ConstrctionPlanListReq.java Просмотреть файл

@@ -0,0 +1,38 @@
package com.ningdatech.pmapi.projectdeclared.entity.req;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

/**
* @Classname PrequalificationDeclaredReq
* @Description
* @Date 2023/2/14 11:42
* @Author PoffyZhang
*/
@Data
public class ConstrctionPlanListReq {

@ApiModelProperty("项目名称")
private String projectName;

@ApiModelProperty("申报单位")
private String buildOrg;

@ApiModelProperty("项目类型")
private Integer projectType;

@ApiModelProperty("预算年度")
private Integer projectYear;

@ApiModelProperty("创建时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createOnMin;

@ApiModelProperty("创建时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createOnMax;

}

+ 38
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/entity/req/PrequalificationDeclaredListReq.java Просмотреть файл

@@ -0,0 +1,38 @@
package com.ningdatech.pmapi.projectdeclared.entity.req;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

/**
* @Classname PrequalificationDeclaredReq
* @Description
* @Date 2023/2/14 11:42
* @Author PoffyZhang
*/
@Data
public class PrequalificationDeclaredListReq {

@ApiModelProperty("项目名称")
private String projectName;

@ApiModelProperty("申报单位")
private String buildOrg;

@ApiModelProperty("项目类型")
private Integer projectType;

@ApiModelProperty("预算年度")
private Integer projectYear;

@ApiModelProperty("创建时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createOnMin;

@ApiModelProperty("创建时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createOnMax;

}

+ 23
- 7
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ConstructionPlanManage.java Просмотреть файл

@@ -6,10 +6,13 @@ 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.statemachine.util.StateMachineUtils;
import com.ningdatech.pmapi.projectdeclared.entity.dto.ConstructionPlanDTO;
import com.ningdatech.pmapi.projectdeclared.entity.dto.DefaultDeclaredDTO;
import com.ningdatech.pmapi.projectdeclared.entity.dto.ProjectConditionDTO;
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.wflow.bean.entity.WflowModels;
import com.wflow.exception.BusinessException;
@@ -18,6 +21,7 @@ import com.wflow.workflow.service.ProcessInstanceService;
import com.wflow.workflow.service.ProcessModelService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
@@ -34,7 +38,7 @@ import java.util.Objects;
@Component
@Slf4j
@RequiredArgsConstructor
public class ConstructionPlanManage {
public class ConstructionPlanManage {

private final IProjectService projectService;

@@ -44,16 +48,20 @@ public class ConstructionPlanManage {

private final StateMachineUtils stateMachineUtils;

private final IProjectInstService projectInstService;

/**
* 提交预审
*
* @param dto
* @return
*/
public String startTheProcess(ConstructionPlanDTO dto) {
Project projectInfo = projectService.getById(dto.getProjectId());

public String startTheProcess(DefaultDeclaredDTO dto) {
ProjectDTO projectDto = dto.getProjectInfo();
VUtils.isTrue(Objects.isNull(projectDto.getId())).throwMessage("提交失败 缺少项目ID!");
Project projectInfo = projectService.getById(projectDto.getId());
VUtils.isTrue(Objects.isNull(projectInfo)).throwMessage("提交失败 此项目不存在!");
VUtils.isTrue(StringUtils.isBlank(projectInfo.getConstructionPlanFile())).throwMessage("提交失败 请提交建设方案!");

String regionCode = projectInfo.getAreaCode();

@@ -71,7 +79,7 @@ public class ConstructionPlanManage {
VUtils.isTrue(!ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode().equals(projectInfo.getStatus()) ||
!ProjectStatusEnum.NOT_APPROVED.getCode().equals(projectInfo.getStage()))
.throwMessage("提交失败 该项目不是 待预审状态或者未立项阶段");
//TODO 再判断 该项目是否 真实走完 单位内部审批
// TODO 再判断 该项目是否 真实走完 预审审批

ProcessStartParamsVo params = new ProcessStartParamsVo();
params.setUser(dto.getUser());
@@ -88,7 +96,7 @@ public class ConstructionPlanManage {
log.info("建设方案项目申报成功 【{}】", instanceId);

//保存建设项目
modifyProject(projectInfo, instanceId, dto.getConstructionPlanFile());
modifyProject(projectInfo, instanceId, projectInfo.getConstructionPlanFile());

return instanceId;
}
@@ -108,6 +116,14 @@ public class ConstructionPlanManage {
//调用状态机 进入下一个通过状态
stateMachineUtils.execute(project, stateMachineUtils.getProjectStatusPassEvent(project.getStatus()));
projectService.updateById(project);

//保存项目和实例的关系
ProjectInst projectInst = new ProjectInst();
projectInst.setProjectId(project.getId());
projectInst.setInstCode(instanceId);
projectInst.setCreatOn(LocalDateTime.now());
projectInst.setUpdateOn(LocalDateTime.now());
projectInstService.save(projectInst);
} catch (Exception e) {
log.error("提交建设方案 项目信息修改 错误 ", e);
throw new BusinessException("提交建设方案 项目信息修改 错误 :" + e.getMessage());


+ 83
- 12
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java Просмотреть файл

@@ -6,20 +6,20 @@ import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ningdatech.basic.function.VUtils;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.common.enumeration.ProjectProcessStageEnum;
import com.ningdatech.pmapi.projectdeclared.entity.ProjectDraft;
import com.ningdatech.pmapi.projectdeclared.entity.dto.DeclaredProjectDTO;
import com.ningdatech.pmapi.projectdeclared.entity.dto.DeclaredProjectListParamDTO;
import com.ningdatech.pmapi.projectdeclared.entity.dto.ProjectConditionDTO;
import com.ningdatech.pmapi.projectdeclared.entity.dto.ProjectDraftSaveDTO;
import com.ningdatech.pmapi.projectdeclared.entity.dto.*;
import com.ningdatech.pmapi.projectdeclared.entity.vo.ProjectDraftVO;
import com.ningdatech.pmapi.projectdeclared.service.IProjectDraftService;
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.ProjectApplication;
import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst;
import com.ningdatech.pmapi.projectlib.service.IProjectApplicationService;
import com.ningdatech.pmapi.projectlib.service.IProjectInstService;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import com.wflow.bean.entity.WflowModels;
import com.wflow.exception.BusinessException;
@@ -60,6 +60,8 @@ public class DeclaredProjectManage {

private final ProcessModelService processModelService;

private final IProjectInstService projectInstService;

public PageVo<ProjectDraftVO> pageDraft(DeclaredProjectListParamDTO params) {
Page<ProjectDraft> page = params.page();
LambdaQueryWrapper<ProjectDraft> wrapper = Wrappers.lambdaQuery(ProjectDraft.class)
@@ -98,12 +100,12 @@ public class DeclaredProjectManage {
}

/**
* 启动实例
* 新项目 启动实例
*
* @param dto
* @return
*/
public String startTheProcess(DeclaredProjectDTO dto) {
public String startTheProcess(DefaultDeclaredDTO dto) {
ProjectDTO projectInfo = dto.getProjectInfo();
String regionCode = projectInfo.getAreaCode();

@@ -123,12 +125,10 @@ public class DeclaredProjectManage {
//放入条件判断的项目字段
ProjectConditionDTO conditionDto = new ProjectConditionDTO();
BeanUtils.copyProperties(dto.getProjectInfo(), conditionDto);
if (Objects.nonNull(conditionDto)) {
dto.getFormData().putAll(
JSON.parseObject(JSON.toJSONString(conditionDto), new TypeReference<Map<String, Object>>() {
})
);
}
dto.getFormData().putAll(
JSON.parseObject(JSON.toJSONString(conditionDto), new TypeReference<Map<String, Object>>() {
})
);
params.setFormData(dto.getFormData());
String instanceId = processService.startProcess(model.getProcessDefId(), params);
log.info("申报项目成功 【{}】", instanceId);
@@ -140,6 +140,70 @@ public class DeclaredProjectManage {
}

/**
* 重新提交 启动实例
*
* @param dto
* @return
*/
public String reStartTheProcess(DefaultDeclaredDTO dto) {
ProjectDTO projectDto = dto.getProjectInfo();
VUtils.isTrue(Objects.isNull(projectDto.getId())).throwMessage("提交失败 缺少项目ID!");
Project projectInfo = projectService.getById(projectDto.getId());
VUtils.isTrue(Objects.isNull(projectInfo)).throwMessage("提交失败 此项目不存在!");

String regionCode = projectInfo.getAreaCode();
WflowModels model = processModelService.getOne(Wrappers.lambdaQuery(WflowModels.class)
.eq(WflowModels::getRegionCode, regionCode)
.eq(WflowModels::getProcessType, ProjectProcessStageEnum.ORG_INTERNAL_APPROVAL_PROCESS.getCode())
.last("limit 1"));

if (Objects.isNull(model)) {
log.error("此 【{}】区域找不到单位流程配置", regionCode);
throw new BusinessException(String.format("此 【%s】区域找不到单位流程配置", regionCode));
}

ProcessStartParamsVo params = new ProcessStartParamsVo();
params.setUser(dto.getUser());
params.setProcessUsers(Collections.emptyMap());
//放入条件判断的项目字段
ProjectConditionDTO conditionDto = new ProjectConditionDTO();
BeanUtils.copyProperties(dto.getProjectInfo(), conditionDto);
dto.getFormData().putAll(
JSON.parseObject(JSON.toJSONString(conditionDto), new TypeReference<Map<String, Object>>() {
})
);
params.setFormData(dto.getFormData());
String instanceId = processService.startProcess(model.getProcessDefId(), params);
log.info("重新申报项目成功 【{}】", instanceId);

//保存项目
modifyProject(projectInfo, instanceId);

return instanceId;
}

private void modifyProject(Project project, String instanceId) {
//流程启动之后 入库项目 重要业务信息 用于列表查询 展示
try {
project.setUpdateOn(LocalDateTime.now());
project.setInstCode(instanceId);
project.setStage(ProjectStatusEnum.NOT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
projectService.updateById(project);
//保存项目和实例的关系
ProjectInst projectInst = new ProjectInst();
projectInst.setProjectId(project.getId());
projectInst.setInstCode(instanceId);
projectInst.setCreatOn(LocalDateTime.now());
projectInst.setUpdateOn(LocalDateTime.now());
projectInstService.save(projectInst);
} catch (Exception e) {
log.error("重新申报项目 项目信息修改 错误 ", e);
throw new BusinessException("重新申报项目 项目信息修改 错误 :" + e.getMessage());
}
}

/**
* 申报项目 时 新增项目到项目库
*
* @param projectDto
@@ -168,6 +232,13 @@ public class DeclaredProjectManage {
}).collect(Collectors.toList());
projectApplicationService.saveBatch(applications);
}
//保存项目和实例的关系
ProjectInst projectInst = new ProjectInst();
projectInst.setProjectId(project.getId());
projectInst.setInstCode(instanceId);
projectInst.setCreatOn(LocalDateTime.now());
projectInst.setUpdateOn(LocalDateTime.now());
projectInstService.save(projectInst);
} catch (Exception e) {
log.error("项目信息入库错误 ", e);
throw new BusinessException("项目信息入库错误 :" + e.getMessage());


+ 49
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java Просмотреть файл

@@ -0,0 +1,49 @@
package com.ningdatech.pmapi.projectdeclared.manage;

import com.google.common.collect.Maps;
import com.ningdatech.pmapi.projectdeclared.entity.dto.DefaultDeclaredDTO;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.Map;
import java.util.function.Function;

/**
* @Classname DefaultDeclaredProjectManage
*
* @Description
* @Date 2023/2/14 17:12
* @Author PoffyZhang
*/
@Component
@Slf4j
@RequiredArgsConstructor
public class DefaultDeclaredProjectManage {

private final DeclaredProjectManage declaredProjectManage;

private final ConstructionPlanManage constructionPlanManage;

private final PrequalificationDeclaredProjectManage prequalificationDeclaredProjectManage;
public Map<Integer, Function<DefaultDeclaredDTO,String>> startProcessMap = Maps.newHashMap();

/**
* 初始化业务分派逻辑,代替了if-else部分
* key: 枚举 状态值
* value: lambda表达式,最终会获取发起实例的函数
*/
@PostConstruct
public void startProcessInit(){
startProcessMap.put(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS.getCode(),
dto->declaredProjectManage.reStartTheProcess(dto));
startProcessMap.put(ProjectStatusEnum.SCHEME_REVIEW_FAILED.getCode(),
dto->constructionPlanManage.startTheProcess(dto));
startProcessMap.put(ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode(),
dto->prequalificationDeclaredProjectManage.startTheProcess(dto));
startProcessMap.put(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED.getCode(),
dto->null);
}

}

+ 52
- 17
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PrequalificationDeclaredProjectManage.java Просмотреть файл

@@ -6,10 +6,14 @@ 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.statemachine.util.StateMachineUtils;
import com.ningdatech.pmapi.projectdeclared.entity.dto.PreDeclaredProjectDTO;
import com.ningdatech.pmapi.projectdeclared.contants.DeclaredProjectContant;
import com.ningdatech.pmapi.projectdeclared.entity.dto.DefaultDeclaredDTO;
import com.ningdatech.pmapi.projectdeclared.entity.dto.ProjectConditionDTO;
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.wflow.bean.entity.WflowModels;
import com.wflow.exception.BusinessException;
@@ -45,15 +49,18 @@ public class PrequalificationDeclaredProjectManage {

private final ProcessModelService processModelService;

private final IProjectInstService projectInstService;

/**
* 提交预审
*
* @param dto
* @return
*/
public String startTheProcess(PreDeclaredProjectDTO dto) {
Project projectInfo = projectService.getById(dto.getProjectId());

public String startTheProcess(DefaultDeclaredDTO dto) {
ProjectDTO projectDto = dto.getProjectInfo();
VUtils.isTrue(Objects.isNull(projectDto.getId())).throwMessage("提交失败 缺少项目ID!");
Project projectInfo = projectService.getById(projectDto.getId());
VUtils.isTrue(Objects.isNull(projectInfo)).throwMessage("提交失败 此项目不存在!");

String regionCode = projectInfo.getAreaCode();
@@ -74,24 +81,44 @@ public class PrequalificationDeclaredProjectManage {
.throwMessage("提交失败 该项目不是 待预审状态或者未立项阶段");
//TODO 再判断 该项目是否 真实走完 单位内部审批

ProcessStartParamsVo params = new ProcessStartParamsVo();
params.setUser(dto.getUser());
params.setProcessUsers(Collections.emptyMap());
//放入条件判断的项目字段
ProjectConditionDTO conditionDto = new ProjectConditionDTO();
BeanUtils.copyProperties(projectInfo, conditionDto);
if (Objects.nonNull(conditionDto)) {
//使用状态机 进入下一步 看看需不需要走省级审批
try {
stateMachineUtils.execute(projectInfo,stateMachineUtils.getProjectStatusPassEvent(projectInfo.getStatus()));
} catch (Exception e) {
log.error("项目 调用状态机出错:",e);
throw new BusinessException(projectInfo.getId() + "项目 调用状态机出错 :" + e.getMessage());
}

String instanceId = null;
//如果是省级部门 需要联审的(申报金额大于1000万 并且是市级项目)
if(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS
.getCode().equals(projectInfo.getStatus())){
//TODO 对接外部 省级
instanceId = DeclaredProjectContant.Instance.PROVINCE_INSTANCE_ID;
}else if(ProjectStatusEnum.PRE_APPLYING
.getCode().equals(projectInfo.getStatus())){
//如果是非省级联审的项目 直接提交 预审
ProcessStartParamsVo params = new ProcessStartParamsVo();
params.setUser(dto.getUser());
params.setProcessUsers(Collections.emptyMap());
//放入条件判断的项目字段
ProjectConditionDTO conditionDto = new ProjectConditionDTO();
BeanUtils.copyProperties(projectInfo, conditionDto);
dto.getFormData().putAll(
JSON.parseObject(JSON.toJSONString(conditionDto), new TypeReference<Map<String, Object>>() {
})
);
params.setFormData(dto.getFormData());
instanceId = processService.startProcess(model.getProcessDefId(), params);
log.info("提交预审项目成功 【{}】", instanceId);

//保存预审项目
if(Objects.nonNull(instanceId)){
modifyProject(projectInfo, instanceId);
}
}else{
throw new BusinessException("项目状态 错误 project :" + JSON.toJSONString(projectInfo));
}
params.setFormData(dto.getFormData());
String instanceId = processService.startProcess(model.getProcessDefId(), params);
log.info("提交预审项目成功 【{}】", instanceId);

//保存预审项目
modifyProject(projectInfo, instanceId);

return instanceId;
}
@@ -110,6 +137,14 @@ public class PrequalificationDeclaredProjectManage {
//调用状态机 进入下一个通过状态
stateMachineUtils.execute(project, stateMachineUtils.getProjectStatusPassEvent(project.getStatus()));
projectService.updateById(project);

//保存项目和实例的关系
ProjectInst projectInst = new ProjectInst();
projectInst.setProjectId(project.getId());
projectInst.setInstCode(instanceId);
projectInst.setCreatOn(LocalDateTime.now());
projectInst.setUpdateOn(LocalDateTime.now());
projectInstService.save(projectInst);
} catch (Exception e) {
log.error("提交预审 项目信息修改 错误 ", e);
throw new BusinessException("提交预审 项目信息修改 错误 :" + e.getMessage());


+ 79
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ProjectAdjustmentManage.java Просмотреть файл

@@ -0,0 +1,79 @@
package com.ningdatech.pmapi.projectdeclared.manage;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.basic.function.VUtils;
import com.ningdatech.pmapi.projectdeclared.entity.dto.DefaultDeclaredDTO;
import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.model.entity.ProjectApplication;
import com.ningdatech.pmapi.projectlib.service.IProjectApplicationService;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import com.wflow.exception.BusinessException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
* @Classname ProjectAdjustmentManage
* @Description 项目内容调整
* @Date 2023/2/1 14:48
* @Author PoffyZhang
*/
@Component
@Slf4j
@RequiredArgsConstructor
public class ProjectAdjustmentManage {

private final IProjectService projectService;

private final IProjectApplicationService projectApplicationService;

private final DefaultDeclaredProjectManage defaultDeclaredProjectManage;

/**
* 项目内容调整
* @param dto
* @return
*/
public String adjustment(DefaultDeclaredDTO dto) {
ProjectDTO projectDto = dto.getProjectInfo();
Project projectInfo = projectService.getById(projectDto.getId());

VUtils.isTrue(Objects.isNull(projectInfo)).throwMessage("调整失败 此项目不存在!");

//先修改项目信息
Project project = new Project();
BeanUtils.copyProperties(projectDto,project);
project.setUpdateOn(LocalDateTime.now());
if(!projectService.updateById(project)){
throw new BusinessException("项目调整失败");
}
//再修改应用信息
if(CollUtil.isNotEmpty(projectDto.getApplicationList())){
//采取批量删除 批量添加的方式
projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class)
.eq(ProjectApplication::getProjectId,project.getId()));
//批量添加
List<ProjectApplication> applications = projectDto.getApplicationList().stream().map(application -> {
ProjectApplication projectApplication = new ProjectApplication();
BeanUtils.copyProperties(application, projectApplication);
projectApplication.setProjectId(project.getId());
return projectApplication;
}).collect(Collectors.toList());
projectApplicationService.saveBatch(applications);
}

//最后去重新 提交项目流程 不同的状态 提交到不同的工作流去
Function<DefaultDeclaredDTO, String> declaredFunction =
defaultDeclaredProjectManage.startProcessMap.get(project.getStatus());
VUtils.isTrue(Objects.isNull(declaredFunction)).throwMessage("状态不正常 没有找到对应申报函数!");
return declaredFunction.apply(dto);
}
}

+ 22
- 18
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/helper/ProjectHelper.java Просмотреть файл

@@ -1,5 +1,6 @@
package com.ningdatech.pmapi.projectlib.helper;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq;
@@ -22,25 +23,28 @@ public class ProjectHelper {
**/
public static LambdaQueryWrapper<Project> projectQuery(ProjectListReq req) {
LambdaQueryWrapper<Project> query = new LambdaQueryWrapper<>();
query.eq(req.getRegionCode() != null, Project::getAreaCode, req.getRegionCode());
query.eq(req.getUserId() != null, Project::getCreateBy, req.getUserId());
query.like(req.getProjectName() != null, Project::getProjectName, req.getProjectName());
query.eq(req.getProjectType() != null, Project::getProjectType, req.getProjectType());
query.eq(req.getProjectYear() != null, Project::getProjectYear, req.getProjectYear());
query.eq(req.getStage() != null, Project::getStage, req.getStage());
query.eq(req.getStatus() != null, Project::getStatus, req.getStatus());
// 申报金额
query.ge(req.getDeclareAmountMin() != null, Project::getDeclareAmount, req.getDeclareAmountMin());
query.le(req.getDeclareAmountMax() != null, Project::getDeclareAmount, req.getDeclareAmountMax());
// 申报时间
query.ge(req.getCreateOnMin() != null, Project::getCreateOn, req.getCreateOnMin());
query.le(req.getCreateOnMax() != null, Project::getCreateOn, req.getCreateOnMax());
// 批复金额
query.ge(req.getApproveAmountMin() != null, Project::getApprovalAmount, req.getApproveAmountMin());
query.le(req.getApproveAmountMax() != null, Project::getApprovalAmount, req.getApproveAmountMax());
query.eq(req.getRegionCode() != null, Project::getAreaCode, req.getRegionCode())
.eq(req.getUserId() != null, Project::getCreateBy, req.getUserId())
.like(req.getProjectName() != null, Project::getProjectName, req.getProjectName())
.eq(req.getProjectType() != null, Project::getProjectType, req.getProjectType())
.eq(req.getProjectYear() != null, Project::getProjectYear, req.getProjectYear())
.eq(req.getStage() != null, Project::getStage, req.getStage())
.eq(req.getStatus() != null, Project::getStatus, req.getStatus())
// 申报金额
.ge(req.getDeclareAmountMin() != null, Project::getDeclareAmount, req.getDeclareAmountMin())
.le(req.getDeclareAmountMax() != null, Project::getDeclareAmount, req.getDeclareAmountMax())
// 申报时间
.ge(req.getCreateOnMin() != null, Project::getCreateOn, req.getCreateOnMin())
.le(req.getCreateOnMax() != null, Project::getCreateOn, req.getCreateOnMax())
// 批复金额
.ge(req.getApproveAmountMin() != null, Project::getApprovalAmount, req.getApproveAmountMin())
.le(req.getApproveAmountMax() != null, Project::getApprovalAmount, req.getApproveAmountMax())

query.like(req.getBuildOrg() != null, Project::getBuildOrgName, req.getBuildOrg());
query.eq(req.getIsTemporaryAugment() != null, Project::getIsTemporaryAugment, req.getIsTemporaryAugment());
.like(req.getBuildOrg() != null, Project::getBuildOrgName, req.getBuildOrg())
.eq(req.getIsTemporaryAugment() != null, Project::getIsTemporaryAugment, req.getIsTemporaryAugment())
//状态 阶段 list
.in(CollUtil.isNotEmpty(req.getStageList()),Project::getStage,req.getStageList())
.in(CollUtil.isNotEmpty(req.getStatusList()),Project::getStatus,req.getStatusList());
return query;
}



+ 11
- 47
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectInst.java Просмотреть файл

@@ -1,9 +1,13 @@
package com.ningdatech.pmapi.projectlib.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
* <p>
@@ -14,65 +18,25 @@ import io.swagger.annotations.ApiModel;
* @since 2023-02-13
*/
@TableName("nd_project_inst")
@Data
@ApiModel(value = "NdProjectInst对象", description = "")
public class ProjectInst implements Serializable {

private static final long serialVersionUID = 1L;

@ApiModelProperty("主键")
@TableId(type = IdType.AUTO)
private Long id;

@ApiModelProperty("项目ID")
private Long projectId;

@ApiModelProperty("实例ID")
private String instCode;

@ApiModelProperty("创建时间")
private LocalDateTime creatOn;

@ApiModelProperty("修改时间")
private LocalDateTime updateOn;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}
public Long getProjectId() {
return projectId;
}

public void setProjectId(Long projectId) {
this.projectId = projectId;
}
public String getInstCode() {
return instCode;
}

public void setInstCode(String instCode) {
this.instCode = instCode;
}
public LocalDateTime getCreatOn() {
return creatOn;
}

public void setCreatOn(LocalDateTime creatOn) {
this.creatOn = creatOn;
}
public LocalDateTime getUpdateOn() {
return updateOn;
}

public void setUpdateOn(LocalDateTime updateOn) {
this.updateOn = updateOn;
}

@Override
public String toString() {
return "NdProjectInst{" +
"id=" + id +
", projectId=" + projectId +
", instCode=" + instCode +
", creatOn=" + creatOn +
", updateOn=" + updateOn +
"}";
}
}

+ 6
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/req/ProjectListReq.java Просмотреть файл

@@ -9,6 +9,7 @@ import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
* <p>
@@ -70,4 +71,9 @@ public class ProjectListReq extends PagePo {
@ApiModelProperty("是否临时增补 0:否 1:是")
private Integer isTemporaryAugment;

@ApiModelProperty("项目阶段 多个")
private List<Integer> stageList;

@ApiModelProperty("项目状态 多个")
private List<Integer> statusList;
}

Загрузка…
Отмена
Сохранить