@@ -2,6 +2,7 @@ package com.ningdatech.pmapi.common.statemachine.util; | |||
import com.ningdatech.basic.exception.BizException; | |||
import com.ningdatech.pmapi.common.constant.ProjectDeclareConst; | |||
import com.ningdatech.pmapi.common.constant.RegionConst; | |||
import com.ningdatech.pmapi.common.constant.StateMachineConst; | |||
import com.ningdatech.pmapi.common.statemachine.builder.ProjectDeclareStateMachineBuilder; | |||
import com.ningdatech.pmapi.common.statemachine.event.ProjectStatusChangeEvent; | |||
@@ -118,7 +119,7 @@ public class StateMachineUtils { | |||
*/ | |||
public static boolean isCityProject(Project project) { | |||
String areaCode = project.getAreaCode(); | |||
if (areaCode.equals(StateMachineConst.LI_SHUI_CITY_AREA_CODE)) { | |||
if (areaCode.equals(RegionConst.RC_LS)) { | |||
return true; | |||
} | |||
return false; | |||
@@ -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; | |||
} | |||
} |
@@ -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<Map<String, Object>>() { | |||
}) | |||
); | |||
params.setFormData(dto.getFormData()); | |||
//把条件值给放入工作流 | |||
defaultDeclaredProjectManage.buildCondition(params,dto); | |||
// 获取发起单位、发起单位主管单位、发起单位上级条线主管单位信息 | |||
Map<String, OrgInfoDTO> orgModelMap = defaultDeclaredProjectManage.buildOrgModelMap(employeeCode,projectInfo); | |||
String instanceId = processService.newStartProcess(model.getProcessDefId(),model.getFormId(), params,orgModelMap); | |||
@@ -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<Map<String, Object>>() { | |||
}) | |||
); | |||
params.setFormData(dto.getFormData()); | |||
//把条件值给放入工作流 | |||
defaultDeclaredProjectManage.buildCondition(params,dto); | |||
// 获取发起单位、发起单位主管单位、发起单位上级主管条线单位信息 | |||
Project project = new Project(); | |||
BeanUtils.copyProperties(projectInfo,project); | |||
@@ -272,10 +268,12 @@ public class DeclaredProjectManage { | |||
project.setProjectCode(projectCode); | |||
projectService.saveOrUpdate(project); | |||
//保存项目应用 | |||
if (CollUtil.isNotEmpty(projectDto.getApplicationList())) { | |||
//采取批量删除 批量添加的方式 | |||
projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class) | |||
.eq(ProjectApplication::getProjectId,project.getId())); | |||
Boolean isApp = Objects.nonNull(projectDto.getIncludeApplication()) && 1 == projectDto.getIncludeApplication() | |||
? Boolean.TRUE : Boolean.FALSE; | |||
//采取批量删除 批量添加的方式 | |||
projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class) | |||
.eq(ProjectApplication::getProjectId,project.getId())); | |||
if (isApp && CollUtil.isNotEmpty(projectDto.getApplicationList())) { | |||
List<ProjectApplication> applications = projectDto.getApplicationList().stream().map(application -> { | |||
ProjectApplication projectApplication = new ProjectApplication(); | |||
BeanUtils.copyProperties(application, projectApplication); | |||
@@ -2,45 +2,32 @@ package com.ningdatech.pmapi.projectdeclared.manage; | |||
import com.alibaba.fastjson.JSON; | |||
import com.alibaba.fastjson.TypeReference; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
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.helper.UserInfoHelper; | |||
import com.ningdatech.pmapi.datascope.model.DataScopeDTO; | |||
import com.ningdatech.pmapi.datascope.utils.DataScopeUtil; | |||
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.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.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; | |||
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; | |||
import com.ningdatech.pmapi.user.util.LoginUserUtil; | |||
import com.wflow.bean.entity.WflowModels; | |||
import com.wflow.bean.entity.WflowOrgModels; | |||
import com.wflow.enums.OrgTypeEnum; | |||
import com.wflow.enums.ProcessDefTypeEnum; | |||
import com.wflow.exception.BusinessException; | |||
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 com.wflow.workflow.service.ProcessInstanceService; | |||
import com.wflow.workflow.service.ProcessModelService; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.BeanUtils; | |||
import org.springframework.stereotype.Component; | |||
import java.math.BigDecimal; | |||
import java.time.LocalDateTime; | |||
import java.util.*; | |||
import java.util.stream.Collectors; | |||
@@ -63,12 +50,6 @@ public class DefaultDeclaredProjectManage { | |||
private final IDingOrganizationService dingOrganizationService; | |||
private final OrgProcdefService orgProcdefService; | |||
private final ProcessModelService processModelService; | |||
private final ProcessInstanceService processService; | |||
private final IProjectInstService projectInstService; | |||
private final IDeclaredStatisticsService statisticsService; | |||
//项目名称去重 | |||
@@ -186,70 +167,6 @@ public class DefaultDeclaredProjectManage { | |||
return orgMap; | |||
} | |||
//直接提交预审方法 提取 在省级联审通过的时候 也可以用 | |||
public String directStartProcess(Project projectInfo,String employeeCode){ | |||
VUtils.isTrue(Objects.isNull(employeeCode)) | |||
.throwMessage("发起人 员工code 不能为空!"); | |||
ProcessStartParamsVo params = new ProcessStartParamsVo(); | |||
params.setUser(buildUser(employeeCode)); | |||
params.setProcessUsers(Collections.emptyMap()); | |||
//放入条件判断的项目字段 | |||
ProjectConditionDTO conditionDto = new ProjectConditionDTO(); | |||
BeanUtils.copyProperties(projectInfo, conditionDto); | |||
params.setFormData(JSON.parseObject(JSON.toJSONString(conditionDto), new TypeReference<Map<String, Object>>() { | |||
})); | |||
String regionCode = projectInfo.getAreaCode(); | |||
WflowModels model = processModelService.getOne(Wrappers.lambdaQuery(WflowModels.class) | |||
.eq(WflowModels::getRegionCode, regionCode) | |||
.eq(WflowModels::getProcessType, ProjectProcessStageEnum.PROJECT_PREQUALIFICATION_APPROVAL_PROCESS.getCode()) | |||
.last("limit 1")); | |||
if (Objects.isNull(model)) { | |||
log.error("此 【{}】区域找不到 预审流程配置", regionCode); | |||
throw new BusinessException(String.format("此 【%s】区域找不到 预审流程配置", regionCode)); | |||
} | |||
// 获取发起单位、发起单位主管单位、发起单位上级主管条线单位信息 | |||
Map<String, OrgInfoDTO> orgModelMap = buildOrgModelMap(employeeCode,projectInfo); | |||
String instanceId = processService.newStartProcess(model.getProcessDefId(),model.getFormId(), params,orgModelMap); | |||
log.info("提交预审项目成功 【{}】", instanceId); | |||
//保存预审项目 | |||
preModifyProject(projectInfo, instanceId); | |||
return instanceId; | |||
} | |||
/** | |||
* 提交预审项目 时 更新信息 | |||
* | |||
* @param project | |||
* @param instanceId | |||
*/ | |||
private void preModifyProject(Project project, String instanceId) { | |||
//流程启动之后 入库项目 重要业务信息 用于列表查询 展示 | |||
try { | |||
project.setUpdateOn(LocalDateTime.now()); | |||
project.setInstCode(instanceId); | |||
projectService.updateById(project); | |||
//保存项目和实例的关系 | |||
ProjectInst projectInst = new ProjectInst(); | |||
projectInst.setProjectId(project.getId()); | |||
projectInst.setInstCode(instanceId); | |||
projectInst.setCreatOn(LocalDateTime.now()); | |||
projectInst.setUpdateOn(LocalDateTime.now()); | |||
projectInst.setInstType(ProjectProcessStageEnum.PROJECT_PREQUALIFICATION_APPROVAL_PROCESS.getCode()); | |||
projectInstService.save(projectInst); | |||
} catch (Exception e) { | |||
log.error("提交预审 项目信息修改 错误 ", e); | |||
throw new BusinessException("提交预审 项目信息修改 错误 :" + e.getMessage()); | |||
} | |||
} | |||
//根据提交者的单位 | |||
public DeclaredProjectStatisticsPO declaredProjectOrgStatistics(Integer year){ | |||
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); | |||
@@ -263,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<Map<String, Object>>() { | |||
}) | |||
); | |||
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<Map<String, Object>>() { | |||
})); | |||
} | |||
} |
@@ -2,16 +2,20 @@ package com.ningdatech.pmapi.projectdeclared.manage; | |||
import com.alibaba.excel.EasyExcel; | |||
import com.alibaba.fastjson.JSON; | |||
import com.alibaba.fastjson.TypeReference; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.ningdatech.basic.function.VUtils; | |||
import com.ningdatech.basic.model.PageVo; | |||
import com.ningdatech.basic.util.NdDateUtils; | |||
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.DefaultDeclaredDTO; | |||
import com.ningdatech.pmapi.projectdeclared.model.dto.PretrialDeclaredExportDTO; | |||
import com.ningdatech.pmapi.projectdeclared.model.dto.ProjectConditionDTO; | |||
import com.ningdatech.pmapi.projectdeclared.model.req.PrequalificationDeclaredListReq; | |||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; | |||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; | |||
@@ -19,13 +23,21 @@ import com.ningdatech.pmapi.projectlib.helper.ProjectHelper; | |||
import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage; | |||
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.model.req.ProjectListReq; | |||
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectInstService; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | |||
import com.ningdatech.pmapi.staging.service.IProjectStagingService; | |||
import com.ningdatech.pmapi.todocenter.constant.TodoCenterContant; | |||
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 com.wflow.workflow.bean.dto.OrgInfoDTO; | |||
import com.wflow.workflow.bean.vo.ProcessStartParamsVo; | |||
import com.wflow.workflow.service.ProcessInstanceService; | |||
import com.wflow.workflow.service.ProcessModelService; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.BeanUtils; | |||
@@ -34,7 +46,9 @@ import org.springframework.transaction.annotation.Transactional; | |||
import javax.servlet.http.HttpServletResponse; | |||
import java.io.IOException; | |||
import java.time.LocalDateTime; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Objects; | |||
import java.util.stream.Collectors; | |||
@@ -59,10 +73,14 @@ public class PrequalificationDeclaredProjectManage { | |||
private final UserInfoHelper userInfoHelper; | |||
private final DefaultDeclaredProjectManage declaredProjectManage; | |||
private final ProcessModelService processModelService; | |||
private final DefaultDeclaredProjectManage defaultDeclaredProjectManage; | |||
private final ProcessInstanceService processInstanceService; | |||
private final IProjectInstService projectInstService; | |||
/** | |||
* 提交预审 | |||
* | |||
@@ -102,6 +120,8 @@ public class PrequalificationDeclaredProjectManage { | |||
projectInfo.setUpdateOn(LocalDateTime.now()); | |||
//保存一下 当前的主管单位发起人 | |||
projectInfo.setPreStartUserId(employeeCode); | |||
//当前实例置为空 | |||
projectInfo.setInstCode(TodoCenterContant.Declared.NULL_INST_CODE); | |||
if(projectStagingService.addByProject(projectInfo,"省级部门联审") | |||
&& projectService.updateById(projectInfo)){ | |||
return "提交省级部门联审成功"; | |||
@@ -110,7 +130,7 @@ public class PrequalificationDeclaredProjectManage { | |||
}else if(ProjectStatusEnum.PRE_APPLYING | |||
.getCode().equals(projectInfo.getStatus())){ | |||
//如果是非省级联审的项目 直接提交 预审 | |||
instanceId = defaultDeclaredProjectManage.directStartProcess(projectInfo,employeeCode); | |||
instanceId = directStartProcess(projectInfo,employeeCode); | |||
}else{ | |||
throw new BusinessException("项目状态 错误 project :" + JSON.toJSONString(projectInfo)); | |||
} | |||
@@ -140,6 +160,68 @@ public class PrequalificationDeclaredProjectManage { | |||
return startTheProcess(dto); | |||
} | |||
//直接提交预审方法 提取 在省级联审通过的时候 也可以用 | |||
public String directStartProcess(Project projectInfo,String employeeCode){ | |||
VUtils.isTrue(Objects.isNull(employeeCode)) | |||
.throwMessage("发起人 员工code 不能为空!"); | |||
ProcessStartParamsVo params = new ProcessStartParamsVo(); | |||
params.setUser(defaultDeclaredProjectManage.buildUser(employeeCode)); | |||
params.setProcessUsers(Collections.emptyMap()); | |||
//把条件值给放入工作流 | |||
defaultDeclaredProjectManage.buildCondition(params,projectInfo); | |||
String regionCode = projectInfo.getAreaCode(); | |||
WflowModels model = processModelService.getOne(Wrappers.lambdaQuery(WflowModels.class) | |||
.eq(WflowModels::getRegionCode, regionCode) | |||
.eq(WflowModels::getProcessType, ProjectProcessStageEnum.PROJECT_PREQUALIFICATION_APPROVAL_PROCESS.getCode()) | |||
.last("limit 1")); | |||
if (Objects.isNull(model)) { | |||
log.error("此 【{}】区域找不到 预审流程配置", regionCode); | |||
throw new BusinessException(String.format("此 【%s】区域找不到 预审流程配置", regionCode)); | |||
} | |||
// 获取发起单位、发起单位主管单位、发起单位上级主管条线单位信息 | |||
Map<String, OrgInfoDTO> orgModelMap = defaultDeclaredProjectManage.buildOrgModelMap(employeeCode,projectInfo); | |||
String instanceId = processInstanceService.newStartProcess(model.getProcessDefId(),model.getFormId(), params,orgModelMap); | |||
log.info("提交预审项目成功 【{}】", instanceId); | |||
//保存预审项目 | |||
preModifyProject(projectInfo, instanceId); | |||
return instanceId; | |||
} | |||
/** | |||
* 提交预审项目 时 更新信息 | |||
* | |||
* @param project | |||
* @param instanceId | |||
*/ | |||
private void preModifyProject(Project project, String instanceId) { | |||
//流程启动之后 入库项目 重要业务信息 用于列表查询 展示 | |||
try { | |||
project.setUpdateOn(LocalDateTime.now()); | |||
project.setInstCode(instanceId); | |||
projectService.updateById(project); | |||
//保存项目和实例的关系 | |||
ProjectInst projectInst = new ProjectInst(); | |||
projectInst.setProjectId(project.getId()); | |||
projectInst.setInstCode(instanceId); | |||
projectInst.setCreatOn(LocalDateTime.now()); | |||
projectInst.setUpdateOn(LocalDateTime.now()); | |||
projectInst.setInstType(ProjectProcessStageEnum.PROJECT_PREQUALIFICATION_APPROVAL_PROCESS.getCode()); | |||
projectInstService.save(projectInst); | |||
} catch (Exception e) { | |||
log.error("提交预审 项目信息修改 错误 ", e); | |||
throw new BusinessException("提交预审 项目信息修改 错误 :" + e.getMessage()); | |||
} | |||
} | |||
/** | |||
* 查询项目库 | |||
* @param preReq | |||
@@ -90,13 +90,8 @@ public class ReviewByDeptJointManage { | |||
Map<String, Object> formData = Maps.newHashMap(); | |||
//放入条件判断的项目字段 | |||
ProjectConditionDTO conditionDto = new ProjectConditionDTO(); | |||
BeanUtils.copyProperties(projectInfo, conditionDto); | |||
formData.putAll( | |||
JSON.parseObject(JSON.toJSONString(conditionDto), new TypeReference<Map<String, Object>>() { | |||
}) | |||
); | |||
params.setFormData(formData); | |||
//把条件值给放入工作流 | |||
defaultDeclaredProjectManage.buildCondition(params,projectInfo); | |||
// 获取发起单位、发起单位主管单位、发起单位上级主管条线单位信息 | |||
Map<String, OrgInfoDTO> orgModelMap = defaultDeclaredProjectManage.buildOrgModelMap(startUserCode,project); | |||
@@ -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<Project> 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); | |||
@@ -234,10 +234,7 @@ public class Project implements Serializable { | |||
@ApiModelProperty("一地创新全省共享项目-是否开启 false:关闭 true:开启") | |||
private Boolean isInnovateWholeProvinceShare; | |||
@TableField(fill = FieldFill.INSERT) | |||
private LocalDateTime createOn; | |||
@TableField(fill = FieldFill.INSERT_UPDATE) | |||
private LocalDateTime updateOn; | |||
@ApiModelProperty("流程实例编号") | |||
@@ -303,6 +303,9 @@ public class ProjectDetailVO { | |||
@ApiModelProperty("21位项目编号") | |||
private String projectCode; | |||
private LocalDateTime createOn; | |||
private LocalDateTime updateOn; | |||
public String getProjectTypeName() { | |||
if (Objects.nonNull(this.projectType)) { | |||
Optional.ofNullable(ProjectTypeEnum.getDesc(this.projectType)) | |||
@@ -12,4 +12,10 @@ public interface TodoCenterContant { | |||
public static final String OR_SIGN_FLAG = "MI_END"; | |||
} | |||
public class Declared { | |||
public static final String NULL_INST_CODE = "EMPTY"; | |||
} | |||
} |
@@ -48,14 +48,21 @@ public class WithDrawHandle { | |||
* @return | |||
*/ | |||
public Boolean checkCanWithdraw(String instanceId, ProcessProgressVo progressInstanceDetail) { | |||
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() | |||
.processInstanceId(instanceId).singleResult(); | |||
UserInfoDetails userInfoDetails = LoginUserUtil.loginUserDetail(); | |||
String employeeCode = userInfoDetails.getEmployeeCode(); | |||
//如果不是当前登录人 | |||
if(!ProcessStatusEnum.UNDER_REVIEW.getDesc() | |||
.equals(progressInstanceDetail.getStatus())){ | |||
return Boolean.FALSE; | |||
} | |||
return checkUserIsRoot(instanceId,null) || | |||
checkUserIsBefore(progressInstanceDetail.getProgressInfo(),null); | |||
// 如果当前登录用户是流程发起人,判断流程是否已经开始审批,如果开始审批,不能撤回 | |||
Boolean userIsRoot = checkUserIsRoot(instanceId, null); | |||
if (Boolean.TRUE.equals(userIsRoot) && canRootWithDraw(historicProcessInstance, employeeCode)){ | |||
return Boolean.TRUE; | |||
} | |||
return checkUserIsBefore(progressInstanceDetail.getProgressInfo(),null); | |||
} | |||
//判断当前操作人 是上一个节点的审批人 | |||
@@ -1,5 +1,6 @@ | |||
package com.ningdatech.pmapi.todocenter.manage; | |||
import cn.hutool.core.collection.CollUtil; | |||
import cn.hutool.core.util.StrUtil; | |||
import com.alibaba.fastjson.JSON; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
@@ -20,6 +21,7 @@ import com.ningdatech.pmapi.projectlib.model.dto.ProjectApplicationDTO; | |||
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; | |||
@@ -30,6 +32,7 @@ import com.ningdatech.pmapi.staging.service.IProjectStagingService; | |||
import com.ningdatech.pmapi.sys.model.entity.Notify; | |||
import com.ningdatech.pmapi.sys.service.INotifyService; | |||
import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo; | |||
import com.ningdatech.pmapi.todocenter.constant.TodoCenterContant; | |||
import com.ningdatech.pmapi.todocenter.service.StatisticsService; | |||
import com.ningdatech.pmapi.todocenter.utils.BuildUserUtils; | |||
import com.ningdatech.pmapi.todocenter.utils.PdfUtils; | |||
@@ -37,23 +40,28 @@ import com.ningdatech.pmapi.user.entity.UserInfo; | |||
import com.ningdatech.pmapi.user.service.IUserInfoService; | |||
import com.ningdatech.pmapi.user.util.LoginUserUtil; | |||
import com.wflow.contants.HisProInsEndActId; | |||
import com.wflow.contants.WflowContant; | |||
import com.wflow.workflow.bean.process.ProgressNode; | |||
import com.wflow.workflow.bean.process.enums.NodeTypeEnum; | |||
import com.wflow.workflow.bean.vo.ProcessProgressVo; | |||
import com.wflow.workflow.enums.ProcessHandlerEnum; | |||
import com.wflow.workflow.service.ProcessInstanceService; | |||
import com.wflow.workflow.service.ProcessTaskService; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.flowable.engine.HistoryService; | |||
import org.flowable.engine.RuntimeService; | |||
import org.flowable.engine.TaskService; | |||
import org.flowable.engine.history.HistoricProcessInstance; | |||
import org.flowable.engine.task.Comment; | |||
import org.flowable.variable.api.history.HistoricVariableInstance; | |||
import org.springframework.beans.BeanUtils; | |||
import org.springframework.stereotype.Component; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import java.time.LocalDateTime; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Objects; | |||
import java.util.*; | |||
import java.util.stream.Collectors; | |||
import static com.ningdatech.pmapi.todocenter.constant.WorkNoticeContant.*; | |||
@@ -69,26 +77,20 @@ import static com.ningdatech.pmapi.todocenter.constant.WorkNoticeContant.*; | |||
@Slf4j | |||
public class HandlerManage { | |||
private final ProcessTaskService processTaskService; | |||
private final RuntimeService runtimeService; | |||
private final TaskService taskService; | |||
private final HistoryService historyService; | |||
private final IUserInfoService userInfoService; | |||
private final IProjectService projectService; | |||
private final ProjectLibManage projectLibManage; | |||
private final StateMachineUtils stateMachineUtils; | |||
private final IDingEmployeeInfoService dingEmployeeInfoService; | |||
private final IDingOrganizationService dingOrganizationService; | |||
private final ProcessInstanceService processInstanceService; | |||
private final INdWorkNoticeStagingService workNoticeStagingService; | |||
private final DefaultDeclaredProjectManage defaultDeclaredProjectManage; | |||
private final IProjectApplicationService projectApplicationService; | |||
private final UserInfoHelper userInfoHelper; | |||
private final BuildUserUtils buildUserUtils; | |||
private final IProjectStagingService projectStagingService; | |||
private final IProjectInstService projectInstService; | |||
private final PdfUtils pdfUtils; | |||
private final FileService fileService; | |||
private final ICompanySignatureService companySignatureService; | |||
private final StatisticsService statisticsService; | |||
private final INotifyService notifyService; | |||
private final DeclaredProjectManage declaredProjectManage; | |||
@@ -201,24 +203,9 @@ public class HandlerManage { | |||
// 更新项目状态为待申报 | |||
updateWithdrawProjectStatus(userId, declaredProject); | |||
// 保存到草稿箱中 | |||
ProjectDraftSaveDTO draftSaveDto = new ProjectDraftSaveDTO(); | |||
ProjectDTO projectInfo = new ProjectDTO(); | |||
BeanUtils.copyProperties(declaredProject,projectInfo); | |||
// 查询出项目关联的应用信息 | |||
List<ProjectApplication> applicationList = projectApplicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) | |||
.eq(ProjectApplication::getProjectId, declaredProject.getId())); | |||
List<ProjectApplicationDTO> applicationDTOList = applicationList.stream().map(a -> { | |||
ProjectApplicationDTO applicationDTO = new ProjectApplicationDTO(); | |||
BeanUtils.copyProperties(a, applicationDTO); | |||
return applicationDTO; | |||
}).collect(Collectors.toList()); | |||
projectInfo.setApplicationList(applicationDTOList); | |||
HashMap<String,Object> dynamicMap = JSON.parseObject(declaredProject.getDynamicForm(), HashMap.class); | |||
projectInfo.setDynamicForm(dynamicMap); | |||
draftSaveDto.setProjectInfo(projectInfo); | |||
declaredProjectManage.saveToDraft(draftSaveDto); | |||
// 并删除项目库中该项目信息 | |||
projectService.removeById(declaredProject); | |||
saveToDraft(declaredProject); | |||
//删除所有项目相关的信息 | |||
deleteProjectRelated(declaredProject); | |||
break; | |||
// 当前项目状态是预审中 | |||
case PRE_APPLYING: | |||
@@ -235,6 +222,44 @@ public class HandlerManage { | |||
} | |||
} | |||
// 保存到草稿箱中 | |||
private void saveToDraft(Project declaredProject) { | |||
ProjectDraftSaveDTO draftSaveDto = new ProjectDraftSaveDTO(); | |||
ProjectDTO projectInfo = new ProjectDTO(); | |||
BeanUtils.copyProperties(declaredProject,projectInfo); | |||
// 查询出项目关联的应用信息 | |||
List<ProjectApplication> applicationList = projectApplicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) | |||
.eq(ProjectApplication::getProjectId, declaredProject.getId())); | |||
List<ProjectApplicationDTO> applicationDTOList = applicationList.stream().map(a -> { | |||
ProjectApplicationDTO applicationDTO = new ProjectApplicationDTO(); | |||
BeanUtils.copyProperties(a, applicationDTO); | |||
return applicationDTO; | |||
}).collect(Collectors.toList()); | |||
projectInfo.setApplicationList(applicationDTOList); | |||
HashMap<String,Object> dynamicMap = JSON.parseObject(declaredProject.getDynamicForm(), HashMap.class); | |||
projectInfo.setDynamicForm(dynamicMap); | |||
draftSaveDto.setProjectInfo(projectInfo); | |||
declaredProjectManage.saveToDraft(draftSaveDto); | |||
} | |||
/** | |||
* 删除项目的所有信息 | |||
* @param declaredProject | |||
*/ | |||
public void deleteProjectRelated(Project declaredProject) { | |||
//删除项目库中该项目信息 | |||
projectService.removeById(declaredProject); | |||
//删除app信息 | |||
projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class) | |||
.eq(ProjectApplication::getProjectId,declaredProject.getId())); | |||
// 删除关联表信息 | |||
projectInstService.remove(Wrappers.lambdaQuery(ProjectInst.class) | |||
.eq(ProjectInst::getProjectId,declaredProject.getId()) | |||
.eq(ProjectInst::getInstCode,declaredProject.getInstCode())); | |||
//删除项目的实例信息 | |||
historyService.deleteHistoricProcessInstance(declaredProject.getInstCode()); | |||
} | |||
/** | |||
* 退回审核后 所处理的逻辑 | |||
* @param declaredProject | |||
@@ -301,15 +326,20 @@ public class HandlerManage { | |||
* @author CMM | |||
* @since 2023/02/08 | |||
*/ | |||
private void updateWithdrawProjectStatus(Long userId, Project declaredProject) { | |||
try { | |||
stateMachineUtils.withDraw(declaredProject); | |||
declaredProject.setUpdateOn(LocalDateTime.now()); | |||
declaredProject.setUpdateBy(userId); | |||
projectService.updateById(declaredProject); | |||
} catch (Exception e) { | |||
throw new BizException("状态机执行失败!"); | |||
} | |||
@Transactional(rollbackFor = Exception.class) | |||
public void updateWithdrawProjectStatus(Long userId, Project declaredProject) { | |||
// 删除关联表信息 | |||
projectInstService.remove(Wrappers.lambdaQuery(ProjectInst.class) | |||
.eq(ProjectInst::getProjectId,declaredProject.getId()) | |||
.eq(ProjectInst::getInstCode,declaredProject.getInstCode())); | |||
//删除项目的实例信息 | |||
historyService.deleteHistoricProcessInstance(declaredProject.getInstCode()); | |||
stateMachineUtils.withDraw(declaredProject); | |||
declaredProject.setUpdateOn(LocalDateTime.now()); | |||
declaredProject.setUpdateBy(userId); | |||
declaredProject.setInstCode(TodoCenterContant.Declared.NULL_INST_CODE); | |||
projectService.updateById(declaredProject); | |||
} | |||
/** | |||
@@ -369,4 +399,28 @@ public class HandlerManage { | |||
workNoticeInfo.setReceiverUserId(receiverUserId); | |||
return workNoticeInfo; | |||
} | |||
public void deleteBackComments(List<HistoricVariableInstance> approves) { | |||
if(CollUtil.isNotEmpty(approves)){ | |||
for(HistoricVariableInstance approve : approves){ | |||
if(approve.getValue() instanceof ProcessHandlerEnum){ | |||
if(ProcessHandlerEnum.BACK.equals(ProcessHandlerEnum.getEnumByName(String.valueOf(approve.getValue())))){ | |||
runtimeService.removeVariable(approve.getProcessInstanceId(),approve.getVariableName()); | |||
Comment comment; | |||
Optional<Comment> first = taskService.getProcessInstanceComments(approve.getProcessInstanceId()) | |||
.stream() | |||
.filter(c -> c.getTaskId().equals(approve.getVariableName().replace("approve_", StringUtils.EMPTY))) | |||
.findFirst(); | |||
if (first.isPresent()){ | |||
comment = first.get(); | |||
taskService.deleteComment(comment.getId()); | |||
} | |||
break; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} |
@@ -439,6 +439,10 @@ public class TodoCenterManage { | |||
Long projectId = request.getProjectId(); | |||
ProcessProgressVo progressInstanceDetail = processInstanceService.getProgressInstanceDetail(nodeId, instanceId); | |||
if(Objects.isNull(progressInstanceDetail)){ | |||
return null; | |||
} | |||
List<ProgressNode> progressInfo = progressInstanceDetail.getProgressInfo(); | |||
if (CollUtil.isNotEmpty(progressInfo)){ | |||
buildUserUtils.buildUserByProcessInfo(progressInfo); | |||
@@ -891,27 +895,8 @@ public class TodoCenterManage { | |||
.processInstanceId(dto.getInstanceId()) | |||
.variableNameLike("approve_%") | |||
.list(); | |||
if(CollUtil.isNotEmpty(approves)){ | |||
for(HistoricVariableInstance approve : approves){ | |||
if(approve.getValue() instanceof ProcessHandlerEnum){ | |||
if(ProcessHandlerEnum.BACK.equals(ProcessHandlerEnum.getEnumByName(String.valueOf(approve.getValue())))){ | |||
runtimeService.removeVariable(approve.getProcessInstanceId(),approve.getVariableName()); | |||
Comment comment; | |||
Optional<Comment> first = taskService.getProcessInstanceComments(approve.getProcessInstanceId()) | |||
.stream() | |||
.filter(c -> c.getTaskId().equals(approve.getVariableName().replace("approve_", StringUtils.EMPTY))) | |||
.findFirst(); | |||
if (first.isPresent()){ | |||
comment = first.get(); | |||
taskService.deleteComment(comment.getId()); | |||
} | |||
break; | |||
} | |||
} | |||
} | |||
} | |||
//删除 退回的评论和意见 | |||
handlerManage.deleteBackComments(approves); | |||
// 更新当前流程状态为审核中 | |||
processTaskService.updateProInstStatus(dto.getInstanceId()); | |||
@@ -928,10 +913,12 @@ public class TodoCenterManage { | |||
throw new BusinessException("项目调整失败"); | |||
} | |||
//再修改应用信息 | |||
if(CollUtil.isNotEmpty(projectDto.getApplicationList())){ | |||
//采取批量删除 批量添加的方式 | |||
projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class) | |||
.eq(ProjectApplication::getProjectId,project.getId())); | |||
Boolean isApp = Objects.nonNull(projectDto.getIncludeApplication()) && 1 == projectDto.getIncludeApplication() | |||
? Boolean.TRUE : Boolean.FALSE; | |||
//批量删除 | |||
projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class) | |||
.eq(ProjectApplication::getProjectId,project.getId())); | |||
if(isApp && CollUtil.isNotEmpty(projectDto.getApplicationList())){ | |||
//批量添加 | |||
List<ProjectApplication> applications = projectDto.getApplicationList().stream().map(application -> { | |||
ProjectApplication projectApplication = new ProjectApplication(); | |||
@@ -15,5 +15,5 @@ public interface StatisticsMapper extends BaseMapper { | |||
TodoCenterStatisticsPO ccNums(@Param("employeeCode") String employeeCode); | |||
TodoCenterStatisticsPO getIdo(String employeeCode); | |||
TodoCenterStatisticsPO getIdo(@Param("employeeCode") String employeeCode); | |||
} |
@@ -27,9 +27,17 @@ | |||
<select id="getTodoOrIdo" parameterType="java.lang.String" | |||
resultType="com.ningdatech.pmapi.todocenter.model.po.TodoCenterStatisticsPO"> | |||
SELECT | |||
sum(CASE WHEN ht.assignee_ = #{employeeCode} AND ht.end_time_ is NULL THEN 1 end) todoNum | |||
FROM | |||
act_hi_taskinst ht | |||
count(0) todoNum | |||
FROM(SELECT | |||
hp.ID_ | |||
FROM | |||
act_hi_procinst hp | |||
LEFT JOIN | |||
act_hi_taskinst ht ON hp.PROC_INST_ID_ = ht.PROC_INST_ID_ | |||
WHERE (ht.assignee_ = #{employeeCode} AND ht.end_time_ is NULL | |||
AND hp.PROC_INST_ID_ NOT IN (SELECT PROC_INST_ID_ FROM act_hi_procinst hp WHERE hp.business_status_ = 'back-end')) | |||
OR (hp.start_user_id_ = #{employeeCode} and hp.business_status_ = 'back-end') | |||
GROUP BY hp.ID_ ) | |||
</select> | |||
<select id="getIdo" parameterType="java.lang.String" | |||