Compare commits
	
		
			3 Commits
		
	
	
		
			4c1e56981b
			...
			39bfed3beb
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 39bfed3beb | ||
|  | 5b48137d66 | ||
|  | 78be17b13b | 
| @ -6,6 +6,8 @@ import { GetSyncData } from '../utils/table/Operation'; | ||||
| import { GetCurrentTime } from '../utils/Common'; | ||||
| import FileUtils from '../utils/FileUtils'; | ||||
| import common from '@ohos.app.ability.common'; | ||||
| import { dConsole } from '../utils/LogWorker'; | ||||
| import { JudgeTag } from '../config'; | ||||
| 
 | ||||
| let baseHost: string = AppStorage.get<string>('host')!; | ||||
| 
 | ||||
| @ -35,43 +37,39 @@ export async function writeObjectOut(params: RegulatoryInterfaceParams, filePath | ||||
|     return { code: 1 } | ||||
|   } | ||||
|   let JGHOST: string = AppStorage.get<string>("JGHOST") || "" | ||||
|   let isJGNew: boolean = false | ||||
|   //获取监管接口地址路径 | ||||
|   if (!JGHOST) { | ||||
|     const syssetParams: MASYSSETTableType[] = await GetSyncData<MASYSSETTableType>("MA_SYSSET"); | ||||
| 
 | ||||
|     syssetParams.forEach(sys => { | ||||
|       if (sys.v_no == '839') { | ||||
|         //是否是新监管 | ||||
|         // globalThis.isJGNew = sys.v_value == '3' | ||||
|         AppStorage.setOrCreate('isJGNew', sys.v_value == '3') | ||||
|         isJGNew = sys.v_value == '3' | ||||
|         AppStorage.setOrCreate('isJGNew', isJGNew) | ||||
|       } | ||||
|       if (sys.v_no == '900') { | ||||
|         // globalThis.JGHOST = validateIP(decodeURIComponent(sys.v_value)) | ||||
|         AppStorage.setOrCreate('JGHOST', validateIP(decodeURIComponent(sys.v_value || ""))) | ||||
|         const ip = decodeURIComponent(sys.v_value || "") | ||||
|         JGHOST = validateIP(ip) || "" | ||||
|         dConsole.log(JudgeTag, "监管地址取值", JGHOST) | ||||
|         AppStorage.setOrCreate('JGHOST', JGHOST) | ||||
|       } | ||||
|     }) | ||||
|   } | ||||
|   // const { xtlb, jkxlh, jkid, drvexam } = params; | ||||
|   const isJGNew: boolean = AppStorage.get<boolean>('isJGNew') || false | ||||
|   //新监管调用 | ||||
|   if (isJGNew) { | ||||
|     dConsole.log(JudgeTag, "新监管") | ||||
|     return await writeObjectOutNew(params, filePath, context) | ||||
|   } | ||||
|   params.drvexam = params.drvexam ?? {}; | ||||
|   params.drvexam.zp = params.drvexam.zp === undefined ? undefined : encodeURIComponent(params.drvexam.zp); | ||||
| 
 | ||||
|   const drvexamArrs = Object.entries(params.drvexam) | ||||
|   const drvexamArr = Object.entries(params.drvexam) | ||||
|     .filter((item: [string, string]) => item[1] != undefined) | ||||
|     .map((item: [string, object]) => `<${item[0]}>${item[1]}</${item[0]}>`) | ||||
|   // const drvexamArrs = Reflect.ownKeys(params.drvexam) | ||||
|   //   .filter(dKey => Reflect.get(params.drvexam, dKey) != undefined) | ||||
|   //   .map((key: string) => ( | ||||
|   //     `<${key}>${Reflect.get(params.drvexam, key)}</${key}>`)); | ||||
| 
 | ||||
