From b146283d1343e923e57bc6f779068862bbb53ffa Mon Sep 17 00:00:00 2001 From: GiteaAdmin Date: Fri, 3 Mar 2023 18:35:58 +0800 Subject: [PATCH] =?UTF-8?q?=20wsp=20forge=20=E5=8F=96=E5=BE=97=20db=5Fid?= =?UTF-8?q?=20update=20=E5=88=B0=20device=5Fnode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/Controllers/DeviceImportController.cs | 20 +++++++++---------- Backend/Controllers/MybaseController.cs | 3 ++- Backend/Models/Device.cs | 13 ++++++++++++ Backend/wwwroot/forgeDemo.html | 1 + Backend/wwwroot/js/forge/ForgeDemo.js | 6 ++++-- 5 files changed, 30 insertions(+), 13 deletions(-) diff --git a/Backend/Controllers/DeviceImportController.cs b/Backend/Controllers/DeviceImportController.cs index 48174fc..5e534a4 100644 --- a/Backend/Controllers/DeviceImportController.cs +++ b/Backend/Controllers/DeviceImportController.cs @@ -779,7 +779,7 @@ namespace Backend.Controllers Logger.LogError("【" + controllerName + "/" + actionName + "】" + "【ERROR:forge匯入不存在device設備】" + idfc.device_number); continue; } - + if (device_guid.ToString() != device_guid_record) { device_guid_record = device_guid.ToString(); @@ -792,18 +792,18 @@ namespace Backend.Controllers await backendRepository.UpdateOneByCustomTable(deviceForLight, "device", $@" device_guid = '{device_guid}'"); } - //燈具 Dictionary device = new Dictionary(); device.Add("@device_node_guid", Guid.NewGuid()); device.Add("@deleted", 0); device.Add("@device_guid", device_guid); - device.Add("@device_node_coordinate_3d", idfc.device_coordinate_3d); - device.Add("@forge_dbid", idfc.forge_dbid); + device.Add("@device_node_coordinate_3d", (idfc.node == null) ? idfc.device_coordinate_3d: idfc.node.device_coordinate_3d); + device.Add("@forge_dbid", (idfc.node == null) ? idfc.forge_dbid: idfc.node.forge_dbid); + device.Add("@device_number", (idfc.node == null) ? idfc.device_number : idfc.node.device_number); device.Add("@priority", node_priority); device.Add("@created_by", myUserInfo.Userinfo_guid); device.Add("@created_at", DateTime.Now); - node_priority++; + node_priority++; await backendRepository.AddOneByCustomTableReturnId(device, "device_node", false); } else @@ -815,9 +815,10 @@ namespace Backend.Controllers device.Add("@room_name", idfc.room_name); device.Add("@updated_at", DateTime.Now); await backendRepository.UpdateOneByCustomTable(device, "device", $@" device_number = '{idfc.device_number}'"); - } - //更新device資料表 room_dbid 欄位 - string sql = @" + } + } + //更新device資料表 room_dbid 欄位 + string sql = @" SET SQL_SAFE_UPDATES = 0; UPDATE device AS de, @@ -827,8 +828,7 @@ namespace Backend.Controllers ) AS re SET de.room_dbid = re.room_id WHERE de.room_name = re.room_name;"; - await backendRepository.ExecuteSql(sql); - } + await backendRepository.ExecuteSql(sql); } apiResult.Code = "0000"; apiResult.Msg = "編輯成功"; diff --git a/Backend/Controllers/MybaseController.cs b/Backend/Controllers/MybaseController.cs index d155cb1..f75c4e0 100644 --- a/Backend/Controllers/MybaseController.cs +++ b/Backend/Controllers/MybaseController.cs @@ -95,7 +95,8 @@ namespace Backend.Controllers { "@created_by", myUserInfo.Userinfo_guid} }; - if (actionName != "CompareData" && controllerName != "NiagaraDataSynchronize") //skip the log + if ((actionName != "CompareData" && controllerName != "NiagaraDataSynchronize") && + (actionName != "ImportDevForCor" && controllerName != "DeviceImport")) //skip the log backendRepository.InsertOperatorLog(operatorLog, "operation_back_log"); //operatorLogRepository.Add(operatorLog, properties); diff --git a/Backend/Models/Device.cs b/Backend/Models/Device.cs index 8bf91bd..004d98a 100644 --- a/Backend/Models/Device.cs +++ b/Backend/Models/Device.cs @@ -265,6 +265,19 @@ namespace Backend.Models } public class ImportDevForCoo + { + public string device_number { get; set; } + public string? device_coordinate_3d { get; set; } + public int forge_dbid { get; set; } + public string room_name { get; set; } + + /// + /// 燈具放在子類別 node 中 + /// + public device_node? node { get; set; } +} + + public class device_node { public string device_number { get; set; } public string device_coordinate_3d { get; set; } diff --git a/Backend/wwwroot/forgeDemo.html b/Backend/wwwroot/forgeDemo.html index cf42e23..e9cec4b 100644 --- a/Backend/wwwroot/forgeDemo.html +++ b/Backend/wwwroot/forgeDemo.html @@ -414,6 +414,7 @@ } function ImportDevForCor() {//callback = null + console.log(tagIdDevList) var url = "/DeviceImport/ImportDevForCor"; $.ajax({ diff --git a/Backend/wwwroot/js/forge/ForgeDemo.js b/Backend/wwwroot/js/forge/ForgeDemo.js index 58a503f..9f44759 100644 --- a/Backend/wwwroot/js/forge/ForgeDemo.js +++ b/Backend/wwwroot/js/forge/ForgeDemo.js @@ -300,7 +300,8 @@ function onDocumentLoadSuccess(doc) { { device_number: item.displayValue, device_coordinate_3d: '{ "x": ' + (position.x).toFixed(2) + ', "y": ' + (position.y).toFixed(2) + ', "z": ' + (position.z).toFixed(2) + ' }', - forge_dbid: e.dbId, room_name: "" + forge_dbid: e.dbId, room_name: "", + node: null }); } @@ -353,7 +354,8 @@ function onDocumentLoadSuccess(doc) { device_number: item.displayValue, device_coordinate_3d: '{ "x": ' + (position.x).toFixed(2) + ', "y": ' + (position.y).toFixed(2) + ', "z": ' + (position.z).toFixed(2) + ' }', forge_dbid: e.dbId, - room_name: "" + room_name: "", + node: null }) } }