|
|
@@ -22,34 +22,35 @@ import com.ningdatech.pmapi.common.constant.DingConstant; |
|
|
|
import com.ningdatech.pmapi.common.constant.ProjectDeclareConstants; |
|
|
|
import com.ningdatech.pmapi.common.util.ExcelDownUtil; |
|
|
|
import com.ningdatech.pmapi.common.util.ExcelExportStyle; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.entity.Project; |
|
|
|
import com.ningdatech.pmapi.projectlib.service.IProjectService; |
|
|
|
import com.ningdatech.pmapi.todocenter.bean.entity.ProcessComment; |
|
|
|
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.model.dto.req.ReqProcessHandlerDTO; |
|
|
|
import com.ningdatech.pmapi.todocenter.model.dto.req.ReqToBeProcessedDTO; |
|
|
|
import com.ningdatech.pmapi.todocenter.model.dto.res.ResHandledProjectListExportDTO; |
|
|
|
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.ResToBeProjectListExportDTO; |
|
|
|
import com.ningdatech.pmapi.todocenter.model.dto.res.ResToBeExportDTO; |
|
|
|
import com.ningdatech.pmapi.todocenter.zwdd.model.MessageContent; |
|
|
|
import com.ningdatech.pmapi.todocenter.zwdd.model.MessageText; |
|
|
|
import com.ningdatech.pmapi.user.entity.UserInfo; |
|
|
|
import com.ningdatech.pmapi.user.service.IUserInfoService; |
|
|
|
import com.ningdatech.pmapi.user.util.LoginUserUtil; |
|
|
|
import com.wflow.bean.do_.UserDo; |
|
|
|
import com.wflow.bean.entity.NdDeclaredProject; |
|
|
|
import com.wflow.bean.entity.WflowCcTasks; |
|
|
|
import com.wflow.bean.entity.WflowModelHistorys; |
|
|
|
import com.wflow.bean.entity.WflowModels; |
|
|
|
import com.wflow.exception.BusinessException; |
|
|
|
import com.wflow.mapper.WflowCcTasksMapper; |
|
|
|
import com.wflow.mapper.WflowModelHistorysMapper; |
|
|
|
import com.wflow.service.NdDeclaredProjectService; |
|
|
|
import com.wflow.service.OrgRepositoryService; |
|
|
|
import com.wflow.utils.UserUtil; |
|
|
|
import com.wflow.workflow.bean.dto.ProcessInstanceOwnerDto; |
|
|
|
import com.wflow.workflow.bean.process.OrgUser; |
|
|
|
import com.wflow.workflow.bean.process.ProcessNode; |
|
|
@@ -58,25 +59,26 @@ import com.wflow.workflow.bean.process.enums.NodeTypeEnum; |
|
|
|
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.service.FormService; |
|
|
|
import com.wflow.workflow.service.*; |
|
|
|
import com.wflow.workflow.utils.Executor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.assertj.core.util.Maps; |
|
|
|
import org.flowable.bpmn.model.*; |
|
|
|
import org.flowable.bpmn.model.Process; |
|
|
|
import org.flowable.engine.*; |
|
|
|
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.repository.ProcessDefinition; |
|
|
|
import org.flowable.engine.runtime.Execution; |
|
|
|
import org.flowable.engine.runtime.ProcessInstance; |
|
|
|
import org.flowable.task.api.Task; |
|
|
|
import org.flowable.task.api.TaskInfo; |
|
|
|
import org.flowable.task.api.TaskQuery; |
|
|
|
import org.flowable.task.api.history.HistoricTaskInstance; |
|
|
|
import org.flowable.task.service.history.NativeHistoricTaskInstanceQuery; |
|
|
@@ -87,6 +89,8 @@ import org.springframework.stereotype.Component; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.IOException; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
@@ -117,7 +121,7 @@ public class TodoCenterManage { |
|
|
|
private final ProcessModelService processModelService; |
|
|
|
private final IUserInfoService userInfoService; |
|
|
|
|
|
|
|
private final NdDeclaredProjectService declaredProjectService; |
|
|
|
private final IProjectService projectService; |
|
|
|
@Resource(name = "executableClient") |
|
|
|
private ExecutableClient client; |
|
|
|
/** |
|
|
@@ -130,17 +134,15 @@ public class TodoCenterManage { |
|
|
|
public PageVo<ResToBeProcessedDTO> queryPendingProjectList(ReqToBeProcessedDTO param) { |
|
|
|
// 获取登录用户ID |
|
|
|
// long userId = LoginUserUtil.getUserId(); |
|
|
|
int userId = 381496; |
|
|
|
// 获取入参分页信息 |
|
|
|
Integer pageSize = param.getPageSize(); |
|
|
|
Integer pageNumber = param.getPageNumber(); |
|
|
|
|
|
|
|
Long userId = 381496L; |
|
|
|
|
|
|
|
TaskQuery taskQuery = taskService.createTaskQuery(); |
|
|
|
taskQuery.active().taskCandidateOrAssigned(String.valueOf(userId)).orderByTaskCreateTime().desc(); |
|
|
|
|
|
|
|
List<Task> taskList = taskQuery.list(); |
|
|
|
Set<String> staterUsers = new HashSet<>(); |
|
|
|
Page<NdDeclaredProject> page = param.page(); |
|
|
|
Page<Project> page = param.page(); |
|
|
|
|
|
|
|
// 将待办任务流程实例一次性取出来,减少查询次数 |
|
|
|
Map<String, HistoricProcessInstance> instanceMap = CollectionUtil.isNotEmpty(taskList) ? |
|
|
@@ -149,27 +151,29 @@ public class TodoCenterManage { |
|
|
|
.list().stream().collect(Collectors.toMap(HistoricProcessInstance::getId, v -> v)) : new HashMap<>(); |
|
|
|
List<String> processInsIds = taskList.stream().map(Task::getProcessInstanceId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
LambdaQueryWrapper<NdDeclaredProject> wrapper = Wrappers.lambdaQuery(NdDeclaredProject.class); |
|
|
|
wrapper.like(StrUtil.isNotBlank(param.getProjectName()),NdDeclaredProject::getProjectName,param.getProjectName()) |
|
|
|
.like(StrUtil.isNotBlank(param.getOrgName()),NdDeclaredProject::getOrgName,param.getOrgName()) |
|
|
|
.eq(Objects.nonNull(param.getProjectYear()),NdDeclaredProject::getProjectYear,param.getProjectYear()) |
|
|
|
.ge(Objects.nonNull(param.getProcessLaunchStartTime()),NdDeclaredProject::getCreateOn,param.getProcessLaunchStartTime()) |
|
|
|
.le(Objects.nonNull(param.getProcessLaunchEndTime()),NdDeclaredProject::getCreateOn,param.getProcessLaunchEndTime()); |
|
|
|
declaredProjectService.page(page,wrapper); |
|
|
|
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); |
|
|
|
|
|
|
|
List<ResToBeProcessedDTO> resVos = page.getRecords().stream().filter(d -> processInsIds.contains(d.getProcInsId())).map(d -> { |
|
|
|
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())); |
|
|
|
res.setProcessLaunchTime(d.getCreateOn()); |
|
|
|
LocalDateTime processLaunchTime = d.getCreateOn(); |
|
|
|
String format = NdDateUtils.format(processLaunchTime, "yyyy-MM-dd HH:mm"); |
|
|
|
LocalDateTime launchTime = LocalDateTime.parse(format, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); |
|
|
|
res.setProcessLaunchTime(launchTime); |
|
|
|
|
|
|
|
HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery().processInstanceId(d.getProcInsId()).singleResult(); |
|
|
|
HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery().processInstanceId(d.getInstCode()).singleResult(); |
|
|
|
HistoricProcessInstance instance = instanceMap.get(task.getProcessInstanceId()); |
|
|
|
HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery() |
|
|
|
.processInstanceId(instance.getId()).variableName("approve_" + task.getId()).singleResult(); |
|
|
|
//从缓存取 |
|
|
|
staterUsers.add(instance.getStartUserId()); |
|
|
|
staterUsers.add(String.valueOf(userId)); |
|
|
|
ProcessTaskVo processTaskVo = ProcessTaskVo.builder() |
|
|
|
.taskId(task.getId()) |
|
|
|
.taskName(task.getName()) |
|
|
@@ -184,9 +188,6 @@ public class TodoCenterManage { |
|
|
|
.ownerId(instance.getStartUserId()) |
|
|
|
.createTime(instance.getStartTime()) |
|
|
|
.taskCreateTime(task.getCreateTime()) |
|
|
|
.taskEndTime(task.getEndTime()) |
|
|
|
.taskResult(String.valueOf(Objects.nonNull(variableInstance) ? |
|
|
|
variableInstance.getValue() : ProcessHandlerParamsVo.Action.recall)) |
|
|
|
.build(); |
|
|
|
res.setProcessTaskInfo(processTaskVo); |
|
|
|
return res; |
|
|
@@ -195,70 +196,13 @@ public class TodoCenterManage { |
|
|
|
List<ResToBeProcessedDTO> result = null; |
|
|
|
if (CollectionUtil.isNotEmpty(staterUsers)) { |
|
|
|
Map<String, OrgUser> userMap = userDeptOrLeaderService.getUserMapByIds(staterUsers); |
|
|
|
result = resVos.stream().peek(v -> v.getProcessTaskInfo() |
|
|
|
.setOwner(userMap.get(v.getProcessTaskInfo().getOwnerId()))) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
result = resVos.stream().peek(v -> v.getProcessTaskInfo().setOwner(userMap.get(v.getProcessTaskInfo().getOwnerId()))) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
// Map<Long,UserInfo> userMap = userInfoService.getUserMapByIds(staterUsers); |
|
|
|
// result = resVos.stream().peek(v -> v.setOwner(userMap.get(userId))) |
|
|
|
// .collect(Collectors.toList()); |
|
|
|
} |
|
|
|
return PageVo.of(result,page.getTotal()); |
|
|
|
|
|
|
|
//List<ResToBeProcessedDTO> resVos = taskList.stream().map(task -> { |
|
|
|
// String nodeId = task.getTaskDefinitionKey(); |
|
|
|
// String instanceId = task.getProcessInstanceId(); |
|
|
|
// |
|
|
|
// ProcessProgressVo instanceProgress = processService.getInstanceProgress(nodeId, instanceId); |
|
|
|
// Map<String, Object> formData = instanceProgress.getFormData(); |
|
|
|
// String status = instanceProgress.getStatus(); |
|
|
|
// Boolean temporarySupplement = (Boolean) formData.get(ProjectDeclareConstants.BasicInformation.TEMPORARY_SUPPLEMENT); |
|
|
|
// ResToBeProcessedDTO res = new ResToBeProcessedDTO(); |
|
|
|
// temporarySupplement = true; |
|
|
|
// if (temporarySupplement.equals(param.getIsSupplement())) { |
|
|
|
// ProcessDefinition processDef = repositoryService.createProcessDefinitionQuery() |
|
|
|
// .processDefinitionId(task.getProcessDefinitionId()) |
|
|
|
// .singleResult(); |
|
|
|
// //从缓存取 |
|
|
|
// ProcessInstanceOwnerDto owner = runtimeService.getVariable(task.getExecutionId(), "owner", ProcessInstanceOwnerDto.class); |
|
|
|
// ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult(); |
|
|
|
// staterUsers.add(owner.getOwner()); |
|
|
|
// ProcessTaskVo processTaskVo = ProcessTaskVo.builder() |
|
|
|
// .taskId(task.getId()) |
|
|
|
// .taskName(task.getName()) |
|
|
|
// .taskDefKey(task.getTaskDefinitionKey()) |
|
|
|
// .processDefId(task.getProcessDefinitionId()) |
|
|
|
// .executionId(task.getExecutionId()) |
|
|
|
// .nodeId(nodeId) |
|
|
|
// .deployId(processDef.getDeploymentId()) |
|
|
|
// .processDefName(processDef.getName()) |
|
|
|
// .version(processDef.getVersion()) |
|
|
|
// .instanceId(instanceId) |
|
|
|
// .ownerId(processInstance.getStartUserId()) |
|
|
|
// .ownerDeptId(owner.getOwnerDeptId()) |
|
|
|
// .ownerDeptName(owner.getOwnerDeptName()) |
|
|
|
// .createTime(processInstance.getStartTime()) |
|
|
|
// .taskCreateTime(task.getCreateTime()) |
|
|
|
// .build(); |
|
|
|
// res.setProcessTaskInfo(processTaskVo); |
|
|
|
// String projectName = (String) formData.get(ProjectDeclareConstants.BasicInformation.PROJECT_NAME); |
|
|
|
// res.setProjectName(projectName); |
|
|
|
// res.setReportUnitId(owner.getOwnerDeptId()); |
|
|
|
// res.setReportUnitName(owner.getOwnerDeptName()); |
|
|
|
// res.setReportAmount((Integer) formData.get(ProjectDeclareConstants.FundDeclareInfo.DECLARE_AMOUNT)); |
|
|
|
// res.setBudgetYear((Integer) formData.get(ProjectDeclareConstants.BasicInformation.BUDGET_YEAR)); |
|
|
|
// res.setProcessStatus(ProcessStatusEnum.getCodeByDesc(status)); |
|
|
|
// res.setProcessStatusName(status); |
|
|
|
// res.setProcessLaunchTime(NdDateUtils.date2LocalDateTime(processInstance.getStartTime())); |
|
|
|
// } |
|
|
|
// return res; |
|
|
|
//}).filter(v -> StringUtils.isBlank(param.getProjectName()) || v.getProjectName().contains(param.getProjectName())) |
|
|
|
// .filter(v -> StringUtils.isBlank(param.getReportUnitName()) || v.getReportUnitName().contains(param.getReportUnitName())) |
|
|
|
// .filter(v -> Objects.isNull(param.getBudgetYear()) || v.getBudgetYear().equals(param.getBudgetYear())) |
|
|
|
// .filter(v -> Objects.isNull(param.getProcessLaunchStartTime()) || v.getProcessLaunchTime().isBefore(param.getProcessLaunchStartTime())) |
|
|
|
// .filter(v -> Objects.isNull(param.getProcessLaunchEndTime()) || v.getProcessLaunchTime().isAfter(param.getProcessLaunchEndTime())) |
|
|
|
// .collect(Collectors.toList()); |
|
|
|
//if (CollectionUtil.isNotEmpty(staterUsers)) { |
|
|
|
// Map<String, OrgUser> userMap = userDeptOrLeaderService.getUserMapByIds(staterUsers); |
|
|
|
// page.setRecords(resVos.stream().peek(v -> v.getProcessTaskInfo().setOwner(userMap.get(v.getProcessTaskInfo().getOwnerId()))).collect(Collectors.toList())); |
|
|
|
//} |
|
|
|
//return PageVo.of(resVos,resVos.size()); |
|
|
|
} |
|
|
|
/** |
|
|
|
* 待办中心列表导出 |
|
|
@@ -272,15 +216,15 @@ public class TodoCenterManage { |
|
|
|
PageVo<ResToBeProcessedDTO> page = queryPendingProjectList(param); |
|
|
|
List<ResToBeProcessedDTO> collect = (List<ResToBeProcessedDTO>) page.getRecords(); |
|
|
|
String fileName = null; |
|
|
|
if (param.getIsSupplement()){ |
|
|
|
if (IsAppendProjectEnum.APPEND_PROJECT.getCode().equals(param.getIsSupplement())){ |
|
|
|
fileName = "待办中心_待我处理_增补项目列表"; |
|
|
|
}else { |
|
|
|
}else if (IsAppendProjectEnum.NOT_APPEND_PROJECT.getCode().equals(param.getIsSupplement())){ |
|
|
|
fileName = "待办中心_待我处理_非增补项目列表"; |
|
|
|
} |
|
|
|
ExcelDownUtil.setFileName(fileName,response); |
|
|
|
//数据导出处理函数 |
|
|
|
try { |
|
|
|
EasyExcel.write(response.getOutputStream(), ResToBeProjectListExportDTO.class) |
|
|
|
EasyExcel.write(response.getOutputStream(), ResToBeExportDTO.class) |
|
|
|
.autoCloseStream(false) |
|
|
|
.registerWriteHandler(ExcelExportStyle.formalStyle()) |
|
|
|
.sheet(fileName) |
|
|
@@ -560,16 +504,19 @@ public class TodoCenterManage { |
|
|
|
FlowNode rootNode = (FlowNode) process.getFlowElement("root", true); |
|
|
|
// 获取当前节点 |
|
|
|
FlowNode currentNode = (FlowNode) process.getFlowElement(task.getTaskDefinitionKey(), true); |
|
|
|
UserTask userTask = (UserTask) process.getFlowElement(task.getTaskDefinitionKey()); |
|
|
|
String currentUserId = userTask.getAssignee(); |
|
|
|
String rootUserId = getRootUserId(rootNode); |
|
|
|
// 判断当前登录用户是否是流程发起人 |
|
|
|
Long userId = LoginUserUtil.getUserId(); |
|
|
|
List<Execution> executions = runtimeService.createExecutionQuery() |
|
|
|
.processInstanceId(task.getProcessInstanceId()) |
|
|
|
.onlyChildExecutions().list(); |
|
|
|
if (rootUserId.equals(String.valueOf(userId))){ |
|
|
|
// TODO 若是流程发起人点击撤回,项目回到上一个状态,并删除当前审核人对应的待办记录 |
|
|
|
// 获取当前流程项目状态 |
|
|
|
Project declaredProject = projectService.getOne(Wrappers.lambdaQuery(Project.class) |
|
|
|
.eq(Project::getInstCode, task.getProcessInstanceId())); |
|
|
|
Integer projectStatusSecond = declaredProject.getProjectStatusSecond(); |
|
|
|
|
|
|
|
List<Execution> executions = runtimeService.createExecutionQuery() |
|
|
|
.processInstanceId(task.getProcessInstanceId()) |
|
|
|
.onlyChildExecutions().list(); |
|
|
|
// 强制流程指向撤回 |
|
|
|
runtimeService.createChangeActivityStateBuilder() |
|
|
|
.processInstanceId(task.getProcessInstanceId()) |
|
|
@@ -580,12 +527,16 @@ public class TodoCenterManage { |
|
|
|
}else { |
|
|
|
FlowElementsContainer parentContainer = currentNode.getParentContainer(); |
|
|
|
for (FlowElement flowElement : parentContainer.getFlowElements()) { |
|
|
|
UserTask BeforeUserTask = (UserTask) flowElement; |
|
|
|
if (BeforeUserTask.getAssignee().equals(String.valueOf(userId))){ |
|
|
|
UserTask beforeUserTask = (UserTask) flowElement; |
|
|
|
if (beforeUserTask.getAssignee().equals(String.valueOf(userId))){ |
|
|
|
// TODO 若是前一个审核人点击撤回,在审核记录中移除自己提交过的审核意见、 |
|
|
|
// 待我处理中移除当前审核人的待办记录、 |
|
|
|
// 待我处理中增加自己的待办记录、 |
|
|
|
// 我已处理中去掉自己之前处理的记录 |
|
|
|
HistoricTaskInstance beforeTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(beforeUserTask.getId()).singleResult(); |
|
|
|
List<Execution> executions = runtimeService.createExecutionQuery() |
|
|
|
.processInstanceId(beforeTaskInstance.getProcessInstanceId()) |
|
|
|
.onlyChildExecutions().list(); |
|
|
|
// 强制流程指向撤回 |
|
|
|
runtimeService.createChangeActivityStateBuilder() |
|
|
|
.processInstanceId(task.getProcessInstanceId()) |
|
|
@@ -648,6 +599,7 @@ public class TodoCenterManage { |
|
|
|
} |
|
|
|
UserDo users = orgRepositoryService.getUserById(instance.getStartUserId()); |
|
|
|
OrgUser startUser = OrgUser.builder().id(users.getUserId()).name(users.getUserName()).avatar(users.getAvatar()).build(); |
|
|
|
|
|
|
|
List<ProgressNode> taskRecords = getHisTaskRecords(instanceId, nodePropsValue); |
|
|
|
// 获取添加抄送任务 |
|
|
|
taskRecords.addAll(getCcTaskRecords(instanceId)); |
|
|
@@ -679,12 +631,14 @@ public class TodoCenterManage { |
|
|
|
.formItems(formService.filterFormAndDataByPermConfig((List<Form>) forms.getValue(), formData, currentNode)) |
|
|
|
.formData(formData) |
|
|
|
.processDefName(instance.getProcessDefinitionName()) |
|
|
|
.staterUser(startUser) |
|
|
|
.starterDept(null == owner ? null : owner.getOwnerDeptName()) |
|
|
|
.startTempUser(startUser) |
|
|
|
.startDept(null == owner ? null : owner.getOwnerDeptName()) |
|
|
|
.result(instance.getEndActivityId()) |
|
|
|
.startTime(instance.getStartTime()) |
|
|
|
.progress(taskRecords) |
|
|
|
.build(); |
|
|
|
// UserInfo userInfo = userInfoService.getById(Long.valueOf(instance.getStartUserId())); |
|
|
|
// res.setStartUser(userInfo); |
|
|
|
if (Objects.isNull(instance.getEndActivityId())){ |
|
|
|
res.setStatus(ProcessStatusEnum.UNDER_REVIEW.name()); |
|
|
|
} else if (HisProInsEndActId.BACK.equals(instance.getEndActivityId())) { |
|
|
@@ -695,6 +649,10 @@ public class TodoCenterManage { |
|
|
|
} else if (HisProInsEndActId.END.equals(instance.getEndActivityId())) { |
|
|
|
res.setStatus(ProcessStatusEnum.APPROVED.name()); |
|
|
|
} |
|
|
|
// 查询项目申报信息 |
|
|
|
Project projectInfo = projectService.getOne(Wrappers.lambdaQuery(Project.class) |
|
|
|
.eq(Project::getInstCode, instanceId)); |
|
|
|
res.setDeclaredProjectInfo(projectInfo); |
|
|
|
return res; |
|
|
|
} |
|
|
|
|
|
|
@@ -780,15 +738,15 @@ public class TodoCenterManage { |
|
|
|
public PageVo<ResToBeProcessedDTO> queryHandledProjectList(ReqToBeProcessedDTO param) { |
|
|
|
// 获取登录用户ID |
|
|
|
// long userId = LoginUserUtil.getUserId(); |
|
|
|
int userId = 381496; |
|
|
|
Long userId = 381496L; |
|
|
|
// 获取入参分页信息 |
|
|
|
Integer pageSize = param.getPageSize(); |
|
|
|
Integer pageNumber = param.getPageNumber(); |
|
|
|
Page<NdDeclaredProject> page = param.page(); |
|
|
|
Page<Project> page = param.page(); |
|
|
|
|
|
|
|
//自定义sql查询所有已办的任务 |
|
|
|
String nativeSql = "SELECT aht.* FROM `ACT_HI_TASKINST` AS aht LEFT JOIN `ACT_HI_VARINST` AS ahv ON SUBSTRING(ahv.NAME_, 9) = aht.ID_ \n" + |
|
|
|
"AND ahv.NAME_ LIKE 'approve_%' WHERE aht.ASSIGNEE_ = '" + userId + "' AND ahv.NAME_ IS NOT NULL ORDER BY aht.END_TIME_ DESC"; |
|
|
|
String nativeSql = "SELECT aht.* FROM ACT_HI_TASKINST AS aht \n" + |
|
|
|
"LEFT JOIN ACT_HI_VARINST AS ahv ON SUBSTRING(ahv.NAME_, 9) = aht.ID_ AND ahv.NAME_ LIKE 'approve_%'\n" + |
|
|
|
"WHERE aht.ASSIGNEE_ = " + userId + " AND ahv.NAME_ IS NOT NULL \n" + |
|
|
|
"ORDER BY aht.END_TIME_ DESC"; |
|
|
|
|
|
|
|
NativeHistoricTaskInstanceQuery taskInstanceQuery = historyService.createNativeHistoricTaskInstanceQuery().sql(nativeSql); |
|
|
|
List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list(); |
|
|
@@ -800,23 +758,30 @@ public class TodoCenterManage { |
|
|
|
.list().stream().collect(Collectors.toMap(HistoricProcessInstance::getId, v -> v)) : new HashMap<>(); |
|
|
|
|
|
|
|
List<String> processInsIds = taskInstances.stream().map(HistoricTaskInstance::getProcessInstanceId).collect(Collectors.toList()); |
|
|
|
LambdaQueryWrapper<NdDeclaredProject> wrapper = Wrappers.lambdaQuery(NdDeclaredProject.class); |
|
|
|
wrapper.like(StrUtil.isNotBlank(param.getProjectName()),NdDeclaredProject::getProjectName,param.getProjectName()) |
|
|
|
.like(StrUtil.isNotBlank(param.getOrgName()),NdDeclaredProject::getOrgName,param.getOrgName()) |
|
|
|
.eq(Objects.nonNull(param.getProjectYear()),NdDeclaredProject::getProjectYear,param.getProjectYear()) |
|
|
|
.ge(Objects.nonNull(param.getProcessLaunchStartTime()),NdDeclaredProject::getCreateOn,param.getProcessLaunchStartTime()) |
|
|
|
.le(Objects.nonNull(param.getProcessLaunchEndTime()),NdDeclaredProject::getCreateOn,param.getProcessLaunchEndTime()); |
|
|
|
declaredProjectService.page(page,wrapper); |
|
|
|
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); |
|
|
|
Set<String> staterUsers = new HashSet<>(); |
|
|
|
List<ResToBeProcessedDTO> resVos = page.getRecords().stream().filter(d -> processInsIds.contains(d.getProcInsId())).map(d -> { |
|
|
|
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())); |
|
|
|
res.setProcessLaunchTime(d.getCreateOn()); |
|
|
|
res.setProcessHandleTime(d.getUpdateOn()); |
|
|
|
|
|
|
|
HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery().processInstanceId(d.getProcInsId()).singleResult(); |
|
|
|
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); |
|
|
|
LocalDateTime processHandleTime = d.getUpdateOn(); |
|
|
|
String handleTimeFormat = NdDateUtils.format(processHandleTime, "yyyy-MM-dd HH:mm"); |
|
|
|
LocalDateTime handleTime = LocalDateTime.parse(handleTimeFormat, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); |
|
|
|
res.setProcessHandleTime(handleTime); |
|
|
|
|
|
|
|
HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery().processInstanceId(d.getInstCode()).singleResult(); |
|
|
|
HistoricProcessInstance instance = instanceMap.get(task.getProcessInstanceId()); |
|
|
|
HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery() |
|
|
|
.processInstanceId(instance.getId()).variableName("approve_" + task.getId()).singleResult(); |
|
|
@@ -850,23 +815,35 @@ public class TodoCenterManage { |
|
|
|
result = resVos.stream().peek(v -> v.getProcessTaskInfo() |
|
|
|
.setOwner(userMap.get(v.getProcessTaskInfo().getOwnerId()))) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
// Map<Long,UserInfo> userMap = userInfoService.getUserMapByIds(staterUsers); |
|
|
|
// result = resVos.stream().peek(v -> v.setOwner(userMap.get(userId))) |
|
|
|
// .collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
return PageVo.of(result,page.getTotal()); |
|
|
|
return PageVo.of(result,resVos.size()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 导出我已处理项目列表 |
|
|
|
* @param response 返回数据流 |
|
|
|
* @param param 请求参数 |
|
|
|
* @return void |
|
|
|
* @author CMM |
|
|
|
* @since 2023/02/06 16:25 |
|
|
|
*/ |
|
|
|
public void exportHandledProjectList(HttpServletResponse response, ReqToBeProcessedDTO param) { |
|
|
|
PageVo<ResToBeProcessedDTO> page = queryHandledProjectList(param); |
|
|
|
List<ResToBeProcessedDTO> collect = (List<ResToBeProcessedDTO>) page.getRecords(); |
|
|
|
String fileName = null; |
|
|
|
if (param.getIsSupplement()){ |
|
|
|
if (IsAppendProjectEnum.APPEND_PROJECT.getCode().equals(param.getIsSupplement())){ |
|
|
|
fileName = "待办中心_我已处理_增补项目列表"; |
|
|
|
}else { |
|
|
|
}else if (IsAppendProjectEnum.NOT_APPEND_PROJECT.getCode().equals(param.getIsSupplement())){ |
|
|
|
fileName = "待办中心_我已处理_非增补项目列表"; |
|
|
|
} |
|
|
|
ExcelDownUtil.setFileName(fileName,response); |
|
|
|
//数据导出处理函数 |
|
|
|
try { |
|
|
|
EasyExcel.write(response.getOutputStream(), ResHandledProjectListExportDTO.class) |
|
|
|
EasyExcel.write(response.getOutputStream(), ResHandledExportDTO.class) |
|
|
|
.autoCloseStream(false) |
|
|
|
.registerWriteHandler(ExcelExportStyle.formalStyle()) |
|
|
|
.sheet(fileName) |
|
|
@@ -875,4 +852,148 @@ public class TodoCenterManage { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询我提交的项目列表 |
|
|
|
* @param param |
|
|
|
* @return com.ningdatech.basic.model.PageVo<com.ningdatech.pmapi.todocenter.model.dto.res.ResToBeProcessedDTO> |
|
|
|
* @author CMM |
|
|
|
* @since 2023/02/06 16:18 |
|
|
|
*/ |
|
|
|
public PageVo<ResToBeProcessedDTO> queryMySubmittedProjectList(ReqToBeProcessedDTO param) { |
|
|
|
HistoricProcessInstanceQuery instanceQuery = historyService.createHistoricProcessInstanceQuery(); |
|
|
|
// Long startUserId = LoginUserUtil.getUserId(); |
|
|
|
Long startUserId = 381496L; |
|
|
|
Page<Project> page = param.page(); |
|
|
|
Executor.builder().ifNotBlankNext(String.valueOf(startUserId), instanceQuery::startedBy); |
|
|
|
List<HistoricProcessInstance> historicProcessInstances = instanceQuery |
|
|
|
.orderByProcessInstanceStartTime().desc() |
|
|
|
.orderByProcessInstanceEndTime().desc() |
|
|
|
.list(); |
|
|
|
//把已办任务流程实例一次性取出来,减少查询次数 |
|
|
|
Map<String, HistoricProcessInstance> instanceMap = CollectionUtil.isNotEmpty(historicProcessInstances) ? |
|
|
|
historyService.createHistoricProcessInstanceQuery().processInstanceIds(historicProcessInstances.stream() |
|
|
|
.map(h -> h.getId()).collect(Collectors.toSet())).list().stream() |
|
|
|
.collect(Collectors.toMap(HistoricProcessInstance::getId, v -> v)) : new HashMap<>(); |
|
|
|
Set<String> historicProcessInstanceIds = historicProcessInstances.stream().map(h -> h.getId()).collect(Collectors.toSet()); |
|
|
|
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); |
|
|
|
Set<String> staterUsers = new HashSet<>(); |
|
|
|
List<ResToBeProcessedDTO> resVos = page.getRecords().stream().filter(d -> historicProcessInstanceIds.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()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取流程实例信息 |
|
|
|
* |
|
|
|
* @param ist 流程实例 |
|
|
|
* @return java.util.List<com.wflow.workflow.bean.vo.ProcessInstanceVo> |
|
|
|
* @author CMM |
|
|
|
* @since 2023/02/06 17:34 |
|
|
|
*/ |
|
|
|
private ProcessInstanceVo getProcessInstanceVos( HistoricProcessInstance ist) { |
|
|
|
Map<String, String> instanceNodeMap = new HashMap<>(); |
|
|
|
ProcessInstanceVo instanceVo = ProcessInstanceVo.builder() |
|
|
|
.processDefId(ist.getProcessDefinitionId()) |
|
|
|
.instanceId(ist.getId()) |
|
|
|
.nodeId(instanceNodeMap.get(ist.getId())) |
|
|
|
.formId(ist.getProcessDefinitionKey()) |
|
|
|
.staterUserId(ist.getStartUserId()) |
|
|
|
.startTime(ist.getStartTime()) |
|
|
|
.finishTime(ist.getEndTime()) |
|
|
|
.processDefName(ist.getProcessDefinitionName()) |
|
|
|
.result(ist.getEndActivityId()) |
|
|
|
.version(ist.getProcessDefinitionVersion()) |
|
|
|
.build(); |
|
|
|
|
|
|
|
if (Objects.isNull(ist.getEndActivityId())) { |
|
|
|
instanceVo.setStatus(ProcessStatusEnum.UNDER_REVIEW.name()); |
|
|
|
} else if (HisProInsEndActId.BACK.equals(ist.getEndActivityId())) { |
|
|
|
// TODO 被退回的审核节点状态这里只是暂时这么判断,具体怎么保存这个退回状态,后面讨论 |
|
|
|
instanceVo.setStatus(ProcessStatusEnum.BE_BACKED.name()); |
|
|
|
} else if (HisProInsEndActId.REJECT.equals(ist.getEndActivityId())) { |
|
|
|
instanceVo.setStatus(ProcessStatusEnum.BE_REJECTED.name()); |
|
|
|
} else if (HisProInsEndActId.END.equals(ist.getEndActivityId())) { |
|
|
|
instanceVo.setStatus(ProcessStatusEnum.APPROVED.name()); |
|
|
|
} |
|
|
|
|
|
|
|
if (ObjectUtil.isNull(ist.getEndActivityId())) { |
|
|
|
// 没有结束,还在走流程,获取任务 |
|
|
|
List<Task> list = |
|
|
|
taskService.createTaskQuery().processInstanceId(ist.getId()).includeIdentityLinks().active().list(); |
|
|
|
instanceVo.setNodeId(Optional.ofNullable(instanceVo.getNodeId()).orElseGet(() -> { |
|
|
|
if (CollectionUtil.isNotEmpty(list)) { |
|
|
|
return list.get(0).getTaskDefinitionKey(); |
|
|
|
} |
|
|
|
return null; |
|
|
|
})); |
|
|
|
instanceVo.setTaskName(StrUtil.join("、", list.stream().map(TaskInfo::getName).collect(Collectors.toSet()))); |
|
|
|
} else { |
|
|
|
if (HisProInsEndActId.WITHDRAW.equals(ist.getEndActivityId())) { |
|
|
|
instanceVo.setTaskName(ProcessStatusEnum.WITHDRAW.getDesc()); |
|
|
|
} else if (HisProInsEndActId.REJECT.equals(ist.getEndActivityId())) { |
|
|
|
instanceVo.setTaskName(ProcessStatusEnum.BE_REJECTED.getDesc()); |
|
|
|
} else { |
|
|
|
instanceVo.setTaskName(ProcessStatusEnum.APPROVED.getDesc()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return instanceVo; |
|
|
|
} |
|
|
|
|
|
|
|
public void exportMySubmittedProjectList(HttpServletResponse response, ReqToBeProcessedDTO param) { |
|
|
|
PageVo<ResToBeProcessedDTO> page = queryMySubmittedProjectList(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(), ResMySubmittedExportDTO.class) |
|
|
|
.autoCloseStream(false) |
|
|
|
.registerWriteHandler(ExcelExportStyle.formalStyle()) |
|
|
|
.sheet(fileName) |
|
|
|
.doWrite(collect); |
|
|
|
} catch (IOException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |