[後端] 調整後台同步cctv型別, 調整model, 調整判定條件
[前端] 調整資料顯示欄位
This commit is contained in:
parent
0c662ec5d1
commit
cd83cf2133
@ -213,7 +213,7 @@ namespace Backend.Controllers
|
|||||||
JOIN variable mv ON d.device_system_tag = mv.system_value AND mv.system_type = @main_system_type and mv.deleted = 0
|
JOIN variable mv ON d.device_system_tag = mv.system_value AND mv.system_type = @main_system_type and mv.deleted = 0
|
||||||
JOIN variable sv ON d.device_name_tag = sv.system_value AND sv.system_type = @sub_system_type and sv.deleted = 0
|
JOIN variable sv ON d.device_name_tag = sv.system_value AND sv.system_type = @sub_system_type and sv.deleted = 0
|
||||||
JOIN floor f ON d.device_floor_tag = f.full_name AND d.device_building_tag = f.building_tag and f.deleted = 0
|
JOIN floor f ON d.device_floor_tag = f.full_name AND d.device_building_tag = f.building_tag and f.deleted = 0
|
||||||
LEFT JOIN device_kind dk ON dk.device_building_tag = d.device_building_tag AND dk.device_system_tag = d.device_system_tag AND dk.device_name_tag = d.device_name_tag
|
LEFT JOIN device_kind dk ON dk.device_building_tag = d.device_building_tag AND dk.device_system_tag = d.device_system_tag AND dk.device_name_tag = d.device_name_tag and dk.is_link = 1
|
||||||
ORDER BY d.priority ASC, d.device_number ASC";
|
ORDER BY d.priority ASC, d.device_number ASC";
|
||||||
|
|
||||||
var devices = await backendRepository.GetAllAsync<Device>(sql, new
|
var devices = await backendRepository.GetAllAsync<Device>(sql, new
|
||||||
@ -981,7 +981,8 @@ namespace Backend.Controllers
|
|||||||
dk.device_error_point_value,
|
dk.device_error_point_value,
|
||||||
dk.device_error_color,
|
dk.device_error_color,
|
||||||
dk.device_error_flashing,
|
dk.device_error_flashing,
|
||||||
dk.device_error_independent
|
dk.device_error_independent,
|
||||||
|
dk.device_model_tag
|
||||||
FROM ( SELECT
|
FROM ( SELECT
|
||||||
d.device_building_tag,
|
d.device_building_tag,
|
||||||
d.device_system_tag,
|
d.device_system_tag,
|
||||||
@ -1004,7 +1005,8 @@ namespace Backend.Controllers
|
|||||||
LEFT JOIN device_kind dk ON dd.device_building_tag = dk.device_building_tag
|
LEFT JOIN device_kind dk ON dd.device_building_tag = dk.device_building_tag
|
||||||
AND dd.device_system_tag = dk.device_system_tag
|
AND dd.device_system_tag = dk.device_system_tag
|
||||||
-- AND dd.device_floor_tag = dk.device_floor_tag
|
-- AND dd.device_floor_tag = dk.device_floor_tag
|
||||||
AND dd.device_name_tag = dk.device_name_tag";
|
AND dd.device_name_tag = dk.device_name_tag
|
||||||
|
and dk.is_link = 1";
|
||||||
|
|
||||||
var deviceKinds = await backendRepository.GetAllAsync<DeviceKind>(sql, post);
|
var deviceKinds = await backendRepository.GetAllAsync<DeviceKind>(sql, post);
|
||||||
|
|
||||||
@ -1035,7 +1037,7 @@ namespace Backend.Controllers
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string sWhere = "device_kind_guid = @Device_kind_guid";
|
string sWhere = "device_kind_guid = @Device_kind_guid and is_link = 1";
|
||||||
|
|
||||||
object param = new { Deleted = 0, Device_kind_guid = guid };
|
object param = new { Deleted = 0, Device_kind_guid = guid };
|
||||||
|
|
||||||
@ -1112,6 +1114,7 @@ namespace Backend.Controllers
|
|||||||
{ "@device_error_color", post.Device_error_color},
|
{ "@device_error_color", post.Device_error_color},
|
||||||
{ "@device_error_flashing", post.Device_error_flashing},
|
{ "@device_error_flashing", post.Device_error_flashing},
|
||||||
{ "@device_error_independent", post.Device_error_independent},
|
{ "@device_error_independent", post.Device_error_independent},
|
||||||
|
{ "@is_link", 1},
|
||||||
{ "@created_by", myUserInfo.Userinfo_guid}
|
{ "@created_by", myUserInfo.Userinfo_guid}
|
||||||
};
|
};
|
||||||
await backendRepository.AddOneByCustomTable(deviceKindDic, "device_kind");
|
await backendRepository.AddOneByCustomTable(deviceKindDic, "device_kind");
|
||||||
@ -1194,6 +1197,7 @@ namespace Backend.Controllers
|
|||||||
{ "@device_error_color", post.Device_error_color},
|
{ "@device_error_color", post.Device_error_color},
|
||||||
{ "@device_error_flashing", post.Device_error_flashing},
|
{ "@device_error_flashing", post.Device_error_flashing},
|
||||||
{ "@device_error_independent", post.Device_error_independent},
|
{ "@device_error_independent", post.Device_error_independent},
|
||||||
|
{ "@is_link", 1},
|
||||||
{ "@created_by", myUserInfo.Userinfo_guid}
|
{ "@created_by", myUserInfo.Userinfo_guid}
|
||||||
};
|
};
|
||||||
await backendRepository.AddOneByCustomTable(deviceKindDic, "device_kind");
|
await backendRepository.AddOneByCustomTable(deviceKindDic, "device_kind");
|
||||||
|
@ -753,7 +753,7 @@ namespace Backend.Controllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var tags = await backendRepository.GetAllAsync<Tags>(
|
var tags = await backendRepository.GetAllAsync<Tags>(
|
||||||
@$"select * from (select dk.device_building_tag ,dk.device_name_tag,dk.device_system_tag from device_kind dk where dk.device_normal_point_id = @id) dkn
|
@$"select * from (select dk.device_building_tag ,dk.device_name_tag,dk.device_system_tag from device_kind dk where dk.device_normal_point_id = @id and is_link = 1) dkn
|
||||||
union(select dk.device_building_tag, dk.device_name_tag, dk.device_system_tag from device_kind dk where dk.device_close_point_id = @id)
|
union(select dk.device_building_tag, dk.device_name_tag, dk.device_system_tag from device_kind dk where dk.device_close_point_id = @id)
|
||||||
union(select dk.device_building_tag, dk.device_name_tag, dk.device_system_tag from device_kind dk where dk.device_error_point_id = @id)", new { id = post.guid});
|
union(select dk.device_building_tag, dk.device_name_tag, dk.device_system_tag from device_kind dk where dk.device_error_point_id = @id)", new { id = post.guid});
|
||||||
|
|
||||||
@ -779,7 +779,8 @@ namespace Backend.Controllers
|
|||||||
foreach (var tag in tags)
|
foreach (var tag in tags)
|
||||||
{
|
{
|
||||||
unionsql += $@"select d.building_tag,d.device_system_tag,d.device_name_tag,d.device_last_name from device d where d.device_name_tag = '{sub_system.system_value}'
|
unionsql += $@"select d.building_tag,d.device_system_tag,d.device_name_tag,d.device_last_name from device d where d.device_name_tag = '{sub_system.system_value}'
|
||||||
and d.device_building_tag = '{tag.device_building_tag}' and d.device_system_tag = '{tag.device_system_tag}' and d.device_name_tag = '{tag.device_name_tag}' group by d.building_guid,d.main_system_guid,d.sub_system_guid,d.device_name_tag";
|
and d.device_building_tag = '{tag.device_building_tag}' and d.device_system_tag = '{tag.device_system_tag}' and d.device_name_tag = '{tag.device_name_tag}'
|
||||||
|
group by d.building_guid,d.main_system_guid,d.sub_system_guid,d.device_name_tag";
|
||||||
if (!last.Equals(tag))
|
if (!last.Equals(tag))
|
||||||
{
|
{
|
||||||
unionsql += " union ";
|
unionsql += " union ";
|
||||||
|
@ -78,6 +78,7 @@ namespace Backend.Models
|
|||||||
public string Device_port { get; set; }
|
public string Device_port { get; set; }
|
||||||
public string device_name_tag { get; set; }
|
public string device_name_tag { get; set; }
|
||||||
public string device_system_tag { get; set; }
|
public string device_system_tag { get; set; }
|
||||||
|
public string device_model_tag { get; set; }
|
||||||
public List<DeviceDisaster> Device_disasters { get; set; } //防災類型
|
public List<DeviceDisaster> Device_disasters { get; set; } //防災類型
|
||||||
public List<DeviceNode> Device_nodes { get; set; } //設備子節點
|
public List<DeviceNode> Device_nodes { get; set; } //設備子節點
|
||||||
}
|
}
|
||||||
@ -167,6 +168,7 @@ namespace Backend.Models
|
|||||||
public string Device_error_color { get; set; }
|
public string Device_error_color { get; set; }
|
||||||
public byte Device_error_flashing { get; set; }
|
public byte Device_error_flashing { get; set; }
|
||||||
public byte Device_error_independent { get; set; }
|
public byte Device_error_independent { get; set; }
|
||||||
|
public string device_model_tag { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PointName
|
public class PointName
|
||||||
|
@ -59,6 +59,7 @@ namespace Backend.Models
|
|||||||
public string device_building_tag { get; set; }
|
public string device_building_tag { get; set; }
|
||||||
public string device_system_tag { get; set; }
|
public string device_system_tag { get; set; }
|
||||||
public string device_name_tag { get; set; }
|
public string device_name_tag { get; set; }
|
||||||
|
public string device_model_tag { get; set; }
|
||||||
}
|
}
|
||||||
public class Deletebool
|
public class Deletebool
|
||||||
{
|
{
|
||||||
|
@ -1338,7 +1338,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"data": "device_name_tag"
|
"data": null,
|
||||||
|
"render": function (data, type, row, meta) {
|
||||||
|
return data.device_system_tag == "S" && data.device_name_tag == "C" ? data.device_model_tag : data.device_name_tag;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"data": "device_image",
|
"data": "device_image",
|
||||||
|
@ -478,6 +478,7 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
var layer3sql = "";
|
var layer3sql = "";
|
||||||
var sWhere = "";
|
var sWhere = "";
|
||||||
var singleSubSql = "";
|
var singleSubSql = "";
|
||||||
|
var cctvSql = "";
|
||||||
if (!String.IsNullOrEmpty(post.main_system_tag))
|
if (!String.IsNullOrEmpty(post.main_system_tag))
|
||||||
{
|
{
|
||||||
main_system_guidsql = $" and d.device_system_tag = '{post.main_system_tag}'";
|
main_system_guidsql = $" and d.device_system_tag = '{post.main_system_tag}'";
|
||||||
@ -493,6 +494,9 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
{
|
{
|
||||||
sub_system_guidsql = $" and d.device_name_tag = '{post.sub_system_tag}'";
|
sub_system_guidsql = $" and d.device_name_tag = '{post.sub_system_tag}'";
|
||||||
singleSubSql = $"and di.device_name_tag = '{post.sub_system_tag}'";
|
singleSubSql = $"and di.device_name_tag = '{post.sub_system_tag}'";
|
||||||
|
|
||||||
|
if (post.main_system_tag.Equals("S") && post.sub_system_tag.Equals("C"))
|
||||||
|
cctvSql = $" and d.device_model_tag = dk.device_model_tag";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!String.IsNullOrEmpty(post.device_system_category_layer3))
|
if (!String.IsNullOrEmpty(post.device_system_category_layer3))
|
||||||
@ -590,6 +594,8 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
and d.device_system_tag = dk.device_system_tag
|
and d.device_system_tag = dk.device_system_tag
|
||||||
-- and d.device_floor_tag = dk.device_floor_tag
|
-- and d.device_floor_tag = dk.device_floor_tag
|
||||||
and d.device_name_tag = dk.device_name_tag
|
and d.device_name_tag = dk.device_name_tag
|
||||||
|
and dk.is_link = 1
|
||||||
|
{cctvSql}
|
||||||
left join device_master dm ON d.device_building_tag = dm.device_building_tag
|
left join device_master dm ON d.device_building_tag = dm.device_building_tag
|
||||||
AND d.device_name_tag = dm.device_name_tag
|
AND d.device_name_tag = dm.device_name_tag
|
||||||
left join (
|
left join (
|
||||||
|
@ -74,6 +74,7 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
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
|
||||||
join device d on v1.system_value = d.device_system_tag and v2.system_value = d.device_name_tag and d.deleted = 0
|
join device d on v1.system_value = d.device_system_tag and v2.system_value = d.device_name_tag and d.deleted = 0
|
||||||
left join device_kind dk on v1.system_value = dk.device_system_tag and v2.system_value = dk.device_name_tag and dk.device_building_tag = @building_tag
|
left join device_kind dk on v1.system_value = dk.device_system_tag and v2.system_value = dk.device_name_tag and dk.device_building_tag = @building_tag
|
||||||
|
and dk.is_link = 1 and (dk.device_model_tag is null or dk.device_model_tag = d.device_model_tag)
|
||||||
-- left join device_item di on v2.system_value = di.device_name_tag and v1.system_value = di.device_system_tag and di.deleted = 0
|
-- left join device_item di on v2.system_value = di.device_name_tag and v1.system_value = di.device_system_tag and di.deleted = 0
|
||||||
join (
|
join (
|
||||||
select distinct main_system_tag, sub_system_tag, priority from building_menu where building_tag = @building_tag and is_link = 1
|
select distinct main_system_tag, sub_system_tag, priority from building_menu where building_tag = @building_tag and is_link = 1
|
||||||
@ -298,7 +299,7 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
d.room_dbid, d.device_coordinate_3d, d.forge_dbid
|
d.room_dbid, d.device_coordinate_3d, d.forge_dbid
|
||||||
from device d
|
from device d
|
||||||
left join device_kind dk on d.device_building_tag = dk.device_building_tag and d.device_system_tag = dk.device_system_tag
|
left join device_kind dk on d.device_building_tag = dk.device_building_tag and d.device_system_tag = dk.device_system_tag
|
||||||
and d.device_name_tag = dk.device_name_tag
|
and d.device_name_tag = dk.device_name_tag and dk.is_link = 1 and (dk.device_model_tag is null or dk.device_model_tag = d.device_model_tag)
|
||||||
where d.deleted = 0 and d.device_name_tag = @sub_system_tag and d.device_building_tag = @building_tag and d.device_floor_tag = @floor_tag
|
where d.deleted = 0 and d.device_name_tag = @sub_system_tag and d.device_building_tag = @building_tag and d.device_floor_tag = @floor_tag
|
||||||
order by d.device_number";
|
order by d.device_number";
|
||||||
var dlParam = new { @sub_system_tag = fd.sub_system_tag, @building_tag = fd.building_tag, @floor_tag = f.full_name };
|
var dlParam = new { @sub_system_tag = fd.sub_system_tag, @building_tag = fd.building_tag, @floor_tag = f.full_name };
|
||||||
|
@ -126,7 +126,7 @@ namespace Repository.BackendRepository.Implement
|
|||||||
{
|
{
|
||||||
isDome= true;
|
isDome= true;
|
||||||
sb.Append($@" insert into import_niagara_tag(niagara_tags, device_area_tag, device_building_tag, device_system_tag,
|
sb.Append($@" insert into import_niagara_tag(niagara_tags, device_area_tag, device_building_tag, device_system_tag,
|
||||||
device_name_tag, device_floor_tag, device_master_tag, device_last_name_tag, device_serial_tag, device_full_name, atDateTime) values('" +
|
device_name_tag, device_floor_tag, device_master_tag, device_last_name_tag, device_serial_tag, device_model_tag, device_full_name, atDateTime) values('" +
|
||||||
row.tag_name + "', '" + //niagara_tags
|
row.tag_name + "', '" + //niagara_tags
|
||||||
"', '" + //device_area_tag
|
"', '" + //device_area_tag
|
||||||
arrTag[0] + "', '" + //device_building_tag
|
arrTag[0] + "', '" + //device_building_tag
|
||||||
@ -136,6 +136,7 @@ namespace Repository.BackendRepository.Implement
|
|||||||
"', '" + //device_master_tag
|
"', '" + //device_master_tag
|
||||||
"', '" + //device_last_name_tag
|
"', '" + //device_last_name_tag
|
||||||
arrTag[4] + "', '" + //device_serial_tag
|
arrTag[4] + "', '" + //device_serial_tag
|
||||||
|
arrTag[3] + "', '" + //device_model_tag
|
||||||
row.displayName + "', " + //device_full_name
|
row.displayName + "', " + //device_full_name
|
||||||
"now());"); //atDateTime
|
"now());"); //atDateTime
|
||||||
//await conn.ExecuteAsync(sb.ToString());
|
//await conn.ExecuteAsync(sb.ToString());
|
||||||
@ -455,6 +456,7 @@ namespace Repository.BackendRepository.Implement
|
|||||||
#region device, device_kind 新增
|
#region device, device_kind 新增
|
||||||
stopwatchSection = new Stopwatch();
|
stopwatchSection = new Stopwatch();
|
||||||
stopwatchSection.Start();
|
stopwatchSection.Start();
|
||||||
|
int count = 0;
|
||||||
//新增至device, is_link = 1
|
//新增至device, is_link = 1
|
||||||
if (result.Count > 0)
|
if (result.Count > 0)
|
||||||
{
|
{
|
||||||
@ -470,7 +472,6 @@ namespace Repository.BackendRepository.Implement
|
|||||||
device_name_tag = x.Key.device_name_tag2
|
device_name_tag = x.Key.device_name_tag2
|
||||||
});
|
});
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
foreach (var data in result)
|
foreach (var data in result)
|
||||||
{
|
{
|
||||||
//開關控制在個別燈具(device_node層) and 小類為二線式照明系統 and tag第八段開頭不是 G
|
//開關控制在個別燈具(device_node層) and 小類為二線式照明系統 and tag第八段開頭不是 G
|
||||||
@ -482,7 +483,7 @@ namespace Repository.BackendRepository.Implement
|
|||||||
else {
|
else {
|
||||||
sb.Append($@" insert device(device_guid, deleted, status, priority, is_link, device_area_tag,
|
sb.Append($@" insert device(device_guid, deleted, status, priority, is_link, device_area_tag,
|
||||||
device_building_tag, device_system_tag, device_name_tag, full_name, device_floor_tag, device_master,
|
device_building_tag, device_system_tag, device_name_tag, full_name, device_floor_tag, device_master,
|
||||||
device_last_name, device_serial_tag, device_number, device_system_category_layer3, visible, created_at, updated_at)
|
device_last_name, device_serial_tag, device_model_tag, device_number, device_system_category_layer3, visible, created_at, updated_at)
|
||||||
values(uuid(), 0, 1, 0, 1, '" +
|
values(uuid(), 0, 1, 0, 1, '" +
|
||||||
data.device_area_tag + "', '" +
|
data.device_area_tag + "', '" +
|
||||||
data.device_building_tag + "', '" +
|
data.device_building_tag + "', '" +
|
||||||
@ -493,6 +494,7 @@ namespace Repository.BackendRepository.Implement
|
|||||||
data.device_master_tag + "', '" +
|
data.device_master_tag + "', '" +
|
||||||
data.device_last_name_tag + "', '" +
|
data.device_last_name_tag + "', '" +
|
||||||
data.device_serial_tag + "', '" +
|
data.device_serial_tag + "', '" +
|
||||||
|
data.device_model_tag + "', '" +
|
||||||
data.niagara_tags + "', '" +
|
data.niagara_tags + "', '" +
|
||||||
data.device_system_tag + "', 1, now(), now() );");
|
data.device_system_tag + "', 1, now(), now() );");
|
||||||
count += 1;
|
count += 1;
|
||||||
@ -522,8 +524,34 @@ namespace Repository.BackendRepository.Implement
|
|||||||
|
|
||||||
stopwatchSection = new Stopwatch();
|
stopwatchSection = new Stopwatch();
|
||||||
stopwatchSection.Start();
|
stopwatchSection.Start();
|
||||||
count = 0;
|
|
||||||
foreach (var data in result2)
|
foreach (var data in result2)
|
||||||
|
{
|
||||||
|
if (data.device_system_tag.Equals("S") && data.device_name_tag.Equals("C"))
|
||||||
|
{
|
||||||
|
var sqlString = new StringBuilder();
|
||||||
|
sqlString.Append("select * from device_kind where device_building_tag = '" + data.device_building_tag + "' and device_system_tag = '" + data.device_system_tag + "' and device_name_tag = '" + data.device_name_tag + "' and device_model_tag = '" + data.device_model_tag + "'");
|
||||||
|
var dk = (await conn.QueryAsync<device_kind>(sqlString.ToString())).ToList<device_kind>();
|
||||||
|
|
||||||
|
if (dk.Count == 0)
|
||||||
|
{
|
||||||
|
sb2.Append($@"INSERT device_kind (device_kind_guid, device_building_tag, device_system_tag, device_name_tag,
|
||||||
|
device_normal_flashing, device_close_flashing, device_error_flashing, device_error_independent,
|
||||||
|
created_by, created_at, device_model_tag, is_link)
|
||||||
|
VALUES (uuid(), '" + data.device_building_tag + "', '" + data.device_system_tag + "', '" + data.device_name_tag +
|
||||||
|
"', 0, 0, 1, 0, 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now(), '" + data.device_model_tag + "', 1);");
|
||||||
|
count += 1;
|
||||||
|
if (count >= 100)
|
||||||
|
{
|
||||||
|
using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
|
||||||
|
{
|
||||||
|
await conn.ExecuteAsync(sb2.ToString());
|
||||||
|
}
|
||||||
|
sb2.Clear();
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
var sqlString = new StringBuilder();
|
var sqlString = new StringBuilder();
|
||||||
sqlString.Append("select * from device_kind where device_building_tag = '" + data.device_building_tag + "' and device_system_tag = '" + data.device_system_tag + "' and device_name_tag = '" + data.device_name_tag + "'");
|
sqlString.Append("select * from device_kind where device_building_tag = '" + data.device_building_tag + "' and device_system_tag = '" + data.device_system_tag + "' and device_name_tag = '" + data.device_name_tag + "'");
|
||||||
@ -533,9 +561,79 @@ namespace Repository.BackendRepository.Implement
|
|||||||
{
|
{
|
||||||
sb2.Append($@"INSERT device_kind (device_kind_guid, device_building_tag, device_system_tag, device_name_tag,
|
sb2.Append($@"INSERT device_kind (device_kind_guid, device_building_tag, device_system_tag, device_name_tag,
|
||||||
device_normal_flashing, device_close_flashing, device_error_flashing, device_error_independent,
|
device_normal_flashing, device_close_flashing, device_error_flashing, device_error_independent,
|
||||||
created_by, created_at)
|
created_by, created_at, is_link)
|
||||||
VALUES (uuid(), '" + data.device_building_tag + "', '" + data.device_system_tag + "', '" + data.device_name_tag +
|
VALUES (uuid(), '" + data.device_building_tag + "', '" + data.device_system_tag + "', '" + data.device_name_tag +
|
||||||
"', 0, 0, 1, 0, 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now());");
|
"', 0, 0, 1, 0, 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now(), 1);");
|
||||||
|
count += 1;
|
||||||
|
if (count >= 100)
|
||||||
|
{
|
||||||
|
using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
|
||||||
|
{
|
||||||
|
await conn.ExecuteAsync(sb2.ToString());
|
||||||
|
}
|
||||||
|
sb2.Clear();
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sb2.Length > 0)
|
||||||
|
{
|
||||||
|
using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
|
||||||
|
{
|
||||||
|
await conn.ExecuteAsync(sb2.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
sb2.Clear();
|
||||||
|
}
|
||||||
|
stopwatchSection.Stop();
|
||||||
|
await KeepTimeLog("insert into device_kind", stopwatchSection.ElapsedMilliseconds);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region device_kind process for cctv
|
||||||
|
stopwatchSection = new Stopwatch();
|
||||||
|
stopwatchSection.Start();
|
||||||
|
using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
|
||||||
|
{
|
||||||
|
await conn.ExecuteAsync(@"SET SQL_SAFE_UPDATES = 0;
|
||||||
|
update device d join import_niagara_tag n on d.device_number = n.niagara_tags set d.device_model_tag = n.device_model_tag
|
||||||
|
where d.device_system_tag = 'S' and d.device_name_tag = 'C' and (d.device_model_tag is null or d.device_model_tag = '');");
|
||||||
|
}
|
||||||
|
stopwatchSection.Stop();
|
||||||
|
await KeepTimeLog("update cctv model is null or empty", stopwatchSection.ElapsedMilliseconds);
|
||||||
|
|
||||||
|
stopwatchSection = new Stopwatch();
|
||||||
|
stopwatchSection.Start();
|
||||||
|
var resultDeviceItem = await conn.QueryAsync<NiagaraTags>($@"select * from import_niagara_tag where device_system_tag = 'S' and device_name_tag = 'C';");
|
||||||
|
var result3 = resultDeviceItem.GroupBy(x => new
|
||||||
|
{
|
||||||
|
device_building_tag2 = x.device_building_tag,
|
||||||
|
device_system_tag2 = x.device_system_tag,
|
||||||
|
device_name_tag2 = x.device_name_tag,
|
||||||
|
device_model_tag2 = x.device_model_tag
|
||||||
|
}).Select(x => new Device_item8
|
||||||
|
{
|
||||||
|
device_building_tag = x.Key.device_building_tag2,
|
||||||
|
device_system_tag = x.Key.device_system_tag2,
|
||||||
|
device_name_tag = x.Key.device_name_tag2,
|
||||||
|
device_model_tag = x.Key.device_model_tag2
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var data in result3)
|
||||||
|
{
|
||||||
|
var sqlString = new StringBuilder();
|
||||||
|
sqlString.Append("select * from device_kind where device_building_tag = '" + data.device_building_tag + "' and device_system_tag = '" + data.device_system_tag + "' and device_name_tag = '" + data.device_name_tag + "' and device_model_tag = '" + data.device_model_tag + "'");
|
||||||
|
var dk = (await conn.QueryAsync<device_kind>(sqlString.ToString())).ToList<device_kind>();
|
||||||
|
|
||||||
|
if (dk.Count == 0)
|
||||||
|
{
|
||||||
|
sb2.Append($@"INSERT device_kind (device_kind_guid, device_building_tag, device_system_tag, device_name_tag,
|
||||||
|
device_normal_flashing, device_close_flashing, device_error_flashing, device_error_independent,
|
||||||
|
created_by, created_at, device_model_tag, is_link)
|
||||||
|
VALUES (uuid(), '" + data.device_building_tag + "', '" + data.device_system_tag + "', '" + data.device_name_tag +
|
||||||
|
"', 0, 0, 1, 0, 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now(), '" + data.device_model_tag + "', 1);");
|
||||||
count += 1;
|
count += 1;
|
||||||
if (count >= 100)
|
if (count >= 100)
|
||||||
{
|
{
|
||||||
@ -558,10 +656,38 @@ namespace Repository.BackendRepository.Implement
|
|||||||
|
|
||||||
sb2.Clear();
|
sb2.Clear();
|
||||||
}
|
}
|
||||||
stopwatchSection.Stop();
|
|
||||||
await KeepTimeLog("insert into device_kind", stopwatchSection.ElapsedMilliseconds);
|
|
||||||
|
|
||||||
|
using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
|
||||||
|
{
|
||||||
|
await conn.ExecuteAsync($@"SET SQL_SAFE_UPDATES = 0;
|
||||||
|
UPDATE device_kind dk
|
||||||
|
left JOIN (
|
||||||
|
SELECT device_system_tag, device_name_tag, device_model_tag
|
||||||
|
FROM import_niagara_tag
|
||||||
|
LIMIT 100000
|
||||||
|
) i ON dk.device_system_tag = i.device_system_tag
|
||||||
|
and dk.device_name_tag = i.device_name_tag
|
||||||
|
and dk.device_model_tag = i.device_model_tag
|
||||||
|
SET dk.is_link = 0
|
||||||
|
WHERE dk.is_link = 1 and dk.device_system_tag = 'S' and dk.device_name_tag = 'C' and i.device_system_tag is null;");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
|
||||||
|
{
|
||||||
|
await conn.ExecuteAsync($@"SET SQL_SAFE_UPDATES = 0;
|
||||||
|
UPDATE device_kind dk
|
||||||
|
left JOIN (
|
||||||
|
SELECT device_system_tag, device_name_tag, device_model_tag
|
||||||
|
FROM import_niagara_tag
|
||||||
|
LIMIT 100000
|
||||||
|
) i ON dk.device_system_tag = i.device_system_tag
|
||||||
|
and dk.device_name_tag = i.device_name_tag
|
||||||
|
and dk.device_model_tag = i.device_model_tag
|
||||||
|
SET dk.is_link = 1
|
||||||
|
WHERE dk.is_link = 0 and dk.device_system_tag = 'S' and dk.device_name_tag = 'C' and i.device_system_tag is not null;");
|
||||||
|
}
|
||||||
|
stopwatchSection.Stop();
|
||||||
|
await KeepTimeLog("insert/update cctv model is_link", stopwatchSection.ElapsedMilliseconds);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region device_node 新增
|
#region device_node 新增
|
||||||
@ -591,7 +717,7 @@ namespace Repository.BackendRepository.Implement
|
|||||||
device_name_tag = x.Key.device_name_tag2
|
device_name_tag = x.Key.device_name_tag2
|
||||||
});
|
});
|
||||||
|
|
||||||
int count = 0;
|
count = 0;
|
||||||
foreach (var data in result)
|
foreach (var data in result)
|
||||||
{
|
{
|
||||||
//開關控制在個別燈具(device_node層) and 小類為二線式照明系統 and tag第八段開頭不是 G
|
//開關控制在個別燈具(device_node層) and 小類為二線式照明系統 and tag第八段開頭不是 G
|
||||||
|
@ -64,8 +64,8 @@ namespace Repository.Models
|
|||||||
public string device_last_name_tag { get; set; }
|
public string device_last_name_tag { get; set; }
|
||||||
public string device_serial_tag { get; set; }
|
public string device_serial_tag { get; set; }
|
||||||
public string point_name { get; set; }
|
public string point_name { get; set; }
|
||||||
|
|
||||||
//public string result_value { get; set; }
|
//public string result_value { get; set; }
|
||||||
|
public string device_model_tag { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class NiagaraTags
|
public class NiagaraTags
|
||||||
@ -84,6 +84,7 @@ namespace Repository.Models
|
|||||||
public string device_full_name { get; set; }
|
public string device_full_name { get; set; }
|
||||||
public string atDateTime { get; set; }
|
public string atDateTime { get; set; }
|
||||||
public int is_used { get; set; }
|
public int is_used { get; set; }
|
||||||
|
public string device_model_tag { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class NiagaraTagsForItem
|
public class NiagaraTagsForItem
|
||||||
|
Loading…
Reference in New Issue
Block a user