[WebApi]歷史資料更版
This commit is contained in:
parent
7c9866d54e
commit
8dd6c4c4c3
@ -51,17 +51,42 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
apiResult.Code = "5000";
|
apiResult.Code = "5000";
|
||||||
return BadRequest(apiResult);
|
return BadRequest(apiResult);
|
||||||
}
|
}
|
||||||
else if (string.IsNullOrEmpty(fd.building_tag))
|
List<HistoryDBMainSub> dbsub = new List<HistoryDBMainSub>();
|
||||||
|
string sWhere = @$"where c.account = @account";
|
||||||
|
var is_Binding = await backendRepository.GetOneAsync<string>("select system_value from variable where system_type = 'AuthPageBindingSubsystem' and system_key = 'is_Binding' and deleted = 0");
|
||||||
|
if (is_Binding == "0")
|
||||||
{
|
{
|
||||||
apiResult.Code = "0002";
|
sWhere = string.Empty;
|
||||||
apiResult.Msg = "必須選擇東別";
|
|
||||||
return apiResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var dbsub = await frontendRepository.GetAllAsync<HistoryDBMainSub>(
|
if (string.IsNullOrEmpty(fd.building_tag))
|
||||||
@$"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,
|
{
|
||||||
|
dbsub = await frontendRepository.GetAllAsync<HistoryDBMainSub>(
|
||||||
|
@$"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, bm.priority,
|
||||||
|
dk.device_normal_color, dk.device_close_color, dk.device_error_color,dk.device_normal_flashing, dk.device_close_flashing, dk.device_error_flashing,
|
||||||
|
dk.device_normal_text, dk.device_close_text, dk.device_error_text,dk.device_normal_point_name, dk.device_close_point_name, dk.device_error_point_name,
|
||||||
|
dk.device_normal_point_value, dk.device_close_point_value, dk.device_error_point_value
|
||||||
|
-- di.full_name as device_item_name, di.points as device_item_points, di.unit as device_item_unit, di.is_show_riserDiagram as device_item_is_show_riserDiagram,
|
||||||
|
-- di.is_controll as device_item_is_controll, di.is_bool as device_item_is_bool, di.is_link as device_item_is_link
|
||||||
|
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
|
||||||
|
join device d on v1.system_value = d.device_system_tag and v2.system_value = d.device_name_tag and d.deleted = 0
|
||||||
|
left join device_kind dk on v1.system_value = dk.device_system_tag and v2.system_value = dk.device_name_tag
|
||||||
|
-- left join device_item di on v2.system_value = di.device_name_tag and v1.system_value = di.device_system_tag and di.deleted = 0
|
||||||
|
join (
|
||||||
|
select distinct main_system_tag, sub_system_tag, priority from building_menu where is_link = 1
|
||||||
|
) as bm on v2.system_value = bm.sub_system_tag and v1.system_value = bm.main_system_tag
|
||||||
|
{sWhere}
|
||||||
|
order by v2.system_priority, bm.priority", new { @account = myUser.account, @sub_system_type = sub_system_type, @main_system_type = main_system_type });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dbsub = await frontendRepository.GetAllAsync<HistoryDBMainSub>(
|
||||||
|
@$"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, bm.priority,
|
||||||
dk.device_normal_color, dk.device_close_color, dk.device_error_color,dk.device_normal_flashing, dk.device_close_flashing, dk.device_error_flashing,
|
dk.device_normal_color, dk.device_close_color, dk.device_error_color,dk.device_normal_flashing, dk.device_close_flashing, dk.device_error_flashing,
|
||||||
dk.device_normal_text, dk.device_close_text, dk.device_error_text,dk.device_normal_point_name, dk.device_close_point_name, dk.device_error_point_name,
|
dk.device_normal_text, dk.device_close_text, dk.device_error_text,dk.device_normal_point_name, dk.device_close_point_name, dk.device_error_point_name,
|
||||||
dk.device_normal_point_value, dk.device_close_point_value, dk.device_error_point_value
|
dk.device_normal_point_value, dk.device_close_point_value, dk.device_error_point_value
|
||||||
@ -76,10 +101,11 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
left join device_kind dk on v1.system_value = dk.device_system_tag and v2.system_value = dk.device_name_tag and dk.device_building_tag = @building_tag
|
left join device_kind dk on v1.system_value = dk.device_system_tag and v2.system_value = dk.device_name_tag and dk.device_building_tag = @building_tag
|
||||||
-- left join device_item di on v2.system_value = di.device_name_tag and v1.system_value = di.device_system_tag and di.deleted = 0
|
-- left join device_item di on v2.system_value = di.device_name_tag and v1.system_value = di.device_system_tag and di.deleted = 0
|
||||||
join (
|
join (
|
||||||
select distinct main_system_tag, sub_system_tag from building_menu where building_tag = @building_tag and is_link = 1
|
select distinct main_system_tag, sub_system_tag, priority from building_menu where building_tag = @building_tag and is_link = 1
|
||||||
) as bm on v2.system_value = bm.sub_system_tag and v1.system_value = bm.main_system_tag
|
) as bm on v2.system_value = bm.sub_system_tag and v1.system_value = bm.main_system_tag
|
||||||
where c.account = @account
|
{sWhere}
|
||||||
order by v2.system_priority", new { @account = myUser.account, @sub_system_type = sub_system_type, @main_system_type = main_system_type, @building_tag = fd.building_tag });
|
order by v2.system_priority, bm.priority", new { @account = myUser.account, @sub_system_type = sub_system_type, @main_system_type = main_system_type, @building_tag = fd.building_tag });
|
||||||
|
}
|
||||||
var mains = dbsub.GroupBy(a => a.main_system_tag).ToList();
|
var mains = dbsub.GroupBy(a => a.main_system_tag).ToList();
|
||||||
apiResult.Data = new History_MainSubBuildFloor();
|
apiResult.Data = new History_MainSubBuildFloor();
|
||||||
apiResult.Data.history_Main_Systems = new List<History_Main_system>();
|
apiResult.Data.history_Main_Systems = new List<History_Main_system>();
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -263,19 +263,94 @@ namespace FrontendWebApi.Models
|
|||||||
public string End_timestamp { get; set; }
|
public string End_timestamp { get; set; }
|
||||||
public List<HistoryItem> HistoryItems { get; set; }
|
public List<HistoryItem> HistoryItems { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class HistoryItem
|
public class HistoryItem
|
||||||
{
|
{
|
||||||
public string Device_number_point { get; set; }
|
public string Device_number_point { get; set; }
|
||||||
public string Device_number { get; set; }
|
public string Device_number { get; set; }
|
||||||
public string Unit { get; set; }
|
public string Unit { get; set; }
|
||||||
}
|
}
|
||||||
|
public class GetHistoryBuildingDevice
|
||||||
|
{
|
||||||
|
public string building_tag { get; set; }
|
||||||
|
public string building_name { get; set; }
|
||||||
|
public string device_guid { get; set; }
|
||||||
|
|
||||||
|
public string device_number { get; set; }
|
||||||
|
public string device_name { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
public class HistoryBuildingDevice
|
||||||
|
{
|
||||||
|
public string building_tag { get; set; }
|
||||||
|
public string building_name { get; set; }
|
||||||
|
public List<HistoryDevice> device_list { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
public class HistoryDevice
|
||||||
|
{
|
||||||
|
public string device_guid { get; set; }
|
||||||
|
|
||||||
|
public string device_number { get; set; }
|
||||||
|
public string device_name { get; set; }
|
||||||
|
}
|
||||||
|
public class PostHistoryDataFilter
|
||||||
|
{
|
||||||
|
public int Type { get; set; }
|
||||||
|
|
||||||
|
public List<string> Building_tag_list { get; set; }
|
||||||
|
public string Start_date { get; set; }
|
||||||
|
public string End_date { get; set; }
|
||||||
|
public string Start_time { get; set; }
|
||||||
|
public string End_time { get; set; }
|
||||||
|
public List<string> Device_list { get; set; }
|
||||||
|
public List<string> Points { get; set; }
|
||||||
|
public int PageNumber { get; set; }
|
||||||
|
}
|
||||||
|
public class PageResultT<T>
|
||||||
|
{
|
||||||
|
public IEnumerable<T> Items { get; set; }
|
||||||
|
public int PageNumber { get; set; }
|
||||||
|
public int PageSize { get; set; }
|
||||||
|
public int TotalItems { get; set; }
|
||||||
|
public int TotalPages => (int)Math.Ceiling((double)TotalItems / PageSize);
|
||||||
|
public double ElapsedTime { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
public class HistoryFavorite
|
||||||
|
{
|
||||||
|
public string favorite_guid { get; set; }
|
||||||
|
public int deleted { get; set; }
|
||||||
|
|
||||||
|
public string favorite_name { get; set; }
|
||||||
|
public string userinfo_guid { get; set; }
|
||||||
|
|
||||||
|
public int type { get; set; }
|
||||||
|
public string device_name_tag { get; set; }
|
||||||
|
|
||||||
|
public List<string> device_list { get; set; } = new List<string>();
|
||||||
|
public List<string> Points { get; set; } = new List<string>();
|
||||||
|
|
||||||
|
public string created_at { get; set; }
|
||||||
|
|
||||||
|
public string updated_at { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
public class HistoryFavoriteDetail
|
||||||
|
{
|
||||||
|
public string favorite_guid { get; set; }
|
||||||
|
public string key { get; set; }
|
||||||
|
|
||||||
|
public string value { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public class DeviceItemInfo
|
public class DeviceItemInfo
|
||||||
{
|
{
|
||||||
public string Building_name { get; set; }
|
public string Building_name { get; set; }
|
||||||
public string Main_system_name { get; set; }
|
public string Main_system_name { get; set; }
|
||||||
public string Sub_system_name { get; set; }
|
public string Sub_system_name { get; set; }
|
||||||
|
public string Device_building_tag { get; set; }
|
||||||
|
|
||||||
public string Device_number { get; set; }
|
public string Device_number { get; set; }
|
||||||
public string Device_name { get; set; }
|
public string Device_name { get; set; }
|
||||||
public string Item_name { get; set; }
|
public string Item_name { get; set; }
|
||||||
|
@ -52,6 +52,7 @@ namespace FrontendWebApi.Models
|
|||||||
public string System_type { get; set; }
|
public string System_type { get; set; }
|
||||||
public string System_key { get; set; }
|
public string System_key { get; set; }
|
||||||
public string system_value { get; set; }
|
public string system_value { get; set; }
|
||||||
|
public int? system_priority { get; set; }
|
||||||
public int? system_parent_id { get; set; }
|
public int? system_parent_id { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user