提交内容:API映射公共单据

备注:整理代码,优化代码,删除冗余
提交人:邹江涛
This commit is contained in:
zoujiangtao 2024-12-06 10:59:28 +08:00
parent a2507e8a6d
commit 23bfa5a450
1 changed files with 23 additions and 8 deletions

View File

@ -166,6 +166,15 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin {
} }
} }
/**
* 处理楼层
*
* @param parentJson 父JSON对象
* @param parentKey 父字段标识
* @param currentFloor 当前层级对象List
* @param floors 所有楼层对象List<List>
* @param dynamic 源单据对象
*/
private void processFloor(JSONObject parentJson, String parentKey, List<DynamicObject> currentFloor, List<List<DynamicObject>> floors, DynamicObject dynamic) { private void processFloor(JSONObject parentJson, String parentKey, List<DynamicObject> currentFloor, List<List<DynamicObject>> floors, DynamicObject dynamic) {
logger.info("进入processFloor方法"); logger.info("进入processFloor方法");
if (currentFloor.isEmpty()) { if (currentFloor.isEmpty()) {
@ -399,6 +408,13 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin {
} }
} }
/**
* 获取子对象集合
*
* @param floors 所有层级的所有对象
* @param parentKey 父节点的shkd_tarfield
* @return 子对象集合
*/
private List<DynamicObject> getChildren(List<List<DynamicObject>> floors, String parentKey) { private List<DynamicObject> getChildren(List<List<DynamicObject>> floors, String parentKey) {
List<DynamicObject> children = new ArrayList<>(); List<DynamicObject> children = new ArrayList<>();
for (List<DynamicObject> floor : floors) { for (List<DynamicObject> floor : floors) {
@ -447,6 +463,7 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin {
/** /**
* 给value赋值 * 给value赋值
*
* @param dynamicObject 映射分录的单行数据 * @param dynamicObject 映射分录的单行数据
* @param billObject 源单数据 * @param billObject 源单数据
* @param jsonObject JSON对象 * @param jsonObject JSON对象
@ -553,11 +570,9 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin {
jsonObject.put(key, childJson); jsonObject.put(key, childJson);
} else if ("数组".equals(tartype)) { } else if ("数组".equals(tartype)) {
JSONArray childJsonArray = new JSONArray(); JSONArray childJsonArray = new JSONArray();
for (DynamicObject childDynamicObject : getChildren(floors, dynamicObject.getString("shkd_tarfield"))) {
JSONObject childJson = new JSONObject(); JSONObject childJson = new JSONObject();
processFloor(childJson, key, Collections.singletonList(childDynamicObject), floors, billObject); processFloor(childJson, key, getChildren(floors, dynamicObject.getString("shkd_tarfield")), floors, billObject);
childJsonArray.add(childJson); childJsonArray.add(childJson);
}
jsonObject.put(key, childJsonArray); jsonObject.put(key, childJsonArray);
} }
} }