[後端] 修改獲取device_item getway
This commit is contained in:
parent
16ea38418c
commit
61c8e79e9c
@ -7,6 +7,7 @@ using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Quartz;
|
||||
using Repository.BackendRepository.Implement;
|
||||
using Repository.BackendRepository.Interface;
|
||||
using Repository.Helper;
|
||||
using System;
|
||||
@ -160,8 +161,12 @@ namespace BackendWorkerService.Quartz.Jobs
|
||||
List<Dictionary<string, object>> waterArchiveDayRawDatas = new List<Dictionary<string, object>>();
|
||||
foreach (var deviceNumberPoint in electricDeviceNumberPoints)
|
||||
{
|
||||
device_number = deviceNumberPoint.FullDeviceNumberPoint;
|
||||
var station = buildingStation.Where(x => x.system_key == deviceNumberPoint.DeviceNumber.Split("_")[1]).Select(x => x.system_value).FirstOrDefault();
|
||||
device_number = deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "");
|
||||
var station = backgroundServiceRepository.GetOneAsync<string>($@"select parent_path from import_niagara_item_history where device_building_tag = '{device_number.Split("_")[1].Replace("$3", "")}' and
|
||||
device_system_tag = '{device_number.Split("_")[2]}' and device_name_tag = '{device_number.Split("_")[3]}'
|
||||
and device_floor_tag = '{device_number.Split("_")[4]}' and device_master_tag = '{device_number.Split("_")[5]}'
|
||||
and device_last_name_tag = '{device_number.Split("_")[6]}' and device_serial_tag = '{device_number.Split("_")[7]}'
|
||||
and device_point_name = '{device_number.Split("_")[8]}'").Result;
|
||||
archiveRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/{deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "")}/~historyRollup/");
|
||||
//HttpWebRequest archiveDayRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/H_E1_B1F_MVCB_MVCBH_V1/~historyRollup/");
|
||||
archiveRequest.Method = "POST";
|
||||
@ -218,8 +223,12 @@ namespace BackendWorkerService.Quartz.Jobs
|
||||
}
|
||||
foreach (var deviceNumberPoint in waterDeviceNumberPoints)
|
||||
{
|
||||
device_number = deviceNumberPoint.FullDeviceNumberPoint;
|
||||
var station = buildingStation.Where(x => x.system_key == deviceNumberPoint.DeviceNumber.Split("_")[1]).Select(x => x.system_value).FirstOrDefault();
|
||||
device_number = deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "");
|
||||
var station = backgroundServiceRepository.GetOneAsync<string>($@"select parent_path from import_niagara_item_history where device_building_tag = '{device_number.Split("_")[1].Replace("$3", "")}' and
|
||||
device_system_tag = '{device_number.Split("_")[2]}' and device_name_tag = '{device_number.Split("_")[3]}'
|
||||
and device_floor_tag = '{device_number.Split("_")[4]}' and device_master_tag = '{device_number.Split("_")[5]}'
|
||||
and device_last_name_tag = '{device_number.Split("_")[6]}' and device_serial_tag = '{device_number.Split("_")[7]}'
|
||||
and device_point_name = '{device_number.Split("_")[8]}'").Result;
|
||||
archiveRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/{deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "")}/~historyRollup/");
|
||||
//HttpWebRequest archiveDayRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/H_E1_B1F_MVCB_MVCBH_V1/~historyRollup/");
|
||||
archiveRequest.Method = "POST";
|
||||
@ -631,8 +640,12 @@ namespace BackendWorkerService.Quartz.Jobs
|
||||
List<Dictionary<string, object>> waterArchiveWeekRawDatas = new List<Dictionary<string, object>>();
|
||||
foreach (var deviceNumberPoint in electricDeviceNumberPoints)
|
||||
{
|
||||
device_number = deviceNumberPoint.FullDeviceNumberPoint;
|
||||
var station = buildingStation.Where(x => x.system_key == deviceNumberPoint.DeviceNumber.Split("_")[1]).Select(x => x.system_value).FirstOrDefault();
|
||||
device_number = deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "");
|
||||
var station = backgroundServiceRepository.GetOneAsync<string>($@"select parent_path from import_niagara_item_history where device_building_tag = '{device_number.Split("_")[1].Replace("$3", "")}' and
|
||||
device_system_tag = '{device_number.Split("_")[2]}' and device_name_tag = '{device_number.Split("_")[3]}'
|
||||
and device_floor_tag = '{device_number.Split("_")[4]}' and device_master_tag = '{device_number.Split("_")[5]}'
|
||||
and device_last_name_tag = '{device_number.Split("_")[6]}' and device_serial_tag = '{device_number.Split("_")[7]}'
|
||||
and device_point_name = '{device_number.Split("_")[8]}'").Result;
|
||||
archiveRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/{deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "")}/~historyRollup/");
|
||||
//HttpWebRequest archiveWeekRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/H_E1_B1F_MVCB_MVCBH_V1/~historyRollup/");
|
||||
archiveRequest.Method = "POST";
|
||||
@ -690,8 +703,12 @@ namespace BackendWorkerService.Quartz.Jobs
|
||||
}
|
||||
foreach (var deviceNumberPoint in waterDeviceNumberPoints)
|
||||
{
|
||||
device_number = deviceNumberPoint.FullDeviceNumberPoint;
|
||||
var station = buildingStation.Where(x => x.system_key == deviceNumberPoint.DeviceNumber.Split("_")[1]).Select(x => x.system_value).FirstOrDefault();
|
||||
device_number = deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "");
|
||||
var station = backgroundServiceRepository.GetOneAsync<string>($@"select parent_path from import_niagara_item_history where device_building_tag = '{device_number.Split("_")[1].Replace("$3", "")}' and
|
||||
device_system_tag = '{device_number.Split("_")[2]}' and device_name_tag = '{device_number.Split("_")[3]}'
|
||||
and device_floor_tag = '{device_number.Split("_")[4]}' and device_master_tag = '{device_number.Split("_")[5]}'
|
||||
and device_last_name_tag = '{device_number.Split("_")[6]}' and device_serial_tag = '{device_number.Split("_")[7]}'
|
||||
and device_point_name = '{device_number.Split("_")[8]}'").Result;
|
||||
archiveRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/{deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "")}/~historyRollup/");
|
||||
//HttpWebRequest archiveWeekRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/H_E1_B1F_MVCB_MVCBH_V1/~historyRollup/");
|
||||
archiveRequest.Method = "POST";
|
||||
@ -1000,8 +1017,12 @@ namespace BackendWorkerService.Quartz.Jobs
|
||||
List<Dictionary<string, object>> waterArchiveMonthRawDatas = new List<Dictionary<string, object>>();
|
||||
foreach (var deviceNumberPoint in electricDeviceNumberPoints)
|
||||
{
|
||||
device_number = deviceNumberPoint.FullDeviceNumberPoint;
|
||||
var station = buildingStation.Where(x => x.system_key == deviceNumberPoint.DeviceNumber.Split("_")[1]).Select(x => x.system_value).FirstOrDefault();
|
||||
device_number = deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "");
|
||||
var station = backgroundServiceRepository.GetOneAsync<string>($@"select parent_path from import_niagara_item_history where device_building_tag = '{device_number.Split("_")[1].Replace("$3", "")}' and
|
||||
device_system_tag = '{device_number.Split("_")[2]}' and device_name_tag = '{device_number.Split("_")[3]}'
|
||||
and device_floor_tag = '{device_number.Split("_")[4]}' and device_master_tag = '{device_number.Split("_")[5]}'
|
||||
and device_last_name_tag = '{device_number.Split("_")[6]}' and device_serial_tag = '{device_number.Split("_")[7]}'
|
||||
and device_point_name = '{device_number.Split("_")[8]}'").Result;
|
||||
archiveRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/{deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "")}/~historyRollup/");
|
||||
//HttpWebRequest archiveMonthRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/H_E1_B1F_MVCB_MVCBH_V1/~historyRollup/");
|
||||
archiveRequest.Method = "POST";
|
||||
@ -1058,8 +1079,12 @@ namespace BackendWorkerService.Quartz.Jobs
|
||||
}
|
||||
foreach (var deviceNumberPoint in waterDeviceNumberPoints)
|
||||
{
|
||||
device_number = deviceNumberPoint.FullDeviceNumberPoint;
|
||||
var station = buildingStation.Where(x => x.system_key == deviceNumberPoint.DeviceNumber.Split("_")[1]).Select(x => x.system_value).FirstOrDefault();
|
||||
device_number = deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "");
|
||||
var station = backgroundServiceRepository.GetOneAsync<string>($@"select parent_path from import_niagara_item_history where device_building_tag = '{device_number.Split("_")[1].Replace("$3", "")}' and
|
||||
device_system_tag = '{device_number.Split("_")[2]}' and device_name_tag = '{device_number.Split("_")[3]}'
|
||||
and device_floor_tag = '{device_number.Split("_")[4]}' and device_master_tag = '{device_number.Split("_")[5]}'
|
||||
and device_last_name_tag = '{device_number.Split("_")[6]}' and device_serial_tag = '{device_number.Split("_")[7]}'
|
||||
and device_point_name = '{device_number.Split("_")[8]}'").Result;
|
||||
archiveRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/{deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "")}/~historyRollup/");
|
||||
//HttpWebRequest archiveMonthRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/H_E1_B1F_MVCB_MVCBH_V1/~historyRollup/");
|
||||
archiveRequest.Method = "POST";
|
||||
|
@ -280,7 +280,12 @@ namespace BackendWorkerService.Services.Implement
|
||||
<reltime name='interval' val = 'PT1D' />
|
||||
</obj>";
|
||||
|
||||
var station = buildingStation.Where(x => x.system_key == deviceNumberPoint.DeviceNumber.Split("_")[1]).Select(x => x.system_value).FirstOrDefault();
|
||||
string device_number = deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "");
|
||||
var station = backgroundServiceRepository.GetOneAsync<string>($@"select parent_path from import_niagara_item_history where device_building_tag = '{device_number.Split("_")[1].Replace("$3", "")}' and
|
||||
device_system_tag = '{device_number.Split("_")[2]}' and device_name_tag = '{device_number.Split("_")[3]}'
|
||||
and device_floor_tag = '{device_number.Split("_")[4]}' and device_master_tag = '{device_number.Split("_")[5]}'
|
||||
and device_last_name_tag = '{device_number.Split("_")[6]}' and device_serial_tag = '{device_number.Split("_")[7]}'
|
||||
and device_point_name = '{device_number.Split("_")[8]}'").Result;
|
||||
HttpWebRequest archiveDayRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/{deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "")}/~historyRollup/");
|
||||
//HttpWebRequest archiveDayRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/H_E1_B1F_MVCB_MVCBH_V1/~historyRollup/");
|
||||
archiveDayRequest.Method = "POST";
|
||||
@ -371,7 +376,12 @@ namespace BackendWorkerService.Services.Implement
|
||||
<reltime name='interval' val = 'PT1D' />
|
||||
</obj>";
|
||||
|
||||
var station = buildingStation.Where(x => x.system_key == deviceNumberPoint.DeviceNumber.Split("_")[1]).Select(x => x.system_value).FirstOrDefault();
|
||||
string device_number = deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "");
|
||||
var station = backgroundServiceRepository.GetOneAsync<string>($@"select parent_path from import_niagara_item_history where device_building_tag = '{device_number.Split("_")[1].Replace("$3", "")}' and
|
||||
device_system_tag = '{device_number.Split("_")[2]}' and device_name_tag = '{device_number.Split("_")[3]}'
|
||||
and device_floor_tag = '{device_number.Split("_")[4]}' and device_master_tag = '{device_number.Split("_")[5]}'
|
||||
and device_last_name_tag = '{device_number.Split("_")[6]}' and device_serial_tag = '{device_number.Split("_")[7]}'
|
||||
and device_point_name = '{device_number.Split("_")[8]}'").Result;
|
||||
HttpWebRequest archiveDayRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/{deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "")}/~historyRollup/");
|
||||
//HttpWebRequest archiveDayRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/H_E1_B1F_MVCB_MVCBH_V1/~historyRollup/");
|
||||
archiveDayRequest.Method = "POST";
|
||||
@ -460,7 +470,12 @@ namespace BackendWorkerService.Services.Implement
|
||||
<reltime name='interval' val = 'PT7D' />
|
||||
</obj>";
|
||||
|
||||
var station = buildingStation.Where(x => x.system_key == deviceNumberPoint.DeviceNumber.Split("_")[1]).Select(x => x.system_value).FirstOrDefault();
|
||||
string device_number = deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "");
|
||||
var station = backgroundServiceRepository.GetOneAsync<string>($@"select parent_path from import_niagara_item_history where device_building_tag = '{device_number.Split("_")[1].Replace("$3", "")}' and
|
||||
device_system_tag = '{device_number.Split("_")[2]}' and device_name_tag = '{device_number.Split("_")[3]}'
|
||||
and device_floor_tag = '{device_number.Split("_")[4]}' and device_master_tag = '{device_number.Split("_")[5]}'
|
||||
and device_last_name_tag = '{device_number.Split("_")[6]}' and device_serial_tag = '{device_number.Split("_")[7]}'
|
||||
and device_point_name = '{device_number.Split("_")[8]}'").Result;
|
||||
HttpWebRequest archiveWeekRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/{deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "")}/~historyRollup/");
|
||||
//HttpWebRequest archiveWeekRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/H_E1_B1F_MVCB_MVCBH_V1/~historyRollup/");
|
||||
archiveWeekRequest.Method = "POST";
|
||||
@ -545,7 +560,12 @@ namespace BackendWorkerService.Services.Implement
|
||||
<reltime name='interval' val = 'PT7D' />
|
||||
</obj>";
|
||||
|
||||
var station = buildingStation.Where(x => x.system_key == deviceNumberPoint.DeviceNumber.Split("_")[1]).Select(x => x.system_value).FirstOrDefault();
|
||||
string device_number = deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "");
|
||||
var station = backgroundServiceRepository.GetOneAsync<string>($@"select parent_path from import_niagara_item_history where device_building_tag = '{device_number.Split("_")[1].Replace("$3", "")}' and
|
||||
device_system_tag = '{device_number.Split("_")[2]}' and device_name_tag = '{device_number.Split("_")[3]}'
|
||||
and device_floor_tag = '{device_number.Split("_")[4]}' and device_master_tag = '{device_number.Split("_")[5]}'
|
||||
and device_last_name_tag = '{device_number.Split("_")[6]}' and device_serial_tag = '{device_number.Split("_")[7]}'
|
||||
and device_point_name = '{device_number.Split("_")[8]}'").Result;
|
||||
HttpWebRequest archiveWeekRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/{deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "")}/~historyRollup/");
|
||||
//HttpWebRequest archiveWeekRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/H_E1_B1F_MVCB_MVCBH_V1/~historyRollup/");
|
||||
archiveWeekRequest.Method = "POST";
|
||||
@ -636,7 +656,12 @@ namespace BackendWorkerService.Services.Implement
|
||||
<reltime name='interval' val = 'PT{dayInMonth}D' />
|
||||
</obj>";
|
||||
|
||||
var station = buildingStation.Where(x => x.system_key == deviceNumberPoint.DeviceNumber.Split("_")[1]).Select(x => x.system_value).FirstOrDefault();
|
||||
string device_number = deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "");
|
||||
var station = backgroundServiceRepository.GetOneAsync<string>($@"select parent_path from import_niagara_item_history where device_building_tag = '{device_number.Split("_")[1].Replace("$3", "")}' and
|
||||
device_system_tag = '{device_number.Split("_")[2]}' and device_name_tag = '{device_number.Split("_")[3]}'
|
||||
and device_floor_tag = '{device_number.Split("_")[4]}' and device_master_tag = '{device_number.Split("_")[5]}'
|
||||
and device_last_name_tag = '{device_number.Split("_")[6]}' and device_serial_tag = '{device_number.Split("_")[7]}'
|
||||
and device_point_name = '{device_number.Split("_")[8]}'").Result;
|
||||
HttpWebRequest archiveMonthRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/{deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "")}/~historyRollup/");
|
||||
//HttpWebRequest archiveMonthRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/H_E1_B1F_MVCB_MVCBH_V1/~historyRollup/");
|
||||
archiveMonthRequest.Method = "POST";
|
||||
@ -724,7 +749,12 @@ namespace BackendWorkerService.Services.Implement
|
||||
<reltime name='interval' val = 'PT{dayInMonth}D' />
|
||||
</obj>";
|
||||
|
||||
var station = buildingStation.Where(x => x.system_key == deviceNumberPoint.DeviceNumber.Split("_")[1]).Select(x => x.system_value).FirstOrDefault();
|
||||
string device_number = deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "");
|
||||
var station = backgroundServiceRepository.GetOneAsync<string>($@"select parent_path from import_niagara_item_history where device_building_tag = '{device_number.Split("_")[1].Replace("$3", "")}' and
|
||||
device_system_tag = '{device_number.Split("_")[2]}' and device_name_tag = '{device_number.Split("_")[3]}'
|
||||
and device_floor_tag = '{device_number.Split("_")[4]}' and device_master_tag = '{device_number.Split("_")[5]}'
|
||||
and device_last_name_tag = '{device_number.Split("_")[6]}' and device_serial_tag = '{device_number.Split("_")[7]}'
|
||||
and device_point_name = '{device_number.Split("_")[8]}'").Result;
|
||||
HttpWebRequest archiveMonthRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/{deviceNumberPoint.FullDeviceNumberPoint.Replace("$3", "")}/~historyRollup/");
|
||||
//HttpWebRequest archiveMonthRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/H_E1_B1F_MVCB_MVCBH_V1/~historyRollup/");
|
||||
archiveMonthRequest.Method = "POST";
|
||||
|
@ -283,8 +283,7 @@
|
||||
|
||||
$('#devPointsList').html(strHtml);
|
||||
|
||||
if (!hisFirst)
|
||||
{
|
||||
if (!hisFirst) {
|
||||
let start = new Date($('#his_startdate').val());
|
||||
let end = new Date(new Date().setDate(new Date($('#his_enddate input').val()).getDate() + 1));
|
||||
|
||||
@ -309,13 +308,27 @@
|
||||
var edt = new Date(new Date().setDate(sdt.getDate() + 1));
|
||||
start = start ?? sdt.toLocaleDateString();
|
||||
end = end ?? edt.toLocaleDateString();
|
||||
// callBackFromHistory();
|
||||
getHistoryDataByBaja(pageAct.deviceNumber + "_" + pageAct.deviceItem,
|
||||
new Date(start).getTime(),
|
||||
new Date(end).getTime(),
|
||||
pageAct.deviceName,
|
||||
pageAct.hisBuiName,
|
||||
callBackFromHistory);
|
||||
|
||||
let sendData = {
|
||||
device_number: pageAct.deviceNumber,
|
||||
device_point: pageAct.deviceItem
|
||||
}
|
||||
objSendData.Data = sendData;
|
||||
let url = baseApiUrl + "/api/DevGetWay";
|
||||
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
|
||||
if (res && res.code == "0000") {
|
||||
pageAct.hisBuiName = res.data;
|
||||
getHistoryDataByBaja(pageAct.deviceNumber + "_" + pageAct.deviceItem,
|
||||
new Date(start).getTime(),
|
||||
new Date(end).getTime(),
|
||||
pageAct.deviceName,
|
||||
pageAct.hisBuiName,
|
||||
callBackFromHistory);
|
||||
}
|
||||
else {
|
||||
$(loadEle).Loading("close");
|
||||
}
|
||||
}, function (res) { $(loadEle).Loading("close"); }, "POST", true).send();
|
||||
}
|
||||
|
||||
function callBackFromHistory(res = '{"count":0,"data":[]}') {
|
||||
@ -447,44 +460,44 @@
|
||||
v.type = pageAct.devicePoiName.split(" ")[0];
|
||||
});
|
||||
|
||||
let tag = "#historyTable";
|
||||
let tag = "#historyTable";
|
||||
|
||||
let column_defs = [
|
||||
{ "targets": [0], "width": "20%", "sortable": true },
|
||||
{ "targets": [1], "width": "20%", "sortable": true },
|
||||
{ "targets": [2], "width": "20%", "sortable": true }
|
||||
];
|
||||
let column_defs = [
|
||||
{ "targets": [0], "width": "20%", "sortable": true },
|
||||
{ "targets": [1], "width": "20%", "sortable": true },
|
||||
{ "targets": [2], "width": "20%", "sortable": true }
|
||||
];
|
||||
|
||||
let columns = [
|
||||
{
|
||||
"title": "類別",
|
||||
"data": "type"
|
||||
},
|
||||
{
|
||||
"title": "設備名稱",
|
||||
"data": "deviceName",
|
||||
},
|
||||
{
|
||||
"title": "數值",
|
||||
"data": "value",
|
||||
"render": function (data) {
|
||||
if (isNaN(data.toString())) {
|
||||
return data
|
||||
}
|
||||
return data.roundDecimal(2);
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "紀錄時間",
|
||||
"data": "timestamp",
|
||||
"render": function (data) {
|
||||
return displayDate(data, "datetime");
|
||||
}
|
||||
}
|
||||
];
|
||||
let columns = [
|
||||
{
|
||||
"title": "類別",
|
||||
"data": "type"
|
||||
},
|
||||
{
|
||||
"title": "設備名稱",
|
||||
"data": "deviceName",
|
||||
},
|
||||
{
|
||||
"title": "數值",
|
||||
"data": "value",
|
||||
"render": function (data) {
|
||||
if (isNaN(data.toString())) {
|
||||
return data
|
||||
}
|
||||
return data.roundDecimal(2);
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "紀錄時間",
|
||||
"data": "timestamp",
|
||||
"render": function (data) {
|
||||
return displayDate(data, "datetime");
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
historyTable = new YourTeam.JqDataTables.getTableByStatic(tag, data, columns, column_defs, null, null, null, null, "tpi");
|
||||
$(tag).DataTable().order([ 3, 'desc' ]);
|
||||
$(tag).DataTable().order([3, 'desc']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -496,7 +509,7 @@
|
||||
v.starttime = (pageAct.dateType == "month" ? new Date($('#getmonth').val()) : new Date($('#his_startdate').val()));
|
||||
v.endtime = $('#his_enddate input').val() === "" ? null : new Date($('#his_enddate input').val());
|
||||
v.dateType = pageAct.dateType;
|
||||
v.device_number = pageAct.deviceNumber;
|
||||
v.device_number = pageAct.deviceNumber;
|
||||
objSendData.Data = v;
|
||||
|
||||
$.ajax({
|
||||
@ -536,25 +549,25 @@
|
||||
}
|
||||
|
||||
//選擇棟別
|
||||
function SelectBuild(e, building_tag) {
|
||||
$(loadEle).Loading("start");
|
||||
checkIsSelectedBuilding();
|
||||
}
|
||||
|
||||
function checkIsSelectedBuilding() {
|
||||
let result = false;
|
||||
let buildingRadios = $("[name=buildingRadio]:checked");
|
||||
buildingTag = null;
|
||||
if (buildingRadios && buildingRadios.length > 0) {
|
||||
$("[name=buildingRadio]").parent().removeClass("btn-info");
|
||||
$("[name=buildingRadio]").parent().addClass("btn-secondary");
|
||||
$("[name=buildingRadio]:checked").parent().removeClass("btn-secondary");
|
||||
$("[name=buildingRadio]:checked").parent().addClass("btn-info");
|
||||
buildingTag = buildingRadios.val(); //building tag
|
||||
pageAct.hisBuiName = buildingRadios.prop('id').split("-")[1];
|
||||
initList();
|
||||
result = true;
|
||||
function SelectBuild(e, building_tag) {
|
||||
$(loadEle).Loading("start");
|
||||
checkIsSelectedBuilding();
|
||||
}
|
||||
|
||||
function checkIsSelectedBuilding() {
|
||||
let result = false;
|
||||
let buildingRadios = $("[name=buildingRadio]:checked");
|
||||
buildingTag = null;
|
||||
if (buildingRadios && buildingRadios.length > 0) {
|
||||
$("[name=buildingRadio]").parent().removeClass("btn-info");
|
||||
$("[name=buildingRadio]").parent().addClass("btn-secondary");
|
||||
$("[name=buildingRadio]:checked").parent().removeClass("btn-secondary");
|
||||
$("[name=buildingRadio]:checked").parent().addClass("btn-info");
|
||||
buildingTag = buildingRadios.val(); //building tag
|
||||
pageAct.hisBuiName = buildingRadios.prop('id').split("-")[1];
|
||||
initList();
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
</script>
|
@ -118,35 +118,47 @@ namespace FrontendWebApi.ApiControllers
|
||||
foreach (var d in listDevicePoint)
|
||||
{
|
||||
string buildingTag = d.DeviceNumber.Split("_")[1];
|
||||
var station = buildStation.Where(x => x.system_key == buildingTag).Select(x => x.system_value).FirstOrDefault();
|
||||
var archiveRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/{d.FullDeviceNumberPoint.Replace("$3", "")}/~historyRollup/");
|
||||
archiveRequest.Method = "POST";
|
||||
archiveRequest.Headers.Add("Authorization", "Basic " + encoded);
|
||||
archiveRequest.PreAuthenticate = true;
|
||||
var station = backendRepository.GetOneAsync<string>($@"select parent_path from import_niagara_item_history where device_building_tag = '{d.FullDeviceNumberPoint.Split("_")[1].Replace("$3", "")}' and
|
||||
device_system_tag = '{d.FullDeviceNumberPoint.Split("_")[2]}' and device_name_tag = '{d.FullDeviceNumberPoint.Split("_")[3]}'
|
||||
and device_floor_tag = '{d.FullDeviceNumberPoint.Split("_")[4]}' and device_master_tag = '{d.FullDeviceNumberPoint.Split("_")[5]}'
|
||||
and device_last_name_tag = '{d.FullDeviceNumberPoint.Split("_")[6]}' and device_serial_tag = '{d.FullDeviceNumberPoint.Split("_")[7]}'
|
||||
and device_point_name = '{d.FullDeviceNumberPoint.Split("_")[8]}'").Result;
|
||||
|
||||
byte[] byteArray = Encoding.UTF8.GetBytes(historyQueryFilter);
|
||||
using (Stream reqStream = archiveRequest.GetRequestStream())
|
||||
if (!string.IsNullOrEmpty(station))
|
||||
{
|
||||
reqStream.Write(byteArray, 0, byteArray.Length);
|
||||
var archiveRequest = (HttpWebRequest)WebRequest.Create($"{obixApiConfig.ApiBase}obix/histories/{station}/{d.FullDeviceNumberPoint.Replace("$3", "")}/~historyRollup/");
|
||||
archiveRequest.Method = "POST";
|
||||
archiveRequest.Headers.Add("Authorization", "Basic " + encoded);
|
||||
archiveRequest.PreAuthenticate = true;
|
||||
|
||||
byte[] byteArray = Encoding.UTF8.GetBytes(historyQueryFilter);
|
||||
using (Stream reqStream = archiveRequest.GetRequestStream())
|
||||
{
|
||||
reqStream.Write(byteArray, 0, byteArray.Length);
|
||||
}
|
||||
|
||||
var archiveResponse = (HttpWebResponse)archiveRequest.GetResponse();
|
||||
var archiveResponseContent = new StreamReader(archiveResponse.GetResponseStream()).ReadToEnd();
|
||||
archiveResponse.Dispose();
|
||||
archiveResponse.Close();
|
||||
|
||||
XmlDocument xmlDocument = new XmlDocument();
|
||||
xmlDocument.LoadXml(archiveResponseContent);
|
||||
var archiveJson = JsonConvert.SerializeXmlNode(xmlDocument);
|
||||
var archiveJsonResult = (JObject)JsonConvert.DeserializeObject(archiveJson);
|
||||
|
||||
if (!archiveJsonResult.ContainsKey("err"))
|
||||
{
|
||||
var jsonDevice = new JsonDevice();
|
||||
jsonDevice.deviceNumberPoint = d;
|
||||
jsonDevice.json = archiveJsonResult;
|
||||
jsonDevice.building_tag = buildingTag;
|
||||
jd.Add(jsonDevice);
|
||||
}
|
||||
}
|
||||
|
||||
var archiveResponse = (HttpWebResponse)archiveRequest.GetResponse();
|
||||
var archiveResponseContent = new StreamReader(archiveResponse.GetResponseStream()).ReadToEnd();
|
||||
archiveResponse.Dispose();
|
||||
archiveResponse.Close();
|
||||
|
||||
XmlDocument xmlDocument = new XmlDocument();
|
||||
xmlDocument.LoadXml(archiveResponseContent);
|
||||
var archiveJson = JsonConvert.SerializeXmlNode(xmlDocument);
|
||||
var archiveJsonResult = (JObject)JsonConvert.DeserializeObject(archiveJson);
|
||||
|
||||
if (!archiveJsonResult.ContainsKey("err"))
|
||||
else
|
||||
{
|
||||
var jsonDevice = new JsonDevice();
|
||||
jsonDevice.deviceNumberPoint = d;
|
||||
jsonDevice.json = archiveJsonResult;
|
||||
jsonDevice.building_tag = buildingTag;
|
||||
jd.Add(jsonDevice);
|
||||
Logger.LogError("【Device GetWay Error】, device_number: " + d.FullDeviceNumberPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -175,5 +175,47 @@ namespace FrontendWebApi.ApiControllers
|
||||
}
|
||||
return Ok(apiResult);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("api/DevGetWay")]
|
||||
public async Task<ActionResult<ApiResult<string>>> GetDevGetWay([FromBody] DeviceGetWayInput input)
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>(jwt_str);
|
||||
//check input
|
||||
if (input == null || string.IsNullOrEmpty(input.device_number) || string.IsNullOrEmpty(input.device_point))
|
||||
{
|
||||
apiResult.Code = "9998";
|
||||
apiResult.Msg = "資料輸入錯誤。";
|
||||
return Ok(apiResult);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var getWayStr = await backendRepository.GetOneAsync<string>($@"select parent_path from import_niagara_item_history where device_building_tag = '{input.device_number.Split("_")[1]}'
|
||||
and device_system_tag = '{input.device_number.Split("_")[2]}' and device_name_tag = '{input.device_number.Split("_")[3]}'
|
||||
and device_floor_tag = '{input.device_number.Split("_")[4]}' and device_master_tag = '{input.device_number.Split("_")[5]}'
|
||||
and device_last_name_tag = '{input.device_number.Split("_")[6]}' and device_serial_tag = '{input.device_number.Split("_")[7]}'
|
||||
and device_point_name = '{input.device_point}'");
|
||||
|
||||
//check string
|
||||
if (string.IsNullOrEmpty(getWayStr))
|
||||
{
|
||||
apiResult.Code = "9997";
|
||||
apiResult.Msg = "資料獲取錯誤。";
|
||||
return Ok(apiResult);
|
||||
}
|
||||
|
||||
apiResult.Data = getWayStr;
|
||||
apiResult.Code = "0000";
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
return Ok(apiResult);
|
||||
}
|
||||
return Ok(apiResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -195,5 +195,9 @@ namespace FrontendWebApi.Models
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class DeviceGetWayInput
|
||||
{
|
||||
public string device_number { get; set; }
|
||||
public string device_point { get; set; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user