[後端] 修改排程parking, 修改device item history流程, 修改api使用時間過於長問題, 修改is_link 判斷
This commit is contained in:
parent
919130d94f
commit
420af41026
@ -13,6 +13,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
using NPOI.SS.Formula.Functions;
|
using NPOI.SS.Formula.Functions;
|
||||||
using Repository.Helper;
|
using Repository.Helper;
|
||||||
using Microsoft.AspNetCore.Routing.Matching;
|
using Microsoft.AspNetCore.Routing.Matching;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Backend.Controllers
|
namespace Backend.Controllers
|
||||||
{
|
{
|
||||||
@ -192,7 +193,7 @@ namespace Backend.Controllers
|
|||||||
public async Task<ApiResult<bool>> DevIteComData([FromBody] List<ImpNiaItem> ds)
|
public async Task<ApiResult<bool>> DevIteComData([FromBody] List<ImpNiaItem> ds)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
var oldDs = JsonConvert.DeserializeObject<List<ImpNiaItem>>(JsonConvert.SerializeObject(ds));
|
||||||
ApiResult<bool> apiResult = new ApiResult<bool>();
|
ApiResult<bool> apiResult = new ApiResult<bool>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -200,14 +201,7 @@ namespace Backend.Controllers
|
|||||||
{
|
{
|
||||||
//string ss = ds.Where(x => x.tag_name != "").FirstOrDefault().tag_name;
|
//string ss = ds.Where(x => x.tag_name != "").FirstOrDefault().tag_name;
|
||||||
//var building = ss.Split("_")[0];
|
//var building = ss.Split("_")[0];
|
||||||
|
|
||||||
var building = ds.GroupBy(x => x.device_building_tag).Select(x => x.Key).ToList();
|
var building = ds.GroupBy(x => x.device_building_tag).Select(x => x.Key).ToList();
|
||||||
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();
|
|
||||||
|
|
||||||
#region 歷史資料處理
|
#region 歷史資料處理
|
||||||
ds.Clear();
|
ds.Clear();
|
||||||
var isDome = await backendRepository.GetOneAsync<string>("select system_value from variable where deleted = 0 and system_type = 'project_name';");
|
var isDome = await backendRepository.GetOneAsync<string>("select system_value from variable where deleted = 0 and system_type = 'project_name';");
|
||||||
@ -229,6 +223,12 @@ namespace Backend.Controllers
|
|||||||
await niagaraDataSynchronizeRepository.RecoverSysTag("import_niagara_item_history"); // recover missing deivce_system_tag
|
await niagaraDataSynchronizeRepository.RecoverSysTag("import_niagara_item_history"); // recover missing deivce_system_tag
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
await niagaraDataSynchronizeRepository.InsertItemFromNiagara(oldDs, 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;
|
result = true;
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
|
@ -176,103 +176,106 @@ namespace Backend.Services.Implement
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region main program
|
|
||||||
List<ImpNiaItem> result = new List<ImpNiaItem>();
|
List<ImpNiaItem> result = new List<ImpNiaItem>();
|
||||||
String API_Url = urlString;
|
#region main program (deleted)
|
||||||
|
//String API_Url = urlString;
|
||||||
|
|
||||||
HttpWebRequest Postrequest = (HttpWebRequest)WebRequest.Create(API_Url);
|
//HttpWebRequest Postrequest = (HttpWebRequest)WebRequest.Create(API_Url);
|
||||||
Postrequest.Method = "GET";
|
//Postrequest.Method = "GET";
|
||||||
Postrequest.Headers.Add("Authorization", "Basic " + encoded);
|
//Postrequest.Headers.Add("Authorization", "Basic " + encoded);
|
||||||
Postrequest.PreAuthenticate = true;
|
//Postrequest.PreAuthenticate = true;
|
||||||
Postrequest.Timeout = System.Threading.Timeout.Infinite;
|
//Postrequest.Timeout = System.Threading.Timeout.Infinite;
|
||||||
|
|
||||||
HttpWebResponse response = (HttpWebResponse)Postrequest.GetResponse();
|
//HttpWebResponse response = (HttpWebResponse)Postrequest.GetResponse();
|
||||||
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
|
//var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
|
||||||
|
|
||||||
XmlDocument xmlDoc = new XmlDocument();
|
//XmlDocument xmlDoc = new XmlDocument();
|
||||||
xmlDoc.LoadXml(responseString);
|
//xmlDoc.LoadXml(responseString);
|
||||||
|
|
||||||
//ref https://stackoverflow.com/questions/642293/how-do-i-read-and-parse-an-xml-file-in-c
|
////ref https://stackoverflow.com/questions/642293/how-do-i-read-and-parse-an-xml-file-in-c
|
||||||
foreach (XmlNode node in xmlDoc.DocumentElement.ChildNodes)
|
//foreach (XmlNode node in xmlDoc.DocumentElement.ChildNodes)
|
||||||
{
|
//{
|
||||||
var stationName = node.Attributes["name"].InnerText; // WSP_Supervisor
|
// var stationName = node.Attributes["name"].InnerText; // WSP_Supervisor
|
||||||
oneStationName = oneStationName ?? stationName;
|
// if (stationName.Split("_").Length > 1 && stationName.Split("_")[1] == building_tag.Split("_")[0])
|
||||||
String API_Url2 = urlString + "/" + stationName; // http://192.168.0.136:8081/obix/histories/WSP_Supervisor
|
// {
|
||||||
|
// oneStationName = oneStationName ?? stationName;
|
||||||
|
// String API_Url2 = urlString + "/" + stationName; // http://192.168.0.136:8081/obix/histories/WSP_Supervisor
|
||||||
|
|
||||||
HttpWebRequest Postrequest2 = (HttpWebRequest)WebRequest.Create(API_Url2);
|
// HttpWebRequest Postrequest2 = (HttpWebRequest)WebRequest.Create(API_Url2);
|
||||||
Postrequest2.Method = "GET";
|
// Postrequest2.Method = "GET";
|
||||||
Postrequest2.Headers.Add("Authorization", "Basic " + encoded);
|
// Postrequest2.Headers.Add("Authorization", "Basic " + encoded);
|
||||||
Postrequest2.PreAuthenticate = true;
|
// Postrequest2.PreAuthenticate = true;
|
||||||
Postrequest2.Timeout = System.Threading.Timeout.Infinite;
|
// Postrequest2.Timeout = System.Threading.Timeout.Infinite;
|
||||||
|
|
||||||
HttpWebResponse response2 = (HttpWebResponse)Postrequest2.GetResponse();
|
// HttpWebResponse response2 = (HttpWebResponse)Postrequest2.GetResponse();
|
||||||
var responseString2 = new StreamReader(response2.GetResponseStream()).ReadToEnd();
|
// var responseString2 = new StreamReader(response2.GetResponseStream()).ReadToEnd();
|
||||||
|
|
||||||
XmlDocument xmlDoc2 = new XmlDocument();
|
// XmlDocument xmlDoc2 = new XmlDocument();
|
||||||
xmlDoc2.LoadXml(responseString2);
|
// xmlDoc2.LoadXml(responseString2);
|
||||||
// Create a namespace manager to handle the XML namespace
|
// // Create a namespace manager to handle the XML namespace
|
||||||
XmlNamespaceManager namespaceManager = new XmlNamespaceManager(xmlDoc2.NameTable);
|
// XmlNamespaceManager namespaceManager = new XmlNamespaceManager(xmlDoc2.NameTable);
|
||||||
string xmlns = xmlDoc2.DocumentElement.GetAttribute("xmlns") ?? "http://obix.org/ns/schema/1.0";
|
// string xmlns = xmlDoc2.DocumentElement.GetAttribute("xmlns") ?? "http://obix.org/ns/schema/1.0";
|
||||||
namespaceManager.AddNamespace("obix", xmlns);
|
// namespaceManager.AddNamespace("obix", xmlns);
|
||||||
|
|
||||||
// Select all "ref" nodes using an XPath expression
|
// // Select all "ref" nodes using an XPath expression
|
||||||
XmlNodeList refNodes = xmlDoc2.SelectNodes($"//obix:ref[starts-with(@name, '{AreaTag ?? building_tag}')]", namespaceManager);
|
// XmlNodeList refNodes = xmlDoc2.SelectNodes($"//obix:ref[starts-with(@name, '{AreaTag ?? building_tag}')]", namespaceManager);
|
||||||
foreach (XmlNode node2 in refNodes)
|
// foreach (XmlNode node2 in refNodes)
|
||||||
{
|
// {
|
||||||
string tagName = node2.Attributes["name"].InnerText;
|
// string tagName = node2.Attributes["name"].InnerText;
|
||||||
if (tagName.Split('_').Length == 9)
|
// if (tagName.Split('_').Length == 9)
|
||||||
{
|
// {
|
||||||
ImpNiaItem row = new ImpNiaItem();
|
// ImpNiaItem row = new ImpNiaItem();
|
||||||
row.device_area_tag = tagName.Split('_')[0];
|
// row.device_area_tag = tagName.Split('_')[0];
|
||||||
row.device_building_tag = tagName.Split('_')[1];
|
// row.device_building_tag = tagName.Split('_')[1];
|
||||||
row.device_system_tag = tagName.Split('_')[2];
|
// row.device_system_tag = tagName.Split('_')[2];
|
||||||
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('_')[8];
|
||||||
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.Replace('_', '/') && !x.isHistory).Select(x => x.displayName).FirstOrDefault();
|
// row.full_name = conPoint.Where(x => x.name == tagName.Replace('_', '/') && !x.isHistory).Select(x => x.displayName).FirstOrDefault();
|
||||||
if (conPoint.Where(x => x.name == tagName.Replace('_', '/') && !x.isHistory).FirstOrDefault() != null)
|
// if (conPoint.Where(x => x.name == tagName.Replace('_', '/') && !x.isHistory).FirstOrDefault() != null)
|
||||||
conPoint.Where(x => x.name == tagName.Replace('_', '/') && !x.isHistory).FirstOrDefault().isHistory = true;
|
// conPoint.Where(x => x.name == tagName.Replace('_', '/') && !x.isHistory).FirstOrDefault().isHistory = true;
|
||||||
row.isHistory = true;
|
// row.isHistory = true;
|
||||||
|
|
||||||
result.Add(row);
|
// result.Add(row);
|
||||||
}
|
// }
|
||||||
else if (tagName.Split('_').Length == 6)
|
// else if (tagName.Split('_').Length == 6)
|
||||||
{ //巨蛋 tag 5 段版本
|
// { //巨蛋 tag 5 段版本
|
||||||
ImpNiaItem row = new ImpNiaItem();
|
// ImpNiaItem row = new ImpNiaItem();
|
||||||
if (tagName.Split('_')[1] == "S" || tagName.Split('_')[1] == "B" || tagName.Split('_')[1] == "CWB") //for security system and parking system
|
// if (tagName.Split('_')[1] == "S" || tagName.Split('_')[1] == "B" || tagName.Split('_')[1] == "CWB") //for security system and parking system
|
||||||
{
|
// {
|
||||||
row.device_building_tag = tagName.Split('_')[0];
|
// row.device_building_tag = tagName.Split('_')[0];
|
||||||
row.device_system_tag = tagName.Split('_')[1];
|
// row.device_system_tag = tagName.Split('_')[1];
|
||||||
row.device_floor_tag = tagName.Split('_')[2];
|
// row.device_floor_tag = tagName.Split('_')[2];
|
||||||
row.device_name_tag = tagName.Split('_')[3];
|
// row.device_name_tag = tagName.Split('_')[3];
|
||||||
row.device_point_name = tagName.Split('_')[5];
|
// row.device_point_name = tagName.Split('_')[5];
|
||||||
}
|
// }
|
||||||
else //for normal
|
// else //for normal
|
||||||
{
|
// {
|
||||||
row.device_building_tag = tagName.Split('_')[0];
|
// row.device_building_tag = tagName.Split('_')[0];
|
||||||
row.device_floor_tag = tagName.Split('_')[2];
|
// row.device_floor_tag = tagName.Split('_')[2];
|
||||||
row.device_name_tag = tagName.Split('_')[1];
|
// row.device_name_tag = tagName.Split('_')[1];
|
||||||
row.device_point_name = tagName.Split('_')[5];
|
// row.device_point_name = tagName.Split('_')[5];
|
||||||
}
|
// }
|
||||||
|
|
||||||
row.parent_path = stationName;
|
// row.parent_path = stationName;
|
||||||
//full_name 其實是點位名稱 point_name
|
// //full_name 其實是點位名稱 point_name
|
||||||
var deviceNumber = tagName.Substring(0, tagName.LastIndexOf(tagName.Split("_")[5]) - 1);
|
// var deviceNumber = tagName.Substring(0, tagName.LastIndexOf(tagName.Split("_")[5]) - 1);
|
||||||
var point = tagName.Split("_")[5];
|
// var point = tagName.Split("_")[5];
|
||||||
conPoint = conPoint.Where(x => x.name.Split("/").Length > 6).ToList();
|
// conPoint = conPoint.Where(x => x.name.Split("/").Length > 6).ToList();
|
||||||
row.full_name = conPoint.Where(x => x.name.Split("/")[5] == deviceNumber && x.name.Split("/")[6] == point && !x.isHistory).Select(x => x.displayName).FirstOrDefault();
|
// row.full_name = conPoint.Where(x => x.name.Split("/")[5] == deviceNumber && x.name.Split("/")[6] == point && !x.isHistory).Select(x => x.displayName).FirstOrDefault();
|
||||||
if (conPoint.Where(x => x.name.Split("/")[5] == deviceNumber && x.name.Split("/")[6] == point && !x.isHistory).FirstOrDefault() != null)
|
// if (conPoint.Where(x => x.name.Split("/")[5] == deviceNumber && x.name.Split("/")[6] == point && !x.isHistory).FirstOrDefault() != null)
|
||||||
conPoint.Where(x => x.name.Split("/")[5] == deviceNumber && x.name.Split("/")[6] == point && !x.isHistory).FirstOrDefault().isHistory = true;
|
// conPoint.Where(x => x.name.Split("/")[5] == deviceNumber && x.name.Split("/")[6] == point && !x.isHistory).FirstOrDefault().isHistory = true;
|
||||||
row.isHistory = true;
|
// row.isHistory = true;
|
||||||
result.Add(row);
|
// result.Add(row);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
#endregion
|
#endregion
|
||||||
var newConPoint = conPoint.Where(x => !x.isHistory).ToArray();
|
|
||||||
foreach(var n in newConPoint)
|
foreach(var n in conPoint)
|
||||||
{
|
{
|
||||||
if (n.name.Split('/').Length == 9)
|
if (n.name.Split('/').Length == 9)
|
||||||
{
|
{
|
||||||
@ -283,9 +286,7 @@ namespace Backend.Services.Implement
|
|||||||
device_system_tag = n.name.Split('/')[2],
|
device_system_tag = n.name.Split('/')[2],
|
||||||
device_name_tag = n.name.Split('/')[3],
|
device_name_tag = n.name.Split('/')[3],
|
||||||
device_point_name = n.name.Split('/')[8],
|
device_point_name = n.name.Split('/')[8],
|
||||||
full_name = n.displayName,
|
full_name = n.displayName
|
||||||
parent_path = oneStationName,
|
|
||||||
isHistory = n.isHistory
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (n.name.Split('/').Length == 7) // Arena/D2/CWB/L110/CAP/D2_CWB_L110_CAP_MET1/Summery
|
else if (n.name.Split('/').Length == 7) // Arena/D2/CWB/L110/CAP/D2_CWB_L110_CAP_MET1/Summery
|
||||||
@ -298,9 +299,7 @@ namespace Backend.Services.Implement
|
|||||||
device_floor_tag = n.name.Split('/')[3],
|
device_floor_tag = n.name.Split('/')[3],
|
||||||
device_name_tag = n.name.Split('/')[4],
|
device_name_tag = n.name.Split('/')[4],
|
||||||
device_point_name = n.name.Split('/')[6],
|
device_point_name = n.name.Split('/')[6],
|
||||||
full_name = n.displayName,
|
full_name = n.displayName
|
||||||
parent_path = oneStationName,
|
|
||||||
isHistory = n.isHistory
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else //for normal
|
else //for normal
|
||||||
@ -312,9 +311,7 @@ namespace Backend.Services.Implement
|
|||||||
device_floor_tag = n.name.Split('/')[3],
|
device_floor_tag = n.name.Split('/')[3],
|
||||||
device_name_tag = n.name.Split('/')[2],
|
device_name_tag = n.name.Split('/')[2],
|
||||||
device_point_name = n.name.Split('/')[6],
|
device_point_name = n.name.Split('/')[6],
|
||||||
full_name = n.displayName,
|
full_name = n.displayName
|
||||||
parent_path = oneStationName,
|
|
||||||
isHistory = n.isHistory
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,19 +121,19 @@ namespace BackendWorkerService
|
|||||||
//);
|
//);
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region 停車場管理(設定每 5秒 執行一次)
|
#region 停車場管理(設定每 5秒 執行一次)
|
||||||
//services.AddSingleton<ParkingJob>();
|
services.AddSingleton<ParkingJob>();
|
||||||
//services.AddSingleton(
|
services.AddSingleton(
|
||||||
//new JobSchedule(jobType: typeof(ParkingJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:ParkingJob"))
|
new JobSchedule(jobType: typeof(ParkingJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:ParkingJob"))
|
||||||
//);
|
);
|
||||||
//#endregion
|
#endregion
|
||||||
|
|
||||||
//#region 電錶歸檔(設定每 小時 執行一次)
|
#region 電錶歸檔(設定每 小時 執行一次)
|
||||||
//services.AddSingleton<ArchiveElectricMeterHourJob>();
|
services.AddSingleton<ArchiveElectricMeterHourJob>();
|
||||||
//services.AddSingleton(
|
services.AddSingleton(
|
||||||
//new JobSchedule(jobType: typeof(ArchiveElectricMeterHourJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:ArchiveElectricMeterHourJob"))
|
new JobSchedule(jobType: typeof(ArchiveElectricMeterHourJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:ArchiveElectricMeterHourJob"))
|
||||||
//);
|
);
|
||||||
//#endregion
|
#endregion
|
||||||
|
|
||||||
#region 電錶歸檔(設定每 天 執行一次)
|
#region 電錶歸檔(設定每 天 執行一次)
|
||||||
services.AddSingleton<ArchiveElectricMeterDayJob>();
|
services.AddSingleton<ArchiveElectricMeterDayJob>();
|
||||||
@ -143,10 +143,10 @@ namespace BackendWorkerService
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 定時取得氣象API
|
#region 定時取得氣象API
|
||||||
services.AddSingleton<Quartz.Jobs.WeatherAPIJob>();
|
//services.AddSingleton<Quartz.Jobs.WeatherAPIJob>();
|
||||||
services.AddSingleton(
|
//services.AddSingleton(
|
||||||
new JobSchedule(jobType: typeof(Quartz.Jobs.WeatherAPIJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:WeatherAPIJob"))
|
//new JobSchedule(jobType: typeof(Quartz.Jobs.WeatherAPIJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:WeatherAPIJob"))
|
||||||
);
|
//);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}).ConfigureLogging((hostContext, logFactory) => {
|
}).ConfigureLogging((hostContext, logFactory) => {
|
||||||
|
@ -69,6 +69,8 @@ namespace BackendWorkerService.Quartz.Jobs
|
|||||||
spaceRequest.Method = "GET";
|
spaceRequest.Method = "GET";
|
||||||
//request.Headers.Add("Authorization", "Basic " + encoded);
|
//request.Headers.Add("Authorization", "Basic " + encoded);
|
||||||
spaceRequest.PreAuthenticate = true;
|
spaceRequest.PreAuthenticate = true;
|
||||||
|
spaceRequest.Timeout = System.Threading.Timeout.Infinite;
|
||||||
|
spaceRequest.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
|
||||||
|
|
||||||
//Stopwatch stopWatch = new Stopwatch();
|
//Stopwatch stopWatch = new Stopwatch();
|
||||||
//stopWatch.Start();
|
//stopWatch.Start();
|
||||||
@ -116,6 +118,7 @@ namespace BackendWorkerService.Quartz.Jobs
|
|||||||
request.Method = "POST";
|
request.Method = "POST";
|
||||||
request.Headers.Add("Authorization", "Basic " + encoded);
|
request.Headers.Add("Authorization", "Basic " + encoded);
|
||||||
request.PreAuthenticate = true;
|
request.PreAuthenticate = true;
|
||||||
|
request.Timeout = System.Threading.Timeout.Infinite;
|
||||||
|
|
||||||
var real = $@"<real val='{area.Remain}' />";
|
var real = $@"<real val='{area.Remain}' />";
|
||||||
byte[] realByteArray = Encoding.UTF8.GetBytes(real);
|
byte[] realByteArray = Encoding.UTF8.GetBytes(real);
|
||||||
@ -123,7 +126,6 @@ namespace BackendWorkerService.Quartz.Jobs
|
|||||||
{
|
{
|
||||||
reqStream.Write(realByteArray, 0, realByteArray.Length);
|
reqStream.Write(realByteArray, 0, realByteArray.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||||||
var responseContent = new StreamReader(response.GetResponseStream()).ReadToEnd();
|
var responseContent = new StreamReader(response.GetResponseStream()).ReadToEnd();
|
||||||
|
|
||||||
@ -180,7 +182,7 @@ namespace BackendWorkerService.Quartz.Jobs
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 取得設備資訊
|
#region 取得設備資訊
|
||||||
if (await task_Detail.GetNeedWorkTask("ParkingJob", "Device"))
|
if (await task_Detail.GetNeedWorkTask("ParkingJob", "Device"))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -191,6 +193,7 @@ namespace BackendWorkerService.Quartz.Jobs
|
|||||||
equipmentRequest.Method = "GET";
|
equipmentRequest.Method = "GET";
|
||||||
//request.Headers.Add("Authorization", "Basic " + encoded);
|
//request.Headers.Add("Authorization", "Basic " + encoded);
|
||||||
equipmentRequest.PreAuthenticate = true;
|
equipmentRequest.PreAuthenticate = true;
|
||||||
|
equipmentRequest.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
|
||||||
|
|
||||||
HttpWebResponse equipmentResponse = (HttpWebResponse)equipmentRequest.GetResponse();
|
HttpWebResponse equipmentResponse = (HttpWebResponse)equipmentRequest.GetResponse();
|
||||||
var equipmentResponseContent = new StreamReader(equipmentResponse.GetResponseStream()).ReadToEnd();
|
var equipmentResponseContent = new StreamReader(equipmentResponse.GetResponseStream()).ReadToEnd();
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
"MessageNotificationJob": "0 0 2 * * ?",
|
"MessageNotificationJob": "0 0 2 * * ?",
|
||||||
"DataDeliveryJob": "0 0 2 * * ?",
|
"DataDeliveryJob": "0 0 2 * * ?",
|
||||||
"RegularUpdateDBTableJob": "0 0 2 * * ?",
|
"RegularUpdateDBTableJob": "0 0 2 * * ?",
|
||||||
"ParkingJob": "0 0 2 * * ?",
|
"ParkingJob": "0/5 * * * * ?",
|
||||||
"ArchiveElectricMeterHourJob": "0 0 2 * * ?",
|
"ArchiveElectricMeterHourJob": "0 0 2 * * ?",
|
||||||
"ArchiveElectricMeterDayJob": "0/5 * * * * ?",
|
"ArchiveElectricMeterDayJob": "0/5 * * * * ?",
|
||||||
"WeatherAPIJob": "0 0 2 * * ?"
|
"WeatherAPIJob": "0 0 2 * * ?"
|
||||||
@ -25,7 +25,8 @@
|
|||||||
//"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
|
||||||
"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //mcut
|
//"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //mcut
|
||||||
|
"Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821
|
||||||
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
|
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
|
||||||
"Password": "FVAPxztxpY4gJJKQ/se4bQ=="
|
"Password": "FVAPxztxpY4gJJKQ/se4bQ=="
|
||||||
},
|
},
|
||||||
|
@ -25,7 +25,8 @@
|
|||||||
//"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
|
||||||
"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //mcut
|
//"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //mcut
|
||||||
|
"Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821
|
||||||
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
|
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
|
||||||
"Password": "FVAPxztxpY4gJJKQ/se4bQ=="
|
"Password": "FVAPxztxpY4gJJKQ/se4bQ=="
|
||||||
},
|
},
|
||||||
|
@ -200,7 +200,7 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
order by b.priority, v1.system_priority, me.priority, v2.system_priority, v2.created_at DESC", new { Account = account });
|
order by b.priority, v1.system_priority, me.priority, v2.system_priority, v2.created_at DESC", new { Account = account });
|
||||||
|
|
||||||
var floorsql = await backendRepository.GetAllAsync<Floorsql>(@"
|
var floorsql = await backendRepository.GetAllAsync<Floorsql>(@"
|
||||||
select * from (select * from sub_system_floor ssf where ssf.deleted = 0 and ssf.status = 0) a
|
select * from (select * from sub_system_floor ssf where ssf.deleted = 0 and ssf.status = 0 and ssf.is_link = 1) a
|
||||||
left join floor on floor.full_name = a.floor_tag order by floor.priority;");
|
left join floor on floor.full_name = a.floor_tag order by floor.priority;");
|
||||||
|
|
||||||
var common = await backendRepository.GetAllAsync<KeyValue>($@"select ap.building_tag Name,ap.ShowView Value from auth_page ap
|
var common = await backendRepository.GetAllAsync<KeyValue>($@"select ap.building_tag Name,ap.ShowView Value from auth_page ap
|
||||||
@ -329,7 +329,7 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
|
|
||||||
List<Floor> Floors = new List<Floor>();
|
List<Floor> Floors = new List<Floor>();
|
||||||
var floorsql = await backendRepository.GetAllAsync<Floorsql>($@"
|
var floorsql = await backendRepository.GetAllAsync<Floorsql>($@"
|
||||||
select * from (select * from sub_system_floor ssf where ssf.deleted = 0 and ssf.status = 0 and ssf.building_tag = '{get.building_tag}' and ssf.main_system_tag = '{get.main_system_tag}' and ssf.sub_system_tag = '{get.sub_system_tag}') a
|
select * from (select * from sub_system_floor ssf where ssf.deleted = 0 and ssf.status = 0 and ssf.building_tag = '{get.building_tag}' and ssf.main_system_tag = '{get.main_system_tag}' and ssf.sub_system_tag = '{get.sub_system_tag}' and ssf.is_link = 1) a
|
||||||
left join floor on floor.full_name = a.floor_tag and a.building_tag = floor.building_tag
|
left join floor on floor.full_name = a.floor_tag and a.building_tag = floor.building_tag
|
||||||
where floor.deleted = 0
|
where floor.deleted = 0
|
||||||
order by floor.priority");
|
order by floor.priority");
|
||||||
|
@ -343,9 +343,12 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
join userinfo c on c.role_guid = a.role_guid
|
join userinfo c on c.role_guid = a.role_guid
|
||||||
join variable v2 on b.ShowView = v2.id and v2.system_type = @sub_system_type
|
join variable v2 on b.ShowView = v2.id and v2.system_type = @sub_system_type
|
||||||
join variable v1 on v1.id = v2.system_parent_id and v1.system_type = @main_system_type
|
join variable v1 on v1.id = v2.system_parent_id and v1.system_type = @main_system_type
|
||||||
join device d on v1.system_value = d.device_system_tag and v2.system_value = d.device_name_tag and d.deleted = 0 and d.visible = 1 and d.is_link = 1
|
join (
|
||||||
join device_item di on d.device_system_tag=di.device_system_tag and d.device_name_tag=di.device_name_tag
|
select distinct device_system_tag, device_name_tag, device_serial_tag, device_number, full_name from device d where d.deleted = 0 and d.visible = 1 and d.is_link = 1 limit 1000000
|
||||||
and di.is_link = 1 and di.is_show_history = 1
|
) d on v1.system_value = d.device_system_tag and v2.system_value = d.device_name_tag
|
||||||
|
join (
|
||||||
|
select distinct device_system_tag, device_name_tag, is_show_history from device_item where deleted = 0 and is_link = 1 and is_show_history = 1
|
||||||
|
) di on d.device_system_tag=di.device_system_tag and d.device_name_tag=di.device_name_tag
|
||||||
where c.account = @account
|
where c.account = @account
|
||||||
order by v1.system_priority, v2.system_priority", new { @account = myUser.account, @sub_system_type = sub_system_type, @main_system_type = main_system_type });
|
order by v1.system_priority, v2.system_priority", new { @account = myUser.account, @sub_system_type = sub_system_type, @main_system_type = main_system_type });
|
||||||
var dbbuilding = await frontendRepository.GetAllAsync<History_Build>(
|
var dbbuilding = await frontendRepository.GetAllAsync<History_Build>(
|
||||||
|
@ -242,9 +242,7 @@ namespace Repository.BackendRepository.Implement
|
|||||||
device_system_tag = x.device_system_tag,
|
device_system_tag = x.device_system_tag,
|
||||||
device_name_tag = x.device_name_tag,
|
device_name_tag = x.device_name_tag,
|
||||||
device_point_name = x.device_point_name,
|
device_point_name = x.device_point_name,
|
||||||
full_name = x.full_name,
|
full_name = x.full_name
|
||||||
parent_path = x.parent_path,
|
|
||||||
isHistory = x.isHistory
|
|
||||||
})
|
})
|
||||||
.Select(x => new ImpNiaItem
|
.Select(x => new ImpNiaItem
|
||||||
{
|
{
|
||||||
@ -253,9 +251,7 @@ namespace Repository.BackendRepository.Implement
|
|||||||
device_system_tag = x.Key.device_system_tag,
|
device_system_tag = x.Key.device_system_tag,
|
||||||
device_name_tag = x.Key.device_name_tag,
|
device_name_tag = x.Key.device_name_tag,
|
||||||
device_point_name = x.Key.device_point_name,
|
device_point_name = x.Key.device_point_name,
|
||||||
full_name = x.Key.full_name,
|
full_name = x.Key.full_name
|
||||||
parent_path = x.Key.parent_path,
|
|
||||||
isHistory = x.Key.isHistory
|
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
@ -269,9 +265,9 @@ namespace Repository.BackendRepository.Implement
|
|||||||
row.device_system_tag + "', '" +
|
row.device_system_tag + "', '" +
|
||||||
row.device_name_tag + "', '" +
|
row.device_name_tag + "', '" +
|
||||||
row.device_point_name + "', '" +
|
row.device_point_name + "', '" +
|
||||||
row.parent_path + "', '" +
|
"" + "', '" +
|
||||||
row.full_name + "'," +
|
row.full_name + "'," +
|
||||||
row.isHistory +
|
"0" +
|
||||||
");");
|
");");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,6 +288,34 @@ namespace Repository.BackendRepository.Implement
|
|||||||
await conn.ExecuteAsync(sb.ToString());
|
await conn.ExecuteAsync(sb.ToString());
|
||||||
}
|
}
|
||||||
sb.Clear();
|
sb.Clear();
|
||||||
|
|
||||||
|
sb.Append($@"SET SQL_SAFE_UPDATES = 0;
|
||||||
|
update import_niagara_item ini
|
||||||
|
join (
|
||||||
|
select device_building_tag, device_system_tag, device_name_tag, device_point_name
|
||||||
|
from import_niagara_item_history
|
||||||
|
group by device_building_tag, device_system_tag, device_name_tag, device_point_name
|
||||||
|
) as inih on ini.device_building_tag = inih.device_building_tag and ini.device_system_tag = inih.device_system_tag and ini.device_name_tag = inih.device_name_tag
|
||||||
|
and ini.device_point_name = inih.device_point_name
|
||||||
|
set ini.is_history = 1");
|
||||||
|
|
||||||
|
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||||
|
{
|
||||||
|
await conn.ExecuteAsync(sb.ToString());
|
||||||
|
}
|
||||||
|
sb.Clear();
|
||||||
|
|
||||||
|
sb.Append($@"SET SQL_SAFE_UPDATES = 0;
|
||||||
|
update import_niagara_item ini
|
||||||
|
join (
|
||||||
|
select distinct device_building_tag, parent_path from import_niagara_item_history
|
||||||
|
) inih on ini.device_building_tag = inih.device_building_tag
|
||||||
|
set ini.parent_path = inih.parent_path");
|
||||||
|
|
||||||
|
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||||
|
{
|
||||||
|
await conn.ExecuteAsync(sb.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@ -565,7 +589,7 @@ namespace Repository.BackendRepository.Implement
|
|||||||
FROM import_niagara_item m
|
FROM import_niagara_item m
|
||||||
LEFT JOIN device_item d
|
LEFT JOIN device_item d
|
||||||
ON m.device_system_tag = d.device_system_tag and m.device_name_tag = d.device_name_tag and m.device_point_name = d.points and m.device_building_tag collate utf8mb4_0900_ai_ci = d.device_building_tag
|
ON m.device_system_tag = d.device_system_tag and m.device_name_tag = d.device_name_tag and m.device_point_name = d.points and m.device_building_tag collate utf8mb4_0900_ai_ci = d.device_building_tag
|
||||||
WHERE d.points IS NULL;");
|
WHERE d.points IS NULL and d.deleted = 0;");
|
||||||
result = (await conn.QueryAsync<NiagaraTagsForItem>(sb.ToString())).ToList<NiagaraTagsForItem>();
|
result = (await conn.QueryAsync<NiagaraTagsForItem>(sb.ToString())).ToList<NiagaraTagsForItem>();
|
||||||
|
|
||||||
sb.Clear();
|
sb.Clear();
|
||||||
@ -623,13 +647,14 @@ namespace Repository.BackendRepository.Implement
|
|||||||
sb.Append($@" SET SQL_SAFE_UPDATES = 0;
|
sb.Append($@" SET SQL_SAFE_UPDATES = 0;
|
||||||
UPDATE device_item d
|
UPDATE device_item d
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT device_system_tag, device_name_tag, device_point_name, full_name
|
SELECT device_system_tag, device_name_tag, device_point_name, full_name, device_building_tag
|
||||||
FROM import_niagara_item
|
FROM import_niagara_item
|
||||||
LIMIT 100000 -- Specify your desired limit here
|
LIMIT 100000 -- Specify your desired limit here
|
||||||
) m
|
) m
|
||||||
ON d.device_system_tag = m.device_system_tag
|
ON d.device_system_tag = m.device_system_tag
|
||||||
AND d.device_name_tag = m.device_name_tag
|
AND d.device_name_tag = m.device_name_tag
|
||||||
AND d.points = m.device_point_name
|
AND d.points = m.device_point_name
|
||||||
|
AND d.device_building_tag = m.device_building_tag
|
||||||
SET d.is_link = CASE WHEN m.device_point_name IS NULL THEN 0 ELSE 1 END;");
|
SET d.is_link = CASE WHEN m.device_point_name IS NULL THEN 0 ELSE 1 END;");
|
||||||
|
|
||||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||||
@ -641,7 +666,7 @@ namespace Repository.BackendRepository.Implement
|
|||||||
sb.Append($@" SET SQL_SAFE_UPDATES = 0;
|
sb.Append($@" SET SQL_SAFE_UPDATES = 0;
|
||||||
UPDATE device_item d
|
UPDATE device_item d
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT m.device_system_tag, m.device_name_tag, m.device_point_name, m.full_name
|
SELECT m.device_system_tag, m.device_name_tag, m.device_point_name, m.full_name, device_building_tag
|
||||||
FROM import_niagara_item m
|
FROM import_niagara_item m
|
||||||
WHERE (m.is_history = 1)
|
WHERE (m.is_history = 1)
|
||||||
LIMIT 100000 -- Specify your desired limit here
|
LIMIT 100000 -- Specify your desired limit here
|
||||||
@ -649,7 +674,8 @@ namespace Repository.BackendRepository.Implement
|
|||||||
ON d.device_system_tag = subquery.device_system_tag
|
ON d.device_system_tag = subquery.device_system_tag
|
||||||
AND d.device_name_tag = subquery.device_name_tag
|
AND d.device_name_tag = subquery.device_name_tag
|
||||||
AND d.points = subquery.device_point_name
|
AND d.points = subquery.device_point_name
|
||||||
SET d.is_show_history = CASE WHEN subquery.device_point_name IS NULL THEN 0 ELSE 1 END");
|
AND d.device_building_tag = subquery.device_building_tag
|
||||||
|
SET d.is_show_history = CASE WHEN subquery.device_point_name IS NULL THEN 0 ELSE 1 END;");
|
||||||
|
|
||||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||||
{
|
{
|
||||||
@ -738,6 +764,22 @@ namespace Repository.BackendRepository.Implement
|
|||||||
{
|
{
|
||||||
await conn.ExecuteAsync(sb.ToString());
|
await conn.ExecuteAsync(sb.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sb.Clear();
|
||||||
|
sb.Append($@"SET SQL_SAFE_UPDATES = 0;
|
||||||
|
UPDATE building_menu b LEFT JOIN (
|
||||||
|
select device_building_tag, device_system_tag, device_name_tag
|
||||||
|
from import_niagara_tag
|
||||||
|
group by device_building_tag, device_system_tag, device_name_tag
|
||||||
|
) AS a ON b.building_tag COLLATE utf8mb4_0900_ai_ci = a.device_building_tag COLLATE utf8mb4_0900_ai_ci
|
||||||
|
and a.device_system_tag COLLATE utf8mb4_0900_ai_ci = b.main_system_tag COLLATE utf8mb4_0900_ai_ci and a.device_name_tag COLLATE utf8mb4_0900_ai_ci = b.sub_system_tag COLLATE utf8mb4_0900_ai_ci
|
||||||
|
SET b.is_link = 1
|
||||||
|
WHERE a.device_building_tag IS NOT NULL and b.is_link < 2");
|
||||||
|
|
||||||
|
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||||
|
{
|
||||||
|
await conn.ExecuteAsync(sb.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
@ -814,7 +856,26 @@ namespace Repository.BackendRepository.Implement
|
|||||||
and b.sub_system_tag COLLATE utf8mb4_0900_ai_ci = a.device_name_tag COLLATE utf8mb4_0900_ai_ci
|
and b.sub_system_tag COLLATE utf8mb4_0900_ai_ci = a.device_name_tag COLLATE utf8mb4_0900_ai_ci
|
||||||
and b.floor_tag COLLATE utf8mb4_0900_ai_ci = a.device_floor_tag COLLATE utf8mb4_0900_ai_ci
|
and b.floor_tag COLLATE utf8mb4_0900_ai_ci = a.device_floor_tag COLLATE utf8mb4_0900_ai_ci
|
||||||
SET b.is_link = 0
|
SET b.is_link = 0
|
||||||
WHERE b.building_tag IS NULL");
|
WHERE a.device_building_tag IS NULL");
|
||||||
|
|
||||||
|
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||||
|
{
|
||||||
|
await conn.ExecuteAsync(sb.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.Clear();
|
||||||
|
|
||||||
|
sb.Append($@" SET SQL_SAFE_UPDATES = 0;
|
||||||
|
UPDATE sub_system_floor b LEFT JOIN (
|
||||||
|
select device_building_tag, device_system_tag, device_name_tag, device_floor_tag
|
||||||
|
from import_niagara_tag
|
||||||
|
group by device_building_tag, device_system_tag, device_name_tag, device_floor_tag
|
||||||
|
) AS a ON b.building_tag COLLATE utf8mb4_0900_ai_ci = a.device_building_tag COLLATE utf8mb4_0900_ai_ci
|
||||||
|
and b.main_system_tag COLLATE utf8mb4_0900_ai_ci = a.device_system_tag COLLATE utf8mb4_0900_ai_ci
|
||||||
|
and b.sub_system_tag COLLATE utf8mb4_0900_ai_ci = a.device_name_tag COLLATE utf8mb4_0900_ai_ci
|
||||||
|
and b.floor_tag COLLATE utf8mb4_0900_ai_ci = a.device_floor_tag COLLATE utf8mb4_0900_ai_ci
|
||||||
|
SET b.is_link = 1
|
||||||
|
WHERE a.device_building_tag IS NOT NULL");
|
||||||
|
|
||||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user