소스 검색

Merge remote-tracking branch 'origin/master'

tags/24080901
liuxinxin 1 년 전
부모
커밋
d6f9bc801e
14개의 변경된 파일375개의 추가작업 그리고 237개의 파일을 삭제
  1. +10
    -10
      pmapi/src/main/java/com/ningdatech/pmapi/common/statemachine/event/ProjectStatusChangeEvent.java
  2. +2
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/ding/task/OrganizationBatchGetTask.java
  3. +4
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/entity/dto/DeclaredProjectDto.java
  4. +6
    -6
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java
  5. +3
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/entity/ProcessComment.java
  6. +1
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/entity/ProgressNode.java
  7. +23
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/controller/TodoCenterController.java
  8. +0
    -97
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/enums/ProcessHandlerEnum.java
  9. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/extension/cmd/BackToHisApprovalNodeCmd.java
  10. +104
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/extension/cmd/SaveCommentCmd.java
  11. +177
    -76
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java
  12. +2
    -42
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/req/ReqProcessHandlerDTO.java
  13. +41
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/res/ResCcMeExportDTO.java
  14. +1
    -1
      pmapi/src/main/resources/application-dev.yml

+ 10
- 10
pmapi/src/main/java/com/ningdatech/pmapi/common/statemachine/event/ProjectStatusChangeEvent.java 파일 보기

@@ -26,43 +26,43 @@ public enum ProjectStatusChangeEvent {
/**
* 项目申报提交(项目状态进入:单位内部审核中)
*/
PROJECT_APPLICATION_SUBMIT(1015,null,null),
PROJECT_APPLICATION_SUBMIT(10015,null,null),
/**
* 单位内部审核驳回(项目状态进入:单位内部审核不通过)
*/
UNDER_INTERNAL_REJECT(null,1001,null),
UNDER_INTERNAL_REJECT(null,10001,null),
/**
* 单位内部审核通过(项目状态进入:待预审)
*/
UNDER_INTERNAL_PASS(1001,null,null),
UNDER_INTERNAL_PASS(10001,null,null),
/**
* 预审申报(项目状态进入:待预审选择,有判断条件:市级项目且申报金额大于1000万项目状态变为:省级部门联审中;否则项目状态变为:预审中)
*/
PRELIMINARY_REVIEW_DECLARE(1003,null,null),
PRELIMINARY_REVIEW_DECLARE(10003,null,null),
/**
* 省级部门联审不通过(项目状态变为:省级部门联审不通过)
*/
PROVINCIAL_DEPARTMENT_REVIEW_REJECT(null,1004,null),
PROVINCIAL_DEPARTMENT_REVIEW_REJECT(null,10004,null),
/**
* 省级部门联审通过(项目状态变为:预审中)
*/
PROVINCIAL_DEPARTMENT_REVIEW_PASS(1004,null,null),
PROVINCIAL_DEPARTMENT_REVIEW_PASS(10004,null,null),
/**
* 预审驳回(项目状态变为:预审不通过)
*/
PRELIMINARY_REVIEW_REJECT(null,1006,null),
PRELIMINARY_REVIEW_REJECT(null,10006,null),
/**
* 预审通过(项目状态变为:部门联审中)
*/
PRELIMINARY_REVIEW_PASS(1006,null,null),
PRELIMINARY_REVIEW_PASS(10006,null,null),
/**
* 部门联审驳回(项目状态变为:部门联审不通过)
*/
DEPARTMENT_UNITED_REVIEW_REJECT(null,1008,null),
DEPARTMENT_UNITED_REVIEW_REJECT(null,10008,null),
/**
* 部门联审通过(项目状态变为:年度计划中)
*/
DEPARTMENT_UNITED_REVIEW_PASS(1008,null,null),
DEPARTMENT_UNITED_REVIEW_PASS(10008,null,null),
/**
* 年度计划暂缓(项目状态变为:被暂缓)
*/


+ 2
- 0
pmapi/src/main/java/com/ningdatech/pmapi/ding/task/OrganizationBatchGetTask.java 파일 보기

@@ -1,3 +1,4 @@

package com.ningdatech.pmapi.ding.task;

import cn.hutool.core.collection.CollUtil;
@@ -160,3 +161,4 @@ public class OrganizationBatchGetTask {
}

}


+ 4
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/entity/dto/DeclaredProjectDto.java 파일 보기

@@ -1,6 +1,7 @@
package com.ningdatech.pmapi.projectdeclared.entity.dto;

import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.wflow.workflow.bean.dto.ProcessInstanceUserDto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -30,4 +31,7 @@ public class DeclaredProjectDto implements Serializable {

@NotBlank
private String regionCode;

@NotNull
private ProcessInstanceUserDto user;
}

+ 6
- 6
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java 파일 보기

@@ -140,12 +140,12 @@ public class DeclaredProjectManage {
}

