diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/constant/ProjectConstant.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/constant/ProjectConstant.java index 9d032e9..c34a508 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/constant/ProjectConstant.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/constant/ProjectConstant.java @@ -11,5 +11,9 @@ public interface ProjectConstant { class ProjectLib{ public static final String PROJECT_BASIC = "basic"; public static final String PROJECT_CONSTRUCT = "construct"; + + public static final String CHANGES_KEY = "changes"; + + public static final String PROCESS_KEY = "process"; } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectLibController.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectLibController.java index f0c4902..b462e64 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectLibController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectLibController.java @@ -54,7 +54,7 @@ public class ProjectLibController { } @GetMapping("/change-record/{id}") - @ApiOperation("查看项目变更记录-输入任一项目ID即可") + @ApiOperation("查看项目变更记录") public JSONObject changeRecord(@PathVariable Long id) { return projectLibManage.changeRecord(id); } 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 05d7e6c..52bf8a9 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 @@ -60,6 +60,8 @@ import com.ningdatech.pmapi.projectlib.model.vo.ProjectApplicationVO; import com.ningdatech.pmapi.projectlib.model.vo.ProjectDetailVO; import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; import com.ningdatech.pmapi.projectlib.service.*; +import com.ningdatech.pmapi.todocenter.model.req.ProcessDetailReq; +import com.ningdatech.pmapi.todocenter.service.ITodoService; import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; import com.ningdatech.pmapi.user.util.LoginUserUtil; import com.wflow.exception.BusinessException; @@ -67,7 +69,6 @@ import com.wflow.workflow.bean.vo.ProcessDetailVO; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.checkerframework.checker.nullness.qual.Nullable; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Component; @@ -111,6 +112,8 @@ public class ProjectLibManage { private final IPaymentPlanService paymentPlanService; + private final ITodoService todoService; + public PageVo projectLibList(ProjectListReq req) { LambdaQueryWrapper query = ProjectHelper.projectQuery(req); query.eq(Project::getNewest,Boolean.TRUE); @@ -1184,6 +1187,14 @@ public class ProjectLibManage { return res; } - return new CompareUtils().compareToJson(twoVersions.get(0), twoVersions.get(1),null); + Project lastProject = twoVersions.get(1); + Project thisProject = twoVersions.get(0); + res.put(ProjectConstant.ProjectLib.CHANGES_KEY, + new CompareUtils().compareToJson(thisProject, lastProject,null)); + ProcessDetailReq req = new ProcessDetailReq(); + req.setProjectId(lastProject.getId()); + req.setInstanceId(lastProject.getInstCode()); + res.put(ProjectConstant.ProjectLib.PROCESS_KEY,todoService.getProcessDetail(req)); + return res; } } 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 04ad446..bc72d51 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 @@ -479,7 +479,7 @@ public class HandlerManage { * @param taskId * @return */ - public Boolean checkIsContainsTask(List progressNodes, String taskId) { + public static Boolean checkIsContainsTask(List progressNodes, String taskId) { if(CollUtil.isEmpty(progressNodes)){ return Boolean.FALSE; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java index 404d13c..8ba8ec0 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java @@ -599,7 +599,7 @@ public class TodoCenterManage { .equals(userFullInfoDTO.getEmpPosUnitCode())){ //说明是此单位的人 //那么要去看 taskId 是不是 在这个单位内的任务 - Boolean isContainsTask = handlerManage.checkIsContainsTask(children,taskId); + Boolean isContainsTask = HandlerManage.checkIsContainsTask(children,taskId); if(isContainsTask){ res[0] = Boolean.TRUE; return; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/service/ITodoService.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/service/ITodoService.java new file mode 100644 index 0000000..5c8c530 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/service/ITodoService.java @@ -0,0 +1,19 @@ +package com.ningdatech.pmapi.todocenter.service; + +import com.ningdatech.pmapi.todocenter.model.req.ProcessDetailReq; +import com.ningdatech.pmapi.todocenter.model.vo.ProcessProgressDetailVo; + +/** + * @Classname ITodoService + * @Description + * @Date 2023/7/25 15:41 + * @Author PoffyZhang + */ +public interface ITodoService { + /** + * 获取事例详情 + * @param request + * @return + */ + ProcessProgressDetailVo getProcessDetail(ProcessDetailReq request) ; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/service/impl/TodoServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/service/impl/TodoServiceImpl.java new file mode 100644 index 0000000..e5a0490 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/service/impl/TodoServiceImpl.java @@ -0,0 +1,164 @@ +package com.ningdatech.pmapi.todocenter.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ningdatech.pmapi.common.helper.UserInfoHelper; +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.todocenter.handle.PassHandle; +import com.ningdatech.pmapi.todocenter.handle.WithDrawHandle; +import com.ningdatech.pmapi.todocenter.manage.HandlerManage; +import com.ningdatech.pmapi.todocenter.model.req.ProcessDetailReq; +import com.ningdatech.pmapi.todocenter.model.vo.ProcessProgressDetailVo; +import com.ningdatech.pmapi.todocenter.service.ITodoService; +import com.ningdatech.pmapi.todocenter.utils.BuildUserUtils; +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.workflow.bean.process.ProgressNode; +import com.wflow.workflow.bean.process.enums.NodeTypeEnum; +import com.wflow.workflow.bean.vo.ProcessProgressVo; +import com.wflow.workflow.service.ProcessInstanceService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Objects; + +/** + * @Classname TodoService + * @Description + * @Date 2023/7/25 15:41 + * @Author PoffyZhang + */ +@Service +@AllArgsConstructor +@Slf4j +public class TodoServiceImpl implements ITodoService { + + private final ProcessInstanceService processInstanceService; + + private final BuildUserUtils buildUserUtils; + + private final UserInfoHelper userInfoHelper; + + private final WithDrawHandle withDrawHandle; + + private final PassHandle passHandle; + + private final IProjectService projectService; + + private final IProjectInstService projectInstService; + + /** + * 查询流程表单数据及审批的进度步骤 + * + * @param request 请求参数 + * @return 流程进度及表单详情 + */ + public ProcessProgressDetailVo getProcessDetail(ProcessDetailReq request) { + String employeeCode = LoginUserUtil.loginUserDetail().getEmployeeCode(); + String instanceId = request.getInstanceId(); + String nodeId = request.getNodeId(); + Long projectId = request.getProjectId(); + String taskId = request.getTaskId(); + ProcessProgressVo progressInstanceDetail = processInstanceService.getProgressInstanceDetail(nodeId, instanceId,taskId); + + if(Objects.isNull(progressInstanceDetail)){ + return null; + } + + List progressInfo = progressInstanceDetail.getProgressInfo(); + Boolean isHighLine = Boolean.FALSE; + if (CollUtil.isNotEmpty(progressInfo)){ + buildUserUtils.buildUserByProcessInfo(progressInfo); + isHighLine = checkHighLine(progressInfo,taskId,LoginUserUtil.loginUserDetail()); + } + ProcessProgressDetailVo res = new ProcessProgressDetailVo(); + res.setProcessProgressVo(progressInstanceDetail); + res.setStatus(progressInstanceDetail.getStatus()); + res.setProjectId(projectId); + res.setCanWithdraw(withDrawHandle.checkCanWithdraw(instanceId,progressInstanceDetail,request.getTaskId())); + res.setIsHighLine(isHighLine); + passHandle.checkCanPassOrSeal(request.getInstanceId(),request.getTaskId(),employeeCode,res); + //是不是被 驳回|退回 + res.setIsChange(isChangeRecord(projectId)); + return res; + } + + /** + * 筛选 当前登录人 是不是 上级条线单位的审批 + * @param progressInfo + * @param taskId + * @param user + * @return + */ + private Boolean checkHighLine(List progressInfo, String taskId, UserInfoDetails user) { + if(CollUtil.isEmpty(progressInfo)){ + return Boolean.FALSE; + } + + final Boolean[] res = {Boolean.FALSE}; + progressInfo.forEach(p -> { + //如果是 子流程 + if(Objects.nonNull(p.getNodeType()) && NodeTypeEnum.SUB.name().equals(p.getNodeType().name())){ + //如果不是上级条线单位 根本不用理 + if(!p.getIsHighLine()){ + return; + } + List children = p.getChildren(); + ProgressNode progressNode = children.get(0); + String userId = progressNode.getUserId(); + if(StringUtils.isBlank(userId)){ + return; + } + UserFullInfoDTO userFullInfoDTO = userInfoHelper.getUserFullInfoByEmployeeCode(userId); + if(Objects.nonNull(userFullInfoDTO) && user.getEmpPosUnitCode() + .equals(userFullInfoDTO.getEmpPosUnitCode())){ + //说明是此单位的人 + //那么要去看 taskId 是不是 在这个单位内的任务 + Boolean isContainsTask = HandlerManage.checkIsContainsTask(children,taskId); + if(isContainsTask){ + res[0] = Boolean.TRUE; + return; + } + } + } + }); + return res[0]; + } + + /** + * 判断 当前项目是不是被驳回 或者 退回过 + * @param projectId + * @return + */ + private Boolean isChangeRecord(Long projectId) { + //1.先判断下 项目存不存在 + Project project = projectService.getById(projectId); + if(Objects.isNull(project)){ + return Boolean.FALSE; + } + + List projectIds = projectService.getAllVersionProjectId(project); + //2.要判断 项目在当前状态 有没有被驳回和退回过 + //当前项目状态流程的 实例 看看是不是有2个以上 有2个说明 有退回 驳回 + List pis = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) + .in(ProjectInst::getProjectId, projectIds) + .orderByDesc(ProjectInst::getInstType) + .last("limit 2")); + if(CollUtil.isEmpty(pis)){ + return Boolean.FALSE; + } + if( pis.size() < 2 || + !pis.get(0).getInstType().equals(pis.get(1).getInstType())) { + return Boolean.FALSE; + } + + return Boolean.TRUE; + } +}