[設備管理] 前後端 系統大小類及棟別guid 改為tag ,調整前後端程序

This commit is contained in:
dev01 2022-10-22 13:14:13 +08:00
parent ece10e2d19
commit 50ffddbe55
4 changed files with 78 additions and 71 deletions

View File

@ -85,43 +85,43 @@ namespace Backend.Controllers
"; ";
var subSystemFloorRawDatas = await backendRepository.GetAllAsync<SubSystemFloorRawData>(sub_sql); var subSystemFloorRawDatas = await backendRepository.GetAllAsync<SubSystemFloorRawData>(sub_sql);
var buildingMenu_Group_Building_guid = buildingMenuRawDatas.GroupBy(x => x.building_tag).ToList(); var buildingMenu_Group_Building_tag = buildingMenuRawDatas.GroupBy(x => x.building_tag).ToList();
List<BuildingCollapse> buildingCollapses = new List<BuildingCollapse>(); List<BuildingCollapse> buildingCollapses = new List<BuildingCollapse>();
foreach (var buildingMenus_Building_guid in buildingMenu_Group_Building_guid) foreach (var buildingMenus_Building_tag in buildingMenu_Group_Building_tag)
{ {
BuildingCollapse buildingCollapse = new BuildingCollapse(); BuildingCollapse buildingCollapse = new BuildingCollapse();
buildingCollapse.Building_guid = buildingMenus_Building_guid.Key; buildingCollapse.Building_tag = buildingMenus_Building_tag.Key;
buildingCollapse.Full_name = buildingMenus_Building_guid.First().bFull_name; buildingCollapse.Full_name = buildingMenus_Building_tag.First().bFull_name;
buildingCollapse.Main_systems = new List<Main_system>(); buildingCollapse.Main_systems = new List<Main_system>();
var buildingMenus_Group_Main_system_guid = buildingMenus_Building_guid.GroupBy(x => x.main_system_tag).ToList(); var buildingMenus_Group_Main_system_tag = buildingMenus_Building_tag.GroupBy(x => x.main_system_tag).ToList();
foreach (var buildingMenus_Main_system_guid in buildingMenus_Group_Main_system_guid) foreach (var buildingMenus_Main_system_tag in buildingMenus_Group_Main_system_tag)
{ {
Main_system main_System = new Main_system(); Main_system main_System = new Main_system();
main_System.Main_system_guid = buildingMenus_Main_system_guid.Key; main_System.Main_system_tag = buildingMenus_Main_system_tag.Key;
main_System.Full_name = buildingMenus_Main_system_guid.First().mFull_name; main_System.Full_name = buildingMenus_Main_system_tag.First().mFull_name;
main_System.Sub_systems = new List<Sub_system>(); main_System.Sub_systems = new List<Sub_system>();
var buildingMenus_Group_Sub_system_guid = buildingMenus_Main_system_guid.GroupBy(x => x.sub_system_tag).ToList(); var buildingMenus_Group_Sub_system_tag = buildingMenus_Main_system_tag.GroupBy(x => x.sub_system_tag).ToList();
foreach (var buildingMenus_Sub_system_guid in buildingMenus_Group_Sub_system_guid) foreach (var buildingMenus_Sub_system_tag in buildingMenus_Group_Sub_system_tag)
{ {
Sub_system sub_System = new Sub_system(); Sub_system sub_System = new Sub_system();
sub_System.Sub_system_guid = buildingMenus_Sub_system_guid.Key; sub_System.Sub_system_tag = buildingMenus_Sub_system_tag.Key;
sub_System.Full_name = buildingMenus_Sub_system_guid.First().sFull_name; sub_System.Full_name = buildingMenus_Sub_system_tag.First().sFull_name;
sub_System.Floors = new List<Floor>(); sub_System.Floors = new List<Floor>();
var floorRawDatas = subSystemFloorRawDatas.Where(x => x.building_tag == buildingCollapse.Building_guid var floorRawDatas = subSystemFloorRawDatas.Where(x => x.building_tag == buildingCollapse.Building_tag
&& x.main_system_tag == main_System.Main_system_guid && x.main_system_tag == main_System.Main_system_tag
&& x.sub_system_tag == sub_System.Sub_system_guid).ToList(); && x.sub_system_tag == sub_System.Sub_system_tag).ToList();
foreach (var floorRawData in floorRawDatas) foreach (var floorRawData in floorRawDatas)
{ {
Floor floor = new Floor(); Floor floor = new Floor();
floor.Floor_guid = floorRawData.Floor_guid; floor.Floor_tag = floorRawData.Floor_tag;
floor.Full_name = floorRawData.fFull_name; floor.Full_name = floorRawData.fFull_name;
floor.InitMapName = floorRawData.InitMapName; floor.InitMapName = floorRawData.InitMapName;
floor.Floor_map_name = floorRawData.Floor_map_name; floor.Floor_map_name = floorRawData.Floor_map_name;
@ -201,7 +201,14 @@ namespace Backend.Controllers
LEFT JOIN device_kind dk ON dk.device_building_tag = d.device_building_tag AND dk.device_system_tag = d.device_system_tag AND dk.device_name_tag = d.device_name_tag LEFT JOIN device_kind dk ON dk.device_building_tag = d.device_building_tag AND dk.device_system_tag = d.device_system_tag AND dk.device_name_tag = d.device_name_tag
ORDER BY d.priority ASC, d.device_number ASC"; ORDER BY d.priority ASC, d.device_number ASC";
var devices = await backendRepository.GetAllAsync<Device>(sql, post); var devices = await backendRepository.GetAllAsync<Device>(sql, new {
building_tag = post.building_tag,
main_system_tag = post.device_system_tag,
sub_system_tag = post.device_name_tag,
floor_tag = post.device_floor_tag,
main_system_type = main_system_type,
sub_system_type = sub_system_type
});
var sql_node = $@"SELECT var sql_node = $@"SELECT
dn.device_node_guid, dn.device_node_guid,
@ -246,8 +253,8 @@ namespace Backend.Controllers
d.*, d.*,
d.full_name AS Device_full_name, d.full_name AS Device_full_name,
b.full_name AS Building_full_name, b.full_name AS Building_full_name,
ms.full_name AS Main_system_full_name, mv.system_key AS Main_system_full_name,
ss.full_name AS Sub_system_full_name, sv.system_key AS Sub_system_full_name,
f.full_name AS Floor_full_name f.full_name AS Floor_full_name
FROM ( FROM (
SELECT * SELECT *
@ -256,13 +263,13 @@ namespace Backend.Controllers
d.device_guid = @Device_guid d.device_guid = @Device_guid
AND d.deleted = @Deleted AND d.deleted = @Deleted
) d ) d
JOIN building b ON d.building_guid = b.building_guid JOIN building b ON d.device_building_tag = b.building_tag
JOIN main_system ms ON d.main_system_guid = ms.main_system_guid JOIN variable mv ON d.device_system_tag = mv.system_value AND mv.system_type = @main_system_type
JOIN sub_system ss ON d.sub_system_guid = ss.sub_system_guid JOIN variable sv ON d.device_name_tag = sv.system_value AND sv.system_type = @sub_system_type
JOIN floor f ON d.floor_guid = f.floor_guid JOIN floor f ON d.device_floor_tag = f.full_name
"; ";
object param = new { Deleted = 0, Device_guid = guid }; object param = new { Deleted = 0, Device_guid = guid ,main_system_type = main_system_type , sub_system_type = sub_system_type };
var device = await backendRepository.GetOneAsync<Device>(sql, param); var device = await backendRepository.GetOneAsync<Device>(sql, param);
@ -354,10 +361,10 @@ namespace Backend.Controllers
Dictionary<string, object> deviceDic = new Dictionary<string, object>() Dictionary<string, object> deviceDic = new Dictionary<string, object>()
{ {
{ "@device_guid", guid}, { "@device_guid", guid},
{ "@building_guid", post.Building_guid}, { "@building_tag", post.Building_tag},
{ "@main_system_guid", post.Main_system_guid}, { "@main_system_tag", post.Main_system_tag},
{ "@sub_system_guid", post.Sub_system_guid}, { "@sub_system_tag", post.Sub_system_tag},
{ "@floor_guid", post.Floor_guid}, { "@floor_guid", post.Floor_tag},
{ "@full_name", device_name_tag + device_serial_tag}, { "@full_name", device_name_tag + device_serial_tag},
{ "@device_building_tag", device_building_tag}, { "@device_building_tag", device_building_tag},
{ "@device_system_tag", device_system_tag}, { "@device_system_tag", device_system_tag},
@ -801,7 +808,7 @@ namespace Backend.Controllers
try try
{ {
var rawDatas = await backendRepository.GetAllAsync<DeviceImportCheckTempRawData>("import_niagara_tag", "ORDER BY device_building_tag, device_system_tag, device_floor_tag, device_name_tag"); var rawDatas = await backendRepository.GetAllAsync<DeviceImportCheckTempRawData>("import_niagara_tag", null,null,"device_building_tag, device_system_tag, device_floor_tag, device_name_tag");
var rawDatas_Group_Building_tag = rawDatas.GroupBy(x => x.Device_building_tag).ToList(); var rawDatas_Group_Building_tag = rawDatas.GroupBy(x => x.Device_building_tag).ToList();
List<DeviceImportCheckTempFilter> tempFilters = new List<DeviceImportCheckTempFilter>(); List<DeviceImportCheckTempFilter> tempFilters = new List<DeviceImportCheckTempFilter>();
@ -962,7 +969,7 @@ namespace Backend.Controllers
d.device_building_tag = @building_tag d.device_building_tag = @building_tag
AND d.device_system_tag = @main_system_tag AND d.device_system_tag = @main_system_tag
AND d.device_name_tag = @sub_system_tag AND d.device_name_tag = @sub_system_tag
-- AND d.floor_guid = @Floor_guid -- AND d.floor_guid = @Floor_tag
AND d.deleted = 0 AND d.deleted = 0
) d ) d
GROUP BY d.device_building_tag, GROUP BY d.device_building_tag,
@ -1256,7 +1263,7 @@ namespace Backend.Controllers
CREATE TABLE `device_group` ( CREATE TABLE `device_group` (
`id` int(11) NOT NULL, `id` int(11) NOT NULL,
`device_disaster` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `device_disaster` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`device_building_guid` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'guid', `device_building_tag` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'guid',
`device_floor_guid` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'guid', `device_floor_guid` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'guid',
`device_area_tag` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `device_area_tag` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`device_system_category_layer2` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'device_system_tag', `device_system_category_layer2` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'device_system_tag',
@ -1268,10 +1275,10 @@ namespace Backend.Controllers
await backendRepository.ExecuteSql(delete_group_sql); await backendRepository.ExecuteSql(delete_group_sql);
//更新整個device_group //更新整個device_group
var insert_group_sql = @" var insert_group_sql = @"
INSERT INTO device_group (device_disaster, device_building_guid, device_floor_guid, device_system_category_layer2, device_system_category_layer3, device_amount) INSERT INTO device_group (device_disaster, device_building_tag, device_floor_guid, device_system_category_layer2, device_system_category_layer3, device_amount)
SELECT SELECT
dd.device_system_value AS device_disaster, dd.device_system_value AS device_disaster,
d.building_guid AS device_building_guid, d.building_tag AS device_building_tag,
d.floor_guid AS device_floor_guid, d.floor_guid AS device_floor_guid,
vv.device_system_category_layer2 AS device_system_category_layer2, vv.device_system_category_layer2 AS device_system_category_layer2,
d.device_system_category_layer3 AS device_system_category_layer3, d.device_system_category_layer3 AS device_system_category_layer3,
@ -1287,7 +1294,7 @@ namespace Backend.Controllers
) vv ON d.device_system_category_layer3 = vv.device_system_category_layer3 ) vv ON d.device_system_category_layer3 = vv.device_system_category_layer3
WHERE d.deleted = 0 WHERE d.deleted = 0
GROUP BY dd.device_system_value, GROUP BY dd.device_system_value,
d.building_guid, d.building_tag,
d.floor_guid, d.floor_guid,
vv.device_system_category_layer2, vv.device_system_category_layer2,
d.device_system_category_layer3"; d.device_system_category_layer3";
@ -1305,8 +1312,8 @@ namespace Backend.Controllers
{ {
{ "@id", deviceGroup.id}, { "@id", deviceGroup.id},
{ "@device_disaster", deviceGroup.device_disaster}, { "@device_disaster", deviceGroup.device_disaster},
{ "@device_building_guid", deviceGroup.device_building_guid}, { "@device_building_tag", deviceGroup.device_building_tag},
{ "@device_floor_guid", deviceGroup.device_floor_guid}, { "@device_floor_guid", deviceGroup.device_floor_tag},
{ "@device_system_category_layer2", deviceGroup.device_system_category_layer2}, { "@device_system_category_layer2", deviceGroup.device_system_category_layer2},
{ "@device_system_category_layer3", deviceGroup.device_system_category_layer3}, { "@device_system_category_layer3", deviceGroup.device_system_category_layer3},
{ "@device_amount", deviceGroup.device_amount}, { "@device_amount", deviceGroup.device_amount},
@ -1572,15 +1579,15 @@ namespace Backend.Controllers
/// <param name="guid"></param> /// <param name="guid"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public async Task<ApiResult<List<Device_item>>> GetDeviceItem(string sub_system_guid) public async Task<ApiResult<List<Device_item>>> GetDeviceItem(string sub_system_tag)
{ {
ApiResult<List<Device_item>> apiResult = new ApiResult<List<Device_item>>(); ApiResult<List<Device_item>> apiResult = new ApiResult<List<Device_item>>();
try try
{ {
string sWhere = "deleted = 0 AND sub_system_guid = @Sub_system_guid"; string sWhere = "deleted = 0 AND sub_system_tag = @Sub_system_tag";
object param = new { Sub_system_guid = sub_system_guid }; object param = new { Sub_system_tag = sub_system_tag };
var deviceItems = await backendRepository.GetAllAsync<Device_item>("device_item", sWhere, param); var deviceItems = await backendRepository.GetAllAsync<Device_item>("device_item", sWhere, param);

View File

@ -20,7 +20,7 @@ namespace Backend.Models
public class BuildingCollapse : Actor public class BuildingCollapse : Actor
{ {
public string Building_guid { get; set; } public string Building_tag { get; set; }
public string Full_name { get; set; } public string Full_name { get; set; }
public string Ip_address { get; set; } public string Ip_address { get; set; }
public int Priority { get; set; } public int Priority { get; set; }
@ -28,7 +28,7 @@ namespace Backend.Models
} }
public class Main_system public class Main_system
{ {
public string Main_system_guid { get; set; } public string Main_system_tag { get; set; }
public string Full_name { get; set; } public string Full_name { get; set; }
public int Priority { get; set; } public int Priority { get; set; }
public string Code { get; set; } public string Code { get; set; }
@ -36,7 +36,7 @@ namespace Backend.Models
} }
public class Sub_system public class Sub_system
{ {
public string Sub_system_guid { get; set; } public string Sub_system_tag { get; set; }
public string Full_name { get; set; } public string Full_name { get; set; }
public int Priority { get; set; } public int Priority { get; set; }
public byte Drawing { get; set; } public byte Drawing { get; set; }
@ -47,7 +47,7 @@ namespace Backend.Models
} }
public class Floor public class Floor
{ {
public string Floor_guid { get; set; } public string Floor_tag { get; set; }
public string Full_name { get; set; } public string Full_name { get; set; }
public string InitMapName { get; set; } public string InitMapName { get; set; }
public string Floor_map_name { get; set; } //平面圖檔名 public string Floor_map_name { get; set; } //平面圖檔名
@ -60,7 +60,7 @@ namespace Backend.Models
public string building_tag { get; set; } public string building_tag { get; set; }
public string main_system_tag { get; set; } public string main_system_tag { get; set; }
public string sub_system_tag { get; set; } public string sub_system_tag { get; set; }
public string Floor_guid { get; set; } public string Floor_tag { get; set; }
public string fFull_name { get; set; } public string fFull_name { get; set; }
public string InitMapName { get; set; } public string InitMapName { get; set; }
public string Floor_map_name { get; set; } public string Floor_map_name { get; set; }

View File

@ -16,10 +16,10 @@ namespace Backend.Models
public class PostDeviceInfoAdd public class PostDeviceInfoAdd
{ {
public string Building_guid { get; set; } public string Building_tag { get; set; }
public string Main_system_guid { get; set; } public string Main_system_tag { get; set; }
public string Sub_system_guid { get; set; } public string Sub_system_tag { get; set; }
public string Floor_guid { get; set; } public string Floor_tag { get; set; }
public List<SelcectedDeviceAdd> SelectedDevices { get; set; } public List<SelcectedDeviceAdd> SelectedDevices { get; set; }
public IFormFile SelectedDevicesFile { get; set; } public IFormFile SelectedDevicesFile { get; set; }
} }
@ -239,8 +239,8 @@ namespace Backend.Models
{ {
public int id { get; set; } public int id { get; set; }
public string device_disaster { get; set; } public string device_disaster { get; set; }
public string device_building_guid { get; set; } public string device_building_tag { get; set; }
public string device_floor_guid { get; set; } public string device_floor_tag { get; set; }
public string device_system_category_layer2 { get; set; } public string device_system_category_layer2 { get; set; }
public string device_system_category_layer3 { get; set; } public string device_system_category_layer3 { get; set; }
public int device_amount { get; set; } public int device_amount { get; set; }

View File

@ -747,10 +747,10 @@
"url": "/DeviceManage/DeviceTableList", "url": "/DeviceManage/DeviceTableList",
"type": "POST", "type": "POST",
"data": function (d) { "data": function (d) {
d.Buliding_tag = selected_building_menu.buliding_tag ? selected_building_menu.buliding_tag : ""; d.building_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : "";
d.Main_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : ""; d.device_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : "";
d.Sub_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : ""; d.device_name_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : "";
d.Floor_tag = selected_floor_tag ? selected_floor_tag : ""; d.device_floor_tag = selected_floor_tag ? selected_floor_tag : "";
}, },
"dataSrc": function (rel) { "dataSrc": function (rel) {
if (rel.code == "9999") { if (rel.code == "9999") {
@ -1050,7 +1050,7 @@
"url": "/DeviceManage/GetDeviceMasterTableList", "url": "/DeviceManage/GetDeviceMasterTableList",
"type": "POST", "type": "POST",
"data": function (d) { "data": function (d) {
d.Buliding_tag = selected_building_menu.buliding_tag ? selected_building_menu.buliding_tag : ""; d.Building_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : "";
d.Main_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : ""; d.Main_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : "";
d.Sub_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : ""; d.Sub_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : "";
d.Floor_tag = selected_floor_tag ? selected_floor_tag : ""; d.Floor_tag = selected_floor_tag ? selected_floor_tag : "";
@ -1077,11 +1077,11 @@
$("#device-master-list-btn").click(function (e) { $("#device-master-list-btn").click(function (e) {
e.preventDefault(); e.preventDefault();
var selectedBuliding_tag = selected_building_menu.buliding_tag ? selected_building_menu.buliding_tag : ""; var selectedBuilding_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : "";
var selectedMain_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : ""; var selectedMain_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : "";
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 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 selectedFloor_tag = selected_floor_tag ? selected_floor_tag : ""; var selectedFloor_tag = selected_floor_tag ? selected_floor_tag : "";
if (selectedBuliding_tag == '' || selectedMain_system_tag == '' || selectedSub_system_tag == '' || selectedFloor_tag == '') { if (selectedBuilding_tag == '' || selectedMain_system_tag == '' || selectedSub_system_tag == '' || selectedFloor_tag == '') {
toast_warning("請先選擇系統類別及樓層。"); toast_warning("請先選擇系統類別及樓層。");
return; return;
} }
@ -1494,7 +1494,7 @@
"url": "/DeviceManage/DeviceKindTableList", "url": "/DeviceManage/DeviceKindTableList",
"type": "POST", "type": "POST",
"data": function (d) { "data": function (d) {
d.Buliding_tag = selected_building_menu.buliding_tag ? selected_building_menu.buliding_tag : ""; d.Building_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : "";
d.Main_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : ""; d.Main_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : "";
d.Sub_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : ""; d.Sub_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : "";
d.Floor_tag = selected_floor_tag ? selected_floor_tag : ""; d.Floor_tag = selected_floor_tag ? selected_floor_tag : "";
@ -1910,7 +1910,7 @@
html += ` html += `
<li class="list-group-item pr-0 d-flex justify-content-between"> <li class="list-group-item pr-0 d-flex justify-content-between">
<a href="javascript:;" onclick="ChangeFloorPanel(this)" <a href="javascript:;" onclick="ChangeFloorPanel(this)"
data-building-tag="${buildingCollapse.buliding_tag}" data-building-tag="${buildingCollapse.building_tag}"
data-main-system-tag="${main_system.main_system_tag}" data-main-system-tag="${main_system.main_system_tag}"
data-sub-system-tag="${sub_system.sub_system_tag}"> data-sub-system-tag="${sub_system.sub_system_tag}">
${sub_system.full_name} ${sub_system.full_name}
@ -1944,14 +1944,14 @@
function ChangeFloorPanel(dom) { function ChangeFloorPanel(dom) {
var selected_target = { var selected_target = {
"buliding_tag": $(dom).attr("data-building-tag") ? $(dom).attr("data-building-tag") : "", "building_tag": $(dom).attr("data-building-tag") ? $(dom).attr("data-building-tag") : "",
"main_system_tag": $(dom).attr("data-main-system-tag") ? $(dom).attr("data-main-system-tag") : "", "main_system_tag": $(dom).attr("data-main-system-tag") ? $(dom).attr("data-main-system-tag") : "",
"sub_system_tag": $(dom).attr("data-sub-system-tag") ? $(dom).attr("data-sub-system-tag") : "", "sub_system_tag": $(dom).attr("data-sub-system-tag") ? $(dom).attr("data-sub-system-tag") : "",
} }
buildingCollapses.forEach(function (building_item, building_index) { buildingCollapses.forEach(function (building_item, building_index) {
if (building_item.buliding_tag == selected_target.buliding_tag) { if (building_item.building_tag == selected_target.building_tag) {
selected_building_menu.buliding_tag = building_item.buliding_tag; selected_building_menu.building_tag = building_item.building_tag;
selected_building_menu.main_system = {}; selected_building_menu.main_system = {};
building_item.main_systems.forEach(function (main_system_item, main_system_index) { building_item.main_systems.forEach(function (main_system_item, main_system_index) {
@ -1971,7 +1971,7 @@
//匯入floor panel //匯入floor panel
$(".floor-panel-wrap").empty(); $(".floor-panel-wrap").empty();
sub_system_item.floors.forEach(function (floor_item, floor_index) { sub_system_item.floors.forEach(function (floor_item, floor_index) {
$(".floor-panel-wrap").append(`<button type="button" class="btn btn-secondary waves-effect waves-themed mr-2 mb-2 btn-floor" onclick="ChangeDevicePanel(this)" data-floor-guid="${floor_item.Floor_tag}">${floor_item.full_name}</button>`) $(".floor-panel-wrap").append(`<button type="button" class="btn btn-secondary waves-effect waves-themed mr-2 mb-2 btn-floor" onclick="ChangeDevicePanel(this)" data-floor-guid="${floor_item.floor_tag}">${floor_item.full_name}</button>`)
}); });
} }
}); });
@ -1990,7 +1990,7 @@
selected_floor_tag = $(dom).attr("data-floor-guid") ? $(dom).attr("data-floor-guid") : "" selected_floor_tag = $(dom).attr("data-floor-guid") ? $(dom).attr("data-floor-guid") : ""
var current_floor = selected_building_menu.main_system.sub_system.floors.filter(function (item) { var current_floor = selected_building_menu.main_system.sub_system.floors.filter(function (item) {
return item.Floor_tag == selected_floor_tag return item.floor_tag == selected_floor_tag
})[0]; })[0];
$.each($(".btn-floor"), function (index, item) { $.each($(".btn-floor"), function (index, item) {
@ -2522,11 +2522,11 @@
//#region 新增設備 //#region 新增設備
function AddDevice() { function AddDevice() {
var selectedBuliding_tag = selected_building_menu.buliding_tag ? selected_building_menu.buliding_tag : ""; var selectedBuilding_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : "";
var selectedMain_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : ""; var selectedMain_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : "";
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 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 selectedFloor_tag = selected_floor_tag ? selected_floor_tag : ""; var selectedFloor_tag = selected_floor_tag ? selected_floor_tag : "";
if (selectedBuliding_tag == '' || selectedMain_system_tag == '' || selectedSub_system_tag == '' || selectedFloor_tag == '') { if (selectedBuilding_tag == '' || selectedMain_system_tag == '' || selectedSub_system_tag == '' || selectedFloor_tag == '') {
toast_warning("請先選擇系統類別及樓層。"); toast_warning("請先選擇系統類別及樓層。");
return; return;
} }
@ -2676,11 +2676,11 @@
//#region 設備儲存(透過新增按鈕) //#region 設備儲存(透過新增按鈕)
function SaveDeviceAdd() { function SaveDeviceAdd() {
var selectedBuliding_tag = selected_building_menu.buliding_tag ? selected_building_menu.buliding_tag : ""; var selectedBuilding_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : "";
var selectedMain_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : ""; var selectedMain_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : "";
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 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 selectedFloor_tag = selected_floor_tag ? selected_floor_tag : ""; var selectedFloor_tag = selected_floor_tag ? selected_floor_tag : "";
if (selectedBuliding_tag == '' || selectedMain_system_tag == '' || selectedSub_system_tag == '' || selectedFloor_tag == '') if (selectedBuilding_tag == '' || selectedMain_system_tag == '' || selectedSub_system_tag == '' || selectedFloor_tag == '')
{ {
toast_warning("請先選擇系統類別及樓層。"); toast_warning("請先選擇系統類別及樓層。");
return; return;
@ -2710,7 +2710,7 @@
var url = "/DeviceManage/SaveDeviceInfoAdd"; var url = "/DeviceManage/SaveDeviceInfoAdd";
@*var send_data = { @*var send_data = {
Buliding_tag: selectedBuliding_tag, Building_tag: selectedBuilding_tag,
Main_system_tag: selectedMain_system_tag, Main_system_tag: selectedMain_system_tag,
Sub_system_tag: selectedSub_system_tag, Sub_system_tag: selectedSub_system_tag,
Floor_tag: selectedFloor_tag, Floor_tag: selectedFloor_tag,
@ -2734,7 +2734,7 @@
var formData = new FormData(); var formData = new FormData();
formData.append("Buliding_tag", selectedBuliding_tag); formData.append("Building_tag", selectedBuilding_tag);
formData.append("Main_system_tag", selectedMain_system_tag); formData.append("Main_system_tag", selectedMain_system_tag);
formData.append("Sub_system_tag", selectedSub_system_tag); formData.append("Sub_system_tag", selectedSub_system_tag);
formData.append("Floor_tag", selectedFloor_tag); formData.append("Floor_tag", selectedFloor_tag);