Browse Source

提交项目 优化

master
PoffyZhang 1 year ago
parent
commit
bed4d5c0ac
4 changed files with 82 additions and 9 deletions
  1. +10
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/entity/dto/DeclaredProjectDto.java
  2. +35
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/entity/dto/ProjectConditionDto.java
  3. +36
    -8
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java
  4. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectApplication.java

+ 10
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/entity/dto/DeclaredProjectDto.java View File

@@ -1,5 +1,7 @@
package com.ningdatech.pmapi.projectdeclared.entity.dto;

import cn.hutool.core.collection.CollUtil;
import com.google.common.collect.Maps;
import com.ningdatech.pmapi.projectlib.model.dto.ProjectDto;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.wflow.workflow.bean.dto.ProcessInstanceUserDto;
@@ -35,4 +37,12 @@ public class DeclaredProjectDto implements Serializable {

@NotNull
private ProcessInstanceUserDto user;

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

+ 35
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/entity/dto/ProjectConditionDto.java View File

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

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;

/**
* @Classname DeclaredProjectDto
* @Description 申报项目 里的条件判断实体
* @Date 2023/2/1 14:52
* @Author PoffyZhang
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ProjectConditionDto implements Serializable {

private Long projectId;

@ApiModelProperty("申报金额")
private BigDecimal declareAmount;

@ApiModelProperty("是否临时增补 0:否 1:是")
private Integer isTemporaryAugment;

@ApiModelProperty("是否数字化改革项目 0:否 1:是")
private Integer isDigitalReform;


}

+ 36
- 8
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java View File

@@ -1,5 +1,6 @@
package com.ningdatech.pmapi.projectdeclared.manage;

import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -10,12 +11,14 @@ import com.ningdatech.pmapi.common.enums.ProjectProessStageEnum;
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.vo.ProjectDeclaredDetailVO;
import com.ningdatech.pmapi.projectdeclared.entity.vo.ProjectDeclaredListItemVO;
import com.ningdatech.pmapi.projectdeclared.entity.vo.ProjectDraftVo;
import com.ningdatech.pmapi.projectdeclared.service.IProjectDraftService;
import com.ningdatech.pmapi.projectlib.enums.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.service.IProjectApplicationService;
@@ -144,17 +147,34 @@ public class DeclaredProjectManage {
params.setUser(dto.getUser());
params.setProcessUsers(Collections.emptyMap());
//放入条件判断的项目字段
dto.getFormData().putAll(
JSON.parseObject(JSON.toJSONString(dto.getProjectInfo()), new TypeReference<Map<String, Object>>() {
}));
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>>() {})
);
}
params.setFormData(dto.getFormData());
String instanceId = processService.startProcess(model.getProcessDefId(), params);
String instanceId = processService.startProcess(model.getProcessDefId(), params);
log.info("申报项目成功 【{}】",instanceId);

//保存项目
saveProject(dto.getProjectInfo(),instanceId,regionCode);

return instanceId;
}

/**
* 申报项目 时 新增项目到项目库
* @param projectDto
* @param instanceId
*/
private void saveProject(ProjectDto projectDto,String instanceId,String regionCode) {
//流程启动之后 入库项目 重要业务信息 用于列表查询 展示
try{
//保存项目表信息
Project project = new Project();
BeanUtils.copyProperties(dto.getProjectInfo(),project);
BeanUtils.copyProperties(projectDto,project);
project.setCreateOn(LocalDateTime.now());
project.setUpdateOn(LocalDateTime.now());
project.setAreaCode(regionCode);
@@ -162,12 +182,20 @@ public class DeclaredProjectManage {
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
project.setInstCode(instanceId);
projectService.save(project);
//保存项目应用
if(CollUtil.isNotEmpty(projectDto.getApplicationList())){
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);
}
}catch (Exception e){
log.error("项目信息入库错误 ",e);
throw new BusinessException("项目信息入库错误 请注意格式");
throw new BusinessException("项目信息入库错误 :" + e.getMessage());
}

return instanceId;
}

/**


+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectApplication.java View File

@@ -29,7 +29,7 @@ public class ProjectApplication implements Serializable {
private Long id;

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

@ApiModelProperty("是否初次建设 0否 1是")
private Integer isFirst;


Loading…
Cancel
Save