diff --git a/Frontend/_historyData.html b/Frontend/_historyData.html
index 1f56b5b..4f8e54e 100644
--- a/Frontend/_historyData.html
+++ b/Frontend/_historyData.html
@@ -43,10 +43,8 @@
-
@@ -77,7 +75,6 @@
\ No newline at end of file
diff --git a/FrontendWebApi/ApiControllers/HistoryController.cs b/FrontendWebApi/ApiControllers/HistoryController.cs
index 9daf30a..904eb13 100644
--- a/FrontendWebApi/ApiControllers/HistoryController.cs
+++ b/FrontendWebApi/ApiControllers/HistoryController.cs
@@ -165,12 +165,14 @@ namespace FrontendWebApi.ApiControllers
try
{
var dbsub = await frontendRepository.GetAllAsync
(
- @$"select distinct v1.system_key main_name, v1.system_value main_system_tag, v2.system_key sub_name, v2.system_value sub_system_tag, v1.system_priority, v2.system_priority
+ @$"select distinct v1.system_key main_name, v1.system_value main_system_tag, v2.system_key sub_name, v2.system_value sub_system_tag, v1.system_priority, v2.system_priority,
+ d.device_number, d.full_name as device_full_name, d.device_serial_tag
from role_auth a
join auth_page b on a.AuthCode = b.AuthCode
join userinfo c on c.role_guid = a.role_guid
join variable v2 on b.ShowView = v2.id and v2.system_type = @sub_system_type
join variable v1 on v1.id = v2.system_parent_id and v1.system_type = @main_system_type
+ left join device d on v1.system_value = d.device_system_tag and v2.system_value = d.device_name_tag and d.deleted = 0
where c.account = @account
order by v1.system_priority, v2.system_priority", new { @account = myUser.account, @sub_system_type = sub_system_type, @main_system_type = main_system_type });
var dbbuilding = await frontendRepository.GetAllAsync(
@@ -189,21 +191,76 @@ namespace FrontendWebApi.ApiControllers
History_Main_system history_Main_System = new History_Main_system();
history_Main_System.main_system_tag = main.Select(a => a.main_system_tag).FirstOrDefault();
history_Main_System.full_name = main.Select(a => a.main_name).FirstOrDefault();
- history_Main_System.History_Sub_systems = new List();
- var subs = dbsub.Where(x => x.main_system_tag == main.Select(m => m.main_system_tag).FirstOrDefault()).ToList();
+ var subs = dbsub.Where(x => x.main_system_tag == main.Select(m => m.main_system_tag).FirstOrDefault()).GroupBy(x => x.sub_system_tag).ToList();
+ history_Main_System.History_Sub_systems = subs.Count > 0 ? new List() : null;
foreach (var sub in subs)
{
History_Sub_system history_Sub_System = new History_Sub_system();
- history_Sub_System.full_name = sub.sub_name;
- history_Sub_System.sub_system_tag = sub.sub_system_tag;
+ history_Sub_System.full_name = sub.Select(x => x.sub_name).FirstOrDefault();
+ history_Sub_System.sub_system_tag = sub.Select(x => x.sub_system_tag).FirstOrDefault();
+
+
+ var devices = dbsub.Where(x => x.main_system_tag == main.Select(m => m.main_system_tag).FirstOrDefault() && x.sub_system_tag == sub.Select(x => x.sub_system_tag).FirstOrDefault() && x.device_number != null).ToList();
+ history_Sub_System.device = devices.Count > 0 ? new List() : null;
+ foreach (var d in devices)
+ {
+ Device device = new Device();
+ device.device_number = d.device_number;
+ device.device_serial_tag = d.device_serial_tag;
+ device.full_name = d.device_full_name;
+ history_Sub_System.device.Add(device);
+ }
+
history_Main_System.History_Sub_systems.Add(history_Sub_System);
}
apiResult.Data.history_Main_Systems.Add(history_Main_System);
}
apiResult.Data.history_Builds = dbbuilding;
apiResult.Code = "0000";
+ }
+ catch (Exception exception)
+ {
+ apiResult.Code = "9999";
+ apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
+ Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
+ return Ok(apiResult);
+ }
+ return Ok(apiResult);
+ }
+ ///
+ /// 即時趨勢條件過濾條件面板
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("api/History/GetDevPoi")]
+ public async Task>>> GetDevPoi([FromBody] HistoryFind hf)
+ {
+ ApiResult> apiResult = new ApiResult>(jwt_str);
+ if (!jwtlife)
+ {
+ apiResult.Code = "5000";
+ return BadRequest(apiResult);
+ }
+ else if (string.IsNullOrEmpty(hf.device_number))
+ {
+ apiResult.Code = "0002";
+ apiResult.Msg = "必須選擇設備";
+ return apiResult;
+ }
+
+ try
+ {
+ List deviceItems = new List();
+ var main_system_value = hf.device_number.Split('_')[2];
+ var sub_system_value = hf.device_number.Split('_')[3];
+ var sqlString = $@"select * from device_item where deleted = 0 and device_system_tag = @main_system_value and device_name_tag = @sub_system_value";
+ deviceItems = await frontendRepository.GetAllAsync(sqlString, new { @main_system_value = main_system_value, @sub_system_value = sub_system_value });
+
+ apiResult.Data = deviceItems;
+ apiResult.Code = "0000";
}
catch (Exception exception)
{
diff --git a/FrontendWebApi/Models/Build.cs b/FrontendWebApi/Models/Build.cs
index 4efb89b..31d0f9f 100644
--- a/FrontendWebApi/Models/Build.cs
+++ b/FrontendWebApi/Models/Build.cs
@@ -161,6 +161,7 @@ namespace FrontendWebApi.Models
public string device_floor_tag { get; set; }
public string device_name_tag { get; set; }
public string device_serial_tag { get; set; }
+ public string device_last_name { get; set; }
public string device_system_category_layer3 { get; set; }
public string device_ip { get; set; }
public string device_port { get; set; }
diff --git a/FrontendWebApi/Models/HistoryClass.cs b/FrontendWebApi/Models/HistoryClass.cs
index 048b3c6..8a2a10a 100644
--- a/FrontendWebApi/Models/HistoryClass.cs
+++ b/FrontendWebApi/Models/HistoryClass.cs
@@ -59,6 +59,9 @@ namespace FrontendWebApi.Models
public string main_name { get; set; }
public string sub_system_tag { get; set; }
public string sub_name { get; set; }
+ public string device_number { get; set; }
+ public string device_full_name { get; set; }
+ public string device_serial_tag { get; set; }
public string device_normal_color { get; set; }
public string device_close_color { get; set; }
public string device_error_color { get; set; }
@@ -79,6 +82,7 @@ namespace FrontendWebApi.Models
public class HistoryFind
{
public string building_tag { get; set; }
+ public string device_number { get; set; }
}
public class BuildingFloorRawData
{
@@ -118,6 +122,7 @@ namespace FrontendWebApi.Models
public string device_normal_color { get; set; }
public string device_close_color { get; set; }
public string device_error_color { get; set; }
+ public List device { get; set; }
public string device_normal_flashing { get; set; }
public string device_close_flashing { get; set; }
public string device_error_flashing { get; set; }