feat:评判修改
This commit is contained in:
		
							parent
							
								
									23a4b0829a
								
							
						
					
					
						commit
						2a32af7fa1
					
				| @ -32,10 +32,10 @@ export default async function writeObjectOutNew(data,filePath): Promise<WR> { | ||||
|   fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`,JSON.stringify({ | ||||
|     wglb,jkxlh,glbm,jgbh,sjbs, | ||||
|     data:params.data, | ||||
|     file:params.file, | ||||
|     file:{...params.file,param:[]}, | ||||
|   })); | ||||
| 
 | ||||
|   return await request({ | ||||
|   const temp = await request({ | ||||
|     host: globalThis.JGHOST, | ||||
|     method: 'post', | ||||
|     //是否是新中心
 | ||||
| @ -61,6 +61,12 @@ export default async function writeObjectOutNew(data,filePath): Promise<WR> { | ||||
|                  </SOAP-ENV:Body> | ||||
|                </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) { | ||||
|  | ||||
| @ -4,6 +4,7 @@ import { getSyncData } from '../service/initable' | ||||
| import { getChuankouFn } from '../../common/service/indexService' | ||||
| import FileUtil from '../../common/utils/File' | ||||
| import { GlobalConfig } from '../../config/index' | ||||
| import emitter from '@ohos.events.emitter'; | ||||
| 
 | ||||
| export async function sendMsg(val) { | ||||
|   // globalThis.udpClient1&&globalThis.udpClient1.sendMsg(val)
 | ||||
| @ -178,6 +179,15 @@ export async function getUDP2(context,errorFlag?) { | ||||
|           console.log('getUDPOnmessageByGlobalUDP2Message') | ||||
|           if (val.id == '32') { | ||||
|             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') { | ||||
|             let tmpList = [] | ||||
| @ -298,11 +308,18 @@ export async function setJudgeUdp() { | ||||
| 
 | ||||
|   if (config && config.udplocalIp) { | ||||
|     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.bindUdp() | ||||
|     await udpClientbyCenter.onMessage_2((val) => {}) | ||||
| 
 | ||||
|     //远程监听开始考试、结束考试、扣分指令
 | ||||
| 
 | ||||
|     // globalThis.judgeUdpClient = udpClientbyCenter;
 | ||||
|     return { | ||||
|       send(bytes) { | ||||
| @ -315,7 +332,15 @@ export async function setJudgeUdp() { | ||||
|           }) | ||||
|           currentUdpIndex = udpIndex | ||||
|         } | ||||
|       } | ||||
|       }, | ||||
| 
 | ||||
|       //远程查询扣分项
 | ||||
|       //远程确认扣分
 | ||||
|       confirmKF(){ | ||||
| 
 | ||||
|       }, | ||||
|       //远程开始考试
 | ||||
|       //远程结束考试
 | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										71
									
								
								entry/src/main/ets/common/utils/UdpEvent.ets
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								entry/src/main/ets/common/utils/UdpEvent.ets
									
									
									
									
									
										Normal 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} | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| @ -148,7 +148,7 @@ function handleCenterCode(msgXml,isNewCenter){ | ||||
|         const msg = JSON.parse(msgXml); | ||||
|         const result = msg?.data[0]?.result; | ||||
|         if(result){ | ||||
|             const {code,message,keystr} = result | ||||
|             const {code,message,retval} = result | ||||
|             if(code != '1'){ | ||||
|                 const rMessage = decodeURIComponent(message as string) | ||||
|                 // globalThis.title=rMessage
 | ||||
| @ -160,7 +160,7 @@ function handleCenterCode(msgXml,isNewCenter){ | ||||
|                 }); | ||||
|                 return {code,message} | ||||
|             }else{ | ||||
|                 return { code ,keystr} | ||||
|                 return { code ,keystr:retval} | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| @ -168,9 +168,8 @@ function handleCenterCode(msgXml,isNewCenter){ | ||||
|     //正则匹配code message字段
 | ||||
|     const [code,message,keystr] = [/<code>(.*)<\/code>/i,/<message>(.*)<\/message>/i,/<keystr>(.*)<\/keystr>/i].map(pattern=>{ | ||||
|         const patternArr =  pattern.exec(msgXml); | ||||
|         return patternArr[1] | ||||
|         return patternArr && patternArr[1] | ||||
|     }); | ||||
| 
 | ||||
|     console.info('surenjun =>request-prev',keystr) | ||||
| 
 | ||||
|     if(code != '1'){ | ||||
|  | ||||
| @ -18,6 +18,7 @@ import { voiceService } from '../common/service/voiceService'; | ||||
| import errorMsgDialog from './compontents/errorMsgDialog' | ||||
| import { getSyncData } from '../common/service/initable'; | ||||
| import GetDistance from '../common/utils/GetDistance' | ||||
| import UdpEvent from '../common/utils/UdpEvent' | ||||
| import UIAbility from '@ohos.app.ability.UIAbility'; | ||||
| import { endRecordVideo, getUserAlbumItemByDisplayName, saveStartRecordVideo } from '../common/service/videoService'; | ||||
| 
 | ||||
| @ -299,9 +300,7 @@ struct Index { | ||||
|     this.loading = false | ||||
|     globalThis.lsh = '1111111111111' | ||||
|     globalThis.errorDialog = this.errorDialog | ||||
|     const distanceClass = new GetDistance(globalThis.context) | ||||
|     await distanceClass.initFolder() | ||||
|     globalThis.distanceClass = distanceClass | ||||
|     globalThis.udpEvent = new UdpEvent(); | ||||
|   } | ||||
| 
 | ||||
|   async testXMLToJSONInWorker() { | ||||
| @ -443,6 +442,12 @@ struct Index { | ||||
|     getTCP() | ||||
|     this.deviceId = globalThis.carInfo.carNo | ||||
|     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.version = globalThis.version; | ||||
|     this.hasAuth = globalThis.hasAuth; | ||||
|  | ||||
| @ -36,6 +36,7 @@ export default struct DeductedPopup { | ||||
|     kfdm: string, | ||||
|     markreal: number, | ||||
|     markcatalog: string | ||||
|     score:number | ||||
|   }[] = [] | ||||
|   //开始考试前判绕车一周评判是否开启 | ||||
|   @State isOpen: boolean = false | ||||
| @ -126,7 +127,7 @@ export default struct DeductedPopup { | ||||
|     const index = this.currentIndex ? this.currentUniversalPageIndex : this.currentPageIndex; | ||||
|     const mark = this.universalMarkRules[index * 7 + this.selectedLine]; | ||||
|     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 | ||||
| 
 | ||||
|     //计算总扣分 | ||||
| @ -142,17 +143,12 @@ export default struct DeductedPopup { | ||||
|     }))) | ||||
| 
 | ||||
|     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) | ||||
|       }); | ||||
|       return | ||||
|     } | ||||
| 
 | ||||
|     if (singlePlay) { | ||||
|       return | ||||
|     } else { | ||||
|       this.closePopup() | ||||
|     } | ||||
|     this.closePopup(); | ||||
|     return; | ||||
| 
 | ||||
|     if (score < 90) { | ||||
|  | ||||
| @ -24,7 +24,8 @@ export interface MarkRule { | ||||
|   kfxh?: string | ||||
|   onlyoneid?: number | ||||
|   nocancelid?: number | ||||
|   gps_sid?: number | ||||
|   gps_sid?: number, | ||||
|   score?:number | ||||
| } | ||||
| 
 | ||||
| export interface KF{ | ||||
|  | ||||
| @ -14,6 +14,7 @@ import { judgeConfig } from './utils/judgeConfig'; | ||||
| import { uploadExamProgressData, writeObjectOut } from '../../api/judge'; | ||||
| import UsbService from '../../common/service/usbService'; | ||||
| import { LANE,KF } from '../judgeSDK/api/judgeSDK.d'; | ||||
| import {saveStartRecordVideo,endRecordVideo} from '../../common/service/videoService' | ||||
| import { | ||||
|   Array2Byte, | ||||
|   convertGpsCoord2, | ||||
| @ -103,7 +104,7 @@ export default class Judge { | ||||
|   //开始评判
 | ||||
|   private async judging(callBack: Function) { | ||||
|     const {judgeUI} = this; | ||||
|     const { name, lsh, idCard} = judgeUI; | ||||
|     const { name, lsh, idCard,kssycs} = judgeUI; | ||||
|     const fileLog = new FileLog(judgeUI.context); | ||||
|     const filePath = await fileLog.initFileLogo({ | ||||
|       name, lsh, idCard | ||||
| @ -165,6 +166,10 @@ export default class Judge { | ||||
|     console.info(judgeTag, '6.开始考试注册完成') | ||||
|     avPlayer.playAudio([globalThis.singlePlay ? 'voice/ksks.WAV' : 'voice/监管成功.mp3']) | ||||
| 
 | ||||
|     if(!globalThis.singlePlay){ | ||||
|       this.videoData = await saveStartRecordVideo(`${name}_${kssycs}`) | ||||
|     } | ||||
| 
 | ||||
|     const {examSubject,projectsObj} = this.judgeUI | ||||
|     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
 | ||||
|     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 { | ||||
|       beginProject, | ||||
|       pointsDedute, | ||||
| @ -493,7 +498,7 @@ export default class Judge { | ||||
|       case 1: | ||||
|         const code = projectsObj[xmdm].projectCodeCenter; | ||||
|         const isEnd = projectsObj[xmdm].isEnd; | ||||
|         const kmCode = getKmProjectVoice(code, 1, judgeConfigObj, lane) | ||||
|         const kmCode = getKmProjectVoice(code, 1, judgeConfigObj, lane,xmxh) | ||||
|         if (!ignoreVoiceCodeArr.includes(code)) { | ||||
|           kmCode && avPlayer.playAudio([`voice/${kmCode}.mp3`],true) | ||||
|         } | ||||
| @ -515,7 +520,7 @@ export default class Judge { | ||||
|       case 2:{ | ||||
|         const endCode = projectsObj[xmdm].projectCodeCenter; | ||||
|         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) { | ||||
|           endKmCode && avPlayer.playAudio([`voice/${endKmCode}.mp3`]) | ||||
|         } | ||||
| @ -1040,9 +1045,9 @@ export default class Judge { | ||||
| 
 | ||||
|     console.info(judgeTag, `考试成绩:${totalScore}`) | ||||
|     if(!singlePlay){ | ||||
|       await endRecordVideo(this.videoData) | ||||
|       await uploadProgressData(); | ||||
|     } | ||||
| 
 | ||||
|     //语音播放扣分项
 | ||||
|     let score = 0; | ||||
|     if (kfArr.length) { | ||||
| @ -1633,4 +1638,5 @@ export default class Judge { | ||||
|   private lane: LANE = { | ||||
|     road: '', num: 0, count: 0 | ||||
|   } | ||||
|   private videoData:any | ||||
| } | ||||
| @ -88,16 +88,17 @@ export function getKmProjectVoice( | ||||
|   // 1:项目开始 2:项目结束
 | ||||
|   type: 1 | 2, | ||||
|   judgeConfig, | ||||
|   lane | ||||
|   lane, | ||||
|   xmxh | ||||
| ) { | ||||
|   const carInfo = globalThis.carInfo; | ||||
|   const { examSubject } = carInfo; | ||||
|   const param506Str = judgeConfig['506']?.split(',') || []; | ||||
|   const param512Str = judgeConfig['512']?.split(',') || []; | ||||
|   const param544Str = judgeConfig['544'] || 0; | ||||
|   const param544Str = judgeConfig['544']?.split(',') || []; | ||||
|   const param405Str = judgeConfig['405'] || 0; | ||||
| 
 | ||||
|   const {num,count} = lane | ||||
|   const {num,count,road} = lane | ||||
|   if(examSubject == 2){ | ||||
|     return projectCode | ||||
|   } | ||||
| @ -120,8 +121,10 @@ export function getKmProjectVoice( | ||||
|       : undefined | ||||
|     //直线行驶
 | ||||
|     case 40700 : return type === 1 ? 407001 : undefined | ||||
|     //TODO 通过学校  结束param544Str
 | ||||
|     case 41100 : return type === 1 ? (param512Str[2] ==3 ? 411001 : undefined):undefined | ||||
|     //通过学校  结束param544Str
 | ||||
|     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 | ||||
|     //通过人行横道
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user