工会管理-分工会干部:新增并初始化“基层干部”角色,并为已成功分配分工会干部角色的人员补齐该角色。
This commit is contained in:
@@ -34,6 +34,7 @@ RoleConstant {
|
||||
SCHOOL_OUTLAY_ADMIN("校工会经费管理员"),
|
||||
|
||||
BRANCH_UNION_ADMIN("分工会管理员"),
|
||||
BRANCH_UNION_CADRE("基层干部"),
|
||||
BRANCH_UNION_CHAIRMAN("分工会主席"),
|
||||
BRANCH_UNION_VICE_CHAIRMAN("分工会副主席"),
|
||||
BRANCH_UNION_OPERATOR("分工会操作员"),
|
||||
|
||||
@@ -357,26 +357,29 @@ public class SysUnionController {
|
||||
unionCadre.setIsJoin(true);
|
||||
dao.insert(unionCadre);
|
||||
|
||||
// 去走工作流
|
||||
boolean isAdmin = AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_ADMIN.name());
|
||||
Dict args = Dict.create();
|
||||
args.set("submit", isAdmin ? "admin" : "branch");
|
||||
args.set(FlowConst.SUBMIT_TYPE, ProcessSubmitTypeEnum.APPLY.getCode());
|
||||
args.set(FlowConst.FORM_DATA, unionCadre);
|
||||
|
||||
ProcessInstance instance = flowEngine.startProcessInstanceByKey("JCGHWY", unionCadre.getId(), SecurityUtil.getUserId(), args);
|
||||
// 自动完成第一个申请任务
|
||||
List<ProcessTask> doingTaskList = flowEngine.processTaskService().getDoingTaskList(instance.getId(), null);
|
||||
for (ProcessTask task : doingTaskList) {
|
||||
flowEngine.executeProcessTask(task.getId(), SecurityUtil.getUserId(), args);
|
||||
}
|
||||
|
||||
if (isAdmin) {
|
||||
// 如果是管理员,直接加角色
|
||||
sysRoleService.clear("sys_user_role", Cnd.where("roleId", "=", role.getId()).and("userId", "=", userId).and("unionId", "=", unionId));
|
||||
sysRoleService.insert("sys_user_role", Chain.make("roleId", role.getId()).add("userId", userId).add("unionId", unionId));
|
||||
Sys_role cadreRole = sysRoleService.getByCode(RoleConstant.BRANCH_UNION_CADRE);
|
||||
sysRoleService.clear("sys_user_role", Cnd.where("roleId", "=", cadreRole.getId()).and("userId", "=", userId).and("unionId", "=", unionId));
|
||||
sysRoleService.insert("sys_user_role", Chain.make("roleId", cadreRole.getId()).add("userId", userId).add("unionId", unionId));
|
||||
sysRoleService.clearCache();
|
||||
sysUserService.clearCache();
|
||||
} else {
|
||||
// 分工会管理员添加干部时提交校工会审核。
|
||||
Dict args = Dict.create();
|
||||
args.set("submit", "branch");
|
||||
args.set(FlowConst.SUBMIT_TYPE, ProcessSubmitTypeEnum.APPLY.getCode());
|
||||
args.set(FlowConst.FORM_DATA, unionCadre);
|
||||
|
||||
ProcessInstance instance = flowEngine.startProcessInstanceByKey("JCGHWY", unionCadre.getId(), SecurityUtil.getUserId(), args);
|
||||
// 自动完成第一个申请任务
|
||||
List<ProcessTask> doingTaskList = flowEngine.processTaskService().getDoingTaskList(instance.getId(), null);
|
||||
for (ProcessTask task : doingTaskList) {
|
||||
flowEngine.executeProcessTask(task.getId(), SecurityUtil.getUserId(), args);
|
||||
}
|
||||
}
|
||||
|
||||
return Result.success();
|
||||
@@ -385,11 +388,19 @@ public class SysUnionController {
|
||||
@At
|
||||
@ApiOperation("删除分工会人员角色")
|
||||
@SaCheckPermission("sys.manager.union.branchOfficer")
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public Result deleteBranchUnionUserRole(String userId, String roleCode, String unionId) {
|
||||
Sys_role role = sysRoleService.fetch(Cnd.where("code", "=", roleCode));
|
||||
if (Lang.isEmpty(role)) {
|
||||
throw new BaseException("无法找到{}对应编码的角色", roleCode);
|
||||
}
|
||||
Cnd unionCadreCnd = Cnd.where("userId", "=", userId)
|
||||
.and("unionId", "=", unionId).and("roleCode", "=", roleCode);
|
||||
List<Sys_union_cadre> unionCadres = dao.query(Sys_union_cadre.class, unionCadreCnd);
|
||||
// 删除干部申请时同步删除流程,避免审核列表残留空白待办。
|
||||
for (Sys_union_cadre unionCadre : unionCadres) {
|
||||
flowEngine.processInstanceService().deleteProcessInstanceByBusinessKey(unionCadre.getId());
|
||||
}
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("roleId", "=", role.getId());
|
||||
if (StrUtil.isNotBlank(userId)) {
|
||||
@@ -401,8 +412,20 @@ public class SysUnionController {
|
||||
|
||||
sysRoleService.clear("sys_user_role", cnd);
|
||||
|
||||
dao.clear(Sys_union_cadre.class, Cnd.where("userId", "=", userId)
|
||||
.and("unionId", "=", unionId).and("roleCode", "=", roleCode));
|
||||
dao.clear(Sys_union_cadre.class, unionCadreCnd);
|
||||
|
||||
List<String> branchUnionRoleCodes = sysDictService.getSubListByCode("BRANCH_UNION_ROLES")
|
||||
.stream().map(Sys_dict::getCode).toList();
|
||||
List<String> branchUnionRoleIds = CollUtil.isEmpty(branchUnionRoleCodes) ? List.of() :
|
||||
sysRoleService.query(Cnd.where("code", "in", branchUnionRoleCodes))
|
||||
.stream().map(Sys_role::getId).toList();
|
||||
int branchUnionRoleCount = CollUtil.isEmpty(branchUnionRoleIds) ? 0 : dao.count(Sys_user_role.class,
|
||||
Cnd.where("userId", "=", userId).and("unionId", "=", unionId).and("roleId", "in", branchUnionRoleIds));
|
||||
if (branchUnionRoleCount == 0) {
|
||||
Sys_role cadreRole = sysRoleService.getByCode(RoleConstant.BRANCH_UNION_CADRE);
|
||||
sysRoleService.clear("sys_user_role", Cnd.where("roleId", "=", cadreRole.getId())
|
||||
.and("userId", "=", userId).and("unionId", "=", unionId));
|
||||
}
|
||||
|
||||
sysRoleService.clearCache();
|
||||
sysUserService.clearCache();
|
||||
@@ -510,6 +533,7 @@ public class SysUnionController {
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("t.taskName", "=", "2978a74a-75c1-4f95-99f9-9c08c480f1b5");
|
||||
cnd.and("info.id", "is not", null);
|
||||
if (pageForm.getAudit()) {
|
||||
cnd.and("t.taskState", "in", List.of(ProcessTaskStateEnum.FINISHED.getCode(),
|
||||
ProcessTaskStateEnum.WITHDRAW.getCode(), ProcessTaskStateEnum.INTERRUPT.getCode()));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.budwk.app.sys.interceptor;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.budwk.app.base.constant.RoleConstant;
|
||||
import com.budwk.app.flow.constant.FlowConst;
|
||||
import com.budwk.app.flow.engine.FlowInterceptor;
|
||||
import com.budwk.app.flow.engine.core.Execution;
|
||||
@@ -44,6 +45,13 @@ public class SysUnionSchoolAuditInterceptor implements FlowInterceptor {
|
||||
sysRoleService.insert("sys_user_role", Chain.make("roleId", role.getId())
|
||||
.add("userId", unionBean.getUserId()).add("unionId", unionBean.getUnionId()));
|
||||
|
||||
// 分工会干部统一增加基层干部角色,便于按干部身份集中管理。
|
||||
Sys_role cadreRole = sysRoleService.getByCode(RoleConstant.BRANCH_UNION_CADRE);
|
||||
sysRoleService.clear("sys_user_role", Cnd.where("roleId", "=", cadreRole.getId())
|
||||
.and("userId", "=", unionBean.getUserId()).and("unionId", "=", unionBean.getUnionId()));
|
||||
sysRoleService.insert("sys_user_role", Chain.make("roleId", cadreRole.getId())
|
||||
.add("userId", unionBean.getUserId()).add("unionId", unionBean.getUnionId()));
|
||||
|
||||
// 清除缓存
|
||||
sysRoleService.clearCache();
|
||||
sysUserService.clearCache();
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
-- 初始化“基层干部”角色,并为已成功分配分工会干部角色的人员补齐该角色。
|
||||
SET @now := CAST(UNIX_TIMESTAMP(NOW()) * 1000 AS UNSIGNED);
|
||||
|
||||
INSERT INTO `sys_role`
|
||||
(`id`, `name`, `code`, `aliasName`, `disabled`, `unitid`, `note`, `sort`, `createdBy`, `createdAt`, `updatedBy`, `updatedAt`, `delFlag`)
|
||||
SELECT
|
||||
'c1d5a6e7b8f94032a1b2c3d4e5f60718', '基层干部', 'BRANCH_UNION_CADRE', 'BranchUnionCadre',
|
||||
0, NULL, '分工会干部统一身份角色', 50, '', @now, '', @now, 0
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM `sys_role` WHERE `code` = 'BRANCH_UNION_CADRE'
|
||||
);
|
||||
|
||||
INSERT INTO `sys_user_role` (`roleId`, `userId`, `unionId`)
|
||||
SELECT DISTINCT
|
||||
cadre_role.`id`, assigned_role.`userId`, assigned_role.`unionId`
|
||||
FROM `sys_user_role` assigned_role
|
||||
INNER JOIN `sys_role` business_role
|
||||
ON business_role.`id` = assigned_role.`roleId`
|
||||
INNER JOIN `sys_dict` branch_role_parent
|
||||
ON branch_role_parent.`code` = 'BRANCH_UNION_ROLES'
|
||||
INNER JOIN `sys_dict` branch_role_item
|
||||
ON branch_role_item.`parentId` = branch_role_parent.`id`
|
||||
AND branch_role_item.`code` = business_role.`code`
|
||||
INNER JOIN `sys_role` cadre_role
|
||||
ON cadre_role.`code` = 'BRANCH_UNION_CADRE'
|
||||
WHERE assigned_role.`userId` IS NOT NULL
|
||||
AND assigned_role.`unionId` IS NOT NULL
|
||||
AND assigned_role.`unionId` <> ''
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM `sys_user_role` existing_cadre
|
||||
WHERE existing_cadre.`roleId` = cadre_role.`id`
|
||||
AND existing_cadre.`userId` = assigned_role.`userId`
|
||||
AND existing_cadre.`unionId` = assigned_role.`unionId`
|
||||
);
|
||||
Reference in New Issue
Block a user