Commit 6c06a0bc by 宋祥

1.数据权限开发

parent bf921dc4
...@@ -6,13 +6,15 @@ package com.baosight.hggp.common; ...@@ -6,13 +6,15 @@ package com.baosight.hggp.common;
* @author:songx * @author:songx
* @date:2024/3/21,9:58 * @date:2024/3/21,9:58
*/ */
public enum AuthTypeEnum { public enum DataAuthTypeEnum {
ALL("all", "全部"), ALL("all", "全部"),
NO_AUTH("noAuth", "不可查看"), NO_AUTH("noAuth", "不可查看"),
ONLY_COMPANY("onlyCompany", "本企业"), ONLY_COMPANY("4", "本企业"),
ONLY_FACTORY("onlyFactory", "本厂"), ONLY_FACTORY("3", "本厂"),
ONLY_DEPT("onlyDept", "本部门"); ONLY_DEPT("2", "本部门"),
ONLY_PEOPLE("1", "本人")
;
/** /**
* 编码 * 编码
...@@ -24,7 +26,7 @@ public enum AuthTypeEnum { ...@@ -24,7 +26,7 @@ public enum AuthTypeEnum {
*/ */
private String name; private String name;
AuthTypeEnum(String code, String name) { DataAuthTypeEnum(String code, String name) {
this.code = code; this.code = code;
this.name = name; this.name = name;
} }
...@@ -35,8 +37,8 @@ public enum AuthTypeEnum { ...@@ -35,8 +37,8 @@ public enum AuthTypeEnum {
* @param code * @param code
* @return * @return
*/ */
public static AuthTypeEnum getByCode(String code) { public static DataAuthTypeEnum getByCode(String code) {
for (AuthTypeEnum item : AuthTypeEnum.values()) { for (DataAuthTypeEnum item : DataAuthTypeEnum.values()) {
if (item.getCode().equals(code)) { if (item.getCode().equals(code)) {
return item; return item;
} }
......
...@@ -70,12 +70,25 @@ public enum DdynamicEnum { ...@@ -70,12 +70,25 @@ public enum DdynamicEnum {
* 编写:ly * 编写:ly
*/ */
DEPT_CODE_BLOCK_ID("dept_code_block_id", "orgId", "orgCname", "factoryCode", "factoryName", "companyCode", DEPT_CODE_BLOCK_ID("dept_code_block_id", "orgId", "orgCname", "factoryCode", "factoryName", "companyCode",
"companyName", "HGXSOrg.queryAll"); "companyName", "HGXSOrg.queryAll"),
/**
* 模块:系统管理
* 用途:厂区查询
/** 将结果集放入的块名 */ * 编写:ly
*/
FACTORY_CODE_BLOCK_ID("factory_code_block_id", "orgId", "orgCname", "companyCode",
"companyName", "HGXSOrg.queryAll"),
/**
* 模块:系统管理
* 用途:公司查询
* 编写:ly
*/
COMPANY_CODE_BLOCK_ID("company_code_block_id", "orgId", "orgCname", "HGXSOrg.queryAll"),
;
/** 将结果集放入的块名 */
private final String blockId; private final String blockId;
/** 字段名 */ /** 字段名 */
private final String value; private final String value;
......
package com.baosight.hggp.controller;
import com.baosight.hggp.core.tools.ThreadLocalTools;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import lombok.extern.slf4j.Slf4j;
/**
* @author:songx
* @date:2024/3/14,14:26
*/
@Slf4j
@Controller
@CrossOrigin
@RequestMapping({"/dataAuth"})
public class DataAuthController {
/**
* 数据权限临时使用
*
* @param value 1-已用,0-停用
*/
@RequestMapping({"/enable/{value}"})
public String enable(@PathVariable String value) {
try {
ThreadLocalTools.DATA_AUTH.set(!"0".equals(value));
} catch (Exception e) {
log.error("操作失败:{}", e.getMessage(), e);
return "操作失败";
}
return "操作成功";
}
}
...@@ -139,24 +139,4 @@ public class FileDownloadController { ...@@ -139,24 +139,4 @@ public class FileDownloadController {
return strBuilder.toString(); return strBuilder.toString();
} }
/**
* 数据权限临时使用
*
* @param value
* @param request
* @param response
* @throws IOException
*/
@RequestMapping({"/dataAuth/{value}"})
public String dataAuth(@PathVariable String value, HttpServletRequest request, HttpServletResponse response)
throws IOException {
try {
ThreadLocalTools.DATA_AUTH.set("0".equals(value) ? false : true);
} catch (Exception e) {
response.getWriter().write("数据接口异常");
return "操作失败";
}
return "操作成功";
}
} }
package com.baosight.hggp.core.security; package com.baosight.hggp.core.security;
import com.baosight.hggp.core.enums.OrgTypeEnum;
import com.baosight.hggp.hg.xs.domain.Company;
import com.baosight.hggp.hg.xs.domain.Dept;
import com.baosight.hggp.hg.xs.domain.Org; import com.baosight.hggp.hg.xs.domain.Org;
import com.baosight.hggp.hg.xs.domain.User; import com.baosight.hggp.hg.xs.domain.User;
import com.baosight.hggp.hg.xs.domain.UserGroup;
import com.baosight.hggp.hg.xs.tools.HGXSTools; import com.baosight.hggp.hg.xs.tools.HGXSTools;
import com.baosight.hggp.util.StringUtils;
import com.baosight.iplat4j.core.ei.EiConstant; import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo; import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException; import com.baosight.iplat4j.core.exception.PlatException;
...@@ -12,11 +17,10 @@ import org.apache.commons.collections.CollectionUtils; ...@@ -12,11 +17,10 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import java.util.stream.Collectors;
/** /**
* @author:songx * @author:songx
...@@ -78,7 +82,11 @@ public class UserSessionUtils extends UserSession { ...@@ -78,7 +82,11 @@ public class UserSessionUtils extends UserSession {
* @return * @return
*/ */
public static List<String> getOrgId() { public static List<String> getOrgId() {
return HGXSTools.XsOrg.getOrgId(); List<Org> orgs = HGXSTools.XsOrg.queryByUser();
if (CollectionUtils.isEmpty(orgs)) {
return null;
}
return orgs.stream().map(item -> item.getOrgId()).collect(Collectors.toList());
} }
/** /**
...@@ -87,59 +95,69 @@ public class UserSessionUtils extends UserSession { ...@@ -87,59 +95,69 @@ public class UserSessionUtils extends UserSession {
* @return * @return
*/ */
public static List<String> getFactoryCode() { public static List<String> getFactoryCode() {
List<String> orgIds = getOrgId(); List<Org> orgs = HGXSTools.XsOrg.queryByUser();
if (CollectionUtils.isEmpty(orgIds)) { if (CollectionUtils.isEmpty(orgs)) {
return null; return null;
} }
List<String> factoryCodes = new ArrayList<>(); List<String> factoryCodes = new ArrayList<>();
for (String orgId : orgIds) { for (Org org : orgs) {
Org org = HGXSTools.XsOrg.queryFactory(orgId); if (OrgTypeEnum.FACTORY.getCode().equals(org.getOrgType())) {
if (org != null) {
factoryCodes.add(org.getOrgId()); factoryCodes.add(org.getOrgId());
} }
} }
return factoryCodes; return factoryCodes;
} }
/**
* *获取登录用户所有角色
*
* @return
*/
public static List<UserGroup> getRole() {
return HGXSTools.XsUserGroup.queryByUser();
}
/** /**
* TODO *
* *获取登录用户所有角色的公司列表 * *获取登录用户所有角色的公司列表
*
* @return * @return
*/ */
public static List<Map<String,String>> getRoleCompany(){ public static List<Company> getRoleCompany() {
Map<String,String> map = new HashMap<String,String>(){{ List<UserGroup> userGroups = HGXSTools.XsUserGroup.queryByUser();
put("companyCode","001"); if (CollectionUtils.isEmpty(userGroups)) {
put("companyName","公司A"); return null;
}}; }
return new ArrayList<Map<String,String>>(){{add(map);}}; List<String> companyCodes = userGroups.stream().map(UserGroup::getCompanyCode)
.filter(StringUtils::isNotBlank).collect(Collectors.toList());
// 查询组织信息
List<Org> orgs = HGXSTools.XsOrg.list(companyCodes);
return orgs.stream().map(item -> new Company(item.getOrgId(), item.getOrgCname())).collect(Collectors.toList());
} }
/** /**
* TODO *
* *获取指定公司的部门列表 * *获取指定公司的部门列表
*
* @return * @return
*/ */
public static List<Map<String,String>> getDepByCompany(String companyCode){ public static List<Dept> getDepByCompany(String companyCode) {
Map<String,String> map = new HashMap<String,String>(){{ List<Org> orgs = HGXSTools.XsOrg.queryByParent(companyCode, OrgTypeEnum.DEPT.getCode());
put("depCode","001"); if (CollectionUtils.isEmpty(orgs)) {
put("depName","公司A"); return null;
}}; }
return new ArrayList<Map<String,String>>(){{add(map);}}; return orgs.stream().map(item -> new Dept(item.getOrgId(), item.getOrgCname())).collect(Collectors.toList());
} }
/** /**
* TODO *
* *获取指定公司的人员列表 * *获取指定公司的人员列表
*
* @return * @return
*/ */
public static List<Map<String,String>> getUserByCompany(String companyCode){ public static List<User> getUserByCompany(String companyCode) {
Map<String,String> map = new HashMap<String,String>(){{ // 查询该公司下的所有组织机构
put("userCode","");//工号 List<String> orgIds = HGXSTools.XsOrg.queryChildren(companyCode);
put("userName","");//用户名称 if (CollectionUtils.isEmpty(orgIds)) {
put("userPhone","");//用户电话 return null;
put("depCode","");//所属部门编码 }
put("depName","");//所属部门名称 return HGXSTools.XsUser.queryByOrg(orgIds);
}};
return new ArrayList<Map<String,String>>(){{add(map);}};
} }
} }
...@@ -394,6 +394,18 @@ public class HGSqlConstant { ...@@ -394,6 +394,18 @@ public class HGSqlConstant {
} }
/** /**
* 用户
*
* @author:songx
* @date:2024/5/8,10:55
*/
public class HgXsUser {
// 根据组织查询
public static final String QUERY_BY_ORG = "HGXSUserGroup.queryByOrg";
}
/**
* 用户群组 * 用户群组
* *
* @author:songx * @author:songx
...@@ -420,7 +432,7 @@ public class HGSqlConstant { ...@@ -420,7 +432,7 @@ public class HGSqlConstant {
// 查询父级信息,含自己(递归) // 查询父级信息,含自己(递归)
public static final String QUERY_PARENT = "HGXSOrg.queryParent"; public static final String QUERY_PARENT = "HGXSOrg.queryParent";
// 查询用户组织机构 // 查询用户组织机构
public static final String QUERY_ORG_ID = "HGXSUser.queryOrgId"; public static final String QUERY_BY_USER = "HGXSOrg.queryByUser";
} }
} }
...@@ -3,6 +3,7 @@ package com.baosight.hggp.hg.pz.service; ...@@ -3,6 +3,7 @@ package com.baosight.hggp.hg.pz.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation; import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.core.constant.CommonConstant; import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoUtils; import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.enums.OrgTypeEnum;
import com.baosight.hggp.core.enums.ValidFlagEnum; import com.baosight.hggp.core.enums.ValidFlagEnum;
import com.baosight.hggp.hg.constant.HGConstant; import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.pz.domain.HGPZ009; import com.baosight.hggp.hg.pz.domain.HGPZ009;
...@@ -11,6 +12,7 @@ import com.baosight.hggp.util.AssertUtils; ...@@ -11,6 +12,7 @@ import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.DateUtils; import com.baosight.hggp.util.DateUtils;
import com.baosight.hggp.util.EiInfoUtils; import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.LogUtils; import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.MapUtils;
import com.baosight.hggp.util.contants.ACConstants; import com.baosight.hggp.util.contants.ACConstants;
import com.baosight.iplat4j.core.ProjectInfo; import com.baosight.iplat4j.core.ProjectInfo;
import com.baosight.iplat4j.core.ei.EiConstant; import com.baosight.iplat4j.core.ei.EiConstant;
...@@ -18,9 +20,11 @@ import com.baosight.iplat4j.core.ei.EiInfo; ...@@ -18,9 +20,11 @@ import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException; import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceBase; import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.core.service.soa.XLocalManager; import com.baosight.iplat4j.core.service.soa.XLocalManager;
import com.baosight.iplat4j.core.service.soa.XServiceManager;
import com.baosight.iplat4j.core.web.threadlocal.UserSession; import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import com.baosight.iplat4j.ed.util.SequenceGenerator; import com.baosight.iplat4j.ed.util.SequenceGenerator;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -140,6 +144,8 @@ public class ServiceHGPZ009 extends ServiceBase { ...@@ -140,6 +144,8 @@ public class ServiceHGPZ009 extends ServiceBase {
null, null); null, null);
// 关联企业管理员角色 // 关联企业管理员角色
this.insertGroupMember(fPz009, userId); this.insertGroupMember(fPz009, userId);
// 新增组织机构顶级
this.insertOrg(fPz009);
} }
/** /**
...@@ -204,6 +210,36 @@ public class ServiceHGPZ009 extends ServiceBase { ...@@ -204,6 +210,36 @@ public class ServiceHGPZ009 extends ServiceBase {
} }
/** /**
* 组织机构
*
* @param fPz009
*/
private void insertOrg(HGPZ009 fPz009) {
List<Map> newRows = new ArrayList<>();
Map row = new HashMap();
row.put("orgId", fPz009.getAccountCode());
row.put("orgEname", fPz009.getAccountCode());
row.put("orgCname", fPz009.getAccountName());
row.put("orgType", OrgTypeEnum.COMPANY.getCode());
row.put("accountCode", fPz009.getAccountCode());
row.put("establishDate", DateUtils.shortDate());
row.put("parentOrgId", "");
row.put("recCreator", UserSession.getLoginName());
row.put("factoryCode", "");
row.put("factoryName", "");
row.put("companyCode", fPz009.getAccountCode());
row.put("companyName", fPz009.getAccountName());
newRows.add(row);
EiInfo call = new EiInfo();
call.set("list", newRows);
call.set(EiConstant.serviceId, "S_XS_87");
EiInfo outInfo = XServiceManager.call(call);
if (outInfo.getStatus() < 0) {
throw new PlatException(outInfo.getMsg());
}
}
/**
* 修改操作 * 修改操作
* *
* @param inInfo * @param inInfo
......
package com.baosight.hggp.hg.xs.domain;
/**
* @author:songx
* @date:2024/5/8,13:47
*/
public class Company {
public static final String FIELD_COMPANY_CODE = "companyCode"; /* 公司编码*/
public static final String FIELD_COMPANY_NAME = "companyName"; /* 公司名称*/
/**
* 公司编码
*/
private String companyCode;
/**
* 公司名称
*/
private String companyName;
public Company() {
}
public Company(String companyCode, String companyName) {
this.companyCode = companyCode;
this.companyName = companyName;
}
public String getCompanyCode() {
return companyCode;
}
public void setCompanyCode(String companyCode) {
this.companyCode = companyCode;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
}
package com.baosight.hggp.hg.xs.domain;
/**
* @author:songx
* @date:2024/5/8,13:47
*/
public class Dept {
/**
* 部门编码
*/
private String depCode;
/**
* 部门名称
*/
private String depName;
public Dept() {
}
public Dept(String depCode, String depName) {
this.depCode = depCode;
this.depName = depName;
}
public String getDepCode() {
return depCode;
}
public void setDepCode(String depCode) {
this.depCode = depCode;
}
public String getDepName() {
return depName;
}
public void setDeptName(String depName) {
this.depName = depName;
}
}
package com.baosight.hggp.hg.xs.domain;
/**
* @author:songx
* @date:2024/5/8,13:47
*/
public class Factory {
/**
* 厂区编码
*/
private String factoryCode;
/**
* 厂区名称
*/
private String factoryName;
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;
}
}
...@@ -18,9 +18,11 @@ public class Org extends DaoEPBase { ...@@ -18,9 +18,11 @@ public class Org extends DaoEPBase {
public static final String FIELD_ORG_ENAME = "orgEname"; /* 组织机构名称*/ public static final String FIELD_ORG_ENAME = "orgEname"; /* 组织机构名称*/
public static final String FIELD_ORG_CNAME = "orgCname"; /* 组织机构名称*/ public static final String FIELD_ORG_CNAME = "orgCname"; /* 组织机构名称*/
public static final String FIELD_ORG_TYPE = "orgType"; /* 用户ID*/ public static final String FIELD_ORG_TYPE = "orgType"; /* 用户ID*/
public static final String FIELD_PARENT_ORG_ID = "parentOrgId"; /* 用户中文名*/ public static final String FIELD_PARENT_ORG_ID = "parentOrgId"; /* 父级组织ID*/
public static final String FIELD_FACTORY_CODE = "factoryCode"; /* 性别*/ public static final String FIELD_FACTORY_CODE = "factoryCode"; /* 厂区代码*/
public static final String FIELD_FACTORY_NAME = "factoryName"; /* 手机号*/ public static final String FIELD_FACTORY_NAME = "factoryName"; /* 厂区名称*/
public static final String FIELD_COMPANY_CODE = "companyCode"; /* 公司编码*/
public static final String FIELD_COMPANY_NAME = "companyName"; /* 公司名称*/
public static final String FIELD_LEVEL = "level"; /* 邮箱*/ public static final String FIELD_LEVEL = "level"; /* 邮箱*/
private String accountCode = ""; /* 企业编码 */ private String accountCode = ""; /* 企业编码 */
...@@ -31,6 +33,8 @@ public class Org extends DaoEPBase { ...@@ -31,6 +33,8 @@ public class Org extends DaoEPBase {
private String parentOrgId = ""; /* 父级组织ID */ private String parentOrgId = ""; /* 父级组织ID */
private String factoryCode = ""; /* 厂区编码 */ private String factoryCode = ""; /* 厂区编码 */
private String factoryName = ""; /* 厂区名称 */ private String factoryName = ""; /* 厂区名称 */
private String companyCode = ""; /* 公司编码 */
private String companyName = ""; /* 公司名称 */
private String level = ""; /* 层级 */ private String level = ""; /* 层级 */
/** /**
...@@ -71,6 +75,14 @@ public class Org extends DaoEPBase { ...@@ -71,6 +75,14 @@ public class Org extends DaoEPBase {
eiColumn.setDescName("厂区名称"); eiColumn.setDescName("厂区名称");
eiMetadata.addMeta(eiColumn); eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_COMPANY_CODE);
eiColumn.setDescName("公司编码");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_COMPANY_NAME);
eiColumn.setDescName("公司名称");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_LEVEL); eiColumn = new EiColumn(FIELD_LEVEL);
eiColumn.setDescName("层级"); eiColumn.setDescName("层级");
eiMetadata.addMeta(eiColumn); eiMetadata.addMeta(eiColumn);
...@@ -148,6 +160,22 @@ public class Org extends DaoEPBase { ...@@ -148,6 +160,22 @@ public class Org extends DaoEPBase {
this.factoryName = factoryName; this.factoryName = factoryName;
} }
public String getCompanyCode() {
return companyCode;
}
public void setCompanyCode(String companyCode) {
this.companyCode = companyCode;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getLevel() { public String getLevel() {
return level; return level;
} }
...@@ -172,6 +200,8 @@ public class Org extends DaoEPBase { ...@@ -172,6 +200,8 @@ public class Org extends DaoEPBase {
setParentOrgId(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_PARENT_ORG_ID)), parentOrgId)); setParentOrgId(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_PARENT_ORG_ID)), parentOrgId));
setFactoryCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_FACTORY_CODE)), factoryCode)); setFactoryCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_FACTORY_CODE)), factoryCode));
setFactoryName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_FACTORY_NAME)), factoryName)); setFactoryName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_FACTORY_NAME)), factoryName));
setCompanyCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_COMPANY_CODE)), companyCode));
setCompanyName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_COMPANY_NAME)), companyName));
setLevel(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_LEVEL)), level)); setLevel(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_LEVEL)), level));
} }
...@@ -190,6 +220,8 @@ public class Org extends DaoEPBase { ...@@ -190,6 +220,8 @@ public class Org extends DaoEPBase {
map.put(FIELD_PARENT_ORG_ID, StringUtils.toString(parentOrgId, eiMetadata.getMeta(FIELD_PARENT_ORG_ID))); map.put(FIELD_PARENT_ORG_ID, StringUtils.toString(parentOrgId, eiMetadata.getMeta(FIELD_PARENT_ORG_ID)));
map.put(FIELD_FACTORY_CODE, StringUtils.toString(factoryCode, eiMetadata.getMeta(FIELD_FACTORY_CODE))); map.put(FIELD_FACTORY_CODE, StringUtils.toString(factoryCode, eiMetadata.getMeta(FIELD_FACTORY_CODE)));
map.put(FIELD_FACTORY_NAME, StringUtils.toString(factoryName, eiMetadata.getMeta(FIELD_FACTORY_NAME))); map.put(FIELD_FACTORY_NAME, StringUtils.toString(factoryName, eiMetadata.getMeta(FIELD_FACTORY_NAME)));
map.put(FIELD_COMPANY_CODE, StringUtils.toString(companyCode, eiMetadata.getMeta(FIELD_COMPANY_CODE)));
map.put(FIELD_COMPANY_NAME, StringUtils.toString(companyName, eiMetadata.getMeta(FIELD_COMPANY_NAME)));
map.put(FIELD_LEVEL, StringUtils.toString(level, eiMetadata.getMeta(FIELD_LEVEL))); map.put(FIELD_LEVEL, StringUtils.toString(level, eiMetadata.getMeta(FIELD_LEVEL)));
return map; return map;
......
...@@ -15,6 +15,8 @@ public class User implements Serializable { ...@@ -15,6 +15,8 @@ public class User implements Serializable {
public static final String FIELD_MOBILE = "mobile"; /* 手机号*/ public static final String FIELD_MOBILE = "mobile"; /* 手机号*/
public static final String FIELD_EMAIL = "email"; /* 邮箱*/ public static final String FIELD_EMAIL = "email"; /* 邮箱*/
public static final String FIELD_ACCOUNT_CODE = "accountCode"; /* 帐套代码*/ public static final String FIELD_ACCOUNT_CODE = "accountCode"; /* 帐套代码*/
public static final String FIELD_DEP_CODE = "depCode"; /* 部门编码*/
public static final String FIELD_DEP_NAME = "depName"; /* 部门名称*/
/** /**
* 用户ID * 用户ID
...@@ -51,6 +53,16 @@ public class User implements Serializable { ...@@ -51,6 +53,16 @@ public class User implements Serializable {
*/ */
private String accountCode; private String accountCode;
/**
* 部门代码
*/
private String depCode;
/**
* 部门名称
*/
private String depName;
public String getUserId() { public String getUserId() {
return userId; return userId;
} }
...@@ -99,6 +111,22 @@ public class User implements Serializable { ...@@ -99,6 +111,22 @@ public class User implements Serializable {
this.accountCode = accountCode; this.accountCode = accountCode;
} }
public String getDepCode() {
return depCode;
}
public void setDepCode(String depCode) {
this.depCode = depCode;
}
public String getDepName() {
return depName;
}
public void setDepName(String depName) {
this.depName = depName;
}
public String getGender() { public String getGender() {
return gender; return gender;
} }
......
...@@ -11,7 +11,11 @@ public class UserGroup implements Serializable { ...@@ -11,7 +11,11 @@ public class UserGroup implements Serializable {
public static final String FIELD_ID = "id"; /* ID*/ public static final String FIELD_ID = "id"; /* ID*/
public static final String FIELD_GROUP_ENAME = "groupEname"; /* 群组英文名*/ public static final String FIELD_GROUP_ENAME = "groupEname"; /* 群组英文名*/
public static final String FIELD_GROUP_CNAME = "groupCname"; /* 群组中文名*/ public static final String FIELD_GROUP_CNAME = "groupCname"; /* 群组中文名*/
public static final String FIELD_ACCOUNT_CODE = "accountCode"; /* 帐套代码*/ public static final String FIELD_ACCOUNT_CODE = "accountCode"; /* 帐套编码*/
public static final String FIELD_DATA_AUTH_TYPE = "dataAuthType"; /* 数据权限类型*/
public static final String FIELD_DEP_CODE = "depCode"; /* 部门编码*/
public static final String FIELD_FACTORY_CODE = "factoryCode"; /* 厂区编码*/
public static final String FIELD_COMPANY_CODE = "companyCode"; /* 公司编码*/
public static final String FIELD_USER_ID = "userId"; /* 用户ID*/ public static final String FIELD_USER_ID = "userId"; /* 用户ID*/
/** /**
...@@ -30,11 +34,31 @@ public class UserGroup implements Serializable { ...@@ -30,11 +34,31 @@ public class UserGroup implements Serializable {
private String groupCname; private String groupCname;
/** /**
* 企业代 * 帐套编
*/ */
private String accountCode; private String accountCode;
/** /**
* 部门编码
*/
private String dataAuthType;
/**
* 部门编码
*/
private String depCode;
/**
* 厂区编码
*/
private String factoryCode;
/**
* 公司编码
*/
private String companyCode;
/**
* 用户ID * 用户ID
*/ */
private String userId; private String userId;
...@@ -63,6 +87,14 @@ public class UserGroup implements Serializable { ...@@ -63,6 +87,14 @@ public class UserGroup implements Serializable {
this.groupCname = groupCname; this.groupCname = groupCname;
} }
public String getDataAuthType() {
return dataAuthType;
}
public void setDataAuthType(String dataAuthType) {
this.dataAuthType = dataAuthType;
}
public String getAccountCode() { public String getAccountCode() {
return accountCode; return accountCode;
} }
...@@ -71,6 +103,30 @@ public class UserGroup implements Serializable { ...@@ -71,6 +103,30 @@ public class UserGroup implements Serializable {
this.accountCode = accountCode; this.accountCode = accountCode;
} }
public String getDepCode() {
return depCode;
}
public void setDepCode(String depCode) {
this.depCode = depCode;
}
public String getFactoryCode() {
return factoryCode;
}
public void setFactoryCode(String factoryCode) {
this.factoryCode = factoryCode;
}
public String getCompanyCode() {
return companyCode;
}
public void setCompanyCode(String companyCode) {
this.companyCode = companyCode;
}
public String getUserId() { public String getUserId() {
return userId; return userId;
} }
......
...@@ -87,6 +87,7 @@ public class ServiceHGXSOrg extends ServiceBase { ...@@ -87,6 +87,7 @@ public class ServiceHGXSOrg extends ServiceBase {
public EiInfo queryDeptComboBox(EiInfo inInfo) { public EiInfo queryDeptComboBox(EiInfo inInfo) {
try { try {
Map queryRow = EiInfoUtils.getFirstRow(inInfo); Map queryRow = EiInfoUtils.getFirstRow(inInfo);
queryRow.put("orgType", OrgTypeEnum.DEPT.getCode());
List<DdynamicEnum> list = new ArrayList<>(); List<DdynamicEnum> list = new ArrayList<>();
list.add(DdynamicEnum.DEPT_CODE_BLOCK_ID); list.add(DdynamicEnum.DEPT_CODE_BLOCK_ID);
CommonMethod.initBlock(inInfo, list, queryRow, false); CommonMethod.initBlock(inInfo, list, queryRow, false);
......
...@@ -44,11 +44,14 @@ ...@@ -44,11 +44,14 @@
<!-- 查询组织信息 --> <!-- 查询组织信息 -->
<select id="query" resultClass="com.baosight.hggp.hg.xs.domain.Org"> <select id="query" resultClass="com.baosight.hggp.hg.xs.domain.Org">
SELECT SELECT
ORG_ID as "orgId", ORG_ID as "orgId",
ORG_ENAME as "orgEname", ORG_ENAME as "orgEname",
ORG_CNAME as "orgCname", ORG_CNAME as "orgCname",
ORG_TYPE as "orgType", ORG_TYPE as "orgType",
PARENT_ORG_ID as "parentOrgId" PARENT_ORG_ID as "parentOrgId",
ACCOUNT_CODE AS "accountCode",
FACTORY_CODE AS "factoryCode",
COMPANY_CODE AS "companyCode"
FROM ${platSchema}.TXSOG01 FROM ${platSchema}.TXSOG01
WHERE 1=1 WHERE 1=1
<include refid="condition"/> <include refid="condition"/>
...@@ -72,8 +75,8 @@ ...@@ -72,8 +75,8 @@
(CASE WHEN T3.ORG_TYPE = 'factory' THEN T3.ORG_CNAME (CASE WHEN T3.ORG_TYPE = 'factory' THEN T3.ORG_CNAME
WHEN T3.FACTORY_CODE != '' THEN CONCAT('[', T5.FACTORY_NAME, ']', T3.ORG_CNAME) WHEN T3.FACTORY_CODE != '' THEN CONCAT('[', T5.FACTORY_NAME, ']', T3.ORG_CNAME)
ELSE T3.ORG_CNAME END) AS "orgCname", ELSE T3.ORG_CNAME END) AS "orgCname",
T3.ORG_TYPE AS "orgType", T3.FACTORY_CODE AS "factoryCode", T5.FACTORY_NAME AS "factoryName", T3.ORG_TYPE AS "orgType", T3.FACTORY_CODE AS "factoryCode", T3.FACTORY_NAME AS "factoryName",
T3.COMPANY_CODE AS "companyCode", T5.COMPANY_NAME AS "companyName" T3.COMPANY_CODE AS "companyCode", T3.COMPANY_NAME AS "companyName"
FROM ( FROM (
SELECT SELECT
@CODES AS CODES, @CODES AS CODES,
...@@ -211,4 +214,21 @@ ...@@ -211,4 +214,21 @@
WHERE CODESET_CODE = 'hpjx.hpjx.poorType' WHERE CODESET_CODE = 'hpjx.hpjx.poorType'
</select> </select>
<!-- 查询用户组织机构 -->
<select id="queryByUser" resultClass="com.baosight.hggp.hg.xs.domain.Org">
SELECT
A.ORG_ID AS "orgId",
A.ORG_ENAME AS "orgEname",
A.ORG_CNAME AS "orgCname",
A.ORG_TYPE AS "orgType",
A.ACCOUNT_CODE AS "accounCcode",
A.FACTORY_CODE AS "factoryCode",
A.COMPANY_CODE AS "companyCode"
FROM ${platSchema}.TXSOG01 A, ${platSchema}.TXSOG02 B, ${platSchema}.XS_USER C
WHERE 1=1
AND A.ORG_ID = B.ORG_ID
AND B.USER_ID = C.USER_ID
AND C.LOGIN_NAME = #loginName#
</select>
</sqlMap> </sqlMap>
...@@ -75,11 +75,32 @@ ...@@ -75,11 +75,32 @@
AND MEMBER_ID = #memberId# AND MEMBER_ID = #memberId#
</select> </select>
<!-- 查询用户组织机构 --> <!-- id查询 -->
<select id="queryOrgId" resultClass="java.util.LinkedHashMap"> <select id="queryByOrg" resultClass="com.baosight.hggp.hg.xs.domain.User">
SELECT ORG_ID AS "orgId" SELECT
FROM ${platSchema}.TXSOG02 A.ORG_ID AS "depCode",
WHERE USER_ID = #userId# A.ORG_CNAME AS "depName",
C.USER_ID as "userId", <!-- 用户id -->
C.USER_NAME as "userName", <!-- 用户名 -->
C.LOGIN_NAME as "loginName", <!-- 登录id -->
C.GENDER as "gender", <!-- 性别 -->
C.MOBILE as "mobile", <!-- 手机号 -->
C.EMAIL as "email", <!-- 邮箱 -->
C.ACCOUNT_CODE as "accountCode" <!-- 企业编码 -->
FROM ${platSchema}.TXSOG01 A, ${platSchema}.TXSOG02 B, ${platSchema}.XS_USER C
WHERE 1=1
AND A.ORG_ID = B.ORG_ID
AND B.USER_ID = C.USER_ID
AND C.LOGIN_NAME = #loginName#
<isNotEmpty prepend=" AND " property="accountCode">
A.ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="orgId">
A.ORG_ID = #orgId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="orgIds">
A.ORG_ID IN <iterate close=")" open="(" conjunction="," property="orgIds">#orgIds[]#</iterate>
</isNotEmpty>
</select> </select>
</sqlMap> </sqlMap>
...@@ -30,15 +30,24 @@ ...@@ -30,15 +30,24 @@
A.ID as "id", <!-- id --> A.ID as "id", <!-- id -->
A.GROUP_ENAME as "groupEname", <!-- 群组英文名 --> A.GROUP_ENAME as "groupEname", <!-- 群组英文名 -->
A.GROUP_CNAME as "groupCname", <!-- 群组中文名 --> A.GROUP_CNAME as "groupCname", <!-- 群组中文名 -->
A.ACCOUNT_CODE as "accountCode", <!-- 企业编码 --> A.DATA_AUTH_TYPE as "dataAuthType", <!-- 数据权限类型 -->
A.ACCOUNT_CODE as "accountCode", <!-- 帐套编码 -->
A.DEP_CODE as "depCode", <!-- 部门编码 -->
A.FACTORY_CODE as "factoryCode", <!-- 厂区编码 -->
A.COMPANY_CODE as "companyCode", <!-- 公司编码 -->
B.MEMBER_ID as "userId" <!-- 用户ID --> B.MEMBER_ID as "userId" <!-- 用户ID -->
FROM ${platSchema}.XS_USER_GROUP A, FROM ${platSchema}.XS_USER_GROUP A,
${platSchema}.XS_USER_GROUP_MEMBER B ${platSchema}.XS_USER_GROUP_MEMBER B,
${platSchema}.XS_USER C
WHERE 1=1 WHERE 1=1
AND A.ID = B.PARENT_ID AND A.ID = B.PARENT_ID
AND B.MEMBER_ID = C.USER_ID
AND B.MEMBER_TYPE = 'USER' AND B.MEMBER_TYPE = 'USER'
<isNotEmpty prepend=" AND " property="userId">
C.USER_ID = #userId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="userIds"> <isNotEmpty prepend=" AND " property="userIds">
B.MEMBER_ID IN <iterate close=")" open="(" conjunction="," property="userIds">#userIds[]#</iterate> C.USER_ID IN <iterate close=")" open="(" conjunction="," property="userIds">#userIds[]#</iterate>
</isNotEmpty> </isNotEmpty>
</select> </select>
......
...@@ -19,7 +19,6 @@ import com.baosight.iplat4j.core.exception.PlatException; ...@@ -19,7 +19,6 @@ import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.soa.XLocalManager; import com.baosight.iplat4j.core.service.soa.XLocalManager;
import com.baosight.iplat4j.core.web.threadlocal.UserSession; import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import com.baosight.xservices.xs.constants.LoginConstants; import com.baosight.xservices.xs.constants.LoginConstants;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -54,6 +53,19 @@ public class HGXSTools { ...@@ -54,6 +53,19 @@ public class HGXSTools {
} }
/** /**
* 查询用户
*
* @param orgIds
* @return
*/
public static List<User> queryByOrg(List<String> orgIds) {
AssertUtils.isEmpty(orgIds, "组织ID不能为空");
Map paramMap = new HashMap();
paramMap.put("orgIds", orgIds);
return DaoBase.getInstance().query(HGSqlConstant.HgXsUser.QUERY_BY_ORG, paramMap);
}
/**
* 查询 * 查询
* *
* @param loginNames * @param loginNames
...@@ -161,6 +173,17 @@ public class HGXSTools { ...@@ -161,6 +173,17 @@ public class HGXSTools {
public static class XsUserGroup { public static class XsUserGroup {
/** /**
* 查询用户角色
*
* @return
*/
public static List<UserGroup> queryByUser() {
Map paramMap = new HashMap();
paramMap.put("userId", UserSession.getUserId());
return DaoBase.getInstance().query(HGSqlConstant.HgXsUserGroup.QUERY_BY_USER, paramMap);
}
/**
* 查询 * 查询
* *
* @param userIds * @param userIds
...@@ -246,22 +269,45 @@ public class HGXSTools { ...@@ -246,22 +269,45 @@ public class HGXSTools {
} }
/** /**
* 查询用户组织机构 * 查询组织机构
* *
* @param orgIds
* @return * @return
*/ */
public static List<String> getOrgId() { public static List<Org> list(List<String> orgIds) {
AssertUtils.isEmpty(orgIds, "组织编码不能为空");
Map paramMap = new HashMap(); Map paramMap = new HashMap();
paramMap.put("userId", UserSession.getLoginName()); paramMap.put("orgIds", orgIds);
List<Map> results = DaoBase.getInstance().query(HGSqlConstant.HgXsOrg.QUERY_ORG_ID, paramMap); return DaoBase.getInstance().query(HGSqlConstant.HgXsOrg.QUERY, paramMap);
}
/**
* 查询
*
* @param orgIds
* @return
*/
public static Map<String, Org> map(List<String> orgIds) {
List<Org> results = list(orgIds);
if (CollectionUtils.isEmpty(results)) { if (CollectionUtils.isEmpty(results)) {
return null; return null;
} }
return results.stream().map(item -> item.get("orgId").toString()).collect(Collectors.toList()); return results.stream().collect(Collectors.toMap(Org::getOrgId, item -> item));
} }
/** /**
* 查询 * 查询用户组织机构
*
* @return
*/
public static List<Org> queryByUser() {
Map paramMap = new HashMap();
paramMap.put("loginName", UserSession.getLoginName());
return DaoBase.getInstance().query(HGSqlConstant.HgXsOrg.QUERY_BY_USER, paramMap);
}
/**
* 查询父级
* *
* @param orgId * @param orgId
* @return * @return
...@@ -287,7 +333,7 @@ public class HGXSTools { ...@@ -287,7 +333,7 @@ public class HGXSTools {
queryMap.put("orgId", orgId); queryMap.put("orgId", orgId);
queryMap.put("orgType", OrgTypeEnum.COMPANY.getCode()); queryMap.put("orgType", OrgTypeEnum.COMPANY.getCode());
List<Org> results = DaoBase.getInstance().query(HGSqlConstant.HgXsOrg.QUERY_PARENT, queryMap); List<Org> results = DaoBase.getInstance().query(HGSqlConstant.HgXsOrg.QUERY_PARENT, queryMap);
return CollectionUtils.isEmpty(results) ? null : results.get(0); return CollectionUtils.isEmpty(results) ? null : results.get(results.size() - 1);
} }
/** /**
...@@ -312,9 +358,20 @@ public class HGXSTools { ...@@ -312,9 +358,20 @@ public class HGXSTools {
* @return * @return
*/ */
public static List<Org> queryByParent(String parentOrgId) { public static List<Org> queryByParent(String parentOrgId) {
return queryByParent(parentOrgId, null);
}
/**
* 查询指定组织机构下所有的子集组织机构
*
* @param parentOrgId root:查询企业所有的组织信息
* @return
*/
public static List<Org> queryByParent(String parentOrgId, String orgType) {
AssertUtils.isNull(parentOrgId, "组织ID不能为空"); AssertUtils.isNull(parentOrgId, "组织ID不能为空");
Map queryMap = new HashMap(); Map queryMap = new HashMap();
queryMap.put("parentOrgId", parentOrgId); queryMap.put("parentOrgId", parentOrgId);
queryMap.put("orgType", orgType);
return DaoBase.getInstance().query(HGSqlConstant.HgXsOrg.QUERY_ALL, queryMap); return DaoBase.getInstance().query(HGSqlConstant.HgXsOrg.QUERY_ALL, queryMap);
} }
......
...@@ -17,6 +17,7 @@ import com.baosight.iplat4j.core.web.threadlocal.UserSession; ...@@ -17,6 +17,7 @@ import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -48,7 +49,7 @@ public class CommonMethod { ...@@ -48,7 +49,7 @@ public class CommonMethod {
/* 新建一个块 将每个表查询到的结果放入单独的块中 */ /* 新建一个块 将每个表查询到的结果放入单独的块中 */
EiBlock eiBlock; EiBlock eiBlock;
/* 行数据 将每个数据源查询到的数据放到每个模块的行数据中 */ /* 行数据 将每个数据源查询到的数据放到每个模块的行数据中 */
Map<String, String> row; LinkedHashMap<String, String> row;
/* 每个数据源查询到的结果暂存在这个变量中 */ /* 每个数据源查询到的结果暂存在这个变量中 */
List results; List results;
/* 将结果集中的每个结果暂存然后 强转为map */ /* 将结果集中的每个结果暂存然后 强转为map */
...@@ -68,9 +69,9 @@ public class CommonMethod { ...@@ -68,9 +69,9 @@ public class CommonMethod {
eiBlock = new EiBlock(tableParam.getBlockId()); eiBlock = new EiBlock(tableParam.getBlockId());
/* 将所有查询到的结果放到暂存变量中 */ /* 将所有查询到的结果放到暂存变量中 */
results = dao.query(tableParam.getDbSource(), selectParams, EiConstant.defaultOffset, -999999); results = dao.query(tableParam.getDbSource(), selectParams, EiConstant.defaultOffset, -999999);
List<Map> resultRows = new ArrayList<>(); List<LinkedHashMap> resultRows = new ArrayList<>();
for (Object result : results) { for (Object result : results) {
row = new HashMap<>(); row = new LinkedHashMap<>();
try { try {
tryValue = (Map) result; tryValue = (Map) result;
}catch (ClassCastException e){ }catch (ClassCastException e){
......
package com.baosight.iplat4j.core.data.ibatis.dao; package com.baosight.iplat4j.core.data.ibatis.dao;
import com.baosight.hggp.common.AuthTypeEnum; import com.baosight.hggp.common.DataAuthTypeEnum;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.security.UserSessionUtils; import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.core.tools.ThreadLocalTools; import com.baosight.hggp.core.tools.ThreadLocalTools;
import com.baosight.hggp.hg.xs.domain.UserGroup;
import com.baosight.hggp.hg.xs.tools.HGXSTools;
import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.StringUtils; import com.baosight.hggp.util.StringUtils;
import com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext; import com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext;
import com.baosight.iplat4j.core.service.soa.DomainQuery.PageStatus; import com.baosight.iplat4j.core.service.soa.DomainQuery.PageStatus;
...@@ -10,11 +14,11 @@ import com.baosight.iplat4j.core.util.ExceptionUtil; ...@@ -10,11 +14,11 @@ import com.baosight.iplat4j.core.util.ExceptionUtil;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
/** /**
* @author:songx * @author:songx
...@@ -162,7 +166,7 @@ public class SqlMapDaoLogProxy extends SqlMapDao { ...@@ -162,7 +166,7 @@ public class SqlMapDaoLogProxy extends SqlMapDao {
*/ */
private void setAuthParam(String name, Object parameters) { private void setAuthParam(String name, Object parameters) {
// 需要过滤部分sql name,否则会形成死循环 // 需要过滤部分sql name,否则会形成死循环
if (!name.startsWith("HP") || !(parameters instanceof Map)) { if (!name.startsWith("HG") || !(parameters instanceof Map)) {
return; return;
} }
if (parameters == null) { if (parameters == null) {
...@@ -182,7 +186,7 @@ public class SqlMapDaoLogProxy extends SqlMapDao { ...@@ -182,7 +186,7 @@ public class SqlMapDaoLogProxy extends SqlMapDao {
*/ */
private void setAccountCode(String name, Object parameters) { private void setAccountCode(String name, Object parameters) {
// 需要过滤部分sql name,否则会形成死循环 // 需要过滤部分sql name,否则会形成死循环
String[] serviceFilter = {"HGXSUser", "HPPZ009.query"}; String[] serviceFilter = {"HGXSUser", "HGPZ009.query"};
if (StringUtils.startsWithAny(name, serviceFilter)) { if (StringUtils.startsWithAny(name, serviceFilter)) {
return; return;
} }
...@@ -197,7 +201,7 @@ public class SqlMapDaoLogProxy extends SqlMapDao { ...@@ -197,7 +201,7 @@ public class SqlMapDaoLogProxy extends SqlMapDao {
*/ */
private void setDataAuth(String name, Object parameters) { private void setDataAuth(String name, Object parameters) {
// 需要过滤部分sql name,否则会形成死循环 // 需要过滤部分sql name,否则会形成死循环
String[] serviceFilter = {"HGXSUser", "HGXSOrg", "HGPZ009.query", "HPPZ010.query"}; String[] serviceFilter = {"HGXSUser", "HGXSOrg", "HGXSUserGroup", "HGPZ009.query", "HGPZ010.query"};
if (StringUtils.startsWithAny(name, serviceFilter)) { if (StringUtils.startsWithAny(name, serviceFilter)) {
return; return;
} }
...@@ -209,73 +213,62 @@ public class SqlMapDaoLogProxy extends SqlMapDao { ...@@ -209,73 +213,62 @@ public class SqlMapDaoLogProxy extends SqlMapDao {
if (StringUtils.isNotBlank(authEnable) && "0".equals(authEnable)) { if (StringUtils.isNotBlank(authEnable) && "0".equals(authEnable)) {
return; return;
} }
// 页面英文名 // 当前用户所有角色
String pageEname = ThreadLocalTools.FORM_ENAME.get(); List<UserGroup> userGroups = UserSessionUtils.getRole();
if (StringUtils.isBlank(pageEname)) { AssertUtils.isEmpty(userGroups, "当前用户未绑定角色,无法操作数据,请联系管理员!");
return; // 构建数据权限
} buildDataAuth(userGroups, parameters);
// 当前用户所在的部门
List<String> userOrgIds = UserSessionUtils.getOrgId();
// AssertUtils.isEmpty(userOrgIds, "当前用户未绑定部门,无法操作数据,请联系管理员!");
if (CollectionUtils.isEmpty(userOrgIds)) {
((Map) parameters).put("depCode", "unbound dep");
return;
}
// 构建部门权限
buildDepAuth(pageEname, userOrgIds, parameters);
} }
/** /**
* 构建部门权限 * 构建部门权限
* *
* @param pageEname * @param userGroups
* @param userOrgIds
* @param parameters * @param parameters
*/ */
private void buildDepAuth(String pageEname, List<String> userOrgIds, Object parameters) { private void buildDataAuth(List<UserGroup> userGroups, Object parameters) {
// 查询当前页面设置的所有权限 List<String> depCodes = new ArrayList<>();
// List<HPPZ010> dbPz010s = HPPZTools.HpPz010.listByPage(pageEname, userOrgIds); for (UserGroup userGroup : userGroups) {
// if (CollectionUtils.isEmpty(dbPz010s)) { String dataAuthType = userGroup.getDataAuthType();
// ((Map) parameters).put("depCode", AuthTypeEnum.NO_AUTH.getCode()); if (DataAuthTypeEnum.ONLY_PEOPLE.getCode().equals(dataAuthType)) {
// return; ((Map) parameters).put("authOnlyPeople", CommonConstant.YesNo.YES_1);
// } } else {
// 构建数据范围权限查询条件 List<String> depAuths = buildDepCondition(userGroup);
// List<String> depCodes = new ArrayList<>(); if (CollectionUtils.isNotEmpty(depAuths)) {
// for (HPPZ010 dbPz010 : dbPz010s) { depCodes.addAll(depAuths);
// List<String> depAuths = buildDepCondition(dbPz010); }
// ALL查看所有数据,仅限本企业 }
// if (depAuths.contains(AuthTypeEnum.ALL.getCode())) { }
// depCodes = null; // 去除重复数据
// break; if (CollectionUtils.isEmpty(depCodes)) {
// } depCodes.add(DataAuthTypeEnum.NO_AUTH.getCode());
// depCodes.addAll(depAuths); } else {
// } depCodes = depCodes.stream().distinct().collect(Collectors.toList());
// ((Map) parameters).put("depCodes", depCodes); }
((Map) parameters).put("authDepCodes", depCodes);
} }
/** /**
* 组装 Custom Data Auth Condition * 组装 Custom Data Auth Condition
* *
* @param dbPz010 * @param userGroup
*/ */
// private List<String> buildDepCondition(HPPZ010 dbPz010) { private List<String> buildDepCondition(UserGroup userGroup) {
// String authType = dbPz010.getAuthType(); String dataAuthType = userGroup.getDataAuthType();
// if (StringUtils.isBlank(authType) || AuthTypeEnum.NO_AUTH.getCode().equals(authType)) { if (StringUtils.isBlank(dataAuthType)) {
// return Arrays.asList(AuthTypeEnum.NO_AUTH.getCode()); return null;
// } }
// String authDepCode = dbPz010.getAuthDepCode(); if (DataAuthTypeEnum.ONLY_COMPANY.getCode().equals(dataAuthType)) {
// // 看全部 return HGXSTools.XsOrg.queryChildren(userGroup.getCompanyCode());
// if (AuthTypeEnum.ONLY_COMPANY.getCode().equals(authType)) { } else if (DataAuthTypeEnum.ONLY_FACTORY.getCode().equals(dataAuthType)) {
// return Arrays.asList(AuthTypeEnum.ALL.getCode()); if (StringUtils.isBlank(userGroup.getFactoryCode())) {
// } else if (AuthTypeEnum.ONLY_FACTORY.getCode().equals(authType)) { return null;
// // 查询当前部门所在的厂及子集 }
// Org factoryOrg = HPXSTools.XsOrg.queryFactory(authDepCode); return HGXSTools.XsOrg.queryChildren(userGroup.getFactoryCode());
// return HPXSTools.XsOrg.queryChildren(factoryOrg.getOrgId()); } else if (DataAuthTypeEnum.ONLY_DEPT.getCode().equals(dataAuthType)) {
// } else if (AuthTypeEnum.ONLY_DEPT.getCode().equals(authType)) { return HGXSTools.XsOrg.queryChildren(userGroup.getDepCode());
// return HPXSTools.XsOrg.queryChildren(authDepCode); }
// } else { return null;
// return Arrays.asList(AuthTypeEnum.NO_AUTH.getCode()); }
// }
// }
} }
package com.baosight.xservices.xs.domain;
import com.baosight.iplat4j.core.data.DaoEPBase;
import com.baosight.iplat4j.core.ei.EiColumn;
/**
* @author:songx
* @date:2024/5/8,9:49
*/
public class XS02 extends DaoEPBase {
public XS02() {
this.initMetaData();
}
public void initMetaData() {
EiColumn eiColumn = new EiColumn("groupId");
eiColumn.setDescName("用户群组ID");
eiColumn.setMaxLength(32);
eiColumn.setNullable(false);
eiColumn.setPrimaryKey(true);
this.eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("groupEname");
eiColumn.setDescName("群组英文名");
eiColumn.setMaxLength(32);
eiColumn.setNullable(false);
this.eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("groupCname");
eiColumn.setDescName("群组中文名");
eiColumn.setMaxLength(128);
eiColumn.setNullable(false);
this.eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("groupType");
eiColumn.setDescName("群组类型");
eiColumn.setMaxLength(32);
eiColumn.setNullable(false);
this.eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("sortIndex");
eiColumn.setDescName("排序");
eiColumn.setMaxLength(11);
eiColumn.setNullable(true);
this.eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("recCreator");
eiColumn.setDescName("创建人");
eiColumn.setMaxLength(32);
this.eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("recCreateTime");
eiColumn.setDescName("创建时间");
eiColumn.setMaxLength(255);
eiColumn.setWidth(255);
this.eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("manageGroupEname");
eiColumn.setDescName("管辖组");
eiColumn.setMaxLength(32);
eiColumn.setNullable(false);
this.eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("recRevisor");
eiColumn.setDescName("修改人");
eiColumn.setMaxLength(32);
this.eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("recReviseTime");
eiColumn.setDescName("修改时间");
eiColumn.setMaxLength(255);
eiColumn.setWidth(255);
this.eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("archiveFlag");
eiColumn.setDescName("归档标记");
eiColumn.setMaxLength(1);
this.eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("accountCode");
eiColumn.setDescName("帐套编码");
eiColumn.setMaxLength(1);
this.eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("deptCode");
eiColumn.setDescName("部门编码");
eiColumn.setMaxLength(1);
this.eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("factoryCode");
eiColumn.setDescName("厂区编码");
eiColumn.setMaxLength(1);
this.eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("companyCode");
eiColumn.setDescName("公司编码");
eiColumn.setMaxLength(1);
this.eiMetadata.addMeta(eiColumn);
}
}
package com.baosight.xservices.xs.og.service; package com.baosight.xservices.xs.og.service;
import com.baosight.hggp.core.security.UserSessionUtils; import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.pz.tools.HGPZTools; import com.baosight.hggp.hg.xs.domain.Org;
import com.baosight.hggp.hg.xs.tools.HGXSTools;
import com.baosight.iplat4j.core.ei.EiBlock; import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiBlockMeta; import com.baosight.iplat4j.core.ei.EiBlockMeta;
import com.baosight.iplat4j.core.ei.EiColumn; import com.baosight.iplat4j.core.ei.EiColumn;
...@@ -34,13 +35,14 @@ public class ServiceXSOG0800 extends TreeService { ...@@ -34,13 +35,14 @@ public class ServiceXSOG0800 extends TreeService {
public List getTopNodes() { public List getTopNodes() {
HashMap<String, String> map = new HashMap(); HashMap<String, String> map = new HashMap();
List<HashMap> list = new ArrayList(); List<HashMap> list = new ArrayList();
map.put("label", "root");
//
String accountCode = UserSessionUtils.getAccountCode(); String accountCode = UserSessionUtils.getAccountCode();
if (StringUtils.isEmpty(accountCode)) { if (StringUtils.isEmpty(accountCode)) {
map.put("label", "root");
map.put("text", "组织机构"); map.put("text", "组织机构");
} else { } else {
map.put("text", HGPZTools.HgPz009.getByCode(accountCode).getAccountName()); Org org = HGXSTools.XsOrg.get(accountCode);
map.put("label", org == null ? "root" : org.getOrgId());
map.put("text", org == null ? "组织机构" : org.getOrgCname());
} }
map.put("leaf", "0"); map.put("leaf", "0");
map.put("parent", "0"); map.put("parent", "0");
......
...@@ -54,8 +54,8 @@ public class ServiceXSOG0801A extends ServiceEPBase { ...@@ -54,8 +54,8 @@ public class ServiceXSOG0801A extends ServiceEPBase {
// 查询组织 // 查询组织
Org org = HGXSTools.XsOrg.get(parentOrgId); Org org = HGXSTools.XsOrg.get(parentOrgId);
if (OrgTypeEnum.COMPANY.getCode().equals(org.getOrgType())) { if (OrgTypeEnum.COMPANY.getCode().equals(org.getOrgType())) {
condition = String.format(" ITEM_CODE IN ('%s', '%s')", OrgTypeEnum.FACTORY.getCode(), condition = String.format(" ITEM_CODE IN ('%s', '%s', '%s')", OrgTypeEnum.COMPANY.getCode(),
OrgTypeEnum.DEPT.getCode()); OrgTypeEnum.FACTORY.getCode(), OrgTypeEnum.DEPT.getCode());
} else if (OrgTypeEnum.FACTORY.getCode().equals(org.getOrgType())) { } else if (OrgTypeEnum.FACTORY.getCode().equals(org.getOrgType())) {
condition = String.format(" ITEM_CODE IN ('%s')", OrgTypeEnum.DEPT.getCode()); condition = String.format(" ITEM_CODE IN ('%s')", OrgTypeEnum.DEPT.getCode());
} else if (OrgTypeEnum.DEPT.getCode().equals(org.getOrgType())) { } else if (OrgTypeEnum.DEPT.getCode().equals(org.getOrgType())) {
......
...@@ -44,8 +44,8 @@ public class ServiceXSOG0801B extends ServiceEPBase { ...@@ -44,8 +44,8 @@ public class ServiceXSOG0801B extends ServiceEPBase {
queryMap.put("parentOrgId", org.getParentOrgId()); queryMap.put("parentOrgId", org.getParentOrgId());
String condition; String condition;
if (OrgTypeEnum.COMPANY.getCode().equals(org.getOrgType())) { if (OrgTypeEnum.COMPANY.getCode().equals(org.getOrgType())) {
condition = String.format(" ITEM_CODE IN ('%s', '%s')", OrgTypeEnum.FACTORY.getCode(), condition = String.format(" ITEM_CODE IN ('%s', '%s', '%s')", OrgTypeEnum.COMPANY.getCode(),
OrgTypeEnum.DEPT.getCode()); OrgTypeEnum.FACTORY.getCode(), OrgTypeEnum.DEPT.getCode());
} else if (OrgTypeEnum.FACTORY.getCode().equals(org.getOrgType())) { } else if (OrgTypeEnum.FACTORY.getCode().equals(org.getOrgType())) {
condition = String.format(" ITEM_CODE IN ('%s')", OrgTypeEnum.DEPT.getCode()); condition = String.format(" ITEM_CODE IN ('%s')", OrgTypeEnum.DEPT.getCode());
} else if (OrgTypeEnum.DEPT.getCode().equals(org.getOrgType())) { } else if (OrgTypeEnum.DEPT.getCode().equals(org.getOrgType())) {
......
...@@ -3,6 +3,8 @@ package com.baosight.xservices.xs.service; ...@@ -3,6 +3,8 @@ package com.baosight.xservices.xs.service;
import com.baosight.hggp.common.DdynamicEnum; import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.enums.OrgTypeEnum; import com.baosight.hggp.core.enums.OrgTypeEnum;
import com.baosight.hggp.core.security.UserSessionUtils; import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.pz.domain.HGPZ009;
import com.baosight.hggp.hg.pz.tools.HGPZTools;
import com.baosight.hggp.hg.xs.tools.HGXSTools; import com.baosight.hggp.hg.xs.tools.HGXSTools;
import com.baosight.hggp.util.CommonMethod; import com.baosight.hggp.util.CommonMethod;
import com.baosight.hggp.util.LogUtils; import com.baosight.hggp.util.LogUtils;
...@@ -20,6 +22,8 @@ import com.baosight.xservices.xs.domain.XS02; ...@@ -20,6 +22,8 @@ import com.baosight.xservices.xs.domain.XS02;
import com.baosight.xservices.xs.util.LoginUserDetails; import com.baosight.xservices.xs.util.LoginUserDetails;
import com.baosight.xservices.xs.util.UserSession; import com.baosight.xservices.xs.util.UserSession;
import org.apache.commons.lang.StringUtils;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -47,29 +51,43 @@ public class ServiceXS3002 extends ServiceEPBase { ...@@ -47,29 +51,43 @@ public class ServiceXS3002 extends ServiceEPBase {
Map queryMap = new HashMap(); Map queryMap = new HashMap();
queryMap.put("orgType", OrgTypeEnum.DEPT.getCode()); queryMap.put("orgType", OrgTypeEnum.DEPT.getCode());
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.DEPT_CODE_BLOCK_ID), queryMap); CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.DEPT_CODE_BLOCK_ID), queryMap);
queryMap = new HashMap();
queryMap.put("orgType", OrgTypeEnum.FACTORY.getCode());
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.FACTORY_CODE_BLOCK_ID), queryMap);
queryMap = new HashMap();
queryMap.put("orgType", OrgTypeEnum.COMPANY.getCode());
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.COMPANY_CODE_BLOCK_ID), queryMap);
} catch (PlatException e) { } catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败"); LogUtils.setDetailMsg(inInfo, e, "初始化失败");
} }
return inInfo; return inInfo;
} }
/**
* 新增
*
* @param inInfo
* @return
*/
public EiInfo insert(EiInfo inInfo) { public EiInfo insert(EiInfo inInfo) {
EiInfo eiInfo = new EiInfo(); EiInfo eiInfo = new EiInfo();
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock); EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
String accountCode = UserSessionUtils.getAccountCode(); String accountCode = UserSessionUtils.getAccountCode();
for(int i = 0; i < eiBlock.getRowCount(); ++i) { // 查询你企业信息
HGPZ009 dbPz009 = StringUtils.isBlank(accountCode) ? null : HGPZTools.HgPz009.getByCode(accountCode);
final String companyPrefix = dbPz009 == null ? "" : dbPz009.getLoginPrefix() + "_";
for (int i = 0; i < eiBlock.getRowCount(); ++i) {
Map<String, Object> inInfoRowMap = eiBlock.getRow(i); Map<String, Object> inInfoRowMap = eiBlock.getRow(i);
inInfoRowMap.remove("groupId"); inInfoRowMap.remove("groupId");
inInfoRowMap.put("groupEname", companyPrefix + inInfoRowMap.get("groupEname"));
inInfoRowMap.put("recCreator", UserSession.getUser().getUsername()); inInfoRowMap.put("recCreator", UserSession.getUser().getUsername());
inInfoRowMap.put("recCreateTime", DateUtils.curDateTimeStr14()); inInfoRowMap.put("recCreateTime", DateUtils.curDateTimeStr14());
// 设置所属企业 added by songx at 2024-01-16 // 设置所属企业 added by songx at 2024-01-16
inInfoRowMap.put("accountCode", accountCode); inInfoRowMap.put("accountCode", accountCode);
} }
eiInfo.addBlock(inInfo.getBlock(EiConstant.resultBlock)); eiInfo.addBlock(inInfo.getBlock(EiConstant.resultBlock));
eiInfo.set(EiConstant.serviceId, "S_XS_18"); eiInfo.set(EiConstant.serviceId, "S_XS_18");
EiInfo outInfo = XServiceManager.call(eiInfo); return XServiceManager.call(eiInfo);
return outInfo;
} }
/** /**
...@@ -86,20 +104,23 @@ public class ServiceXS3002 extends ServiceEPBase { ...@@ -86,20 +104,23 @@ public class ServiceXS3002 extends ServiceEPBase {
return super.query(inInfo, "XS02.query", new XS02()); return super.query(inInfo, "XS02.query", new XS02());
} }
/**
* 修改
*
* @param inInfo
* @return
*/
public EiInfo update(EiInfo inInfo) { public EiInfo update(EiInfo inInfo) {
EiInfo eiInfo = new EiInfo(); EiInfo eiInfo = new EiInfo();
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock); EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
for (int i = 0; i < eiBlock.getRowCount(); ++i) {
for(int i = 0; i < eiBlock.getRowCount(); ++i) {
Map<String, Object> inInfoRowMap = eiBlock.getRow(i); Map<String, Object> inInfoRowMap = eiBlock.getRow(i);
inInfoRowMap.put("recRevisor", UserSession.getUser().getUsername()); inInfoRowMap.put("recRevisor", UserSession.getUser().getUsername());
inInfoRowMap.put("recReviseTime", DateUtils.curDateTimeStr14()); inInfoRowMap.put("recReviseTime", DateUtils.curDateTimeStr14());
} }
eiInfo.addBlock(inInfo.getBlock(EiConstant.resultBlock)); eiInfo.addBlock(inInfo.getBlock(EiConstant.resultBlock));
eiInfo.set(EiConstant.serviceId, "S_XS_20"); eiInfo.set(EiConstant.serviceId, "S_XS_20");
EiInfo outInfo = XServiceManager.call(eiInfo); return XServiceManager.call(eiInfo);
return outInfo;
} }
public EiInfo delete(EiInfo inInfo) { public EiInfo delete(EiInfo inInfo) {
......
...@@ -295,7 +295,6 @@ public class ServiceXSOrgManage extends ServiceEPBase { ...@@ -295,7 +295,6 @@ public class ServiceXSOrgManage extends ServiceEPBase {
EiBlock block = new EiBlock(EiConstant.resultBlock); EiBlock block = new EiBlock(EiConstant.resultBlock);
updateInfo.addBlock(block); updateInfo.addBlock(block);
Map orgEnameMap = new HashMap(); Map orgEnameMap = new HashMap();
for(int i = 0; i < list.size(); ++i) { for(int i = 0; i < list.size(); ++i) {
Map<String, Object> inInfoRowMap = (Map)list.get(i); Map<String, Object> inInfoRowMap = (Map)list.get(i);
String orgEname = inInfoRowMap.get("orgEname") == null ? "" : inInfoRowMap.get("orgEname").toString(); String orgEname = inInfoRowMap.get("orgEname") == null ? "" : inInfoRowMap.get("orgEname").toString();
......
...@@ -549,6 +549,12 @@ public class ServiceXSUserManage extends ServiceEPBase { ...@@ -549,6 +549,12 @@ public class ServiceXSUserManage extends ServiceEPBase {
} }
} }
/**
* 新增用户组
*
* @param inInfo
* @return
*/
public EiInfo insertUserGroup(EiInfo inInfo) { public EiInfo insertUserGroup(EiInfo inInfo) {
boolean ignoreDuplicate = "true".equals(inInfo.get("ignoreDuplicate")); boolean ignoreDuplicate = "true".equals(inInfo.get("ignoreDuplicate"));
XSServiceUtils.apiDataHandleDecorator(inInfo); XSServiceUtils.apiDataHandleDecorator(inInfo);
...@@ -667,6 +673,12 @@ public class ServiceXSUserManage extends ServiceEPBase { ...@@ -667,6 +673,12 @@ public class ServiceXSUserManage extends ServiceEPBase {
} }
} }
/**
* 修改用户组
*
* @param inInfo
* @return
*/
public EiInfo updateUserGroup(EiInfo inInfo) { public EiInfo updateUserGroup(EiInfo inInfo) {
XSServiceUtils.apiDataHandleDecorator(inInfo); XSServiceUtils.apiDataHandleDecorator(inInfo);
if (inInfo.getStatus() == -1) { if (inInfo.getStatus() == -1) {
......
...@@ -15,7 +15,11 @@ ...@@ -15,7 +15,11 @@
REC_REVISOR, REC_REVISOR,
REC_REVISE_TIME, REC_REVISE_TIME,
ARCHIVE_FLAG, ARCHIVE_FLAG,
ACCOUNT_CODE ACCOUNT_CODE,
DEP_CODE,
FACTORY_CODE,
COMPANY_CODE,
DATA_AUTH_TYPE
) VALUES ( ) VALUES (
#groupId#, #groupId#,
#groupEname#, #groupEname#,
...@@ -28,7 +32,11 @@ ...@@ -28,7 +32,11 @@
#recRevisor#, #recRevisor#,
#recReviseTime#, #recReviseTime#,
#archiveFlag#, #archiveFlag#,
#accountCode# #accountCode#,
#depCode#,
#factoryCode#,
#companyCode#,
#dataAuthType#
) )
</insert> </insert>
...@@ -78,10 +86,19 @@ ...@@ -78,10 +86,19 @@
t1.rec_revisor as "recRevisor", t1.rec_revisor as "recRevisor",
t1.rec_revise_time as "recReviseTime", t1.rec_revise_time as "recReviseTime",
t1.archive_flag as "archiveFlag", t1.archive_flag as "archiveFlag",
t1.account_code as "accountCode",
t1.dep_code as "depCode",
t1.factory_code as "factoryCode",
t1.company_code as "companyCode",
t1.data_auth_type as "dataAuthType",
t2.group_cname as "manageGroupCname" t2.group_cname as "manageGroupCname"
FROM (select id,group_ename,group_cname,manage_group_ename,group_type,sort_index,rec_creator,rec_create_time, FROM (
rec_revisor,rec_revise_time,archive_flag,account_code from ${platSchema}.XS_USER_GROUP where group_ename != 'ADMIN') t1 select id,group_ename,group_cname,manage_group_ename,group_type,sort_index,
left join ${platSchema}.XS_USER_GROUP t2 on t1.manage_group_ename=t2.group_ename rec_creator,rec_create_time, rec_revisor,rec_revise_time, archive_flag,
account_code, dep_code, factory_code, company_code, data_auth_type
from ${platSchema}.XS_USER_GROUP where group_ename != 'ADMIN'
) t1
left join ${platSchema}.XS_USER_GROUP t2 on t1.manage_group_ename = t2.group_ename
where 1=1 where 1=1
<isNotEmpty prepend=" AND " property="groupId"> <isNotEmpty prepend=" AND " property="groupId">
t1.id = #groupId# t1.id = #groupId#
...@@ -190,6 +207,10 @@ ...@@ -190,6 +207,10 @@
UPDATE ${platSchema}.XS_USER_GROUP UPDATE ${platSchema}.XS_USER_GROUP
<dynamic prepend="set"> <dynamic prepend="set">
manage_group_ename = #manageGroupEname#, manage_group_ename = #manageGroupEname#,
DEP_CODE = #depCode#,
FACTORY_CODE = #factoryCode#,
COMPANY_CODE = #companyCode#,
DATA_AUTH_TYPE = #dataAuthType#,
<isNotEmpty prepend="," property="groupEname"> <isNotEmpty prepend="," property="groupEname">
group_ename = #groupEname# group_ename = #groupEname#
</isNotEmpty> </isNotEmpty>
......
...@@ -48,6 +48,7 @@ $(function () { ...@@ -48,6 +48,7 @@ $(function () {
$(window).load(function () { $(window).load(function () {
resultGrid.dataSource.page(1) resultGrid.dataSource.page(1)
}); });
$(document.body).on("click", "#QUERY", function (e) { $(document.body).on("click", "#QUERY", function (e) {
var loginName = $("[name = 'inqu_status-0-loginName']").val(); var loginName = $("[name = 'inqu_status-0-loginName']").val();
var userName = $("[name = 'inqu_status-0-userName']").val(); var userName = $("[name = 'inqu_status-0-userName']").val();
......
let deptCodeGlobalData = [];
$(function () { $(function () {
setTimeout(() => { setTimeout(() => {
...@@ -13,9 +11,7 @@ $(function () { ...@@ -13,9 +11,7 @@ $(function () {
pageSize: 20 pageSize: 20
}, },
loadComplete: function () { loadComplete: function () {
$('#QUERY').on('click', () => {
refreshQuery();
})
}, },
onRowClick: function (e) { onRowClick: function (e) {
getSelectedModel(e) getSelectedModel(e)
...@@ -32,18 +28,7 @@ $(function () { ...@@ -32,18 +28,7 @@ $(function () {
}, },
loadComplete: function (grid) { loadComplete: function (grid) {
grid.dataSource.bind("change", function (e) { grid.dataSource.bind("change", function (e) {
if (e.field == "deptCode") { deptCodeChange(e);
var item = e.items[0];
for (let k = 0; k < resultGrid.getCheckedRowsIndex() + 1; k++) {
for (let i = 0; i < deptCodeGlobalData.length; i++) {
if (deptCodeGlobalData[i]['textField'] === item.deptCode) {
resultGrid.setCellValue(item, 'factoryCode', deptCodeGlobalData[i]['param1Field']);
resultGrid.setCellValue(item, 'companyCode', deptCodeGlobalData[i]['param2Field']);
break;
}
}
}
}
}); });
} }
}, },
...@@ -195,11 +180,12 @@ $(function () { ...@@ -195,11 +180,12 @@ $(function () {
}, },
}, },
} }
$("#resourceTab").addClass("i-fit-height"); $("#resourceTab").addClass("i-fit-height");
$("#splitter").kendoSplitter({ $("#splitter").kendoSplitter({
panes: [ panes: [
{size: "40%", min: "30%", max: "70%", collapsible: true}, {size: "50%", min: "30%", max: "70%", collapsible: true},
{}, {},
{collapsible: true} {collapsible: true}
] ]
...@@ -215,7 +201,7 @@ $(function () { ...@@ -215,7 +201,7 @@ $(function () {
if (document.getElementById("splitter").getElementsByClassName("k-splitbar").length !== 1) { if (document.getElementById("splitter").getElementsByClassName("k-splitbar").length !== 1) {
$("#splitter").kendoSplitter({ $("#splitter").kendoSplitter({
panes: [ panes: [
{size: "40%", min: "30%", max: "70%", collapsible: true}, {size: "50%", min: "30%", max: "70%", collapsible: true},
{}, {},
{collapsible: true} {collapsible: true}
] ]
...@@ -225,30 +211,38 @@ $(function () { ...@@ -225,30 +211,38 @@ $(function () {
} }
} }
$(document.body).on("click", "#QUERY", function (e) {
refreshQuery();
});
}); });
/** /**
* 页面加载时执行 * 页面加载时执行
*/ */
$(window).load(function () { $(window).load(function () {
// 部门
initDept();
}); });
/** /**
* 初始化部门 * 部门编码变更
*/ */
let initDept = function () { let deptCodeChange = function (e) {
let inInfo = new EiInfo(); if (e.field != "depCode") {
inInfo.set("inqu_status-0-orgType", 'dept'); return;
EiCommunicator.send("HGXSOrg", "queryDeptComboBox", inInfo, { }
onSuccess: function (ei) { let item = e.items[0];
deptCodeGlobalData = ei.getBlock("dept_code_block_id").getMappedRows(); let deptCodeRows = __eiInfo.blocks.dept_code_block_id.rows;
}, for (let k = 0; k < resultGrid.getCheckedRowsIndex() + 1; k++) {
onFail: function (ei) { for (let i = 0; i < deptCodeRows.length; i++) {
if (deptCodeRows[i][1] === item.depCode) {
let factoryCode = deptCodeRows[i][2];
resultGrid.setCellValue(item, 'factoryCode', factoryCode == null ? "" : factoryCode);
let companyCode = deptCodeRows[i][4]
resultGrid.setCellValue(item, 'companyCode', companyCode == null ? "" : companyCode);
return;
}
} }
}, {async: false}); }
} }
function refreshQuery() { function refreshQuery() {
......
...@@ -18,27 +18,39 @@ ...@@ -18,27 +18,39 @@
</div> </div>
<hr> <hr>
<EF:EFGrid blockId="result" autoDraw="no" personal="true" autoBind="true"> <EF:EFGrid blockId="result" autoDraw="no" personal="true" autoBind="true">
<EF:EFColumn ename="groupId" cname="用户群组ID" readonly="false" hidden="true" primaryKey="true"/> <EF:EFColumn ename="groupId" cname="用户群组ID" readonly="false" hidden="true" primaryKey="true"/>
<EF:EFColumn ename="groupEname" cname="角色英文名" style="text-align:left;" readonly="true" <EF:EFColumn ename="groupEname" cname="角色英文名" style="text-align:left;" readonly="true"
required="true" data-regex="/^[@_a-zA-Z0-9]{1,32}$/" required="true" data-regex="/^[@_a-zA-Z0-9]{1,32}$/"
data-errorprompt="对不起,用户组英文名只能是32位英文字母或数字字符或下划线或@符"/> data-errorprompt="对不起,用户组英文名只能是32位英文字母或数字字符或下划线或@符"/>
<EF:EFColumn ename="groupCname" cname="角色中文名" required="true" style="text-align:left;"/> <EF:EFColumn ename="groupCname" cname="角色中文名" required="true" style="text-align:left;"/>
<EF:EFComboColumn ename="deptCode" required="true" cname="所属部门" width="110" align="center" <EF:EFComboColumn ename="dataAuthType" cname="查看数据范围" width="110" align="center"
defaultValue="" filter="contains"> required="true">
<EF:EFCodeOption codeName="hggp.role.dataAuthType"/>
</EF:EFComboColumn>
<EF:EFComboColumn ename="depCode" cname="所属部门" width="110" align="center"
defaultValue="" filter="contains" required="true">
<EF:EFOptions blockId="dept_code_block_id" valueField="valueField" textField="textField"/> <EF:EFOptions blockId="dept_code_block_id" valueField="valueField" textField="textField"/>
</EF:EFComboColumn> </EF:EFComboColumn>
<EF:EFColumn ename="factoryCode" cname="所属厂区" width="150" align="center" required="true" readonly="true"/> <EF:EFComboColumn ename="factoryCode" cname="所属厂区" enable="false" width="110" align="center"
<EF:EFColumn ename="companyCode" cname="所属公司" width="150" align="center" required="true" readonly="true"/> defaultValue="">
<EF:EFOptions blockId="factory_code_block_id" valueField="valueField"
textField="textField"/>
</EF:EFComboColumn>
<EF:EFComboColumn ename="companyCode" cname="所属公司" enable="false" width="110" align="center"
defaultValue="">
<EF:EFOptions blockId="company_code_block_id" valueField="valueField"
textField="textField"/>
</EF:EFComboColumn>
<EF:EFColumn ename="manageGroupEname" cname="管辖组英文名" style="text-align:left;" hidden="true"/> <EF:EFColumn ename="manageGroupEname" cname="管辖组英文名" style="text-align:left;" hidden="true"/>
<EF:EFColumn ename="manageGroupCname" cname="管辖组中文名" style="text-align:left;" readonly="true" <EF:EFColumn ename="manageGroupCname" cname="管辖组中文名" style="text-align:left;" readonly="true"
hidden="true"/> hidden="true"/>
<EF:EFComboColumn ename="groupType" cname="群组类型" valueField="valueField" textField="textField" <EF:EFComboColumn ename="groupType" cname="群组类型" valueField="valueField" textField="textField"
defaultValue="NORMAL" columnTemplate="#=textField#" align="center" defaultValue="NORMAL" columnTemplate="#=textField#" align="center"
required="true" hidden="true"> required="true" hidden="true">
<EF:EFCodeOption codeName="iplat.xs.userGroup"/> <EF:EFCodeOption codeName="iplat.xs.userGroup"/>
</EF:EFComboColumn> </EF:EFComboColumn>
<EF:EFColumn ename="sortIndex" cname="排序" style="text-align:right;" hidden="true"/> <EF:EFColumn ename="sortIndex" cname="排序" style="text-align:right;" hidden="true"/>
<EF:EFColumn ename="recCreator" cname="创建人" enable="false" style="text-align:left;" <EF:EFColumn ename="recCreator" cname="创建人" enable="false" style="text-align:left;"
hidden="true"/> hidden="true"/>
<EF:EFColumn ename="recCreateTime" cname="创建时间" enable="false" editType="datetime" <EF:EFColumn ename="recCreateTime" cname="创建时间" enable="false" editType="datetime"
parseFormats="['yyyyMMddHHmmss','yyyy-MM-dd HH:mm:ss']" parseFormats="['yyyyMMddHHmmss','yyyy-MM-dd HH:mm:ss']"
......
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