fix: 过程任务队列
This commit is contained in:
parent
31e0fd9d2a
commit
e75a2c076f
@ -81,3 +81,6 @@ export const LogTag = '[LogWorker]';
|
|||||||
// 开始考试,结束考试标志
|
// 开始考试,结束考试标志
|
||||||
export const StartEndExamTag = '[StartEndExam]';
|
export const StartEndExamTag = '[StartEndExam]';
|
||||||
|
|
||||||
|
// Queue
|
||||||
|
export const QueueTag = '[Queue]'
|
||||||
|
|
||||||
|
|||||||
@ -815,7 +815,7 @@ export interface DistanceClass {
|
|||||||
|
|
||||||
export interface WR {
|
export interface WR {
|
||||||
message?: string
|
message?: string
|
||||||
code?: number
|
code?: string
|
||||||
keystr?: string
|
keystr?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -248,6 +248,7 @@ export interface ObtainCarExamInfoParams {
|
|||||||
|
|
||||||
//监管接口参数
|
//监管接口参数
|
||||||
export interface RegulatoryInterfaceParams {
|
export interface RegulatoryInterfaceParams {
|
||||||
|
JGHOST?: string
|
||||||
xtlb?: string;
|
xtlb?: string;
|
||||||
jkxlh?: string;
|
jkxlh?: string;
|
||||||
jkid?: string;
|
jkid?: string;
|
||||||
|
|||||||
@ -29,7 +29,7 @@ import {
|
|||||||
examJudgeSetRealExamCallback,
|
examJudgeSetRealExamCallback,
|
||||||
examJudgeSoundEnd
|
examJudgeSoundEnd
|
||||||
} from './JudgeSDKUtils'
|
} from './JudgeSDKUtils'
|
||||||
import { ProjectStart, UploadProgressPhoto } from './ProcessDataProcessing'
|
import { DeductPoints, ProjectEnd, ProjectStart, UploadProgressPhoto } from './ProcessDataProcessing'
|
||||||
import { endRecordVideo, saveStartRecordVideo } from '../../utils/Video'
|
import { endRecordVideo, saveStartRecordVideo } from '../../utils/Video'
|
||||||
import router from '@ohos.router'
|
import router from '@ohos.router'
|
||||||
import { GetSyncData, UpdateTableByArray } from '../../utils/table/Operation'
|
import { GetSyncData, UpdateTableByArray } from '../../utils/table/Operation'
|
||||||
@ -110,6 +110,18 @@ export class BaseJudge {
|
|||||||
}
|
}
|
||||||
}, 200)
|
}, 200)
|
||||||
if (!project.isEnd) {
|
if (!project.isEnd) {
|
||||||
|
// judgeTask.addTask(async () => {
|
||||||
|
// console.info(judgeTag, `项目开始-${xmdm}-${projectsObj[xmdm].name}`)
|
||||||
|
// await beginProject(xmdm, xmxh)
|
||||||
|
// }, {
|
||||||
|
// isDelay: true
|
||||||
|
// })
|
||||||
|
// judgeTask.addTask(async () => {
|
||||||
|
// console.info(judgeTag, `项目-${xmdm}-上传照片 start`)
|
||||||
|
// await uploadProgressPhoto(xmdm)
|
||||||
|
// }, {
|
||||||
|
// isDelay: true
|
||||||
|
// })
|
||||||
ProjectStart(xmdm, that.xmxh, judgeUI)
|
ProjectStart(xmdm, that.xmxh, judgeUI)
|
||||||
UploadProgressPhoto(xmdm, that.plcData!, judgeUI)
|
UploadProgressPhoto(xmdm, that.plcData!, judgeUI)
|
||||||
}
|
}
|
||||||
@ -132,6 +144,7 @@ export class BaseJudge {
|
|||||||
// }, {
|
// }, {
|
||||||
// isDelay: true
|
// isDelay: true
|
||||||
// })
|
// })
|
||||||
|
ProjectEnd(xmdm, that.xmxh, judgeUI)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dConsole.log(JudgeTag, "项目结束判定3")
|
dConsole.log(JudgeTag, "项目结束判定3")
|
||||||
@ -164,6 +177,7 @@ export class BaseJudge {
|
|||||||
// }, {
|
// }, {
|
||||||
// isDelay: true
|
// isDelay: true
|
||||||
// })
|
// })
|
||||||
|
DeductPoints(Number(currentKf.xmdm), currentKf, that.xmmcEndCode || "", judgeUI)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -174,6 +188,7 @@ export class BaseJudge {
|
|||||||
if (!singlePlay && that.videoData) {
|
if (!singlePlay && that.videoData) {
|
||||||
await endRecordVideo(that.videoData)
|
await endRecordVideo(that.videoData)
|
||||||
}
|
}
|
||||||
|
// TODO
|
||||||
// judgeTask.addTask(async () => {
|
// judgeTask.addTask(async () => {
|
||||||
// dConsole.info(JudgeTag, '考试结束 start')
|
// dConsole.info(JudgeTag, '考试结束 start')
|
||||||
// AppStorage.setOrCreate('isJudge', false)
|
// AppStorage.setOrCreate('isJudge', false)
|
||||||
@ -515,7 +530,7 @@ export class BaseJudge {
|
|||||||
}
|
}
|
||||||
const currentProject: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm)
|
const currentProject: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm)
|
||||||
|
|
||||||
if (currentProject.isUpload) {
|
if (!currentProject.isUpload) {
|
||||||
dConsole.info(JudgeTag, '项目补传开始')
|
dConsole.info(JudgeTag, '项目补传开始')
|
||||||
// judgeTask.addTask(async () => {
|
// judgeTask.addTask(async () => {
|
||||||
// await this.beginProject(xmdm)
|
// await this.beginProject(xmdm)
|
||||||
|
|||||||
@ -1,13 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
* 过程数据处理
|
* 过程数据处理
|
||||||
*/
|
*/
|
||||||
import { ProcessDataTag } from '../../config';
|
import { ProcessDataTag, QueueTag } from '../../config';
|
||||||
import {
|
import {
|
||||||
CarInfoType,
|
CarInfoType,
|
||||||
CDSBInfo,
|
CDSBInfo,
|
||||||
CDSBInfos,
|
CDSBInfos,
|
||||||
DrvexamType,
|
DrvexamType,
|
||||||
JudgeUI,
|
|
||||||
MarkRule,
|
MarkRule,
|
||||||
PLCType,
|
PLCType,
|
||||||
ProjectInfo,
|
ProjectInfo,
|
||||||
@ -39,13 +38,14 @@ export const ProjectStart = (ksxm: number, xmxh: string, judgeUI: JudgePage) =>
|
|||||||
kssj: dayTs().format("YYYY-MM-DD HH:mm:ss")
|
kssj: dayTs().format("YYYY-MM-DD HH:mm:ss")
|
||||||
}
|
}
|
||||||
const data: RegulatoryInterfaceParams = {
|
const data: RegulatoryInterfaceParams = {
|
||||||
|
JGHOST: AppStorage.get<string>("JGHOST") || "",
|
||||||
//系统类别 接口序列号 接口标识
|
//系统类别 接口序列号 接口标识
|
||||||
xtlb: '17',
|
xtlb: '17',
|
||||||
jkxlh: judgeUI.serialNumber,
|
jkxlh: judgeUI.serialNumber,
|
||||||
jkid: '17C52',
|
jkid: '17C52',
|
||||||
drvexam
|
drvexam
|
||||||
}
|
}
|
||||||
dConsole.log(ProcessDataTag, "项目开始数据处理", data)
|
dConsole.log(ProcessDataTag, QueueTag, "项目开始数据处理", data)
|
||||||
ProcessDataTaskPoolInstance.addTask(data)
|
ProcessDataTaskPoolInstance.addTask(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,12 +69,13 @@ export const UploadProgressPhoto = async (ksxm: number, plcData: PLCType, judgeU
|
|||||||
ksdd: encodeURI(judgeUI.ksdd)
|
ksdd: encodeURI(judgeUI.ksdd)
|
||||||
}
|
}
|
||||||
const data: RegulatoryInterfaceParams = {
|
const data: RegulatoryInterfaceParams = {
|
||||||
|
JGHOST: AppStorage.get<string>("JGHOST") || "",
|
||||||
xtlb: '17',
|
xtlb: '17',
|
||||||
jkxlh: judgeUI.serialNumber,
|
jkxlh: judgeUI.serialNumber,
|
||||||
jkid: '17C54',
|
jkid: '17C54',
|
||||||
drvexam
|
drvexam
|
||||||
};
|
};
|
||||||
dConsole.log(ProcessDataTag, "上传过程照片数据处理", data);
|
dConsole.log(ProcessDataTag, QueueTag, "上传过程照片数据处理", data);
|
||||||
ProcessDataTaskPoolInstance.addTask(data)
|
ProcessDataTaskPoolInstance.addTask(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,12 +132,13 @@ export const DeductPoints = (ksxm: number, kf: MarkRule, xmmcEndCode: string, ju
|
|||||||
kfsj: dayTs().format("YYYY-MM-DD HH:mm:ss"),
|
kfsj: dayTs().format("YYYY-MM-DD HH:mm:ss"),
|
||||||
}
|
}
|
||||||
const data: RegulatoryInterfaceParams = {
|
const data: RegulatoryInterfaceParams = {
|
||||||
|
JGHOST: AppStorage.get<string>("JGHOST") || "",
|
||||||
xtlb: '17',
|
xtlb: '17',
|
||||||
jkxlh: serialNumber,
|
jkxlh: serialNumber,
|
||||||
jkid: '17C53',
|
jkid: '17C53',
|
||||||
drvexam
|
drvexam
|
||||||
}
|
}
|
||||||
dConsole.log(ProcessDataTag, "扣分上传数据", data)
|
dConsole.log(ProcessDataTag, QueueTag, "扣分上传数据", data)
|
||||||
ProcessDataTaskPoolInstance.addTask(data)
|
ProcessDataTaskPoolInstance.addTask(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,11 +165,12 @@ export const ProjectEnd = (ksxm: number, xmxh: string, judgeUI: JudgePage) => {
|
|||||||
}
|
}
|
||||||
const data: RegulatoryInterfaceParams = {
|
const data: RegulatoryInterfaceParams = {
|
||||||
xtlb: '17',
|
xtlb: '17',
|
||||||
|
JGHOST: AppStorage.get<string>("JGHOST") || "",
|
||||||
jkxlh: judgeUI.serialNumber,
|
jkxlh: judgeUI.serialNumber,
|
||||||
jkid: '17C55',
|
jkid: '17C55',
|
||||||
drvexam
|
drvexam
|
||||||
}
|
}
|
||||||
dConsole.log(ProcessDataTag, "结束项目数据", data)
|
dConsole.log(ProcessDataTag, QueueTag, "结束项目数据", data)
|
||||||
ProcessDataTaskPoolInstance.addTask(data)
|
ProcessDataTaskPoolInstance.addTask(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { ProcessDataEnumType, RegulatoryInterfaceParams, WR, WuxiExamType } from '../../model';
|
import { RegulatoryInterfaceParams, WR, WuxiExamType } from '../../model';
|
||||||
import taskpool from '@ohos.taskpool';
|
import taskpool from '@ohos.taskpool';
|
||||||
import { dConsole } from '../../utils/LogWorker';
|
import { QueueTag } from '../../config';
|
||||||
import http from '@ohos.net.http';
|
import http from '@ohos.net.http';
|
||||||
import Request from '../../utils/Request';
|
import Request from '../../utils/Request';
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ export class ProcessDataTaskPool {
|
|||||||
* @param dataItem 任务数据
|
* @param dataItem 任务数据
|
||||||
*/
|
*/
|
||||||
public addTask(dataItem: RegulatoryInterfaceParams): void {
|
public addTask(dataItem: RegulatoryInterfaceParams): void {
|
||||||
console.info(`[Queue] 新任务已添加: ${JSON.stringify(dataItem)},当前队列长度: ${this.queue.length + 1}`);
|
console.info(QueueTag, `新任务已添加: ${JSON.stringify(dataItem)},当前队列长度: ${this.queue.length + 1}`);
|
||||||
this.queue.push(dataItem); // 将任务添加到队尾
|
this.queue.push(dataItem); // 将任务添加到队尾
|
||||||
|
|
||||||
// 每次添加任务,增加当前批次的总任务数
|
// 每次添加任务,增加当前批次的总任务数
|
||||||
@ -92,7 +92,7 @@ export class ProcessDataTaskPool {
|
|||||||
*/
|
*/
|
||||||
private triggerProcessing(): void {
|
private triggerProcessing(): void {
|
||||||
if (this.isProcessing) {
|
if (this.isProcessing) {
|
||||||
console.log('[Queue] 处理器正在运行中,新任务将在稍后被处理。');
|
console.log(QueueTag, '处理器正在运行中,新任务将在稍后被处理。');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.processQueue();
|
this.processQueue();
|
||||||
@ -100,14 +100,14 @@ export class ProcessDataTaskPool {
|
|||||||
|
|
||||||
private async processQueue(): Promise<void> {
|
private async processQueue(): Promise<void> {
|
||||||
this.isProcessing = true;
|
this.isProcessing = true;
|
||||||
console.log(`[Queue] 启动处理器... 待处理任务数: ${this.queue.length}`);
|
console.log(QueueTag, `启动处理器... 待处理任务数: ${this.queue.length}`);
|
||||||
|
|
||||||
while (this.queue.length > 0) {
|
while (this.queue.length > 0) {
|
||||||
const taskData = this.queue[0]; // 查看队首任务
|
const taskData = this.queue[0]; // 查看队首任务
|
||||||
this.taskStartTime = Date.now(); // 记录任务开始时间
|
this.taskStartTime = Date.now(); // 记录任务开始时间
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log(`[Queue] 开始处理任务: ${JSON.stringify(taskData)}`);
|
console.log(QueueTag, `开始处理任务: ${JSON.stringify(taskData)}`);
|
||||||
|
|
||||||
const obj: WuxiExamType = {
|
const obj: WuxiExamType = {
|
||||||
xtlb: taskData.xtlb,
|
xtlb: taskData.xtlb,
|
||||||
@ -117,17 +117,17 @@ export class ProcessDataTaskPool {
|
|||||||
zp: "",
|
zp: "",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
dConsole.writeProcessData(ProcessDataEnumType.WuxiExam, JSON.stringify(obj));
|
// dConsole.writeProcessData(ProcessDataEnumType.WuxiExam, JSON.stringify(obj));
|
||||||
|
|
||||||
await this.processSingleTaskWithRetries(taskData);
|
await this.processSingleTaskWithRetries(taskData);
|
||||||
|
|
||||||
// 任务成功
|
// 任务成功
|
||||||
this.queue.shift();
|
this.queue.shift();
|
||||||
console.log(`[Queue] ✅ 任务处理成功,已从队列移除。剩余任务: ${this.queue.length}`);
|
console.log(QueueTag, `✅ 任务处理成功,已从队列移除。剩余任务: ${this.queue.length}`);
|
||||||
this.successfulTasksInCurrentBatch++; // 增加成功任务计数
|
this.successfulTasksInCurrentBatch++; // 增加成功任务计数
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// 任务永久失败
|
// 任务永久失败
|
||||||
console.error(`[Queue] 🔥 任务永久失败: ${(error as Error).message}`);
|
console.error(QueueTag, ` 🔥 任务永久失败: ${(error as Error).message}`);
|
||||||
const failedTask = this.queue.shift(); // 移除失败的任务
|
const failedTask = this.queue.shift(); // 移除失败的任务
|
||||||
console.error(`[Queue] 失败的任务已被移除: ${JSON.stringify(failedTask)},将继续处理下一个任务。`);
|
console.error(`[Queue] 失败的任务已被移除: ${JSON.stringify(failedTask)},将继续处理下一个任务。`);
|
||||||
this.failedTasksInCurrentBatch++; // 增加失败任务计数
|
this.failedTasksInCurrentBatch++; // 增加失败任务计数
|
||||||
@ -140,7 +140,7 @@ export class ProcessDataTaskPool {
|
|||||||
|
|
||||||
// 检查是否所有任务都已处理完
|
// 检查是否所有任务都已处理完
|
||||||
if (this.queue.length === 0 && this.completedTasksInCurrentBatch === this.totalTasksInCurrentBatch) {
|
if (this.queue.length === 0 && this.completedTasksInCurrentBatch === this.totalTasksInCurrentBatch) {
|
||||||
console.log('[Queue] 所有任务处理完毕!');
|
console.log(QueueTag, ' 所有任务处理完毕!');
|
||||||
this.onAllTasksCompletedCallback?.(
|
this.onAllTasksCompletedCallback?.(
|
||||||
this.totalTasksInCurrentBatch,
|
this.totalTasksInCurrentBatch,
|
||||||
this.completedTasksInCurrentBatch,
|
this.completedTasksInCurrentBatch,
|
||||||
@ -155,14 +155,14 @@ export class ProcessDataTaskPool {
|
|||||||
const elapsedTime = Date.now() - this.taskStartTime;
|
const elapsedTime = Date.now() - this.taskStartTime;
|
||||||
if (elapsedTime < this.minProcessingTime) {
|
if (elapsedTime < this.minProcessingTime) {
|
||||||
const delayTime = this.minProcessingTime - elapsedTime;
|
const delayTime = this.minProcessingTime - elapsedTime;
|
||||||
console.log(`[Queue] 任务处理耗时 ${elapsedTime}ms,需要延迟 ${delayTime}ms 以满足最小处理时间要求`);
|
console.log(QueueTag, ` 任务处理耗时 ${elapsedTime}ms,需要延迟 ${delayTime}ms 以满足最小处理时间要求`);
|
||||||
await this.delay(delayTime);
|
await this.delay(delayTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isProcessing = false;
|
this.isProcessing = false;
|
||||||
console.log('[Queue] 处理器已停止。');
|
console.log(QueueTag, ' 处理器已停止。');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -204,18 +204,22 @@ export class ProcessDataTaskPool {
|
|||||||
const attemptNum = attempt + 1;
|
const attemptNum = attempt + 1;
|
||||||
try {
|
try {
|
||||||
const attemptType = attempt === 0 ? '初次尝试' : `重试 ${attempt}`;
|
const attemptType = attempt === 0 ? '初次尝试' : `重试 ${attempt}`;
|
||||||
console.log(`[Queue] 开始上传 (${attemptType}, 总共第 ${attemptNum} 次)`);
|
console.log(QueueTag, `开始上传 (${attemptType}, 总共第 ${attemptNum} 次)`);
|
||||||
|
// dConsole.log(QueueTag, "需要上传的数据", taskData)
|
||||||
|
let data: RegulatoryInterfaceParams = {
|
||||||
|
JGHOST: "http://192.168.36.2:8081",
|
||||||
|
xtlb: "17"
|
||||||
|
}
|
||||||
const result: WR = (await taskpool.execute(uploadWorkerTask, taskData)) as WR;
|
const result: WR = (await taskpool.execute(uploadWorkerTask, taskData)) as WR;
|
||||||
|
|
||||||
dConsole.writeProcessData(ProcessDataEnumType.WuxiExam, JSON.stringify(result));
|
// dConsole.writeProcessData(ProcessDataEnumType.WuxiExam, JSON.stringify(result));
|
||||||
if (result.code === 1) {
|
if (result.code === "1") {
|
||||||
console.log(`[Queue] ✔️ 上传成功 (在第 ${attemptNum} 次尝试)`);
|
console.log(QueueTag, ` ✔️ 上传成功 (在第 ${attemptNum} 次尝试)`);
|
||||||
return; // 成功,立即返回
|
return; // 成功,立即返回
|
||||||
}
|
}
|
||||||
console.warn(`[Queue] ❌ 上传失败 (第 ${attemptNum} 次)。响应: ${result.message}`);
|
console.warn(QueueTag, ` ❌ 上传失败 (第 ${attemptNum} 次)。${result.code},响应: ${decodeURIComponent(result.message)}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`[Queue] ❌ TaskPool 执行或网络错误 (第 ${attemptNum} 次): ${e}`);
|
console.error(QueueTag, ` ❌ TaskPool 执行或网络错误 (第 ${attemptNum} 次): ${e}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attempt === this.maxRetries) {
|
if (attempt === this.maxRetries) {
|
||||||
@ -229,40 +233,39 @@ export class ProcessDataTaskPool {
|
|||||||
|
|
||||||
export const ProcessDataTaskPoolInstance = new ProcessDataTaskPool();
|
export const ProcessDataTaskPoolInstance = new ProcessDataTaskPool();
|
||||||
|
|
||||||
|
@Concurrent
|
||||||
export async function uploadWorkerTask(data: RegulatoryInterfaceParams): Promise<WR> {
|
export async function uploadWorkerTask(data: RegulatoryInterfaceParams): Promise<WR> {
|
||||||
let singlePlay: boolean = false;
|
let singlePlay: boolean = false;
|
||||||
let isJGNew = false;
|
let isJGNew = false;
|
||||||
try {
|
try {
|
||||||
|
const sendProcessData = async (data: RegulatoryInterfaceParams, singlePlay: boolean, isJGNew: boolean): Promise<WR> => {
|
||||||
|
if (singlePlay) {
|
||||||
|
return { code: "1" }
|
||||||
|
}
|
||||||
|
if (isJGNew) {
|
||||||
|
// 调用新监管
|
||||||
|
}
|
||||||
|
data.drvexam = data.drvexam ?? {};
|
||||||
|
if (data.drvexam.zp !== undefined && data.drvexam.zp !== null) {
|
||||||
|
data.drvexam.zp = encodeURIComponent(data.drvexam.zp);
|
||||||
|
}
|
||||||
|
|
||||||
|
const drvexamArr = Object.entries(data.drvexam)
|
||||||
|
.filter((item: [string, string]) => item[1] != undefined)
|
||||||
|
.map((item: [string, object]) => `<${item[0]}>${item[1]}</${item[0]}>`)
|
||||||
|
return await Request<object>({
|
||||||
|
host: data.JGHOST,
|
||||||
|
url: '/dems_ws/services/TmriOutAccess?wsdl',
|
||||||
|
data: `<?xml version="1.0"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" > <SOAP-ENV:Body> <writeObjectOut xmlns="http://service.es.doron"> <xtlb>${data.xtlb}</xtlb> <jkxlh>${data.jkxlh}</jkxlh> <jkid>${data.jkid}</jkid> <UTF8XmlDoc> <![CDATA[ <?xm lversion="1.0 "encoding="GBK"?> <root> <drvexam> ${drvexamArr.join('')} </drvexam> </root> ]]> </UTF8XmlDoc> </writeObjectOut> </SOAP-ENV:Body> </SOAP-ENV:Envelope>`,
|
||||||
|
method: http.RequestMethod.POST,
|
||||||
|
xml: true
|
||||||
|
})
|
||||||
|
}
|
||||||
const response = await sendProcessData(data, singlePlay, isJGNew);
|
const response = await sendProcessData(data, singlePlay, isJGNew);
|
||||||
return response;
|
return response;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const error = err as Error;
|
const error = err as Error;
|
||||||
console.error(`[Worker] 上传时发生异常: ${error.message}`);
|
console.error(QueueTag, `[Worker] 上传时发生异常: ${error.message}`);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sendProcessData(data: RegulatoryInterfaceParams, singlePlay: boolean, isJGNew: boolean): Promise<WR> {
|
|
||||||
if (singlePlay) {
|
|
||||||
return { code: 1 }
|
|
||||||
}
|
|
||||||
if (isJGNew) {
|
|
||||||
// 调用新监管
|
|
||||||
}
|
|
||||||
data.drvexam = data.drvexam ?? {};
|
|
||||||
if (data.drvexam.zp !== undefined && data.drvexam.zp !== null) {
|
|
||||||
data.drvexam.zp = encodeURIComponent(data.drvexam.zp);
|
|
||||||
}
|
|
||||||
|
|
||||||
const drvexamArr = Object.entries(data.drvexam)
|
|
||||||
.filter((item: [string, string]) => item[1] != undefined)
|
|
||||||
.map((item: [string, object]) => `<${item[0]}>${item[1]}</${item[0]}>`)
|
|
||||||
let JGHOST: string = AppStorage.get<string>("JGHOST") || ""
|
|
||||||
return await Request<object>({
|
|
||||||
host: JGHOST,
|
|
||||||
url: '/dems_ws/services/TmriOutAccess?wsdl',
|
|
||||||
data: `<?xml version="1.0"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" > <SOAP-ENV:Body> <writeObjectOut xmlns="http://service.es.doron"> <xtlb>${data.xtlb}</xtlb> <jkxlh>${data.jkxlh}</jkxlh> <jkid>${data.jkid}</jkid> <UTF8XmlDoc> <![CDATA[ <?xm lversion="1.0 "encoding="GBK"?> <root> <drvexam> ${drvexamArr.join('')} </drvexam> </root> ]]> </UTF8XmlDoc> </writeObjectOut> </SOAP-ENV:Body> </SOAP-ENV:Envelope>`,
|
|
||||||
method: http.RequestMethod.POST,
|
|
||||||
xml: true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@ -15,43 +15,25 @@ import {
|
|||||||
MAPITEMPOINTITEM,
|
MAPITEMPOINTITEM,
|
||||||
MAPPOINT,
|
MAPPOINT,
|
||||||
MarkRule,
|
MarkRule,
|
||||||
ProcessDataEnumType,
|
Project,
|
||||||
ProjectInfo,
|
ProjectInfo,
|
||||||
|
ProjectInfos,
|
||||||
RouteParamsType,
|
RouteParamsType,
|
||||||
SyssetConfig,
|
SyssetConfig,
|
||||||
SYSTEM_PARAM,
|
SYSTEM_PARAM
|
||||||
Project,
|
|
||||||
ProjectInfos,
|
|
||||||
JudgeCallBackData,
|
|
||||||
KmItem
|
|
||||||
} from '../../model';
|
} from '../../model';
|
||||||
import common from '@ohos.app.ability.common';
|
import common from '@ohos.app.ability.common';
|
||||||
import { dConsole } from '../../utils/LogWorker';
|
import { dConsole } from '../../utils/LogWorker';
|
||||||
import {
|
import { examJudgeVersion } from './JudgeSDKUtils';
|
||||||
examJudgeBeginExam,
|
|
||||||
examJudgeEndExam,
|
|
||||||
examJudgeInit,
|
|
||||||
examJudgeSetLogCallback,
|
|
||||||
examJudgeSetPerformCallback,
|
|
||||||
examJudgeSetRealExamCallback,
|
|
||||||
examJudgeVersion
|
|
||||||
} from './JudgeSDKUtils';
|
|
||||||
import JudgeBusiness from './JudgeBusiness';
|
import JudgeBusiness from './JudgeBusiness';
|
||||||
import { saveStartRecordVideo } from '../../utils/Video';
|
|
||||||
import router from '@ohos.router';
|
import router from '@ohos.router';
|
||||||
import {
|
import { GetModelData } from './utils';
|
||||||
CurrentProjectConversion,
|
|
||||||
DeductionProjectConversion,
|
|
||||||
DetectingDifferences,
|
|
||||||
GetCarStatus,
|
|
||||||
GetModelData
|
|
||||||
} from './utils';
|
|
||||||
import { BaseJudge, BaseJudgeImpl, GetSysSetResult } from './BaseJudgeBussines';
|
import { BaseJudge, BaseJudgeImpl, GetSysSetResult } from './BaseJudgeBussines';
|
||||||
import { GetSyncData } from '../../utils/table/Operation';
|
import { GetSyncData } from '../../utils/table/Operation';
|
||||||
import promptAction from '@ohos.promptAction';
|
import promptAction from '@ohos.promptAction';
|
||||||
import { JudgePage } from '../Judge';
|
import { JudgePage } from '../Judge';
|
||||||
import systemDateTime from '@ohos.systemDateTime';
|
import systemDateTime from '@ohos.systemDateTime';
|
||||||
import { testKm2Items, testKm3Items } from "../../mock/Judge"
|
import { testKm2Items, testKm3Items } from '../../mock/Judge';
|
||||||
|
|
||||||
export class SmallJudge extends BaseJudge implements BaseJudgeImpl {
|
export class SmallJudge extends BaseJudge implements BaseJudgeImpl {
|
||||||
public async GetJudgeBeginData(projects: Project[], carType: string, kssycs: string, isDdxk: boolean, ddxkTime: number, projectsCenterObj: Object, ddxkKsxmArr: string[], ddxkKfArr: string[], passingScore: number, wayno: number, name: string, lsh: string, idCard: string, isExam: boolean) {
|
public async GetJudgeBeginData(projects: Project[], carType: string, kssycs: string, isDdxk: boolean, ddxkTime: number, projectsCenterObj: Object, ddxkKsxmArr: string[], ddxkKfArr: string[], passingScore: number, wayno: number, name: string, lsh: string, idCard: string, isExam: boolean) {
|
||||||
@ -133,10 +115,11 @@ export class SmallJudge extends BaseJudge implements BaseJudgeImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//获取版本号
|
//获取版本号
|
||||||
const mark: MarkRule[] = Reflect.ownKeys(markRuleListObj).map(ruleKey => {
|
// const mark: MarkRule[] = Reflect.ownKeys(markRuleListObj).map(ruleKey => {
|
||||||
const current: MarkRule = Reflect.get(markRuleListObj, ruleKey)
|
// const current: MarkRule = Reflect.get(markRuleListObj, ruleKey)
|
||||||
return current
|
// return current
|
||||||
})
|
// })
|
||||||
|
const mark: MarkRule[] = Object.values(markRuleListObj)
|
||||||
const initInfo: JudgeInitObj = {
|
const initInfo: JudgeInitObj = {
|
||||||
sdkver: await examJudgeVersion(),
|
sdkver: await examJudgeVersion(),
|
||||||
appver: AppStorage.get<BaseInfoType>('baseInfo')?.version || "",
|
appver: AppStorage.get<BaseInfoType>('baseInfo')?.version || "",
|
||||||
|
|||||||
@ -274,6 +274,7 @@ struct UserInfoPage {
|
|||||||
res.id = index.toString()
|
res.id = index.toString()
|
||||||
})
|
})
|
||||||
await SqlInsertTable("USERLIST", this.list || [])
|
await SqlInsertTable("USERLIST", this.list || [])
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
await this.getExaminationStudentInfoFn()
|
await this.getExaminationStudentInfoFn()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ class logWorker {
|
|||||||
public currentExamCatalog: string = ""
|
public currentExamCatalog: string = ""
|
||||||
private workerInstance: worker.ThreadWorker | null = null;
|
private workerInstance: worker.ThreadWorker | null = null;
|
||||||
// 是否开启日志 1开启
|
// 是否开启日志 1开启
|
||||||
private isLogEnabled: string = "0";
|
private isLogEnabled: string = "1";
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
if (logWorker.instance) {
|
if (logWorker.instance) {
|
||||||
|
|||||||
@ -145,7 +145,7 @@ type RequestResult = Object | object | string | CenterCodeResult
|
|||||||
|
|
||||||
export default function Request<T extends RequestResult>(options: RequestOption): Promise<T> {
|
export default function Request<T extends RequestResult>(options: RequestOption): Promise<T> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const base: string = AppStorage.get<string>("host") || "http://127.0.0.1"
|
const base: string = options.host ? options.host : AppStorage.get<string>("host") || "http://127.0.0.1"
|
||||||
const instance = http.createHttp()
|
const instance = http.createHttp()
|
||||||
const baseURL = options.host || base
|
const baseURL = options.host || base
|
||||||
console.log(RequestTag, "基础url:", baseURL)
|
console.log(RequestTag, "基础url:", baseURL)
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
//差分信号
|
//差分信号
|
||||||
import { TCPTag } from '../../config';
|
import { TCPTag } from '../../config';
|
||||||
import { EnvironmentConfigurationType } from '../../model';
|
import { EnvironmentConfigurationType } from '../../model';
|
||||||
|
import { dConsole } from '../LogWorker';
|
||||||
import TcpClient from '../TcpUtils';
|
import TcpClient from '../TcpUtils';
|
||||||
|
|
||||||
class differentialSignal {
|
class differentialSignal {
|
||||||
@ -16,7 +17,7 @@ class differentialSignal {
|
|||||||
console.error(TCPTag, "TCP发生错误")
|
console.error(TCPTag, "TCP发生错误")
|
||||||
this.differentialSignalTcp.reBind()
|
this.differentialSignalTcp.reBind()
|
||||||
})
|
})
|
||||||
console.log(TCPTag, "初始化", JSON.stringify(config))
|
dConsole.low(TCPTag, "初始化", JSON.stringify(config))
|
||||||
if (config.tcplocalIp || config.tcplocalIpPort || config.tcpOppositeIp || config.tcpOppositePort) {
|
if (config.tcplocalIp || config.tcplocalIpPort || config.tcpOppositeIp || config.tcpOppositePort) {
|
||||||
this.differentialSignalTcp.init(config.tcplocalIp || "", config.tcplocalIpPort || "", config.tcpOppositeIp || "",
|
this.differentialSignalTcp.init(config.tcplocalIp || "", config.tcplocalIpPort || "", config.tcpOppositeIp || "",
|
||||||
config.tcpOppositePort || "");
|
config.tcpOppositePort || "");
|
||||||
@ -30,7 +31,7 @@ class differentialSignal {
|
|||||||
// 组装消息,一秒发送五次
|
// 组装消息,一秒发送五次
|
||||||
let data = "1";
|
let data = "1";
|
||||||
this.timer = setInterval(() => {
|
this.timer = setInterval(() => {
|
||||||
console.log(TCPTag, "发送给中心消息")
|
dConsole.low(TCPTag, "发送给中心消息")
|
||||||
this.differentialSignalTcp.sendMsg(data);
|
this.differentialSignalTcp.sendMsg(data);
|
||||||
}, 200);
|
}, 200);
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ class differentialSignal {
|
|||||||
// 获取消息
|
// 获取消息
|
||||||
getData(callback: (data: ArrayBuffer) => void) {
|
getData(callback: (data: ArrayBuffer) => void) {
|
||||||
this.differentialSignalTcp.onMsg((data: ArrayBuffer) => {
|
this.differentialSignalTcp.onMsg((data: ArrayBuffer) => {
|
||||||
// console.log(TCPTag, "获取TCP消息", data);
|
dConsole.low(TCPTag, "获取TCP消息", data);
|
||||||
callback(data);
|
callback(data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user