From 96e5f430fdd577a7efcba5219067be0e6282efdb Mon Sep 17 00:00:00 2001 From: liulu Date: Mon, 4 Nov 2024 15:49:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=86=E7=A0=81=E6=9C=BA=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/sunyard/chsm/dto/DeviceDTO.java | 4 ++++ .../java/com/sunyard/chsm/dto/DeviceGroupDTO.java | 5 +++++ .../chsm/service/impl/DeviceGroupServiceImpl.java | 13 ++++++++++--- .../chsm/service/impl/DeviceServiceImpl.java | 1 + 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/chsm-web-manage/src/main/java/com/sunyard/chsm/dto/DeviceDTO.java b/chsm-web-manage/src/main/java/com/sunyard/chsm/dto/DeviceDTO.java index e80dd4f..a4480c1 100644 --- a/chsm-web-manage/src/main/java/com/sunyard/chsm/dto/DeviceDTO.java +++ b/chsm-web-manage/src/main/java/com/sunyard/chsm/dto/DeviceDTO.java @@ -122,6 +122,10 @@ public abstract class DeviceDTO { * 访问凭证 */ private String accessCredentials; + /** + * 设备是否已经分组 + */ + private Boolean isGrouped; /** * 备注 */ diff --git a/chsm-web-manage/src/main/java/com/sunyard/chsm/dto/DeviceGroupDTO.java b/chsm-web-manage/src/main/java/com/sunyard/chsm/dto/DeviceGroupDTO.java index 2158d30..abfab9a 100644 --- a/chsm-web-manage/src/main/java/com/sunyard/chsm/dto/DeviceGroupDTO.java +++ b/chsm-web-manage/src/main/java/com/sunyard/chsm/dto/DeviceGroupDTO.java @@ -1,6 +1,7 @@ package com.sunyard.chsm.dto; import com.sunyard.chsm.model.PageQuery; +import com.sunyard.chsm.model.entity.Device; import lombok.Data; import lombok.EqualsAndHashCode; @@ -31,6 +32,10 @@ public abstract class DeviceGroupDTO { * 设备组名称 */ private String name; + /** + * 已选设备列表 + */ + private List checkedDevices; /** * 密码设备 */ diff --git a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/DeviceGroupServiceImpl.java b/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/DeviceGroupServiceImpl.java index 502298d..cc0b786 100644 --- a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/DeviceGroupServiceImpl.java +++ b/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/DeviceGroupServiceImpl.java @@ -67,10 +67,17 @@ public class DeviceGroupServiceImpl implements DeviceGroupService { DeviceGroupDTO.DGView view = new DeviceGroupDTO.DGView(); BeanUtils.copyProperties(it, view); - Map deviceNames = groupMap.getOrDefault(it.getId(), Collections.emptyList()) + Map deviceNames = groupMap.getOrDefault(it.getId(), Collections.emptyList()) .stream() - .collect(Collectors.toMap(it2 -> String.valueOf(it2.getId()), Device::getName)); - + .collect(Collectors.toMap(Device::getId, Device::getName)); + List deviceList = deviceNames.entrySet() + .stream().map(entry -> { + Device d = new Device(); + d.setId(entry.getKey()); + d.setName(entry.getValue()); + return d; + }).collect(Collectors.toList()); + view.setCheckedDevices(deviceList); view.setDeviceNames(String.join(",", deviceNames.values())); return view; }) diff --git a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/DeviceServiceImpl.java b/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/DeviceServiceImpl.java index a87ccc0..84e520c 100644 --- a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/DeviceServiceImpl.java +++ b/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/DeviceServiceImpl.java @@ -56,6 +56,7 @@ public class DeviceServiceImpl implements DeviceService { .map(it -> { DeviceDTO.DeviceView view = new DeviceDTO.DeviceView(); BeanUtils.copyProperties(it, view); + view.setIsGrouped(it.getGroupId() > 0); Optional.ofNullable(ManufacturerEnum.of(it.getManufacturer())) .map(ManufacturerEnum::getName) .ifPresent(view::setManufacturerText);