[修改] 修改設備管理獲取資料
This commit is contained in:
parent
6fbc9b41fb
commit
1b77cd4ab2
@ -46,45 +46,46 @@ namespace Backend.Controllers
|
|||||||
|
|
||||||
//取得區域選單
|
//取得區域選單
|
||||||
var sql = $@"SELECT
|
var sql = $@"SELECT
|
||||||
bm.*,
|
bm.*,
|
||||||
b.full_name AS bFull_name,
|
b.full_name AS bFull_name,
|
||||||
b.priority AS bPriority,
|
b.priority AS bPriority,
|
||||||
ms.full_name AS mFull_name,
|
mv.system_key AS mFull_name,
|
||||||
ms.priority AS mPriority,
|
mv.system_priority AS mPriority,
|
||||||
ss.full_name AS sFull_name,
|
sv.system_key AS sFull_name,
|
||||||
ss.priority AS sPriority
|
sv.system_priority AS sPriority
|
||||||
FROM building_menu bm
|
FROM building_menu bm
|
||||||
LEFT JOIN building b ON bm.building_guid = b.building_guid AND b.deleted = 0
|
LEFT JOIN building b ON bm.building_tag = b.building_tag AND b.deleted = 0
|
||||||
LEFT JOIN main_system ms ON bm.main_system_guid = ms.main_system_guid AND ms.deleted = 0
|
LEFT JOIN variable mv ON bm.main_system_tag = mv.system_value AND mv.deleted = 0
|
||||||
LEFT JOIN sub_system ss ON bm.sub_system_guid = ss.sub_system_guid AND ss.deleted = 0";
|
LEFT JOIN variable sv ON bm.sub_system_tag = sv.system_value AND sv.deleted = 0";
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(filter))
|
if (!string.IsNullOrEmpty(filter))
|
||||||
{
|
{
|
||||||
sql += $@" WHERE (
|
sql += $@" WHERE (
|
||||||
b.full_name LIKE CONCAT('%', @Filter, '%')
|
b.full_name LIKE CONCAT('%', @Filter, '%')
|
||||||
OR ms.full_name LIKE CONCAT('%', @Filter, '%')
|
OR mv.system_key LIKE CONCAT('%', @Filter, '%')
|
||||||
OR ss.full_name LIKE CONCAT('%', @Filter, '%')
|
OR sv.system_key LIKE CONCAT('%', @Filter, '%')
|
||||||
)";
|
)";
|
||||||
}
|
}
|
||||||
|
|
||||||
sql += $@" ORDER BY b.priority, ms.priority, ss.priority, ss.created_at DESC";
|
sql += $@" ORDER BY b.priority, mv.system_priority, sv.system_priority, sv.created_at DESC";
|
||||||
|
|
||||||
var buildingMenuRawDatas = await backendRepository.GetAllAsync<BuildingMenuRawData>(sql, new { Filter = filter });
|
var buildingMenuRawDatas = await backendRepository.GetAllAsync<BuildingMenuRawData>(sql, new { Filter = filter });
|
||||||
|
|
||||||
//取得系統小類樓層
|
//取得系統小類樓層
|
||||||
var sub_sql = $@"SELECT
|
var sub_sql = $@"SELECT
|
||||||
ssf.*,
|
ssf.*,
|
||||||
f.full_name AS fFull_name,
|
f.full_name AS fFull_name,
|
||||||
f.InitMapName,
|
f.InitMapName,
|
||||||
f.floor_map_name,
|
f.floor_map_name,
|
||||||
f.priority AS fPriority
|
f.priority AS fPriority
|
||||||
FROM sub_system_floor ssf
|
FROM sub_system_floor ssf
|
||||||
LEFT JOIN floor f ON ssf.floor_guid = f.floor_guid AND f.deleted = 0
|
LEFT JOIN floor f ON ssf.floor_tag = f.full_name AND ssf.building_tag = f.building_tag AND f.deleted = 0
|
||||||
WHERE ssf.deleted = 0
|
WHERE ssf.deleted = 0
|
||||||
ORDER BY f.priority, f.created_at";
|
ORDER BY f.priority, f.created_at
|
||||||
|
";
|
||||||
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_guid).ToList();
|
var buildingMenu_Group_Building_guid = 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_guid in buildingMenu_Group_Building_guid)
|
||||||
@ -95,7 +96,7 @@ namespace Backend.Controllers
|
|||||||
buildingCollapse.Full_name = buildingMenus_Building_guid.First().bFull_name;
|
buildingCollapse.Full_name = buildingMenus_Building_guid.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_guid).ToList();
|
var buildingMenus_Group_Main_system_guid = buildingMenus_Building_guid.GroupBy(x => x.main_system_tag).ToList();
|
||||||
|
|
||||||
foreach (var buildingMenus_Main_system_guid in buildingMenus_Group_Main_system_guid)
|
foreach (var buildingMenus_Main_system_guid in buildingMenus_Group_Main_system_guid)
|
||||||
{
|
{
|
||||||
@ -104,7 +105,7 @@ namespace Backend.Controllers
|
|||||||
main_System.Full_name = buildingMenus_Main_system_guid.First().mFull_name;
|
main_System.Full_name = buildingMenus_Main_system_guid.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_guid).ToList();
|
var buildingMenus_Group_Sub_system_guid = buildingMenus_Main_system_guid.GroupBy(x => x.sub_system_tag).ToList();
|
||||||
|
|
||||||
foreach (var buildingMenus_Sub_system_guid in buildingMenus_Group_Sub_system_guid)
|
foreach (var buildingMenus_Sub_system_guid in buildingMenus_Group_Sub_system_guid)
|
||||||
{
|
{
|
||||||
@ -113,9 +114,9 @@ namespace Backend.Controllers
|
|||||||
sub_System.Full_name = buildingMenus_Sub_system_guid.First().sFull_name;
|
sub_System.Full_name = buildingMenus_Sub_system_guid.First().sFull_name;
|
||||||
sub_System.Floors = new List<Floor>();
|
sub_System.Floors = new List<Floor>();
|
||||||
|
|
||||||
var floorRawDatas = subSystemFloorRawDatas.Where(x => x.Building_guid == buildingCollapse.Building_guid
|
var floorRawDatas = subSystemFloorRawDatas.Where(x => x.building_tag == buildingCollapse.Building_guid
|
||||||
&& x.Main_system_guid == main_System.Main_system_guid
|
&& x.main_system_tag == main_System.Main_system_guid
|
||||||
&& x.Sub_system_guid == sub_System.Sub_system_guid).ToList();
|
&& x.sub_system_tag == sub_System.Sub_system_guid).ToList();
|
||||||
|
|
||||||
foreach (var floorRawData in floorRawDatas)
|
foreach (var floorRawData in floorRawDatas)
|
||||||
{
|
{
|
||||||
@ -164,46 +165,41 @@ namespace Backend.Controllers
|
|||||||
{
|
{
|
||||||
|
|
||||||
var sql = $@"SELECT
|
var sql = $@"SELECT
|
||||||
d.*,
|
d.*,
|
||||||
d.full_name AS Device_full_name,
|
d.device_last_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,
|
||||||
dk.device_image,
|
dk.device_image,
|
||||||
CONCAT('{baseURL}', '{deviceKindFilePath}', dk.device_image) AS device_image_url,
|
CONCAT('{baseURL}', '{deviceKindFilePath}', dk.device_image) AS device_image_url,
|
||||||
dk.device_close_color,
|
dk.device_close_color,
|
||||||
dk.device_normal_color,
|
dk.device_normal_color,
|
||||||
dk.device_error_color,
|
dk.device_error_color,
|
||||||
dk.device_normal_flashing,
|
dk.device_normal_flashing,
|
||||||
dk.device_close_flashing,
|
dk.device_close_flashing,
|
||||||
dk.device_error_flashing,
|
dk.device_error_flashing,
|
||||||
(SELECT
|
(SELECT
|
||||||
GROUP_CONCAT( IFNULL(system_key, ' '), ',')
|
GROUP_CONCAT( IFNULL(system_key, ' '), ',')
|
||||||
FROM device_disaster dd
|
FROM device_disaster dd
|
||||||
JOIN variable v ON v.deleted = 0 AND v.system_type = 'disaster' AND v.system_value = dd.device_system_value
|
JOIN variable v ON v.deleted = 0 AND v.system_type = 'disaster' AND v.system_value = dd.device_system_value
|
||||||
WHERE dd.device_guid = d.device_guid
|
WHERE dd.device_guid = d.device_guid
|
||||||
) AS Device_disaster_type_text
|
) AS Device_disaster_type_text
|
||||||
FROM (
|
FROM (
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM device d
|
FROM device d
|
||||||
WHERE
|
WHERE d.device_building_tag = @building_tag
|
||||||
d.building_guid = @Building_guid
|
AND d.device_system_tag = @main_system_tag
|
||||||
AND d.main_system_guid = @Main_system_guid
|
AND d.device_name_tag = @sub_system_tag
|
||||||
AND d.sub_system_guid = @Sub_system_guid
|
AND d.device_floor_tag = @floor_tag
|
||||||
AND d.floor_guid = @Floor_guid
|
AND d.deleted = 0
|
||||||
AND d.deleted = 0
|
) d
|
||||||
) d
|
JOIN building b ON d.device_building_tag = b.building_tag
|
||||||
JOIN building b ON d.building_guid = b.building_guid
|
JOIN variable mv ON d.device_system_tag = mv.system_value AND mv.system_type = @main_system_type
|
||||||
JOIN main_system ms ON d.main_system_guid = ms.main_system_guid
|
JOIN variable sv ON d.device_name_tag = sv.system_value AND sv.system_type = @sub_system_type
|
||||||
JOIN sub_system ss ON d.sub_system_guid = ss.sub_system_guid
|
JOIN floor f ON d.device_floor_tag = f.full_name AND d.device_building_tag = f.building_tag
|
||||||
JOIN floor f ON d.floor_guid = f.floor_guid
|
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
|
ORDER BY d.priority ASC, d.device_number ASC";
|
||||||
AND dk.device_system_tag = d.device_system_tag
|
|
||||||
-- AND dk.device_floor_tag = d.device_floor_tag
|
|
||||||
AND dk.device_name_tag = d.device_name_tag
|
|
||||||
ORDER BY d.priority ASC, d.device_number ASC
|
|
||||||
";
|
|
||||||
|
|
||||||
var devices = await backendRepository.GetAllAsync<Device>(sql, post);
|
var devices = await backendRepository.GetAllAsync<Device>(sql, post);
|
||||||
|
|
||||||
@ -929,55 +925,54 @@ namespace Backend.Controllers
|
|||||||
{
|
{
|
||||||
|
|
||||||
var sql = $@"SELECT
|
var sql = $@"SELECT
|
||||||
dk.device_kind_guid,
|
dk.device_kind_guid,
|
||||||
dd.device_building_tag,
|
dd.device_building_tag,
|
||||||
dd.device_system_tag,
|
dd.device_system_tag,
|
||||||
-- dd.device_floor_tag,
|
-- dd.device_floor_tag,
|
||||||
dd.device_name_tag,
|
dd.device_name_tag,
|
||||||
dk.device_image,
|
dk.device_image,
|
||||||
dk.device_normal_text,
|
dk.device_normal_text,
|
||||||
dk.device_normal_point_name,
|
dk.device_normal_point_name,
|
||||||
dk.device_normal_point_col,
|
dk.device_normal_point_col,
|
||||||
dk.device_normal_point_value,
|
dk.device_normal_point_value,
|
||||||
dk.device_normal_color,
|
dk.device_normal_color,
|
||||||
dk.device_normal_flashing,
|
dk.device_normal_flashing,
|
||||||
dk.device_close_text,
|
dk.device_close_text,
|
||||||
dk.device_close_point_name,
|
dk.device_close_point_name,
|
||||||
dk.device_close_point_col,
|
dk.device_close_point_col,
|
||||||
dk.device_close_point_value,
|
dk.device_close_point_value,
|
||||||
dk.device_close_color,
|
dk.device_close_color,
|
||||||
dk.device_close_flashing,
|
dk.device_close_flashing,
|
||||||
dk.device_error_text,
|
dk.device_error_text,
|
||||||
dk.device_error_point_name,
|
dk.device_error_point_name,
|
||||||
dk.device_error_point_col,
|
dk.device_error_point_col,
|
||||||
dk.device_error_point_value,
|
dk.device_error_point_value,
|
||||||
dk.device_error_color,
|
dk.device_error_color,
|
||||||
dk.device_error_flashing,
|
dk.device_error_flashing,
|
||||||
dk.device_error_independent
|
dk.device_error_independent
|
||||||
FROM ( SELECT
|
FROM ( SELECT
|
||||||
d.device_building_tag,
|
d.device_building_tag,
|
||||||
d.device_system_tag,
|
d.device_system_tag,
|
||||||
-- d.device_floor_tag,
|
-- d.device_floor_tag,
|
||||||
d.device_name_tag
|
d.device_name_tag
|
||||||
FROM (
|
FROM (
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM device d
|
FROM device d
|
||||||
WHERE
|
WHERE
|
||||||
d.building_guid = @Building_guid
|
d.device_building_tag = @building_tag
|
||||||
AND d.main_system_guid = @Main_system_guid
|
AND d.device_system_tag = @main_system_tag
|
||||||
AND d.sub_system_guid = @Sub_system_guid
|
AND d.device_name_tag = @sub_system_tag
|
||||||
-- AND d.floor_guid = @Floor_guid
|
-- AND d.floor_guid = @Floor_guid
|
||||||
AND d.deleted = 0
|
AND d.deleted = 0
|
||||||
) d
|
) d
|
||||||
GROUP BY d.device_building_tag,
|
GROUP BY d.device_building_tag,
|
||||||
d.device_system_tag,
|
d.device_system_tag,
|
||||||
-- d.device_floor_tag,
|
-- d.device_floor_tag,
|
||||||
d.device_name_tag) dd
|
d.device_name_tag) dd
|
||||||
LEFT JOIN device_kind dk ON dd.device_building_tag = dk.device_building_tag
|
LEFT JOIN device_kind dk ON dd.device_building_tag = dk.device_building_tag
|
||||||
AND dd.device_system_tag = dk.device_system_tag
|
AND dd.device_system_tag = dk.device_system_tag
|
||||||
-- AND dd.device_floor_tag = dk.device_floor_tag
|
-- AND dd.device_floor_tag = dk.device_floor_tag
|
||||||
AND dd.device_name_tag = dk.device_name_tag
|
AND dd.device_name_tag = dk.device_name_tag";
|
||||||
";
|
|
||||||
|
|
||||||
var deviceKinds = await backendRepository.GetAllAsync<DeviceKind>(sql, post);
|
var deviceKinds = await backendRepository.GetAllAsync<DeviceKind>(sql, post);
|
||||||
|
|
||||||
@ -1335,30 +1330,28 @@ namespace Backend.Controllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sql = $@"SELECT
|
var sql = $@"SELECT
|
||||||
dm.device_master_guid,
|
dm.device_master_guid,
|
||||||
dd.device_building_tag,
|
dd.device_building_tag,
|
||||||
dd.device_name_tag,
|
dd.device_name_tag,
|
||||||
dm.device_master_number,
|
dm.device_master_number,
|
||||||
dm.device_master_full_name,
|
dm.device_master_full_name,
|
||||||
dm.device_master_icon
|
dm.device_master_icon
|
||||||
FROM ( SELECT
|
FROM ( SELECT
|
||||||
d.device_building_tag,
|
d.device_building_tag,
|
||||||
d.device_name_tag
|
d.device_name_tag
|
||||||
FROM (
|
FROM (
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM device d
|
FROM device d
|
||||||
WHERE
|
WHERE
|
||||||
d.building_guid = @Building_guid
|
d.device_building_tag = @building_tag
|
||||||
AND d.main_system_guid = @Main_system_guid
|
AND d.device_system_tag = @main_system_tag
|
||||||
AND d.sub_system_guid = @Sub_system_guid
|
AND d.device_name_tag = @sub_system_tag
|
||||||
AND d.floor_guid = @Floor_guid
|
AND d.device_floor_tag = @floor_tag
|
||||||
AND d.deleted = 0
|
AND d.deleted = 0
|
||||||
) d
|
) d
|
||||||
GROUP BY d.device_building_tag,
|
GROUP BY d.device_building_tag, d.device_name_tag) dd
|
||||||
d.device_name_tag) dd
|
LEFT JOIN device_master dm ON dd.device_building_tag = dm.device_building_tag
|
||||||
LEFT JOIN device_master dm ON dd.device_building_tag = dm.device_building_tag
|
AND dd.device_name_tag = dm.device_name_tag";
|
||||||
AND dd.device_name_tag = dm.device_name_tag
|
|
||||||
";
|
|
||||||
|
|
||||||
var deviceMasters = await backendRepository.GetAllAsync<DeviceMaster>(sql, post);
|
var deviceMasters = await backendRepository.GetAllAsync<DeviceMaster>(sql, post);
|
||||||
|
|
||||||
|
@ -7,13 +7,13 @@ namespace Backend.Models
|
|||||||
{
|
{
|
||||||
public class BuildingMenuRawData
|
public class BuildingMenuRawData
|
||||||
{
|
{
|
||||||
public string Building_guid { get; set; }
|
public string building_tag { get; set; }
|
||||||
public string bFull_name { get; set; }
|
public string bFull_name { get; set; }
|
||||||
public int bPriority { get; set; }
|
public int bPriority { get; set; }
|
||||||
public string Main_system_guid { get; set; }
|
public string main_system_tag { get; set; }
|
||||||
public string mFull_name { get; set; }
|
public string mFull_name { get; set; }
|
||||||
public int mPriority { get; set; }
|
public int mPriority { get; set; }
|
||||||
public string Sub_system_guid { get; set; }
|
public string sub_system_tag { get; set; }
|
||||||
public string sFull_name { get; set; }
|
public string sFull_name { get; set; }
|
||||||
public int sPriority { get; set; }
|
public int sPriority { get; set; }
|
||||||
}
|
}
|
||||||
@ -56,10 +56,10 @@ namespace Backend.Models
|
|||||||
|
|
||||||
public class SubSystemFloorRawData
|
public class SubSystemFloorRawData
|
||||||
{
|
{
|
||||||
public string Sub_system_floor_guid { get; set; }
|
public string id { get; set; }
|
||||||
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_guid { get; set; }
|
||||||
public string fFull_name { get; set; }
|
public string fFull_name { get; set; }
|
||||||
public string InitMapName { get; set; }
|
public string InitMapName { get; set; }
|
||||||
|
@ -8,10 +8,10 @@ namespace Backend.Models
|
|||||||
{
|
{
|
||||||
public class PostDeviceFilter
|
public class PostDeviceFilter
|
||||||
{
|
{
|
||||||
public string Building_guid { get; set; }
|
public string building_tag { get; set; }
|
||||||
public string Main_system_guid { get; set; }
|
public string device_system_tag { get; set; }
|
||||||
public string Sub_system_guid { get; set; }
|
public string device_name_tag { get; set; }
|
||||||
public string Floor_guid { get; set; }
|
public string device_floor_tag { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PostDeviceInfoAdd
|
public class PostDeviceInfoAdd
|
||||||
|
Loading…
Reference in New Issue
Block a user