同步代码问题修复

dev
ic_excellent 2023-07-18 10:36:26 +08:00
parent ae93310168
commit 7db56b7b40
6 changed files with 51 additions and 27 deletions

View File

@ -57,60 +57,60 @@ public class ResponseMappingDeal {
} }
/** /**
* <h2> note by youhong.ai</h2> * <h2> </h2>
* *
* @param uniqueCode * @param uniqueCode
* @param responseMap map * @param responseMap map
*/ */
public void doResponseSync(String uniqueCode, Map<String, Object> responseMap) { public void doResponseSync(String uniqueCode, Map<String, Object> responseMap) {
// note by youhong.ai 查询配置表 // 查询配置表
List<ResponseConfig> responseConfigList = configMapper.queryResponseConfigByUnique(uniqueCode); List<ResponseConfig> responseConfigList = configMapper.queryResponseConfigByUnique(uniqueCode);
logger.info(String.format("%s 相关响应配置信息==> %s", uniqueCode, JSON.toJSONString(responseConfigList))); logger.info(String.format("%s 相关响应配置信息==> %s", uniqueCode, JSON.toJSONString(responseConfigList)));
// note by youhong.ai 自定义校验 // 自定义校验
ResponseUtil.parameterJudgment(responseConfigList, "response config is empty please check!!! "); ResponseUtil.parameterJudgment(responseConfigList, "response config is empty please check!!! ");
Map<String, ResponseConfig> tableNameConfig; Map<String, ResponseConfig> tableNameConfig;
try { try {
// note by youhong.ai 对查询到的多个配置进行整合以同步表表名作为key 配置作为value // 对查询到的多个配置进行整合以同步表表名作为key 配置作为value
tableNameConfig = responseConfigList.stream().collect(Collectors.toMap(ResponseConfig::getModelTableName, v -> v)); tableNameConfig = responseConfigList.stream().collect(Collectors.toMap(ResponseConfig::getModelTableName, v -> v));
} catch (Exception e) { } catch (Exception e) {
logger.error("response config error please check!!! " + Util.getErrString(e)); logger.error("response config error please check!!! " + Util.getErrString(e));
throw new ResponseException("response config error please check!!! "); throw new ResponseException("response config error please check!!! ");
} }
ResponseUtil.parameterJudgment(responseMap, "接口返回都为空 你处理个勾"); ResponseUtil.parameterJudgment(responseMap, "接口返回都为空 你处理个勾");
// note by youhong.ai 循环同步每一个表 // 循环同步每一个表
tableNameConfig.forEach((key, value) -> doResponseSync(value, responseMap)); tableNameConfig.forEach((key, value) -> doResponseSync(value, responseMap));
} }
/** /**
* <h2>note by youhong.ai </h2> * <h2> </h2>
* *
* @param responseConfig * @param responseConfig
* @param responseMap * @param responseMap
*/ */
public void doResponseSync(ResponseConfig responseConfig, Map<String, Object> responseMap) { public void doResponseSync(ResponseConfig responseConfig, Map<String, Object> responseMap) {
// note by youhong.ai 获取别名配置明细数据 // 获取别名配置明细数据
List<ResponseConfigAlias> responseConfigAliasList = responseConfig.getResponseConfigAliasList(); List<ResponseConfigAlias> responseConfigAliasList = responseConfig.getResponseConfigAliasList();
ResponseUtil.parameterJudgment(responseConfigAliasList, "responseConfigAliasList config is empty please check!!!"); ResponseUtil.parameterJudgment(responseConfigAliasList, "responseConfigAliasList config is empty please check!!!");
// note by youhong.ai 获取转换值配置明细 // 获取转换值配置明细
List<ResponseConfigValueChange> valueChangeList = responseConfig.getValueChangeList(); List<ResponseConfigValueChange> valueChangeList = responseConfig.getValueChangeList();
ResponseUtil.parameterJudgment(valueChangeList, "valueChangeList config is empty please check!!!"); ResponseUtil.parameterJudgment(valueChangeList, "valueChangeList config is empty please check!!!");
// 数据信息按是否主表分组 // 数据信息按是否主表分组
Map<Integer, List<ResponseConfigAlias>> aliasMap = responseConfigAliasList.stream().collect(Collectors.groupingBy(ResponseConfigAlias::getTableType)); Map<Integer, List<ResponseConfigAlias>> aliasMap = responseConfigAliasList.stream().collect(Collectors.groupingBy(ResponseConfigAlias::getTableType));
// note by youhong.ai 获取主表别名配置数据 // 获取主表别名配置数据
List<ResponseConfigAlias> mainConfigList = aliasMap.get(ResponseConfigConstant.MAIN_TABLE); List<ResponseConfigAlias> mainConfigList = aliasMap.get(ResponseConfigConstant.MAIN_TABLE);
// note by youhong.ai 按照表类型分组 // 按照表类型分组
Map<Integer, List<ResponseConfigValueChange>> mainOrDetail = valueChangeList.stream().collect(Collectors.groupingBy(ResponseConfigValueChange::getTableType)); Map<Integer, List<ResponseConfigValueChange>> mainOrDetail = valueChangeList.stream().collect(Collectors.groupingBy(ResponseConfigValueChange::getTableType));
// note by youhong.ai 获取主表值配置 // 获取主表值配置
List<ResponseConfigValueChange> mainValueChangeList = mainOrDetail.get(ResponseConfigConstant.MAIN_TABLE); List<ResponseConfigValueChange> mainValueChangeList = mainOrDetail.get(ResponseConfigConstant.MAIN_TABLE);
TableDefinition tableDefinition; TableDefinition tableDefinition;
// note by youhong.ai 如果有主表配置 // 如果有主表配置
if (ResponseUtil.parameterIsNotNull(mainConfigList)) { if (ResponseUtil.parameterIsNotNull(mainConfigList)) {
// note by youhong.ai 解析json为表描述对象 // 解析json为表描述对象
tableDefinition = this.parsingJsonToTable(responseConfig.getModelTableName(), responseConfig, mainConfigList, mainValueChangeList, responseMap, true, this::detailTableDeal); tableDefinition = this.parsingJsonToTable(responseConfig.getModelTableName(), responseConfig, mainConfigList, mainValueChangeList, responseMap, true, this::detailTableDeal);
} else { } else {
// note by youhong.ai 如果没有主表配置,纯配置明细同步 // 如果没有主表配置,纯配置明细同步
Map<String, TableDefinition> detailTable = new HashMap<>(); Map<String, TableDefinition> detailTable = new HashMap<>();
// note by youhong.ai 处理明细表 // 处理明细表
this.detailTableDeal(responseConfig, responseMap, detailTable); this.detailTableDeal(responseConfig, responseMap, detailTable);
tableDefinition = TableDefinition.builder() tableDefinition = TableDefinition.builder()
.detailTableMap(detailTable) .detailTableMap(detailTable)
@ -124,8 +124,9 @@ public class ResponseMappingDeal {
tableDefinition.dataProcess(); tableDefinition.dataProcess();
} }
/** /**
* <h2>note by youhon.ai json</h2> * <h2>note by youhong.ai json</h2>
* *
* @param tableName * @param tableName
* @param responseConfig * @param responseConfig
@ -144,9 +145,9 @@ public class ResponseMappingDeal {
Map<String, Object> responseMap, Map<String, Object> responseMap,
boolean isMainTable, boolean isMainTable,
Bi3Function<ResponseConfig, Map<String, Object>, Map<String, TableDefinition>, String> detailCallBack) { Bi3Function<ResponseConfig, Map<String, Object>, Map<String, TableDefinition>, String> detailCallBack) {
// note by youhong.ai 过滤出主表别名主数据配置 // 过滤出主表别名主数据配置
List<ResponseConfigAlias> mainAliasList = responseConfigAliasList.stream().filter(item -> item.getMainData() == ResponseConfigConstant.MAIN_DATA).collect(Collectors.toList()); List<ResponseConfigAlias> mainAliasList = responseConfigAliasList.stream().filter(item -> item.getMainData() == ResponseConfigConstant.MAIN_DATA).collect(Collectors.toList());
// note by youhong.ai 主表别名有且只能有一个主数据 // 主表别名有且只能有一个主数据
if (responseConfigAliasList.size() > 1) { if (responseConfigAliasList.size() > 1) {
throw new ResponseException("The master data cannot be multiple please check !!! "); throw new ResponseException("The master data cannot be multiple please check !!! ");
} }
@ -158,13 +159,11 @@ public class ResponseMappingDeal {
responseConfigAliasList.forEach(item -> { responseConfigAliasList.forEach(item -> {
String dataPath = item.getDataPath(); String dataPath = item.getDataPath();
String dataAlias = item.getDataAlias(); String dataAlias = item.getDataAlias();
// node by youhong.ai 通过路径获取对应的值 // 通过路径获取对应的值
Object parsingData = Util.getValueByKeyStr(dataPath, responseMap); Object parsingData = "rootNode".equalsIgnoreCase(dataPath) ? responseMap : Util.getValueByKeyStr(dataPath, responseMap);
// node by youhong.ai 别名->值 // 别名->值
aliasData.put(dataAlias, parsingData); aliasData.put(dataAlias, parsingData);
}); });
// Map<Integer, List<ResponseConfigValueChange>> mainOrDetail = valueChangeList.stream().collect(Collectors.groupingBy(ResponseConfigValueChange::getTableType));
// List<ResponseConfigValueChange> mainValueChangeList = mainOrDetail.get(ResponseConfigConstant.MAIN_TABLE);
ResponseUtil.parameterJudgment(valueChangeList, "main table valueChangeList config is empty please check!!!"); ResponseUtil.parameterJudgment(valueChangeList, "main table valueChangeList config is empty please check!!!");
// 获取主表的主数据信息 // 获取主表的主数据信息
ResponseConfigAlias mainDataAlias = mainAliasList.get(0); ResponseConfigAlias mainDataAlias = mainAliasList.get(0);
@ -180,7 +179,7 @@ public class ResponseMappingDeal {
String dataPath = mainDataAlias.getDataPath(); String dataPath = mainDataAlias.getDataPath();
List<RowDefinition> rowDefinitionList = new ArrayList<>(); List<RowDefinition> rowDefinitionList = new ArrayList<>();
Map<String, TableDefinition> detailTable = isMainTable ? new HashMap<>() : null; Map<String, TableDefinition> detailTable = isMainTable ? new HashMap<>() : null;
// note by youhong.ai 如果是json数组 // 如果是json数组
if (mainDataAlias.getDataType() == ResponseConfigConstant.JSON_ARRAY) { if (mainDataAlias.getDataType() == ResponseConfigConstant.JSON_ARRAY) {
List<Map<String, Object>> mainList = (List<Map<String, Object>>) Util.getValueByKeyStr(dataPath, aliasData); List<Map<String, Object>> mainList = (List<Map<String, Object>>) Util.getValueByKeyStr(dataPath, aliasData);
for (Map<String, Object> mainItem : mainList) { for (Map<String, Object> mainItem : mainList) {

View File

@ -104,4 +104,20 @@ public class BankController {
} }
} }
@GET
@Path("/getBudge")
@Produces(MediaType.APPLICATION_JSON)
public String getBudge(@Context HttpServletRequest request, @Context HttpServletResponse response) {
try{
log.info("====== into getBudge success =======");
String budgeDetailType = request.getParameter("budgeDetailType");
log.info("budgeDetailType:"+budgeDetailType);
String budgeType = bankService.getBudgeType(budgeDetailType);
return ApiResult.success(budgeType);
}catch (Exception e){
log.error("getCommonSelect error ==> "+Util.getErrString(e));
return ApiResult.error(e.getMessage());
}
}
} }

View File

@ -1,8 +1,10 @@
package com.api.bokang.xiao.zhenn.mapper; package com.api.bokang.xiao.zhenn.mapper;
import aiyh.utils.annotation.recordset.ParamMapper;
import aiyh.utils.annotation.recordset.Select; import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper; import aiyh.utils.annotation.recordset.SqlMapper;
import java.sql.Struct;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -145,4 +147,7 @@ public interface BankMapper {
"WHERE wb.currentnodetype = 3 " + "WHERE wb.currentnodetype = 3 " +
" AND wb.lastoperatedate BETWEEN #{beginDate} AND #{endDate} ") " AND wb.lastoperatedate BETWEEN #{beginDate} AND #{endDate} ")
List<Map<String, Object>> queryOaOtherDetailList(Map<String, Object> param); List<Map<String, Object>> queryOaOtherDetailList(Map<String, Object> param);
@Select("select string_agg(budgettypeid,',') from BudgetUserInfoView where keyId in ($split{budgeDetailType})")
String queryBudgeType(@ParamMapper("budgeDetailType")String budgeDetailType);
} }

View File

@ -254,4 +254,8 @@ public class BankService {
log.info("excel List ==>"+objects.size()); log.info("excel List ==>"+objects.size());
EasyExcel.write(outputStream, aClass).sheet("Sheet1").doWrite(objects); EasyExcel.write(outputStream, aClass).sheet("Sheet1").doWrite(objects);
} }
public String getBudgeType(String budgeDetailType) {
return bankMapper.queryBudgeType(budgeDetailType);
}
} }

View File

@ -127,8 +127,8 @@ public class NormalTest extends BaseTest {
ParseTest parseTest = new ParseTest(); ParseTest parseTest = new ParseTest();
Map<String, Object> resultData = parseTest.getResultData(); Map<String, Object> resultData = parseTest.getResultData();
System.out.println(JSON.toJSONString(resultData)); System.out.println(JSON.toJSONString(resultData));
ResponseMappingDeal responseMappingDeal = new ResponseMappingDeal(); //ResponseMappingDeal responseMappingDeal = new ResponseMappingDeal();
responseMappingDeal.doResponseSync("test1",resultData); //responseMappingDeal.doResponseSync("test1",resultData);
} }
@Test @Test

View File

@ -97,7 +97,7 @@ public class ParseTest extends BaseTest {
Map<String, Object> data = new HashMap<>(); Map<String, Object> data = new HashMap<>();
data.put("name", "肖博亢"); data.put("name", "肖博亢");
data.put("age", 18); data.put("age", 18);
data.put("sex", ""); data.put("sex", "");
List<Map<String, Object>> friends = new ArrayList<>(); List<Map<String, Object>> friends = new ArrayList<>();
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
Map<String, Object> friend = new HashMap<>(); Map<String, Object> friend = new HashMap<>();