Merge branch 'api10' of http://88.22.24.105:3000/harmony_car/subject-two into api10
This commit is contained in:
		
						commit
						1a6a87ebae
					
				| @ -1,6 +1,7 @@ | ||||
| 
 | ||||
| import { GetCurrentTime } from '../../../utils/Common' | ||||
| import FileUtils from '../../../utils/FileUtils' | ||||
| import common from '@ohos.app.ability.common'; | ||||
| 
 | ||||
| interface StuInfo { | ||||
|   name: string | ||||
| @ -24,56 +25,46 @@ export default class FileLog { | ||||
|   public examLineDataFd: number = undefined | ||||
|   // 过程文件数据 | ||||
|   public setExamProgressData = async (str: Object) => { | ||||
|     const { fileUtil, folderPath, progressDataFd } = this; | ||||
|     this.progressDataFd = | ||||
|       await fileUtil.editFile(`${folderPath}/exam_progress_data.txt`, JSON.stringify(str), progressDataFd); | ||||
|       await this.fileUtil.editFile(`${this.folderPath}/exam_progress_data.txt`, JSON.stringify(str), this.progressDataFd); | ||||
|   } | ||||
|   // 无锡所接口数据 | ||||
|   public setExamJudgeWuxiData = async (str) => { | ||||
|     const { fileUtil, folderPath, examJudgeWuxiDataFd } = this; | ||||
|     this.examJudgeWuxiDataFd = await fileUtil.editFile(`${folderPath}/wuxi_exam_data.txt`, str, examJudgeWuxiDataFd); | ||||
|   public setExamJudgeWuxiData = async (str:string) => { | ||||
|     this.examJudgeWuxiDataFd = await this.fileUtil.editFile(`${this.folderPath}/wuxi_exam_data.txt`, str, this.examJudgeWuxiDataFd); | ||||
|   } | ||||
|   // 无锡所过程数据 | ||||
|   public setExamJudgeWuxiProgressData = async (str) => { | ||||
|     const { fileUtil, folderPath, examJudgeWuxiProgressDataFd } = this; | ||||
|   public setExamJudgeWuxiProgressData = async (str:string) => { | ||||
|     this.examJudgeWuxiProgressDataFd = | ||||
|       await fileUtil.editFile(`${folderPath}/wuxi_progress_data.txt`, str, examJudgeWuxiProgressDataFd); | ||||
|       await this.fileUtil.editFile(`${this.folderPath}/wuxi_progress_data.txt`, str, this.examJudgeWuxiProgressDataFd); | ||||
|   } | ||||
|   // plc文件数据 | ||||
|   public setPlcProgressData = async (str: Object) => { | ||||
|     const { fileUtil, folderPath, plcDataFd } = this; | ||||
|     this.plcDataFd = await fileUtil.editFile(`${folderPath}/plc_data.txt`, JSON.stringify(str), plcDataFd); | ||||
|     this.plcDataFd = await this.fileUtil.editFile(`${this.folderPath}/plc_data.txt`, JSON.stringify(str), this.plcDataFd); | ||||
|   } | ||||
|   // 过程评判json数据 | ||||
|   public setExamJudgeData = async (str: Object) => { | ||||
|     const { fileUtil, folderPath, examJudgeDataFd } = this; | ||||
|     this.examJudgeDataFd = | ||||
|       await fileUtil.editFile(`${folderPath}/judge_exam_data.txt`, JSON.stringify(str), examJudgeDataFd); | ||||
|       await this.fileUtil.editFile(`${this.folderPath}/judge_exam_data.txt`, JSON.stringify(str), this.examJudgeDataFd); | ||||
|   } | ||||
|   // 过程评判回调数据 | ||||
|   public setExamJudgeCallbackData = async (str: string) => { | ||||
|     const { fileUtil, folderPath, examJudgeCallbackDataFd } = this; | ||||
|     this.examJudgeCallbackDataFd = | ||||
|       await fileUtil.editFile(`${folderPath}/judge_progress_callback_data.txt`, str, examJudgeCallbackDataFd); | ||||
|       await this.fileUtil.editFile(`${this.folderPath}/judge_progress_callback_data.txt`, str, this.examJudgeCallbackDataFd); | ||||
|   } | ||||
|   // 过程评判日志调数据 | ||||
|   public setExamJudgeLogData = async (str: string) => { | ||||
|     const { fileUtil, folderPath, examJudgeLogDataFd } = this; | ||||
|     this.examJudgeLogDataFd = await fileUtil.editFile(`${folderPath}/judge_log_data.txt`, str, examJudgeLogDataFd); | ||||
|     this.examJudgeLogDataFd = await this.fileUtil.editFile(`${this.folderPath}/judge_log_data.txt`, str, this.examJudgeLogDataFd); | ||||
|   } | ||||
|   // 设置四合一画面数据 | ||||
|   public setFourAndOneLogData = async (str: string) => { | ||||
|     const { fileUtil, folderPath, fourAndOneLogDataFd } = this; | ||||
|     this.fourAndOneLogDataFd = await fileUtil.editFile(`${folderPath}/four_one_log_data.txt`, str, fourAndOneLogDataFd); | ||||
|     this.fourAndOneLogDataFd = await this.fileUtil.editFile(`${this.folderPath}/four_one_log_data.txt`, str, this.fourAndOneLogDataFd); | ||||
|   } | ||||
|   public setFourAndOneLogDataBytes = async (str: string) => { | ||||
|     const { fileUtil, folderPath, fourAndOneLogDataBytesFd } = this; | ||||
|     this.fourAndOneLogDataBytesFd = | ||||
|       await fileUtil.editFile(`${folderPath}/four_one_log_byte_data.txt`, str, fourAndOneLogDataBytesFd); | ||||
|       await this.fileUtil.editFile(`${this.folderPath}/four_one_log_byte_data.txt`, str, this.fourAndOneLogDataBytesFd); | ||||
|   } | ||||
|   // 无锡所轨迹数据 | ||||
|   public setExamLineData = async (plcStr) => { | ||||
|     const { fileUtil, folderPath, examLineDataFd } = this; | ||||
|   public setExamLineData = async (plcStr:string) => { | ||||
|     const plcData = plcStr.split(','); | ||||
|     const time = await GetCurrentTime(); | ||||
|     const lineData = [ | ||||
| @ -103,25 +94,23 @@ export default class FileLog { | ||||
|       /*结束符*/ time, | ||||
|     ]; | ||||
|     this.examLineDataFd = | ||||
|       await fileUtil.editFile(`${folderPath}/exam_wuxi_data.txt`, JSON.stringify(lineData), examLineDataFd); | ||||
|       await this.fileUtil.editFile(`${this.folderPath}/exam_wuxi_data.txt`, JSON.stringify(lineData),this.examLineDataFd); | ||||
|   }; | ||||
|   //后续文件路径待替换 | ||||
|   private fileUtil: FileUtils | ||||
|   private stuInfo: StuInfo | ||||
|   // 设置文件夹 | ||||
|   public initFileLogo = async (stuInfo: StuInfo) => { | ||||
|     const { fileUtil, setExamLineData } = this | ||||
|     const { name, lsh, idCard } = stuInfo; | ||||
|     this.stuInfo = stuInfo; | ||||
|     const time = await GetCurrentTime() | ||||
|     const date = time.split(' ')[0].split('-').join('_') | ||||
|     const hourTime = time.split(' ')[1].split(':').join('_') | ||||
|     const folderPath = await fileUtil.initFolder(`/logs/${date}/${date}_${hourTime}_${lsh}_${idCard}_${name}`); | ||||
|     const folderPath = await this.fileUtil.initFolder(`/logs/${date}/${date}_${hourTime}_${stuInfo.lsh}_${stuInfo.idCard}_${stuInfo.name}`); | ||||
|     this.folderPath = folderPath; | ||||
|     return folderPath | ||||
|   } | ||||
| 
 | ||||
|   constructor(context) { | ||||
|   constructor(context:common.UIAbilityContext) { | ||||
|     const fileUtil = new FileUtils(context) | ||||
|     this.fileUtil = fileUtil | ||||
| 
 | ||||
| @ -129,10 +118,9 @@ export default class FileLog { | ||||
| 
 | ||||
|   //关闭所有文件写入 | ||||
|   public closeAllFiles = async () => { | ||||
|     const { fileUtil, folderPath, fourAndOneLogDataFd } = this; | ||||
|     ['exam_progress_data', 'wuxi_exam_data', 'wuxi_progress_data', 'plc_data', 'judge_exam_data', | ||||
|       'judge_progress_callback_data', 'judge_log_data', 'four_one_log_data', 'four_one_log_byte_data'].forEach(path => { | ||||
|       fileUtil.closeFile(`${folderPath}/${path}.txt`); | ||||
|       this.fileUtil.closeFile(`${this.folderPath}/${path}.txt`); | ||||
|     }) | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -1,20 +1,26 @@ | ||||
| import zlib from '@ohos.zlib'; | ||||
| import promptAction from '@ohos.promptAction'; | ||||
| import FileUtils from '../../../utils/FileUtils'; | ||||
| import common from '@ohos.app.ability.common'; | ||||
| 
 | ||||
| interface Options{ | ||||
|   level:number | ||||
|   memLevel:number | ||||
|   strategy:number | ||||
| } | ||||
| 
 | ||||
| export default class FileModel { | ||||
|   public folderPath: string | ||||
|   // 设置文件夹 | ||||
|   public initFolder = async () => { | ||||
|     const { fileUtil } = this | ||||
|     await fileUtil.initFolder(`/models/model_enc`); | ||||
|     const folderPath = await fileUtil.initFolder(`/models`); | ||||
|     await this.fileUtil.initFolder(`/models/model_enc`); | ||||
|     const folderPath = await this.fileUtil.initFolder(`/models`); | ||||
|     this.folderPath = folderPath; | ||||
|   } | ||||
|   //后续文件路径待替换 | ||||
|   private fileUtil: FileUtils | ||||
| 
 | ||||
|   constructor(context) { | ||||
|   constructor(context:common.UIAbilityContext) { | ||||
|     (async () => { | ||||
|       const fileUtil = new FileUtils(context) | ||||
|       this.fileUtil = fileUtil | ||||
| @ -23,31 +29,31 @@ export default class FileModel { | ||||
|   } | ||||
| 
 | ||||
|   // 存储zip文件并解压 | ||||
|   public storingFiles = async (str) => { | ||||
|     const { fileUtil, folderPath } = this; | ||||
|     await fileUtil.editFile(`${folderPath}/model.zip`, str) | ||||
|   public storingFiles = async (str:string) => { | ||||
|     await this.fileUtil.editFile(`${this.folderPath}/model.zip`, str) | ||||
| 
 | ||||
|     let options = { | ||||
|     const folderPath = this.folderPath | ||||
|     let options:Options = { | ||||
|       level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION, | ||||
|       memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT, | ||||
|       strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY | ||||
|     }; | ||||
| 
 | ||||
|     zlib.unzipFile( | ||||
|       `${folderPath}/model.zip`, | ||||
|       `${folderPath}`, | ||||
|       options).then((data) => { | ||||
|       console.log("unzipFile result:" + data); | ||||
|     }).catch((err) => { | ||||
|     try { | ||||
|       zlib.unzipFile( | ||||
|         `${folderPath}/model.zip`, | ||||
|         `${folderPath}`, | ||||
|         options).then((data) => { | ||||
|         console.log("unzipFile result:" + data); | ||||
|       }) | ||||
|     }catch (err) { | ||||
|       console.log("catch((err)=>" + err); | ||||
|     }) | ||||
| 
 | ||||
|     } | ||||
|   } | ||||
|   //获取文件内容 | ||||
|   public getModelContent = (folderPath, fileName) => { | ||||
|     const { fileUtil } = this; | ||||
|   public getModelContent = (folderPath:string, fileName:string) => { | ||||
|     try { | ||||
|       const content = fileUtil.getFileContent(`${folderPath}/${fileName}`) | ||||
|       const content = this.fileUtil.getFileContent(`${folderPath}/${fileName}`) | ||||
|       return content; | ||||
|     } catch (e) { | ||||
|       console.info('surenjun', JSON.stringify(e)) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user