fix: 考试结束
This commit is contained in:
parent
0040466703
commit
98e17164e1
@ -1,5 +1,5 @@
|
||||
{
|
||||
"lockfileVersion": 1,
|
||||
"lockfileVersion": 2,
|
||||
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
|
||||
"specifiers": {},
|
||||
"packages": {}
|
||||
|
||||
@ -84,3 +84,6 @@ export const StartEndExamTag = '[StartEndExam]';
|
||||
// Queue
|
||||
export const QueueTag = '[Queue]'
|
||||
|
||||
// 考试过程数据
|
||||
export const ExamProcessDataTag = '[ExamProcessData]';
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@ export const JudgeConfig: JudgeConfigType = {
|
||||
//是否开启拍照
|
||||
isPhotoOpen: true,
|
||||
//扣分语音是否强制开启
|
||||
kfVoiceOpen: true,
|
||||
kfVoiceOpen: false,
|
||||
//忽略的考试项目
|
||||
ignoreProjects: [],
|
||||
// 是否忽略考试前熄火、车门检查
|
||||
|
||||
@ -818,7 +818,7 @@ export interface DistanceClass {
|
||||
|
||||
export interface WR {
|
||||
message?: string
|
||||
code?: string
|
||||
code: string
|
||||
keystr?: string
|
||||
}
|
||||
|
||||
|
||||
38
entry/src/main/ets/model/ProcessData.ets
Normal file
38
entry/src/main/ets/model/ProcessData.ets
Normal 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;
|
||||
}
|
||||
@ -20,4 +20,6 @@ export * from "./TableColumn"
|
||||
|
||||
export * from "./Other"
|
||||
|
||||
export * from "./Worker"
|
||||
export * from "./Worker"
|
||||
|
||||
export * from "./ProcessData"
|
||||
@ -196,7 +196,7 @@ export struct JudgePage {
|
||||
})
|
||||
|
||||
laneSignalChange() {
|
||||
dConsole.log("车道信号变化1", this.laneSignal)
|
||||
// dConsole.log("车道信号变化1", this.laneSignal)
|
||||
}
|
||||
|
||||
async aboutToDisappear() {
|
||||
|
||||
@ -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,12 +29,11 @@ import {
|
||||
examJudgeSetRealExamCallback,
|
||||
examJudgeSoundEnd
|
||||
} from './JudgeSDKUtils'
|
||||
import { DeductPoints, ProjectEnd, 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'
|
||||
import { CurrentProjectConversion, DeductionProjectConversion, DetectingDifferences, GetCarStatus } from './utils'
|
||||
import { ProcessDataTaskPoolInstance } from './ProcessDataTaskPool'
|
||||
|
||||
|
||||
export interface GetSysSetResult {
|
||||
@ -129,13 +128,13 @@ export class BaseJudge {
|
||||
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}`)
|
||||
@ -148,7 +147,7 @@ export class BaseJudge {
|
||||
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) {
|
||||
@ -183,16 +182,19 @@ export class BaseJudge {
|
||||
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) => {
|
||||
dConsole.log(JudgeTag, "考试结束判断", data)
|
||||
})
|
||||
// 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)
|
||||
@ -375,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;
|
||||
@ -470,7 +457,6 @@ export class BaseJudge {
|
||||
case 'voice/exam_pass.mp3':
|
||||
currentKssycs = 0;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -589,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)
|
||||
})
|
||||
@ -612,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)) {
|
||||
@ -754,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'
|
||||
}))
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* 过程数据处理
|
||||
*/
|
||||
import { ProcessDataTag, QueueTag } from '../../config';
|
||||
import { ExamProcessDataTag, ProcessDataTag, QueueTag } from '../../config';
|
||||
import {
|
||||
CarInfoType,
|
||||
CDSBInfo,
|
||||
@ -9,6 +9,7 @@ import {
|
||||
DrvexamType,
|
||||
MarkRule,
|
||||
PLCType,
|
||||
ProgressCallback,
|
||||
ProjectInfo,
|
||||
RegulatoryInterfaceParams
|
||||
} from '../../model';
|
||||
@ -16,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';
|
||||
|
||||
/**
|
||||
@ -45,7 +47,7 @@ export const ProjectStart = (ksxm: number, xmxh: string, judgeUI: JudgePage) =>
|
||||
jkid: '17C52',
|
||||
drvexam
|
||||
}
|
||||
dConsole.log(ProcessDataTag, QueueTag, "项目开始数据处理", data)
|
||||
dConsole.log(ProcessDataTag, QueueTag, ExamProcessDataTag, "项目开始数据处理", data)
|
||||
ProcessDataTaskPoolInstance.addTask(data)
|
||||
}
|
||||
|
||||
@ -75,7 +77,7 @@ export const UploadProgressPhoto = async (ksxm: number, plcData: PLCType, judgeU
|
||||
jkid: '17C54',
|
||||
drvexam
|
||||
};
|
||||
dConsole.log(ProcessDataTag, QueueTag, "上传过程照片数据处理", data);
|
||||
dConsole.log(ProcessDataTag, QueueTag, ExamProcessDataTag, "上传过程照片数据处理", data);
|
||||
ProcessDataTaskPoolInstance.addTask(data)
|
||||
}
|
||||
|
||||
@ -138,7 +140,7 @@ export const DeductPoints = (ksxm: number, kf: MarkRule, xmmcEndCode: string, ju
|
||||
jkid: '17C53',
|
||||
drvexam
|
||||
}
|
||||
dConsole.log(ProcessDataTag, QueueTag, "扣分上传数据", data)
|
||||
dConsole.log(ProcessDataTag, QueueTag, ExamProcessDataTag, "扣分上传数据", data)
|
||||
ProcessDataTaskPoolInstance.addTask(data)
|
||||
}
|
||||
|
||||
@ -170,10 +172,40 @@ export const ProjectEnd = (ksxm: number, xmxh: string, judgeUI: JudgePage) => {
|
||||
jkid: '17C55',
|
||||
drvexam
|
||||
}
|
||||
dConsole.log(ProcessDataTag, QueueTag, "结束项目数据", 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);
|
||||
|
||||
@ -1,42 +1,22 @@
|
||||
import { RegulatoryInterfaceParams, WR, WuxiExamType } from '../../model';
|
||||
import {
|
||||
OnAllTasksCompletedCallback,
|
||||
OnBatchProgressUpdateCallback,
|
||||
ProcessDataEnumType,
|
||||
ProgressCallback,
|
||||
QueueTask,
|
||||
RegulatoryInterfaceParams,
|
||||
WR,
|
||||
WuxiExamType
|
||||
} from '../../model';
|
||||
import taskpool from '@ohos.taskpool';
|
||||
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 {
|
||||
public addTask(dataItem: RegulatoryInterfaceParams, callback?: ProgressCallback): void {
|
||||
console.info(QueueTag, `新任务已添加: ${JSON.stringify(dataItem)},当前队列长度: ${this.queue.length + 1}`);
|
||||
this.queue.push(dataItem); // 将任务添加到队尾
|
||||
this.queue.push({ data: dataItem, callback: callback }); // 将任务添加到队尾
|
||||
|
||||
// 每次添加任务,增加当前批次的总任务数
|
||||
this.totalTasksInCurrentBatch++;
|
||||
@ -103,7 +83,9 @@ export class ProcessDataTaskPool {
|
||||
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 {
|
||||
@ -117,9 +99,9 @@ export class ProcessDataTaskPool {
|
||||
zp: "",
|
||||
},
|
||||
};
|
||||
// dConsole.writeProcessData(ProcessDataEnumType.WuxiExam, JSON.stringify(obj));
|
||||
dConsole.writeProcessData(ProcessDataEnumType.WuxiExam, JSON.stringify(obj));
|
||||
|
||||
await this.processSingleTaskWithRetries(taskData);
|
||||
await this.processSingleTaskWithRetries(taskData, callback);
|
||||
|
||||
// 任务成功
|
||||
this.queue.shift();
|
||||
@ -140,7 +122,7 @@ export class ProcessDataTaskPool {
|
||||
|
||||
// 检查是否所有任务都已处理完
|
||||
if (this.queue.length === 0 && this.completedTasksInCurrentBatch === this.totalTasksInCurrentBatch) {
|
||||
console.log(QueueTag, ' 所有任务处理完毕!');
|
||||
console.log(QueueTag, ' 所有任务处理完毕!"总数', this.totalTasksInCurrentBatch, "完成的");
|
||||
this.onAllTasksCompletedCallback?.(
|
||||
this.totalTasksInCurrentBatch,
|
||||
this.completedTasksInCurrentBatch,
|
||||
@ -199,20 +181,15 @@ 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(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;
|
||||
|
||||
// dConsole.writeProcessData(ProcessDataEnumType.WuxiExam, JSON.stringify(result));
|
||||
callback(result)
|
||||
dConsole.writeProcessData(ProcessDataEnumType.WuxiExam, JSON.stringify(result));
|
||||
if (result.code === "1") {
|
||||
console.log(QueueTag, ` ✔️ 上传成功 (在第 ${attemptNum} 次尝试)`);
|
||||
return; // 成功,立即返回
|
||||
@ -259,7 +236,7 @@ export async function uploadWorkerTask(data: RegulatoryInterfaceParams): Promise
|
||||
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;
|
||||
|
||||
@ -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)
|
||||
})
|
||||
|
||||
@ -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);
|
||||
});
|
||||
|
||||
@ -31,7 +31,7 @@ class differentialSignal {
|
||||
// 组装消息,一秒发送五次
|
||||
let data = "1";
|
||||
this.timer = setInterval(() => {
|
||||
dConsole.low(TCPTag, "发送给中心消息")
|
||||
// dConsole.low(TCPTag, "发送给中心消息")
|
||||
this.differentialSignalTcp.sendMsg(data);
|
||||
}, 200);
|
||||
|
||||
@ -40,7 +40,7 @@ class differentialSignal {
|
||||
// 获取消息
|
||||
getData(callback: (data: ArrayBuffer) => void) {
|
||||
this.differentialSignalTcp.onMsg((data: ArrayBuffer) => {
|
||||
dConsole.low(TCPTag, "获取TCP消息", data);
|
||||
// dConsole.low(TCPTag, "获取TCP消息", data);
|
||||
callback(data);
|
||||
});
|
||||
}
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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`,
|
||||
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user