koishi-plugin-jscn-aaaquery 1.0.18 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +50 -15
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -42,7 +42,7 @@ function evaluateOpticalPower(power) {
|
|
|
42
42
|
if (isNaN(powerValue)) {
|
|
43
43
|
return "";
|
|
44
44
|
}
|
|
45
|
-
if (powerValue >= -
|
|
45
|
+
if (powerValue >= -22 && powerValue <= -8) {
|
|
46
46
|
return "🟢正常";
|
|
47
47
|
} else if (powerValue > -8) {
|
|
48
48
|
return "🔴过高";
|
|
@@ -646,11 +646,6 @@ function apply(ctx, config) {
|
|
|
646
646
|
}
|
|
647
647
|
__name(queryOrderLog, "queryOrderLog");
|
|
648
648
|
async function queryRadiusUser(account) {
|
|
649
|
-
const cachedData = getFromCache("radiusUser", { account });
|
|
650
|
-
if (cachedData) {
|
|
651
|
-
console.log("使用缓存的RADIUS用户信息");
|
|
652
|
-
return cachedData;
|
|
653
|
-
}
|
|
654
649
|
return addToQueue("radiusUser", { account }, async () => {
|
|
655
650
|
try {
|
|
656
651
|
console.log("开始查询RADIUS用户信息...");
|
|
@@ -673,7 +668,6 @@ function apply(ctx, config) {
|
|
|
673
668
|
}
|
|
674
669
|
);
|
|
675
670
|
console.log("查询响应:", JSON.stringify(response, null, 2));
|
|
676
|
-
setCache("radiusUser", { account }, response);
|
|
677
671
|
return response;
|
|
678
672
|
} catch (error) {
|
|
679
673
|
console.error("查询RADIUS用户错误详情:", error);
|
|
@@ -905,6 +899,34 @@ function apply(ctx, config) {
|
|
|
905
899
|
console.log(`清理了 ${expiredCount} 个超时的消息任务`);
|
|
906
900
|
}
|
|
907
901
|
}, MESSAGE_CLEAN_INTERVAL2);
|
|
902
|
+
async function queryRefreshOnuPower(cid, gponIndex, onuIndex) {
|
|
903
|
+
return addToQueue("refreshPower", { cid, gponIndex, onuIndex }, async () => {
|
|
904
|
+
try {
|
|
905
|
+
console.log("开始刷新光功率信息...");
|
|
906
|
+
const token = await getToken();
|
|
907
|
+
const response = await ctx.http.get(`${config.baseUrl}/fttx/onu/refreshOnuPower`, {
|
|
908
|
+
params: { cid, gponIndex, onuIndex },
|
|
909
|
+
headers: {
|
|
910
|
+
"Authorization": token,
|
|
911
|
+
"Accept": "application/json",
|
|
912
|
+
"Content-Type": "application/json"
|
|
913
|
+
}
|
|
914
|
+
});
|
|
915
|
+
console.log("光功率刷新响应:", JSON.stringify(response, null, 2));
|
|
916
|
+
if (response.status === 200 && response.data) {
|
|
917
|
+
return response.data;
|
|
918
|
+
}
|
|
919
|
+
return null;
|
|
920
|
+
} catch (error) {
|
|
921
|
+
console.error("光功率刷新查询错误详情:", error);
|
|
922
|
+
if (error.response) {
|
|
923
|
+
console.error("错误响应:", error.response.data);
|
|
924
|
+
}
|
|
925
|
+
return null;
|
|
926
|
+
}
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
__name(queryRefreshOnuPower, "queryRefreshOnuPower");
|
|
908
930
|
async function queryTerminalInfo(mac, needDetailedInfo = false) {
|
|
909
931
|
const formattedMac = formatMacAddress(mac);
|
|
910
932
|
try {
|
|
@@ -916,6 +938,12 @@ function apply(ctx, config) {
|
|
|
916
938
|
queryOnuDetailInfo(onuList.id),
|
|
917
939
|
queryOnuDetailVlanInfo(onuList.id)
|
|
918
940
|
]);
|
|
941
|
+
let powerInfo = null;
|
|
942
|
+
try {
|
|
943
|
+
powerInfo = await queryRefreshOnuPower(onuDetail.cid, onuDetail.gponIndex, onuDetail.onuIndex);
|
|
944
|
+
} catch (powerError) {
|
|
945
|
+
console.error("光功率刷新失败,将使用详情接口数据:", powerError);
|
|
946
|
+
}
|
|
919
947
|
if (needDetailedInfo) {
|
|
920
948
|
const [ccname, order] = await Promise.all([
|
|
921
949
|
queryCCName(formattedMac),
|
|
@@ -926,13 +954,15 @@ function apply(ctx, config) {
|
|
|
926
954
|
onuDetail,
|
|
927
955
|
ccname,
|
|
928
956
|
order,
|
|
929
|
-
vlanInfo
|
|
957
|
+
vlanInfo,
|
|
958
|
+
powerInfo
|
|
930
959
|
};
|
|
931
960
|
}
|
|
932
961
|
return {
|
|
933
962
|
onuList,
|
|
934
963
|
onuDetail,
|
|
935
|
-
vlanInfo
|
|
964
|
+
vlanInfo,
|
|
965
|
+
powerInfo
|
|
936
966
|
};
|
|
937
967
|
} catch (error) {
|
|
938
968
|
console.error("终端查询过程出错:", error);
|
|
@@ -942,20 +972,25 @@ function apply(ctx, config) {
|
|
|
942
972
|
__name(queryTerminalInfo, "queryTerminalInfo");
|
|
943
973
|
async function smartQueryMacAddress(cleanInput) {
|
|
944
974
|
try {
|
|
945
|
-
const { onuDetail, ccname, order, vlanInfo } = await queryTerminalInfo(cleanInput, true);
|
|
975
|
+
const { onuDetail, ccname, order, vlanInfo, powerInfo } = await queryTerminalInfo(cleanInput, true);
|
|
976
|
+
const deviceStatus = powerInfo ? powerInfo.status : onuDetail.status;
|
|
977
|
+
const receivePower = powerInfo ? powerInfo.onuReceivePower : onuDetail.onuReceivePower;
|
|
978
|
+
const sendPower = powerInfo ? powerInfo.onuSendPower : onuDetail.onuSendPower;
|
|
979
|
+
const statusHealth = powerInfo ? powerInfo.statusHealth : onuDetail.statusHealth;
|
|
980
|
+
const isOnline = deviceStatus === 1;
|
|
946
981
|
const messages = [
|
|
947
982
|
"🖥️ 终端基本信息",
|
|
948
983
|
getSeparator(),
|
|
949
984
|
`MAC地址: ${cleanInput}`,
|
|
950
|
-
`状态:${
|
|
985
|
+
`状态:${isOnline ? "在线 ✅" : "不在线 ❌"}`,
|
|
951
986
|
`机房: ${onuDetail.roomName}`,
|
|
952
987
|
`设备名称: `,
|
|
953
988
|
`${onuDetail.deviceName}`,
|
|
954
989
|
`OLT IP: ${onuDetail.oltIp}`,
|
|
955
990
|
`PON端口: ${onuDetail.portName}`,
|
|
956
991
|
`端口逻辑号: ${onuDetail.logicId}`,
|
|
957
|
-
`发射光功率: ${
|
|
958
|
-
`接收光功率: ${
|
|
992
|
+
`发射光功率: ${!isOnline || !sendPower ? "设备不在线" : sendPower + "dBm"}`,
|
|
993
|
+
`接收光功率: ${!isOnline || !receivePower ? "设备不在线" : receivePower + "dBm " + evaluateOpticalPower(receivePower)}`,
|
|
959
994
|
`CCName: ${ccname}`,
|
|
960
995
|
"",
|
|
961
996
|
"📃 工单信息",
|
|
@@ -1066,8 +1101,8 @@ function apply(ctx, config) {
|
|
|
1066
1101
|
);
|
|
1067
1102
|
} else if (accountInfo.onlineStatus === "离线" && accountInfo.isPass === "原因未知") {
|
|
1068
1103
|
message.push(
|
|
1069
|
-
|
|
1070
|
-
|
|
1104
|
+
`未检索该账号的拨号记录⚠️`,
|
|
1105
|
+
`请尝试重新拨号或检查ONU配置和账号是否正确!`
|
|
1071
1106
|
);
|
|
1072
1107
|
} else if (accountInfo.onlineStatus === "离线" || accountInfo.onlineStatus === "不在线") {
|
|
1073
1108
|
message.push(
|