diff --git a/Backend/Controllers/DeviceManageController.cs b/Backend/Controllers/DeviceManageController.cs index 6240ac4..2f9aca4 100644 --- a/Backend/Controllers/DeviceManageController.cs +++ b/Backend/Controllers/DeviceManageController.cs @@ -200,9 +200,10 @@ 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, new { - building_tag = post.building_tag, + + 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, @@ -269,7 +270,7 @@ namespace Backend.Controllers JOIN floor f ON d.device_floor_tag = f.full_name "; - object param = new { Deleted = 0, Device_guid = guid ,main_system_type = main_system_type , sub_system_type = sub_system_type }; + 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); @@ -333,7 +334,7 @@ namespace Backend.Controllers { List> deviceDics = new List>(); List> device_disaster_dicts = new List>(); - + PostDeviceKind postDeviceKind = new PostDeviceKind(); using (var reader = new StreamReader(post.SelectedDevicesFile.OpenReadStream())) { string content = reader.ReadToEnd(); @@ -376,6 +377,14 @@ namespace Backend.Controllers { "@created_by", myUserInfo.Userinfo_guid}, }; + postDeviceKind = new PostDeviceKind() + { + Device_building_tag = device_building_tag, + Device_system_tag = device_system_tag, + Device_floor_tag = device_floor_tag, + Device_name_tag = device_name_tag, + }; + deviceDics.Add(deviceDic); if (device.Device_disasters != null) @@ -405,6 +414,8 @@ namespace Backend.Controllers await ResetDeviceGroup(); //重新寫入設備群組 + await AddDeviceKind(postDeviceKind); + apiResult.Code = "0000"; apiResult.Msg = "修改成功"; @@ -807,7 +818,7 @@ namespace Backend.Controllers try { - var rawDatas = await backendRepository.GetAllAsync("import_niagara_tag", null,null,"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(); @@ -966,8 +977,8 @@ namespace Backend.Controllers FROM device d WHERE d.device_building_tag = @building_tag - AND d.device_system_tag = @main_system_tag - AND d.device_name_tag = @sub_system_tag + AND d.device_system_tag = @device_system_tag + AND d.device_name_tag = @device_name_tag -- AND d.floor_guid = @Floor_tag AND d.deleted = 0 ) d @@ -1028,6 +1039,70 @@ namespace Backend.Controllers return apiResult; } + + public async Task AddDeviceKind(PostDeviceKind post) + { + + string sWhere = @$"device_building_tag = @building_tag and device_system_tag = @system_tag and device_name_tag = @name_tag"; + + object param = new { building_tag = post.Device_building_tag, system_tag = post.Device_system_tag, name_tag = post.Device_name_tag }; + + var deviceKind = await backendRepository.GetOneAsync("device_kind", sWhere, param); + + if (deviceKind == null) + { + //新增 + //產生一組GUID + var guid = Guid.NewGuid(); + + //抓出點位名稱 + //var point_name = new PointName(); + + //var sql_device_normal_point = @"SELECT n.points AS device_normal_point_name FROM (SELECT * FROM device_item di WHERE di.device_item_id = @device_normal_point_guid) n"; + //point_name.Device_normal_point_name = await backendRepository.GetOneAsync(sql_device_normal_point, new { device_normal_point_guid = post.Device_normal_point_guid }); + + //var sql_device_close_point = @"SELECT c.points AS device_close_point_name FROM (SELECT * FROM device_item di WHERE di.device_item_guid = @device_close_point_guid) c"; + //point_name.Device_close_point_name = await backendRepository.GetOneAsync(sql_device_close_point, new { device_close_point_guid = post.Device_close_point_guid }); + + //var sql_device_error_point = @"SELECT e.points AS device_error_point_name FROM (SELECT * FROM device_item di WHERE di.device_item_guid = @device_error_point_guid) e"; + //point_name.Device_error_point_name = await backendRepository.GetOneAsync(sql_device_error_point, new { device_error_point_guid = post.Device_error_point_guid }); + + Dictionary deviceKindDic = new Dictionary() + { + { "@device_kind_guid", guid}, + { "@device_building_tag", post.Device_building_tag}, + { "@device_system_tag", post.Device_system_tag}, + //{ "@device_floor_tag", post.Device_floor_tag}, + { "@device_name_tag", post.Device_name_tag}, + { "@device_image", null }, + { "@device_normal_text", post.Device_normal_text}, + { "@device_normal_point_guid", post.Device_normal_point_guid}, + { "@device_normal_point_name", null}, + { "@device_normal_point_col", post.Device_normal_point_col}, + { "@device_normal_point_value", post.Device_normal_point_value}, + { "@device_normal_color", post.Device_normal_color}, + { "@device_normal_flashing", post.Device_normal_flashing}, + { "@device_close_text", post.Device_close_text}, + { "@device_close_point_guid", post.Device_close_point_guid}, + { "@device_close_point_name", null}, + { "@device_close_point_col", post.Device_close_point_col}, + { "@device_close_point_value", post.Device_close_point_value}, + { "@device_close_color", post.Device_close_color}, + { "@device_close_flashing", post.Device_close_flashing}, + { "@device_error_text", post.Device_error_text}, + { "@device_error_point_guid", post.Device_error_point_guid}, + { "@device_error_point_name", null}, + { "@device_error_point_col", post.Device_error_point_col}, + { "@device_error_point_value", post.Device_error_point_value}, + { "@device_error_color", post.Device_error_color}, + { "@device_error_flashing", post.Device_error_flashing}, + { "@device_error_independent", post.Device_error_independent}, + { "@created_by", myUserInfo.Userinfo_guid} + }; + await backendRepository.AddOneByCustomTable(deviceKindDic, "device_kind"); + } + } + /// /// 修改 設備基本資料 /// @@ -1065,14 +1140,14 @@ namespace Backend.Controllers //抓出點位名稱 var point_name = new PointName(); - var sql_device_normal_point = @"SELECT n.points AS device_normal_point_name FROM (SELECT * FROM device_item di WHERE di.device_item_guid = @device_normal_point_guid) n"; - point_name.Device_normal_point_name = await backendRepository.GetOneAsync(sql_device_normal_point, new { device_normal_point_guid = post.Device_normal_point_guid }); + var sql_device_normal_point = @"SELECT n.points AS device_normal_point_name FROM (SELECT * FROM device_item di WHERE di.id = @device_normal_point_id) n"; + point_name.Device_normal_point_name = await backendRepository.GetOneAsync(sql_device_normal_point, new { device_normal_point_id = post.Device_normal_point_guid }); - var sql_device_close_point = @"SELECT c.points AS device_close_point_name FROM (SELECT * FROM device_item di WHERE di.device_item_guid = @device_close_point_guid) c"; - point_name.Device_close_point_name = await backendRepository.GetOneAsync(sql_device_close_point, new { device_close_point_guid = post.Device_close_point_guid }); + var sql_device_close_point = @"SELECT c.points AS device_close_point_name FROM (SELECT * FROM device_item di WHERE di.id = @device_close_point_id) c"; + point_name.Device_close_point_name = await backendRepository.GetOneAsync(sql_device_close_point, new { device_close_point_id = post.Device_close_point_guid }); - var sql_device_error_point = @"SELECT e.points AS device_error_point_name FROM (SELECT * FROM device_item di WHERE di.device_item_guid = @device_error_point_guid) e"; - point_name.Device_error_point_name = await backendRepository.GetOneAsync(sql_device_error_point, new { device_error_point_guid = post.Device_error_point_guid }); + var sql_device_error_point = @"SELECT e.points AS device_error_point_name FROM (SELECT * FROM device_item di WHERE di.id = @device_error_point_id) e"; + point_name.Device_error_point_name = await backendRepository.GetOneAsync(sql_device_error_point, new { device_error_point_id = post.Device_error_point_guid }); Dictionary deviceKindDic = new Dictionary() { @@ -1122,23 +1197,23 @@ namespace Backend.Controllers } #region 新增至派送資料表 - List fileInfos = new List(); - if (post.Device_image_file != null) - { - var split = post.Device_image_file.FileName.Split("."); - var fileName = guid + "." + split[split.Length - 1]; + //List fileInfos = new List(); + //if (post.Device_image_file != null) + //{ + // var split = post.Device_image_file.FileName.Split("."); + // var fileName = guid + "." + split[split.Length - 1]; - var fullPath = Path.Combine(deviceKindFileSaveAsPath, fileName); + // var fullPath = Path.Combine(deviceKindFileSaveAsPath, fileName); - Repository.Models.FileInfo fileInfo = new Repository.Models.FileInfo(); - fileInfo.Folder = "device_icon"; - fileInfo.OriginalFileName = null; - fileInfo.FileName = fileName; - fileInfo.File = fullPath; + // Repository.Models.FileInfo fileInfo = new Repository.Models.FileInfo(); + // fileInfo.Folder = "device_icon"; + // fileInfo.OriginalFileName = null; + // fileInfo.FileName = fileName; + // fileInfo.File = fullPath; - fileInfos.Add(fileInfo); - await backendRepository.ManualInsertFileBackgroundServiceTask("", "", "device_kind", fileInfos); - } + // fileInfos.Add(fileInfo); + // await backendRepository.ManualInsertFileBackgroundServiceTask("", "", "device_kind", fileInfos); + //} #endregion apiResult.Code = "0000"; @@ -1163,14 +1238,14 @@ namespace Backend.Controllers //抓出點位名稱 var point_name = new PointName(); - var sql_device_normal_point = @"SELECT n.points AS device_normal_point_name FROM (SELECT * FROM device_item di WHERE di.device_item_guid = @device_normal_point_guid) n"; - point_name.Device_normal_point_name = await backendRepository.GetOneAsync(sql_device_normal_point, new { device_normal_point_guid = post.Device_normal_point_guid }); + var sql_device_normal_point = @"SELECT n.points AS device_normal_point_name FROM (SELECT * FROM device_item di WHERE di.id = @device_normal_point_id) n"; + point_name.Device_normal_point_name = await backendRepository.GetOneAsync(sql_device_normal_point, new { device_normal_point_id = post.Device_normal_point_guid }); - var sql_device_close_point = @"SELECT c.points AS device_close_point_name FROM (SELECT * FROM device_item di WHERE di.device_item_guid = @device_close_point_guid) c"; - point_name.Device_close_point_name = await backendRepository.GetOneAsync(sql_device_close_point, new { device_close_point_guid = post.Device_close_point_guid }); + var sql_device_close_point = @"SELECT c.points AS device_close_point_name FROM (SELECT * FROM device_item di WHERE di.id = @device_close_point_id) c"; + point_name.Device_close_point_name = await backendRepository.GetOneAsync(sql_device_close_point, new { device_close_point_id = post.Device_close_point_guid }); - var sql_device_error_point = @"SELECT e.points AS device_error_point_name FROM (SELECT * FROM device_item di WHERE di.device_item_guid = @device_error_point_guid) e"; - point_name.Device_error_point_name = await backendRepository.GetOneAsync(sql_device_error_point, new { device_error_point_guid = post.Device_error_point_guid }); + var sql_device_error_point = @"SELECT e.points AS device_error_point_name FROM (SELECT * FROM device_item di WHERE di.id = @device_error_point_id) e"; + point_name.Device_error_point_name = await backendRepository.GetOneAsync(sql_device_error_point, new { device_error_point_id = post.Device_error_point_guid }); Dictionary deviceKindDic = new Dictionary() { @@ -1220,23 +1295,23 @@ namespace Backend.Controllers } #region 新增至派送資料表 - List fileInfos = new List(); - if (post.Device_image_file != null) - { - var split = post.Device_image_file.FileName.Split("."); - var fileName = image_guid + "." + split[split.Length - 1]; + //List fileInfos = new List(); + //if (post.Device_image_file != null) + //{ + // var split = post.Device_image_file.FileName.Split("."); + // var fileName = image_guid + "." + split[split.Length - 1]; - var fullPath = Path.Combine(deviceKindFileSaveAsPath, fileName); + // var fullPath = Path.Combine(deviceKindFileSaveAsPath, fileName); - Repository.Models.FileInfo fileInfo = new Repository.Models.FileInfo(); - fileInfo.Folder = "device_icon"; - fileInfo.OriginalFileName = deviceKind.Device_image; - fileInfo.FileName = fileName; - fileInfo.File = fullPath; + // Repository.Models.FileInfo fileInfo = new Repository.Models.FileInfo(); + // fileInfo.Folder = "device_icon"; + // fileInfo.OriginalFileName = deviceKind.Device_image; + // fileInfo.FileName = fileName; + // fileInfo.File = fullPath; - fileInfos.Add(fileInfo); - await backendRepository.ManualInsertFileBackgroundServiceTask("", "", "device_kind", fileInfos); - } + // fileInfos.Add(fileInfo); + // await backendRepository.ManualInsertFileBackgroundServiceTask("", "", "device_kind", fileInfos); + //} #endregion apiResult.Code = "0000"; @@ -1321,7 +1396,7 @@ namespace Backend.Controllers deviceGroupsDics.Add(deviceGroupDic); } - + #endregion } @@ -1390,7 +1465,7 @@ namespace Backend.Controllers { string sWhere = "device_master_guid = @Device_master_guid"; - object param = new {Device_master_guid = guid }; + object param = new { Device_master_guid = guid }; var deviceMaster = await backendRepository.GetOneAsync("device_master", sWhere, param); @@ -1442,7 +1517,7 @@ namespace Backend.Controllers } string temp_device_master_number = null; - if (!string.IsNullOrEmpty( post.Device_building_tag) && !string.IsNullOrEmpty(post.Device_name_tag)) + if (!string.IsNullOrEmpty(post.Device_building_tag) && !string.IsNullOrEmpty(post.Device_name_tag)) { temp_device_master_number = post.Device_building_tag + "_" + post.Device_name_tag; } @@ -1585,7 +1660,7 @@ namespace Backend.Controllers try { - string sWhere = "deleted = 0 AND sub_system_tag = @Sub_system_tag"; + string sWhere = "deleted = 0 AND device_name_tag = @Sub_system_tag"; object param = new { Sub_system_tag = sub_system_tag }; diff --git a/Backend/Views/BuildMenu/Index.cshtml b/Backend/Views/BuildMenu/Index.cshtml index 55f2e9c..625704e 100644 --- a/Backend/Views/BuildMenu/Index.cshtml +++ b/Backend/Views/BuildMenu/Index.cshtml @@ -175,8 +175,8 @@ -
-
+
+
@@ -263,7 +263,13 @@
- + + +
+
+ @@ -294,7 +300,7 @@
-
+
@@ -973,7 +979,7 @@ $(drawingParent).find('[id^=build_menu_icon_click_url_width_height_modal_div]').hide(); $(drawingParent).find('[id^=build_menu_planimetric_floor_modal_div]').hide(); $(drawingParent).find('[id^=build_menu_systemurl_modal_div]').hide(); - + $(drawingParent).find('[id^=build_menu_planimetric_modal_div]').show(); if ($(value).val() == 2) { $(drawingParent).find('[id^=planimetric_click]').attr("disabled", false); $(drawingParent).find('[id^=build_menu_systemurl_modal_div]').show(); @@ -992,6 +998,8 @@ $(drawingParent).find('[id^=build_menu_blankurl_modal_div]').show(); } else if ($(value).val() == 3) { $(drawingParent).find('[id^=planimetric_click]').prop("checked", false).attr("disabled", true); + } else { + $(drawingParent).find('[id^=build_menu_planimetric_modal_div]').hide(); } }) diff --git a/Backend/Views/DeviceManage/Index.cshtml b/Backend/Views/DeviceManage/Index.cshtml index 73243f6..2b97f38 100644 --- a/Backend/Views/DeviceManage/Index.cshtml +++ b/Backend/Views/DeviceManage/Index.cshtml @@ -1494,10 +1494,10 @@ "url": "/DeviceManage/DeviceKindTableList", "type": "POST", "data": function (d) { - 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 : ""; + 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.Floor_tag = selected_floor_tag ? selected_floor_tag : ""; }, "dataSrc": function (rel) { if (rel.code == "9999") { @@ -1574,9 +1574,9 @@ $("#device_close_point_name_modal").append($("