[後端] 修改getsubmain

This commit is contained in:
dev02 2023-06-13 16:11:10 +08:00
parent 117b7bae3c
commit 05d7f7ea0f

View File

@ -239,9 +239,26 @@ namespace FrontendWebApi.ApiControllers
foreach (var sub in subs) foreach (var sub in subs)
{ {
History_Sub_system history_Sub_System = new History_Sub_system(); History_Sub_system history_Sub_System = new History_Sub_system();
history_Sub_System.full_name = sub.Select(x => x.sub_name).FirstOrDefault(); if (main.Select(x => x.main_system_tag).FirstOrDefault() != "S")
history_Sub_System.sub_system_tag = sub.Select(x => x.sub_system_tag).FirstOrDefault(); {
history_Sub_System.is_show_history = sub.Select(x => x.device_item_is_show_hsitory).FirstOrDefault(); 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();
history_Sub_System.is_show_history = sub.Select(x => x.device_item_is_show_hsitory).FirstOrDefault();
}
else
{
string name = sub.Select(x => x.sub_name).FirstOrDefault();
bool check = true;
if (name == "人流計數")
check = sub.Any(x => x.sub_system_tag.StartsWith(hf.building_tag));
if (check)
{
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();
history_Sub_System.is_show_history = sub.Select(x => x.device_item_is_show_hsitory).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).OrderBy(x=>x.device_full_name.Length).ThenBy(x=>x.device_full_name).ToList(); 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).OrderBy(x=>x.device_full_name.Length).ThenBy(x=>x.device_full_name).ToList();
history_Sub_System.device = devices.Count > 0 ? new List<Device>() : null; history_Sub_System.device = devices.Count > 0 ? new List<Device>() : null;