fix: 优化落盘操作,优化数据操作
This commit is contained in:
		
							parent
							
								
									ac408a3281
								
							
						
					
					
						commit
						21a5067117
					
				| @ -96,6 +96,10 @@ export async function initTable() { | ||||
| export function sqlInsertCommonFn(tableName, resultArr, delFlag = true) { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     DB.clearTable(tableName).then((res) => { | ||||
|       if (!resultArr || resultArr.length == 0) { | ||||
|         resolve(true) | ||||
|         return | ||||
|       } | ||||
|       let INSERT_SQL = "INSERT INTO " + tableName | ||||
|         + " (" + map[tableName].ACCOUNT_TABLE.columns.toString() + ") VALUES " | ||||
| 
 | ||||
| @ -190,9 +194,11 @@ export async function getDataBaseTable(params, reqParam) { | ||||
|       }); | ||||
|       return | ||||
|     } | ||||
|     const str = { "head": { "time": dateFormat(date) }, | ||||
|     const str = { | ||||
|       "head": { "time": dateFormat(date) }, | ||||
|       "body": | ||||
|       { "tableName": params.tableName, // 表名
 | ||||
|       { | ||||
|         "tableName": params.tableName, // 表名
 | ||||
|         "paraKdid": reqParam.paraKdid, //参数平台kdid
 | ||||
|         "examinationRoomId": reqParam.examinationRoomId, //考试平台kdid
 | ||||
|         "typeRsp": "0" // 赋默认值0,无需改变
 | ||||
| @ -233,9 +239,11 @@ export async function upDateTable(params, reqParam) { | ||||
|       return | ||||
|     } | ||||
| 
 | ||||
|     const str = { "head": { "time": dateFormat(date) }, | ||||
|     const str = { | ||||
|       "head": { "time": dateFormat(date) }, | ||||
|       "body": | ||||
|       { "tableName": params.tableName, // 表名
 | ||||
|       { | ||||
|         "tableName": params.tableName, // 表名
 | ||||
|         "paraKdid": reqParam.paraKdid, //参数平台kdid
 | ||||
|         "examinationRoomId": reqParam.kdid, //考试平台kdid
 | ||||
|         "typeRsp": "0" // 赋默认值0,无需改变
 | ||||
| @ -269,9 +277,11 @@ export async function getMySystemSetTable(params, reqParam) { | ||||
|       }); | ||||
|       return | ||||
|     } | ||||
|     const str = { "head": { "time": dateFormat(date) }, | ||||
|     const str = { | ||||
|       "head": { "time": dateFormat(date) }, | ||||
|       "body": | ||||
|       { "tableName": params.tableName, // 表名
 | ||||
|       { | ||||
|         "tableName": params.tableName, // 表名
 | ||||
|         "paraKdid": reqParam?.paraKdid, //参数平台kdid
 | ||||
|         "examinationRoomId": reqParam?.kdid, //考试平台kdid
 | ||||
|         "typeRsp": "0" // 赋默认值0,无需改变
 | ||||
| @ -347,7 +357,8 @@ export async function getEsCarModel(context) { | ||||
|     }); | ||||
|     return | ||||
|   } | ||||
|   const carStr = { "head": { "time": dateFormat(date) }, | ||||
|   const carStr = { | ||||
|     "head": { "time": dateFormat(date) }, | ||||
|     "body": | ||||
|     { | ||||
|       "rtkType": "1", //1:车模 2:场地模型
 | ||||
| @ -358,7 +369,8 @@ export async function getEsCarModel(context) { | ||||
|       "carMac": globalThis.deviceNo | ||||
|     } | ||||
|   } | ||||
|   const venueStr = { "head": { "time": dateFormat(date) }, | ||||
|   const venueStr = { | ||||
|     "head": { "time": dateFormat(date) }, | ||||
|     "body": | ||||
|     { | ||||
|       "rtkType": "2", //1:车模 2:场地模型
 | ||||
| @ -396,9 +408,12 @@ export async function upDataZhongxinginitialization(param) { | ||||
|     if (param.singlePlay) { | ||||
|       console.log('teststet0', JSON.stringify(param)) | ||||
|       const fileUtil = new FileUtil(param.context) | ||||
|       const tableList = ['MA_SYSSET', 'MA_SYSTEMPARM', 'MA_MARKRULE', 'MA_MARKRULESET', 'ES_CARINFO', 'MA_MAP_ROAD', 'MA_MAP_ROAD_LANE', 'MAP_SUBITEM', 'MA_T_CARPARMSET', 'MA_MAP_ITEMCLASS', 'MA_MAP_POINT', 'MA_MAP_POINT_ITEM']; | ||||
|       const tableList = | ||||
|         ['MA_SYSSET', 'MA_SYSTEMPARM', 'MA_MARKRULE', 'MA_MARKRULESET', 'ES_CARINFO', 'MA_MAP_ROAD', 'MA_MAP_ROAD_LANE', | ||||
|           'MAP_SUBITEM', 'MA_T_CARPARMSET', 'MA_MAP_ITEMCLASS', 'MA_MAP_POINT', 'MA_MAP_POINT_ITEM']; | ||||
|       for (let i = 0; i <= tableList.length - 1; i++) { | ||||
|         const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + `/config/tableList/${tableList[i]}.txt`); | ||||
|         const data = | ||||
|           await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + `/config/tableList/${tableList[i]}.txt`); | ||||
|         const result = await sqlInsertCommonFn(tableList[i], JSON.parse(data) || [], param.context) | ||||
| 
 | ||||
|         result ? (flag = true) : (flag = false) | ||||
|  | ||||
| @ -57,8 +57,7 @@ export async function startRecordVideo(param, td, context, dir, path?, index?) { | ||||
|       var recordResult = rtsp_server.startRecordVideo(context, video_uri, fileName, date, dir); | ||||
|       const handleId = recordResult.dataInt; | ||||
|       reslove(handleId) | ||||
|     } | ||||
|     else { | ||||
|     } else { | ||||
|       console.log(`Rtsprecord startRecordVideo rtsp_server isnull`); | ||||
|       reslove(0) | ||||
|     } | ||||
| @ -74,10 +73,10 @@ export async function endRecordVideo(record_handleObj) { | ||||
|       console.log(`Rtsprecord endRecordVideo begin`); | ||||
|       // @ts-ignore
 | ||||
|       var recordResult = rtsp_server.endRecordVideo(record_handleObj[key]); | ||||
|       console.log(`Rtsprecord endRecordVideo record_handle` + record_handleObj[key].dataInt + ` filename:` + record_handleObj[key].fileName); | ||||
|       console.log(`Rtsprecord endRecordVideo record_handle` + record_handleObj[key].dataInt + ` filename:` + | ||||
|       record_handleObj[key].fileName); | ||||
| 
 | ||||
|     } | ||||
|     else { | ||||
|     } else { | ||||
|       console.log(`Rtsprecord endRecordVideo handleId isnull`); | ||||
|     } | ||||
|   } | ||||
| @ -123,7 +122,8 @@ async function getfilehandleCode(td, param, dir, path, index) { | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| export async function getUserAlbumItemByDisplayName(displayName: string, day?, type?): Promise<photoAccessHelper.Album> { | ||||
| export async function getUserAlbumItemByDisplayName(displayName: string, day?, | ||||
|   type?): Promise<photoAccessHelper.Album> { | ||||
|   let fetchResult = null | ||||
|   let album: photoAccessHelper.Album = null | ||||
|   try { | ||||
| @ -136,7 +136,9 @@ export async function getUserAlbumItemByDisplayName(displayName: string, day?, t | ||||
|     }; | ||||
|     const userFileMgr = photoAccessHelper.getPhotoAccessHelper(globalThis.context); | ||||
| 
 | ||||
|     fetchResult = await userFileMgr.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions); | ||||
|     fetchResult = | ||||
|       await userFileMgr.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, | ||||
|         fetchOptions); | ||||
|     console.log('get getUserAlbumItemByDisplayName, count: ' + JSON.stringify(fetchResult)); | ||||
|     if (fetchResult.getCount() > 0) { | ||||
|       const albums = await fetchResult.getLastObject(); | ||||
| @ -194,7 +196,9 @@ export async function delPic(day, type) { | ||||
|     fetchColumns: [], | ||||
|     predicates: predicates | ||||
|   }; | ||||
|   let albumList: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions); | ||||
|   let albumList: photoAccessHelper.FetchResult<photoAccessHelper.Album> = | ||||
|     await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, | ||||
|       albumFetchOptions); | ||||
|   let albums = await albumList.getAllObjects(); | ||||
|   for (let i = 0; i <= albums.length; i++) { | ||||
|     let albumName = albums[i].albumName | ||||
| @ -223,8 +227,7 @@ export async function takePhoto(param, context, dir, flag = 1, callback?) { | ||||
|       console.log("baohaowen_detectLoop round end size1:" + snapResult.fileSize); | ||||
|       callback({ fileSize: snapResult.fileSize, errorCode: snapResult.errorCode }) | ||||
|     }); | ||||
|   } | ||||
|   else { | ||||
|   } else { | ||||
|     return new Promise<takePhotoParam>(async (resolve, reject) => { | ||||
|       const time = await getCurrentTime() | ||||
|       const date = time.split(' ')[0] | ||||
| @ -264,7 +267,8 @@ export async function deleteAllFileByPiC(dirName, type = 1) { | ||||
|   fileHelper.deleteFileOfAlbum(dirName, type); | ||||
| } | ||||
| 
 | ||||
| export async function deleteAllVideos(context, type: photoAccessHelper.AlbumType, subType: photoAccessHelper.AlbumSubtype): Promise<void> { | ||||
| export async function deleteAllVideos(context, type: photoAccessHelper.AlbumType, | ||||
|   subType: photoAccessHelper.AlbumSubtype): Promise<void> { | ||||
|   let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = null; | ||||
|   try { | ||||
|     const userFileMgr = photoAccessHelper.getPhotoAccessHelper(context); | ||||
|  | ||||
| @ -98,7 +98,7 @@ struct UserInfo { | ||||
|     if (singlePlay) { | ||||
|       return '' | ||||
|     } else { | ||||
|       const {filePhoto} = this; | ||||
|       const { filePhoto } = this; | ||||
|       const photoBase64 = await filePhoto.getPhoto(); | ||||
|       return photoBase64 | ||||
|     } | ||||
| @ -119,7 +119,7 @@ struct UserInfo { | ||||
|       this.ksksLimit = true | ||||
| 
 | ||||
|       if (globalThis.singlePlay) { | ||||
|         const {examSubject} = globalThis.carInfo; | ||||
|         const { examSubject } = globalThis.carInfo; | ||||
|         this.currentUser.id = '0' | ||||
|         await upDateTableByArray('USER', [this.currentUser]) | ||||
|         router.pushUrl({ | ||||
| @ -312,7 +312,7 @@ struct UserInfo { | ||||
| 
 | ||||
|         globalThis.lsh = res.lsh | ||||
|         globalThis.ksyh = res.ksy1sfzmhm | ||||
|         const {examSubject} = globalThis.carInfo; | ||||
|         const { examSubject } = globalThis.carInfo; | ||||
|         // this.currentUser.kszp=this.photo+res.kszp | ||||
|         // this.currentUser.ksmjzp=this.photo+this.currentUser.ksmjzp | ||||
|         if (globalThis.singlePlay) { | ||||
| @ -637,7 +637,8 @@ struct UserInfo { | ||||
|     this.ksksLimit = false | ||||
|     // this.isBoardPrePareSetPopupOpen=true | ||||
|     this.isFirstBoardPrePareSetPopupBtnShow = false | ||||
|     console.log('isFirstBoardPrePareSetPopupBtnShow', this.isFirstBoardPrePareSetPopupBtnShow, this.isBoardPrePareSetPopupOpen) | ||||
|     console.log('isFirstBoardPrePareSetPopupBtnShow', this.isFirstBoardPrePareSetPopupBtnShow, | ||||
|       this.isBoardPrePareSetPopupOpen) | ||||
|     this.startExam = false | ||||
|     // await upDateTableByArray('USER', []) | ||||
|     // await upDateTableByArray('USERLIST', []) | ||||
| @ -646,10 +647,14 @@ struct UserInfo { | ||||
|     this.type = '2' | ||||
|     this.errorDialog.open() | ||||
|     this.updateTimeLimit = true | ||||
|     const param = `<getExaminationStudentInfoReq><head><checkCode>${Md5.Instance.get_md5(globalThis.carInfo.carId + globalThis.carInfo.examinationRoomId + globalThis.username)}</checkCode></head><body><carId>${globalThis.carInfo.carId}</carId><examinationRoomId>${globalThis.carInfo.examinationRoomId}</examinationRoomId><examinerName>${globalThis.username}</examinerName><sfzmhm></sfzmhm></body></getExaminationStudentInfoReq>` | ||||
|     const param = `<getExaminationStudentInfoReq><head><checkCode>${Md5.Instance.get_md5(globalThis.carInfo.carId + | ||||
|     globalThis.carInfo.examinationRoomId + | ||||
|     globalThis.username)}</checkCode></head><body><carId>${globalThis.carInfo.carId}</carId><examinationRoomId>${globalThis.carInfo.examinationRoomId}</examinationRoomId><examinerName>${globalThis.username}</examinerName><sfzmhm></sfzmhm></body></getExaminationStudentInfoReq>` | ||||
|     try { | ||||
|       getExaminationStudentInfo(param).then(async (res) => { | ||||
|         console.log("temp log ", JSON.stringify(res)) | ||||
|         await DB.clearTable('USER') | ||||
|         await DB.clearTable('USERLIST') | ||||
|         this.errorDialog.close() | ||||
|         setTimeout(() => { | ||||
|           this.updateTimeLimit = false | ||||
| @ -795,7 +800,8 @@ struct UserInfo { | ||||
|       return | ||||
|     } | ||||
|     console.log('JsonJson', JSON.stringify(this.currentUser)) | ||||
|     const param = `<?xml version="1.0" encoding="UTF-8" ?><examinationStuAbsentReq><body><carId>${globalThis.carInfo.carId}</carId><cardNo>${this.currentUser.sfzmhm}</cardNo><examinationRoomId>${globalThis.carInfo.examinationRoomId}</examinationRoomId><examinerName>${globalThis.username}</examinerName><lsh>${this.lsh}</lsh></body></examinationStuAbsentReq>` | ||||
|     const param = | ||||
|       `<?xml version="1.0" encoding="UTF-8" ?><examinationStuAbsentReq><body><carId>${globalThis.carInfo.carId}</carId><cardNo>${this.currentUser.sfzmhm}</cardNo><examinationRoomId>${globalThis.carInfo.examinationRoomId}</examinationRoomId><examinerName>${globalThis.username}</examinerName><lsh>${this.lsh}</lsh></body></examinationStuAbsentReq>` | ||||
|     console.log('carNo1111', param) | ||||
| 
 | ||||
|     examinationStuAbsent(param).then(res => { | ||||
| @ -831,7 +837,7 @@ struct UserInfo { | ||||
|       return | ||||
|     } | ||||
|     const carInfo = globalThis.carInfo; | ||||
|     const {carId,examinationRoomId} = carInfo; | ||||
|     const { carId, examinationRoomId } = carInfo; | ||||
|     const examItems = await getExaminationItem({ | ||||
|       time: getCurrentTime(), | ||||
|       carId, | ||||
| @ -853,7 +859,7 @@ struct UserInfo { | ||||
|     globalThis.statue = 4 | ||||
|     this.stepFlag = true | ||||
|     const carInfo = globalThis.carInfo; | ||||
|     const {carId,examinationRoomId} = carInfo; | ||||
|     const { carId, examinationRoomId } = carInfo; | ||||
|     let examItems = { getExaminationItemRsp: { body: { ykxx: '' } } }; | ||||
|     if (!globalThis.singlePlay) { | ||||
|       //获取已考项目 | ||||
| @ -871,7 +877,7 @@ struct UserInfo { | ||||
| 
 | ||||
|     avPlayer.playAudio([`voice/监管通信中.mp3`], false, async () => { | ||||
|       console.info('surenjun', '播放结束开始考试接口调用') | ||||
|       const {code,keystr,message} = await this.beginExam() || {}; | ||||
|       const { code, keystr, message } = await this.beginExam() || {}; | ||||
|       console.info('surenjun', '开始考试接口调用结束') | ||||
|       // console.info('surenjun',code +'') | ||||
|       //@ts-ignore TODO code转换 | ||||
| @ -908,8 +914,8 @@ struct UserInfo { | ||||
| 
 | ||||
|   // 检测车门、熄火信号 | ||||
|   async checkSignal(): Promise<boolean> { | ||||
|     const {isCheckFireOpen} = judgeConfig | ||||
|     const {systemParam,isBoardPrePareSetPopupOpen} = this; | ||||
|     const { isCheckFireOpen } = judgeConfig | ||||
|     const { systemParam, isBoardPrePareSetPopupOpen } = this; | ||||
|     const Param803Str = systemParam.Param803Str | ||||
|     if (Param803Str === '') { | ||||
|       return true | ||||
| @ -1014,8 +1020,8 @@ struct UserInfo { | ||||
|   // 开始考试 | ||||
|   async beginExam() { | ||||
|     const carInfo = globalThis.carInfo; | ||||
|     const {carId,examinationRoomId} = carInfo; | ||||
|     const { examSubject,plateNo } = carInfo; | ||||
|     const { carId, examinationRoomId } = carInfo; | ||||
|     const { examSubject, plateNo } = carInfo; | ||||
|     const date = new Date() | ||||
|     globalThis.startHourTime = await getCurrentHourTime() | ||||
|     const photoBase64 = await this.getPhoto(); | ||||
| @ -1119,11 +1125,13 @@ struct UserInfo { | ||||
|             } | ||||
|             .width(165 * this.ratio) | ||||
|             .height(85 * this.ratio) | ||||
|             .backgroundImage(item.sfzmhm != this.currentUser.sfzmhm ? $r('app.media.userbox2') : $r('app.media.userboxbg')) | ||||
|             .backgroundImage(item.sfzmhm != this.currentUser.sfzmhm ? $r('app.media.userbox2') : | ||||
|             $r('app.media.userboxbg')) | ||||
|             .backgroundImageSize({ width: '100%', height: '100%' }) | ||||
|             .onClick(() => { | ||||
|               console.log('this.startExam', this.startExam, this.systemParam.Param364, this.isExamStart) | ||||
|               if ((this.isExamStart && !globalThis.singlePlay && this.systemParam.Param341) || (this.startExam && this.systemParam.Param364 == '2')) { | ||||
|               if ((this.isExamStart && !globalThis.singlePlay && this.systemParam.Param341) || | ||||
|                 (this.startExam && this.systemParam.Param364 == '2')) { | ||||
|                 return | ||||
|               } | ||||
|               this.currentUser = EmptyCandidateObject | ||||
| @ -1218,14 +1226,17 @@ struct UserInfo { | ||||
|             .onClick(() => { | ||||
|               // this.avPlayer.playAudio(['button_media.wav']) | ||||
|               //  已开始考试不能缺考   已考过一次学员不能缺考                                                 车上不能缺考 | ||||
|               if (this.ksksLimit || (this.systemParam.Param352Str == '1' && this.currentUser.kssycs == '1') || this.systemParam.Param770Str == '1') { | ||||
|               if (this.ksksLimit || (this.systemParam.Param352Str == '1' && this.currentUser.kssycs == '1') || | ||||
|                 this.systemParam.Param770Str == '1') { | ||||
|                 return | ||||
|               } | ||||
|               this.ksksLimit = true | ||||
|               this.qkFlag = true | ||||
|             }) | ||||
| 
 | ||||
|           if (this.isBoardPrePareSetPopupOpen && (this.isSecondBoardPrePareSetPopupOpen && this.currentUser.kssycs == '2') && !this.isFirstBoardPrePareSetPopupBtnShow) { | ||||
|           if (this.isBoardPrePareSetPopupOpen && | ||||
|             (this.isSecondBoardPrePareSetPopupOpen && this.currentUser.kssycs == '2') && | ||||
|             !this.isFirstBoardPrePareSetPopupBtnShow) { | ||||
|             //上车准备 | ||||
|             // Image($r('app.media.sczb_btn')).commStyle() | ||||
|             imageBtn({ btnWidth: 220 * this.ratio, btnHeight: 69 * this.ratio, imgSrc: $r('app.media.sczb_btn') }) | ||||
|  | ||||
| @ -13,39 +13,17 @@ interface Params { | ||||
| } | ||||
| 
 | ||||
| export default class FilePhoto { | ||||
|   public mediaTest | ||||
|   private params: Params | ||||
|   private context: any | ||||
|   private fileUtil: FileUtil | ||||
|   public mediaTest | ||||
| 
 | ||||
|   constructor(context) { | ||||
|     (async () => { | ||||
|       //TODO 309参数 获取拍照摄像头拍照通道
 | ||||
|       const fileUtil = new FileUtil(context) | ||||
|       const strConfig = await fileUtil.readFile('/mnt/hmdfs/100/account/device_view/local/files/duolun/config/config3.txt'); | ||||
|       const config = JSON.parse(strConfig) | ||||
|       const {userName,ip,pwd,port,rlls,pztd} = config | ||||
|       this.params = { | ||||
|         userName, | ||||
|         pwd, | ||||
|         ip, | ||||
|         port, | ||||
|         rlls, | ||||
|         pztd | ||||
|       } | ||||
|       this.context = context | ||||
|       this.fileUtil = fileUtil | ||||
|     })() | ||||
|   } | ||||
| 
 | ||||
|   public getPhoto = async () => { | ||||
|     const {params} = this; | ||||
|     const { params } = this; | ||||
|     if (!judgeConfig.isPhotoOpen) { | ||||
|       return '' | ||||
|     } else { | ||||
|       try { | ||||
|         console.info('surenjun', '拍照开始') | ||||
|         const res = await takePhoto(params, this.context, 'pz/', 2); | ||||
|         const res = await takePhoto(params, this.context, 'pz/', 0); | ||||
|         console.info('surenjun', '拍照结束' + JSON.stringify(res)) | ||||
|         return res.base64 | ||||
|       } catch (e) { | ||||
| @ -58,4 +36,26 @@ export default class FilePhoto { | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   private fileUtil: FileUtil | ||||
| 
 | ||||
|   constructor(context) { | ||||
|     (async () => { | ||||
|       //TODO 309参数 获取拍照摄像头拍照通道
 | ||||
|       const fileUtil = new FileUtil(context) | ||||
|       const strConfig = | ||||
|         await fileUtil.readFile('/mnt/hmdfs/100/account/device_view/local/files/duolun/config/config3.txt'); | ||||
|       const config = JSON.parse(strConfig) | ||||
|       const { userName, ip, pwd, port, rlls, pztd } = config | ||||
|       this.params = { | ||||
|         userName, | ||||
|         pwd, | ||||
|         ip, | ||||
|         port, | ||||
|         rlls, | ||||
|         pztd | ||||
|       } | ||||
|       this.context = context | ||||
|       this.fileUtil = fileUtil | ||||
|     })() | ||||
|   } | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user