|
|
@@ -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("导出失败!"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |