feat:评判修改

This commit is contained in:
surenjun 2024-09-03 19:28:07 +08:00
parent 23a4b0829a
commit 2a32af7fa1
10 changed files with 145 additions and 33 deletions

View File

@ -32,10 +32,10 @@ export default async function writeObjectOutNew(data,filePath): Promise<WR> {
fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`,JSON.stringify({ fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`,JSON.stringify({
wglb,jkxlh,glbm,jgbh,sjbs, wglb,jkxlh,glbm,jgbh,sjbs,
data:params.data, data:params.data,
file:params.file, file:{...params.file,param:[]},
})); }));
return await request({ const temp = await request({
host: globalThis.JGHOST, host: globalThis.JGHOST,
method: 'post', method: 'post',
//是否是新中心 //是否是新中心
@ -61,6 +61,12 @@ export default async function writeObjectOutNew(data,filePath): Promise<WR> {
</SOAP-ENV:Body> </SOAP-ENV:Body>
</SOAP-ENV:Envelope>`, </SOAP-ENV:Envelope>`,
}) })
if(filePath){
const fileUtil = new FileUtil(globalThis.context);
await fileUtil.initFolder(filePath);
fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`,JSON.stringify(temp) +`\n`);
}
return temp
} }
export async function getParams(jkid, drvexam) { export async function getParams(jkid, drvexam) {

View File

@ -4,6 +4,7 @@ import { getSyncData } from '../service/initable'
import { getChuankouFn } from '../../common/service/indexService' import { getChuankouFn } from '../../common/service/indexService'
import FileUtil from '../../common/utils/File' import FileUtil from '../../common/utils/File'
import { GlobalConfig } from '../../config/index' import { GlobalConfig } from '../../config/index'
import emitter from '@ohos.events.emitter';
export async function sendMsg(val) { export async function sendMsg(val) {
// globalThis.udpClient1&&globalThis.udpClient1.sendMsg(val) // globalThis.udpClient1&&globalThis.udpClient1.sendMsg(val)
@ -178,6 +179,15 @@ export async function getUDP2(context,errorFlag?) {
console.log('getUDPOnmessageByGlobalUDP2Message') console.log('getUDPOnmessageByGlobalUDP2Message')
if (val.id == '32') { if (val.id == '32') {
globalThis.signNum = val.body[1] globalThis.signNum = val.body[1]
if(val.body[0] == 5){
}
if(val.body[0] == 11){
globalThis.udpEvent.sendBeginExam()
}
if(val.body[0] == 12){
globalThis.udpEvent.sendEndExam()
}
} else if (val.id == '46') { } else if (val.id == '46') {
let tmpList = [] let tmpList = []
@ -298,11 +308,18 @@ export async function setJudgeUdp() {
if (config && config.udplocalIp) { if (config && config.udplocalIp) {
const {udplocalIp} = config; const {udplocalIp} = config;
const udpClientbyCenter: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '8080', globalThis.carInfo?.udpAddress, globalThis.carInfo?.hintPort) const udpClientbyCenter: UdpClientByCenter = new UdpClientByCenter(
udplocalIp, '8080',
globalThis.carInfo?.udpAddress,
globalThis.carInfo?.hintPort
)
await udpClientbyCenter.onError_Callback(()=>{}) await udpClientbyCenter.onError_Callback(()=>{})
await udpClientbyCenter.bindUdp() await udpClientbyCenter.bindUdp()
await udpClientbyCenter.onMessage_2((val) => {}) await udpClientbyCenter.onMessage_2((val) => {})
//远程监听开始考试、结束考试、扣分指令
// globalThis.judgeUdpClient = udpClientbyCenter; // globalThis.judgeUdpClient = udpClientbyCenter;
return { return {
send(bytes) { send(bytes) {
@ -315,7 +332,15 @@ export async function setJudgeUdp() {
}) })
currentUdpIndex = udpIndex currentUdpIndex = udpIndex
} }
} },
//远程查询扣分项
//远程确认扣分
confirmKF(){
},
//远程开始考试
//远程结束考试
} }
} }

View File

@ -0,0 +1,71 @@
import emitter from '@ohos.events.emitter';
export const EVENTID = {
//远程扣分处理
kfEventId:35,
//远程扣分查询
kfAskEventId:36,
//远程扣分确认
kfConfirmEventId:37,
//远程开始考试
beginExamEventId:11,
//远程结束考试
endExamEventId:12
}
export default class JudgeEmitter{
private beginExamCallBack:Function = ()=>{}
private endExamCallBack:Function = ()=>{}
constructor() {
this.init()
}
init = async ()=>{
emitter.on({eventId:EVENTID.beginExamEventId}, () => {
this?.beginExamCallBack()
});
emitter.on({eventId:EVENTID.endExamEventId}, () => {
this?.endExamCallBack()
});
emitter.on({eventId:EVENTID.kfEventId}, () => {
this?.endExamCallBack()
});
}
//监听开始考试
public onBeginExam = async (callBack?:Function)=>{
this.beginExamCallBack = callBack
}
//监听结束考试
public onEndExam = async (callBack?:Function)=>{
this.endExamCallBack = callBack
}
//监听扣分处理
public onKfExam= async (callBack?:Function)=>{
this.endExamCallBack = callBack
}
//开始考试
public sendBeginExam = async(content)=>{
emitter.emit({eventId:EVENTID.beginExamEventId}, {
data:{ content }
});
}
//结束考试
public sendEndExam = async(content)=>{
emitter.emit({eventId:EVENTID.endExamEventId}, {
data:{content}
});
}
}

View File

@ -148,7 +148,7 @@ function handleCenterCode(msgXml,isNewCenter){
const msg = JSON.parse(msgXml); const msg = JSON.parse(msgXml);
const result = msg?.data[0]?.result; const result = msg?.data[0]?.result;
if(result){ if(result){
const {code,message,keystr} = result const {code,message,retval} = result
if(code != '1'){ if(code != '1'){
const rMessage = decodeURIComponent(message as string) const rMessage = decodeURIComponent(message as string)
// globalThis.title=rMessage // globalThis.title=rMessage
@ -160,7 +160,7 @@ function handleCenterCode(msgXml,isNewCenter){
}); });
return {code,message} return {code,message}
}else{ }else{
return { code ,keystr} return { code ,keystr:retval}
} }
} }
} }
@ -168,9 +168,8 @@ function handleCenterCode(msgXml,isNewCenter){
//正则匹配code message字段 //正则匹配code message字段
const [code,message,keystr] = [/<code>(.*)<\/code>/i,/<message>(.*)<\/message>/i,/<keystr>(.*)<\/keystr>/i].map(pattern=>{ const [code,message,keystr] = [/<code>(.*)<\/code>/i,/<message>(.*)<\/message>/i,/<keystr>(.*)<\/keystr>/i].map(pattern=>{
const patternArr = pattern.exec(msgXml); const patternArr = pattern.exec(msgXml);
return patternArr[1] return patternArr && patternArr[1]
}); });
console.info('surenjun =>request-prev',keystr) console.info('surenjun =>request-prev',keystr)
if(code != '1'){ if(code != '1'){

View File

@ -18,6 +18,7 @@ import { voiceService } from '../common/service/voiceService';
import errorMsgDialog from './compontents/errorMsgDialog' import errorMsgDialog from './compontents/errorMsgDialog'
import { getSyncData } from '../common/service/initable'; import { getSyncData } from '../common/service/initable';
import GetDistance from '../common/utils/GetDistance' import GetDistance from '../common/utils/GetDistance'
import UdpEvent from '../common/utils/UdpEvent'
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
import { endRecordVideo, getUserAlbumItemByDisplayName, saveStartRecordVideo } from '../common/service/videoService'; import { endRecordVideo, getUserAlbumItemByDisplayName, saveStartRecordVideo } from '../common/service/videoService';
@ -299,9 +300,7 @@ struct Index {
this.loading = false this.loading = false
globalThis.lsh = '1111111111111' globalThis.lsh = '1111111111111'
globalThis.errorDialog = this.errorDialog globalThis.errorDialog = this.errorDialog
const distanceClass = new GetDistance(globalThis.context) globalThis.udpEvent = new UdpEvent();
await distanceClass.initFolder()
globalThis.distanceClass = distanceClass
} }
async testXMLToJSONInWorker() { async testXMLToJSONInWorker() {
@ -443,6 +442,12 @@ struct Index {
getTCP() getTCP()
this.deviceId = globalThis.carInfo.carNo this.deviceId = globalThis.carInfo.carNo
await setCurrentTime(); await setCurrentTime();
if(!globalThis.distanceClass){
const distanceClass = new GetDistance(globalThis.context)
await distanceClass.initFolder()
globalThis.distanceClass = distanceClass
console.info('surenjun','distanceClass=>初始化完成')
}
this.carNum = globalThis.carInfo.plateNo; this.carNum = globalThis.carInfo.plateNo;
this.version = globalThis.version; this.version = globalThis.version;
this.hasAuth = globalThis.hasAuth; this.hasAuth = globalThis.hasAuth;

View File

@ -436,7 +436,7 @@ struct UserInfo {
if(that.list.length == 0){ if(that.list.length == 0){
clearInterval(that.interval) clearInterval(that.interval)
that.interval = setInterval(() => { that.interval = setInterval(() => {
that.getExaminationStudentInfoFn() that.getExaminationStudentInfoFn()
}, 5000) }, 5000)
}else{ }else{
that.getExaminationStudentInfoFn() that.getExaminationStudentInfoFn()
@ -451,7 +451,7 @@ struct UserInfo {
//人脸比对窗口关闭 //人脸比对窗口关闭
changeFaceCompareSuccess() { changeFaceCompareSuccess() {
this.ksksLimit = false this.ksksLimit = false
console.log('this.faceCompareSuces', this.faceCompareSucess, JSON.stringify(this.currentUser)) console.log('this.faceCompareSuces', this.faceCompareSucess, JSON.stringify(this.currentUser))
if (this.faceCompareSucess > 0) { if (this.faceCompareSucess > 0) {
//人脸比对通过 //人脸比对通过

View File

@ -36,6 +36,7 @@ export default struct DeductedPopup {
kfdm: string, kfdm: string,
markreal: number, markreal: number,
markcatalog: string markcatalog: string
score:number
}[] = [] }[] = []
//开始考试前判绕车一周评判是否开启 //开始考试前判绕车一周评判是否开启
@State isOpen: boolean = false @State isOpen: boolean = false
@ -126,7 +127,7 @@ export default struct DeductedPopup {
const index = this.currentIndex ? this.currentUniversalPageIndex : this.currentPageIndex; const index = this.currentIndex ? this.currentUniversalPageIndex : this.currentPageIndex;
const mark = this.universalMarkRules[index * 7 + this.selectedLine]; 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 }) this.kfdmArr.push({ xmdm: 1, kfdm: mark.markserial, markreal: mark.markreal, markcatalog: mark.markcatalog ,score:mark.score})
const kfdmArr = this.kfdmArr const kfdmArr = this.kfdmArr
//计算总扣分 //计算总扣分
@ -142,17 +143,12 @@ export default struct DeductedPopup {
}))) })))
if (judgeConfigObj['418'] == '1' || judgeConfig.kfVoiceOpen) { if (judgeConfigObj['418'] == '1' || judgeConfig.kfVoiceOpen) {
avPlayer.playAudio([`voice/${mark.markcatalog}.mp3`], false, () => { avPlayer.playAudio([`voice/${mark.markcatalog}.mp3`,`voice/mark_${Math.abs(mark.score)}.mp3`], false, () => {
this.closePopup(true) this.closePopup(true)
}); });
return return
} }
this.closePopup();
if (singlePlay) {
return
} else {
this.closePopup()
}
return; return;
if (score < 90) { if (score < 90) {

View File

@ -24,7 +24,8 @@ export interface MarkRule {
kfxh?: string kfxh?: string
onlyoneid?: number onlyoneid?: number
nocancelid?: number nocancelid?: number
gps_sid?: number gps_sid?: number,
score?:number
} }
export interface KF{ export interface KF{

View File

@ -14,6 +14,7 @@ import { judgeConfig } from './utils/judgeConfig';
import { uploadExamProgressData, writeObjectOut } from '../../api/judge'; import { uploadExamProgressData, writeObjectOut } from '../../api/judge';
import UsbService from '../../common/service/usbService'; import UsbService from '../../common/service/usbService';
import { LANE,KF } from '../judgeSDK/api/judgeSDK.d'; import { LANE,KF } from '../judgeSDK/api/judgeSDK.d';
import {saveStartRecordVideo,endRecordVideo} from '../../common/service/videoService'
import { import {
Array2Byte, Array2Byte,
convertGpsCoord2, convertGpsCoord2,
@ -103,7 +104,7 @@ export default class Judge {
//开始评判 //开始评判
private async judging(callBack: Function) { private async judging(callBack: Function) {
const {judgeUI} = this; const {judgeUI} = this;
const { name, lsh, idCard} = judgeUI; const { name, lsh, idCard,kssycs} = judgeUI;
const fileLog = new FileLog(judgeUI.context); const fileLog = new FileLog(judgeUI.context);
const filePath = await fileLog.initFileLogo({ const filePath = await fileLog.initFileLogo({
name, lsh, idCard name, lsh, idCard
@ -165,6 +166,10 @@ export default class Judge {
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){
this.videoData = await saveStartRecordVideo(`${name}_${kssycs}`)
}
const {examSubject,projectsObj} = this.judgeUI const {examSubject,projectsObj} = this.judgeUI
if(examSubject == 3){ if(examSubject == 3){
//不做模拟灯光,需要做上车准备 =>(请上车准备) //不做模拟灯光,需要做上车准备 =>(请上车准备)
@ -459,7 +464,7 @@ export default class Judge {
}); });
//语音播报 //语音播报
this.goVoiceAnnounce(event, xmdm, this.kfArr, xmjs, ksjs) this.goVoiceAnnounce(event, xmdm, this.kfArr, xmjs, ksjs,xmxh)
//更新UI //更新UI
if (event == 1 || event == 2 || event == 3 || event == 6) { if (event == 1 || event == 2 || event == 3 || event == 6) {
@ -469,7 +474,7 @@ export default class Judge {
} }
// 更改考试状态 // 更改考试状态
goVoiceAnnounce = async (event, xmdm, kf, xmjs, ksjs) => { goVoiceAnnounce = async (event, xmdm, kf, xmjs, ksjs,xmxh) => {
const { const {
beginProject, beginProject,
pointsDedute, pointsDedute,
@ -493,7 +498,7 @@ export default class Judge {
case 1: case 1:
const code = projectsObj[xmdm].projectCodeCenter; const code = projectsObj[xmdm].projectCodeCenter;
const isEnd = projectsObj[xmdm].isEnd; const isEnd = projectsObj[xmdm].isEnd;
const kmCode = getKmProjectVoice(code, 1, judgeConfigObj, lane) const kmCode = getKmProjectVoice(code, 1, judgeConfigObj, lane,xmxh)
if (!ignoreVoiceCodeArr.includes(code)) { if (!ignoreVoiceCodeArr.includes(code)) {
kmCode && avPlayer.playAudio([`voice/${kmCode}.mp3`],true) kmCode && avPlayer.playAudio([`voice/${kmCode}.mp3`],true)
} }
@ -515,7 +520,7 @@ export default class Judge {
case 2:{ case 2:{
const endCode = projectsObj[xmdm].projectCodeCenter; const endCode = projectsObj[xmdm].projectCodeCenter;
const projectIsEnd = projectsObj[xmdm].isEnd; const projectIsEnd = projectsObj[xmdm].isEnd;
const endKmCode = getKmProjectVoice(endCode, 2, judgeConfigObj, lane) const endKmCode = getKmProjectVoice(endCode, 2, judgeConfigObj, lane,xmxh)
if (!ignoreVoiceCodeArr.includes(endCode) && examSubject == 3) { if (!ignoreVoiceCodeArr.includes(endCode) && examSubject == 3) {
endKmCode && avPlayer.playAudio([`voice/${endKmCode}.mp3`]) endKmCode && avPlayer.playAudio([`voice/${endKmCode}.mp3`])
} }
@ -1040,9 +1045,9 @@ export default class Judge {
console.info(judgeTag, `考试成绩:${totalScore}`) console.info(judgeTag, `考试成绩:${totalScore}`)
if(!singlePlay){ if(!singlePlay){
await endRecordVideo(this.videoData)
await uploadProgressData(); await uploadProgressData();
} }
//语音播放扣分项 //语音播放扣分项
let score = 0; let score = 0;
if (kfArr.length) { if (kfArr.length) {
@ -1633,4 +1638,5 @@ export default class Judge {
private lane: LANE = { private lane: LANE = {
road: '', num: 0, count: 0 road: '', num: 0, count: 0
} }
private videoData:any
} }

View File

@ -88,16 +88,17 @@ export function getKmProjectVoice(
// 1:项目开始 2:项目结束 // 1:项目开始 2:项目结束
type: 1 | 2, type: 1 | 2,
judgeConfig, judgeConfig,
lane lane,
xmxh
) { ) {
const carInfo = globalThis.carInfo; const carInfo = globalThis.carInfo;
const { examSubject } = carInfo; const { examSubject } = carInfo;
const param506Str = judgeConfig['506']?.split(',') || []; const param506Str = judgeConfig['506']?.split(',') || [];
const param512Str = judgeConfig['512']?.split(',') || []; const param512Str = judgeConfig['512']?.split(',') || [];
const param544Str = judgeConfig['544'] || 0; const param544Str = judgeConfig['544']?.split(',') || [];
const param405Str = judgeConfig['405'] || 0; const param405Str = judgeConfig['405'] || 0;
const {num,count} = lane const {num,count,road} = lane
if(examSubject == 2){ if(examSubject == 2){
return projectCode return projectCode
} }
@ -120,8 +121,10 @@ export function getKmProjectVoice(
: undefined : undefined
//直线行驶 //直线行驶
case 40700 : return type === 1 ? 407001 : undefined case 40700 : return type === 1 ? 407001 : undefined
//TODO 通过学校 结束param544Str //通过学校 结束param544Str
case 41100 : return type === 1 ? (param512Str[2] ==3 ? 411001 : undefined):undefined case 41100 : return type === 1
? (param512Str[2] ==3 ? 411001 : undefined)
: (param544Str.includes(xmxh) ? undefined : 411004)
//通过车站 //通过车站
case 41200 : return type === 1 ? (param512Str[2] ==3 ? 412001 : undefined):undefined case 41200 : return type === 1 ? (param512Str[2] ==3 ? 412001 : undefined):undefined
//通过人行横道 //通过人行横道