fix: 优化拍照逻辑

This commit is contained in:
wangzhongjie 2025-08-06 14:57:59 +08:00
parent 3938e0761f
commit 829cb9e576
16 changed files with 251 additions and 317 deletions

View File

@ -4,7 +4,7 @@ import window from '@ohos.window';
import { GlobalConfig } from '../config/global';
import Want from '@ohos.app.ability.Want';
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
import { BaseInfoType, CarInfoType, EnvironmentConfigurationType, ExaminerInfoType } from '../model';
import { BaseInfoType, CarInfoType, EnvironmentConfigurationType, ExaminerInfoType, VideoConfig } from '../model';
import DB from '../utils/DbSql';
import { DrivingDataStorage } from '../utils/business/DrivingDataStorage';
import { InitTable } from '../utils/table/Operation';
@ -20,7 +20,7 @@ export default class EntryAbility extends UIAbility {
await DB.init(this.context)
try {
let fileUtil = new FileUtils(this.context)
// 一些地址配置
// 读取系统设置参数
const data = await fileUtil.readFile(GlobalConfig.commonFileWriteAddress + '/config/ipConfig.txt');
if (data !== '' && data !== undefined) {
const result: EnvironmentConfigurationType = JSON.parse(data)
@ -32,6 +32,12 @@ export default class EntryAbility extends UIAbility {
const host = `http://${result.centerIp}:${result.centerPort}`
AppStorage.setOrCreate<string>("host", host)
}
// 读取视频配置
const videoData = await fileUtil.readFile(GlobalConfig.commonFileWriteAddress + '/config/config3.txt');
if (videoData !== '' && videoData !== undefined) {
const videoConfig: VideoConfig = JSON.parse(videoData)
AppStorage.setOrCreate<VideoConfig>("VideoConfig", videoConfig)
}
await InitTable()
} catch (e) {
console.error(EntryTag, 'sql first error', e)

View File

@ -8,7 +8,7 @@ import { uploadExamMileage } from '../api/judge';
import DwztErrorPopup from './compontents/judge/DwztErrorPopup';
import MsgPopup from './compontents/judge/MsgPopup';
import { JudgeConfig, JudgeTag } from '../config';
import JudgeAndProjectComponent from './Judge/components/JudgeAndProject';
import {
AmplifyItem,
CARINFO,
@ -30,6 +30,8 @@ import {
MarkRule,
MarkRules,
MASYSSETTableType,
PerLane,
ProcessDataEnumType,
Project,
ProjectInfo,
ProjectInfos,
@ -37,23 +39,20 @@ import {
SYSSET,
SyssetConfig,
SYSTEMPARMARR,
User,
ProcessDataEnumType,
PerLane
User
} from '../model';
import { GetSyncData } from '../utils/table/Operation';
import dayTs from '../utils/Date';
import { GetCurrentTime } from '../utils/Common';
import FileUtils from '../utils/FileUtils';
import SignalTrajectoryDialog from './Judge/SignalTrajectoryDialog';
import { DefaultJudgeConfigData, InitialPerLane, ProcessDataMock } from '../mock';
import SignalTrajectoryDialog from './Judge/components/SignalTrajectoryDialog';
import { DefaultJudgeConfigData, InitialPerLane } from '../mock';
import { dConsole } from '../utils/LogWorker';
import ConfirmDialog from './compontents/ConfirmDialog';
import CarLoadingDialog from './compontents/CarLoading';
import HeaderComponent from './compontents/Header';
import MessageComponent from './Judge/Message';
import OperatingAreaComponent from './Judge/OperatingArea';
import JudgeAndProjectComponent from './Judge/JudgeAndProject';
import MessageComponent from './Judge/components/Message';
import OperatingAreaComponent from './Judge/components/OperatingArea';
import { GetIsExitManualProject } from './Judge/utils';
import { InitMapPoint, InitMapPointItem } from './Judge/TableUtils';
@ -148,9 +147,6 @@ struct JudgePage {
@State isErrorMsgEnd: boolean = false
@State disConnectErrorOpen: boolean = false
@State @Watch("laneSignalChange") laneSignal: PerLane = InitialPerLane
laneSignalChange(){
dConsole.log("车道信号变化1",this.laneSignal)
}
public context = getContext(this) as common.UIAbilityContext;
// 信号查看弹窗
signalTrajectoryDialogController: CustomDialogController = new CustomDialogController({
@ -201,6 +197,10 @@ struct JudgePage {
customStyle: true
})
laneSignalChange() {
dConsole.log("车道信号变化1", this.laneSignal)
}
async aboutToDisappear() {
this.generateExamRecordsDialogController.close()
clearInterval(this.mileageTimer)
@ -250,7 +250,7 @@ struct JudgePage {
//是否开启轨迹回放模式
if (JudgeConfig.isTrajectoryOpen) {
this.initTrajectoryParam(JudgeConfig.trajectoryPath)
this.initTrajectoryParam()
} else {
await this.initSystemParam()
await this.initMarkRules();
@ -638,11 +638,10 @@ struct JudgePage {
}
// 初始化本地systemparam表、markrule表
async initTrajectoryParam(trajectoryPath: string) {
const isTrajectoryOpen = JudgeConfig.isTrajectoryOpen
async initTrajectoryParam() {
//轨迹回放读取 systemparam表、markrule表
const fileUtil = new FileUtils(this.context);
const folderPath = await fileUtil.initFolder(trajectoryPath);
const folderPath = await fileUtil.initFolder(JudgeConfig.trajectoryPath);
const str = await fileUtil.readFile(folderPath);
const strArr = str.split('\n');
const initData = strArr[0]
@ -652,7 +651,7 @@ struct JudgePage {
const beginDataObj: JudgeBeginObj = JSON.parse(beginData)
const examSubject = this.carInfo.examSubject;
this.examSubject = (isTrajectoryOpen ? (initDataObj.kskm) : examSubject) + '';
this.examSubject = (JudgeConfig.isTrajectoryOpen ? (initDataObj.kskm) : examSubject) + '';
this.carInfo.examSubject = this.examSubject
this.singlePlay = beginDataObj.exam == 0;
this.carName = initDataObj.name;
@ -789,8 +788,7 @@ struct JudgePage {
confirmMark: async (item: string, serial: string) => {
clearTimeout(this.popTimer)
this.popTimer = setTimeout(async () => {
const judge = this.judge
await judge.setJudgeMark(item, serial);
await this.judge.setJudgeMark(item, serial);
this.isDeductedPopShow = false
this.popTimer = null;
}, 500)
@ -806,8 +804,7 @@ struct JudgePage {
confirmAmplify: async (amplify: AmplifyItem) => {
clearTimeout(this.popTimer)
this.popTimer = setTimeout(async () => {
const judge = this.judge
await judge.setJudgeItem(amplify.projectCode, 1);
await this.judge.setJudgeItem(amplify.projectCode, 1);
this.isAmplifyPopShow = false
this.popTimer = null;
}, 500)
@ -856,7 +853,6 @@ struct JudgePage {
const isManualProjectIn = this.isManualProjectIn;
const artSubject3ProjectsCodesArr = this.artSubject3ProjectsCodesArr;
const projectsObj = this.projectsObj;
const projectCode = artSubject3ProjectsCodesArr[index]
let sideParkingStatus = GetIsExitManualProject(index, this.judgeConfigObj, this.artSubject3ProjectsCodesArr, this.projectsObj, this.carztStr, this.isManualProjectIn, this.isProjectIn, this.jl, this.examMileage, this.isRequiredProjectsEnd, this.lane)
if (index === 5) {
@ -888,8 +884,7 @@ struct JudgePage {
this.amplifiedImgIndex = index;
this.isAmplifyPopShow = true
} else {
const judge = this.judge
await judge.setJudgeItem(projectCode, 1);
await this.judge.setJudgeItem(projectCode, 1);
}
} else {
if (index === 5) {

View File

@ -2,13 +2,6 @@ import libJudgeSdk from '@ohos.judgesdk';
import { DistanceParam, JudgeBeginObj, JudgeInitObj, PLCType } from '../../model';
import { dConsole } from '../../utils/LogWorker';
/**
* 苏仁君
* @date 2023/04/10
* @desc 调用c++评判库
**/
/**
*
* @desc 获取版本信息
@ -122,12 +115,7 @@ export async function examJudgeBeginExam(data: JudgeBeginObj) {
}
/* @params level日志等级infoStr日志信息len数据长度
* @desc处理日志文件
*/
// export function handleLog(level, infoStr, len) {
// //TODO
// }
/*
* @desc结束考试

View File

@ -1,8 +1,8 @@
import { JudgeTag } from '../../config';
import { DefaultJudgeConfigObj, LANE, MarkRule, ProjectInfo, ProjectInfos } from '../../model';
import { CutArray } from '../../utils/Common';
import { dConsole } from '../../utils/LogWorker';
import { GetIsEndManualProject, GetIsExitManualProject } from './utils';
import { JudgeTag } from '../../../config/index';
import { DefaultJudgeConfigObj, LANE, MarkRule, ProjectInfo, ProjectInfos } from '../../../model/index';
import { CutArray } from '../../../utils/Common';
import { dConsole } from '../../../utils/LogWorker';
import { GetIsEndManualProject, GetIsExitManualProject } from '../utils';
@Component
export default struct JudgeAndProjectComponent {
@ -190,7 +190,7 @@ export default struct JudgeAndProjectComponent {
ListItem() {
Text(project.name) {
}
.fontColor(this.getProjectColor(Reflect.get(this.projectsObj,project.projectCode)))
.fontColor(this.getProjectColor(Reflect.get(this.projectsObj, project.projectCode)))
.margin({ bottom: 2 })
.fontSize(24)
}.margin({ bottom: 2 })

View File

@ -1,3 +1,6 @@
/**
* 科目三手动扣分确认对话框
*/
@CustomDialog
export default struct ManualConfirmationOfSubjectThreeProjectsDialog {
private controller?: CustomDialogController

View File

@ -1,5 +1,5 @@
import { DefaultJudgeConfigObj } from '../../model'
import { FormatTimeFlexible } from '../../utils/Common'
import { DefaultJudgeConfigObj } from '../../../model/index'
import { FormatTimeFlexible } from '../../../utils/Common'
@Component
export default struct MessageComponent {

View File

@ -1,4 +1,4 @@
import { DefaultJudgeConfigObj } from '../../model'
import { DefaultJudgeConfigObj } from '../../../model/index'
import Prompt from '@system.prompt'
@Component

View File

@ -1,19 +1,18 @@
import { PerLane } from '../../model'
import { dConsole } from '../../utils/LogWorker'
import SignalDisplayComponent from '../compontents/SignalDisplay'
import TabComponent from '../compontents/Tab'
import { PerLane } from '../../../model/index'
import { dConsole } from '../../../utils/LogWorker'
import SignalDisplayComponent from '../../compontents/SignalDisplay'
import TabComponent from '../../compontents/Tab'
@CustomDialog
export default struct SignalTrajectoryDialog {
@State active: number = 0
@Link @Watch("laneSignalChange") laneSignal: PerLane
private controller?: CustomDialogController
laneSignalChange() {
dConsole.log("车道信号变化222", this.laneSignal)
}
private controller?: CustomDialogController
build() {
// Scroll() {

View File

@ -1,3 +1,6 @@
/**
* 科目三手动扣分弹窗
*/
@CustomDialog
export default struct SubjectThreeManualDeductionOfPointsDialog {
private controller?: CustomDialogController

View File

@ -11,11 +11,16 @@ import {
ProjectInfos,
ProjectRoads,
Radar,
VideoConfig,
Vision
} from '../../model';
import { ArrayToByteArray, NumberToByteArray } from '../../utils/Common';
import dayTs from '../../utils/Date';
import { dConsole } from '../../utils/LogWorker';
import common from '@ohos.app.ability.common';
import { JudgeConfig, JudgeTag } from '../../config';
import { takePhoto } from '../../utils/Video';
import Prompt from '@system.prompt';
// 中心信号转换
@ -832,3 +837,4 @@ export const GetIsEndManualProject = (index: number, artSubject3Projects: string
}
return (type == '3' || type == '4') ? `${projectName}_red` : `${projectName}_green`;
}

View File

@ -6,7 +6,6 @@ import testNapi from '@ohos.idcard';
import IDCardSDK from '@ohos.idcard';
import common from '@ohos.app.ability.common';
import promptAction from '@ohos.promptAction';
import FilePhoto from './judgeSDK/utils/filePhoto';
import { CandidateData, EmptyCandidateObject } from '../mock/CandidateData';
import BoardPrePareSetPopup from './compontents/judge/BoardPrePareSetPopup';
@ -37,7 +36,7 @@ import { BusinessError } from '@ohos.base';
import { GetSyncData, SqlInsertTable } from '../utils/table/Operation';
import { CheckSignal, GetCurrentUserKeyValue, InitializeExamProcessData } from './UserInfo/utils';
import dayTs from '../utils/Date';
import { GetCurrentTime, NumberToByteArray } from '../utils/Common';
import { GetCurrentTime, GetPhotoBase64, NumberToByteArray } from '../utils/Common';
import DB from '../utils/DbSql';
import { CenterUDPBusinessInstance } from '../utils/business/CenterUdpBusiness';
import { JudgeEmitterInstance } from '../utils/business/UdpEvent';
@ -154,17 +153,6 @@ struct UserInfoPage {
@State startExam: boolean = false
@State singlePlay: boolean = false
private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
private filePhoto!: FilePhoto
// 过程照片拍照
getPhoto = async () => {
//单机模式返回空照片
if (this.singlePlay) {
return ''
} else {
const photoBase64: string = (await this.filePhoto.getPhoto()) || "";
return photoBase64
}
}
private avPlayer!: VoiceAnnounce
private labelBlocks: LabelBlockType[] = [
{ label: '考生姓名', key: 'xm' },
@ -229,7 +217,6 @@ struct UserInfoPage {
this.startExam = false
this.updateTimeLimit = false
this.currentUser = EmptyCandidateObject
this.filePhoto = new FilePhoto(this.context);
this.singlePlay = AppStorage.get<boolean>('singlePlay') || false
dConsole.log("this.singlePlay", this.singlePlay)
this.examinerLoginInfo = AppStorage.get<ExaminerLoginInfo>('examinerInfo')!
@ -907,7 +894,7 @@ struct UserInfoPage {
dConsole.log(StartExamTag, "开始考试")
const startHourTime = dayTs().format("HHmmssSSS")
AppStorage.setOrCreate('startHourTime', startHourTime)
const photoBase64 = await this.getPhoto();
const photoBase64 = await GetPhotoBase64(this.context);
if (photoBase64 == '') {
dConsole.log(StartExamTag, "拍照失败")
this.startExamDialogController.close()

View File

@ -75,6 +75,8 @@ struct VideoConfigPage {
const folderPath = await this.fileUtil.initFolder(`/config`);
dConsole.log(this.oldVideoConfig.videoNum, this.videoConfig.videoNum, "查看")
this.fileUtil.addFile(`${folderPath}/config3.txt`, JSON.stringify(this.videoConfig))
AppStorage.setOrCreate<VideoConfig>("VideoConfig", this.videoConfig)
this.fileUtil.closeFile(`${folderPath}/config3.txt`)
}
async getFileHandleCode(td: number): Promise<Boolean> {

View File

@ -4,9 +4,8 @@ import common from '@ohos.app.ability.common';
import VoiceAnnounce from '../../judgeSDK/utils/voiceAnnouncements';
import { writeObjectOut } from '../../../api/judge';
import JudgeTask from '../../judgeSDK/utils/judgeTask';
import FilePhoto from '../../judgeSDK/utils/filePhoto';
import { CarInfoType, MarkRule, MASYSSETTableType, RegulatoryInterfaceParams, User } from '../../../model';
import { GetCurrentTime } from '../../../utils/Common';
import { GetCurrentTime, GetPhotoBase64 } from '../../../utils/Common';
import FileUtils from '../../../utils/FileUtils';
import { GetSyncData } from '../../../utils/table/Operation';
import { dConsole } from '../../../utils/LogWorker';
@ -69,17 +68,6 @@ export default struct DeductedPopup {
}
private context = getContext(this) as common.UIAbilityContext;
private judgeTask!: JudgeTask
private filePhoto!: FilePhoto
// 过程照片拍照
getPhoto = async (empty?: boolean) => {
//单机模式返回空照片
if (this.singlePlay) {
return ''
} else {
const photoBase64: string = await this.filePhoto.getPhoto() || "";
return photoBase64
}
}
private avPlayer!: VoiceAnnounce
async aboutToAppear() {
@ -87,8 +75,6 @@ export default struct DeductedPopup {
this.singlePlay = AppStorage.get<boolean>('singlePlay')!
this.avPlayer = new VoiceAnnounce(this.context);
this.judgeTask = new JudgeTask();
const mediaTest = new FilePhoto(this.context);
this.filePhoto = mediaTest
//上车准备
// this.universalMarkRules = this.markRules.filter(item => this.currentItems.includes(item.itemno+''))
// const { isTrajectoryOpen } = judgeConfig;
@ -205,7 +191,7 @@ export default struct DeductedPopup {
// const { examSubject, plateNo, carNo } = carInfo;
const time = GetCurrentTime();
dConsole.info('surenjun uploadProgressPhoto',)
const photoBase64 = await this.getPhoto()
const photoBase64 = await GetPhotoBase64(this.context)
const photoData: RegulatoryInterfaceParams = {
xtlb: '17',
jkxlh: this.serialNumber.toString(),
@ -279,7 +265,7 @@ export default struct DeductedPopup {
//考试结束
async endFn() {
const time = GetCurrentTime();
const photoBase64 = await this.getPhoto()
const photoBase64 = await GetPhotoBase64(this.context)
const endData: RegulatoryInterfaceParams = {
xtlb: '17',
jkxlh: this.serialNumber.toString(),

View File

@ -5,7 +5,6 @@ import buffer from '@ohos.buffer';
import VoiceAnnounce from './utils/voiceAnnouncements';
import FileModel from './utils/fileModel';
import FilePhoto from './utils/filePhoto';
import JudgeTask from './utils/judgeTask';
import { JudgeConfig, JudgeTag } from '../../config';
import { GetSyncData, SqlInsertTable } from '../../utils/table/Operation';
@ -14,7 +13,7 @@ import { uploadExamProgressData, writeObjectOut } from '../../api/judge';
import { endRecordVideo, saveStartRecordVideo } from '../../utils/Video';
import common from '@ohos.app.ability.common';
import { ConvertDdmmToDecimalDegrees, DeepClone, GetCurrentTime } from '../../utils/Common';
import { ConvertDdmmToDecimalDegrees, DeepClone, GetCurrentTime, GetPhotoBase64 } from '../../utils/Common';
import UsbService from '../../utils/USB';
import FileUtils from '../../utils/FileUtils';
import {
@ -164,19 +163,6 @@ export default class Judge {
private xmdm: string | number = ""
private xmxh: string = ""
private fileModel?: FileModel
private filePhoto?: FilePhoto
// 过程照片拍照
getPhoto = async (empty?: boolean) => {
const singlePlay: boolean = AppStorage.get<boolean>('singlePlay') || false
//单机模式返回空照片
if (singlePlay) {
return ''
} else {
const photoBase64 = await this.filePhoto?.getPhoto();
dConsole.info(JudgeTag, '拍照完成')
return photoBase64
}
}
private usbService: UsbService
//是否是考试模式
private isExam: boolean
@ -184,48 +170,6 @@ 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服务序列号
@ -270,60 +214,6 @@ 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 () => {
@ -374,40 +264,47 @@ export default class Judge {
AppStorage.setOrCreate('msgStr', plc)
return tempData
}
// 处理轨迹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)
// 处理udp plc信号
handleUdp = async (msg: string) => {
const stachArr = msg.split(',')
if (stachArr[0] != '#DN_GD' || this.isUdpEnd) {
return
}
const msg: PLCType = JSON.parse(strArr[num]);
num++
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.过程数据
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)
// 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)
}
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;
// 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 isEndTip: boolean = false;
//本地轨迹回放地址
@ -427,6 +324,32 @@ export default class Judge {
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');
@ -501,7 +424,7 @@ export default class Judge {
const time = GetCurrentTime();
const judgeUI = this.judgeUI
const plcData = this.plcData
const photoBase64 = await this.getPhoto();
const photoBase64 = await GetPhotoBase64(this.context);
const carInfo = AppStorage.get<CarInfoType>('carInfo');
const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, ksxm)
@ -530,32 +453,6 @@ 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;
@ -674,6 +571,95 @@ 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;
@ -686,7 +672,6 @@ export default class Judge {
this.fileUtil = new FileUtils(judgeUI.context)
this.judgeTask = new JudgeTask()
this.usbService = new UsbService();
this.filePhoto = new FilePhoto(judgeUI.context);
this.kfArr = judgeUI.kfArr
this.xmmcStr = '';
this.xmmcCode = '';
@ -785,7 +770,6 @@ export default class Judge {
// 获取开始考试数据
getJudgeBeginData = async () => {
const examinerInfo = AppStorage.get<ExaminerInfoType>('examinerInfo')
// const code = examinerInfo.code
const examinerName = examinerInfo?.name || ""
let currentParams: RouteParamsType = router.getParams() as RouteParamsType;
@ -1407,7 +1391,6 @@ export default class Judge {
const judgeUI = this.judgeUI
const ksjs = this.ksjs
const getPhoto = this.getPhoto
const avPlayer = this.avPlayer
const kfArr = this.kfArr
const filePath = this.filePath
@ -1423,7 +1406,7 @@ export default class Judge {
//TODO 断网考试结束补传
// await uploadDisConnectData();
const time = GetCurrentTime();
const photoBase64 = await getPhoto();
const photoBase64 = await GetPhotoBase64(this.context);
const d1 = ksjs?.d1 || 0;
const d2 = ksjs?.d2 || 0;
const d3 = ksjs?.d3 || 0;
@ -1862,14 +1845,11 @@ export default class Judge {
const judgeUI = this.judgeUI;
const name = judgeUI.name
const lsh = judgeUI.lsh
const idCard = judgeUI.idCard
const kssycs = judgeUI.kssycs
const manualMarkRules = judgeUI.manualMarkRules
const getJudgeBeginData = this.getJudgeBeginData;
const handDistance = this.getJudgeBeginData;
const handleTrajectoryUdp = this.handleTrajectoryUdp;
const isTrajectoryOpen = this.isTrajectoryOpen;
const trajectoryPath = this.trajectoryPath;

View File

@ -1,50 +0,0 @@
import { takePhoto } from '../../../utils/Video';
import promptAction from '@ohos.promptAction';
import { JudgeConfig } from '../../../config';
import FileUtils from '../../../utils/FileUtils';
import { VideoConfig } from '../../../model/Common';
import common from '@ohos.app.ability.common';
import { dConsole } from '../../../utils/LogWorker';
export default class FilePhoto {
private params!: VideoConfig
private context!: common.UIAbilityContext
public getPhoto = async () => {
if (!JudgeConfig.isPhotoOpen) {
return ''
} else {
try {
dConsole.info('surenjun', '拍照开始')
const res = await takePhoto(this.params, this.context, 'pz/', 2);
dConsole.info('surenjun', '拍照结束' + JSON.stringify(res))
return res.base64
} catch (e) {
dConsole.error('surenjun =>拍照异常' + JSON.stringify(e))
promptAction.showToast({
message: '拍照异常,请联系工程人员!',
duration: 2000
});
return ''
}
}
}
constructor(context: common.UIAbilityContext) {
(async () => {
//TODO 309参数 获取拍照摄像头拍照通道
const fileUtil = new FileUtils(context)
const strConfig =
await fileUtil.readFile('/mnt/hmdfs/100/account/device_view/local/files/duolun/config/config3.txt');
const config: VideoConfig = JSON.parse(strConfig as string)
this.params = {
userName: config.userName,
pwd: config.pwd,
ip: config.ip,
port: config.port,
rlls: config.rlls,
pztd: config.pztd,
}
this.context = context
})()
}
}

View File

@ -1,10 +1,13 @@
import dayTs from './Date';
import fs from '@ohos.file.fs';
import { BusinessError } from '@ohos.base';
import { CommonFileTag } from '../config';
import { CommonFileTag, JudgeConfig, JudgeTag } from '../config';
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
import Prompt from '@system.prompt';
import common from '@ohos.app.ability.common';
import { dConsole } from './LogWorker';
import { takePhoto } from './Video';
import { VideoConfig } from '../model';
enum timeType {
fulltime = 1
@ -323,3 +326,29 @@ export async function UseAuth(context: common.UIAbilityContext): Promise<boolean
return false;
}
}
/**
* 获取拍照图片
*/
export const GetPhotoBase64 = async (context: common.UIAbilityContext): Promise<string> => {
// 获取视频参数
const videoConfig = AppStorage.get<VideoConfig>('videoConfig');
const singlePlay: boolean = AppStorage.get<boolean>('singlePlay') || false
if (!JudgeConfig.isPhotoOpen || singlePlay) {
return ""
} else {
try {
dConsole.info(JudgeTag, '拍照开始')
const res = await takePhoto(videoConfig, context, 'pz/', 2);
dConsole.info(JudgeTag, '拍照完成')
return res.base64
} catch (e) {
dConsole.error(JudgeTag, '拍照异常' + JSON.stringify(e))
Prompt.showToast({
message: '拍照异常,请检查摄像头是否正常',
duration: 3000
});
return ''
}
}
}