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); } }