lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/mapper/EamEquipmentMapper.java
@@ -26,6 +26,13 @@ List<EamEquipment> queryByProductionId(String productionId); /** * æ¥è¯¢EAM建模ä¸çè®¾å¤ * @param eamCenterId * @return */ List<EamEquipment> queryByEamCenterId(String eamCenterId); /** * å页æ¥è¯¢ * @param page * @param queryWrapper lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/mapper/xml/EamEquipmentMapper.xml
@@ -38,4 +38,10 @@ on e.id = ext.id ${ew.customSqlSegment} </select> <select id="queryByEamCenterId" resultType="org.jeecg.modules.eam.entity.EamEquipment"> select * from eam_equipment where del_flag = 0 and factory_org_code =(select org_cod,e from eam_base_factory where eam_base_factory.id=#{eamCenterId}) </select> </mapper> lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/service/IEamEquipmentService.java
@@ -37,6 +37,13 @@ List<EamEquipmentTree> loadTreeListByProductionIds(String ids); /** * è·åEAMä¸å¿ä¸ç设å¤ä¿¡æ¯ * @param ids EAMä¸å¿ids * @return */ List<EamEquipmentTree> loadTreeListByEamCenterIds(String ids); /** * 设å¤å°è´¦å页æ¥è¯¢ * @param page * @param eamEquipment 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(",")); //è·åææEAMæ°æ® List<BaseFactory> baseFactoryList = baseFactoryService.list(new LambdaQueryWrapper<BaseFactory>().eq(BaseFactory::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(BaseFactory::getSorter)); List<String> allBaseFactoryIds = new ArrayList<>(); //æ¾å°ææäº§çº¿idçä¸çº§id 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()); } } } } lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/tree/FindsEquipmentEamCenterUtil.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,73 @@ package org.jeecg.modules.eam.tree; import org.jeecg.common.util.oConvertUtils; import org.jeecg.modules.eam.vo.EamEquipmentTree; import org.jeecg.modules.system.entity.BaseFactory; import org.jeecg.modules.system.model.EamBaseFactoryTreeModel; import java.util.ArrayList; import java.util.List; public class FindsEquipmentEamCenterUtil { /** * è·å MdcEquipmentTree */ public static List<EamEquipmentTree> wrapEquipmentBaseFactoryTreeList(List<BaseFactory> recordList) { List<EamEquipmentTree> idList = new ArrayList<>(); List<EamBaseFactoryTreeModel> records = new ArrayList<>(); for (BaseFactory BaseFactory : recordList) { records.add(new EamBaseFactoryTreeModel(BaseFactory)); } getChildren(records, idList); setEmptyChildrenAsNull(idList); return idList; } /** * è¯¥æ¹æ³æ¯æ¾å°å¹¶å°è£ 顶级ç¶ç±»çèç¹å°TreeListéå */ private static void getChildren(List<EamBaseFactoryTreeModel> recordList, List<EamEquipmentTree> idList) { List<EamBaseFactoryTreeModel> treeList = new ArrayList<>(); for (EamBaseFactoryTreeModel EamBaseFactoryTreeModel : recordList) { if (oConvertUtils.isEmpty(EamBaseFactoryTreeModel.getParentId())) { // EamBaseFactoryTreeModel.setType(1); treeList.add(EamBaseFactoryTreeModel); idList.add(new EamEquipmentTree().convertByBaseFactory(EamBaseFactoryTreeModel)); } } getGrandChildren(treeList, recordList, idList); } /** *è¯¥æ¹æ³æ¯æ¾å°é¡¶çº§ç¶ç±»ä¸çææåèç¹éåå¹¶å°è£ å°TreeListéå */ private static void getGrandChildren(List<EamBaseFactoryTreeModel> treeList, List<EamBaseFactoryTreeModel> recordList, List<EamEquipmentTree> idList) { for (int i = 0; i < treeList.size(); i++) { EamBaseFactoryTreeModel model = treeList.get(i); EamEquipmentTree mdcEquipmentTree = idList.get(i); for (int i1 = 0; i1 < recordList.size(); i1++) { EamBaseFactoryTreeModel m = recordList.get(i1); if (m.getParentId() != null && m.getParentId().equals(model.getId())) { model.getChildren().add(m); // m.setType(1); mdcEquipmentTree.getChildren().add(new EamEquipmentTree().convertByBaseFactory(m)); } } getGrandChildren(treeList.get(i).getChildren(), recordList, idList.get(i).getChildren()); } } /** * è¯¥æ¹æ³æ¯å°åèç¹ä¸ºç©ºçListéå设置为Nullå¼ */ private static void setEmptyChildrenAsNull(List<EamEquipmentTree> idList) { for (EamEquipmentTree mdcEquipmentTree : idList) { if (mdcEquipmentTree.getChildren().isEmpty()) { mdcEquipmentTree.setLeaf(true); } else { setEmptyChildrenAsNull(mdcEquipmentTree.getChildren()); mdcEquipmentTree.setLeaf(false); } } } } lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/vo/EamEquipmentTree.java
@@ -5,6 +5,7 @@ import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import org.jeecg.modules.eam.entity.EamEquipment; import org.jeecg.modules.system.model.EamBaseFactoryTreeModel; import org.jeecg.modules.system.model.MdcProductionTreeModel; import org.jeecg.modules.system.model.SysDepartTreeModel; @@ -118,4 +119,20 @@ this.orgType = treeModel.getOrgType(); return this; } /** * å°EamBaseFactoryTreeModelçé¨åæ°æ®æ¾å¨è¯¥å¯¹è±¡å½ä¸ * * @param treeModel * @return */ public EamEquipmentTree convertByBaseFactory(EamBaseFactoryTreeModel treeModel) { this.key = treeModel.getId(); this.value = treeModel.getId(); this.title = treeModel.getFactoryName(); this.memo = treeModel.getRemark(); // this.type = treeModel.getType(); this.orgType = treeModel.getOrgType(); return this; } } lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentController.java
@@ -316,6 +316,20 @@ return result; } @ApiOperation(value = "设å¤è¡¨-éè¿EAMä¸å¿idsè·åè®¾å¤æ ", notes = "设å¤è¡¨-éè¿EAMä¸å¿idsè·åè®¾å¤æ ") @GetMapping(value = "/loadTreeListByEamCenterIds") public Result<List<EamEquipmentTree>> loadTreeListByEamCenterIds(@RequestParam(name = "ids", required = true) String ids) { Result<List<EamEquipmentTree>> result = new Result<>(); try { List<EamEquipmentTree> mdcEquipmentTreeList = eamEquipmentService.loadTreeListByEamCenterIds(ids); result.setSuccess(true); result.setResult(mdcEquipmentTreeList); } catch (Exception e) { log.error(e.getMessage(), e); } return result; } /** * æ£ç´¢è®¾å¤ * @param keyword æ¥è¯¢å ³é®è¯ 设å¤ç¼å·ï¼è®¾å¤å称模ç³å¹é