This commit is contained in:
dev02 2023-05-30 17:17:36 +08:00
commit d541e72dd6
5 changed files with 3249 additions and 3298 deletions

View File

@ -55,7 +55,6 @@
$(function () {
$(loadEle).Loading("start");
getBuildMenu((arr, data) => {
console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@", arr, data);
buildMenuData = data;
if (arr.indexOf(4) != -1) {
getFloDevList(arr[0] == 4 ? "left" : "right");
@ -119,7 +118,7 @@
let deviceCloseArr = [];
myBaja.setSubscribeDevicesCallBack(function (data) {
// console.log(data)
console.log("subDevice 開始");
let matchDevice = allDevList.filter(
(x) => x.device_number == data.device_number_full
)[0];
@ -237,15 +236,10 @@
(device) => device.device_number === matchDevice.device_number
)
) {
if (pageAct.sysSubTag === "L1") {
$(`#${matchDevice.device_number}_status`)
.attr("data-light-error-type", "error")
.data("light-error-type", "error");
} else {
$(`#${matchDevice.device_number}_status`)
.attr("data-light-type", "error")
.data("light-type", "error");
}
$(`#${matchDevice.device_number}_status`)
.attr("data-light-error-type", "error")
.data("light-error-type", "error");
alarmDbIdList.push(matchDevice);
} else if (
data.point_name == errDevPoiName &&
@ -260,8 +254,21 @@
}
if (
allDevList.length ===
deviceNormalArr.length + deviceCloseArr.length + alarmDbIdList.length
deviceCloseArr.length === 0 &&
alarmDbIdList.some(
(device) => device.device_number === matchDevice.device_number
)
) {
$(`#${matchDevice.device_number}_status`)
.attr("data-light-type", "error")
.data("light-type", "error");
}
if (
(!pageAct.floTag &&
allDevList.length ===
deviceNormalArr.length + deviceCloseArr.length) ||
allDevList.length === deviceNormalArr.length + alarmDbIdList.length
) {
changeColorForHotspot(
deviceNormalArr.map(({ spriteDbid }) => spriteDbid),
@ -292,166 +299,12 @@
if (data.findIndex((x) => x.point_name == "CO2") != -1) {
// 顯示溫度條
showHeatCO2("[name=forgeHeatBar]");
} else if (data.findIndex((x) => x.point_name == "Temp") != -1) {
} else if (data.findIndex((x) => x.point_name == "Temp" || x.point_name == "TEMP") != -1) {
// 顯示溫度條
showHeat("[name=forgeHeatBar]");
}
});
}
// function subDevice() {
// let myBaja = new subscriptionDevices();
// var ordPath = {
// area_tag: pageAct.AreaTag,
// building_tag: pageAct.buiTag,
// system_tag: pageAct.sysMainTag,
// name_tag: pageAct.sysSubTag,
// };
// myBaja.setSubscribeDevicesByBql(ordPath);
// // 燈熱點用
// let lightOnHotColorArr = [];
// let lightOffHotColorArr = [];
// // 燈光圈用
// let lightOnGuidArr = [];
// let lightOffGuidArr = [];
// myBaja.setSubscribeDevicesCallBack(function (data) {
// // console.log(data)
// let matchDevice = allDevList.filter(
// (x) => x.device_number == data.device_number_full
// )[0];
// if (!matchDevice) {
// return false;
// }
// //將訂閱值塞入 subDeviceData
// if (
// subDeviceData.findIndex(
// (x) => x.device_number == matchDevice.device_number
// ) == -1
// ) {
// let obj = {};
// obj.device_number = matchDevice.device_number;
// obj.dbid = matchDevice.forge_dbid;
// subDeviceData.push(obj);
// }
// let subData = subDeviceData.filter(
// (x) => x.device_number == matchDevice.device_number
// )[0];
// if (subData) {
// subData[data.point_name] = data.value;
// }
// let norDevPoiName = matchDevice.device_normal_point_name;
// let cloDevPoiName = matchDevice.device_close_point_name;
// let errDevPoiName = matchDevice.device_error_point_name;
// if (data.point_name == "ONOFF" && pageAct.sysSubTag === "L1") {
// const lightOn = data.value.includes("true");
// setLightOpenOrClose(lightOn, matchDevice.device_guid);
// if (lightOn) {
// setLightValues(matchDevice.device_guid, 200, 0xe1cf18);
// // changeColorForHotspot(matchDevice.spriteDbid, null, true)
// if (
// !lightOnHotColorArr.some(
// ({ spriteDbid }) => spriteDbid === matchDevice.spriteDbid
// )
// ) {
// lightOnHotColorArr.push(matchDevice);
// }
// lightOffHotColorArr = lightOffHotColorArr.filter(
// (light) => light.spriteDbid !== matchDevice.spriteDbid
// );
// heatMap?.changeTemp(matchDevice.device_number, 40);
// } else {
// setLightValues(matchDevice.device_guid, 0, 0xffffff);
// // changeColorForHotspot(matchDevice.spriteDbid)
// if (
// !lightOffHotColorArr.some(
// ({ spriteDbid }) => spriteDbid === matchDevice.spriteDbid
// )
// ) {
// lightOffHotColorArr.push(matchDevice);
// }
// lightOnHotColorArr = lightOnHotColorArr.filter(
// (light) => light.spriteDbid !== matchDevice.spriteDbid
// );
// heatMap?.changeTemp(matchDevice.device_number, 0);
// }
// }
// if (data.point_name == "Temp") {
// heatMap?.changeTemp(
// data.device_number_full,
// !isNaN(parseInt(data.value)) ? parseInt(data.value) : 0
// );
// let devIdx = allDevList.findIndex(
// (x) => x.device_number == data.device_number_full
// );
// allDevList[devIdx]._temp = !isNaN(parseInt(data.value))
// ? parseInt(data.value)
// : 0;
// }
// if (
// data.point_name == norDevPoiName &&
// data.value == matchDevice.device_normal_point_value
// ) {
// //顯示正常燈號
// $(`#${matchDevice.device_number}_status`)
// .attr("data-light-type", "normal")
// .data("light-type", "normal");
// } else if (
// data.point_name == cloDevPoiName &&
// data.value == matchDevice.device_close_point_value
// ) {
// $(`#${matchDevice.device_number}_status`)
// .attr("data-light-type", "close")
// .data("light-type", "close");
// } else if (
// data.point_name == errDevPoiName &&
// data.value == matchDevice.device_error_point_value
// ) {
// $(`#${matchDevice.device_number}_status`)
// .attr("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");
// setLightColor();
// setForgeHotSpotColor(matchDevice);
// lightDevForgeSpotLig(matchDevice);
// // 從設備訂閱更新每個設備卡片即時點位
// setDevItemPoiValBySub(data);
// });
// myBaja.setSubscribeDeviceEndCallBack(function (data) {
// endPageLoading();
// if (data.findIndex((x) => x.point_name == "Temp") != -1) {
// // 顯示溫度條
// showHeat("[name=forgeHeatBar]");
// }
// });
// }
function lightDevForgeSpotLig(devObj) { }
@ -605,9 +458,9 @@
endPageLoading();
} else {
// 訂閱 baja 設備
if (pageAct.sysSubTag !== "L1" && pageAct.sysSubTag !== "M12") {
subDevice();
}
// if (pageAct.sysSubTag !== "L1" && pageAct.sysSubTag !== "M12") {
// subDevice();
// }
}
// 繪製 html
@ -865,14 +718,14 @@
.map((y) => x)
);
for (let sub of stSubArr) {
let matchDevice = allDevList.filter(
(x) => x.device_number == sub[0]?.device_number
)[0];
if (matchDevice) {
setForgeHotSpotColor(matchDevice);
}
}
// for (let sub of stSubArr) {
// let matchDevice = allDevList.filter(
// (x) => x.device_number == sub[0]?.device_number
// )[0];
// if (matchDevice) {
// setForgeHotSpotColor(matchDevice);
// }
// }
}
if (pageAct.sysSubTag == "W2") {
// console.log("@@",pageAct, pageAct.sub_system_tag)
@ -1036,11 +889,14 @@
allDevList.forEach((dev, idx) => {
if (dev.device_number == devNum) {
dev.spriteDbid = dbid;
setForgeHotSpotColor(dev);
// setForgeHotSpotColor(dev);
}
});
$(ele).data("dbId", dbid);
});
if (pageAct.sysSubTag !== "L1" && pageAct.sysSubTag !== "M12") {
subDevice();
}
});
onEvent("yt:tooltip:show", "[name=devItem]", function (e, obj) {

View File

@ -43,6 +43,7 @@
var zoomToggle = 1.3;
$(function () {
$(loadEle).Loading("start");
alarmDbIdList = [];
$("#topLight").html(setTopLight());
setLightColor();
initChart();
@ -442,7 +443,7 @@
});
cData._dbId = dbid;
cData.spriteDbid = dbid;
setForgeHotSpotColor(cData);
// setForgeHotSpotColor(cData);
});
});
floChart.setOption(option);
@ -597,9 +598,36 @@
heatMap?.changeTemp(matchDevice.device_number, 0);
}
}
if (
data.point_name == errDevPoiName &&
data.value !== matchDevice.device_error_point_value &&
alarmDbIdList.some(
({ device_number }) => matchDevice.device_number === device_number
)
) {
alarmDbIdList = alarmDbIdList.filter(
({ device_number }) => matchDevice.device_number === device_number
);
} else if (
data.point_name == errDevPoiName &&
data.value == matchDevice.device_error_point_value &&
!alarmDbIdList.some(
({ device_number }) => matchDevice.device_number === device_number
)
) {
$(`#${matchDevice.device_number}_status`)
.attr("data-light-type", "error")
.data("light-type", "error");
alarmDbIdList.push(matchDevice);
}
if (
data.point_name == norDevPoiName &&
data.value == matchDevice.device_normal_point_value
data.value == matchDevice.device_normal_point_value &&
!deviceScatterNormalArr.some(
({ device_number }) => data.device_number_full === device_number
)
) {
//顯示正常燈號
$(`#${matchDevice.device_number}_status`)
@ -609,120 +637,114 @@
deviceScatterCloseArr = deviceScatterCloseArr.filter(
(device) => device.spriteDbid !== matchDevice.spriteDbid
);
deviceScatterErrorArr = deviceScatterErrorArr.filter(
(device) => device.spriteDbid !== matchDevice.spriteDbid
);
} else if (
data.point_name == cloDevPoiName &&
data.value == matchDevice.device_close_point_value
data.value == matchDevice.device_close_point_value &&
!deviceScatterCloseArr.some(
({ device_number }) => data.device_number_full === device_number
)
) {
$(`#${matchDevice.device_number}_status`)
.attr("data-light-type", "close")
.data("light-type", "close");
deviceScatterCloseArr.push(matchDevice);
deviceScatterNormalArr = deviceScatterNormalArr.filter(
(device) => device.spriteDbid !== matchDevice.spriteDbid
);
deviceScatterErrorArr = deviceScatterErrorArr.filter(
(device) => device.spriteDbid !== matchDevice.spriteDbid
);
} else if (
data.point_name == errDevPoiName &&
data.value == matchDevice.device_error_point_value
) {
$(`#${matchDevice.device_number}_status`)
.attr("data-light-type", "error")
.data("light-type", "error");
deviceScatterErrorArr.push(matchDevice);
deviceScatterNormalArr = deviceScatterNormalArr.filter(
(device) => device.spriteDbid !== matchDevice.spriteDbid
);
deviceScatterCloseArr = deviceScatterCloseArr.filter(
(device) => device.spriteDbid !== matchDevice.spriteDbid
);
}
console.log(deviceScatterCloseArr.length,
deviceScatterNormalArr.length,
deviceScatterErrorArr.length)
if (pageAct.sysSubTag === "L1" && lightControl === "node") {
alarmDbIdList = alarmDbIdList.filter(
({ device_node_guid }) =>
device_node_guid !== undefined && device_node_guid !== null
);
deviceScatterNormalArr = deviceScatterNormalArr.filter(
({ device_node_guid }) =>
device_node_guid !== undefined && device_node_guid !== null
);
deviceScatterCloseArr = deviceScatterCloseArr.filter(
({ device_node_guid }) =>
device_node_guid !== undefined && device_node_guid !== null
);
lightOnHotColorArr = lightOnHotColorArr.filter(
({ device_node_guid }) =>
device_node_guid !== undefined && device_node_guid !== null
);
lightOffHotColorArr = lightOffHotColorArr.filter(
({ device_node_guid }) =>
device_node_guid !== undefined && device_node_guid !== null
);
}
if (
option.series[0].data.length ===
lightOnHotColorArr.length + lightOffHotColorArr.length
deviceScatterCloseArr.length + deviceScatterNormalArr.length ===
option.series[0].data.length ||
deviceScatterCloseArr.length +
deviceScatterNormalArr.length +
alarmDbIdList.length ===
option.series[0].data.length
) {
lightOnHotColorArr.forEach((light) => {
const cur = option.series[0].data.find(
({ device_number }) => device_number === light.device_number
);
deviceScatterNormalArr.length &&
deviceScatterNormalArr.forEach((device) => {
const cur = option.series[0].data.find(
({ device_number }) => device_number === device.device_number
);
const onColor = currentData.find(
({ device_number }) => device_number === light.device_number
).device_normal_color;
cur.itemStyle = { color: onColor };
});
lightOffHotColorArr.forEach((light) => {
const cur = option.series[0].data.find(
({ device_number }) => device_number === light.device_number
);
const offColor = currentData.find(
({ device_number }) => device_number === light.device_number
).device_close_color;
cur.itemStyle = { color: offColor };
});
floChart.setOption(option);
const normalColor = currentData.find(
({ device_number }) => device_number === device.device_number
).device_normal_color;
if (cur) {
cur.itemStyle = { color: normalColor };
}
});
changeColorForHotspot(
lightOnHotColorArr.map(({ spriteDbid }) => spriteDbid),
deviceScatterNormalArr.map(({ spriteDbid }) => spriteDbid),
null,
true
);
deviceScatterCloseArr.length &&
deviceScatterCloseArr.forEach((device) => {
const cur = option.series[0].data.find(
({ device_number }) => device_number === device.device_number
);
const closeColor = currentData.find(
({ device_number }) => device_number === device.device_number
).device_close_color;
if (cur) {
cur.itemStyle = { color: closeColor };
}
});
changeColorForHotspot(
lightOffHotColorArr.map(({ spriteDbid }) => spriteDbid),
deviceScatterCloseArr.map(({ spriteDbid }) => spriteDbid),
null,
false
);
$(loadEle).Loading("close");
} else if (
deviceScatterCloseArr.length +
deviceScatterNormalArr.length +
deviceScatterErrorArr.length ===
option.series[0].data.length
) {
deviceScatterNormalArr.forEach((device) => {
const cur = option.series[0].data.find(
({ device_number }) => device_number === device.device_number
);
const normalColor = currentData.find(
({ device_number }) => device_number === device.device_number
).device_normal_color;
cur.itemStyle = { color: normalColor };
});
alarmDbIdList.length &&
alarmDbIdList.forEach((device) => {
const cur = option.series[0].data.find(
({ device_number }) => device_number === device.device_number
);
const errColor = currentData.find(
({ device_number }) => device_number === device.device_number
)?.device_error_color;
deviceScatterCloseArr.forEach((device) => {
const cur = option.series[0].data.find(
({ device_number }) => device_number === device.device_number
);
const closeColor = currentData.find(
({ device_number }) => device_number === device.device_number
).device_close_color;
cur.itemStyle = { color: closeColor };
});
deviceScatterErrorArr.forEach((device) => {
const cur = option.series[0].data.find(
({ device_number }) => device_number === device.device_number
);
const errColor = currentData.find(
({ device_number }) => device_number === device.device_number
).device_error_color;
cur.itemStyle = { color: errColor };
});
if (cur) {
cur.itemStyle = { color: errColor };
}
});
changeColorForHotspot(
alarmDbIdList.map(({ spriteDbid }) => spriteDbid),
"error",
false
);
floChart.setOption(option);
setForgeHotSpotColor(matchDevice);
$(loadEle).Loading("close");
}
});
@ -1595,7 +1617,6 @@
});
};
}
if (pageAct.sysSubTag === "M12" && !elevatorShow) {
let sensorObjs = [];
addHotPoint(viewer);

File diff suppressed because it is too large Load Diff

View File

@ -922,9 +922,9 @@ async function addHotPoint(data) {
return;
} else {
spriteColor = new THREE.Color(0xffffff);
spriteIcon = "/file/img/forge/hotspot.svg";
spriteIcon = "/file/img/forge/sensor_circle.svg";
if (location.href.indexOf("localhost:5966") != -1) {
spriteIcon = "/img/forge/hotspot.svg";
spriteIcon = "/img/forge/sensor_circle.svg";
}
}
@ -973,7 +973,7 @@ async function addHotPoint(data) {
// console.log(`Sprite clicked: ${event.dbId}`);
for (let i = dbIdStart; i <= myDataList.length + 10; i++) {
!alarmDbIdList.some((dbId) => dbId == i) &&
!alarmDbIdList.some(({ spriteDbid }) => spriteDbid == i) &&
pageAct.sysSubTag !== "L1" &&
changeColorForHotspot(i);
changeScaleForHotspot(i, true);
@ -990,7 +990,7 @@ async function addHotPoint(data) {
}
$(selector).trigger("autodesk:click:sprite", { event, myData });
} else {
!alarmDbIdList.some((dbId) => dbId == i) &&
!alarmDbIdList.some(({ spriteDbid }) => spriteDbid == event.dbId) &&
pageAct.sysSubTag !== "L1" &&
changeColorForHotspot(event.dbId, null);
changeScaleForHotspot(event.dbId, false);
@ -1038,25 +1038,47 @@ async function addHotPoint(data) {
//}
}
//hex -> rgbsensor_circle
function hexToRgb(hex) {
return (
"rgb(" +
parseInt("0x" + hex.slice(1, 3)) +
"," +
parseInt("0x" + hex.slice(3, 5)) +
"," +
parseInt("0x" + hex.slice(5, 7)) +
")"
);
}
// 熱點 更換顏色
async function changeColorForHotspot(dbId, type = null, lightOn = false) {
async function changeColorForHotspot(dbId, type = null, OnOff = false) {
const dataVizExtn = await viewer.loadExtension("Autodesk.DataVisualization");
let spriteColorFocus = new THREE.Color(0xffffff);
if (pageAct.sysSubTag == "L1") {
spriteColorFocus = lightOn
? new THREE.Color(0xffd524)
: new THREE.Color(0x40525e);
if (lightOn) {
console.log(dbId);
}
} else if (type == "focus" && pageAct.sysSubTag !== "M12") {
spriteColorFocus = OnOff
? pageAct.sysSubObj.device_normal_color
? new THREE.Color(hexToRgb(pageAct.sysSubObj.device_normal_color))
: new THREE.Color(0xffffff)
: pageAct.sysSubObj.device_close_color
? new THREE.Color(hexToRgb(pageAct.sysSubObj.device_close_color))
: new THREE.Color(0xffffff);
if (type == "focus") {
spriteColorFocus = new THREE.Color(0x00ffe1);
} else if (type == "error") {
spriteColorFocus = new THREE.Color(0xff0000);
spriteColorFocus = new THREE.Color(
hexToRgb(pageAct.sysSubObj.device_error_color)
);
spriteErrIcon = baseForgeApiUrl + "/file/img/forge/sensor_circle.svg";
if (location.href.indexOf("localhost:5966") != -1) {
spriteErrIcon = baseForgeApiUrl + "/img/forge/sensor_circle.svg";
}
}
const viewablesToUpdate = dbId;
dataVizExtn.invalidateViewables(viewablesToUpdate, (viewable) => {
return {
url: "/file/img/forge/sensor_circle.svg",
color: spriteColorFocus,
};
});

File diff suppressed because it is too large Load Diff