Commit 750bcb2f by 宋祥

1.初始化用户类

parent 6b4c4474
...@@ -32,7 +32,7 @@ public class UserSessionUtils extends UserSession { ...@@ -32,7 +32,7 @@ public class UserSessionUtils extends UserSession {
public static User getUser() { public static User getUser() {
EiInfo eiInfo = new EiInfo(); EiInfo eiInfo = new EiInfo();
eiInfo.set("userId", UserSession.getUserId()); eiInfo.set("userId", UserSession.getUserId());
eiInfo.set(EiConstant.serviceName, "HPXSUser"); eiInfo.set(EiConstant.serviceName, "HGXSUser");
eiInfo.set(EiConstant.methodName, "getUser"); eiInfo.set(EiConstant.methodName, "getUser");
EiInfo outInfo = XLocalManager.call(eiInfo); EiInfo outInfo = XLocalManager.call(eiInfo);
// -1表示报错 // -1表示报错
......
...@@ -399,16 +399,16 @@ public class HGSqlConstant { ...@@ -399,16 +399,16 @@ public class HGSqlConstant {
* @author:songx * @author:songx
* @date:2024/1/20,16:45 * @date:2024/1/20,16:45
*/ */
public class HpXsOrg { public class HgXsOrg {
// 查询组织机构 // 查询组织机构
public static final String QUERY = "HPXSOrg.query"; public static final String QUERY = "HGXSOrg.query";
// 查询企业下所有的组织机构 // 查询企业下所有的组织机构
public static final String QUERY_ALL = "HPXSOrg.queryAll"; public static final String QUERY_ALL = "HGXSOrg.queryAll";
// 查询父级信息,含自己(递归) // 查询父级信息,含自己(递归)
public static final String QUERY_PARENT = "HPXSOrg.queryParent"; public static final String QUERY_PARENT = "HGXSOrg.queryParent";
// 查询用户组织机构 // 查询用户组织机构
public static final String QUERY_ORG_ID = "HPXSUser.queryOrgId"; public static final String QUERY_ORG_ID = "HGXSUser.queryOrgId";
} }
} }
package com.baosight.hggp.hg.xs.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.util.CommonMethod;
import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.ObjectUtils;
import com.baosight.hggp.util.contants.ACConstants;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author:songx
* @date:2024/1/15,15:08
*/
public class ServiceHGXSOrg extends ServiceBase {
/**
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "组织管理", operType = "查询", operDesc = "厂区下拉框")
public EiInfo queryFactoryComboBox(EiInfo inInfo) {
try {
List<DdynamicEnum> list = new ArrayList<>();
list.add(DdynamicEnum.FACTORY_RECORD_BLOCK_ID);
CommonMethod.initBlock(inInfo, list, EiInfoUtils.getFirstRow(inInfo), false);
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "查询厂区失败");
}
return inInfo;
}
/**
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "组织管理", operType = "查询", operDesc = "组下拉框")
public EiInfo queryGroupComboBox(EiInfo inInfo) {
try {
Map queryRow = EiInfoUtils.getFirstRow(inInfo);
if (ObjectUtils.isEmpty(queryRow.get("parentOrgId"))) {
queryRow.put("parentOrgId", CommonConstant.Field.ROOT);
}
List<DdynamicEnum> list = new ArrayList<>();
list.add(DdynamicEnum.GROUP_RECORD_BLOCK_ID);
CommonMethod.initBlock(inInfo, list, queryRow, false);
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "查询组失败");
}
return inInfo;
}
/**
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "组织管理", operType = "查询", operDesc = "组下拉框")
public EiInfo queryAppGroup(EiInfo inInfo) {
try {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0, "userId", UserSessionUtils.getUserId());
Map queryRow = EiInfoUtils.getFirstRow(inInfo);
List<DdynamicEnum> list = new ArrayList<>();
list.add(DdynamicEnum.USER_GROUP_BLOCK_ID);
CommonMethod.initBlock(inInfo, list, queryRow, false);
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "查询组失败");
inInfo.setStatus(500);
}
return inInfo;
}
}
package com.baosight.hggp.hg.xs.service;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.xs.domain.User;
import com.baosight.hggp.util.CommonMethod;
import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.ObjectUtils;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import org.apache.commons.lang.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 当前类已屏蔽SQL自动补全企业参数,如需查询需要需自行添加企业编码参数
*
* @author:songx
* @date:2024/1/15,15:08
*/
public class ServiceHGXSUser extends ServiceBase {
/**
* 获取用户信息
*
* @param eiInfo
* @return
*/
public EiInfo getUser(EiInfo eiInfo) {
EiInfo outInfo = new EiInfo();
int status = 0;
String msg = "";
try {
String userId = eiInfo.getString("userId");
if (StringUtils.isNotEmpty(userId)) {
Map map = new HashMap();
map.put("userId", userId);
List<User> users = dao.query("HGXSUser.query", map);
if (users != null && users.size() > 0) {
status = 1;
msg = "用户存在!";
outInfo.set("result", users.get(0));
} else {
msg = "用户信息不存在!";
}
} else {
msg = "传入用户名不能为空!";
}
outInfo.setStatus(status);
outInfo.setMsg(msg);
} catch (Exception e) {
LogUtils.setDetailMsg(outInfo, e, "平台调用用户信息异常");
}
return outInfo;
}
/**
* 查询用户下拉框
*
* @param inInfo
* @return
*/
public EiInfo queryComboBox(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
queryMap.put("companyCode", UserSessionUtils.getCompanyCode());
List<DdynamicEnum> list = new ArrayList<>();
list.add(DdynamicEnum.USER_BLOCK_ID);
CommonMethod.initBlock(inInfo, list, queryMap);
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "查询企业失败");
}
return inInfo;
}
/**
* 查询用户的企业下拉框
*
* @param inInfo
* @return
*/
public EiInfo queryCompanyComboBox(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
if (ObjectUtils.isNullBlank(queryMap.get("loginName"))) {
return inInfo;
}
List<DdynamicEnum> list = new ArrayList<>();
list.add(DdynamicEnum.COMPANY_RECORD_BLOCK_ID);
queryMap.put("companyCode", UserSessionUtils.getCompanyCode());
CommonMethod.initBlock(inInfo, list, queryMap, false);
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "查询企业失败");
}
return inInfo;
}
}
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd"> <!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="HPXSOrg"> <sqlMap namespace="HGXSOrg">
<sql id="condition"> <sql id="condition">
AND IS_DELETED = '0' AND IS_DELETED = '0'
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd"> <!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="HPXSUser"> <sqlMap namespace="HGXSUser">
<sql id="condition"> <sql id="condition">
<isNotEmpty prepend=" AND " property="loginName"> <isNotEmpty prepend=" AND " property="loginName">
......
...@@ -46,7 +46,7 @@ public class HGXSTools { ...@@ -46,7 +46,7 @@ public class HGXSTools {
AssertUtils.isEmpty(loginName, "用户登录名不能为空"); AssertUtils.isEmpty(loginName, "用户登录名不能为空");
Map paramMap = new HashMap(); Map paramMap = new HashMap();
paramMap.put("loginName", loginName); paramMap.put("loginName", loginName);
List<User> results = DaoBase.getInstance().query("HPXSUser.query", paramMap); List<User> results = DaoBase.getInstance().query("HGXSUser.query", paramMap);
return CollectionUtils.isEmpty(results) ? null : results.get(0); return CollectionUtils.isEmpty(results) ? null : results.get(0);
} }
...@@ -62,7 +62,7 @@ public class HGXSTools { ...@@ -62,7 +62,7 @@ public class HGXSTools {
} }
Map queryMap = new HashMap(); Map queryMap = new HashMap();
queryMap.put("loginNames", loginNames); queryMap.put("loginNames", loginNames);
return DaoBase.getInstance().query("HPXSUser.query", queryMap); return DaoBase.getInstance().query("HGXSUser.query", queryMap);
} }
/** /**
...@@ -88,7 +88,7 @@ public class HGXSTools { ...@@ -88,7 +88,7 @@ public class HGXSTools {
public static int countByCompany(String companyCode) { public static int countByCompany(String companyCode) {
Map paramMap = new HashMap(); Map paramMap = new HashMap();
paramMap.put("companyCode", companyCode); paramMap.put("companyCode", companyCode);
List<Integer> results = DaoBase.getInstance().query("HPXSUser.count", paramMap); List<Integer> results = DaoBase.getInstance().query("HGXSUser.count", paramMap);
return CollectionUtils.isEmpty(results) ? 0 : results.get(0); return CollectionUtils.isEmpty(results) ? 0 : results.get(0);
} }
...@@ -164,7 +164,7 @@ public class HGXSTools { ...@@ -164,7 +164,7 @@ public class HGXSTools {
AssertUtils.isEmpty(orgId, "组织编码不能为空"); AssertUtils.isEmpty(orgId, "组织编码不能为空");
Map paramMap = new HashMap(); Map paramMap = new HashMap();
paramMap.put("orgId", orgId); paramMap.put("orgId", orgId);
List<Org> results = DaoBase.getInstance().query(HGSqlConstant.HpXsOrg.QUERY, paramMap); List<Org> results = DaoBase.getInstance().query(HGSqlConstant.HgXsOrg.QUERY, paramMap);
AssertUtils.isEmpty(results, String.format("组织信息[%s]不存在", orgId)); AssertUtils.isEmpty(results, String.format("组织信息[%s]不存在", orgId));
return results.get(0); return results.get(0);
} }
...@@ -177,7 +177,7 @@ public class HGXSTools { ...@@ -177,7 +177,7 @@ public class HGXSTools {
public static List<String> getOrgId() { public static List<String> getOrgId() {
Map paramMap = new HashMap(); Map paramMap = new HashMap();
paramMap.put("userId", UserSession.getLoginName()); paramMap.put("userId", UserSession.getLoginName());
List<Map> results = DaoBase.getInstance().query(HGSqlConstant.HpXsOrg.QUERY_ORG_ID, paramMap); List<Map> results = DaoBase.getInstance().query(HGSqlConstant.HgXsOrg.QUERY_ORG_ID, paramMap);
if (CollectionUtils.isEmpty(results)) { if (CollectionUtils.isEmpty(results)) {
return null; return null;
} }
...@@ -194,7 +194,7 @@ public class HGXSTools { ...@@ -194,7 +194,7 @@ public class HGXSTools {
AssertUtils.isNull(orgId, "组织ID不能为空"); AssertUtils.isNull(orgId, "组织ID不能为空");
Map queryMap = new HashMap(); Map queryMap = new HashMap();
queryMap.put("orgId", orgId); queryMap.put("orgId", orgId);
List<Org> results = DaoBase.getInstance().query(HGSqlConstant.HpXsOrg.QUERY_PARENT, queryMap); List<Org> results = DaoBase.getInstance().query(HGSqlConstant.HgXsOrg.QUERY_PARENT, queryMap);
AssertUtils.isEmpty(results, String.format("组织[%s]不存在父级信息", orgId)); AssertUtils.isEmpty(results, String.format("组织[%s]不存在父级信息", orgId));
return results; return results;
} }
...@@ -210,7 +210,7 @@ public class HGXSTools { ...@@ -210,7 +210,7 @@ public class HGXSTools {
Map queryMap = new HashMap(); Map queryMap = new HashMap();
queryMap.put("orgId", orgId); queryMap.put("orgId", orgId);
queryMap.put("orgType", OrgTypeEnum.FACTORY.getCode()); queryMap.put("orgType", OrgTypeEnum.FACTORY.getCode());
List<Org> results = DaoBase.getInstance().query(HGSqlConstant.HpXsOrg.QUERY_PARENT, queryMap); List<Org> results = DaoBase.getInstance().query(HGSqlConstant.HgXsOrg.QUERY_PARENT, queryMap);
AssertUtils.isEmpty(results, String.format("组织[%s]不存在厂区信息", orgId)); AssertUtils.isEmpty(results, String.format("组织[%s]不存在厂区信息", orgId));
return results.get(0); return results.get(0);
} }
...@@ -225,7 +225,7 @@ public class HGXSTools { ...@@ -225,7 +225,7 @@ public class HGXSTools {
AssertUtils.isNull(parentOrgId, "组织ID不能为空"); AssertUtils.isNull(parentOrgId, "组织ID不能为空");
Map queryMap = new HashMap(); Map queryMap = new HashMap();
queryMap.put("parentOrgId", parentOrgId); queryMap.put("parentOrgId", parentOrgId);
return DaoBase.getInstance().query(HGSqlConstant.HpXsOrg.QUERY_ALL, queryMap); return DaoBase.getInstance().query(HGSqlConstant.HgXsOrg.QUERY_ALL, queryMap);
} }
/** /**
...@@ -240,7 +240,7 @@ public class HGXSTools { ...@@ -240,7 +240,7 @@ public class HGXSTools {
} }
Map queryMap = new HashMap(); Map queryMap = new HashMap();
queryMap.put("companyCode", companyCode); queryMap.put("companyCode", companyCode);
List<Org> results = DaoBase.getInstance().query(HGSqlConstant.HpXsOrg.QUERY_ALL, queryMap); List<Org> results = DaoBase.getInstance().query(HGSqlConstant.HgXsOrg.QUERY_ALL, queryMap);
if (CollectionUtils.isEmpty(results)) { if (CollectionUtils.isEmpty(results)) {
return null; return null;
} }
...@@ -262,7 +262,7 @@ public class HGXSTools { ...@@ -262,7 +262,7 @@ public class HGXSTools {
queryMap.put("parentOrgId", orgId); queryMap.put("parentOrgId", orgId);
queryMap.put("orgType", orgType); queryMap.put("orgType", orgType);
List<Map> results = DaoBase.getInstance().query("HPXSOrg.queryGroupComboBox", queryMap); List<Map> results = DaoBase.getInstance().query("HGXSOrg.queryGroupComboBox", queryMap);
AssertUtils.isEmpty(results, String.format("组织[%s]不存在父级信息", orgId)); AssertUtils.isEmpty(results, String.format("组织[%s]不存在父级信息", orgId));
return results; return results;
} }
......
...@@ -182,7 +182,7 @@ public class SqlMapDaoLogProxy extends SqlMapDao { ...@@ -182,7 +182,7 @@ public class SqlMapDaoLogProxy extends SqlMapDao {
*/ */
private void setCompanyCode(String name, Object parameters) { private void setCompanyCode(String name, Object parameters) {
// 需要过滤部分sql name,否则会形成死循环 // 需要过滤部分sql name,否则会形成死循环
String[] serviceFilter = {"HPXSUser", "HPPZ009.query"}; String[] serviceFilter = {"HGXSUser", "HPPZ009.query"};
if (StringUtils.startsWithAny(name, serviceFilter)) { if (StringUtils.startsWithAny(name, serviceFilter)) {
return; return;
} }
...@@ -197,7 +197,7 @@ public class SqlMapDaoLogProxy extends SqlMapDao { ...@@ -197,7 +197,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 = {"HPXSUser", "HPXSOrg", "HPPZ009.query", "HPPZ010.query"}; String[] serviceFilter = {"HGXSUser", "HGXSOrg", "HPPZ009.query", "HPPZ010.query"};
if (StringUtils.startsWithAny(name, serviceFilter)) { if (StringUtils.startsWithAny(name, serviceFilter)) {
return; return;
} }
......
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