[Frontend][系統監控] 熱點放入 forge3D 程序建置 | 串資料庫拿取設備座標放入 3d 圖建置 | [FrontendWebApi] 後端撈取設備座標API 調整 | [系統監控] 電梯判斷node程序調整

This commit is contained in:
dev01 2022-12-27 18:44:22 +08:00
parent 64e9b8e3f0
commit 34f6022b10
8 changed files with 102 additions and 46 deletions

View File

@ -45,8 +45,9 @@
setLightColor();
}
if (arr.indexOf(5) != -1) {
setHotspotPoint();
show3DModel(data.urn_3D);
getHotspotPoint(() => {
show3DModel(data.urn_3D);
});
}
});
@ -255,38 +256,38 @@
function show3DModel(urn) {
launchViewerForHotspot(urn, (viewer, nodeIds) => {
getHotspotPoint();
},"[name=forgeViewer]");
}
function getHotspotPoint() {
function getHotspotPoint(callback = null) {
let url = baseApiUrl + "/api/GetDevForCor";
let sendData = [{
let sendData = {
"device_area_tag": pageAct.AreaTag,
"device_building_tag": pageAct.buiTag,
"device_system_tag": pageAct.sysMainTag,
"device_name_tag": pageAct.sysSubTag,
}];
};
objSendData.Data = sendData;
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
if (!res || res.code != "0000" || !res.data) {
} else {
devicePointList.push(res.data.device_coordinate_3d);
let myDataList = res.data?.filter(x => x.device_coordinate_3d != null && isJSON(x.device_coordinate_3d)).map(x => { return { position: JSON.parse(x.device_coordinate_3d) } });
setHotspotPoint(myDataList);
callback ? callback() : "";
}
}, null, "POST").send();
}
function setHotspotPoint() {
//先假設有抓到點位的座標 之後api改input後再接
const mydatalist = [{ position: { x: -21.95, y: 8.92, z: 63.27 } },
{ position: { x: -21.95, y: 7.61, z: 63.27 } },
{ position: { x: -21.95, y: 6.43, z: 63.27 } },
{ position: { x: -21.95, y: 5.31, z: 63.27 } }
];
getHopspotPoint(mydatalist);
function setHotspotPoint(myDataList = []) {
console.log(myDataList)
getHopspotPoint(myDataList);
}
onEvent("autodesk:click:sprite", "[name=forgeViewer]", function (e, obj) {
console.log(e, obj)
})
</script>

View File

@ -314,14 +314,15 @@ function getNodeIdByDbIds(allDbIdsStr, callback = null) {
let _childId = 0;
let evelMap = new Map();
let finTimeout = null;
let isCalled = false;
let fin2Timeout = null;
let hasElec = false;
allDbIdsStr.forEach((dbId) => {
curDbId = parseInt(dbId);
viewer.getProperties(curDbId, function (e) {
e.properties.forEach(function (item, idx) {
if (item.displayName == "tag_id" && e.name == "【電梯】") {
if (item.displayName == "tag_id" && e.name.indexOf("【電梯】") != -1) {
hasElec = true
tagId = e.dbId;
viewer.getProperties(tagId, function (e2) {
e2.properties.forEach(function (item2, idx2) {
@ -341,8 +342,7 @@ function getNodeIdByDbIds(allDbIdsStr, callback = null) {
console.log("map: " + evelMap);
clearTimeout(finTimeout)
finTimeout = setTimeout(() => {
if (isCalled == false) {
isCalled = true;
if (hasElec == true) {
callback ? callback(evelMap) : "";
}
}, 10)
@ -353,10 +353,9 @@ function getNodeIdByDbIds(allDbIdsStr, callback = null) {
});
})
} else {
clearTimeout(finTimeout)
finTimeout = setTimeout(() => {
if (isCalled == false) {
isCalled = true;
clearTimeout(fin2Timeout)
fin2Timeout = setTimeout(() => {
if (hasElec == false) {
callback ? callback([]) : "";
}
}, 10)
@ -622,7 +621,7 @@ async function addHotPoint(data) {
const DataVizCore = Autodesk.DataVisualization.Core;
const viewableType = Autodesk.DataVisualization.Core.ViewableType.SPRITE;//DataVizCore.ViewableType.SPRITE;
const spriteColor = new THREE.Color(0xffffff);
const spriteIcon = "/img/forge/hotspot.svg";
const spriteIcon = "/file/img/forge/hotspot.svg";
const style = new DataVizCore.ViewableStyle(viewableType, spriteColor, spriteIcon);
@ -654,6 +653,7 @@ async function addHotPoint(data) {
if (event.dbId >= 10 && event.dbId <= 13) {//event.dbId > 0 && event.dbId < 19
console.log(`Sprite clicked: ${event.dbId}`);
openHotspotModal();
$(selector).trigger("autodesk:click:sprite", event);
}
if (event.clickInfo != null) {
@ -671,11 +671,12 @@ async function addHotPoint(data) {
if (dbIds.length > 0) {
// 處理已選取元件的邏輯
$(selector).trigger("autodesk:click:sprite", event);
//openHotspotModal();
console.log(`------ name: ${viewer.model.getInstanceTree().getNodeName(dbIds)} , dbId: ${dbIds}`);//, id: ${event.clickInfo.object.id}, position.x: ${event.clickInfo.point.x}, y: ${event.clickInfo.point.y}, z: ${event.clickInfo.point.z}
} else {
// 處理沒有選取元件的邏輯
$(selector).trigger("autodesk:click:sprite", event);
console.log("no item");
}
}

View File

@ -3,6 +3,7 @@ var baseApiUrl = "http://localhost:3604";
var baseImgUrl = "https://localhost:44376";
var varRegApiUrl = "/reg/api/"; //註冊API路徑
var varApiUrl = "/api/"; //API路徑
var varPathDevIcon = "/upload/device_icon/";
var varPathImg = "/Upload/Images/";
var varPathFile = "/Upload/Files/";
var varGraPath = "/upload/graph_manage";

View File

@ -389,3 +389,12 @@ function strToDate(text, type = null, cal = 0) {
}
return result;
}
function isJSON(str) {
try {
JSON.parse(str);
return true;
} catch {
return false;
}
}

View File

@ -669,31 +669,29 @@ namespace FrontendWebApi.ApiControllers
[HttpPost]
[Route("api/GetDevForCor")]
public async Task<ActionResult<List<DevForCor>>> GetDevForCor([FromBody] List<Device> post)
public async Task<ActionResult<List<DevForCor>>> GetDevForCor([FromBody] Device p)
{
ApiResult<List<DevForCor>> apiResult = new ApiResult<List<DevForCor>>();
List<DevForCor> device = new List<DevForCor>();
try
{
if (post != null)
if (p != null)
{
if (post.Count > 0)
var param = new
{
foreach (var p in post)
{
var param = new { @device_area_tag = p.device_area_tag, @device_building_tag = p.device_building_tag, @device_system_tag = p.device_system_tag, @device_name_tag = p.device_name_tag,
@device_floor_tag = p.device_floor_tag };
var d = await backendRepository.GetOneAsync<DevForCor>($@"select * from device where deleted = 0 and select * from device
where deleted = 0 and device_area_tag = @device_area_tag and device_building_tag = @device_building_tag
and device_system_tag = @device_system_tag and device_name_tag = @device_name_tag
and device_floor_tag = ifnull(@device_floor_tag, device_floor_tag) "
, param);
if (d != null)
device.Add(d);
}
}
apiResult.Data = device;
@device_area_tag = p.device_area_tag,
@device_building_tag = p.device_building_tag,
@device_system_tag = p.device_system_tag,
@device_name_tag = p.device_name_tag,
@device_floor_tag = p.device_floor_tag
};
var d = await backendRepository.GetAllAsync<DevForCor>($@"select device_guid,device_number,device_floor_tag,device_coordinate_3d,forge_dbid
from device where deleted = 0 and device_area_tag = @device_area_tag and device_building_tag = @device_building_tag
and device_system_tag = @device_system_tag and device_name_tag = @device_name_tag
and device_floor_tag = ifnull(@device_floor_tag, device_floor_tag) ", param);
apiResult.Data = d;
apiResult.Code = "0000";
}
else
@ -711,5 +709,49 @@ namespace FrontendWebApi.ApiControllers
}
return Ok(apiResult);
}
/// <summary>
/// 燈控排程列表
/// </summary>
/// <param name="account"></param>
/// <returns></returns>
[HttpPost]
[Route("api/Device/GetLigSchList")]
public async Task<ActionResult<ApiResult<BuildBuildingMenu>>> GetLigSchList([FromBody] FindDevice fd)
{
ApiResult<BuildBuildingMenu> apiResult = new ApiResult<BuildBuildingMenu>(jwt_str);
if (!jwtlife)
{
apiResult.Code = "5000";
return BadRequest(apiResult);
}
else if (string.IsNullOrEmpty(fd.device_guid))
{
apiResult.Code = "0002";
apiResult.Msg = "傳入參數不完整";
return apiResult;
}
try
{
var buiMenu = await frontendRepository.GetOneAsync<BuildBuildingMenu>(
@$"SELECT b.urn_3D,bm.* FROM building_menu bm
JOIN building b on b.building_tag = bm.building_tag
WHERE bm.building_tag = @building_tag AND bm.main_system_tag = @main_system_tag AND bm.sub_system_tag = @sub_system_tag",
new { @sub_system_tag = fd.sub_system_tag, @main_system_tag = fd.main_system_tag, @building_tag = fd.building_tag });
apiResult.Data = buiMenu;
apiResult.Code = "0000";
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
return Ok(apiResult);
}
return Ok(apiResult);
}
}
}

View File

@ -31,5 +31,7 @@
</Content>
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
</Project>

View File

@ -127,6 +127,6 @@ namespace FrontendWebApi.Models
public string device_number { get; set; }
public string device_floor_tag { get; set; }
public string device_coordinate_3d { get; set; }
public int forge_dbid { get; set; }
public int? forge_dbid { get; set; }
}
}

View File

@ -22,8 +22,8 @@
"MySqlDBConfig": {
"Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201
"Port": "js2LutKe+rdjzdxMPQUrvQ==",
"Database": "VJB2XC+lAtzuHObDGMVOAA==", //
//"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
//"Database": "VJB2XC+lAtzuHObDGMVOAA==", //
"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
"Password": "FVAPxztxpY4gJJKQ/se4bQ=="
},