fix: 修改部分错误

This commit is contained in:
wangzhongjie 2025-02-18 13:22:38 +08:00
parent f041e2a8bb
commit c4856b956f
8 changed files with 173 additions and 193 deletions

View File

@ -1,5 +1,6 @@
import request from '../utils/Request'
import http from '@ohos.net.http'
import { FaceCompareResp } from '../model'
/**
* 照片比对
@ -20,7 +21,7 @@ interface FaceCompareParams {
}
export async function faceCompare(params: FaceCompareParams) {
return request<object>({
return request<FaceCompareResp>({
url: '/der2/services/imageCompare/base64ImageStrCompare.ws',
data: `<?xml version="1.0" encoding="UTF-8" ?>
<imageCompareReq>

View File

@ -22,6 +22,7 @@ export interface CarInfoType {
carId?: string;
examinationRoomId?: string;
plateNo?: string;
carNo?: string;
}

View File

@ -2,4 +2,12 @@ export interface AmplifyItem {
name: string;
projectCode: string;
projectCodeCenter: string;
}
export interface UDPParamType {
id?: number;
list?: number[];
carNo?: string;
placeId?: string;
sendCallback?: () => void;
}

View File

@ -12,3 +12,10 @@ interface Head {
resultMessage: string;
}
export interface FaceCompareResp {
imageCompareRsp: ImageCompareRsp
}
interface ImageCompareRsp {
head: Head;
}

View File

@ -7,8 +7,14 @@ import { string2Bytes } from '../../common/utils/tools';
import { takePhoto } from '../../service/videoService';
import { GlobalConfig } from '../../config/index';
import { VideoConfigData } from '../../mock';
import { VideoConfig } from '../../model';
import App from '@system.app';
import { CarInfoType, UDPParamType, VideoConfig } from '../../model';
interface ParamType {
id?: number;
list?: number[];
carNo?: string | undefined;
placeId?: string | undefined;
}
@Component
export default struct FaceCompare {
@ -30,13 +36,13 @@ export default struct FaceCompare {
@State showControls: boolean = false
@State isAutoPlay: boolean = true
@State signNum: number = 0;
@State carinfo: object = {};
@State carInfo: CarInfoType = {};
@State param: VideoConfig = VideoConfigData
private times = 1; //人脸比对失败次数, 超过3次将不会自动比对需要点击重新打开重新触发
private vocObj = null;
private vocObj: voiceService = null;
private controller: VideoController = new VideoController()
private fileUtil: FileUtil
private interval: any
private interval: number = -1
private context = getContext(this) as common.UIAbilityContext;
constructor() {
@ -114,7 +120,7 @@ export default struct FaceCompare {
this.showFaceCompare = !this.showFaceCompare
this.showFaceCompareFlag = !this.showFaceCompareFlag
this.faceCompareSucess = -1
AppStorage.setOrCreate('statue',2)
AppStorage.setOrCreate('statue', 2)
})
}
.width('88.9%')
@ -151,9 +157,7 @@ export default struct FaceCompare {
this.showFaceCompare = !this.showFaceCompare
this.showFaceCompareFlag = !this.showFaceCompareFlag
this.faceCompareSucess = -1
AppStorage.setOrCreate('statue',2)
AppStorage.setOrCreate('statue', 2)
})
}
.width('100%')
@ -167,7 +171,7 @@ export default struct FaceCompare {
async aboutToAppear() {
const fileUtil = new FileUtil(this.context)
this.carInfo=AppStorage.get('carInfo')
this.carInfo = AppStorage.get('carInfo')
this.fileUtil = fileUtil
this.getVideoConfig()
}
@ -179,13 +183,13 @@ export default struct FaceCompare {
}
getqkFn() {
let tmpList = [];
let tmpList: number[] = [];
tmpList.push(string2Bytes(AppStorage.get('signNum'), 1 * 8)[0])
const param = {
const param: ParamType = {
id: 41,
list: tmpList,
carNo: this.carInfo.carNo,
placeId: this.carInfo.examinationRoomId
carNo: this.carInfo?.carNo as string,
placeId: this.carInfo?.examinationRoomId
}
globalThis.udpClient2.sendMsgExt(param, this.context)
}
@ -200,12 +204,11 @@ export default struct FaceCompare {
sfzh: this.sfzh,
firstImage: this.firstImage.substr(22),
secondImage: data.base64,
type: 2,
verifyType: 1
type: "2",
verifyType: "1"
})
.then(res => {
console.log('mmmmm8', JSON.stringify(res))
// @ts-ignore
if (res.imageCompareRsp.head.resultCode == '0') {
this.controller.stop()
this.showFaceCompare = !this.showFaceCompare
@ -231,14 +234,13 @@ export default struct FaceCompare {
}
async heartMsg(context) {
let tmpList = []
async heartMsg() {
let tmpList: number[] = []
const str = this.lsh
console.log('this.lshbitbit', this.lsh, this.carInfo.carNo, this.carInfo.examinationRoomId)
for (let i = 0; i < str.length; i++) {
tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0])
}
const param = {
const param: UDPParamType = {
id: 46,
list: tmpList,
carNo: this.carInfo.carNo,
@ -251,7 +253,7 @@ export default struct FaceCompare {
clearInterval(this.interval)
this.interval = setInterval(() => {
if (this.callBackFlag) {
const param2 = {
const param2: UDPParamType = {
id: 47,
list: tmpList,
carNo: this.carInfo.carNo,
@ -272,7 +274,7 @@ export default struct FaceCompare {
this.faceCompareSucess = 1
clearInterval(this.interval)
} else if (val.body[13] == '0' && this.callBackFlag) {
AppStorage.setOrCreate('statue',2)
AppStorage.setOrCreate('statue', 2)
this.vocObj && this.vocObj.playAudio({
type: 1,
name: 'face_chekc_fail.wav'
@ -285,11 +287,11 @@ export default struct FaceCompare {
async getVideoConfig() {
console.log('faceEnterIn')
this.vocObj = new voiceService(async (status, val, next) => {
this.vocObj = new voiceService(async (status: string, val: string) => {
if (status == 'idle') {
if (val == 'face_check.mp3' || val == 'face_fail.mp3') {
if (this.times >= 3) {
AppStorage.setOrCreate('statue',3)
AppStorage.setOrCreate('statue', 3)
this.faceCompareSucess = -1;
this.vocObj && this.vocObj.playAudio({
type: 1,
@ -304,7 +306,7 @@ export default struct FaceCompare {
} else if (val == 'yzcg.wav') {
this.showFaceCompare = !this.showFaceCompare
this.showFaceCompareFlag = !this.showFaceCompareFlag
AppStorage.setOrCreate('statue',4)
AppStorage.setOrCreate('statue', 4)
this.faceCompareSucess = 1;
this.vocObj && this.vocObj.releasePlayer()

View File

@ -2,16 +2,16 @@ import router from '@ohos.router';
@CustomDialog
export default struct errorMsgDialog {
private controller?: CustomDialogController
cancel: () => void = () => {
}
confirm: () => void = () => {
}
dialogRatio: number = 0.8
title?: string
type: string //1 tip 2loading 3Dialog
@State angle: number = 0
@State ratio: number = 1700 / 960
private controller?: CustomDialogController
cancel: () => void = () => {
}
confirm: () => void = () => {
}
@Styles
commStyle(){
@ -47,17 +47,17 @@ export default struct errorMsgDialog {
Row() {
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Text(' 取 消 ')
.fontSize(24 * this.ratio* this.dialogRatio*0.6 )
.fontSize(24 * this.ratio * this.dialogRatio * 0.6)
.fontColor('#fff')
.width(60 * this.ratio* this.dialogRatio)
.width(60 * this.ratio * this.dialogRatio)
}
.commStyle()
.onClick(() => {
if (this.controller != undefined) {
const errorCode=AppStorage.Get('errorMsg');
const errorCode: number = AppStorage.get('errorMsg');
// const errorCodeFlage=AppStorage.Get('errorCodeFlage');
// console.log('errorCode',errorCode,errorCodeFlage)
if(errorCode==0){
if (errorCode == 0) {
router.replaceUrl({
url: 'pages/Index',
}, router.RouterMode.Single);
@ -67,65 +67,64 @@ export default struct errorMsgDialog {
this.cancel()
this.controller.close()
}
}).margin({ right: 10 * this.ratio * this.dialogRatio})
}).margin({ right: 10 * this.ratio * this.dialogRatio })
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Text(' 确 定 ')
.fontSize(24 * this.ratio* this.dialogRatio*0.6)
.fontSize(24 * this.ratio * this.dialogRatio * 0.6)
.fontColor('#fff')
.width(60 * this.ratio* this.dialogRatio)
.width(60 * this.ratio * this.dialogRatio)
}
.commStyle()
.onClick(() => {
const errorCode=AppStorage.Get('errorCode');
const errorCodeFlage=AppStorage.Get('errorCodeFlage');
console.log('errorCode',errorCode,errorCodeFlage)
if(errorCode==0&&errorCodeFlage){
router.replaceUrl({
url: 'pages/Index',
}, router.RouterMode.Single);
router.clear();
const errorCode: number = AppStorage.get('errorCode');
const errorCodeFlage: string = AppStorage.get('errorCodeFlage');
console.log('errorCode', errorCode, errorCodeFlage)
if (errorCode == 0 && errorCodeFlage) {
router.replaceUrl({
url: 'pages/Index',
}, router.RouterMode.Single);
router.clear();
}
console.log('errorCode',errorCode,errorCodeFlage)
}
console.log('errorCode', errorCode, errorCodeFlage)
if (this.controller != undefined){
if (this.controller != undefined) {
this.confirm()
this.controller.close()
}
}
}
)
)
}
.padding({ bottom: 20 })
}
}
.backgroundColor('#E6E3DF')
.borderRadius(19 * this.ratio)
.constraintSize({ minWidth: 520 })
}
.padding({bottom:20})
}
}
.
backgroundColor('#E6E3DF')
.borderRadius(19 * this.ratio)
.constraintSize({ minWidth: 520 })
}
aboutToAppear() {
AppStorage.SetOrCreate('errorMsg', 0);
aboutToAppear() {
AppStorage.SetOrCreate('errorMsg', 0);
setTimeout(() => {
console.log('this.type', this.type, this.angle)
if (this.type == '2') {
this.angle = 360
}
}, 1000)
if (this.type == '1') {
setTimeout(() => {
this.controller.close()
}, 2000)
console.log('this.type', this.type, this.angle)
if (this.type == '2') {
this.angle = 360
}
}, 1000)
if (this.type == '1') {
setTimeout(() => {
this.controller.close()
}, 2000)
}
}
}
aboutToDisappear() {
this.title = ''
this.angle = 0
AppStorage.SetOrCreate('errorCodeFlage', false);
}
aboutToDisappear() {
this.title = ''
this.angle = 0
AppStorage.SetOrCreate('errorCodeFlage', false);
}
}

View File

@ -5,7 +5,7 @@ import common from '@ohos.app.ability.common';
import VoiceAnnounce from '../../judgeSDK/utils/voiceAnnouncements';
import { getCurrentTime } from '../../../common/utils/tools';
import { MarkRule, SYSSET } from '../../judgeSDK/api/judgeSDK.d';
import { uploadExamProgressData, writeObjectOut } from '../../../api/judge';
import { writeObjectOut } from '../../../api/judge';
import JudgeTask from '../../judgeSDK/utils/judgeTask';
import FilePhoto from '../../judgeSDK/utils/filePhoto';
@ -17,10 +17,6 @@ interface SEL {
//考前模拟人工扣分
@Component
export default struct DeductedPopup {
private context = getContext(this) as common.UIAbilityContext;
private judgeTask: JudgeTask
private filePhoto: FilePhoto
private avPlayer
@State name: string = ''
@State idCard: string = ''
@State lsh: string = ''
@ -36,7 +32,7 @@ export default struct DeductedPopup {
kfdm: string,
markreal: number,
markcatalog: string
score:number
score: number
}[] = []
//开始考试前判绕车一周评判是否开启
@State isOpen: boolean = false
@ -57,27 +53,36 @@ export default struct DeductedPopup {
@State selectedLine: number = undefined
@State carInfo: object = {}
@State singlePlay: boolean = false
private closePopup: Function = () => {
}
private confirmMark: Function = (itemno: number, serial: string) => {
}
private endLoading: Function = () => {
}
@State selectedLineStyle: SEL = {
fontColor: '#FFF',
bgColor: '#B36E00'
}
// 过程照片拍照
getPhoto = async (empty?: boolean) => {
//单机模式返回空照片
if (this.singlePlay) {
return ''
} else {
const { filePhoto } = this;
const photoBase64 = await filePhoto.getPhoto();
return photoBase64
}
}
private context = getContext(this) as common.UIAbilityContext;
private judgeTask: JudgeTask
private filePhoto: FilePhoto
private avPlayer
async aboutToAppear() {
this.carInfo=AppStorage.get('carInfo')
this.singlePlay=AppStorage.get('singlePlay')
this.carInfo = AppStorage.get('carInfo')
this.singlePlay = AppStorage.get('singlePlay')
this.avPlayer = new VoiceAnnounce();
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;
const { isTrajectoryOpen } = judgeConfig;
if (isTrajectoryOpen) {
await this.initDb()
} else {
@ -97,7 +102,7 @@ export default struct DeductedPopup {
//本地数据初始化
async initDb() {
const {isTrajectoryOpen,trajectoryPath} = judgeConfig
const { isTrajectoryOpen, trajectoryPath } = judgeConfig
const examSubject = this.carInfo.examSubject;
//轨迹回放读取 systemparam表、markrule表
const fileUtil = new FileUtil(this.context);
@ -112,29 +117,17 @@ export default struct DeductedPopup {
await this.initStudent()
}
// 过程照片拍照
getPhoto = async (empty?: boolean) => {
//单机模式返回空照片
if (this.singlePlay) {
return ''
} else {
const {filePhoto} = this;
const photoBase64 = await filePhoto.getPhoto();
return photoBase64
}
}
// 扣分操作
async pointsDedute() {
const index = this.currentIndex ? this.currentUniversalPageIndex : this.currentPageIndex;
const mark = this.universalMarkRules[index * 7 + this.selectedLine];
const {judgeConfigObj,kssycs,avPlayer,judgeTask} = this;
const { judgeConfigObj, kssycs, avPlayer, judgeTask } = this;
this.kfdmArr.push({
xmdm: 1,
kfdm: mark.markserial,
markreal: mark.markreal,
markcatalog: mark.markcatalog ,
score:mark.score
markcatalog: mark.markcatalog,
score: mark.score
})
const kfdmArr = this.kfdmArr
@ -151,7 +144,7 @@ export default struct DeductedPopup {
})))
if (judgeConfigObj['418'] == '1' || judgeConfig.kfVoiceOpen) {
avPlayer.playAudio([`voice/${mark.markcatalog}.mp3`,`voice/mark_${Math.abs(mark.score)}.mp3`], false, () => {
avPlayer.playAudio([`voice/${mark.markcatalog}.mp3`, `voice/mark_${Math.abs(mark.score)}.mp3`], false, () => {
this.closePopup(true)
});
return
@ -179,7 +172,8 @@ export default struct DeductedPopup {
}
;
let voiceURL = score < 90 ? `voice/${kssycs == '1' ? 'exam_no_pass_finish' : 'exam_no_pass'}.mp3` : 'voice/exam_pass.mp3'
let voiceURL =
score < 90 ? `voice/${kssycs == '1' ? 'exam_no_pass_finish' : 'exam_no_pass'}.mp3` : 'voice/exam_pass.mp3'
let kfScore = 0;
if (kfdmArr.length) {
@ -210,11 +204,13 @@ export default struct DeductedPopup {
async beginProject() {
//项目开始 //过程照片 //扣分 //结束考试
const carInfo = this.carInfo;
const { examSubject,plateNo } = carInfo;
const {serialNumber,lsh,idCard,ksxl,kslx,ksdd} = this
const { examSubject, plateNo } = carInfo;
const { serialNumber, lsh, idCard, ksxl, kslx, ksdd } = this
const time = await getCurrentTime();
const beginData = {
xtlb: '17', jkxlh: serialNumber, jkid: '17C52',
xtlb: '17',
jkxlh: serialNumber,
jkid: '17C52',
drvexam: {
// 考试科目 身份证号码
lsh,
@ -237,14 +233,16 @@ export default struct DeductedPopup {
//过程照片
async uploadProgressPhoto() {
const {serialNumber,lsh,idCard,ksdd,kfdmArr,getPhoto} = this;
const { serialNumber, lsh, idCard, ksdd, kfdmArr, getPhoto } = this;
const carInfo = this.carInfo;
const { examSubject,plateNo,carNo } = carInfo;
const { examSubject, plateNo, carNo } = carInfo;
const time = await getCurrentTime();
console.info('surenjun uploadProgressPhoto',)
const photoBase64 = await getPhoto()
const photoData = {
xtlb: '17', jkxlh: serialNumber, jkid: '17C54',
xtlb: '17',
jkxlh: serialNumber,
jkid: '17C54',
drvexam: {
lsh,
kskm: examSubject,
@ -265,14 +263,16 @@ export default struct DeductedPopup {
// 扣分
async kfFn() {
const {serialNumber,lsh,idCard,ksdd,kfdmArr} = this;
const { serialNumber, lsh, idCard, ksdd, kfdmArr } = this;
const kfLen = kfdmArr.length;
const kf = kfdmArr[kfLen -1];
const carInfo = this.carInfo;
const { examSubject} = carInfo;
const { examSubject } = carInfo;
const time = await getCurrentTime();
const kfData = {
xtlb: '17', jkxlh: serialNumber, jkid: '17C53',
xtlb: '17',
jkxlh: serialNumber,
jkid: '17C53',
drvexam: {
lsh,
kskm: examSubject,
@ -293,11 +293,13 @@ export default struct DeductedPopup {
// 项目结束
async endProject() {
const carInfo = this.carInfo;
const { examSubject,plateNo,carNo } = carInfo;
const {lsh,idCard,serialNumber,ksdd,kslx,ksxl,} = this;
const { examSubject, plateNo, carNo } = carInfo;
const { lsh, idCard, serialNumber, ksdd, kslx, ksxl, } = this;
const time = await getCurrentTime();
const endProjectData = {
xtlb: '17', jkxlh: serialNumber, jkid: '17C55',
xtlb: '17',
jkxlh: serialNumber,
jkid: '17C55',
drvexam: {
lsh,
kskm: examSubject,
@ -316,13 +318,15 @@ export default struct DeductedPopup {
//考试结束
async endFn() {
const {serialNumber,lsh,idCard,score,getPhoto} = this;
const { serialNumber, lsh, idCard, score, getPhoto } = this;
const carInfo = this.carInfo;
const { examSubject,plateNo } = carInfo;
const { examSubject, plateNo } = carInfo;
const time = await getCurrentTime();
const photoBase64 = await getPhoto();
const endData = {
xtlb: '17', jkxlh: serialNumber, jkid: '17C56',
xtlb: '17',
jkxlh: serialNumber,
jkid: '17C56',
drvexam: {
lsh,
kchp: decodeURI(plateNo),
@ -395,7 +399,7 @@ export default struct DeductedPopup {
const students = await getSyncData('USER')
const stuInfo = students[0] || {};
const {xm,sfzmhm,lsh,kszp,ksdd,kssycs,kslx,ksxl} = stuInfo;
const { xm, sfzmhm, lsh, kszp, ksdd, kssycs, kslx, ksxl } = stuInfo;
this.name = xm || '测试考生';
this.idCard = sfzmhm || '01234567891010';
this.lsh = lsh;
@ -420,7 +424,7 @@ export default struct DeductedPopup {
//选中扣分项
getSelectedLine(index) {
const {selectedLine,selectedLineStyle,lineBg} = this;
const { selectedLine, selectedLineStyle, lineBg } = this;
if (selectedLine === index) {
return selectedLineStyle.bgColor
}
@ -433,7 +437,7 @@ export default struct DeductedPopup {
//获取当前页的数据
getCurrentMarkRuleList() {
const {currentIndex,currentUniversalPageIndex,currentPageIndex,universalMarkRules} = this;
const { currentIndex, currentUniversalPageIndex, currentPageIndex, universalMarkRules } = this;
if (currentIndex) {
//通用评判
return universalMarkRules.slice(currentUniversalPageIndex * 7, (currentUniversalPageIndex + 1) * 7)
@ -477,7 +481,8 @@ export default struct DeductedPopup {
Row() {
if (
(Math.ceil(this.universalMarkRules.length / 7 - 1)) >= (this.currentIndex ? this.currentUniversalPageIndex : this.currentPageIndex) &&
(Math.ceil(this.universalMarkRules.length / 7 - 1)) >=
(this.currentIndex ? this.currentUniversalPageIndex : this.currentPageIndex) &&
(this.currentIndex ? this.currentUniversalPageIndex : this.currentPageIndex) > 0
) {
Row() {
@ -499,7 +504,8 @@ export default struct DeductedPopup {
}
if (
(Math.ceil(this.universalMarkRules.length / 7 - 1)) > (this.currentIndex ? this.currentUniversalPageIndex : this.currentPageIndex)
(Math.ceil(this.universalMarkRules.length / 7 - 1)) >
(this.currentIndex ? this.currentUniversalPageIndex : this.currentPageIndex)
) {
Row() {
Text('下一页') {
@ -560,7 +566,12 @@ export default struct DeductedPopup {
.height(710)
.position({ x: '10%', y: '10%' })
.backgroundColor('#E6E3DF')
.padding({ top: 15, bottom: 15, left: 25, right: 25 })
.padding({
top: 15,
bottom: 15,
left: 25,
right: 25
})
.borderRadius(20)
Row() {
@ -574,11 +585,20 @@ export default struct DeductedPopup {
//没有扣分项目通过
this.closePopup(this.kfdmArr.length ? true : false)
// judgeTask.addTask(async () => {
// await this.endProject()
// }, { isDelay: true })
// judgeTask.addTask(async () => {
// await this.endProject()
// }, { isDelay: true })
})
}.width('100%').height('100%').position({ y: 0 }).backgroundColor('rgba(0,0,0,0.7)')
}
private closePopup: Function = () => {
}
private confirmMark: Function = (itemno: number, serial: string) => {
}
private endLoading: Function = () => {
}
}

View File

@ -1,58 +0,0 @@
import Prompt from '@system.prompt'
const TAG = 'SURENJUN_JUDGE'
interface QUEUE{
fn:Function,
config?:{
isDelay:boolean
delayTime:number
}
}
export default class JudgeTask{
private queue = []
private status:string
constructor() {
this.queue = []
this.status = 'end'
}
executeQueue = async ()=>{
const {queue,executeQueue} = this
if(queue.length){
for (const currentTask of queue) {
const {fn,delayConfig:{
isDelay = false,
delayTime = 1000
}} = currentTask;
const {status} = this
try {
isDelay
?setTimeout(async ()=>{await fn()})
:await fn();
}catch (e){
// console.info(TAG,'过程数据接口解析错误')
Prompt.showToast({
message: '过程数据接口解析错误',
duration: 3000
});
}
this.queue.shift()
await executeQueue()
}
}else{
this.status = 'end'
}
}
addTask = async (fn,delayConfig?:{
isDelay:Boolean,
delayTime:Number
}) =>{
this.queue.push({fn,delayConfig});
if(this.status == 'end' && this.queue.length === 1){
await this.executeQueue();
}
}
}