Commit 6c06a0bc by 宋祥

1.数据权限开发

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