From 9af3c041b118f7821909d9a0505868723b9413e6 Mon Sep 17 00:00:00 2001 From: "jay.chang" Date: Wed, 24 Apr 2024 14:55:45 +0800 Subject: [PATCH] =?UTF-8?q?[Backend]=E4=BF=AE=E6=AD=A3=E5=BE=8C=E5=8F=B0?= =?UTF-8?q?=E7=9B=B8=E9=97=9C=E9=A1=AF=E7=A4=BA=E6=A2=9D=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E9=9A=B1=E8=97=8F=E8=A8=AD=E5=82=99=E9=BB=9E=E4=BD=8D=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=88=AA=E9=99=A4=E6=8C=89=E9=88=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/Controllers/BuildMenuController.cs | 12 +++++------ Backend/Controllers/DeviceManageController.cs | 5 ++++- Backend/Views/DeviceManage/Index.cshtml | 21 +++++++++++++------ 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Backend/Controllers/BuildMenuController.cs b/Backend/Controllers/BuildMenuController.cs index ae51322..d635af6 100644 --- a/Backend/Controllers/BuildMenuController.cs +++ b/Backend/Controllers/BuildMenuController.cs @@ -54,7 +54,7 @@ namespace Backend.Controllers { var sqlString = @$"select v.system_value value, v.system_key name from ( - select main_system_tag from building_menu bm where bm.building_tag = @building_tag group by bm.main_system_tag + select main_system_tag from building_menu bm where bm.building_tag = @building_tag and is_link = 1 group by bm.building_tag,bm.main_system_tag ) bm join variable v on v.system_value = bm.main_system_tag AND v.system_type = @main_system_type and v.deleted = 0 ORDER BY v.system_priority ASC"; @@ -108,12 +108,12 @@ namespace Backend.Controllers List KeyValue = new List(); try { - var mainList = await backendRepository.GetAllAsync("select id from variable where system_value = @main_system_tag and system_type = @main_system_type", new { main_system_tag = post.main_system_tag, main_system_type = main_system_type}); + var mainList = await backendRepository.GetAllAsync("select id from variable where system_value = @main_system_tag and system_type = @main_system_type and deleted = 0", new { main_system_tag = post.main_system_tag, main_system_type = main_system_type}); var sqlString = @$"select sv.system_value value, sv.system_key name from variable sv left join ( - select * from building_menu bm where bm.building_tag = @building_tag + select * from building_menu bm where bm.building_tag = @building_tag and is_link = 1 ) bm on sv.system_value = bm.sub_system_tag where bm.sub_system_tag is null and sv.deleted = 0 and sv.system_parent_id in @mainList ORDER BY sv.system_priority ASC, sv.created_at DESC"; @@ -139,7 +139,7 @@ namespace Backend.Controllers ApiResult apiResult = new ApiResult(); try { - var get = await backendRepository.GetOneAsync("building_menu", $"building_tag = '{buildMenu.building_tag}' and main_system_tag = '{buildMenu.main_system_tag}' and sub_system_tag = '{buildMenu.sub_system_tag}'"); + var get = await backendRepository.GetOneAsync("building_menu", $"building_tag = '{buildMenu.building_tag}' and main_system_tag = '{buildMenu.main_system_tag}' and sub_system_tag = '{buildMenu.sub_system_tag}' and is_link = 1"); if (get == null) { var subV = await backendRepository.GetOneAsync("variable", "system_value = @sub_tag and system_type = @sub_system_type", new { sub_tag = buildMenu.sub_system_tag, sub_system_type = sub_system_type }); @@ -233,7 +233,7 @@ namespace Backend.Controllers await backendRepository.AddOneByCustomTable(dictionary, "building_menu"); - var max = await backendRepository.GetOneAsync("select Max(CONVERT(SUBSTRING(AuthCode,2,5), SIGNED)) AuthCode from auth_page ap where ap.AuthCode like 'F%'"); + var max = await backendRepository.GetOneAsync("select ifnull((select Max(CONVERT(SUBSTRING(AuthCode,2,5), SIGNED)) AuthCode from auth_page ap where ap.AuthCode like 'F%'),'0') AuthCode"); var pageSql = $@"select sv.system_key SubName, mv.system_key MainName from variable sv @@ -494,7 +494,7 @@ namespace Backend.Controllers from ( select * from sub_system_floor ssf - where ssf.building_tag = @building_tag and ssf.main_system_tag = @main_system_tag and ssf.sub_system_tag = @sub_system_tag and deleted = 0 and status = 0 + where ssf.building_tag = @building_tag and ssf.main_system_tag = @main_system_tag and ssf.sub_system_tag = @sub_system_tag and deleted = 0 and status = 0 and is_link = 1 ) sf left join floor f on sf.floor_tag = f.full_name and sf.building_tag = f.building_tag and f.deleted = 0 left join variable mv on sf.main_system_tag = mv.system_value and mv.system_type = @main_system_type and mv.deleted = 0 diff --git a/Backend/Controllers/DeviceManageController.cs b/Backend/Controllers/DeviceManageController.cs index 0511da2..ae5c713 100644 --- a/Backend/Controllers/DeviceManageController.cs +++ b/Backend/Controllers/DeviceManageController.cs @@ -129,7 +129,10 @@ namespace Backend.Controllers var floorRawDatas = subSystemFloorRawDatas.Where(x => x.building_tag == buildingCollapse.Building_tag && x.main_system_tag == main_System.Main_system_tag && x.sub_system_tag == sub_System.Sub_system_tag).ToList(); - + if (floorRawDatas.Count == 0 ) // 如果沒有相關小類樓層則不顯示 + { + continue; + } foreach (var floorRawData in floorRawDatas) { Floor floor = new Floor(); diff --git a/Backend/Views/DeviceManage/Index.cshtml b/Backend/Views/DeviceManage/Index.cshtml index dc4f689..20b8c0a 100644 --- a/Backend/Views/DeviceManage/Index.cshtml +++ b/Backend/Views/DeviceManage/Index.cshtml @@ -82,7 +82,8 @@ 設備基本資料
- 新增設備 + @*隱藏新增按鈕 + 新增設備*@
@@ -158,9 +159,9 @@ - +