diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/LeaveApplyEndProcessor.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/LeaveApplyEndProcessor.java index bfdbcae2c..59685cc66 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/LeaveApplyEndProcessor.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/LeaveApplyEndProcessor.java @@ -28,6 +28,7 @@ public class LeaveApplyEndProcessor implements ExecutionListener { final Object approved = delegateExecution.getVariable("approved"); OALeaveDO updateDo = new OALeaveDO(); updateDo.setId(Long.valueOf(businessKey)); + // TODO @jason:代码的格式哈。} else { 。另外,这里可以简化成,二元表达式 if (Objects.equals(approved, true)) { updateDo.setStatus(FlowStatusEnum.PASS.getStatus()); }else{ diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/impl/OALeaveServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/impl/OALeaveServiceImpl.java index 42c5840c4..9ccc281d0 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/impl/OALeaveServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/impl/OALeaveServiceImpl.java @@ -26,11 +26,9 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; -import javax.validation.constraints.NotNull; import java.util.*; import static cn.iocoder.yudao.adminserver.modules.bpm.enums.oa.OAErrorCodeConstants.*; -import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.POST_CODE_DUPLICATE; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; /** @@ -116,6 +114,7 @@ public class OALeaveServiceImpl implements OALeaveService { } } + // TODO @jason:要不,请假不支持删除,只支持取消? @Override public void deleteLeave(Long id) { // 校验存在 diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/TaskService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/TaskService.java index c358d8706..f2dc5aa79 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/TaskService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/TaskService.java @@ -6,7 +6,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import javax.servlet.http.HttpServletResponse; import java.util.List; - +// TODO @jason:前缀 /** * 用户任务服务接口 */ @@ -25,14 +25,13 @@ public interface TaskService { */ void claimTask(String taskId); - + // TODO @jason:可以把实现方法的注释,统一写到接口里 /** * 办理完成用户任务 * @param taskReq 任务参数, 包含任务的参数,和 评论 */ void completeTask(TaskReqVO taskReq); - /** * 根据任务id, 查询已经完成的用户任务,未完成的用户任务 * @param taskQuery 查询参数 一般 taskId @@ -45,7 +44,6 @@ public interface TaskService { */ List getHistorySteps(String processInstanceId); - /** * 获取用户任务的 formKey, 对应外置表单, 需要根据formKey 对应业务表单 * @param taskQuery 查询参数 ,一般taskId diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/impl/TaskServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/impl/TaskServiceImpl.java index 70c29e866..d9cb60a70 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/impl/TaskServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/impl/TaskServiceImpl.java @@ -174,21 +174,24 @@ public class TaskServiceImpl implements TaskService { public void getHighlightImg(String processInstanceId, HttpServletResponse response) { // 查询历史 //TODO 云扬四海 貌似流程结束后,点击审批进度会报错 - HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); - // 如果有结束时间 + // TODO @Li:一些 historyService 的查询,貌似比较通用,是不是抽一些小方法出来 + HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); + // 如果有结束时间 TODO @Li:如果查询不到,是不是抛出一个业务异常比较好哈? if (hpi == null) { return; } // 没有结束时间。说明流程在执行过程中 + // TODO @Li:一些 runtimeService 的查询,貌似比较通用,是不是抽一些小方法出来 ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); - BpmnModel bpmnModel = repositoryService.getBpmnModel(pi.getProcessDefinitionId()); + BpmnModel bpmnModel = repositoryService.getBpmnModel(pi.getProcessDefinitionId()); // TODO @Li:这块和下面的逻辑比较相关,可以在后面一点查询。 List highLightedActivities = new ArrayList<>(); List historicActivityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId) - .orderByHistoricActivityInstanceId().asc().list(); + .orderByHistoricActivityInstanceId().asc().list(); // TODO @Li:这块和下面的逻辑比较相关,可以在后面一点查询。 // 获取所有活动节点 List finishedInstances = historyService.createHistoricActivityInstanceQuery() .processInstanceId(processInstanceId).finished().list(); + // TODO @Li:highLightedActivities 结果,可以使用 CollUtils.buildList() 方法。即使不用,也应该用 stream。简洁很重要。 for (HistoricActivityInstance hai : finishedInstances) { highLightedActivities.add(hai.getActivityId()); } @@ -199,6 +202,7 @@ public class TaskServiceImpl implements TaskService { List highLightedFlowIds = getHighLightedFlows(bpmnModel, historicActivityInstances); //设置"宋体" + // TODO @Li:Service 返回 bytes,最终 Controller 去写 try (InputStream inputStream = processDiagramGenerator.generateDiagram(bpmnModel, highLightedActivities, highLightedFlowIds, "宋体", "宋体", "宋体")){ String picName = hpi.getProcessDefinitionName()+".svg"; @@ -207,9 +211,9 @@ public class TaskServiceImpl implements TaskService { } catch (IOException e) { log.error(ExceptionUtils.getStackTrace(e)); } - } + // TODO @Li:参考 ServletUtils 方法。如果没有满足的,可以在写一个。 private void responseImage(HttpServletResponse response, InputStream inputStream, String picName) throws IOException { response.setContentType("application/octet-stream;charset=UTF-8"); response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(picName, "UTF-8")); @@ -220,6 +224,8 @@ public class TaskServiceImpl implements TaskService { } response.flushBuffer(); } + + // TODO @Li:这个方法的可读性还有一定的优化空间,可以思考下哈。 /** * 获取已经流转的线 https://blog.csdn.net/qiuxinfa123/article/details/119579863 * @see @@ -244,6 +250,7 @@ public class TaskServiceImpl implements TaskService { } } + // TODO @Li:这两个变量,直接放到循环里。这种优化一般不需要做的,对性能影响超级小。 FlowNode currentFlowNode; FlowNode targetFlowNode; // 遍历已完成的活动实例,从每个实例的outgoingFlows中找到已执行的 @@ -252,11 +259,10 @@ public class TaskServiceImpl implements TaskService { currentFlowNode = (FlowNode) bpmnModel.getMainProcess().getFlowElement(currentActivityInstance.getActivityId(), true); List sequenceFlows = currentFlowNode.getOutgoingFlows(); - /** - * 遍历outgoingFlows并找到已流转的 满足如下条件认为已已流转: - * 1.当前节点是并行网关或兼容网关,则通过outgoingFlows能够在历史活动中找到的全部节点均为已流转 - * 2.当前节点是以上两种类型之外的,通过outgoingFlows查找到的时间最早的流转节点视为有效流转 - */ + // 遍历outgoingFlows并找到已流转的 满足如下条件认为已已流转: + // 1.当前节点是并行网关或兼容网关,则通过outgoingFlows能够在历史活动中找到的全部节点均为已流转 + // 2.当前节点是以上两种类型之外的,通过outgoingFlows查找到的时间最早的流转节点视为有效流转 + // TODO @Li:“parallelGateway” 和 "inclusiveGateway",有对应的枚举么?如果木有,可以自己枚举哈 if ("parallelGateway".equals(currentActivityInstance.getActivityType()) || "inclusiveGateway".equals(currentActivityInstance.getActivityType())) { // 遍历历史活动节点,找到匹配流程目标节点的 for (SequenceFlow sequenceFlow : sequenceFlows) { @@ -266,6 +272,7 @@ public class TaskServiceImpl implements TaskService { } } } else { + // TODO @Li:如果是为了获取到时间更早的一个,是不是遍历的过程中,就可以解决 List> tempMapList = new ArrayList<>(); for (SequenceFlow sequenceFlow : sequenceFlows) { for (HistoricActivityInstance historicActivityInstance : historicActivityInstances) { @@ -283,6 +290,7 @@ public class TaskServiceImpl implements TaskService { long earliestStamp = 0L; String highLightedFlowId = null; for (Map map : tempMapList) { + // TODO @Li:可以使用 MapUtil 去 get 值 long highLightedFlowStartTime = Long.valueOf(map.get("highLightedFlowStartTime").toString()); if (earliestStamp == 0 || earliestStamp >= highLightedFlowStartTime) { highLightedFlowId = map.get("highLightedFlowId").toString(); diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/mysql/user/SysUserMapper.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/mysql/user/SysUserMapper.java index 0b0a6dbe2..85f7b5fa1 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/mysql/user/SysUserMapper.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/mysql/user/SysUserMapper.java @@ -56,6 +56,7 @@ public interface SysUserMapper extends BaseMapperX { return selectList(new QueryWrapperX().like("username", username)); } + // TODO jason:变量平铺比较好 default List selectListByBaseVO(SysUserBaseVO reqVO) { return selectList(new QueryWrapperX().likeIfPresent("username", reqVO.getUsername()) .likeIfPresent("nickname", reqVO.getNickname()) diff --git a/yudao-framework/yudao-spring-boot-starter-activiti/pom.xml b/yudao-framework/yudao-spring-boot-starter-activiti/pom.xml index 08ac8c4bc..c2b403f62 100644 --- a/yudao-framework/yudao-spring-boot-starter-activiti/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-activiti/pom.xml @@ -19,6 +19,7 @@ 7.1.0.M6 + diff --git a/yudao-framework/yudao-spring-boot-starter-activiti/src/main/java/cn/iocoder/yudao/framework/activiti/config/YudaoActivitiConfiguration.java b/yudao-framework/yudao-spring-boot-starter-activiti/src/main/java/cn/iocoder/yudao/framework/activiti/config/YudaoActivitiConfiguration.java index 6ce7991ac..a6edd0a44 100644 --- a/yudao-framework/yudao-spring-boot-starter-activiti/src/main/java/cn/iocoder/yudao/framework/activiti/config/YudaoActivitiConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-activiti/src/main/java/cn/iocoder/yudao/framework/activiti/config/YudaoActivitiConfiguration.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.framework.activiti.config; +import lombok.AllArgsConstructor; import org.activiti.api.runtime.shared.identity.UserGroupManager; import org.activiti.image.ProcessDiagramGenerator; import org.activiti.image.impl.DefaultProcessDiagramGenerator; @@ -14,24 +15,27 @@ import org.springframework.stereotype.Component; public class YudaoActivitiConfiguration { - + // TODO @Li:可以说明下 ProcessDiagramGenerator 作用 @Bean public ProcessDiagramGenerator processDiagramGenerator (){ return new DefaultProcessDiagramGenerator(); } + + /** + * ProcessEngineConfigurationConfigurer 实现类,设置使用 MyBatis SqlSessionFactory + */ @Component + @AllArgsConstructor public static class SqlSessionFactoryProcessEngineConfigurationConfigurer implements ProcessEngineConfigurationConfigurer { private final SqlSessionFactory sqlSessionFactory; - public SqlSessionFactoryProcessEngineConfigurationConfigurer(SqlSessionFactory sessionFactory) { - this.sqlSessionFactory = sessionFactory; - } @Override public void configure(SpringProcessEngineConfiguration springProcessEngineConfiguration) { springProcessEngineConfiguration.setSqlSessionFactory(sqlSessionFactory); } + }