diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/contants/DeclaredProjectContant.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/contants/DeclaredProjectContant.java index 0662efb..2a3fe25 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/contants/DeclaredProjectContant.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/contants/DeclaredProjectContant.java @@ -26,8 +26,11 @@ public interface DeclaredProjectContant { public static final Integer YEAR_THREE = 2; public static final Integer YEAR_FOUR = 4; + public static final Integer YEAR_DRAW_SURPLUS = 100; + public static final String FIXED_NUMBER = "0130"; - public static final Long PROJECT_ID = 999L; + public static final Long MAX_PROJECT_ID = 999L; + public static final Long MIN_PROJECT_ID = 1L; } } 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 570d09c..814468b 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 @@ -129,13 +129,8 @@ public class ConstructionPlanManage { params.setUser(declaredProjectManage.buildUser(employeeCode)); params.setProcessUsers(Collections.emptyMap()); //放入条件判断的项目字段 - ProjectConditionDTO conditionDto = new ProjectConditionDTO(); - BeanUtils.copyProperties(projectInfo, conditionDto); - dto.getFormData().putAll( - JSON.parseObject(JSON.toJSONString(conditionDto), new TypeReference>() { - }) - ); - params.setFormData(dto.getFormData()); + //把条件值给放入工作流 + defaultDeclaredProjectManage.buildCondition(params,dto); // 获取发起单位、发起单位主管单位、发起单位上级条线主管单位信息 Map orgModelMap = defaultDeclaredProjectManage.buildOrgModelMap(employeeCode,projectInfo); String instanceId = processService.newStartProcess(model.getProcessDefId(),model.getFormId(), params,orgModelMap); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java index e32c21e..c1517b9 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java @@ -228,14 +228,10 @@ public class DeclaredProjectManage { ProcessStartParamsVo params = new ProcessStartParamsVo(); params.setUser(defaultDeclaredProjectManage.buildUser(employeeCode)); params.setProcessUsers(Collections.emptyMap()); - //放入条件判断的项目字段 - ProjectConditionDTO conditionDto = new ProjectConditionDTO(); - BeanUtils.copyProperties(dto.getProjectInfo(), conditionDto); - dto.getFormData().putAll( - JSON.parseObject(JSON.toJSONString(conditionDto), new TypeReference>() { - }) - ); - params.setFormData(dto.getFormData()); + + //把条件值给放入工作流 + defaultDeclaredProjectManage.buildCondition(params,dto); + // 获取发起单位、发起单位主管单位、发起单位上级主管条线单位信息 Project project = new Project(); BeanUtils.copyProperties(projectInfo,project); 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 fbfe8dd..b1cf79d 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,10 +1,14 @@ package com.ningdatech.pmapi.projectdeclared.manage; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ningdatech.basic.function.VUtils; import com.ningdatech.pmapi.common.helper.UserInfoHelper; import com.ningdatech.pmapi.organization.model.entity.DingOrganization; import com.ningdatech.pmapi.organization.service.IDingOrganizationService; +import com.ningdatech.pmapi.projectdeclared.model.dto.DefaultDeclaredDTO; +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.model.dto.ProjectDTO; @@ -18,8 +22,10 @@ import com.wflow.enums.ProcessDefTypeEnum; 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 lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Component; import java.math.BigDecimal; import java.util.*; @@ -174,4 +180,33 @@ public class DefaultDeclaredProjectManage { //查此人建设单位的项目 return statisticsService.getRegionStatistics(user.getRegionCode(),year); } + + /** + * 把条件值放入工作流 用于判断条件 根据dto + * @param params + * @param dto + */ + public void buildCondition(ProcessStartParamsVo params, DefaultDeclaredDTO dto) { + //放入条件判断的项目字段 + ProjectConditionDTO conditionDto = new ProjectConditionDTO(); + BeanUtils.copyProperties(dto.getProjectInfo(), conditionDto); + dto.getFormData().putAll( + JSON.parseObject(JSON.toJSONString(conditionDto), new TypeReference>() { + }) + ); + params.setFormData(dto.getFormData()); + } + + /** + * 把条件值放入工作流 用于判断条件 根据d项目实体 + * @param params + * @param projectInfo + */ + public void buildCondition(ProcessStartParamsVo params, Project projectInfo) { + //放入条件判断的项目字段 + ProjectConditionDTO conditionDto = new ProjectConditionDTO(); + BeanUtils.copyProperties(projectInfo, conditionDto); + params.setFormData(JSON.parseObject(JSON.toJSONString(conditionDto), new TypeReference>() { + })); + } } 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 f8a3e9e..1457c1c 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 @@ -168,11 +168,9 @@ public class PrequalificationDeclaredProjectManage { 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>() { - })); + + //把条件值给放入工作流 + defaultDeclaredProjectManage.buildCondition(params,projectInfo); String regionCode = projectInfo.getAreaCode(); 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 4d6ae72..a1bf20f 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 @@ -90,13 +90,8 @@ public class ReviewByDeptJointManage { Map formData = Maps.newHashMap(); //放入条件判断的项目字段 - ProjectConditionDTO conditionDto = new ProjectConditionDTO(); - BeanUtils.copyProperties(projectInfo, conditionDto); - formData.putAll( - JSON.parseObject(JSON.toJSONString(conditionDto), new TypeReference>() { - }) - ); - params.setFormData(formData); + //把条件值给放入工作流 + defaultDeclaredProjectManage.buildCondition(params,projectInfo); // 获取发起单位、发起单位主管单位、发起单位上级主管条线单位信息 Map orgModelMap = defaultDeclaredProjectManage.buildOrgModelMap(startUserCode,project); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java index a5212c0..05854c3 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java @@ -1,5 +1,6 @@ package com.ningdatech.pmapi.projectdeclared.utils; +import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ningdatech.basic.exception.BizException; import com.ningdatech.basic.util.StrPool; @@ -34,9 +35,7 @@ public class GenerateProjectCodeUtil { // 获取所属行政区划代码(6位) String areaCode = projectInfo.getAreaCode(); // 获取建设年度后两位 - Integer projectYear = projectInfo.getProjectYear(); - String year = String.valueOf(projectYear) - .substring(DeclaredProjectContant.Project.YEAR_THREE, DeclaredProjectContant.Project.YEAR_FOUR); + String year = String.valueOf(projectInfo.getProjectYear() % DeclaredProjectContant.Project.YEAR_DRAW_SURPLUS); // 9-12位固定 String fixedNumber = DeclaredProjectContant.Project.FIXED_NUMBER; // 获取公司的财政编码 @@ -52,11 +51,11 @@ public class GenerateProjectCodeUtil { String projectIdStr; // 获取项目库当前最大项目序号 List projectList = projectService.list(Wrappers.lambdaQuery(Project.class).orderByDesc(Project::getId)); - Project project = projectList.get(0); - Long projectId = project.getId(); - if (projectId > DeclaredProjectContant.Project.PROJECT_ID){ + Project project = CollUtil.isEmpty(projectList) ? null : projectList.get(0); + Long projectId = Objects.isNull(project) ? DeclaredProjectContant.Project.MIN_PROJECT_ID : project.getId(); + if (projectId > DeclaredProjectContant.Project.MAX_PROJECT_ID){ // 超过999的项目号从1开始 1 - Long newProjectId = projectId - DeclaredProjectContant.Project.PROJECT_ID; + Long newProjectId = projectId % DeclaredProjectContant.Project.MAX_PROJECT_ID; projectIdStr = String.format(StrPool.FORMAT_NUMBER_THREE, newProjectId); }else { projectIdStr = String.format(StrPool.FORMAT_NUMBER_THREE, projectId);