[ALL]歷史資料呈現點位改成根據device_number而非小類,連帶新增device_number欄位進import_niagara_item_history去做對應
This commit is contained in:
parent
9f957b06b4
commit
d2baf9b87b
@ -607,6 +607,9 @@ namespace Backend.Services.Implement
|
||||
else if (tagName.Split('_').Length == 6)
|
||||
{ //巨蛋 tag 5 段版本
|
||||
ImpNiaItem row = new ImpNiaItem();
|
||||
int index = tagName.LastIndexOf('_');
|
||||
string device = (index != -1) ? tagName.Substring(0, index) : tagName;
|
||||
row.device_number = device; // 2024.08.01 新增 為了解決不同小類下的設備有不同點位的問題
|
||||
if (tagName.Split('_')[1] == "S" || tagName.Split('_')[1] == "B" || tagName.Split('_')[1] == "CWB") //for security system
|
||||
{
|
||||
row.device_building_tag = tagName.Split('_')[0];
|
||||
|
@ -593,6 +593,7 @@ namespace FrontendWebApi.ApiControllers
|
||||
and b.device_building_tag COLLATE utf8mb4_unicode_ci = a.device_building_tag
|
||||
and b.device_name_tag COLLATE utf8mb4_unicode_ci = a.device_name_tag
|
||||
join building c on c.building_tag = a.device_building_tag
|
||||
join import_niagara_item_history h on a.device_number = h.device_number
|
||||
join variable v1 on v1.system_value = a.device_system_tag and v1.deleted = 0 and v1.system_type = 'device_system_category_layer2'
|
||||
join variable v2 on v2.system_value = a.device_name_tag and v2.deleted = 0 and v2.system_type = 'device_system_category_layer3'
|
||||
where a.deleted = 0 and b.deleted = 0 and v2.deleted = 0 and v1.deleted = 0 and b.is_link = 1 and b.is_show_history = 1
|
||||
@ -635,6 +636,7 @@ namespace FrontendWebApi.ApiControllers
|
||||
and a.device_building_tag COLLATE utf8mb4_unicode_ci = b.device_building_tag
|
||||
and a.device_name_tag COLLATE utf8mb4_unicode_ci = b.device_name_tag
|
||||
join building c on c.building_tag = b.device_building_tag
|
||||
join import_niagara_item_history h on b.device_number = h.device_number and a.points = h.device_point_name
|
||||
join variable v1 on v1.system_value = b.device_system_tag and v1.deleted = 0 and v1.system_type = 'device_system_category_layer2'
|
||||
join variable v2 on v2.system_value = b.device_name_tag and v2.deleted = 0 and v2.system_type = 'device_system_category_layer3'
|
||||
where a.deleted = 0 and b.deleted = 0 and v2.deleted = 0 and v1.deleted = 0
|
||||
|
@ -1803,6 +1803,7 @@ SET FOREIGN_KEY_CHECKS = 0;
|
||||
DROP TABLE IF EXISTS `import_niagara_item_history`;
|
||||
CREATE TABLE `import_niagara_item_history` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`device_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '完整 TagName 設備編號',
|
||||
`device_area_tag` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
|
||||
`device_building_tag` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
|
||||
`device_system_tag` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
|
||||
@ -1847,11 +1848,12 @@ SET FOREIGN_KEY_CHECKS = 1;";
|
||||
{
|
||||
if (count == 0)
|
||||
{
|
||||
ss = @"insert import_niagara_item_history(device_area_tag, device_building_tag, device_system_tag, device_name_tag, device_floor_tag, device_master_tag,
|
||||
ss = @"insert import_niagara_item_history(device_number,device_area_tag, device_building_tag, device_system_tag, device_name_tag, device_floor_tag, device_master_tag,
|
||||
device_last_name_tag, device_serial_tag, device_point_name, parent_path, full_name, is_history, created_at) values";
|
||||
}
|
||||
|
||||
ss += $@" ('" +
|
||||
row.device_number + "', '" +
|
||||
row.device_area_tag + "', '" +
|
||||
row.device_building_tag + "', '" +
|
||||
row.device_system_tag + "', '" +
|
||||
|
@ -123,6 +123,7 @@ namespace Repository.Models
|
||||
|
||||
public class ImpNiaItem
|
||||
{
|
||||
public string device_number { get; set; }
|
||||
public string device_area_tag { get; set; }
|
||||
public string device_building_tag { get; set; }
|
||||
public string device_system_tag { get; set; }
|
||||
|
Loading…
Reference in New Issue
Block a user