提案流程
This commit is contained in:
+75
@@ -0,0 +1,75 @@
|
|||||||
|
package com.budwk.app.zhgh.democratic.proposal.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_role;
|
||||||
|
import com.budwk.app.sys.services.SysRoleService;
|
||||||
|
import com.budwk.app.sys.views.View_user;
|
||||||
|
import com.budwk.app.zhgh.democratic.proposal.models.ProposalInfo;
|
||||||
|
import org.nutz.dao.Cnd;
|
||||||
|
import org.nutz.dao.Dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按提案申请人所属分工会分配主席审核人,不使用当前附议人的组织信息。
|
||||||
|
*/
|
||||||
|
public class ProposalApplicantBranchUnionChairmanAssignmentHandler implements AssignmentHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从流程业务编号定位提案申请人,再查询其所属分工会已启用的主席角色用户。
|
||||||
|
*
|
||||||
|
* @param model 当前审核任务模型,无需额外配置人员参数
|
||||||
|
* @param execution 流程执行上下文,流程实例的 businessNo 应为提案 ID
|
||||||
|
* @return 分工会主席用户 ID 列表;申请人或主席配置缺失时抛出业务异常
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<String> assign(TaskModel model, Execution execution) {
|
||||||
|
Dao dao = ServiceContext.find(Dao.class);
|
||||||
|
String proposalId = execution.getProcessInstance().getBusinessNo();
|
||||||
|
ProposalInfo proposal = StrUtil.isBlank(proposalId) ? null : dao.fetch(ProposalInfo.class, proposalId);
|
||||||
|
if (proposal == null || StrUtil.isBlank(proposal.getCreateUserId())) {
|
||||||
|
throw new BaseException("提案申请人不存在,无法分配分工会主席审核人");
|
||||||
|
}
|
||||||
|
|
||||||
|
View_user applicant = dao.fetch(View_user.class, Cnd.where(View_user::getId, "=", proposal.getCreateUserId()));
|
||||||
|
if (applicant == null || StrUtil.isBlank(applicant.getUnionId())) {
|
||||||
|
throw new BaseException("提案申请人未设置所属分工会,无法分配主席审核人");
|
||||||
|
}
|
||||||
|
|
||||||
|
Sys_role chairmanRole = ServiceContext.find(SysRoleService.class)
|
||||||
|
.getByCode(RoleConstant.BRANCH_UNION_CHAIRMAN);
|
||||||
|
if (chairmanRole == null) {
|
||||||
|
throw new BaseException("分工会主席角色不存在,请联系校工会进行设置");
|
||||||
|
}
|
||||||
|
List<String> chairmanIds = dao.query(Sys_user_role.class,
|
||||||
|
Cnd.where(Sys_user_role::getRoleId, "=", chairmanRole.getId())
|
||||||
|
.and(Sys_user_role::getUnionId, "=", applicant.getUnionId())
|
||||||
|
.and(Sys_user_role::getEnable, "=", true))
|
||||||
|
.stream()
|
||||||
|
.map(Sys_user_role::getUserId)
|
||||||
|
.filter(StrUtil::isNotBlank)
|
||||||
|
.distinct()
|
||||||
|
.toList();
|
||||||
|
if (chairmanIds.isEmpty()) {
|
||||||
|
throw new BaseException("提案申请人所属分工会没有设置主席,请联系校工会进行设置");
|
||||||
|
}
|
||||||
|
return chairmanIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMessage() {
|
||||||
|
return "提案申请人所属分工会主席";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getOrder() {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user