Merge branch 'MCUT' of https://gitea.mjm-staging.developers-homelab.net/BIMS/BIMS into MCUT
This commit is contained in:
commit
1bc6a04d65
@ -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));
|
||||||
|
|
||||||
|
@ -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