diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/mapper/MaDevInfoMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/mapper/MaDevInfoMapper.java index 000a43d..f24179d 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/mapper/MaDevInfoMapper.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/mapper/MaDevInfoMapper.java @@ -46,5 +46,7 @@ public interface MaDevInfoMapper { List getDeviceByMaIds(String[] maIdArray); + //查询装备总数 + Integer selectTotalDeviceCount(); } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/service/MaDevInfoServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/service/MaDevInfoServiceImpl.java index 933645c..945cd44 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/service/MaDevInfoServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/service/MaDevInfoServiceImpl.java @@ -121,11 +121,17 @@ public class MaDevInfoServiceImpl implements MaDevInfoService { } /** - * 将扁平列表构建成树,并添加一个总的根节点 + * 将扁平列表构建成树,并添加一个总的根节点,根节点名称包含设备总数 */ public DeviceTreeBean buildTree(List list) { + // 统计设备总数(列表的size即为总数量) + //int totalCount = list == null ? 0 : list.size(); + + Integer totalCount=mapper.selectTotalDeviceCount(); + if (list == null || list.isEmpty()) { - return new DeviceTreeBean("0", "-1", "设备目录"); + // 空列表时显示总数为0 + return new DeviceTreeBean("0", "-1", "装备目录(总数:0)"); } // 1. 创建 id -> node 映射 @@ -152,19 +158,21 @@ public class MaDevInfoServiceImpl implements MaDevInfoService { // 如果父节点不存在,挂到虚拟根 parentNode = virtualRoot; } - if (StringUtils.isEmpty(parentNode.getChildren())) { + if (parentNode.getChildren() == null) { parentNode.setChildren(new ArrayList<>()); } parentNode.getChildren().add(node); } - // 5. 创建最终的总根节点 - DeviceTreeBean root = new DeviceTreeBean("0", "-1", "设备目录"); + + // 5. 创建最终的总根节点,名称包含设备总数 + DeviceTreeBean root = new DeviceTreeBean("0", "-1", String.format("装备目录(总数:%d)", totalCount)); if (virtualRoot.getChildren() != null && !virtualRoot.getChildren().isEmpty()) { - if (StringUtils.isEmpty(root.getChildren())) { + if (root.getChildren() == null) { root.setChildren(new ArrayList<>()); } root.getChildren().addAll(virtualRoot.getChildren()); } + return root; } diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/MaDevInfoMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/MaDevInfoMapper.xml index f340c92..9edd458 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/MaDevInfoMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/MaDevInfoMapper.xml @@ -241,6 +241,9 @@ mt.parent_id as pId FROM ma_type mt WHERE mt.level != '7' + + AND mt.type_name LIKE CONCAT('%', #{name}, '%') + + + +