同步代码问题修复
parent
ae93310168
commit
7db56b7b40
|
@ -57,60 +57,60 @@ public class ResponseMappingDeal {
|
|||
}
|
||||
|
||||
/**
|
||||
* <h2>响应同步 note by youhong.ai</h2>
|
||||
* <h2>响应同步 </h2>
|
||||
*
|
||||
* @param uniqueCode 唯一表示
|
||||
* @param responseMap 响应map
|
||||
*/
|
||||
public void doResponseSync(String uniqueCode, Map<String, Object> responseMap) {
|
||||
// note by youhong.ai 查询配置表
|
||||
// 查询配置表
|
||||
List<ResponseConfig> responseConfigList = configMapper.queryResponseConfigByUnique(uniqueCode);
|
||||
logger.info(String.format("%s 相关响应配置信息==> %s", uniqueCode, JSON.toJSONString(responseConfigList)));
|
||||
// note by youhong.ai 自定义校验
|
||||
// 自定义校验
|
||||
ResponseUtil.parameterJudgment(responseConfigList, "response config is empty please check!!! ");
|
||||
Map<String, ResponseConfig> tableNameConfig;
|
||||
try {
|
||||
// note by youhong.ai 对查询到的多个配置进行整合,以同步表表名作为key 配置作为value
|
||||
// 对查询到的多个配置进行整合,以同步表表名作为key 配置作为value
|
||||
tableNameConfig = responseConfigList.stream().collect(Collectors.toMap(ResponseConfig::getModelTableName, v -> v));
|
||||
} catch (Exception e) {
|
||||
logger.error("response config error please check!!! " + Util.getErrString(e));
|
||||
throw new ResponseException("response config error please check!!! ");
|
||||
}
|
||||
ResponseUtil.parameterJudgment(responseMap, "接口返回都为空 你处理个勾");
|
||||
// note by youhong.ai 循环同步每一个表
|
||||
// 循环同步每一个表
|
||||
tableNameConfig.forEach((key, value) -> doResponseSync(value, responseMap));
|
||||
}
|
||||
|
||||
/**
|
||||
* <h2>note by youhong.ai 同步数据</h2>
|
||||
* <h2> 同步数据</h2>
|
||||
*
|
||||
* @param responseConfig 配置表
|
||||
* @param responseMap 响应结果
|
||||
*/
|
||||
public void doResponseSync(ResponseConfig responseConfig, Map<String, Object> responseMap) {
|
||||
// note by youhong.ai 获取别名配置明细数据
|
||||
// 获取别名配置明细数据
|
||||
List<ResponseConfigAlias> responseConfigAliasList = responseConfig.getResponseConfigAliasList();
|
||||
ResponseUtil.parameterJudgment(responseConfigAliasList, "responseConfigAliasList config is empty please check!!!");
|
||||
// note by youhong.ai 获取转换值配置明细
|
||||
// 获取转换值配置明细
|
||||
List<ResponseConfigValueChange> valueChangeList = responseConfig.getValueChangeList();
|
||||
ResponseUtil.parameterJudgment(valueChangeList, "valueChangeList config is empty please check!!!");
|
||||
// 数据信息按是否主表分组
|
||||
Map<Integer, List<ResponseConfigAlias>> aliasMap = responseConfigAliasList.stream().collect(Collectors.groupingBy(ResponseConfigAlias::getTableType));
|
||||
// note by youhong.ai 获取主表别名配置数据
|
||||
// 获取主表别名配置数据
|
||||
List<ResponseConfigAlias> mainConfigList = aliasMap.get(ResponseConfigConstant.MAIN_TABLE);
|
||||
// note by youhong.ai 按照表类型分组
|
||||
// 按照表类型分组
|
||||
Map<Integer, List<ResponseConfigValueChange>> mainOrDetail = valueChangeList.stream().collect(Collectors.groupingBy(ResponseConfigValueChange::getTableType));
|
||||
// note by youhong.ai 获取主表值配置
|
||||
// 获取主表值配置
|
||||
List<ResponseConfigValueChange> mainValueChangeList = mainOrDetail.get(ResponseConfigConstant.MAIN_TABLE);
|
||||
TableDefinition tableDefinition;
|
||||
// note by youhong.ai 如果有主表配置
|
||||
// 如果有主表配置
|
||||
if (ResponseUtil.parameterIsNotNull(mainConfigList)) {
|
||||
// note by youhong.ai 解析json为表描述对象
|
||||
// 解析json为表描述对象
|
||||
tableDefinition = this.parsingJsonToTable(responseConfig.getModelTableName(), responseConfig, mainConfigList, mainValueChangeList, responseMap, true, this::detailTableDeal);
|
||||
} else {
|
||||
// note by youhong.ai 如果没有主表配置,纯配置明细同步
|
||||
// 如果没有主表配置,纯配置明细同步
|
||||
Map<String, TableDefinition> detailTable = new HashMap<>();
|
||||
// note by youhong.ai 处理明细表
|
||||
// 处理明细表
|
||||
this.detailTableDeal(responseConfig, responseMap, detailTable);
|
||||
tableDefinition = TableDefinition.builder()
|
||||
.detailTableMap(detailTable)
|
||||
|
@ -124,8 +124,9 @@ public class ResponseMappingDeal {
|
|||
tableDefinition.dataProcess();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>note by youhon.ai 解析json为表描述对象</h2>
|
||||
* <h2>note by youhong.ai 解析json为表描述对象</h2>
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @param responseConfig 响应配置
|
||||
|
@ -144,9 +145,9 @@ public class ResponseMappingDeal {
|
|||
Map<String, Object> responseMap,
|
||||
boolean isMainTable,
|
||||
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());
|
||||
// note by youhong.ai 主表别名有且只能有一个主数据
|
||||
// 主表别名有且只能有一个主数据
|
||||
if (responseConfigAliasList.size() > 1) {
|
||||
throw new ResponseException("The master data cannot be multiple please check !!! ");
|
||||
}
|
||||
|
@ -158,13 +159,11 @@ public class ResponseMappingDeal {
|
|||
responseConfigAliasList.forEach(item -> {
|
||||
String dataPath = item.getDataPath();
|
||||
String dataAlias = item.getDataAlias();
|
||||
// node by youhong.ai 通过路径获取对应的值
|
||||
Object parsingData = Util.getValueByKeyStr(dataPath, responseMap);
|
||||
// node by youhong.ai 别名->值
|
||||
// 通过路径获取对应的值
|
||||
Object parsingData = "rootNode".equalsIgnoreCase(dataPath) ? responseMap : Util.getValueByKeyStr(dataPath, responseMap);
|
||||
// 别名->值
|
||||
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!!!");
|
||||
// 获取主表的主数据信息
|
||||
ResponseConfigAlias mainDataAlias = mainAliasList.get(0);
|
||||
|
@ -180,7 +179,7 @@ public class ResponseMappingDeal {
|
|||
String dataPath = mainDataAlias.getDataPath();
|
||||
List<RowDefinition> rowDefinitionList = new ArrayList<>();
|
||||
Map<String, TableDefinition> detailTable = isMainTable ? new HashMap<>() : null;
|
||||
// note by youhong.ai 如果是json数组
|
||||
// 如果是json数组
|
||||
if (mainDataAlias.getDataType() == ResponseConfigConstant.JSON_ARRAY) {
|
||||
List<Map<String, Object>> mainList = (List<Map<String, Object>>) Util.getValueByKeyStr(dataPath, aliasData);
|
||||
for (Map<String, Object> mainItem : mainList) {
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package com.api.bokang.xiao.zhenn.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.ParamMapper;
|
||||
import aiyh.utils.annotation.recordset.Select;
|
||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||
|
||||
import java.sql.Struct;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -145,4 +147,7 @@ public interface BankMapper {
|
|||
"WHERE wb.currentnodetype = 3 " +
|
||||
" AND wb.lastoperatedate BETWEEN #{beginDate} AND #{endDate} ")
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -254,4 +254,8 @@ public class BankService {
|
|||
log.info("excel List ==>"+objects.size());
|
||||
EasyExcel.write(outputStream, aClass).sheet("Sheet1").doWrite(objects);
|
||||
}
|
||||
|
||||
public String getBudgeType(String budgeDetailType) {
|
||||
return bankMapper.queryBudgeType(budgeDetailType);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,8 +127,8 @@ public class NormalTest extends BaseTest {
|
|||
ParseTest parseTest = new ParseTest();
|
||||
Map<String, Object> resultData = parseTest.getResultData();
|
||||
System.out.println(JSON.toJSONString(resultData));
|
||||
ResponseMappingDeal responseMappingDeal = new ResponseMappingDeal();
|
||||
responseMappingDeal.doResponseSync("test1",resultData);
|
||||
//ResponseMappingDeal responseMappingDeal = new ResponseMappingDeal();
|
||||
//responseMappingDeal.doResponseSync("test1",resultData);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -97,7 +97,7 @@ public class ParseTest extends BaseTest {
|
|||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("name", "肖博亢");
|
||||
data.put("age", 18);
|
||||
data.put("sex", "女");
|
||||
data.put("sex", "男");
|
||||
List<Map<String, Object>> friends = new ArrayList<>();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
Map<String, Object> friend = new HashMap<>();
|
||||
|
|
Loading…
Reference in New Issue