diff --git a/entry/src/main/ets/api/judge.ets b/entry/src/main/ets/api/judge.ets index 9cc2b3bb..88f90ff8 100644 --- a/entry/src/main/ets/api/judge.ets +++ b/entry/src/main/ets/api/judge.ets @@ -6,7 +6,7 @@ import { GetSyncData } from '../utils/table/Operation'; import { GetCurrentTime } from '../utils/Common'; import FileUtils from '../utils/FileUtils'; -let baseHost: string = AppStorage.get('host'); +let baseHost: string = AppStorage.get('host'); // 下载模型 @@ -27,11 +27,11 @@ interface WR { // 通用监管接口 export async function writeObjectOut(params: RegulatoryInterfaceParams, filePath?: string): Promise { - const singlePlay: boolean = AppStorage.get('singlePlay') + const singlePlay: boolean = AppStorage.get('singlePlay') if (singlePlay) { return { code: 1 } } - let JGHOST: string = AppStorage.get("JGHOST") + let JGHOST: string = AppStorage.get("JGHOST") //获取监管接口地址路径 if (!JGHOST) { const syssetParams: MASYSSETTableType[] = await GetSyncData("MA_SYSSET"); @@ -49,7 +49,7 @@ export async function writeObjectOut(params: RegulatoryInterfaceParams, filePath }) } // const { xtlb, jkxlh, jkid, drvexam } = params; - const isJGNew: boolean = AppStorage.get('isJGNew') + const isJGNew: boolean = AppStorage.get('isJGNew') //新监管调用 if (isJGNew) { return await writeObjectOutNew(params, filePath) @@ -73,7 +73,7 @@ export async function writeObjectOut(params: RegulatoryInterfaceParams, filePath } //对象转换成xml - JGHOST = AppStorage.get("JGHOST") + JGHOST = AppStorage.get("JGHOST") const temp = await request({ host: JGHOST, url: '/dems_ws/services/TmriOutAccess?wsdl', @@ -132,7 +132,7 @@ interface UploadExamProgressDataParams { // 过程文件上传 export async function uploadExamProgressData(params: UploadExamProgressDataParams) { // const singlePlay = globalThis.singlePlay - const singlePlay: boolean = AppStorage.get('singlePlay') + const singlePlay: boolean = AppStorage.get('singlePlay') if (singlePlay) { return } @@ -169,7 +169,7 @@ interface UploadExamProgressDataParams2 { export async function uploadExamProgressData2(params: UploadExamProgressDataParams2) { // const singlePlay = globalThis.singlePlay - const singlePlay: boolean = AppStorage.get('singlePlay') + const singlePlay: boolean = AppStorage.get('singlePlay') if (singlePlay) { return } @@ -203,7 +203,7 @@ interface UploadExamMileage { // 上传考试里程 export async function uploadExamMileage(params: UploadExamMileage) { // const singlePlay = globalThis.singlePlay - const singlePlay: boolean = AppStorage.get('singlePlay') + const singlePlay: boolean = AppStorage.get('singlePlay') if (singlePlay) { return @@ -230,7 +230,7 @@ export async function uploadExamMileage(params: UploadExamMileage) { // 上传考试成绩 export async function uploadExamGrade(params: ESObject) { // const singlePlay = globalThis.singlePlay - const singlePlay: boolean = AppStorage.get('singlePlay') + const singlePlay: boolean = AppStorage.get('singlePlay') if (singlePlay) { return } diff --git a/entry/src/main/ets/common/service/initable.ets b/entry/src/main/ets/common/service/initable.ets index 87827d7f..87e18250 100644 --- a/entry/src/main/ets/common/service/initable.ets +++ b/entry/src/main/ets/common/service/initable.ets @@ -30,6 +30,7 @@ import { GlobalConfig } from '../../config/index'; import prompt from '@ohos.promptAction'; import DB, { ColumnType } from '../database/DbSql'; import FileUtils from '../../utils/FileUtils'; +import { TimeSynchronizationRspBody } from '../../model'; //读表 //参数平台 @@ -291,7 +292,7 @@ export async function delSyncTable(tableName, context?) { //获取车模、场地模型 export async function getEsCarModel(context) { const date = new Date() - const timeInfo = AppStorage.get('timeInfo') + const timeInfo = AppStorage.get('timeInfo') if (!timeInfo?.paraKdid) { prompt.showToast({ message: 'paraKdid获取失败', @@ -308,7 +309,7 @@ export async function getEsCarModel(context) { "paraKdid": timeInfo.paraKdid, //参数平台kdid "examinationRoomId": timeInfo.kdid, //考试平台kdid // "carMac":"MAC-HCPAD-210", - "carMac": AppStorage.get('deviceNo') + "carMac": AppStorage.get('deviceNo') } } const venueStr = { @@ -320,7 +321,7 @@ export async function getEsCarModel(context) { "paraKdid": timeInfo.paraKdid, //参数平台kdid "examinationRoomId": timeInfo.kdid, //考试平台kdid // "carMac":"MAC-HCPAD-210", - "carMac": AppStorage.get('deviceNo') + "carMac": AppStorage.get('deviceNo') } } diff --git a/entry/src/main/ets/common/utils/GlobalUdp.ts b/entry/src/main/ets/common/utils/GlobalUdp.ts index 64d28221..dca009b4 100644 --- a/entry/src/main/ets/common/utils/GlobalUdp.ts +++ b/entry/src/main/ets/common/utils/GlobalUdp.ts @@ -137,7 +137,7 @@ export async function getUDP2(context, errorFlag?) { globalThis.udpEvent.sendKfContent(val.body[0]) } else if (val.id == '46') { let tmpList = [] - const str = AppStorage.get('lsh') + const str = AppStorage.get('lsh') for (let i = 0; i < str.length; i++) { tmpList.push(this.string2Bytes(str.charCodeAt(i), 1 * 8)[0]) } @@ -188,7 +188,7 @@ export async function setJudgeUdp() { const fileUtil = new FileUtil(context) const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/ipConfig.txt'); const config = JSON.parse(data) - const carInfo = AppStorage.get('carInfo') + const carInfo = AppStorage.get('carInfo') // // const config = await getSyncData('IpConfigTable'); let udpIndex = 0; diff --git a/entry/src/main/ets/common/utils/UdpJudge.ts b/entry/src/main/ets/common/utils/UdpJudge.ts index e7532b3b..36be176b 100644 --- a/entry/src/main/ets/common/utils/UdpJudge.ts +++ b/entry/src/main/ets/common/utils/UdpJudge.ts @@ -2,7 +2,7 @@ import systemTime from '@ohos.systemDateTime'; import { testKm2Items, testKm3Items } from '../../pages/judgeSDK/dataTest/index'; import { judgeConfig } from '../../pages/judgeSDK/utils/judgeConfig'; import { setJudgeUdp, setTopLineUdp } from './GlobalUdp'; -import { examCalcGpsDistance } from '../../pages/judgeSDK/api' +import { examCalcGpsDistance } from '../../pages/judgeSDK/api'; export const initJudgeUdp = async () => { AppStorage.setOrCreate('serialIndex', 0) @@ -51,7 +51,7 @@ export const initJudgeUdp = async () => { } export const getMessageHeartbeat = async (msg) => { - const carInfo = AppStorage.get('carInfo'); + const carInfo = AppStorage.get('carInfo'); const { examSubject, plateNo } = carInfo; const ksyh = '0000000000000' const { fourInOneScreen:{ gpsDigit } } = judgeConfig diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 7f8ef164..3e78fa27 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -44,10 +44,10 @@ export default class EntryAbility extends UIAbility { AppStorage.setOrCreate('carInfo', {}) AppStorage.setOrCreate('examinerInfo', {}) - AppStorage.setOrCreate('lsh', '0000000000000') - AppStorage.setOrCreate('statue', 1) //考试状态 - AppStorage.setOrCreate('signNum', 0) //心跳指令编号 - AppStorage.setOrCreate('deviceNo', 0) //设备号 + AppStorage.setOrCreate('lsh', '0000000000000') + AppStorage.setOrCreate('statue', "1") //考试状态 + AppStorage.setOrCreate('signNum', 0) //心跳指令编号 + AppStorage.setOrCreate('deviceNo', "") //设备号 AppStorage.setOrCreate('baseInfo', { hasAuth: false, version: GlobalConfig.version.jn.km3[0], diff --git a/entry/src/main/ets/model/Table.ets b/entry/src/main/ets/model/Table.ets index 1b44272b..822e92de 100644 --- a/entry/src/main/ets/model/Table.ets +++ b/entry/src/main/ets/model/Table.ets @@ -1,5 +1,5 @@ -import { ColumnInfo, ColumnType } from '../common/database/DbSql' import common from '@ohos.app.ability.common'; +import { ColumnInfo, ColumnType } from '../utils/DbSql'; export const MA_SYS_SET_COLUMN: ColumnInfo[] = [ { diff --git a/entry/src/main/ets/model/api.ets b/entry/src/main/ets/model/api.ets index f8464c01..7c52bddf 100644 --- a/entry/src/main/ets/model/api.ets +++ b/entry/src/main/ets/model/api.ets @@ -1,4 +1,4 @@ -import { DrvexamType } from "."; +import { DrvexamType } from '.'; // -----new----- export interface ApiResponseType { @@ -28,6 +28,8 @@ interface TimeSynchronizationRsp { export interface TimeSynchronizationRspBody { mode?: string; url?: string + paraKdid?: string + kdid?: string } interface UploadExamCarCheckResultRsp { diff --git a/entry/src/main/ets/pages/CarCheck.ets b/entry/src/main/ets/pages/CarCheck.ets index 397a7685..3f22ade5 100644 --- a/entry/src/main/ets/pages/CarCheck.ets +++ b/entry/src/main/ets/pages/CarCheck.ets @@ -4,9 +4,8 @@ import TopLogo from './compontents/TopLogo'; import testNapi from '@ohos.hiserialsdk'; import { DwMapData, PassData, RealNumData, StackValueData, WarnFlagData, WarnFlagTipData } from '../mock'; import { BaseInfoType, RouteParamsType } from '../model/Common'; -import { CarCheckDataType, CarConfigurationParams, CarInfoType } from '../model'; +import { CarCheckDataType, CarConfigurationParams, CarInfoType, SpzdType } from '../model'; import { BusinessError } from '@ohos.base'; -import { SpzdType } from '../model'; import { voiceService } from '../utils/Voice'; import dayTs from '../utils/Date'; @@ -46,7 +45,7 @@ struct Index { // private AccountTable = new AccountTable(()=>{},CommonConstants); aboutToAppear() { const that = this - this.carInfo = AppStorage.get('carInfo') + this.carInfo = AppStorage.get('carInfo') this.vocObj = new voiceService(async (status: string, val: string) => { if (!that.breakFlag) { return @@ -121,7 +120,7 @@ struct Index { // carConfigurationInfoFn() { - if (AppStorage.get('singlePlay')) { + if (AppStorage.get('singlePlay')) { const str = "1:5;2:5;3:5;4:5;5:5;6:5;7:5;8:5;9:5;10:5;11:5;12:5;13:5;14:5;15:5;16:5;17:5;18:5;19:5;20:5;21:5;22:2;23:5;24:5" const data = str.split(';') @@ -137,7 +136,7 @@ struct Index { this.checkListCopy = JSON.parse(JSON.stringify(this.checkList)) return } - const baseInfo = AppStorage.get('baseInfo') as BaseInfoType + const baseInfo = AppStorage.get("baseInfo") //模拟真实数据 const param: CarConfigurationParams = { body: { @@ -277,7 +276,7 @@ struct Index { type: 1, name: flag ? 'zjwtg.wav' : 'zjtg.wav' }) - if (AppStorage.get('singlePlay')) { + if (AppStorage.get('singlePlay')) { return } let date = new Date(); diff --git a/entry/src/main/ets/pages/ExaminerLogin.ets b/entry/src/main/ets/pages/ExaminerLogin.ets index a95c9f5d..92af74d7 100644 --- a/entry/src/main/ets/pages/ExaminerLogin.ets +++ b/entry/src/main/ets/pages/ExaminerLogin.ets @@ -94,7 +94,7 @@ struct Index { if (this.limit) { return } - const carInfo: CarInfoType = AppStorage.get('carInfo') + const carInfo: CarInfoType = AppStorage.get('carInfo') const param: UserLoginType = { carId: carInfo.carId as string, examinationRoomId: carInfo.examinationRoomId as string, @@ -130,7 +130,7 @@ struct Index { console.log('res11', JSON.stringify(res)) const examinerLoginInfo: ExaminerLoginInfo = res.examinerLoginRsp.body examinerLoginInfo.username = this.inputTextArr[0] - AppStorage.setOrCreate('examinerLoginInfo', examinerLoginInfo) + AppStorage.setOrCreate('examinerLoginInfo', examinerLoginInfo) }).catch((err: BusinessError) => { console.log('jiangsong12', JSON.stringify(err)) this.errorDialog.close() diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 1aa2fac0..c24fd614 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -11,8 +11,12 @@ import errorMsgDialog from './compontents/errorMsgDialog'; import imageBtn from './compontents/imageBtn'; import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; import { BaseInfoType } from '../model/Common'; -import { CarInfoType } from '../model'; -import { InitializeTheCentralTableType, MASYSSETTableType, TimeInfo } from '../model'; +import { + CarInfoType, + InitializeTheCentralTableType, + MASYSSETTableType, + TimeSynchronizationRspBody +} from '../model'; import { GetCarInfo, GetDeviceInfo, SetCurrentTime, SetSerialNumber, UseAuth } from './Index/utils'; import { GetSyncData, InitializeTheCentralTable } from '../utils/table/Operation'; import { BusinessError } from '@ohos.base'; @@ -56,7 +60,7 @@ struct Index { ) private interval = -1; private avPlayer: VoiceAnnounce - private timeInfo: TimeInfo + private timeInfo: TimeSynchronizationRspBody private context = getContext(this) as common.UIAbilityContext; @Styles @@ -353,7 +357,7 @@ struct Index { async aboutToAppear() { this.avPlayer = new VoiceAnnounce(); - this.ratio = AppStorage.get('ratio') + this.ratio = AppStorage.get('ratio') this.initParamFlag = false this.delLoading = false this.dialogVisiable = false @@ -391,7 +395,7 @@ struct Index { kdid: this.timeInfo?.kdid || this.timeInfo?.paraKdid, mode: this.timeInfo?.mode, context: this.context, - host: AppStorage.get('host'), + host: AppStorage.get('host'), centerHost: this.timeInfo?.url, singlePlay: this.singlePlay } @@ -427,13 +431,13 @@ struct Index { } async heartMsg() { - const signNum = AppStorage.get('signNum') as number - const statue = AppStorage.get('statue') as number - const lsh = AppStorage.get('lsh') as String + const signNum = AppStorage.get('signNum') + const statue = AppStorage.get('statue') + const lsh = AppStorage.get('lsh') const arr = [signNum || 0, statue || 1] let tmpList: number[] = []; - tmpList.push(NumberToByteArray(arr[0], 1 * 8)[0]) - tmpList.push(NumberToByteArray(arr[1], 1 * 8)[0]) + tmpList.push(NumberToByteArray(Number(arr[0]), 1 * 8)[0]) + tmpList.push(NumberToByteArray(Number(arr[1]), 1 * 8)[0]) const str = lsh || '0000000000000' for (let i = 0; i < str.length; i++) { tmpList.push(NumberToByteArray(str.charCodeAt(i), 1 * 8)[0]) @@ -453,8 +457,8 @@ struct Index { async onPageShow() { console.log('ttttt', 1111) - this.singlePlay = AppStorage.get('singlePlay') - this.baseInfo = AppStorage.get('baseInfo') as BaseInfoType + this.singlePlay = AppStorage.get('singlePlay') + this.baseInfo = AppStorage.get('baseInfo') // await this.userAuth(); UseAuth(this.context).then(() => { this.initParams() @@ -504,12 +508,12 @@ struct Index { await GetCarInfo() await getUDP2(this.context, false) getTCP() - this.carInfo = AppStorage.get('carInfo') + this.carInfo = AppStorage.get('carInfo') this.deviceId = this.carInfo.carNo // await setCurrentTime(); await SetCurrentTime() - this.timeInfo = AppStorage.get('timeInfo') - const distanceClass = AppStorage.get('distanceClass') as boolean + this.timeInfo = AppStorage.get('timeInfo') + const distanceClass = AppStorage.get('distanceClass') if (!distanceClass) { const distanceClass = new GetDistance(this.context) await distanceClass.initFolder() diff --git a/entry/src/main/ets/pages/Index/utils.ets b/entry/src/main/ets/pages/Index/utils.ets index 534360ff..cb674473 100644 --- a/entry/src/main/ets/pages/Index/utils.ets +++ b/entry/src/main/ets/pages/Index/utils.ets @@ -16,7 +16,10 @@ import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; import { BusinessError } from '@ohos.base'; import systemTime from '@ohos.systemTime'; import { VideoConfigData } from '../../mock'; -ontext: common.UIAbilityContext): Promise { +import FileUtils from '../../utils/FileUtils'; + +//获取设备信息 +export async function GetDeviceInfo(context: common.UIAbilityContext): Promise { return new Promise(async (resolve, reject) => { const fileUtil = new FileUtils(context) const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/deviceNo.txt'); @@ -40,7 +43,7 @@ export async function GetCarInfo() { let date = new Date(); let params: ObtainCarExamInfoParams = { time: dayTs(date).format("YYYY-MM-DD HH:mm:ss"), - deviceNo: AppStorage.get('deviceNo') + deviceNo: AppStorage.get('deviceNo') }; let res: ApiResponseType = await obtainCarExamInfo(params) if (res.obtainCarExamInfoRsp.body) { @@ -87,7 +90,7 @@ export async function SetCurrentTime(): Promise { judgeVersion: baseInfo.judgeVersion } let res: ApiResponseType = await timeSynchronization(params); - AppStorage.setOrCreate('timeInfo', res.timeSynchronizationRsp.body) + AppStorage.setOrCreate('timeInfo', res.timeSynchronizationRsp.body) let currentTime = res.timeSynchronizationRsp.head.time; let times = new Date(currentTime).getTime(); try { diff --git a/entry/src/main/ets/pages/Judge.ets b/entry/src/main/ets/pages/Judge.ets index 699b11b9..8193d0d4 100644 --- a/entry/src/main/ets/pages/Judge.ets +++ b/entry/src/main/ets/pages/Judge.ets @@ -159,8 +159,8 @@ struct Index { async aboutToAppear() { const time = await GetCurrentTime() - this.carInfo = AppStorage.get('carInfo') - this.singlePlay = AppStorage.get('singlePlay') + this.carInfo = AppStorage.get('carInfo') + this.singlePlay = AppStorage.get('singlePlay') this.startTime = time.split(' ')[1] this.startFullTime = await GetCurrentTime(1); // this.startHourTime = await getCurrentHourTime() diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index 4d272aae..b9e10832 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -220,9 +220,9 @@ struct UserInfo { this.ksksLimit = false this.currentUser = EmptyCandidateObject this.filePhoto = new FilePhoto(this.context); - this.singlePlay = AppStorage.get('singlePlay') - this.examinerLoginInfo = AppStorage.get('examinerLoginInfo') - this.carInfo = AppStorage.get('carInfo') + this.singlePlay = AppStorage.get('singlePlay') + this.examinerLoginInfo = AppStorage.get('examinerLoginInfo') + this.carInfo = AppStorage.get('carInfo') //语音功能on // new WebRTCVoice(this.context); //初始化数据 @@ -485,7 +485,7 @@ struct UserInfo { //考点端查询缺考指令内容消息请求 getqkFn() { let tmpList: Array = []; - tmpList.push(NumberToByteArray(AppStorage.get('signNum'), 1 * 8)[0]) + tmpList.push(NumberToByteArray(AppStorage.get('signNum'), 1 * 8)[0]) const param: QKParamType = { id: 41, list: tmpList, @@ -1275,7 +1275,7 @@ struct UserInfo { getqkFlag: $getqkFlag, faceCatchImg: $faceCatchImg, showFaceCompare: $showFaceCompare, - lsh: AppStorage.get('lsh'), + lsh: AppStorage.get('lsh'), }) } if (this.qkFlag) { diff --git a/entry/src/main/ets/pages/compontents/FaceCompare.ets b/entry/src/main/ets/pages/compontents/FaceCompare.ets index f049ad8e..0843e8b9 100644 --- a/entry/src/main/ets/pages/compontents/FaceCompare.ets +++ b/entry/src/main/ets/pages/compontents/FaceCompare.ets @@ -174,7 +174,7 @@ export default struct FaceCompare { async aboutToAppear() { const fileUtil = new FileUtils(this.context) - this.carInfo = AppStorage.get('carInfo') + this.carInfo = AppStorage.get('carInfo') this.fileUtil = fileUtil this.getVideoConfig() } @@ -187,7 +187,7 @@ export default struct FaceCompare { getqkFn() { let tmpList: number[] = []; - tmpList.push(NumberToByteArray(AppStorage.get('signNum'), 1 * 8)[0]) + tmpList.push(NumberToByteArray(AppStorage.get ('signNum'), 1 * 8)[0]) const param: ParamType = { id: 41, list: tmpList, diff --git a/entry/src/main/ets/pages/compontents/judge/BoardPrePareSetPopup.ets b/entry/src/main/ets/pages/compontents/judge/BoardPrePareSetPopup.ets index ccb7ce7a..8427f19c 100644 --- a/entry/src/main/ets/pages/compontents/judge/BoardPrePareSetPopup.ets +++ b/entry/src/main/ets/pages/compontents/judge/BoardPrePareSetPopup.ets @@ -81,8 +81,8 @@ export default struct DeductedPopup { private avPlayer: VoiceAnnounce async aboutToAppear() { - this.carInfo = AppStorage.get('carInfo') - this.singlePlay = AppStorage.get('singlePlay') + this.carInfo = AppStorage.get('carInfo') + this.singlePlay = AppStorage.get('singlePlay') this.avPlayer = new VoiceAnnounce(); this.judgeTask = new JudgeTask(); const mediaTest = new FilePhoto(this.context); diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ets b/entry/src/main/ets/pages/judgeSDK/judge.ets index 273f1589..3fcd2d85 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ets +++ b/entry/src/main/ets/pages/judgeSDK/judge.ets @@ -48,6 +48,7 @@ import { Array2Byte, convertGpsCoord2, deepClone, fillZero, string2Bytes } from import { GetCurrentTime, StringToASCII } from '../../utils/Common'; import UsbService from '../../utils/USB'; import FileUtils from '../../utils/FileUtils'; +import { BaseInfoType, CarInfoType } from '../../model'; const judgeTag = 'SURENJUN_JUDGE' @@ -68,7 +69,7 @@ export default class Judge { } //上传无锡所过程数据 uploadProgressData = async () => { - const carInfo = AppStorage.get('carInfo') + const carInfo = AppStorage.get('carInfo') const { judgeUI, fileUtil, fileLog } = this; const { idCard, startFullTime } = judgeUI const { carId, examinationRoomId } = carInfo @@ -119,7 +120,7 @@ export default class Judge { } // 处理特殊参数配置 handleSEP = async (code: number) => { - const carInfo = AppStorage.get('carInfo') + const carInfo = AppStorage.get('carInfo') const { judgeUI:{ judgeConfigObj @@ -239,7 +240,7 @@ export default class Judge { private filePhoto: FilePhoto // 过程照片拍照 getPhoto = async (empty?: boolean) => { - const singlePlay: boolean = AppStorage.get('singlePlay') + const singlePlay: boolean = AppStorage.get('singlePlay') //单机模式返回空照片 if (singlePlay) { return '' @@ -466,7 +467,7 @@ export default class Judge { if (!this.isExamEnd) { await examJudgeRealExam(plcData) } - let udpIndex = AppStorage.get('udpIndex') as number; + let udpIndex = AppStorage.get('udpIndex'); let [prevJd, preWd] = [0, 0] if (udpIndex % 5 === 0 && !this.isUdpEnd) { // TODO UPD缺失 @@ -521,7 +522,7 @@ export default class Judge { private isJudgeDisConnect: boolean; // 项目开始接口同步 beginProject = async (ksxm) => { - const carInfo = AppStorage.get('carInfo'); + const carInfo = AppStorage.get('carInfo'); const { examSubject, plateNo } = carInfo; const { judgeUI, fileLog, getSbbm, xmxh, filePath } = this; const { lsh, idCard, serialNumber, projectsObj, ksdd, kslx, xldm } = judgeUI @@ -557,7 +558,7 @@ export default class Judge { } // 项目结束接口同步 endProject = async (ksxm) => { - const carInfo = AppStorage.get('carInfo'); + const carInfo = AppStorage.get('carInfo'); const { examSubject, plateNo, carNo } = carInfo; const { judgeUI, fileLog, getSbxh, xmxh, getSbbm, filePath } = this; const { lsh, idCard, serialNumber, projectsObj, cdsbInfoObj, ksdd, kslx, xldm, } = judgeUI @@ -623,7 +624,7 @@ export default class Judge { const time = await GetCurrentTime(); const { judgeUI, plcData, getPhoto, fileLog, filePath } = this; const photoBase64 = await getPhoto(); - const carInfo = AppStorage.get('carInfo'); + const carInfo = AppStorage.get('carInfo'); const { examSubject, plateNo, carNo } = carInfo; const { lsh, idCard, serialNumber, projectsObj, ksdd, judgeConfigObj } = judgeUI; const { sensor, gps } = plcData @@ -703,7 +704,7 @@ export default class Judge { // 获取评判初始化数据 getJudgeInitData = async () => { const { getModelData, getKm3JudgeInitConfig } = this - const carInfo = AppStorage.get('carInfo'); + const carInfo = AppStorage.get('carInfo'); const { examSubject, plateNo, carId } = carInfo; const judgeUI = this.judgeUI const { projectsObj, itemInfoObj, markRuleListObj, carType, carName, systemparmArr, carinfoArr } = judgeUI @@ -723,7 +724,7 @@ export default class Judge { const sdkver = await examJudgeVersion(); const initInfo = { sdkver, - appver: AppStorage.get('baseInfo').version, + appver: AppStorage.get('baseInfo').version, kskm: examSubject * 1, kchp: plateNo, kchm: carId * 1, @@ -1104,7 +1105,7 @@ export default class Judge { case 5: console.info(judgeTag, '考试结束') //关闭录像 - const singlePlay = AppStorage.get('singlePlay') as boolean + const singlePlay = AppStorage.get('singlePlay') if (!singlePlay) { await endRecordVideo(this.videoData) } @@ -1131,7 +1132,7 @@ export default class Judge { } // 考试扣分 pointsDedute = async (ksxm, kf) => { - const carInfo = AppStorage.get('carInfo'); + const carInfo = AppStorage.get('carInfo'); const { examSubject, plateNo, carNo } = carInfo; const { judgeUI, getProjectInfo, fileLog, xmmcSingleCode, xmmcEndCode, filePath } = this; const { lsh, idCard, serialNumber, ksdd, projectsObj } = judgeUI @@ -1212,7 +1213,7 @@ export default class Judge { const { judgeConfigObj, examSubject, isAllProjectsEnd, totalScore, passingScore } = judgeUI; //计算考试分数 // this.judgeUI.totalScore = isAllProjectsEnd ? totalScore : 0; - const singlePlay = AppStorage.get('singlePlay') + const singlePlay = AppStorage.get('singlePlay') const param302 = judgeConfigObj['302']; // globalThis.windowClass.setWindowSystemBarEnable(['navigation']) @@ -1261,8 +1262,8 @@ export default class Judge { } // 考试结束 public endExam = async (isManual?: Boolean) => { - const carInfo = AppStorage.get('carInfo'); - const singlePlay = AppStorage.get('singlePlay') + const carInfo = AppStorage.get('carInfo'); + const singlePlay = AppStorage.get('singlePlay') const { examSubject, plateNo } = carInfo; const { judgeUI, @@ -1447,7 +1448,7 @@ export default class Judge { } // 消息心跳发送 getMessageHeartbeat = async (isEnd?: Boolean) => { - const carInfo = AppStorage.get('carInfo'); + const carInfo = AppStorage.get('carInfo'); const { examSubject, plateNo, ksyh } = carInfo; const { judgeUI, @@ -1464,7 +1465,7 @@ export default class Judge { getSbxh, fileLog, } = this; - const singlePlay = AppStorage.get('singlePlay') + const singlePlay = AppStorage.get('singlePlay') const { lsh, startHourTime, totalScore, examTime, judgeConfigObj } = judgeUI; const { fourInOneScreen:{ diff --git a/entry/src/main/ets/pages/judgeSDK/utils/judgeCommon.ets b/entry/src/main/ets/pages/judgeSDK/utils/judgeCommon.ets index 7d4ce240..fd524a1d 100644 --- a/entry/src/main/ets/pages/judgeSDK/utils/judgeCommon.ets +++ b/entry/src/main/ets/pages/judgeSDK/utils/judgeCommon.ets @@ -2,6 +2,7 @@ import { testMarkRules, testRealExam } from '../dataTest/index'; import systemTime from '@ohos.systemDateTime'; import { Array2Byte } from './Common'; +import { CarInfoType } from '../../../model'; //获取本地扣分项 export const getTestMarkRules = () => { @@ -110,7 +111,7 @@ export function getKmProjectVoice( lane, xmxh ) { - const carInfo = AppStorage.get('carInfo'); + const carInfo = AppStorage.get('carInfo'); const { examSubject } = carInfo; const param506Str = judgeConfig['506']?.split(',') || []; const param512Str = judgeConfig['512']?.split(',') || []; @@ -206,7 +207,7 @@ export function promptWxCode( ) { let toast = ''; - const singlePlay = AppStorage.get('singlePlay') + const singlePlay = AppStorage.get('singlePlay') if (singlePlay) { return } diff --git a/entry/src/main/ets/pages/judgeSDK/utils/judgeReal.ets b/entry/src/main/ets/pages/judgeSDK/utils/judgeReal.ets index 7b56621c..18c89c94 100644 --- a/entry/src/main/ets/pages/judgeSDK/utils/judgeReal.ets +++ b/entry/src/main/ets/pages/judgeSDK/utils/judgeReal.ets @@ -21,7 +21,7 @@ export default class JudgeImg { } async init() { - const isJudgeInitBool = AppStorage.get('isJudgeInitBool'); + const isJudgeInitBool = AppStorage.get('isJudgeInitBool'); const { judgeUI } = this; //TODO 临时处理 diff --git a/entry/src/main/ets/pages/webRTC/model/WebRtcModel.ts b/entry/src/main/ets/pages/webRTC/model/WebRtcModel.ts index 7092f5bb..124e4e7c 100644 --- a/entry/src/main/ets/pages/webRTC/model/WebRtcModel.ts +++ b/entry/src/main/ets/pages/webRTC/model/WebRtcModel.ts @@ -1,14 +1,12 @@ import media from '@ohos.multimedia.media'; import webSocket from '@ohos.net.webSocket'; -import camera from '@ohos.multimedia.camera'; -import common from '@ohos.app.ability.common'; -import ethernet from '@ohos.net.ethernet'; -import prompt from '@ohos.prompt' +import prompt from '@ohos.prompt'; const TAG_RTC: string = '[SURENJUN_RTC]'; -const carNo = AppStorage.get('carInfo').carNo; +const carNo = AppStorage.get('carInfo').carNo; const WS_SERVER = `ws://192.168.36.9:5000/ws/KM2-C${carNo}/2`; + // const WS_SERVER = 'wss://webrtc.nirbheek.in:8443'; // const WS_SERVER = 'wss://webrtc.youzhi.life:8443'; export enum WebRtcState { @@ -25,18 +23,90 @@ export enum WebRtcState { } export default class WebRtcModel { - private ourId : string = ''; + public isConnected: boolean = false; + sendIceCandidate = async (icecandidate: any) => { + const { peerId, remoteUserId } = this + this.sendMessage(JSON.stringify({ + eventName: '__ice_candidate', + data: { + userID: remoteUserId, + id: 'audio', + label: 0, + fromId: peerId, + candidate: icecandidate.candidate + } + })); + } + private ourId: string = ''; //TODO 待替换 private peerId: string = `KM2-C${carNo}`; - public isConnected: boolean = false; private remoteUserId: string = ''; - private roomId: string = ''; // private state: number = WebRtcState.UNKNOWN; - + private roomId: string = ''; private context: any = undefined; - private ws : webSocket.WebSocket = undefined; - private webrtc : media.WebRtc = undefined; + private ws: webSocket.WebSocket = undefined; + private webrtc: media.WebRtc = undefined; + sendAnswer = async () => { + const { peerId:fromID, remoteUserId:userID } = this; + console.info(TAG_RTC, 'surenjun') + try { + let answer = await this.webrtc.createAnswer(); + console.info(TAG_RTC, 'createAnswer: ' + JSON.stringify(answer)); + + this.webrtc.setLocalDescription(answer); + + this.sendMessage(JSON.stringify({ + eventName: '__answer', + data: { + userID, + fromID, + label: 0, + id: 'audio', + sdp: answer.sdp + } + })) + this.isConnected = true; + } catch (e) { + console.error(TAG_RTC, 'createAnswer: ' + JSON.stringify(e)); + } + } + receiveSdp = async (sdp) => { + let type = sdp.type as string; + // let text = json.sdp.text as string; + if (type === 'offer') { + this.webrtc.setRemoteDescription(sdp); + this.sendAnswer(); + prompt.showToast({ + message: '语音对讲连接完成', + duration: 4000 + }); + } else if (type === 'answer') { + this.webrtc.setRemoteDescription(sdp); + } + } private stateCallback: (state: number, message: string) => void = undefined; + sendOffer = async () => { + const { peerId:fromID, remoteUserId:userID } = this; + try { + let offer = await this.webrtc.createOffer(); + this.webrtc.setLocalDescription(offer); + if (this.stateCallback) { + this.stateCallback(WebRtcState.PEER_NEGOTIATING, '发送Offer'); + } + this.sendMessage(JSON.stringify({ + eventName: '__answer', + data: { + userID, + fromID, + label: 0, + id: 'audio', + sdp: offer.sdp + } + })) + } catch (e) { + console.error(TAG_RTC, 'createOffer: ' + JSON.stringify(e)); + } + } initWebSocket(ourId: string, handleStateChange: (state, message) => void) { @@ -57,30 +127,49 @@ export default class WebRtcModel { console.info(TAG_RTC, '信令服务器连接失败'); }); - this.ws.on('message', (err, value:string) => { - const {acceptInvited,receiveIce,sendAnswer,receiveSdp,disconnect} = this; + this.ws.on('message', (err, value: string) => { + const { acceptInvited, receiveIce, sendAnswer, receiveSdp, disconnect } = this; const socketMessage = JSON.parse(value); - const {eventName,data:{candidate,sdp,room,userID,inviteID:fromId,toID}} = socketMessage; + const { + eventName, data:{ + candidate, + sdp, + room, + userID, + inviteID: fromId, + toID + } + } = socketMessage; - console.info(TAG_RTC,'receive message =>' + eventName.split('__')[1]) - switch (eventName.split('__')[1]){ + console.info(TAG_RTC, 'receive message =>' + eventName.split('__')[1]) + switch (eventName.split('__')[1]) { - //离开 - case 'leave':disconnect();break + //离开 + case 'leave': + disconnect(); + break - //收到对方邀请通知 - case 'invite':acceptInvited(fromId , room);break; + //收到对方邀请通知 + case 'invite': + acceptInvited(fromId, room); + break; - //对方接受通话邀请 + //对方接受通话邀请 case 'new_peer': - //添加ice证书 - case 'ice_candidate':receiveIce(candidate);break; + //添加ice证书 + case 'ice_candidate': + receiveIce(candidate); + break; case 'answer': - // sendAnswer() + // sendAnswer() - case 'offer':receiveSdp({type:'offer',sdp});break; + case 'offer': + receiveSdp({ + type: 'offer', sdp + }); + break; default: } @@ -149,7 +238,11 @@ export default class WebRtcModel { console.info(TAG_RTC, 'webrtc prepare'); // 参数暂时无效 - this.webrtc.prepare({ iceServers: [ { urls: "stun://stun.l.google.com:19302" } ] }); + this.webrtc.prepare({ + iceServers: [{ + urls: "stun://stun.l.google.com:19302" + }] + }); } async connect(peerId: string) { @@ -163,7 +256,7 @@ export default class WebRtcModel { this.sendMessage('SESSION ' + this.peerId) } - public disconnect = async ()=> { + public disconnect = async () => { console.info(TAG_RTC, 'disconnect'); if (this.ws) { this.webrtc.close() @@ -174,78 +267,17 @@ export default class WebRtcModel { }); const webRtcModel = new WebRtcModel() webRtcModel.setContext(this.context); - webRtcModel.initWebSocket('', ()=>{}); + webRtcModel.initWebSocket('', () => { + }); webRtcModel.initRtc(); } } - sendOffer = async ()=> { - const {peerId:fromID,remoteUserId:userID} = this; - try { - let offer = await this.webrtc.createOffer(); - this.webrtc.setLocalDescription(offer); - if (this.stateCallback) { - this.stateCallback(WebRtcState.PEER_NEGOTIATING, '发送Offer'); - } - this.sendMessage(JSON.stringify({ - eventName:'__answer', - data:{ - userID, - fromID, - label:0, - id:'audio', - sdp:offer.sdp - } - })) - } catch (e) { - console.error( TAG_RTC, 'createOffer: ' + JSON.stringify(e)); - } - } - - sendAnswer = async () => { - const {peerId:fromID,remoteUserId:userID} = this; - console.info(TAG_RTC,'surenjun') - try { - let answer = await this.webrtc.createAnswer(); - console.info(TAG_RTC, 'createAnswer: ' + JSON.stringify(answer)); - - this.webrtc.setLocalDescription(answer); - - this.sendMessage(JSON.stringify({ - eventName:'__answer', - data:{ - userID, - fromID, - label:0, - id:'audio', - sdp:answer.sdp - } - })) - this.isConnected = true; - } catch (e) { - console.error( TAG_RTC, 'createAnswer: ' + JSON.stringify(e)); - } - } - - sendIceCandidate = async (icecandidate: any) => { - const {peerId,remoteUserId} = this - this.sendMessage(JSON.stringify({ - eventName:'__ice_candidate', - data:{ - userID:remoteUserId, - id:'audio', - label:0, - fromId:peerId, - candidate:icecandidate.candidate - } - })); - } - - sendMessage = async (message:string) => { + sendMessage = async (message: string) => { this.ws.send(message, (error, success) => { - if (success){ + if (success) { console.info(TAG_RTC, 'ws send success' + message) - }else{ + } else { console.error(TAG_RTC, 'ws send error: ' + error); } }); @@ -256,28 +288,13 @@ export default class WebRtcModel { return await this.ws.close(); } - receiveSdp = async (sdp) => { - let type = sdp.type as string; - // let text = json.sdp.text as string; - if (type === 'offer') { - this.webrtc.setRemoteDescription(sdp); - this.sendAnswer(); - prompt.showToast({ - message: '语音对讲连接完成', - duration: 4000 - }); - } else if (type === 'answer') { - this.webrtc.setRemoteDescription(sdp); - } - } - - receiveIce = (ice) => { + receiveIce = (ice) => { try { this.webrtc.addIceCandidate({ - candidate:ice, + candidate: ice, }); - }catch (e){ - console.info(TAG_RTC,JSON.stringify(e)) + } catch (e) { + console.info(TAG_RTC, JSON.stringify(e)) } } @@ -294,16 +311,16 @@ export default class WebRtcModel { } //接受对方的邀请 - acceptInvited = (fromId:string,roomId:string) =>{ - const {sendMessage,peerId} = this; + acceptInvited = (fromId: string, roomId: string) => { + const { sendMessage, peerId } = this; this.remoteUserId = fromId; this.roomId = roomId sendMessage(JSON.stringify({ - eventName:'__join', - data:{ - userID:peerId, - room:roomId + eventName: '__join', + data: { + userID: peerId, + room: roomId } })) diff --git a/entry/src/main/ets/utils/UdpUtils.ets b/entry/src/main/ets/utils/UdpUtils.ets index 0be0e270..fc42726a 100644 --- a/entry/src/main/ets/utils/UdpUtils.ets +++ b/entry/src/main/ets/utils/UdpUtils.ets @@ -108,7 +108,7 @@ class CenterUDPClient extends UdpClient { try { const fileUtil = new FileUtils(context) const data = await fileUtil.readFile("" + '/config/ipConfig.txt'); - const carInfo: CarInfoType = AppStorage.get('carInfo') + const carInfo: CarInfoType = AppStorage.get('carInfo') if (data?.length > 0) { const result: IPConfig = JSON.parse(data) this.create(result.udplocalIp, '8800', carInfo?.udpAddress, carInfo?.messagePort) diff --git a/entry/src/main/ets/utils/business/GetDistance.ets b/entry/src/main/ets/utils/business/GetDistance.ets index 87bdc7db..54635cb0 100644 --- a/entry/src/main/ets/utils/business/GetDistance.ets +++ b/entry/src/main/ets/utils/business/GetDistance.ets @@ -61,7 +61,7 @@ export default class GetDistance { //上传行驶里程数据 uploadData = async () => { setInterval(() => { - const { carId } = AppStorage.get('carInfo'); + const { carId } = AppStorage.get('carInfo'); const { date, timeStr, totalDistance } = this; return //"carid":"1001","startTime":"2024-08-24 08:09:01","time":"111233", "mileage":"1222"