diff --git a/Backend/Controllers/NiagaraDataSynchronizeController.cs b/Backend/Controllers/NiagaraDataSynchronizeController.cs index 64d22ca..f33735a 100644 --- a/Backend/Controllers/NiagaraDataSynchronizeController.cs +++ b/Backend/Controllers/NiagaraDataSynchronizeController.cs @@ -83,7 +83,8 @@ namespace Backend.Controllers try { - var building = ds.FirstOrDefault().building; + string ss = ds.Where(x => x.tag_name != "").FirstOrDefault().tag_name; + var building = ss.Split("_")[0]; string LightSwitchLevel = await niagaraDataSynchronizeRepository.getLightSwitchLevel(); //獲取照明開關 是否在 device or device_node await niagaraDataSynchronizeRepository.InsertNiagaraTagList(ds, building, tag_quantity); // 匯入 MySQL table: import_niagara_tag await niagaraDataSynchronizeRepository.DeviceComparison(LightSwitchLevel); @@ -147,16 +148,23 @@ namespace Backend.Controllers ApiResult apiResult = new ApiResult(); try { - var building = ds.FirstOrDefault().device_building_tag; - await niagaraDataSynchronizeRepository.InsertItemFromNiagara(ds, building); // insert 暫存table import_niagara_item - await niagaraDataSynchronizeRepository.DeviceItemComparison(); //insert device_item - await niagaraDataSynchronizeRepository.CheckItemDiffFullNameAndCover(); // update device_item.fullname - await niagaraDataSynchronizeRepository.ItemCheckFullNameEmptyReplaceByDeviceName(); // 檢查device_item內FullName為空的值,以points取代 - await niagaraDataSynchronizeRepository.CheckItemIsShowHistory(); - result = true; + if (ds.Count > 0) + { + //string ss = ds.Where(x => x.tag_name != "").FirstOrDefault().tag_name; + //var building = ss.Split("_")[0]; - apiResult.Code = "0000"; - apiResult.Data = result; + var building = ds.FirstOrDefault().device_building_tag; + await niagaraDataSynchronizeRepository.InsertItemFromNiagara(ds, building); // insert 暫存table import_niagara_item + await niagaraDataSynchronizeRepository.DeviceItemComparison(); //insert device_item + await niagaraDataSynchronizeRepository.CheckItemDiffFullNameAndCover(); // update device_item.fullname + await niagaraDataSynchronizeRepository.ItemCheckFullNameEmptyReplaceByDeviceName(); // 檢查device_item內FullName為空的值,以points取代 + await niagaraDataSynchronizeRepository.CheckItemIsShowHistory(); + result = true; + + apiResult.Code = "0000"; + apiResult.Data = result; + } + } catch (Exception exception) { diff --git a/Backend/Services/Implement/webRequestService.cs b/Backend/Services/Implement/webRequestService.cs index 994120b..208940b 100644 --- a/Backend/Services/Implement/webRequestService.cs +++ b/Backend/Services/Implement/webRequestService.cs @@ -134,8 +134,10 @@ namespace Backend.Services.Implement /// public List obixHisQuery(string bqlUrlString, string urlString, string slot) { - String username = "obixUser"; - String password = "Admin123456"; + //String username = "obixUser"; + //String password = "Admin123456"; + String username = "stanGG"; + String password = "St12345678"; String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password)); #region get control point data @@ -234,11 +236,12 @@ namespace Backend.Services.Implement row.device_system_tag = tagName.Split('_')[1]; row.device_floor_tag = tagName.Split('_')[4]; row.device_name_tag = tagName.Split('_')[3]; - row.device_point_name = tagName.Split('_')[8]; + row.device_point_name = tagName.Split('_')[5]; row.parent_path = stationName; //full_name 其實是點位名稱 point_name row.full_name = conPoint.Where(x => x.name == tagName).Select(x => x.displayName).FirstOrDefault(); + result.Add(row); } } } diff --git a/Backend/appsettings.Development.json b/Backend/appsettings.Development.json index 4805877..380f7c4 100644 --- a/Backend/appsettings.Development.json +++ b/Backend/appsettings.Development.json @@ -18,8 +18,8 @@ "Port": "js2LutKe+rdjzdxMPQUrvQ==", //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30 //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp - //"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome - "Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel + "Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome + //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel "Root": "SzdxEgaJJ7tcTCrUl2zKsA==", "Password": "FVAPxztxpY4gJJKQ/se4bQ==" } @@ -57,8 +57,8 @@ //"ObixHisBqlQuery": "7C/j7U8PmDqMxpb7f6gMpHFicuOA83OZeuWHBFdi/xpfEIklxyQ/wP75bEKwrdh+fXXgjmpc9cLX9GqbBC7eGw==", //三菱 //"ObixHisUrlQuery": "7C/j7U8PmDqMxpb7f6gMpD06cJcRzpVx0+IAssROlE4MlzSDPojSI17+XkQIL9Eu" //三菱 - //"UrlSlot": "e1dUH6340WkFoHPJYq7IYQ==", // 巨蛋棟 D2 - "UrlSlot": "f9cDBTw5PCfbDTOt4Kwbew==", // 旅館棟 slot:/Arena/H| + "UrlSlot": "e1dUH6340WkFoHPJYq7IYQ==", // 巨蛋棟 D2 + //"UrlSlot": "f9cDBTw5PCfbDTOt4Kwbew==", // 旅館棟 slot:/Arena/H| "ObixQuery": "7C/j7U8PmDqMxpb7f6gMpIDkLYyNwmXoqhx+N1G+fqQxEETrRbFLZfC7Sud5yX24CphfLlSUbfjft7gcP6v+gw==", //巨蛋 http://192.168.0.136:8082/obix/config/Program/ObixQuery/query/ "ObixHisBqlQuery": "7C/j7U8PmDqMxpb7f6gMpIDkLYyNwmXoqhx+N1G+fqQxEETrRbFLZfC7Sud5yX24CphfLlSUbfjft7gcP6v+gw==", // 巨蛋 http://192.168.0.136:8082/obix/config/Program/ObixQuery/query/ "ObixHisUrlQuery": "7C/j7U8PmDqMxpb7f6gMpEVUZrrjJT0WiTUBn0FzipXfBFsxYAX3plIWBcJ+oZzW", //巨蛋 http://192.168.0.136:8081/obix/histories diff --git a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs index 20f6c53..8429f7f 100644 --- a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs +++ b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs @@ -68,7 +68,7 @@ namespace Repository.BackendRepository.Implement }); StringBuilder sb = new StringBuilder(); - + bool isDome = false; //是否為巨蛋案 foreach (var row in ds2) { if (string.IsNullOrEmpty(row.tag_name)) continue; @@ -97,12 +97,13 @@ namespace Repository.BackendRepository.Implement { if (arrTag.Length == 5) { + isDome= true; sb.Append($@" insert into import_niagara_tag(niagara_tags, 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_full_name, atDateTime) values('" + row.tag_name + "', '" + //niagara_tags "', '" + //device_area_tag arrTag[0] + "', '" + //device_building_tag - arrTag[1] + "', '" + //device_system_tag + arrTag[1] + "', '" + //device_system_tag 巨蛋沒有大類,後面再用關聯的方式補上 arrTag[3] + "', '" + //device_name_tag arrTag[2] + "', '" + //device_floor_tag "', '" + //device_master_tag @@ -118,6 +119,20 @@ namespace Repository.BackendRepository.Implement { await conn.ExecuteAsync(sb.ToString()); sb.Clear(); + + //巨蛋特殊處理 + if (isDome) + { + sb.Append($@" -- tag 第二碼為小類(除了安全系統之外) + update import_niagara_tag set device_name_tag = device_system_tag + where device_system_tag <> 'S'; + + update import_niagara_tag a join dic_system b + on a.device_name_tag COLLATE utf8mb4_general_ci = b.s2_code + set device_system_tag = b.s1_code -- tag 第二碼為小類(除了安全系統之外) + where device_system_tag <> 'S'; -- 安全系統 第二段大類 第四段小類"); + await conn.ExecuteAsync(sb.ToString()); + } } } catch (Exception exception) diff --git a/z01_WinAPP/Program.cs b/z01_WinAPP/Program.cs index c9a90d4..5de7e2b 100644 --- a/z01_WinAPP/Program.cs +++ b/z01_WinAPP/Program.cs @@ -18,7 +18,7 @@ namespace tpDomeWinAPP Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - //Application.Run(new fmCheckTagName()); + // Application.Run(new fmCheckTagName()); Application.Run(new fmDecrypt()); } } diff --git a/z01_WinAPP/Service/webRequestSvc.cs b/z01_WinAPP/Service/webRequestSvc.cs index 1b27b2c..6d31260 100644 --- a/z01_WinAPP/Service/webRequestSvc.cs +++ b/z01_WinAPP/Service/webRequestSvc.cs @@ -144,8 +144,10 @@ namespace tpDomeWinAPP.Service public List obixQuery(string urlString, string bql) { List result = new List(); - String username = "obixUser"; - String password = "Admin123456"; + //String username = "obixUser"; + //String password = "Admin123456"; + String username = "stanGG"; + String password = "St12345678"; String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password)); String API_Url = urlString; @@ -168,9 +170,7 @@ namespace tpDomeWinAPP.Service xmlDoc.LoadXml(responseString); //xmlDoc.Load("N4v1021.xml");//N4v1021 - //xmlDoc.Save("N4.xml"); - - + //xmlDoc.Save("N4.xml"); string jsonText = JsonConvert.SerializeXmlNode(xmlDoc); @@ -197,7 +197,7 @@ namespace tpDomeWinAPP.Service } else if (i > 1 && i < s2.Length - 2) { - row.tag_name += "_" + s2[i]; + row.tag_name += "_" + s2[i].Replace("$3", ""); } } diff --git a/z01_WinAPP/fmCheckTagName.cs b/z01_WinAPP/fmCheckTagName.cs index 18b31b8..fcd70ef 100644 --- a/z01_WinAPP/fmCheckTagName.cs +++ b/z01_WinAPP/fmCheckTagName.cs @@ -166,10 +166,18 @@ namespace tpDomeWinAPP if (tabControl1.SelectedIndex == 0) { webRequestSvc svc = new webRequestSvc(); - string url_slot2 = "slot:/NTPC/B1|";//wsp - string bql = url_slot + "bql:select " + top100 + " * from control:ControlPoint ";//三菱: url_slot; wsp: url_slot2 - //ds = svc.obixQuery("http://60.251.164.125:8080/obix/config/Arena/Program/ObixQuery/query/", bql); - ds = svc.obixQuery("http://192.168.0.136:8080/obix/config/Program/ObixQuery/query/", bql);//三菱 + //string url_slot2 = "slot:/NTPC/B1|";//wsp + //string bql = url_slot + "bql:select " + top100 + " * from control:ControlPoint ";//三菱: url_slot; wsp: url_slot2 + ////ds = svc.obixQuery("http://60.251.164.125:8080/obix/config/Arena/Program/ObixQuery/query/", bql); + //ds = svc.obixQuery("http://192.168.0.136:8080/obix/config/Program/ObixQuery/query/", bql);//三菱 + //ds = svc.obixQuery("http://192.168.0.136:8081/obix/config/Program/ObixQuery/query/", bql);//wsp + //ds = svc.obixQuery("http://localhost:8080/obix/config/Program/ObixQuery/query/", bql); + + // string url_slot2 = "slot:/Arena/H/F1/B5F/FP/H_F1_B5F_FP_01|";//"ip:greencloud.fic.com.tw|foxs:|station:|slot:/Arena/H/F1/B5F/FP/H_F1_B5F_FP_01|"; + string url_slot2 = "slot:/Arena/H|"; + string bql = url_slot + "neql:hs:geoAddr=\"ER1\" ";//三菱: url_slot; wsp: url_slot2 + ds = svc.obixQuery("http://60.251.164.125:8080/obix/config/Arena/Program/ObixQuery/query/", bql); + //ds = svc.obixQuery("http://60.251.164.125:8080/obix/config/Program/ObixQuery/query/", bql);//三菱 //ds = svc.obixQuery("http://192.168.0.136:8081/obix/config/Program/ObixQuery/query/", bql);//wsp //ds = svc.obixQuery("http://localhost:8080/obix/config/Program/ObixQuery/query/", bql); dataGridView1.DataSource = ds;