diff --git a/FrontendWebApi/ApiControllers/DeviceManageController.cs b/FrontendWebApi/ApiControllers/DeviceManageController.cs index 7e2bc64..23583ff 100644 --- a/FrontendWebApi/ApiControllers/DeviceManageController.cs +++ b/FrontendWebApi/ApiControllers/DeviceManageController.cs @@ -62,11 +62,23 @@ namespace FrontendWebApi.ApiControllers var mains = dbsub.GroupBy(a => a.main_system_tag).ToList(); apiResult.Data = new History_MainSubBuildFloor(); apiResult.Data.history_Main_Systems = new List(); + foreach (var main in mains) { 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(); + 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); }