diff --git a/Frontend/_sysMonAll.html b/Frontend/_sysMonAll.html
index d72236d..3457c60 100644
--- a/Frontend/_sysMonAll.html
+++ b/Frontend/_sysMonAll.html
@@ -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)
+ })
\ No newline at end of file
diff --git a/Frontend/js/forge/forgemodel.js b/Frontend/js/forge/forgemodel.js
index c0f8d3e..3729e3c 100644
--- a/Frontend/js/forge/forgemodel.js
+++ b/Frontend/js/forge/forgemodel.js
@@ -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");
}
}
diff --git a/Frontend/js/init.js b/Frontend/js/init.js
index c3a1b84..402059d 100644
--- a/Frontend/js/init.js
+++ b/Frontend/js/init.js
@@ -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";
diff --git a/Frontend/js/site.js b/Frontend/js/site.js
index 50d6da7..f6041eb 100644
--- a/Frontend/js/site.js
+++ b/Frontend/js/site.js
@@ -388,4 +388,13 @@ function strToDate(text, type = null, cal = 0) {
result = calDay(tarDate, cal);
}
return result;
+}
+
+function isJSON(str) {
+ try {
+ JSON.parse(str);
+ return true;
+ } catch {
+ return false;
+ }
}
\ No newline at end of file
diff --git a/FrontendWebApi/ApiControllers/DeviceManageController.cs b/FrontendWebApi/ApiControllers/DeviceManageController.cs
index 2a2d306..3240399 100644
--- a/FrontendWebApi/ApiControllers/DeviceManageController.cs
+++ b/FrontendWebApi/ApiControllers/DeviceManageController.cs
@@ -669,31 +669,29 @@ namespace FrontendWebApi.ApiControllers
[HttpPost]
[Route("api/GetDevForCor")]
- public async Task>> GetDevForCor([FromBody] List post)
+ public async Task>> GetDevForCor([FromBody] Device p)
{
ApiResult> apiResult = new ApiResult>();
List device = new List();
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($@"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($@"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);
}
+
+ ///
+ /// 燈控排程列表
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("api/Device/GetLigSchList")]
+ public async Task>> GetLigSchList([FromBody] FindDevice fd)
+ {
+ ApiResult apiResult = new ApiResult(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(
+ @$"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);
+ }
}
}
\ No newline at end of file
diff --git a/FrontendWebApi/FrontendWebApi.csproj b/FrontendWebApi/FrontendWebApi.csproj
index ef80a5f..fe797d3 100644
--- a/FrontendWebApi/FrontendWebApi.csproj
+++ b/FrontendWebApi/FrontendWebApi.csproj
@@ -31,5 +31,7 @@
+
+
diff --git a/FrontendWebApi/Models/Device.cs b/FrontendWebApi/Models/Device.cs
index b73125b..5140e57 100644
--- a/FrontendWebApi/Models/Device.cs
+++ b/FrontendWebApi/Models/Device.cs
@@ -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; }
}
}
diff --git a/FrontendWebApi/appsettings.json b/FrontendWebApi/appsettings.json
index 5ae0baa..393dd42 100644
--- a/FrontendWebApi/appsettings.json
+++ b/FrontendWebApi/appsettings.json
@@ -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=="
},