diff --git a/ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeKingbaseConfig.java b/ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeKingbaseConfig.java index 36675c5..7d4f1d0 100644 --- a/ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeKingbaseConfig.java +++ b/ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeKingbaseConfig.java @@ -57,7 +57,7 @@ public class GeneratorCodeKingbaseConfig { public static void main(String[] args) { //generate("Liuxinxin", "expert", PATH_LXX, "expert_gov_business_strip"); - generate("CMM", "test", PATH_CMM, "nd_project_delay_apply"); + generate("CMM", "test", PATH_CMM, "nd_project_apply_borrow"); } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/controller/ProjectFileController.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/controller/ProjectFileController.java index 557c915..3bc5a69 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/controller/ProjectFileController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/controller/ProjectFileController.java @@ -43,6 +43,7 @@ public class ProjectFileController { @ApiOperation(value = "申请借阅", notes = "申请借阅") @WebLog("档案管理-项目档案-申请借阅") public String wantRead(@PathVariable Long projectId){ - return projectFileManage.wantRead(projectId); + String instanceId = projectFileManage.startApplyBorrowProcess(projectId); + return "启动申请借阅流程实例 【" + instanceId + "】 成功"; } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/manage/ProjectFileManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/manage/ProjectFileManage.java index 5da888a..a1d26e9 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/manage/ProjectFileManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/manage/ProjectFileManage.java @@ -2,20 +2,47 @@ package com.ningdatech.pmapi.filemanage.manage; 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.constant.BizConst; +import com.ningdatech.pmapi.common.enumeration.ProjectProcessStageEnum; +import com.ningdatech.pmapi.common.helper.UserInfoHelper; import com.ningdatech.pmapi.filemanage.model.param.ProjectFileListParam; import com.ningdatech.pmapi.filemanage.model.vo.ProjectFileListVO; import com.ningdatech.pmapi.filemanage.model.vo.ProjectFileVO; +import com.ningdatech.pmapi.projectdeclared.manage.DefaultDeclaredProjectManage; +import com.ningdatech.pmapi.projectlib.enumeration.InstTypeEnum; +import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage; import com.ningdatech.pmapi.projectlib.model.entity.Project; +import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; import com.ningdatech.pmapi.projectlib.model.vo.ProjectDetailVO; +import com.ningdatech.pmapi.projectlib.service.IProjectInstService; import com.ningdatech.pmapi.projectlib.service.IProjectService; +import com.ningdatech.pmapi.staging.enums.MsgTypeEnum; +import com.ningdatech.pmapi.sys.manage.NoticeManage; +import com.ningdatech.pmapi.todocenter.constant.WorkNoticeContant; +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.contants.HisProInsEndActId; +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.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.flowable.engine.HistoryService; +import org.flowable.engine.history.HistoricProcessInstance; import org.springframework.stereotype.Component; +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; /** @@ -30,8 +57,14 @@ import java.util.stream.Collectors; public class ProjectFileManage { private final IProjectService projectService; - private final ProjectLibManage projectLibManage; + private final UserInfoHelper userInfoHelper; + private final ProcessModelService processModelService; + private final DefaultDeclaredProjectManage defaultDeclaredProjectManage; + private final ProcessInstanceService processInstanceService; + private final NoticeManage noticeManage; + private final IProjectInstService projectInstService; + private final HistoryService historyService; public PageVo list(ProjectFileListParam param) { Page page = param.page(); @@ -50,6 +83,19 @@ public class ProjectFileManage { vo.setBuildOrgName(p.getBuildOrgName()); vo.setPojectCode(p.getProjectCode()); vo.setProjectName(p.getProjectName()); + // 判断当前项目是否已经开启了申请借阅并且没有审批完成 + String instCode = p.getInstCode(); + // 获取流程通过后的流程实例 + HistoricProcessInstance newInstance = historyService.createHistoricProcessInstanceQuery() + .processInstanceId(instCode) + .singleResult(); + ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class) + .eq(ProjectInst::getInstCode, instCode)); + Integer instType = projectInst.getInstType(); + if (InstTypeEnum.APPLY_BORROW.getCode().equals(instType) && + !HisProInsEndActId.END.equals(newInstance.getEndActivityId())){ + vo.setCanApplyBorrow(Boolean.FALSE); + } return vo; }).collect(Collectors.toList()); return PageVo.of(vos,page.getTotal()); @@ -65,4 +111,49 @@ public class ProjectFileManage { public String wantRead(Long projectId) { return "申请成功"; } + + public String startApplyBorrowProcess(Long projectId) { + UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); + String employeeCode = user.getEmployeeCode(); + VUtils.isTrue(StringUtils.isBlank(employeeCode)).throwMessage("获取登录用户 员工号 失败!"); + + Project project = projectService.getNewProject(projectId); + VUtils.isTrue(Objects.isNull(project)).throwMessage("提交失败 此项目不存在!"); + + //首先要判断 项目当前状态 是不是 已归档 + VUtils.isTrue(!ProjectStatusEnum.ARCHIVED.getCode().equals(project.getStatus())) + .throwMessage("提交失败 该项目不是 已归档"); + + String regionCode = user.getRegionCode(); + + WflowModels model = processModelService.getOne(Wrappers.lambdaQuery(WflowModels.class) + .eq(WflowModels::getRegionCode, regionCode) + .eq(WflowModels::getProcessType, ProjectProcessStageEnum.APPLY_BORROW.getCode()) + .last(BizConst.LIMIT_1)); + + if (Objects.isNull(model)) { + log.error("此 【{}】区域找不到申请借阅流程配置", regionCode); + throw new BusinessException(String.format("此 【%s】区域找不到申请借阅流程配置", regionCode)); + } + + ProcessStartParamsVo params = new ProcessStartParamsVo(); + params.setUser(defaultDeclaredProjectManage.buildUser(employeeCode)); + params.setProcessUsers(Collections.emptyMap()); + //放入条件判断的项目字段 + //把条件值给放入工作流 + defaultDeclaredProjectManage.buildCondition(params, project); + // 获取发起单位、发起单位主管单位、发起单位上级条线主管单位信息 + Map orgModelMap = defaultDeclaredProjectManage.buildOrgModelMap(employeeCode, project); + String instanceId = processInstanceService.newStartProcess(model.getProcessDefId(), model.getFormId(), params, orgModelMap); + log.info("申请借阅申报成功 【{}】", instanceId); + + // 保存项目借阅实例相关 + projectLibManage.saveProjectByApplyBorrow(project, user, instanceId); + + //发送给第一个审批人消息 + noticeManage.sendFirtUser(project,model.getFormName(),instanceId, + WorkNoticeContant.PASS_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW); + + return instanceId; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/mapper/NdProjectApplyBorrowMapper.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/mapper/NdProjectApplyBorrowMapper.java new file mode 100644 index 0000000..50545f3 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/mapper/NdProjectApplyBorrowMapper.java @@ -0,0 +1,16 @@ +package com.ningdatech.pmapi.filemanage.mapper; + +import com.ningdatech.pmapi.filemanage.model.entity.ProjectApplyBorrow; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * Mapper 接口 + *

+ * + * @author CMM + * @since 2023-06-16 + */ +public interface NdProjectApplyBorrowMapper extends BaseMapper { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/mapper/NdProjectApplyBorrowMapper.xml b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/mapper/NdProjectApplyBorrowMapper.xml new file mode 100644 index 0000000..6a6fa76 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/mapper/NdProjectApplyBorrowMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/entity/ProjectApplyBorrow.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/entity/ProjectApplyBorrow.java new file mode 100644 index 0000000..be5fffc --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/entity/ProjectApplyBorrow.java @@ -0,0 +1,57 @@ +package com.ningdatech.pmapi.filemanage.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; + +/** + *

+ * + *

+ * + * @author CMM + * @since 2023-06-16 + */ +@Data +@TableName("nd_project_apply_borrow") +@ApiModel(value = "NdProjectApplyBorrow对象", description = "") +public class ProjectApplyBorrow implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键") + @TableId(type = IdType.AUTO) + private Long id; + + @ApiModelProperty("借阅项目ID") + private Long projectId; + + @ApiModelProperty("申请借阅员工code") + private String applyBorrowEmployeeCode; + + @ApiModelProperty("申请借阅用户任职单位code") + private String applyBorrowEmpPosUnitCode; + + @ApiModelProperty("申请借阅审批流程ID") + private String instanceId; + + @ApiModelProperty("创建人") + private Long createBy; + + @ApiModelProperty("创建时间") + private LocalDateTime createOn; + + @ApiModelProperty("更新人") + private Long updateBy; + + @ApiModelProperty("更新时间") + private LocalDateTime updateOn; + + @ApiModelProperty("申请借阅是否成功") + private Boolean isSuccess; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/vo/ProjectFileListVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/vo/ProjectFileListVO.java index f7b2657..c4b4d90 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/vo/ProjectFileListVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/model/vo/ProjectFileListVO.java @@ -33,4 +33,7 @@ public class ProjectFileListVO { @ApiModelProperty("最后修改时间") private LocalDateTime updateOn; + + @ApiModelProperty("是否可以申请借阅") + private Boolean canApplyBorrow = Boolean.TRUE; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/service/INdProjectApplyBorrowService.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/service/INdProjectApplyBorrowService.java new file mode 100644 index 0000000..c4667e7 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/service/INdProjectApplyBorrowService.java @@ -0,0 +1,16 @@ +package com.ningdatech.pmapi.filemanage.service; + +import com.ningdatech.pmapi.filemanage.model.entity.ProjectApplyBorrow; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 服务类 + *

+ * + * @author CMM + * @since 2023-06-16 + */ +public interface INdProjectApplyBorrowService extends IService { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/service/impl/NdProjectApplyBorrowServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/service/impl/NdProjectApplyBorrowServiceImpl.java new file mode 100644 index 0000000..a76740e --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/service/impl/NdProjectApplyBorrowServiceImpl.java @@ -0,0 +1,20 @@ +package com.ningdatech.pmapi.filemanage.service.impl; + +import com.ningdatech.pmapi.filemanage.model.entity.ProjectApplyBorrow; +import com.ningdatech.pmapi.filemanage.mapper.NdProjectApplyBorrowMapper; +import com.ningdatech.pmapi.filemanage.service.INdProjectApplyBorrowService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author CMM + * @since 2023-06-16 + */ +@Service +public class NdProjectApplyBorrowServiceImpl extends ServiceImpl implements INdProjectApplyBorrowService { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java index 14c7385..f6dd325 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java @@ -3,7 +3,6 @@ package com.ningdatech.pmapi.projectlib.manage; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.date.DatePattern; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -11,7 +10,6 @@ import com.google.common.collect.Lists; import com.ningdatech.basic.function.VUtils; import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.util.CollUtils; -import com.ningdatech.basic.util.NdDateUtils; import com.ningdatech.file.entity.File; import com.ningdatech.file.service.FileService; import com.ningdatech.pmapi.common.constant.CommonConst; @@ -19,13 +17,14 @@ import com.ningdatech.pmapi.common.constant.RegionConst; import com.ningdatech.pmapi.common.enumeration.CommonEnum; import com.ningdatech.pmapi.common.enumeration.ProjectProcessStageEnum; import com.ningdatech.pmapi.common.helper.RegionCacheHelper; -import com.ningdatech.pmapi.common.helper.UserInfoHelper; import com.ningdatech.pmapi.common.model.entity.ExcelExportWriter; import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; import com.ningdatech.pmapi.common.util.BizUtils; import com.ningdatech.pmapi.common.util.ExcelDownUtil; import com.ningdatech.pmapi.datascope.model.DataScopeDTO; import com.ningdatech.pmapi.datascope.utils.DataScopeUtil; +import com.ningdatech.pmapi.filemanage.model.entity.ProjectApplyBorrow; +import com.ningdatech.pmapi.filemanage.service.INdProjectApplyBorrowService; import com.ningdatech.pmapi.projectdeclared.model.dto.DelayedApplyDTO; import com.ningdatech.pmapi.projectdeclared.utils.GenerateProjectCodeUtil; import com.ningdatech.pmapi.projectlib.enumeration.InstTypeEnum; @@ -79,6 +78,7 @@ public class ProjectLibManage { private final IProjectInstService projectInstService; private final StateMachineUtils stateMachineUtils; private final INdProjectDelayApplyService projectDelayApplyService; + private final INdProjectApplyBorrowService projectApplyBorrowService; public PageVo projectLibList(ProjectListReq req) { LambdaQueryWrapper query = ProjectHelper.projectQuery(req); @@ -644,4 +644,34 @@ public class ProjectLibManage { projectInst.setUpdateOn(LocalDateTime.now()); projectInstService.save(projectInst); } + + public void saveProjectByApplyBorrow(Project project, UserFullInfoDTO user, String instanceId) { + // 更新项目流程实例ID + project.setInstCode(instanceId); + project.setCreateOn(LocalDateTime.now()); + project.setUpdateOn(LocalDateTime.now()); + projectService.updateById(project); + + // 保存项目借阅信息 + ProjectApplyBorrow projectApplyBorrow = new ProjectApplyBorrow(); + projectApplyBorrow.setProjectId(project.getId()); + projectApplyBorrow.setApplyBorrowEmployeeCode(user.getEmployeeCode()); + projectApplyBorrow.setApplyBorrowEmpPosUnitCode(user.getEmpPosUnitCode()); + projectApplyBorrow.setInstanceId(instanceId); + projectApplyBorrow.setCreateOn(LocalDateTime.now()); + projectApplyBorrow.setCreateBy(LoginUserUtil.getUserId()); + projectApplyBorrow.setUpdateOn(LocalDateTime.now()); + projectApplyBorrow.setUpdateBy(LoginUserUtil.getUserId()); + projectApplyBorrow.setIsSuccess(Boolean.FALSE); + projectApplyBorrowService.save(projectApplyBorrow); + + //保存项目和实例的关系 + ProjectInst projectInst = new ProjectInst(); + projectInst.setProjectId(project.getId()); + projectInst.setInstCode(instanceId); + projectInst.setInstType(InstTypeEnum.APPLY_BORROW.getCode()); + projectInst.setCreatOn(LocalDateTime.now()); + projectInst.setUpdateOn(LocalDateTime.now()); + projectInstService.save(projectInst); + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/HandlerManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/HandlerManage.java index 49cbc28..125e1db 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/HandlerManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/HandlerManage.java @@ -12,6 +12,8 @@ import com.google.common.collect.Lists; import com.ningdatech.basic.util.NdDateUtils; import com.ningdatech.file.service.FileService; import com.ningdatech.pmapi.common.constant.ProjectDeclareConst; +import com.ningdatech.pmapi.filemanage.model.entity.ProjectApplyBorrow; +import com.ningdatech.pmapi.filemanage.service.INdProjectApplyBorrowService; import com.ningdatech.pmapi.projectdeclared.converter.ApplicationConverter; import com.ningdatech.pmapi.projectlib.enumeration.InstTypeEnum; import com.ningdatech.pmapi.projectlib.model.entity.ProjectDelayApply; @@ -85,6 +87,8 @@ public class HandlerManage { private final FileService fileService; private final IJoinReviewProvincialBureauService joinReviewProvincialBureauService; private final INdProjectDelayApplyService projectDelayApplyService; + private final INdProjectApplyBorrowService projectApplyBorrowService; + /** * 审核通过后 所处理的逻辑 @@ -146,7 +150,8 @@ public class HandlerManage { updateProjectDelayApplyInfo(declaredProject,instanceId); break; case APPLY_BORROW: - //TODO 申请借阅审批逻辑 + // 更新申请借阅状态为成功 + updateProjectApplyBorrowInfo(declaredProject,instanceId); break; default: throw new BizException("传入实例类型错误: " + instTypeEnum); @@ -209,6 +214,23 @@ public class HandlerManage { } } + private void updateProjectApplyBorrowInfo(Project declaredProject, String instanceId) { + + // 获取申请借阅信息 + ProjectApplyBorrow projectApplyBorrow = projectApplyBorrowService.getOne(Wrappers.lambdaQuery(ProjectApplyBorrow.class) + .eq(ProjectApplyBorrow::getProjectId, declaredProject.getId()) + .eq(ProjectApplyBorrow::getInstanceId, instanceId)); + // 更新项目借阅信息为成功 + projectApplyBorrow.setProjectId(declaredProject.getId()); + projectApplyBorrow.setInstanceId(instanceId); + projectApplyBorrow.setIsSuccess(Boolean.TRUE); + projectApplyBorrow.setCreateOn(LocalDateTime.now()); + projectApplyBorrow.setCreateBy(LoginUserUtil.getUserId()); + projectApplyBorrow.setUpdateOn(LocalDateTime.now()); + projectApplyBorrow.setUpdateBy(LoginUserUtil.getUserId()); + projectApplyBorrowService.updateById(projectApplyBorrow); + } + private void updateProjectDelayApplyInfo(Project declaredProject, String instanceId) { // 获取延期申请填写的相关信息 ProjectDelayApply delayApply = projectDelayApplyService.getOne(Wrappers.lambdaQuery(ProjectDelayApply.class)