权限申请流程代码优化
This commit is contained in:
parent
828f298f40
commit
9da178e32f
@ -0,0 +1,30 @@
|
||||
package com.actionsoft.apps.coe.pal.publisher.at;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryPropertyCache;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryPropertyModel;
|
||||
import com.actionsoft.apps.coe.pal.publisher.constant.FilePermConstant;
|
||||
import com.actionsoft.bpms.bo.engine.BO;
|
||||
import com.actionsoft.bpms.commons.at.AbstExpression;
|
||||
import com.actionsoft.bpms.commons.at.ExpressionContext;
|
||||
import com.actionsoft.exception.AWSExpressionException;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
|
||||
public class GetPALFilePublisherAt extends AbstExpression {
|
||||
public GetPALFilePublisherAt(ExpressionContext atContext, String expressionValue) {
|
||||
super(atContext, expressionValue);
|
||||
}
|
||||
@Override
|
||||
public String execute(String expression) throws AWSExpressionException {
|
||||
//获取PAL文件ID,有可能是多个,逗号隔开
|
||||
String fileIds = getParameter(expression, 1);
|
||||
String targets = "";
|
||||
String[] ids = fileIds.split(",");
|
||||
for (String fileId : ids) {
|
||||
BO bo = SDK.getBOAPI().query(FilePermConstant.BO_ACT_COE_PUBLISH_N).addQuery("PUBLISHFILEID=", fileId).orderBy("ISEND").desc().orderByCreated().detail();
|
||||
targets += bo.getCreateUser()+",";
|
||||
}
|
||||
targets = targets.substring(0, targets.length() - 1);
|
||||
return targets;
|
||||
}
|
||||
}
|
||||
@ -6,5 +6,9 @@ public interface FilePermConstant {
|
||||
|
||||
public static final String BO_ACT_FILE_PERM = "BO_ACT_FILE_PERM";//文件阅览权限申请
|
||||
public static final String BO_ACT_PUBLISH_PERM_SCOPE = "BO_ACT_PUBLISH_PERM_SCOPE";//文件阅览权限台账表
|
||||
public static final String BO_EU_ORG_POSTS = "BO_EU_ORG_POSTS ";//岗位对照表
|
||||
public static final String BO_ACT_COE_PUBLISH_N = "BO_ACT_COE_PUBLISH_N ";//流程发布新增表
|
||||
|
||||
public static final String obj_e076b01bd0d04bc39e5af12e2c8c188c = "obj_e076b01bd0d04bc39e5af12e2c8c188c";//文件阅览权限台账DEF
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package com.actionsoft.apps.coe.pal.publisher.event;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryPropertyCache;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryPropertyModel;
|
||||
import com.actionsoft.apps.coe.pal.publisher.constant.FilePermConstant;
|
||||
import com.actionsoft.bpms.bo.engine.BO;
|
||||
import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
|
||||
@ -7,44 +9,109 @@ import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListener;
|
||||
import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListenerInterface;
|
||||
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance;
|
||||
import com.actionsoft.bpms.util.UUIDGener;
|
||||
import com.actionsoft.bpms.util.UtilString;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 申请权限流程,归档结束后,增加权限
|
||||
*/
|
||||
public class AddFilePermTaskEndEvent extends ExecuteListener implements ExecuteListenerInterface {
|
||||
public String getDescription() {
|
||||
return "申请权限流程,归档结束后,增加权限";
|
||||
return "申请权限流程,归档结束后,按照不同的申请类型增加权限";
|
||||
}
|
||||
public final String wsId = "7d3ca852-a0bd-42e6-80b1-3dcea6f55083";
|
||||
public final String sendScope = "0";
|
||||
@Override
|
||||
public void execute(ProcessExecutionContext ctx) throws Exception {
|
||||
BO bo = ctx.getBO(FilePermConstant.BO_ACT_FILE_PERM);
|
||||
createOrUpdatePublishScope(ctx,bo);
|
||||
//需要判断申请类型
|
||||
String applyType = bo.getString("APPLYTYPE");//申请类型
|
||||
if (applyType.equals("单一权限申请")) {
|
||||
updatePublishScopeSingleFile(ctx,bo);
|
||||
} else if (applyType.equals("批量权限申请")) {
|
||||
//批量申请方式
|
||||
String applyMothod = bo.getString("APPLYMOTHOD");
|
||||
if(applyMothod.equals("按流程架构申请")){
|
||||
updatePublishScopeProcess(ctx,bo);
|
||||
}else{//按发布部门申请
|
||||
updatePublishScopeDept(ctx,bo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public void createOrUpdatePublishScope(ProcessExecutionContext ctx,BO sourceBo) throws Exception {
|
||||
String sendScope = "0";
|
||||
String wsId = "7d3ca852-a0bd-42e6-80b1-3dcea6f55083";
|
||||
//先查询有没有记录,有则更新,无则新增
|
||||
String applyfiles = sourceBo.getString("APPLYFILES");
|
||||
BO oldBo = SDK.getBOAPI().query(FilePermConstant.BO_ACT_PUBLISH_PERM_SCOPE).addQuery("PALVERSIONID=", applyfiles).detail();
|
||||
if(oldBo==null){
|
||||
BO bo = new BO();
|
||||
bo.set("PERMID", UUIDGener.getUUID());
|
||||
bo.set("WSID", wsId);
|
||||
bo.set("PALVERSIONID", sourceBo.getString("APPLYFILES"));
|
||||
bo.set("PALNAME", sourceBo.getString("APPLYFILENAMES"));
|
||||
bo.set("PERMTYPE", sendScope);
|
||||
bo.set("ORGPERM", ctx.getUserContext().getDepartmentModel().getId());
|
||||
//存储发布流程的流程实例ID,与权限阅览数据视图做关联
|
||||
ProcessInstance boProcessInstance = SDK.getProcessAPI()
|
||||
.createBOProcessInstance("obj_e076b01bd0d04bc39e5af12e2c8c188c", ctx.getUserContext().getUID(), "权限阅览");
|
||||
SDK.getBOAPI().create(FilePermConstant.BO_ACT_PUBLISH_PERM_SCOPE, bo, boProcessInstance.getId(), ctx.getUserContext().getUID());
|
||||
|
||||
/**
|
||||
* 单一授权申请更新
|
||||
* @param ctx
|
||||
* @param sourceBo
|
||||
* @throws Exception
|
||||
*/
|
||||
public void updatePublishScopeSingleFile(ProcessExecutionContext ctx,BO sourceBo){
|
||||
String applyfileIds = sourceBo.getString("APPLYFILEIDS");//待申请权限的文件
|
||||
String[] files = applyfileIds.split(",");
|
||||
for (String fileId : files) {
|
||||
BO oldBo = SDK.getBOAPI().query(FilePermConstant.BO_ACT_PUBLISH_PERM_SCOPE).addQuery("PALVERSIONID=", fileId).detail();
|
||||
updateData(ctx,oldBo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程架构申请更新
|
||||
* @param ctx
|
||||
* @param sourceBo
|
||||
* @param wsId
|
||||
*/
|
||||
public void updatePublishScopeProcess(ProcessExecutionContext ctx,BO sourceBo){
|
||||
String architectureScopeId = sourceBo.getString("ARCHITECTURESCOPEID");//架构范围
|
||||
String[] files = architectureScopeId.split(",");
|
||||
for (String fileId : files) {
|
||||
BO oldBo = SDK.getBOAPI().query(FilePermConstant.BO_ACT_PUBLISH_PERM_SCOPE).addQuery("PALVERSIONID=", fileId).detail();
|
||||
updateData(ctx,oldBo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布部门更新
|
||||
* @param ctx
|
||||
* @param sourceBo
|
||||
* @param wsId
|
||||
*/
|
||||
public void updatePublishScopeDept(ProcessExecutionContext ctx,BO sourceBo){
|
||||
//先查询发布部门为当前部门一致的权限
|
||||
String publishDept = sourceBo.getString("PUBLISHDEPT");//所选发布部门
|
||||
String inClause = "'" + String.join("', '", publishDept.split(",")) + "'";
|
||||
List<BO> list = SDK.getBOAPI().query(FilePermConstant.BO_ACT_PUBLISH_PERM_SCOPE).addQuery("PUBLISHDEPTID IN (" + inClause + ")", null).list();
|
||||
for (BO oldBo : list) {
|
||||
updateData(ctx,oldBo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
* @param ctx
|
||||
* @param oldBo
|
||||
*/
|
||||
public void updateData(ProcessExecutionContext ctx,BO oldBo){
|
||||
if(null==oldBo){
|
||||
return;
|
||||
}
|
||||
String postPerm = oldBo.getString("POSTPERM");
|
||||
String thisPerm = ctx.getUserContext().getUserModel().getPositionNo();
|
||||
if(postPerm.contains(thisPerm)){//如果已经存在该岗位,则不再更新
|
||||
return;
|
||||
}else{
|
||||
String orgPerm = oldBo.getString("ORGPERM");
|
||||
orgPerm +=","+ctx.getUserContext().getDepartmentModel().getId();
|
||||
oldBo.set("ORGPERM",orgPerm);
|
||||
if(UtilString.isEmpty(postPerm)){
|
||||
postPerm = thisPerm;
|
||||
}else{
|
||||
postPerm +=","+thisPerm;
|
||||
}
|
||||
oldBo.set("POSTPERM",postPerm);
|
||||
SDK.getBOAPI().update(FilePermConstant.BO_ACT_PUBLISH_PERM_SCOPE,oldBo);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user