|
|
@@ -351,6 +351,46 @@ public class SmsbDepartmentServiceImpl extends ServiceImpl<SmsbDepartmentMapper
|
|
|
return deviceDepartmentDto;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public DeviceDepartmentSimpleDto listDepartmentDeviceSimple(DeviceDepartmentCmd departmentCmd) {
|
|
|
+ // 1. 获取对应部门树
|
|
|
+ SmsbDepartmentCO department = this.queryDepartment(departmentCmd.getTenant() , departmentCmd.getOrg());
|
|
|
+ DeviceDepartmentSimpleDto deviceDepartmentSimpleDto = new DeviceDepartmentSimpleDto();
|
|
|
+ // 2. 获取部门-List<设备id> map
|
|
|
+ if(StringUtils.isEmpty(departmentCmd.getOrg()) && department.getId() == null){
|
|
|
+ // 根节点为租户,该租户下未被分配的设备
|
|
|
+ deviceDepartmentSimpleDto.setDevices(deviceService.ListDeviceUnboundSimple(departmentCmd.getTenant() , departmentCmd.getActivate()));
|
|
|
+ }else {
|
|
|
+ // 根节点为部门
|
|
|
+ deviceDepartmentSimpleDto.setDevices(deviceService.ListDeviceBindSimple(department.getPath() , departmentCmd.getActivate()));
|
|
|
+ }
|
|
|
+ deviceDepartmentSimpleDto.setChildren(childRecurrenceHandleSimple(department.getChildren() , departmentCmd.getActivate()));
|
|
|
+ // 3. 组装设备信息并返回
|
|
|
+ deviceDepartmentSimpleDto.setTenant(department.getTenant());
|
|
|
+ return deviceDepartmentSimpleDto;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 简易参数
|
|
|
+ * @param children
|
|
|
+ * @param activate
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<DeviceDepartmentSimpleDto> childRecurrenceHandleSimple(List<SmsbDepartmentCO> children , Boolean activate){
|
|
|
+ List<DeviceDepartmentSimpleDto> childrenList = Lists.newArrayList();
|
|
|
+ if(!CollectionUtils.isEmpty(children)){
|
|
|
+ children.forEach(child->{
|
|
|
+ DeviceDepartmentSimpleDto deviceDepartmentSimpleDto = new DeviceDepartmentSimpleDto();
|
|
|
+ BeanUtils.copyProperties(child , deviceDepartmentSimpleDto);
|
|
|
+ deviceDepartmentSimpleDto.setDevices(deviceService.ListDeviceBind(child.getPath() , activate));
|
|
|
+ deviceDepartmentSimpleDto.setChildren(childRecurrenceHandleSimple(child.getChildren() , activate));
|
|
|
+ childrenList.add(deviceDepartmentSimpleDto);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return childrenList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private List<DeviceDepartmentDto> chaildRecurrenceHandle(List<SmsbDepartmentCO> children , Boolean activate){
|
|
|
List<DeviceDepartmentDto> childrenList = Lists.newArrayList();
|
|
|
if(!CollectionUtils.isEmpty(children)){
|