From 9658ce154f9cdab03a7af0dcdebdf5ff8c2e74b0 Mon Sep 17 00:00:00 2001 From: wangxuanran <3055088966@qq.com> Date: Thu, 20 Jul 2023 10:32:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=93=8D=E5=BA=94=E5=9B=9E=E5=86=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response_deal/ResponseMappingDeal.java | 10 +++++ .../state/InsertOrUpdateState.java | 3 +- .../utils/response_deal/state/InsertSate.java | 2 +- .../row/HrmDepartmentRowDefinition.java | 45 +++++++++++-------- .../wang/xk_hospital/test/XkHospitalTest.java | 24 +++++----- 5 files changed, 51 insertions(+), 33 deletions(-) diff --git a/src/main/java/aiyh/utils/response_deal/ResponseMappingDeal.java b/src/main/java/aiyh/utils/response_deal/ResponseMappingDeal.java index 0f1977c..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 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 db7e023..c8d8361 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,6 @@ package aiyh.utils.response_deal.state; +import aiyh.utils.Util; import aiyh.utils.response_deal.constant.ResponseConfigConstant; import aiyh.utils.response_deal.entity.RowDefinition; import aiyh.utils.response_deal.entity.TableDefinition; @@ -58,7 +59,7 @@ public class InsertOrUpdateState extends State{ } 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<>()); 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 5863560..3f8f98d 100644 --- a/src/main/java/aiyh/utils/response_deal/state/InsertSate.java +++ b/src/main/java/aiyh/utils/response_deal/state/InsertSate.java @@ -67,7 +67,7 @@ public class InsertSate extends State{ Util.rebuildModeDataShareByAsyncList(1,modeId,dataIdList); }else { String insertSql = MapperBuilderSql.builderInsertSql(assignTable, tempRowDefinition.getUpdateParam(),"item"); - List> insertList = rowDefinitionList.stream().map(RowDefinition::getUpdateParam).collect(Collectors.toList()); + List> insertList = new ArrayList<>(); rowDefinitionList.forEach(item ->{ if(mainOrDetail == ResponseConfigConstant.MAIN_TABLE){ detailTableDeal(item,detailTableMap); diff --git a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/row/HrmDepartmentRowDefinition.java b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/row/HrmDepartmentRowDefinition.java index efbbedf..50ac6fe 100644 --- a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/row/HrmDepartmentRowDefinition.java +++ b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/row/HrmDepartmentRowDefinition.java @@ -2,6 +2,7 @@ package com.api.xuanran.wang.xk_hospital.data_async.definitions.row; import aiyh.utils.Util; import aiyh.utils.excention.CustomerException; +import aiyh.utils.response_deal.constant.ResponseConfigConstant; import aiyh.utils.response_deal.entity.RowDefinition; import aiyh.utils.response_deal.intfaces.RowDefinitionCallback; import aiyh.utils.response_deal.mapper.ConfigMapper; @@ -9,6 +10,7 @@ import aiyh.utils.tool.cn.hutool.core.util.StrUtil; import com.api.xuanran.wang.xk_hospital.data_async.definitions.XkHospitalCommonDefinition; import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; import weaver.conn.RecordSet; import java.util.HashMap; @@ -31,28 +33,33 @@ public class HrmDepartmentRowDefinition extends XkHospitalCommonDefinition imple @Override public boolean judgmentRepetition(RowDefinition rowDefinition) { - String conditionScript = rowDefinition.getConditionScript(); + int orDetail = rowDefinition.getMainOrDetail(); + String conditionScript = Util.sbc2dbcCase(rowDefinition.getConditionScript()); String cusQuerySql = "select id from " + rowDefinition.getAssignTable() + " where " + conditionScript; String dataId = configMapper.executeCusQuerySql(cusQuerySql, rowDefinition.getWhereParam(),new HashMap<>()); - if(StrUtil.isBlank(dataId)){ - int nextId = -1; - if(HRM_RESOURCE.equals(table)){ - nextId = Util.getNextHrmId(); - }else if(DEPARTMENT.equals(table)){ - nextId = Util.getNextDepartmentId(); - } - if(nextId < 0){ - throw new CustomerException("从 " + table + " 获取下一个id失败!"); - } - rowDefinition.setDataId(nextId); - if(HRM_RESOURCE.equals(table)){ - rowDefinition.getUpdateParam().put("id", nextId); - rowDefinition.setConditionScript(""); - return false; - }else { - rowDefinition.getWhereParam().put("id", nextId); - rowDefinition.setConditionScript(" id = #{whereItem.id}"); + if(ResponseConfigConstant.MAIN_TABLE == orDetail){ + if(StrUtil.isBlank(dataId)){ + int nextId = -1; + if(HRM_RESOURCE.equals(table)){ + nextId = Util.getNextHrmId(); + }else if(DEPARTMENT.equals(table)){ + nextId = Util.getNextDepartmentId(); + } + if(nextId < 0){ + throw new CustomerException("从 " + table + " 获取下一个id失败!"); + } + rowDefinition.setDataId(nextId); + if(HRM_RESOURCE.equals(table)){ + rowDefinition.getUpdateParam().put("id", nextId); + rowDefinition.setConditionScript(""); + return false; + }else { + rowDefinition.getWhereParam().put("id", nextId); + rowDefinition.setConditionScript(" id = #{whereItem.id}"); + } } + }else { + return StringUtils.isNotBlank(dataId); } return true; } diff --git a/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java b/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java index 99171ed..3572963 100644 --- a/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java +++ b/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java @@ -38,18 +38,18 @@ public class XkHospitalTest extends BaseTest { @Test public void testB(){ - String json2 = "{\n" + - "\t\"ID\":\"1\",\n" + - "\t\"DeptCode\":\"test3\",\n" + - "\t\"DeptName\":\"科室测试名称3\",\n" + - "\t\"DeptLevel\": null, \n" + - "\t\"ParentDeptCode\": \"test2\",\n" + - "\t\"IsDelete\": false, \n" + - "\t\"Remark\":\"备注\"\n" + - "}\n"; - - Map map2 = JSONObject.parseObject(json2, Map.class); - service.async("4bce0693734a","dept",map2); + // String json2 = "{\n" + + // "\t\"ID\":\"1\",\n" + + // "\t\"DeptCode\":\"test3\",\n" + + // "\t\"DeptName\":\"科室测试名称3\",\n" + + // "\t\"DeptLevel\": null, \n" + + // "\t\"ParentDeptCode\": \"test2\",\n" + + // "\t\"IsDelete\": false, \n" + + // "\t\"Remark\":\"备注\"\n" + + // "}\n"; + // + // Map map2 = JSONObject.parseObject(json2, Map.class); + // service.async("4bce0693734a","dept",map2); String json = "{\n" + "\t\"ID\":\"1\",\n" +