mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-28 16:58:43 +08:00 
			
		
		
		
	暂时回退流程推断的能力
This commit is contained in:
		| @@ -1,7 +1,6 @@ | ||||
| package cn.iocoder.yudao.module.bpm.convert.task; | ||||
|  | ||||
| import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity.BpmActivityRespVO; | ||||
| import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmActivityDO; | ||||
| import org.flowable.engine.history.HistoricActivityInstance; | ||||
| import org.mapstruct.Mapper; | ||||
| import org.mapstruct.Mapping; | ||||
| @@ -20,11 +19,11 @@ public interface BpmActivityConvert { | ||||
|  | ||||
|     BpmActivityConvert INSTANCE = Mappers.getMapper(BpmActivityConvert.class); | ||||
|  | ||||
|     List<BpmActivityRespVO> convertList(List<BpmActivityDO> list); | ||||
|     List<BpmActivityRespVO> convertList(List<HistoricActivityInstance> list); | ||||
|  | ||||
|     @Mappings({ | ||||
|             @Mapping(source = "activityId", target = "key"), | ||||
|             @Mapping(source = "activityType", target = "type") | ||||
|     }) | ||||
|     BpmActivityRespVO convert(BpmActivityDO bean); | ||||
|     BpmActivityRespVO convert(HistoricActivityInstance bean); | ||||
| } | ||||
|   | ||||
| @@ -7,20 +7,9 @@ import org.apache.ibatis.annotations.Param; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * @author kemengkai | ||||
|  * @create 2022-05-09 09:26 TODO @ke:@date 哈。ps:一般这种类,可以不用谢类注释和方法注释。因为是 dao 是通用操作,所以都是通过方法名,可以指导它的用途 | ||||
|  */ | ||||
| @Mapper | ||||
| public interface BpmActivityMapper extends BaseMapperX<BpmActivityDO> { | ||||
|  | ||||
|     // TODO @ke:这个方法,是不是暂时用不到呀。如果是的话,可以删除哈 | ||||
|     /** | ||||
|      * 获取所有历史任务 | ||||
|      * | ||||
|      * @return 返回历史任务 | ||||
|      */ | ||||
|     List<BpmActivityDO> listAll(); | ||||
|  | ||||
|     // TODO @ke:可以试试,把 activiti 的表,映射成对应的实体,然后读取下。我们尽量避免 xml 操作,因为要做多 db 类型的支持,例如说 oracle 等。通过 mybatis plus 帮助我们生成不同数据库的表操作 | ||||
|     /** | ||||
|   | ||||
| @@ -1,35 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.bpm.domain.vo; | ||||
|  | ||||
| import io.swagger.annotations.ApiModelProperty; | ||||
| import lombok.AllArgsConstructor; | ||||
| import lombok.Data; | ||||
| import lombok.NoArgsConstructor; | ||||
|  | ||||
| import java.time.LocalDate; | ||||
|  | ||||
| /** | ||||
|  * 审批流程VO | ||||
|  * | ||||
|  * @author kemengkai | ||||
|  */ | ||||
| @Data | ||||
| @AllArgsConstructor | ||||
| @NoArgsConstructor | ||||
| // TODO @ke:这个类是不是没用呀 | ||||
| public class ApproveProcInstVO { | ||||
|  | ||||
|     @ApiModelProperty("任务id") | ||||
|     private String id; | ||||
|     @ApiModelProperty("任务部署key") | ||||
|     private String taskDefKey; | ||||
|     @ApiModelProperty("任务名称") | ||||
|     private String name; | ||||
|     @ApiModelProperty("审批人登录名") | ||||
|     private String assignee; | ||||
|     @ApiModelProperty("审批人姓名") | ||||
|     private String assigneeName; | ||||
|     @ApiModelProperty("审批回复") | ||||
|     private String taskComment; | ||||
|     @ApiModelProperty("审批完成时间") | ||||
|     private LocalDate endTime; | ||||
| } | ||||
| @@ -1,12 +1,9 @@ | ||||
| package cn.iocoder.yudao.module.bpm.service.task; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; | ||||
| import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity.BpmActivityRespVO; | ||||
| import cn.iocoder.yudao.module.bpm.convert.task.BpmActivityConvert; | ||||
| import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmActivityDO; | ||||
| import cn.iocoder.yudao.module.bpm.dal.mysql.task.BpmActivityMapper; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
|  | ||||
| import org.flowable.engine.HistoryService; | ||||
| import org.flowable.engine.history.HistoricActivityInstance; | ||||
| import org.springframework.stereotype.Service; | ||||
| @@ -32,13 +29,10 @@ public class BpmActivityServiceImpl implements BpmActivityService { | ||||
|     private BpmActivityMapper bpmActivityMapper; | ||||
|  | ||||
|     @Override | ||||
|     @TenantIgnore | ||||
|     public List<BpmActivityRespVO> getActivityListByProcessInstanceId(String procInstId) { | ||||
| //        List<HistoricActivityInstance> activityList = historyService.createHistoricActivityInstanceQuery() | ||||
| //                .processInstanceId(procInstId).list(); | ||||
|         // TODO @ke:这个是想要过滤掉 aha.act_type_ != 'sequenceFlow' 类型么? | ||||
|         List<BpmActivityDO> bpmActivityDOList = bpmActivityMapper.listAllByProcInstIdAndDelete(procInstId); | ||||
|         return BpmActivityConvert.INSTANCE.convertList(bpmActivityDOList); | ||||
|     public List<BpmActivityRespVO> getActivityListByProcessInstanceId(String processInstanceId) { | ||||
|         List<HistoricActivityInstance> activityList = historyService.createHistoricActivityInstanceQuery() | ||||
|                 .processInstanceId(processInstanceId).list(); | ||||
|         return BpmActivityConvert.INSTANCE.convertList(activityList); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|   | ||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -18,8 +18,8 @@ import cn.iocoder.yudao.module.bpm.dal.mysql.task.BpmTaskExtMapper; | ||||
| import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum; | ||||
| import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum; | ||||
| import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService; | ||||
| import cn.iocoder.yudao.module.business.hi.task.inst.service.HiTaskInstService; | ||||
| import cn.iocoder.yudao.module.system.api.dept.DeptApi; | ||||
| import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; | ||||
| import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | ||||
| import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| @@ -78,8 +78,6 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||||
|     private BpmTaskAssignRuleMapper taskAssignRuleMapper; | ||||
|     @Resource | ||||
|     private BpmActivityMapper bpmActivityMapper; | ||||
|     @Resource | ||||
|     private HiTaskInstService hiTaskInstService; | ||||
|  | ||||
|     @Override | ||||
|     public PageResult<BpmTaskTodoPageItemRespVO> getTodoTaskPage(Long userId, BpmTaskTodoPageReqVO pageVO) { | ||||
| @@ -161,22 +159,17 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||||
|     @Override | ||||
|     public List<BpmTaskRespVO> getTaskListByProcessInstanceId(String processInstanceId) { | ||||
|         // 获得任务列表 | ||||
|        /* List<HistoricTaskInstance> tasks = | ||||
|             historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstanceId) | ||||
|         List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery() | ||||
|                 .processInstanceId(processInstanceId) | ||||
|                 .orderByHistoricTaskInstanceStartTime().desc() // 创建时间倒序 | ||||
|                 .list(); | ||||
|         if (CollUtil.isEmpty(tasks)) { | ||||
|             return Collections.emptyList(); | ||||
|         }*/ | ||||
|         } | ||||
|  | ||||
|         // 获得 TaskExtDO Map | ||||
|         //        List<BpmTaskExtDO> bpmTaskExtDOList = | ||||
|         //            taskExtMapper.selectListByTaskIds(convertSet(tasks, HistoricTaskInstance::getId)); | ||||
|  | ||||
| //        List<BpmTaskExtDO> bpmTaskExtDOList = taskExtMapper.listByProcInstId(processInstanceId); | ||||
|         //        List<BpmTaskExtDO> bpmTaskExtDOList = BpmTaskConvert.INSTANCE.distinct(tmpBpmTaskExtDOList); | ||||
|         //        bpmTaskExtDOList.forEach(var -> log.info("var = " + var)); | ||||
|  | ||||
|         /*Map<String, BpmTaskExtDO> bpmTaskExtDoMap = convertMap(bpmTaskExtDOList, BpmTaskExtDO::getTaskId); | ||||
|         List<BpmTaskExtDO> bpmTaskExtDOs = taskExtMapper.selectListByTaskIds(convertSet(tasks, HistoricTaskInstance::getId)); | ||||
|         Map<String, BpmTaskExtDO> bpmTaskExtDOMap = convertMap(bpmTaskExtDOs, BpmTaskExtDO::getTaskId); | ||||
|         // 获得 ProcessInstance Map | ||||
|         HistoricProcessInstance processInstance = processInstanceService.getHistoricProcessInstance(processInstanceId); | ||||
|         // 获得 User Map | ||||
| @@ -184,14 +177,10 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||||
|         userIds.add(NumberUtils.parseLong(processInstance.getStartUserId())); | ||||
|         Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds); | ||||
|         // 获得 Dept Map | ||||
|         Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId));*/ | ||||
|         Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); | ||||
|  | ||||
|         // 拼接数据 | ||||
| //        List<BpmTaskExtDO> tmpBpmTaskExtDOList = taskExtMapper.listByProcInstId(processInstanceId); | ||||
|         // TODO @ke:这个钉钉是咋处理的?得讨论下流程预测的需要程度哈。 | ||||
|         List<BpmTaskExtDO> tmpBpmTaskExtDOList = taskExtMapper.selectListByProcessInstanceId(processInstanceId); | ||||
|         tmpBpmTaskExtDOList.sort(Comparator.comparing(BpmTaskExtDO::getCreateTime)); | ||||
|         return hiTaskInstService.taskGetComment(tmpBpmTaskExtDOList, ""); | ||||
|         return BpmTaskConvert.INSTANCE.convertList3(tasks, bpmTaskExtDOMap, processInstance, userMap, deptMap); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|   | ||||
| @@ -1,20 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.business.hi.task.inst.domain; | ||||
|  | ||||
| import lombok.AllArgsConstructor; | ||||
| import lombok.Data; | ||||
| import lombok.NoArgsConstructor; | ||||
|  | ||||
| /** | ||||
|  * @author kemengkai | ||||
|  * @create 2022-01-11 15:09 | ||||
|  */ | ||||
| @Data | ||||
| @AllArgsConstructor | ||||
| @NoArgsConstructor | ||||
| public class HistoricApproveTaskDTO { | ||||
|  | ||||
|     private String procInstId; | ||||
|     private String name; | ||||
|     private String assignee; | ||||
|  | ||||
| } | ||||
| @@ -1,105 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.business.hi.task.inst.domain.vo; | ||||
|  | ||||
| import lombok.Data; | ||||
| import java.util.Date; | ||||
| import com.fasterxml.jackson.annotation.JsonFormat; | ||||
| import io.swagger.annotations.ApiModelProperty; | ||||
|  | ||||
| /** | ||||
|  *  [  ] | ||||
|  * | ||||
|  * @author 孟凯 | ||||
|  * @version 1.0 | ||||
|  * @company 1024创新实验室( www.1024lab.net ) | ||||
|  * @copyright (c) 1024创新实验室( www.1024lab.net )Inc. All rights reserved. | ||||
|  * @date  2022-01-17 15:14:27 | ||||
|  * @since JDK1.8 | ||||
|  */ | ||||
| @Data | ||||
| public class HiTaskinstVO { | ||||
|     @ApiModelProperty("ID_") | ||||
|     private String id; | ||||
|  | ||||
|     @ApiModelProperty("TASK_DEF_KEY_") | ||||
|     private String taskDefKey; | ||||
|  | ||||
|     @ApiModelProperty("PROC_DEF_KEY_") | ||||
|     private String procDefKey; | ||||
|  | ||||
|     @ApiModelProperty("PROC_DEF_ID_") | ||||
|     private String procDefId; | ||||
|  | ||||
|     @ApiModelProperty("ROOT_PROC_INST_ID_") | ||||
|     private String rootProcInstId; | ||||
|  | ||||
|     @ApiModelProperty("PROC_INST_ID_") | ||||
|     private String procInstId; | ||||
|  | ||||
|     @ApiModelProperty("EXECUTION_ID_") | ||||
|     private String executionId; | ||||
|  | ||||
|     @ApiModelProperty("CASE_DEF_KEY_") | ||||
|     private String caseDefKey; | ||||
|  | ||||
|     @ApiModelProperty("CASE_DEF_ID_") | ||||
|     private String caseDefId; | ||||
|  | ||||
|     @ApiModelProperty("CASE_INST_ID_") | ||||
|     private String caseInstId; | ||||
|  | ||||
|     @ApiModelProperty("CASE_EXECUTION_ID_") | ||||
|     private String caseExecutionId; | ||||
|  | ||||
|     @ApiModelProperty("ACT_INST_ID_") | ||||
|     private String actInstId; | ||||
|  | ||||
|     @ApiModelProperty("NAME_") | ||||
|     private String name; | ||||
|  | ||||
|     @ApiModelProperty("PARENT_TASK_ID_") | ||||
|     private String parentTaskId; | ||||
|  | ||||
|     @ApiModelProperty("DESCRIPTION_") | ||||
|     private String description; | ||||
|  | ||||
|     @ApiModelProperty("OWNER_") | ||||
|     private String owner; | ||||
|  | ||||
|     @ApiModelProperty("ASSIGNEE_") | ||||
|     private String assignee; | ||||
|  | ||||
|     @ApiModelProperty("START_TIME_") | ||||
|     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | ||||
|     private Date startTime; | ||||
|  | ||||
|     @ApiModelProperty("END_TIME_") | ||||
|     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | ||||
|     private Date endTime; | ||||
|  | ||||
|     @ApiModelProperty("DURATION_") | ||||
|     private Long duration; | ||||
|  | ||||
|     @ApiModelProperty("DELETE_REASON_") | ||||
|     private String deleteReason; | ||||
|  | ||||
|     @ApiModelProperty("PRIORITY_") | ||||
|     private Integer priority; | ||||
|  | ||||
|     @ApiModelProperty("DUE_DATE_") | ||||
|     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | ||||
|     private Date dueDate; | ||||
|  | ||||
|     @ApiModelProperty("FOLLOW_UP_DATE_") | ||||
|     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | ||||
|     private Date followUpDate; | ||||
|  | ||||
|     @ApiModelProperty("TENANT_ID_") | ||||
|     private String tenantId; | ||||
|  | ||||
|     @ApiModelProperty("REMOVAL_TIME_") | ||||
|     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | ||||
|     private Date removalTime; | ||||
|  | ||||
|  | ||||
|  | ||||
| } | ||||
| @@ -1,354 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.business.hi.task.inst.service; | ||||
|  | ||||
| import cn.hutool.core.bean.BeanUtil; | ||||
| import cn.hutool.core.collection.CollUtil; | ||||
| import cn.hutool.core.util.ObjectUtil; | ||||
| import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; | ||||
| import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskRespVO; | ||||
| import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskTodoPageItemRespVO; | ||||
| import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO; | ||||
| import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO; | ||||
| import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmTaskAssignRuleMapper; | ||||
| import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; | ||||
| import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; | ||||
| import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; | ||||
| import cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper; | ||||
| import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.flowable.bpmn.model.*; | ||||
| import org.flowable.common.engine.impl.de.odysseus.el.ExpressionFactoryImpl; | ||||
| import org.flowable.common.engine.impl.de.odysseus.el.util.SimpleContext; | ||||
| import org.flowable.common.engine.impl.javax.el.ExpressionFactory; | ||||
| import org.flowable.common.engine.impl.javax.el.ValueExpression; | ||||
| import org.flowable.engine.HistoryService; | ||||
| import org.flowable.engine.RepositoryService; | ||||
| import org.flowable.engine.history.HistoricProcessInstance; | ||||
| import org.flowable.task.api.history.HistoricTaskInstance; | ||||
| import org.flowable.variable.api.history.HistoricVariableInstance; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| import javax.annotation.Resource; | ||||
| import java.util.HashMap; | ||||
| import java.util.LinkedList; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.function.Function; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| /** | ||||
|  * [  ] | ||||
|  * | ||||
|  * @author 孟凯 | ||||
|  * @version 1.0 | ||||
|  */ | ||||
| @Slf4j | ||||
| @Service | ||||
| public class HiTaskInstService { | ||||
|  | ||||
|     @Resource | ||||
|     private HistoryService historyService; | ||||
|     @Resource | ||||
|     private RepositoryService repositoryService; | ||||
|     @Resource | ||||
|     private BpmTaskAssignRuleMapper bpmTaskAssignRuleMapper; | ||||
|     @Resource | ||||
|     private BpmProcessInstanceService processInstanceService; | ||||
|     @Resource | ||||
|     private AdminUserMapper adminUserApi; | ||||
|     @Resource | ||||
|     private DeptMapper deptMapper; | ||||
|  | ||||
|     /** | ||||
|      * 获取任务具体流程信息 | ||||
|      * | ||||
|      * @param taskList 任务信息 | ||||
|      * @param approved 任意选择条件 | ||||
|      * | ||||
|      * @return 返回流程信息 | ||||
|      */ | ||||
|     @TenantIgnore | ||||
|     public List<BpmTaskRespVO> taskGetComment(List<BpmTaskExtDO> taskList, Object approved) { | ||||
|         BpmTaskExtDO task = taskList.get(taskList.size() - 1); | ||||
|         Map<String, BpmTaskExtDO> bpmTaskMap = | ||||
|             taskList.stream().collect(Collectors.toMap(BpmTaskExtDO::getTaskId, Function.identity())); | ||||
|         // 获得 ProcessInstance Map | ||||
|         HistoricProcessInstance procInst = | ||||
|             processInstanceService.getHistoricProcessInstance(task.getProcessInstanceId()); | ||||
|         Map<Long, AdminUserDO> userDoMap = | ||||
|             adminUserApi.selectList().stream().collect(Collectors.toMap(AdminUserDO::getId, Function.identity())); | ||||
|         Map<Long, DeptDO> deptMap = | ||||
|             deptMapper.selectList().stream().collect(Collectors.toMap(DeptDO::getId, Function.identity())); | ||||
|         List<HistoricTaskInstance> hisTaskInstList = | ||||
|             historyService.createHistoricTaskInstanceQuery().processInstanceId(task.getProcessInstanceId()) | ||||
|                 .orderByHistoricTaskInstanceStartTime().desc().list(); | ||||
|         LinkedList<BpmTaskRespVO> bpmTaskRespVOList = | ||||
|             nowTaskFormat(procInst, hisTaskInstList, bpmTaskMap, userDoMap, deptMap); | ||||
|  | ||||
|         //ProcessInstanceId流程实例 | ||||
|         String procInstId = task.getProcessInstanceId(); | ||||
|         List<BpmTaskAssignRuleDO> tmpBpmTaskAssignRuleDOList = | ||||
|             bpmTaskAssignRuleMapper.selectListByProcessDefinitionId(task.getProcessDefinitionId(), null); | ||||
|         List<HistoricVariableInstance> hisVarInstList = | ||||
|             historyService.createHistoricVariableInstanceQuery().processInstanceId(procInstId).list(); | ||||
|         Map<String, Object> hisVarInstMap = new HashMap<>(); | ||||
|         for (HistoricVariableInstance hisVarInst : hisVarInstList) { | ||||
|             hisVarInstMap.put(hisVarInst.getVariableName(), hisVarInst.getValue()); | ||||
|         } | ||||
|         hisVarInstMap.put("approved", approved); | ||||
|         //获取bpm(模型)对象 | ||||
|         BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId()); | ||||
|         getFlow(bpmnModel, task.getTaskDefKey(), tmpBpmTaskAssignRuleDOList, bpmTaskRespVOList, userDoMap, deptMap, | ||||
|             hisVarInstMap); | ||||
|         return bpmTaskRespVOList; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 格式化任务信息 | ||||
|      */ | ||||
|     private LinkedList<BpmTaskRespVO> nowTaskFormat(HistoricProcessInstance procInst, List<HistoricTaskInstance> taskList, | ||||
|         Map<String, BpmTaskExtDO> bpmTaskExtDoMap, Map<Long, AdminUserDO> userMap, Map<Long, DeptDO> deptMap) { | ||||
|         LinkedList<BpmTaskRespVO> bpmTaskRespVOList = new LinkedList<>(); | ||||
|         for (HistoricTaskInstance hisTaskInst : taskList) { | ||||
|             BpmTaskRespVO respVO = initRespVo(hisTaskInst, bpmTaskExtDoMap, procInst, userMap); | ||||
|             AdminUserDO user = userMap.get(Long.valueOf(hisTaskInst.getAssignee())); | ||||
|             if (BeanUtil.isNotEmpty(user)) { | ||||
|                 respVO.setAssigneeUser(setUser(user)); | ||||
|                 DeptDO dept = deptMap.get(user.getDeptId()); | ||||
|                 if (BeanUtil.isNotEmpty(dept)) { | ||||
|                     respVO.getAssigneeUser().setDeptName(dept.getName()); | ||||
|                 } | ||||
|             } | ||||
|             bpmTaskRespVOList.addFirst(respVO); | ||||
|         } | ||||
|         return bpmTaskRespVOList; | ||||
|     } | ||||
|  | ||||
|     private BpmTaskRespVO initRespVo(Object taskInst, Map<String, BpmTaskExtDO> bpmTaskExtDoMap, | ||||
|         HistoricProcessInstance procInst, Map<Long, AdminUserDO> userMap) { | ||||
|         BpmTaskRespVO respVO = new BpmTaskRespVO(); | ||||
|         if (taskInst instanceof HistoricTaskInstance) { | ||||
|             respVO = setBpmnTaskRespVo((HistoricTaskInstance)taskInst); | ||||
|             BeanUtil.copyProperties(taskInst, respVO); | ||||
|             BpmTaskExtDO bpmTaskExtDO = bpmTaskExtDoMap.get(respVO.getId()); | ||||
|             if (ObjectUtil.isNotEmpty(bpmTaskExtDO)) { | ||||
|                 BeanUtil.copyProperties(bpmTaskExtDO, respVO); | ||||
|                 respVO.setId(bpmTaskExtDO.getTaskId()); | ||||
|             } | ||||
|         } | ||||
|         if (taskInst instanceof BpmTaskExtDO) { | ||||
|             respVO = setBpmnTaskRespVo((BpmTaskExtDO)taskInst); | ||||
|             BeanUtil.copyProperties(taskInst, respVO); | ||||
|         } | ||||
|         //            copyTo(bpmTaskExtDO, respVO); | ||||
|         if (procInst != null) { | ||||
|             AdminUserDO startUser = userMap.get(Long.valueOf(procInst.getStartUserId())); | ||||
|             if (BeanUtil.isEmpty(startUser)) { | ||||
|                 throw new RuntimeException("查找不到审批用户!!!"); | ||||
|             } | ||||
|             respVO.setProcessInstance(setProcInst(procInst, startUser)); | ||||
|         } | ||||
|         return respVO; | ||||
|     } | ||||
|  | ||||
|     private BpmTaskRespVO.User setUser(AdminUserDO bean) { | ||||
|         if (bean == null) { | ||||
|             return null; | ||||
|         } | ||||
|  | ||||
|         BpmTaskRespVO.User user = new BpmTaskRespVO.User(); | ||||
|  | ||||
|         user.setId(bean.getId()); | ||||
|         user.setNickname(bean.getNickname()); | ||||
|         user.setDeptId(bean.getDeptId()); | ||||
|  | ||||
|         return user; | ||||
|  | ||||
|     } | ||||
|  | ||||
|     private BpmTaskRespVO setBpmnTaskRespVo(BpmTaskExtDO bean) { | ||||
|         if (bean == null) { | ||||
|             return null; | ||||
|         } | ||||
|  | ||||
|         BpmTaskRespVO bpmTaskRespVO = new BpmTaskRespVO(); | ||||
|  | ||||
|         bpmTaskRespVO.setDefinitionKey(bean.getTaskDefKey()); | ||||
|         bpmTaskRespVO.setId(bean.getTaskId()); | ||||
|         bpmTaskRespVO.setName(bean.getName()); | ||||
|         bpmTaskRespVO.setCreateTime(bean.getCreateTime()); | ||||
|  | ||||
|         return bpmTaskRespVO; | ||||
|     } | ||||
|  | ||||
|     public BpmTaskRespVO setBpmnTaskRespVo(HistoricTaskInstance bean) { | ||||
|         if (bean == null) { | ||||
|             return null; | ||||
|         } | ||||
|  | ||||
|         BpmTaskRespVO bpmTaskRespVO = new BpmTaskRespVO(); | ||||
|  | ||||
|         bpmTaskRespVO.setDefinitionKey(bean.getTaskDefinitionKey()); | ||||
|         bpmTaskRespVO.setId(bean.getId()); | ||||
|         bpmTaskRespVO.setName(bean.getName()); | ||||
|         bpmTaskRespVO.setClaimTime(bean.getClaimTime()); | ||||
|         bpmTaskRespVO.setCreateTime(bean.getCreateTime()); | ||||
|         bpmTaskRespVO.setEndTime(bean.getEndTime()); | ||||
|         bpmTaskRespVO.setDurationInMillis(bean.getDurationInMillis()); | ||||
|  | ||||
|         return bpmTaskRespVO; | ||||
|     } | ||||
|  | ||||
|     public BpmTaskTodoPageItemRespVO.ProcessInstance setProcInst(HistoricProcessInstance processInstance, | ||||
|         AdminUserDO startUser) { | ||||
|         if (processInstance == null && startUser == null) { | ||||
|             return null; | ||||
|         } | ||||
|  | ||||
|         BpmTaskTodoPageItemRespVO.ProcessInstance processInstanceResult = | ||||
|             new BpmTaskTodoPageItemRespVO.ProcessInstance(); | ||||
|  | ||||
|         if (processInstance != null) { | ||||
|             processInstanceResult.setId(processInstance.getId()); | ||||
|             processInstanceResult.setName(processInstance.getName()); | ||||
|             if (processInstance.getStartUserId() != null) { | ||||
|                 processInstanceResult.setStartUserId(Long.parseLong(processInstance.getStartUserId())); | ||||
|             } | ||||
|             processInstanceResult.setProcessDefinitionId(processInstance.getProcessDefinitionId()); | ||||
|         } | ||||
|         if (startUser != null) { | ||||
|             processInstanceResult.setStartUserNickname(startUser.getNickname()); | ||||
|         } | ||||
|  | ||||
|         return processInstanceResult; | ||||
|     } | ||||
|  | ||||
|     private void getFlow(BpmnModel bpmnModel, String taskDefKey, List<BpmTaskAssignRuleDO> tmpBpmTaskAssignRuleDOList, | ||||
|         LinkedList<BpmTaskRespVO> bpmTaskRespVOList, Map<Long, AdminUserDO> userDoMap, Map<Long, DeptDO> deptMap, | ||||
|         Map<String, Object> taskVarMap) { | ||||
|         //传节点定义key获取当前节点 | ||||
|         FlowNode flowNode = (FlowNode)bpmnModel.getFlowElement(taskDefKey); | ||||
|         //输出连线 | ||||
|         List<SequenceFlow> outgoingFlows = flowNode.getOutgoingFlows(); | ||||
|         //遍历返回下一个节点信息 | ||||
|         for (SequenceFlow outgoingFlow : outgoingFlows) { | ||||
|             //类型自己判断(获取下个节点是网关还是节点) | ||||
|             FlowElement targetFlowElement = outgoingFlow.getTargetFlowElement(); | ||||
|             getFlow(bpmnModel, targetFlowElement, tmpBpmTaskAssignRuleDOList, bpmTaskRespVOList, userDoMap, deptMap, | ||||
|                 taskVarMap); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void getFlow(BpmnModel bpmnModel, FlowElement targetFlowElement, | ||||
|         List<BpmTaskAssignRuleDO> tmpBpmTaskAssignRuleDOList, LinkedList<BpmTaskRespVO> bpmTaskRespVOList, | ||||
|         Map<Long, AdminUserDO> userDoMap, Map<Long, DeptDO> deptMap, Map<String, Object> taskVarMap) { | ||||
|         // 下一个taskDefKey | ||||
|         String nextTaskDefKey = null; | ||||
|         //下个是节点 | ||||
|         if (targetFlowElement instanceof UserTask) { | ||||
|             // 判断是否是为并行任务 | ||||
|             List<BpmTaskAssignRuleDO> bpmTaskAssignRuleDOList = tmpBpmTaskAssignRuleDOList.stream().filter( | ||||
|                     bpmTaskAssignRuleDO -> bpmTaskAssignRuleDO.getTaskDefinitionKey().equals(targetFlowElement.getId())) | ||||
|                 .collect(Collectors.toList()); | ||||
|             if (CollUtil.isEmpty(bpmTaskAssignRuleDOList)) { | ||||
|                 throw new RuntimeException("任务key不存在!!!"); | ||||
|             } | ||||
|             for (BpmTaskAssignRuleDO bpmTaskAssignRuleDO : bpmTaskAssignRuleDOList) { | ||||
|                 nextTaskDefKey = bpmTaskAssignRuleDO.getTaskDefinitionKey(); | ||||
|                 for (Long userId : bpmTaskAssignRuleDO.getOptions()) { | ||||
|                     BpmTaskRespVO bpmTaskRespVO = | ||||
|                         (BpmTaskRespVO)new BpmTaskRespVO().setName(targetFlowElement.getName()); | ||||
|                     bpmTaskRespVOList.addLast(bpmTaskRespVO); | ||||
|                     AdminUserDO adminUserDO = userDoMap.get(userId); | ||||
|                     DeptDO deptDO = deptMap.get(adminUserDO.getDeptId()); | ||||
|                     bpmTaskRespVO.setAssigneeUser(setUser(adminUserDO)); | ||||
|                     bpmTaskRespVO.getAssigneeUser().setDeptName(deptDO.getName()); | ||||
|                     // edit by 芋艿 TODO | ||||
| //                    if (!bpmTaskAssignRuleDO.getType().equals(BpmTaskAssignRuleTypeEnum.USER_OR_SIGN.getType()) | ||||
| //                        && !bpmTaskAssignRuleDO.getType().equals(BpmTaskAssignRuleTypeEnum.USER_SIGN.getType())) { | ||||
| //                        break; | ||||
| //                    } | ||||
|                 } | ||||
|             } | ||||
|             getFlow(bpmnModel, nextTaskDefKey, tmpBpmTaskAssignRuleDOList, bpmTaskRespVOList, userDoMap, deptMap, | ||||
|                 taskVarMap); | ||||
|             // 下个节点是网关(调用下面的方法) | ||||
|         } else if (targetFlowElement instanceof ExclusiveGateway) { | ||||
|             String defaultFlow = ((ExclusiveGateway)targetFlowElement).getDefaultFlow(); | ||||
|             FlowElement nexFlowElement = getExclusiveGateway(targetFlowElement, taskVarMap, defaultFlow); | ||||
|             getFlow(bpmnModel, nexFlowElement, tmpBpmTaskAssignRuleDOList, bpmTaskRespVOList, userDoMap, deptMap, | ||||
|                 taskVarMap); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 获取排他网关分支名称、分支表达式、下一级任务节点 | ||||
|      * | ||||
|      * @param flowElement 任务节点 | ||||
|      * @param taskVarMap  审批数据 | ||||
|      */ | ||||
|     private FlowElement getExclusiveGateway(FlowElement flowElement, Map<String, Object> taskVarMap, | ||||
|         String defaultFlow) { | ||||
|         // 获取所有网关分支 | ||||
|         List<SequenceFlow> targetFlows = ((ExclusiveGateway)flowElement).getOutgoingFlows(); | ||||
|         Boolean elExpressionFlag = Boolean.FALSE; | ||||
|         FlowElement sequenceFlowResult = null; | ||||
|         FlowElement defaultSequenceFlow = null; | ||||
|         // 循环每个网关分支 | ||||
|         for (SequenceFlow sequenceFlow : targetFlows) { | ||||
|             if (defaultFlow.equals(sequenceFlow.getId())) { | ||||
|                 defaultSequenceFlow = sequenceFlow.getTargetFlowElement(); | ||||
|                 continue; | ||||
|             } | ||||
|             elExpressionFlag = elExpression(sequenceFlow.getConditionExpression(), taskVarMap); | ||||
|             if (elExpressionFlag) { | ||||
|                 // 获取下一个网关和节点数据 | ||||
|                 FlowElement targetFlowElement = sequenceFlow.getTargetFlowElement(); | ||||
|                 // 网关的下个节点是用户节点 | ||||
|                 if (targetFlowElement instanceof UserTask) { | ||||
|                     sequenceFlowResult = targetFlowElement; | ||||
|                     break; | ||||
|                 } else if (targetFlowElement instanceof EndEvent) { | ||||
|                     log.info("排他网关的下一节点是EndEvent: 结束节点"); | ||||
|                 } else if (targetFlowElement instanceof ServiceTask) { | ||||
|                     log.info("排他网关的下一节点是ServiceTask: 内部方法"); | ||||
|                 } else if (targetFlowElement instanceof ExclusiveGateway) { | ||||
|                     defaultFlow = ((ExclusiveGateway)targetFlowElement).getDefaultFlow(); | ||||
|                     return getExclusiveGateway(targetFlowElement, taskVarMap, defaultFlow); | ||||
|                 } else if (targetFlowElement instanceof SubProcess) { | ||||
|                     log.info("排他网关的下一节点是SubProcess: 内部子流程"); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         if (!elExpressionFlag) { | ||||
|             if (defaultSequenceFlow instanceof UserTask) { | ||||
|                 sequenceFlowResult = defaultSequenceFlow; | ||||
|             } else if (defaultSequenceFlow instanceof ExclusiveGateway) { | ||||
|                 defaultFlow = ((ExclusiveGateway)defaultSequenceFlow).getDefaultFlow(); | ||||
|                 return getExclusiveGateway(defaultSequenceFlow, taskVarMap, defaultFlow); | ||||
|             } | ||||
|         } | ||||
|         return sequenceFlowResult; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 网关分叉条件判断,网关分叉,必须要有默认出口 | ||||
|      * | ||||
|      * @param elExpression el表达式 | ||||
|      * @param variableMap  流程所有变量 | ||||
|      * | ||||
|      * @return 返回true或false | ||||
|      */ | ||||
|     private Boolean elExpression(String elExpression, Map<String, Object> variableMap) { | ||||
|         ExpressionFactory factory = new ExpressionFactoryImpl(); | ||||
|         SimpleContext context = new SimpleContext(); | ||||
|         for (String k : variableMap.keySet()) { | ||||
|             if (variableMap.get(k) != null) { | ||||
|                 context.setVariable(k, | ||||
|                     factory.createValueExpression(variableMap.get(k), variableMap.get(k).getClass())); | ||||
|             } | ||||
|         } | ||||
|         ValueExpression e = factory.createValueExpression(context, elExpression, Boolean.class); | ||||
|         //el表达式和variables得到的结果 | ||||
|         return (Boolean)e.getValue(context); | ||||
|     } | ||||
| } | ||||
| @@ -17,11 +17,6 @@ | ||||
|         </foreach> | ||||
|     </delete> | ||||
|  | ||||
|     <select id="listAll" resultType="cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmActivityDO"> | ||||
|         SELECT * | ||||
|         FROM act_hi_taskinst; | ||||
|     </select> | ||||
|  | ||||
|     <select id="listAllByProcInstIdAndDelete" | ||||
|             resultType="cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmActivityDO"> | ||||
|         SELECT id_                AS `id`, | ||||
|   | ||||
| @@ -116,10 +116,11 @@ export default { | ||||
|       let todoActivity = activityList.find(m => !m.endTime) // 找到待办的任务 | ||||
|       let endActivity = activityList[activityList.length - 1] // 获得最后一个任务 | ||||
|       // debugger | ||||
|       console.log(this.bpmnModeler.getDefinitions().rootElements[0].flowElements); | ||||
|       // console.log(this.bpmnModeler.getDefinitions().rootElements[0].flowElements); | ||||
|       this.bpmnModeler.getDefinitions().rootElements[0].flowElements?.forEach(n => { | ||||
|         let activity = activityList.find(m => m.key === n.id) // 找到对应的活动 | ||||
|         if (n.$type === 'bpmn:UserTask') { // 用户任务 | ||||
|           debugger | ||||
|           if (!activity) { | ||||
|             return; | ||||
|           } | ||||
|   | ||||
| @@ -232,21 +232,27 @@ export default { | ||||
|       this.auditForms = []; | ||||
|       getTaskListByProcessInstanceId(this.id).then(response => { | ||||
|         // 审批记录 | ||||
|         this.tasks = response.data; | ||||
|         this.tasks = []; | ||||
|         // 移除已取消的审批 | ||||
|         response.data.forEach(task => { | ||||
|           if (task.result !== 4) { | ||||
|             this.tasks.push(task); | ||||
|           } | ||||
|         }); | ||||
|         // 排序,将未完成的排在前面,已完成的排在后面; | ||||
|         // this.tasks.sort((a, b) => { | ||||
|         //   // 有已完成的情况,按照完成时间倒序 | ||||
|         //   if (a.endTime && b.endTime) { | ||||
|         //     return b.endTime - a.endTime; | ||||
|         //   } else if (a.endTime) { | ||||
|         //     return 1; | ||||
|         //   } else if (b.endTime) { | ||||
|         //     return -1; | ||||
|         //     // 都是未完成,按照创建时间倒序 | ||||
|         //   } else { | ||||
|         //     return b.createTime - a.createTime; | ||||
|         //   } | ||||
|         // }); | ||||
|         this.tasks.sort((a, b) => { | ||||
|           // 有已完成的情况,按照完成时间倒序 | ||||
|           if (a.endTime && b.endTime) { | ||||
|             return b.endTime - a.endTime; | ||||
|           } else if (a.endTime) { | ||||
|             return 1; | ||||
|           } else if (b.endTime) { | ||||
|             return -1; | ||||
|             // 都是未完成,按照创建时间倒序 | ||||
|           } else { | ||||
|             return b.createTime - a.createTime; | ||||
|           } | ||||
|         }); | ||||
|  | ||||
|         // 需要审核的记录 | ||||
|         const userId = store.getters.userId; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV