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 2fdc7cb..024b45b 100644 --- a/Backend/Views/DeviceManage/Index.cshtml +++ b/Backend/Views/DeviceManage/Index.cshtml @@ -607,7 +607,7 @@