From 23485396df571a795ad1eaa897d9463dc46d86b4 Mon Sep 17 00:00:00 2001 From: dev02 Date: Mon, 28 Aug 2023 09:53:35 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B0=8F=E9=A1=9Edeviceitem,=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=96=B0=E5=A2=9E=E5=B0=8F=E9=A1=9E=E5=95=8F=E9=A1=8C?= =?UTF-8?q?,=20=E4=BF=AE=E6=94=B9=E6=96=B0=E5=A2=9E=E6=A8=93=E5=B1=A4?= =?UTF-8?q?=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/Controllers/BuildInfoController.cs | 2 +- .../Controllers/SystemCategoryController.cs | 60 ++++++++----------- 2 files changed, 25 insertions(+), 37 deletions(-) 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 = "新增成功";