Browse Source

流程处理-通过功能

master
CMM 1 year ago
parent
commit
4bb7f46e54
7 changed files with 361 additions and 80 deletions
  1. +10
    -10
      pmapi/src/main/java/com/ningdatech/pmapi/common/statemachine/event/ProjectStatusChangeEvent.java
  2. +3
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/entity/ProcessComment.java
  3. +23
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/controller/TodoCenterController.java
  4. +104
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/extension/cmd/SaveCommentCmd.java
  5. +179
    -68
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java
  6. +1
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/req/ReqProcessHandlerDTO.java
  7. +41
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/res/ResCcMeExportDTO.java

+ 10
- 10
pmapi/src/main/java/com/ningdatech/pmapi/common/statemachine/event/ProjectStatusChangeEvent.java View File

@@ -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),
/**
* 年度计划暂缓(项目状态变为:被暂缓)
*/


+ 3
- 2
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/entity/ProcessComment.java View File

@@ -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;
}


+ 23
- 0
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/controller/TodoCenterController.java View File

@@ -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);
}


}

+ 104
- 0
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/extension/cmd/SaveCommentCmd.java View File

@@ -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";
}
}

+ 179
- 68
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java View File

@@ -34,12 +34,10 @@ 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;
@@ -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,30 @@ 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);
// 盖章并通过
case SEAL_PASS:
formService.updateInstanceFormData(param.getInstanceId(), formData);
doSealPass(task, param);
doSealPass(task, userId, param);
// 驳回
case REJECT:
formService.updateInstanceFormData(param.getInstanceId(), formData);
doReject(task, param);
doReject(task, userId, param);
break;
// 退回
case BACK:
@@ -273,7 +274,7 @@ public class TodoCenterManage {
break;
// 撤回
case WITHDRAW:
doWithDrawProcess(task);
doWithDrawProcess(task,userId);
break;
default:
throw new IllegalStateException("Unexpected value: " + param.getAction());
@@ -282,16 +283,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 +356,88 @@ 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);
// 保存审核意见
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);
////获取流程定义
//Process process = ProcessDefinitionUtil.getProcess(task.getProcessDefinitionId());
//// 获取当前节点
//FlowNode currentNode = (FlowNode) process.getFlowElement(task.getTaskDefinitionKey(), true);

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

// 获取流程下一个节点浙政钉用户ID
String nextUserId = getNextUserId(currentNode);
String nextUserId = getNextUserId(currentNode,processInstanceId);
// 若有下一个审核人,向其发送浙政钉工作通知:标题:审核任务 内容:【单位名称】的【项目名称】需要您审核。
if (Objects.nonNull(nextUserId)){
UserInfo auditUserInfo = userInfoService.getById(Long.valueOf(nextUserId));
// UserInfo auditUserInfo = userInfoService.getById(Long.valueOf(nextUserId));
// TODO 向其发送浙政钉工作通知
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) process.getFlowElement("root", true);
// 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();
// 根据当前状态获取对应的通过事件
@@ -474,12 +501,14 @@ public class TodoCenterManage {

/**
* 获取当前节点的下一个节点的浙政钉用户ID
* @param currentNode 当前节点
*
* @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,9 +516,25 @@ public class TodoCenterManage {
for (SequenceFlow currentOutgoingFlow : outgoingFlows) {
// 类型自己判断
FlowElement targetFlowElement = currentOutgoingFlow.getTargetFlowElement();
// 如果下个审批节点为结束节点,那么跳过该节点
if (targetFlowElement instanceof EndEvent){
continue;
}
// TODO 若要会签需判断候选人
// 用户任务
if (targetFlowElement instanceof UserTask) {
String name = targetFlowElement.getName();
String extensionId = ((UserTask) targetFlowElement).getExtensionId();
//自定义sql查询所有已办的任务
String nativeSql = "SELECT arv.TEXT_\n" +
"FROM ACT_RU_VARIABLE AS arv \n" +
"WHERE arv.NAME_ = " + name +
"AND arv.PROC_INST_ID_ = " + processInstanceId +
"AND arv.EXECUTION_ID_ = " + extensionId;
NativeHistoricVariableInstanceQuery query = historyService.createNativeHistoricVariableInstanceQuery().sql(nativeSql);
List<HistoricVariableInstance> list = query.list();
HistoricVariableInstance historicVariableInstance = list.get(0);
String variable = runtimeService.getVariable(extensionId, name, String.class);
UserTask userTask = (UserTask) targetFlowElement;
nextUserId = userTask.getAssignee();
break;
@@ -498,21 +543,6 @@ public class TodoCenterManage {
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 +592,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 +604,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 +647,7 @@ public class TodoCenterManage {

/**
* 当为撤回操作时,更新项目表中的项目状态为前一个状态
* @param task
* @param task 当前任务
* @param userId
* @return void
* @author CMM
@@ -651,8 +681,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 +710,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();
@@ -942,7 +974,7 @@ public class TodoCenterManage {
.sheet(fileName)
.doWrite(collect);
} catch (IOException e) {
throw new RuntimeException(e);
throw new BizException("导出失败!");
}
}

@@ -1085,8 +1117,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("导出失败!");
}
}
}

+ 1
- 0
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/req/ReqProcessHandlerDTO.java View File

@@ -1,4 +1,5 @@
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;


+ 41
- 0
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/res/ResCcMeExportDTO.java View File

@@ -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;
}

Loading…
Cancel
Save