This commit is contained in:
dev01 2023-11-13 18:24:27 +08:00
commit 4283fb94ba
7 changed files with 74 additions and 29 deletions

View File

@ -623,11 +623,17 @@ namespace Backend.Controllers
try
{
var building_tag = await backendRepository.GetOneAsync<string>($@"select system_value from variable where system_type = 'project_name' and deleted = 0");
var sql = @"SELECT di.*
//var sql = @"SELECT di.*
// FROM device_item di
// JOIN variable sv ON di.device_name_tag = sv.system_value
// JOIN variable mv ON sv.system_parent_id = mv.id AND di.device_system_tag = mv.system_value
// WHERE sv.id = @id AND di.deleted = @Deleted and di.device_building_tag = @building_tag and di.is_link = 1";
var sql = @"SELECT min(di.id) as id, di.full_name, di.points, di.unit, di.is_show, di.is_show_riserDiagram, di.is_controll, di.is_bool, di.is_link, di.is_show_history, di.device_system_tag, di.device_name_tag
FROM device_item di
JOIN variable sv ON di.device_name_tag = sv.system_value
JOIN variable mv ON sv.system_parent_id = mv.id AND di.device_system_tag = mv.system_value
WHERE sv.id = @id AND di.deleted = @Deleted and di.device_building_tag = @building_tag and di.is_link = 1";
WHERE sv.id = @id and di.deleted = 0 and di.is_link = 1
group by di.full_name, di.points, di.unit, di.is_show, di.is_show_riserDiagram, di.is_controll, di.is_bool, di.is_link, di.is_show_history, di.device_system_tag, di.device_name_tag";
object param = new { Deleted = 0, id = id, building_tag = building_tag.Split("/")[1] };

View File

@ -18,6 +18,8 @@ namespace Backend.Models
public string ApiBase { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public string VendorId { get; set; }
public string VendorToken { get; set; }
}
public class SpaceResponse
@ -34,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; } //該車種剩餘車位數
}
@ -42,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; }
}
@ -55,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; }

View File

@ -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

View File

@ -2,6 +2,7 @@
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NPOI.OpenXml4Net.OPC;
using Quartz;
using Repository.BackendRepository.Interface;
using System;
@ -44,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();
@ -54,8 +56,10 @@ 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();
String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(parkingConfig.UserName + ":" + parkingConfig.Password));
@ -65,9 +69,11 @@ 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);
spaceRequest.Headers.Add("X-VENDOR-TOKEN", parkingConfig.VendorToken);
spaceRequest.PreAuthenticate = true;
spaceRequest.Timeout = System.Threading.Timeout.Infinite;
spaceRequest.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
@ -95,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<object>();
@ -113,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);
@ -154,6 +160,11 @@ namespace BackendWorkerService.Quartz.Jobs
{
logger.LogError("【ParkingJob】【停車場剩餘車位資訊】[修改失敗]{0}", display.ToString());
}
else
{
logger.LogInformation("【ParkingJob】【停車場剩餘車位資訊】[修改成功]{0}", display.ToString());
logger.LogInformation("【ParkingJob】【停車場剩餘車位資訊】[停車場資訊]{0}", item);
}
}
}
}
@ -177,6 +188,8 @@ 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
@ -189,9 +202,11 @@ namespace BackendWorkerService.Quartz.Jobs
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);
equipmentRequest.Headers.Add("X-VENDOR-TOKEN", parkingConfig.VendorToken);
equipmentRequest.PreAuthenticate = true;
equipmentRequest.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
@ -221,10 +236,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";
@ -284,13 +299,18 @@ namespace BackendWorkerService.Quartz.Jobs
{
logger.LogError("【ParkingJob】【設備資訊】[修改失敗]{0}", val.ToString());
}
else
{
logger.LogInformation("【ParkingJob】【設備資訊】[修改成功]{0}", val.ToString());
logger.LogInformation("【ParkingJob】【設備資訊】[設備資訊]{0}", item);
}
}
}
}
}
else
{
logger.LogWarning("【ParkingJob】【設備資訊】[查無該名稱對應表]{0}", equipment.Name);
logger.LogWarning("【ParkingJob】【設備資訊】[查無該名稱對應表]{0}", equipment.Id);
}
}
}
@ -306,6 +326,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

View File

@ -19,14 +19,15 @@
},
"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
//"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel
//"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //mcut
"Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821
//"Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821
"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //ibms_dome_dome
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
"Password": "FVAPxztxpY4gJJKQ/se4bQ=="
},

View File

@ -12,21 +12,23 @@
"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
//"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel
//"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //mcut
"Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821
//"Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821
"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //ibms_dome_dome
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
"Password": "FVAPxztxpY4gJJKQ/se4bQ=="
},

View File

@ -443,10 +443,18 @@ namespace Repository.BackendRepository.Implement
using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
{
await conn.ExecuteAsync(sb.ToString());
await conn.ExecuteAsync(sb2.ToString());
}
sb.Clear();
}
if (sb2.Length > 0)
{
using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
{
await conn.ExecuteAsync(sb2.ToString());
}
sb2.Clear();
}
}
@ -1140,12 +1148,16 @@ namespace Repository.BackendRepository.Implement
string device_guid = device.Where(x => x.device_number == device_number).Select(x => x.device_guid).FirstOrDefault();
string device_system_tag = device.Where(x => x.device_number == device_number).Select(x => x.device_system_tag).FirstOrDefault();
string device_name_tag = device.Where(x => x.device_number == device_number).Select(x => x.device_name_tag).FirstOrDefault();
var check = (await conn.QueryAsync<string>($"select device_guid from device_disaster where device_guid = '{device_guid}' and device_system_value = '{d.disasterValue}'")).FirstOrDefault();
if (string.IsNullOrEmpty(check))
{
sb.Append($@"
insert into device_disaster
(device_guid, device_system_value, device_building_tag, device_system_tag, device_name_tag, device_floor_tag, device_serial_tag, device_number)
values ('{device_guid}', '{d.disasterValue}', '{device_number.Split('_')[0]}', '{device_system_tag}', '{device_name_tag}', '{device_number.Split('_')[2]}',
'{device_number.Split('_')[4]}', '{device_number}'); ");
}
}
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
{