Merge remote-tracking branch 'origin/api10' into api10

This commit is contained in:
Surenjun 2025-03-26 14:58:47 +08:00
commit c8bfacb9af
21 changed files with 226 additions and 198 deletions

View File

@ -6,7 +6,7 @@ import { GetSyncData } from '../utils/table/Operation';
import { GetCurrentTime } from '../utils/Common'; import { GetCurrentTime } from '../utils/Common';
import FileUtils from '../utils/FileUtils'; import FileUtils from '../utils/FileUtils';
let baseHost: string = AppStorage.get('host'); let baseHost: string = AppStorage.get<string>('host');
// 下载模型 // 下载模型
@ -27,11 +27,11 @@ interface WR {
// 通用监管接口 // 通用监管接口
export async function writeObjectOut(params: RegulatoryInterfaceParams, filePath?: string): Promise<WR> { export async function writeObjectOut(params: RegulatoryInterfaceParams, filePath?: string): Promise<WR> {
const singlePlay: boolean = AppStorage.get('singlePlay') const singlePlay: boolean = AppStorage.get<boolean>('singlePlay')
if (singlePlay) { if (singlePlay) {
return { code: 1 } return { code: 1 }
} }
let JGHOST: string = AppStorage.get("JGHOST") let JGHOST: string = AppStorage.get<string>("JGHOST")
//获取监管接口地址路径 //获取监管接口地址路径
if (!JGHOST) { if (!JGHOST) {
const syssetParams: MASYSSETTableType[] = await GetSyncData<MASYSSETTableType>("MA_SYSSET"); const syssetParams: MASYSSETTableType[] = await GetSyncData<MASYSSETTableType>("MA_SYSSET");
@ -49,7 +49,7 @@ export async function writeObjectOut(params: RegulatoryInterfaceParams, filePath
}) })
} }
// const { xtlb, jkxlh, jkid, drvexam } = params; // const { xtlb, jkxlh, jkid, drvexam } = params;
const isJGNew: boolean = AppStorage.get('isJGNew') const isJGNew: boolean = AppStorage.get<boolean>('isJGNew')
//新监管调用 //新监管调用
if (isJGNew) { if (isJGNew) {
return await writeObjectOutNew(params, filePath) return await writeObjectOutNew(params, filePath)
@ -73,7 +73,7 @@ export async function writeObjectOut(params: RegulatoryInterfaceParams, filePath
} }
//对象转换成xml //对象转换成xml
JGHOST = AppStorage.get("JGHOST") JGHOST = AppStorage.get<string>("JGHOST")
const temp = await request<object>({ const temp = await request<object>({
host: JGHOST, host: JGHOST,
url: '/dems_ws/services/TmriOutAccess?wsdl', url: '/dems_ws/services/TmriOutAccess?wsdl',
@ -132,7 +132,7 @@ interface UploadExamProgressDataParams {
// 过程文件上传 // 过程文件上传
export async function uploadExamProgressData(params: UploadExamProgressDataParams) { export async function uploadExamProgressData(params: UploadExamProgressDataParams) {
// const singlePlay = globalThis.singlePlay // const singlePlay = globalThis.singlePlay
const singlePlay: boolean = AppStorage.get('singlePlay') const singlePlay: boolean = AppStorage.get<boolean>('singlePlay')
if (singlePlay) { if (singlePlay) {
return return
} }
@ -169,7 +169,7 @@ interface UploadExamProgressDataParams2 {
export async function uploadExamProgressData2(params: UploadExamProgressDataParams2) { export async function uploadExamProgressData2(params: UploadExamProgressDataParams2) {
// const singlePlay = globalThis.singlePlay // const singlePlay = globalThis.singlePlay
const singlePlay: boolean = AppStorage.get('singlePlay') const singlePlay: boolean = AppStorage.get<boolean>('singlePlay')
if (singlePlay) { if (singlePlay) {
return return
} }
@ -203,7 +203,7 @@ interface UploadExamMileage {
// 上传考试里程 // 上传考试里程
export async function uploadExamMileage(params: UploadExamMileage) { export async function uploadExamMileage(params: UploadExamMileage) {
// const singlePlay = globalThis.singlePlay // const singlePlay = globalThis.singlePlay
const singlePlay: boolean = AppStorage.get('singlePlay') const singlePlay: boolean = AppStorage.get<boolean>('singlePlay')
if (singlePlay) { if (singlePlay) {
return return
@ -230,7 +230,7 @@ export async function uploadExamMileage(params: UploadExamMileage) {
// 上传考试成绩 // 上传考试成绩
export async function uploadExamGrade(params: ESObject) { export async function uploadExamGrade(params: ESObject) {
// const singlePlay = globalThis.singlePlay // const singlePlay = globalThis.singlePlay
const singlePlay: boolean = AppStorage.get('singlePlay') const singlePlay: boolean = AppStorage.get<boolean>('singlePlay')
if (singlePlay) { if (singlePlay) {
return return
} }

View File

@ -30,6 +30,7 @@ import { GlobalConfig } from '../../config/index';
import prompt from '@ohos.promptAction'; import prompt from '@ohos.promptAction';
import DB, { ColumnType } from '../database/DbSql'; import DB, { ColumnType } from '../database/DbSql';
import FileUtils from '../../utils/FileUtils'; import FileUtils from '../../utils/FileUtils';
import { TimeSynchronizationRspBody } from '../../model';
//读表 //读表
//参数平台 //参数平台
@ -291,7 +292,7 @@ export async function delSyncTable(tableName, context?) {
//获取车模、场地模型 //获取车模、场地模型
export async function getEsCarModel(context) { export async function getEsCarModel(context) {
const date = new Date() const date = new Date()
const timeInfo = AppStorage.get('timeInfo') const timeInfo = AppStorage.get<TimeSynchronizationRspBody>('timeInfo')
if (!timeInfo?.paraKdid) { if (!timeInfo?.paraKdid) {
prompt.showToast({ prompt.showToast({
message: 'paraKdid获取失败', message: 'paraKdid获取失败',
@ -308,7 +309,7 @@ export async function getEsCarModel(context) {
"paraKdid": timeInfo.paraKdid, //参数平台kdid "paraKdid": timeInfo.paraKdid, //参数平台kdid
"examinationRoomId": timeInfo.kdid, //考试平台kdid "examinationRoomId": timeInfo.kdid, //考试平台kdid
// "carMac":"MAC-HCPAD-210", // "carMac":"MAC-HCPAD-210",
"carMac": AppStorage.get('deviceNo') "carMac": AppStorage.get<string>('deviceNo')
} }
} }
const venueStr = { const venueStr = {
@ -320,7 +321,7 @@ export async function getEsCarModel(context) {
"paraKdid": timeInfo.paraKdid, //参数平台kdid "paraKdid": timeInfo.paraKdid, //参数平台kdid
"examinationRoomId": timeInfo.kdid, //考试平台kdid "examinationRoomId": timeInfo.kdid, //考试平台kdid
// "carMac":"MAC-HCPAD-210", // "carMac":"MAC-HCPAD-210",
"carMac": AppStorage.get('deviceNo') "carMac": AppStorage.get<string>('deviceNo')
} }
} }

View File

@ -137,7 +137,7 @@ export async function getUDP2(context, errorFlag?) {
globalThis.udpEvent.sendKfContent(val.body[0]) globalThis.udpEvent.sendKfContent(val.body[0])
} else if (val.id == '46') { } else if (val.id == '46') {
let tmpList = [] let tmpList = []
const str = AppStorage.get('lsh') const str = AppStorage.get<string>('lsh')
for (let i = 0; i < str.length; i++) { for (let i = 0; i < str.length; i++) {
tmpList.push(this.string2Bytes(str.charCodeAt(i), 1 * 8)[0]) tmpList.push(this.string2Bytes(str.charCodeAt(i), 1 * 8)[0])
} }
@ -188,7 +188,7 @@ export async function setJudgeUdp() {
const fileUtil = new FileUtil(context) const fileUtil = new FileUtil(context)
const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/ipConfig.txt'); const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/ipConfig.txt');
const config = JSON.parse(data) const config = JSON.parse(data)
const carInfo = AppStorage.get('carInfo') const carInfo = AppStorage.get<CarInfoType>('carInfo')
// //
// const config = await getSyncData('IpConfigTable'); // const config = await getSyncData('IpConfigTable');
let udpIndex = 0; let udpIndex = 0;

View File

@ -2,7 +2,7 @@ import systemTime from '@ohos.systemDateTime';
import { testKm2Items, testKm3Items } from '../../pages/judgeSDK/dataTest/index'; import { testKm2Items, testKm3Items } from '../../pages/judgeSDK/dataTest/index';
import { judgeConfig } from '../../pages/judgeSDK/utils/judgeConfig'; import { judgeConfig } from '../../pages/judgeSDK/utils/judgeConfig';
import { setJudgeUdp, setTopLineUdp } from './GlobalUdp'; import { setJudgeUdp, setTopLineUdp } from './GlobalUdp';
import { examCalcGpsDistance } from '../../pages/judgeSDK/api' import { examCalcGpsDistance } from '../../pages/judgeSDK/api';
export const initJudgeUdp = async () => { export const initJudgeUdp = async () => {
AppStorage.setOrCreate('serialIndex', 0) AppStorage.setOrCreate('serialIndex', 0)
@ -51,7 +51,7 @@ export const initJudgeUdp = async () => {
} }
export const getMessageHeartbeat = async (msg) => { export const getMessageHeartbeat = async (msg) => {
const carInfo = AppStorage.get('carInfo'); const carInfo = AppStorage.get<CarInfoType>('carInfo');
const { examSubject, plateNo } = carInfo; const { examSubject, plateNo } = carInfo;
const ksyh = '0000000000000' const ksyh = '0000000000000'
const { fourInOneScreen:{ gpsDigit } } = judgeConfig const { fourInOneScreen:{ gpsDigit } } = judgeConfig

View File

@ -44,10 +44,10 @@ export default class EntryAbility extends UIAbility {
AppStorage.setOrCreate<CarInfoType>('carInfo', {}) AppStorage.setOrCreate<CarInfoType>('carInfo', {})
AppStorage.setOrCreate<ExaminerInfoType>('examinerInfo', {}) AppStorage.setOrCreate<ExaminerInfoType>('examinerInfo', {})
AppStorage.setOrCreate('lsh', '0000000000000') AppStorage.setOrCreate<string>('lsh', '0000000000000')
AppStorage.setOrCreate('statue', 1) //考试状态 AppStorage.setOrCreate<string>('statue', "1") //考试状态
AppStorage.setOrCreate('signNum', 0) //心跳指令编号 AppStorage.setOrCreate<number>('signNum', 0) //心跳指令编号
AppStorage.setOrCreate('deviceNo', 0) //设备号 AppStorage.setOrCreate<string>('deviceNo', "") //设备号
AppStorage.setOrCreate<BaseInfoType>('baseInfo', { AppStorage.setOrCreate<BaseInfoType>('baseInfo', {
hasAuth: false, hasAuth: false,
version: GlobalConfig.version.jn.km3[0], version: GlobalConfig.version.jn.km3[0],

View File

@ -1,5 +1,5 @@
import { ColumnInfo, ColumnType } from '../common/database/DbSql'
import common from '@ohos.app.ability.common'; import common from '@ohos.app.ability.common';
import { ColumnInfo, ColumnType } from '../utils/DbSql';
export const MA_SYS_SET_COLUMN: ColumnInfo[] = [ export const MA_SYS_SET_COLUMN: ColumnInfo[] = [
{ {

View File

@ -1,4 +1,4 @@
import { DrvexamType } from "."; import { DrvexamType } from '.';
// -----new----- // -----new-----
export interface ApiResponseType { export interface ApiResponseType {
@ -28,6 +28,8 @@ interface TimeSynchronizationRsp {
export interface TimeSynchronizationRspBody { export interface TimeSynchronizationRspBody {
mode?: string; mode?: string;
url?: string url?: string
paraKdid?: string
kdid?: string
} }
interface UploadExamCarCheckResultRsp { interface UploadExamCarCheckResultRsp {

View File

@ -4,9 +4,8 @@ import TopLogo from './compontents/TopLogo';
import testNapi from '@ohos.hiserialsdk'; import testNapi from '@ohos.hiserialsdk';
import { DwMapData, PassData, RealNumData, StackValueData, WarnFlagData, WarnFlagTipData } from '../mock'; import { DwMapData, PassData, RealNumData, StackValueData, WarnFlagData, WarnFlagTipData } from '../mock';
import { BaseInfoType, RouteParamsType } from '../model/Common'; 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 { BusinessError } from '@ohos.base';
import { SpzdType } from '../model';
import { voiceService } from '../utils/Voice'; import { voiceService } from '../utils/Voice';
import dayTs from '../utils/Date'; import dayTs from '../utils/Date';
@ -46,7 +45,7 @@ struct Index {
// private AccountTable = new AccountTable(()=>{},CommonConstants); // private AccountTable = new AccountTable(()=>{},CommonConstants);
aboutToAppear() { aboutToAppear() {
const that = this const that = this
this.carInfo = AppStorage.get('carInfo') this.carInfo = AppStorage.get<CarInfoType>('carInfo')
this.vocObj = new voiceService(async (status: string, val: string) => { this.vocObj = new voiceService(async (status: string, val: string) => {
if (!that.breakFlag) { if (!that.breakFlag) {
return return
@ -121,7 +120,7 @@ struct Index {
// //
carConfigurationInfoFn() { carConfigurationInfoFn() {
if (AppStorage.get('singlePlay')) { if (AppStorage.get<boolean>('singlePlay')) {
const str = 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" "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(';') const data = str.split(';')
@ -137,7 +136,7 @@ struct Index {
this.checkListCopy = JSON.parse(JSON.stringify(this.checkList)) this.checkListCopy = JSON.parse(JSON.stringify(this.checkList))
return return
} }
const baseInfo = AppStorage.get('baseInfo') as BaseInfoType const baseInfo = AppStorage.get<BaseInfoType>("baseInfo")
//模拟真实数据 //模拟真实数据
const param: CarConfigurationParams = { const param: CarConfigurationParams = {
body: { body: {
@ -277,7 +276,7 @@ struct Index {
type: 1, type: 1,
name: flag ? 'zjwtg.wav' : 'zjtg.wav' name: flag ? 'zjwtg.wav' : 'zjtg.wav'
}) })
if (AppStorage.get('singlePlay')) { if (AppStorage.get<boolean>('singlePlay')) {
return return
} }
let date = new Date(); let date = new Date();

View File

@ -94,7 +94,7 @@ struct Index {
if (this.limit) { if (this.limit) {
return return
} }
const carInfo: CarInfoType = AppStorage.get('carInfo') const carInfo: CarInfoType = AppStorage.get<CarInfoType>('carInfo')
const param: UserLoginType = { const param: UserLoginType = {
carId: carInfo.carId as string, carId: carInfo.carId as string,
examinationRoomId: carInfo.examinationRoomId as string, examinationRoomId: carInfo.examinationRoomId as string,
@ -130,7 +130,7 @@ struct Index {
console.log('res11', JSON.stringify(res)) console.log('res11', JSON.stringify(res))
const examinerLoginInfo: ExaminerLoginInfo = res.examinerLoginRsp.body const examinerLoginInfo: ExaminerLoginInfo = res.examinerLoginRsp.body
examinerLoginInfo.username = this.inputTextArr[0] examinerLoginInfo.username = this.inputTextArr[0]
AppStorage.setOrCreate('examinerLoginInfo', examinerLoginInfo) AppStorage.setOrCreate<ExaminerLoginInfo>('examinerLoginInfo', examinerLoginInfo)
}).catch((err: BusinessError) => { }).catch((err: BusinessError) => {
console.log('jiangsong12', JSON.stringify(err)) console.log('jiangsong12', JSON.stringify(err))
this.errorDialog.close() this.errorDialog.close()

View File

@ -11,8 +11,12 @@ import errorMsgDialog from './compontents/errorMsgDialog';
import imageBtn from './compontents/imageBtn'; import imageBtn from './compontents/imageBtn';
import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements';
import { BaseInfoType } from '../model/Common'; import { BaseInfoType } from '../model/Common';
import { CarInfoType } from '../model'; import {
import { InitializeTheCentralTableType, MASYSSETTableType, TimeInfo } from '../model'; CarInfoType,
InitializeTheCentralTableType,
MASYSSETTableType,
TimeSynchronizationRspBody
} from '../model';
import { GetCarInfo, GetDeviceInfo, SetCurrentTime, SetSerialNumber, UseAuth } from './Index/utils'; import { GetCarInfo, GetDeviceInfo, SetCurrentTime, SetSerialNumber, UseAuth } from './Index/utils';
import { GetSyncData, InitializeTheCentralTable } from '../utils/table/Operation'; import { GetSyncData, InitializeTheCentralTable } from '../utils/table/Operation';
import { BusinessError } from '@ohos.base'; import { BusinessError } from '@ohos.base';
@ -56,7 +60,7 @@ struct Index {
) )
private interval = -1; private interval = -1;
private avPlayer: VoiceAnnounce private avPlayer: VoiceAnnounce
private timeInfo: TimeInfo private timeInfo: TimeSynchronizationRspBody
private context = getContext(this) as common.UIAbilityContext; private context = getContext(this) as common.UIAbilityContext;
@Styles @Styles
@ -353,7 +357,7 @@ struct Index {
async aboutToAppear() { async aboutToAppear() {
this.avPlayer = new VoiceAnnounce(); this.avPlayer = new VoiceAnnounce();
this.ratio = AppStorage.get('ratio') this.ratio = AppStorage.get<number>('ratio')
this.initParamFlag = false this.initParamFlag = false
this.delLoading = false this.delLoading = false
this.dialogVisiable = false this.dialogVisiable = false
@ -391,7 +395,7 @@ struct Index {
kdid: this.timeInfo?.kdid || this.timeInfo?.paraKdid, kdid: this.timeInfo?.kdid || this.timeInfo?.paraKdid,
mode: this.timeInfo?.mode, mode: this.timeInfo?.mode,
context: this.context, context: this.context,
host: AppStorage.get('host'), host: AppStorage.get<string>('host'),
centerHost: this.timeInfo?.url, centerHost: this.timeInfo?.url,
singlePlay: this.singlePlay singlePlay: this.singlePlay
} }
@ -427,13 +431,13 @@ struct Index {
} }
async heartMsg() { async heartMsg() {
const signNum = AppStorage.get('signNum') as number const signNum = AppStorage.get<number>('signNum')
const statue = AppStorage.get('statue') as number const statue = AppStorage.get<string>('statue')
const lsh = AppStorage.get('lsh') as String const lsh = AppStorage.get<string>('lsh')
const arr = [signNum || 0, statue || 1] const arr = [signNum || 0, statue || 1]
let tmpList: number[] = []; let tmpList: number[] = [];
tmpList.push(NumberToByteArray(arr[0], 1 * 8)[0]) tmpList.push(NumberToByteArray(Number(arr[0]), 1 * 8)[0])
tmpList.push(NumberToByteArray(arr[1], 1 * 8)[0]) tmpList.push(NumberToByteArray(Number(arr[1]), 1 * 8)[0])
const str = lsh || '0000000000000' const str = lsh || '0000000000000'
for (let i = 0; i < str.length; i++) { for (let i = 0; i < str.length; i++) {
tmpList.push(NumberToByteArray(str.charCodeAt(i), 1 * 8)[0]) tmpList.push(NumberToByteArray(str.charCodeAt(i), 1 * 8)[0])
@ -453,8 +457,8 @@ struct Index {
async onPageShow() { async onPageShow() {
console.log('ttttt', 1111) console.log('ttttt', 1111)
this.singlePlay = AppStorage.get('singlePlay') this.singlePlay = AppStorage.get<boolean>('singlePlay')
this.baseInfo = AppStorage.get('baseInfo') as BaseInfoType this.baseInfo = AppStorage.get<BaseInfoType>('baseInfo')
// await this.userAuth(); // await this.userAuth();
UseAuth(this.context).then(() => { UseAuth(this.context).then(() => {
this.initParams() this.initParams()
@ -504,12 +508,12 @@ struct Index {
await GetCarInfo() await GetCarInfo()
await getUDP2(this.context, false) await getUDP2(this.context, false)
getTCP() getTCP()
this.carInfo = AppStorage.get('carInfo') this.carInfo = AppStorage.get<CarInfoType>('carInfo')
this.deviceId = this.carInfo.carNo this.deviceId = this.carInfo.carNo
// await setCurrentTime(); // await setCurrentTime();
await SetCurrentTime() await SetCurrentTime()
this.timeInfo = AppStorage.get('timeInfo') this.timeInfo = AppStorage.get<TimeSynchronizationRspBody>('timeInfo')
const distanceClass = AppStorage.get('distanceClass') as boolean const distanceClass = AppStorage.get<boolean>('distanceClass')
if (!distanceClass) { if (!distanceClass) {
const distanceClass = new GetDistance(this.context) const distanceClass = new GetDistance(this.context)
await distanceClass.initFolder() await distanceClass.initFolder()

View File

@ -16,7 +16,10 @@ import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
import { BusinessError } from '@ohos.base'; import { BusinessError } from '@ohos.base';
import systemTime from '@ohos.systemTime'; import systemTime from '@ohos.systemTime';
import { VideoConfigData } from '../../mock'; import { VideoConfigData } from '../../mock';
ontext: common.UIAbilityContext): Promise<string> { import FileUtils from '../../utils/FileUtils';
//获取设备信息
export async function GetDeviceInfo(context: common.UIAbilityContext): Promise<string> {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
const fileUtil = new FileUtils(context) const fileUtil = new FileUtils(context)
const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/deviceNo.txt'); const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/deviceNo.txt');
@ -40,7 +43,7 @@ export async function GetCarInfo() {
let date = new Date(); let date = new Date();
let params: ObtainCarExamInfoParams = { let params: ObtainCarExamInfoParams = {
time: dayTs(date).format("YYYY-MM-DD HH:mm:ss"), time: dayTs(date).format("YYYY-MM-DD HH:mm:ss"),
deviceNo: AppStorage.get('deviceNo') deviceNo: AppStorage.get<string>('deviceNo')
}; };
let res: ApiResponseType = await obtainCarExamInfo(params) let res: ApiResponseType = await obtainCarExamInfo(params)
if (res.obtainCarExamInfoRsp.body) { if (res.obtainCarExamInfoRsp.body) {
@ -87,7 +90,7 @@ export async function SetCurrentTime(): Promise<void> {
judgeVersion: baseInfo.judgeVersion judgeVersion: baseInfo.judgeVersion
} }
let res: ApiResponseType = await timeSynchronization(params); let res: ApiResponseType = await timeSynchronization(params);
AppStorage.setOrCreate('timeInfo', res.timeSynchronizationRsp.body) AppStorage.setOrCreate<ApiResponseType.timeSynchronizationRsp.body>('timeInfo', res.timeSynchronizationRsp.body)
let currentTime = res.timeSynchronizationRsp.head.time; let currentTime = res.timeSynchronizationRsp.head.time;
let times = new Date(currentTime).getTime(); let times = new Date(currentTime).getTime();
try { try {

View File

@ -159,8 +159,8 @@ struct Index {
async aboutToAppear() { async aboutToAppear() {
const time = await GetCurrentTime() const time = await GetCurrentTime()
this.carInfo = AppStorage.get('carInfo') this.carInfo = AppStorage.get<CarInfoType>('carInfo')
this.singlePlay = AppStorage.get('singlePlay') this.singlePlay = AppStorage.get<boolean>('singlePlay')
this.startTime = time.split(' ')[1] this.startTime = time.split(' ')[1]
this.startFullTime = await GetCurrentTime(1); this.startFullTime = await GetCurrentTime(1);
// this.startHourTime = await getCurrentHourTime() // this.startHourTime = await getCurrentHourTime()

View File

@ -220,9 +220,9 @@ struct UserInfo {
this.ksksLimit = false this.ksksLimit = false
this.currentUser = EmptyCandidateObject this.currentUser = EmptyCandidateObject
this.filePhoto = new FilePhoto(this.context); this.filePhoto = new FilePhoto(this.context);
this.singlePlay = AppStorage.get('singlePlay') this.singlePlay = AppStorage.get<boolean>('singlePlay')
this.examinerLoginInfo = AppStorage.get('examinerLoginInfo') this.examinerLoginInfo = AppStorage.get<ExaminerLoginInfo>('examinerLoginInfo')
this.carInfo = AppStorage.get('carInfo') this.carInfo = AppStorage.get<CarInfoType>('carInfo')
//语音功能on //语音功能on
// new WebRTCVoice(this.context); // new WebRTCVoice(this.context);
//初始化数据 //初始化数据
@ -485,7 +485,7 @@ struct UserInfo {
//考点端查询缺考指令内容消息请求 //考点端查询缺考指令内容消息请求
getqkFn() { getqkFn() {
let tmpList: Array<number> = []; let tmpList: Array<number> = [];
tmpList.push(NumberToByteArray(AppStorage.get('signNum'), 1 * 8)[0]) tmpList.push(NumberToByteArray(AppStorage.get<number>('signNum'), 1 * 8)[0])
const param: QKParamType = { const param: QKParamType = {
id: 41, id: 41,
list: tmpList, list: tmpList,
@ -1275,7 +1275,7 @@ struct UserInfo {
getqkFlag: $getqkFlag, getqkFlag: $getqkFlag,
faceCatchImg: $faceCatchImg, faceCatchImg: $faceCatchImg,
showFaceCompare: $showFaceCompare, showFaceCompare: $showFaceCompare,
lsh: AppStorage.get('lsh'), lsh: AppStorage.get<string>('lsh'),
}) })
} }
if (this.qkFlag) { if (this.qkFlag) {

View File

@ -174,7 +174,7 @@ export default struct FaceCompare {
async aboutToAppear() { async aboutToAppear() {
const fileUtil = new FileUtils(this.context) const fileUtil = new FileUtils(this.context)
this.carInfo = AppStorage.get('carInfo') this.carInfo = AppStorage.get<CarInfoType>('carInfo')
this.fileUtil = fileUtil this.fileUtil = fileUtil
this.getVideoConfig() this.getVideoConfig()
} }
@ -187,7 +187,7 @@ export default struct FaceCompare {
getqkFn() { getqkFn() {
let tmpList: number[] = []; let tmpList: number[] = [];
tmpList.push(NumberToByteArray(AppStorage.get('signNum'), 1 * 8)[0]) tmpList.push(NumberToByteArray(AppStorage.get <number>('signNum'), 1 * 8)[0])
const param: ParamType = { const param: ParamType = {
id: 41, id: 41,
list: tmpList, list: tmpList,

View File

@ -81,8 +81,8 @@ export default struct DeductedPopup {
private avPlayer: VoiceAnnounce private avPlayer: VoiceAnnounce
async aboutToAppear() { async aboutToAppear() {
this.carInfo = AppStorage.get('carInfo') this.carInfo = AppStorage.get<CarInfoType>('carInfo')
this.singlePlay = AppStorage.get('singlePlay') this.singlePlay = AppStorage.get<boolean>('singlePlay')
this.avPlayer = new VoiceAnnounce(); this.avPlayer = new VoiceAnnounce();
this.judgeTask = new JudgeTask(); this.judgeTask = new JudgeTask();
const mediaTest = new FilePhoto(this.context); const mediaTest = new FilePhoto(this.context);

View File

@ -48,6 +48,7 @@ import { Array2Byte, convertGpsCoord2, deepClone, fillZero, string2Bytes } from
import { GetCurrentTime, StringToASCII } from '../../utils/Common'; import { GetCurrentTime, StringToASCII } from '../../utils/Common';
import UsbService from '../../utils/USB'; import UsbService from '../../utils/USB';
import FileUtils from '../../utils/FileUtils'; import FileUtils from '../../utils/FileUtils';
import { BaseInfoType, CarInfoType } from '../../model';
const judgeTag = 'SURENJUN_JUDGE' const judgeTag = 'SURENJUN_JUDGE'
@ -68,7 +69,7 @@ export default class Judge {
} }
//上传无锡所过程数据 //上传无锡所过程数据
uploadProgressData = async () => { uploadProgressData = async () => {
const carInfo = AppStorage.get('carInfo') const carInfo = AppStorage.get<CarInfoType>('carInfo')
const { judgeUI, fileUtil, fileLog } = this; const { judgeUI, fileUtil, fileLog } = this;
const { idCard, startFullTime } = judgeUI const { idCard, startFullTime } = judgeUI
const { carId, examinationRoomId } = carInfo const { carId, examinationRoomId } = carInfo
@ -119,7 +120,7 @@ export default class Judge {
} }
// 处理特殊参数配置 // 处理特殊参数配置
handleSEP = async (code: number) => { handleSEP = async (code: number) => {
const carInfo = AppStorage.get('carInfo') const carInfo = AppStorage.get<CarInfoType>('carInfo')
const { const {
judgeUI:{ judgeUI:{
judgeConfigObj judgeConfigObj
@ -239,7 +240,7 @@ export default class Judge {
private filePhoto: FilePhoto private filePhoto: FilePhoto
// 过程照片拍照 // 过程照片拍照
getPhoto = async (empty?: boolean) => { getPhoto = async (empty?: boolean) => {
const singlePlay: boolean = AppStorage.get('singlePlay') const singlePlay: boolean = AppStorage.get<boolean>('singlePlay')
//单机模式返回空照片 //单机模式返回空照片
if (singlePlay) { if (singlePlay) {
return '' return ''
@ -466,7 +467,7 @@ export default class Judge {
if (!this.isExamEnd) { if (!this.isExamEnd) {
await examJudgeRealExam(plcData) await examJudgeRealExam(plcData)
} }
let udpIndex = AppStorage.get('udpIndex') as number; let udpIndex = AppStorage.get<number>('udpIndex');
let [prevJd, preWd] = [0, 0] let [prevJd, preWd] = [0, 0]
if (udpIndex % 5 === 0 && !this.isUdpEnd) { if (udpIndex % 5 === 0 && !this.isUdpEnd) {
// TODO UPD缺失 // TODO UPD缺失
@ -521,7 +522,7 @@ export default class Judge {
private isJudgeDisConnect: boolean; private isJudgeDisConnect: boolean;
// 项目开始接口同步 // 项目开始接口同步
beginProject = async (ksxm) => { beginProject = async (ksxm) => {
const carInfo = AppStorage.get('carInfo'); const carInfo = AppStorage.get<CarInfoType>('carInfo');
const { examSubject, plateNo } = carInfo; const { examSubject, plateNo } = carInfo;
const { judgeUI, fileLog, getSbbm, xmxh, filePath } = this; const { judgeUI, fileLog, getSbbm, xmxh, filePath } = this;
const { lsh, idCard, serialNumber, projectsObj, ksdd, kslx, xldm } = judgeUI const { lsh, idCard, serialNumber, projectsObj, ksdd, kslx, xldm } = judgeUI
@ -557,7 +558,7 @@ export default class Judge {
} }
// 项目结束接口同步 // 项目结束接口同步
endProject = async (ksxm) => { endProject = async (ksxm) => {
const carInfo = AppStorage.get('carInfo'); const carInfo = AppStorage.get<CarInfoType>('carInfo');
const { examSubject, plateNo, carNo } = carInfo; const { examSubject, plateNo, carNo } = carInfo;
const { judgeUI, fileLog, getSbxh, xmxh, getSbbm, filePath } = this; const { judgeUI, fileLog, getSbxh, xmxh, getSbbm, filePath } = this;
const { lsh, idCard, serialNumber, projectsObj, cdsbInfoObj, ksdd, kslx, xldm, } = judgeUI const { lsh, idCard, serialNumber, projectsObj, cdsbInfoObj, ksdd, kslx, xldm, } = judgeUI
@ -623,7 +624,7 @@ export default class Judge {
const time = await GetCurrentTime(); const time = await GetCurrentTime();
const { judgeUI, plcData, getPhoto, fileLog, filePath } = this; const { judgeUI, plcData, getPhoto, fileLog, filePath } = this;
const photoBase64 = await getPhoto(); const photoBase64 = await getPhoto();
const carInfo = AppStorage.get('carInfo'); const carInfo = AppStorage.get<CarInfoType>('carInfo');
const { examSubject, plateNo, carNo } = carInfo; const { examSubject, plateNo, carNo } = carInfo;
const { lsh, idCard, serialNumber, projectsObj, ksdd, judgeConfigObj } = judgeUI; const { lsh, idCard, serialNumber, projectsObj, ksdd, judgeConfigObj } = judgeUI;
const { sensor, gps } = plcData const { sensor, gps } = plcData
@ -703,7 +704,7 @@ export default class Judge {
// 获取评判初始化数据 // 获取评判初始化数据
getJudgeInitData = async () => { getJudgeInitData = async () => {
const { getModelData, getKm3JudgeInitConfig } = this const { getModelData, getKm3JudgeInitConfig } = this
const carInfo = AppStorage.get('carInfo'); const carInfo = AppStorage.get<CarInfoType>('carInfo');
const { examSubject, plateNo, carId } = carInfo; const { examSubject, plateNo, carId } = carInfo;
const judgeUI = this.judgeUI const judgeUI = this.judgeUI
const { projectsObj, itemInfoObj, markRuleListObj, carType, carName, systemparmArr, carinfoArr } = judgeUI const { projectsObj, itemInfoObj, markRuleListObj, carType, carName, systemparmArr, carinfoArr } = judgeUI
@ -723,7 +724,7 @@ export default class Judge {
const sdkver = await examJudgeVersion(); const sdkver = await examJudgeVersion();
const initInfo = { const initInfo = {
sdkver, sdkver,
appver: AppStorage.get('baseInfo').version, appver: AppStorage.get<BaseInfoType>('baseInfo').version,
kskm: examSubject * 1, kskm: examSubject * 1,
kchp: plateNo, kchp: plateNo,
kchm: carId * 1, kchm: carId * 1,
@ -1104,7 +1105,7 @@ export default class Judge {
case 5: case 5:
console.info(judgeTag, '考试结束') console.info(judgeTag, '考试结束')
//关闭录像 //关闭录像
const singlePlay = AppStorage.get('singlePlay') as boolean const singlePlay = AppStorage.get<boolean>('singlePlay')
if (!singlePlay) { if (!singlePlay) {
await endRecordVideo(this.videoData) await endRecordVideo(this.videoData)
} }
@ -1131,7 +1132,7 @@ export default class Judge {
} }
// 考试扣分 // 考试扣分
pointsDedute = async (ksxm, kf) => { pointsDedute = async (ksxm, kf) => {
const carInfo = AppStorage.get('carInfo'); const carInfo = AppStorage.get<CarInfoType>('carInfo');
const { examSubject, plateNo, carNo } = carInfo; const { examSubject, plateNo, carNo } = carInfo;
const { judgeUI, getProjectInfo, fileLog, xmmcSingleCode, xmmcEndCode, filePath } = this; const { judgeUI, getProjectInfo, fileLog, xmmcSingleCode, xmmcEndCode, filePath } = this;
const { lsh, idCard, serialNumber, ksdd, projectsObj } = judgeUI const { lsh, idCard, serialNumber, ksdd, projectsObj } = judgeUI
@ -1212,7 +1213,7 @@ export default class Judge {
const { judgeConfigObj, examSubject, isAllProjectsEnd, totalScore, passingScore } = judgeUI; const { judgeConfigObj, examSubject, isAllProjectsEnd, totalScore, passingScore } = judgeUI;
//计算考试分数 //计算考试分数
// this.judgeUI.totalScore = isAllProjectsEnd ? totalScore : 0; // this.judgeUI.totalScore = isAllProjectsEnd ? totalScore : 0;
const singlePlay = AppStorage.get('singlePlay') const singlePlay = AppStorage.get<boolean>('singlePlay')
const param302 = judgeConfigObj['302']; const param302 = judgeConfigObj['302'];
// globalThis.windowClass.setWindowSystemBarEnable(['navigation']) // globalThis.windowClass.setWindowSystemBarEnable(['navigation'])
@ -1261,8 +1262,8 @@ export default class Judge {
} }
// 考试结束 // 考试结束
public endExam = async (isManual?: Boolean) => { public endExam = async (isManual?: Boolean) => {
const carInfo = AppStorage.get('carInfo'); const carInfo = AppStorage.get<CarInfoType>('carInfo');
const singlePlay = AppStorage.get('singlePlay') const singlePlay = AppStorage.get<boolean>('singlePlay')
const { examSubject, plateNo } = carInfo; const { examSubject, plateNo } = carInfo;
const { const {
judgeUI, judgeUI,
@ -1447,7 +1448,7 @@ export default class Judge {
} }
// 消息心跳发送 // 消息心跳发送
getMessageHeartbeat = async (isEnd?: Boolean) => { getMessageHeartbeat = async (isEnd?: Boolean) => {
const carInfo = AppStorage.get('carInfo'); const carInfo = AppStorage.get<CarInfoType>('carInfo');
const { examSubject, plateNo, ksyh } = carInfo; const { examSubject, plateNo, ksyh } = carInfo;
const { const {
judgeUI, judgeUI,
@ -1464,7 +1465,7 @@ export default class Judge {
getSbxh, getSbxh,
fileLog, fileLog,
} = this; } = this;
const singlePlay = AppStorage.get('singlePlay') const singlePlay = AppStorage.get<boolean>('singlePlay')
const { lsh, startHourTime, totalScore, examTime, judgeConfigObj } = judgeUI; const { lsh, startHourTime, totalScore, examTime, judgeConfigObj } = judgeUI;
const { const {
fourInOneScreen:{ fourInOneScreen:{

View File

@ -2,6 +2,7 @@ import { testMarkRules, testRealExam } from '../dataTest/index';
import systemTime from '@ohos.systemDateTime'; import systemTime from '@ohos.systemDateTime';
import { Array2Byte } from './Common'; import { Array2Byte } from './Common';
import { CarInfoType } from '../../../model';
//获取本地扣分项 //获取本地扣分项
export const getTestMarkRules = () => { export const getTestMarkRules = () => {
@ -110,7 +111,7 @@ export function getKmProjectVoice(
lane, lane,
xmxh xmxh
) { ) {
const carInfo = AppStorage.get('carInfo'); const carInfo = AppStorage.get<CarInfoType>('carInfo');
const { examSubject } = carInfo; const { examSubject } = carInfo;
const param506Str = judgeConfig['506']?.split(',') || []; const param506Str = judgeConfig['506']?.split(',') || [];
const param512Str = judgeConfig['512']?.split(',') || []; const param512Str = judgeConfig['512']?.split(',') || [];
@ -206,7 +207,7 @@ export function promptWxCode(
) { ) {
let toast = ''; let toast = '';
const singlePlay = AppStorage.get('singlePlay') const singlePlay = AppStorage.get<boolean>('singlePlay')
if (singlePlay) { if (singlePlay) {
return return
} }

View File

@ -21,7 +21,7 @@ export default class JudgeImg {
} }
async init() { async init() {
const isJudgeInitBool = AppStorage.get('isJudgeInitBool'); const isJudgeInitBool = AppStorage.get<boolean>('isJudgeInitBool');
const { judgeUI } = this; const { judgeUI } = this;
//TODO 临时处理 //TODO 临时处理

View File

@ -1,14 +1,12 @@
import media from '@ohos.multimedia.media'; import media from '@ohos.multimedia.media';
import webSocket from '@ohos.net.webSocket'; import webSocket from '@ohos.net.webSocket';
import camera from '@ohos.multimedia.camera'; import prompt from '@ohos.prompt';
import common from '@ohos.app.ability.common';
import ethernet from '@ohos.net.ethernet';
import prompt from '@ohos.prompt'
const TAG_RTC: string = '[SURENJUN_RTC]'; const TAG_RTC: string = '[SURENJUN_RTC]';
const carNo = AppStorage.get('carInfo').carNo; const carNo = AppStorage.get<CarInfoType>('carInfo').carNo;
const WS_SERVER = `ws://192.168.36.9:5000/ws/KM2-C${carNo}/2`; 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.nirbheek.in:8443';
// const WS_SERVER = 'wss://webrtc.youzhi.life:8443'; // const WS_SERVER = 'wss://webrtc.youzhi.life:8443';
export enum WebRtcState { export enum WebRtcState {
@ -25,18 +23,90 @@ export enum WebRtcState {
} }
export default class WebRtcModel { 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 待替换 //TODO 待替换
private peerId: string = `KM2-C${carNo}`; private peerId: string = `KM2-C${carNo}`;
public isConnected: boolean = false;
private remoteUserId: string = ''; private remoteUserId: string = '';
private roomId: string = '';
// private state: number = WebRtcState.UNKNOWN; // private state: number = WebRtcState.UNKNOWN;
private roomId: string = '';
private context: any = undefined; private context: any = undefined;
private ws : webSocket.WebSocket = undefined; private ws: webSocket.WebSocket = undefined;
private webrtc : media.WebRtc = 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; 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) { initWebSocket(ourId: string, handleStateChange: (state, message) => void) {
@ -57,30 +127,49 @@ export default class WebRtcModel {
console.info(TAG_RTC, '信令服务器连接失败'); console.info(TAG_RTC, '信令服务器连接失败');
}); });
this.ws.on('message', (err, value:string) => { this.ws.on('message', (err, value: string) => {
const {acceptInvited,receiveIce,sendAnswer,receiveSdp,disconnect} = this; const { acceptInvited, receiveIce, sendAnswer, receiveSdp, disconnect } = this;
const socketMessage = JSON.parse(value); 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]) console.info(TAG_RTC, 'receive message =>' + eventName.split('__')[1])
switch (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': case 'new_peer':
//添加ice证书 //添加ice证书
case 'ice_candidate':receiveIce(candidate);break; case 'ice_candidate':
receiveIce(candidate);
break;
case 'answer': case 'answer':
// sendAnswer() // sendAnswer()
case 'offer':receiveSdp({type:'offer',sdp});break; case 'offer':
receiveSdp({
type: 'offer', sdp
});
break;
default: default:
} }
@ -149,7 +238,11 @@ export default class WebRtcModel {
console.info(TAG_RTC, 'webrtc prepare'); 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) { async connect(peerId: string) {
@ -163,7 +256,7 @@ export default class WebRtcModel {
this.sendMessage('SESSION ' + this.peerId) this.sendMessage('SESSION ' + this.peerId)
} }
public disconnect = async ()=> { public disconnect = async () => {
console.info(TAG_RTC, 'disconnect'); console.info(TAG_RTC, 'disconnect');
if (this.ws) { if (this.ws) {
this.webrtc.close() this.webrtc.close()
@ -174,78 +267,17 @@ export default class WebRtcModel {
}); });
const webRtcModel = new WebRtcModel() const webRtcModel = new WebRtcModel()
webRtcModel.setContext(this.context); webRtcModel.setContext(this.context);
webRtcModel.initWebSocket('', ()=>{}); webRtcModel.initWebSocket('', () => {
});
webRtcModel.initRtc(); webRtcModel.initRtc();
} }
} }
sendOffer = async ()=> { sendMessage = async (message: string) => {
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) => {
this.ws.send(message, (error, success) => { this.ws.send(message, (error, success) => {
if (success){ if (success) {
console.info(TAG_RTC, 'ws send success' + message) console.info(TAG_RTC, 'ws send success' + message)
}else{ } else {
console.error(TAG_RTC, 'ws send error: ' + error); console.error(TAG_RTC, 'ws send error: ' + error);
} }
}); });
@ -256,28 +288,13 @@ export default class WebRtcModel {
return await this.ws.close(); return await this.ws.close();
} }
receiveSdp = async (sdp) => { receiveIce = (ice) => {
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) => {
try { try {
this.webrtc.addIceCandidate({ this.webrtc.addIceCandidate({
candidate:ice, candidate: ice,
}); });
}catch (e){ } catch (e) {
console.info(TAG_RTC,JSON.stringify(e)) console.info(TAG_RTC, JSON.stringify(e))
} }
} }
@ -294,16 +311,16 @@ export default class WebRtcModel {
} }
//接受对方的邀请 //接受对方的邀请
acceptInvited = (fromId:string,roomId:string) =>{ acceptInvited = (fromId: string, roomId: string) => {
const {sendMessage,peerId} = this; const { sendMessage, peerId } = this;
this.remoteUserId = fromId; this.remoteUserId = fromId;
this.roomId = roomId this.roomId = roomId
sendMessage(JSON.stringify({ sendMessage(JSON.stringify({
eventName:'__join', eventName: '__join',
data:{ data: {
userID:peerId, userID: peerId,
room:roomId room: roomId
} }
})) }))

View File

@ -108,7 +108,7 @@ class CenterUDPClient extends UdpClient {
try { try {
const fileUtil = new FileUtils(context) const fileUtil = new FileUtils(context)
const data = await fileUtil.readFile("" + '/config/ipConfig.txt'); const data = await fileUtil.readFile("" + '/config/ipConfig.txt');
const carInfo: CarInfoType = AppStorage.get('carInfo') const carInfo: CarInfoType = AppStorage.get<CarInfoType>('carInfo')
if (data?.length > 0) { if (data?.length > 0) {
const result: IPConfig = JSON.parse(data) const result: IPConfig = JSON.parse(data)
this.create(result.udplocalIp, '8800', carInfo?.udpAddress, carInfo?.messagePort) this.create(result.udplocalIp, '8800', carInfo?.udpAddress, carInfo?.messagePort)

View File

@ -61,7 +61,7 @@ export default class GetDistance {
//上传行驶里程数据 //上传行驶里程数据
uploadData = async () => { uploadData = async () => {
setInterval(() => { setInterval(() => {
const { carId } = AppStorage.get('carInfo'); const { carId } = AppStorage.get<CarInfoType>('carInfo');
const { date, timeStr, totalDistance } = this; const { date, timeStr, totalDistance } = this;
return return
//"carid":"1001","startTime":"2024-08-24 08:09:01","time":"111233", "mileage":"1222" //"carid":"1001","startTime":"2024-08-24 08:09:01","time":"111233", "mileage":"1222"