diff --git a/src/main/java/aiyh/utils/Util.java b/src/main/java/aiyh/utils/Util.java
index 16c18ea..f0dd810 100644
--- a/src/main/java/aiyh/utils/Util.java
+++ b/src/main/java/aiyh/utils/Util.java
@@ -12,6 +12,7 @@ import aiyh.utils.mapUtil.UtilHashMap;
import aiyh.utils.mapUtil.UtilLinkedHashMap;
import aiyh.utils.mapper.UtilMapper;
import aiyh.utils.recordset.RecordsetUtil;
+import aiyh.utils.recordset.RsThreadLocalManager;
import aiyh.utils.service.UtilService;
import aiyh.utils.sqlUtil.builderSql.impl.BuilderSqlImpl;
import aiyh.utils.sqlUtil.whereUtil.Where;
@@ -106,6 +107,7 @@ public class Util extends weaver.general.Util {
static ToolUtil toolUtil = new ToolUtil();
private static RecordSet rs;
private static volatile Logger log = null;
+ private static final RsThreadLocalManager LOCAL_MANAGER = new RsThreadLocalManager();
static {
try {
@@ -4092,6 +4094,84 @@ public class Util extends weaver.general.Util {
Util.getLogger().error(getErrString(e));
}
}
+
+ /**
+ *
获取下一个部门id
+ * @author xuanran.wang
+ * @dateTime 2023/7/19 11:24
+ * @return 部门id
+ **/
+ public static int getNextDepartmentId(){
+ return getNextDepartmentId(1);
+ }
+
+ /**
+ * 获取下一个部门id
+ * @author xuanran.wang
+ * @dateTime 2023/7/19 11:24
+ * @param subId 分部id
+ * @return 部门id
+ **/
+ public static int getNextDepartmentId(int subId){
+ char separator = weaver.general.Util.getSeparator();
+ String uuid = UUID.randomUUID().toString();
+ String empty = "";
+ String para = uuid + separator +uuid + separator +
+ empty + separator + empty + separator + subId + separator + 1 + separator + empty;
+ RecordSet procRs = getThreadRecord();
+ procRs.executeProc("HrmDepartment_Insert", para);
+ if(procRs.next()){
+ return procRs.getInt(1);
+ }
+ return -1;
+ }
+
+
+
+ /**
+ * 获取下一个人员id
+ * @author xuanran.wang
+ * @dateTime 2023/4/12 13:24
+ * @return 人员id
+ **/
+ public static int getNextHrmId(){
+ RecordSet procRs = getThreadRecord();
+ procRs.executeProc("HrmResourceMaxId_Get", "");
+ if (procRs.next()) {
+ return procRs.getInt(1);
+ }
+ return -1;
+ }
+
+ /**
+ * 获取当前线程rs对象
+ * @author xuanran.wang
+ * @dateTime 2023/7/19 15:28
+ * @return recordSet对象
+ **/
+ public static RecordSet getThreadRecord(){
+ String name = Thread.currentThread().getId() + "_" + Thread.currentThread().getName();
+ return getRecordFromRsManger(name);
+ }
+
+ /**
+ * 通过名字获取rs池中rs对象
+ * @author xuanran.wang
+ * @dateTime 2023/7/19 15:29
+ * @param name rs池中的key
+ * @return recordSet对象
+ **/
+ public static RecordSet getRecordFromRsManger(String name){
+ RecordSet rs = LOCAL_MANAGER.getRs(name);
+ if(null == rs){
+ LOCAL_MANAGER.setRecordSet(name);
+ rs = LOCAL_MANAGER.getRs(name);
+ if(null == rs){
+ rs = new RecordSet();
+ }
+ }
+ return rs;
+ }
}
diff --git a/src/main/java/aiyh/utils/httpUtil/cushttpclasses/CusHttpServletRequest.java b/src/main/java/aiyh/utils/httpUtil/cushttpclasses/CusHttpServletRequest.java
index 231944e..5dfc3ec 100644
--- a/src/main/java/aiyh/utils/httpUtil/cushttpclasses/CusHttpServletRequest.java
+++ b/src/main/java/aiyh/utils/httpUtil/cushttpclasses/CusHttpServletRequest.java
@@ -1,14 +1,12 @@
package aiyh.utils.httpUtil.cushttpclasses;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletInputStream;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
+import javax.servlet.*;
+import javax.servlet.http.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.Principal;
+import java.util.Collection;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Map;
@@ -95,6 +93,11 @@ public class CusHttpServletRequest implements HttpServletRequest {
return null;
}
+ @Override
+ public String changeSessionId() {
+ return null;
+ }
+
@Override
public String getRequestedSessionId() {
return null;
@@ -143,6 +146,36 @@ public class CusHttpServletRequest implements HttpServletRequest {
return false;
}
+ @Override
+ public boolean authenticate(HttpServletResponse httpServletResponse) throws IOException, ServletException {
+ return false;
+ }
+
+ @Override
+ public void login(String s, String s1) throws ServletException {
+
+ }
+
+ @Override
+ public void logout() throws ServletException {
+
+ }
+
+ @Override
+ public Collection getParts() throws IOException, ServletException {
+ return null;
+ }
+
+ @Override
+ public Part getPart(String s) throws IOException, ServletException {
+ return null;
+ }
+
+ @Override
+ public T upgrade(Class aClass) throws IOException, ServletException {
+ return null;
+ }
+
@Override
public String getProtocol() {
return null;
@@ -218,6 +251,11 @@ public class CusHttpServletRequest implements HttpServletRequest {
return 0;
}
+ @Override
+ public long getContentLengthLong() {
+ return 0;
+ }
+
@Override
public String getContentType() {
return null;
@@ -271,4 +309,59 @@ public class CusHttpServletRequest implements HttpServletRequest {
public String getRealPath(String s) {
return null;
}
+
+ @Override
+ public int getRemotePort() {
+ return 0;
+ }
+
+ @Override
+ public String getLocalName() {
+ return null;
+ }
+
+ @Override
+ public String getLocalAddr() {
+ return null;
+ }
+
+ @Override
+ public int getLocalPort() {
+ return 0;
+ }
+
+ @Override
+ public ServletContext getServletContext() {
+ return null;
+ }
+
+ @Override
+ public AsyncContext startAsync() throws IllegalStateException {
+ return null;
+ }
+
+ @Override
+ public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws IllegalStateException {
+ return null;
+ }
+
+ @Override
+ public boolean isAsyncStarted() {
+ return false;
+ }
+
+ @Override
+ public boolean isAsyncSupported() {
+ return false;
+ }
+
+ @Override
+ public AsyncContext getAsyncContext() {
+ return null;
+ }
+
+ @Override
+ public DispatcherType getDispatcherType() {
+ return null;
+ }
}
diff --git a/src/main/java/aiyh/utils/recordset/FormatSqlUtil.java b/src/main/java/aiyh/utils/recordset/FormatSqlUtil.java
index 0a6303b..a52a5f8 100644
--- a/src/main/java/aiyh/utils/recordset/FormatSqlUtil.java
+++ b/src/main/java/aiyh/utils/recordset/FormatSqlUtil.java
@@ -2,6 +2,7 @@ package aiyh.utils.recordset;
import com.alibaba.druid.sql.SQLUtils;
import com.alibaba.druid.sql.parser.ParserException;
+import com.icbc.api.internal.apache.http.E;
import weaver.conn.RecordSet;
import java.util.Objects;
@@ -27,7 +28,7 @@ public class FormatSqlUtil {
}
try {
return SQLUtils.format(sql, dbType);
- } catch (ParserException e) {
+ } catch (Exception e) {
return toSqlString(sql);
}
}
diff --git a/src/main/java/aiyh/utils/response_deal/ResponseMappingDeal.java b/src/main/java/aiyh/utils/response_deal/ResponseMappingDeal.java
index d4d6ea0..4d8fd4d 100644
--- a/src/main/java/aiyh/utils/response_deal/ResponseMappingDeal.java
+++ b/src/main/java/aiyh/utils/response_deal/ResponseMappingDeal.java
@@ -68,6 +68,16 @@ public class ResponseMappingDeal {
logger.info(String.format("%s 相关响应配置信息==> %s", uniqueCode, JSON.toJSONString(responseConfigList)));
// 自定义校验
ResponseUtil.parameterJudgment(responseConfigList, "response config is empty please check!!! ");
+ // 将所有跟sql有关的字段全部全角转半角
+ responseConfigList.forEach(item-> {
+ item.getResponseConfigAliasList().forEach(responseConfigAlias -> {
+ responseConfigAlias.setConditionScript(Util.sbc2dbcCase(responseConfigAlias.getConditionScript()));
+ responseConfigAlias.setJudgmentScript(Util.sbc2dbcCase(responseConfigAlias.getJudgmentScript()));
+ });
+ item.getValueChangeList().forEach(responseConfigValueChange -> {
+ responseConfigValueChange.setCusText(Util.sbc2dbcCase(responseConfigValueChange.getCusText()));
+ });
+ });
Map tableNameConfig;
try {
// 对查询到的多个配置进行整合,以同步表表名作为key 配置作为value
@@ -117,6 +127,7 @@ public class ResponseMappingDeal {
.tableDefinitionCallback(this.tableCallback)
.tableType(responseConfig.getTableType())
.assignType(ResponseConfigConstant.NO_HANDLE)
+ .tableDefinitionCallback(tableCallback)
.assignTable(responseConfig.getModelTableName()).build();
}
// 做数据处理
@@ -176,7 +187,7 @@ public class ResponseMappingDeal {
.mainOrDetail(tableMainOrDetail)
.tableDefinitionCallback(this.tableCallback)
.assignType(mainDataAlias.getAssignType()).build();
- String dataPath = mainDataAlias.getDataPath();
+ String dataPath = mainDataAlias.getDataAlias();
List rowDefinitionList = new ArrayList<>();
Map detailTable = isMainTable ? new HashMap<>() : null;
// 如果是json数组
diff --git a/src/main/java/aiyh/utils/response_deal/intfaces/TableDefinitionCallback.java b/src/main/java/aiyh/utils/response_deal/intfaces/TableDefinitionCallback.java
index 700f5af..adffd3f 100644
--- a/src/main/java/aiyh/utils/response_deal/intfaces/TableDefinitionCallback.java
+++ b/src/main/java/aiyh/utils/response_deal/intfaces/TableDefinitionCallback.java
@@ -13,4 +13,6 @@ public interface TableDefinitionCallback {
void tableHandle(TableDefinition tableDefinition);
+ void afterHandle(TableDefinition tableDefinition,boolean flag);
+
}
diff --git a/src/main/java/aiyh/utils/response_deal/process/DataChangeProcess.java b/src/main/java/aiyh/utils/response_deal/process/DataChangeProcess.java
index d2d2703..5b54b70 100644
--- a/src/main/java/aiyh/utils/response_deal/process/DataChangeProcess.java
+++ b/src/main/java/aiyh/utils/response_deal/process/DataChangeProcess.java
@@ -7,6 +7,7 @@ import aiyh.utils.response_deal.entity.ResponseConfigValueChange;
import aiyh.utils.response_deal.exception.ResponseException;
import aiyh.utils.response_deal.intfaces.DataChangeInterface;
import aiyh.utils.response_deal.mapper.ConfigMapper;
+import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
@@ -33,7 +34,7 @@ public class DataChangeProcess {
private static final ConfigMapper CONFIG_MAPPER = Util.getMapper(ConfigMapper.class);
- public static final Logger logger = Util.getLogger();
+ public static final Logger logger = Util.getLogger("json_util");
static {
try {
@@ -66,7 +67,7 @@ public class DataChangeProcess {
@MethodRuleNo(value = 0, desc = "默认值")
public static String defaultValue(ResponseConfigValueChange responseConfigValueChange,Map param){
String cusText = responseConfigValueChange.getCusText();
- cusText = Util.dbc2sbcCase(cusText);
+ cusText = Util.sbc2dbcCase(cusText);
responseConfigValueChange.setJsonData(cusText);
return "";
}
@@ -80,13 +81,14 @@ public class DataChangeProcess {
@MethodRuleNo(value = 1, desc = "sql转换")
public static String sqlChange(ResponseConfigValueChange responseConfigValueChange,Map param){
String cusText = responseConfigValueChange.getCusText();
- cusText = Util.dbc2sbcCase(cusText);
+ cusText = Util.sbc2dbcCase(cusText);
if(StringUtils.isBlank(cusText)){
- throw new CustomerException("when selecting Custom sql, the sql string cannot be empty !!!");
+ throw new ResponseException("when selecting Custom sql, the sql string cannot be empty !!!");
}
if(!cusText.startsWith("select ")){
- throw new CustomerException("When you select custom sql, you are not allowed to perform dangerous operations other than SELECT !!!");
+ throw new ResponseException("When you select custom sql, you are not allowed to perform dangerous operations other than SELECT !!!");
}
+ logger.info(Util.logStr("cus sql : {}, params : {}", cusText, JSONObject.toJSONString(param)));
String tempValue = CONFIG_MAPPER.executeCusQuerySql(cusText, param,new HashMap<>());
responseConfigValueChange.setJsonData(tempValue);
return "";
@@ -102,7 +104,7 @@ public class DataChangeProcess {
public static String dateChange(ResponseConfigValueChange responseConfigValueChange,Map param){
String cusText = responseConfigValueChange.getCusText();
Object jsonData = responseConfigValueChange.getJsonData();
- cusText = Util.dbc2sbcCase(cusText);
+ cusText = Util.sbc2dbcCase(cusText);
String fromStr = getDateFormat(cusText,"from:\\{(.*?)\\}");
String toStr = getDateFormat(cusText,"to:\\{(.*?)\\}");
responseConfigValueChange.setJsonData(formatDateTime(Util.null2String(jsonData),fromStr,toStr));
@@ -118,7 +120,7 @@ public class DataChangeProcess {
@MethodRuleNo(value = 3, desc = "自定义接口")
public static String cusInterface(ResponseConfigValueChange responseConfigValueChange,Map param){
String cusText = responseConfigValueChange.getCusText();
- cusText = Util.dbc2sbcCase(cusText);
+ cusText = Util.sbc2dbcCase(cusText);
if(StringUtils.isBlank(cusText)){
throw new CustomerException("The operation full path cannot be empty !!!");
}
diff --git a/src/main/java/aiyh/utils/response_deal/process/TypeChangeProcess.java b/src/main/java/aiyh/utils/response_deal/process/TypeChangeProcess.java
index d691497..5c88327 100644
--- a/src/main/java/aiyh/utils/response_deal/process/TypeChangeProcess.java
+++ b/src/main/java/aiyh/utils/response_deal/process/TypeChangeProcess.java
@@ -20,7 +20,7 @@ public class TypeChangeProcess {
public static final Map> MODE_METHOD_MAP = new HashMap<>();
- public static final Logger logger = Util.getLogger();
+ public static final Logger logger = Util.getLogger("json_util");
static {
try {
diff --git a/src/main/java/aiyh/utils/response_deal/state/InsertOrUpdateState.java b/src/main/java/aiyh/utils/response_deal/state/InsertOrUpdateState.java
index 549969d..cd59460 100644
--- a/src/main/java/aiyh/utils/response_deal/state/InsertOrUpdateState.java
+++ b/src/main/java/aiyh/utils/response_deal/state/InsertOrUpdateState.java
@@ -1,5 +1,8 @@
package aiyh.utils.response_deal.state;
+import aiyh.utils.Util;
+import aiyh.utils.excention.CustomerException;
+import aiyh.utils.excention.ParseSqlException;
import aiyh.utils.response_deal.constant.ResponseConfigConstant;
import aiyh.utils.response_deal.entity.RowDefinition;
import aiyh.utils.response_deal.entity.TableDefinition;
@@ -7,6 +10,7 @@ import aiyh.utils.response_deal.intfaces.RowDefinitionCallback;
import aiyh.utils.response_deal.util.ResponseUtil;
import aiyh.utils.tool.cn.hutool.core.bean.BeanUtil;
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
@@ -22,9 +26,6 @@ public class InsertOrUpdateState extends State{
@Override
public void handle() {
- if(ResponseUtil.parameterIsNotNull(this.context.getTableDefinitionCallback())){
- this.context.getTableDefinitionCallback().tableHandle(this.context);
- }
List rowDefinitionList = this.context.getRowDefinitionList();
List updateRowList = new ArrayList<>();
List insertRowList = new ArrayList<>();
@@ -55,16 +56,24 @@ public class InsertOrUpdateState extends State{
BeanUtil.copyProperties(this.context,tableDefinition);
tableDefinition.setState(null);
tableDefinition.setRowDefinitionList(rowDefinitionList);
- tableDefinition.setTableDefinitionCallback(null);
tableDefinition.setAssignType(assignType);
tableDefinition.setDefaultState(null);
tableDefinition.dataProcess();
}
private boolean judgmentRepetition(RowDefinition rowDefinition){
- String conditionScript = rowDefinition.getConditionScript();
+ String conditionScript = Util.sbc2dbcCase(rowDefinition.getConditionScript());
String cusQuerySql = "select id from " + rowDefinition.getAssignTable() + " where " + conditionScript;
- String dataId = this.configMapper.executeCusQuerySql(cusQuerySql, rowDefinition.getWhereParam(),new HashMap<>());
+ String dataId;
+ try {
+ dataId = this.configMapper.executeCusQuerySql(cusQuerySql, rowDefinition.getWhereParam(),new HashMap<>());
+ }catch (ParseSqlException e){
+ logger.error(Util.logStr("parse sql error, current sql : [{}], whereParam : [{}]", cusQuerySql, JSONObject.toJSONString(rowDefinition.getWhereParam())));
+ throw new CustomerException(e);
+ }
+ if(StrUtil.isNotBlank(dataId)){
+ rowDefinition.setDataId(Util.getIntValue(dataId, -1));
+ }
return StrUtil.isNotBlank(dataId);
}
diff --git a/src/main/java/aiyh/utils/response_deal/state/InsertSate.java b/src/main/java/aiyh/utils/response_deal/state/InsertSate.java
index 8d2ceb5..7567239 100644
--- a/src/main/java/aiyh/utils/response_deal/state/InsertSate.java
+++ b/src/main/java/aiyh/utils/response_deal/state/InsertSate.java
@@ -1,12 +1,15 @@
package aiyh.utils.response_deal.state;
import aiyh.utils.Util;
+import aiyh.utils.excention.CustomerException;
+import aiyh.utils.excention.ParseSqlException;
import aiyh.utils.recordset.MapperBuilderSql;
import aiyh.utils.response_deal.constant.ResponseConfigConstant;
import aiyh.utils.response_deal.entity.RowDefinition;
import aiyh.utils.response_deal.entity.TableDefinition;
import aiyh.utils.response_deal.intfaces.RowDefinitionCallback;
import aiyh.utils.response_deal.util.ResponseUtil;
+import com.alibaba.fastjson.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
@@ -44,6 +47,7 @@ public class InsertSate extends State{
}
});
RowDefinition tempRowDefinition = rowDefinitionList.get(0);
+ boolean flag;
if(tableType == ResponseConfigConstant.MODEL_TABLE && mainOrDetail == ResponseConfigConstant.MAIN_TABLE){
List