From 50ffddbe5564b4e2d13f3134363bad5ca9986720 Mon Sep 17 00:00:00 2001 From: dev01 Date: Sat, 22 Oct 2022 13:14:13 +0800 Subject: [PATCH] =?UTF-8?q?[=E8=A8=AD=E5=82=99=E7=AE=A1=E7=90=86]=20?= =?UTF-8?q?=E5=89=8D=E5=BE=8C=E7=AB=AF=20=E7=B3=BB=E7=B5=B1=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F=E9=A1=9E=E5=8F=8A=E6=A3=9F=E5=88=A5guid=20=E6=94=B9?= =?UTF-8?q?=E7=82=BAtag=20=EF=BC=8C=E8=AA=BF=E6=95=B4=E5=89=8D=E5=BE=8C?= =?UTF-8?q?=E7=AB=AF=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/Controllers/DeviceManageController.cs | 87 ++++++++++--------- Backend/Models/BuildingCollapse.cs | 10 +-- Backend/Models/Device.cs | 12 +-- Backend/Views/DeviceManage/Index.cshtml | 40 ++++----- 4 files changed, 78 insertions(+), 71 deletions(-) diff --git a/Backend/Controllers/DeviceManageController.cs b/Backend/Controllers/DeviceManageController.cs index 6d10dd5..511a74f 100644 --- a/Backend/Controllers/DeviceManageController.cs +++ b/Backend/Controllers/DeviceManageController.cs @@ -85,43 +85,43 @@ namespace Backend.Controllers "; var subSystemFloorRawDatas = await backendRepository.GetAllAsync(sub_sql); - var buildingMenu_Group_Building_guid = buildingMenuRawDatas.GroupBy(x => x.building_tag).ToList(); + var buildingMenu_Group_Building_tag = buildingMenuRawDatas.GroupBy(x => x.building_tag).ToList(); List buildingCollapses = new List(); - foreach (var buildingMenus_Building_guid in buildingMenu_Group_Building_guid) + foreach (var buildingMenus_Building_tag in buildingMenu_Group_Building_tag) { BuildingCollapse buildingCollapse = new BuildingCollapse(); - buildingCollapse.Building_guid = buildingMenus_Building_guid.Key; - buildingCollapse.Full_name = buildingMenus_Building_guid.First().bFull_name; + buildingCollapse.Building_tag = buildingMenus_Building_tag.Key; + buildingCollapse.Full_name = buildingMenus_Building_tag.First().bFull_name; buildingCollapse.Main_systems = new List(); - var buildingMenus_Group_Main_system_guid = buildingMenus_Building_guid.GroupBy(x => x.main_system_tag).ToList(); + var buildingMenus_Group_Main_system_tag = buildingMenus_Building_tag.GroupBy(x => x.main_system_tag).ToList(); - foreach (var buildingMenus_Main_system_guid in buildingMenus_Group_Main_system_guid) + foreach (var buildingMenus_Main_system_tag in buildingMenus_Group_Main_system_tag) { Main_system main_System = new Main_system(); - main_System.Main_system_guid = buildingMenus_Main_system_guid.Key; - main_System.Full_name = buildingMenus_Main_system_guid.First().mFull_name; + main_System.Main_system_tag = buildingMenus_Main_system_tag.Key; + main_System.Full_name = buildingMenus_Main_system_tag.First().mFull_name; main_System.Sub_systems = new List(); - var buildingMenus_Group_Sub_system_guid = buildingMenus_Main_system_guid.GroupBy(x => x.sub_system_tag).ToList(); + var buildingMenus_Group_Sub_system_tag = buildingMenus_Main_system_tag.GroupBy(x => x.sub_system_tag).ToList(); - foreach (var buildingMenus_Sub_system_guid in buildingMenus_Group_Sub_system_guid) + foreach (var buildingMenus_Sub_system_tag in buildingMenus_Group_Sub_system_tag) { Sub_system sub_System = new Sub_system(); - sub_System.Sub_system_guid = buildingMenus_Sub_system_guid.Key; - sub_System.Full_name = buildingMenus_Sub_system_guid.First().sFull_name; + sub_System.Sub_system_tag = buildingMenus_Sub_system_tag.Key; + sub_System.Full_name = buildingMenus_Sub_system_tag.First().sFull_name; sub_System.Floors = new List(); - var floorRawDatas = subSystemFloorRawDatas.Where(x => x.building_tag == buildingCollapse.Building_guid - && x.main_system_tag == main_System.Main_system_guid - && x.sub_system_tag == sub_System.Sub_system_guid).ToList(); + 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(); foreach (var floorRawData in floorRawDatas) { Floor floor = new Floor(); - floor.Floor_guid = floorRawData.Floor_guid; + floor.Floor_tag = floorRawData.Floor_tag; floor.Full_name = floorRawData.fFull_name; floor.InitMapName = floorRawData.InitMapName; floor.Floor_map_name = floorRawData.Floor_map_name; @@ -200,8 +200,15 @@ namespace Backend.Controllers JOIN floor f ON d.device_floor_tag = f.full_name AND d.device_building_tag = f.building_tag LEFT JOIN device_kind dk ON dk.device_building_tag = d.device_building_tag AND dk.device_system_tag = d.device_system_tag AND dk.device_name_tag = d.device_name_tag ORDER BY d.priority ASC, d.device_number ASC"; - - var devices = await backendRepository.GetAllAsync(sql, post); + + var devices = await backendRepository.GetAllAsync(sql, new { + building_tag = post.building_tag, + main_system_tag = post.device_system_tag, + sub_system_tag = post.device_name_tag, + floor_tag = post.device_floor_tag, + main_system_type = main_system_type, + sub_system_type = sub_system_type + }); var sql_node = $@"SELECT dn.device_node_guid, @@ -246,8 +253,8 @@ namespace Backend.Controllers d.*, d.full_name AS Device_full_name, b.full_name AS Building_full_name, - ms.full_name AS Main_system_full_name, - ss.full_name AS Sub_system_full_name, + mv.system_key AS Main_system_full_name, + sv.system_key AS Sub_system_full_name, f.full_name AS Floor_full_name FROM ( SELECT * @@ -256,13 +263,13 @@ namespace Backend.Controllers d.device_guid = @Device_guid AND d.deleted = @Deleted ) d - JOIN building b ON d.building_guid = b.building_guid - JOIN main_system ms ON d.main_system_guid = ms.main_system_guid - JOIN sub_system ss ON d.sub_system_guid = ss.sub_system_guid - JOIN floor f ON d.floor_guid = f.floor_guid + JOIN building b ON d.device_building_tag = b.building_tag + JOIN variable mv ON d.device_system_tag = mv.system_value AND mv.system_type = @main_system_type + JOIN variable sv ON d.device_name_tag = sv.system_value AND sv.system_type = @sub_system_type + JOIN floor f ON d.device_floor_tag = f.full_name "; - object param = new { Deleted = 0, Device_guid = guid }; + object param = new { Deleted = 0, Device_guid = guid ,main_system_type = main_system_type , sub_system_type = sub_system_type }; var device = await backendRepository.GetOneAsync(sql, param); @@ -354,10 +361,10 @@ namespace Backend.Controllers Dictionary deviceDic = new Dictionary() { { "@device_guid", guid}, - { "@building_guid", post.Building_guid}, - { "@main_system_guid", post.Main_system_guid}, - { "@sub_system_guid", post.Sub_system_guid}, - { "@floor_guid", post.Floor_guid}, + { "@building_tag", post.Building_tag}, + { "@main_system_tag", post.Main_system_tag}, + { "@sub_system_tag", post.Sub_system_tag}, + { "@floor_guid", post.Floor_tag}, { "@full_name", device_name_tag + device_serial_tag}, { "@device_building_tag", device_building_tag}, { "@device_system_tag", device_system_tag}, @@ -801,7 +808,7 @@ namespace Backend.Controllers try { - var rawDatas = await backendRepository.GetAllAsync("import_niagara_tag", "ORDER BY device_building_tag, device_system_tag, device_floor_tag, device_name_tag"); + var rawDatas = await backendRepository.GetAllAsync("import_niagara_tag", null,null,"device_building_tag, device_system_tag, device_floor_tag, device_name_tag"); var rawDatas_Group_Building_tag = rawDatas.GroupBy(x => x.Device_building_tag).ToList(); List tempFilters = new List(); @@ -962,7 +969,7 @@ namespace Backend.Controllers d.device_building_tag = @building_tag AND d.device_system_tag = @main_system_tag AND d.device_name_tag = @sub_system_tag - -- AND d.floor_guid = @Floor_guid + -- AND d.floor_guid = @Floor_tag AND d.deleted = 0 ) d GROUP BY d.device_building_tag, @@ -1256,7 +1263,7 @@ namespace Backend.Controllers CREATE TABLE `device_group` ( `id` int(11) NOT NULL, `device_disaster` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '災類', - `device_building_guid` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '設備東別guid', + `device_building_tag` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '設備東別guid', `device_floor_guid` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '設備樓層guid', `device_area_tag` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '設備區域', `device_system_category_layer2` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '系統大類device_system_tag', @@ -1268,10 +1275,10 @@ namespace Backend.Controllers await backendRepository.ExecuteSql(delete_group_sql); //更新整個device_group var insert_group_sql = @" - INSERT INTO device_group (device_disaster, device_building_guid, device_floor_guid, device_system_category_layer2, device_system_category_layer3, device_amount) + INSERT INTO device_group (device_disaster, device_building_tag, device_floor_guid, device_system_category_layer2, device_system_category_layer3, device_amount) SELECT dd.device_system_value AS device_disaster, - d.building_guid AS device_building_guid, + d.building_tag AS device_building_tag, d.floor_guid AS device_floor_guid, vv.device_system_category_layer2 AS device_system_category_layer2, d.device_system_category_layer3 AS device_system_category_layer3, @@ -1287,7 +1294,7 @@ namespace Backend.Controllers ) vv ON d.device_system_category_layer3 = vv.device_system_category_layer3 WHERE d.deleted = 0 GROUP BY dd.device_system_value, - d.building_guid, + d.building_tag, d.floor_guid, vv.device_system_category_layer2, d.device_system_category_layer3"; @@ -1305,8 +1312,8 @@ namespace Backend.Controllers { { "@id", deviceGroup.id}, { "@device_disaster", deviceGroup.device_disaster}, - { "@device_building_guid", deviceGroup.device_building_guid}, - { "@device_floor_guid", deviceGroup.device_floor_guid}, + { "@device_building_tag", deviceGroup.device_building_tag}, + { "@device_floor_guid", deviceGroup.device_floor_tag}, { "@device_system_category_layer2", deviceGroup.device_system_category_layer2}, { "@device_system_category_layer3", deviceGroup.device_system_category_layer3}, { "@device_amount", deviceGroup.device_amount}, @@ -1572,15 +1579,15 @@ namespace Backend.Controllers /// /// [HttpPost] - public async Task>> GetDeviceItem(string sub_system_guid) + public async Task>> GetDeviceItem(string sub_system_tag) { ApiResult> apiResult = new ApiResult>(); try { - string sWhere = "deleted = 0 AND sub_system_guid = @Sub_system_guid"; + string sWhere = "deleted = 0 AND sub_system_tag = @Sub_system_tag"; - object param = new { Sub_system_guid = sub_system_guid }; + object param = new { Sub_system_tag = sub_system_tag }; var deviceItems = await backendRepository.GetAllAsync("device_item", sWhere, param); diff --git a/Backend/Models/BuildingCollapse.cs b/Backend/Models/BuildingCollapse.cs index d7f17df..5627fa5 100644 --- a/Backend/Models/BuildingCollapse.cs +++ b/Backend/Models/BuildingCollapse.cs @@ -20,7 +20,7 @@ namespace Backend.Models public class BuildingCollapse : Actor { - public string Building_guid { get; set; } + public string Building_tag { get; set; } public string Full_name { get; set; } public string Ip_address { get; set; } public int Priority { get; set; } @@ -28,7 +28,7 @@ namespace Backend.Models } public class Main_system { - public string Main_system_guid { get; set; } + public string Main_system_tag { get; set; } public string Full_name { get; set; } public int Priority { get; set; } public string Code { get; set; } @@ -36,7 +36,7 @@ namespace Backend.Models } public class Sub_system { - public string Sub_system_guid { get; set; } + public string Sub_system_tag { get; set; } public string Full_name { get; set; } public int Priority { get; set; } public byte Drawing { get; set; } @@ -47,7 +47,7 @@ namespace Backend.Models } public class Floor { - public string Floor_guid { get; set; } + public string Floor_tag { get; set; } public string Full_name { get; set; } public string InitMapName { get; set; } public string Floor_map_name { get; set; } //平面圖檔名 @@ -60,7 +60,7 @@ namespace Backend.Models public string building_tag { get; set; } public string main_system_tag { get; set; } public string sub_system_tag { get; set; } - public string Floor_guid { get; set; } + public string Floor_tag { get; set; } public string fFull_name { get; set; } public string InitMapName { get; set; } public string Floor_map_name { get; set; } diff --git a/Backend/Models/Device.cs b/Backend/Models/Device.cs index 1956829..15c17f4 100644 --- a/Backend/Models/Device.cs +++ b/Backend/Models/Device.cs @@ -16,10 +16,10 @@ namespace Backend.Models public class PostDeviceInfoAdd { - public string Building_guid { get; set; } - public string Main_system_guid { get; set; } - public string Sub_system_guid { get; set; } - public string Floor_guid { get; set; } + public string Building_tag { get; set; } + public string Main_system_tag { get; set; } + public string Sub_system_tag { get; set; } + public string Floor_tag { get; set; } public List SelectedDevices { get; set; } public IFormFile SelectedDevicesFile { get; set; } } @@ -239,8 +239,8 @@ namespace Backend.Models { public int id { get; set; } public string device_disaster { get; set; } - public string device_building_guid { get; set; } - public string device_floor_guid { get; set; } + public string device_building_tag { get; set; } + public string device_floor_tag { get; set; } public string device_system_category_layer2 { get; set; } public string device_system_category_layer3 { get; set; } public int device_amount { get; set; } diff --git a/Backend/Views/DeviceManage/Index.cshtml b/Backend/Views/DeviceManage/Index.cshtml index 8c0004a..024b45b 100644 --- a/Backend/Views/DeviceManage/Index.cshtml +++ b/Backend/Views/DeviceManage/Index.cshtml @@ -747,10 +747,10 @@ "url": "/DeviceManage/DeviceTableList", "type": "POST", "data": function (d) { - d.Buliding_tag = selected_building_menu.buliding_tag ? selected_building_menu.buliding_tag : ""; - d.Main_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : ""; - d.Sub_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : ""; - d.Floor_tag = selected_floor_tag ? selected_floor_tag : ""; + d.building_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : ""; + d.device_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : ""; + d.device_name_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : ""; + d.device_floor_tag = selected_floor_tag ? selected_floor_tag : ""; }, "dataSrc": function (rel) { if (rel.code == "9999") { @@ -1050,7 +1050,7 @@ "url": "/DeviceManage/GetDeviceMasterTableList", "type": "POST", "data": function (d) { - d.Buliding_tag = selected_building_menu.buliding_tag ? selected_building_menu.buliding_tag : ""; + d.Building_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : ""; d.Main_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : ""; d.Sub_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : ""; d.Floor_tag = selected_floor_tag ? selected_floor_tag : ""; @@ -1077,11 +1077,11 @@ $("#device-master-list-btn").click(function (e) { e.preventDefault(); - var selectedBuliding_tag = selected_building_menu.buliding_tag ? selected_building_menu.buliding_tag : ""; + var selectedBuilding_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : ""; var selectedMain_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : ""; var selectedSub_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : ""; var selectedFloor_tag = selected_floor_tag ? selected_floor_tag : ""; - if (selectedBuliding_tag == '' || selectedMain_system_tag == '' || selectedSub_system_tag == '' || selectedFloor_tag == '') { + if (selectedBuilding_tag == '' || selectedMain_system_tag == '' || selectedSub_system_tag == '' || selectedFloor_tag == '') { toast_warning("請先選擇系統類別及樓層。"); return; } @@ -1494,7 +1494,7 @@ "url": "/DeviceManage/DeviceKindTableList", "type": "POST", "data": function (d) { - d.Buliding_tag = selected_building_menu.buliding_tag ? selected_building_menu.buliding_tag : ""; + d.Building_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : ""; d.Main_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : ""; d.Sub_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : ""; d.Floor_tag = selected_floor_tag ? selected_floor_tag : ""; @@ -1910,7 +1910,7 @@ html += `
  • ${sub_system.full_name} @@ -1944,14 +1944,14 @@ function ChangeFloorPanel(dom) { var selected_target = { - "buliding_tag": $(dom).attr("data-building-tag") ? $(dom).attr("data-building-tag") : "", + "building_tag": $(dom).attr("data-building-tag") ? $(dom).attr("data-building-tag") : "", "main_system_tag": $(dom).attr("data-main-system-tag") ? $(dom).attr("data-main-system-tag") : "", "sub_system_tag": $(dom).attr("data-sub-system-tag") ? $(dom).attr("data-sub-system-tag") : "", } buildingCollapses.forEach(function (building_item, building_index) { - if (building_item.buliding_tag == selected_target.buliding_tag) { - selected_building_menu.buliding_tag = building_item.buliding_tag; + if (building_item.building_tag == selected_target.building_tag) { + selected_building_menu.building_tag = building_item.building_tag; selected_building_menu.main_system = {}; building_item.main_systems.forEach(function (main_system_item, main_system_index) { @@ -1971,7 +1971,7 @@ //匯入floor panel $(".floor-panel-wrap").empty(); sub_system_item.floors.forEach(function (floor_item, floor_index) { - $(".floor-panel-wrap").append(``) + $(".floor-panel-wrap").append(``) }); } }); @@ -1990,7 +1990,7 @@ selected_floor_tag = $(dom).attr("data-floor-guid") ? $(dom).attr("data-floor-guid") : "" var current_floor = selected_building_menu.main_system.sub_system.floors.filter(function (item) { - return item.Floor_tag == selected_floor_tag + return item.floor_tag == selected_floor_tag })[0]; $.each($(".btn-floor"), function (index, item) { @@ -2522,11 +2522,11 @@ //#region 新增設備 function AddDevice() { - var selectedBuliding_tag = selected_building_menu.buliding_tag ? selected_building_menu.buliding_tag : ""; + var selectedBuilding_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : ""; var selectedMain_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : ""; var selectedSub_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : ""; var selectedFloor_tag = selected_floor_tag ? selected_floor_tag : ""; - if (selectedBuliding_tag == '' || selectedMain_system_tag == '' || selectedSub_system_tag == '' || selectedFloor_tag == '') { + if (selectedBuilding_tag == '' || selectedMain_system_tag == '' || selectedSub_system_tag == '' || selectedFloor_tag == '') { toast_warning("請先選擇系統類別及樓層。"); return; } @@ -2676,11 +2676,11 @@ //#region 設備儲存(透過新增按鈕) function SaveDeviceAdd() { - var selectedBuliding_tag = selected_building_menu.buliding_tag ? selected_building_menu.buliding_tag : ""; + var selectedBuilding_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : ""; var selectedMain_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : ""; var selectedSub_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : ""; var selectedFloor_tag = selected_floor_tag ? selected_floor_tag : ""; - if (selectedBuliding_tag == '' || selectedMain_system_tag == '' || selectedSub_system_tag == '' || selectedFloor_tag == '') + if (selectedBuilding_tag == '' || selectedMain_system_tag == '' || selectedSub_system_tag == '' || selectedFloor_tag == '') { toast_warning("請先選擇系統類別及樓層。"); return; @@ -2710,7 +2710,7 @@ var url = "/DeviceManage/SaveDeviceInfoAdd"; @*var send_data = { - Buliding_tag: selectedBuliding_tag, + Building_tag: selectedBuilding_tag, Main_system_tag: selectedMain_system_tag, Sub_system_tag: selectedSub_system_tag, Floor_tag: selectedFloor_tag, @@ -2734,7 +2734,7 @@ var formData = new FormData(); - formData.append("Buliding_tag", selectedBuliding_tag); + formData.append("Building_tag", selectedBuilding_tag); formData.append("Main_system_tag", selectedMain_system_tag); formData.append("Sub_system_tag", selectedSub_system_tag); formData.append("Floor_tag", selectedFloor_tag);