diff --git a/entry/src/main/ets/api/index.ts b/entry/src/main/ets/api/index.ts index 5e9b3fda..d2351940 100644 --- a/entry/src/main/ets/api/index.ts +++ b/entry/src/main/ets/api/index.ts @@ -60,6 +60,7 @@ export async function initCenterCacheByKSPT(params){ }) } + //从参数平台获取模型 export async function initEsModel(params){ return await request({ @@ -78,4 +79,14 @@ export async function initialization(params){ method:'post', xml:true, }) +} + +//参数下发读表接口 +export async function initCarParameter(params){ + return await request({ + url:'/der2/services/para/initCarParameter.ws', + data:params, + method:'post', + xml:false, + }) } \ No newline at end of file diff --git a/entry/src/main/ets/common/database/Rdb.ts b/entry/src/main/ets/common/database/Rdb.ts index b02b140c..1a33adf4 100644 --- a/entry/src/main/ets/common/database/Rdb.ts +++ b/entry/src/main/ets/common/database/Rdb.ts @@ -37,9 +37,12 @@ import ES_CAR_VIDEO_PARAMETER from '../constants/ES_CAR_VIDEO_PARAMETER'; import IpConfigTable from '../constants/IpConfigTable'; import DeviceInfoTable from '../constants/DeviceInfoTable' import USER from '../constants/USER' +import common from '@ohos.app.ability.common'; + +import contextConstant from '@ohos.app.ability.contextConstant'; + import featureAbility from '@ohos.ability.featureAbility' // import { Logger } from '../utils/Logger'; -import Logger from '../utils/Logger'; export default class Rdb { private rdbStore: any = null; private tableName: string; @@ -52,7 +55,7 @@ export default class Rdb { this.columns = columns; } - getRdbStore(callback) { + getRdbStore(callback?,content?) { if (!callback || typeof callback == 'undefined' || callback == undefined) { // Logger.verbose(`${CommonConstants.RDB_TAG}`, 'getRdbStore() has no callback!'); return; @@ -62,7 +65,14 @@ export default class Rdb { callback(); return } - let context = getContext(this); + let context + if(content){ + context=content + }else{ + context=getContext(this) + } + // let context = getContext(this) as common.UIAbilityContext; + // let context = contextConstant(this); const map = { 'MA_MARKRULE': MA_MARKRULE, 'MA_SYSTEMPARM': MA_SYSTEMPARM, @@ -88,18 +98,21 @@ export default class Rdb { 'DeviceInfoTable':DeviceInfoTable } + data_rdb.getRdbStore(context,map[this.tableName].STORE_CONFIG, 1, (err, rdb) => { + console.log('getRdbStoregetRdbStore',err) if (err) { // Logger.error(`${CommonConstants.RDB_TAG}`, 'gerRdbStore() failed, err: ' + err); return; } + console.log('this.sqlCreateTable',this.sqlCreateTable) this.rdbStore = rdb; this.rdbStore.executeSql(this.sqlCreateTable); // Logger.verbose(`${CommonConstants.RDB_TAG}`, 'getRdbStore() finished.'); callback(); }); } - deleteTableData(callback,name){ + deleteTableData(callback,name,content?){ if (!callback || typeof callback == 'undefined' || callback == undefined) { // Logger.verbose(`${CommonConstants.RDB_TAG}`, 'getRdbStore() has no callback!'); return; @@ -109,7 +122,13 @@ export default class Rdb { callback(); return } - let context = getContext(this); + let context + if(content){ + context=content + }else{ + context=getContext(this) + } + // let context = getContext(this); const map = { 'MA_MARKRULE': MA_MARKRULE, 'MA_SYSTEMPARM': MA_SYSTEMPARM, diff --git a/entry/src/main/ets/common/database/tables/AccountTable.ts b/entry/src/main/ets/common/database/tables/AccountTable.ts index 036777ad..686f1316 100644 --- a/entry/src/main/ets/common/database/tables/AccountTable.ts +++ b/entry/src/main/ets/common/database/tables/AccountTable.ts @@ -18,25 +18,26 @@ import Rdb from '../Rdb'; import AccountData from '../../bean/AccountData'; //import CommonConstants from '../../constants/CommonConstants'; export default class AccountTable { -// private accountTable = new Rdb(CommonConstants.ACCOUNT_TABLE.tableName, CommonConstants.ACCOUNT_TABLE.sqlCreate, -// CommonConstants.ACCOUNT_TABLE.columns); + // private accountTable = new Rdb(CommonConstants.ACCOUNT_TABLE.tableName, CommonConstants.ACCOUNT_TABLE.sqlCreate, + // CommonConstants.ACCOUNT_TABLE.columns); private commonConstants private accountTable -// private CommonConstants - constructor(callback: Function = () => {},Constants) { + // private CommonConstants + constructor(callback: Function = () => {},Constants,context?) { this.accountTable= new Rdb(Constants.ACCOUNT_TABLE.tableName, Constants.ACCOUNT_TABLE.sqlCreate, - Constants.ACCOUNT_TABLE.columns) -// this.CommonConstants=Constants + Constants.ACCOUNT_TABLE.columns) + // this.CommonConstants=Constants this.commonConstants=Constants - this.accountTable.getRdbStore(callback); + this.accountTable.getRdbStore(callback,context); + console.log('kkkkkkkk0') } - getRdbStore(callback: Function = () => {}) { - this.accountTable.getRdbStore(callback); + getRdbStore(callback: Function = () => {},context?) { + this.accountTable.getRdbStore(callback,context); } //删除全部数据 - deleteTableData(callback: Function,name) { - this.accountTable.deleteTableData(callback,name); + deleteTableData(callback: Function,name,context?) { + this.accountTable.deleteTableData(callback,name,context); } insertData(account, callback: Function) { const valueBucket = generateBucket(this.commonConstants,account); diff --git a/entry/src/main/ets/common/service/indexService.ts b/entry/src/main/ets/common/service/indexService.ts index e5b97f42..314fee13 100644 --- a/entry/src/main/ets/common/service/indexService.ts +++ b/entry/src/main/ets/common/service/indexService.ts @@ -16,26 +16,26 @@ import { } from '../../common/service/initable' import { GlobalConfig } from '../../config/index' import testNapi from '@ohos.hiserialsdk' - -export async function getliushuiNum(){ +let num=0 +export async function getliushuiNum(context){ console.log('getLiushuihao') - this.fileUtil = new FileUtil(this.context) - const data = await this.fileUtil.readFile(GlobalConfig.comoonfileWriteAddress+'/config/liushui.txt'); + const fileUtil = new FileUtil(context) + const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress+'/config/liushui.txt'); if(data === '' || data === undefined){ - this.num=0 - let str=this.num.toString() + num=0 + let str=num.toString() for(let i=0;str.length<=5;i++){ str='0'+str } - this.lsh=str + globalThis.lshNo=str // return str }else{ - this.num=Number(JSON.parse(data).value)+1 - let str=this.num.toString() + num=Number(JSON.parse(data).value)+1 + let str=num.toString() for(let i=0;str.length<=5;i++){ str='0'+str } - this.lsh=str + globalThis.lshNo=str // return str } } @@ -75,7 +75,7 @@ export async function setliushuiNum(context) { } //双中心表 -export async function getDoubleCeneterTable() { +export async function getDoubleCeneterTable(param) { return new Promise(async (reslove, reject) => { // MA_SYSSET双中心下做合并表格操作 const db = new AccountTable(() => { @@ -84,15 +84,15 @@ export async function getDoubleCeneterTable() { db.query('0', async (array) => { if (array.length) { delSyncTable('MA_SYSSET').then(async () => { - await getDataBaseTable({ tableName: 'MA_SYSSET' }) - await getMySystemSetTable({ tableName: 'MA_SYSSET' }) + await getDataBaseTable({ tableName: 'MA_SYSSET' },param) + await getMySystemSetTable({ tableName: 'MA_SYSSET' },param) }) } else { - await getDataBaseTable({ tableName: 'MA_SYSSET' }) - await getMySystemSetTable({ tableName: 'MA_SYSSET' }) + await getDataBaseTable({ tableName: 'MA_SYSSET' },param) + await getMySystemSetTable({ tableName: 'MA_SYSSET' },param) } }) - }) + },param.context) const typeObj = { 'MA_MARKRULE': false, 'MA_SYSTEMPARM': false, @@ -113,7 +113,7 @@ export async function getDoubleCeneterTable() { 'MA_T_CARPARMSET': false } for (let key in typeObj) { - typeObj[key] = await upDateTable({ tableName: key }) + typeObj[key] = await upDateTable({ tableName: key },param) if (!typeObj[key]) { promptAction.showToast({ message: `未能查询到${key}表数据, 请先检查网络是否连接正常`, @@ -131,13 +131,10 @@ export async function getDoubleCeneterTable() { } //单中心存表 -export async function getSingleCenterTable() { +export async function getSingleCenterTable(param) { return new Promise((reslove, reject) => { - upDataZhongxinginitialization().then((result) => { + upDataZhongxinginitialization(param).then((result) => { if (result) { - router.pushUrl({ - url: 'pages/ExaminerLogin', - }, router.RouterMode.Single) reslove(true) } else { promptAction.showDialog({ @@ -172,6 +169,7 @@ export async function getSingleCenterTable() { } + let interval export async function takePhotoFn(context) { @@ -309,11 +307,8 @@ function getChuankouFnMsg() { console.log('zzc 5 sleep 1s') setTimeout(()=>{ - console.log(`x=${globalThis.num}`) - - console.log('zzc 7 send next msg') getChuankouFnMsg() - },1000) + },500) // hilog.info(0x0000, 'testTag', 'Test NAPI SerialRecvAsync callback in'); // hilog.info(0x0000, 'testTag', 'Test NAPI SerialRecvAsync recevedLen = %{public}d', revTestInfo.recevedLen); diff --git a/entry/src/main/ets/common/service/initable.ts b/entry/src/main/ets/common/service/initable.ts index 068bf92a..e34dd0cf 100644 --- a/entry/src/main/ets/common/service/initable.ts +++ b/entry/src/main/ets/common/service/initable.ts @@ -42,7 +42,7 @@ const map = { 'MA_MAP_POINT_ITEM': MA_MAP_POINT_ITEM, 'MA_MAP_ROAD': MA_MAP_ROAD, 'MA_MAP_ROAD_LANE': MA_MAP_ROAD_LANE, - 'MA_MAP_SUBITEM': MA_MAP_SUBITEM, + 'MAP_SUBITEM': MA_MAP_SUBITEM, 'MA_SYSSET': MA_SYSSET, 'ES_CARINFO': ES_CARINFO, 'ES_EXAMPOINTDETAIL': ES_EXAMPOINTDETAIL, @@ -77,24 +77,25 @@ const centerToMap={ // 'ES_CAR_VIDEO_PARAMETER':ES_CAR_VIDE0pO_PARAMETER } -function sqlInsertCommonFn(tableName,resultArr){ +function sqlInsertCommonFn(tableName,resultArr,context?){ return new Promise((resolve,reject)=>{ const accountTable = new AccountTable(() => { - }, map[tableName]); + }, map[tableName],context); accountTable.getRdbStore(() => { accountTable.query('0', async (result) => { + // console.log('表长度',result.length,tableName) if (result.length == 0) { let INSERT_SQL = "INSERT INTO "+tableName - + " ("+ map[tableName].ACCOUNT_TABLE.columns.toString()+") VALUES " + + " ("+ map[tableName].ACCOUNT_TABLE.columns.toString()+") VALUES " resultArr.map((data,i) => { data.id=`${i}` let str='(' map[tableName].ACCOUNT_TABLE.columns.map((res,index)=>{ if(map[tableName].ACCOUNT_TABLE.columns.length-1==index){ - str+=`"${data[res]||'1'}"` + str+=`"${data[res]||'0'}"` }else{ - str+=`"${data[res]||'1'}"`+',' + str+=`"${data[res]||'0'}"`+',' } }) if(i==resultArr.length-1){ @@ -110,19 +111,19 @@ function sqlInsertCommonFn(tableName,resultArr){ }) } else { - await delSyncTable(tableName) - const result= await sqlInsertCommonFn(tableName,resultArr) + await delSyncTable(tableName,context) + const result= await sqlInsertCommonFn(tableName,resultArr,context) resolve(result) } }, true); - }); + },context); }) } - -export async function getDataBaseTable(params) { +//参数平台 +export async function getDataBaseTable(params,reqParam) { return new Promise((resolve, reject) => { const accountTable = new AccountTable(() => { - }, map[params.tableName]); + }, map[params.tableName],context); accountTable.getRdbStore(() => { accountTable.query('0', async (result) => { if (result.length != 0) { @@ -130,7 +131,7 @@ export async function getDataBaseTable(params) { return } else { const date = new Date() - if(!globalThis.timeInfo?.paraKdid){ + if(!reqParam?.paraKdid){ prompt.showToast({ message: 'paraKdid获取失败', duration: 3000 @@ -140,8 +141,8 @@ export async function getDataBaseTable(params) { const str = { "head": { "time": dateFormat(date) }, "body": { "tableName": params.tableName, // 表名 - "paraKdid": globalThis.timeInfo?.paraKdid, //参数平台kdid - "examinationRoomId": globalThis.carInfo?.examinationRoomId, //考试平台kdid + "paraKdid": reqParam.paraKdid, //参数平台kdid + "examinationRoomId": reqParam.examinationRoomId, //考试平台kdid "typeRsp": "0" // 赋默认值0,无需改变 } } @@ -152,10 +153,16 @@ export async function getDataBaseTable(params) { } let INSERT_SQL = "INSERT INTO "+params.tableName - + " ("+ map[params.tableName].ACCOUNT_TABLE.columns.toString()+") VALUES " + + " ("+ map[params.tableName].ACCOUNT_TABLE.columns.toString()+") VALUES " + if(params.tableName=='MA_SYSSET'){ + res.body[params.tableName]= res.body[params.tableName].filter(res=>{ + return res['v_no']>=300&&res['v_no']<=700 + }) + } res.body[params.tableName].map((data,i) => { - data.id=`${i}` + // data.id=`${i}` + data.id=i let str='(' map[params.tableName].ACCOUNT_TABLE.columns.map((res,index)=>{ if(map[params.tableName].ACCOUNT_TABLE.columns.length-1==index){ @@ -177,7 +184,7 @@ export async function getDataBaseTable(params) { }) } }, true); - }); + },reqParam.context); }) } //依据数组和表名更新sql表 @@ -185,13 +192,11 @@ export async function upDateTableByArray(tableName,arr) { sqlInsertCommonFn(tableName,arr) } //更新双中心表 -export async function upDateTable(params) { +export async function upDateTable(params,reqParam) { return new Promise((resolve, reject) => { const date = new Date() - let paraKdid='' - let examinationRoomId='' - paraKdid=globalThis.timeInfo?globalThis.timeInfo?.paraKdid:'' - examinationRoomId= globalThis.carInfo?globalThis.carInfo.examinationRoomId:'' + let paraKdid=reqParam?.paraKdid||'' + let examinationRoomId=reqParam?.examinationRoomId||'' if(!paraKdid|| !examinationRoomId){ resolve(false) return @@ -213,7 +218,7 @@ export async function upDateTable(params) { return } try { - const result=await sqlInsertCommonFn(params.tableName,res.body[params.tableName]) + const result=await sqlInsertCommonFn(params.tableName,res.body[params.tableName],reqParam.context) resolve(result) }catch (error){ console.log(error) @@ -223,10 +228,10 @@ export async function upDateTable(params) { } //考试平台 -export async function getMySystemSetTable(params) { +export async function getMySystemSetTable(params,reqParam) { return new Promise((resolve, reject) => { const date = new Date() - if(!globalThis.timeInfo?.paraKdid){ + if(!reqParam.paraKdid){ prompt.showToast({ message: 'paraKdid获取失败', duration: 3000 @@ -236,20 +241,25 @@ export async function getMySystemSetTable(params) { const str = { "head": { "time": dateFormat(date) }, "body": { "tableName": params.tableName, // 表名 - "paraKdid": globalThis.timeInfo?.kdid, //考试平台kdid - "examinationRoomId": globalThis.timeInfo?.kdid, //考试平台kdid + "paraKdid": reqParam?.kdid, //考试平台kdid + "examinationRoomId": reqParam?.kdid, //考试平台kdid "typeRsp": "0" // 赋默认值0,无需改变 } } - initCenterCacheByKSPT(str).then((res)=>{ - if( res.body[params.tableName].length==0){ - resolve(); - return - } - sqlInsertCommonFn(params.tableName,res.body[params.tableName]).then((result)=>{ - resolve(result) - }) - }) + initCenterCacheByKSPT(str).then((res)=>{ + if( res.body[params.tableName].length==0){ + resolve(); + return + } + if(params.tableName=='MA_SYSSET'){ + res.body[params.tableName]= res.body[params.tableName].filter(res=>{ + return res['v_no']<300 || res['v_no']>700 + }) + } + sqlInsertCommonFn(params.tableName,res.body[params.tableName],reqParam.context).then((result)=>{ + resolve(result) + }) + }) }) @@ -257,10 +267,10 @@ export async function getMySystemSetTable(params) { } //依据表名同步获取数据 -export async function getSyncData(tableName) { +export async function getSyncData(tableName,context?) { return new Promise((resolve, reject) => { const accountTable = new AccountTable(() => { - }, map[tableName]); + }, map[tableName],context); accountTable.getRdbStore(() => { accountTable.query('0', async (result) => { resolve(result) @@ -270,13 +280,14 @@ export async function getSyncData(tableName) { } -export async function delSyncTable(tableName){ +export async function delSyncTable(tableName,context?){ return new Promise((resolve,reject)=>{ const accountTable = new AccountTable(() => { - }, map[tableName]); - accountTable.deleteTableData(()=>{ + }, map[tableName],context); + accountTable.deleteTableData((ret)=>{ + console.log('删除成功') resolve(true) - },tableName) + },tableName,context) }) } @@ -333,89 +344,98 @@ export async function getEsCarModel(context){ await fileModel.storingFiles(result.buffer) } -export async function upDataZhongxinginitialization(){ +export async function upDataZhongxinginitialization(param){ return new Promise((resolve, reject) => { - if(!globalThis.carInfo?.carId){ + if(!param.carId){ resolve(false) return } const str = { - "carId": globalThis.carInfo?.carId, // 表名 - "examinationRoomId": globalThis.carInfo?.examinationRoomId, //考试平台kdid + "carId": param.carId, // 表名 + "examinationRoomId": param.examinationRoomId, //考试平台kdid videoVersion:'1.0', - judgeVersion:globalThis.judgeVersion, - shellVersion: globalThis.version + judgeVersion:param.judgeVersion, + shellVersion: param.shellVersion } - console.log('respose') - initialization(str).then(async(res)=>{ + console.log('daihai2') + + initialization(str).then((res)=>{ + console.log('daihai3',JSON.stringify(res)) if(!res){ resolve(false) return } let flag + console.log('resposestart') + for(let key in res.initializationRsp.body){ if(!centerToMap[key]){ continue } - try{ - flag= await setSyncCenterSqlData(key,res) - }catch (error){ - console.log(error) - } - if(!flag){ + setSyncCenterSqlData(key,res,param).then((flag) => { + if(!flag){ + resolve(false) + return + }{ + resolve(true) + } + }).catch ((error) => { resolve(false) - return - } + console.log(error) + }) } + console.log('daihai4') + resolve(true) + console.log('resposestart') + }).catch((Error)=>{ resolve(false) }) - }) } -function setSyncCenterSqlData(key,res){ +function setSyncCenterSqlData(key,res,param){ return new Promise((resolve,reject)=>{ const mapName={ 'ItemInfo':'MA_ITEMINFO', 'MarkRule':'MA_MARKRULE', 'SystemParm':'MA_SYSTEMPARM', - 'mapCollectList':'MA_MAP_COLLECT', - 'mapCollectshapeList':'MA_MAP_COLLECT_SHAPE', + 'MA_MAP_COLLECT':'MA_MAP_COLLECT', + 'MA_MAP_COLLECT_SHAPE':'MA_MAP_COLLECT_SHAPE', 'Map_ItemClass':'MA_MAP_ITEMCLASS', 'Map_Point':'MA_MAP_POINT', 'Map_Point_Item':'MA_MAP_POINT_ITEM', 'Map_Road':'MA_MAP_ROAD', 'Map_Road_Lane':'MA_MAP_ROAD_LANE', - 'Map_SubItem':'MA_MAP_SUBITEM', + 'Map_SubItem':'MAP_SUBITEM', 'Sysset':'MA_SYSSET', 'CarInfo':'ES_CARINFO', // 'ES_EXAMPOINTDETAIL':ES_EXAMPOINTDETAIL, - 'MarkRuleSet':'MA_MARKRULE', + 'MarkRuleSet':'MA_MARKRULESET', 'Cdsbinfo':'MA_CDSBINFO', 'T_CarParmSet':'MA_T_CARPARMSET', // 'ES_CAR_VIDEO_PARAMETER':ES_CAR_VIDE0pO_PARAMETER } - const accountTable = new AccountTable(() => { - }, centerToMap[key]); - let arrList + // const accountTable = new AccountTable(() => { + // }, centerToMap[key],param.context); + console.log('kkkkkkkkk',key) + let arrList if(res.initializationRsp.body[key].record instanceof Array){ arrList =res.initializationRsp.body[key].record }else{ arrList=[res.initializationRsp.body[key].record] } - res - sqlInsertCommonFn(mapName[key],arrList).then((result)=>{ - console.log(key,'表建立成功') - if(result){ - resolve(true) - }else{ - resolve(false) - } - }).catch((msg)=>{ - reject(false) - console.log(msg) - }) + sqlInsertCommonFn(mapName[key],arrList,param.context).then((result)=>{ + console.log(key,'表建立成功') + if(result){ + resolve(true) + }else{ + resolve(false) + } + }).catch((msg)=>{ + reject(false) + console.log(key,'表建立失败') + }) }) } diff --git a/entry/src/main/ets/common/service/terminalService.ts b/entry/src/main/ets/common/service/terminalService.ts index e0d033fc..0080b8e8 100644 --- a/entry/src/main/ets/common/service/terminalService.ts +++ b/entry/src/main/ets/common/service/terminalService.ts @@ -6,7 +6,8 @@ import { getSyncData } from '../../common/service/initable' //获取设备信息 export async function getDeviceInfo() { - globalThis.deviceNo = 'HM-AC76'; //科目三设备 + globalThis.deviceNo = '153216400880'; //科目三设备 + // globalThis.deviceNo = '150667400235'; //科目三设备 return new Promise((resolve, reject) => { getSyncData('DeviceInfoTable').then((result: Array) => { diff --git a/entry/src/main/ets/common/service/timeService.ts b/entry/src/main/ets/common/service/timeService.ts index 3e02a81b..4b2704af 100644 --- a/entry/src/main/ets/common/service/timeService.ts +++ b/entry/src/main/ets/common/service/timeService.ts @@ -11,6 +11,7 @@ export async function timeSynchronize() { let res:any = await timeSynchronization(params) res = res.timeSynchronizationRsp; globalThis.timeInfo=res.body + console.log('timeInfo',JSON.stringify(res.body)) diff --git a/entry/src/main/ets/common/service/videoService.ts b/entry/src/main/ets/common/service/videoService.ts index 5ce4ebd0..8f4b7b7f 100644 --- a/entry/src/main/ets/common/service/videoService.ts +++ b/entry/src/main/ets/common/service/videoService.ts @@ -10,7 +10,7 @@ import { getCurrentTime } from '../utils/tools' import record from '@ohos.rtsprecord'; import { FileHelper } from './FileHelper'; -// const rtsp_server = record.createServer(); +const rtsp_server = record.createServer(); //开始录屏 const FILE_ASSET_FETCH_COLUMNS = [photoAccessHelper.PhotoKeys.URI, photoAccessHelper.PhotoKeys.PHOTO_TYPE, @@ -28,7 +28,7 @@ photoAccessHelper.PhotoKeys.TITLE, photoAccessHelper.PhotoKeys.POSITION, photoAccessHelper.PhotoKeys.DATE_TRASHED, photoAccessHelper.PhotoKeys.HIDDEN]; -const rtsp_server = record.createServer(); +// const rtsp_server = record.createServer(); export async function startRecordVideo(param, td, context, dir) { return new Promise((reslove, reject) => { diff --git a/entry/src/main/ets/common/utils/TcpClient.ts b/entry/src/main/ets/common/utils/TcpClient.ts index 0042fc50..ac7a8371 100644 --- a/entry/src/main/ets/common/utils/TcpClient.ts +++ b/entry/src/main/ets/common/utils/TcpClient.ts @@ -24,7 +24,7 @@ export default class TcpClient { onError(callback?){ this.tcp.on('error', err => { hilog.info(0x0000, 'testTag', "on error, err:" + JSON.stringify(err)); - callback() + callback&&callback() // this.closeUdp(()=>{ // this.bindUdp() // }) @@ -39,9 +39,11 @@ export default class TcpClient { this.oppositeIpPort = oppositeIpPort let promise=this.tcp.bind({ address: this.localIp, port:parseInt(this.localIpPort), family: 1 }, err => { if (err) { - hilog.info(0x0000, 'testTag', "tcpBinderror:" + JSON.stringify(err)); + hilog.info(0x0000, 'testTag', "tcpreBinderror:" + JSON.stringify(err)); resolve(true) } + console.log('testTag,rebindtestTag tcp bind success'); + resolve(false) }) @@ -80,12 +82,11 @@ export default class TcpClient { } connectTcp(){ - console.log('testTagtcpoppositeIp',this.oppositeIp,'localIp',this.localIp) + console.log('testTagtcbpoppositeIp',this.oppositeIp,this.oppositeIpPort,'localIp',this.localIp,this.localIpPort) console.log('22323') return new Promise((resolve,reject)=>{ let promise = this.tcp.connect({ address: {address: this.oppositeIp, port: parseInt(this.oppositeIpPort), family: 1} , timeout: 6000}); promise.then(() => { - console.log('testTagbindSuccess') this.tcp.setExtraOptions({ keepAlive: true, @@ -111,7 +112,7 @@ export default class TcpClient { } sendMsg(msg: string) { - console.log('oppositeIp',this.oppositeIp) + console.log('testTagsendoppositeIp',this.oppositeIp) return new Promise((reslove,reject)=>{ let promise = this.tcp.send({ data:msg @@ -146,7 +147,7 @@ export default class TcpClient { onMessage(callback?) { this.tcp.on('message', value => { // console.log('messageLengt',,value.message.length)) - console.log('tcpmsg') + console.log('testTagtcpmsg') // console.log("on message, message:" + value.message+ ", remoteInfo:" ) if (value) { let dataView = new DataView(value.message) @@ -181,17 +182,17 @@ export default class TcpClient { // }); } offTcp(callback) { - this.tcp.off('message', callback); + this.tcp.off('testTagofmessg', callback); } closeTcp(callback) { return new Promise((reslove,reject)=>{ let promise = this.tcp.close(); promise.then(() => { - console.log('close success'); + console.log('testTagclose success'); callback() reslove(true) }).catch(err => { - console.log('close fail'); + console.log('testTagclose fail'); reslove(false) }); }) diff --git a/entry/src/main/ets/common/utils/UdpClient.ts b/entry/src/main/ets/common/utils/UdpClient.ts index fee4c756..8ea74551 100644 --- a/entry/src/main/ets/common/utils/UdpClient.ts +++ b/entry/src/main/ets/common/utils/UdpClient.ts @@ -64,9 +64,9 @@ export default class UdpClient { hilog.info(0x0000, 'udpCLient', 'bind'+ this.localIp+this.localIpPort); let promise = this.udp.bind({ - address: '192.168.7.170', port: 20122, family: 1 + // address: '192.168.7.170', port: 20122, family: 1 // address: '192.168.7.170', port: 31013, family: 1 - // address: this.localIp, port: parseInt(this.localIpPort), family: 1 + address: this.localIp, port: parseInt(this.localIpPort), family: 1 }); promise.then(() => { console.log(`${TAG}udpCLient udp bind success`); @@ -88,10 +88,10 @@ export default class UdpClient { address: { // address: '192.168.7.124', // port: 30013, - address: '192.168.7.124', - port: 20022, - // address: this.oppositeIp, - // port: parseInt(this.oppositeIpPort), + // address: '192.168.7.124', + // port: 20022, + address: this.oppositeIp, + port: parseInt(this.oppositeIpPort), family: 1 } }); diff --git a/entry/src/main/ets/common/utils/UdpClientByCenter.ts b/entry/src/main/ets/common/utils/UdpClientByCenter.ts index 8ddd781f..bc29fdd6 100644 --- a/entry/src/main/ets/common/utils/UdpClientByCenter.ts +++ b/entry/src/main/ets/common/utils/UdpClientByCenter.ts @@ -68,6 +68,7 @@ export default class UdpClientByCenter { }); } initHeartSendMsg(param,context){ + console.log('1111param',JSON.stringify(param)) this.initParam=param this.context=context } @@ -116,9 +117,11 @@ export default class UdpClientByCenter { } setMsgHead({id, list, placeId=62, carNo=489}){ + console.log('globalThis.lshNo',globalThis.lshNo) let a = string2Bytes(`${id}${fillZero(placeId,3)}`, 2*8); - let b = string2Bytes(`${carNo}${this.lsh}`, 4*8); - + console.log('aaa',a) + let b = string2Bytes(`${fillZero(carNo,4)}${globalThis.lshNo}`, 4*8); + console.log('bbb',b) let c = string2Bytes(list.length, 2*8); return [...a,...b,...c]; } @@ -179,6 +182,7 @@ export default class UdpClientByCenter { } onMessage(callback,type?) { this.udp.on('message', value => { + console.log('tttttttt') let arr=[] let dataView = new DataView(value.message) for (let i = 0;i < dataView?.byteLength; ++i) { @@ -198,16 +202,7 @@ export default class UdpClientByCenter { callback({id,length,body:list,sendId:this.sendId}) }); } - onError(callback?){ - this.udp.on('error', err => { - console.log('udpbycenterdiushierroring') - hilog.info(0x0000, 'udpCLientBycenteronerror', 'error'+ JSON.stringify(err)); - console.log("on error, err:" + JSON.stringify(err)) - // this.closeUdp(()=>{ - // this.bindUdp() - // }) - }); - } + closeUdp(callback) { this.udp.close(err=>{ if(err){ diff --git a/entry/src/main/ets/common/utils/UdpJudge.ts b/entry/src/main/ets/common/utils/UdpJudge.ts index d5443865..a0b6fccf 100644 --- a/entry/src/main/ets/common/utils/UdpJudge.ts +++ b/entry/src/main/ets/common/utils/UdpJudge.ts @@ -1,7 +1,7 @@ import systemTime from '@ohos.systemDateTime'; import { Array2Byte, fillZero, string2Bytes, stringToASC } from '../../common/utils/tools'; import { testKmItems } from '../../pages/judgeSDK/dataTest/index'; -import { setJudgeUdp, setTopLineUdp } from './GlobalUdp'; +import { setJudgeUdp, setTopLineUdp } from './GlobleUdp'; import { convertGpsCoord2 } from '../utils/tools'; @@ -38,11 +38,12 @@ export const initJudgeUdp = async () => { export const getMessageHeartbeat = async (msg) => { const carInfo = globalThis.carInfo; - const { examSubject,plateNo,ksyh } = carInfo; - + const { examSubject,plateNo } = carInfo; + const ksyh='0000000000000' const asclshArr = stringToASC(fillZero(globalThis.lsh || 0, 13)); - const ascksyhArr = stringToASC(fillZero(globalThis.ksyh || 0, 13)) - const ascsbxhArr = stringToASC('0000000000') + const ascksyhArr = stringToASC(fillZero(ksyh || 0, 13)) + const ascsbxhArr = stringToASC('00000000') + // const ascsbxhArr = stringToASC('153216400880') const serialIndex = globalThis.serialIndex const tempData = await getPlcData(msg); const {sensor,gps} = tempData; @@ -51,6 +52,8 @@ export const getMessageHeartbeat = async (msg) => { const translateSignals = getTranslateSignals( [zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc, ssc, fsc, lb, mkg, aqd, 0, 0, 0, 0, 0, 0, ygq, sensor.wd, 0] ) + console.log('jinweiduwaike',wd,jd,hxj,fyj,hbg) + const translateProject = getTranslateProject(); //@ts-ignore const translateJd = convertGpsCoord2(wd).toFixed(7) * Math.pow(10, 7) @@ -77,6 +80,7 @@ export const getMessageHeartbeat = async (msg) => { //航向角 俯仰角 高程(海拔) //@ts-ignore string2Bytes((hxj + 90) * 100, 2 * 8), string2Bytes(fyj * 100, 2 * 8), string2Bytes(hbg * 100, 4 * 8), + //dddd translateProjects, //当前项目编号 string2Bytes(0, 8), @@ -84,7 +88,9 @@ export const getMessageHeartbeat = async (msg) => { ascsbxhArr.map(sbxh => string2Bytes(sbxh, 8)[0]), //本次考试行驶距离 string2Bytes(0, 2 * 8), - //扣分 + //扣分值 + string2Bytes(0, 2 * 8), + //扣分数 string2Bytes(0, 2 * 8), //扣分项数量 string2Bytes(0, 8), @@ -95,6 +101,8 @@ export const getMessageHeartbeat = async (msg) => { arr.forEach(itemArr => { tempArr = tempArr.concat(itemArr) }) + console.log('kmkmkm',tempArr.length) + globalThis.serialIndex = 0; return Array2Byte(tempArr) } @@ -125,10 +133,10 @@ const getTranslateProject = () => { status: getCenterProjectStatus(current.status) } }) - const len = Math.floor(tempItems.length / 4); + const len = Math.floor(tempItems.length / 8); const arr = []; for (let i = 0; i <= len; i++) { - const temp = tempItems.slice(i * 4, (i + 1) * 4); + const temp = tempItems.slice(i * 8, (i + 1) * 8); let tempArr = temp.map(item => item.status) if (i === 4) { tempArr = tempArr.concat(['00', '00']) diff --git a/entry/src/main/ets/common/utils/request.ts b/entry/src/main/ets/common/utils/request.ts index 64d66ac2..042454d9 100644 --- a/entry/src/main/ets/common/utils/request.ts +++ b/entry/src/main/ets/common/utils/request.ts @@ -35,13 +35,14 @@ export default async function request(req: any) { paramsStr = paramsStr.toString(); paramsStr = paramsStr.substring(0, paramsStr.length-1) try { - let baseUrl=host?host:(globalThis.host||config.host) + let baseUrl=host?host:(globalThis.host||GlobalConfig.host) // let baseUrl=host?config.csptHost:config.host' console.info('surenjun',baseUrl) const {result,responseCode} = await httpRequest.request(`${baseUrl}${url}${paramsStr}`, options); - + console.log('daihai5') let res:any = xml ? xmlToJson(result) : result; + console.log('daihai55') console.log('响应头地址' + JSON.stringify(res)) let resObj = null; @@ -52,7 +53,12 @@ export default async function request(req: any) { //处理中心服务code if(res.Envelope){ const msgXml = res.Envelope.Body.writeObjectOutResponse.return; - return handleCenterCode(msgXml); + console.log('daihai6') + + const dd = handleCenterCode(msgXml); + console.log('daihai7') + + return dd } if(!xml){ diff --git a/entry/src/main/ets/config/global.ts b/entry/src/main/ets/config/global.ts index 78982eb0..4e939ecc 100644 --- a/entry/src/main/ets/config/global.ts +++ b/entry/src/main/ets/config/global.ts @@ -10,5 +10,5 @@ export const GlobalConfig={ comoonfileWriteAddress:'/mnt/hmdfs/100/account/device_view/local/files', picSavePath:'/storage/cloud/100/files/Photo/', videoSavePath:'/storage/cloud/100/files/Videos/', - host:'http://112.80.35.83:11052' -} \ No newline at end of file + host:'http://172.37.55.191:8082' +} diff --git a/entry/src/main/ets/entryability/EntryAbility.ts b/entry/src/main/ets/entryability/EntryAbility.ts index 9bf20d97..ea4f9da0 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ts +++ b/entry/src/main/ets/entryability/EntryAbility.ts @@ -31,6 +31,9 @@ export default class EntryAbility extends UIAbility { globalThis.version = '2024.11.22.14' globalThis.judgeVersion = '2024.11.22.14' globalThis.videoVersion= '1.0' + // globalThis.version = '2023.12.13.01' + // globalThis.judgeVersion = '2023.09.30.1' + // globalThis.videoVersion= '1.0' // globalThis.version = '2022.03.14.01' //视频遮挡 globalThis.spzd={ @@ -42,9 +45,11 @@ export default class EntryAbility extends UIAbility { globalThis.singlePlay=false //单机模式 globalThis.signNum=0//心跳指令编号 globalThis.lsh='0000000000000'//学员流水号 + globalThis.ratio= 1700 / 960 //适配比例 globalThis.statue=1//考试状态 globalThis.pathDir = this.context.filesDir; - globalThis.context=this.context + globalThis.context = this.context; + globalThis.isJudgeInitBool=false console.info('jiangsong globalThis.pathDir = ' + globalThis.pathDir); // this.requestPermission(this.context) // this.featureAbilityAuth() @@ -52,7 +57,7 @@ export default class EntryAbility extends UIAbility { const windowClass = await windowStage.getMainWindow(); globalThis.windowClass = windowClass // await windowClass.setWindowLayoutFullScreen(true) - await windowClass.setWindowSystemBarEnable([]) //全屏 + // await windowClass.setWindowSystemBarEnable([]) //全屏 await windowClass.setWindowSystemBarEnable(['navigation']) windowStage.loadContent('pages/Index', (err, data) => { diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index c2ac0e9e..f8112a83 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -1,43 +1,73 @@ -import { VideoConfig } from './interfaces'; +// @ts-nocheck +import { VideoConfig } from './interfaces' import common from '@ohos.app.ability.common'; -import router from '@ohos.router'; -import { getCarInfo, getDeviceInfo } from '../common/service/terminalService'; -import { setCurrentTime } from '../common/service/timeService'; -import { string2Bytes } from '../common/utils/tools'; +import router from '@ohos.router' +import { getDeviceInfo ,getCarInfo} from '../common/service/terminalService' +import { setCurrentTime } from '../common/service/timeService' +import {string2Bytes} from '../common/utils/tools' import { FileHelper } from '../common/service/FileHelper'; -import { getUDP, getUDP2 } from '../common/utils/GlobalUdp'; -import { initJudgeUdp } from '../common/utils/UdpJudge'; -import { getTCP } from '../common/utils/GlobalTcp'; -import testNapi from '@ohos.hiserialsdk'; import { getEsCarModel, } from '../common/service/initable' -import { - getDoubleCeneterTable, - getliushuiNum, - getSingleCenterTable, - setliushuiNum, - takePhotoFn -} from '../common/service/indexService'; +import FileUtil from '../common/utils/File' +import { getUDP, getUDP2 } from '../common/utils/GlobleUdp' +import {initJudgeUdp} from '../common/utils/UdpJudge' +import { getTCP } from '../common/utils/GlobleTcp' +import TcpClient from '../common/utils/TcpClient'; +import testNapi from '@ohos.hiserialsdk' +import {setliushuiNum,getliushuiNum,getSingleCenterTable,getDoubleCeneterTable,takePhotoFn} from '../common/service/indexService' import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; -import promptAction from '@ohos.promptAction'; -import { VideoConfigData } from '../mock'; +import worker, { MessageEvents } from '@ohos.worker'; @Entry @Component struct Index { + private fileUtil: FileUtil @State carNum: string = '' @State version: string = '' @State url: string = '' @State hasAuth: boolean = false; @State isSingle: boolean = false; @State deviceId: string = ''; + private interval = null; + private workerInstance = null; @State angle: number = 0 @State ratio: number = 1700 / 960 @State loading: boolean = true @State fd: number = -1; - private interval=null; private context = getContext(this) as common.UIAbilityContext; + @State param: VideoConfig = { + videoNum:'1', + spls: '1', + wz: '0,0', + faceFlag: false, + shuiying: true, + pztd: '2', + ljlx: '', + ip: '192.168.36.94', + port: '554', + userName: 'admin', + pwd: '12345qwe', + td1: '1', + td2: '2', + td3: '3', + td4: '4', + videoRecord1: false, + videoRecord2: true, + videoRecord3: false, + videoRecord4: false, + text1: '', + text2: '', + text3: '', + dolt: '', + fontSize: '', + rlls: '1', + spzd4:false, + spzd3:false, + spzd2:false, + spzd1:false, + zdyz:'5', + } fileHelper =null; build() { Column() { @@ -70,7 +100,7 @@ struct Index { Column() { Row() { if (!this.isSingle) { - Image($r('app.media.index_lw')).width('30.5%').height('74%').onClick(async () => { + Image($r('app.media.index_lw')).width('30.5%').height('74%').onClick(async() => { if (this.loading) { return } @@ -79,21 +109,15 @@ struct Index { this.angle = 360 }, 1000) this.angle = 0 - - //mode为3双中心下载表 - if (globalThis.timeInfo?.mode == '3') { - await getDoubleCeneterTable() - } else if (globalThis.timeInfo?.mode == '1') { - //单中心 - await getSingleCenterTable() - } else { + if(!globalThis.timeInfo){ promptAction.showToast({ message: `网络连接失败`, duration: 3000 }); - this.loading = false + this.loading=false } - this.loading = false + this.testXMLToJSONInWorker() + }) } @@ -129,12 +153,12 @@ struct Index { Column() { Text('V ' + globalThis.version) .fontColor('#CCAE7A') - .fontSize(22 * this.ratio) + .fontSize(22 * globalThis.ratio) .width('30%') .margin({ bottom: 10 }) Text('授权信息:' + (this.hasAuth ? '已授权' : '未授权')) .fontColor('#CCAE7A') - .fontSize(22 * this.ratio) + .fontSize(22 * globalThis.ratio) .width('30%') } .margin({ left: 24 }) @@ -142,45 +166,47 @@ struct Index { GestureGroup(GestureMode.Exclusive, TapGesture({ count: 2 }) .onAction(() => { + // takePhotoFn(this.context) + globalThis.singlePlay = !globalThis.singlePlay this.isSingle = globalThis.singlePlay }) ) ) - Text('考车号:' + globalThis.deviceNo).fontColor('#CCAE7A').fontSize(22 * this.ratio).margin({ right: 24 }) + Text('考车号:' + globalThis.deviceNo).fontColor('#CCAE7A').fontSize(22 * globalThis.ratio).margin({ right: 24 }) } .width('100%') .justifyContent(FlexAlign.SpaceBetween) .margin({ bottom: 10 }) } - // if (this.loading) { - Column() { - Image($r('app.media.open_loading')) - .width(200 * this.ratio) - .rotate({ angle: this.angle }) - .height(200 * this.ratio) - .animation({ - duration: 5000, // 动画时长 - curve: Curve.EaseOut, // 动画曲线 - delay: 500, // 动画延迟 - iterations: -1, // 播放次数 - playMode: PlayMode.Normal, // 动画模式 - }) - .margin({ top: 30 * this.ratio }) - Image($r('app.media.car')) - .width(80 * this.ratio) - .height(80 * this.ratio) - .position({ x: 288 * this.ratio, y: 89 * this.ratio }) - Text('获取考车信息,请稍候……').fontSize(24 * this.ratio).margin({ top: 20 * this.ratio }).fontWeight(400) - } - .width(660 * this.ratio) - .height(360 * this.ratio) - .position({ x: 150 * this.ratio, y: 98 * this.ratio }) - .backgroundColor('#E6E3DF') - .borderRadius(19 * this.ratio) + Column() { + Image($r('app.media.open_loading')) + .width(200 * globalThis.ratio) + .rotate({ angle: this.angle }) + .height(200 * globalThis.ratio) + .animation({ + duration: 5000, // 动画时长 + curve: Curve.EaseOut, // 动画曲线 + delay: 500, // 动画延迟 + iterations: -1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + }) + .margin({ top: 30 * globalThis.ratio }) + Image($r('app.media.car')) + .width(80 * globalThis.ratio) + .height(80 * globalThis.ratio) + .position({ x: 288 * globalThis.ratio, y: 89 * globalThis.ratio }) + Text('获取考车信息,请稍候……').fontSize(24 * globalThis.ratio).margin({ top: 20 * globalThis.ratio }).fontWeight(400) + } + .visibility(this.loading ? Visibility.Visible: Visibility.Hidden) + .width(660 * globalThis.ratio) + .height(360 * globalThis.ratio) + .position({ x: 150 * globalThis.ratio, y: 98 * globalThis.ratio }) + .backgroundColor('#E6E3DF') + .borderRadius(19 * globalThis.ratio) } } .width('100%') @@ -192,13 +218,54 @@ struct Index { } aboutToAppear() { + globalThis.ratio= 1700 / 960 this.angle = 0 this.loading = false + // let workerInstance = new worker.ThreadWorker('entry/ets/pages/worker.ts', { + // name: 'FriendsMoments Worker' + // }); + // this.workerInstance.onmessage = function(e) { + // console.log("onerror") + // router.pushUrl({ + // url: 'pages/ExaminerLogin', + // }, router.RouterMode.Single) + // this.loading=false + // } + } + async testXMLToJSONInWorker(){ + let workerInstance = new worker.ThreadWorker('entry/ets/workers/worker.ts', { + name: 'FriendsMoments Worker' + }); + var xmlStr='123' + console.log("baoyihu before postMessage :"); + const param={ + carId:globalThis.carInfo?.carId, + examinationRoomId:globalThis.carInfo?.examinationRoomId, + judgeVersion:globalThis.judgeVersion, + shellVersion:globalThis.version, + paraKdid:globalThis.timeInfo?.paraKdid, + mode: globalThis.timeInfo?.mode, + context:this.context + } + workerInstance.postMessage(param); + workerInstance.onmessage = (e: MessageEvents): void => { + console.log("baoyihu after postMessage :",e.data); + console.log("onerror") + router.pushUrl({ + url: 'pages/ExaminerLogin', + }, router.RouterMode.Single) + this.loading=false + // let workData: WorkData = e.data; + // if (workData) { + // this.isComplete = workData.isComplete; + // this.json_Str = workData.jsonStr; + // console.log("baoyihu after postMessage json_Str:"+this.json_Str); + // workerInstance.terminate(); + // } + } } - async heartMsg() { - //心跳指令编号 //考试状态 - const arr = [globalThis.signNum || 0, globalThis.statue || 1] + const arr = [globalThis.signNum||0, globalThis.statue||1] let tmpList = []; tmpList.push(string2Bytes(arr[0], 1 * 8)[0]) tmpList.push(string2Bytes(arr[1], 1 * 8)[0]) @@ -206,27 +273,30 @@ struct Index { for (let i = 0;i < str.length; i++) { tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0]) } - const param= {id: 31,list:tmpList,carNo: globalThis.carInfo.carNo,placeId: globalThis.carInfo.examinationRomId} + console.log('globalThis.carInfo',JSON.stringify(globalThis.carInfo)) + + const param= {id: 31,list:tmpList,carNo: globalThis.carInfo.carNo,placeId: globalThis.carInfo.examinationRoomId} + // globalThis.udpClient2.initHeartSendMsg(param,this.context) globalThis.udpClient2.sendMsg(param, this.context) } onPageShow() { this.loading = false + this.createAlbum() this.userAuth(); - //plc getUDP() - //中心udp getUDP2() clearInterval(this.interval) this.interval=setInterval(() => { setliushuiNum(this.context) - getliushuiNum() + getliushuiNum(this.context) this.heartMsg() }, 1000) - // 3s拍照 - takePhotoFn(this.context) - //tcp差分转发,如果差分通过udp转发可注释 + // takePhotoFn(this.context) + + // getTCP() + // const TcpClient: TcpClient =new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort) if (globalThis.singlePlay == undefined || globalThis.singlePlay == null) { globalThis.singlePlay = false @@ -236,15 +306,15 @@ struct Index { console.info('Index onPageShow'); } - //创建截图文件夹 + async createAlbum() { this.fileHelper = new FileHelper(); - // this.fileHelper.createAlbum('jt') + this.fileHelper.createAlbum('jt') this.fileHelper.createAlbum('pz'); } userAuth() { - const permissions: Array = ["ohos.permission.READ_IMAGEVIDEO", "ohos.permission.DISTRIBUTED_DATASYNC" ,'ohos.permission.CONNECTIVITY_INTERNAL','ohos.permission.CAMERA','ohos.permission.READ_MEDIA','ohos.permission.WRITE_MEDIA','ohos.permission.FILE_ACCESS_MANAGER']; + const permissions: Array = ["ohos.permission.SET_TIME","ohos.permission.READ_IMAGEVIDEO", "ohos.permission.DISTRIBUTED_DATASYNC" ,'ohos.permission.CONNECTIVITY_INTERNAL','ohos.permission.CAMERA','ohos.permission.READ_MEDIA','ohos.permission.WRITE_MEDIA','ohos.permission.FILE_ACCESS_MANAGER']; let context = this.context; let atManager = abilityAccessCtrl.createAtManager(); // requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗 @@ -268,10 +338,7 @@ struct Index { } async initParams() { this.loading=false - //获取设备信息 - this.createAlbum() await getDeviceInfo() - //车辆信息 getCarInfo() await setCurrentTime(); this.carNum = globalThis.carInfo.plateNo; @@ -282,6 +349,7 @@ struct Index { // await this.getModel() // const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00] // globalThis.udpClientByTopLine.sendMsg(Array2Byte(arr).buffer) + console.info(testNapi) } async getModel() { const context = this.context; diff --git a/entry/src/main/ets/pages/Judge.ets b/entry/src/main/ets/pages/Judge.ets index d21456be..07d176cc 100644 --- a/entry/src/main/ets/pages/Judge.ets +++ b/entry/src/main/ets/pages/Judge.ets @@ -9,7 +9,7 @@ import Judge from './judgeSDK/judge' import {defaultJudgeConfigObj} from './judgeSDK/utils//judge-common' import { Project, ProjectObj, MarkRule, CDSBInfo, - SYSTEMPARMARR,CARINFO ,MAPPOINT ,MAPITEMPOINTITEM + SYSTEMPARMARR,CARINFO ,MAPPOINT ,MAPITEMPOINTITEM,SYSSET } from './judgeSDK/api/judgeSDK.d' import { getCurrentTime, formatTime, getCurrentHourTime,chunkArr } from '../common/utils/tools' import { examJudgeEndExam } from './judgeSDK/api/index' @@ -29,9 +29,7 @@ struct Index { async aboutToAppear() { globalThis.windowClass.setWindowSystemBarEnable(['']) const time = await getCurrentTime() - const examSubject = globalThis.carInfo.examSubject - this.examSubject = examSubject this.startTime = time.split(' ')[1] this.startFullTime = await getCurrentTime(1); this.startHourTime = await getCurrentHourTime() @@ -67,9 +65,8 @@ struct Index { ? await this.initSystemKm2Param() : await this.initSystemKm3Param() await this.initMarkRules(); + await this.initSysset(); } - - await this.initSysset(); await this.initCDSBInfo() // 科目三新增读取表数据 @@ -122,7 +119,6 @@ struct Index { markreal:mark.markreal * 1, markserial:mark.markserial, kfxh:mark.kfxh, - //TODO 科目三评判新参数 OnlyOneKind:mark.onlyoneid * 1, NoCancelId:mark.nocancelid * 1, GPS_SID:mark.gps_sid == 0 ? false : true @@ -141,34 +137,44 @@ struct Index { } // 获取sysset表信息 - async initSysset() { - const syssetParams = await getSyncData('MA_SYSSET') + async initSysset(sysset?:SYSSET[]) { + const syssetParams = sysset || await getSyncData('MA_SYSSET') //@ts-ignore const serialNumberArr = syssetParams.filter(sys => sys.v_no === '901'); this.serialNumber = (serialNumberArr[0] && serialNumberArr[0].v_value) || '123456' - - const judgeConfig = [] + const {isTrajectoryOpen} = judgeConfig + const syssetJudgeConfigArr = [] //@ts-ignore syssetParams.forEach((sys) => { + if(isTrajectoryOpen){ + sys.v_no = sys.key; + sys.v_name = sys.name; + sys.v_value = sys.value + } + const {v_no,v_value} = sys; const v_no_num = v_no * 1; const value = decodeURIComponent(v_value) if(v_no_num >= 10 &&v_no_num <= 900){ - judgeConfig.push({ + syssetJudgeConfigArr.push({ key: v_no_num,value: value, name: decodeURI(sys.v_name) }) } + //科目三应行驶距离参数 + if(sys.v_no == '303'){ + this.examMileage = sys.v_value + ''; + } this.judgeConfigObj[sys.v_no] = value }); - this.judgeConfig = judgeConfig; + this.judgeConfig = syssetJudgeConfigArr; } // 初始化systemParam表 - async initSystemKm2Param(){ - const systemParms:any = await getSyncData('MA_SYSTEMPARM') + async initSystemKm2Param(sysParam?:SYSTEMPARMARR[]){ + const systemParms:any = sysParam || await getSyncData('MA_SYSTEMPARM') const carName = this.carName; let carNo2 = '',allItems = []; @@ -217,7 +223,7 @@ struct Index { //初始化systemParam表 async initSystemKm3Param(sysParam?:SYSTEMPARMARR[]) { const systemParms: any = sysParam || await getSyncData('MA_SYSTEMPARM') - + console.log('systemParms',JSON.stringify(systemParms)) const {isTrajectoryOpen} = judgeConfig systemParms.forEach((systemParm) => { @@ -232,7 +238,6 @@ struct Index { } const {no1,no2,no3,} = systemParm; - this.systemparmArr.push({ 'NO1':no1*1,'NO2':no2*1,'NO3':no3*1, 'TXT1':decodeURIComponent(systemParm.txt1), @@ -241,7 +246,6 @@ struct Index { }) const txt2 = decodeURIComponent(systemParm.txt2) - if (no1 == 6) { const currentProject = { name: decodeURI(systemParm.txt1), @@ -253,11 +257,10 @@ struct Index { this.projectsCenterObj[txt2] = currentProject this.projects.push(currentProject) } - if(no1 == 3 && no2 == 1 && no3 == 15){ - this.examMileage = decodeURI(systemParm.txt1) - } + // if(no1 == 3 && no2 == 1 && no3 == 15){ + // this.examMileage = decodeURI(systemParm.txt1) + // } }) - const projects = this.projects; if (!projects.length) { prompt.showToast({ @@ -376,19 +379,17 @@ struct Index { pointItemPoints.forEach(itemPoint => { const {point_no,itemno,itemno1,subname} = itemPoint this.mapPointItemArr.push({ - point_no:point_no * 1, - itemno:itemno * 1, - itemno1:itemno1 * 1, - subname + point_no:point_no * 1, + itemno:itemno * 1, + itemno1:itemno1 * 1, + subname }) }) } - // 初始化本地systemparam表、markrule表 async initTrajectoryParam(trajectoryPath:string){ - const examSubject = globalThis.carInfo.examSubject; - + const {isTrajectoryOpen} = judgeConfig //轨迹回放读取 systemparam表、markrule表 const fileUtil = new FileUtil(this.context); const folderPath = await fileUtil.initFolder(trajectoryPath); @@ -396,12 +397,16 @@ struct Index { const strArr = str.split('\n'); const [initData,beginData] = [strArr[0],strArr[1]]; const initDataObj = JSON.parse(initData) - + const systemparm = initDataObj.systemparm; + const examSubject = globalThis.carInfo.examSubject; + this.examSubject = isTrajectoryOpen ? (initDataObj.kskm*1):examSubject; + globalThis.carInfo.examSubject = this.examSubject examSubject == 2 - ? await this.initSystemKm2Param() - : await this.initSystemKm3Param(initDataObj.systemparm) + ? await this.initSystemKm2Param(systemparm) + : await this.initSystemKm3Param(systemparm) //@ts-ignore await this.initMarkRules(testMarkRules); + await this.initSysset(initDataObj.sysset); } @@ -620,10 +625,10 @@ struct Index { Row(){}.width(60).height(60).backgroundImage($rawfile('judge/manual_judge.png'), ImageRepeat.NoRepeat).backgroundImageSize({ width: '100%', height: '100%' }) Text('人工评判').fontColor('#FFF').fontSize(32).padding({right:12}) }.width(334).height(110).justifyContent(FlexAlign.Center).alignItems(VerticalAlign.Center) - .backgroundImage($rawfile('judge/button_nor.png'), ImageRepeat.NoRepeat) - .backgroundImageSize({ width: '100%', height: '100%' }) - .margin({bottom:10}) - .onClick(()=>{ + .backgroundImage($rawfile('judge/button_nor.png'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + .margin({bottom:10}) + .onClick(()=>{ if(this.judgeConfigObj['342'] == 0){ this.isDeductedPopShow = true }else{ @@ -778,7 +783,7 @@ struct Index { const unExitManualProjects = judgeConfigObj['332'].split(',') || []; const param348 = judgeConfigObj['348'] || '0'; - const param387 = judgeConfigObj['348'] || '0'; + const param387 = judgeConfigObj['387'] || '0'; if(judgeConfigObj['342'] === '3' || judgeConfigObj['342'] === '2'){ return false @@ -818,7 +823,7 @@ struct Index { @State startFullTime: string = '' @State startHourTime: string = '' //科目类型 - @State examSubject: 2 | 3 = 2; + @State examSubject: 2 | 3 = 3; @State ddxkTime: number = 0; @State ddxkKsxmArr: string[] = [''] @State ddxkKfArr: string[] = [''] diff --git a/entry/src/main/ets/pages/Register.ets b/entry/src/main/ets/pages/Register.ets index 5dd6378b..4619b448 100644 --- a/entry/src/main/ets/pages/Register.ets +++ b/entry/src/main/ets/pages/Register.ets @@ -20,17 +20,23 @@ export default struct Index { onPageShow() { // this.plateNo=globalThis.carInfo.plateNo - deviceManager.createDeviceManager('com.oh.dts', (error, value) => { - if (error) { - console.error('createDeviceManager failed.'); - return; - } - let dvMgrObj = value; - this.deviceName = dvMgrObj.getLocalDeviceInfoSync().deviceName - this.deviceNo = dvMgrObj.getLocalDeviceInfoSync().deviceId.substring(0, 10).toUpperCase() - this.ip = 'MAC-' + this.deviceNo - globalThis.deviceNo = 'MAC-' + this.deviceNo - }); + console.log('createDeviceManagerstart') + try{ + deviceManager.createDeviceManager('com.oh.dts', (error, value) => { + if (error) { + console.error('createDeviceManager failed.'); + return; + } + let dvMgrObj = value; + this.deviceName = dvMgrObj.getLocalDeviceInfoSync().deviceName + this.deviceNo = dvMgrObj.getLocalDeviceInfoSync().deviceId.substring(0, 10).toUpperCase() + this.ip = 'MAC-' + this.deviceNo + globalThis.deviceNo = 'MAC-' + this.deviceNo + }); + + }catch (error){ + console.log('createDeviceManagererror',error) + } } build() { diff --git a/entry/src/main/ets/pages/TerminalInfos.ets b/entry/src/main/ets/pages/TerminalInfos.ets index 0cdd402e..ff59e3df 100644 --- a/entry/src/main/ets/pages/TerminalInfos.ets +++ b/entry/src/main/ets/pages/TerminalInfos.ets @@ -19,7 +19,7 @@ struct Index { // @State inputTextList2: string[] = ['192.168.7.124','20022'] - @State inputTextList1: string[] = ['112.80.35.83','11055','112.80.35.83','11052','255.255.255.0','192.168.7.1','114.114.114.114','192.168.7.124','20022','192.168.7.170','20122','112.80.35.83','11050'] + @State inputTextList1: string[] = ['172.37.55.191','18782','172.37.55.191','8082','255.255.255.0','192.168.7.1','114.114.114.114','192.168.7.124','20022','192.168.7.170','20122','172.37.55.191','11050'] // @State inputTextList2: string[] = [] // 112.80.35.83 11052 // @State inputTextList1: string[] = ['192.168.36.2','8084','192.168.36.200','20122','255.255.255.0','192.168.36.1','','','114.114.114.114','192.168.36.139','8000'] @@ -88,7 +88,7 @@ struct Index { gateway: this.inputTextList1[5],//value.gateway网关 netMask: this.inputTextList1[4],//value.netMask网络掩码 dnsServers: this.inputTextList1[6], - // domain: "" + domain: "" }, (error) => { if (error) { prompt.showToast({ diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index 7418377d..91763253 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -19,7 +19,7 @@ import {string2Bytes} from '../common/utils/tools' import { getSyncData } from '../common/service/initable' @Entry @Component -export default struct UserInfo { +struct UserInfo { @State pageIndex: number = 0 @State ratio: number = 1700 / 960 @State index: number = 0 @@ -182,7 +182,6 @@ export default struct UserInfo { changeQkfn() { this.qkFn() } - //初始化数据 initData(){ this.stepFlag = false this.faceCompareSucess = 0 @@ -238,6 +237,7 @@ export default struct UserInfo { } + async initSysset() { const that = this; const db = new AccountTable(() => { @@ -276,7 +276,7 @@ export default struct UserInfo { that.getExaminationStudentInfoFn() } }, 5000) - } else { + }else{ this.getExaminationItemFn() } @@ -287,7 +287,7 @@ export default struct UserInfo { changeFaceCompareSuccess() { console.log('this.faceCompareSuces', this.faceCompareSucess, JSON.stringify(this.currentUser)) if (this.faceCompareSucess > 0) { - //人脸比对通过 + //人脸比对通过 this.sfbdinterfaceFn() } } @@ -360,7 +360,6 @@ export default struct UserInfo { console.log('error12error' + error) }) } - //缺考 qkFn() { this.faceCompareSucess = 0 if (globalThis.singlePlay) { @@ -397,7 +396,6 @@ export default struct UserInfo { }) } - // 获取考试项目 async getExaminationItemFn(){ console.info('surenjun', this.currentUser.lsh) if(!this.currentUser.lsh||globalThis.singlePlay){ @@ -411,10 +409,10 @@ export default struct UserInfo { lsh: this.currentUser.lsh || '', examinationRoomId }); - if (examItems?.getExaminationItemRsp?.body?.kssycs != 0) { + if(examItems?.getExaminationItemRsp?.body?.kssycs!=0){ this.getExaminationStudentInfoFn() - } else { - this.dataList = [] + }else{ + this.dataList=[] this.currentUser = EmptyCandidateObject } @@ -771,7 +769,7 @@ struct LabelBlock { Row() { Text(this.label).fontSize(16 * this.ratio).fontColor('#99948A') Row() { - Text(this.value).fontColor('#fff').textAlign(TextAlign.Center).width('100%') + Text(decodeURIComponent(this.value)).fontColor('#fff').textAlign(TextAlign.Center).width('100%') } .commLabelStyle() }.margin({ bottom: 10 * this.ratio }) diff --git a/entry/src/main/ets/pages/compontents/SignDisplayCom.ets b/entry/src/main/ets/pages/compontents/SignDisplayCom.ets index 0a33e007..4fe9d258 100644 --- a/entry/src/main/ets/pages/compontents/SignDisplayCom.ets +++ b/entry/src/main/ets/pages/compontents/SignDisplayCom.ets @@ -138,7 +138,7 @@ export default struct SignDisplayCom { Row() { if(this.showBack){ - Image($r('app.media.topB_back')).width('16.7%').height('12.2%') + Image($r('app.media.topB_back')).height('12.2%') .onClick(() => { router.back() // this.url='back' diff --git a/entry/src/main/ets/pages/interfaces.ts b/entry/src/main/ets/pages/interfaces.ts index 0c73f2cd..95f67a45 100644 --- a/entry/src/main/ets/pages/interfaces.ts +++ b/entry/src/main/ets/pages/interfaces.ts @@ -66,6 +66,14 @@ export interface VideoConfig{ spzd1:boolean, zdyz:string, } - +export interface initTableParam{ + carId:string, + examinationRoomId:string, + judgeVersion:string, + shellVersion:string, + paraKdid:string, + mode: string + +} diff --git a/entry/src/main/ets/pages/judgeSDK/api/judgeSDK.d.ts b/entry/src/main/ets/pages/judgeSDK/api/judgeSDK.d.ts index bd4a1f09..4a49c751 100644 --- a/entry/src/main/ets/pages/judgeSDK/api/judgeSDK.d.ts +++ b/entry/src/main/ets/pages/judgeSDK/api/judgeSDK.d.ts @@ -140,6 +140,11 @@ export interface SOUND { //语音播放提示代码 code:string } +export interface SYSSET { + v_no:string, + v_name:string, + v_value:string +} export interface ProjectObj { [k:any]:Project diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ts b/entry/src/main/ets/pages/judgeSDK/judge.ts index af07ee03..f8d0e106 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ts +++ b/entry/src/main/ets/pages/judgeSDK/judge.ts @@ -20,7 +20,7 @@ import {writeObjectOut,uploadExamProgressData} from '../../api/judge' import {deepClone,getCurrentTime,stringToASC,string2Bytes,fillZero,Array2Byte,convertGpsCoord2} from '../../common/utils/tools' import {getTranslateSignals,getCarStatus,getCarStatusType,getCenterProjectStatus,plcStrToJson,plcStrToWXJson,promptWxCode,getKmProjectVoice} from './utils//judge-common' import {examJudgeSetLogCallback,examJudgeBeginExam,examJudgeInit,examJudgeRealExam,examJudgeSetRealExamCallback,examJudgeSetPerformCallback,examJudgeEndExam,examJudgeArtificialMark,examJudgeArtificialItem} from './api/index' -import Want from '@ohos.app.ability.Want'; + import prompt from '@ohos.prompt'; const judgeTag = 'SURENJUN_JUDGE' @@ -129,6 +129,7 @@ export default class Judge{ await examJudgeBeginExam(beginExamInfo); console.info(judgeTag,'6.开始考试注册完成') + avPlayer.playAudio(['voice/ksks.WAV']) // 处理轨迹plc信息 if(isTrajectoryOpen){ handleTrajectoryUdp(strArr); @@ -139,7 +140,7 @@ export default class Judge{ globalThis.udpClient.onMessage(async (msg) => { handleUdp(msg) }) - avPlayer.playAudio(['voice/ksks.WAV']) + } @@ -706,8 +707,11 @@ export default class Judge{ // 消息心跳发送 getMessageHeartbeat = async (isEnd?:Boolean) => { + console.log('kkkkkkmmm') const carInfo = globalThis.carInfo; const { examSubject,plateNo,ksyh } = carInfo; + // const ksyh='0000000000000' + // const ksyh=globalThis.ksyh ||'0000000000000' const {judgeUI,isExam,serialIndex,tempData,xmmcCode,xmxh,xmmcSingleCode,xmdm,performInfo,kfArr,getTranslateProject,getSbxh} = this; const {lsh,startHourTime,totalScore} = judgeUI; const examType = isExam?examSubject:0; @@ -716,25 +720,36 @@ export default class Judge{ const {jd,wd, hxj, fyj, hbg,} = gps const translateProject = getTranslateProject(); const sbxh = getSbxh(xmdm,xmxh) + console.log('sbxhsbxh',sbxh) const {carzt,dcjl,qjjl,dxjl,bxjl} = performInfo; + console.log('performInfo',JSON.stringify(performInfo)) + // const asclshArr = stringToASC(lsh); + const asclshArr = stringToASC(fillZero('0000000000000' || 0, 13)); - const asclshArr = stringToASC(lsh); //13不足要补0 const ascksyhArr = stringToASC(fillZero(ksyh || 0,13)) const ascsbxhArr = stringToASC(sbxh) const translateSignals = getTranslateSignals( [zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc,ssc,fsc, lb, mkg, aqd, 0,0,0,0 ].concat(getCarStatusType(carzt)).concat([ ygq, sensor.wd, 0 ]) ) + console.log('jinweidu111jdwd0') //@ts-ignore - const translateJd = convertGpsCoord2(wd).toFixed(7) * Math.pow(10,7) + const translateJd = convertGpsCoord2(wd).toFixed(7) * Math.pow(10,7); //@ts-ignore - const translateWd = convertGpsCoord2(jd).toFixed(7) * Math.pow(10,7) + const translateWd = convertGpsCoord2(jd).toFixed(7) * Math.pow(10, 7) + console.log('jinweidu111jdwd') //@ts-ignore - const translateProjects= translateProject.map(num => string2Bytes(num,8)[0]) + const translateProjects = translateProject.map(numStr => string2Bytes(parseInt(numStr, 2), 8)[0]) + + //@ts-ignore + // const translateProjects= translateProject.map(num => string2Bytes(p,8)[0]) + console.log('jinweidu2222',`${examType}${startHourTime}`) const arr = [ //考生号 TODO 考试员号 - asclshArr.map(lsh => string2Bytes(lsh,8)[0]), ascksyhArr.map(ksyh => string2Bytes(ksyh,8)[0]), + asclshArr.map(lsh => string2Bytes(lsh,8)[0]), + //考试员号 + ascksyhArr.map(ksyh => string2Bytes(ksyh,8)[0]), //科目类型(0:未考试 1:科目二 2:科目三) + 考试开始时间 string2Bytes(`${examType}${startHourTime}`,4 * 8), // TODO 消息序号从1开始,0结束 @@ -760,16 +775,20 @@ export default class Judge{ string2Bytes(Math.floor((dcjl + qjjl)/100),2*8), //扣分 string2Bytes(100 - Math.abs(totalScore),2*8), + //扣分数 + //todo扣分值/扣分项 + string2Bytes(0, 2 * 8), //扣分项数量 - string2Bytes(kfArr.length,8), + string2Bytes(kfArr.length,8), //n个扣分序号 + kfArr.map(kf => string2Bytes(kf.kfxh,8)[0]) ] let tempArr = []; arr.forEach(itemArr =>{ tempArr = tempArr.concat(itemArr)}) - this.serialIndex += 1; + console.log('kmkmkm2',tempArr.length) return Array2Byte(tempArr) } @@ -797,7 +816,7 @@ export default class Judge{ sfyk:0, ykkkcs:1, //TODO 考试路线待修改 - wayno:1, + wayno:3, czlx:0, kskssj:await systemTime.getCurrentTime(), ksxm:projects.map(project=>{ @@ -858,12 +877,12 @@ export default class Judge{ const {cdsbInfoObj,projectsObj} = judgeUI; const project = projectsObj[ksxm] if(project === undefined){ - return '0000000000' + return '00000000' } const projectType = project.sbxh; const projectKey = `${ksxm}_${xmxh}`; const currentCdsb = cdsbInfoObj[projectKey] || {}; - const sbxh = currentCdsb.sbbh || '0000000000' + const sbxh = currentCdsb.sbbh || '00000000' return sbxh } @@ -882,18 +901,18 @@ export default class Judge{ // 中心所有项目转换 getTranslateProject = () => { - const {testKmItems} = this; + // const {testKmItems} = this; const tempItems = testKmItems.map(item=>{ - const current = testKmItems[item.code]; + const current = this.testKmItems[item.code]; return { code:item.code, status:getCenterProjectStatus(current.status) } }) - const len = Math.floor(tempItems.length / 4); + const len = Math.floor(tempItems.length / 8); const arr = []; for(let i = 0;i <= len;i++){ - const temp = tempItems.slice( i*4 , (i+1)*4 ); + const temp = tempItems.slice( i*8 , (i+1)*8 ); let tempArr = temp.map(item => item.status) if(i === 4){ tempArr = tempArr.concat(['00','00']) diff --git a/entry/src/main/ets/pages/judgeSDK/utils/judge-config.ts b/entry/src/main/ets/pages/judgeSDK/utils/judge-config.ts index a23c68cf..9b6c6287 100644 --- a/entry/src/main/ets/pages/judgeSDK/utils/judge-config.ts +++ b/entry/src/main/ets/pages/judgeSDK/utils/judge-config.ts @@ -8,7 +8,8 @@ export const judgeConfig = { udpOpen:false, // 本地模型地址 modelPath: 'models/model_enc', - trajectoryPath: 'logs/2024_05_14/0000000000001_342323199501470011_测试学员1_2024_05_14_11_28_31/judge_exam_data.txt' + // 轨迹回放地址 + trajectoryPath: 'logs/2024_06_18/0000000000001_342323199501470011_测试学员1_2024_06_18_14_32_25/judge_exam_data.txt' } //0000000000001_342323199501470011_测试学员1_2024_04_28_10_59_44 @@ -17,7 +18,6 @@ export const judgeConfig = { // 济南轨迹回放 // test_sub3_car_test_jinan-32038219990808021X-20240322173643.txt - // test_sub3_car_test_jinan-32038219990808021X-20240322173643.track // 2024_01_24_11_30_06_2210707689316_620502199005070478_马鸣五 // 2024_01_24_10_25_41_2231212226990_330184200208281821_金晓婷 \ No newline at end of file diff --git a/entry/src/main/ets/pages/judgeSDK/utils/voice-announcements.ts b/entry/src/main/ets/pages/judgeSDK/utils/voice-announcements.ts index 7028b32c..020bcd7b 100644 --- a/entry/src/main/ets/pages/judgeSDK/utils/voice-announcements.ts +++ b/entry/src/main/ets/pages/judgeSDK/utils/voice-announcements.ts @@ -1,4 +1,5 @@ import media from '@ohos.multimedia.media'; +import prompt from '@ohos.prompt'; const TAG = 'VoiceAnnounce' @@ -18,7 +19,6 @@ export default class VoiceAnnounce{ async playAudio(urls:string[],shit,callback:Function){ const {isStopped,queue} = this; this.callback = callback - console.info('surenjun',JSON.stringify(callback)) if(shit){ //队列清空,重新初始化 this.isStopped = true; @@ -45,6 +45,7 @@ export default class VoiceAnnounce{ await go() return } + await avPlayer.play(queue[0],callback); this.queue.shift(); console.info(TAG,JSON.stringify(this.queue),'堆栈弹出'); @@ -73,14 +74,22 @@ class AVPlayer { this.endCallback = callback const avPlayer = await media.createAVPlayer(); this.avPlayer = avPlayer; - return new Promise(async (resolve)=>{ + return new Promise(async (resolve,reject) => { + let url = '' await this.setAVPlayerCallback(()=>{ //@ts-ignore resolve() }); - let url = await globalThis.context.resourceManager.getRawFd(name) - this.avPlayer.fdSrc = url; - + try { + url = await globalThis.context.resourceManager.getRawFd(name); + this.avPlayer.fdSrc = url; + } catch (e) { + prompt.showToast({ + message: `${name}语音文件不存在`, + duration: 4000 + }); + resolve(1) + } }) } //音频播放队列 diff --git a/entry/src/main/ets/workers/worker.ts b/entry/src/main/ets/workers/worker.ts index 7e3ebd73..9262fb2f 100644 --- a/entry/src/main/ets/workers/worker.ts +++ b/entry/src/main/ets/workers/worker.ts @@ -1,55 +1,56 @@ -// import AccountTable from '../common/database/tables/AccountTable'; -// import worker from '@ohos.worker'; -// import { getDataBaseTable, upDateTable, getMySystemSetTable,getSyncData } from '../common/service/initable' -// import MA_SYSSET from '../common/constants/MA_SYSSET'; -// -// -// async function upDateTableFn(data) { -// -// // let flag -// await upDateTable({ tableName: 'MA_MARKRULE' },) -// await upDateTable({ tableName: 'MA_SYSTEMPARM' },) -// -// await upDateTable({ tableName: 'MA_MAP_COLLECT' },data) -// -// await upDateTable({ tableName: 'MA_MAP_COLLECT_SHAPE' },data) -// await upDateTable({ tableName: 'MA_MAP_ITEMCLASS' },data) -// -// await upDateTable({ tableName: 'MA_MAP_POINT' },data) -// -// await upDateTable({ tableName: 'MA_MAP_POINT_ITEM' },data) -// -// await upDateTable({ tableName: 'MA_MAP_ROAD' },data) -// await upDateTable({ tableName: 'MA_MAP_ROAD_LANE' },data) -// await upDateTable({ tableName: 'MA_MAP_SUBITEM' },data) -// await upDateTable({ tableName: 'ES_CARINFO' },data) -// await upDateTable({ tableName: 'ES_EXAMPOINTDETAIL' },data) -// await upDateTable({ tableName: 'MA_MARKRULESET' },data) -// await upDateTable({ tableName: 'ES_CAR_VIDEO_PARAMETER' },data) -// await upDateTable({ tableName: 'MA_CDSBINFO' },data) -// await upDateTable({ tableName: 'MA_ITEMINFO' },data) -// await upDateTable({ tableName: 'MA_T_CARPARMSET' },data) -// workerPort.postMessage("receive data from main.js"); -// -// -// } -// const workerPort = worker.workerPort; -// workerPort.onmessage = function(e){ -// let data = e -// console.log('e.data',e.data) -// upDateTableFn(e.data); -// } -// //console.log('1111111111') -// //accountTable.getRdbStore(() => { -// // accountTable.query(0, (result) => { -// //// this.accounts = result; -// // }, true); -// //}); -// //parentPort.onmessage = function(e){ -// // accountTable.insertData({ id: 0, accountType: 0, typeText: '', amount: 0 }, (id) => { -// // parentPort.postMessage("receive data from main.js") -// //// newAccount.id = id; -// //// this.accounts.push(newAccount); -// // }); -// // -// //} \ No newline at end of file +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import worker, { MessageEvents } from '@ohos.worker'; +import zlib from '@ohos.zlib'; +import request from '@ohos.request'; +import type common from '@ohos.app.ability.common'; +import ConvertXML from '@ohos.convertxml'; +import xml from '@ohos.xml'; +import hilog from '@ohos.hilog'; +import { getDoubleCeneterTable, getSingleCenterTable } from '../common/service/indexService'; +import { initTableParam } from '../pages/interfaces'; + +let workerPort = worker.workerPort; + +workerPort.onmessage = (e: MessageEvents): void => { + let param:initTableParam = e.data; + console.log('baoyihu,onmessage',JSON.stringify(param)) + if(param.mode=='1'){ + //单中心 + getSingleCenterTable(param).then((ret) => { + if (ret) { + workerPort.postMessage({ isComplete: true }); + }else{ + workerPort.postMessage({ isComplete: false }); + } + }) + }else if(param.mode=='3'){ + //双中心 + getDoubleCeneterTable(param).then((ret)=>{ + if (ret) { + workerPort.postMessage({ isComplete: true }); + } + }) + } + + // worker线程向主线程发送信息 + //let context: common.UIAbilityContext = e.data.context; + + + + // workerPort.postMessage({ isComplete: true, jsonStr: result }); + +}; \ No newline at end of file