修改系統監控list

This commit is contained in:
dev02 2022-11-17 15:57:47 +08:00
parent 978e85f857
commit 31547b2270

View File

@ -62,11 +62,23 @@ namespace FrontendWebApi.ApiControllers
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>();
foreach (var main in mains) foreach (var main in mains)
{ {
History_Main_system history_Main_System = new History_Main_system(); 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.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.full_name = main.Select(a => a.main_name).FirstOrDefault();
history_Main_System.History_Sub_systems = new List<History_Sub_system>();
var subs = dbsub.Where(x => x.main_system_tag == main.Select(m => m.main_system_tag).FirstOrDefault()).ToList();
foreach(var sub in subs)
{
History_Sub_system history_Sub_System = new History_Sub_system();
history_Sub_System.sub_system_tag = sub.sub_system_tag;
history_Sub_System.full_name = sub.sub_name;
history_Main_System.History_Sub_systems.Add(history_Sub_System);
}
apiResult.Data.history_Main_Systems.Add(history_Main_System); apiResult.Data.history_Main_Systems.Add(history_Main_System);
} }