From 5dacdc0f58f1086765dc86802dbb2f534a680603 Mon Sep 17 00:00:00 2001 From: dev02 Date: Thu, 17 Nov 2022 18:25:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=AC=84=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/DeviceManageController.cs | 28 +++++++++++++++---- .../ApiControllers/MyBaseApiController.cs | 1 + FrontendWebApi/Models/Device.cs | 1 + 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/FrontendWebApi/ApiControllers/DeviceManageController.cs b/FrontendWebApi/ApiControllers/DeviceManageController.cs index 5161106..8832166 100644 --- a/FrontendWebApi/ApiControllers/DeviceManageController.cs +++ b/FrontendWebApi/ApiControllers/DeviceManageController.cs @@ -1,6 +1,7 @@ using FrontendWebApi.Models; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -22,6 +23,7 @@ namespace FrontendWebApi.ApiControllers { private readonly IBackendRepository backendRepository; private readonly IFrontendRepository frontendRepository; + private string deviceKindFilePath = "upload/device_icon/"; public DeviceManageController ( @@ -194,19 +196,35 @@ namespace FrontendWebApi.ApiControllers foreach (var f in fl) { List dl = new List(); - sqlString = $@"select d.device_guid, d.full_name, d.device_coordinate, dk.device_image, d.device_number, - dk.device_normal_point_id, dk.device_normal_point_guid, dk.device_normal_point_col, dk.device_normal_point_value, dk.device_normal_flashing, - dk.device_close_point_id, dk.device_close_point_guid, dk.device_close_point_col, dk.device_close_point_value, dk.device_close_flashing, - dk.device_error_point_id, dk.device_error_point_guid, dk.device_error_point_col, dk.device_error_point_value, dk.device_error_flashing + sqlString = $@"select d.device_guid, d.full_name, d.device_coordinate, dk.device_image, d.device_number, CONCAT('{baseURL}', '{deviceKindFilePath}', dk.device_image) AS device_image_url, + dk.device_normal_point_id, dk.device_normal_point_guid, dk.device_normal_point_col, dk.device_normal_point_value, dk.device_normal_flashing, + dk.device_close_point_id, dk.device_close_point_guid, dk.device_close_point_col, dk.device_close_point_value, dk.device_close_flashing, + dk.device_error_point_id, dk.device_error_point_guid, dk.device_error_point_col, dk.device_error_point_value, dk.device_error_flashing from device d left join device_kind dk on d.device_building_tag = dk.device_building_tag and d.device_system_tag = dk.device_system_tag and d.device_name_tag = dk.device_name_tag where d.deleted = 0 and d.device_name_tag = @sub_system_tag and d.device_building_tag = @building_tag and d.device_floor_tag = @floor_tag"; var dlParam = new { @sub_system_tag = fd.sub_system_tag, @building_tag = fd.building_tag, @floor_tag = f.full_name }; dl = await backendRepository.GetAllAsync(sqlString, dlParam); + + foreach(var d in dl) + { + var sql_node = $@"SELECT + dn.device_node_guid, + dn.device_guid, + dn.full_name AS Device_node_full_name, + dn.device_node_coordinate, + dn.priority + FROM device_node dn + WHERE dn.deleted = 0 AND dn.device_guid = @device_guid + ORDER BY dn.priority ASC"; + + d.Device_nodes = await backendRepository.GetAllAsync(sql_node, new { device_guid = d.device_guid }); + } f.device_list = dl; } - + + apiResult.Data = fl; apiResult.Code = "0000"; } diff --git a/FrontendWebApi/ApiControllers/MyBaseApiController.cs b/FrontendWebApi/ApiControllers/MyBaseApiController.cs index 1a6b7fc..8821f51 100644 --- a/FrontendWebApi/ApiControllers/MyBaseApiController.cs +++ b/FrontendWebApi/ApiControllers/MyBaseApiController.cs @@ -25,6 +25,7 @@ namespace FrontendWebApi.ApiControllers private ILogger _logger; protected ILogger Logger => _logger ?? (_logger = HttpContext?.RequestServices.GetService>()); private IJwtHelpers jwt => HttpContext?.RequestServices.GetService(); + public string baseURL => HttpContext?.Request.Scheme + "://" + HttpContext?.Request.Host + "/"; public MyBaseApiController() { } protected JwtGet myUser; diff --git a/FrontendWebApi/Models/Device.cs b/FrontendWebApi/Models/Device.cs index f671d5c..a7200ad 100644 --- a/FrontendWebApi/Models/Device.cs +++ b/FrontendWebApi/Models/Device.cs @@ -65,6 +65,7 @@ namespace FrontendWebApi.Models public string device_error_point_col { get; set; } public string device_error_point_value { get; set; } public string device_error_flashing { get; set; } + public List Device_nodes { get; set; } } public class DeviceBaseInfo