修改後台同步設備
This commit is contained in:
parent
b4c150a1d4
commit
4d38c0d73d
@ -95,7 +95,8 @@ namespace Backend.Controllers
|
|||||||
{ "@created_by", myUserInfo.Userinfo_guid}
|
{ "@created_by", myUserInfo.Userinfo_guid}
|
||||||
};
|
};
|
||||||
|
|
||||||
backendRepository.InsertOperatorLog(operatorLog, "operation_back_log");
|
if (actionName != "CompareData" && controllerName != "NiagaraDataSynchronize") //skip the log
|
||||||
|
backendRepository.InsertOperatorLog(operatorLog, "operation_back_log");
|
||||||
|
|
||||||
//operatorLogRepository.Add(operatorLog, properties);
|
//operatorLogRepository.Add(operatorLog, properties);
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -8,6 +8,7 @@ using Microsoft.Extensions.Logging;
|
|||||||
using Backend.Services;
|
using Backend.Services;
|
||||||
using Backend.Services.Implement;
|
using Backend.Services.Implement;
|
||||||
using Repository.Models;
|
using Repository.Models;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Backend.Controllers
|
namespace Backend.Controllers
|
||||||
{
|
{
|
||||||
@ -69,13 +70,14 @@ namespace Backend.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<ApiResult<bool>> CompareData(List<Device_value> ds, string building)
|
public async Task<ApiResult<bool>> CompareData([FromBody] List<Device_value> ds)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
ApiResult<bool> apiResult = new ApiResult<bool>();
|
ApiResult<bool> apiResult = new ApiResult<bool>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var building = ds.FirstOrDefault().building;
|
||||||
await niagaraDataSynchronizeRepository.InsertNiagaraTagList(ds, building);
|
await niagaraDataSynchronizeRepository.InsertNiagaraTagList(ds, building);
|
||||||
await niagaraDataSynchronizeRepository.InsertItemFromNiagara(ds, building);
|
await niagaraDataSynchronizeRepository.InsertItemFromNiagara(ds, building);
|
||||||
await niagaraDataSynchronizeRepository.DeviceComparison();
|
await niagaraDataSynchronizeRepository.DeviceComparison();
|
||||||
|
@ -144,20 +144,29 @@
|
|||||||
//比對資料,有差異的話,再同步到device等資料表
|
//比對資料,有差異的話,再同步到device等資料表
|
||||||
var url_synchronize_data = "/NiagaraDataSynchronize/CompareData/";
|
var url_synchronize_data = "/NiagaraDataSynchronize/CompareData/";
|
||||||
|
|
||||||
var send_data = {
|
$.each(ds, function (i, v) {
|
||||||
ds: ds,
|
v.building = building;
|
||||||
building: building
|
})
|
||||||
}
|
|
||||||
$.post(url_synchronize_data, send_data, function (rel) {
|
$.ajax({
|
||||||
if (rel.code != "0000") {
|
method: "POST",
|
||||||
toast_error(rel.msg);
|
url: url_synchronize_data,
|
||||||
document.getElementById('loadDataText').innerText = "比對資料出錯了!";
|
data: JSON.stringify(ds),
|
||||||
return;
|
cache: false,
|
||||||
}
|
async: false,
|
||||||
var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
|
contentType: "application/json; charset=UTF-8",
|
||||||
var dateTime = date + ' ' + time;
|
dataType: 'json',
|
||||||
document.getElementById('loadDataText').innerText = "比對完成 \n" + dateTime;
|
success: function (rel) {
|
||||||
}, 'json');
|
if (rel.code != "0000") {
|
||||||
|
toast_error(rel.msg);
|
||||||
|
document.getElementById('loadDataText').innerText = "比對資料出錯了!";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
|
||||||
|
var dateTime = date + ' ' + time;
|
||||||
|
document.getElementById('loadDataText').innerText = "比對完成 \n" + dateTime;
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
document.getElementById('loadDataText').innerText = "查無資料 無法比對!";
|
document.getElementById('loadDataText').innerText = "查無資料 無法比對!";
|
||||||
|
@ -10,7 +10,6 @@ using System.Threading.Tasks;
|
|||||||
using System.Transactions;
|
using System.Transactions;
|
||||||
using Repository.Models;
|
using Repository.Models;
|
||||||
|
|
||||||
|
|
||||||
namespace Repository.BackendRepository.Implement
|
namespace Repository.BackendRepository.Implement
|
||||||
{
|
{
|
||||||
public class NiagaraDataSynchronizeRepository : BackendRepository, INiagaraDataSynchronizeRepository
|
public class NiagaraDataSynchronizeRepository : BackendRepository, INiagaraDataSynchronizeRepository
|
||||||
@ -389,15 +388,22 @@ namespace Repository.BackendRepository.Implement
|
|||||||
{
|
{
|
||||||
foreach (var data in result)
|
foreach (var data in result)
|
||||||
{
|
{
|
||||||
|
StringBuilder sqlString = new StringBuilder();
|
||||||
|
sqlString.Append(@"select * from building_menu where building_tag = '" + data.device_building_tag + "' and main_system_tag = '" + data.device_system_tag + "' and sub_system_tag = '" + data.device_name_tag + "'");
|
||||||
|
var bm = (await conn.QueryAsync<building_menu>(sqlString.ToString())).ToList<building_menu>();
|
||||||
|
|
||||||
#region insert building_menu
|
#region insert building_menu
|
||||||
sb.Append(@"insert building_menu(building_tag, main_system_tag, sub_system_tag, device_building_tag, device_system_tag,
|
if (bm.Count == 0)
|
||||||
is_link, created_by, created_at, updated_by, updated_at)
|
{
|
||||||
VALUES ('" + data.device_building_tag + "', '" +
|
sb.Append(@"insert building_menu(building_tag, main_system_tag, sub_system_tag, device_building_tag, device_system_tag,
|
||||||
data.device_system_tag + "', '" +
|
is_link, created_by, created_at, updated_by, updated_at)
|
||||||
data.device_name_tag + "', '" +
|
VALUES ('" + data.device_building_tag + "', '" +
|
||||||
data.device_building_tag + "', '" +
|
data.device_system_tag + "', '" +
|
||||||
data.device_system_tag + "', " +
|
data.device_name_tag + "', '" +
|
||||||
"1, 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now(), 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now() );");
|
data.device_building_tag + "', '" +
|
||||||
|
data.device_system_tag + "', " +
|
||||||
|
"1, 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now(), 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now() );");
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
if (sb.Length > 0)
|
if (sb.Length > 0)
|
||||||
|
@ -47,6 +47,7 @@ namespace Repository.Models
|
|||||||
public string value { get; set; }
|
public string value { get; set; }
|
||||||
public string tag_name { get; set; }
|
public string tag_name { get; set; }
|
||||||
public string point_name { get; set; }
|
public string point_name { get; set; }
|
||||||
|
public string building { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Device_item8
|
public class Device_item8
|
||||||
@ -93,4 +94,10 @@ namespace Repository.Models
|
|||||||
public string device_point_name { get; set; }
|
public string device_point_name { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class building_menu
|
||||||
|
{
|
||||||
|
public string building_tag { get; set; }
|
||||||
|
public string device_system_tag { get; set; }
|
||||||
|
public string device_name_tag { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user