权限阅览导入事件修改

This commit is contained in:
Mr-wang 2023-11-03 11:24:29 +08:00
parent 2e57d2b17f
commit e7307e3d5c
2 changed files with 89 additions and 2 deletions

View File

@ -0,0 +1,87 @@
package com.actionsoft.apps.coe.pal.publisher.event;
import com.actionsoft.bpms.bo.engine.BO;
import com.actionsoft.bpms.commons.database.RowMap;
import com.actionsoft.bpms.dw.exec.event.ideimport.DataWindowBeforeImport;
import com.actionsoft.bpms.dw.exec.imp.model.ImportModel;
import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.bpms.util.DBSql;
import com.actionsoft.exception.AWSException;
import java.util.List;
import java.util.Map;
public class DataWindowImportBeforeEvent extends DataWindowBeforeImport {
@Override
public boolean excute(UserContext userContext, String s, String s1, List<ImportModel> list, String s2, Map<String, Object> map) throws AWSException {
for (ImportModel importModel:list){
BO bo = importModel.getBo();
String orgPerm = bo.getString("ORGPERM");
String postPerm = bo.getString("POSTPERM");
String levelPerm = bo.getString("LEVELPERM");
mapNameSToIds(bo, orgPerm, 0);
mapNameSToIds(bo, postPerm, 1);
}
return false;
}
/**
* 将导入的权限名称转换为对应id或编码
*
* @param bo bo表
* @param map map
* @param permTypeName 权限类型名称
* @param type 权限类型
* @author wangpf
*/
private void mapNameSToIds(BO bo, String permTypeName, int type) {
String[] names = permTypeName.split("\\s+|\\.|\\|\\,|@");
String ids = "";
for (String name : names) {
String sql = generateSqlByType(type, name);
List<RowMap> maps = DBSql.getMaps(sql);
if (maps != null && maps.size() == 1) {
ids += maps.get(0).getString("ID") + ",";
}
}
if (ids.length() > 0) {
if (type == 0) {
bo.set("ORGPERM", ids.substring(0, ids.length() - 1));
}
if (type == 1) {
bo.set("POSTPERM", ids.substring(0, ids.length() - 1));
}
if (type == 2) {
bo.set("LEVELPERM", ids.substring(0, ids.length() - 1));
}
}
}
/**
* 根据权限类型生成sql
*
* @param type 权限类型
* @param name 权限名称
* @return {@link String}
*/
private String generateSqlByType(int type, String name) {
String sql = "";
switch (type) {
case 0:
sql = "SELECT ID,DEPARTMENTNAME FROM orgdepartment WHERE DEPARTMENTNAME = '" + name + "'";
break;
case 1:
sql = "SELECT ROLENO AS ID,ROLENAME FROM ORGROLE WHERE ROLENAME = '" + name + "'";
break;
case 2:
sql = "SELECT RANKSUB_NO AS ID,RANKSUB_NAME FROM BO_ACT_PAL_LEVEL_SUB WHERE RANKSUB_NAME = '" + name + "'";
break;
}
return sql;
}
}

View File

@ -52,7 +52,7 @@ public class PermissionReadingDataWindowValidateEvent extends DataWindowValidate
} }
} }
} }
if (ids.length() > 0) { /*if (ids.length() > 0) {
if (type == 0) { if (type == 0) {
bo.set("ORGPERM", ids.substring(0, ids.length() - 1)); bo.set("ORGPERM", ids.substring(0, ids.length() - 1));
} }
@ -63,7 +63,7 @@ public class PermissionReadingDataWindowValidateEvent extends DataWindowValidate
if (type == 2) { if (type == 2) {
bo.set("LEVELPERM", ids.substring(0, ids.length() - 1)); bo.set("LEVELPERM", ids.substring(0, ids.length() - 1));
} }
} }*/
} }
/** /**