|
@@ -26,7 +26,11 @@ export function useWs() {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- function initWs(data: any, callback: any) {
|
|
|
+ function delay(ms: number): Promise<void> {
|
|
|
+ return new Promise(resolve => setTimeout(resolve, ms));
|
|
|
+ }
|
|
|
+
|
|
|
+ async function initWs(data: any, callback: any) {
|
|
|
examStateList = []; //当前状态码
|
|
|
testList = []; //区列表
|
|
|
wkList = []; //工作站列表
|
|
@@ -56,23 +60,27 @@ export function useWs() {
|
|
|
callback({ cmd: 'disconnect_request', data: { message: 'WS连接超时' } });
|
|
|
}
|
|
|
}, 20000);
|
|
|
- socket.on('connect', (e: any) => {
|
|
|
+ socket.on('connect', async (e: any) => {
|
|
|
callback({ cmd: 'mySid', data: { sid: socket.id.replace('/midexam#', '') } });
|
|
|
if (testList.length > 1) {
|
|
|
//单WS多区直接执行
|
|
|
- testList.forEach((item: any) => {
|
|
|
- let examId = `${parameter.project}_${item}`;
|
|
|
- if (parameter.taskId) {
|
|
|
- getTaskStarts(examId);
|
|
|
- } else {
|
|
|
- getExamStarts(examId);
|
|
|
- }
|
|
|
- getNetWork(examId, (e: any) => {
|
|
|
- if (!e.status) {
|
|
|
- callback({ cmd: 'disconnect_request', exam_id: examId, data: { message: '工作站未响应' } });
|
|
|
+
|
|
|
+ for (const item of testList) {
|
|
|
+ await delay(100); // 延时 1 秒
|
|
|
+ let examId = `${parameter.project}_${item}`;
|
|
|
+ if (parameter.taskId) {
|
|
|
+ getTaskStarts(examId);
|
|
|
+ } else {
|
|
|
+ getExamStarts(examId);
|
|
|
}
|
|
|
- });
|
|
|
- });
|
|
|
+ getNetWork(examId, (e: any) => {
|
|
|
+ if (!e.status) {
|
|
|
+ callback({cmd: 'disconnect_request', exam_id: examId, data: {message: '工作站未响应'}});
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
//分组延迟执行
|
|
|
// let num = 10; //每次执行10个
|