Browse Source

设备类型名

fly 2 years ago
parent
commit
364d7b5f71
1 changed files with 9 additions and 2 deletions
  1. 9 2
      Service/DeviceService.cs

+ 9 - 2
Service/DeviceService.cs

@@ -158,6 +158,7 @@ namespace WingDeviceService.Service
                 departmentName = department?.OrganizationName ?? string.Empty;
             }
             //是否在线 todo
+            var deviceTypeModel = await _deviceInfoDBServiceProxy.FindDictionaryByCodeAsync(deviceDb.DeviceType);
             var result = new DeviceExtendInfoDTO()
             {
                 DepartmentName = departmentName,
@@ -174,7 +175,8 @@ namespace WingDeviceService.Service
                 SDKSoftwareVersion = deviceDb.SDKSoftwareVersion,
                 OrganizationCode = deviceDb.OrganizationCode,
                 DepartmentCode = deviceDb.DepartmentCode,
-                ShortCode = deviceDb.ShortCode
+                ShortCode = deviceDb.ShortCode,
+                DeviceTypeName = deviceTypeModel.Value
             };
             return result;
         }
@@ -772,12 +774,17 @@ namespace WingDeviceService.Service
                 var organizationDirectors = await _userServiceProxy.FindUserListByUserCodesAsync(organizationDirectorCodes);
                 var deviceCodes = deviceInfoDOList.Select(x => x.DeviceCode).ToList();
                 var deviceTokens = await _authenticationService.GetTokenWithClientIdsAsync(new GetTokenWithClientIdsRequest { ClientIds = deviceCodes });
+                var deviceTypeList = await _deviceInfoDBServiceProxy.FindDictionaryItemsAsync(new FindDictionaryItemsDBRequest { DictionaryType = (int)DictionaryTypeEnum.DeviceType });
                 foreach (var dto in deviceInfoDOList)
                 {
                     var device = dto.MappingTo<DeviceExtendInfoDTO>();
                     device.IsOnline = deviceTokens.FirstOrDefault(x => x.ClientId == dto.DeviceCode)?.IsOnline ?? false;
                     device.DepartmentName = organizations.FirstOrDefault(x => x.OrganizationCode == dto.DepartmentCode)?.OrganizationName;
-
+                    device.DeviceTypeName = deviceTypeList.FirstOrDefault(t => t.DictionaryCode == device.DeviceType)?.Value;
+                    if (string.IsNullOrWhiteSpace(device.DeviceTypeName))
+                    {
+                        device.DeviceTypeName = device.DeviceType;
+                    }
                     var organization = organizations.FirstOrDefault(x => x.OrganizationCode == dto.OrganizationCode);
                     if (organization != null)
                     {