浏览代码

区域修改

tags/24080901
WendyYang 1年前
父节点
当前提交
2130f221e7
共有 1 个文件被更改,包括 54 次插入53 次删除
  1. +54
    -53
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java

+ 54
- 53
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java 查看文件

@@ -13,7 +13,6 @@ import com.ningdatech.pmapi.common.model.entity.ExcelExportWriter;
import com.ningdatech.pmapi.common.statemachine.event.ProjectStatusChangeEvent;
import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils;
import com.ningdatech.pmapi.common.util.ExcelDownUtil;
import com.ningdatech.pmapi.common.util.SendWorkNoticeUtil;
import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo;
import com.ningdatech.pmapi.organization.model.entity.DingOrganization;
import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService;
@@ -30,12 +29,10 @@ import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo;
import com.ningdatech.pmapi.todocenter.bean.vo.ProcessProgressDetailVo;
import com.ningdatech.pmapi.todocenter.enumeration.IsAppendProjectEnum;
import com.ningdatech.pmapi.todocenter.model.dto.req.ProcessDetailReq;
import com.ningdatech.pmapi.todocenter.model.dto.req.ToBeProcessedReq;
import com.ningdatech.pmapi.todocenter.model.dto.req.ToBeProcessedExportReq;
import com.ningdatech.pmapi.todocenter.model.dto.req.ToBeProcessedReq;
import com.ningdatech.pmapi.todocenter.model.dto.vo.ResToBeProcessedVO;

import com.ningdatech.pmapi.user.entity.UserInfo;
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO;
import com.ningdatech.pmapi.user.service.IUserInfoService;
import com.ningdatech.pmapi.user.util.LoginUserUtil;
import com.wflow.contants.HisProInsEndActId;
@@ -47,23 +44,23 @@ import com.wflow.workflow.bean.vo.ProcessInstanceVo;
import com.wflow.workflow.bean.vo.ProcessProgressVo;
import com.wflow.workflow.bean.vo.ProcessTaskVo;
import com.wflow.workflow.enums.ProcessStatusEnum;
import com.wflow.workflow.service.*;
import com.wflow.workflow.service.ProcessInstanceService;
import com.wflow.workflow.service.ProcessTaskService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.assertj.core.util.Lists;
import org.flowable.bpmn.model.*;
import org.flowable.engine.*;
import org.flowable.engine.HistoryService;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.runtime.ActivityInstance;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;

import static cn.hutool.core.collection.CollUtil.isEmpty;
import static cn.hutool.core.collection.CollUtil.isNotEmpty;
import static com.ningdatech.pmapi.todocenter.constant.WorkNotice.*;
import static com.wflow.workflow.task.TriggerServiceTask.runtimeService;

@@ -102,8 +99,8 @@ public class TodoCenterManage {
Long userId = LoginUserUtil.getUserId();
//因为要解耦 不能把项目和工作流一起查
//1.先查出用户工作流
List<ProcessTaskVo> userTodoList = processTaskService.getUserTodoList(param.getProcessDefId(),String.valueOf(userId));
if(CollUtil.isEmpty(userTodoList)){
List<ProcessTaskVo> userTodoList = processTaskService.getUserTodoList(param.getProcessDefId(), String.valueOf(userId));
if (CollUtil.isEmpty(userTodoList)) {
return PageVo.empty();
}
List<String> instCodes = userTodoList.stream().map(ProcessTaskVo::getInstanceId).collect(Collectors.toList());
@@ -112,16 +109,16 @@ public class TodoCenterManage {
//2.再分页查询项目信息
ProjectListReq projectListReq = new ProjectListReq();
projectListReq.setInstCodes(instCodes);
BeanUtils.copyProperties(param,projectListReq);
BeanUtils.copyProperties(param, projectListReq);
PageVo<ProjectLibListItemVO> projectPage = projectLibManage.projectLibList(projectListReq);

if(0L == projectPage.getTotal()){
if (0L == projectPage.getTotal()) {
return PageVo.empty();
}

List<HistoricProcessInstance> instances = historyService.createHistoricProcessInstanceQuery()
.list();
Map<String,HistoricProcessInstance> instanceMap = CollUtils.listToMap(instances,HistoricProcessInstance::getId);
Map<String, HistoricProcessInstance> instanceMap = CollUtils.listToMap(instances, HistoricProcessInstance::getId);

List<ResToBeProcessedVO> resVos = projectPage.getRecords().stream().map(d -> {
ResToBeProcessedVO res = new ResToBeProcessedVO();
@@ -129,7 +126,7 @@ public class TodoCenterManage {
res.setProjectId(d.getId());
ProcessTaskVo taskVo = taskVoMap.get(d.getInstCode());
res.setNodeId(taskVo.getTaskDefKey());
if(instanceMap.containsKey(d.getInstCode())){
if (instanceMap.containsKey(d.getInstCode())) {
res.setProcessStatusName(processInstanceService
.buildProcessStatusStr(instanceMap.get(d.getInstCode())));
}
@@ -156,13 +153,13 @@ public class TodoCenterManage {

//因为要解耦 不能把项目和工作流一起查
//1.先查出用户工作流
List<ProcessTaskVo> userTodoList = processTaskService.getUserTodoList(param.getProcessDefId(),String.valueOf(userId));
List<ProcessTaskVo> userTodoList = processTaskService.getUserTodoList(param.getProcessDefId(), String.valueOf(userId));
List<String> instCodes = userTodoList.stream().map(ProcessTaskVo::getInstanceId).collect(Collectors.toList());

//2.再查询项目信息
ProjectListReq projectListReq = new ProjectListReq();
projectListReq.setInstCodes(instCodes);
BeanUtils.copyProperties(param,projectListReq);
BeanUtils.copyProperties(param, projectListReq);
List<Project> projects = CollUtil.isEmpty(userTodoList) ? Collections.emptyList() : projectLibManage.projectList(projectListReq);
PageVo<ProjectLibListItemVO> projectLibList = projectLibManage.projectLibList(projectListReq);

@@ -207,7 +204,7 @@ public class TodoCenterManage {
// 获取当前申报项目
Project declaredProject = projectService.getOne(Wrappers.lambdaQuery(Project.class)
.eq(Project::getInstCode, processInstanceId)
.eq(Project::getId,projectId));
.eq(Project::getId, projectId));
VUtils.isTrue(Objects.isNull(projectId)).throwMessage("获取项目ID失败!");
// 获取当前项目名称
String projectName = declaredProject.getProjectName();
@@ -244,12 +241,12 @@ public class TodoCenterManage {
ProgressNode currentNode = newProgressInfo.get(newProgressInfo.size() - 1);
UserInfo auditUserInfo = null;
// 说明当前节点是子流程节点
if (currentNode.getNodeType().name().equals(NodeTypeEnum.SUB.name())){
if (currentNode.getNodeType().name().equals(NodeTypeEnum.SUB.name())) {
List<ProgressNode> children = currentNode.getChildren();
// 获取子流程当前审核人节点
ProgressNode subCurrentNode = children.get(children.size() - 1);
auditUserInfo = userInfoService.getById(Long.valueOf(subCurrentNode.getUserId()));
}else {
} else {
auditUserInfo = userInfoService.getById(Long.valueOf(currentNode.getUserId()));
}

@@ -271,13 +268,13 @@ public class TodoCenterManage {
switch (Objects.requireNonNull(ProjectStatusEnum.getValue(projectStatus))) {
// 当前项目状态是单位内部审核中
case UNDER_INTERNAL_AUDIT:
// 当前项目状态是预审中
// 当前项目状态是预审中
case PRE_APPLYING:
// 当前项目状态是部门联审中
// 当前项目状态是部门联审中
case DEPARTMENT_JOINT_REVIEW:
// 当前项目状态是方案评审中
// 当前项目状态是方案评审中
case SCHEME_UNDER_REVIEW:
// 当前项目状态是终验审核中
// 当前项目状态是终验审核中
case FINAL_ACCEPTANCE_IS_UNDER_REVIEW:
updatePassProjectStatus(userId, declaredProject);
break;
@@ -290,11 +287,11 @@ public class TodoCenterManage {
passWorkNoticeInfo2.setMsg(passMsg2);
// 放入工作通知暂存表中,通过扫表异步发送
workNoticeStagingService.addByWorkNotice(passWorkNoticeInfo2, MsgTypeEnum.PASS);
}else {
} else {
// 若有下一个审核人(当前节点的用户),
// 向其发送浙政钉工作通知:标题:审核任务 内容:【单位名称】的【项目名称】需要您审核。
// 获取发送浙政钉工作通知必要信息
if (Objects.isNull(auditUserInfo)){
if (Objects.isNull(auditUserInfo)) {
throw new BizException("审核人信息不存在!");
}
WorkNoticeInfo sendWorkNoticeInfo = getSendWorkNoticeInfo(auditUserInfo);
@@ -339,7 +336,7 @@ public class TodoCenterManage {
// 撤回(流程发起人和当前流程审核人的前一个审核人操作)
case WITHDRAW:
// 当前登录用户是流程发起人
if (userId.equals(Long.valueOf(startUserId))){
if (userId.equals(Long.valueOf(startUserId))) {
processTaskService.handleTask(param, userId);
// 若是流程发起人点击撤回,项目回到上一个状态,需调用状态机更新项目状态,流程状态更新为审核通过
switch (Objects.requireNonNull(ProjectStatusEnum.getValue(projectStatus))) {
@@ -358,7 +355,7 @@ public class TodoCenterManage {
default:
throw new IllegalStateException("Unexpected value: " + projectStatus);
}
}else {
} else {
// 当前登录用户不是流程发起人
List<ProgressNode> currentProgressInfo = currentInstanceDetail.getProgressInfo();
// 获取当前工作流任务前一个审核人信息
@@ -369,12 +366,12 @@ public class TodoCenterManage {
ProcessInstanceUserDto currentUser = currentProgressNode.getUser();
// 判断当前工作流任务前一个审核人的部门和当前登录用户的部门是否是同一个,如果是同一个才可以撤回,否则抛出异常
boolean orgFlag = currentUser.getOrgCode().equals(beforeUser.getOrgCode());
boolean userFlag = beforeUser.getUserId().equals(String.valueOf( userId));
boolean userFlag = beforeUser.getUserId().equals(String.valueOf(userId));
if (!orgFlag) {
throw new BizException("下一个审核人和您不是同一个部门,无法撤回!");
} else if (!userFlag){
} else if (!userFlag) {
throw new BizException("当前登录用户无法进行撤回操作!");
} else{
} else {
processTaskService.handleTask(param, userId);
}
}
@@ -412,6 +409,7 @@ public class TodoCenterManage {

/**
* 获取发送浙政钉工作通知的信息
*
* @param auditUserInfo
* @return com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo
* @author CMM
@@ -420,7 +418,7 @@ public class TodoCenterManage {
public WorkNoticeInfo getSendWorkNoticeInfo(UserInfo auditUserInfo) {
WorkNoticeInfo workNoticeInfo = new WorkNoticeInfo();
Long accountId = auditUserInfo.getAccountId();
if (Objects.isNull(accountId)){
if (Objects.isNull(accountId)) {
throw new BizException("该用户没有录入浙政钉信息!");
}
workNoticeInfo.setAccountId(accountId);
@@ -436,12 +434,13 @@ public class TodoCenterManage {
workNoticeInfo.setOrganizationName(organizationName);
// 构建唯一的消息ID
String bizMsgId = "ZD_WORK_NOTICE_" + StrUtil.UNDERLINE + organizationCode + StrUtil.UNDERLINE
+ organizationName + accountId + StrUtil.UNDERLINE + System.currentTimeMillis();
+ organizationName + accountId + StrUtil.UNDERLINE + System.currentTimeMillis();
workNoticeInfo.setBizMsgId(bizMsgId);
String receiverUserId = String.valueOf(accountId);
workNoticeInfo.setReceiverUserId(receiverUserId);
return workNoticeInfo;
}

/**
* 当为通过操作时,更新项目表中项目状态
*
@@ -497,6 +496,7 @@ public class TodoCenterManage {
return rootUserId;

}

/**
* 获取当前节点的下一个节点的审核用户ID
*
@@ -571,18 +571,18 @@ public class TodoCenterManage {

Set<String> userSet = Sets.newHashSet();
progressInfo.forEach(node -> {
if(CollUtil.isNotEmpty(node.getChildren())){
for(ProgressNode innerNode : node.getChildren()){
if (CollUtil.isNotEmpty(node.getChildren())) {
for (ProgressNode innerNode : node.getChildren()) {
userSet.add(innerNode.getUserId());
}
}else{
} else {
userSet.add(node.getUserId());
}
});
Map<String, ProcessInstanceUserDto> userMap = userInfoService.getUserMapByIds(userSet);

// 装配节点审核人员信息
buildUser(progressInfo,userMap);
buildUser(progressInfo, userMap);

ProcessProgressDetailVo res = new ProcessProgressDetailVo();
res.setProcessProgressVo(progressInstanceDetail);
@@ -591,11 +591,11 @@ public class TodoCenterManage {
return res;
}

private void buildUser(List<ProgressNode> progressInfo,Map<String, ProcessInstanceUserDto> userMap) {
private void buildUser(List<ProgressNode> progressInfo, Map<String, ProcessInstanceUserDto> userMap) {
for (ProgressNode progressNode : progressInfo) {
progressNode.setUser(userMap.get(progressNode.getUserId()));
if(CollUtil.isNotEmpty(progressNode.getChildren())){
buildUser(progressNode.getChildren(),userMap);
if (CollUtil.isNotEmpty(progressNode.getChildren())) {
buildUser(progressNode.getChildren(), userMap);
}
}
}
@@ -612,8 +612,8 @@ public class TodoCenterManage {
Long userId = LoginUserUtil.getUserId();

// 查出用户已处理工作流
List<ProcessTaskVo> userIdoList = processTaskService.getUserIdoList(param.getProcessDefId(),String.valueOf(userId));
if(CollUtil.isEmpty(userIdoList)){
List<ProcessTaskVo> userIdoList = processTaskService.getUserIdoList(param.getProcessDefId(), String.valueOf(userId));
if (CollUtil.isEmpty(userIdoList)) {
return PageVo.empty();
}
List<String> instCodes = userIdoList.stream().map(ProcessTaskVo::getInstanceId).collect(Collectors.toList());
@@ -622,7 +622,7 @@ public class TodoCenterManage {
// 分页查询项目信息
ProjectListReq projectListReq = new ProjectListReq();
projectListReq.setInstCodes(instCodes);
BeanUtils.copyProperties(param,projectListReq);
BeanUtils.copyProperties(param, projectListReq);

PageVo<ProjectLibListItemVO> projectPage = projectLibManage.projectLibList(projectListReq);
if (0L == projectPage.getTotal()) {
@@ -637,7 +637,7 @@ public class TodoCenterManage {
res.setProcessHandleTime(d.getUpdateOn());
return res;
}).collect(Collectors.toList());
return PageVo.of(resVos,projectPage.getTotal());
return PageVo.of(resVos, projectPage.getTotal());
}

/**
@@ -704,12 +704,12 @@ public class TodoCenterManage {
public PageVo<ResToBeProcessedVO> mySubmittedList(ToBeProcessedReq param) {

// 获取登录用户ID
Long startUserId = LoginUserUtil.getUserId();
Long startUserId = LoginUserUtil.getUserId();
// 查出登录用户已提交工作流
List<ProcessInstanceVo> userSubmittedList = processInstanceService.getUserSubmittedList(String.valueOf(startUserId), param.getProcessDefId(), null);
Map<String, ProcessInstanceVo> instanceVoMap = userSubmittedList.stream()
.collect(Collectors.toMap(ProcessInstanceVo::getInstanceId, v -> v));
if(CollUtil.isEmpty(userSubmittedList)){
if (CollUtil.isEmpty(userSubmittedList)) {
return PageVo.empty();
}
List<String> instCodes = userSubmittedList.stream().map(ProcessInstanceVo::getInstanceId).collect(Collectors.toList());
@@ -717,7 +717,7 @@ public class TodoCenterManage {
// 分页查询项目信息
ProjectListReq projectListReq = new ProjectListReq();
projectListReq.setInstCodes(instCodes);
BeanUtils.copyProperties(param,projectListReq);
BeanUtils.copyProperties(param, projectListReq);

PageVo<ProjectLibListItemVO> projectPage = projectLibManage.projectLibList(projectListReq);
if (0L == projectPage.getTotal()) {
@@ -733,7 +733,7 @@ public class TodoCenterManage {
res.setProcessLaunchTime(d.getCreateOn());
return res;
}).collect(Collectors.toList());
return PageVo.of(resVos,projectPage.getTotal());
return PageVo.of(resVos, projectPage.getTotal());
}

/**
@@ -748,7 +748,7 @@ public class TodoCenterManage {
public void exportMySubmittedList(HttpServletResponse response, ToBeProcessedExportReq param) {

// 获取登录用户ID
long userId = LoginUserUtil.getUserId();
long userId = LoginUserUtil.getUserId();

param.setPageNumber(CommonConst.EXPORT_PAGE_NUMBER);
param.setPageSize(CommonConst.EXPORT_PAGE_SIZE);
@@ -761,7 +761,8 @@ public class TodoCenterManage {
projectListReq.setInstCodes(instCodes);
BeanUtils.copyProperties(param, projectListReq);
List<Project> projects = CollUtil.isEmpty(userSubmittedList) ? Collections.emptyList() :
projectLibManage.projectList(projectListReq);projectLibManage.projectList(projectListReq);
projectLibManage.projectList(projectListReq);
projectLibManage.projectList(projectListReq);

ExcelExportWriter excelExportWriter = new ExcelExportWriter();

@@ -799,11 +800,11 @@ public class TodoCenterManage {
*/
public PageVo<ResToBeProcessedVO> ccmeList(ToBeProcessedReq param) {
// 获取当前登录用户ID
Long userId = LoginUserUtil.getUserId();
Long userId = LoginUserUtil.getUserId();

// 查询抄送登录用户的工作流
List<ProcessInstanceVo> ccMeList = processInstanceService.getCcMeList(param.getProcessDefId(), String.valueOf(userId));
if(CollUtil.isEmpty(ccMeList)){
if (CollUtil.isEmpty(ccMeList)) {
return PageVo.empty();
}
List<String> instCodes = ccMeList.stream().map(ProcessInstanceVo::getInstanceId).collect(Collectors.toList());
@@ -813,7 +814,7 @@ public class TodoCenterManage {
// 分页查询项目信息
ProjectListReq projectListReq = new ProjectListReq();
projectListReq.setInstCodes(instCodes);
BeanUtils.copyProperties(param,projectListReq);
BeanUtils.copyProperties(param, projectListReq);

PageVo<ProjectLibListItemVO> projectPage = projectLibManage.projectLibList(projectListReq);
if (0L == projectPage.getTotal()) {
@@ -830,7 +831,7 @@ public class TodoCenterManage {
res.setProcessLaunchTime(d.getCreateOn());
return res;
}).collect(Collectors.toList());
return PageVo.of(resVos,projectPage.getTotal());
return PageVo.of(resVos, projectPage.getTotal());
}

/**


正在加载...
取消
保存