ProcessStartParamsVo params = new ProcessStartParamsVo();
ProcessInstanceUserDto user = new ProcessInstanceUserDto();
user.setOrgCode("6179678");
user.setOrgName("数转办");
user.setUserId("381496");
user.setUserName("旅人");
params.setUser(user);
// ProcessInstanceUserDto user = new ProcessInstanceUserDto();
// user.setOrgCode("6179678");
// user.setOrgName("数转办");
// user.setUserId("381496");
// user.setUserName("旅人");
params.setUser(dto.getUser());
params.setProcessUsers(Collections.emptyMap());
dto.getFormData().putAll(
JSON.parseObject(JSON.toJSONString(dto.getProjectInfo()), new TypeReference<Map<String, Object>>() {


+ 3
- 2
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/entity/ProcessComment.java 파일 보기

@@ -1,5 +1,6 @@
package com.ningdatech.pmapi.todocenter.bean.entity;

import com.ningdatech.pmapi.common.model.FileBasicInfo;
import com.wflow.workflow.bean.vo.ProcessHandlerParamsVo;
import lombok.AllArgsConstructor;
import lombok.Builder;
@@ -26,9 +27,9 @@ public class ProcessComment {
/**
* 评论附件
*/
protected List<Attachment> attachments;
protected List<FileBasicInfo> attachments;

public ProcessComment(String text, List<Attachment> attachments) {
public ProcessComment(String text, List<FileBasicInfo> attachments) {
this.text = text;
this.attachments = null == attachments ? Collections.emptyList() : attachments;
}


+ 1
- 2
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/entity/ProgressNode.java 파일 보기

@@ -1,11 +1,10 @@
package com.ningdatech.pmapi.todocenter.bean.entity;

import com.ningdatech.pmapi.todocenter.bean.vo.ProgressNodeAuditInfoVo;
import com.ningdatech.pmapi.todocenter.enums.ProcessHandlerEnum;
import com.ningdatech.pmapi.todocenter.model.dto.req.ReqProcessHandlerDTO;
import com.wflow.workflow.bean.process.OrgUser;
import com.wflow.workflow.bean.process.enums.ApprovalModeEnum;
import com.wflow.workflow.bean.process.enums.NodeTypeEnum;
import com.wflow.workflow.enums.ProcessHandlerEnum;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;


+ 23
- 0
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/controller/TodoCenterController.java 파일 보기

@@ -128,5 +128,28 @@ public class TodoCenterController {
ExcelDownUtil.downXlsx(response,param,todoCenterManage::exportMySubmittedProjectList);
}

/**
* 待办中心-抄送我的项目列表查询
* @param param
* @return
*/
@GetMapping("/query-CcMe-list")
public ApiResponse<PageVo<ResToBeProcessedDTO>> queryCcMeProjectList(@Valid @ModelAttribute ReqToBeProcessedDTO param){
PageVo<ResToBeProcessedDTO> result = todoCenterManage.queryCcMeProjectList(param);
return ApiResponse.ofSuccess(result);
}

/**
* 待办中心-抄送我的项目列表导出
*
* @param param
* @param response
* @return void
*/
@GetMapping("/exportCcMe")
public void exportCcMeProjectList(ReqToBeProcessedDTO param, HttpServletResponse response){
ExcelDownUtil.downXlsx(response,param,todoCenterManage::exportCcMeProjectList);
}


}

+ 0
- 97
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/enums/ProcessHandlerEnum.java 파일 보기

@@ -1,97 +0,0 @@
package com.ningdatech.pmapi.todocenter.enums;

import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
* 流程处理类型
* @author CMM
* @since 2023/02/01 16:58
*/
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "ProcessHandlerEnum", description = "流程处理类型-枚举")
public enum ProcessHandlerEnum {
/**
* 通过
*/

PASS(1, "通过"),

/**
* 盖章并通过
*/
SEAL_PASS(2, "盖章并通过"),

/**
* 退回
*/
BACK(3,"退回"),

/**
* 撤回
*/
WITHDRAW(4,"撤回"),
/**
* 驳回
*/
REJECT(5,"驳回");


private Integer code;
private String desc;

public String getDesc() {
return desc;
}

public void setDesc(String desc) {
this.desc = desc;
}

public static String getDescByCode(Integer code) {
if(Objects.isNull(code)){
return StringUtils.EMPTY;
}
for (ProcessHandlerEnum t : ProcessHandlerEnum.values()) {
if (code.equals(t.getCode())) {
return t.desc;
}
}
return StringUtils.EMPTY;
}

public static Integer getCodeByDesc(String desc) {
if(Objects.isNull(desc)){
return null;
}
for (ProcessHandlerEnum t : ProcessHandlerEnum.values()) {
if (desc.equals(t.getCode())) {
return t.code;
}
}
return null;
}

public static ProcessHandlerEnum getEnumByValue(Integer code) {
if(Objects.isNull(code)){
return null;
}
for (ProcessHandlerEnum t : ProcessHandlerEnum.values()) {
if (code.equals(t.getCode())) {
return t;
}
}
return null;
}

public boolean eq(String val) {
return this.name().equals(val);
}
}

+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/extension/cmd/BackToHisApprovalNodeCmd.java 파일 보기

@@ -4,7 +4,7 @@ import java.io.Serializable;
import java.util.*;
import java.util.stream.Collectors;

import com.ningdatech.pmapi.todocenter.enums.ProcessHandlerEnum;
import com.wflow.workflow.enums.ProcessHandlerEnum;
import lombok.RequiredArgsConstructor;
import org.assertj.core.util.Sets;
import org.flowable.bpmn.model.FlowNode;


+ 104
- 0
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/extension/cmd/SaveCommentCmd.java 파일 보기

@@ -0,0 +1,104 @@
package com.ningdatech.pmapi.todocenter.extension.cmd;

import org.flowable.common.engine.api.FlowableException;
import org.flowable.common.engine.api.FlowableObjectNotFoundException;
import org.flowable.common.engine.impl.identity.Authentication;
import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.engine.compatibility.Flowable5CompatibilityHandler;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.persistence.entity.CommentEntity;
import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
import org.flowable.engine.impl.util.CommandContextUtil;
import org.flowable.engine.impl.util.Flowable5Util;
import org.flowable.engine.runtime.Execution;
import org.flowable.engine.task.Comment;
import org.flowable.task.api.Task;
import org.flowable.task.service.impl.persistence.entity.TaskEntity;

/**
* 保存评论
*
* @author CMM
* @since 2023/02/09 11:43
*/

public class SaveCommentCmd implements Command<Comment> {

protected String taskId;
protected String processInstanceId;
protected String userId;
protected String message;
protected String type;


public SaveCommentCmd(String taskId, String processInstanceId, String userId , String message) {
this.taskId = taskId;
this.processInstanceId = processInstanceId;
this.userId = userId;
this.message = message;
}

@Override
public Comment execute(CommandContext commandContext) {
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);
TaskEntity task = null;
if (this.taskId != null) {
task = processEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(this.taskId);
if (task == null) {
throw new FlowableObjectNotFoundException("Cannot find task with id " + this.taskId, Task.class);
}

if (task.isSuspended()) {
throw new FlowableException(this.getSuspendedTaskException());
}
}

ExecutionEntity execution = null;
if (this.processInstanceId != null) {
execution = (ExecutionEntity)processEngineConfiguration.getExecutionEntityManager().findById(this.processInstanceId);
if (execution == null) {
throw new FlowableObjectNotFoundException("execution " + this.processInstanceId + " doesn't exist", Execution.class);
}

if (execution.isSuspended()) {
throw new FlowableException(this.getSuspendedExceptionMessage());
}
}

String processDefinitionId = null;
if (execution != null) {
processDefinitionId = execution.getProcessDefinitionId();
} else if (task != null) {
processDefinitionId = task.getProcessDefinitionId();
}

if (Flowable5Util.isFlowable5ProcessDefinitionId(commandContext, processDefinitionId)) {
Flowable5CompatibilityHandler compatibilityHandler = Flowable5Util.getFlowable5CompatibilityHandler();
return compatibilityHandler.addComment(this.taskId, this.processInstanceId, this.type, this.message);
} else {
CommentEntity comment = (CommentEntity)processEngineConfiguration.getCommentEntityManager().create();
comment.setUserId(userId);
comment.setType(this.type == null ? "comment" : this.type);
comment.setTime(processEngineConfiguration.getClock().getCurrentTime());
comment.setTaskId(this.taskId);
comment.setProcessInstanceId(this.processInstanceId);
comment.setAction("AddComment");
String eventMessage = this.message.replaceAll("\\s+", " ");
if (eventMessage.length() > 163) {
eventMessage = eventMessage.substring(0, 160) + "...";
}

comment.setMessage(eventMessage);
comment.setFullMessage(this.message);
processEngineConfiguration.getCommentEntityManager().insert(comment);
return comment;
}
}
protected String getSuspendedTaskException() {
return "Cannot add a comment to a suspended task";
}
protected String getSuspendedExceptionMessage() {
return "Cannot add a comment to a suspended execution";
}
}

+ 177
- 76
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java 파일 보기

@@ -19,7 +19,6 @@ import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.basic.util.NdDateUtils;
import com.ningdatech.pmapi.common.constant.DingConstant;
import com.ningdatech.pmapi.common.constant.ProjectDeclareConstants;
import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils;
import com.ningdatech.pmapi.common.util.ExcelDownUtil;
import com.ningdatech.pmapi.common.util.ExcelExportStyle;
@@ -31,15 +30,12 @@ import com.ningdatech.pmapi.todocenter.bean.entity.ProgressNode;
import com.ningdatech.pmapi.todocenter.bean.vo.ProcessProgressDetailVo;
import com.ningdatech.pmapi.todocenter.constant.HisProInsEndActId;
import com.ningdatech.pmapi.todocenter.enums.IsAppendProjectEnum;
import com.ningdatech.pmapi.todocenter.enums.ProcessHandlerEnum;
import com.ningdatech.pmapi.todocenter.enums.ProcessStatusEnum;
import com.ningdatech.pmapi.todocenter.extension.cmd.BackToHisApprovalNodeCmd;
import com.ningdatech.pmapi.todocenter.extension.cmd.SaveCommentCmd;
import com.ningdatech.pmapi.todocenter.model.dto.req.ReqProcessHandlerDTO;
import com.ningdatech.pmapi.todocenter.model.dto.req.ReqToBeProcessedDTO;
import com.ningdatech.pmapi.todocenter.model.dto.res.ResHandledExportDTO;
import com.ningdatech.pmapi.todocenter.model.dto.res.ResMySubmittedExportDTO;
import com.ningdatech.pmapi.todocenter.model.dto.res.ResToBeProcessedDTO;
import com.ningdatech.pmapi.todocenter.model.dto.res.ResToBeExportDTO;
import com.ningdatech.pmapi.todocenter.model.dto.res.*;
import com.ningdatech.pmapi.todocenter.zwdd.model.MessageContent;
import com.ningdatech.pmapi.todocenter.zwdd.model.MessageText;
import com.ningdatech.pmapi.user.entity.UserInfo;
@@ -53,6 +49,7 @@ import com.wflow.exception.BusinessException;
import com.wflow.mapper.WflowCcTasksMapper;
import com.wflow.mapper.WflowModelHistorysMapper;
import com.wflow.service.OrgRepositoryService;
import com.wflow.utils.CodeUtil;
import com.wflow.workflow.bean.dto.ProcessInstanceUserDto;
import com.wflow.workflow.bean.process.OrgUser;
import com.wflow.workflow.bean.process.ProcessNode;
@@ -62,9 +59,9 @@ import com.wflow.workflow.bean.process.form.Form;
import com.wflow.workflow.bean.process.props.ApprovalProps;
import com.wflow.workflow.bean.vo.ProcessHandlerParamsVo;
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.config.WflowGlobalVarDef;
import com.wflow.workflow.enums.ProcessHandlerEnum;
import com.wflow.workflow.service.FormService;
import com.wflow.workflow.service.*;
import com.wflow.workflow.utils.Executor;
@@ -78,6 +75,7 @@ import org.flowable.engine.history.HistoricActivityInstance;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.history.HistoricProcessInstanceQuery;
import org.flowable.engine.impl.util.ProcessDefinitionUtil;
import org.flowable.engine.runtime.ActivityInstance;
import org.flowable.engine.runtime.Execution;
import org.flowable.task.api.Task;
import org.flowable.task.api.TaskInfo;
@@ -85,6 +83,7 @@ import org.flowable.task.api.TaskQuery;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.service.history.NativeHistoricTaskInstanceQuery;
import org.flowable.variable.api.history.HistoricVariableInstance;
import org.flowable.variable.api.history.NativeHistoricVariableInstanceQuery;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

@@ -232,7 +231,7 @@ public class TodoCenterManage {
.sheet(fileName)
.doWrite(collect);
} catch (IOException e) {
throw new RuntimeException(e);
throw new BizException("导出失败!");
}
}
/**
@@ -243,28 +242,32 @@ public class TodoCenterManage {
* @since 2023/02/01 17:43
*/
public void handler(ReqProcessHandlerDTO param) {
Long userId = LoginUserUtil.getUserId();

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

Long userId = 381496L;

Task task = taskService.createTaskQuery().taskId(param.getTaskId()).active().singleResult();
HashMap<String, Object> formData = new HashMap<>(32);
if (Objects.isNull(task)) {
throw new BizException("任务不存在");
}
if (hasComment(param.getAuditInfo())) {
taskService.addComment(param.getTaskId(), param.getInstanceId(), JSONObject.toJSONString(param.getAuditInfo()));
}
switch (param.getAction()) {
// 通过
case PASS:
formService.updateInstanceFormData(param.getInstanceId(), formData);
doPass(task, param);
doPass(task, userId, param);
break;
// 盖章并通过
case SEAL_PASS:
formService.updateInstanceFormData(param.getInstanceId(), formData);
doSealPass(task, param);
doSealPass(task, userId, param);
break;
// 驳回
case REJECT:
formService.updateInstanceFormData(param.getInstanceId(), formData);
doReject(task, param);
doReject(task, userId, param);
break;
// 退回
case BACK:
@@ -273,7 +276,7 @@ public class TodoCenterManage {
break;
// 撤回
case WITHDRAW:
doWithDrawProcess(task);
doWithDrawProcess(task,userId);
break;
default:
throw new IllegalStateException("Unexpected value: " + param.getAction());
@@ -282,16 +285,22 @@ public class TodoCenterManage {

/**
* 审批任务:驳回
*
* @param task 当前任务
* @param param 参数
* @param userId
* @param param 参数
*/
private void doReject(Task task, ReqProcessHandlerDTO param) {
private void doReject(Task task, Long userId, ReqProcessHandlerDTO param) {
// 获取当前申报项目
Project declaredProject = projectService.getOne(Wrappers.lambdaQuery(Project.class)
.eq(Project::getInstCode, task.getProcessInstanceId()));
String projectName = declaredProject.getProjectName();

Map<String, Object> var = new HashMap<>(16);
var.put("approve_" + task.getId(), param.getAction());
// TODO 中止流程并使项目进入对应状态,给项目创建人、流程发起人发送浙政钉工作通知:【项目名称】的【流程名称】被驳回,请及时处理。
//获取流程定义
Process process = ProcessDefinitionUtil.getProcess(task.getProcessDefinitionId());
String projectName = getProjectName(task);
// 获取根节点即流程发起节点
FlowNode rootNode = (FlowNode) process.getFlowElement("root", true);
// TODO 中止流程并使项目进入对应状态,给项目创建人、流程发起人发送浙政钉工作通知:【项目名称】的【流程名称】被驳回,请及时处理。
@@ -349,68 +358,83 @@ public class TodoCenterManage {

/**
* 审批任务:盖章并通过
*
* @param task 当前任务
* @param param 参数
* @param userId
* @param param 参数
*/
private void doSealPass(Task task, ReqProcessHandlerDTO param) {
private void doSealPass(Task task, Long userId, ReqProcessHandlerDTO param) {
Map<String, Object> var = new HashMap<>(16);
var.put("approve_" + task.getId(), param.getAction());

// TODO 判断项目申报单位级别,区县单位申报有上级主管单位意见栏,市级单位没有

// TODO 市级单位:为大数据局;区县单位:为大数据中心(根据附件区分?)

// 获取当前申报项目
Project declaredProject = projectService.getOne(Wrappers.lambdaQuery(Project.class)
.eq(Project::getInstCode, task.getProcessInstanceId()));
// 更新项目状态到下一个状态
updatePassProjectStatus(task);
updatePassProjectStatus(task, userId, declaredProject);
taskService.complete(param.getTaskId(), var);
}

/**
* 审批任务:通过
*
* @param task 当前任务
* @param param 参数
* @param userId
* @param param 参数
*/
private void doPass(Task task, ReqProcessHandlerDTO param) {
private void doPass(Task task, Long userId, ReqProcessHandlerDTO param) {
String processInstanceId = task.getProcessInstanceId();
// 获取当前申报项目
Project declaredProject = projectService.getOne(Wrappers.lambdaQuery(Project.class)
.eq(Project::getInstCode, task.getProcessInstanceId()));
String projectName = declaredProject.getProjectName();

String projectName = getProjectName(task);
Map<String, Object> var = new HashMap<>(16);
var.put("approve_" + task.getId(), param.getAction());
//获取流程定义
Process process = ProcessDefinitionUtil.getProcess(task.getProcessDefinitionId());
// 获取当前节点
FlowNode currentNode = (FlowNode) process.getFlowElement(task.getTaskDefinitionKey(), true);
// 获取流程下一个节点浙政钉用户ID
String nextUserId = getNextUserId(currentNode);
// 保存审核意见
if (hasComment(param.getAuditInfo())) {
//执行自定义的保存评论的功能
managementService.executeCommand(new SaveCommentCmd(param.getTaskId(),param.getInstanceId(),String.valueOf(userId),JSONObject.toJSONString(param.getAuditInfo())));
}
updatePassProjectStatus(task,userId,declaredProject);
taskService.complete(param.getTaskId(), var);

// 获取bpm对象
BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
//传节点定义key 获取当前节点
FlowNode currentNode = (FlowNode) bpmnModel.getFlowElement(task.getTaskDefinitionKey());

// 获取流程下一个节点的审核用户ID
String nextUserId = getNextUserId(currentNode,processInstanceId);
// 若有下一个审核人,向其发送浙政钉工作通知:标题:审核任务 内容:【单位名称】的【项目名称】需要您审核。
if (Objects.nonNull(nextUserId)){
UserInfo auditUserInfo = userInfoService.getById(Long.valueOf(nextUserId));
// TODO 向其发送浙政钉工作通知
// TODO 获取浙政钉用户dingKey,向其发送浙政钉工作通知
String msg = String.format(PASS_MSG_TEMPLATE,null,projectName);
sendWorkNotice(auditUserInfo,msg);
// sendWorkNotice(auditUserInfo,msg);
}else {
// 若没有,向发起人发送浙政钉工作通知:【项目名称】已通过【流程名称】,请及时开始下一步操作。
// TODO 向其发送浙政钉工作通知 获取根节点的孩子节点(即发起人节点),向其发送浙政钉工作通知
// 获取根节点即流程发起节点
FlowNode rootNode = (FlowNode) process.getFlowElement("root", true);
sendWorkNoticeToStartUser(task, projectName, rootNode);
FlowNode rootNode = (FlowNode) bpmnModel.getFlowElement("root");
// sendWorkNoticeToStartUser(task, projectName, rootNode);
}

updatePassProjectStatus(task);
taskService.complete(param.getTaskId(), var);
}

/**
* 当为通过操作时,更新项目表中项目状态
* @param task 当前任务
*
* @param task 当前任务
* @param userId
* @param declaredProject
* @return void
* @author CMM
* @since 2023/02/08 20:38
*/
private void updatePassProjectStatus(Task task) {
// 获取当前登录用户
Long userId = LoginUserUtil.getUserId();
// 获取当前申报项目
Project declaredProject = projectService.getOne(Wrappers.lambdaQuery(Project.class)
.eq(Project::getInstCode, task.getProcessInstanceId()));
private void updatePassProjectStatus(Task task, Long userId, Project declaredProject) {
// 获取当前流程项目状态
Integer projectStatusSecond = declaredProject.getProjectStatusSecond();
// 根据当前状态获取对应的通过事件
@@ -473,13 +497,15 @@ public class TodoCenterManage {
}

/**
* 获取当前节点的下一个节点的浙政钉用户ID
* @param currentNode 当前节点
* 获取当前节点的下一个节点的审核用户ID
*
* @param currentNode 当前节点
* @param processInstanceId
* @return java.lang.String 下一个节点的浙政钉用户ID
* @author CMM
* @since 2023/02/02 16:49
*/
private String getNextUserId(FlowNode currentNode) {
private String getNextUserId(FlowNode currentNode, String processInstanceId) {
String nextUserId = null;
// 输出连线
List<SequenceFlow> outgoingFlows = currentNode.getOutgoingFlows();
@@ -487,32 +513,25 @@ public class TodoCenterManage {
for (SequenceFlow currentOutgoingFlow : outgoingFlows) {
// 类型自己判断
FlowElement targetFlowElement = currentOutgoingFlow.getTargetFlowElement();
// 如果下个审批节点为结束节点,那么跳过该节点
if (targetFlowElement instanceof EndEvent){
continue;
}
// TODO 若要会签需判断候选人
// 用户任务
if (targetFlowElement instanceof UserTask) {
UserTask userTask = (UserTask) targetFlowElement;
nextUserId = userTask.getAssignee();
String actId = targetFlowElement.getId();
ActivityInstance activityInstance = runtimeService.createActivityInstanceQuery()
.processInstanceId(processInstanceId)
.activityId(actId).singleResult();
String executionId = activityInstance.getExecutionId();
nextUserId = runtimeService.getVariable(executionId, "assignee", String.class);
break;
}
}
return nextUserId;
}
/**
* 获取任务节点的申报项目名称
* @param task 当前任务
* @return java.lang.String 项目名称
* @author CMM
* @since 2023/02/01 17:27
*/
private String getProjectName(Task task) {
String nodeId = task.getTaskDefinitionKey();
String instanceId = task.getProcessInstanceId();
ProcessProgressVo instanceProgress = processService.getInstanceProgress(nodeId, instanceId);
Map<String, Object> formData = instanceProgress.getFormData();
String projectName = (String) formData.get(ProjectDeclareConstants.BasicInformation.PROJECT_NAME);
return projectName;
}
/**
* 判断处理操作是否含有审核意见
* @param comment 审核意见
* @return boolean
@@ -562,9 +581,10 @@ public class TodoCenterManage {
/**
* 撤销流程处理
*
* @param task 当前任务
* @param task 当前任务
* @param userId
*/
private void doWithDrawProcess(Task task) {
private void doWithDrawProcess(Task task, Long userId) {
//获取流程定义
Process process = ProcessDefinitionUtil.getProcess(task.getProcessDefinitionId());
// 获取当前运行流程的发起人节点信息
@@ -573,7 +593,6 @@ public class TodoCenterManage {
FlowNode currentNode = (FlowNode) process.getFlowElement(task.getTaskDefinitionKey(), true);
String rootUserId = getRootUserId(rootNode);
// 判断当前登录用户是否是流程发起人
Long userId = LoginUserUtil.getUserId();
if (rootUserId.equals(String.valueOf(userId))){
// TODO 若是流程发起人点击撤回,项目回到上一个状态,并删除当前审核人对应的待办记录
updateWithdrawProjectStatus(task, userId);
@@ -617,7 +636,7 @@ public class TodoCenterManage {

/**
* 当为撤回操作时,更新项目表中的项目状态为前一个状态
* @param task
* @param task 当前任务
* @param userId
* @return void
* @author CMM
@@ -651,8 +670,10 @@ public class TodoCenterManage {
* @param param 参数
*/
private void doBackTask(Task task, Long userId, ReqProcessHandlerDTO param) {
// 获取项目名称
String projectName = getProjectName(task);
// 获取当前申报项目
Project declaredProject = projectService.getOne(Wrappers.lambdaQuery(Project.class)
.eq(Project::getInstCode, task.getProcessInstanceId()));
String projectName = declaredProject.getProjectName();
//获取流程定义
Process process = ProcessDefinitionUtil.getProcess(task.getProcessDefinitionId());
// 获取根节点即流程发起节点
@@ -678,7 +699,7 @@ public class TodoCenterManage {
HistoricVariableInstance forms = historyService.createHistoricVariableInstanceQuery()
.processInstanceId(instanceId).variableName(WflowGlobalVarDef.WFLOW_FORMS).singleResult();
List<HistoricVariableInstance> formDatas = historyService.createHistoricVariableInstanceQuery()
.processInstanceId(instanceId).variableNameLike("field%").list();
.processInstanceId(instanceId).list();
// 取节点设置
HistoricVariableInstance nodeProps = historyService.createHistoricVariableInstanceQuery()
.processInstanceId(instanceId).variableName(WflowGlobalVarDef.WFLOW_NODE_PROPS).singleResult();
@@ -714,7 +735,8 @@ public class TodoCenterManage {
.result(ProcessHandlerEnum.PASS)
.build());
// 提取全量表单数据
Map<String, Object> formData = formDatas.stream().collect(Collectors.toMap(HistoricVariableInstance::getVariableName, HistoricVariableInstance::getValue));
Map<String, Object> formData = formDatas.stream().filter(CodeUtil.distinctByKey(HistoricVariableInstance::getVariableName)).collect(Collectors.toMap(HistoricVariableInstance::getVariableName,
HistoricVariableInstance::getValue));
HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery()
.processInstanceId(instanceId).variableName("owner").singleResult();
ProcessInstanceUserDto owner = (ProcessInstanceUserDto) variableInstance.getValue();
@@ -942,7 +964,7 @@ public class TodoCenterManage {
.sheet(fileName)
.doWrite(collect);
} catch (IOException e) {
throw new RuntimeException(e);
throw new BizException("导出失败!");
}
}

@@ -1085,8 +1107,87 @@ public class TodoCenterManage {
.sheet(fileName)
.doWrite(collect);
} catch (IOException e) {
throw new RuntimeException(e);
throw new BizException("导出失败!");
}

}

public PageVo<ResToBeProcessedDTO> queryCcMeProjectList(ReqToBeProcessedDTO param) {
// 获取当前登录用户ID
// Long userId = LoginUserUtil.getUserId();

Long userId = 381496L;
Page<Project> page = param.page();
Set<String> staterUsers = new HashSet<>();
List<WflowCcTasks> ccTasks = ccTasksMapper.selectList(Wrappers.lambdaQuery(WflowCcTasks.class)
.eq(WflowCcTasks::getUserId, String.valueOf(userId))
.orderByDesc(WflowCcTasks::getCreateTime));

LambdaQueryWrapper<Project> wrapper = Wrappers.lambdaQuery(Project.class);
wrapper.like(StrUtil.isNotBlank(param.getProjectName()),Project::getProjectName,param.getProjectName())
.like(StrUtil.isNotBlank(param.getBuildUnitName()),Project::getBuildUnitName,param.getBuildUnitName())
.eq(Objects.nonNull(param.getProjectYear()),Project::getProjectYear,param.getProjectYear())
.eq(Objects.nonNull(param.getIsSupplement()),Project::getIsTemporaryAugment,param.getIsSupplement())
.ge(Objects.nonNull(param.getProcessLaunchStartTime()),Project::getBeginTime,param.getProcessLaunchStartTime())
.le(Objects.nonNull(param.getProcessLaunchEndTime()),Project::getEndTime,param.getProcessLaunchEndTime());
projectService.page(page,wrapper);

// 将抄送我的流程实例一次性取出来,减少查询次数
Map<String, HistoricProcessInstance> instanceMap = CollectionUtil.isNotEmpty(ccTasks) ?
historyService.createHistoricProcessInstanceQuery().processInstanceIds(ccTasks.stream()
.map(WflowCcTasks::getInstanceId).collect(Collectors.toSet()))
.list().stream().collect(Collectors.toMap(HistoricProcessInstance::getId, v -> v)) : new HashMap<>();
List<String> processInsIds = ccTasks.stream().map(WflowCcTasks::getInstanceId).collect(Collectors.toList());
List<ResToBeProcessedDTO> resVos = page.getRecords().stream().filter(d -> processInsIds.contains(d.getInstCode())).map(d -> {
ResToBeProcessedDTO res = new ResToBeProcessedDTO();
BeanUtils.copyProperties(d, res);
res.setProcessStatusName(ProcessStatusEnum.getDescByCode(d.getProcessStatus()));
LocalDateTime processLaunchTime = d.getCreateOn();
String launchTimeFormat = NdDateUtils.format(processLaunchTime, "yyyy-MM-dd HH:mm");
LocalDateTime launchTime = LocalDateTime.parse(launchTimeFormat, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
res.setProcessLaunchTime(launchTime);
HistoricProcessInstance ist = instanceMap.get(d.getInstCode());
staterUsers.add(ist.getStartUserId());
ProcessInstanceVo processInstanceVo = getProcessInstanceVos(ist);
res.setProcessInstanceInfo(processInstanceVo);
return res;
}).collect(Collectors.toList());

if (CollectionUtil.isNotEmpty(staterUsers)) {
Map<String, OrgUser> userMap = userDeptOrLeaderService.getUserMapByIds(staterUsers);
resVos.stream().map(v -> {
v.getProcessInstanceInfo().setStaterUser(userMap.get(v.getProcessInstanceInfo().getStaterUserId()));
return v;
}).collect(Collectors.toList());
}

//if (CollectionUtil.isNotEmpty(staterUsers)) {
// Map<Long, UserInfo> userMap = userInfoService.getUserMapByIds(staterUsers);
// resVos.stream().peek(v -> v.setOwner(userMap.get(startUserId)))
// .collect(Collectors.toList());
//}
return PageVo.of(resVos,resVos.size());
}

public void exportCcMeProjectList(HttpServletResponse response, ReqToBeProcessedDTO param) {
PageVo<ResToBeProcessedDTO> page = queryCcMeProjectList(param);
List<ResToBeProcessedDTO> collect = (List<ResToBeProcessedDTO>) page.getRecords();
String fileName = null;
if (IsAppendProjectEnum.APPEND_PROJECT.getCode().equals(param.getIsSupplement())){
fileName = "待办中心_抄送我的_增补项目列表";
}else if (IsAppendProjectEnum.NOT_APPEND_PROJECT.getCode().equals(param.getIsSupplement())){
fileName = "待办中心_抄送我的_非增补项目列表";
}
ExcelDownUtil.setFileName(fileName,response);
//数据导出处理函数
try {
EasyExcel.write(response.getOutputStream(), ResCcMeExportDTO.class)
.autoCloseStream(false)
.registerWriteHandler(ExcelExportStyle.formalStyle())
.sheet(fileName)
.doWrite(collect);
} catch (IOException e) {
throw new BizException("导出失败!");
}
}
}

+ 2
- 42
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/req/ReqProcessHandlerDTO.java 파일 보기

@@ -1,11 +1,10 @@
package com.ningdatech.pmapi.todocenter.model.dto.req;
import com.ningdatech.pmapi.common.model.FileBasicInfo;
import com.ningdatech.pmapi.todocenter.bean.entity.ProcessComment;
import com.ningdatech.pmapi.todocenter.enums.ProcessHandlerEnum;
import com.wflow.workflow.enums.ProcessHandlerEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;

/**
* 流程处理操作参数实体
@@ -47,43 +46,4 @@ public class ReqProcessHandlerDTO {
* 审核信息
*/
private ProcessComment auditInfo;
///**
// * 审核通过意见
// */
//private String auditPassOpinion;
//
///**
// * 审核通过附件
// */
//private FileBasicInfo auditPassAppendix;
///**
// * 盖章通过意见
// */
//private String sealPassOpinion;
//
///**
// * 盖章通过附件
// */
//private FileBasicInfo sealPassAppendix;
///**
// * 审核退回意见
// */
//private String auditBackOpinion;
///**
// * 审核退回附件
// */
//private FileBasicInfo auditBackAppendix;
///**
// * 审核驳回意见
// */
//private String auditRejectOpinion;
//
///**
// * 审核驳回附件
// */
//private FileBasicInfo auditRejectAppendix;
//public enum Action{
// //通过、盖章并通过、退回、撤回、驳回
// pass, seal_pass ,back, withdraw, reject;
//}
}

+ 41
- 0
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/res/ResCcMeExportDTO.java 파일 보기

@@ -0,0 +1,41 @@
package com.ningdatech.pmapi.todocenter.model.dto.res;

import java.io.Serializable;
import java.time.LocalDateTime;

import com.alibaba.excel.annotation.ExcelProperty;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* 待办中心抄送我的项目列表导出实体
*
* @author CMM
* @since 2023/01/19 16:42
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResCcMeExportDTO implements Serializable {
private static final long serialVersionUID = 1L;

@ExcelProperty("项目名称")
private String projectName;

@ExcelProperty("申报单位")
private String reportUnitName;

@ExcelProperty("申报金额")
private Integer reportAmount;

@ExcelProperty("预算年度")
private Integer budgetYear;

@ExcelProperty("流程状态")
private String processStatusName;

@ExcelProperty("发起时间")
private LocalDateTime processLaunchTime;
}

+ 1
- 1
pmapi/src/main/resources/application-dev.yml 파일 보기

@@ -1,5 +1,5 @@
server:
port: 28888
port: 38888
servlet:
context-path: /pm



불러오는 중...
취소
저장