响应回写问题修复

dev
wangxuanran 2023-07-20 10:32:08 +08:00
parent fe37d194a3
commit 9658ce154f
5 changed files with 51 additions and 33 deletions

View File

@ -68,6 +68,16 @@ public class ResponseMappingDeal {
logger.info(String.format("%s 相关响应配置信息==> %s", uniqueCode, JSON.toJSONString(responseConfigList))); logger.info(String.format("%s 相关响应配置信息==> %s", uniqueCode, JSON.toJSONString(responseConfigList)));
// 自定义校验 // 自定义校验
ResponseUtil.parameterJudgment(responseConfigList, "response config is empty please check!!! "); 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<String, ResponseConfig> tableNameConfig; Map<String, ResponseConfig> tableNameConfig;
try { try {
// 对查询到的多个配置进行整合以同步表表名作为key 配置作为value // 对查询到的多个配置进行整合以同步表表名作为key 配置作为value

View File

@ -1,5 +1,6 @@
package aiyh.utils.response_deal.state; package aiyh.utils.response_deal.state;
import aiyh.utils.Util;
import aiyh.utils.response_deal.constant.ResponseConfigConstant; import aiyh.utils.response_deal.constant.ResponseConfigConstant;
import aiyh.utils.response_deal.entity.RowDefinition; import aiyh.utils.response_deal.entity.RowDefinition;
import aiyh.utils.response_deal.entity.TableDefinition; import aiyh.utils.response_deal.entity.TableDefinition;
@ -58,7 +59,7 @@ public class InsertOrUpdateState extends State{
} }
private boolean judgmentRepetition(RowDefinition rowDefinition){ 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 cusQuerySql = "select id from " + rowDefinition.getAssignTable() + " where " + conditionScript;
String dataId = this.configMapper.executeCusQuerySql(cusQuerySql, rowDefinition.getWhereParam(),new HashMap<>()); String dataId = this.configMapper.executeCusQuerySql(cusQuerySql, rowDefinition.getWhereParam(),new HashMap<>());
return StrUtil.isNotBlank(dataId); return StrUtil.isNotBlank(dataId);

View File

@ -67,7 +67,7 @@ public class InsertSate extends State{
Util.rebuildModeDataShareByAsyncList(1,modeId,dataIdList); Util.rebuildModeDataShareByAsyncList(1,modeId,dataIdList);
}else { }else {
String insertSql = MapperBuilderSql.builderInsertSql(assignTable, tempRowDefinition.getUpdateParam(),"item"); String insertSql = MapperBuilderSql.builderInsertSql(assignTable, tempRowDefinition.getUpdateParam(),"item");
List<Map<String, Object>> insertList = rowDefinitionList.stream().map(RowDefinition::getUpdateParam).collect(Collectors.toList()); List<Map<String, Object>> insertList = new ArrayList<>();
rowDefinitionList.forEach(item ->{ rowDefinitionList.forEach(item ->{
if(mainOrDetail == ResponseConfigConstant.MAIN_TABLE){ if(mainOrDetail == ResponseConfigConstant.MAIN_TABLE){
detailTableDeal(item,detailTableMap); detailTableDeal(item,detailTableMap);

View File

@ -2,6 +2,7 @@ package com.api.xuanran.wang.xk_hospital.data_async.definitions.row;
import aiyh.utils.Util; import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException; import aiyh.utils.excention.CustomerException;
import aiyh.utils.response_deal.constant.ResponseConfigConstant;
import aiyh.utils.response_deal.entity.RowDefinition; import aiyh.utils.response_deal.entity.RowDefinition;
import aiyh.utils.response_deal.intfaces.RowDefinitionCallback; import aiyh.utils.response_deal.intfaces.RowDefinitionCallback;
import aiyh.utils.response_deal.mapper.ConfigMapper; 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 com.api.xuanran.wang.xk_hospital.data_async.definitions.XkHospitalCommonDefinition;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
import java.util.HashMap; import java.util.HashMap;
@ -31,28 +33,33 @@ public class HrmDepartmentRowDefinition extends XkHospitalCommonDefinition imple
@Override @Override
public boolean judgmentRepetition(RowDefinition rowDefinition) { 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 cusQuerySql = "select id from " + rowDefinition.getAssignTable() + " where " + conditionScript;
String dataId = configMapper.executeCusQuerySql(cusQuerySql, rowDefinition.getWhereParam(),new HashMap<>()); String dataId = configMapper.executeCusQuerySql(cusQuerySql, rowDefinition.getWhereParam(),new HashMap<>());
if(StrUtil.isBlank(dataId)){ if(ResponseConfigConstant.MAIN_TABLE == orDetail){
int nextId = -1; if(StrUtil.isBlank(dataId)){
if(HRM_RESOURCE.equals(table)){ int nextId = -1;
nextId = Util.getNextHrmId(); if(HRM_RESOURCE.equals(table)){
}else if(DEPARTMENT.equals(table)){ nextId = Util.getNextHrmId();
nextId = Util.getNextDepartmentId(); }else if(DEPARTMENT.equals(table)){
} nextId = Util.getNextDepartmentId();
if(nextId < 0){ }
throw new CustomerException("从 " + table + " 获取下一个id失败!"); if(nextId < 0){
} throw new CustomerException("从 " + table + " 获取下一个id失败!");
rowDefinition.setDataId(nextId); }
if(HRM_RESOURCE.equals(table)){ rowDefinition.setDataId(nextId);
rowDefinition.getUpdateParam().put("id", nextId); if(HRM_RESOURCE.equals(table)){
rowDefinition.setConditionScript(""); rowDefinition.getUpdateParam().put("id", nextId);
return false; rowDefinition.setConditionScript("");
}else { return false;
rowDefinition.getWhereParam().put("id", nextId); }else {
rowDefinition.setConditionScript(" id = #{whereItem.id}"); rowDefinition.getWhereParam().put("id", nextId);
rowDefinition.setConditionScript(" id = #{whereItem.id}");
}
} }
}else {
return StringUtils.isNotBlank(dataId);
} }
return true; return true;
} }

View File

@ -38,18 +38,18 @@ public class XkHospitalTest extends BaseTest {
@Test @Test
public void testB(){ public void testB(){
String json2 = "{\n" + // String json2 = "{\n" +
"\t\"ID\":\"1\",\n" + // "\t\"ID\":\"1\",\n" +
"\t\"DeptCode\":\"test3\",\n" + // "\t\"DeptCode\":\"test3\",\n" +
"\t\"DeptName\":\"科室测试名称3\",\n" + // "\t\"DeptName\":\"科室测试名称3\",\n" +
"\t\"DeptLevel\": null, \n" + // "\t\"DeptLevel\": null, \n" +
"\t\"ParentDeptCode\": \"test2\",\n" + // "\t\"ParentDeptCode\": \"test2\",\n" +
"\t\"IsDelete\": false, \n" + // "\t\"IsDelete\": false, \n" +
"\t\"Remark\":\"备注\"\n" + // "\t\"Remark\":\"备注\"\n" +
"}\n"; // "}\n";
//
Map map2 = JSONObject.parseObject(json2, Map.class); // Map map2 = JSONObject.parseObject(json2, Map.class);
service.async("4bce0693734a","dept",map2); // service.async("4bce0693734a","dept",map2);
String json = "{\n" + String json = "{\n" +
"\t\"ID\":\"1\",\n" + "\t\"ID\":\"1\",\n" +