From 73ea4a9a680913694d7e2e19153731439936118e Mon Sep 17 00:00:00 2001 From: dev02 Date: Thu, 2 Nov 2023 13:19:23 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E8=AA=BF=E6=95=B4?= =?UTF-8?q?=E6=8E=92=E7=A8=8B=E5=81=9C=E8=BB=8A=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/Models/Parking.cs | 6 ++--- Backend/appsettings.Development.json | 2 +- .../Quartz/Jobs/ParkingJob.cs | 25 +++++++++++-------- .../appsettings.Development.json | 4 +-- BackendWorkerService/appsettings.json | 7 +++--- 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/Backend/Models/Parking.cs b/Backend/Models/Parking.cs index 21facfa..784083d 100644 --- a/Backend/Models/Parking.cs +++ b/Backend/Models/Parking.cs @@ -36,7 +36,7 @@ namespace Backend.Models public class CarType { - public int Vehicle_type_id { get; set; } //車種(請參照車種列表) + public string Vehicle_type_id { get; set; } //車種(請參照車種列表) public int Total { get; set; } //該車種總車位數 public int Remain { get; set; } //該車種剩餘車位數 } @@ -44,7 +44,7 @@ namespace Backend.Models public partial class Area { 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 Remain { get; set; } } @@ -57,7 +57,7 @@ namespace Backend.Models public class EquipmentPayload { - public int Id { get; set; } + public string Id { get; set; } public string Name { get; set; } public string Type { get; set; } public bool Alive { get; set; } diff --git a/Backend/appsettings.Development.json b/Backend/appsettings.Development.json index 84c3607..2a7e0a5 100644 --- a/Backend/appsettings.Development.json +++ b/Backend/appsettings.Development.json @@ -15,7 +15,7 @@ "DBConfig": { "MySqlDBConfig": { "Server": "jbgI3Q4uFL4Kd9bbvToklA==", //0.201 - "Port": "mkF51jVbg40V5K5eTh2Ckw==", + "Port": "mkF51jVbg40V5K5eTh2Ckw==", //3306 //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30 //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp //"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome diff --git a/BackendWorkerService/Quartz/Jobs/ParkingJob.cs b/BackendWorkerService/Quartz/Jobs/ParkingJob.cs index 653db61..e2a9c25 100644 --- a/BackendWorkerService/Quartz/Jobs/ParkingJob.cs +++ b/BackendWorkerService/Quartz/Jobs/ParkingJob.cs @@ -45,6 +45,7 @@ namespace BackendWorkerService.Quartz.Jobs { if(await task_Detail.GetNeedWorkTask("ParkingJob", "All")) { + var item = string.Empty; await task_Detail.InsertWorkTime("ParkingJob", "All", "任務開始"); EDFunction ed = new EDFunction(); 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.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.UserName = ed.AESDecrypt(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.UserName = variable.Where(x => x.Name == "UserName").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.VendorToken = variable.Where(x => x.Name == "X-VENDOR-TOKEN").Select(x => x.Value).FirstOrDefault(); @@ -68,7 +69,7 @@ namespace BackendWorkerService.Quartz.Jobs try { 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"; //request.Headers.Add("Authorization", "Basic " + encoded); 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(); if (selectedMapping != null) { + item = area.Name; var tagName = selectedMapping.system_value; var apiFormat = @"{0}obix/config/Arena/{1}/{2}/{3}/{4}/{5}/CV/set"; - var tagNameSplit = tagName.Split("_"); var parames = new List(); @@ -118,7 +119,7 @@ namespace BackendWorkerService.Quartz.Jobs parames.Add(tagName); // 第五段 完整 tag } } - logger.LogError(@$"【ParkingJob】【停車場剩餘車位】{apiFormat}"); + //logger.LogError(@$"【ParkingJob】【停車場剩餘車位】{apiFormat}"); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(string.Format(apiFormat, parames.ToArray())); request.Method = "POST"; request.Headers.Add("Authorization", "Basic " + encoded); @@ -182,19 +183,21 @@ namespace BackendWorkerService.Quartz.Jobs await task_Detail.WorkFail("ParkingJob", "Parking", exception.ToString()); logger.LogInformation("【ParkingJob】【執行失敗停車場剩餘車位Job】"); logger.LogInformation("【ParkingJob】【執行失敗停車場剩餘車位Job】[Exception]:{0}", exception.ToString()); + logger.LogInformation("【ParkingJob】【執行失敗停車場剩餘車位Job】[Item]: {0}", item); + logger.LogInformation("【ParkingJob】【執行失敗停車場剩餘車位Job】[encoded]: {0}", encoded); } } #endregion #region 取得設備資訊 - if (await task_Detail.GetNeedWorkTask("ParkingJob", "Device")) + if (await task_Detail.GetNeedWorkTask("ParkingJob", "Device")) { try { await task_Detail.InsertWorkTime("ParkingJob", "Device", "開始執行設備資訊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"; //request.Headers.Add("Authorization", "Basic " + encoded); equipmentRequest.Headers.Add("X-VENDOR-ID", parkingConfig.VendorId); @@ -228,10 +231,10 @@ namespace BackendWorkerService.Quartz.Jobs 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) { - + item = equipment.Id; var tagName = selectedMapping.system_value; var apiFormat = @"{0}obix/config/Arena/{1}/{2}/{3}/{4}/{5}/ST/set"; @@ -297,7 +300,7 @@ namespace BackendWorkerService.Quartz.Jobs } 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()); logger.LogInformation("【ParkingJob】【執行失敗設備資訊Job】"); logger.LogInformation("【ParkingJob】【執行失敗設備資訊Job】[Exception]:{0}", exception.ToString()); + logger.LogInformation("【ParkingJob】【執行失敗設備資訊Job】[item]:{0}", item); + logger.LogInformation("【ParkingJob】【執行失敗設備資訊Job】[encoded]:{0}", encoded); } } #endregion diff --git a/BackendWorkerService/appsettings.Development.json b/BackendWorkerService/appsettings.Development.json index 5c0ee01..8c89eee 100644 --- a/BackendWorkerService/appsettings.Development.json +++ b/BackendWorkerService/appsettings.Development.json @@ -19,8 +19,8 @@ }, "DBConfig": { "MySqlDBConfig": { - "Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201 - "Port": "js2LutKe+rdjzdxMPQUrvQ==", + "Server": "jbgI3Q4uFL4Kd9bbvToklA==", //0.202 + "Port": "mkF51jVbg40V5K5eTh2Ckw==", //3306 //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30 //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp //"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome diff --git a/BackendWorkerService/appsettings.json b/BackendWorkerService/appsettings.json index 771a64b..201af70 100644 --- a/BackendWorkerService/appsettings.json +++ b/BackendWorkerService/appsettings.json @@ -12,15 +12,16 @@ "MessageNotificationJob": "0 0 2 * * ?", "DataDeliveryJob": "0 0 2 * * ?", "RegularUpdateDBTableJob": "0 0 2 * * ?", - "ParkingJob": "0 0 2 * * ?", + "ParkingJob": "0/5 * * * * ?", + //"ParkingJob": "0 0 2 * * ?", "ArchiveElectricMeterHourJob": "0 0 2 * * ?", "ArchiveElectricMeterDayJob": "0/5 * * * * ?", "WeatherAPIJob": "0 0 2 * * ?" }, "DBConfig": { "MySqlDBConfig": { - "Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201 - "Port": "js2LutKe+rdjzdxMPQUrvQ==", + "Server": "jbgI3Q4uFL4Kd9bbvToklA==", //0.202 + "Port": "mkF51jVbg40V5K5eTh2Ckw==", //3306 //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30 //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp //"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome