装备台账页面

This commit is contained in:
itcast 2025-10-29 18:40:56 +08:00
parent 68555df7f1
commit 086f68ff22
3 changed files with 27 additions and 6 deletions

View File

@ -46,5 +46,7 @@ public interface MaDevInfoMapper {
List<MaDevInfo> getDeviceByMaIds(String[] maIdArray); List<MaDevInfo> getDeviceByMaIds(String[] maIdArray);
//查询装备总数
Integer selectTotalDeviceCount();
} }

View File

@ -121,11 +121,17 @@ public class MaDevInfoServiceImpl implements MaDevInfoService {
} }
/** /**
* 将扁平列表构建成树并添加一个总的根节点 * 将扁平列表构建成树并添加一个总的根节点根节点名称包含设备总数
*/ */
public DeviceTreeBean buildTree(List<DeviceTreeBean> list) { public DeviceTreeBean buildTree(List<DeviceTreeBean> list) {
// 统计设备总数列表的size即为总数量
//int totalCount = list == null ? 0 : list.size();
Integer totalCount=mapper.selectTotalDeviceCount();
if (list == null || list.isEmpty()) { if (list == null || list.isEmpty()) {
return new DeviceTreeBean("0", "-1", "设备目录"); // 空列表时显示总数为0
return new DeviceTreeBean("0", "-1", "装备目录总数0");
} }
// 1. 创建 id -> node 映射 // 1. 创建 id -> node 映射
@ -152,19 +158,21 @@ public class MaDevInfoServiceImpl implements MaDevInfoService {
// 如果父节点不存在挂到虚拟根 // 如果父节点不存在挂到虚拟根
parentNode = virtualRoot; parentNode = virtualRoot;
} }
if (StringUtils.isEmpty(parentNode.getChildren())) { if (parentNode.getChildren() == null) {
parentNode.setChildren(new ArrayList<>()); parentNode.setChildren(new ArrayList<>());
} }
parentNode.getChildren().add(node); 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 (virtualRoot.getChildren() != null && !virtualRoot.getChildren().isEmpty()) {
if (StringUtils.isEmpty(root.getChildren())) { if (root.getChildren() == null) {
root.setChildren(new ArrayList<>()); root.setChildren(new ArrayList<>());
} }
root.getChildren().addAll(virtualRoot.getChildren()); root.getChildren().addAll(virtualRoot.getChildren());
} }
return root; return root;
} }

View File

@ -241,6 +241,9 @@
mt.parent_id as pId mt.parent_id as pId
FROM ma_type mt FROM ma_type mt
WHERE mt.level != '7' WHERE mt.level != '7'
<if test="name != null and name != ''">
AND mt.type_name LIKE CONCAT('%', #{name}, '%')
</if>
</select> </select>
<select id="deviceCount" resultType="com.bonus.material.devchange.domain.DeviceCountBean"> <select id="deviceCount" resultType="com.bonus.material.devchange.domain.DeviceCountBean">
@ -502,4 +505,12 @@
</foreach> </foreach>
</select> </select>
<select id="selectTotalDeviceCount" resultType="java.lang.Integer">
SELECT COUNT( t.type_id)
FROM ma_dev_info d
JOIN ma_type t ON d.type_id = t.type_id
</select>
</mapper> </mapper>