[Frontend] index.html 及 forgemodel.js 合併

This commit is contained in:
dev01 2023-01-04 17:34:09 +08:00
commit dd2a66075c
11 changed files with 342 additions and 109 deletions

View File

@ -184,7 +184,6 @@
<script>
var curLightIsOpen = true;
var objSendData = { Data: null };
$(document).ready(function () {
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDLm53ZA');
@ -238,8 +237,10 @@
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDK01FUCVFNiU4QiU4NiVFNyVCMyVCQiVFNyVCNSVCMV8lRTUlOEQlOEElRTklODAlOEYlRTYlOTglOEUlRTUlQkIlQkElRTclQUYlODlfMTJfMzAubndk');
//12.31 整棟樓
launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGEzaHFzZmZ6cWJub3V4a3BsZGt1a3NldzRzajIxdzUtYmltc19tb2RlbHMvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDJUU5JTlCJTk5JUU2JUE4JUExJUU1JUJDJThGK01FUCVFNiU4QiU4NiVFNyVCMyVCQiVFNyVCNSVCMV8yMDIyXzEyXzMxLm53ZA');
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGEzaHFzZmZ6cWJub3V4a3BsZGt1a3NldzRzajIxdzUtYmltc19tb2RlbHMvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDJUU5JTlCJTk5JUU2JUE4JUExJUU1JUJDJThGK01FUCVFNiU4QiU4NiVFNyVCMyVCQiVFNyVCNSVCMV8yMDIyXzEyXzMxLm53ZA');
//雙模式
launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGEzaHFzZmZ6cWJub3V4a3BsZGt1a3NldzRzajIxdzUtYmltc19tb2RlbHMvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDJUU5JTlCJTk5JUU2JUE4JUExJUU1JUJDJThGK01FUCVFNiU4QiU4NiVFNyVCMyVCQiVFNyVCNSVCMV8yMDIyXzEyXzMxLm53ZA==');
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwQVJDJUUzJTgwJTkxXzIwMjJfMTJfMTMubndk');//new ARC
@ -384,75 +385,6 @@
function ImportDevForCor() {//callback = null
var url = "/DeviceImport/ImportDevForCor";
//let sendData = {
// "device_number": pageAct.AreaTag,
// "device_coordinate_3d": "",
// "device_dbid": "",
//};
objSendData.Data = tagIdDevList;
//ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
// if (!res || res.code != "0000" || !res.data) {
// console.log(rel.msg);
// } else {
// console.log(rel.msg);
// }
//}, null, "POST").send();
//$.post(url, objSendData.Data, function (rel) {
// if (rel.code != "0000") {
// if (rel.code == "9999") {
// //toast_error(rel.msg);
// console.log(rel.msg);
// }
// else {
// //toast_warning(rel.msg);
// console.log(rel.msg);
// }
// return;
// }
// else {
// //toast_ok(rel.msg);
// console.log(rel.msg);
// //ReloadRawDataCheckTable();
// }
//}, 'json');
//headers={'content-type': 'application/json'}
//$.ajax({
// type: "POST",
// url: url,
// data: objSendData.Data,
// cache: false,
// contentType: 'application/json',
// processData: false,
// success: function (rel) {
// //$("#save-building-btn").html('確定').attr("disabled", false);
// if (rel.code != "0000") {
// if (rel.code == "9999") {
// //toast_error(rel.msg);
// console.log(rel.msg);
// }
// else {
// //toast_warning(rel.msg);
// console.log(rel.msg);
// }
// return;
// }
// else {
// //toast_ok(rel.msg);
// console.log(rel.msg);
// //buildInfoTable.ajax.reload(null, false);
// //$('#build-modal').modal('hide');
// return;
// }
// },
// fail: function (xhr, status, error) {
// //$("#save-building-btn").html('確定').attr("disabled", false);
// //toast_error(rel.msg);
// }
//});
$.ajax({
method: "POST",
@ -463,29 +395,21 @@
contentType: "application/json; charset=UTF-8",
dataType: 'json',
success: function (rel) {
//$("#save-building-btn").html('確定').attr("disabled", false);
if (rel.code != "0000") {
if (rel.code == "9999") {
//toast_error(rel.msg);
console.log(rel.msg);
}
else {
//toast_warning(rel.msg);
console.log(rel.msg);
}
return;
}
else {
//toast_ok(rel.msg);
console.log(rel.msg);
//buildInfoTable.ajax.reload(null, false);
//$('#build-modal').modal('hide');
return;
}
},
fail: function (xhr, status, error) {
//$("#save-building-btn").html('確定').attr("disabled", false);
//toast_error(rel.msg);
}
});

View File

@ -253,6 +253,7 @@
<script>
var rolAuthTable = null;
$(function () {
asyncUser();
clearPagSes();
getRoleSel();
loadAccManTable();
@ -269,7 +270,7 @@
method: "POST",
}
let tag = "#accManTable";
let sendData = {};
if (pageAct.accManName != null)
sendData.Full_name = pageAct.accManName;
@ -904,4 +905,16 @@
}
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
}
function asyncUser() {
getUserByBaja(syncUsrCallBack)
}
function syncUsrCallBack(rel) {
let url = baseApiUrl + "/User/SyncUser";
var data = JSON.parse(rel);
objSendData.Data = data.data;
console.log(objSendData);
ytAjax = new YourTeam.Ajax(url, objSendData, null, null, "POST").send();
}
</script>

View File

@ -45,7 +45,9 @@
setLightColor();
}
if (arr.indexOf(3) != -1) {
getHotspotPoint(() => {
getLightDevice();
show3DModel(data.urn_3D);
});
@ -335,11 +337,50 @@
}
async function getLightDevice() {//callback = null
getLightData(null);
let url = baseApiUrl + "/api/GetDevNodeForCor";
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 {
let myLightList = [];
$.each(res.data, (idx, data) => {
let item = {};
item.position = {};
if (data.device_node_coordinate_3d != null && isJSON(data.device_node_coordinate_3d)) {
item.position = JSON.parse(data.device_node_coordinate_3d);
}
$.extend(item, data);
myLightList.push(item);
})
console.log("2", myLightList);
setLightList(myLightList);
//callback ? callback() : "";
}
}, null, "POST").send();
}
function setHotspotPoint(myDataList = []) {
console.log(myDataList)
getHopspotPoint(myDataList);
}
async function setLightList(myDataList = []) {
console.log(myDataList);
getLightData(myDataList);
}
var parentEle = "";
onEvent("autodesk:click:sprite", "[name=forgeViewer]", function (e, obj) {
forgeUnFocusAll();

View File

@ -140,7 +140,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
<!--we need this logo when user switches to nav-function-top-->
<div class="page-logo">
<a href="javascript:;" name="topFunBtn" data-page="dashboard" class="page-logo-link press-scale-down d-flex align-items-center position-relative">
<img src="img/logo.png" alt="SmartAdmin WebApp" aria-roledescription="logo">
<img name="webLogo" src="img/logo.png" alt="SmartAdmin WebApp" aria-roledescription="logo">
<!--<span class="page-logo-text mr-1">SmartAdmin WebApp</span>-->
<!--<span class="position-absolute text-white opacity-50 small pos-top pos-right mr-2 mt-n2"></span>
@ -824,6 +824,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
function isValidLogin() {
$("#app").load("_dashboard.html", loadCallback);
getLogo();
getUserInfo();
iniFroList();
showMainSys();
@ -1467,6 +1468,17 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
}, null, "POST").send();
}
function getLogo() {
$.ajax({
method: "post",
url: 'api/GetLogo',
async: false,
success: function (rel) {
$('[name=webLogo]').attr('src', 'img/' + rel);
}
})
}
function getUserInfo() {
let url = baseApiUrl + varApiUrl + "getUserFull";

View File

@ -4,7 +4,9 @@ let fragProxy;
var targetFloorZ;
var elevatorSpeed;
var selector = "#forgeViewer";
let myDataList;
var myDataList;
var lightDataList;
var lightList = [];//燈光清單
var levels;//剖面用
var lowerIdx;//剖面的下方樓層
var upperIdx;//剖面的上方樓層
@ -304,6 +306,16 @@ class elevator3D {
}
function onDocumentLoadSuccess(doc, eleOption) {
//取得燈光清單
if (lightDataList != undefined && lightDataList != null && lightDataList.length > 0) {
lightDataList.forEach((myData, index) => {
//if (myData.priority == 5) {
const position = JSON.parse(myData.device_node_coordinate_3d);
lightList.push({ dbid: myData.forge_dbid, spotLight: newLight(position) });
//}
});
}
var viewables = doc.getRoot().getDefaultGeometry();
viewer.loadDocumentNode(doc, viewables).then(i => {
// documented loaded, any action?
@ -323,9 +335,10 @@ function onDocumentLoadSuccess(doc, eleOption) {
$(selector).trigger("autodesk:loaded");
/*});*/
});
}
// 輔助函數,使用 Promise 封裝 viewer.getProperties 函數
@ -608,35 +621,18 @@ class ADHeatMaps {
}
}
function setTransparentBuilding() {
//allDbIdsStr.forEach((dbId) => {
// setTransparency(dbId, 0.2);
//})
for (var i = 0; i < allDbIdsStr.length; i++) {
setTransparency(parseInt(allDbIdsStr[i]), 0.2);
}
//全部物件 透明度: 輸入0:透明輸入1:不透明
function setTransparentBuilding(transparent) {
for (var i = 0; i < allDbIdsStr.length; i++) {
setTransparency(parseInt(allDbIdsStr[i]), transparent);
}
}
function recoverTransparentBuilding() {
//allDbIdsStr.forEach((dbId) => {
// setTransparency(dbId, 1);
//})
for (var i = 0; i < allDbIdsStr.length; i++) {
setTransparency(parseInt(allDbIdsStr[i]), 1);
}
}
//設定模型 透明度
function setTransparency(nodeId, opacity) {
var model = viewer.model;
//var nodeId = 1633;
var fragList = viewer.model.getFragmentList();
var fragIds = []
var fragIds = [];
model.getData().instanceTree.enumNodeFragments(
nodeId, (fragId) => {
@ -703,6 +699,14 @@ async function addHotPoint(data) {
const style = new DataVizCore.ViewableStyle(viewableType, spriteColor, spriteIcon);
//取得燈光清單
//if (lightDataList != undefined && lightDataList != null && lightDataList.length > 0) {
// lightDataList.forEach((myData, index) => {
// const position = JSON.parse(myData.device_node_coordinate_3d);
// lightList.push({ dbid: myData.forge_dbid, spotLight: newLight(position) });
// });
//}
//熱點 點擊事件註冊
viewer.addEventListener(DataVizCore.MOUSE_CLICK, onSpriteClicked);// SPRITE_SELECTED
@ -1039,4 +1043,82 @@ function profile() {
const lowerCutPlaneParam = this.getCutPlaneParam(lowerIdx, -1);
this.viewer.setCutPlanes([upperCutPlaneParam, lowerCutPlaneParam]);
}
//----------------- end -----------------------------------------------
//----------------- end -----------------------------------------------
//新增燈光
async function newLight(lightPosition) {
//聚光燈
var spotLight = new THREE.SpotLight(0xffffff, 200, 20, 0.6, 0.5, 10);
spotLight.position.set(lightPosition.x, lightPosition.y, lightPosition.z);
spotLight.castShadow = false;
spotLight.visible = true;
spotLight.target.position.set(lightPosition.x, lightPosition.y, lightPosition.z-20);
viewer.scene.add(spotLight.target);
viewer.scene.add(spotLight);
viewer.impl.sceneUpdated(true);
return spotLight;
}
//調整燈光 強度、顏色
async function setLightValues(dbid, intensity, color) {
for (var i = 0; i < lightList.length; i++) {
if (lightList[i].dbid == dbid) {
lightList[i].spotLight.intensity = intensity;
var tempcolor = new THREE.Color().setHex(color);
lightList[i].spotLight.color = tempcolor;
viewer.impl.sceneUpdated(true);
}
}
}
//燈光開關
function setLightOpenOrClose(value, light) {
if (value) {
light.visible = true;
}
else {
light.visible = false;
}
viewer.impl.sceneUpdated(true);
}
//透過nodeId更改物件顏色或顯示與否color請填寫THREE.Vector4
function changeColorTransparency(nodeId, color) {//變綠色
//var color = new THREE.Vector4(0, 1, 0, 1);//綠色前三個代表r、g、b; 亦可填入255/255
//var color = new THREE.Vector4(0, 1, 0, 0);//不顯示顏色;最後的參數為透明度
viewer.setThemingColor(nodeId, color);
}
//隱藏全物件
function hideAllObjects() {
//viewer.hide(4);//只針對一個物件(dbid為4)做隱藏
for (var i = 0; i < allDbIdsStr.length; i++) {
viewer.hide(parseInt(allDbIdsStr[i]));
}
}
//顯示全物件
function showAllObjects() {
//viewer.show(4); //只針對一個物件(dbid為4)做顯示
for (var i = 0; i < allDbIdsStr.length; i++) {
viewer.show(parseInt(allDbIdsStr[i]));
}
}
//======================== 外部呼叫function ===========================
//紀錄熱點座標
function getHopspotPoint(data) {
myDataList = data;
}
//紀錄燈具座標
async function getLightData(data) {
lightDataList = data;
}
//呼叫載入熱圖
async function toLoadHeatmap(roomArr) {
const model = viewer.model;
loadHeatmaps(model, roomArr);
}
//============================= end ===================================

View File

@ -0,0 +1,32 @@
function getUserByBaja(callback) {
var _result = "";
var _ss = "";
var _index = 0;
var syncAcc = [];
require(['baja!'], function (baja) {
baja.Ord.make("local:|foxs:|station:|slot:/Services/UserService|bql:select * from baja:User where enabled = 'true' and toString != 'defaultPrototype'").get()
.then(function (table) {
table.cursor({
each: function (item) {
if (_index == 0)
_ss += '{"Account": "' + item.$map.$map.toString.$display + '"}';
else
_ss += ',{"Account": "' + item.$map.$map.toString.$display + '"}';
_index++;
},
after: function () {
_result += '{' + '"count": ' + _index + ', "data":[';
_result += _ss;
_result += ']}';
if (typeof callback === 'function') {
callback(_result);
}
},
limit: -1,
offset: 0
})
});
});
}

View File

@ -27,7 +27,7 @@
<div class="blankpage-form-field">
<div class="page-logo m-0 w-100 align-items-center justify-content-center rounded border-bottom-left-radius-0 border-bottom-right-radius-0 px-4">
<div class="page-logo-link press-scale-down d-flex align-items-center">
<img src="img/logo.png" aria-roledescription="logo">
<img name="webLogo" src="img/logo.png" aria-roledescription="logo">
<span class="page-logo-text mr-1">全方位監控系統</span>
</div>
</div>
@ -198,8 +198,9 @@
e.preventDefault();
})
getLogo();
}
function Login(account, e) {
cookies = new YourTeam.Utility.Cookie();
e ? e.preventDefault() : "";
@ -244,6 +245,17 @@
}
function getLogo() {
$.ajax({
method: "post",
url: 'api/GetLogo',
async: false,
success: function (rel) {
$('[name=webLogo]').attr('src', 'img/' + rel);
}
})
}
</script>
<script type="text/javascript">

View File

@ -711,6 +711,37 @@ namespace FrontendWebApi.ApiControllers
return Ok(apiResult);
}
[HttpPost]
[Route("api/GetDevNodeForCor")]
public async Task<ActionResult<List<DevNodeForCor>>> GetDevNodeForCor([FromBody] Device p)
{
ApiResult<List<DevNodeForCor>> apiResult = new ApiResult<List<DevNodeForCor>>();
List<DevNodeForCor> device = new List<DevNodeForCor>();
try
{
apiResult.Code = "0001";
if (p != null )
{
if (p.device_system_tag == "LT" && p.device_name_tag == "L1")
{
var d = await backendRepository.GetAllAsync<DevNodeForCor>($@"select device_guid,priority,device_node_coordinate_3d,forge_dbid from device_node where deleted = 0");
apiResult.Data = d;
apiResult.Code = "0000";
}
}
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
return Ok(apiResult);
}
return Ok(apiResult);
}
/// <summary>
/// 燈控排程列表
/// </summary>

View File

@ -915,5 +915,60 @@ namespace FrontendWebApi.ApiControllers
}
return Ok(apiResult);
}
[HttpPost]
public async Task<ActionResult<ApiResult<string>>> SyncUser([FromBody] List<SaveUserManager> post)
{
ApiResult<string> apiResult = new ApiResult<string>();
try
{
await backendRepository.ExecuteSql("update userinfo deleted = 1 where deleted = 0");
if (post != null)
{
if (post.Count > 0)
{
foreach(var acc in post)
{
var account = await frontendRepository.GetOneAsync<UserManagerList>("select * from userinfo where account = @account", new { @account = acc.Account });
if (account != null)
{
await backendRepository.ExecuteSql("update userinfo set deleted = 0 where userinfo_guid = @guid", new { @guid = account.Userinfo_guid });
}
else
{
//產生一組GUID
var guid = Guid.NewGuid(); //角色GUID
Dictionary<string, object> user = new Dictionary<string, object>();
user = new Dictionary<string, object>()
{
{ "@userinfo_guid", guid},
{ "@full_name", acc.Account},
{ "@account", acc.Account},
{ "@role_guid", "F127F501-A7BB-4C46-AB82-0809C1C8D2C1"},
{ "@created_by", myUser.userinfo_guid},
{ "@created_at", DateTime.Now}
};
await backendRepository.AddOneByCustomTable(user, "userinfo");
}
}
}
}
apiResult.Code = "0000";
apiResult.Data = "同步成功";
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
return Ok(apiResult);
}
return Ok(apiResult);
}
}
}

View File

@ -155,5 +155,28 @@ namespace FrontendWebApi.ApiControllers
return apiResult;
}
[HttpPost]
[Route("api/GetLogo")]
public async Task<ApiResult<string>> GetLogo()
{
ApiResult<string> apiResult = new ApiResult<string>();
try
{
var sqlString = $@"select system_type from variable where system_type = 'logo'";
var data = await backendRepository.GetOneAsync<string>(sqlString);
apiResult.Code = "0000";
apiResult.Data = data;
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
return apiResult;
}
}
}

View File

@ -133,4 +133,12 @@ namespace FrontendWebApi.Models
public string device_coordinate_3d { get; set; }
public int? forge_dbid { get; set; }
}
public class DevNodeForCor
{
public string device_guid { get; set; }
public int priority { get; set; }
public string device_node_coordinate_3d { get; set; }
public int? forge_dbid { get; set; }
}
}