修改歷史資料程序

This commit is contained in:
dev02 2023-08-03 13:54:31 +08:00
parent 93c12bbbde
commit e14be83897
2 changed files with 14 additions and 35 deletions

View File

@ -259,20 +259,8 @@
$('#devPointsList').html(strHtml); $('#devPointsList').html(strHtml);
if (!hisFirst) { if (!hisFirst) {
let start = new Date($('#his_startdate').val()); searchDate();
let end = new Date(new Date().setDate(new Date($('#his_enddate input').val()).getDate() + 1));
if (pageAct.dateType == "today" || pageAct.dateType == "day" || pageAct.dateType == "ytd")
end = new Date(new Date(start.valueOf()).setDate(start.getDate() + 1));
else if (pageAct.dateType == "month") {
start = new Date($('#getmonth').val());
end = new Date(new Date(start.valueOf()).setDate(start.getDate() + 30));
}
else if (pageAct.dateType != "range")
return;
getData(formatDate(start, "date", true), formatDate(end, "date", true));
} }
} }
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send(); ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
@ -283,8 +271,8 @@
$(loadEle).Loading("start"); $(loadEle).Loading("start");
var sdt = new Date(); var sdt = new Date();
var edt = new Date(new Date().setDate(sdt.getDate() + 1)); var edt = new Date(new Date().setDate(sdt.getDate() + 1));
start = start ?? sdt.toLocaleDateString(); start = start + " 00:00:00" ?? sdt.toLocaleDateString();
end = end ?? edt.toLocaleDateString(); end = end + " 23:59:59"?? edt.toLocaleDateString();
// callBackFromHistory(); // callBackFromHistory();
getHistoryDataByBaja(pageAct.deviceNumber + "_" + pageAct.deviceItem, getHistoryDataByBaja(pageAct.deviceNumber + "_" + pageAct.deviceItem,
new Date(start).getTime(), new Date(start).getTime(),
@ -318,19 +306,7 @@
pageAct.devicePoiName = $(elem).text(); pageAct.devicePoiName = $(elem).text();
pageAct.deviceItem = deviceItem; pageAct.deviceItem = deviceItem;
let start = new Date($('#his_startdate').val()); searchDate();
let end = new Date(new Date().setDate(new Date($('#his_enddate input').val()).getDate() + 1));
if (pageAct.dateType == "today" || pageAct.dateType == "day" || pageAct.dateType == "ytd")
end = new Date(new Date(start.valueOf()).setDate(start.getDate() + 1));
else if (pageAct.dateType == "month") {
start = new Date($('#getmonth').val());
end = new Date(new Date(start.valueOf()).setDate(start.getDate() + 30));
}
else if (pageAct.dateType != "range")
return;
getData(formatDate(start, "date", true), formatDate(end, "date", true));
} }
} }
@ -389,13 +365,14 @@
function searchDate() { function searchDate() {
let start = new Date($('#his_startdate').val()); let start = new Date($('#his_startdate').val());
let end = new Date(new Date().setDate(new Date($('#his_enddate input').val()).getDate() + 1)); let end = new Date($('#his_enddate input').val());
if (pageAct.dateType == "today" || pageAct.dateType == "day" || pageAct.dateType == "ytd") if (pageAct.dateType == "today" || pageAct.dateType == "day" || pageAct.dateType == "ytd")
end = new Date(new Date(start.valueOf()).setDate(start.getDate() + 1)); end = start;
else if (pageAct.dateType == "month") { else if (pageAct.dateType == "month") {
start = new Date($('#getmonth').val()); start = new Date($('#getmonth').val());
end = new Date(new Date(start.valueOf()).setDate(start.getDate() + 30)); end = new Date(start.valueOf()).setMonth(start.getMonth() + 1);
end = new Date(new Date(end).setDate(new Date(end).getDate() - 1));
} }
else if (pageAct.dateType != "range") else if (pageAct.dateType != "range")
return; return;
@ -473,7 +450,10 @@
v.starttime = pageAct.hisStartDate; v.starttime = pageAct.hisStartDate;
v.endtime = pageAct.hisEndDate; v.endtime = pageAct.hisEndDate;
v.dateType = pageAct.dateType; v.dateType = pageAct.dateType;
v.device_number = pageAct.deviceNumber; v.device_number = pageAct.deviceNumber;
v.device_item = pageAct.deviceItem;
v.deviceComName = pageAct.deviceComName;
v.building_tag = pageAct.buiTag;
objSendData.Data = v; objSendData.Data = v;
$.ajax({ $.ajax({

View File

@ -74,10 +74,9 @@ namespace FrontendWebApi.ApiControllers
#endregion obix #endregion obix
#region get device and device_item(point) #region get device and device_item(point)
var device = backendRepository.GetAllAsync<Device>($"select * from device where deleted = 0 and is_link = 1 and device_number = '{lhe.device_number}'").Result; var device = backendRepository.GetAllAsync<Device>($"select * from device where deleted = 0 and is_link = 1 and device_number = '{lhe.device_number}'").Result;
var devicePoint = backendRepository.GetAllAsync<Device_item>($"select * from device_item where deleted = 0 and is_link = 1 and is_show_history = 1 and device_building_tag = '{lhe.building_tag}' and points = '{lhe.device_item}'").Result; var devicePoint = backendRepository.GetAllAsync<Device_item>($"select * from device_item where deleted = 0 and is_link = 1 and is_show_history = 1 and device_building_tag = '{lhe.building_tag}'").Result;
#endregion #endregion
#region get data from niagara #region get data from niagara
lhe.endtime = lhe.dateType == "today" ? lhe.starttime : lhe.dateType == "month" ? lhe.starttime.AddMonths(1) : lhe.endtime;
var startTimestamp = string.Format("{0}T00:00:00.000+08:00", lhe.starttime.ToString("yyyy-MM-dd")); var startTimestamp = string.Format("{0}T00:00:00.000+08:00", lhe.starttime.ToString("yyyy-MM-dd"));
var endTimestamp = string.Format("{0}T23:59:59.000+08:00", lhe.endtime?.ToString("yyyy-MM-dd")); var endTimestamp = string.Format("{0}T23:59:59.000+08:00", lhe.endtime?.ToString("yyyy-MM-dd"));
var historyQueryFilter = $@"<obj is='obix: HistoryFilter'> var historyQueryFilter = $@"<obj is='obix: HistoryFilter'>