From abfa995a320ba69faf35fb84535e913cef4a13b3 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期四, 17 十月 2024 18:12:26 +0800 Subject: [PATCH] update 优化 监听器兼容所有demo案例 --- ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java | 35 +++++++++++++++++++++++------------ 1 files changed, 23 insertions(+), 12 deletions(-) diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java index 9d14bc8..f81c85f 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java @@ -46,9 +46,7 @@ */ @Override public TestLeaveVo queryById(Long id) { - TestLeaveVo testLeaveVo = baseMapper.selectVoById(id); - testLeaveVo.setProcessInstanceId(workflowService.getInstanceIdByBusinessKey(String.valueOf(id))); - return testLeaveVo; + return baseMapper.selectVoById(id); } /** @@ -113,34 +111,47 @@ public Boolean deleteWithValidByIds(Collection<Long> ids) { List<String> idList = StreamUtils.toList(ids, String::valueOf); workflowService.deleteRunAndHisInstance(idList); - return baseMapper.deleteBatchIds(ids) > 0; + return baseMapper.deleteByIds(ids) > 0; } /** * 鎬讳綋娴佺▼鐩戝惉(渚嬪: 鎻愪氦 閫�鍥� 鎾ら攢 缁堟 浣滃簾绛�) + * 姝e父浣跨敤鍙渶#processEvent.key=='leave1' + * 绀轰緥涓轰簡鏂逛究鍒欎娇鐢╯tartsWith鍖归厤浜嗗叏閮ㄧず渚媖ey * * @param processEvent 鍙傛暟 */ - @EventListener(condition = "#processEvent.key=='leave1'") + @EventListener(condition = "#processEvent.key.startsWith('leave')") public void processHandler(ProcessEvent processEvent) { log.info("褰撳墠浠诲姟鎵ц浜唟}", processEvent.toString()); TestLeave testLeave = baseMapper.selectById(Long.valueOf(processEvent.getBusinessKey())); testLeave.setStatus(processEvent.getStatus()); + if (processEvent.isSubmit()) { + testLeave.setStatus(BusinessStatusEnum.WAITING.getStatus()); + } baseMapper.updateById(testLeave); } /** * 鎵ц鍔炵悊浠诲姟鐩戝惉 + * 绀轰緥锛氫篃鍙�氳繃 @EventListener(condition = "#processTaskEvent.key=='leave1'")杩涜鍒ゆ柇 + * 鍦ㄦ柟娉曚腑鍒ゆ柇娴佺▼鑺傜偣key + * if ("xxx".equals(processTaskEvent.getTaskDefinitionKey())) { + * //鎵ц涓氬姟閫昏緫 + * } * * @param processTaskEvent 鍙傛暟 */ - @EventListener(condition = "#processTaskEvent.keyNode=='leave1_Activity_14633hx'") + @EventListener(condition = "#processTaskEvent.key.startsWith('leave')") public void processTaskHandler(ProcessTaskEvent processTaskEvent) { - log.info("褰撳墠浠诲姟鎵ц浜唟}", processTaskEvent.toString()); - TestLeave testLeave = baseMapper.selectById(Long.valueOf(processTaskEvent.getBusinessKey())); - testLeave.setStatus(BusinessStatusEnum.WAITING.getStatus()); - baseMapper.updateById(testLeave); + // 鎵�鏈塪emo妗堜緥鐨勭敵璇蜂汉鑺傜偣id + String[] ids = {"Activity_14633hx", "Activity_19b1i4j", "Activity_0uscrk3", + "Activity_0uscrk3", "Activity_0x6b71j", "Activity_0zy3g6j", "Activity_06a55t0"}; + if (StringUtils.equalsAny(processTaskEvent.getTaskDefinitionKey(), ids)) { + log.info("褰撳墠浠诲姟鎵ц浜唟}", processTaskEvent.toString()); + TestLeave testLeave = baseMapper.selectById(Long.valueOf(processTaskEvent.getBusinessKey())); + testLeave.setStatus(BusinessStatusEnum.WAITING.getStatus()); + baseMapper.updateById(testLeave); + } } - - } -- Gitblit v1.9.3