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);