diff --git a/src/main/java/com/api/xuanran/wang/ambofo/checkuser/controller/CheckUserController.java b/src/main/java/com/api/xuanran/wang/ambofo/checkuser/controller/CheckUserController.java
index d33caa7..ab3a016 100644
--- a/src/main/java/com/api/xuanran/wang/ambofo/checkuser/controller/CheckUserController.java
+++ b/src/main/java/com/api/xuanran/wang/ambofo/checkuser/controller/CheckUserController.java
@@ -13,6 +13,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
+import java.util.Map;
/**
*
安波福从AD域中校验用户是否存在
@@ -32,8 +33,7 @@ public class CheckUserController {
String checkContent = request.getParameter("checkContent");
try {
CheckUserService checkUserService = new CheckUserService();
- boolean has = checkUserService.checkADHasUser(checkContent);
- return ApiResult.success(has,"ok");
+ return ApiResult.success(checkUserService.checkADHasUser(checkContent),"ok");
}catch (Exception e){
String error = Util.logStr("AD查询接口发生异常:{}", e.getMessage());
log.error(error);
diff --git a/src/main/java/com/api/xuanran/wang/ambofo/checkuser/service/CheckUserService.java b/src/main/java/com/api/xuanran/wang/ambofo/checkuser/service/CheckUserService.java
index 1ced546..df6393e 100644
--- a/src/main/java/com/api/xuanran/wang/ambofo/checkuser/service/CheckUserService.java
+++ b/src/main/java/com/api/xuanran/wang/ambofo/checkuser/service/CheckUserService.java
@@ -9,10 +9,13 @@ import org.apache.log4j.Logger;
import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
import javax.naming.ldap.InitialLdapContext;
import javax.naming.ldap.LdapContext;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
@@ -37,7 +40,6 @@ public class CheckUserService {
if(MapUtils.isEmpty(ADConfig)){
throw new CustomerException("请检查/filesystem/prop/prop2map 文件夹下是否存在AmbofoADConfig.properties文件!");
}
-
log.info(Util.logStr("AD配置对象 : [{}]", JSONObject.toJSONString(ADConfig)));
}
@@ -46,9 +48,9 @@ public class CheckUserService {
* @author xuanran.wang
* @dateTime 2022/12/12 15:22
* @param checkInfo 校验内容
- * @return true/false 有/没有
+ * @return map 人员信息 mail:****,userName
**/
- public boolean checkADHasUser(String checkInfo) {
+ public Map checkADHasUser(String checkInfo) {
//连接到AD
LdapContext ldapContext = login();
try {
@@ -66,39 +68,24 @@ public class CheckUserService {
NamingEnumeration answer = ldapContext.search(searchBase, searchFilter, searchControl);
boolean has = answer.hasMoreElements();
log.info("has " + has);
+ HashMap res = new HashMap<>();
if(has){
SearchResult sr = (SearchResult) answer.next();
- String dn = sr.getName();
- log.info("dn " + dn);
+// String dn = sr.getName();
+ NamingEnumeration extends Attribute> attrs = sr.getAttributes().getAll();
+ while (attrs.hasMore()) {
+ Attribute attr = attrs.next();
+ String id = attr.getID();
+ Object value = attr.get();
+ if("mail".equals(id)){
+ res.put("mail", value);
+ }else if ("displayName".equals(id)){
+ res.put("userName", value);
+ }
+ }
}
// 初始化搜索结果数为0
- return has;
- } catch (NamingException e) {
- throw new CustomerException(Util.logStr("从AD搜索用户异常:[{}]",e.getMessage()));
- } finally {
- close(ldapContext);
- }
- }
-
- public void logAllUser() {
- //连接到AD
- LdapContext ldapContext = login();
- try {
- // 域节点
- String searchBase = Util.null2String(ADConfig.get("searchBase"));
- // LDAP搜索过滤器类 cn=*name*模糊查询 cn=name 精确查询 String searchFilter = "(objectClass="+type+")";
- // 创建搜索控制器
- SearchControls searchControl = new SearchControls();
- // 设置搜索范围 深度
- searchControl.setSearchScope(SearchControls.SUBTREE_SCOPE);
- // 根据设置的域节点、过滤器类和搜索控制器搜索LDAP得到结果
- NamingEnumeration answer = ldapContext.search(searchBase, "", searchControl);
- //4. 获取查询的内容
- while (answer.hasMoreElements()) {
- SearchResult sr = (SearchResult) answer.next();
- String dn = sr.getName();
- log.info("dn " + dn);
- }
+ return res;
} catch (NamingException e) {
throw new CustomerException(Util.logStr("从AD搜索用户异常:[{}]",e.getMessage()));
} finally {
diff --git a/src/main/java/weaver/xuanran/wang/bme/action/CusCreateWaterNoAction.java b/src/main/java/weaver/xuanran/wang/bme/action/CusCreateWaterNoAction.java
index ca7d9eb..e129c0b 100644
--- a/src/main/java/weaver/xuanran/wang/bme/action/CusCreateWaterNoAction.java
+++ b/src/main/java/weaver/xuanran/wang/bme/action/CusCreateWaterNoAction.java
@@ -2,8 +2,11 @@ package weaver.xuanran.wang.bme.action;
import aiyh.utils.Util;
import aiyh.utils.action.SafeCusBaseAction;
+import aiyh.utils.annotation.PrintParamMark;
import aiyh.utils.annotation.RequiredMark;
import aiyh.utils.excention.CustomerException;
+import aiyh.utils.sqlUtil.sqlResult.impl.PrepSqlResultImpl;
+import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
import weaver.conn.RecordSetTrans;
import weaver.hrm.User;
@@ -11,7 +14,9 @@ import weaver.soa.workflow.request.RequestInfo;
import weaver.xuanran.wang.common.util.CommonUtil;
import weaver.xuanran.wang.common.util.CusInfoToOAUtil;
+import java.util.HashMap;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
/**
@@ -29,20 +34,42 @@ public class CusCreateWaterNoAction extends SafeCusBaseAction {
* 存货分类编码字段
**/
@RequiredMark
+ @PrintParamMark
private String invClassificationCode;
/**
* 存货编码 生成编号后写入这个字段
**/
@RequiredMark
+ @PrintParamMark
private String inventoryCode;
/**
* 生成流水号日志记录模块id
**/
+ @RequiredMark
+ @PrintParamMark
private String serialNumberModelId;
- private static final String START_NO = "0101";
+ /**
+ * 明细表下标 如果配置了就会把主表生成的存货编码复制到明细表中
+ **/
+ @PrintParamMark
+ private String detailIndex;
+
+ /**
+ * 明细表存货编码字段名
+ **/
+ @PrintParamMark
+ private String detailInventoryCode;
+
+ /**
+ * 创建流水的条件
+ **/
+ @PrintParamMark
+ private String createWhere;
+
+ private static final String START_NO = "01.01";
@Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
@@ -50,6 +77,19 @@ public class CusCreateWaterNoAction extends SafeCusBaseAction {
RecordSetTrans rsts = new RecordSetTrans();
rsts.setAutoCommit(false);
try {
+ RecordSet rs = new RecordSet();
+ String sql = " select id from " + billTable + " where requestid = ? ";
+ if(StringUtils.isNotBlank(createWhere)){
+ sql += " and " + createWhere;
+ }
+ String mainId = "";
+ if(rs.executeQuery(sql, requestId) && rs.next()) {
+ mainId = Util.null2DefaultStr(rs.getString(1),"");
+ }
+ if(StringUtils.isBlank(mainId)){
+ log.info(Util.logStr("本条流程跳过生成编号!当前sql:{}", sql));
+ return;
+ }
Map mainTableValue = getMainTableValue(requestInfo);
String invClassificationCodeVal = mainTableValue.get(invClassificationCode);
String nextInventoryCode = getNextInventoryCode(invClassificationCodeVal);
@@ -58,7 +98,24 @@ public class CusCreateWaterNoAction extends SafeCusBaseAction {
log.error(Util.logStr("sql :{}, nextInventoryCode : {}, requestId: {}", updateSql, nextInventoryCode, requestId));
throw new CustomerException("更新表单存货编码字段失败!");
}
+ // 将主表的存货编码插入到明细表中
+ if(StringUtils.isNotBlank(detailIndex)
+ && StringUtils.isNotBlank(mainId)
+ && StringUtils.isNotBlank(detailInventoryCode)){
+ Map detailParams = new HashMap<>();
+ detailParams.put("mainid", mainId);
+ detailParams.put(detailInventoryCode, nextInventoryCode);
+ PrepSqlResultImpl insertSql = Util.createSqlBuilder().insertSql(billTable + "_dt" + detailIndex, detailParams);
+ String sqlStr = insertSql.getSqlStr();
+ List