diff --git a/Backend/Controllers/DeviceManageController.cs b/Backend/Controllers/DeviceManageController.cs
index 64e9bed..c810839 100644
--- a/Backend/Controllers/DeviceManageController.cs
+++ b/Backend/Controllers/DeviceManageController.cs
@@ -1653,18 +1653,18 @@ namespace Backend.Controllers
///
/// 取得子系統的device item
///
- ///
+ ///
///
[HttpPost]
- public async Task>> GetDeviceItem(string sub_system_tag)
+ public async Task>> GetDeviceItem(DeviceItemInput input)
{
ApiResult> apiResult = new ApiResult>();
try
{
- string sWhere = "deleted = 0 AND device_name_tag = @Sub_system_tag";
+ string sWhere = "deleted = 0 AND device_name_tag = @Sub_system_tag and device_building_tag = @device_building_tag";
- object param = new { Sub_system_tag = sub_system_tag };
+ object param = new { Sub_system_tag = input.sub_system_tag, device_building_tag = input.building_tag };
var deviceItems = await backendRepository.GetAllAsync("device_item", sWhere, param);
diff --git a/Backend/Controllers/SystemCategoryController.cs b/Backend/Controllers/SystemCategoryController.cs
index 2509b47..641391b 100644
--- a/Backend/Controllers/SystemCategoryController.cs
+++ b/Backend/Controllers/SystemCategoryController.cs
@@ -581,14 +581,14 @@ namespace Backend.Controllers
ApiResult> apiResult = new ApiResult>();
try
{
-
+ var building_tag = await backendRepository.GetOneAsync($@"select system_value from variable where system_type = 'project_name' and deleted = 0");
var sql = @"SELECT di.*
FROM device_item di
JOIN variable sv ON di.device_name_tag = sv.system_value
JOIN variable mv ON sv.system_parent_id = mv.id AND di.device_system_tag = mv.system_value
- WHERE sv.id = @id AND di.deleted = @Deleted";
+ WHERE sv.id = @id AND di.deleted = @Deleted and di.device_building_tag = @building_tag";
- object param = new { Deleted = 0, id = id };
+ object param = new { Deleted = 0, id = id, building_tag = building_tag.Split("/")[1] };
var systemSubs = await backendRepository.GetAllAsync(sql, param);
diff --git a/Backend/Models/SystemCategory.cs b/Backend/Models/SystemCategory.cs
index d661db9..ba54301 100644
--- a/Backend/Models/SystemCategory.cs
+++ b/Backend/Models/SystemCategory.cs
@@ -78,4 +78,10 @@ namespace Backend.Models
public string guid { get; set; }
public string subguid { get; set; }
}
+
+ public class DeviceItemInput
+ {
+ public string sub_system_tag { get; set; }
+ public string building_tag { get; set; }
+ }
}
diff --git a/Backend/Views/DeviceManage/Index.cshtml b/Backend/Views/DeviceManage/Index.cshtml
index cb23ecf..f066639 100644
--- a/Backend/Views/DeviceManage/Index.cshtml
+++ b/Backend/Views/DeviceManage/Index.cshtml
@@ -1551,7 +1551,8 @@
var selectedSub_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : "";
var url = "/DeviceManage/GetDeviceItem";
var send_data = {
- sub_system_tag: selectedSub_system_tag
+ sub_system_tag: selectedSub_system_tag,
+ building_tag: selected_device_building_tag
}
$.post(url, send_data, function (rel) {
diff --git a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs
index 193cf9e..674fef8 100644
--- a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs
+++ b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs
@@ -471,7 +471,7 @@ namespace Repository.BackendRepository.Implement
isBool = 1;
}
sb.Append($@"insert device_item(deleted, points, is_show, is_show_riserDiagram, is_controll, is_bool, is_show_history, is_link,
- device_system_tag, device_name_tag, full_name, parent_path, created_at, updated_at)
+ device_system_tag, device_name_tag, device_building_tag, full_name, parent_path, created_at, updated_at)
VALUES (0, '" +
data.device_point_name + "', 1, 0, " +
isControll + "," +
@@ -480,6 +480,7 @@ namespace Repository.BackendRepository.Implement
", 1, '" +
data.device_system_tag + "', '" +
data.device_name_tag + "', '" +
+ data.device_building_tag + "', '" +
data.full_name + "', '" +
data.parent_path + "', " +
"now(), now());");