[後端] 修改sql, 修改parking header, 修改同步disaster 相同
This commit is contained in:
parent
a37224647e
commit
eefb7bb12a
@ -623,11 +623,17 @@ namespace Backend.Controllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var building_tag = await backendRepository.GetOneAsync<string>($@"select system_value from variable where system_type = 'project_name' and deleted = 0");
|
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), 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
|
FROM device_item di
|
||||||
JOIN variable sv ON di.device_name_tag = sv.system_value
|
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
|
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 = 35 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] };
|
object param = new { Deleted = 0, id = id, building_tag = building_tag.Split("/")[1] };
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@ namespace Backend.Models
|
|||||||
public string ApiBase { get; set; }
|
public string ApiBase { get; set; }
|
||||||
public string UserName { get; set; }
|
public string UserName { get; set; }
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
|
public string VendorId { get; set; }
|
||||||
|
public string VendorToken { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SpaceResponse
|
public class SpaceResponse
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using NPOI.OpenXml4Net.OPC;
|
||||||
using Quartz;
|
using Quartz;
|
||||||
using Repository.BackendRepository.Interface;
|
using Repository.BackendRepository.Interface;
|
||||||
using System;
|
using System;
|
||||||
@ -56,6 +57,8 @@ namespace BackendWorkerService.Quartz.Jobs
|
|||||||
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 = 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.Password = ed.AESDecrypt(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));
|
String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(parkingConfig.UserName + ":" + parkingConfig.Password));
|
||||||
|
|
||||||
@ -68,6 +71,8 @@ namespace BackendWorkerService.Quartz.Jobs
|
|||||||
HttpWebRequest spaceRequest = (HttpWebRequest)WebRequest.Create($"{parkingConfig.Host}{parkingConfig.Prefix}/api/space/details");
|
HttpWebRequest spaceRequest = (HttpWebRequest)WebRequest.Create($"{parkingConfig.Host}{parkingConfig.Prefix}/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-TOKEN", parkingConfig.VendorToken);
|
||||||
spaceRequest.PreAuthenticate = true;
|
spaceRequest.PreAuthenticate = true;
|
||||||
spaceRequest.Timeout = System.Threading.Timeout.Infinite;
|
spaceRequest.Timeout = System.Threading.Timeout.Infinite;
|
||||||
spaceRequest.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
|
spaceRequest.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
|
||||||
@ -192,6 +197,8 @@ namespace BackendWorkerService.Quartz.Jobs
|
|||||||
HttpWebRequest equipmentRequest = (HttpWebRequest)WebRequest.Create($"{parkingConfig.Host}{parkingConfig.Prefix}/api/equipment/state");
|
HttpWebRequest equipmentRequest = (HttpWebRequest)WebRequest.Create($"{parkingConfig.Host}{parkingConfig.Prefix}/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-TOKEN", parkingConfig.VendorToken);
|
||||||
equipmentRequest.PreAuthenticate = true;
|
equipmentRequest.PreAuthenticate = true;
|
||||||
equipmentRequest.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
|
equipmentRequest.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@
|
|||||||
//"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
|
//"Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821
|
||||||
|
"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //ibms_dome_dome
|
||||||
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
|
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
|
||||||
"Password": "FVAPxztxpY4gJJKQ/se4bQ=="
|
"Password": "FVAPxztxpY4gJJKQ/se4bQ=="
|
||||||
},
|
},
|
||||||
|
@ -26,7 +26,8 @@
|
|||||||
//"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
|
//"Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821
|
||||||
|
"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //ibms_dome_dome
|
||||||
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
|
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
|
||||||
"Password": "FVAPxztxpY4gJJKQ/se4bQ=="
|
"Password": "FVAPxztxpY4gJJKQ/se4bQ=="
|
||||||
},
|
},
|
||||||
|
@ -1140,12 +1140,16 @@ namespace Repository.BackendRepository.Implement
|
|||||||
string device_guid = device.Where(x => x.device_number == device_number).Select(x => x.device_guid).FirstOrDefault();
|
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_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();
|
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($@"
|
sb.Append($@"
|
||||||
insert into device_disaster
|
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)
|
(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]}',
|
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}'); ");
|
'{device_number.Split('_')[4]}', '{device_number}'); ");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user