fix: 去掉旧的日志
This commit is contained in:
		
							parent
							
								
									0a5648967d
								
							
						
					
					
						commit
						3938e0761f
					
				| @ -177,7 +177,7 @@ struct VideoConfigPage { | ||||
|             type: "3", | ||||
|             click: async () => { | ||||
|               const arr = ['1', '2', '3', '4'] | ||||
|               if (!arr.includes(this.videoConfig.pztd)) { | ||||
|               if (!arr.includes(this.videoConfig?.pztd || "")) { | ||||
|                 Prompt.showToast({ | ||||
|                   message: '请填写正确的拍照通道', | ||||
|                   duration: 3000 | ||||
|  | ||||
| @ -6,7 +6,6 @@ import buffer from '@ohos.buffer'; | ||||
| import VoiceAnnounce from './utils/voiceAnnouncements'; | ||||
| import FileModel from './utils/fileModel'; | ||||
| import FilePhoto from './utils/filePhoto'; | ||||
| import FileLog from './utils/fileLog'; | ||||
| import JudgeTask from './utils/judgeTask'; | ||||
| import { JudgeConfig, JudgeTag } from '../../config'; | ||||
| import { GetSyncData, SqlInsertTable } from '../../utils/table/Operation'; | ||||
| @ -101,8 +100,6 @@ export default class Judge { | ||||
|       sharps: this.getModelData('km3/Sharps.txt') || "" | ||||
|     } | ||||
|   } | ||||
|   private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; | ||||
|   private fileLog?: FileLog | ||||
|   //人工扣分 | ||||
|   public setJudgeMark = async (itemno: string, serial: string, type = 1) => { | ||||
|     await examJudgeArtificialMark(Number(itemno), serial, type); | ||||
| @ -113,7 +110,8 @@ export default class Judge { | ||||
|       serial, | ||||
|       type | ||||
|     }) | ||||
|     await this.fileLog?.setExamJudgeData(str) | ||||
|     // await this.fileLog?.setExamJudgeData(str) | ||||
|     dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, str) | ||||
|     dConsole.info(JudgeTag, `人工扣分-${itemno}-${serial}`) | ||||
|   } | ||||
|   //人工操作项目 | ||||
| @ -125,9 +123,11 @@ export default class Judge { | ||||
|       itemno: Number(itemno), | ||||
|       type | ||||
|     }) | ||||
|     await this.fileLog?.setExamJudgeData(str) | ||||
|     // await this.fileLog?.setExamJudgeData(str) | ||||
|     dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, str) | ||||
|     dConsole.info(JudgeTag, `人工评判${type == 1 ? '进入' : '取消'}项目-${itemno}`) | ||||
|   } | ||||
|   private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; | ||||
|   private filePath: string = "" | ||||
|   private totalScore: number = -1 | ||||
|   private prevJd: number = 0 | ||||
| @ -184,6 +184,48 @@ export default class Judge { | ||||
|   private isExamEnd: boolean | ||||
|   // 是否发送udp | ||||
|   private isUdpEnd: boolean = false | ||||
|   // 处理udp plc信号 | ||||
|   handleUdp = async (msg: string) => { | ||||
|     const stachArr = msg.split(',') | ||||
|     if (stachArr[0] != '#DN_GD' || this.isUdpEnd) { | ||||
|       return | ||||
|     } | ||||
|     const gpsPart = msg.split("#END$GPS,")[1]; | ||||
|     const gpsStatus = gpsPart.split(",")[0]; | ||||
|     if (gpsStatus === "4") { | ||||
|       dConsole.log(JudgeTag, "差分状态正常", gpsStatus) | ||||
|       this.judgeUI.isDwztRight = true | ||||
|     } else { | ||||
|       dConsole.log(JudgeTag, "差分状态异常", gpsStatus) | ||||
|       this.judgeUI.isDwztRight = false | ||||
|     } | ||||
|     this.judgeUI.isDwztRight | ||||
|     const plcData = await this.getPlcData(msg); | ||||
|     // 4.过程数据 | ||||
|     // await this.fileLog?.setExamJudgeData(JSON.stringify(plcData)) | ||||
|     dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, JSON.stringify(plcData)) | ||||
|     //检测到有无锡所设备接入,需要发送特定的数据,供检测 | ||||
|     // if (this.usbService.isWXUSBDevice) { | ||||
|     //   const str = await senorToWXDataStr(msg); | ||||
|     //   this.usbService.sendUSB(str) | ||||
|     // } | ||||
|     const param350: number = Reflect.get(this.judgeUI.judgeConfigObj, '350') | ||||
|     this.judgeUI.sd = ((param350 == 0 ? plcData.gps.sd : plcData.sensor.cs) as number * 1.852).toFixed(0) + '' | ||||
|     this.judgeUI.dw = (Math.floor(plcData.sensor.dw as number) || 0) + '' | ||||
|     //TODO 暂时关闭差分检测异常 | ||||
|     // await this.checkDwzt(plcData.gps.dwzt,plcData.gps.jdzt); | ||||
|     if (!this.isExamEnd) { | ||||
|       await examJudgeRealExam(plcData) | ||||
|     } | ||||
|     // let udpIndex = AppStorage.get<number>('udpIndex') || 0; | ||||
|     // if (udpIndex % 5 === 0 && !this.isUdpEnd) { | ||||
|     // TODO UPD缺失 | ||||
|     // const judgeUdp = globalThis.judgeUdp | ||||
|     // const bytes = await this.getMessageHeartbeat(this.isExamEnd); | ||||
|     // judgeUdp.send(bytes) | ||||
|     // } | ||||
|     // AppStorage.setOrCreate('udpIndex', udpIndex++) | ||||
|   } | ||||
|   //是否手动结束考试 | ||||
|   private isManual: boolean = false | ||||
|   //UDP服务序列号 | ||||
| @ -194,16 +236,14 @@ export default class Judge { | ||||
|     const carInfo = AppStorage.get<CarInfoType>('carInfo') | ||||
|     const judgeUI = this.judgeUI | ||||
|     const fileUtil = this.fileUtil | ||||
|     const fileLog = this.fileLog | ||||
|     const carId = carInfo?.carId || "" | ||||
|     const examinationRoomId = carInfo?.examinationRoomId || "" | ||||
| 
 | ||||
|     const folderPath = fileLog?.folderPath | ||||
|     const base64 = new util.Base64(); | ||||
|     const time = GetCurrentTime(); | ||||
|     const endTime = GetCurrentTime(1) | ||||
|     let examDataBase64: string = '' | ||||
|     const examDataStr: string = await this.fileUtil.readFile(`${folderPath}/wuxi_progress_data.txt`); | ||||
|     const examDataStr: string = await this.fileUtil.readFile(`${dConsole.currentExamCatalog}/wuxi_progress_data.txt`); | ||||
|     try { | ||||
|       let tempBuff = buffer.alloc(examDataStr.length, examDataStr) | ||||
|       let examData: Uint8Array = new Uint8Array(tempBuff.buffer) | ||||
| @ -230,6 +270,60 @@ export default class Judge { | ||||
|     dConsole.info(JudgeTag, '过程数据文件上传 end') | ||||
|   } | ||||
|   private judgeTask: JudgeTask | ||||
|   // 检测扣分、结束项目时该项目是否开始 | ||||
|   checkProjectIsStart = async (xmdm: number, currentType: 1 | 2, kf?: MarkRule) => { | ||||
|     if (xmdm == 20) { | ||||
|       return true | ||||
|     } | ||||
|     const judgeUI = this.judgeUI; | ||||
|     const judgeTask = this.judgeTask; | ||||
|     const projectsObj: object = this.judgeUI.projectsObj | ||||
|     const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm) | ||||
|     const isUpload = currentProject.isUpload | ||||
| 
 | ||||
|     //如果项目没有开始 | ||||
|     dConsole.info(JudgeTag, 'surenjun isUpload=>', isUpload) | ||||
|     if (!isUpload) { | ||||
|       dConsole.info(JudgeTag, '项目补传开始') | ||||
|       //项目开始补传 | ||||
|       judgeTask.addTask(async () => { | ||||
|         await this.beginProject(xmdm) | ||||
|       }, { | ||||
|         isDelay: true | ||||
|       }) | ||||
|       judgeTask.addTask(async () => { | ||||
|         await this.uploadProgressPhoto(xmdm) | ||||
|       }, { | ||||
|         isDelay: true | ||||
|       }) | ||||
|       currentProject.isUpload = true; | ||||
|       Reflect.set(this.judgeUI.projectsObj, xmdm, currentProject) | ||||
|       //扣分补传 | ||||
|       if (currentType == 2) { | ||||
|         judgeTask.addTask(async () => { | ||||
|           await this.pointsDedute(xmdm, kf!) | ||||
|         }, { | ||||
|           isDelay: true | ||||
|         }) | ||||
|       } | ||||
|       //扣分补传判断是否合格 不合格补传项目结束 | ||||
|       if (currentType == 1 || (currentType == 2 && this.totalScore < judgeUI.passingScore)) { | ||||
|         judgeTask.addTask(async () => { | ||||
|           await this.endProject(xmdm) | ||||
|         }, { | ||||
|           isDelay: true | ||||
|         }) | ||||
|         currentProject.isEnd = true; | ||||
|         Reflect.set(this.judgeUI.projectsObj, xmdm, currentProject) | ||||
|       } | ||||
|       judgeTask.addTask(async () => { | ||||
|         this.checkExamIsEnd() | ||||
|       }) | ||||
|       return false; | ||||
|     } else { | ||||
|       return true | ||||
|     } | ||||
|   } | ||||
|   private tempData?: PLCType | ||||
|   //实时计算gps经纬度距离 | ||||
|   handDistance = async () => { | ||||
| @ -260,7 +354,8 @@ export default class Judge { | ||||
|   private plcData?: PLCType | ||||
|   // 获取plc数据 | ||||
|   getPlcData = async (plc: string) => { | ||||
|     await this.fileLog?.setPlcProgressData(plc) | ||||
|     // await this.fileLog?.setPlcProgressData(plc) | ||||
|     dConsole.writeProcessData(ProcessDataEnumType.PlcData, plc) | ||||
|     //plc字符串转化成评判初始化数据 | ||||
|     const tempData = await PlcStrToJson(plc); | ||||
|     //模拟灯光回放时刻 | ||||
| @ -270,7 +365,8 @@ export default class Judge { | ||||
|     //plc字符串转化成无锡所过程数据 | ||||
|     const wuXiDataStr = await PlcStrToWXJson(plc) | ||||
|     this.plcData = tempData | ||||
|     await this.fileLog?.setExamJudgeWuxiProgressData(wuXiDataStr) | ||||
|     // await this.fileLog?.setExamJudgeWuxiProgressData(wuXiDataStr) | ||||
|     dConsole.writeProcessData(ProcessDataEnumType.WuxiProgressData, wuXiDataStr) | ||||
|     this.tempData = tempData | ||||
|     this.plcStr = plc; | ||||
|     this.mndgStr = ''; | ||||
| @ -278,46 +374,40 @@ export default class Judge { | ||||
|     AppStorage.setOrCreate('msgStr', plc) | ||||
|     return tempData | ||||
|   } | ||||
|   // 处理udp plc信号 | ||||
|   handleUdp = async (msg: string) => { | ||||
|     const stachArr = msg.split(',') | ||||
|     if (stachArr[0] != '#DN_GD' || this.isUdpEnd) { | ||||
|       return | ||||
|     } | ||||
|     const gpsPart = msg.split("#END$GPS,")[1]; | ||||
|     const gpsStatus = gpsPart.split(",")[0]; | ||||
|     if (gpsStatus === "4") { | ||||
|       dConsole.log(JudgeTag, "差分状态正常", gpsStatus) | ||||
|       this.judgeUI.isDwztRight = true | ||||
|     } else { | ||||
|       dConsole.log(JudgeTag, "差分状态异常", gpsStatus) | ||||
|       this.judgeUI.isDwztRight = false | ||||
|     } | ||||
|     this.judgeUI.isDwztRight | ||||
|     const plcData = await this.getPlcData(msg); | ||||
|     // 4.过程数据 | ||||
|     await this.fileLog?.setExamJudgeData(JSON.stringify(plcData)) | ||||
|     //检测到有无锡所设备接入,需要发送特定的数据,供检测 | ||||
|     // if (this.usbService.isWXUSBDevice) { | ||||
|     //   const str = await senorToWXDataStr(msg); | ||||
|     //   this.usbService.sendUSB(str) | ||||
|     // } | ||||
|     const param350: number = Reflect.get(this.judgeUI.judgeConfigObj, '350') | ||||
|     this.judgeUI.sd = ((param350 == 0 ? plcData.gps.sd : plcData.sensor.cs) as number * 1.852).toFixed(0) + '' | ||||
|     this.judgeUI.dw = (Math.floor(plcData.sensor.dw as number) || 0) + '' | ||||
|     //TODO 暂时关闭差分检测异常 | ||||
|     // await this.checkDwzt(plcData.gps.dwzt,plcData.gps.jdzt); | ||||
|     if (!this.isExamEnd) { | ||||
|       await examJudgeRealExam(plcData) | ||||
|     } | ||||
|     // let udpIndex = AppStorage.get<number>('udpIndex') || 0; | ||||
|     // if (udpIndex % 5 === 0 && !this.isUdpEnd) { | ||||
|     // TODO UPD缺失 | ||||
|     // const judgeUdp = globalThis.judgeUdp | ||||
|     // const bytes = await this.getMessageHeartbeat(this.isExamEnd); | ||||
|     // judgeUdp.send(bytes) | ||||
|     // } | ||||
|     // AppStorage.setOrCreate('udpIndex', udpIndex++) | ||||
|   // 处理轨迹plc信号 | ||||
|   handleTrajectoryUdp = async (strArr: string[]) => { | ||||
|     let num = 2; | ||||
|     const judgeTimer = setInterval(async () => { | ||||
|       const msgStr = strArr[num]; | ||||
|       if (msgStr == '') { | ||||
|         dConsole.info(JudgeTag, '模拟数据考试结束') | ||||
|         clearInterval(judgeTimer) | ||||
|         this.checkExamIsEnd(true) | ||||
|         return | ||||
|       } | ||||
|       const msg: PLCType = JSON.parse(strArr[num]); | ||||
|       num++ | ||||
|       // 4.过程数据 | ||||
|       this.tempData = msg | ||||
|       // this.judgeUI.isDwztRight = (msg?.gps?.dwzt == 4 && msg?.gps?.jdzt == 3); | ||||
|       this.judgeUI.sd = Math.floor(msg?.gps?.sd * 1.852) + ''; | ||||
|       this.judgeUI.dw = Math.floor(msg?.sensor?.dw) + '' | ||||
|       this.plcData = msg | ||||
|       // this.judgeUI.isDwztRight = msg.gps.dwzt == 4; | ||||
|       AppStorage.setOrCreate('msgStr', '') | ||||
|       if (msg.method === 'examJudgeArtificialItem') { | ||||
|         this.setJudgeItem(msg.itemno, msg.type) | ||||
|       } | ||||
|       if (msg.method === 'examJudgeArtificialMark') { | ||||
|         this.setJudgeItem(msg.itemno, msg.serial) | ||||
|       } | ||||
|       await examJudgeRealExam(msg) | ||||
|       // const bytes = await this.getMessageHeartbeat(); | ||||
|       // bytes && globalThis.judgeUdp.send(bytes) | ||||
| 
 | ||||
|     }, 200) | ||||
|     // TODO 定时器缺失 | ||||
|     // globalThis.judgeTimer = judgeTimer; | ||||
|   } | ||||
|   private isEndTip: boolean = false; | ||||
|   //本地轨迹回放地址 | ||||
| @ -331,39 +421,12 @@ export default class Judge { | ||||
|     if (!this.isJudgeDisConnect) { | ||||
|       return | ||||
|     } | ||||
|     const folderPath = this.fileLog?.folderPath | ||||
|     const examDataStr = await this.fileUtil.readFile(`${folderPath}/wuxi_dis_progress_data.txt`); | ||||
|     const examDataStr = await this.fileUtil.readFile(`${dConsole.currentExamCatalog}/wuxi_dis_progress_data.txt`); | ||||
|     const examDataArr = examDataStr.split('\n'); | ||||
|     for (let examDataStr of examDataArr) { | ||||
|       const code = await writeObjectOut(JSON.parse(examDataStr), "", this.context); | ||||
|     } | ||||
|   } | ||||
|   private artSubject3ProjectsCodesArr: number[] = [3, 9, 4, 10, 12, 11] | ||||
|   private lane: LANE = { | ||||
|     road: '', num: 0, count: 0 | ||||
|   } | ||||
|   private disConnectNum: number = 0; | ||||
|   //调用监管接口 | ||||
|   sendWriteObjectOut: SendWriteObjectOut = async (data, filePath) => { | ||||
|     const temp = await writeObjectOut(data, filePath, this.context); | ||||
|     dConsole.log(JudgeTag, "wzj", JSON.stringify(temp)) | ||||
|     //断网&网络超时次数计算 | ||||
|     if (temp.code == 2300007 || temp.code == 2300028) { | ||||
|       this.disConnectNum += 1; | ||||
|       if (this.disConnectNum < 5) { | ||||
|         return await this.sendWriteObjectOut(data, filePath) | ||||
|       } | ||||
|     } | ||||
| 
 | ||||
|     if (this.disConnectNum >= 5) { | ||||
|       dConsole.info('surenjun', '123') | ||||
|       this.judgeUI.errorMsg = '当前的考试过程信息网络传输异常,程序点击确认将重启!'; | ||||
|       this.judgeUI.disConnectErrorOpen = true | ||||
|     } | ||||
| 
 | ||||
|     this.disConnectNum = 0 | ||||
|     return temp | ||||
|   } | ||||
|   // 项目开始接口同步 | ||||
|   beginProject = async (ksxm: number) => { | ||||
|     const carInfo = AppStorage.get<CarInfoType>('carInfo'); | ||||
| @ -467,6 +530,32 @@ export default class Judge { | ||||
|     UploadRegulatoryCodeConversion('17C54', temp.code || 0) | ||||
|     dConsole.info(JudgeTag, '上传照片 end') | ||||
|   } | ||||
|   private artSubject3ProjectsCodesArr: number[] = [3, 9, 4, 10, 12, 11] | ||||
|   private lane: LANE = { | ||||
|     road: '', num: 0, count: 0 | ||||
|   } | ||||
|   private disConnectNum: number = 0; | ||||
|   //调用监管接口 | ||||
|   sendWriteObjectOut: SendWriteObjectOut = async (data, filePath) => { | ||||
|     const temp = await writeObjectOut(data, filePath, this.context); | ||||
|     dConsole.log(JudgeTag, "wzj", JSON.stringify(temp)) | ||||
|     //断网&网络超时次数计算 | ||||
|     if (temp.code == 2300007 || temp.code == 2300028) { | ||||
|       this.disConnectNum += 1; | ||||
|       if (this.disConnectNum < 5) { | ||||
|         return await this.sendWriteObjectOut(data, filePath) | ||||
|       } | ||||
|     } | ||||
| 
 | ||||
|     if (this.disConnectNum >= 5) { | ||||
|       dConsole.info('surenjun', '123') | ||||
|       this.judgeUI.errorMsg = '当前的考试过程信息网络传输异常,程序点击确认将重启!'; | ||||
|       this.judgeUI.disConnectErrorOpen = true | ||||
|     } | ||||
| 
 | ||||
|     this.disConnectNum = 0 | ||||
|     return temp | ||||
|   } | ||||
|   private videoData?: RecordHandleType | ||||
|   //当前科目二的考试项目 | ||||
|   private deductedPopShowTimer: number = 0; | ||||
| @ -585,95 +674,6 @@ export default class Judge { | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   // 检测扣分、结束项目时该项目是否开始 | ||||
|   checkProjectIsStart = async (xmdm: number, currentType: 1 | 2, kf?: MarkRule) => { | ||||
|     if (xmdm == 20) { | ||||
|       return true | ||||
|     } | ||||
|     const judgeUI = this.judgeUI; | ||||
|     const judgeTask = this.judgeTask; | ||||
|     const projectsObj: object = this.judgeUI.projectsObj | ||||
|     const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm) | ||||
|     const isUpload = currentProject.isUpload | ||||
| 
 | ||||
|     //如果项目没有开始 | ||||
|     dConsole.info(JudgeTag, 'surenjun isUpload=>', isUpload) | ||||
|     if (!isUpload) { | ||||
|       dConsole.info(JudgeTag, '项目补传开始') | ||||
|       //项目开始补传 | ||||
|       judgeTask.addTask(async () => { | ||||
|         await this.beginProject(xmdm) | ||||
|       }, { | ||||
|         isDelay: true | ||||
|       }) | ||||
|       judgeTask.addTask(async () => { | ||||
|         await this.uploadProgressPhoto(xmdm) | ||||
|       }, { | ||||
|         isDelay: true | ||||
|       }) | ||||
|       currentProject.isUpload = true; | ||||
|       Reflect.set(this.judgeUI.projectsObj, xmdm, currentProject) | ||||
|       //扣分补传 | ||||
|       if (currentType == 2) { | ||||
|         judgeTask.addTask(async () => { | ||||
|           await this.pointsDedute(xmdm, kf!) | ||||
|         }, { | ||||
|           isDelay: true | ||||
|         }) | ||||
|       } | ||||
|       //扣分补传判断是否合格 不合格补传项目结束 | ||||
|       if (currentType == 1 || (currentType == 2 && this.totalScore < judgeUI.passingScore)) { | ||||
|         judgeTask.addTask(async () => { | ||||
|           await this.endProject(xmdm) | ||||
|         }, { | ||||
|           isDelay: true | ||||
|         }) | ||||
|         currentProject.isEnd = true; | ||||
|         Reflect.set(this.judgeUI.projectsObj, xmdm, currentProject) | ||||
|       } | ||||
|       judgeTask.addTask(async () => { | ||||
|         this.checkExamIsEnd() | ||||
|       }) | ||||
|       return false; | ||||
|     } else { | ||||
|       return true | ||||
|     } | ||||
|   } | ||||
|   // 处理轨迹plc信号 | ||||
|   handleTrajectoryUdp = async (strArr: string[]) => { | ||||
|     let num = 2; | ||||
|     const judgeTimer = setInterval(async () => { | ||||
|       const msgStr = strArr[num]; | ||||
|       if (msgStr == '') { | ||||
|         dConsole.info(JudgeTag, '模拟数据考试结束') | ||||
|         clearInterval(judgeTimer) | ||||
|         this.checkExamIsEnd(true) | ||||
|         return | ||||
|       } | ||||
|       const msg: PLCType = JSON.parse(strArr[num]); | ||||
|       num++ | ||||
|       // 4.过程数据 | ||||
|       this.tempData = msg | ||||
|       // this.judgeUI.isDwztRight = (msg?.gps?.dwzt == 4 && msg?.gps?.jdzt == 3); | ||||
|       this.judgeUI.sd = Math.floor(msg?.gps?.sd * 1.852) + ''; | ||||
|       this.judgeUI.dw = Math.floor(msg?.sensor?.dw) + '' | ||||
|       this.plcData = msg | ||||
|       // this.judgeUI.isDwztRight = msg.gps.dwzt == 4; | ||||
|       AppStorage.setOrCreate('msgStr', '') | ||||
|       if (msg.method === 'examJudgeArtificialItem') { | ||||
|         this.setJudgeItem(msg.itemno, msg.type) | ||||
|       } | ||||
|       if (msg.method === 'examJudgeArtificialMark') { | ||||
|         this.setJudgeItem(msg.itemno, msg.serial) | ||||
|       } | ||||
|       await examJudgeRealExam(msg) | ||||
|       // const bytes = await this.getMessageHeartbeat(); | ||||
|       // bytes && globalThis.judgeUdp.send(bytes) | ||||
| 
 | ||||
|     }, 200) | ||||
|     // TODO 定时器缺失 | ||||
|     // globalThis.judgeTimer = judgeTimer; | ||||
|   } | ||||
| 
 | ||||
|   constructor(judgeUI: JudgeUI) { | ||||
|     this.serialIndex = 1; | ||||
| @ -870,7 +870,6 @@ export default class Judge { | ||||
|     const goJudgeVoice = this.goJudgeVoice; | ||||
|     const setMndg = this.setMndg; | ||||
|     const avPlayer = this.avPlayer; | ||||
|     const fileLog = this.fileLog; | ||||
|     const judgeUI = this.judgeUI; | ||||
| 
 | ||||
|     const carzt = examData.carzt | ||||
| @ -989,7 +988,10 @@ export default class Judge { | ||||
|     //考试结束 | ||||
|       case 5: | ||||
|         this.ksjs = ksjs; | ||||
|         await fileLog?.setExamJudgeData(JSON.stringify({ | ||||
|       // await fileLog?.setExamJudgeData(JSON.stringify({ | ||||
|       //   method: 'examJudgeEndExam' | ||||
|       // })) | ||||
|         dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, JSON.stringify({ | ||||
|           method: 'examJudgeEndExam' | ||||
|         })) | ||||
|         break; | ||||
| @ -1304,7 +1306,7 @@ export default class Judge { | ||||
|   // 评判语音提示 | ||||
|   goJudgeVoice = async (sound: JudgeSound) => { | ||||
|     const avPlayer = this.avPlayer | ||||
|     const fileLog = this.fileLog | ||||
|     // const fileLog = this.fileLog | ||||
|     dConsole.info('surenjun code=>', JSON.stringify(sound.code)) | ||||
|     //判断是不是模拟灯光语音 | ||||
|     if (sound.type == 1) { | ||||
| @ -1312,7 +1314,13 @@ export default class Judge { | ||||
|         examJudgeSoundEnd({ | ||||
|           xmdm: sound.xmdm, code: sound.code[0], type: sound.type | ||||
|         }) | ||||
|         fileLog?.setExamJudgeData(JSON.stringify({ | ||||
|         // fileLog?.setExamJudgeData(JSON.stringify({ | ||||
|         //   method: 'examJudgeSoundEnd', | ||||
|         //   itemno: sound.xmdm, | ||||
|         //   code: sound.code[0], | ||||
|         //   type: sound.type, | ||||
|         // })) | ||||
|         dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, JSON.stringify({ | ||||
|           method: 'examJudgeSoundEnd', | ||||
|           itemno: sound.xmdm, | ||||
|           code: sound.code[0], | ||||
|  | ||||
| @ -1,127 +0,0 @@ | ||||
| import { GetCurrentTime } from '../../../utils/Common'; | ||||
| import FileUtils from '../../../utils/FileUtils'; | ||||
| import common from '@ohos.app.ability.common'; | ||||
| 
 | ||||
| interface StuInfo { | ||||
|   name: string | ||||
|   lsh: string | ||||
|   idCard: string | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| export default class FileLog { | ||||
|   public folderPath?: string | ||||
|   public progressDataFd: number | undefined = undefined | ||||
|   public examJudgeWuxiDataFd: number | undefined = undefined | ||||
|   public examJudgeWuxiProgressDataFd: number | undefined = undefined | ||||
|   public plcDataFd: number | undefined = undefined | ||||
|   public examJudgeDataFd: number | undefined = undefined | ||||
|   public examJudgeCallbackDataFd: number | undefined = undefined | ||||
|   public examJudgeLogDataFd: number | undefined = undefined | ||||
|   public fourAndOneLogDataFd: number | undefined = undefined | ||||
|   public fourAndOneLogDataBytesFd: number | undefined = undefined | ||||
|   public examLineDataFd: number | undefined = undefined | ||||
|   private fileUtil: FileUtils | ||||
|   // 过程文件数据 | ||||
|   public setExamProgressData = async (str: Object) => { | ||||
|     this.progressDataFd = | ||||
|       await this.fileUtil.editFile(`${this.folderPath}/exam_progress_data.txt`, JSON.stringify(str)); | ||||
|   } | ||||
|   // 无锡所接口数据 | ||||
|   public setExamJudgeWuxiData = async (str: string) => { | ||||
|     // this.examJudgeWuxiDataFd = | ||||
|     //   await this.fileUtil.editFile(`${this.folderPath}/wuxi_exam_data.txt`, str); | ||||
|   } | ||||
|   // 无锡所过程数据 | ||||
|   public setExamJudgeWuxiProgressData = async (str: string) => { | ||||
|     // this.examJudgeWuxiProgressDataFd = | ||||
|     //   await this.fileUtil.editFile(`${this.folderPath}/wuxi_progress_data.txt`, str); | ||||
|   } | ||||
|   // plc文件数据 | ||||
|   public setPlcProgressData = async (str: Object) => { | ||||
|     // this.plcDataFd = | ||||
|     //   await this.fileUtil.editFile(`${this.folderPath}/plc_data.txt`, JSON.stringify(str)); | ||||
|   } | ||||
|   // 过程评判json数据 | ||||
|   public setExamJudgeData = async (str: string) => { | ||||
|     // this.examJudgeDataFd = | ||||
|     //   await this.fileUtil.editFile(`${this.folderPath}/judge_exam_data.txt`, str); | ||||
|   } | ||||
|   // 过程评判回调数据 | ||||
|   public setExamJudgeCallbackData = async (str: string) => { | ||||
|     // this.examJudgeCallbackDataFd = | ||||
|     //   await this.fileUtil.editFile(`${this.folderPath}/judge_progress_callback_data.txt`, str); | ||||
|   } | ||||
|   // 过程评判日志调数据 | ||||
|   public setExamJudgeLogData = async (str: string) => { | ||||
|     // this.examJudgeLogDataFd = | ||||
|     //   await this.fileUtil.editFile(`${this.folderPath}/judge_log_data.txt`, str); | ||||
|   } | ||||
|   // 设置四合一画面数据 | ||||
|   public setFourAndOneLogData = async (str: string) => { | ||||
|     this.fourAndOneLogDataFd = | ||||
|       await this.fileUtil.editFile(`${this.folderPath}/four_one_log_data.txt`, str); | ||||
|   } | ||||
|   public setFourAndOneLogDataBytes = async (str: string) => { | ||||
|     this.fourAndOneLogDataBytesFd = | ||||
|       await this.fileUtil.editFile(`${this.folderPath}/four_one_log_byte_data.txt`, str); | ||||
|   } | ||||
|   // 无锡所轨迹数据 | ||||
|   public setExamLineData = async (plcStr: string) => { | ||||
|     const plcData = plcStr.split(','); | ||||
|     const time = GetCurrentTime(); | ||||
|     const lineData = [ | ||||
|     /*帧头*/time, | ||||
|       /*卫星时间*/time, | ||||
|       /*经度*/ plcData[95], | ||||
|       /*纬度*/ plcData[95], | ||||
|       /*高度*/ plcData[86], | ||||
|       /*方位角*/ 0, | ||||
|       /*俯仰角*/ plcData[91], | ||||
|       /*速度角*/'', | ||||
|       /*速度*/  plcData[97], | ||||
|       /*横滚*/'', | ||||
|       /*卫星定位状态*/'', | ||||
|       /*卫星定向状态*/'', | ||||
|       /*前天线可用星数*/'', | ||||
|       /*后天线可用星数*/'', | ||||
|       /*东向位置坐标*/'', | ||||
|       /*北向位置坐标*/'', | ||||
|       /*天向位置坐标*/'', | ||||
|       /*东向速度*/'', | ||||
|       /*北向速度*/'', | ||||
|       /*评判信号1*/[plcData[14], plcData[19], plcData[5], '', plcData[2], plcData[3], plcData[7], plcData[8], | ||||
|         plcData[13], plcData[12], plcData[17], '', plcData[4], plcData[11], plcData[20], plcData[9], 0].join(','), | ||||
|       /*评判信号2*/['', plcData[28], '', '', plcData[10], '', '', '', '', '', '', '', '', '', '', '', '', ''].join(','), | ||||
|       /*发动机转速*/ plcData[25], | ||||
|       /*结束符*/ time, | ||||
|     ]; | ||||
|     this.examLineDataFd = | ||||
|       await this.fileUtil.editFile(`${this.folderPath}/exam_wuxi_data.txt`, JSON.stringify(lineData)); | ||||
|   }; | ||||
|   // private stuInfo: StuInfo | ||||
|   // 设置文件夹 | ||||
|   public initFileLogo = async (stuInfo: StuInfo) => { | ||||
|     // this.stuInfo = stuInfo; | ||||
|     // const time = GetCurrentTime() | ||||
|     // const date = time.split(' ')[0].split('-').join('_') | ||||
|     // const hourTime = time.split(' ')[1].split(':').join('_') | ||||
|     // const folderPath = | ||||
|     //   await this.fileUtil.initFolder(`/logs/${date}/${date}_${hourTime}_${stuInfo.lsh}_${stuInfo.idCard}_${stuInfo.name}`); | ||||
|     // this.folderPath = folderPath; | ||||
|     return "folderPath" | ||||
|   } | ||||
| 
 | ||||
|   constructor(context: common.UIAbilityContext) { | ||||
|     const fileUtil = new FileUtils(context) | ||||
|     this.fileUtil = fileUtil | ||||
|   } | ||||
| 
 | ||||
|   //关闭所有文件写入 | ||||
|   public closeAllFiles = async () => { | ||||
|     ['exam_progress_data', 'wuxi_exam_data', 'wuxi_progress_data', 'plc_data', 'judge_exam_data', | ||||
|       'judge_progress_callback_data', 'judge_log_data', 'four_one_log_data', 'four_one_log_byte_data'].forEach(path => { | ||||
|       this.fileUtil.closeFile(`${this.folderPath}/${path}.txt`); | ||||
|     }) | ||||
|   } | ||||
| } | ||||
| @ -1,13 +1,16 @@ | ||||
| // 日志向外暴露的方法 | ||||
| import dayTs from './Date'; | ||||
| import worker from '@ohos.worker'; | ||||
| import { GlobalConfig } from '../config'; | ||||
| import { LogWorkerMessage, ProcessDataEnumType, WorkerMessageType } from '../model/index'; | ||||
| import dayTs from './Date'; | ||||
| 
 | ||||
| const MAX_MESSAGE_LENGTH = 300; | ||||
| const LOG_CHUNK_PREFIX = '[切割消息序号'; | ||||
| 
 | ||||
| class logWorker { | ||||
|   private static instance: logWorker | null = null; | ||||
|   // 当前考试的数据目录 | ||||
|   public currentExamCatalog: string = "" | ||||
|   private workerInstance: worker.ThreadWorker | null = null; | ||||
|   // 是否开启日志 1开启 | ||||
|   private isLogEnabled: string = "0"; | ||||
| @ -58,6 +61,8 @@ class logWorker { | ||||
|       type: WorkerMessageType.ExamProcessInit, | ||||
|       studentDirName: dirName | ||||
|     } | ||||
|     let date = dayTs().format("YYYY_MM_DD") | ||||
|     this.currentExamCatalog = `${GlobalConfig.commonFileWriteAddress}/logs/${date}/${dirName}` | ||||
|     if (this.isLogEnabled === "1") { | ||||
|       this.workerInstance?.postMessage(JSON.stringify(data)) | ||||
|     } | ||||
| @ -74,8 +79,9 @@ class logWorker { | ||||
|       this.workerInstance?.postMessage(JSON.stringify(params)) | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // 关闭过程数据写入 | ||||
|   closeProcessData(){ | ||||
|   closeProcessData() { | ||||
|     let params: LogWorkerMessage = { | ||||
|       type: WorkerMessageType.CloseProcessData, | ||||
|     } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user