|   if (filePath) { | ||||
|     const fileUtil = new FileUtils(context); | ||||
|     await fileUtil.initFolder(filePath); | ||||
| 
 | ||||
|     let obj: WuxiExamType = { | ||||
|       xtlb: params.xtlb, | ||||
|       jkxlh: params.jkxlh, | ||||
| @ -83,9 +81,8 @@ export async function writeObjectOut(params: RegulatoryInterfaceParams, filePath | ||||
|     } | ||||
|     fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`, JSON.stringify(obj) + `\n`); | ||||
|   } | ||||
| 
 | ||||
|   dConsole.log(JudgeTag, "老监管", JGHOST) | ||||
|   //对象转换成xml | ||||
|   JGHOST = AppStorage.get<string>("JGHOST") || "" | ||||
|   const temp = await request<object>({ | ||||
|     host: JGHOST, | ||||
|     url: '/dems_ws/services/TmriOutAccess?wsdl', | ||||
| @ -105,7 +102,7 @@ export async function writeObjectOut(params: RegulatoryInterfaceParams, filePath | ||||
|                         <?xm lversion="1.0 "encoding="GBK"?> | ||||
|                         <root> | ||||
|                           <drvexam> | ||||
|                             ${drvexamArrs} | ||||
|                             ${drvexamArr} | ||||
|                           </drvexam> | ||||
|                         </root> | ||||
|                       ]]> | ||||
| @ -262,11 +259,6 @@ export async function uploadExamMileage(params: UploadExamMileage) { | ||||
| //   }) | ||||
| // } | ||||
| 
 | ||||
| function validateIP(path: string) { | ||||
|   const reg = new RegExp(`(\w+):\/\/([^/:]+)(:\d*)?`) | ||||
|   const result = path.match(reg); | ||||
|   return result ? result[0] : ""; | ||||
| } | ||||
| 
 | ||||
| // 上传运行时常 | ||||
| export async function uploadHarmonyLiCheng(data: object) { | ||||
| @ -277,3 +269,11 @@ export async function uploadHarmonyLiCheng(data: object) { | ||||
|     xml: false | ||||
|   }) | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| function validateIP(path: string) { | ||||
|   // const regex = /(\w+):\/\/([\d.]+)(:\d+)?/; | ||||
|   const regex = new RegExp("(\\w+):\\/\\/([\\d.]+)(:\\d+)?"); | ||||
|   const result = path.match(regex); | ||||
|   return result ? result[0] : null; | ||||
| } | ||||
|  | ||||
| @ -165,6 +165,10 @@ export interface EnvironmentConfigurationType { | ||||
|   isOpenFiniteDifference?: string | ||||
|   //   是否开启调试模式 | ||||
|   isOpenDebugger?: string | ||||
|   //   外壳版本 | ||||
|   version?: string | ||||
|   //   评判版本 | ||||
|   judgeVersion?: string | ||||
| } | ||||
| 
 | ||||
| //全局配置 | ||||
|  | ||||
| @ -132,7 +132,13 @@ struct ExaminerLoginPage { | ||||
|                     const endTime = new Date().getTime(); | ||||
|                     const elapsedTime = endTime - startTime; | ||||
|                     const remainingTime = Math.max(0, minDisplayTime - elapsedTime); | ||||
| 
 | ||||
|                     const examinerLoginInfo: ExaminerLoginInfo | undefined = res.examinerLoginRsp?.body; | ||||
|                     if (!examinerLoginInfo) { | ||||
|                       dConsole.error(ExaminerLoginTag, 'examinerLoginRsp.body is undefined'); | ||||
|                       return; | ||||
|                     } | ||||
|                     examinerLoginInfo.username = this.userName; | ||||
|                     AppStorage.setOrCreate<ExaminerLoginInfo>('examinerInfo', examinerLoginInfo); | ||||
|                     // 延迟关闭弹窗和跳转 | ||||
|                     setTimeout(() => { | ||||
|                       this.loadingDialog.close(); | ||||
| @ -142,14 +148,6 @@ struct ExaminerLoginPage { | ||||
|                           type: 1 | ||||
|                         } | ||||
|                       }, router.RouterMode.Single); | ||||
| 
 | ||||
|                       const examinerLoginInfo: ExaminerLoginInfo | undefined = res.examinerLoginRsp?.body; | ||||
|                       if (!examinerLoginInfo) { | ||||
|                         dConsole.error(ExaminerLoginTag, 'examinerLoginRsp.body is undefined'); | ||||
|                         return; | ||||
|                       } | ||||
|                       examinerLoginInfo.username = this.userName; | ||||
|                       AppStorage.setOrCreate<ExaminerLoginInfo>('examinerInfo', examinerLoginInfo); | ||||
|                     }, remainingTime); | ||||
| 
 | ||||
|                   } catch (e) { | ||||
|  | ||||
| @ -206,7 +206,7 @@ struct Index { | ||||
|       this.initWork = true | ||||
|     } | ||||
|     DifferentialAndSignal.onMsg(() => { | ||||
|       dConsole.log("外层接受") | ||||
|       // dConsole.log("外层接受") | ||||
|     }) | ||||
|   } | ||||
| 
 | ||||
|  | ||||
| @ -41,7 +41,7 @@ import { GetCurrentTime, NumberToByteArray } from '../utils/Common'; | ||||
| import DB from '../utils/DbSql'; | ||||
| import { CenterUDPBusinessInstance } from '../utils/business/CenterUdpBusiness'; | ||||
| import { JudgeEmitterInstance } from '../utils/business/UdpEvent'; | ||||
| import { JudgeConfig, StartExamTag } from '../config'; | ||||
| import { JudgeConfig, StartExamTag, UserInfoTag } from '../config'; | ||||
| import { dConsole } from '../utils/LogWorker'; | ||||
| import HeaderComponent from './compontents/Header'; | ||||
| import AvatarComponent from './UserInfo/Avatar'; | ||||
| @ -778,7 +778,7 @@ struct UserInfoPage { | ||||
|       sfzmhm: this.currentUser.sfzmhm, | ||||
|       examinationRoomId: this.carInfo.examinationRoomId || "", | ||||
|       username: this.examinerLoginInfo.username || "", | ||||
|       lsh: this.lsh | ||||
|       lsh: this.lsh, | ||||
|     } | ||||
|     dConsole.log('carNo1111', param) | ||||
|     examinationStuAbsent(param).then(res => { | ||||
| @ -800,6 +800,7 @@ struct UserInfoPage { | ||||
|         this.pageIndex = 0 | ||||
|         this.qkFlag = false | ||||
|         this.currentUser = EmptyCandidateObject | ||||
|         this.missAnExamDialogController.close() | ||||
|         this.getExaminationStudentInfoFn() | ||||
|         return | ||||
|       } | ||||
| @ -854,9 +855,8 @@ struct UserInfoPage { | ||||
| 
 | ||||
|     avPlayer.playAudio([`voice/监管通信中.mp3`], false, async () => { | ||||
|       dConsole.info('surenjun', '播放结束开始考试接口调用') | ||||
|       // const { code, keystr, message } = await this.beginExam() || {}; | ||||
|       const res = await this.beginExam() | ||||
|       dConsole.info('surenjun', '开始考试接口调用结束') | ||||
|       dConsole.info('surenjun', '开始考试接口调用结束', JSON.stringify(res)) | ||||
|       //TODO code转换 | ||||
| 
 | ||||
|       if (res.code != 1) { | ||||
| @ -1007,7 +1007,7 @@ struct UserInfoPage { | ||||
|       return { code: -200 } | ||||
|     } | ||||
|     const drvexam: DrvexamType = { | ||||
|       lsh: "this.currentUser.lsh", | ||||
|       lsh: this.currentUser.lsh, | ||||
|       kskm: this.carInfo.examSubject, | ||||
|       ksxtbh: this.ksxtbh || '222', | ||||
|       sfzmhm: this.currentUser.sfzmhm || '', | ||||
| @ -1216,6 +1216,7 @@ struct UserInfoPage { | ||||
|                 .margin({ bottom: 21 }) | ||||
|                 .onClick(async () => { | ||||
|                   if (this.systemParam.Param612Str == '1') { | ||||
|                     dConsole.log(UserInfoTag, "不给开始考试") | ||||
|                     return | ||||
|                   } | ||||
|                   await this.prePareExam() | ||||
| @ -1229,7 +1230,7 @@ struct UserInfoPage { | ||||
|         FaceCompare({ | ||||
|           sfzh: this.currentUser.sfzmhm, | ||||
|           firstImage: this.currentUser.kszp, | ||||
|           faceCompareSucess: $faceCompareSucess, | ||||
|           faceCompareSuccess: $faceCompareSucess, | ||||
|           getqkFlag: $getqkFlag, | ||||
|           faceCatchImg: $faceCatchImg, | ||||
|           showFaceCompare: $showFaceCompare, | ||||
|  | ||||
| @ -12,12 +12,6 @@ import { takePhoto, takePhotoParam } from '../../utils/Video'; | ||||
| import { voiceService } from '../../utils/Voice'; | ||||
| import { dConsole } from '../../utils/LogWorker'; | ||||
| 
 | ||||
| interface ParamType { | ||||
|   id?: number; | ||||
|   list?: number[]; | ||||
|   carNo?: string | undefined; | ||||
|   placeId?: string | undefined; | ||||
| } | ||||
| 
 | ||||
| @Component | ||||
| export default struct FaceCompare { | ||||
| @ -26,7 +20,7 @@ export default struct FaceCompare { | ||||
|   @Prop sfzh: string; | ||||
|   @Prop lsh: string; | ||||
|   @Prop firstImage: string; | ||||
|   @Link faceCompareSucess: number; | ||||
|   @Link faceCompareSuccess: number; | ||||
|   @Link showFaceCompare: boolean; | ||||
|   @Link getqkFlag: boolean; | ||||
|   @Link faceCatchImg: string; | ||||
| @ -48,14 +42,172 @@ export default struct FaceCompare { | ||||
|   private interval: number = -1 | ||||
|   private context = getContext(this) as common.UIAbilityContext; | ||||
| 
 | ||||
|   constructor() { | ||||
|     super() | ||||
|   async aboutToAppear() { | ||||
|     const fileUtil = new FileUtils(this.context) | ||||
|     this.carInfo = AppStorage.get<CarInfoType>('carInfo')! | ||||
|     this.fileUtil = fileUtil | ||||
|     this.getVideoConfig() | ||||
|   } | ||||
| 
 | ||||
|   clearIntervalFn() { | ||||
|     this.callBackFlag = false | ||||
|     clearInterval(this.interval) | ||||
|     this.vocObj && this.vocObj.releasePlayer() | ||||
|   } | ||||
| 
 | ||||
|   async faceCompareFn() { | ||||
|     dConsole.log('mmmmm0', 2) | ||||
|     this.param.pztd = this.param.rlls | ||||
|     const data: takePhotoParam = await takePhoto(this.param, this.context, 'jt/', 1,) | ||||
|     this.base64 = this.imageBase64 + (data?.base64 || "") | ||||
|     dConsole.log('mmmmt', this.base64) | ||||
|     faceCompare({ | ||||
|       sfzh: this.sfzh.toString(), | ||||
|       firstImage: this.firstImage.substr(22), | ||||
|       secondImage: data?.base64 || "", | ||||
|       type: "2", | ||||
|       verifyType: "1" | ||||
|     }) | ||||
|       .then(res => { | ||||
|         dConsole.log('mmmmm8', JSON.stringify(res)) | ||||
|         if (res.imageCompareRsp?.head?.resultCode == '0') { | ||||
|           this.controller.stop() | ||||
|           this.showFaceCompare = !this.showFaceCompare | ||||
|           this.showFaceCompareFlag = !this.showFaceCompareFlag | ||||
|           this.faceCompareSuccess = 1; | ||||
|           // this.faceCatchImg = result | ||||
|           this.vocObj.playAudio({ | ||||
|             type: 1, | ||||
|             name: 'yzcg.wav' | ||||
|           }) | ||||
|         } else { | ||||
|           this.times++; | ||||
|           //3s后开始语音提示 | ||||
|           this.vocObj.playAudio({ | ||||
|             type: 1, | ||||
|             name: 'face_fail.mp3' | ||||
|           }) | ||||
| 
 | ||||
|         } | ||||
|       }) | ||||
|     dConsole.log('mmmmm8', 9) | ||||
|   } | ||||
| 
 | ||||
|   async heartMsg() { | ||||
|     let tmpList: number[] = [] | ||||
|     const str = this.lsh | ||||
|     dConsole.log('this.lshbitbit', this.lsh, this.carInfo.carNo, this.carInfo.examinationRoomId) | ||||
|     for (let i = 0; i < str.length; i++) { | ||||
|       if (str && str.charCodeAt(i) !== undefined) { | ||||
|         tmpList.push(NumberToByteArray(str.charCodeAt(i), 1 * 8)[0]); | ||||
|       } | ||||
|     } | ||||
|     const param: UDPParamType = { | ||||
|       id: 46, | ||||
|       list: tmpList, | ||||
|       carNo: this.carInfo.carNo || "", | ||||
|       placeId: this.carInfo.examinationRoomId || "", | ||||
|       sendCallback: () => { | ||||
|         this.callBackFlag = true | ||||
|       } | ||||
|     } | ||||
|     CenterUDPBusinessInstance.sendData(param) | ||||
|     // UDP缺失 | ||||
|     // globalThis.udpClient2 && globalThis.udpClient2.sendMsgExt(param, this.context) | ||||
|     clearInterval(this.interval) | ||||
|     this.interval = setInterval(() => { | ||||
|       if (this.callBackFlag) { | ||||
|         const param2: UDPParamType = { | ||||
|           id: 47, | ||||
|           list: tmpList, | ||||
|           carNo: this.carInfo.carNo || "", | ||||
|           placeId: this.carInfo.examinationRoomId || "", | ||||
|         } | ||||
|         CenterUDPBusinessInstance.sendData(param2) | ||||
|       } | ||||
|     }, 1000) | ||||
|     CenterUDPBusinessInstance.onMsg((val) => { | ||||
|       if (AppStorage.get('statue') != 3) { | ||||
|         return | ||||
|       } | ||||
|       if (val.id == 48) { | ||||
|         if (val.body[13] == 1) { | ||||
|           this.showFaceCompareFlag = !this.showFaceCompareFlag | ||||
|           this.showFaceCompare = !this.showFaceCompare | ||||
|           this.vocObj && this.vocObj.releasePlayer() | ||||
|           this.faceCompareSuccess = 1 | ||||
|           clearInterval(this.interval) | ||||
|         } else if (val.body[13] == 1 && this.callBackFlag) { | ||||
|           AppStorage.setOrCreate('statue', 2) | ||||
|           this.vocObj && this.vocObj.playAudio({ | ||||
|             type: 1, | ||||
|             name: 'face_chekc_fail.wav' | ||||
|           }) | ||||
|         } | ||||
|       } | ||||
|     }) | ||||
| 
 | ||||
|   } | ||||
| 
 | ||||
|   async getVideoConfig() { | ||||
|     dConsole.log('faceEnterIn') | ||||
|     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); | ||||
|             this.faceCompareSuccess = -1; | ||||
|             this.vocObj && this.vocObj.playAudio({ | ||||
|               type: 1, | ||||
|               name: 'face_checking.wav', | ||||
|             }); | ||||
|             this.heartMsg(); | ||||
|           } else { | ||||
|             setTimeout(() => { | ||||
|               this.faceCompareFn(); | ||||
|             }, 2000); | ||||
|           } | ||||
|         } else if (val === 'yzcg.wav') { | ||||
|           this.showFaceCompare = !this.showFaceCompare; | ||||
|           this.showFaceCompareFlag = !this.showFaceCompareFlag; | ||||
|           AppStorage.setOrCreate('statue', 4); | ||||
|           this.faceCompareSuccess = 1; | ||||
|           this.vocObj && this.vocObj.releasePlayer(); | ||||
|         } else if (val === 'face_chekc_fail.wav') { | ||||
|           this.vocObj && this.vocObj.releasePlayer(); | ||||
|           this.faceCompareSuccess = -1; | ||||
|           this.showFaceCompare = !this.showFaceCompare; | ||||
|           this.showFaceCompareFlag = !this.showFaceCompareFlag; | ||||
|         } | ||||
|       } | ||||
|     }, this.context); | ||||
| 
 | ||||
|     const data = await this.fileUtil.readFile(GlobalConfig.commonFileWriteAddress + '/config/config3.txt'); | ||||
|     dConsole.log('faceEnterIn,data', data) | ||||
| 
 | ||||
|     setTimeout(() => { | ||||
|       this.vocObj && this.vocObj.playAudio({ | ||||
|         type: 1, | ||||
|         name: 'face_check.mp3' | ||||
|       }) | ||||
|     }, 1000) | ||||
|     this.param = JSON.parse(data) | ||||
|     this.param.userName = JSON.parse(data).userName | ||||
|     this.param.ip = this.param.ip | ||||
|     this.param.pwd = this.param.pwd | ||||
|     this.param.port = this.param.port | ||||
|     this.param.rlls = this.param.rlls | ||||
|     this.controller.start() | ||||
|   } | ||||
| 
 | ||||
|   async aboutToDisappear() { | ||||
|     clearInterval(this.interval) | ||||
|   } | ||||
| 
 | ||||
|   build() { | ||||
|     Column() { | ||||
|       Column() { | ||||
|         Text('照片比对')// .lineHeight('16%') | ||||
|         Text('照片比对') | ||||
|           .height('16%') | ||||
|           .fontWeight(FontWeight.Bold) | ||||
|           .fontSize(24) | ||||
| @ -122,7 +274,7 @@ export default struct FaceCompare { | ||||
|               this.vocObj && this.vocObj.releasePlayer() | ||||
|               this.showFaceCompare = !this.showFaceCompare | ||||
|               this.showFaceCompareFlag = !this.showFaceCompareFlag | ||||
|               this.faceCompareSucess = -1 | ||||
|               this.faceCompareSuccess = -1 | ||||
|               AppStorage.setOrCreate('statue', 2) | ||||
|             }) | ||||
|           } | ||||
| @ -159,10 +311,8 @@ export default struct FaceCompare { | ||||
|         this.vocObj && this.vocObj.releasePlayer() | ||||
|         this.showFaceCompare = !this.showFaceCompare | ||||
|         this.showFaceCompareFlag = !this.showFaceCompareFlag | ||||
|         this.faceCompareSucess = -1 | ||||
|         this.faceCompareSuccess = -1 | ||||
|         AppStorage.setOrCreate('statue', 2) | ||||
| 
 | ||||
| 
 | ||||
|       }) | ||||
|     } | ||||
|     .width('100%') | ||||
| @ -170,172 +320,5 @@ export default struct FaceCompare { | ||||
|     .backgroundColor('rgba(0, 0, 0, 0.8)') | ||||
|     .position({ x: 0, y: 0 }) | ||||
|   } | ||||
| 
 | ||||
|   onPageShow() { | ||||
|   } | ||||
| 
 | ||||
|   async aboutToAppear() { | ||||
|     const fileUtil = new FileUtils(this.context) | ||||
|     this.carInfo = AppStorage.get<CarInfoType>('carInfo')! | ||||
|     this.fileUtil = fileUtil | ||||
|     this.getVideoConfig() | ||||
|   } | ||||
| 
 | ||||
|   clearIntervalFn() { | ||||
|     this.callBackFlag = false | ||||
|     clearInterval(this.interval) | ||||
|     this.vocObj && this.vocObj.releasePlayer() | ||||
|   } | ||||
| 
 | ||||
|   async faceComparFn() { | ||||
|     dConsole.log('mmmmm0', 2) | ||||
|     this.param.pztd = this.param.rlls | ||||
|     const data: takePhotoParam = await takePhoto(this.param, this.context, 'jt/', 1,) | ||||
|     this.base64 = this.imageBase64 + (data?.base64 || "") | ||||
|     dConsole.log('mmmmt', this.base64) | ||||
|     faceCompare({ | ||||
|       sfzh: this.sfzh.toString(), | ||||
|       firstImage: this.firstImage.substr(22), | ||||
|       secondImage: data?.base64 || "", | ||||
|       type: "2", | ||||
|       verifyType: "1" | ||||
|     }) | ||||
|       .then(res => { | ||||
|         dConsole.log('mmmmm8', JSON.stringify(res)) | ||||
|         if (res.imageCompareRsp?.head?.resultCode == '0') { | ||||
|           this.controller.stop() | ||||
|           this.showFaceCompare = !this.showFaceCompare | ||||
|           this.showFaceCompareFlag = !this.showFaceCompareFlag | ||||
|           this.faceCompareSucess = 1; | ||||
|           // this.faceCatchImg = result | ||||
|           this.vocObj.playAudio({ | ||||
|             type: 1, | ||||
|             name: 'yzcg.wav' | ||||
|           }) | ||||
|         } else { | ||||
|           this.times++; | ||||
|           //3s后开始语音提示 | ||||
|           this.vocObj.playAudio({ | ||||
|             type: 1, | ||||
|             name: 'face_fail.mp3' | ||||
|           }) | ||||
| 
 | ||||
|         } | ||||
|       }) | ||||
|     dConsole.log('mmmmm8', 9) | ||||
| 
 | ||||
| 
 | ||||
|   } | ||||
| 
 | ||||
|   async heartMsg() { | ||||
|     let tmpList: number[] = [] | ||||
|     const str = this.lsh | ||||
|     dConsole.log('this.lshbitbit', this.lsh, this.carInfo.carNo, this.carInfo.examinationRoomId) | ||||
|     for (let i = 0; i < str.length; i++) { | ||||
|       if (str && str.charCodeAt(i) !== undefined) { | ||||
|         tmpList.push(NumberToByteArray(str.charCodeAt(i), 1 * 8)[0]); | ||||
|       } | ||||
|     } | ||||
|     const param: UDPParamType = { | ||||
|       id: 46, | ||||
|       list: tmpList, | ||||
|       carNo: this.carInfo.carNo || "", | ||||
|       placeId: this.carInfo.examinationRoomId || "", | ||||
|       sendCallback: () => { | ||||
|         this.callBackFlag = true | ||||
|       } | ||||
|     } | ||||
|     CenterUDPBusinessInstance.sendData(param) | ||||
|     // UDP缺失 | ||||
|     // globalThis.udpClient2 && globalThis.udpClient2.sendMsgExt(param, this.context) | ||||
|     clearInterval(this.interval) | ||||
|     this.interval = setInterval(() => { | ||||
|       if (this.callBackFlag) { | ||||
|         const param2: UDPParamType = { | ||||
|           id: 47, | ||||
|           list: tmpList, | ||||
|           carNo: this.carInfo.carNo || "", | ||||
|           placeId: this.carInfo.examinationRoomId || "", | ||||
|         } | ||||
|         CenterUDPBusinessInstance.sendData(param2) | ||||
|       } | ||||
|     }, 1000) | ||||
|     CenterUDPBusinessInstance.onMsg((val) => { | ||||
|       if (AppStorage.get('statue') != 3) { | ||||
|         return | ||||
|       } | ||||
|       if (val.id == 48) { | ||||
|         if (val.body[13] == 1) { | ||||
|           this.showFaceCompareFlag = !this.showFaceCompareFlag | ||||
|           this.showFaceCompare = !this.showFaceCompare | ||||
|           this.vocObj && this.vocObj.releasePlayer() | ||||
|           this.faceCompareSucess = 1 | ||||
|           clearInterval(this.interval) | ||||
|         } else if (val.body[13] == 1 && this.callBackFlag) { | ||||
|           AppStorage.setOrCreate('statue', 2) | ||||
|           this.vocObj && this.vocObj.playAudio({ | ||||
|             type: 1, | ||||
|             name: 'face_chekc_fail.wav' | ||||
|           }) | ||||
|         } | ||||
|       } | ||||
|     }) | ||||
| 
 | ||||
|   } | ||||
| 
 | ||||
|   async getVideoConfig() { | ||||
|     dConsole.log('faceEnterIn') | ||||
|     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); | ||||
|             this.faceCompareSucess = -1; | ||||
|             this.vocObj && this.vocObj.playAudio({ | ||||
|               type: 1, | ||||
|               name: 'face_checking.wav', | ||||
|             }); | ||||
|             this.heartMsg(); | ||||
|           } else { | ||||
|             setTimeout(() => { | ||||
|               this.faceComparFn(); | ||||
|             }, 2000); | ||||
|           } | ||||
|         } else if (val === 'yzcg.wav') { | ||||
|           this.showFaceCompare = !this.showFaceCompare; | ||||
|           this.showFaceCompareFlag = !this.showFaceCompareFlag; | ||||
|           AppStorage.setOrCreate('statue', 4); | ||||
|           this.faceCompareSucess = 1; | ||||
|           this.vocObj && this.vocObj.releasePlayer(); | ||||
|         } else if (val === 'face_chekc_fail.wav') { | ||||
|           this.vocObj && this.vocObj.releasePlayer(); | ||||
|           this.faceCompareSucess = -1; | ||||
|           this.showFaceCompare = !this.showFaceCompare; | ||||
|           this.showFaceCompareFlag = !this.showFaceCompareFlag; | ||||
|         } | ||||
|       } | ||||
|     }, this.context); | ||||
| 
 | ||||
|     const data = await this.fileUtil.readFile(GlobalConfig.commonFileWriteAddress + '/config/config3.txt'); | ||||
|     dConsole.log('faceEnterIn,data', data) | ||||
| 
 | ||||
|     setTimeout(() => { | ||||
|       this.vocObj && this.vocObj.playAudio({ | ||||
|         type: 1, | ||||
|         name: 'face_check.mp3' | ||||
|       }) | ||||
|     }, 1000) | ||||
|     this.param = JSON.parse(data) | ||||
|     this.param.userName = JSON.parse(data).userName | ||||
|     this.param.ip = this.param.ip | ||||
|     this.param.pwd = this.param.pwd | ||||
|     this.param.port = this.param.port | ||||
|     this.param.rlls = this.param.rlls | ||||
|     this.controller.start() | ||||
|   } | ||||
| 
 | ||||
|   async aboutToDisappear() { | ||||
|     clearInterval(this.interval) | ||||
|   } | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -87,10 +87,12 @@ export default struct SignalDisplayComponent { | ||||
|       t++ | ||||
|     } | ||||
|     this.GPSColum[14].value = ((Number((this.signArr[97] || 0)) * 1.852).toFixed(2)).toString() | ||||
|     const str0 = this.signArr[93].slice(0, 2); | ||||
|     const str1 = this.signArr[93].slice(2, 4); | ||||
|     const str2 = this.signArr[93].slice(4); | ||||
|     this.signArr[93] = str2 + str1 + str0 | ||||
|     if (this.signArr.length > 93 && this.signArr[93]) { | ||||
|       const str0 = this.signArr[93].slice(0, 2); | ||||
|       const str1 = this.signArr[93].slice(2, 4); | ||||
|       const str2 = this.signArr[93].slice(4); | ||||
|       this.signArr[93] = str2 + str1 + str0 | ||||
|     } | ||||
|     this.GPSColum[10].value = this.signArr[93] | ||||
| 
 | ||||
|     // this.signArr[53]=192.168.7.170' | ||||
|  | ||||
| @ -62,7 +62,7 @@ class logWorker { | ||||
| 
 | ||||
|   // 通用日志方法 | ||||
|   private logWithLevel(level: 'log' | 'info' | 'error', ...args: ESObject[]): void { | ||||
|     console.log("当前环境查看", this.isLogEnabled, "日志级别:", level) | ||||
|     // console.log("当前环境查看", this.isLogEnabled, "日志级别:", level) | ||||
|     if (this.isLogEnabled === "1") { | ||||
|       const message = this.formatMessage(...args); | ||||
|       if (message.length > MAX_MESSAGE_LENGTH) { | ||||
|  | ||||
| @ -3,6 +3,7 @@ import convertxml from '@ohos.convertxml'; | ||||
| import { BusinessError } from '@ohos.base'; | ||||
| import promptAction from '@ohos.promptAction'; | ||||
| import { RequestTag } from '../config'; | ||||
| import Prompt from '@system.prompt'; | ||||
| 
 | ||||
| interface RequestOption { | ||||
|   url: string | ||||
| @ -87,7 +88,7 @@ interface CenterCodeResult { | ||||
|   keystr?: string | ||||
| } | ||||
| 
 | ||||
| function dealCenterCode(message: string, isNewCenter: boolean = false): CenterCodeResult { | ||||
| function dealCenterCode(message: string, isNewCenter: boolean = false): CenterCodeResult | undefined { | ||||
|   if (isNewCenter) { | ||||
|     const msg: object = JSON.parse(message); | ||||
|     const result: object = msg?.['data'][0]?.result; | ||||
| @ -111,23 +112,33 @@ function dealCenterCode(message: string, isNewCenter: boolean = false): CenterCo | ||||
|         return returnResult | ||||
|       } | ||||
|     } | ||||
|   } else { | ||||
|     const result = [new RegExp('<code>(.*)<\/code>', 'i'), new RegExp('<message>(.*)<\/message>', 'i'), new RegExp('<keystr>(.*)<\/keystr>', 'i')].map(pattern => { | ||||
|       const patternArr = pattern.exec(message); | ||||
|       return patternArr && patternArr[1] | ||||
|     }); | ||||
| 
 | ||||
|     if (result[0] != '1') { | ||||
|       promptAction.showToast({ | ||||
|         message: decodeURIComponent(message as string), | ||||
|         duration: 3000 | ||||
|       }); | ||||
| 
 | ||||
|       return { code: result[0], message: decodeURIComponent(result[1]) } | ||||
|     } else { | ||||
|       return { code: result[0], message: decodeURIComponent(result[1]), keystr: result[2], } | ||||
|     } | ||||
|   } | ||||
|   const result = parseXml(message) | ||||
|   if (result.code != '1') { | ||||
|     Prompt.showToast({ | ||||
|       message: decodeURIComponent(message as string), | ||||
|       duration: 3000 | ||||
|     }); | ||||
|     return { code: result.code, message: decodeURIComponent(result.message || "") } as CenterCodeResult | ||||
|   } else { | ||||
|     return result | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| function parseXml(xml: string) { | ||||
|   const codeRegex = new RegExp("<code>(.*?)<\\/code>"); | ||||
|   const messageRegex = new RegExp("<message>(.*?)<\\/message>"); | ||||
|   const keystrRegex = new RegExp("<keystr>(.*?)<\\/keystr>"); | ||||
| 
 | ||||
|   const codeMatch = xml.match(codeRegex); | ||||
|   const messageMatch = xml.match(messageRegex); | ||||
|   const keystrMatch = xml.match(keystrRegex); | ||||
| 
 | ||||
|   return { | ||||
|     code: codeMatch ? codeMatch[1] : null, | ||||
|     message: messageMatch ? messageMatch[1] : null, | ||||
|     keystr: keystrMatch ? keystrMatch[1] : null, | ||||
|   } as CenterCodeResult; | ||||
| } | ||||
| 
 | ||||
| type RequestResult = Object | object | string | CenterCodeResult | ||||
| @ -149,9 +160,9 @@ export default function Request<T extends RequestResult>(options: RequestOption) | ||||
|       readTimeout: options.timeout || 30 * 1000 | ||||
|     }).then(async data => { | ||||
|       console.log(RequestTag, baseURL, options.url, "返回的数据", JSON.stringify(data)) | ||||
|       // let result = options.xml ? xmlToJSON(data.result as string) : data.result | ||||
|       console.log(RequestTag, baseURL, options.url, "入参", options.accept, "xml", options.xml) | ||||
|       let result = options.xml ? (options.accept ? data.result : xmlToJSON(data.result as string)) : data.result; | ||||
|       console.log("结束xml解析") | ||||
|       console.log("结束xml解析", JSON.stringify(result)) | ||||
|       let resObj: object = new Object() | ||||
|       if (typeof result === 'string') { | ||||
|         result = JSON.parse(result) | ||||
|  | ||||
| @ -49,7 +49,7 @@ export const InitSerialPortData = | ||||
|   * @returns Promise<number> 成功返回发送的字节数,失败返回-1 | ||||
|  */ | ||||
| export const SendSerialPortData = (fd: number, data: number[]) => { | ||||
|   console.log(SerialPortTag, "wzj-----发送数据") | ||||
|   // console.log(SerialPortTag, "wzj-----发送数据") | ||||
|   return new Promise<number>((resolve, reject) => { | ||||
|     testNapi.SerialSendAsync(fd, data, (value: number) => { | ||||
|       if (value === -1) { | ||||
| @ -68,7 +68,7 @@ export const SendSerialPortData = (fd: number, data: number[]) => { | ||||
|   * @returns Promise<HiSerialSDK.receiveInfo> 成功返回接收到的数据,失败返回-1 | ||||
|  */ | ||||
| export const ReceiveSerialPortData = (fd: number, timeout: number,) => { | ||||
|   console.log(SerialPortTag, "wzj-----接受数据") | ||||
|   // console.log(SerialPortTag, "wzj-----接受数据") | ||||
|   return new Promise<HiSerialSDK.receiveInfo>((resolve) => { | ||||
|     testNapi.SerialRecvAsync(fd, timeout, (value: HiSerialSDK.receiveInfo) => { | ||||
|       resolve(value) | ||||
|  | ||||
| @ -79,7 +79,7 @@ export default class UdpClient { | ||||
|         address: this.oppositeIp, port: parseInt(this.oppositeIpPort), family: 1 | ||||
|       } | ||||
|     }).then(res => { | ||||
|       console.log(UDPTag, "udp发送成功", JSON.stringify(res)) | ||||
|       // console.log(UDPTag, "udp发送成功", JSON.stringify(res)) | ||||
|     }) | ||||
|   } | ||||
| 
 | ||||
| @ -139,7 +139,7 @@ export default class UdpClient { | ||||
|   private bindEvent() { | ||||
|     this.udp?.on("message", value => { | ||||
|       let result = this.dealMethod?.(value.message) | ||||
|       console.log(UDPTag, "中心返回消息", result) | ||||
|       // console.log(UDPTag, "中心返回消息", result) | ||||
|       this.messageEvents.forEach(cb => { | ||||
|         cb(result) | ||||
|       }) | ||||
|  | ||||
| @ -45,7 +45,7 @@ class CenterUDPBusiness { | ||||
|     this.timer = setInterval(() => { | ||||
|       // 生成流水号 | ||||
|       SerialNumberInstance.generate() | ||||
|       console.log(CenterUdpTag, "流水号生成") | ||||
|       // console.log(CenterUdpTag, "流水号生成") | ||||
|       // SetSerialNumber() | ||||
|       const arr = [this.signNum || 0, this.statue || 1] | ||||
|       let tmpList: number[] = []; | ||||
| @ -57,16 +57,16 @@ class CenterUDPBusiness { | ||||
|       for (let i = 0; i < str.length; i++) { | ||||
|         tmpList.push(NumberToByteArray(str.charCodeAt(i), 1 * 8)[0]) | ||||
|       } | ||||
|       console.log(CenterUdpTag, "学员流水号", JSON.stringify(tmpList)) | ||||
|       // console.log(CenterUdpTag, "学员流水号", JSON.stringify(tmpList)) | ||||
|       const data: UDPParamType = { | ||||
|         id: 31, | ||||
|         list: tmpList, | ||||
|         carNo: this.carInfo.carNo!, | ||||
|         placeId: this.carInfo.examinationRoomId! | ||||
|       } | ||||
|       console.log(CenterUdpTag, "查看生成的", JSON.stringify(data)) | ||||
|       // console.log(CenterUdpTag, "查看生成的", JSON.stringify(data)) | ||||
|       const param = this.setWholeMsg(data) | ||||
|       console.log(CenterUdpTag, "查看", JSON.stringify(param)) | ||||
|       // console.log(CenterUdpTag, "查看", JSON.stringify(param)) | ||||
|       this.udp.sendMsg(param); | ||||
|     }, 1000); | ||||
|   } | ||||
|  | ||||
| @ -67,7 +67,7 @@ class differentialAndSignal { | ||||
|   getMessage() { | ||||
|     this.workerInstance.onmessage = (e: MessageEvents): void => { | ||||
|       if (e.data) { | ||||
|         console.log(WorkerTag, "Worker 收到消息: " + e.data); | ||||
|         // console.log(WorkerTag, "Worker 收到消息: " + e.data); | ||||
|         this.events.forEach((callback) => { | ||||
|           callback(e.data); | ||||
|         }); | ||||
|  | ||||
| @ -41,7 +41,7 @@ class differentialSignal { | ||||
|   //   获取消息 | ||||
|   getData(callback: (data: ArrayBuffer) => void) { | ||||
|     this.differentialSignalTcp.onMsg((data: ArrayBuffer) => { | ||||
|       console.log(TCPTag, "获取", data); | ||||
|       // console.log(TCPTag, "获取", data); | ||||
|       callback(data); | ||||
|     }); | ||||
|   } | ||||
|  | ||||
| @ -135,6 +135,7 @@ export async function InitializeTheCentralTable(params: InitializeTheCentralTabl | ||||
|     if (!res || !res.head || res.head.resultCode === "1") { | ||||
|       resolve(false); | ||||
|     } | ||||
|     dConsole.log(InitTableTag, "插表操作开始"); | ||||
|     if (res && res.body) { | ||||
|       try { | ||||
|         const tableKeys = Object.keys(res.body); | ||||
| @ -145,9 +146,12 @@ export async function InitializeTheCentralTable(params: InitializeTheCentralTabl | ||||
| 
 | ||||
|           dConsole.log(InitTableTag, "-------------------表名-----------------------", newKey, isExit); | ||||
| 
 | ||||
|           if (!isExit) return false; | ||||
|           if (!isExit) { | ||||
|             dConsole.error(InitTableTag, newKey, "表不存在") | ||||
|             return false | ||||
|           } | ||||
| 
 | ||||
|           dConsole.log("可以插入的表", newKey, CenterMap.get(newKey)); | ||||
|           dConsole.log(InitTableTag, "可以插入的表", newKey, CenterMap.get(newKey)); | ||||
| 
 | ||||
|           let arrList: Array<RecordType> | RecordType = []; | ||||
|           const value: PublicInfoType = Reflect.get(res.body, key); | ||||
| @ -167,6 +171,7 @@ export async function InitializeTheCentralTable(params: InitializeTheCentralTabl | ||||
|           dConsole.log(InitTableTag, "插入表结果,表", newKey, "结果", result); | ||||
| 
 | ||||
|           if (!result) { | ||||
|             dConsole.log(InitTableTag, "初始化失败", newKey) | ||||
|             Prompt.showToast({ | ||||
|               message: `初始化表 ${newKey} 失败` | ||||
|             }); | ||||
|  | ||||
| @ -1,7 +1,13 @@ | ||||
| // 处理worker线程的消息tcp拿差分改正数,udp给后置机 | ||||
| import worker, { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope } from '@ohos.worker'; | ||||
| import { SerialPortTag, WorkerTag } from '../config'; | ||||
| import { CenterCallBackMsgType, WorkerBackMessage, WorkerBackMessageType, WorkerMessage } from '../model'; | ||||
| import { WorkerTag } from '../config'; | ||||
| import { | ||||
|   CenterCallBackMsgType, | ||||
|   EnvironmentConfigurationType, | ||||
|   WorkerBackMessage, | ||||
|   WorkerBackMessageType, | ||||
|   WorkerMessage | ||||
| } from '../model'; | ||||
| import { CenterUDPBusinessInstance } from '../utils/business/CenterUdpBusiness'; | ||||
| import { DifferentialSignal } from '../utils/business/DifferentialSignal'; | ||||
| import { ObtainUdpBusinessInstance } from '../utils/business/ObtainUdpBusiness'; | ||||
| @ -23,7 +29,7 @@ workerPort.onmessage = (e: MessageEvents) => { | ||||
|   // if (result.centerUdpParam) { | ||||
|   //   CenterUDPBusinessInstance.sendData(result.centerUdpParam); | ||||
|   // } | ||||
|   getDataFn() | ||||
|   getDataFn(result.config) | ||||
|   // 必传环境配置 | ||||
|   if (result.close) { | ||||
|     closedFn(result) | ||||
| @ -50,19 +56,19 @@ function initFn(result: WorkerMessage) { | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| function getDataFn() { | ||||
| function getDataFn(config: EnvironmentConfigurationType) { | ||||
|   // 获取TCP差分改正数信号 | ||||
|   DifferentialSignal.getData((data: ArrayBuffer) => { | ||||
|     console.log(WorkerTag, "Received differential signal data:", data.byteLength, "bytes") | ||||
|     // console.log(WorkerTag, "Received differential signal data:", data.byteLength, "bytes") | ||||
|     // TCP拿到差分改正数发给后置机 | ||||
|     ObtainUdpBusinessInstance.sendData(data) | ||||
|   }) | ||||
|   // 后置机回执PLC和GPS | ||||
|   ObtainUdpBusinessInstance.onMsg(async (data: string) => { | ||||
|     if (data !== "") { | ||||
|     if (data !== "" && config.carType !== "2") { | ||||
|       // TODO | ||||
|       // 需要观察 | ||||
|       console.log(WorkerTag, "后置机消息", data) | ||||
|       // console.log(WorkerTag, "后置机消息", data) | ||||
|       const res = await SerialPortService.getData() | ||||
|       if (res.length > 0) { | ||||
|         const dataArray = data.split(","); | ||||
| @ -70,7 +76,7 @@ function getDataFn() { | ||||
|         dataArray[28] = res[9].toString(); | ||||
|         data = dataArray.join(","); | ||||
|       } | ||||
|       console.log(SerialPortTag, "处理完的档位信号", data) | ||||
|       // console.log(SerialPortTag, "处理完的档位信号", data) | ||||
|       workerPort.postMessage( | ||||
|         JSON.stringify({ | ||||
|           type: WorkerBackMessageType.ObtainUdpData, | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user