[FrontendWebApi] 系統監控 API 程序調整
This commit is contained in:
commit
bd4976a267
@ -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<DeviceLists> dl = new List<DeviceLists>();
|
||||
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<DeviceLists>(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<DeviceNode>(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<List<DeviceOpeRecord>> apiResult = new ApiResult<List<DeviceOpeRecord>>();
|
||||
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<DeviceOpeRecord>(sql, param);
|
||||
|
@ -25,6 +25,7 @@ namespace FrontendWebApi.ApiControllers
|
||||
private ILogger<T> _logger;
|
||||
protected ILogger<T> Logger => _logger ?? (_logger = HttpContext?.RequestServices.GetService<ILogger<T>>());
|
||||
private IJwtHelpers jwt => HttpContext?.RequestServices.GetService<IJwtHelpers>();
|
||||
public string baseURL => HttpContext?.Request.Scheme + "://" + HttpContext?.Request.Host + "/";
|
||||
|
||||
public MyBaseApiController() { }
|
||||
protected JwtGet myUser;
|
||||
|
@ -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<DeviceNode> 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; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user