更新 device 資料表 room_dbid, room_name
This commit is contained in:
parent
6d57a2b200
commit
d3df21b0b9
@ -394,7 +394,7 @@ namespace Backend.Controllers
|
|||||||
deviceImportCheck.Add("@device_name_tag", arr_device_number[3]); //設備名稱
|
deviceImportCheck.Add("@device_name_tag", arr_device_number[3]); //設備名稱
|
||||||
|
|
||||||
var pad = string.Empty;
|
var pad = string.Empty;
|
||||||
if(i < 10)
|
if (i < 10)
|
||||||
{
|
{
|
||||||
pad = i.ToString().PadLeft(2, '0');
|
pad = i.ToString().PadLeft(2, '0');
|
||||||
}
|
}
|
||||||
@ -766,20 +766,21 @@ namespace Backend.Controllers
|
|||||||
await backendRepository.TruncateTable("device_node");
|
await backendRepository.TruncateTable("device_node");
|
||||||
|
|
||||||
int node_priority = 1;
|
int node_priority = 1;
|
||||||
foreach(var idfc in post)
|
foreach (var idfc in post)
|
||||||
{
|
{
|
||||||
if (idfc.device_number.IndexOf("_LT_L1") > -1)
|
if (idfc.device_number.IndexOf("_LT_L1") > -1)
|
||||||
{
|
{
|
||||||
//取得device_guid
|
//取得device_guid
|
||||||
var sWhere = $@" deleted = 0 and device_number = '" + idfc.device_number + "'";
|
var sWhere = $@" deleted = 0 and device_number = '" + idfc.device_number + "'";
|
||||||
var device_guid = await backendRepository.GetOneColAsync("device", sWhere, "device_guid");
|
var device_guid = await backendRepository.GetOneColAsync("device", sWhere, "device_guid");
|
||||||
if(device_guid.ToString() != device_guid_record)
|
if (device_guid.ToString() != device_guid_record)
|
||||||
{
|
{
|
||||||
device_guid_record = device_guid.ToString();
|
device_guid_record = device_guid.ToString();
|
||||||
node_priority = 1;
|
node_priority = 1;
|
||||||
Dictionary<string, object> deviceForLight = new Dictionary<string, object>();
|
Dictionary<string, object> deviceForLight = new Dictionary<string, object>();
|
||||||
deviceForLight.Add("@device_coordinate_3d", idfc.device_coordinate_3d);
|
deviceForLight.Add("@device_coordinate_3d", idfc.device_coordinate_3d);
|
||||||
deviceForLight.Add("@forge_dbid", idfc.forge_dbid);
|
deviceForLight.Add("@forge_dbid", idfc.forge_dbid);
|
||||||
|
deviceForLight.Add("@room_name", idfc.room_name);
|
||||||
deviceForLight.Add("@updated_at", DateTime.Now);
|
deviceForLight.Add("@updated_at", DateTime.Now);
|
||||||
await backendRepository.UpdateOneByCustomTable(deviceForLight, "device", $@" device_guid = '{device_guid}'");
|
await backendRepository.UpdateOneByCustomTable(deviceForLight, "device", $@" device_guid = '{device_guid}'");
|
||||||
}
|
}
|
||||||
@ -803,9 +804,21 @@ namespace Backend.Controllers
|
|||||||
Dictionary<string, object> device = new Dictionary<string, object>();
|
Dictionary<string, object> device = new Dictionary<string, object>();
|
||||||
device.Add("@device_coordinate_3d", idfc.device_coordinate_3d);
|
device.Add("@device_coordinate_3d", idfc.device_coordinate_3d);
|
||||||
device.Add("@forge_dbid", idfc.forge_dbid);
|
device.Add("@forge_dbid", idfc.forge_dbid);
|
||||||
|
device.Add("@room_name", idfc.room_name);
|
||||||
device.Add("@updated_at", DateTime.Now);
|
device.Add("@updated_at", DateTime.Now);
|
||||||
await backendRepository.UpdateOneByCustomTable(device, "device", $@" device_number = '{idfc.device_number}'");
|
await backendRepository.UpdateOneByCustomTable(device, "device", $@" device_number = '{idfc.device_number}'");
|
||||||
}
|
}
|
||||||
|
//更新device資料表 room_dbid 欄位
|
||||||
|
string sql = @"
|
||||||
|
UPDATE
|
||||||
|
device AS de,
|
||||||
|
(
|
||||||
|
select f.room_id, f.room_name from forge_room f
|
||||||
|
join device d ON f.room_name = d.room_name
|
||||||
|
) AS re
|
||||||
|
SET de.room_dbid = re.room_id
|
||||||
|
WHERE de.room_name = re.room_name;";
|
||||||
|
await backendRepository.ExecuteSql(sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
|
@ -269,6 +269,7 @@ namespace Backend.Models
|
|||||||
public string device_number { get; set; }
|
public string device_number { get; set; }
|
||||||
public string device_coordinate_3d { get; set; }
|
public string device_coordinate_3d { get; set; }
|
||||||
public int forge_dbid { get; set; }
|
public int forge_dbid { get; set; }
|
||||||
|
public string room_name { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ImportForgeRoom
|
public class ImportForgeRoom
|
||||||
|
@ -246,9 +246,9 @@
|
|||||||
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6LW1vZGVsX3Rlc3QxMTIxLyVFMyU4MCU5MCVFNSU4RiVCMCVFNSU4QyU5NyVFNCVCOCVBRCVFOCU4RiVCMSVFNSVBNCVBNyVFNiVBOCU5MyVFMyU4MCU5MUFSQyVFOSU5QiU5OSVFNiVBOCVBMSVFNSVCQyU4RitNRVAlRTYlOEIlODYlRTclQjMlQkIlRTclQjUlQjFfJUU1JTg4JUFBJUU3JTg3JTg4JUU1JTg1JUI3XzIwMjNfMDFfMDYubndk');
|
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6LW1vZGVsX3Rlc3QxMTIxLyVFMyU4MCU5MCVFNSU4RiVCMCVFNSU4QyU5NyVFNCVCOCVBRCVFOCU4RiVCMSVFNSVBNCVBNyVFNiVBOCU5MyVFMyU4MCU5MUFSQyVFOSU5QiU5OSVFNiVBOCVBMSVFNSVCQyU4RitNRVAlRTYlOEIlODYlRTclQjMlQkIlRTclQjUlQjFfJUU1JTg4JUFBJUU3JTg3JTg4JUU1JTg1JUI3XzIwMjNfMDFfMDYubndk');
|
||||||
|
|
||||||
|
|
||||||
launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6LW1vZGVsX3Rlc3QxMTIxLyVFMyU4MCU5MCVFNSU4RiVCMCVFNSU4QyU5NyVFNCVCOCVBRCVFOCU4RiVCMSVFNSVBNCVBNyVFNiVBOCU5MyVFMyU4MCU5MUFSQyVFOSU5QiU5OSVFNiVBOCVBMSVFNSVCQyU4RitNRVAlRTYlOEIlODYlRTclQjMlQkIlRTclQjUlQjFfJUU1JTg4JUFBJUU3JTg3JTg4JUU1JTg1JUI3XzIwMjNfMDFfMDYubndk');
|
launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGEzaHFzZmZ6cWJub3V4a3BsZGt1a3NldzRzajIxdzUtYmltc19tb2RlbHMvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDJUU5JTlCJTk5JUU2JUE4JUExJUU1JUJDJThGK01FUCVFNiU4QiU4NiVFNyVCMyVCQiVFNyVCNSVCMV8wMTEwLm53ZA==');
|
||||||
|
|
||||||
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwQVJDJUUzJTgwJTkxXzIwMjJfMTJfMTMubndk');//new ARC
|
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlFX2ZvcmdlX3Rlc3QvJUUzJFTgwJTkwQVJDJUUzJTgwJTkxXzIwMjJfMTJfMTMubndk');//new ARC
|
||||||
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwTUVQJUUzJTgwJTkxXzIwMjJfMTJfMTMubndj');//new MEP
|
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwTUVQJUUzJTgwJTkxXzIwMjJfMTJfMTMubndj');//new MEP
|
||||||
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwQVJDJUUzJTgwJTkxJUU1JTg1JUE4JUU2JUEzJTlGXzIwMjJfMTJfMTMubndj');//全棟 ARC
|
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwQVJDJUUzJTgwJTkxJUU1JTg1JUE4JUU2JUEzJTlGXzIwMjJfMTJfMTMubndj');//全棟 ARC
|
||||||
|
|
||||||
|
@ -297,11 +297,18 @@ function onDocumentLoadSuccess(doc) {
|
|||||||
//console.log("position: (" + (position.x).toFixed(2) + ", " + (position.y).toFixed(2) + ", " + (position.z).toFixed(2) + ")");
|
//console.log("position: (" + (position.x).toFixed(2) + ", " + (position.y).toFixed(2) + ", " + (position.z).toFixed(2) + ")");
|
||||||
//console.log("--------------------------------------------------");
|
//console.log("--------------------------------------------------");
|
||||||
////}
|
////}
|
||||||
tagIdDevList.push({ device_number: item.displayValue, device_coordinate_3d: '{ "x": ' + (position.x).toFixed(2) + ', "y": ' + (position.y).toFixed(2) + ', "z": ' + (position.z).toFixed(2) + ' }', forge_dbid: e.dbId });
|
tagIdDevList.push({ device_number: item.displayValue, device_coordinate_3d: '{ "x": ' + (position.x).toFixed(2) + ', "y": ' + (position.y).toFixed(2) + ', "z": ' + (position.z).toFixed(2) + ' }', forge_dbid: e.dbId, room_name: "" });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (item.displayName == "【room_id】") {
|
||||||
|
tagIdDevList = tagIdDevList.map(tagItem => {
|
||||||
|
if (tagItem.forge_dbid === e.dbId) {
|
||||||
|
tagItem = { ...tagItem, room_name: item.displayValue }
|
||||||
|
}
|
||||||
|
return tagItem
|
||||||
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user