From 17b9f2485b569756e18624ab6af215e40bebcf3c Mon Sep 17 00:00:00 2001 From: dev02 Date: Thu, 6 Jul 2023 11:42:43 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=BE=8C=E5=8F=B0]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=A8=93=E5=B1=A4=E9=A1=AF=E7=A4=BA=E5=9C=96=E6=AA=94=E5=95=8F?= =?UTF-8?q?=E9=A1=8C,=20=E4=BF=AE=E6=94=B9=E5=88=87=E6=8F=9B=E6=A3=9F?= =?UTF-8?q?=E5=88=A5=E5=95=8F=E9=A1=8C,=20=E9=97=9C=E9=96=89=E9=BB=9E?= =?UTF-8?q?=E4=BD=8D=E6=96=B0=E5=A2=9E,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/Controllers/BuildInfoController.cs | 2 +- .../Controllers/SystemCategoryController.cs | 39 +++++++++------ Backend/Views/BuildInfo/Index.cshtml | 48 +++++++++++++++---- Backend/Views/SystemCategory/Index.cshtml | 14 +++--- .../Views/SystemCategory/_SystemSub.cshtml | 4 +- .../bfa367b0-4867-4d0e-b821-bbc127b79be1.svg | 0 BackendWorkerService/Program.cs | 12 ++--- 7 files changed, 80 insertions(+), 39 deletions(-) create mode 100644 Backend/wwwroot/upload/floor_map/bfa367b0-4867-4d0e-b821-bbc127b79be1.svg diff --git a/Backend/Controllers/BuildInfoController.cs b/Backend/Controllers/BuildInfoController.cs index c03565a..71176cd 100644 --- a/Backend/Controllers/BuildInfoController.cs +++ b/Backend/Controllers/BuildInfoController.cs @@ -468,7 +468,7 @@ namespace Backend.Controllers if (!string.IsNullOrEmpty(buildFloor.InitMapName)) { - buildFloor.MapUrl = "/upload/floor_map/" + buildFloor.Floor_guid + ".svg"; + buildFloor.MapUrl = baseURL + "upload/floor_map/" + buildFloor.Floor_map_name + ".svg"; } apiResult.Code = "0000"; diff --git a/Backend/Controllers/SystemCategoryController.cs b/Backend/Controllers/SystemCategoryController.cs index 9246230..e063514 100644 --- a/Backend/Controllers/SystemCategoryController.cs +++ b/Backend/Controllers/SystemCategoryController.cs @@ -531,24 +531,33 @@ namespace Backend.Controllers if (device_Item.id == 0) { - + var building = await backendRepository.GetAllAsync("select building_tag from building where deleted = 0;"); + var parentPath = await backendRepository.GetOneAsync("select system_value from variable where deleted = 0 and system_type = 'obixStatus'"); + List> device_iteDic = new List>(); //新增 - Dictionary Device_itemDic = new Dictionary() + 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}, + { "@device_building_tag", b}, + { "@parent_path", parentPath}, + { "@is_link", 1}, + { "@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_iteDic.Add(Device_itemDic); + } + await backendRepository.AddMutiByCustomTable(device_iteDic, "device_item"); apiResult.Code = "0000"; apiResult.Msg = "新增成功"; } diff --git a/Backend/Views/BuildInfo/Index.cshtml b/Backend/Views/BuildInfo/Index.cshtml index a498f85..6876afe 100644 --- a/Backend/Views/BuildInfo/Index.cshtml +++ b/Backend/Views/BuildInfo/Index.cshtml @@ -108,6 +108,9 @@ //樓層設定上方選單 $("#BuildList").empty(); $.each(data, function (key, value) { + if (value.building_tag.includes("$3")) + value.building_tag = value.building_tag.replace("$3", ""); + $("#BuildList").append(``); @*if (key == 0) { selected_build_guid_top_name = value.full_name; @@ -454,7 +457,7 @@ var file = input3Dfile; var formData = new FormData(); formData.append('fileToUpload', file); - formData.append('bucketKey', "zo4zguyalhjrl5o81va39pkdgr82wamq-202305_bim");//forge上傳平台-資料夾 + formData.append('bucketKey', "zo4zguyalhjrl5o81va39pkdgr82wamq-202305_bim");//forge上傳平台-資料夾 $.ajax({ url: '/api/forge/oss/objects', @@ -530,7 +533,10 @@ var url = "/BuildInfo/EditBuildInfo"; var formData = new FormData(); - formData.append("building_tag", selected_build_guid); + if ($.isNumeric(selected_build_guid[0])) + formData.append("building_tag", "$3" + selected_build_guid); + else + formData.append("building_tag", selected_build_guid); formData.append("Full_name", $('#build_name_modal').val()); formData.append("Ip_address", $('#ip_address_modal').val()); formData.append("Ip_port", $('#ip_port_modal').val()); @@ -682,7 +688,10 @@ "url": "/BuildInfo/BuildFloorList", "type": "POST", "data": function (d) { - d.build_tag = selected_build_guid_top; + if ($.isNumeric(selected_build_guid_top[0])) + d.build_tag = selected_build_guid_top = "$3" + selected_build_guid_top; + else + d.build_tag = selected_build_guid_top; }, "dataSrc": function (rel) { if (rel.code == "9999") { @@ -762,11 +771,14 @@ return; } else { + $('#floor-modal').modal(); + $("#BuildName").html(selected_build_guid_top_name); $("#floor_name_modal").val(rel.data.full_name); - @*$("#map_file_preview_modal").attr("data-original", rel.data.mapUrl);*@ - - $('#floor-modal').modal(); + if (rel.data.mapUrl) + loadURLToInputFiled(rel.data.mapUrl, rel.data.initMapName + ".svg"); + else + $('#floor_map_file_modal')[0].value = ""; } }, 'json'); }); @@ -962,7 +974,7 @@ function translateObject(urn) { $("#forgeViewer").empty(); //if (node == null) node = $('#appBuckets').jstree(true).get_selected(true)[0]; - var bucketKey = "zo4zguyalhjrl5o81va39pkdgr82wamq-202305_bim";//forge上傳平台-資料夾 + var bucketKey = "zo4zguyalhjrl5o81va39pkdgr82wamq-202305_bim";//forge上傳平台-資料夾 var objectKey = urn; jQuery.post({ @@ -977,6 +989,26 @@ } //#endregion - + function loadURLToInputFiled(url, filesName){ + getImgURL(url, (imgBlob)=>{ + // Load img blob to input + // WIP: UTF8 character error + let fileName = filesName + let file = new File([imgBlob], fileName,{type:"image/svg+xml", lastModified:new Date().getTime()}, 'utf-8'); + let container = new DataTransfer(); + container.items.add(file); + $('#floor_map_file_modal')[0].files = container.files; + }) + } + // xmlHTTP return blob respond + function getImgURL(url, callback){ + var xhr = new XMLHttpRequest(); + xhr.onload = function() { + callback(xhr.response); + }; + xhr.open('GET', url); + xhr.responseType = 'blob'; + xhr.send(); + } } \ No newline at end of file diff --git a/Backend/Views/SystemCategory/Index.cshtml b/Backend/Views/SystemCategory/Index.cshtml index 85c5184..2c59b31 100644 --- a/Backend/Views/SystemCategory/Index.cshtml +++ b/Backend/Views/SystemCategory/Index.cshtml @@ -594,13 +594,13 @@ //#endregion //#region 新增設備項目 - function Adddevice_item() { - //SubDeviceItemValidate.resetForm(); - selected_system_device_item_guid = ""; - $("#device-sub-modal .modal-title").html("設備項目 - 新增"); - $("#device-item-sub-form").trigger("reset"); - $("#device-sub-modal").modal(); - } + //function Adddevice_item() { + // //SubDeviceItemValidate.resetForm(); + // selected_system_device_item_guid = ""; + // $("#device-sub-modal .modal-title").html("設備項目 - 新增"); + // $("#device-item-sub-form").trigger("reset"); + // $("#device-sub-modal").modal(); + //} //#endregion $('#system_sub_table').on("click", "tbody>tr", function () { diff --git a/Backend/Views/SystemCategory/_SystemSub.cshtml b/Backend/Views/SystemCategory/_SystemSub.cshtml index 6b8d240..93ac7a9 100644 --- a/Backend/Views/SystemCategory/_SystemSub.cshtml +++ b/Backend/Views/SystemCategory/_SystemSub.cshtml @@ -32,11 +32,11 @@