[後端] 修改同步niagara樓層更新
[前端] 修改history.html tag with "$3" problem
This commit is contained in:
parent
f1b138ce7b
commit
9e9a06f907
@ -120,6 +120,7 @@ namespace Backend.Controllers
|
|||||||
await niagaraDataSynchronizeRepository.CheckFullNameEmptyReplaceByDeviceName();
|
await niagaraDataSynchronizeRepository.CheckFullNameEmptyReplaceByDeviceName();
|
||||||
await niagaraDataSynchronizeRepository.InsertBuildingMenu();
|
await niagaraDataSynchronizeRepository.InsertBuildingMenu();
|
||||||
await niagaraDataSynchronizeRepository.InsertSubSystemFloor();
|
await niagaraDataSynchronizeRepository.InsertSubSystemFloor();
|
||||||
|
await niagaraDataSynchronizeRepository.InsertFloor();
|
||||||
await this.DeviceDisasterAsync();
|
await this.DeviceDisasterAsync();
|
||||||
result = true;
|
result = true;
|
||||||
|
|
||||||
|
@ -219,6 +219,9 @@
|
|||||||
<ul style="${(i1 != null ? index == i1 : first) && index2 == i2 ? `display:block;` : ``}">`;
|
<ul style="${(i1 != null ? index == i1 : first) && index2 == i2 ? `display:block;` : ``}">`;
|
||||||
|
|
||||||
$.each(val2.device, function (index3, val3) {
|
$.each(val2.device, function (index3, val3) {
|
||||||
|
if (val3.device_number.includes("$3"))
|
||||||
|
val3.device_number = val3.device_number.replace("$3", "");
|
||||||
|
|
||||||
strHtml += `<li data-tabname="hisListItem">
|
strHtml += `<li data-tabname="hisListItem">
|
||||||
<a href="#" onClick="setValue('${val3.device_number}', '${val3.full_name}', null)" data-filter-tags="${val3.full_name.toLowerCase()} ${val3.device_serial_tag.toLowerCase()}" data-devnum="${val3.device_number}">
|
<a href="#" onClick="setValue('${val3.device_number}', '${val3.full_name}', null)" data-filter-tags="${val3.full_name.toLowerCase()} ${val3.device_serial_tag.toLowerCase()}" data-devnum="${val3.device_number}">
|
||||||
<span class="nav-link-text">
|
<span class="nav-link-text">
|
||||||
@ -280,7 +283,8 @@
|
|||||||
|
|
||||||
$('#devPointsList').html(strHtml);
|
$('#devPointsList').html(strHtml);
|
||||||
|
|
||||||
if (!hisFirst) {
|
if (!hisFirst)
|
||||||
|
{
|
||||||
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(new Date().setDate(new Date($('#his_enddate input').val()).getDate() + 1));
|
||||||
|
|
||||||
@ -443,43 +447,43 @@
|
|||||||
v.type = pageAct.devicePoiName.split(" ")[0];
|
v.type = pageAct.devicePoiName.split(" ")[0];
|
||||||
});
|
});
|
||||||
|
|
||||||
let tag = "#historyTable";
|
let tag = "#historyTable";
|
||||||
|
|
||||||
let column_defs = [
|
let column_defs = [
|
||||||
{ "targets": [0], "width": "20%", "sortable": true },
|
{ "targets": [0], "width": "20%", "sortable": true },
|
||||||
{ "targets": [1], "width": "20%", "sortable": true },
|
{ "targets": [1], "width": "20%", "sortable": true },
|
||||||
{ "targets": [2], "width": "20%", "sortable": true }
|
{ "targets": [2], "width": "20%", "sortable": true }
|
||||||
];
|
];
|
||||||
|
|
||||||
let columns = [
|
let columns = [
|
||||||
{
|
{
|
||||||
"title": "類別",
|
"title": "類別",
|
||||||
"data": "type"
|
"data": "type"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "設備名稱",
|
"title": "設備名稱",
|
||||||
"data": "deviceName",
|
"data": "deviceName",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "數值",
|
"title": "數值",
|
||||||
"data": "value",
|
"data": "value",
|
||||||
"render": function (data) {
|
"render": function (data) {
|
||||||
if (isNaN(data.toString())) {
|
if (isNaN(data.toString())) {
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
return data.roundDecimal(2);
|
return data.roundDecimal(2);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "紀錄時間",
|
"title": "紀錄時間",
|
||||||
"data": "timestamp",
|
"data": "timestamp",
|
||||||
"render": function (data) {
|
"render": function (data) {
|
||||||
return displayDate(data, "datetime");
|
return displayDate(data, "datetime");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
historyTable = new YourTeam.JqDataTables.getTableByStatic(tag, data, columns, column_defs, null, null, null, null, "tpi");
|
historyTable = new YourTeam.JqDataTables.getTableByStatic(tag, data, columns, column_defs, null, null, null, null, "tpi");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,25 +534,25 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//選擇棟別
|
//選擇棟別
|
||||||
function SelectBuild(e, building_tag) {
|
function SelectBuild(e, building_tag) {
|
||||||
$(loadEle).Loading("start");
|
$(loadEle).Loading("start");
|
||||||
checkIsSelectedBuilding();
|
checkIsSelectedBuilding();
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkIsSelectedBuilding() {
|
function checkIsSelectedBuilding() {
|
||||||
let result = false;
|
let result = false;
|
||||||
let buildingRadios = $("[name=buildingRadio]:checked");
|
let buildingRadios = $("[name=buildingRadio]:checked");
|
||||||
buildingTag = null;
|
buildingTag = null;
|
||||||
if (buildingRadios && buildingRadios.length > 0) {
|
if (buildingRadios && buildingRadios.length > 0) {
|
||||||
$("[name=buildingRadio]").parent().removeClass("btn-info");
|
$("[name=buildingRadio]").parent().removeClass("btn-info");
|
||||||
$("[name=buildingRadio]").parent().addClass("btn-secondary");
|
$("[name=buildingRadio]").parent().addClass("btn-secondary");
|
||||||
$("[name=buildingRadio]:checked").parent().removeClass("btn-secondary");
|
$("[name=buildingRadio]:checked").parent().removeClass("btn-secondary");
|
||||||
$("[name=buildingRadio]:checked").parent().addClass("btn-info");
|
$("[name=buildingRadio]:checked").parent().addClass("btn-info");
|
||||||
buildingTag = buildingRadios.val(); //building tag
|
buildingTag = buildingRadios.val(); //building tag
|
||||||
pageAct.hisBuiName = buildingRadios.prop('id').split("-")[1];
|
pageAct.hisBuiName = buildingRadios.prop('id').split("-")[1];
|
||||||
initList();
|
initList();
|
||||||
result = true;
|
result = true;
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
@ -453,7 +453,7 @@ namespace Repository.BackendRepository.Implement
|
|||||||
sb.Append($@" SELECT m.*
|
sb.Append($@" SELECT m.*
|
||||||
FROM import_niagara_item m
|
FROM import_niagara_item m
|
||||||
LEFT JOIN device_item d
|
LEFT JOIN device_item d
|
||||||
ON m.device_system_tag = d.device_system_tag and m.device_name_tag = d.device_name_tag and m.device_point_name = d.points
|
ON m.device_system_tag = d.device_system_tag and m.device_name_tag = d.device_name_tag and m.device_point_name = d.points and m.device_building_tag collate utf8mb4_0900_ai_ci = d.device_building_tag
|
||||||
WHERE d.points IS NULL");
|
WHERE d.points IS NULL");
|
||||||
result = (await conn.QueryAsync<NiagaraTagsForItem>(sb.ToString())).ToList<NiagaraTagsForItem>();
|
result = (await conn.QueryAsync<NiagaraTagsForItem>(sb.ToString())).ToList<NiagaraTagsForItem>();
|
||||||
|
|
||||||
@ -913,5 +913,101 @@ namespace Repository.BackendRepository.Implement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task InsertFloor()
|
||||||
|
{
|
||||||
|
using (IDbConnection conn = GetDbConnection())
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<NiagaraTags> result;
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
#region comparison floor and sub_system_floor
|
||||||
|
sb.Append($@" select tag.*
|
||||||
|
from (
|
||||||
|
select device_building_tag, device_floor_tag
|
||||||
|
from import_niagara_tag
|
||||||
|
group by device_building_tag, device_floor_tag
|
||||||
|
) AS tag
|
||||||
|
LEFT JOIN floor f
|
||||||
|
ON tag.device_building_tag = f.building_tag and tag.device_floor_tag = f.full_name and f.deleted = 0
|
||||||
|
WHERE f.building_tag IS NULL;");
|
||||||
|
result = (await conn.QueryAsync<NiagaraTags>(sb.ToString())).ToList<NiagaraTags>();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
sb.Clear();
|
||||||
|
#region insert floor
|
||||||
|
if (result.Count > 0)
|
||||||
|
{
|
||||||
|
Dictionary<string, int> floorPriority = new Dictionary<string, int>();
|
||||||
|
foreach (var data in result)
|
||||||
|
{
|
||||||
|
FloorPriority fp = (await conn.QueryAsync<FloorPriority>($@"select building_tag, max(priority) as priority from floor
|
||||||
|
where building_tag = '{data.device_building_tag}' and deleted = 0 group by building_tag;")).FirstOrDefault();
|
||||||
|
int priority = 0;
|
||||||
|
|
||||||
|
if (fp == null && floorPriority.GetValueOrDefault(data.device_building_tag) == 0)
|
||||||
|
floorPriority.Add(data.device_building_tag, 0);
|
||||||
|
else if (fp != null && floorPriority.GetValueOrDefault(fp.building_tag) == 0)
|
||||||
|
floorPriority.Add(fp.building_tag, fp.Priority);
|
||||||
|
|
||||||
|
priority = ++floorPriority[data.device_building_tag];
|
||||||
|
|
||||||
|
sb.Append($@"insert into floor(floor_guid, building_tag, deleted, status, full_name, priority, created_by, created_at)
|
||||||
|
VALUES (uuid(), '{data.device_building_tag}', 0, 1, '{data.device_floor_tag}', {priority}, 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now());");
|
||||||
|
}
|
||||||
|
if (sb.Length > 0)
|
||||||
|
{
|
||||||
|
await conn.ExecuteAsync(sb.ToString());
|
||||||
|
sb.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region update unuse floor with niagara data
|
||||||
|
var floor = (await conn.QueryAsync<BuildFloor>($@"select f1.*
|
||||||
|
from floor as f1
|
||||||
|
left join (
|
||||||
|
select f.floor_guid
|
||||||
|
from (
|
||||||
|
select device_building_tag, device_floor_tag
|
||||||
|
from import_niagara_tag
|
||||||
|
group by device_building_tag, device_floor_tag
|
||||||
|
) AS tag
|
||||||
|
LEFT JOIN floor f
|
||||||
|
ON tag.device_building_tag = f.building_tag and tag.device_floor_tag = f.full_name and f.deleted = 0
|
||||||
|
) as f2 on f1.floor_guid = f2.floor_guid
|
||||||
|
where f2.floor_guid is null and f1.deleted = 0;")).ToList<BuildFloor>();
|
||||||
|
|
||||||
|
if (floor.Count > 0)
|
||||||
|
{
|
||||||
|
sb.Clear();
|
||||||
|
foreach (var f in floor)
|
||||||
|
{
|
||||||
|
sb.Append($"update floor set deleted = 1 where floor_guid = '{f.Floor_guid}';");
|
||||||
|
}
|
||||||
|
|
||||||
|
await conn.ExecuteAsync(sb.ToString());
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,16 @@ namespace Repository.BackendRepository.Interface
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task InsertSubSystemFloor();
|
Task InsertSubSystemFloor();
|
||||||
|
/// <summary>
|
||||||
|
/// compare deviceDisaster
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dv"></param>
|
||||||
|
/// <returns></returns>
|
||||||
Task DeviceDisasterAysnc(List<Device_value_disaster> dv);
|
Task DeviceDisasterAysnc(List<Device_value_disaster> dv);
|
||||||
|
/// <summary>
|
||||||
|
/// insert to floor
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task InsertFloor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,8 @@ namespace Repository.Models
|
|||||||
public class FloorPriority
|
public class FloorPriority
|
||||||
{
|
{
|
||||||
public string Floor_guid { get; set; } //樓層GUID
|
public string Floor_guid { get; set; } //樓層GUID
|
||||||
|
public string building_tag { get; set; }
|
||||||
|
public string full_name { get; set; }
|
||||||
public int Priority { get; set; }
|
public int Priority { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user