From a6efc98ddf0afc935ad88d91f8817f5fc2593169 Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期二, 08 七月 2025 20:32:25 +0800 Subject: [PATCH] 设备表-通过EAM中心ids获取设备树 --- lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentServiceImpl.java | 68 ++++++++++++++++++++++++++++++++++ 1 files changed, 68 insertions(+), 0 deletions(-) diff --git a/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentServiceImpl.java b/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentServiceImpl.java index 7146a61..4976c34 100644 --- a/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentServiceImpl.java +++ b/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentServiceImpl.java @@ -14,6 +14,7 @@ import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.util.oConvertUtils; import org.jeecg.modules.eam.aspect.annotation.EquipmentHistoryLog; +import org.jeecg.modules.eam.tree.FindsEquipmentEamCenterUtil; import org.jeecg.modules.system.entity.BaseFactory; import org.jeecg.modules.system.entity.BaseFactoryUser; import org.jeecg.modules.system.service.IBaseFactoryService; @@ -119,6 +120,32 @@ List<EamEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list); //濉厖璁惧鏁版嵁 fillEquipmentByProduction(treeList); + return treeList; + } + + /** + * 鑾峰彇EAM涓績涓嬬殑璁惧淇℃伅 + * @param ids EAM涓績ids + * @return + */ + @Override + public List<EamEquipmentTree> loadTreeListByEamCenterIds(String ids){ + List<String> baseFactoryIds = Arrays.asList(ids.split(",")); + //鑾峰彇鎵�鏈塃AM鏁版嵁 + List<BaseFactory> baseFactoryList = baseFactoryService.list(new LambdaQueryWrapper<BaseFactory>().eq(BaseFactory::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(BaseFactory::getSorter)); + List<String> allBaseFactoryIds = new ArrayList<>(); + //鎵惧埌鎵�鏈変骇绾縤d鐨勪笂绾d + if (!baseFactoryIds.isEmpty()) { + for (String baseFactoryId : baseFactoryIds) { + this.getAllBaseFactoryIds(baseFactoryList, baseFactoryId, allBaseFactoryIds); + } + } + //杩囨护EAM鏁版嵁 + List<BaseFactory> list = baseFactoryList.stream().filter((BaseFactory baseFactory) -> allBaseFactoryIds.contains(baseFactory.getId())).collect(Collectors.toList()); + //缁勮EAM璁惧鏍� + List<EamEquipmentTree> treeList = FindsEquipmentEamCenterUtil.wrapEquipmentBaseFactoryTreeList(list); + //濉厖璁惧鏁版嵁 + fillEquipmentByBaseFactory(treeList); return treeList; } @@ -389,6 +416,26 @@ } /** + * 鑾峰彇鎵�鏈夌殑浜х嚎id锛堝寘鍚墍鏈変笂绾э級 + */ + private void getAllBaseFactoryIds(List<BaseFactory> baseFactoryList, String baseFactoryId, List<String> allBaseFactoryIds) { + if (!allBaseFactoryIds.contains(baseFactoryId)) { + allBaseFactoryIds.add(baseFactoryId); + } + for (BaseFactory baseFactory : baseFactoryList) { + if (StringUtils.isEmpty(baseFactory.getParentId())) { + continue; + } + if (baseFactoryId.equals(baseFactory.getId())) { + if (!allBaseFactoryIds.contains(baseFactory.getParentId())) { + allBaseFactoryIds.add(baseFactory.getParentId()); + getAllBaseFactoryIds(baseFactoryList, baseFactory.getParentId(), allBaseFactoryIds); + } + } + } + } + + /** * 浜х嚎璁惧鏍戝~鍏呰澶囨暟鎹� */ private void fillEquipmentByProduction(List<EamEquipmentTree> treeList) { @@ -409,4 +456,25 @@ } } + /** + * 浜х嚎璁惧鏍戝~鍏呰澶囨暟鎹� + */ + private void fillEquipmentByBaseFactory(List<EamEquipmentTree> treeList) { + for (EamEquipmentTree mdcEquipmentTree : treeList) { + List<EamEquipment> equipmentList = eamEquipmentMapper.queryByEamCenterId(mdcEquipmentTree.getKey()); + if (CollectionUtil.isNotEmpty(equipmentList)) { + for (EamEquipment mdcEquipment : equipmentList) { + EamEquipmentTree tree = new EamEquipmentTree().convert(mdcEquipment); + tree.setParentId(mdcEquipmentTree.getKey()); + tree.setType(2); + mdcEquipmentTree.getChildren().add(tree); + } + mdcEquipmentTree.setLeaf(false); + } + if (CollectionUtil.isNotEmpty(mdcEquipmentTree.getChildren())) { + fillEquipmentByBaseFactory(mdcEquipmentTree.getChildren()); + } + } + } + } -- Gitblit v1.9.3