From 7db56b7b40433f3418870f2e42b8c59af13324a0 Mon Sep 17 00:00:00 2001 From: ic_excellent <2570192571@qq.com> Date: Tue, 18 Jul 2023 10:36:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BB=A3=E7=A0=81=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 | 47 +++++++++---------- .../xiao/zhenn/controller/BankController.java | 16 +++++++ .../bokang/xiao/zhenn/mapper/BankMapper.java | 5 ++ .../xiao/zhenn/service/BankService.java | 4 ++ src/test/java/bokang/xiao/NormalTest.java | 4 +- .../utiltest/resultjsonparase/ParseTest.java | 2 +- 6 files changed, 51 insertions(+), 27 deletions(-) diff --git a/src/main/java/aiyh/utils/response_deal/ResponseMappingDeal.java b/src/main/java/aiyh/utils/response_deal/ResponseMappingDeal.java index ed63911..d4d6ea0 100644 --- a/src/main/java/aiyh/utils/response_deal/ResponseMappingDeal.java +++ b/src/main/java/aiyh/utils/response_deal/ResponseMappingDeal.java @@ -57,60 +57,60 @@ public class ResponseMappingDeal { } /** - *

响应同步 note by youhong.ai

+ *

响应同步

* * @param uniqueCode 唯一表示 * @param responseMap 响应map */ public void doResponseSync(String uniqueCode, Map responseMap) { - // note by youhong.ai 查询配置表 + // 查询配置表 List 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 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)); } /** - *

note by youhong.ai 同步数据

+ *

同步数据

* * @param responseConfig 配置表 * @param responseMap 响应结果 */ public void doResponseSync(ResponseConfig responseConfig, Map responseMap) { - // note by youhong.ai 获取别名配置明细数据 + // 获取别名配置明细数据 List responseConfigAliasList = responseConfig.getResponseConfigAliasList(); ResponseUtil.parameterJudgment(responseConfigAliasList, "responseConfigAliasList config is empty please check!!!"); - // note by youhong.ai 获取转换值配置明细 + // 获取转换值配置明细 List valueChangeList = responseConfig.getValueChangeList(); ResponseUtil.parameterJudgment(valueChangeList, "valueChangeList config is empty please check!!!"); // 数据信息按是否主表分组 Map> aliasMap = responseConfigAliasList.stream().collect(Collectors.groupingBy(ResponseConfigAlias::getTableType)); - // note by youhong.ai 获取主表别名配置数据 + // 获取主表别名配置数据 List mainConfigList = aliasMap.get(ResponseConfigConstant.MAIN_TABLE); - // note by youhong.ai 按照表类型分组 + // 按照表类型分组 Map> mainOrDetail = valueChangeList.stream().collect(Collectors.groupingBy(ResponseConfigValueChange::getTableType)); - // note by youhong.ai 获取主表值配置 + // 获取主表值配置 List 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 detailTable = new HashMap<>(); - // note by youhong.ai 处理明细表 + // 处理明细表 this.detailTableDeal(responseConfig, responseMap, detailTable); tableDefinition = TableDefinition.builder() .detailTableMap(detailTable) @@ -123,9 +123,10 @@ public class ResponseMappingDeal { tableDefinition.setDefaultState(stateClassKey); tableDefinition.dataProcess(); } + /** - *

note by youhon.ai 解析json为表描述对象

+ *

note by youhong.ai 解析json为表描述对象

* * @param tableName 表名 * @param responseConfig 响应配置 @@ -144,9 +145,9 @@ public class ResponseMappingDeal { Map responseMap, boolean isMainTable, Bi3Function, Map, String> detailCallBack) { - // note by youhong.ai 过滤出主表别名主数据配置 + // 过滤出主表别名主数据配置 List 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> mainOrDetail = valueChangeList.stream().collect(Collectors.groupingBy(ResponseConfigValueChange::getTableType)); - // List 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 rowDefinitionList = new ArrayList<>(); Map detailTable = isMainTable ? new HashMap<>() : null; - // note by youhong.ai 如果是json数组 + // 如果是json数组 if (mainDataAlias.getDataType() == ResponseConfigConstant.JSON_ARRAY) { List> mainList = (List>) Util.getValueByKeyStr(dataPath, aliasData); for (Map mainItem : mainList) { diff --git a/src/main/java/com/api/bokang/xiao/zhenn/controller/BankController.java b/src/main/java/com/api/bokang/xiao/zhenn/controller/BankController.java index 9a03898..d5f83a2 100644 --- a/src/main/java/com/api/bokang/xiao/zhenn/controller/BankController.java +++ b/src/main/java/com/api/bokang/xiao/zhenn/controller/BankController.java @@ -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()); + } + } + } diff --git a/src/main/java/com/api/bokang/xiao/zhenn/mapper/BankMapper.java b/src/main/java/com/api/bokang/xiao/zhenn/mapper/BankMapper.java index 8bbed02..bbea146 100644 --- a/src/main/java/com/api/bokang/xiao/zhenn/mapper/BankMapper.java +++ b/src/main/java/com/api/bokang/xiao/zhenn/mapper/BankMapper.java @@ -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> queryOaOtherDetailList(Map param); + + @Select("select string_agg(budgettypeid,',') from BudgetUserInfoView where keyId in ($split{budgeDetailType})") + String queryBudgeType(@ParamMapper("budgeDetailType")String budgeDetailType); } diff --git a/src/main/java/com/api/bokang/xiao/zhenn/service/BankService.java b/src/main/java/com/api/bokang/xiao/zhenn/service/BankService.java index b9835a9..dfd4da3 100644 --- a/src/main/java/com/api/bokang/xiao/zhenn/service/BankService.java +++ b/src/main/java/com/api/bokang/xiao/zhenn/service/BankService.java @@ -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); + } } diff --git a/src/test/java/bokang/xiao/NormalTest.java b/src/test/java/bokang/xiao/NormalTest.java index 01f406e..bd19a33 100644 --- a/src/test/java/bokang/xiao/NormalTest.java +++ b/src/test/java/bokang/xiao/NormalTest.java @@ -127,8 +127,8 @@ public class NormalTest extends BaseTest { ParseTest parseTest = new ParseTest(); Map 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 diff --git a/src/test/java/youhong/ai/utiltest/resultjsonparase/ParseTest.java b/src/test/java/youhong/ai/utiltest/resultjsonparase/ParseTest.java index b7620a4..7694a0e 100644 --- a/src/test/java/youhong/ai/utiltest/resultjsonparase/ParseTest.java +++ b/src/test/java/youhong/ai/utiltest/resultjsonparase/ParseTest.java @@ -97,7 +97,7 @@ public class ParseTest extends BaseTest { Map data = new HashMap<>(); data.put("name", "肖博亢"); data.put("age", 18); - data.put("sex", "女"); + data.put("sex", "男"); List> friends = new ArrayList<>(); for (int i = 0; i < 5; i++) { Map friend = new HashMap<>();