From 23855599412c4d61b38d78f0f3abd3430a48b5b1 Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期三, 25 六月 2025 11:51:38 +0800 Subject: [PATCH] Merge branch 'mdc_hyjs_master' --- lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/util/FindsProductionsChildrenUtil.java | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 108 insertions(+), 0 deletions(-) diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/util/FindsProductionsChildrenUtil.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/util/FindsProductionsChildrenUtil.java new file mode 100644 index 0000000..3857c1d --- /dev/null +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/util/FindsProductionsChildrenUtil.java @@ -0,0 +1,108 @@ +package org.jeecg.modules.system.util; + +import cn.hutool.core.util.StrUtil; +import org.jeecg.common.util.oConvertUtils; +import org.jeecg.modules.system.entity.MdcProduction; +import org.jeecg.modules.system.model.MdcProductionTreeModel; +import org.jeecg.modules.system.model.ProductionIdModel; + +import java.util.ArrayList; +import java.util.List; + +/** + * 瀵瑰簲浜х嚎鐨勮〃锛屽鐞嗗苟鏌ユ壘鏍戠粨鏋勬暟鎹� + * + * @author: LiuS + * @create: 2023-03-23 14:46 + */ +public class FindsProductionsChildrenUtil { + + /** + * queryTreeList鐨勫瓙鏂规硶 ====1===== + * 璇ユ柟娉曟槸s灏哅dcProduction绫诲瀷鐨刲ist闆嗗悎杞崲鎴怣dcProductionTreeModel绫诲瀷鐨勯泦鍚� + */ + public static List<MdcProductionTreeModel> wrapTreeDataToTreeList(List<MdcProduction> recordList) { + List<ProductionIdModel> idList = new ArrayList<>(); + List<MdcProductionTreeModel> records = new ArrayList<>(); + for (int i = 0; i < recordList.size(); i++) { + MdcProduction mdcProduction = recordList.get(i); + if (StrUtil.isEmpty(mdcProduction.getDescription())){ + mdcProduction.setDescription(""); + } + records.add(new MdcProductionTreeModel(mdcProduction)); + } + List<MdcProductionTreeModel> tree = findChildren(records, idList); + setEmptyChildrenAsNull(tree); + return tree; + } + + /** + * queryTreeList鐨勫瓙鏂规硶 ====1===== + * 璇ユ柟娉曟槸鎵惧埌骞跺皝瑁呴《绾х埗绫荤殑鑺傜偣鍒癟reeList闆嗗悎 + */ + public static List<MdcProductionTreeModel> findChildren(List<MdcProductionTreeModel> recordList, List<ProductionIdModel> productionIdList) { + List<MdcProductionTreeModel> treeList = new ArrayList<>(); + for (int i = 0; i < recordList.size(); i++) { + MdcProductionTreeModel branch = recordList.get(i); + if (oConvertUtils.isEmpty(branch.getParentId())) { + treeList.add(branch); + ProductionIdModel productionIdModel = new ProductionIdModel().convert(branch); + productionIdList.add(productionIdModel); + } + } + getGrandChildren(treeList, recordList, productionIdList); + return treeList; + } + + /** + * queryTreeList鐨勫瓙鏂规硶====3==== + *璇ユ柟娉曟槸鎵惧埌椤剁骇鐖剁被涓嬬殑鎵�鏈夊瓙鑺傜偣闆嗗悎骞跺皝瑁呭埌TreeList闆嗗悎 + */ + private static void getGrandChildren(List<MdcProductionTreeModel> treeList, List<MdcProductionTreeModel> recordList, List<ProductionIdModel> idList) { + for (int i = 0; i < treeList.size(); i++) { + MdcProductionTreeModel model = treeList.get(i); + ProductionIdModel idModel = idList.get(i); + for (int i1 = 0; i1 < recordList.size(); i1++) { + MdcProductionTreeModel m = recordList.get(i1); + if (m.getParentId() != null && m.getParentId().equals(model.getId())) { + model.getChildren().add(m); + ProductionIdModel pim = new ProductionIdModel().convert(m); + idModel.setSelectable(false); + idModel.getChildren().add(pim); + } + } + getGrandChildren(treeList.get(i).getChildren(), recordList, idList.get(i).getChildren()); + } + } + + /** + * queryTreeList鐨勫瓙鏂规硶 ====4==== + * 璇ユ柟娉曟槸灏嗗瓙鑺傜偣涓虹┖鐨凩ist闆嗗悎璁剧疆涓篘ull鍊� + */ + private static void setEmptyChildrenAsNull(List<MdcProductionTreeModel> treeList) { + for (int i = 0; i < treeList.size(); i++) { + MdcProductionTreeModel model = treeList.get(i); + if (model.getChildren().size() == 0) { + model.setChildren(null); + model.setLeaf(true); + } else { + setEmptyChildrenAsNull(model.getChildren()); + model.setLeaf(false); + } + } + } + + /** + * 鑾峰彇 DepartIdModel + */ + public static List<ProductionIdModel> wrapTreeDataToProductionIdTreeList(List<MdcProduction> recordList) { + List<ProductionIdModel> idList = new ArrayList<>(); + List<MdcProductionTreeModel> records = new ArrayList<>(); + for (int i = 0; i < recordList.size(); i++) { + MdcProduction mdcProduction = recordList.get(i); + records.add(new MdcProductionTreeModel(mdcProduction)); + } + findChildren(records, idList); + return idList; + } +} -- Gitblit v1.9.3