From 23bfa5a45087868ea2e282de99de73871f589c4c Mon Sep 17 00:00:00 2001 From: zoujiangtao Date: Fri, 6 Dec 2024 10:59:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=86=85=E5=AE=B9=EF=BC=9AAP?= =?UTF-8?q?I=E6=98=A0=E5=B0=84=E5=85=AC=E5=85=B1=E5=8D=95=E6=8D=AE=20?= =?UTF-8?q?=E5=A4=87=E6=B3=A8=EF=BC=9A=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=EF=BC=8C=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=86=97=E4=BD=99=20=E6=8F=90=E4=BA=A4=E4=BA=BA?= =?UTF-8?q?=EF=BC=9A=E9=82=B9=E6=B1=9F=E6=B6=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sys/plugin/form/ApiMappingBillPlugin.java | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/form/ApiMappingBillPlugin.java b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/form/ApiMappingBillPlugin.java index 7fdfbba..26f238e 100644 --- a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/form/ApiMappingBillPlugin.java +++ b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/form/ApiMappingBillPlugin.java @@ -166,6 +166,15 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin { } } + /** + * 处理楼层 + * + * @param parentJson 父JSON对象 + * @param parentKey 父字段标识 + * @param currentFloor 当前层级对象(List) + * @param floors 所有楼层对象(List) + * @param dynamic 源单据对象 + */ private void processFloor(JSONObject parentJson, String parentKey, List currentFloor, List> floors, DynamicObject dynamic) { logger.info("进入processFloor方法"); if (currentFloor.isEmpty()) { @@ -399,6 +408,13 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin { } } + /** + * 获取子对象集合 + * + * @param floors 所有层级的所有对象 + * @param parentKey 父节点的shkd_tarfield + * @return 子对象集合 + */ private List getChildren(List> floors, String parentKey) { List children = new ArrayList<>(); for (List floor : floors) { @@ -447,10 +463,11 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin { /** * 给value赋值 + * * @param dynamicObject 映射分录的单行数据 - * @param billObject 源单数据 - * @param jsonObject JSON对象 - * @param floors 层集合 + * @param billObject 源单数据 + * @param jsonObject JSON对象 + * @param floors 层集合 */ private void valueAssignment(DynamicObject dynamicObject, DynamicObject billObject, JSONObject jsonObject, List> floors) { @@ -553,11 +570,9 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin { jsonObject.put(key, childJson); } else if ("数组".equals(tartype)) { JSONArray childJsonArray = new JSONArray(); - for (DynamicObject childDynamicObject : getChildren(floors, dynamicObject.getString("shkd_tarfield"))) { - JSONObject childJson = new JSONObject(); - processFloor(childJson, key, Collections.singletonList(childDynamicObject), floors, billObject); - childJsonArray.add(childJson); - } + JSONObject childJson = new JSONObject(); + processFloor(childJson, key, getChildren(floors, dynamicObject.getString("shkd_tarfield")), floors, billObject); + childJsonArray.add(childJson); jsonObject.put(key, childJsonArray); } }