dev #63

Merged
wangzhongjie merged 206 commits from dev into main 2024-12-16 10:31:20 +08:00
7 changed files with 193 additions and 113 deletions
Showing only changes of commit 4f1a4f894c - Show all commits

View File

@ -6,7 +6,6 @@ import common from '@ohos.app.ability.common'
import fs from '@ohos.file.fs' import fs from '@ohos.file.fs'
const LOGTAG = 'LOGTAG' const LOGTAG = 'LOGTAG'
export default class FileUtil{ export default class FileUtil{
private context: common.UIAbilityContext private context: common.UIAbilityContext
private wantInfos: Want[] private wantInfos: Want[]
@ -16,6 +15,7 @@ export default class FileUtil {
private absolutePath = '/mnt/hmdfs/100/account/device_view/local/files' private absolutePath = '/mnt/hmdfs/100/account/device_view/local/files'
public destFile:string public destFile:string
public filePathFdObj:Object = {}
constructor(wantInfos) { constructor(wantInfos) {
const {requestPermission} = this; const {requestPermission} = this;
@ -42,20 +42,19 @@ export default class FileUtil {
} catch (e) { } catch (e) {
console.info('初始化文件夹失败',path) console.info('初始化文件夹失败',path)
promptAction.showToast({ promptAction.showToast({
message: `初始化文件夹失败` + JSON.stringify(e), message:`初始化文件夹失败`+ folderPath + JSON.stringify(e),
duration:4000, duration:4000,
}) })
} }
})); }));
return path; return path;
} }
/* /*
* @desc * @desc
* *
*/ */
public addFile = async (filePath: string, content: string, type?: string, fd?) => { public addFile = async (filePath:string,content:string,type?:string)=>{
const { READ_WRITE,CREATE,APPEND }= fs.OpenMode const { READ_WRITE,CREATE,APPEND }= fs.OpenMode
const isExit = fs.accessSync(filePath); const isExit = fs.accessSync(filePath);
//文件存在先删除 //文件存在先删除
@ -63,55 +62,62 @@ export default class FileUtil {
fs.unlinkSync(filePath); fs.unlinkSync(filePath);
} }
try { try {
let file let file = fs.openSync(filePath, READ_WRITE | CREATE);
if (!fd) {
file = fs.openSync(filePath, READ_WRITE | CREATE);
}
//追加写入文件 //追加写入文件
fs.writeSync(file.fd,content) fs.writeSync(file.fd,content)
fs.closeSync(file) fs.closeSync(file)
return file.fd console.error(LOGTAG,'写入文件成功')
return true
}catch (e){ }catch (e){
promptAction.showToast({
message:`addFile文件失败`+ filePath +JSON.stringify(e),
duration:4000,
})
console.error(LOGTAG,'写入失败',JSON.stringify(e)) console.error(LOGTAG,'写入失败',JSON.stringify(e))
} }
} }
public openFileSync = async (filePath) => {
const { READ_WRITE,CREATE,APPEND } = fs.OpenMode
let file = fs.openSync(filePath, READ_WRITE | APPEND | CREATE);
return file
}
public editFileWidthOutOpen(file, content) {
const newStr = content + '\n'
fs.writeSync(file.fd, newStr)
fs.closeSync(file)
console.error(LOGTAG, '写入文件成功')
}
/* /*
* @desc * @desc
* *
*/ */
public editFile = async (filePath:string,content:string,fd?:number)=>{ public editFile = async (filePath:string,content:string,fd?:number)=>{
const {filePathFdObj} = this;
const { READ_WRITE,CREATE,APPEND }= fs.OpenMode const { READ_WRITE,CREATE,APPEND }= fs.OpenMode
try {
const newStr = content + '\n' const newStr = content + '\n'
if (fd !== undefined) { const thisFile = filePathFdObj[filePath];
try {
if(thisFile){
fs.writeSync(fd,newStr) fs.writeSync(fd,newStr)
return fd return fd;
}else{ }else{
let file = fs.openSync(filePath, READ_WRITE | APPEND |CREATE); let file = fs.openSync(filePath, READ_WRITE | APPEND |CREATE);
fs.writeSync(file.fd,newStr) fs.writeSync(file.fd,newStr)
this.filePathFdObj[filePath] = file
return file.fd return file.fd
} }
} catch (e) { } catch (e) {
promptAction.showToast({
message:`editFile文件失败`+ filePath +JSON.stringify(e),
duration:4000,
})
console.error(LOGTAG,JSON.stringify(e)) console.error(LOGTAG,JSON.stringify(e))
} }
} }
/*
* @desc
*
*/
public closeFile = async (filePath:string)=>{
const {filePathFdObj} = this;
const thisFile = filePathFdObj[filePath];
if(thisFile){
fs.closeSync(thisFile);
console.info(LOGTAG,filePath + '文件关闭成功')
}
}
/* /*
* @desc * @desc
* *
@ -121,7 +127,12 @@ export default class FileUtil {
console.log('strrr',filePath) console.log('strrr',filePath)
const str = await fs.readText(filePath); const str = await fs.readText(filePath);
return str return str
} catch (err) { }catch (e){
promptAction.showToast({
message:`读取文件失败`+ filePath +JSON.stringify(e),
duration:4000,
})
console.log('readFile文件失败'+ filePath +JSON.stringify(e))
return '' return ''
} }
@ -254,4 +265,6 @@ export default class FileUtil {
} }
}) })
} }
} }

View File

@ -10,6 +10,7 @@ import { defaultJudgeConfigObj } from './judgeSDK/utils//judgeCommon';
import {uploadExamMileage} from '../api/judge' import {uploadExamMileage} from '../api/judge'
import DwztErrorPopup from './compontents/judge/DwztErrorPopup' import DwztErrorPopup from './compontents/judge/DwztErrorPopup'
import {debounce} from '../common/utils/tools' import {debounce} from '../common/utils/tools'
import MsgPopup from './compontents/judge/MsgPopup'
import { import {
CARINFO, CARINFO,
@ -186,6 +187,12 @@ struct Index {
name: decodeURI(sys.v_name) name: decodeURI(sys.v_name)
}) })
} }
//623 考试中是否可以查看轨迹画面(0-否+1-是)
if(sys.v_no == '623'){
this.syssetParam623 = value == '1'?true:false
}
//科目三应行驶距离参数 //科目三应行驶距离参数
if (sys.v_no == '303') { if (sys.v_no == '303') {
this.examMileage = this.examMileage == '0'?(sys.v_value + ''): this.examMileage; this.examMileage = this.examMileage == '0'?(sys.v_value + ''): this.examMileage;
@ -930,6 +937,7 @@ struct Index {
showBack: false, showBack: false,
scaleNum: 1.8, scaleNum: 1.8,
msgStr: this.judge.plcStr || '', msgStr: this.judge.plcStr || '',
showTrajectory:globalThis.singlePlay ? true : (this.syssetParam623),
}).margin({ top: 100 }) }).margin({ top: 100 })
Row() { Row() {
@ -977,6 +985,10 @@ struct Index {
this.endPopupVisible = false; this.endPopupVisible = false;
}, },
confirmFn: async () => { confirmFn: async () => {
if(this.isErrorMsgEnd){
router.back()
return
}
if (this.judgeConfigObj['344'] == 1) { if (this.judgeConfigObj['344'] == 1) {
Prompt.showToast({ Prompt.showToast({
message: '考试未结束,不允许手动退出!', message: '考试未结束,不允许手动退出!',
@ -991,6 +1003,7 @@ struct Index {
try { try {
this.judge.checkExamIsEnd(true); this.judge.checkExamIsEnd(true);
} catch (e) { } catch (e) {
this.judge.closeAllFiles()
router.back() router.back()
} }
@ -1005,6 +1018,16 @@ struct Index {
}) })
} }
if (this.errorMsg){
MsgPopup({
title: this.errorMsg,
confirmFn:()=>{
this.errorMsg = ''
this.isErrorMsgEnd = true;
},
})
}
if(this.dwztErrorVisible){ if(this.dwztErrorVisible){
DwztErrorPopup({ DwztErrorPopup({
title:'当前差分状态异常,学员将无法正常进行考试评判,请将车辆行驶到开阔地,等待程序自检,差分正常后会自动关闭该对话框', title:'当前差分状态异常,学员将无法正常进行考试评判,请将车辆行驶到开阔地,等待程序自检,差分正常后会自动关闭该对话框',
@ -1324,6 +1347,7 @@ struct Index {
@State xldm: string = '' @State xldm: string = ''
//监管接口序列号 //监管接口序列号
@State serialNumber: number = 0 @State serialNumber: number = 0
@State syssetParam623: boolean = false;
@State carType: string = '' @State carType: string = ''
@State carName: string = '' @State carName: string = ''
@State isDeductedPopShow: boolean = false @State isDeductedPopShow: boolean = false
@ -1369,4 +1393,6 @@ struct Index {
@State dwztErrorVisible: boolean = false; @State dwztErrorVisible: boolean = false;
@State popTimer:number =0; @State popTimer:number =0;
@State carlist:string= '' @State carlist:string= ''
@State errorMsg: string = ''
@State isErrorMsgEnd: boolean = false
} }

View File

@ -9,6 +9,7 @@ import { GlobalConfig } from '../../config/index'
@Component @Component
export default struct SignDisplayCom { export default struct SignDisplayCom {
@State showBack: boolean = false @State showBack: boolean = false
@Prop showTrajectory:boolean = false
@State scaleNum: number = 1 @State scaleNum: number = 1
@State msg: string = '' @State msg: string = ''
@State signArr: Array<any> = [] @State signArr: Array<any> = []
@ -50,7 +51,7 @@ export default struct SignDisplayCom {
}) })
if (!this.showBack) { if (this.showTrajectory) {
Row() { Row() {
Text('实时轨迹').fontColor(this.active == 1 ? '#FFAD33' : '#e7cba3').fontSize(20 * this.ratio) Text('实时轨迹').fontColor(this.active == 1 ? '#FFAD33' : '#e7cba3').fontSize(20 * this.ratio)
} }

View File

@ -0,0 +1,23 @@
@Component
export default struct MsgPopup{
constructor() {
super()
}
private title:string = ''
private confirmFn:(event?: ClickEvent) => void
build(){
Column(){
Column(){
Text(this.title).fontSize(36).margin({bottom:20}).lineHeight(50)
Row(){}.height(100)
Row(){
Text('确定').backgroundImage($rawfile('judge/end-btn.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).width(250).height(95).fontSize(28).fontColor('#FFF').textAlign(TextAlign.Center).onClick(this.confirmFn)
}.margin({top:20})
}.width('65%').height('70%').padding(30).backgroundColor('#E6E3DF').borderRadius(38).position({y:'12%',x:'17.5%'}).justifyContent(FlexAlign.Center)
}.width('100%').height('100%').position({y:0}).backgroundColor('rgba(0,0,0,0.7)')
}
}

View File

@ -95,6 +95,7 @@ export default class Judge {
: ( projectCenterObj.isEnd ? 3 : 1 ) : ( projectCenterObj.isEnd ? 3 : 1 )
} }
}) })
console.info(judgeTag+'testKmItems',JSON.stringify(this.testKmItems)) console.info(judgeTag+'testKmItems',JSON.stringify(this.testKmItems))
this.isExamEnd = false; this.isExamEnd = false;
} }
@ -170,7 +171,7 @@ export default class Judge {
await fileLog.setExamJudgeData(beginExamInfo) await fileLog.setExamJudgeData(beginExamInfo)
await examJudgeBeginExam(beginExamInfo); await examJudgeBeginExam(beginExamInfo);
console.info(judgeTag, '6.开始考试注册完成') console.info(judgeTag, '6.开始考试注册完成')
avPlayer.playAudio([globalThis.singlePlay ? 'voice/ksks.WAV' : 'voice/监管成功.mp3']) avPlayer.playAudio([globalThis.singlePlay ? 'voice/ksks.wav' : 'voice/监管成功.mp3'])
if(!globalThis.singlePlay){ if(!globalThis.singlePlay){
this.videoData = await saveStartRecordVideo(`${name}_${kssycs}`) this.videoData = await saveStartRecordVideo(`${name}_${kssycs}`)
@ -542,7 +543,8 @@ export default class Judge {
judgeUI, judgeUI,
checkExamIsEnd, checkExamIsEnd,
checkProjectIsStart, checkProjectIsStart,
lane lane,
closeAllFiles
} = this; } = this;
const {projectsObj,judgeConfigObj,examSubject,examMileage,jl,isAllProjectsEnd} = judgeUI; const {projectsObj,judgeConfigObj,examSubject,examMileage,jl,isAllProjectsEnd} = judgeUI;
@ -640,6 +642,7 @@ export default class Judge {
judgeTask.addTask(async () => { judgeTask.addTask(async () => {
console.info(judgeTag, '考试结束 start') console.info(judgeTag, '考试结束 start')
globalThis.isJudge = false; globalThis.isJudge = false;
closeAllFiles()
await handEndExam(ksjs) await handEndExam(ksjs)
}) })
clearInterval(globalThis.judgeTimer) clearInterval(globalThis.judgeTimer)
@ -1062,10 +1065,11 @@ export default class Judge {
if(code != 1){ if(code != 1){
avPlayer.playAudio(['voice/监管失败.mp3']) avPlayer.playAudio(['voice/监管失败.mp3'])
this.judgeUI.errorMsg = decodeURIComponent(message)
this.isUdpEnd = true this.isUdpEnd = true
router.back();
return return
} }
console.info(judgeTag, '考试结束 end') console.info(judgeTag, '考试结束 end')
const param302 = judgeConfigObj['302']; const param302 = judgeConfigObj['302'];
judgeUI.loadingPopupVisible = true; judgeUI.loadingPopupVisible = true;
@ -1566,7 +1570,7 @@ export default class Judge {
const msgStr = strArr[num]; const msgStr = strArr[num];
if(msgStr == ''){ if(msgStr == ''){
console.info(judgeTag, '模拟数据考试结束') console.info(judgeTag, '模拟数据考试结束')
// globalThis.windowClass.setWindowSystemBarEnable(['navigation']) globalThis.windowClass.setWindowSystemBarEnable(['navigation'])
clearInterval(judgeTimer) clearInterval(judgeTimer)
this.checkExamIsEnd(true) this.checkExamIsEnd(true)
return return
@ -1664,6 +1668,11 @@ export default class Judge {
} }
} }
closeAllFiles = ()=>{
this.fileLog.closeAllFiles()
}
public plcStr: string public plcStr: string
private judgeUI private judgeUI
private fileLog private fileLog

View File

@ -14,8 +14,8 @@ interface StuInfo{
} }
const LOGTAG = 'LOGTAG' const LOGTAG = 'LOGTAG'
export default class FileLog {
export default class FileLog {
//后续文件路径待替换 //后续文件路径待替换
private fileUtil: FileUtil private fileUtil: FileUtil
private stuInfo: StuInfo private stuInfo: StuInfo
@ -105,6 +105,14 @@ export default class FileLog {
this.fourAndOneLogDataBytesFd = await fileUtil.editFile(`${folderPath}/four_one_log_byte_data.txt`, str, fourAndOneLogDataBytesFd); this.fourAndOneLogDataBytesFd = await fileUtil.editFile(`${folderPath}/four_one_log_byte_data.txt`, str, fourAndOneLogDataBytesFd);
} }
//关闭所有文件写入
public closeAllFiles = async () => {
const {fileUtil,folderPath,fourAndOneLogDataFd} = this;
['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 => {
fileUtil.closeFile(`${folderPath}/${path}.txt`);
})
}
// 无锡所轨迹数据 // 无锡所轨迹数据
public setExamLineData = async (plcStr) => { public setExamLineData = async (plcStr) => {
const {fileUtil,folderPath,examLineDataFd} = this; const {fileUtil,folderPath,examLineDataFd} = this;

Binary file not shown.