backend: 巨蛋棟 niagara 同步

This commit is contained in:
GiteaAdmin 2023-04-21 02:06:32 +08:00
parent a38a4473dd
commit 2d17934443
7 changed files with 64 additions and 30 deletions

View File

@ -83,7 +83,8 @@ namespace Backend.Controllers
try 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 string LightSwitchLevel = await niagaraDataSynchronizeRepository.getLightSwitchLevel(); //獲取照明開關 是否在 device or device_node
await niagaraDataSynchronizeRepository.InsertNiagaraTagList(ds, building, tag_quantity); // 匯入 MySQL table: import_niagara_tag await niagaraDataSynchronizeRepository.InsertNiagaraTagList(ds, building, tag_quantity); // 匯入 MySQL table: import_niagara_tag
await niagaraDataSynchronizeRepository.DeviceComparison(LightSwitchLevel); await niagaraDataSynchronizeRepository.DeviceComparison(LightSwitchLevel);
@ -147,16 +148,23 @@ namespace Backend.Controllers
ApiResult<bool> apiResult = new ApiResult<bool>(); ApiResult<bool> apiResult = new ApiResult<bool>();
try try
{ {
var building = ds.FirstOrDefault().device_building_tag; if (ds.Count > 0)
await niagaraDataSynchronizeRepository.InsertItemFromNiagara(ds, building); // insert 暫存table import_niagara_item {
await niagaraDataSynchronizeRepository.DeviceItemComparison(); //insert device_item //string ss = ds.Where(x => x.tag_name != "").FirstOrDefault().tag_name;
await niagaraDataSynchronizeRepository.CheckItemDiffFullNameAndCover(); // update device_item.fullname //var building = ss.Split("_")[0];
await niagaraDataSynchronizeRepository.ItemCheckFullNameEmptyReplaceByDeviceName(); // 檢查device_item內FullName為空的值以points取代
await niagaraDataSynchronizeRepository.CheckItemIsShowHistory(); var building = ds.FirstOrDefault().device_building_tag;
result = true; 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;
}
apiResult.Code = "0000";
apiResult.Data = result;
} }
catch (Exception exception) catch (Exception exception)
{ {

View File

@ -134,8 +134,10 @@ namespace Backend.Services.Implement
/// <returns></returns> /// <returns></returns>
public List<ImpNiaItem> obixHisQuery(string bqlUrlString, string urlString, string slot) public List<ImpNiaItem> obixHisQuery(string bqlUrlString, string urlString, string slot)
{ {
String username = "obixUser"; //String username = "obixUser";
String password = "Admin123456"; //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 encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
#region get control point data #region get control point data
@ -234,11 +236,12 @@ namespace Backend.Services.Implement
row.device_system_tag = tagName.Split('_')[1]; row.device_system_tag = tagName.Split('_')[1];
row.device_floor_tag = tagName.Split('_')[4]; row.device_floor_tag = tagName.Split('_')[4];
row.device_name_tag = tagName.Split('_')[3]; 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; row.parent_path = stationName;
//full_name 其實是點位名稱 point_name //full_name 其實是點位名稱 point_name
row.full_name = conPoint.Where(x => x.name == tagName).Select(x => x.displayName).FirstOrDefault(); row.full_name = conPoint.Where(x => x.name == tagName).Select(x => x.displayName).FirstOrDefault();
result.Add(row);
} }
} }
} }

View File

@ -18,8 +18,8 @@
"Port": "js2LutKe+rdjzdxMPQUrvQ==", "Port": "js2LutKe+rdjzdxMPQUrvQ==",
//"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30 //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30
//"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
//"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome "Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==", "Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
"Password": "FVAPxztxpY4gJJKQ/se4bQ==" "Password": "FVAPxztxpY4gJJKQ/se4bQ=="
} }
@ -57,8 +57,8 @@
//"ObixHisBqlQuery": "7C/j7U8PmDqMxpb7f6gMpHFicuOA83OZeuWHBFdi/xpfEIklxyQ/wP75bEKwrdh+fXXgjmpc9cLX9GqbBC7eGw==", // //"ObixHisBqlQuery": "7C/j7U8PmDqMxpb7f6gMpHFicuOA83OZeuWHBFdi/xpfEIklxyQ/wP75bEKwrdh+fXXgjmpc9cLX9GqbBC7eGw==", //
//"ObixHisUrlQuery": "7C/j7U8PmDqMxpb7f6gMpD06cJcRzpVx0+IAssROlE4MlzSDPojSI17+XkQIL9Eu" // //"ObixHisUrlQuery": "7C/j7U8PmDqMxpb7f6gMpD06cJcRzpVx0+IAssROlE4MlzSDPojSI17+XkQIL9Eu" //
//"UrlSlot": "e1dUH6340WkFoHPJYq7IYQ==", // D2 "UrlSlot": "e1dUH6340WkFoHPJYq7IYQ==", // D2
"UrlSlot": "f9cDBTw5PCfbDTOt4Kwbew==", // slot:/Arena/H| //"UrlSlot": "f9cDBTw5PCfbDTOt4Kwbew==", // slot:/Arena/H|
"ObixQuery": "7C/j7U8PmDqMxpb7f6gMpIDkLYyNwmXoqhx+N1G+fqQxEETrRbFLZfC7Sud5yX24CphfLlSUbfjft7gcP6v+gw==", // http://192.168.0.136:8082/obix/config/Program/ObixQuery/query/ "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/ "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 "ObixHisUrlQuery": "7C/j7U8PmDqMxpb7f6gMpEVUZrrjJT0WiTUBn0FzipXfBFsxYAX3plIWBcJ+oZzW", // http://192.168.0.136:8081/obix/histories

