feat: 添加上下文支持到视频录制功能,优化UDP信号处理和照片上传逻辑
This commit is contained in:
parent
d1bbbef2e6
commit
95825e2b77
@ -144,6 +144,7 @@ export default class Judge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public plcStr: string
|
public plcStr: string
|
||||||
|
private context: common.UIAbilityContext
|
||||||
private judgeUI
|
private judgeUI
|
||||||
// 检测扣分、结束项目时该项目是否开始
|
// 检测扣分、结束项目时该项目是否开始
|
||||||
checkProjectIsStart = async (xmdm, currentType: 1 | 2, kf?: KF) => {
|
checkProjectIsStart = async (xmdm, currentType: 1 | 2, kf?: KF) => {
|
||||||
@ -261,6 +262,40 @@ export default class Judge {
|
|||||||
private isExamEnd: boolean
|
private isExamEnd: boolean
|
||||||
// 是否发送udp
|
// 是否发送udp
|
||||||
private isUdpEnd: boolean = false
|
private isUdpEnd: boolean = false
|
||||||
|
// 处理udp plc信号
|
||||||
|
handleUdp = async (msg) => {
|
||||||
|
console.info('plc信号', msg)
|
||||||
|
// const { fileLog, getPlcData, usbService, isUdpEnd, isExamEnd, judgeUI } = this
|
||||||
|
const stachArr = msg.split(',')
|
||||||
|
if (stachArr[0] != '#DN_GD' || this.isUdpEnd) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const plcData = await this.getPlcData(msg);
|
||||||
|
// 4.过程数据
|
||||||
|
await this.fileLog.setExamJudgeData(plcData)
|
||||||
|
//检测到有无锡所设备接入,需要发送特定的数据,供检测
|
||||||
|
if (this.usbService.isWXUSBDevice) {
|
||||||
|
const str = await senorToWXDataStr(msg);
|
||||||
|
this.usbService.sendUSB(str)
|
||||||
|
}
|
||||||
|
const param350 = 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('udpIndex') as number;
|
||||||
|
let [prevJd, preWd] = [0, 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
|
private isManual: boolean
|
||||||
//UDP服务序列号
|
//UDP服务序列号
|
||||||
@ -447,40 +482,6 @@ export default class Judge {
|
|||||||
|
|
||||||
return tempData
|
return tempData
|
||||||
}
|
}
|
||||||
// 处理udp plc信号
|
|
||||||
handleUdp = async (msg) => {
|
|
||||||
console.info('plc信号', msg)
|
|
||||||
// const { fileLog, getPlcData, usbService, isUdpEnd, isExamEnd, judgeUI } = this
|
|
||||||
const stachArr = msg.split(',')
|
|
||||||
if (stachArr[0] != '#DN_GD' || this.isUdpEnd) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const plcData = await this.getPlcData(msg);
|
|
||||||
// 4.过程数据
|
|
||||||
await this.fileLog.setExamJudgeData(plcData)
|
|
||||||
//检测到有无锡所设备接入,需要发送特定的数据,供检测
|
|
||||||
if (this.usbService.isWXUSBDevice) {
|
|
||||||
const str = await senorToWXDataStr(msg);
|
|
||||||
this.usbService.sendUSB(str)
|
|
||||||
}
|
|
||||||
const param350 = 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('udpIndex') as number;
|
|
||||||
let [prevJd, preWd] = [0, 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信号
|
// 处理轨迹plc信号
|
||||||
handleTrajectoryUdp = async (strArr) => {
|
handleTrajectoryUdp = async (strArr) => {
|
||||||
// const { fileLog, setJudgeItem, setJudgeMark, endExam } = this;
|
// const { fileLog, setJudgeItem, setJudgeMark, endExam } = this;
|
||||||
@ -524,6 +525,67 @@ export default class Judge {
|
|||||||
private isTrajectoryOpen: boolean;
|
private isTrajectoryOpen: boolean;
|
||||||
// 调代理接口是否断网了
|
// 调代理接口是否断网了
|
||||||
private isJudgeDisConnect: boolean;
|
private isJudgeDisConnect: boolean;
|
||||||
|
// 考试过程照片
|
||||||
|
uploadProgressPhoto = async (ksxm) => {
|
||||||
|
const time = await getCurrentTime();
|
||||||
|
const { judgeUI, plcData, getPhoto, fileLog, filePath } = this;
|
||||||
|
const photoBase64 = await getPhoto();
|
||||||
|
const carInfo = AppStorage.get('carInfo');
|
||||||
|
const { examSubject, plateNo, carNo } = carInfo;
|
||||||
|
const { lsh, idCard, serialNumber, projectsObj, ksdd, judgeConfigObj } = judgeUI;
|
||||||
|
const { sensor, gps } = plcData
|
||||||
|
const project = projectsObj[ksxm]
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
xtlb: '17',
|
||||||
|
jkxlh: serialNumber,
|
||||||
|
jkid: '17C54',
|
||||||
|
drvexam: {
|
||||||
|
lsh,
|
||||||
|
kskm: examSubject,
|
||||||
|
ksxm: project.projectCodeCenter,
|
||||||
|
sfzmhm: idCard,
|
||||||
|
kchp: encodeURI(plateNo),
|
||||||
|
zpsj: time,
|
||||||
|
zp: photoBase64,
|
||||||
|
cs: Math.floor((judgeConfigObj['350'] == 0 ? gps.sd : sensor.cs) * 1.852),
|
||||||
|
ksdd: encodeURI(ksdd)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { code } = await this.sendWriteObjectOut(data, filePath);
|
||||||
|
if (code === 2300007) {
|
||||||
|
this.isJudgeDisConnect = true
|
||||||
|
}
|
||||||
|
promptWxCode('17C54', code)
|
||||||
|
console.info(judgeTag, '上传照片 end')
|
||||||
|
}
|
||||||
|
private artSubject3ProjectsCodesArr: number[] = [3, 9, 4, 10, 12, 11]
|
||||||
|
private lane: LANE = {
|
||||||
|
road: '', num: 0, count: 0
|
||||||
|
}
|
||||||
|
private videoData: any
|
||||||
|
private disConnectNum: number = 0;
|
||||||
|
//调用监管接口
|
||||||
|
sendWriteObjectOut = async (data, filePath) => {
|
||||||
|
const temp = await writeObjectOut(data, filePath);
|
||||||
|
console.log("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) {
|
||||||
|
console.info('surenjun', '123')
|
||||||
|
this.judgeUI.errorMsg = '当前的考试过程信息网络传输异常,程序点击确认将重启!';
|
||||||
|
this.judgeUI.disConnectErrorOpen = true
|
||||||
|
}
|
||||||
|
|
||||||
|
this.disConnectNum = 0
|
||||||
|
return temp
|
||||||
|
}
|
||||||
// 项目开始接口同步
|
// 项目开始接口同步
|
||||||
beginProject = async (ksxm) => {
|
beginProject = async (ksxm) => {
|
||||||
const carInfo = AppStorage.get('carInfo');
|
const carInfo = AppStorage.get('carInfo');
|
||||||
@ -596,67 +658,6 @@ export default class Judge {
|
|||||||
console.info(judgeTag, '项目结束 end')
|
console.info(judgeTag, '项目结束 end')
|
||||||
promptWxCode('17C55', code)
|
promptWxCode('17C55', code)
|
||||||
}
|
}
|
||||||
private artSubject3ProjectsCodesArr: number[] = [3, 9, 4, 10, 12, 11]
|
|
||||||
private lane: LANE = {
|
|
||||||
road: '', num: 0, count: 0
|
|
||||||
}
|
|
||||||
private videoData: any
|
|
||||||
private disConnectNum: number = 0;
|
|
||||||
//调用监管接口
|
|
||||||
sendWriteObjectOut = async (data, filePath) => {
|
|
||||||
const temp = await writeObjectOut(data, filePath);
|
|
||||||
console.log("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) {
|
|
||||||
console.info('surenjun', '123')
|
|
||||||
this.judgeUI.errorMsg = '当前的考试过程信息网络传输异常,程序点击确认将重启!';
|
|
||||||
this.judgeUI.disConnectErrorOpen = true
|
|
||||||
}
|
|
||||||
|
|
||||||
this.disConnectNum = 0
|
|
||||||
return temp
|
|
||||||
}
|
|
||||||
// 考试过程照片
|
|
||||||
uploadProgressPhoto = async (ksxm) => {
|
|
||||||
const time = await getCurrentTime();
|
|
||||||
const { judgeUI, plcData, getPhoto, fileLog, filePath } = this;
|
|
||||||
const photoBase64 = await getPhoto();
|
|
||||||
const carInfo = AppStorage.get('carInfo');
|
|
||||||
const { examSubject, plateNo, carNo } = carInfo;
|
|
||||||
const { lsh, idCard, serialNumber, projectsObj, ksdd, judgeConfigObj } = judgeUI;
|
|
||||||
const { sensor, gps } = plcData
|
|
||||||
const project = projectsObj[ksxm]
|
|
||||||
|
|
||||||
const data = {
|
|
||||||
xtlb: '17',
|
|
||||||
jkxlh: serialNumber,
|
|
||||||
jkid: '17C54',
|
|
||||||
drvexam: {
|
|
||||||
lsh,
|
|
||||||
kskm: examSubject,
|
|
||||||
ksxm: project.projectCodeCenter,
|
|
||||||
sfzmhm: idCard,
|
|
||||||
kchp: encodeURI(plateNo),
|
|
||||||
zpsj: time,
|
|
||||||
zp: photoBase64,
|
|
||||||
cs: Math.floor((judgeConfigObj['350'] == 0 ? gps.sd : sensor.cs) * 1.852),
|
|
||||||
ksdd: encodeURI(ksdd)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { code } = await this.sendWriteObjectOut(data, filePath);
|
|
||||||
if (code === 2300007) {
|
|
||||||
this.isJudgeDisConnect = true
|
|
||||||
}
|
|
||||||
promptWxCode('17C54', code)
|
|
||||||
console.info(judgeTag, '上传照片 end')
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(judgeUI) {
|
constructor(judgeUI) {
|
||||||
this.serialIndex = 1;
|
this.serialIndex = 1;
|
||||||
@ -1789,7 +1790,7 @@ export default class Judge {
|
|||||||
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}`, this.context)
|
||||||
}
|
}
|
||||||
|
|
||||||
const { examSubject, projectsObj } = this.judgeUI
|
const { examSubject, projectsObj } = this.judgeUI
|
||||||
|
|||||||
@ -79,7 +79,6 @@ export async function endRecordVideo(record_handleObj: RecordHandleType) {
|
|||||||
|
|
||||||
|
|
||||||
export async function saveStartRecordVideo(path: string, context?: common.UIAbilityContext): Promise<RecordHandleType> {
|
export async function saveStartRecordVideo(path: string, context?: common.UIAbilityContext): Promise<RecordHandleType> {
|
||||||
context = context || globalThis.context
|
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
const fileUtil = new FileUtil(context)
|
const fileUtil = new FileUtil(context)
|
||||||
const fileHelper = new FileHelper();
|
const fileHelper = new FileHelper();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user