[後端] 調整排程停車管理
This commit is contained in:
parent
8b693b60b4
commit
73ea4a9a68
@ -36,7 +36,7 @@ namespace Backend.Models
|
|||||||
|
|
||||||
public class CarType
|
public class CarType
|
||||||
{
|
{
|
||||||
public int Vehicle_type_id { get; set; } //車種(請參照車種列表)
|
public string Vehicle_type_id { get; set; } //車種(請參照車種列表)
|
||||||
public int Total { get; set; } //該車種總車位數
|
public int Total { get; set; } //該車種總車位數
|
||||||
public int Remain { get; set; } //該車種剩餘車位數
|
public int Remain { get; set; } //該車種剩餘車位數
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ namespace Backend.Models
|
|||||||
public partial class Area
|
public partial class Area
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public int Vehicle_type_id { get; set; }
|
public string Vehicle_type_id { get; set; }
|
||||||
public int Total { get; set; }
|
public int Total { get; set; }
|
||||||
public int Remain { get; set; }
|
public int Remain { get; set; }
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ namespace Backend.Models
|
|||||||
|
|
||||||
public class EquipmentPayload
|
public class EquipmentPayload
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public string Id { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Type { get; set; }
|
public string Type { get; set; }
|
||||||
public bool Alive { get; set; }
|
public bool Alive { get; set; }
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
"DBConfig": {
|
"DBConfig": {
|
||||||
"MySqlDBConfig": {
|
"MySqlDBConfig": {
|
||||||
"Server": "jbgI3Q4uFL4Kd9bbvToklA==", //0.201
|
"Server": "jbgI3Q4uFL4Kd9bbvToklA==", //0.201
|
||||||
"Port": "mkF51jVbg40V5K5eTh2Ckw==",
|
"Port": "mkF51jVbg40V5K5eTh2Ckw==", //3306
|
||||||
//"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
|
||||||
|
@ -45,6 +45,7 @@ namespace BackendWorkerService.Quartz.Jobs
|
|||||||
{
|
{
|
||||||
if(await task_Detail.GetNeedWorkTask("ParkingJob", "All"))
|
if(await task_Detail.GetNeedWorkTask("ParkingJob", "All"))
|
||||||
{
|
{
|
||||||
|
var item = string.Empty;
|
||||||
await task_Detail.InsertWorkTime("ParkingJob", "All", "任務開始");
|
await task_Detail.InsertWorkTime("ParkingJob", "All", "任務開始");
|
||||||
EDFunction ed = new EDFunction();
|
EDFunction ed = new EDFunction();
|
||||||
var parkingConfig = new ParkingConfig();
|
var parkingConfig = new ParkingConfig();
|
||||||
@ -55,8 +56,8 @@ namespace BackendWorkerService.Quartz.Jobs
|
|||||||
parkingConfig.Host = variable.Where(x => x.Name == "Host").Select(x => x.Value).FirstOrDefault();
|
parkingConfig.Host = variable.Where(x => x.Name == "Host").Select(x => x.Value).FirstOrDefault();
|
||||||
parkingConfig.Prefix = variable.Where(x => x.Name == "Prefix").Select(x => x.Value).FirstOrDefault();
|
parkingConfig.Prefix = variable.Where(x => x.Name == "Prefix").Select(x => x.Value).FirstOrDefault();
|
||||||
parkingConfig.ApiBase = variable.Where(x => x.Name == "ApiBase").Select(x => x.Value).FirstOrDefault();
|
parkingConfig.ApiBase = variable.Where(x => x.Name == "ApiBase").Select(x => x.Value).FirstOrDefault();
|
||||||
parkingConfig.UserName = ed.AESDecrypt(variable.Where(x => x.Name == "UserName").Select(x => x.Value).FirstOrDefault());
|
parkingConfig.UserName = variable.Where(x => x.Name == "UserName").Select(x => x.Value).FirstOrDefault();
|
||||||
parkingConfig.Password = ed.AESDecrypt(variable.Where(x => x.Name == "Password").Select(x => x.Value).FirstOrDefault());
|
parkingConfig.Password = variable.Where(x => x.Name == "Password").Select(x => x.Value).FirstOrDefault();
|
||||||
parkingConfig.VendorId = variable.Where(x => x.Name == "X-VENDOR-ID").Select(x => x.Value).FirstOrDefault();
|
parkingConfig.VendorId = variable.Where(x => x.Name == "X-VENDOR-ID").Select(x => x.Value).FirstOrDefault();
|
||||||
parkingConfig.VendorToken = variable.Where(x => x.Name == "X-VENDOR-TOKEN").Select(x => x.Value).FirstOrDefault();
|
parkingConfig.VendorToken = variable.Where(x => x.Name == "X-VENDOR-TOKEN").Select(x => x.Value).FirstOrDefault();
|
||||||
|
|
||||||
@ -68,7 +69,7 @@ namespace BackendWorkerService.Quartz.Jobs
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
await task_Detail.InsertWorkTime("ParkingJob", "Parking", "開始執行停車場剩餘車位Job");
|
await task_Detail.InsertWorkTime("ParkingJob", "Parking", "開始執行停車場剩餘車位Job");
|
||||||
HttpWebRequest spaceRequest = (HttpWebRequest)WebRequest.Create($"{parkingConfig.Host}{parkingConfig.Prefix}/api/space/details");
|
HttpWebRequest spaceRequest = (HttpWebRequest)WebRequest.Create($"{parkingConfig.Host}/api/space/details");
|
||||||
spaceRequest.Method = "GET";
|
spaceRequest.Method = "GET";
|
||||||
//request.Headers.Add("Authorization", "Basic " + encoded);
|
//request.Headers.Add("Authorization", "Basic " + encoded);
|
||||||
spaceRequest.Headers.Add("X-VENDOR-ID", parkingConfig.VendorId);
|
spaceRequest.Headers.Add("X-VENDOR-ID", parkingConfig.VendorId);
|
||||||
@ -100,9 +101,9 @@ namespace BackendWorkerService.Quartz.Jobs
|
|||||||
var selectedMapping = parkingSapceMapping.Where(x => x.System_key == area.Name).FirstOrDefault();
|
var selectedMapping = parkingSapceMapping.Where(x => x.System_key == area.Name).FirstOrDefault();
|
||||||
if (selectedMapping != null)
|
if (selectedMapping != null)
|
||||||
{
|
{
|
||||||
|
item = area.Name;
|
||||||
var tagName = selectedMapping.system_value;
|
var tagName = selectedMapping.system_value;
|
||||||
var apiFormat = @"{0}obix/config/Arena/{1}/{2}/{3}/{4}/{5}/CV/set";
|
var apiFormat = @"{0}obix/config/Arena/{1}/{2}/{3}/{4}/{5}/CV/set";
|
||||||
|
|
||||||
var tagNameSplit = tagName.Split("_");
|
var tagNameSplit = tagName.Split("_");
|
||||||
|
|
||||||
var parames = new List<object>();
|
var parames = new List<object>();
|
||||||
@ -118,7 +119,7 @@ namespace BackendWorkerService.Quartz.Jobs
|
|||||||
parames.Add(tagName); // 第五段 完整 tag
|
parames.Add(tagName); // 第五段 完整 tag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.LogError(@$"【ParkingJob】【停車場剩餘車位】{apiFormat}");
|
//logger.LogError(@$"【ParkingJob】【停車場剩餘車位】{apiFormat}");
|
||||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(string.Format(apiFormat, parames.ToArray()));
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(string.Format(apiFormat, parames.ToArray()));
|
||||||
request.Method = "POST";
|
request.Method = "POST";
|
||||||
request.Headers.Add("Authorization", "Basic " + encoded);
|
request.Headers.Add("Authorization", "Basic " + encoded);
|
||||||
@ -182,6 +183,8 @@ namespace BackendWorkerService.Quartz.Jobs
|
|||||||
await task_Detail.WorkFail("ParkingJob", "Parking", exception.ToString());
|
await task_Detail.WorkFail("ParkingJob", "Parking", exception.ToString());
|
||||||
logger.LogInformation("【ParkingJob】【執行失敗停車場剩餘車位Job】");
|
logger.LogInformation("【ParkingJob】【執行失敗停車場剩餘車位Job】");
|
||||||
logger.LogInformation("【ParkingJob】【執行失敗停車場剩餘車位Job】[Exception]:{0}", exception.ToString());
|
logger.LogInformation("【ParkingJob】【執行失敗停車場剩餘車位Job】[Exception]:{0}", exception.ToString());
|
||||||
|
logger.LogInformation("【ParkingJob】【執行失敗停車場剩餘車位Job】[Item]: {0}", item);
|
||||||
|
logger.LogInformation("【ParkingJob】【執行失敗停車場剩餘車位Job】[encoded]: {0}", encoded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -194,7 +197,7 @@ namespace BackendWorkerService.Quartz.Jobs
|
|||||||
await task_Detail.InsertWorkTime("ParkingJob", "Device", "開始執行設備資訊Job");
|
await task_Detail.InsertWorkTime("ParkingJob", "Device", "開始執行設備資訊Job");
|
||||||
//logger.LogInformation("【ParkingJob】【開始執行設備資訊Job】");
|
//logger.LogInformation("【ParkingJob】【開始執行設備資訊Job】");
|
||||||
|
|
||||||
HttpWebRequest equipmentRequest = (HttpWebRequest)WebRequest.Create($"{parkingConfig.Host}{parkingConfig.Prefix}/api/equipment/state");
|
HttpWebRequest equipmentRequest = (HttpWebRequest)WebRequest.Create($"{parkingConfig.Host}/api/equipment/state");
|
||||||
equipmentRequest.Method = "GET";
|
equipmentRequest.Method = "GET";
|
||||||
//request.Headers.Add("Authorization", "Basic " + encoded);
|
//request.Headers.Add("Authorization", "Basic " + encoded);
|
||||||
equipmentRequest.Headers.Add("X-VENDOR-ID", parkingConfig.VendorId);
|
equipmentRequest.Headers.Add("X-VENDOR-ID", parkingConfig.VendorId);
|
||||||
@ -228,10 +231,10 @@ namespace BackendWorkerService.Quartz.Jobs
|
|||||||
foreach (var equipment in equipmentResponseResult.Payload)
|
foreach (var equipment in equipmentResponseResult.Payload)
|
||||||
{
|
{
|
||||||
//找出對定的設備代碼
|
//找出對定的設備代碼
|
||||||
var selectedMapping = parkingEquipmentMapping.Where(x => x.System_key == equipment.Name).FirstOrDefault();
|
var selectedMapping = parkingEquipmentMapping.Where(x => x.System_key == equipment.Id).FirstOrDefault();
|
||||||
if (selectedMapping != null)
|
if (selectedMapping != null)
|
||||||
{
|
{
|
||||||
|
item = equipment.Id;
|
||||||
var tagName = selectedMapping.system_value;
|
var tagName = selectedMapping.system_value;
|
||||||
var apiFormat = @"{0}obix/config/Arena/{1}/{2}/{3}/{4}/{5}/ST/set";
|
var apiFormat = @"{0}obix/config/Arena/{1}/{2}/{3}/{4}/{5}/ST/set";
|
||||||
|
|
||||||
@ -297,7 +300,7 @@ namespace BackendWorkerService.Quartz.Jobs
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.LogWarning("【ParkingJob】【設備資訊】[查無該名稱對應表]:{0}", equipment.Name);
|
logger.LogWarning("【ParkingJob】【設備資訊】[查無該名稱對應表]:{0}", equipment.Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -313,6 +316,8 @@ namespace BackendWorkerService.Quartz.Jobs
|
|||||||
await task_Detail.WorkFail("ParkingJob", "Device", exception.ToString());
|
await task_Detail.WorkFail("ParkingJob", "Device", exception.ToString());
|
||||||
logger.LogInformation("【ParkingJob】【執行失敗設備資訊Job】");
|
logger.LogInformation("【ParkingJob】【執行失敗設備資訊Job】");
|
||||||
logger.LogInformation("【ParkingJob】【執行失敗設備資訊Job】[Exception]:{0}", exception.ToString());
|
logger.LogInformation("【ParkingJob】【執行失敗設備資訊Job】[Exception]:{0}", exception.ToString());
|
||||||
|
logger.LogInformation("【ParkingJob】【執行失敗設備資訊Job】[item]:{0}", item);
|
||||||
|
logger.LogInformation("【ParkingJob】【執行失敗設備資訊Job】[encoded]:{0}", encoded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
},
|
},
|
||||||
"DBConfig": {
|
"DBConfig": {
|
||||||
"MySqlDBConfig": {
|
"MySqlDBConfig": {
|
||||||
"Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201
|
"Server": "jbgI3Q4uFL4Kd9bbvToklA==", //0.202
|
||||||
"Port": "js2LutKe+rdjzdxMPQUrvQ==",
|
"Port": "mkF51jVbg40V5K5eTh2Ckw==", //3306
|
||||||
//"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
|
||||||
|
@ -12,15 +12,16 @@
|
|||||||
"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 * * * * ?",
|
||||||
|
//"ParkingJob": "0 0 2 * * ?",
|
||||||
"ArchiveElectricMeterHourJob": "0 0 2 * * ?",
|
"ArchiveElectricMeterHourJob": "0 0 2 * * ?",
|
||||||
"ArchiveElectricMeterDayJob": "0/5 * * * * ?",
|
"ArchiveElectricMeterDayJob": "0/5 * * * * ?",
|
||||||
"WeatherAPIJob": "0 0 2 * * ?"
|
"WeatherAPIJob": "0 0 2 * * ?"
|
||||||
},
|
},
|
||||||
"DBConfig": {
|
"DBConfig": {
|
||||||
"MySqlDBConfig": {
|
"MySqlDBConfig": {
|
||||||
"Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201
|
"Server": "jbgI3Q4uFL4Kd9bbvToklA==", //0.202
|
||||||
"Port": "js2LutKe+rdjzdxMPQUrvQ==",
|
"Port": "mkF51jVbg40V5K5eTh2Ckw==", //3306
|
||||||
//"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
|
||||||
|
Loading…
Reference in New Issue
Block a user