From 0de7a593e9d10cf587a45a3aae3a2c5e8fcf6590 Mon Sep 17 00:00:00 2001 From: wangxuanran <3055088966@qq.com> Date: Thu, 20 Jul 2023 13:03:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../state/InsertOrUpdateState.java | 3 ++ .../utils/response_deal/state/InsertSate.java | 1 + .../aiyh/utils/response_deal/state/State.java | 2 +- .../response_deal/state/UpdateState.java | 6 +++ .../table/HrmDepartmentTableDefinition.java | 15 +++++- .../wang/xk_hospital/test/XkHospitalTest.java | 48 ++++++++++++++++++- 6 files changed, 71 insertions(+), 4 deletions(-) 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 c8d8361..1ec7952 100644 --- a/src/main/java/aiyh/utils/response_deal/state/InsertOrUpdateState.java +++ b/src/main/java/aiyh/utils/response_deal/state/InsertOrUpdateState.java @@ -62,6 +62,9 @@ public class InsertOrUpdateState extends State{ 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<>()); + if(StrUtil.isNotBlank(dataId)){ + rowDefinition.setDataId(Util.getIntValue(dataId, -1)); + } 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 3f8f98d..31cf7b7 100644 --- a/src/main/java/aiyh/utils/response_deal/state/InsertSate.java +++ b/src/main/java/aiyh/utils/response_deal/state/InsertSate.java @@ -97,6 +97,7 @@ public class InsertSate extends State{ } rowDefinitionList.forEach(item ->{ item.getUpdateParam().put("mainid",mainId); + item.getWhereParam().put("mainid",mainId); }); if(mainDetailMap.containsKey(key)){ TableDefinition tableDefinition = mainDetailMap.get(key); diff --git a/src/main/java/aiyh/utils/response_deal/state/State.java b/src/main/java/aiyh/utils/response_deal/state/State.java index 6bea1b3..29a0a3b 100644 --- a/src/main/java/aiyh/utils/response_deal/state/State.java +++ b/src/main/java/aiyh/utils/response_deal/state/State.java @@ -16,7 +16,7 @@ public abstract class State { protected final ConfigMapper configMapper = Util.getMapper(ConfigMapper.class); /** 日志对象 */ - protected final Logger logger = Util.getLogger(); + protected final Logger logger = Util.getLogger("json_util"); /** 上下文对象 */ protected TableDefinition context; diff --git a/src/main/java/aiyh/utils/response_deal/state/UpdateState.java b/src/main/java/aiyh/utils/response_deal/state/UpdateState.java index 2a64808..b7c4ebe 100644 --- a/src/main/java/aiyh/utils/response_deal/state/UpdateState.java +++ b/src/main/java/aiyh/utils/response_deal/state/UpdateState.java @@ -83,6 +83,12 @@ public class UpdateState extends State { return; } detailTableMap.forEach((key,value) ->{ + if(item.getDataId() > 0){ + for (RowDefinition rowDefinition : value.getRowDefinitionList()) { + rowDefinition.getUpdateParam().put("mainid", item.getDataId()); + rowDefinition.getWhereParam().put("mainid", item.getDataId()); + } + } if(mainDetailMap.containsKey(key)){ mainDetailMap.get(key).getRowDefinitionList().addAll(value.getRowDefinitionList()); }else { diff --git a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/table/HrmDepartmentTableDefinition.java b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/table/HrmDepartmentTableDefinition.java index bc637bf..8d7aac7 100644 --- a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/table/HrmDepartmentTableDefinition.java +++ b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/table/HrmDepartmentTableDefinition.java @@ -2,6 +2,7 @@ package com.api.xuanran.wang.xk_hospital.data_async.definitions.table; 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.entity.TableDefinition; import aiyh.utils.response_deal.intfaces.TableDefinitionCallback; @@ -13,6 +14,7 @@ import weaver.matrix.MatrixUtil; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.stream.Collectors; /** @@ -29,7 +31,18 @@ public class HrmDepartmentTableDefinition extends XkHospitalCommonDefinition imp @Override public void tableHandle(TableDefinition tableDefinition) { - + if(ResponseConfigConstant.DETAIL_TABLE == tableDefinition.getMainOrDetail()){ + List list = tableDefinition.getRowDefinitionList(); + if(CollectionUtils.isEmpty(list)){ + return; + } + for (RowDefinition rowDefinition : list) { + Object mainId = rowDefinition.getUpdateParam().remove("mainid"); + if(!Objects.isNull(mainId)){ + rowDefinition.getUpdateParam().put("id", mainId); + } + } + } } @Override 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 3572963..1afaa31 100644 --- a/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java +++ b/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java @@ -53,8 +53,8 @@ public class XkHospitalTest extends BaseTest { String json = "{\n" + "\t\"ID\":\"1\",\n" + - "\t\"EmplCode\":\"TEST1\",\n" + - "\t\"EmplName\":\"测试人员1\",\n" + + "\t\"EmplCode\":\"TEST10\",\n" + + "\t\"EmplName\":\"测试人员10\",\n" + "\t\"EmplType\":\"人员类型代码\",\n" + "\t\"EmplTypeCaption\":\"人员类型名称\",\n" + "\t\"Gender\":\"男\",\n" + @@ -70,4 +70,48 @@ public class XkHospitalTest extends BaseTest { Util.null2DefaultStr(null,""); service.async("4bce0693734c","hrm",map); } + + @Test + public void testC(){ + String json = "{\n" + + "\t\"ID\":\"主键\",\n" + + "\t\"GroupID\":\"test_yl_01\",\n" + + "\t\"GroupCode\":\"test_yl_dm_03\",\n" + + "\t\"GroupName\":\"医疗组名称1\",\n" + + "\t\"DeptCode\":\"test03\",\n" + + "\t\"DeptName\":\"测试科室03\",\n" + + "\t\"WardCode\":\"病区代码\",\n" + + "\t\"WardName\":\"病区名称\",\n" + + "\t\"Ward_BedNumber\":\"病区床位数,int类型\",\n" + + "\t\"IsDelete\":\"是否停用,bool类型\",\n" + + "\t\"Remark\":\"备注\",\n" + + "\t\"Wards\":[\t\n" + + "\t\t{\t\t\t\n" + + "\t\t\t\"ID\":\"1\",\n" + + "\t\t\t\"WardCode\":\"bq_01\",\n" + + "\t\t\t\"WardName\":\"病区名称01_2_3\"\n" + + "\t\t},{\t\t\t\n" + + "\t\t\t\"ID\":\"2\",\n" + + "\t\t\t\"WardCode\":\"bq_03\",\n" + + "\t\t\t\"WardName\":\"病区名称02_1_3\"\n" + + "\t\t}\n" + + "\t],\n" + + "\t\"WardHeads\":[\n" + + "\t\t{\n" + + "\t\t\t\"ID\":\"1\",\n" + + "\t\t\t\"EmplCode\":\"TEST10\",\n" + + "\t\t\t\"EmplName\":\"傻逼01\",\n" + + "\t\t\t\"Category\":\"人员分组,当人员为主治和住院医师时使用\"\n" + + "\t\t},{\n" + + "\t\t\t\"ID\":\"2\",\n" + + "\t\t\t\"EmplCode\":\"TEST10\",\n" + + "\t\t\t\"EmplName\":\"傻逼02\",\n" + + "\t\t\t\"Category\":\"人员分组,当人员为主治和住院医师时使用\"\n" + + "\t\t}\n" + + "\t]\n" + + "}\n"; + Map map = JSONObject.parseObject(json, Map.class); + Util.null2DefaultStr(null,""); + service.async("4bce0693734d","common", map); + } }