View File

@ -68,7 +68,7 @@ namespace Repository.BackendRepository.Implement
}); });
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
bool isDome = false; //是否為巨蛋案
foreach (var row in ds2) foreach (var row in ds2)
{ {
if (string.IsNullOrEmpty(row.tag_name)) continue; if (string.IsNullOrEmpty(row.tag_name)) continue;
@ -97,12 +97,13 @@ namespace Repository.BackendRepository.Implement
{ {
if (arrTag.Length == 5) if (arrTag.Length == 5)
{ {
isDome= true;
sb.Append($@" insert into import_niagara_tag(niagara_tags, device_area_tag, device_building_tag, device_system_tag, 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('" + 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 row.tag_name + "', '" + //niagara_tags
"', '" + //device_area_tag "', '" + //device_area_tag
arrTag[0] + "', '" + //device_building_tag arrTag[0] + "', '" + //device_building_tag
arrTag[1] + "', '" + //device_system_tag arrTag[1] + "', '" + //device_system_tag 巨蛋沒有大類,後面再用關聯的方式補上
arrTag[3] + "', '" + //device_name_tag arrTag[3] + "', '" + //device_name_tag
arrTag[2] + "', '" + //device_floor_tag arrTag[2] + "', '" + //device_floor_tag
"', '" + //device_master_tag "', '" + //device_master_tag
@ -118,6 +119,20 @@ namespace Repository.BackendRepository.Implement
{ {
await conn.ExecuteAsync(sb.ToString()); await conn.ExecuteAsync(sb.ToString());
sb.Clear(); 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) catch (Exception exception)

View File

@ -18,7 +18,7 @@ namespace tpDomeWinAPP
Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
//Application.Run(new fmCheckTagName()); // Application.Run(new fmCheckTagName());
Application.Run(new fmDecrypt()); Application.Run(new fmDecrypt());
} }
} }

View File

@ -144,8 +144,10 @@ namespace tpDomeWinAPP.Service
public List<device_value2> obixQuery(string urlString, string bql) public List<device_value2> obixQuery(string urlString, string bql)
{ {
List<device_value2> result = new List<device_value2>(); List<device_value2> result = new List<device_value2>();
String username = "obixUser"; //String username = "obixUser";
String password = "Admin123456"; //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 encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
String API_Url = urlString; String API_Url = urlString;
@ -171,8 +173,6 @@ namespace tpDomeWinAPP.Service
//xmlDoc.Save("N4.xml"); //xmlDoc.Save("N4.xml");
string jsonText = JsonConvert.SerializeXmlNode(xmlDoc); string jsonText = JsonConvert.SerializeXmlNode(xmlDoc);
// JObject resultVal = (JObject)JsonConvert.DeserializeObject(jsonText); // JObject resultVal = (JObject)JsonConvert.DeserializeObject(jsonText);
var data = Welcome.FromJson(jsonText); var data = Welcome.FromJson(jsonText);
@ -197,7 +197,7 @@ namespace tpDomeWinAPP.Service
} }
else if (i > 1 && i < s2.Length - 2) else if (i > 1 && i < s2.Length - 2)
{ {
row.tag_name += "_" + s2[i]; row.tag_name += "_" + s2[i].Replace("$3", "");
} }
} }

View File

@ -166,10 +166,18 @@ namespace tpDomeWinAPP
if (tabControl1.SelectedIndex == 0) if (tabControl1.SelectedIndex == 0)
{ {
webRequestSvc svc = new webRequestSvc(); webRequestSvc svc = new webRequestSvc();
string url_slot2 = "slot:/NTPC/B1|";//wsp //string url_slot2 = "slot:/NTPC/B1|";//wsp
string bql = url_slot + "bql:select " + top100 + " * from control:ControlPoint ";//三菱: url_slot; wsp: url_slot2 //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://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: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://192.168.0.136:8081/obix/config/Program/ObixQuery/query/", bql);//wsp
//ds = svc.obixQuery("http://localhost:8080/obix/config/Program/ObixQuery/query/", bql); //ds = svc.obixQuery("http://localhost:8080/obix/config/Program/ObixQuery/query/", bql);
dataGridView1.DataSource = ds; dataGridView1.DataSource = ds;