From e7307e3d5c22408279fd841fee13ec4a8e61c1f7 Mon Sep 17 00:00:00 2001 From: Mr-wang Date: Fri, 3 Nov 2023 11:24:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=83=E9=99=90=E9=98=85=E8=A7=88=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E4=BA=8B=E4=BB=B6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/DataWindowImportBeforeEvent.java | 87 +++++++++++++++++++ ...missionReadingDataWindowValidateEvent.java | 4 +- 2 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/DataWindowImportBeforeEvent.java diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/DataWindowImportBeforeEvent.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/DataWindowImportBeforeEvent.java new file mode 100644 index 00000000..392fafca --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/DataWindowImportBeforeEvent.java @@ -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 list, String s2, Map 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 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; + } + +} diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PermissionReadingDataWindowValidateEvent.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PermissionReadingDataWindowValidateEvent.java index 8dfaed6c..d880feea 100644 --- a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PermissionReadingDataWindowValidateEvent.java +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/event/PermissionReadingDataWindowValidateEvent.java @@ -52,7 +52,7 @@ public class PermissionReadingDataWindowValidateEvent extends DataWindowValidate } } } - if (ids.length() > 0) { + /*if (ids.length() > 0) { if (type == 0) { bo.set("ORGPERM", ids.substring(0, ids.length() - 1)); } @@ -63,7 +63,7 @@ public class PermissionReadingDataWindowValidateEvent extends DataWindowValidate if (type == 2) { bo.set("LEVELPERM", ids.substring(0, ids.length() - 1)); } - } + }*/ } /**