diff --git a/FrontendWebApi/ApiControllers/DeviceManageController.cs b/FrontendWebApi/ApiControllers/DeviceManageController.cs index 67b7dbd..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"; } @@ -266,10 +284,11 @@ namespace FrontendWebApi.ApiControllers ApiResult> apiResult = new ApiResult>(); try { - string sql = $@"select orr.work_type, orr.fix_do, ui.full_name as work_person_name, orr.finish_time, orr.created_at + string sql = $@"select orr.work_type, orr.fix_do, ui.full_name as work_person_name, orr.finish_time, orr.created_at, dn.device_node_guid, dn.full_name as device_node_name from device d join operation_record orr on d.device_number = orr.fix_do_code and orr.deleted = 0 left join userinfo ui on orr.work_person_id = ui.userinfo_guid + left join device_node dn on d.device_guid = dn.device_guid where d.deleted = 0 and d.device_guid = @device_guid"; object param = new { @device_guid = device_guid }; var device = await backendRepository.GetAllAsync(sql, param); 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 d35bbec..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 @@ -110,5 +111,7 @@ namespace FrontendWebApi.Models return Convert.ToDateTime(finish_time).ToString("yyyy-MM-dd HH:mm:ss"); } } //結束時間 + public string device_node_guid { get; set; } + public string device_node_name { get; set; } } }