diff --git a/src/main/java/aiyh/utils/Util.java b/src/main/java/aiyh/utils/Util.java
index 136bd19..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 {
@@ -4111,14 +4113,15 @@ public class Util extends weaver.general.Util {
* @return 部门id
**/
public static int getNextDepartmentId(int subId){
- RecordSet insertRs = new RecordSet();
char separator = weaver.general.Util.getSeparator();
String uuid = UUID.randomUUID().toString();
+ String empty = "";
String para = uuid + separator +uuid + separator +
- "" + separator + "" + separator + subId + separator + 1 + separator + "";
- insertRs.executeProc("HrmDepartment_Insert", para);
- if(insertRs.next()){
- return insertRs.getInt(1);
+ 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;
}
@@ -4132,13 +4135,43 @@ public class Util extends weaver.general.Util {
* @return 人员id
**/
public static int getNextHrmId(){
- RecordSet procRs = new RecordSet();
+ 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/response_deal/ResponseMappingDeal.java b/src/main/java/aiyh/utils/response_deal/ResponseMappingDeal.java
index 81f6d36..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();
}
// 做数据处理
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 e0965cc..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;
@@ -62,19 +65,35 @@ public class InsertSate extends State{
}
String updateSql = MapperBuilderSql.builderUpdateSql(assignTable, tempRowDefinition.getUpdateParam(),"upItem");
updateSql = updateSql + " where id = #{whereItem.id}";
- flag = this.configMapper.executeUpdateBatchCusSql(updateSql, updateList, whereList);
+ try {
+ flag = this.configMapper.executeUpdateBatchCusSql(updateSql, updateList, whereList);
+ }catch (ParseSqlException e){
+ logger.error(Util.logStr("parse sql error, current sql : [{}], updateList : [{}], whereList : [{}]", updateSql, JSONObject.toJSONString(updateList), JSONObject.toJSONString(whereList)));
+ throw new CustomerException(e);
+ }
String modeId = Util.getModeIdByTableName(assignTable);
Util.rebuildModeDataShareByAsyncList(1,modeId,dataIdList);
- if(ResponseUtil.parameterIsNotNull(detailTableMap) && flag){
- detailTableMap.forEach((key,value)->{
- value.setDefaultState(null);
- value.dataProcess();
- });
- }
}else {
String insertSql = MapperBuilderSql.builderInsertSql(assignTable, tempRowDefinition.getUpdateParam(),"item");
- List