休学和给与退学

This commit is contained in:
2025-09-14 17:12:29 +08:00
parent 1d17ec90ef
commit 85c9bb5b66
2 changed files with 32 additions and 27 deletions

View File

@@ -1,60 +1,65 @@
package com.srs.flowable.listener.disciplinary;
import com.srs.common.utils.WeChatUtil;
import com.srs.common.utils.spring.SpringUtils;
import com.srs.flowable.mapper.DisciplinaryMapper;
import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.ExecutionListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.List;
@Component
/**
* 学工领导审批监听器
* 使用 @Component + @Autowired兼容 Flowable Delegate Expression
*/
@Component("xgldshListener")
@Slf4j
public class XGLDSHListener implements ExecutionListener {
@Autowired
private DisciplinaryMapper disciplinaryMapper;
@Autowired
private WeChatUtil weChatUtil;
@Override
public void notify(DelegateExecution delegateExecution) {
DisciplinaryMapper disciplinaryMapper = SpringUtils.getBean(DisciplinaryMapper.class);
public void notify(DelegateExecution execution) {
// 固定角色 Key
final String TARGET_ROLE_KEY = "xgldsp";
String processInstanceId = execution.getProcessInstanceId();
// 步骤 1: 查询角色下的所有审批人 userId
log.info("流程实例 [{}]: 触发 XGLDSHListener为角色 '{}' 节点准备数据...", processInstanceId, TARGET_ROLE_KEY);
// 查询角色下审批人
List<Long> userIdList = disciplinaryMapper.getApprovalByRoleKey(TARGET_ROLE_KEY);
if (userIdList == null || userIdList.isEmpty()) {
throw new RuntimeException("未找到角色 '" + TARGET_ROLE_KEY + "' 的审批人员,无法发送通知。");
if (CollectionUtils.isEmpty(userIdList)) {
log.error("流程实例 [{}]: 角色 '{}' 未配置审批人员", processInstanceId, TARGET_ROLE_KEY);
throw new RuntimeException("学工领导审批人员未设置");
}
// 发送企微通知
sendWeChatNotification(userIdList, processInstanceId, TARGET_ROLE_KEY);
}
private void sendWeChatNotification(List<Long> userIdList, String processInstanceId, String roleKey) {
try {
// 步骤 2: 查询 userName 列表
List<String> userNameList = disciplinaryMapper.getUserNamesByUserIdList(userIdList);
if (CollectionUtils.isEmpty(userNameList)) {
log.warn("流程实例 [{}]: 角色 '{}' 审批人存在但无人配置企微账号", processInstanceId, roleKey);
return;
}
if (userNameList != null && !userNameList.isEmpty()) {
String toUser = String.join("|", userNameList);
WeChatUtil weChatUtil = SpringUtils.getBean(WeChatUtil.class);
String content = "您有一条新的学生违纪审批任务待处理," +
"<a href='http://zhxg.gxsdxy.cn/web/#/pages/Approval/index'>请点击前往处理</a>";
"<a href='http://zhxg.gxsdxy.cn/web/#/pages/Approval/index'>请点击前往处理</a>";
// 步骤 3: 发送企业微信通知
weChatUtil.sendTextMessage(toUser, content);
log.info("已成功向角色 '{}' 成员发送企业微信审批通知接收人: {}", TARGET_ROLE_KEY, toUser);
} else {
log.warn("角色 '{}' 下找到 {} 个用户,但无对应的企业微信账号,无法发送通知。", TARGET_ROLE_KEY, userIdList.size());
}
log.info("流程实例 [{}]: 已成功向角色 '{}' 成员发送企通知接收人: {}", processInstanceId, roleKey, toUser);
} catch (Exception e) {
log.error("向角色 '{}' 发送企业微信通知时出现异常,但流程将继续。错误详情: {}", TARGET_ROLE_KEY, e.getMessage(), e);
log.error("流程实例 [{}]: 向角色 '{}' 发送企微通知异常", processInstanceId, roleKey, e);
}
}
}

View File

@@ -114,7 +114,7 @@ public class RtStuQuitSchoolServiceImpl extends ServiceImpl<RtStuQuitSchoolMappe
variables.put("approval", SecurityUtils.getUserId());
variables.put("deptId", SecurityUtils.getDeptId());
AjaxResult ajaxResult = flowDefinitionService.startProcessInstanceById("flow_vxuubvdh:14:915008", variables);
AjaxResult ajaxResult = flowDefinitionService.startProcessInstanceById("flow_vxuubvdh:20:962552", variables);
String code = ajaxResult.get("code").toString();
if (code.equals("200")) {