diff --git a/Backend/Controllers/BuildInfoController.cs b/Backend/Controllers/BuildInfoController.cs index f06e9bb..5b57556 100644 --- a/Backend/Controllers/BuildInfoController.cs +++ b/Backend/Controllers/BuildInfoController.cs @@ -495,7 +495,7 @@ namespace Backend.Controllers try { - var check = await backendRepository.GetOneAsync($@"select floor_guid from variable where floor_guid != {post.Floor_guid} and building_tag = '{post.Building_tag}' and + var check = await backendRepository.GetOneAsync($@"select floor_guid from floor where floor_guid != '{post.Floor_guid ?? ""}' and building_tag = '{post.Building_tag}' and full_name = '{post.Full_name}' and deleted = 0;"); if (!string.IsNullOrEmpty(check)) { diff --git a/Backend/Controllers/SystemCategoryController.cs b/Backend/Controllers/SystemCategoryController.cs index a45c5e1..0030edd 100644 --- a/Backend/Controllers/SystemCategoryController.cs +++ b/Backend/Controllers/SystemCategoryController.cs @@ -317,7 +317,7 @@ namespace Backend.Controllers try { - var check = await backendRepository.GetOneAsync($"select id from variable where id != {post.id} and system_type = '{sub_system_type}' and system_value = '{post.system_value}' and deleted = 0;"); + var check = await backendRepository.GetOneAsync($"select id from variable where id != {post.id} and system_type = '{sub_system_type}' and system_value = '{post.system_value}' and system_parent_id = {post.system_parent_id} and deleted = 0;"); if (!string.IsNullOrEmpty(check)) { apiResult.Code = "9998"; @@ -331,19 +331,8 @@ namespace Backend.Controllers var systemSub = await backendRepository.GetOneAsync("variable", sWhere, param); - sWhere = @$"deleted = 0 AND system_type = @sub_system_type AND system_value = @system_value"; - param = new { sub_system_type = sub_system_type, system_value = post.system_value }; - var subV = await backendRepository.GetOneAsync("variable", sWhere, param); - if (systemSub == null) - { - if (subV != null) - { - apiResult.Code = "0001"; - apiResult.Msg = "不可新增相同的系統小類代號。"; - return apiResult; - } - + { //新增 //產生一組GUID //獲取最新的大類 @@ -370,13 +359,6 @@ namespace Backend.Controllers } else { - if (subV != null) - { - apiResult.Code = "0001"; - apiResult.Msg = "不可修改成相同的系統小類代號。"; - return apiResult; - } - Dictionary systemSubDic = new Dictionary() { @@ -546,23 +528,29 @@ namespace Backend.Controllers if (device_Item.id == 0) { - - //新增 - Dictionary Device_itemDic = new Dictionary() + var building = await backendRepository.GetAllAsync("select building_tag from building where deleted = 0"); + foreach (var b in building) { - { "@device_system_tag", main_tag}, - { "@device_name_tag", sub_tag}, - { "@full_name", device_Item.full_name}, - { "@points", device_Item.points}, - { "@unit", device_Item.unit}, - { "@is_show", device_Item.is_show}, - { "@is_show_riserDiagram", device_Item.is_show_riserDiagram}, - { "@is_controll", device_Item.is_controll}, - { "@is_bool", device_Item.is_bool}, - { "@is_show_history", device_Item.is_show_history}, - { "@created_by", myUserInfo.Userinfo_guid}, - }; - await backendRepository.AddOneByCustomTable(Device_itemDic, "device_item"); + //新增 + Dictionary Device_itemDic = new Dictionary() + { + { "@device_system_tag", main_tag}, + { "@device_name_tag", sub_tag}, + { "@full_name", device_Item.full_name}, + { "@points", device_Item.points}, + { "@unit", device_Item.unit}, + { "@is_show", device_Item.is_show}, + { "@is_show_riserDiagram", device_Item.is_show_riserDiagram}, + { "@is_controll", device_Item.is_controll}, + { "@is_bool", device_Item.is_bool}, + { "@is_show_history", device_Item.is_show_history}, + { "@created_by", myUserInfo.Userinfo_guid}, + { "@device_building_tag", b}, + { "@is_link", "1"}, + }; + await backendRepository.AddOneByCustomTable(Device_itemDic, "device_item"); + + } apiResult.Code = "0000"; apiResult.Msg = "新增成功";