Compare commits

..

5 Commits

Author SHA1 Message Date
wangzhongjie
98e17164e1 fix: 考试结束 2025-10-15 10:31:18 +08:00
wangzhongjie
0040466703 fix: 参数问题 2025-10-14 17:04:54 +08:00
wangzhongjie
dcb826724e fix: 合并 2025-10-14 16:57:37 +08:00
wangzhongjie
d46a53f37e fix: 过程任务队列 2025-10-14 16:55:14 +08:00
wangzhongjie
e75a2c076f fix: 过程任务队列 2025-10-14 16:52:29 +08:00
21 changed files with 244 additions and 190 deletions

View File

@ -1,5 +1,5 @@
{
"lockfileVersion": 1,
"lockfileVersion": 2,
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
"specifiers": {},
"packages": {}

View File

@ -81,3 +81,9 @@ export const LogTag = '[LogWorker]';
// 开始考试,结束考试标志
export const StartEndExamTag = '[StartEndExam]';
// Queue
export const QueueTag = '[Queue]'
// 考试过程数据
export const ExamProcessDataTag = '[ExamProcessData]';

View File

@ -16,7 +16,7 @@ export const JudgeConfig: JudgeConfigType = {
//是否开启拍照
isPhotoOpen: true,
//扣分语音是否强制开启
kfVoiceOpen: true,
kfVoiceOpen: false,
//忽略的考试项目
ignoreProjects: [],
// 是否忽略考试前熄火、车门检查

View File

@ -433,6 +433,8 @@ export interface MAPPOINT {
f_gps_e: number,
f_gps_n: number,
passed: number
X_MCH: string,
}
export interface MAPITEMPOINTITEM {
@ -558,6 +560,7 @@ export interface CAR_INFO {
FLAG: string,
BK1: string,
BK2: string
X_MCH: string,
}
export interface KmItem {
@ -815,7 +818,7 @@ export interface DistanceClass {
export interface WR {
message?: string
code?: number
code: string
keystr?: string
}

View File

@ -0,0 +1,38 @@
/**
* 定义批次进度更新时的回调函数类型
* @param totalTasks 本批次总任务数
* @param completedTasks 已完成任务数 (成功 + 失败)
* @param successfulTasks 成功完成的任务数
* @param failedTasks 失败的任务数
* @param progressPercentage 当前进度百分比 (0-100)
*/
import { RegulatoryInterfaceParams, WR } from '.';
export type OnBatchProgressUpdateCallback = (
totalTasks: number,
completedTasks: number,
successfulTasks: number,
failedTasks: number,
progressPercentage: number
) => void;
/**
* 定义所有任务完成时的回调函数类型
* @param totalTasks 本批次总任务数
* @param completedTasks 已完成任务数 (成功 + 失败)
* @param successfulTasks 成功完成的任务数
* @param failedTasks 失败的任务数
*/
export type OnAllTasksCompletedCallback = (
totalTasks: number,
completedTasks: number,
successfulTasks: number,
failedTasks: number
) => void;
export type ProgressCallback = (data: WR) => void;
export interface QueueTask {
data: RegulatoryInterfaceParams;
callback?: ProgressCallback;
}

View File

@ -248,6 +248,7 @@ export interface ObtainCarExamInfoParams {
//监管接口参数
export interface RegulatoryInterfaceParams {
JGHOST?: string
xtlb?: string;
jkxlh?: string;
jkid?: string;

View File

@ -20,4 +20,6 @@ export * from "./TableColumn"
export * from "./Other"
export * from "./Worker"
export * from "./Worker"
export * from "./ProcessData"

View File

@ -23,7 +23,6 @@ import {
LANE,
MA_CDSBINFOType,
MA_ITEMINFOType,
MA_SYSTEMPARMType,
MAPITEMPOINTITEM,
MAPPOINT,
MarkRule,
@ -162,6 +161,7 @@ export struct JudgePage {
customStyle: true
})
// private judge: Judge = new Judge(this)
private judgeBusiness = new JudgeBusiness(this)
// 结束考试弹窗
endExamDialogController: CustomDialogController = new CustomDialogController({
builder: ConfirmDialog({
@ -194,10 +194,9 @@ export struct JudgePage {
}),
customStyle: true
})
private judgeBusiness = new JudgeBusiness(this)
laneSignalChange() {
dConsole.log("车道信号变化1", this.laneSignal)
// dConsole.log("车道信号变化1", this.laneSignal)
}
async aboutToDisappear() {
@ -261,6 +260,7 @@ export struct JudgePage {
FLAG: carInfo.flag!,
BK1: carInfo.bk1!,
BK2: carInfo.bk2!,
X_MCH: carInfo.x_mch || "",
})
dConsole.info(JudgeTag, 'surenjun =>carinfoArrr', JSON.stringify(this.carinfoArr))
}

View File

@ -1,5 +1,4 @@
import {
CarInfoType,
JudgeBeginObj,
JudgeCallBackData,
JudgeConfigObj,
@ -12,13 +11,14 @@ import {
ProjectInfo,
ProjectInfos,
SYSTEM_PARAM,
User
User,
WR
} from '../../model'
import JudgeBusiness from './JudgeBusiness'
import { JudgePage } from '../Judge'
import VoiceAnnounce from '../judgeSDK/utils/voiceAnnouncements'
import { dConsole } from '../../utils/LogWorker'
import { JudgeConfig, JudgeTag } from '../../config'
import { ExamProcessDataTag, JudgeConfig, JudgeTag, QueueTag } from '../../config'
import {
examJudgeArtificialItem,
examJudgeBeginExam,
@ -29,7 +29,7 @@ import {
examJudgeSetRealExamCallback,
examJudgeSoundEnd
} from './JudgeSDKUtils'
import { ProjectStart, UploadProgressPhoto } from './ProcessDataProcessing'
import { DeductPoints, ProjectEnd, ProjectStart, TheExamIsOver, UploadProgressPhoto } from './ProcessDataProcessing'
import { endRecordVideo, saveStartRecordVideo } from '../../utils/Video'
import router from '@ohos.router'
import { GetSyncData, UpdateTableByArray } from '../../utils/table/Operation'
@ -110,19 +110,31 @@ export class BaseJudge {
}
}, 200)
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)
UploadProgressPhoto(xmdm, that.plcData!, judgeUI)
}
break;
}
case 2: {
dConsole.log(JudgeTag, "项目结束判定1")
dConsole.log(JudgeTag, ExamProcessDataTag, "项目结束判定1")
const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm)
const isStart = await this.checkProjectIsStart(xmdm, 2, judgeUI, that)
if (isStart) {
// 项目结束了就不再生成数据
dConsole.info(JudgeTag + ' projectIsEnd =>', project.isEnd)
dConsole.info(JudgeTag, ExamProcessDataTag, ' 项目是否结束 =>', project.isEnd)
if (!project.isEnd) {
// judgeTask.addTask(async () => {
// dConsole.info(JudgeTag, `项目结束-${xmdm}-${project.name}`)
@ -132,9 +144,10 @@ export class BaseJudge {
// }, {
// isDelay: true
// })
ProjectEnd(xmdm, that.xmxh, judgeUI)
}
}
dConsole.log(JudgeTag, "项目结束判定3")
dConsole.log(JudgeTag, ExamProcessDataTag, "项目结束判定3")
try {
const param512: JudgeConfigObj = (Reflect.get(judgeUI.judgeConfigObj, '512') || '').split(',');
if (!judgeUI.isProjectIn) {
@ -164,16 +177,24 @@ export class BaseJudge {
// }, {
// isDelay: true
// })
DeductPoints(Number(currentKf.xmdm), currentKf, that.xmmcEndCode || "", judgeUI)
}
break
}
case 5: {
dConsole.log(JudgeTag, "考试结束")
dConsole.log(JudgeTag, QueueTag, "考试结束")
const singlePlay = AppStorage.get<boolean>('singlePlay')
// 关闭录像
if (!singlePlay && that.videoData) {
await endRecordVideo(that.videoData)
}
// TODO
// ProcessDataTaskPoolInstance.setOnAllTasksCompletedCallback((data) => {
// if (event === 5) {
// dConsole.log(JudgeTag, QueueTag, "这才是考试结束判定")
// }
// dConsole.log(JudgeTag, QueueTag, "考试结束判断", data)
// })
// judgeTask.addTask(async () => {
// dConsole.info(JudgeTag, '考试结束 start')
// AppStorage.setOrCreate('isJudge', false)
@ -356,51 +377,36 @@ export class BaseJudge {
} catch (e) {
console.info(JudgeTag, JSON.stringify(e))
}
TheExamIsOver(judgeUI, that, async (res: WR) => {
dConsole.log(JudgeTag, ExamProcessDataTag, "考试结束接口完成", res)
const code = res.code!.toString()
if (code !== "1") {
that?.avPlayer?.playAudio(['voice/监管失败.mp3'])
judgeUI.errorMsg = decodeURIComponent(res?.message || "")
if (code.toString() === "2300028" || code.toString() === "2300007") {
judgeUI.errorMsg = '当前的考试过程信息监管审核未通过,程序将退出!'
}
judgeUI.generateExamRecordsDialogController.close();
return
} else {
await this.endExam(judgeUI, that)
}
})
await this.endExam(judgeUI, that)
})
}
// 考试结束 Todo
async endExam(judgeUI: JudgePage, that: JudgeBusiness) {
const carInfo: CarInfoType = AppStorage.get("carInfo")!
const singlePlay = judgeUI.singlePlay
//TODO 断网考试结束补传
// await uploadDisConnectData();
// const time = GetCurrentTime();
// const photoBase64 = await getPhoto();
// const {d1,d2,d3,d4,d5} = that.ksjs
// const data = {
// xtlb: '17', jkxlh: serialNumber, jkid: '17C56',
// drvexam: {
// lsh,
// kchp: encodeURI(plateNo),
// kskm: examSubject,
// sfzmhm: idCard,
// //@ts-ignore
// zp: photoBase64,
// jssj: time,
// kscj: (totalScore * 1) > 0 ? totalScore : 0,
// kslc: Math.ceil(((ksjs?.qjjl + ksjs?.dcjl) || 0) / 100),
// // 1,22;2,560;3,128;4,0;5,0;
// dwlc: [d1, d2, d3, d4, d5].map((d, index) => `${index + 1},${Math.floor(d / 100)}`).join(';'),
// }
// }
let backTimeOut = setTimeout(() => {
router.back()
}, 90 * 1000)
// const {code,keystr,message} = await this.sendWriteObjectOut(data, filePath);
// promptWxCode('17C56', code)
// if (code != 1) {
// that.avPlayer.playAudio(['voice/监管失败.mp3'])
// judgeUI.errorMsg = decodeURIComponent(message)
//
// if (code == 2300028 || code == 2300007) {
// judgeUI.errorMsg = '当前的考试过程信息监管审核未通过,程序将退出!'
// }
// judgeUI.generateExamRecordsDialogController.close();
// return
// }
console.info(JudgeTag, '考试结束 end')
const param302 = judgeUI.judgeConfigObj.param_302;
let currentKssycs = 0;
@ -451,7 +457,6 @@ export class BaseJudge {
case 'voice/exam_pass.mp3':
currentKssycs = 0;
break;
}
}
@ -514,7 +519,7 @@ export class BaseJudge {
}
const currentProject: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm)
if (currentProject.isUpload) {
if (!currentProject.isUpload) {
dConsole.info(JudgeTag, '项目补传开始')
// judgeTask.addTask(async () => {
// await this.beginProject(xmdm)
@ -570,7 +575,7 @@ export class BaseJudge {
}
//日志回调
dConsole.info(JudgeTag, '1.进入评判入口')
await examJudgeSetLogCallback(6, async (level: number, info: string, len: number) => {
await examJudgeSetLogCallback(1, async (level: number, info: string, len: number) => {
dConsole.log(JudgeTag, '评判日志:' + info)
dConsole.writeProcessData(ProcessDataEnumType.JudgeLogData, info)
})
@ -593,7 +598,7 @@ export class BaseJudge {
await this.judging(strData, callBack, judgeUI, that)
})
await examJudgeSetPerformCallback(async (info: string) => {
dConsole.info('评判实时数据', info)
// dConsole.info('评判实时数据', info)
that.performInfo = JSON.parse(info)
const jl = Math.floor((that.performInfo!.qjjl + that.performInfo!.dcjl) / 100);
if (jl > Number(judgeUI.examMileage)) {
@ -735,9 +740,6 @@ export class BaseJudge {
case 5: {
dConsole.info(JudgeTag, "考试结束")
that.ksjs = ksjs;
// await fileLog?.setExamJudgeData(JSON.stringify({
// method: 'examJudgeEndExam'
// }))
dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, JSON.stringify({
method: 'examJudgeEndExam'
}))

View File

@ -1,15 +1,15 @@
/**
* 过程数据处理
*/
import { ProcessDataTag } from '../../config';
import { ExamProcessDataTag, ProcessDataTag, QueueTag } from '../../config';
import {
CarInfoType,
CDSBInfo,
CDSBInfos,
DrvexamType,
JudgeUI,
MarkRule,
PLCType,
ProgressCallback,
ProjectInfo,
RegulatoryInterfaceParams
} from '../../model';
@ -17,6 +17,7 @@ import { GetPhotoBase64 } from '../../utils/Common';
import dayTs from '../../utils/Date';
import { dConsole } from '../../utils/LogWorker';
import { JudgePage } from '../Judge';
import JudgeBusiness from './JudgeBusiness';
import { ProcessDataTaskPoolInstance } from './ProcessDataTaskPool';
/**
@ -39,13 +40,14 @@ export const ProjectStart = (ksxm: number, xmxh: string, judgeUI: JudgePage) =>
kssj: dayTs().format("YYYY-MM-DD HH:mm:ss")
}
const data: RegulatoryInterfaceParams = {
JGHOST: AppStorage.get<string>("JGHOST") || "",
//系统类别 接口序列号 接口标识
xtlb: '17',
jkxlh: judgeUI.serialNumber,
jkid: '17C52',
drvexam
}
dConsole.log(ProcessDataTag, "项目开始数据处理", data)
dConsole.log(ProcessDataTag, QueueTag, ExamProcessDataTag, "项目开始数据处理", data)
ProcessDataTaskPoolInstance.addTask(data)
}
@ -69,12 +71,13 @@ export const UploadProgressPhoto = async (ksxm: number, plcData: PLCType, judgeU
ksdd: encodeURI(judgeUI.ksdd)
}
const data: RegulatoryInterfaceParams = {
JGHOST: AppStorage.get<string>("JGHOST") || "",
xtlb: '17',
jkxlh: judgeUI.serialNumber,
jkid: '17C54',
drvexam
};
dConsole.log(ProcessDataTag, "上传过程照片数据处理", data);
dConsole.log(ProcessDataTag, QueueTag, ExamProcessDataTag, "上传过程照片数据处理", data);
ProcessDataTaskPoolInstance.addTask(data)
}
@ -131,12 +134,13 @@ export const DeductPoints = (ksxm: number, kf: MarkRule, xmmcEndCode: string, ju
kfsj: dayTs().format("YYYY-MM-DD HH:mm:ss"),
}
const data: RegulatoryInterfaceParams = {
JGHOST: AppStorage.get<string>("JGHOST") || "",
xtlb: '17',
jkxlh: serialNumber,
jkid: '17C53',
drvexam
}
dConsole.log(ProcessDataTag, "扣分上传数据", data)
dConsole.log(ProcessDataTag, QueueTag, ExamProcessDataTag, "扣分上传数据", data)
ProcessDataTaskPoolInstance.addTask(data)
}
@ -163,14 +167,45 @@ export const ProjectEnd = (ksxm: number, xmxh: string, judgeUI: JudgePage) => {
}
const data: RegulatoryInterfaceParams = {
xtlb: '17',
JGHOST: AppStorage.get<string>("JGHOST") || "",
jkxlh: judgeUI.serialNumber,
jkid: '17C55',
drvexam
}
dConsole.log(ProcessDataTag, "结束项目数据", data)
dConsole.log(ProcessDataTag, QueueTag, ExamProcessDataTag, "结束项目数据", data)
ProcessDataTaskPoolInstance.addTask(data)
}
/**
* 考试结束接口
* @returns
*/
export const TheExamIsOver = async (judgeUI: JudgePage, that: JudgeBusiness, callback: ProgressCallback) => {
const carInfo: CarInfoType = AppStorage.get("carInfo")!
const photoBase64 = await GetPhotoBase64(judgeUI.context);
const ksjs = that.ksjs!
const data: RegulatoryInterfaceParams = {
JGHOST: AppStorage.get<string>("JGHOST") || "",
xtlb: '17',
jkxlh: judgeUI.serialNumber,
jkid: '17C56',
drvexam: {
lsh: judgeUI.lsh,
kchp: encodeURI(carInfo?.plateNo || ""),
kskm: carInfo?.examSubject || "2",
sfzmhm: judgeUI.idCard,
zp: photoBase64,
jssj: dayTs().format("YYYY-MM-DD HH:mm:ss"),
kscj: (judgeUI.totalScore * 1) > 0 ? judgeUI.totalScore : 0,
kslc: Math.ceil(((ksjs?.qjjl! + ksjs?.dcjl!) || 0) / 100),
dwlc: [ksjs.d1, ksjs.d2, ksjs.d3, ksjs.d4, ksjs!.d5].map((d, index) => `${index + 1},${Math.floor(d / 100)}`)
.join(';'),
}
}
dConsole.log(ProcessDataTag, QueueTag, ExamProcessDataTag, "考试结束数据", data)
ProcessDataTaskPoolInstance.addTask(data, callback)
}
const getSBXH = (ksxm: number, xmxh: string, cdsbInfoObj: CDSBInfos, projectsObj: object, examSubject: string): string => {
const project: ProjectInfo = Reflect.get(projectsObj, ksxm);

View File

@ -1,42 +1,22 @@
import { ProcessDataEnumType, RegulatoryInterfaceParams, WR, WuxiExamType } from '../../model';
import {
OnAllTasksCompletedCallback,
OnBatchProgressUpdateCallback,
ProcessDataEnumType,
ProgressCallback,
QueueTask,
RegulatoryInterfaceParams,
WR,
WuxiExamType
} from '../../model';
import taskpool from '@ohos.taskpool';
import { dConsole } from '../../utils/LogWorker';
import { QueueTag } from '../../config';
import http from '@ohos.net.http';
import Request from '../../utils/Request';
/**
* 定义批次进度更新时的回调函数类型
* @param totalTasks 本批次总任务数
* @param completedTasks 已完成任务数 (成功 + 失败)
* @param successfulTasks 成功完成的任务数
* @param failedTasks 失败的任务数
* @param progressPercentage 当前进度百分比 (0-100)
*/
export type OnBatchProgressUpdateCallback = (
totalTasks: number,
completedTasks: number,
successfulTasks: number,
failedTasks: number,
progressPercentage: number
) => void;
/**
* 定义所有任务完成时的回调函数类型
* @param totalTasks 本批次总任务数
* @param completedTasks 已完成任务数 (成功 + 失败)
* @param successfulTasks 成功完成的任务数
* @param failedTasks 失败的任务数
*/
export type OnAllTasksCompletedCallback = (
totalTasks: number,
completedTasks: number,
successfulTasks: number,
failedTasks: number
) => void;
import { dConsole } from '../../utils/LogWorker';
export class ProcessDataTaskPool {
private queue: RegulatoryInterfaceParams[] = [];
private queue: QueueTask[] = [];
private isProcessing: boolean = false;
/** 最大重试次数。1次初次尝试 + 5次重试 = 总共6次尝试。 */
private readonly maxRetries = 5;
@ -77,9 +57,9 @@ export class ProcessDataTaskPool {
* 进而影响 `onAllTasksCompletedCallback` 的触发时机和进度计算。
* @param dataItem 任务数据
*/
public addTask(dataItem: RegulatoryInterfaceParams): void {
console.info(`[Queue] 新任务已添加: ${JSON.stringify(dataItem)},当前队列长度: ${this.queue.length + 1}`);
this.queue.push(dataItem); // 将任务添加到队尾
public addTask(dataItem: RegulatoryInterfaceParams, callback?: ProgressCallback): void {
console.info(QueueTag, `新任务已添加: ${JSON.stringify(dataItem)},当前队列长度: ${this.queue.length + 1}`);
this.queue.push({ data: dataItem, callback: callback }); // 将任务添加到队尾
// 每次添加任务,增加当前批次的总任务数
this.totalTasksInCurrentBatch++;
@ -92,7 +72,7 @@ export class ProcessDataTaskPool {
*/
private triggerProcessing(): void {
if (this.isProcessing) {
console.log('[Queue] 处理器正在运行中,新任务将在稍后被处理。');
console.log(QueueTag, '处理器正在运行中,新任务将在稍后被处理。');
return;
}
this.processQueue();
@ -100,14 +80,16 @@ export class ProcessDataTaskPool {
private async processQueue(): Promise<void> {
this.isProcessing = true;
console.log(`[Queue] 启动处理器... 待处理任务数: ${this.queue.length}`);
console.log(QueueTag, `启动处理器... 待处理任务数: ${this.queue.length}`);
while (this.queue.length > 0) {
const taskData = this.queue[0]; // 查看队首任务
const taskData = this.queue[0].data; // 查看队首任务
const callback = this.queue[0].callback || (() => {
});
this.taskStartTime = Date.now(); // 记录任务开始时间
try {
console.log(`[Queue] 开始处理任务: ${JSON.stringify(taskData)}`);
console.log(QueueTag, `开始处理任务: ${JSON.stringify(taskData)}`);
const obj: WuxiExamType = {
xtlb: taskData.xtlb,
@ -119,15 +101,15 @@ export class ProcessDataTaskPool {
};
dConsole.writeProcessData(ProcessDataEnumType.WuxiExam, JSON.stringify(obj));
await this.processSingleTaskWithRetries(taskData);
await this.processSingleTaskWithRetries(taskData, callback);
// 任务成功
this.queue.shift();
console.log(`[Queue] ✅ 任务处理成功,已从队列移除。剩余任务: ${this.queue.length}`);
console.log(QueueTag, `✅ 任务处理成功,已从队列移除。剩余任务: ${this.queue.length}`);
this.successfulTasksInCurrentBatch++; // 增加成功任务计数
} catch (error) {
// 任务永久失败
console.error(`[Queue] 🔥 任务永久失败: ${(error as Error).message}`);
console.error(QueueTag, ` 🔥 任务永久失败: ${(error as Error).message}`);
const failedTask = this.queue.shift(); // 移除失败的任务
console.error(`[Queue] 失败的任务已被移除: ${JSON.stringify(failedTask)},将继续处理下一个任务。`);
this.failedTasksInCurrentBatch++; // 增加失败任务计数
@ -140,7 +122,7 @@ export class ProcessDataTaskPool {
// 检查是否所有任务都已处理完
if (this.queue.length === 0 && this.completedTasksInCurrentBatch === this.totalTasksInCurrentBatch) {
console.log('[Queue] 所有任务处理完毕!');
console.log(QueueTag, ' 所有任务处理完毕!"总数', this.totalTasksInCurrentBatch, "完成的");
this.onAllTasksCompletedCallback?.(
this.totalTasksInCurrentBatch,
this.completedTasksInCurrentBatch,
@ -155,14 +137,14 @@ export class ProcessDataTaskPool {
const elapsedTime = Date.now() - this.taskStartTime;
if (elapsedTime < this.minProcessingTime) {
const delayTime = this.minProcessingTime - elapsedTime;
console.log(`[Queue] 任务处理耗时 ${elapsedTime}ms需要延迟 ${delayTime}ms 以满足最小处理时间要求`);
console.log(QueueTag, ` 任务处理耗时 ${elapsedTime}ms需要延迟 ${delayTime}ms 以满足最小处理时间要求`);
await this.delay(delayTime);
}
}
}
this.isProcessing = false;
console.log('[Queue] 处理器已停止。');
console.log(QueueTag, ' 处理器已停止。');
}
/**
@ -199,23 +181,22 @@ export class ProcessDataTaskPool {
return new Promise(resolve => setTimeout(resolve, ms));
}
private async processSingleTaskWithRetries(taskData: RegulatoryInterfaceParams): Promise<void> {
private async processSingleTaskWithRetries(taskData: RegulatoryInterfaceParams, callback: ProgressCallback): Promise<void> {
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
const attemptNum = attempt + 1;
try {
const attemptType = attempt === 0 ? '初次尝试' : `重试 ${attempt}`;
console.log(`[Queue] 开始上传 (${attemptType}, 总共第 ${attemptNum} 次)`);
console.log(QueueTag, `开始上传 (${attemptType}, 总共第 ${attemptNum} 次)`);
const result: WR = (await taskpool.execute(uploadWorkerTask, taskData)) as WR;
callback(result)
dConsole.writeProcessData(ProcessDataEnumType.WuxiExam, JSON.stringify(result));
if (result.code === 1) {
console.log(`[Queue] ✔️ 上传成功 (在第 ${attemptNum} 次尝试)`);
if (result.code === "1") {
console.log(QueueTag, ` ✔️ 上传成功 (在第 ${attemptNum} 次尝试)`);
return; // 成功,立即返回
}
console.warn(`[Queue] ❌ 上传失败 (第 ${attemptNum} 次)。响应: ${result.message}`);
console.warn(QueueTag, ` ❌ 上传失败 (第 ${attemptNum} 次)。${result.code},响应: ${decodeURIComponent(result.message)}`);
} catch (e) {
console.error(`[Queue] ❌ TaskPool 执行或网络错误 (第 ${attemptNum} 次): ${e}`);
console.error(QueueTag, ` ❌ TaskPool 执行或网络错误 (第 ${attemptNum} 次): ${e}`);
}
if (attempt === this.maxRetries) {
@ -229,40 +210,39 @@ export class ProcessDataTaskPool {
export const ProcessDataTaskPoolInstance = new ProcessDataTaskPool();
@Concurrent
export async function uploadWorkerTask(data: RegulatoryInterfaceParams): Promise<WR> {
let singlePlay: boolean = false;
let isJGNew = false;
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
}) as WR
}
const response = await sendProcessData(data, singlePlay, isJGNew);
return response;
} catch (err) {
const error = err as Error;
console.error(`[Worker] 上传时发生异常: ${error.message}`);
console.error(QueueTag, `[Worker] 上传时发生异常: ${error.message}`);
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
})
}

View File

@ -15,43 +15,25 @@ import {
MAPITEMPOINTITEM,
MAPPOINT,
MarkRule,
ProcessDataEnumType,
Project,
ProjectInfo,
ProjectInfos,
RouteParamsType,
SyssetConfig,
SYSTEM_PARAM,
Project,
ProjectInfos,
JudgeCallBackData,
KmItem
SYSTEM_PARAM
} from '../../model';
import common from '@ohos.app.ability.common';
import { dConsole } from '../../utils/LogWorker';
import {
examJudgeBeginExam,
examJudgeEndExam,
examJudgeInit,
examJudgeSetLogCallback,
examJudgeSetPerformCallback,
examJudgeSetRealExamCallback,
examJudgeVersion
} from './JudgeSDKUtils';
import { examJudgeVersion } from './JudgeSDKUtils';
import JudgeBusiness from './JudgeBusiness';
import { saveStartRecordVideo } from '../../utils/Video';
import router from '@ohos.router';
import {
CurrentProjectConversion,
DeductionProjectConversion,
DetectingDifferences,
GetCarStatus,
GetModelData
} from './utils';
import { GetModelData } from './utils';
import { BaseJudge, BaseJudgeImpl, GetSysSetResult } from './BaseJudgeBussines';
import { GetSyncData } from '../../utils/table/Operation';
import promptAction from '@ohos.promptAction';
import { JudgePage } from '../Judge';
import systemDateTime from '@ohos.systemDateTime';
import { testKm2Items, testKm3Items } from "../../mock/Judge"
import { testKm2Items, testKm3Items } from '../../mock/Judge';
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) {
@ -133,10 +115,11 @@ export class SmallJudge extends BaseJudge implements BaseJudgeImpl {
}
//获取版本号
const mark: MarkRule[] = Reflect.ownKeys(markRuleListObj).map(ruleKey => {
const current: MarkRule = Reflect.get(markRuleListObj, ruleKey)
return current
})
// const mark: MarkRule[] = Reflect.ownKeys(markRuleListObj).map(ruleKey => {
// const current: MarkRule = Reflect.get(markRuleListObj, ruleKey)
// return current
// })
const mark: MarkRule[] = Object.values(markRuleListObj)
const initInfo: JudgeInitObj = {
sdkver: await examJudgeVersion(),
appver: AppStorage.get<BaseInfoType>('baseInfo')?.version || "",

View File

@ -274,6 +274,7 @@ struct UserInfoPage {
res.id = index.toString()
})
await SqlInsertTable("USERLIST", this.list || [])
} else {
await this.getExaminationStudentInfoFn()
}

View File

@ -13,7 +13,7 @@ class logWorker {
public currentExamCatalog: string = ""
private workerInstance: worker.ThreadWorker | null = null;
// 是否开启日志 1开启
private isLogEnabled: string = "0";
private isLogEnabled: string = "1";
constructor() {
if (logWorker.instance) {

View File

@ -145,7 +145,7 @@ type RequestResult = Object | object | string | CenterCodeResult
export default function Request<T extends RequestResult>(options: RequestOption): Promise<T> {
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 baseURL = options.host || base
console.log(RequestTag, "基础url:", baseURL)

View File

@ -144,7 +144,7 @@ export default class UdpClient {
private bindEvent() {
this.udp?.on("message", value => {
let result = this.dealMethod?.(value.message)
console.log(UDPTag, "udp获取消息", result)
// console.log(UDPTag, "udp获取消息", result)
this.messageEvents.forEach(cb => {
cb(result)
})

View File

@ -72,8 +72,8 @@ class differentialAndSignal {
getMessage() {
this.workerInstance.onmessage = (e: MessageEvents): void => {
if (e.data) {
console.log(WorkerTag, "Worker 收到消息: " + e.data);
console.log(WorkerTag, "Worker 目前监听数量: " + this.events.length.toString());
// console.log(WorkerTag, "Worker 收到消息: " + e.data);
// console.log(WorkerTag, "Worker 目前监听数量: " + this.events.length.toString());
this.events.forEach((callback) => {
callback(e.data);
});

View File

@ -1,6 +1,7 @@
//差分信号
import { TCPTag } from '../../config';
import { EnvironmentConfigurationType } from '../../model';
import { dConsole } from '../LogWorker';
import TcpClient from '../TcpUtils';
class differentialSignal {
@ -16,7 +17,7 @@ class differentialSignal {
console.error(TCPTag, "TCP发生错误")
this.differentialSignalTcp.reBind()
})
console.log(TCPTag, "初始化", JSON.stringify(config))
dConsole.low(TCPTag, "初始化", JSON.stringify(config))
if (config.tcplocalIp || config.tcplocalIpPort || config.tcpOppositeIp || config.tcpOppositePort) {
this.differentialSignalTcp.init(config.tcplocalIp || "", config.tcplocalIpPort || "", config.tcpOppositeIp || "",
config.tcpOppositePort || "");
@ -30,7 +31,7 @@ class differentialSignal {
// 组装消息,一秒发送五次
let data = "1";
this.timer = setInterval(() => {
console.log(TCPTag, "发送给中心消息")
// dConsole.low(TCPTag, "发送给中心消息")
this.differentialSignalTcp.sendMsg(data);
}, 200);
@ -39,7 +40,7 @@ class differentialSignal {
// 获取消息
getData(callback: (data: ArrayBuffer) => void) {
this.differentialSignalTcp.onMsg((data: ArrayBuffer) => {
// console.log(TCPTag, "获取TCP消息", data);
// dConsole.low(TCPTag, "获取TCP消息", data);
callback(data);
});
}

View File

@ -1,6 +1,6 @@
// 处理worker线程的消息tcp拿差分改正数,udp给后置机
import worker, { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope } from '@ohos.worker';
import { SerialPortTag, WorkerTag } from '../config';
import { WorkerTag } from '../config';
import {
CenterCallBackMsgType,
EnvironmentConfigurationType,
@ -68,17 +68,17 @@ function getDataFn(config: EnvironmentConfigurationType) {
if (data !== "" && config.carType !== "2") {
// TODO
// 需要观察
console.log(WorkerTag, "后置机消息", data)
// console.log(WorkerTag, "后置机消息", data)
const res = await SerialPortService.getData()
console.log(SerialPortTag, "档位原始数据", res)
// console.log(SerialPortTag, "档位原始数据", res)
if (res.length > 0) {
const dataArray = data.split(",");
// 替换data的第28位
dataArray[28] = res[9].toString();
data = dataArray.join(",");
console.log(SerialPortTag, "档位", res[9].toString())
// console.log(SerialPortTag, "档位", res[9].toString())
}
console.log(SerialPortTag, "处理完的档位信号", data)
// console.log(SerialPortTag, "处理完的档位信号", data)
workerPort.postMessage(
JSON.stringify({
type: WorkerBackMessageType.ObtainUdpData,

View File

@ -13,7 +13,7 @@ let fileFdArr: number[] = []
let writeQueue: Array<FileQueueType> = [];
let isProcessing = false;
workerPort.onmessage = (e: MessageEvents) => {
console.log(LogTag, "日志系统worker收到消息")
// console.log(LogTag, "日志系统worker收到消息")
// 日志文件目录
let logPaths: LogPathType = {
log: `${GlobalConfig.commonFileWriteAddress}/logs/${dayTs().format("YYYY_MM_DD")}/log/log.log`,

View File

@ -1,18 +1,20 @@
{
"lockfileVersion": 1,
"lockfileVersion": 2,
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
"specifiers": {
"@ohos/crypto-js@2.0.3": "@ohos/crypto-js@2.0.3",
"@ohos/hypium@1.0.19": "@ohos/hypium@1.0.19"
"@ohos/hypium@1.0.19": "@ohos/hypium@1.0.19",
"@ohos/crypto-js@2.0.3": "@ohos/crypto-js@2.0.3"
},
"packages": {
"@ohos/crypto-js@2.0.3": {
"resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/crypto-js/-/crypto-js-2.0.3.har",
"integrity": "sha512-LuHaR1kD5PxnOXnuR1fWvPwGtbed9Q/QGzk6JOh8y5Wdzvi8brPesODZiaWf9scOVRHsbTPOtZw91vWB35p1vQ=="
},
"@ohos/hypium@1.0.19": {
"resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.19.har",
"integrity": "sha512-cEjDgLFCm3cWZDeRXk7agBUkPqjWxUo6AQeiu0gEkb3J8ESqlduQLSIXeo3cCsm8U/asL7iKjF85ZyOuufAGSQ=="
"integrity": "sha512-cEjDgLFCm3cWZDeRXk7agBUkPqjWxUo6AQeiu0gEkb3J8ESqlduQLSIXeo3cCsm8U/asL7iKjF85ZyOuufAGSQ==",
"registryType": "ohpm"
},
"@ohos/crypto-js@2.0.3": {
"resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/crypto-js/-/crypto-js-2.0.3.har",
"integrity": "sha512-LuHaR1kD5PxnOXnuR1fWvPwGtbed9Q/QGzk6JOh8y5Wdzvi8brPesODZiaWf9scOVRHsbTPOtZw91vWB35p1vQ==",
"registryType": "ohpm"
}
}
}