Merge branch 'master' of https://gitea.mjm-staging.developers-homelab.net/BIMS/BIMS
This commit is contained in:
commit
a920c364f5
@ -43,10 +43,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row mb-2">
|
<div class="row mb-2">
|
||||||
<div class="btn-group">
|
<div id="devPointsList" class="btn-group">
|
||||||
<button type="button" class="btn btn-secondary waves-effect waves-themed">溫度</button>
|
|
||||||
<button type="button" class="btn btn-secondary waves-effect waves-themed">輸入電壓</button>
|
|
||||||
<button type="button" class="btn btn-secondary waves-effect waves-themed">輸入電流</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -77,7 +75,6 @@
|
|||||||
</main>
|
</main>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
initList();
|
initList();
|
||||||
|
|
||||||
@ -101,9 +98,8 @@
|
|||||||
let url = baseApiUrl + "/api/History/GetMainSub";
|
let url = baseApiUrl + "/api/History/GetMainSub";
|
||||||
function success(res) {
|
function success(res) {
|
||||||
let strHtml = ``;
|
let strHtml = ``;
|
||||||
let sst = '';
|
let i1 = null, i2 = null, first = true;
|
||||||
let sstn = '';
|
|
||||||
let mst = '';
|
|
||||||
|
|
||||||
$.each(res.data.history_Main_Systems, function (index, val) {
|
$.each(res.data.history_Main_Systems, function (index, val) {
|
||||||
strHtml += `<li>
|
strHtml += `<li>
|
||||||
@ -112,45 +108,80 @@
|
|||||||
</a>
|
</a>
|
||||||
<ul style="${index == 0 ? `display:block;` : ``}">`;
|
<ul style="${index == 0 ? `display:block;` : ``}">`;
|
||||||
|
|
||||||
|
i1 = (val.history_Sub_systems != null && i1 == null) ? index : null;
|
||||||
|
|
||||||
$.each(val.history_Sub_systems, function (index2, val2) {
|
$.each(val.history_Sub_systems, function (index2, val2) {
|
||||||
|
i2 = (val2.device != null && i2 == null) ? index2 : null;
|
||||||
|
|
||||||
strHtml += `<li>
|
strHtml += `<li>
|
||||||
<a href="#" onClick="getData('${val.main_system_tag}', '${val2.sub_system_tag}', '${val2.full_name}')" data-filter-tags="user interface buttons" data-subtag="${val2.sub_system_tag}">
|
<a href="#" data-filter-tags="user interface buttons" data-subtag="${val2.sub_system_tag}">
|
||||||
<span class="nav-link-text">
|
<span class="nav-link-text">
|
||||||
${val2.full_name} ${val2.sub_system_tag}
|
${val2.full_name} ${val2.sub_system_tag}
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</li>`;
|
<ul style="${index == i1 && index2 == i2 ? `display:block;` : ``}">`;
|
||||||
|
|
||||||
if (index == 0 && index2 == 0) {
|
$.each(val2.device, function (index3, val3) {
|
||||||
sst = val2.sub_system_tag;
|
strHtml += `<li>
|
||||||
mst = val.main_system_tag;
|
<a href="#" onClick=setValue('${val3.device_number}', '${val3.full_name}') data-filter-tags="user interface buttons" data-devnum="${val3.device_number}">
|
||||||
sstn = val2.full_name;
|
<span class="nav-link-text">
|
||||||
}
|
${val3.full_name} ${val3.device_serial_tag}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</li>`;
|
||||||
|
|
||||||
|
if (index == i1 && index2 == i2 && first) {
|
||||||
|
pageAct.deviceNumber = val3.device_number;
|
||||||
|
pageAct.deviceSerialTag = val3.device_serial_tag;
|
||||||
|
devPointsList();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
strHtml += `</ul> </li>`;
|
||||||
});
|
});
|
||||||
strHtml += `</ul> </li>`;
|
strHtml += `</ul> </li>`;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#js_nested_list').html(strHtml);
|
$('#js_nested_list').html(strHtml);
|
||||||
getData(mst, sst, sstn);
|
|
||||||
}
|
}
|
||||||
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
|
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getData(mst, sst, sstn) {
|
function devPointsList() {
|
||||||
//var dt = new Date();
|
let sendData = {
|
||||||
//console.log(dt);
|
device_number: pageAct.deviceNumber
|
||||||
|
}
|
||||||
|
objSendData.Data = sendData;
|
||||||
|
let url = baseApiUrl + "/api/History/GetDevPoi";
|
||||||
|
function success(res) {
|
||||||
|
let strHtml = ``;
|
||||||
|
|
||||||
|
$.each(res.data, function (index, val) {
|
||||||
|
strHtml += `<button onClick="setValue(null, null, '${val.points}')" type="button" class="btn btn-secondary waves-effect waves-themed">${val.full_name} ${val.points}</button>`;
|
||||||
|
|
||||||
|
if (index == 0) {
|
||||||
|
pageAct.deviceItem = val.points;
|
||||||
|
//getData();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#devPointsList').html(strHtml);
|
||||||
|
}
|
||||||
|
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getData() {
|
||||||
|
// var dt = new Date();
|
||||||
|
// console.log(dt);
|
||||||
// var start = dt.getFullYear().toString() + "-" + dt.getMonth().toString() + "-" + (dt.getDate()).toString() + "T00:00:00Z";
|
// var start = dt.getFullYear().toString() + "-" + dt.getMonth().toString() + "-" + (dt.getDate()).toString() + "T00:00:00Z";
|
||||||
//var end = dt.getFullYear().toString() + "-" + dt.getMonth().toString() + "-" + (dt.getDate() + 1).toString() + "T00:00:00Z";
|
//var end = dt.getFullYear().toString() + "-" + dt.getMonth().toString() + "-" + (dt.getDate() + 1).toString() + "T00:00:00Z";
|
||||||
// console.log(new Date(start).getTime());
|
// console.log(new Date(start).getTime());
|
||||||
// console.log(new Date(end).getTime());
|
// console.log(new Date(end).getTime());
|
||||||
getHistoryDataByBaja("TPE_B1_EE_E4", //"TPE_" + pageAct.buiTag + "_" + mst + "_" + sst,
|
//getHistoryDataByBaja(pageAct.deviceNumber + "_" + pageAct.deviceItem,
|
||||||
/*1666396800000,*/
|
// 1666396800000,
|
||||||
//1666483200000,
|
// 1666483200000,
|
||||||
1668927197000,
|
// pageAct.deviceName,
|
||||||
1668963661000,
|
// "Mitsubishi_Sup",
|
||||||
sstn,
|
// callBackFromHistory);
|
||||||
"Mitsubishi_Sup",
|
|
||||||
callBackFromHistory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function callBackFromHistory(res) {
|
function callBackFromHistory(res) {
|
||||||
@ -158,8 +189,14 @@
|
|||||||
console.log(res)
|
console.log(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
function callbackForHistory(result) {
|
function setValue(deviceNumber, deviceName, deviceItem) {
|
||||||
console.log(result);
|
if ((deviceNumber != null && deviceNumber != undefined) && (deviceName != null && deviceName != undefined)) {
|
||||||
|
pageAct.deviceNumber = deviceNumber;
|
||||||
|
pageAct.deviceName = deviceName;
|
||||||
|
devPointsList();
|
||||||
|
}
|
||||||
|
else if (deviceItem != null && deviceItem != undefined) {
|
||||||
|
pageAct.deviceItem = deviceItem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
@ -165,12 +165,14 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var dbsub = await frontendRepository.GetAllAsync<HistoryDBMainSub>(
|
var dbsub = await frontendRepository.GetAllAsync<HistoryDBMainSub>(
|
||||||
@$"select distinct v1.system_key main_name, v1.system_value main_system_tag, v2.system_key sub_name, v2.system_value sub_system_tag, v1.system_priority, v2.system_priority
|
@$"select distinct v1.system_key main_name, v1.system_value main_system_tag, v2.system_key sub_name, v2.system_value sub_system_tag, v1.system_priority, v2.system_priority,
|
||||||
|
d.device_number, d.full_name as device_full_name, d.device_serial_tag
|
||||||
from role_auth a
|
from role_auth a
|
||||||
join auth_page b on a.AuthCode = b.AuthCode
|
join auth_page b on a.AuthCode = b.AuthCode
|
||||||
join userinfo c on c.role_guid = a.role_guid
|
join userinfo c on c.role_guid = a.role_guid
|
||||||
join variable v2 on b.ShowView = v2.id and v2.system_type = @sub_system_type
|
join variable v2 on b.ShowView = v2.id and v2.system_type = @sub_system_type
|
||||||
join variable v1 on v1.id = v2.system_parent_id and v1.system_type = @main_system_type
|
join variable v1 on v1.id = v2.system_parent_id and v1.system_type = @main_system_type
|
||||||
|
left join device d on v1.system_value = d.device_system_tag and v2.system_value = d.device_name_tag and d.deleted = 0
|
||||||
where c.account = @account
|
where c.account = @account
|
||||||
order by v1.system_priority, v2.system_priority", new { @account = myUser.account, @sub_system_type = sub_system_type, @main_system_type = main_system_type });
|
order by v1.system_priority, v2.system_priority", new { @account = myUser.account, @sub_system_type = sub_system_type, @main_system_type = main_system_type });
|
||||||
var dbbuilding = await frontendRepository.GetAllAsync<History_Build>(
|
var dbbuilding = await frontendRepository.GetAllAsync<History_Build>(
|
||||||
@ -189,21 +191,76 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
History_Main_system history_Main_System = new History_Main_system();
|
History_Main_system history_Main_System = new History_Main_system();
|
||||||
history_Main_System.main_system_tag = main.Select(a => a.main_system_tag).FirstOrDefault();
|
history_Main_System.main_system_tag = main.Select(a => a.main_system_tag).FirstOrDefault();
|
||||||
history_Main_System.full_name = main.Select(a => a.main_name).FirstOrDefault();
|
history_Main_System.full_name = main.Select(a => a.main_name).FirstOrDefault();
|
||||||
history_Main_System.History_Sub_systems = new List<History_Sub_system>();
|
|
||||||
|
|
||||||
var subs = dbsub.Where(x => x.main_system_tag == main.Select(m => m.main_system_tag).FirstOrDefault()).ToList();
|
var subs = dbsub.Where(x => x.main_system_tag == main.Select(m => m.main_system_tag).FirstOrDefault()).GroupBy(x => x.sub_system_tag).ToList();
|
||||||
|
history_Main_System.History_Sub_systems = subs.Count > 0 ? new List<History_Sub_system>() : null;
|
||||||
foreach (var sub in subs)
|
foreach (var sub in subs)
|
||||||
{
|
{
|
||||||
History_Sub_system history_Sub_System = new History_Sub_system();
|
History_Sub_system history_Sub_System = new History_Sub_system();
|
||||||
history_Sub_System.full_name = sub.sub_name;
|
history_Sub_System.full_name = sub.Select(x => x.sub_name).FirstOrDefault();
|
||||||
history_Sub_System.sub_system_tag = sub.sub_system_tag;
|
history_Sub_System.sub_system_tag = sub.Select(x => x.sub_system_tag).FirstOrDefault();
|
||||||
|
|
||||||
|
|
||||||
|
var devices = dbsub.Where(x => x.main_system_tag == main.Select(m => m.main_system_tag).FirstOrDefault() && x.sub_system_tag == sub.Select(x => x.sub_system_tag).FirstOrDefault() && x.device_number != null).ToList();
|
||||||
|
history_Sub_System.device = devices.Count > 0 ? new List<Device>() : null;
|
||||||
|
foreach (var d in devices)
|
||||||
|
{
|
||||||
|
Device device = new Device();
|
||||||
|
device.device_number = d.device_number;
|
||||||
|
device.device_serial_tag = d.device_serial_tag;
|
||||||
|
device.full_name = d.device_full_name;
|
||||||
|
history_Sub_System.device.Add(device);
|
||||||
|
}
|
||||||
|
|
||||||
history_Main_System.History_Sub_systems.Add(history_Sub_System);
|
history_Main_System.History_Sub_systems.Add(history_Sub_System);
|
||||||
}
|
}
|
||||||
apiResult.Data.history_Main_Systems.Add(history_Main_System);
|
apiResult.Data.history_Main_Systems.Add(history_Main_System);
|
||||||
}
|
}
|
||||||
apiResult.Data.history_Builds = dbbuilding;
|
apiResult.Data.history_Builds = dbbuilding;
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
apiResult.Code = "9999";
|
||||||
|
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
|
||||||
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||||
|
return Ok(apiResult);
|
||||||
|
}
|
||||||
|
return Ok(apiResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 即時趨勢條件過濾條件面板
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="account"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("api/History/GetDevPoi")]
|
||||||
|
public async Task<ActionResult<ApiResult<List<DeviceItem>>>> GetDevPoi([FromBody] HistoryFind hf)
|
||||||
|
{
|
||||||
|
ApiResult<List<DeviceItem>> apiResult = new ApiResult<List<DeviceItem>>(jwt_str);
|
||||||
|
if (!jwtlife)
|
||||||
|
{
|
||||||
|
apiResult.Code = "5000";
|
||||||
|
return BadRequest(apiResult);
|
||||||
|
}
|
||||||
|
else if (string.IsNullOrEmpty(hf.device_number))
|
||||||
|
{
|
||||||
|
apiResult.Code = "0002";
|
||||||
|
apiResult.Msg = "必須選擇設備";
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<DeviceItem> deviceItems = new List<DeviceItem>();
|
||||||
|
var main_system_value = hf.device_number.Split('_')[2];
|
||||||
|
var sub_system_value = hf.device_number.Split('_')[3];
|
||||||
|
var sqlString = $@"select * from device_item where deleted = 0 and device_system_tag = @main_system_value and device_name_tag = @sub_system_value";
|
||||||
|
deviceItems = await frontendRepository.GetAllAsync<DeviceItem>(sqlString, new { @main_system_value = main_system_value, @sub_system_value = sub_system_value });
|
||||||
|
|
||||||
|
apiResult.Data = deviceItems;
|
||||||
|
apiResult.Code = "0000";
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
|
@ -161,6 +161,7 @@ namespace FrontendWebApi.Models
|
|||||||
public string device_floor_tag { get; set; }
|
public string device_floor_tag { get; set; }
|
||||||
public string device_name_tag { get; set; }
|
public string device_name_tag { get; set; }
|
||||||
public string device_serial_tag { get; set; }
|
public string device_serial_tag { get; set; }
|
||||||
|
public string device_last_name { get; set; }
|
||||||
public string device_system_category_layer3 { get; set; }
|
public string device_system_category_layer3 { get; set; }
|
||||||
public string device_ip { get; set; }
|
public string device_ip { get; set; }
|
||||||
public string device_port { get; set; }
|
public string device_port { get; set; }
|
||||||
|
@ -59,6 +59,9 @@ namespace FrontendWebApi.Models
|
|||||||
public string main_name { get; set; }
|
public string main_name { get; set; }
|
||||||
public string sub_system_tag { get; set; }
|
public string sub_system_tag { get; set; }
|
||||||
public string sub_name { get; set; }
|
public string sub_name { get; set; }
|
||||||
|
public string device_number { get; set; }
|
||||||
|
public string device_full_name { get; set; }
|
||||||
|
public string device_serial_tag { get; set; }
|
||||||
public string device_normal_color { get; set; }
|
public string device_normal_color { get; set; }
|
||||||
public string device_close_color { get; set; }
|
public string device_close_color { get; set; }
|
||||||
public string device_error_color { get; set; }
|
public string device_error_color { get; set; }
|
||||||
@ -79,6 +82,7 @@ namespace FrontendWebApi.Models
|
|||||||
public class HistoryFind
|
public class HistoryFind
|
||||||
{
|
{
|
||||||
public string building_tag { get; set; }
|
public string building_tag { get; set; }
|
||||||
|
public string device_number { get; set; }
|
||||||
}
|
}
|
||||||
public class BuildingFloorRawData
|
public class BuildingFloorRawData
|
||||||
{
|
{
|
||||||
@ -118,6 +122,7 @@ namespace FrontendWebApi.Models
|
|||||||
public string device_normal_color { get; set; }
|
public string device_normal_color { get; set; }
|
||||||
public string device_close_color { get; set; }
|
public string device_close_color { get; set; }
|
||||||
public string device_error_color { get; set; }
|
public string device_error_color { get; set; }
|
||||||
|
public List<Device> device { get; set; }
|
||||||
public string device_normal_flashing { get; set; }
|
public string device_normal_flashing { get; set; }
|
||||||
public string device_close_flashing { get; set; }
|
public string device_close_flashing { get; set; }
|
||||||
public string device_error_flashing { get; set; }
|
public string device_error_flashing { get; set; }
|
||||||
|
Loading…
Reference in New Issue
Block a user