koishi-plugin-jscn-aaaquery 1.0.13 → 1.0.15
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 +220 -167
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -51,15 +51,21 @@ function evaluateOpticalPower(power) {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
__name(evaluateOpticalPower, "evaluateOpticalPower");
|
|
54
|
-
var CACHE_EXPIRE_TIME =
|
|
54
|
+
var CACHE_EXPIRE_TIME = 1 * 60 * 1e3;
|
|
55
55
|
var CACHE_CLEAN_INTERVAL = 60 * 1e3;
|
|
56
56
|
var CACHE_STATS_RESET_INTERVAL = 24 * 60 * 60 * 1e3;
|
|
57
|
-
var QUEUE_EXPIRE_TIME =
|
|
57
|
+
var QUEUE_EXPIRE_TIME = 1 * 60 * 1e3;
|
|
58
58
|
var QUEUE_CLEAN_INTERVAL = 30 * 1e3;
|
|
59
59
|
var MAX_CONCURRENT_REQUESTS = 5;
|
|
60
|
-
var MESSAGE_TIMEOUT =
|
|
60
|
+
var MESSAGE_TIMEOUT = 1 * 60 * 1e3;
|
|
61
61
|
var MESSAGE_CLEAN_INTERVAL = 60 * 1e3;
|
|
62
62
|
function apply(ctx, config) {
|
|
63
|
+
const CACHE_EXPIRATION = 1 * 60 * 1e3;
|
|
64
|
+
const CACHE_CLEANUP_INTERVAL = 5 * 60 * 1e3;
|
|
65
|
+
const CACHE_STATS_RESET_INTERVAL2 = 24 * 60 * 60 * 1e3;
|
|
66
|
+
const REQUEST_QUEUE_EXPIRATION = 1 * 60 * 1e3;
|
|
67
|
+
const REQUEST_QUEUE_CLEANUP_INTERVAL = 5 * 60 * 1e3;
|
|
68
|
+
const TOKEN_REFRESH_THRESHOLD = 30 * 60 * 1e3;
|
|
63
69
|
let currentToken = null;
|
|
64
70
|
let tokenExpireTime = 0;
|
|
65
71
|
const requestQueue = {};
|
|
@@ -77,7 +83,7 @@ function apply(ctx, config) {
|
|
|
77
83
|
const requestWaitQueue = [];
|
|
78
84
|
const messageQueue = [];
|
|
79
85
|
let isProcessingMessage = false;
|
|
80
|
-
const MESSAGE_TIMEOUT2 =
|
|
86
|
+
const MESSAGE_TIMEOUT2 = 1 * 60 * 1e3;
|
|
81
87
|
const MESSAGE_CLEAN_INTERVAL2 = 60 * 1e3;
|
|
82
88
|
const MAX_QUEUE_LENGTH = 50;
|
|
83
89
|
function getCacheKey(type, params) {
|
|
@@ -140,7 +146,7 @@ function apply(ctx, config) {
|
|
|
140
146
|
cacheStats.misses = 0;
|
|
141
147
|
cacheStats.cleanups = 0;
|
|
142
148
|
cacheStats.itemsRemoved = 0;
|
|
143
|
-
},
|
|
149
|
+
}, CACHE_STATS_RESET_INTERVAL2);
|
|
144
150
|
function getCacheStats() {
|
|
145
151
|
updateCacheStats();
|
|
146
152
|
const hitRate = cacheStats.hits + cacheStats.misses > 0 ? Math.round(cacheStats.hits / (cacheStats.hits + cacheStats.misses) * 100) : 0;
|
|
@@ -245,12 +251,32 @@ function apply(ctx, config) {
|
|
|
245
251
|
__name(isAccountResponseComplete, "isAccountResponseComplete");
|
|
246
252
|
async function getToken() {
|
|
247
253
|
const now = Date.now();
|
|
254
|
+
if (currentToken && now < tokenExpireTime - TOKEN_REFRESH_THRESHOLD) {
|
|
255
|
+
console.log("使用缓存的token,过期时间:", new Date(tokenExpireTime).toLocaleString());
|
|
256
|
+
return currentToken;
|
|
257
|
+
}
|
|
248
258
|
if (currentToken && now < tokenExpireTime) {
|
|
249
|
-
console.log("
|
|
259
|
+
console.log("token即将过期,后台刷新token");
|
|
260
|
+
refreshTokenInBackground();
|
|
250
261
|
return currentToken;
|
|
251
262
|
}
|
|
263
|
+
return refreshToken();
|
|
264
|
+
}
|
|
265
|
+
__name(getToken, "getToken");
|
|
266
|
+
async function refreshTokenInBackground() {
|
|
252
267
|
try {
|
|
253
|
-
console.log("
|
|
268
|
+
console.log("开始在后台刷新token...");
|
|
269
|
+
refreshToken().catch((error) => {
|
|
270
|
+
console.error("后台刷新token失败:", error);
|
|
271
|
+
});
|
|
272
|
+
} catch (error) {
|
|
273
|
+
console.error("启动后台刷新token失败:", error);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
__name(refreshTokenInBackground, "refreshTokenInBackground");
|
|
277
|
+
async function refreshToken() {
|
|
278
|
+
try {
|
|
279
|
+
console.log("开始登录请求刷新token...");
|
|
254
280
|
await waitForRequestSlot();
|
|
255
281
|
const response = await ctx.http.post(
|
|
256
282
|
`${config.baseUrl}/admin/login`,
|
|
@@ -280,19 +306,84 @@ function apply(ctx, config) {
|
|
|
280
306
|
releaseRequestSlot();
|
|
281
307
|
}
|
|
282
308
|
}
|
|
283
|
-
__name(
|
|
309
|
+
__name(refreshToken, "refreshToken");
|
|
284
310
|
async function queryAccount(account) {
|
|
285
311
|
const formattedAccount = formatAccount(account);
|
|
286
|
-
const cachedData = getFromCache("account", { account: formattedAccount });
|
|
287
|
-
if (cachedData) {
|
|
288
|
-
console.log("使用缓存的账号信息");
|
|
289
|
-
return cachedData;
|
|
290
|
-
}
|
|
291
312
|
return addToQueue("account", { account: formattedAccount }, async () => {
|
|
313
|
+
let retryCount = 0;
|
|
314
|
+
const maxRetries = 1;
|
|
315
|
+
while (retryCount <= maxRetries) {
|
|
316
|
+
try {
|
|
317
|
+
console.log("开始查询账号信息...");
|
|
318
|
+
const token = await getToken();
|
|
319
|
+
const response = await ctx.http.get(`${config.baseUrl}/fttx/aaa/aaaCertification`, {
|
|
320
|
+
params: { accessUserName: formattedAccount },
|
|
321
|
+
headers: {
|
|
322
|
+
"Authorization": token,
|
|
323
|
+
"Accept": "application/json",
|
|
324
|
+
"Content-Type": "application/json"
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
console.log("查询响应:", JSON.stringify(response, null, 2));
|
|
328
|
+
if (response.status === 200 && response.data) {
|
|
329
|
+
if (response.data.isPass === "上线失败") {
|
|
330
|
+
console.log("账号上线失败,将使用失败信息");
|
|
331
|
+
if (!response.data.startTimeSum) response.data.startTimeSum = 0;
|
|
332
|
+
if (!response.data.maxUpSpeed) response.data.maxUpSpeed = 0;
|
|
333
|
+
if (!response.data.maxDownSpeed) response.data.maxDownSpeed = 0;
|
|
334
|
+
if (!response.data.startTime) response.data.startTime = response.data.onlineFailTime || "未知";
|
|
335
|
+
if (!response.data.nickName) response.data.nickName = response.data.nickName || "未知";
|
|
336
|
+
return response.data;
|
|
337
|
+
}
|
|
338
|
+
if (response.data.onlineStatus === "离线" || response.data.onlineStatus === "不在线" || response.data.isPass === "原因未知") {
|
|
339
|
+
console.log("账号离线或状态异常,将使用有限信息");
|
|
340
|
+
if (!response.data.startTimeSum) response.data.startTimeSum = 0;
|
|
341
|
+
if (!response.data.maxUpSpeed) response.data.maxUpSpeed = 0;
|
|
342
|
+
if (!response.data.maxDownSpeed) response.data.maxDownSpeed = 0;
|
|
343
|
+
if (!response.data.startTime) response.data.startTime = response.data.userLoginOutTime || "未知";
|
|
344
|
+
if (!response.data.nickName) response.data.nickName = "未知";
|
|
345
|
+
if (!response.data.mac) response.data.mac = "未知";
|
|
346
|
+
if (!response.data.userIp) response.data.userIp = "未知";
|
|
347
|
+
if (!response.data.accessDomain) response.data.accessDomain = "未知";
|
|
348
|
+
return response.data;
|
|
349
|
+
}
|
|
350
|
+
if (!isAccountResponseComplete(response.data)) {
|
|
351
|
+
throw new Error("账号信息有误,请检查账号是否正确");
|
|
352
|
+
}
|
|
353
|
+
return response.data;
|
|
354
|
+
}
|
|
355
|
+
throw new Error(`查询失败:${response.message || "未知错误"}`);
|
|
356
|
+
} catch (error) {
|
|
357
|
+
console.error("查询错误详情:", error);
|
|
358
|
+
if (error.response) {
|
|
359
|
+
console.error("错误响应:", error.response.data);
|
|
360
|
+
if (error.response.status === 401) {
|
|
361
|
+
console.log("Token已过期或无效,正在重置token并重试...");
|
|
362
|
+
currentToken = null;
|
|
363
|
+
tokenExpireTime = 0;
|
|
364
|
+
if (retryCount < maxRetries) {
|
|
365
|
+
retryCount++;
|
|
366
|
+
console.log(`重试第${retryCount}次`);
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
throw error;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
throw new Error("请求失败,重试次数已用完");
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
__name(queryAccount, "queryAccount");
|
|
378
|
+
async function queryAccountDetail(account) {
|
|
379
|
+
const formattedAccount = formatAccount(account);
|
|
380
|
+
let retryCount = 0;
|
|
381
|
+
const maxRetries = 1;
|
|
382
|
+
while (retryCount <= maxRetries) {
|
|
292
383
|
try {
|
|
293
|
-
console.log("
|
|
384
|
+
console.log("开始查询账号详情记录...");
|
|
294
385
|
const token = await getToken();
|
|
295
|
-
const response = await ctx.http.get(`${config.baseUrl}/fttx/aaa/
|
|
386
|
+
const response = await ctx.http.get(`${config.baseUrl}/fttx/aaa/getMoreRecord`, {
|
|
296
387
|
params: { accessUserName: formattedAccount },
|
|
297
388
|
headers: {
|
|
298
389
|
"Authorization": token,
|
|
@@ -302,33 +393,6 @@ function apply(ctx, config) {
|
|
|
302
393
|
});
|
|
303
394
|
console.log("查询响应:", JSON.stringify(response, null, 2));
|
|
304
395
|
if (response.status === 200 && response.data) {
|
|
305
|
-
if (response.data.isPass === "上线失败") {
|
|
306
|
-
console.log("账号上线失败,将使用失败信息");
|
|
307
|
-
if (!response.data.startTimeSum) response.data.startTimeSum = 0;
|
|
308
|
-
if (!response.data.maxUpSpeed) response.data.maxUpSpeed = 0;
|
|
309
|
-
if (!response.data.maxDownSpeed) response.data.maxDownSpeed = 0;
|
|
310
|
-
if (!response.data.startTime) response.data.startTime = response.data.onlineFailTime || "未知";
|
|
311
|
-
if (!response.data.nickName) response.data.nickName = response.data.nickName || "未知";
|
|
312
|
-
setCache("account", { account: formattedAccount }, response.data);
|
|
313
|
-
return response.data;
|
|
314
|
-
}
|
|
315
|
-
if (response.data.onlineStatus === "离线" || response.data.onlineStatus === "不在线" || response.data.isPass === "原因未知") {
|
|
316
|
-
console.log("账号离线或状态异常,将使用有限信息");
|
|
317
|
-
if (!response.data.startTimeSum) response.data.startTimeSum = 0;
|
|
318
|
-
if (!response.data.maxUpSpeed) response.data.maxUpSpeed = 0;
|
|
319
|
-
if (!response.data.maxDownSpeed) response.data.maxDownSpeed = 0;
|
|
320
|
-
if (!response.data.startTime) response.data.startTime = response.data.userLoginOutTime || "未知";
|
|
321
|
-
if (!response.data.nickName) response.data.nickName = "未知";
|
|
322
|
-
if (!response.data.mac) response.data.mac = "未知";
|
|
323
|
-
if (!response.data.userIp) response.data.userIp = "未知";
|
|
324
|
-
if (!response.data.accessDomain) response.data.accessDomain = "未知";
|
|
325
|
-
setCache("account", { account: formattedAccount }, response.data);
|
|
326
|
-
return response.data;
|
|
327
|
-
}
|
|
328
|
-
if (!isAccountResponseComplete(response.data)) {
|
|
329
|
-
throw new Error("账号信息有误,请检查账号是否正确");
|
|
330
|
-
}
|
|
331
|
-
setCache("account", { account: formattedAccount }, response.data);
|
|
332
396
|
return response.data;
|
|
333
397
|
}
|
|
334
398
|
throw new Error(`查询失败:${response.message || "未知错误"}`);
|
|
@@ -336,150 +400,113 @@ function apply(ctx, config) {
|
|
|
336
400
|
console.error("查询错误详情:", error);
|
|
337
401
|
if (error.response) {
|
|
338
402
|
console.error("错误响应:", error.response.data);
|
|
403
|
+
if (error.response.status === 401) {
|
|
404
|
+
console.log("Token已过期或无效,正在重置token并重试...");
|
|
405
|
+
currentToken = null;
|
|
406
|
+
tokenExpireTime = 0;
|
|
407
|
+
if (retryCount < maxRetries) {
|
|
408
|
+
retryCount++;
|
|
409
|
+
console.log(`重试第${retryCount}次`);
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
339
413
|
}
|
|
340
414
|
throw error;
|
|
341
415
|
}
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
__name(queryAccount, "queryAccount");
|
|
345
|
-
async function queryAccountDetail(account) {
|
|
346
|
-
const formattedAccount = formatAccount(account);
|
|
347
|
-
try {
|
|
348
|
-
console.log("开始查询账号详情记录...");
|
|
349
|
-
const token = await getToken();
|
|
350
|
-
const response = await ctx.http.get(`${config.baseUrl}/fttx/aaa/getMoreRecord`, {
|
|
351
|
-
params: { accessUserName: formattedAccount },
|
|
352
|
-
headers: {
|
|
353
|
-
"Authorization": token,
|
|
354
|
-
"Accept": "application/json",
|
|
355
|
-
"Content-Type": "application/json"
|
|
356
|
-
}
|
|
357
|
-
});
|
|
358
|
-
console.log("查询响应:", JSON.stringify(response, null, 2));
|
|
359
|
-
if (response.status === 200 && response.data) {
|
|
360
|
-
return response.data;
|
|
361
|
-
}
|
|
362
|
-
throw new Error(`查询失败:${response.message || "未知错误"}`);
|
|
363
|
-
} catch (error) {
|
|
364
|
-
console.error("查询错误详情:", error);
|
|
365
|
-
if (error.response) {
|
|
366
|
-
console.error("错误响应:", error.response.data);
|
|
367
|
-
}
|
|
368
|
-
throw error;
|
|
369
416
|
}
|
|
417
|
+
throw new Error("请求失败,重试次数已用完");
|
|
370
418
|
}
|
|
371
419
|
__name(queryAccountDetail, "queryAccountDetail");
|
|
372
420
|
async function queryOnuList(mac) {
|
|
373
|
-
const cachedData = getFromCache("onuList", { mac });
|
|
374
|
-
if (cachedData) {
|
|
375
|
-
console.log("使用缓存的设备信息");
|
|
376
|
-
return cachedData;
|
|
377
|
-
}
|
|
378
421
|
return addToQueue("onuList", { mac }, async () => {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
422
|
+
let retryCount = 0;
|
|
423
|
+
const maxRetries = 1;
|
|
424
|
+
while (retryCount <= maxRetries) {
|
|
425
|
+
try {
|
|
426
|
+
console.log("开始查询MAC设备信息...");
|
|
427
|
+
const token = await getToken();
|
|
428
|
+
const response = await ctx.http.get(`${config.baseUrl}/fttx/onu/searchOnuList`, {
|
|
429
|
+
params: { mac, limit: 10, page: 1 },
|
|
430
|
+
headers: {
|
|
431
|
+
"Authorization": token,
|
|
432
|
+
"Accept": "application/json",
|
|
433
|
+
"Content-Type": "application/json"
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
console.log("查询响应:", JSON.stringify(response, null, 2));
|
|
437
|
+
if (response.status === 200 && response.data && response.data.rows && response.data.rows.length > 0) {
|
|
438
|
+
const activeOnu = response.data.rows.find((row) => row.status === 1);
|
|
439
|
+
if (activeOnu) {
|
|
440
|
+
console.log("找到在线设备:", activeOnu);
|
|
441
|
+
return activeOnu;
|
|
442
|
+
}
|
|
443
|
+
const lastOnu = response.data.rows[response.data.rows.length - 1];
|
|
444
|
+
console.log("没有在线设备,返回最后一条记录:", lastOnu);
|
|
445
|
+
return lastOnu;
|
|
388
446
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
447
|
+
throw new Error(`查询失败:${response.message || "未找到设备信息"}`);
|
|
448
|
+
} catch (error) {
|
|
449
|
+
console.error("查询错误详情:", error);
|
|
450
|
+
if (error.response) {
|
|
451
|
+
console.error("错误响应:", error.response.data);
|
|
452
|
+
if (error.response.status === 401) {
|
|
453
|
+
console.log("Token已过期或无效,正在重置token并重试...");
|
|
454
|
+
currentToken = null;
|
|
455
|
+
tokenExpireTime = 0;
|
|
456
|
+
if (retryCount < maxRetries) {
|
|
457
|
+
retryCount++;
|
|
458
|
+
console.log(`重试第${retryCount}次`);
|
|
459
|
+
continue;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
397
462
|
}
|
|
398
|
-
|
|
399
|
-
console.log("没有在线设备,返回最后一条记录:", lastOnu);
|
|
400
|
-
setCache("onuList", { mac }, lastOnu);
|
|
401
|
-
return lastOnu;
|
|
402
|
-
}
|
|
403
|
-
throw new Error(`查询失败:${response.message || "未找到设备信息"}`);
|
|
404
|
-
} catch (error) {
|
|
405
|
-
console.error("查询错误详情:", error);
|
|
406
|
-
if (error.response) {
|
|
407
|
-
console.error("错误响应:", error.response.data);
|
|
463
|
+
throw error;
|
|
408
464
|
}
|
|
409
|
-
throw error;
|
|
410
465
|
}
|
|
466
|
+
throw new Error("请求失败,重试次数已用完");
|
|
411
467
|
});
|
|
412
468
|
}
|
|
413
469
|
__name(queryOnuList, "queryOnuList");
|
|
414
470
|
async function queryOnuDetailInfo(onuId) {
|
|
415
|
-
const cachedData = getFromCache("onuDetail", { onuId });
|
|
416
|
-
if (cachedData) {
|
|
417
|
-
console.log("使用缓存的设备详细信息");
|
|
418
|
-
return cachedData;
|
|
419
|
-
}
|
|
420
471
|
return addToQueue("onuDetail", { onuId }, async () => {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
472
|
+
let retryCount = 0;
|
|
473
|
+
const maxRetries = 1;
|
|
474
|
+
while (retryCount <= maxRetries) {
|
|
475
|
+
try {
|
|
476
|
+
console.log("开始查询MAC详细信息...");
|
|
477
|
+
const token = await getToken();
|
|
478
|
+
const response = await ctx.http.get(`${config.baseUrl}/fttx/onu/onuDetailInfo`, {
|
|
479
|
+
params: { onuId },
|
|
480
|
+
headers: {
|
|
481
|
+
"Authorization": token,
|
|
482
|
+
"Accept": "application/json",
|
|
483
|
+
"Content-Type": "application/json"
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
console.log("查询响应:", JSON.stringify(response, null, 2));
|
|
487
|
+
if (response.status === 200 && response.data) {
|
|
488
|
+
return response.data;
|
|
430
489
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
headers: {
|
|
445
|
-
"Authorization": token,
|
|
446
|
-
"Accept": "application/json",
|
|
447
|
-
"Content-Type": "application/json"
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
);
|
|
451
|
-
if (powerResponse.status === 200 && powerResponse.data) {
|
|
452
|
-
console.log("光功率刷新结果:", powerResponse.data);
|
|
453
|
-
if (powerResponse.data.status !== void 0) {
|
|
454
|
-
response.data.status = powerResponse.data.status;
|
|
455
|
-
}
|
|
456
|
-
if (response.data.status !== 1 && (powerResponse.data.onuReceivePower === void 0 || powerResponse.data.onuSendPower === void 0)) {
|
|
457
|
-
response.data.onuReceivePower = "设备不在线";
|
|
458
|
-
response.data.onuSendPower = "设备不在线";
|
|
459
|
-
} else {
|
|
460
|
-
response.data.onuReceivePower = powerResponse.data.onuReceivePower;
|
|
461
|
-
response.data.onuSendPower = powerResponse.data.onuSendPower;
|
|
490
|
+
throw new Error(`查询失败:${response.message || "未知错误"}`);
|
|
491
|
+
} catch (error) {
|
|
492
|
+
console.error("查询错误详情:", error);
|
|
493
|
+
if (error.response) {
|
|
494
|
+
console.error("错误响应:", error.response.data);
|
|
495
|
+
if (error.response.status === 401) {
|
|
496
|
+
console.log("Token已过期或无效,正在重置token并重试...");
|
|
497
|
+
currentToken = null;
|
|
498
|
+
tokenExpireTime = 0;
|
|
499
|
+
if (retryCount < maxRetries) {
|
|
500
|
+
retryCount++;
|
|
501
|
+
console.log(`重试第${retryCount}次`);
|
|
502
|
+
continue;
|
|
462
503
|
}
|
|
463
|
-
response.data.statusHealth = powerResponse.data.statusHealth;
|
|
464
|
-
}
|
|
465
|
-
} catch (error) {
|
|
466
|
-
console.error("刷新光功率过程中出错:", error);
|
|
467
|
-
if (response.data.status !== 1 && (response.data.onuReceivePower === void 0 || response.data.onuReceivePower === null || response.data.onuSendPower === void 0 || response.data.onuSendPower === null)) {
|
|
468
|
-
response.data.onuReceivePower = "设备不在线";
|
|
469
|
-
response.data.onuSendPower = "设备不在线";
|
|
470
504
|
}
|
|
471
505
|
}
|
|
472
|
-
|
|
473
|
-
return response.data;
|
|
474
|
-
}
|
|
475
|
-
throw new Error(`查询失败:${response.message || "未知错误"}`);
|
|
476
|
-
} catch (error) {
|
|
477
|
-
console.error("查询错误详情:", error);
|
|
478
|
-
if (error.response) {
|
|
479
|
-
console.error("错误响应:", error.response.data);
|
|
506
|
+
throw error;
|
|
480
507
|
}
|
|
481
|
-
throw error;
|
|
482
508
|
}
|
|
509
|
+
throw new Error("请求失败,重试次数已用完");
|
|
483
510
|
});
|
|
484
511
|
}
|
|
485
512
|
__name(queryOnuDetailInfo, "queryOnuDetailInfo");
|
|
@@ -1035,11 +1062,24 @@ function apply(ctx, config) {
|
|
|
1035
1062
|
`回复消息: ${accountInfo.failReplyMessage || "未知"}`,
|
|
1036
1063
|
`原因分析: ${accountInfo.reasonAnaly || "未知"}`
|
|
1037
1064
|
);
|
|
1038
|
-
} else if (accountInfo.onlineStatus === "离线"
|
|
1065
|
+
} else if (accountInfo.onlineStatus === "离线" && accountInfo.isPass === "原因未知") {
|
|
1039
1066
|
message.push(
|
|
1040
1067
|
`未检索到账号信息⚠️`,
|
|
1041
1068
|
`请检查ONU配置和账号是否正确或尝试重新拨号!`
|
|
1042
1069
|
);
|
|
1070
|
+
} else if (accountInfo.onlineStatus === "离线" || accountInfo.onlineStatus === "不在线") {
|
|
1071
|
+
message.push(
|
|
1072
|
+
`MAC地址: ${accountInfo.mac || "未知"}`
|
|
1073
|
+
);
|
|
1074
|
+
if (accountInfo.startTime) {
|
|
1075
|
+
message.push(`最后在线: ${accountInfo.startTime || "未知"}`);
|
|
1076
|
+
}
|
|
1077
|
+
if (accountInfo.offlineReason) {
|
|
1078
|
+
message.push(`离线原因: ${accountInfo.offlineReason || "未知"}`);
|
|
1079
|
+
}
|
|
1080
|
+
if (accountInfo.reasonAnaly) {
|
|
1081
|
+
message.push(`原因分析: ${accountInfo.reasonAnaly || "未知"}`);
|
|
1082
|
+
}
|
|
1043
1083
|
} else {
|
|
1044
1084
|
message.push(
|
|
1045
1085
|
`IP地址: ${accountInfo.userIp}`,
|
|
@@ -1077,7 +1117,7 @@ function apply(ctx, config) {
|
|
|
1077
1117
|
`账号: ${input}`,
|
|
1078
1118
|
`RADIUS状态: ${translateUserStatus(user.user_status)} ${user.user_status === "active" ? "✅" : user.user_status === "suspend" ? "⚠️" : "❌"}`,
|
|
1079
1119
|
"",
|
|
1080
|
-
"⚠️
|
|
1120
|
+
"⚠️ 账号信息查询失败",
|
|
1081
1121
|
`错误信息: ${accountError.message || "未知错误"}`,
|
|
1082
1122
|
""
|
|
1083
1123
|
];
|
|
@@ -1161,11 +1201,24 @@ function apply(ctx, config) {
|
|
|
1161
1201
|
`回复消息: ${accountInfo.failReplyMessage || "未知"}`,
|
|
1162
1202
|
`原因分析: ${accountInfo.reasonAnaly || "未知"}`
|
|
1163
1203
|
);
|
|
1164
|
-
} else if (accountInfo.onlineStatus === "离线"
|
|
1204
|
+
} else if (accountInfo.onlineStatus === "离线" && accountInfo.isPass === "原因未知") {
|
|
1165
1205
|
message.push(
|
|
1166
1206
|
`未检索到账号信息⚠️`,
|
|
1167
1207
|
`请检查ONU配置和账号是否正确或尝试重新拨号!`
|
|
1168
1208
|
);
|
|
1209
|
+
} else if (accountInfo.onlineStatus === "离线" || accountInfo.onlineStatus === "不在线") {
|
|
1210
|
+
message.push(
|
|
1211
|
+
`MAC地址: ${accountInfo.mac || "未知"}`
|
|
1212
|
+
);
|
|
1213
|
+
if (accountInfo.startTime) {
|
|
1214
|
+
message.push(`最后在线: ${accountInfo.startTime || "未知"}`);
|
|
1215
|
+
}
|
|
1216
|
+
if (accountInfo.offlineReason) {
|
|
1217
|
+
message.push(`离线原因: ${accountInfo.offlineReason || "未知"}`);
|
|
1218
|
+
}
|
|
1219
|
+
if (accountInfo.reasonAnaly) {
|
|
1220
|
+
message.push(`原因分析: ${accountInfo.reasonAnaly || "未知"}`);
|
|
1221
|
+
}
|
|
1169
1222
|
} else {
|
|
1170
1223
|
message.push(
|
|
1171
1224
|
`IP地址: ${accountInfo.userIp}`,
|
|
@@ -1203,7 +1256,7 @@ function apply(ctx, config) {
|
|
|
1203
1256
|
`账号: ${account}`,
|
|
1204
1257
|
`RADIUS状态: ${translateUserStatus(user.user_status)} ${user.user_status === "active" ? "✅" : user.user_status === "suspend" ? "⚠️" : "❌"}`,
|
|
1205
1258
|
"",
|
|
1206
|
-
"⚠️
|
|
1259
|
+
"⚠️ 账号信息查询失败",
|
|
1207
1260
|
`错误信息: ${accountError.message || "未知错误"}`,
|
|
1208
1261
|
""
|
|
1209
1262
|
];
|