照明設備開關 bug 修正

This commit is contained in:
Celeste 2023-04-28 14:01:58 +08:00
parent 605f3f8f87
commit 4e96375be4
5 changed files with 3653 additions and 3751 deletions

View File

@ -6,29 +6,23 @@
</div> </div>
<!-- Modal center Add --> <!-- Modal center Add -->
<div <div class="modal fade"
class="modal fade" id="lightSchModal"
id="lightSchModal" tabindex="-1"
tabindex="-1" role="dialog"
role="dialog" aria-hidden="true"
aria-hidden="true" data-backdrop="static"
data-backdrop="static" data-keyboard="false">
data-keyboard="false" <div class="modal-dialog modal-dialog-centered"
> role="document"
<div style="min-width: 60%">
class="modal-dialog modal-dialog-centered"
role="document"
style="min-width: 60%"
>
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h4 class="modal-title">燈控排程</h4> <h4 class="modal-title">燈控排程</h4>
<button <button type="button"
type="button" class="close"
class="close" data-dismiss="modal"
data-dismiss="modal" aria-label="Close">
aria-label="Close"
>
<span aria-hidden="true"><i class="fal fa-times"></i></span> <span aria-hidden="true"><i class="fal fa-times"></i></span>
</button> </button>
</div> </div>
@ -59,6 +53,7 @@
var forgeInvTypeDef = null; var forgeInvTypeDef = null;
$(function () { $(function () {
$(loadEle).Loading("start");
getBuildMenu((arr, data) => { getBuildMenu((arr, data) => {
buildMenuData = data; buildMenuData = data;
if (arr.indexOf(4) != -1) { if (arr.indexOf(4) != -1) {
@ -162,15 +157,31 @@
if (lightOn) { if (lightOn) {
setLightValues(matchDevice.device_guid, 200, 0xe1cf18); setLightValues(matchDevice.device_guid, 200, 0xe1cf18);
// changeColorForHotspot(matchDevice.spriteDbid, null, true) // changeColorForHotspot(matchDevice.spriteDbid, null, true)
lightOnHotColorArr.push(matchDevice.spriteDbid); if (
!lightOnHotColorArr.some(
({ spriteDbid }) => spriteDbid === matchDevice.spriteDbid
)
) {
lightOnHotColorArr.push(matchDevice);
}
lightOffHotColorArr = lightOffHotColorArr.filter(
(light) => light.spriteDbid !== matchDevice.spriteDbid
);
heatMap?.changeTemp(matchDevice.device_number, 40); heatMap?.changeTemp(matchDevice.device_number, 40);
} else { } else {
setLightValues(matchDevice.device_guid, 0, 0xffffff); setLightValues(matchDevice.device_guid, 0, 0xffffff);
// changeColorForHotspot(matchDevice.spriteDbid) // changeColorForHotspot(matchDevice.spriteDbid)
if (
!lightOffHotColorArr.some(
({ spriteDbid }) => spriteDbid === matchDevice.spriteDbid
)
) {
lightOffHotColorArr.push(matchDevice);
}
lightOnHotColorArr = lightOnHotColorArr.filter( lightOnHotColorArr = lightOnHotColorArr.filter(
(light) => light !== matchDevice.spriteDbid (light) => light.spriteDbid !== matchDevice.spriteDbid
); );
lightOffHotColorArr.push(matchDevice.spriteDbid);
heatMap?.changeTemp(matchDevice.device_number, 0); heatMap?.changeTemp(matchDevice.device_number, 0);
} }
} }
@ -187,7 +198,6 @@
? parseInt(data.value) ? parseInt(data.value)
: 0; : 0;
} }
if ( if (
data.point_name == norDevPoiName && data.point_name == norDevPoiName &&
data.value == matchDevice.device_normal_point_value data.value == matchDevice.device_normal_point_value
@ -211,9 +221,24 @@
.attr("data-light-type", "error") .attr("data-light-type", "error")
.data("light-type", "error"); .data("light-type", "error");
} }
if (
allDevList.length ===
lightOnHotColorArr.length + lightOffHotColorArr.length
) {
changeColorForHotspot(
lightOnHotColorArr.map(({ spriteDbid }) => spriteDbid),
null,
true
);
changeColorForHotspot(
lightOffHotColorArr.map(({ spriteDbid }) => spriteDbid),
null,
false
);
}
$(loadEle).Loading("close");
changeColorForHotspot(lightOnHotColorArr, null, true);
changeColorForHotspot(lightOffHotColorArr, null, false);
setLightColor(); setLightColor();
setForgeHotSpotColor(matchDevice); setForgeHotSpotColor(matchDevice);
lightDevForgeSpotLig(matchDevice); lightDevForgeSpotLig(matchDevice);
@ -230,7 +255,7 @@
}); });
} }
function lightDevForgeSpotLig(devObj) {} function lightDevForgeSpotLig(devObj) { }
// 從設備訂閱更新每個設備卡片即時點位 // 從設備訂閱更新每個設備卡片即時點位
function setDevItemPoiValBySub(data) { function setDevItemPoiValBySub(data) {
@ -289,7 +314,7 @@
if ( if (
subData && subData &&
subData[device.device_error_point_name] == subData[device.device_error_point_name] ==
device.device_error_point_value && device.device_error_point_value &&
(!isNaN(parseInt(device.spriteDbid)) || !isNaN(parseInt(device._dbId))) (!isNaN(parseInt(device.spriteDbid)) || !isNaN(parseInt(device._dbId)))
) { ) {
const _dbId = parseInt(device.spriteDbid) || parseInt(device._dbId); const _dbId = parseInt(device.spriteDbid) || parseInt(device._dbId);
@ -299,7 +324,7 @@
} else if ( } else if (
subData && subData &&
subData[device.device_error_point_name] !== subData[device.device_error_point_name] !==
device.device_error_point_value && device.device_error_point_value &&
(!isNaN(parseInt(device.spriteDbid)) || !isNaN(parseInt(device._dbId))) (!isNaN(parseInt(device.spriteDbid)) || !isNaN(parseInt(device._dbId)))
) { ) {
const _dbId = parseInt(device.spriteDbid) || parseInt(device._dbId); const _dbId = parseInt(device.spriteDbid) || parseInt(device._dbId);
@ -342,44 +367,33 @@
$.each(floObj.device_list, (index2, devObj) => { $.each(floObj.device_list, (index2, devObj) => {
allDevList.push(devObj); allDevList.push(devObj);
let devItem = getRiserPoiObj(); let devItem = getRiserPoiObj();
strHtml += `<div class="card m-1 border device-wrap" data-number="${ strHtml += `<div class="card m-1 border device-wrap" data-number="${devObj.device_number
devObj.device_number }" data-position="${position}">
}" data-position="${position}">
<div class="card-body p-2"> <div class="card-body p-2">
<div class="d-flex mb-2"> <div class="d-flex mb-2">
<div class="mr-5 cur-poi"> <div class="mr-5 cur-poi">
<span class="d-inline-block mr-3"> <span class="d-inline-block mr-3">
<img src="${ <img src="${baseImgUrl +
baseImgUrl + varPathDevIcon +
varPathDevIcon + devObj.device_image
devObj.device_image }" class="profile-image rounded-circle" onerror="defDev(this)" alt="...">
}" class="profile-image rounded-circle" onerror="defDev(this)" alt="...">
</span> </span>
<a name="devItemName" data-number="${ <a name="devItemName" data-number="${devObj.device_number
devObj.device_number }" href="javascript:;">${devObj.full_name
}" href="javascript:;">${ }</a>
devObj.full_name
}</a>
</div> </div>
</div> </div>
<div class="d-flex mb-0 mt-2 align-items-center"> <div class="d-flex mb-0 mt-2 align-items-center">
<span id="${ <span id="${devObj.device_number
devObj.device_number }_status" class="circle-light"></span>
}_status" class="circle-light"></span> <span class="${devItem ? "" : "d-none"
<span class="${ } ml-2">${devItem?.full_name
devItem ? "" : "d-none" }<span name="devItemPoiVal" data-point="${devItem?.points
} ml-2">${ }"></span>${devItem?.unit}</span>
devItem?.full_name <a href="javascript:;" name="devItem" data-id="${devObj.device_guid
}<span name="devItemPoiVal" data-point="${ }" data-number="${devObj.device_number
devItem?.points }" data-name="${devObj.full_name
}"></span>${devItem?.unit}</span> }" class=" ml-2 mb-0 " data-toggle="tooltip" title="默认的 Tooltip">詳細資料</a>
<a href="javascript:;" name="devItem" data-id="${
devObj.device_guid
}" data-number="${
devObj.device_number
}" data-name="${
devObj.full_name
}" class=" ml-2 mb-0 " data-toggle="tooltip" title="默认的 Tooltip">詳細資料</a>
</div> </div>
</div> </div>
</div>`; </div>`;
@ -469,9 +483,9 @@
callback callback
? callback( ? callback(
[res.data.left_drawing, res.data.right_drawing], [res.data.left_drawing, res.data.right_drawing],
res.data res.data
) )
: ""; : "";
} }
}, },
@ -511,12 +525,11 @@
} }
function show3DModel(urn) { function show3DModel(urn) {
$(loadEle).Loading("start");
launchViewerForHotspot( launchViewerForHotspot(
urn, urn,
(viewer, nodeIds) => { (viewer, nodeIds) => {
// 隱藏 toolbar // 隱藏 toolbar
// document.querySelector("#guiviewer3d-toolbar").style.display = "none"; document.querySelector("#guiviewer3d-toolbar").style.display = "none";
let devDbIds = allDevList.map((x) => x.forge_dbid); let devDbIds = allDevList.map((x) => x.forge_dbid);
// 大類 // 大類
let subDevDbId = []; let subDevDbId = [];
@ -534,11 +547,11 @@
setInviForge(forgeInvTypeDef, [...devDbIds, ...subDevDbId]); setInviForge(forgeInvTypeDef, [...devDbIds, ...subDevDbId]);
} }
$(loadEle).Loading("close");
let sensorObjs = []; let sensorObjs = [];
let devices = []; let devices = [];
if (pageAct.sysSubTag === "M12") { if (pageAct.sysSubTag === "M12") {
addHotPoint(viewer); addHotPoint(viewer);
Forge3DSensor.sensorTimes = 0;
allDevList.forEach((device) => { allDevList.forEach((device) => {
Forge3DSensor.sensorTimes++; Forge3DSensor.sensorTimes++;
const sensorObj = new Forge3DSensor({ const sensorObj = new Forge3DSensor({
@ -550,23 +563,23 @@
selector: "[name=forgeViewer]", selector: "[name=forgeViewer]",
elevCb: elevatorShow elevCb: elevatorShow
? () => { ? () => {
let elevOption = { let elevOption = {
selector: "[name=forgeViewer]", selector: "[name=forgeViewer]",
viewer: viewer, viewer: viewer,
ordPath: { ordPath: {
area_tag: pageAct.AreaTag, area_tag: pageAct.AreaTag,
building_tag: pageAct.buiTag, building_tag: pageAct.buiTag,
}, },
sensorObjs, sensorObjs,
}; };
// 電梯移動訂閱程序載入 // 電梯移動訂閱程序載入
let forge3DElev = new Forge3DElevFull(elevOption); let forge3DElev = new Forge3DElevFull(elevOption);
forge3DElev.bajaEndCallback = function () { forge3DElev.bajaEndCallback = function () {
endPageLoading(); endPageLoading();
}; };
forge3DElev.init(); forge3DElev.init();
} }
: null, : null,
curDevice: { curDevice: {
...device, ...device,
@ -670,9 +683,7 @@
getE1NodeId(viewer); getE1NodeId(viewer);
} }
}, },
() => { () => { },
$(loadEle).Loading("close");
},
"[name=forgeViewer]" "[name=forgeViewer]"
); );
} }

View File

@ -49,7 +49,7 @@
getHotspotPoint(() => { getHotspotPoint(() => {
show3DModel(pageAct.urn); show3DModel(pageAct.urn);
}); });
if (!tempSubTag.includes(pageAct.sysSubTag)) { if (tempSubTag.includes(pageAct.sysSubTag)) {
$("#topLight").html(setTopLight()); $("#topLight").html(setTopLight());
setLightColor(); setLightColor();
} }
@ -573,7 +573,13 @@
if (lightOn && matchDevice.spriteDbid) { if (lightOn && matchDevice.spriteDbid) {
// setLightValues(matchDevice.device_guid, 200, 0xe1cf18); // setLightValues(matchDevice.device_guid, 200, 0xe1cf18);
// changeColorForHotspot(matchDevice.spriteDbid, null, lightOn); // changeColorForHotspot(matchDevice.spriteDbid, null, lightOn);
lightOnHotColorArr.push(matchDevice); if (
!lightOnHotColorArr.some(
({ spriteDbid }) => spriteDbid === matchDevice.spriteDbid
)
) {
lightOnHotColorArr.push(matchDevice);
}
lightOffHotColorArr = lightOffHotColorArr.filter( lightOffHotColorArr = lightOffHotColorArr.filter(
(light) => light.spriteDbid !== matchDevice.spriteDbid (light) => light.spriteDbid !== matchDevice.spriteDbid
); );
@ -582,10 +588,16 @@
// console.log(lightOn, matchDevice); // console.log(lightOn, matchDevice);
// setLightValues(matchDevice.device_guid, 0, 0xffffff); // setLightValues(matchDevice.device_guid, 0, 0xffffff);
// changeColorForHotspot(matchDevice.spriteDbid, null, lightOn); // changeColorForHotspot(matchDevice.spriteDbid, null, lightOn);
if (
!lightOffHotColorArr.some(
({ spriteDbid }) => spriteDbid === matchDevice.spriteDbid
)
) {
lightOffHotColorArr.push(matchDevice);
}
lightOnHotColorArr = lightOnHotColorArr.filter( lightOnHotColorArr = lightOnHotColorArr.filter(
(light) => light.spriteDbid !== matchDevice.spriteDbid (light) => light.spriteDbid !== matchDevice.spriteDbid
); );
lightOffHotColorArr.push(matchDevice);
heatMap?.changeTemp(matchDevice.device_number, 0); heatMap?.changeTemp(matchDevice.device_number, 0);
} }
} }
@ -681,7 +693,6 @@
deviceScatterErrorArr.length === deviceScatterErrorArr.length ===
option.series[0].data.length option.series[0].data.length
) { ) {
console.log("deviceScatterNormalArr", deviceScatterNormalArr)
deviceScatterNormalArr.forEach((device) => { deviceScatterNormalArr.forEach((device) => {
const cur = option.series[0].data.find( const cur = option.series[0].data.find(
({ device_number }) => device_number === device.device_number ({ device_number }) => device_number === device.device_number
@ -693,7 +704,6 @@
cur.itemStyle = { color: normalColor }; cur.itemStyle = { color: normalColor };
}); });
deviceScatterCloseArr.forEach((device) => { deviceScatterCloseArr.forEach((device) => {
const cur = option.series[0].data.find( const cur = option.series[0].data.find(
({ device_number }) => device_number === device.device_number ({ device_number }) => device_number === device.device_number
@ -1150,7 +1160,7 @@
}; };
obj.itemStyle = { obj.itemStyle = {
color: item.device_color || item.device_normal_color, color: item.device_color || item.device_close_color,
}; };
res.push(obj); res.push(obj);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff