Commit 7efc9eba by 宋祥

1.数据权限开发

parent d341d9f1
package com.baosight.hpjx.common;
import com.baosight.iplat4j.core.ei.EiBlock;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 数据权限类型
*
* @author:songx
* @date:2024/3/21,9:58
*/
public enum AuthTypeEnum {
ONLY_FACTORY("onlyFactory", "本厂"),
ONLY_DEPT("onlyDept", "本部门");
/**
* 编码
*/
private String code;
/**
* 中文名称
*/
private String name;
AuthTypeEnum(String code, String name) {
this.code = code;
this.name = name;
}
/**
* 根据编码获取
*
* @param code
* @return
*/
public static AuthTypeEnum getByCode(String code) {
for (AuthTypeEnum item : AuthTypeEnum.values()) {
if (item.getCode().equals(code)) {
return item;
}
}
return null;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package com.baosight.hpjx.core.configuration;
import com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext;
import com.baosight.iplat4j.eu.dm.PlatFileUploadManagerByAmazonS3;
import com.baosight.iplat4j.eu.dm.util.PlatFileUploader;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import lombok.extern.slf4j.Slf4j;
/**
* 初始化注入bean
*
* @author:songx
* @date:2024/3/13,15:03
*/
@Slf4j
@Configuration
@ConditionalOnProperty(
name = {"iplat4j.admin.objectStorage.s3.switch"},
havingValue = "on"
)
public class ConfigurationBean {
@Bean(name = "platFileUploader")
public PlatFileUploader newPlatFileUploader() {
return new PlatFileUploader();
}
@Bean(name = "fileUpLoadManager")
public PlatFileUploadManagerByAmazonS3 newPlatFileUploadManagerByAmazonS3() {
return new PlatFileUploadManagerByAmazonS3();
}
}
......@@ -119,9 +119,9 @@ public class DaoUtils {
}
// 创建人部门编码
try {
BeanUtils.setProperty(bean, "depCode", HPXSTools.getOrgId());
BeanUtils.setProperty(bean, "depCode", HPXSTools.XsOrg.getOrgId());
} catch (Exception e) {
log.warn("写入创建人企业编码失败", e);
log.warn("写入创建人部门编码失败", e);
}
// 创建时刻
try {
......@@ -175,7 +175,7 @@ public class DaoUtils {
}
// 创建人部门编码
try {
map.put("depCode", HPXSTools.getOrgId());
map.put("depCode", HPXSTools.XsOrg.getOrgId());
} catch (Exception e) {
log.warn("写入创建人企业编码失败", e);
}
......
......@@ -7,7 +7,6 @@ import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.soa.XLocalManager;
import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import com.baosight.xservices.xs.util.LoginUserDetails;
import org.apache.commons.collections.MapUtils;
import java.util.concurrent.ConcurrentHashMap;
......@@ -20,8 +19,6 @@ import java.util.concurrent.ConcurrentMap;
public class UserSessionUtils extends UserSession {
private static ConcurrentMap companyMap = new ConcurrentHashMap();
private static ConcurrentMap depMap = new ConcurrentHashMap();
private static ConcurrentMap userAdminMap = new ConcurrentHashMap();
/**
* 获取用户信息
......@@ -79,31 +76,7 @@ public class UserSessionUtils extends UserSession {
if (loginName == null) {
return null;
}
String depCode = MapUtils.getString(depMap, loginName);
if (depCode == null) {
depCode = HPXSTools.getOrgId();
depCode = depCode == null ? "" : depCode.trim();
depMap.put(loginName, depCode);
}
return depCode;
}
/**
* 获取登录用户是否超级管理员
*
* @return
*/
public static boolean isUserAdmin() {
String loginName = getLoginName();
if (loginName == null) {
return false;
}
Boolean isUserAdmin = MapUtils.getBoolean(userAdminMap, loginName);
if (isUserAdmin == null) {
isUserAdmin = LoginUserDetails.isUserAdmin(loginName);
userAdminMap.put(loginName, isUserAdmin);
}
return isUserAdmin;
return HPXSTools.XsOrg.getOrgId();
}
}
......@@ -252,8 +252,6 @@ public class HPSqlConstant {
*/
public class HPPZ010 {
// 新增
public static final String INSERT = "HPPZ010.insert";
// 查询
public static final String QUERY = "HPPZ010.query";
}
......
package com.baosight.hpjx.hp.mt.service;
import cn.hutool.core.util.PageUtil;
import cn.hutool.core.util.StrUtil;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
......@@ -10,10 +9,7 @@ import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.constant.HPSqlConstant;
import com.baosight.hpjx.hp.mt.untils.Base64ToMultipartFile;
import com.baosight.hpjx.hp.mt.untils.Base64Utils;
import com.baosight.hpjx.hp.mt.untils.UploadUtils;
import com.baosight.hpjx.hp.sc.domain.HPSC002A;
import com.baosight.hpjx.hp.sc.domain.HPSC005;
import com.baosight.hpjx.hp.xs.domain.User;
import com.baosight.hpjx.hp.zl.domain.HPZL001;
import com.baosight.hpjx.hp.zl.domain.HPZL001A;
......@@ -26,12 +22,7 @@ import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import net.sf.json.JSONObject;
import org.apache.commons.collections.MapUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import javax.imageio.ImageIO;
......
......@@ -233,10 +233,9 @@ public class ServiceHPPZ009 extends ServiceBase {
HPPZ009 fPz009 = new HPPZ009();
fPz009.fromMap(resultRows.get(i));
// 校验企业下是否存在用户
int count = HPXSTools.countByCompany(fPz009.getCompanyCode());
int count = HPXSTools.XsUser.countByCompany(fPz009.getCompanyCode());
if (count > 0) {
throw new PlatException(String.format("企业[%s]已关联用户,请先解除用户",
fPz009.getCompanyName()));
throw new PlatException(String.format("企业[%s]已关联用户,请先解除用户", fPz009.getCompanyName()));
}
DaoUtils.update(HPPZ009.DELETE, fPz009);
}
......
......@@ -4,15 +4,10 @@ import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.core.enums.UserStatusEnum;
import com.baosight.hpjx.core.security.UserSessionUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.constant.HPSqlConstant;
import com.baosight.hpjx.hp.pz.domain.HPPZ013;
import com.baosight.hpjx.hp.pz.domain.HPPZ01301;
import com.baosight.hpjx.hp.pz.domain.HPPZ014;
import com.baosight.hpjx.hp.pz.domain.HPPZ01401;
import com.baosight.hpjx.hp.pz.tools.HPPZTools;
import com.baosight.hpjx.hp.xs.tools.HPXSTools;
import com.baosight.hpjx.util.AssertUtils;
import com.baosight.hpjx.util.CommonMethod;
......@@ -23,7 +18,6 @@ import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.collections.CollectionUtils;
......
......@@ -20,6 +20,9 @@
<sql id="condition">
AND DELETE_FLAG = 0
<isNotEmpty prepend=" " property="dataAuthCondition">
$dataAuthCondition$
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
......
......@@ -4,43 +4,52 @@
<sql id="column">
ID as "id",
SUBJECT_ID as "subjectId", <!-- 授权主体ID -->
SUBJECT_TYPE as "subjectType", <!-- 授权主体类别 -->
OBJECT_ID as "objectId", <!-- 授权客体ID -->
OBJECT_TYPE as "objectType", <!-- 授权客体类别 -->
COMPANY_CODE as "companyCode", <!-- 企业编码 -->
DEP_CODE as "depCode", <!-- 部门编码 -->
CREATED_BY as "createdBy", <!-- 创建人 -->
CREATED_NAME as "createdName", <!-- 创建人名称 -->
CREATED_TIME as "createdTime", <!-- 创建时间 -->
UPDATED_BY as "updatedBy", <!-- 更新人 -->
UPDATED_NAME as "updatedName", <!-- 更新人名称 -->
UPDATED_TIME as "updatedTime" <!-- 更新时间 -->
UPDATED_TIME as "updatedTime", <!-- 更新时间 -->
PAGE_ENAME as "pageEname", <!-- 页面英文名 -->
PAGE_CNAME as "pageCname", <!-- 页面中文名 -->
CUSTOM_AUTH as "customAuth", <!-- 自定义权限 -->
DEP_AUTH as "depAuth" <!-- 部门权限 -->
</sql>
<sql id="condition">
<isNotEmpty prepend=" AND " property="id">
ID = #id#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="subjectId">
SUBJECT_ID = #subjectId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="subjectType">
SUBJECT_TYPE = #subjectType#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="objectId">
OBJECT_ID = #objectId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="objectType">
OBJECT_TYPE = #objectType#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="id">
ID = #id#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCode">
COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="depCode">
DEP_CODE = #depCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="pageEname">
PAGE_ENAME = #pageEname#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="pageCname">
PAGE_CNAME = #pageCname#
</isNotEmpty>
</sql>
<!-- 公共修改字段 -->
<sql id="updateRevise">
UPDATED_BY = #updatedBy#,
UPDATED_NAME = #updatedName#,
UPDATED_TIME = #updatedTime#
</sql>
<sql id="orderBy">
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
</isNotEmpty>
<isEmpty property="orderBy">
ID asc
ID ASC
</isEmpty>
</dynamic>
</sql>
......@@ -58,20 +67,57 @@
<include refid="condition" />
</select>
<!-- 查询树节点 -->
<select id="queryTreeNode" resultClass="java.util.HashMap">
SELECT
TREE_ENAME AS "parent",
NODE_ENAME AS "label",
NODE_CNAME AS "text",
(CASE WHEN NODE_TYPE='2' THEN 0 ELSE 1 END) AS "leaf",
NODE_SORT_ID AS "sortIndex"
FROM ${platSchema}.TEDPI10
WHERE 1=1
AND NODE_ENAME NOT IN ('EP') <!-- 排除系统页面 -->
<isNotEmpty prepend=" AND " property="node">
TREE_ENAME = #node#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="nodeEnames">
NODE_ENAME IN <iterate close=")" open="(" conjunction="," property="nodeEnames">#nodeEnames[]#</iterate>
</isNotEmpty>
<!-- nodeType=2:目录。非目录或者非管理员非root节点仅显示有权限的菜单 -->
<isEqual prepend=" AND " property="isOnlyAuth" compareValue="Y">
(NODE_TYPE = '2' OR NODE_ENAME IN (
SELECT D.RESOURCE_ENAME
FROM ${platSchema}.XS_USER A,
${platSchema}.XS_USER_GROUP_MEMBER B,
${platSchema}.XS_AUTHORIZATION C,
${platSchema}.XS_RESOURCE D
WHERE A.USER_ID = B.MEMBER_ID
AND B.PARENT_ID = C.SUBJECT_ID
AND C.OBJECT_ID = D.ID
AND A.LOGIN_NAME = #loginName#
AND D.TYPE = 'PAGE'
))
</isEqual>
ORDER BY NODE_SORT_ID ASC
</select>
<insert id="insert">
INSERT INTO ${hpjxSchema}.T_HPPZ010 (
SUBJECT_ID, <!-- 授权主体ID -->
SUBJECT_TYPE, <!-- 授权主体类别 -->
OBJECT_ID, <!-- 授权客体ID -->
OBJECT_TYPE, <!-- 授权客体类别 -->
CREATED_BY, <!-- 创建人 -->
CREATED_NAME, <!-- 创建人名称 -->
CREATED_TIME <!-- 创建时间 -->
COMPANY_CODE, <!-- 企业编码 -->
DEP_CODE, <!-- 部门编码 -->
CREATED_BY, <!-- 创建人 -->
CREATED_NAME, <!-- 创建人名称 -->
CREATED_TIME, <!-- 创建时间 -->
PAGE_ENAME, <!-- 页面英文名 -->
PAGE_CNAME, <!-- 页面中文名 -->
CUSTOM_AUTH, <!-- 自定义权限 -->
DEP_AUTH <!-- 部门权限 -->
) VALUES (
#subjectId#, #subjectType#, #objectId#, #objectType#, #createdBy#,
#createdName#, #createdTime#
#companyCode#, #depCode#, #createdBy#, #createdName#, #createdTime#,
#pageEname#, #pageCname#, #customAuth#, #depAuth#
)
</insert>
</insert>
<delete id="delete">
DELETE FROM ${hpjxSchema}.T_HPPZ010 WHERE ID = #id#
......@@ -79,14 +125,9 @@
<update id="update">
UPDATE ${hpjxSchema}.T_HPPZ010
SET
SUBJECT_ID = #subjectId#, <!-- 授权主体ID -->
SUBJECT_TYPE = #subjectType#, <!-- 授权主体类别 -->
OBJECT_ID = #objectId#, <!-- 授权客体ID -->
OBJECT_TYPE = #objectType#, <!-- 授权客体类别 -->
UPDATED_BY = #updatedBy#, <!-- 更新人 -->
UPDATED_NAME = #updatedName#, <!-- 更新人名称 -->
UPDATED_TIME = #updatedTime# <!-- 更新时间 -->
SET CUSTOM_AUTH = #customAuth#, <!-- 权限类型 -->
DEP_AUTH = #depAuth#, <!-- 部门权限 -->
<include refid="updateRevise"/>
WHERE ID = #id#
</update>
......
......@@ -4,12 +4,14 @@ import com.baosight.hpjx.common.InventTypeEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoBase;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.core.security.UserSessionUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.constant.HPSqlConstant;
import com.baosight.hpjx.hp.pz.domain.HPPZ004;
import com.baosight.hpjx.hp.pz.domain.HPPZ006;
import com.baosight.hpjx.hp.pz.domain.HPPZ007;
import com.baosight.hpjx.hp.pz.domain.HPPZ009;
import com.baosight.hpjx.hp.pz.domain.HPPZ010;
import com.baosight.hpjx.hp.pz.domain.HPPZ011;
import com.baosight.hpjx.hp.pz.domain.HPPZ013;
import com.baosight.hpjx.hp.pz.domain.HPPZ015;
......@@ -544,6 +546,35 @@ public class HPPZTools {
}
/**
* 数据权限管理
*
* @author:songx
* @date:2024/3/20,14:20
*/
public static class HpPz010 {
/**
* 查询菜单权限
*
* @param pageEname
* @return
*/
public static HPPZ010 getByPage(String pageEname) {
AssertUtils.isNull(pageEname, "菜单ID不能为空");
String companyCode = UserSessionUtils.getCompanyCode();
if (StringUtils.isBlank(companyCode)) {
return null;
}
Map queryMap = new HashMap();
queryMap.put(HPPZ010.FIELD_COMPANY_CODE, UserSessionUtils.getCompanyCode());
queryMap.put(HPPZ010.FIELD_PAGE_ENAME, pageEname);
List<HPPZ010> results = DaoBase.getInstance().query(HPPZ010.QUERY, queryMap);
return CollectionUtils.isEmpty(results) ? null : results.get(0);
}
}
/**
* @author:songx
* @date:2024/3/14,20:59
*/
......
......@@ -2,33 +2,12 @@ package com.baosight.hpjx.hp.sc.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.HPConstants;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.pz.tools.HPPZTools;
import com.baosight.hpjx.hp.sc.domain.HPSC005;
import com.baosight.hpjx.hp.sc.domain.HPSC006;
import com.baosight.hpjx.hp.sc.tools.HPSCTools;
import com.baosight.hpjx.hp.xs.tools.HPXSTools;
import com.baosight.hpjx.util.AssertUtils;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.StringUtil;
import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.core.util.NumberUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
......
......@@ -3,7 +3,6 @@ package com.baosight.hpjx.hp.sc.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.ProdOrderStatusEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoBase;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
......@@ -20,7 +19,6 @@ import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.collections.CollectionUtils;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
......
......@@ -6,8 +6,6 @@ import com.baosight.hpjx.common.ProdOrderStatusEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.pz.domain.HPPZ011;
import com.baosight.hpjx.hp.pz.tools.HPPZTools;
import com.baosight.hpjx.hp.sc.domain.HPSC005;
import com.baosight.hpjx.hp.sc.domain.HPSC005A;
import com.baosight.hpjx.hp.sc.tools.HPSCTools;
......
package com.baosight.hpjx.hp.sc.service;
import cn.hutool.core.bean.BeanUtil;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.HPConstants;
import com.baosight.hpjx.common.ProdOrderStatusEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.core.security.UserSessionUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.ds.domain.HPDS002;
import com.baosight.hpjx.hp.pz.domain.HPPZ011;
import com.baosight.hpjx.hp.pz.tools.HPPZTools;
import com.baosight.hpjx.hp.sc.domain.*;
import com.baosight.hpjx.hp.sc.tools.HPSCTools;
import com.baosight.hpjx.hp.xs.domain.Org;
import com.baosight.hpjx.hp.xs.tools.HPXSTools;
import com.baosight.hpjx.util.*;
import com.baosight.iplat4j.core.ProjectInfo;
......@@ -25,13 +20,11 @@ import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.core.service.soa.XServiceManager;
import com.baosight.iplat4j.core.util.NumberUtils;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.lang.StringUtils;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
......
......@@ -2,25 +2,18 @@ package com.baosight.hpjx.hp.sc.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.core.security.UserSessionUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.pz.tools.HPPZTools;
import com.baosight.hpjx.hp.sc.domain.HPSC004;
import com.baosight.hpjx.hp.sc.domain.HPSC005;
import com.baosight.hpjx.hp.sc.domain.HPSC006;
import com.baosight.hpjx.hp.sc.domain.HPSC007;
import com.baosight.hpjx.hp.sc.tools.HPSCTools;
import com.baosight.hpjx.hp.xs.domain.User;
import com.baosight.hpjx.util.*;
import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.core.service.soa.XLocalManager;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import java.math.BigDecimal;
import java.text.DecimalFormat;
......
......@@ -2,10 +2,8 @@ package com.baosight.hpjx.hp.sc.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.hp.pz.domain.HPPZ011;
import com.baosight.hpjx.hp.sc.domain.HPSC001;
import com.baosight.hpjx.hp.sc.domain.HPSC098;
import com.baosight.hpjx.hp.xs.domain.Org;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.iplat4j.core.ei.EiConstant;
......
......@@ -33,6 +33,21 @@ public class Org implements Serializable {
*/
private String parentOrgId;
/**
* 厂区编码
*/
private String factoryCode;
/**
* 厂区名称
*/
private String factoryName;
/**
* 层级
*/
private String level;
public String getOrgId() {
return orgId;
}
......@@ -73,4 +88,27 @@ public class Org implements Serializable {
this.parentOrgId = parentOrgId;
}
public String getFactoryCode() {
return factoryCode;
}
public void setFactoryCode(String factoryCode) {
this.factoryCode = factoryCode;
}
public String getFactoryName() {
return factoryName;
}
public void setFactoryName(String factoryName) {
this.factoryName = factoryName;
}
public String getLevel() {
return level;
}
public void setLevel(String level) {
this.level = level;
}
}
package com.baosight.hpjx.hp.xs.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.core.security.UserSessionUtils;
import com.baosight.hpjx.hp.xs.domain.User;
......@@ -18,6 +17,8 @@ import java.util.List;
import java.util.Map;
/**
* 当前类已屏蔽SQL自动补全企业参数,如需查询需要需自行添加企业编码参数
*
* @author:songx
* @date:2024/1/15,15:08
*/
......@@ -90,6 +91,7 @@ public class ServiceHPXSUser extends ServiceBase {
}
List<DdynamicEnum> list = new ArrayList<>();
list.add(DdynamicEnum.COMPANY_RECORD_BLOCK_ID);
queryMap.put("companyCode", UserSessionUtils.getCompanyCode());
CommonMethod.initBlock(inInfo, list, queryMap, false);
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "查询企业失败");
......
......@@ -4,20 +4,20 @@
Version : 1.0
schema : hpjx
tableName : TEUDM_TEMP
COMPANY_CODE VARCHAR NOT NULL primarykey,
DOC_ID VARCHAR NOT NULL primarykey,
DIR_ID VARCHAR NOT NULL,
DOC_NAME VARCHAR NOT NULL,
CHG_NAME VARCHAR NOT NULL,
DOC_SIZE DECIMAL NOT NULL,
DOC_TAG VARCHAR NOT NULL,
CREATED_BY VARCHAR NOT NULL,
CREATED_NAME VARCHAR NOT NULL,
CREATED_TIME VARCHAR NOT NULL,
UPDATED_BY VARCHAR NOT NULL,
UPDATED_NAME VARCHAR NOT NULL,
UPDATED_TIME VARCHAR NOT NULL,
ARCHIVE_FLAG VARCHAR NOT NULL,
COMPANY_CODE VARCHAR NOT NULL primarykey,
DOC_ID VARCHAR NOT NULL primarykey,
DIR_ID VARCHAR NOT NULL,
DOC_NAME VARCHAR NOT NULL,
CHG_NAME VARCHAR NOT NULL,
DOC_SIZE DECIMAL NOT NULL,
DOC_TAG VARCHAR NOT NULL,
CREATED_BY VARCHAR NOT NULL,
CREATED_NAME VARCHAR NOT NULL,
CREATED_TIME VARCHAR NOT NULL,
UPDATED_BY VARCHAR NOT NULL,
UPDATED_NAME VARCHAR NOT NULL,
UPDATED_TIME VARCHAR NOT NULL,
ARCHIVE_FLAG VARCHAR NOT NULL,
REAL_PATH VARCHAR
-->
<sqlMap namespace="HPXS002">
......
......@@ -63,6 +63,33 @@
<include refid="customCondition"/>
</select>
<!-- 查询企业所有的组织机构 -->
<select id="queryAll" parameterClass="java.util.HashMap" resultClass="com.baosight.hpjx.hp.xs.domain.Org">
SELECT
T2.LEVEL AS "level", T3.ORG_ID AS "orgId",
(CASE WHEN T3.ORG_TYPE = 'factory' THEN T3.ORG_CNAME ELSE CONCAT('[',T5.FACTORY_NAME,']',T3.ORG_CNAME) END) AS "orgCname",
T3.ORG_TYPE AS "orgType", T3.FACTORY_CODE AS "factoryCode", T5.FACTORY_NAME AS "factoryName"
FROM (
SELECT
@CODES AS CODES,
(SELECT @CODES:=GROUP_CONCAT(ORG_ID)
FROM ${platSchema}.TXSOG01
WHERE FIND_IN_SET(PARENT_ORG_ID, @CODES)
AND COMPANY_CODE = #companyCode#
AND IS_DELETED = 0
) AS T1,
@LEVEL:=@LEVEL+1 AS LEVEL
FROM ${platSchema}.TXSOG01,
(SELECT @CODES:='root', @LEVEL:= 0) T4
WHERE @CODES IS NOT NULL
) T2,
${platSchema}.TXSOG01 T3
LEFT JOIN ${platSchema}.TXSOG01 T5 ON T3.FACTORY_CODE = T5.ORG_ID
WHERE 1=1
AND FIND_IN_SET(T3.ORG_ID, T2.CODES)
ORDER BY T3.FACTORY_CODE ASC, T2.LEVEL ASC, T3.ORG_ID ASC
</select>
<!-- 查询父级信息(递归) -->
<select id="queryParent" resultClass="com.baosight.hpjx.hp.xs.domain.Org">
SELECT
......
......@@ -2,6 +2,7 @@ package com.baosight.hpjx.hp.xs.tools;
import com.baosight.hpjx.core.dao.DaoBase;
import com.baosight.hpjx.core.enums.OrgTypeEnum;
import com.baosight.hpjx.core.security.UserSessionUtils;
import com.baosight.hpjx.hp.xs.domain.Org;
import com.baosight.hpjx.hp.xs.domain.User;
import com.baosight.hpjx.util.AssertUtils;
......@@ -29,31 +30,6 @@ import java.util.stream.Collectors;
public class HPXSTools {
/**
* 统计企业下的用户数量
*
* @param companyCode
* @return
*/
public static int countByCompany(String companyCode) {
Map paramMap = new HashMap();
paramMap.put("companyCode", companyCode);
List<Integer> results = DaoBase.getInstance().query("HPXSUser.count", paramMap);
return CollectionUtils.isEmpty(results) ? 0 : results.get(0);
}
/**
* 查询用户组织机构
*
* @return
*/
public static String getOrgId() {
Map paramMap = new HashMap();
paramMap.put("userId", UserSession.getLoginName());
List<Map> results = DaoBase.getInstance().query("HPXSUser.queryOrgId", paramMap);
return CollectionUtils.isEmpty(results) ? "" : results.get(0).get("orgId").toString();
}
/**
* @author:songx
* @date:2024/2/4,10:35
*/
......@@ -102,6 +78,19 @@ public class HPXSTools {
}
/**
* 统计企业下的用户数量
*
* @param companyCode
* @return
*/
public static int countByCompany(String companyCode) {
Map paramMap = new HashMap();
paramMap.put("companyCode", companyCode);
List<Integer> results = DaoBase.getInstance().query("HPXSUser.count", paramMap);
return CollectionUtils.isEmpty(results) ? 0 : results.get(0);
}
/**
* 初始化新增用户
*
* @param companyCode
......@@ -179,6 +168,18 @@ public class HPXSTools {
}
/**
* 查询用户组织机构
*
* @return
*/
public static String getOrgId() {
Map paramMap = new HashMap();
paramMap.put("userId", UserSession.getLoginName());
List<Map> results = DaoBase.getInstance().query("HPXSUser.queryOrgId", paramMap);
return CollectionUtils.isEmpty(results) ? "" : results.get(0).get("orgId").toString();
}
/**
* 查询
*
* @param orgId
......@@ -208,7 +209,27 @@ public class HPXSTools {
AssertUtils.isNull(results, String.format("组织[%s]不存在厂区信息", orgId));
return results.get(0);
}
/**
* 查询企业下所有组织按厂区分组
*
* @return
*/
public static Map<String, List<Org>> queryAllFactoryMap() {
String companyCode = UserSessionUtils.getCompanyCode();
if (StringUtils.isBlank(companyCode)) {
return null;
}
Map queryMap = new HashMap();
queryMap.put("companyCode", companyCode);
List<Org> results = DaoBase.getInstance().query("HPXSOrg.queryAll", queryMap);
if (CollectionUtils.isEmpty(results)) {
return null;
}
return results.stream().filter(org -> StringUtils.isNotNull(org.getFactoryCode()))
.collect(Collectors.groupingBy(Org::getFactoryCode));
}
/**
* 查询
*
......
......@@ -6,8 +6,6 @@ import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.constant.HPSqlConstant;
import com.baosight.hpjx.hp.sc.tools.HPSCTools;
import com.baosight.hpjx.hp.xs.tools.HPXSTools;
import com.baosight.hpjx.hp.zl.domain.HPZL001;
import com.baosight.hpjx.util.AssertUtils;
import com.baosight.hpjx.util.CommonMethod;
......@@ -17,7 +15,6 @@ import com.baosight.hpjx.util.StringUtil;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.collections.MapUtils;
......
......@@ -26,26 +26,7 @@ public class LogUtils {
* @return
*/
public static void setDetailMsg(EiInfo inInfo, Throwable e, String title) {
title = StringUtils.isEmpty(title) ? "服务异常" : title;
// 打印日志
print(e, title);
// 设置EiInfo错误消息
if (inInfo == null) {
return;
}
inInfo.setStatus(EiConstant.STATUS_FAILURE);
inInfo.setMsg(title);
if (e == null) {
inInfo.setDetailMsg("");
return;
}
// 由于平台调用链不支持查看detailMsg的消息内容,因此这里修改成往Msg中写错误信息
inInfo.setDetailMsg(e.getMessage());
if (e instanceof PlatException) {
inInfo.setMsg(inInfo.getMsg().concat(",原因:").concat(e.getMessage()));
} else {
inInfo.setMsg(inInfo.getMsg().concat(",原因参见详细错误描述!"));
}
setMsg(inInfo, e, title);
}
/**
......@@ -70,7 +51,11 @@ public class LogUtils {
inInfo.setMsg(msg.concat("未知"));
return;
}
inInfo.setMsg(msg.concat(e.getMessage()));
if (e instanceof PlatException) {
inInfo.setMsg(msg.concat(e.getMessage()));
} else {
inInfo.setMsg(msg.concat("内部错误,请稍后再试"));
}
}
/**
......
package com.baosight.iplat4j.core.data.ibatis.dao;
import com.baosight.hpjx.common.AuthTypeEnum;
import com.baosight.hpjx.core.security.UserSessionUtils;
import com.baosight.hpjx.hp.pz.domain.HPPZ010;
import com.baosight.hpjx.hp.pz.tools.HPPZTools;
import com.baosight.hpjx.util.MapUtils;
import com.baosight.hpjx.util.ObjectUtils;
import com.baosight.hpjx.util.StringUtils;
import com.baosight.iplat4j.core.service.soa.DomainQuery.PageStatus;
import com.baosight.iplat4j.core.util.ExceptionUtil;
......@@ -24,7 +29,7 @@ public class SqlMapDaoLogProxy extends SqlMapDao {
public List query(String name, Object parameters) {
try {
// 初始化参数
this.initParam(name, parameters);
this.setCompanyCode(name, parameters);
List ret = super.query(name, parameters);
return ret;
} catch (RuntimeException var4) {
......@@ -35,7 +40,7 @@ public class SqlMapDaoLogProxy extends SqlMapDao {
public List queryAll(String name, Object parameters) {
try {
// 初始化参数
this.initParam(name, parameters);
this.setCompanyCode(name, parameters);
List ret = super.queryAll(name, parameters);
return ret;
} catch (RuntimeException var4) {
......@@ -46,7 +51,7 @@ public class SqlMapDaoLogProxy extends SqlMapDao {
public List query(String name, Object parameters, int offset, int limit) {
try {
// 初始化参数
this.initParam(name, parameters);
this.setCompanyCode(name, parameters);
List ret = super.query(name, parameters, offset, limit);
return ret;
} catch (RuntimeException var6) {
......@@ -72,7 +77,7 @@ public class SqlMapDaoLogProxy extends SqlMapDao {
try {
// 初始化参数
this.initParam(name, parameters);
this.setCompanyCode(name, parameters);
int ret = super.count(name, parameters);
return ret;
} catch (RuntimeException var5) {
......@@ -149,12 +154,12 @@ public class SqlMapDaoLogProxy extends SqlMapDao {
}
/**
* 初始化参数
* 设置企业编码
*
* @param name
* @param parameters
*/
private void initParam(String name, Object parameters) {
private void setCompanyCode(String name, Object parameters) {
// 查询登录用户信息时不设置企业编码,否则会形成死循环
// 仅限业务模块的查询需要设置企业编码
if (name.startsWith("HPXSUser") || !name.startsWith("HP") || !(parameters instanceof Map)) {
......@@ -168,4 +173,69 @@ public class SqlMapDaoLogProxy extends SqlMapDao {
// 部门编码
// ((Map) parameters).put("depCode", UserSessionUtils.getDepCode());
}
/**
* 设置数据权限
*
* @param name
* @param parameters
*/
private void setDataAuth(String name, Object parameters) {
// 仅限业务模块的查询需要设置企业编码
if (name.startsWith("HPXSUser") || !name.startsWith("HP") || !(parameters instanceof Map)) {
return;
}
if (parameters == null) {
parameters = new HashMap();
}
// 页面英文名
String pageEname = MapUtils.getString((Map) parameters, "pageEname");
if (StringUtils.isBlank(pageEname)) {
return;
}
// 组装权限条件
HPPZ010 dbPz010 = HPPZTools.HpPz010.getByPage(pageEname);
if (dbPz010 == null || StringUtils.isBlank(dbPz010.getCustomAuth())
|| StringUtils.isBlank(dbPz010.getDepAuth())) {
((Map) parameters).put("dataAuthCondition", " AND DEP_CODE = 'NOT AUTH'");
return;
}
buildCustomCondition(dbPz010);
buildDepCondition(dbPz010);
}
/**
* 组装 Custom Data Auth Condition
*
* @param dbPz010
*/
private void buildCustomCondition(HPPZ010 dbPz010) {
if (StringUtils.isBlank(dbPz010.getCustomAuth())) {
return;
}
String[] customAuths = dbPz010.getCustomAuth().split(",");
for (String item : customAuths) {
AuthTypeEnum authTypeEnum = AuthTypeEnum.getByCode(item);
if (authTypeEnum == null) {
continue;
}
}
}
/**
* 组装 Dep Data Auth Condition
*
* @param dbPz010
*/
private void buildDepCondition(HPPZ010 dbPz010) {
if (StringUtils.isBlank(dbPz010.getDepAuth())) {
return;
}
String[] depAuths = dbPz010.getDepAuth().split(",");
for (String item : depAuths) {
}
}
}
......@@ -26,7 +26,6 @@ import com.baosight.xservices.xs.util.LoginUserDetails;
import org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......
package com.baosight.xservices.xs.og.service;
import com.baosight.hpjx.core.constant.CodesetConstant;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.enums.OrgTypeEnum;
import com.baosight.hpjx.core.security.UserSessionUtils;
import com.baosight.hpjx.core.tools.CodeValueTools;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.kc.domain.HPKC010;
import com.baosight.hpjx.hp.xs.domain.Org;
import com.baosight.hpjx.hp.xs.tools.HPXSTools;
......@@ -13,19 +11,13 @@ import com.baosight.hpjx.util.DateUtils;
import com.baosight.hpjx.util.EiInfoUtils;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.MapUtils;
import com.baosight.hpjx.util.StringUtils;
import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import com.baosight.iplat4j.core.service.soa.XServiceManager;
import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import com.baosight.xservices.xs.og.domain.XSOG01;
import com.baosight.xservices.xs.util.LoginUserDetails;
import org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
......
package com.baosight.xservices.xs.service;
import com.baosight.hpjx.core.security.UserSessionUtils;
import com.baosight.iplat4j.core.FrameworkInfo;
import com.baosight.iplat4j.core.ei.EiBlockMeta;
import com.baosight.iplat4j.core.ei.EiColumn;
......@@ -41,10 +40,10 @@ public class ServiceXS0705 extends MenuTreeService {
public List getChildNodes(String parentLabel) {
String manageSwitch = StringUtils.defaultIfEmpty(PlatApplicationContext.getProperty("xservices.security.manage.switch"), "off");
Map params = new HashMap();
if (StringUtils.isEmpty(parentLabel) || "$".equals(parentLabel)) {
parentLabel = "root";
}
Map params = new HashMap();
String loginName = UserSession.getUser().getUsername();
params.put("node", parentLabel);
params.put("loginName", loginName);
......@@ -61,46 +60,41 @@ public class ServiceXS0705 extends MenuTreeService {
List ret = this.dao.query(stmt, params);
if ("off".equals(manageSwitch)) {
return ret;
} else {
List ret2 = new ArrayList();
for(int i = 0; i < ret.size(); ++i) {
Map node = (Map)ret.get(i);
String text = node.get("text").toString();
if (text.indexOf("[页面]") > 0) {
ret2.add(0, ret.get(i));
} else {
ret2.add(ret.get(i));
}
}
List ret2 = new ArrayList();
for (int i = 0; i < ret.size(); ++i) {
Map node = (Map) ret.get(i);
String text = node.get("text").toString();
if (text.indexOf("[页面]") > 0) {
ret2.add(0, ret.get(i));
} else {
ret2.add(ret.get(i));
}
List authorized = new ArrayList();
if (!LoginUserDetails.isUserAdmin(loginName)) {
if (AuthenticationInfo.userManageAuthentication.get(loginName) == null) {
AuthenticationInfo.getUserManageAuthentication(loginName);
}
List authManageList = (List)AuthenticationInfo.userManageAuthentication.get(loginName);
for(int i = 0; i < ret2.size(); ++i) {
Map node = (Map)ret.get(i);
BigDecimal nodeLeaf = new BigDecimal("1");
BigDecimal leaf = (BigDecimal)node.get("leaf");
if (nodeLeaf.equals(leaf)) {
String label = (String)node.get("label");
if (this.isManageResource(label, authManageList)) {
authorized.add(node);
}
} else {
authorized.add(node);
}
}
List authorized = new ArrayList();
if (LoginUserDetails.isUserAdmin(loginName)) {
authorized = ret2;
return authorized;
}
if (AuthenticationInfo.userManageAuthentication.get(loginName) == null) {
AuthenticationInfo.getUserManageAuthentication(loginName);
}
List authManageList = (List) AuthenticationInfo.userManageAuthentication.get(loginName);
for (int i = 0; i < ret2.size(); ++i) {
Map node = (Map) ret.get(i);
BigDecimal nodeLeaf = new BigDecimal("1");
BigDecimal leaf = (BigDecimal) node.get("leaf");
if (nodeLeaf.equals(leaf)) {
String label = (String) node.get("label");
if (this.isManageResource(label, authManageList)) {
authorized.add(node);
}
} else {
authorized = ret2;
authorized.add(node);
}
return authorized;
}
return authorized;
}
private boolean isManageResource(String label, List authManageList) {
......
......@@ -67,7 +67,7 @@
<isNotEmpty prepend=" AND " property="node">
t1.node_ename like concat(#node#, '%')
</isNotEmpty>
order by "sortIndex"
order by sortIndex asc
</select>
<select id="query2" resultClass="java.util.HashMap">
......
$(function () {
IPLATUI.EFGrid.result = {
pageable: {
pageSize: 20,
pageSizes: [10, 20, 50, 70, 100],
},
}
// 查询
$("#QUERY").on("click", query);
IPLATUI.EFTree = {
"pageTree": {
// ROOT: {label: "root", text: "系统菜单", leaf: true}
select: function (e) {
treeNodeSelect(this.dataItem(e.node));
},
selectTreeNode: {}
}
};
// 保存
$("#BTN_SAVE").on("click", save);
// 删除
$("#BTN_DELETE").on("click", deleteFunc);
$("#SAVE").on("click", save);
});
/**
* 页面加载时执行
*/
$(window).load(function () {
// 查询
query();
// 禁用checkBox
disableCheckBox(true);
// 全选框绑定事件
allCheckBoxEvent();
// 子项绑定事件
customAuthCheckBoxEvent();
depAuthCheckBoxEvent()
});
/**
* 查询
* checkBox集合
*
* @returns {*|jQuery|HTMLElement}
*/
let listCustomCheckBox = function () {
return $("input:checkbox[name='result-0-customAuth']");
}
/**
* checkBox集合
*
* @returns {*|jQuery|HTMLElement}
*/
let listDepCheckBox = function () {
return $("input:checkbox[name='result-0-depAuth']");
}
/**
* 清除checkBox选择
*
* @param bool
*/
let clearCheckedCheckBox = function () {
// 全选
$("input:checkbox[name='result-0-authAll']").prop('checked', '');
// 权限子项
checkedCheckBox(false);
}
/**
* 选中或取消checkBox
*
* @param bool
*/
let checkedCheckBox = function (bool) {
// 权限子项
listCustomCheckBox().prop('checked', bool);
listDepCheckBox().prop('checked', bool);
}
/**
* 禁用或启用checkBox
*/
let disableCheckBox = function (bool) {
// 全选
$("input:checkbox[name='result-0-authAll']").attr('readonly', bool);
// 权限子项
listCustomCheckBox().each(function () {
$(this).attr('readonly', bool);
});
listDepCheckBox().each(function () {
$(this).attr('readonly', bool);
});
}
/**
* 全选框绑定事件
*/
let allCheckBoxEvent = function () {
$("input:checkbox[name='result-0-authAll']").on("change", function () {
if ($(this).prop('readonly')) {
$(this).attr('checked', false);
return;
}
checkedCheckBox(this.checked);
});
}
/**
* 子项绑定事件
*/
let customAuthCheckBoxEvent = function () {
$("input:checkbox[name='result-0-customAuth']").on("change", function () {
if ($(this).prop('readonly')) {
$(this).prop('checked', '');
return;
}
// 判断全选框是选中还是不选中
setAllCheckBox();
});
}
/**
* 子项绑定事件
*/
let depAuthCheckBoxEvent = function () {
$("input:checkbox[name='result-0-depAuth']").on("change", function () {
if ($(this).prop('readonly')) {
$(this).prop('checked', '');
return;
}
// 判断全选框是选中还是不选中
setAllCheckBox();
});
}
/**
* 设置全选框选中或取消
*/
let setAllCheckBox = function (){
// 判断全选框是选中还是不选中
let allCheckBool = true;
listCustomCheckBox().each(function () {
if ($(this).prop('checked') == false) {
allCheckBool = false;
}
})
listDepCheckBox().each(function () {
if ($(this).prop('checked') == false) {
allCheckBool = false;
}
})
// 全选
$("input:checkbox[name='result-0-authAll']").prop('checked', allCheckBool);
}
/**
* 树节点选中
*
* @param e
*/
let treeNodeSelect = function (nodeData) {
// 设置选择的节点
setSelectTreeNode(nodeData);
// 非叶子节点清空显示
if (nodeData.leaf) {
// 禁用checkBox
disableCheckBox(true);
// 清空选项
clearCheckedCheckBox();
} else {
// 启用checkBox
disableCheckBox(false);
// 渲染权限
showAuthInput(nodeData.label);
}
}
/**
* 设置选择的节点
*
* @param nodeData
*/
let query = function () {
resultGrid.dataSource.page(1);
let setSelectTreeNode = function (nodeData) {
IPLATUI.EFTree.pageTree.selectTreeNode.label = nodeData.label;
IPLATUI.EFTree.pageTree.selectTreeNode.text = nodeData.text;
IPLATUI.EFTree.pageTree.selectTreeNode.leaf = nodeData.leaf;
}
/**
* 显示权限选择框
*
* @param node
*/
let showAuthInput = function (node) {
// 渲染权限
let inInfo = new EiInfo();
inInfo.set("inqu_status-0-pageEname", node);
EiCommunicator.send("HPPZ010", "getByPage", inInfo, {
onSuccess: getByPageSuccess,
onFail: function (res) {
}
}, {async: false});
}
/**
* 获取页面权限成功
*
* @param res
*/
let getByPageSuccess = function (res) {
// 清空所有选项
clearCheckedCheckBox();
if (res.status < 0) {
message(res.msg);
return;
}
let resultRows = res.getBlock("result").getMappedRows();
if (resultRows.length == 0) {
return;
}
let customAuth = resultRows[0]['customAuth'];
if(!isBlank(customAuth)){
let customAuths = customAuth.split(',');
listCustomCheckBox().each(function () {
for (let i = 0; i < customAuths.length; i++) {
if ($(this).val() == customAuths[i]) {
$(this).prop('checked', 'true');
}
}
})
}
let depAuth = resultRows[0]['depAuth'];
if(!isBlank(depAuth)){
let depAuths = depAuth.split(',');
listDepCheckBox().each(function () {
for (let i = 0; i < depAuths.length; i++) {
if ($(this).val() == depAuths[i]) {
$(this).prop('checked', 'true');
}
}
})
}
// 判断全选框是选中还是不选中
setAllCheckBox();
}
/**
* 保存
*/
let save = function () {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
// 检查是否选择的叶子节点
let selectTreeNode = IPLATUI.EFTree.pageTree.selectTreeNode;
if (selectTreeNode.leaf) {
message("【" + selectTreeNode.text + "】不是叶子节点,请选择菜单树叶子节点进行授权");
return;
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HPPZ009", "save", true);
}
JSUtils.confirm("确定对勾选中的数据做\"保存\"操作? ", {
ok: saveOk
});
}
/**
* 删除
* 保存确认
*/
let deleteFunc = function () {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"删除\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HPPZ009", "delete", true);
let saveOk = function () {
let customAuth = '';
listCustomCheckBox().each(function () {
if ($(this).prop('checked')) {
customAuth += ('' == customAuth ? $(this).val() : ',' + $(this).val());
}
});
})
let depAuth = '';
listDepCheckBox().each(function () {
if ($(this).prop('checked')) {
depAuth += ('' == depAuth ? $(this).val() : ',' + $(this).val());
}
})
let selectTreeNode = IPLATUI.EFTree.pageTree.selectTreeNode;
let inInfo = new EiInfo();
inInfo.set("result-0-pageEname", selectTreeNode.label);
inInfo.set("result-0-pageCname", selectTreeNode.text);
inInfo.set("result-0-customAuth", customAuth);
inInfo.set("result-0-depAuth", depAuth);
EiCommunicator.send("HPPZ010", "save", inInfo, {
onSuccess: function (res) {
message(res.msg);
},
onFail: function (res) {
}
}, {async: false});
}
<%@ page import="com.baosight.hpjx.hp.xs.tools.HPXSTools" %>
<%@ page import="java.util.List" %>
<%@ page import="com.baosight.hpjx.hp.xs.domain.Org" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="com.baosight.hpjx.core.enums.OrgTypeEnum" %>
<!DOCTYPE html>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="EF" tagdir="/WEB-INF/tags/EF" %>
<%
Map<String, List<Org>> orgMap = HPXSTools.XsOrg.queryAllFactoryMap();
if (orgMap == null) {
orgMap = new HashMap<>();
}
request.setAttribute("orgMap", orgMap);
%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<EF:EFPage>
<div class="row" style="margin: 0 -10px;">
<div class="col-md-4">
<div class="col-md-3">
<EF:EFRegion title="系统菜单树" id="tree" fitHeight="true">
<EF:EFTree bindId="groupsTree" ename="node" textField="text" valueField="label" hasChildren="leaf"
serviceName="XS0705" methodName="query" style="height:435px;">
<EF:EFTree bindId="pageTree" ename="node" textField="text" valueField="label" hasChildren="leaf"
serviceName="HPPZ010" methodName="queryTreeNode">
</EF:EFTree>
</EF:EFRegion>
</div>
<div class="col-md-8">
<EF:EFRegion title="查询区" id="inqu">
<div class="row" >
<EF:EFInput type="hidden" cname="授权主体ID" ename="subjectId" row="0" blockId="inqu_status"/>
<EF:EFInput type="hidden" ename="objectCname" row ="0" blockId="inqu_status"/>
<EF:EFInput type="hidden" cname="授权类别" ename="operationType" row="0" blockId="inqu_status" value="ACCESS"/>
<EF:EFInput row="0" blockId="inqu_status" ename="objectEname" cname="授权客体名称" type="hidden"/>
<div class="col-xs-4">
<div class="form-group">
<label class="col-md-5 control-label">
授权主体名称
</label>
<div class="col-md-7">
<input name="inqu_status-0-subjectName" data-query="gt" class="k-textbox input-time query-need"
placeholder="请输入授权主体名称" />
</div>
</div>
</div>
<EF:EFSelect blockId="inqu_status" cname="授权主体类别" ename="subjectType" row="0" defaultValue="全部" colWidth="4" ratio="5:7">
<EF:EFOption label="全部" value=""/>
<EF:EFCodeOption codeName="iplat.xs.subjectType" textField="label" valueField="value"/>
</EF:EFSelect>
<div class="col-xs-4">
<div class="form-group">
<label class="col-md-5 control-label">
授权客体名称
</label>
<div class="col-md-7">
<input name="inqu_status-0-objectName" data-query="gt" class="k-textbox input-time query-need"
placeholder="请输入授权客体名称" />
</div>
</div>
</div>
<EF:EFSelect blockId="inqu_status" cname="授权客体类别" colWidth="4" ename="objectType" row="0" defaultValue="全部" ratio="5:7">
<EF:EFOption label="全部" value=""/>
<EF:EFCodeOption codeName="xs.og.objectType" textField="label" valueField="value"/>
</EF:EFSelect>
<div class="col-xs-8" style="text-align: right" id="inqu_inside"></div>
</div>
</EF:EFRegion>
<EF:EFInput ename="objectCname" cname="授权主体名称" type="hidden"/>
<EF:EFRegion title="记录集" id="result" fitHeight="true">
<EF:EFGrid blockId="result" autoDraw="false">
<EF:EFColumn ename="subjectId" cname="授权主体ID" hidden="true"/>
<EF:EFColumn ename="subjectName" cname="授权主体名称" readonly="true" locked="true"/>
<EF:EFComboColumn enable="false" cname="授权主体类别" locked="true" ename="subjectType"
defaultValue="USER" style="text-align:center;">
<EF:EFCodeOption codeName="iplat.xs.subjectType" textField="label" valueField="value"/>
</EF:EFComboColumn>
<EF:EFColumn ename="objectId" cname="授权客体ID" hidden="true"/>
<EF:EFColumn ename="objectName" cname="授权客体名称" readonly="true" locked="true"/>
<EF:EFComboColumn enable="false" cname="授权客体类别" locked="true" ename="objectType"
defaultValue="RESOURCE" style="text-align:center;">
<EF:EFCodeOption codeName="xs.og.objectType" textField="label" valueField="value"/>
</EF:EFComboColumn>
<EF:EFComboColumn cname="操作类型" ename="operationType" readonly="true"
defaultValue="ACCESS" style="text-align:center;">
<EF:EFCodeOption codeName="services.xs.operationType" textField="label" valueField="value"/>
</EF:EFComboColumn>
<EF:EFColumn ename="sortIndex" cname="排序" style="text-align:center;"/>
<EF:EFColumn ename="recCreator" cname="创建人" style="text-align:center;" readonly="true"/>
<EF:EFColumn ename="recCreateTime" cname="创建时间" editType="datetime" readonly="true" displayType="datetime" parseFormats="['yyyyMMddHHmmss','yyyy-MM-dd HH:mm:ss']" style="text-align:center;"/>
<EF:EFColumn ename="recRevisor" cname="修改人" style="text-align:center;" readonly="true"/>
<EF:EFColumn ename="recReviseTime" cname="修改时间" readonly="true" editType="datetime" displayType="datetime" parseFormats="['yyyyMMddHHmmss','yyyy-MM-dd HH:mm:ss']" style="text-align:center;"/>
<EF:EFColumn ename="archiveFlag" cname="归档标记" style="text-align:center;"/>
</EF:EFGrid>
</EF:EFRegion>
</div>
</div>
<EF:EFWindow id="authSubject" width="58%" top="100px" left="280px">
<div id="ef_popup_gridA" >
<EF:EFRegion id="inquA" title="查询条件" type="query" efRegionShowClear="true" efRegionSave="true">
<div class="col-md-9">
<%-- <EF:EFRegion title="自定义" id="result" hidden="true">--%>
<%-- <div class="row">--%>
<%-- <EF:EFInput cname="本厂" blockId="result" ename="customAuth" row="0" value="onlyFactory" colWidth="3"--%>
<%-- type="checkbox" inline="true"/>--%>
<%-- <EF:EFInput cname="本部门" blockId="result" ename="customAuth" row="0" value="onlyDept" colWidth="3"--%>
<%-- type="checkbox" inline="true"/>--%>
<%-- </div>--%>
<%-- </EF:EFRegion>--%>
<EF:EFRegion title="组织机构" id="org">
<div class="row">
<div class="col-xs-2 control-label">
<span>用户组英文名</span>
</div>
<div class="col-xs-2">
<EF:EFInput ename="inqu_status-0-groupEname" cname="用户组英文名" inline="true"/>
</div>
<div class="col-xs-3 control-label">
<span>用户组中文名</span>
</div>
<div class="col-xs-2">
<EF:EFInput ename="inqu_status-0-groupCname" cname="用户组中文名" inline="true"/>
</div>
<div class="col-xs-2" style="text-align: right" id="inqua_inside"></div>
<EF:EFInput cname="全选" blockId="result" ename="authAll" row="0" value="0" colWidth="3"
type="checkbox" inline="true"/>
</div>
<c:forEach items="${requestScope.orgMap}" var="entry">
<c:forEach items="${entry.value}" var="item" varStatus="i">
<c:if test="${item.orgType == 'factory'}">
<c:if test="${i.index == 0}">
<div class="row">
<EF:EFInput cname="${item.orgCname}" blockId="result" ename="depAuth" row="0"
value="${item.orgId}" colWidth="3" type="checkbox" inline="true"/>
</div>
<div class="row">
</c:if>
<c:if test="${i.index != 0}">
</div>
<div class="row">
<EF:EFInput cname="${item.orgCname}" blockId="result" ename="depAuth" row="0"
value="${item.orgId}" colWidth="3" type="checkbox" inline="true"/>
</div>
<div class="row">
</c:if>
</c:if>
<c:if test="${item.orgType != 'factory'}">
<EF:EFInput cname="${item.orgCname}" blockId="result" ename="depAuth" row="0"
value="${item.orgId}" colWidth="3" type="checkbox" inline="true"/>
</c:if>
</c:forEach>
</div>
</c:forEach>
</EF:EFRegion>
<EF:EFRegion id="resultA" title="记录集">
<div class="text-right">
<EF:EFButton cname="确定" ename="ef_popup_gridA_commit"></EF:EFButton>
</div>
<EF:EFGrid blockId="resultA" queryMethod="queryForGridSubject" autoDraw="false">
<EF:EFColumn ename="groupId" locked="true" cname="群组ID" hidden="true" primaryKey="true"/>
<EF:EFColumn ename="groupEname" locked="true" cname="群组英文名" readonly="true" width="300"/>
<EF:EFColumn ename="groupCname" cname="群组中文名" readonly="true" width="300"/>
</EF:EFGrid>
<EF:EFRegion title="提示">
<%-- <span style="color: red">1:非叶子节点授权时,会同步将该节点下的所有子节点权限设置为当前选择的权限。</span>--%>
</EF:EFRegion>
</div>
</EF:EFWindow>
</div>
<EF:EFWindow id="menuPageAuth" url="${ctx}/web/XS0707" width="78%" top="80px" left="120px"></EF:EFWindow>
</EF:EFPage>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment