This commit is contained in:
@jyuhsin
2026-01-30 13:42:01 +08:00
parent 7393cc2421
commit 6dab151b79
7 changed files with 342 additions and 21 deletions
@@ -0,0 +1,79 @@
package com.budwk.app.flow.handler;
import cn.hutool.core.util.StrUtil;
import com.budwk.app.base.constant.RoleConstant;
import com.budwk.app.base.exception.BaseException;
import com.budwk.app.flow.engine.AssignmentHandler;
import com.budwk.app.flow.engine.core.Execution;
import com.budwk.app.flow.engine.core.ServiceContext;
import com.budwk.app.flow.engine.model.TaskModel;
import com.budwk.app.sys.models.Sys_role;
import com.budwk.app.sys.models.Sys_user;
import com.budwk.app.sys.models.Sys_user_role;
import com.budwk.app.sys.services.SysRoleService;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.lang.Lang;
import java.util.List;
/**
* @ClassName FlowGeneralViceDelegationAuditSelfUnitByArgsAssignmentHandler
* @Author JyuHsin
* @Date 2026/1/30 10:14
* @Version 1.0
* @Description 获取代表团副团长,只有联合代表团才有副团长审核,而且只审核副团长自己单位的提案
*/
public class FlowGeneralViceDelegationAuditSelfUnitByArgsAssignmentHandler implements AssignmentHandler {
@Override
public List<String> assign(TaskModel model, Execution execution) {
String sessionId = execution.getArgs().getStr("sessionId");
String delegationId = execution.getArgs().getStr("delegationId");
String unitId = execution.getArgs().getStr("unitId");
if (StrUtil.isBlank(sessionId)) {
throw new BaseException("参数 sessionId 不能为空");
}
if (StrUtil.isBlank(delegationId)) {
throw new BaseException("参数 delegationId 不能为空");
}
if (StrUtil.isBlank(unitId)) {
throw new BaseException("参数 unitId 不能为空");
}
SysRoleService sysRoleService = ServiceContext.find(SysRoleService.class);
Sys_role role = sysRoleService.getByCode(RoleConstant.TEACHER_CONGRESS_VICE_DELEGATION_HEAD);
List<Sys_user_role> roles = ServiceContext.find(Dao.class).query(
Sys_user_role.class,
Cnd.where(Sys_user_role::getRoleId, "=", role.getId())
.and(Sys_user_role::getTcDelegationId, "=", delegationId)
.and(Sys_user_role::getTcSessionId, "=", sessionId)
);
if (Lang.isEmpty(roles)) {
throw new RuntimeException("您所在的代表团没有设置副团长,无法流转到下一步,请联系校工会进行设置。");
}
List<String> list = roles.stream().map(Sys_user_role::getUserId).toList();
List<Sys_user> userList = ServiceContext.find(Dao.class).query(Sys_user.class, Cnd.where(Sys_user::getId, "in", list));
// 过滤本单位的副团长
List<Sys_user> auditUserList = userList.stream().filter(user -> user.getUnitId().equals(unitId)).toList();
if (Lang.isEmpty(auditUserList)) {
throw new RuntimeException("您所在的代表团没有设置和您所在单位相符的副团长。");
}
return auditUserList.stream().map(Sys_user::getId).toList();
}
@Override
public String getMessage() {
return "获取代表团副团长(审核副团长本单位,根据args中的sessionId和delegationId和unitId)";
}
@Override
public int getOrder() {
return AssignmentHandler.super.getOrder();
}
}