This commit is contained in:
dev02 2022-10-22 13:24:35 +08:00
commit 5258ba2a0f
4 changed files with 111 additions and 104 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

@ -607,7 +607,7 @@
<script src="~/js/echarts.min.js"></script> <script src="~/js/echarts.min.js"></script>
<script> <script>
var buildingCollapses; var buildingCollapses;
var selected_building_menu = {}, selected_floor_guid; var selected_building_menu = {}, selected_floor_tag;
var chartDom, myChart, option, var chartDom, myChart, option,
floor_map_mode = "view", //平面圖當前模式 floor_map_mode = "view", //平面圖當前模式
selected_temp_device, //被選擇要修改的設備 selected_temp_device, //被選擇要修改的設備
@ -747,10 +747,10 @@
"url": "/DeviceManage/DeviceTableList", "url": "/DeviceManage/DeviceTableList",
"type": "POST", "type": "POST",
"data": function (d) { "data": function (d) {
d.Building_guid = selected_building_menu.building_guid ? selected_building_menu.building_guid : ""; d.building_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : "";
d.Main_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_guid : ""; d.device_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : "";
d.Sub_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_guid : "" : ""; 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_guid = selected_floor_guid ? selected_floor_guid : ""; 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,10 +1050,10 @@
"url": "/DeviceManage/GetDeviceMasterTableList", "url": "/DeviceManage/GetDeviceMasterTableList",
"type": "POST", "type": "POST",
"data": function (d) { "data": function (d) {
d.Building_guid = selected_building_menu.building_guid ? selected_building_menu.building_guid : ""; d.Building_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : "";
d.Main_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_guid : ""; d.Main_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : "";
d.Sub_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_guid : "" : ""; 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_guid = selected_floor_guid ? selected_floor_guid : ""; d.Floor_tag = selected_floor_tag ? selected_floor_tag : "";
}, },
"dataSrc": function (rel) { "dataSrc": function (rel) {
if (rel.code == "9999") { if (rel.code == "9999") {
@ -1077,11 +1077,11 @@
$("#device-master-list-btn").click(function (e) { $("#device-master-list-btn").click(function (e) {
e.preventDefault(); e.preventDefault();
var selectedBuilding_guid = selected_building_menu.building_guid ? selected_building_menu.building_guid : ""; var selectedBuilding_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : "";
var selectedMain_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_guid : ""; var selectedMain_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : "";
var selectedSub_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_guid : "" : ""; 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_guid = selected_floor_guid ? selected_floor_guid : ""; var selectedFloor_tag = selected_floor_tag ? selected_floor_tag : "";
if (selectedBuilding_guid == '' || selectedMain_system_guid == '' || selectedSub_system_guid == '' || selectedFloor_guid == '') { if (selectedBuilding_tag == '' || selectedMain_system_tag == '' || selectedSub_system_tag == '' || selectedFloor_tag == '') {
toast_warning("請先選擇系統類別及樓層。"); toast_warning("請先選擇系統類別及樓層。");
return; return;
} }
@ -1494,10 +1494,10 @@
"url": "/DeviceManage/DeviceKindTableList", "url": "/DeviceManage/DeviceKindTableList",
"type": "POST", "type": "POST",
"data": function (d) { "data": function (d) {
d.Building_guid = selected_building_menu.building_guid ? selected_building_menu.building_guid : ""; d.Building_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : "";
d.Main_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_guid : ""; d.Main_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : "";
d.Sub_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_guid : "" : ""; 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_guid = selected_floor_guid ? selected_floor_guid : ""; d.Floor_tag = selected_floor_tag ? selected_floor_tag : "";
}, },
"dataSrc": function (rel) { "dataSrc": function (rel) {
if (rel.code == "9999") { if (rel.code == "9999") {
@ -1549,10 +1549,10 @@
device_kind_data = rel.data; device_kind_data = rel.data;
//取得單一設備基本資料 //取得單一設備基本資料
var selectedSub_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_guid : "" : ""; 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 url = "/DeviceManage/GetDeviceItem";
var send_data = { var send_data = {
sub_system_guid: selectedSub_system_guid sub_system_tag: selectedSub_system_tag
} }
$.post(url, send_data, function (rel) { $.post(url, send_data, function (rel) {
@ -1910,9 +1910,9 @@
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-guid="${buildingCollapse.building_guid}" data-building-tag="${buildingCollapse.building_tag}"
data-main-system-guid="${main_system.main_system_guid}" data-main-system-tag="${main_system.main_system_tag}"
data-sub-system-guid="${sub_system.sub_system_guid}"> data-sub-system-tag="${sub_system.sub_system_tag}">
${sub_system.full_name} ${sub_system.full_name}
</a> </a>
</li>`; </li>`;
@ -1944,26 +1944,26 @@
function ChangeFloorPanel(dom) { function ChangeFloorPanel(dom) {
var selected_target = { var selected_target = {
"building_guid": $(dom).attr("data-building-guid") ? $(dom).attr("data-building-guid") : "", "building_tag": $(dom).attr("data-building-tag") ? $(dom).attr("data-building-tag") : "",
"main_system_guid": $(dom).attr("data-main-system-guid") ? $(dom).attr("data-main-system-guid") : "", "main_system_tag": $(dom).attr("data-main-system-tag") ? $(dom).attr("data-main-system-tag") : "",
"sub_system_guid": $(dom).attr("data-sub-system-guid") ? $(dom).attr("data-sub-system-guid") : "", "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.building_guid == selected_target.building_guid) { if (building_item.building_tag == selected_target.building_tag) {
selected_building_menu.building_guid = building_item.building_guid; 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) {
if (main_system_item.main_system_guid == selected_target.main_system_guid) { if (main_system_item.main_system_tag == selected_target.main_system_tag) {
selected_building_menu.main_system.main_system_guid = main_system_item.main_system_guid selected_building_menu.main_system.main_system_tag = main_system_item.main_system_tag
selected_building_menu.main_system.sub_system = {}; selected_building_menu.main_system.sub_system = {};
$("#select-main-system-name").html(main_system_item.full_name); $("#select-main-system-name").html(main_system_item.full_name);
main_system_item.sub_systems.forEach(function (sub_system_item, sub_system_index) { main_system_item.sub_systems.forEach(function (sub_system_item, sub_system_index) {
if (sub_system_item.sub_system_guid == selected_target.sub_system_guid) { if (sub_system_item.sub_system_tag == selected_target.sub_system_tag) {
selected_building_menu.main_system.sub_system.sub_system_guid = sub_system_item.sub_system_guid selected_building_menu.main_system.sub_system.sub_system_tag = sub_system_item.sub_system_tag
selected_building_menu.main_system.sub_system.floors = sub_system_item.floors; selected_building_menu.main_system.sub_system.floors = sub_system_item.floors;
$("#select-sub-system-name").html(sub_system_item.full_name); $("#select-sub-system-name").html(sub_system_item.full_name);
@ -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_guid}">${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>`)
}); });
} }
}); });
@ -1987,10 +1987,10 @@
//#region 變更平面圖與設備的控制面板 //#region 變更平面圖與設備的控制面板
function ChangeDevicePanel(dom) { function ChangeDevicePanel(dom) {
selected_floor_guid = $(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_guid == selected_floor_guid 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 selectedBuilding_guid = selected_building_menu.building_guid ? selected_building_menu.building_guid : ""; var selectedBuilding_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : "";
var selectedMain_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_guid : ""; var selectedMain_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : "";
var selectedSub_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_guid : "" : ""; 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_guid = selected_floor_guid ? selected_floor_guid : ""; var selectedFloor_tag = selected_floor_tag ? selected_floor_tag : "";
if (selectedBuilding_guid == '' || selectedMain_system_guid == '' || selectedSub_system_guid == '' || selectedFloor_guid == '') { 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 selectedBuilding_guid = selected_building_menu.building_guid ? selected_building_menu.building_guid : ""; var selectedBuilding_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : "";
var selectedMain_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_guid : ""; var selectedMain_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : "";
var selectedSub_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_guid : "" : ""; 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_guid = selected_floor_guid ? selected_floor_guid : ""; var selectedFloor_tag = selected_floor_tag ? selected_floor_tag : "";
if (selectedBuilding_guid == '' || selectedMain_system_guid == '' || selectedSub_system_guid == '' || selectedFloor_guid == '') if (selectedBuilding_tag == '' || selectedMain_system_tag == '' || selectedSub_system_tag == '' || selectedFloor_tag == '')
{ {
toast_warning("請先選擇系統類別及樓層。"); toast_warning("請先選擇系統類別及樓層。");
return; return;
@ -2710,10 +2710,10 @@
var url = "/DeviceManage/SaveDeviceInfoAdd"; var url = "/DeviceManage/SaveDeviceInfoAdd";
@*var send_data = { @*var send_data = {
Building_guid: selectedBuilding_guid, Building_tag: selectedBuilding_tag,
Main_system_guid: selectedMain_system_guid, Main_system_tag: selectedMain_system_tag,
Sub_system_guid: selectedSub_system_guid, Sub_system_tag: selectedSub_system_tag,
Floor_guid: selectedFloor_guid, Floor_tag: selectedFloor_tag,
SelectedDevices: selectedDevices SelectedDevices: selectedDevices
} }
@ -2734,10 +2734,10 @@
var formData = new FormData(); var formData = new FormData();
formData.append("Building_guid", selectedBuilding_guid); formData.append("Building_tag", selectedBuilding_tag);
formData.append("Main_system_guid", selectedMain_system_guid); formData.append("Main_system_tag", selectedMain_system_tag);
formData.append("Sub_system_guid", selectedSub_system_guid); formData.append("Sub_system_tag", selectedSub_system_tag);
formData.append("Floor_guid", selectedFloor_guid); formData.append("Floor_tag", selectedFloor_tag);
formData.append("SelectedDevicesFile", blob); formData.append("SelectedDevicesFile", blob);
$.ajax({ $.ajax({