Compare commits
	
		
			No commits in common. "5354ec983c167fb8acd43263609c9830cb509555" and "27583fb77d601122daf56368778c4fd747c9c0b9" have entirely different histories.
		
	
	
		
			5354ec983c
			...
			27583fb77d
		
	
		
@ -1,15 +1,13 @@
 | 
			
		||||
import request from '../utils/Request'
 | 
			
		||||
import http from '@ohos.net.http'
 | 
			
		||||
import request from "../utils/Request"
 | 
			
		||||
import http from "@ohos.net.http"
 | 
			
		||||
import {
 | 
			
		||||
  ApiResponseType,
 | 
			
		||||
  InitializeTheCentralTableType,
 | 
			
		||||
  InitModelParams,
 | 
			
		||||
  InitModelResponse,
 | 
			
		||||
  ObtainCarExamInfoParams,
 | 
			
		||||
  ResponseDataType,
 | 
			
		||||
  TimeSynchronizationParams,
 | 
			
		||||
  TimeSynchronizationRspBody
 | 
			
		||||
} from '../model'
 | 
			
		||||
} from "../model"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//同步时间
 | 
			
		||||
@ -111,9 +109,9 @@ export async function initCenterCacheByKSPT(params: object, url: string) {
 | 
			
		||||
 | 
			
		||||
//从参数平台获取模型
 | 
			
		||||
// TODO 类型需要补全
 | 
			
		||||
export async function initEsModel(params: InitModelParams) {
 | 
			
		||||
export async function initEsModel(params: ESObject) {
 | 
			
		||||
  const timeInfo: TimeSynchronizationRspBody = AppStorage.get<TimeSynchronizationRspBody>('timeInfo')
 | 
			
		||||
  return await request<InitModelResponse>({
 | 
			
		||||
  return await request<object>({
 | 
			
		||||
    url: '/para/initEsModel.ws',
 | 
			
		||||
    data: params,
 | 
			
		||||
    method: http.RequestMethod.POST,
 | 
			
		||||
 | 
			
		||||
@ -1,11 +1,10 @@
 | 
			
		||||
import request from '../utils/Request'
 | 
			
		||||
import http from '@ohos.net.http'
 | 
			
		||||
import { UserLoginType } from '../model/ExaminerLogin'
 | 
			
		||||
import { ApiResponseType } from '../model'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export async function examinerLogin(params: UserLoginType) {
 | 
			
		||||
  return request<ApiResponseType>({
 | 
			
		||||
  return request({
 | 
			
		||||
    url: '/der2/services/exam/examinerLogin.ws',
 | 
			
		||||
    data: `<?xml version="1.0" encoding="UTF-8" ?>
 | 
			
		||||
                <examinerLoginReq>
 | 
			
		||||
 | 
			
		||||
@ -2,20 +2,21 @@ import UIAbility from '@ohos.app.ability.UIAbility';
 | 
			
		||||
import hilog from '@ohos.hilog';
 | 
			
		||||
import window from '@ohos.window';
 | 
			
		||||
import { GlobalConfig } from '../config/global';
 | 
			
		||||
import { initTable } from '../common/service/initable';
 | 
			
		||||
import Want from '@ohos.app.ability.Want';
 | 
			
		||||
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
 | 
			
		||||
import { BaseInfoType, CarInfoType, ExaminerInfoType } from '../model';
 | 
			
		||||
import { tcpUtil } from '../utils/TcpRequest';
 | 
			
		||||
import DB from '../utils/DbSql';
 | 
			
		||||
import { DrivingDataStorage } from '../utils/business/DrivingDataStorage';
 | 
			
		||||
import { InitTable } from '../utils/table/Operation';
 | 
			
		||||
 | 
			
		||||
export default class EntryAbility extends UIAbility {
 | 
			
		||||
  async onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
 | 
			
		||||
    try {
 | 
			
		||||
      console.log("sql first")
 | 
			
		||||
      await DB.init(this.context)
 | 
			
		||||
      await InitTable()
 | 
			
		||||
      // 创建一个user表
 | 
			
		||||
      await initTable()
 | 
			
		||||
      console.log("sql first success")
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
      console.error('sql first error', e)
 | 
			
		||||
 | 
			
		||||
@ -117,12 +117,10 @@ export interface CarInfoType {
 | 
			
		||||
  messagePort?: string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// TODO
 | 
			
		||||
export interface ExaminerInfoType {
 | 
			
		||||
  code?: string
 | 
			
		||||
  ksyxm?: string
 | 
			
		||||
  name?: string
 | 
			
		||||
  sfzmhm?: string
 | 
			
		||||
  statusRgpp?: string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 一些运行配置
 | 
			
		||||
 | 
			
		||||
@ -14,26 +14,6 @@ export interface ApiResponseType {
 | 
			
		||||
 | 
			
		||||
  // 缺考
 | 
			
		||||
  examinationStuAbsentRsp?: ExaminationStuAbsentRsp
 | 
			
		||||
  //   考官登录
 | 
			
		||||
  examinerLoginRsp?: ExaminerLoginRsp
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface ExaminerLoginRsp {
 | 
			
		||||
  head: Head
 | 
			
		||||
  body: ExaminerLoginInfo
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface ExaminerLoginInfo {
 | 
			
		||||
  carId?: string;
 | 
			
		||||
  examinationRoomId?: string;
 | 
			
		||||
  examinerName?: string;
 | 
			
		||||
  examinerPwd?: string;
 | 
			
		||||
  username?: string;
 | 
			
		||||
  kgxm?: string;
 | 
			
		||||
  ksyh?: string;
 | 
			
		||||
  plateNo?: string
 | 
			
		||||
  isNeedCheck?: string
 | 
			
		||||
  examSubject?: string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface ExaminationStuAbsentRsp {
 | 
			
		||||
@ -108,32 +88,10 @@ export interface TimeSynchronizationParams {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface Head {
 | 
			
		||||
  resultCode?: string;
 | 
			
		||||
  time?: string;
 | 
			
		||||
  resultMessage?: string;
 | 
			
		||||
  checkCode?: string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface InitModelParams {
 | 
			
		||||
  head: Head;
 | 
			
		||||
  body: InitModelBody;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface InitModelResponse {
 | 
			
		||||
  body: InitModelResponseBody
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface InitModelResponseBody {
 | 
			
		||||
  // TODO
 | 
			
		||||
  ES_MODEL: ESObject
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface InitModelBody {
 | 
			
		||||
  rtkType?: string;
 | 
			
		||||
  rspType?: string;
 | 
			
		||||
  paraKdid?: string;
 | 
			
		||||
  examinationRoomId?: string;
 | 
			
		||||
  carMac?: string;
 | 
			
		||||
  resultCode: string;
 | 
			
		||||
  time: string;
 | 
			
		||||
  resultMessage: string;
 | 
			
		||||
  checkCode: string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// -----new-----
 | 
			
		||||
@ -162,6 +120,18 @@ export interface ResponseDataType {
 | 
			
		||||
  initializationRsp?: ImageCompareRsp
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface ExaminerLoginInfo {
 | 
			
		||||
  carId?: string;
 | 
			
		||||
  examinationRoomId?: string;
 | 
			
		||||
  examinerName?: string;
 | 
			
		||||
  examinerPwd?: string;
 | 
			
		||||
  username?: string;
 | 
			
		||||
  kgxm?: string;
 | 
			
		||||
  ksyh?: string;
 | 
			
		||||
  plateNo?: string
 | 
			
		||||
  isNeedCheck?: string
 | 
			
		||||
  examSubject?: string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface SpzdType {
 | 
			
		||||
  carId?: string;
 | 
			
		||||
 | 
			
		||||
@ -180,7 +180,7 @@ struct Index {
 | 
			
		||||
 | 
			
		||||
  getPLCInfo() {
 | 
			
		||||
    const that = this
 | 
			
		||||
    ObtainSignalData.getData((msg) => {
 | 
			
		||||
    ObtainSignalData.getData((msg)=>{
 | 
			
		||||
      if (!this.breakFlag) {
 | 
			
		||||
        return
 | 
			
		||||
      }
 | 
			
		||||
@ -220,7 +220,7 @@ struct Index {
 | 
			
		||||
        return
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (this.warnFlagTip.get(that.index).length > 1) {
 | 
			
		||||
      if (this.warnFlagTip[that.index].length > 1) {
 | 
			
		||||
        if (that.stachValue[that.index] != that.signArr[that.realNum[that.index]]) {
 | 
			
		||||
          that.warnFlag[that.index] = '2'
 | 
			
		||||
        }
 | 
			
		||||
@ -344,15 +344,15 @@ struct Index {
 | 
			
		||||
    this.passArray[this.index] = true
 | 
			
		||||
    this.passArray = JSON.parse(JSON.stringify(this.passArray))
 | 
			
		||||
    this.subFlag = true
 | 
			
		||||
    let name: string = this.warnFlagTip.get(this.index)[0]
 | 
			
		||||
    if (this.warnFlagTip.get(this.index).length == 1) {
 | 
			
		||||
    let name: string = this.warnFlagTip[this.index][0]
 | 
			
		||||
    if (this.warnFlagTip[this.index].length == 1) {
 | 
			
		||||
      this.vocObj.playAudio({
 | 
			
		||||
        type: 1,
 | 
			
		||||
        name,
 | 
			
		||||
      })
 | 
			
		||||
    } else if (this.warnFlagTip.get(this.index).length == 2) {
 | 
			
		||||
    } else if (this.warnFlagTip[this.index].length == 2) {
 | 
			
		||||
      if (this.signArr[this.realNum[this.index]] && this.signArr[this.realNum[this.index]] != '0') {
 | 
			
		||||
        name = this.warnFlagTip.get(this.index)[1]
 | 
			
		||||
        name = this.warnFlagTip[this.index][1]
 | 
			
		||||
        this.vocObj.playAudio({
 | 
			
		||||
          type: 1,
 | 
			
		||||
          name,
 | 
			
		||||
 | 
			
		||||
@ -6,7 +6,7 @@ import imageBtn from './compontents/imageBtn';
 | 
			
		||||
import { UserLoginType } from '../model/ExaminerLogin';
 | 
			
		||||
import { BusinessError } from '@ohos.base';
 | 
			
		||||
import { examinerLogin } from '../api/login';
 | 
			
		||||
import { ApiResponseType, CarInfoType, ExaminerLoginInfo } from '../model/index';
 | 
			
		||||
import { CarInfoType, ExaminerLoginInfo } from '../model/index';
 | 
			
		||||
import { CryptoJS } from '@ohos/crypto-js';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -108,7 +108,7 @@ struct Index {
 | 
			
		||||
                    this.limit = true
 | 
			
		||||
                    try {
 | 
			
		||||
                      // TODO
 | 
			
		||||
                      examinerLogin(param).then((res: ApiResponseType) => {
 | 
			
		||||
                      examinerLogin(param).then((res: ESObject) => {
 | 
			
		||||
                        // AppStorage.setOrCreate('examinerInfo', res?.examinerLoginRsp?.body)
 | 
			
		||||
                        console.log('res?.examinerLoginRsp?.head?.resultCode', res?.examinerLoginRsp?.head?.resultCode,
 | 
			
		||||
                          JSON.stringify(res))
 | 
			
		||||
@ -134,10 +134,12 @@ struct Index {
 | 
			
		||||
                        examinerLoginInfo.username = this.inputTextArr[0]
 | 
			
		||||
                        AppStorage.setOrCreate<ExaminerLoginInfo>('examinerInfo', examinerLoginInfo)
 | 
			
		||||
                      }).catch((err: BusinessError) => {
 | 
			
		||||
                        console.log('jiangsong12', JSON.stringify(err))
 | 
			
		||||
                        this.errorDialog.close()
 | 
			
		||||
                        this.limit = false
 | 
			
		||||
                      })
 | 
			
		||||
                    } catch (error) {
 | 
			
		||||
                    } catch (eroor) {
 | 
			
		||||
                      console.log('erroreee')
 | 
			
		||||
                      this.errorDialog.close()
 | 
			
		||||
                      this.limit = false
 | 
			
		||||
                    }
 | 
			
		||||
@ -189,9 +191,12 @@ struct Index {
 | 
			
		||||
 | 
			
		||||
  aboutToAppear() {
 | 
			
		||||
    this.url = ''
 | 
			
		||||
    console.info('ExmainerLogin aboutToAppear');
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  onPageShow() {
 | 
			
		||||
    // this.vocObj = new voiceService(async (status, val, next) => {
 | 
			
		||||
    // });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  outClick() {
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,8 @@
 | 
			
		||||
import common from '@ohos.app.ability.common';
 | 
			
		||||
import router from '@ohos.router';
 | 
			
		||||
 | 
			
		||||
// import { initJudgeUdp } from '../common/utils/UdpJudge';
 | 
			
		||||
import { getEsCarModel, getSyncData, } from '../common/service/initable';
 | 
			
		||||
import { initJudgeUdp } from '../common/utils/UdpJudge';
 | 
			
		||||
import { judgeConfig } from './judgeSDK/utils/judgeConfig';
 | 
			
		||||
import promptAction from '@ohos.promptAction';
 | 
			
		||||
import errorMsgDialog from './compontents/errorMsgDialog';
 | 
			
		||||
@ -9,10 +10,10 @@ import imageBtn from './compontents/imageBtn';
 | 
			
		||||
import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements';
 | 
			
		||||
import { BaseInfoType, centerCallBackMsgType } from '../model/Common';
 | 
			
		||||
import {
 | 
			
		||||
  CarInfoType,
 | 
			
		||||
  InitializeTheCentralTableType,
 | 
			
		||||
  MASYSSETTableType,
 | 
			
		||||
  TimeSynchronizationRspBody
 | 
			
		||||
    CarInfoType,
 | 
			
		||||
    InitializeTheCentralTableType,
 | 
			
		||||
    MASYSSETTableType,
 | 
			
		||||
    TimeSynchronizationRspBody
 | 
			
		||||
} from '../model';
 | 
			
		||||
import { GetCarInfo, GetDeviceInfo, SetCurrentTime, SetSerialNumber, UseAuth } from './Index/utils';
 | 
			
		||||
import { GetSyncData, InitializeTheCentralTable } from '../utils/table/Operation';
 | 
			
		||||
@ -23,7 +24,6 @@ import { GetCurrentTime } from '../utils/Common';
 | 
			
		||||
import { ObtainSignalData } from '../utils/business/ObtainSignalData';
 | 
			
		||||
import { CentralHeartbeat } from '../utils/business/CentralHeartbeat';
 | 
			
		||||
import { DrivingDataStorage } from '../utils/business/DrivingDataStorage';
 | 
			
		||||
import { initJudgeUdp } from '../utils/business/UdpJudge';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@Entry
 | 
			
		||||
@ -170,7 +170,7 @@ struct Index {
 | 
			
		||||
                  return
 | 
			
		||||
                }
 | 
			
		||||
                //判断数据库是否有表数据,有则直接跳转,没有则读取本地数据
 | 
			
		||||
                GetSyncData<MASYSSETTableType>('MA_SYSSET').then((data: Array<MASYSSETTableType>) => {
 | 
			
		||||
                getSyncData('MA_SYSSET').then((data: Array<string>) => {
 | 
			
		||||
                  console.log('datadata', JSON.stringify(data))
 | 
			
		||||
                  if (data?.[0]) {
 | 
			
		||||
                    router.pushUrl({
 | 
			
		||||
@ -456,6 +456,7 @@ struct Index {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async onPageShow() {
 | 
			
		||||
    console.log('ttttt', 1111)
 | 
			
		||||
    this.singlePlay = AppStorage.get<boolean>('singlePlay')
 | 
			
		||||
    this.baseInfo = AppStorage.get<BaseInfoType>('baseInfo')
 | 
			
		||||
    // await this.userAuth();
 | 
			
		||||
@ -465,6 +466,7 @@ struct Index {
 | 
			
		||||
    });
 | 
			
		||||
    if (this.singlePlay == undefined || this.singlePlay == null) {
 | 
			
		||||
      // setVideoParam()
 | 
			
		||||
      console.log('diyidiy')
 | 
			
		||||
      this.context.resourceManager.getRawFileContent("welcome.wav")
 | 
			
		||||
        .then(() => {
 | 
			
		||||
          this.avPlayer.playAudio(['welcome.wav'])
 | 
			
		||||
@ -503,7 +505,7 @@ struct Index {
 | 
			
		||||
    ObtainSignalData.init();
 | 
			
		||||
    CentralHeartbeat.init();
 | 
			
		||||
    CentralHeartbeat.sendHeartData()
 | 
			
		||||
    CentralHeartbeat.getData((data: centerCallBackMsgType) => {
 | 
			
		||||
    CentralHeartbeat.getData((data:centerCallBackMsgType)=>{
 | 
			
		||||
      if (data.id == 32) {
 | 
			
		||||
        AppStorage.setOrCreate('signNum', data.body[1])
 | 
			
		||||
      }
 | 
			
		||||
@ -518,6 +520,13 @@ struct Index {
 | 
			
		||||
    // await setCurrentTime();
 | 
			
		||||
    await SetCurrentTime()
 | 
			
		||||
    this.timeInfo = AppStorage.get<TimeSynchronizationRspBody>('timeInfo')
 | 
			
		||||
    // const distanceClass = AppStorage.get<boolean>('distanceClass')
 | 
			
		||||
    // if (!distanceClass) {
 | 
			
		||||
    //   const distanceClass = new GetDistance(this.context)
 | 
			
		||||
    //   await distanceClass.initFolder()
 | 
			
		||||
    //   AppStorage.setOrCreate('distanceClass', distanceClass)
 | 
			
		||||
    //   console.info('surenjun', 'distanceClass=>初始化完成')
 | 
			
		||||
    // }
 | 
			
		||||
    DrivingDataStorage.init(this.context)
 | 
			
		||||
    DrivingDataStorage.initializeTheDrivingDataFolder()
 | 
			
		||||
    setTimeout(() => {
 | 
			
		||||
@ -538,4 +547,10 @@ struct Index {
 | 
			
		||||
    }, 1000)
 | 
			
		||||
    this.createAlbum()
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async getModel() {
 | 
			
		||||
    const context = this.context;
 | 
			
		||||
    //下载模型
 | 
			
		||||
    await getEsCarModel(context)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -1,15 +1,15 @@
 | 
			
		||||
import { getSyncData } from '../../../common/service/initable';
 | 
			
		||||
import { judgeConfig } from '../../judgeSDK/utils/judgeConfig';
 | 
			
		||||
 | 
			
		||||
import common from '@ohos.app.ability.common';
 | 
			
		||||
import VoiceAnnounce from '../../judgeSDK/utils/voiceAnnouncements';
 | 
			
		||||
import { MarkRule } from '../../judgeSDK/api/judgeSDK.d';
 | 
			
		||||
import { MarkRule, SYSSET } from '../../judgeSDK/api/judgeSDK.d';
 | 
			
		||||
import { writeObjectOut } from '../../../api/judge';
 | 
			
		||||
import JudgeTask from '../../judgeSDK/utils/judgeTask';
 | 
			
		||||
import FilePhoto from '../../judgeSDK/utils/filePhoto';
 | 
			
		||||
import { CarInfoType, MASYSSETTableType } from '../../../model';
 | 
			
		||||
import { CarInfoType } from '../../../model';
 | 
			
		||||
import { GetCurrentTime } from '../../../utils/Common';
 | 
			
		||||
import FileUtils from '../../../utils/FileUtils';
 | 
			
		||||
import { GetSyncData } from '../../../utils/table/Operation';
 | 
			
		||||
 | 
			
		||||
interface SEL {
 | 
			
		||||
  fontColor: string
 | 
			
		||||
@ -353,8 +353,8 @@ export default struct DeductedPopup {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //获取sysset表数据
 | 
			
		||||
  async initSysset(sysset?: MASYSSETTableType[]) {
 | 
			
		||||
    const syssetParams = sysset || await GetSyncData<MASYSSETTableType>('MA_SYSSET');
 | 
			
		||||
  async initSysset(sysset?: SYSSET[]) {
 | 
			
		||||
    const syssetParams = sysset || await getSyncData('MA_SYSSET');
 | 
			
		||||
    console.info('surenjun syssetParams', JSON.stringify(syssetParams));
 | 
			
		||||
    syssetParams.forEach(sys => {
 | 
			
		||||
      //监管序列号
 | 
			
		||||
 | 
			
		||||
@ -1,129 +0,0 @@
 | 
			
		||||
import emitter from '@ohos.events.emitter';
 | 
			
		||||
 | 
			
		||||
export const EVENTID = {
 | 
			
		||||
  //远程扣分处理
 | 
			
		||||
  kfEventId: 35,
 | 
			
		||||
  //远程扣分查询
 | 
			
		||||
  kfAskEventId: 36,
 | 
			
		||||
  //远程扣分确认
 | 
			
		||||
  kfConfirmEventId: 37,
 | 
			
		||||
 | 
			
		||||
  //远程开始考试
 | 
			
		||||
  beginExamEventId: 11,
 | 
			
		||||
  //远程结束考试
 | 
			
		||||
  endExamEventId: 12
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default class JudgeEmitter {
 | 
			
		||||
  //监听开始考试
 | 
			
		||||
  public onBeginExam = async (callBack?: Function) => {
 | 
			
		||||
    console.info('surenjun', '注册远程开始考试事件')
 | 
			
		||||
    this.beginExamCallBack = callBack
 | 
			
		||||
  }
 | 
			
		||||
  //监听结束考试
 | 
			
		||||
  public onEndExam = async (callBack?: Function) => {
 | 
			
		||||
    console.info('surenjun', '注册远程结束考试事件')
 | 
			
		||||
    this.endExamCallBack = callBack
 | 
			
		||||
  }
 | 
			
		||||
  //监听扣分处理
 | 
			
		||||
  public onKfExam = async (callBack?: Function) => {
 | 
			
		||||
    console.info('surenjun', '注册远程扣分考试事件')
 | 
			
		||||
    this.kfContent = callBack
 | 
			
		||||
  }
 | 
			
		||||
  //开始考试
 | 
			
		||||
  public sendBeginExam = async (content: string) => {
 | 
			
		||||
    emitter.emit({
 | 
			
		||||
      eventId: EVENTID.beginExamEventId
 | 
			
		||||
    }, {
 | 
			
		||||
      data: {
 | 
			
		||||
        directives: content
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
  //结束考试
 | 
			
		||||
  public sendEndExam = async (content: string) => {
 | 
			
		||||
    emitter.emit({
 | 
			
		||||
      eventId: EVENTID.endExamEventId
 | 
			
		||||
    }, {
 | 
			
		||||
      data: {
 | 
			
		||||
        directives: content
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
  private directives: string
 | 
			
		||||
  //扣分
 | 
			
		||||
  public sendKfContent = async (kfxh: string) => {
 | 
			
		||||
    const directives = this.directives
 | 
			
		||||
    console.info('surenjun', `udpEvent收到扣分事件。kfxh=>${kfxh};directives=>${directives}`)
 | 
			
		||||
    emitter.emit({
 | 
			
		||||
      eventId: EVENTID.kfEventId
 | 
			
		||||
    }, {
 | 
			
		||||
      data: {
 | 
			
		||||
        directives,
 | 
			
		||||
        kfxh
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
  //监听扣分指令
 | 
			
		||||
  public sendOnKf = async (directives: string) => {
 | 
			
		||||
    //TODO 临时存储指令编号
 | 
			
		||||
    this.directives = directives
 | 
			
		||||
    globalThis.judgeUdp.askKf(directives)
 | 
			
		||||
  }
 | 
			
		||||
  // 获取扣分项目编号
 | 
			
		||||
  public onConfirmKf = async (kfxh: string) => {
 | 
			
		||||
    const directives = this.directives;
 | 
			
		||||
    emitter.emit({
 | 
			
		||||
      eventId: EVENTID.kfConfirmEventId
 | 
			
		||||
    }, {
 | 
			
		||||
      data: {
 | 
			
		||||
        kfxh, directives
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  constructor() {
 | 
			
		||||
    this.init()
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  init = async () => {
 | 
			
		||||
    console.info('surenjun', '开始注册udp事件')
 | 
			
		||||
    emitter.off(EVENTID.beginExamEventId)
 | 
			
		||||
    emitter.off(EVENTID.endExamEventId)
 | 
			
		||||
    emitter.off(EVENTID.kfConfirmEventId)
 | 
			
		||||
    emitter.off(EVENTID.kfEventId)
 | 
			
		||||
 | 
			
		||||
    emitter.on({
 | 
			
		||||
      eventId: EVENTID.beginExamEventId
 | 
			
		||||
    }, () => {
 | 
			
		||||
      this?.beginExamCallBack()
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    emitter.on({
 | 
			
		||||
      eventId: EVENTID.endExamEventId
 | 
			
		||||
    }, () => {
 | 
			
		||||
      this?.endExamCallBack()
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    emitter.on({
 | 
			
		||||
      eventId: EVENTID.kfEventId
 | 
			
		||||
    }, (data) => {
 | 
			
		||||
      console.info('surenjun  EVENTID.kfEvent' + JSON.stringify(data))
 | 
			
		||||
      this?.kfContent(data)
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private beginExamCallBack: Function = () => {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private endExamCallBack: Function = () => {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private confirmExamCallBack: Function = () => {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private kfContent: Function = () => {
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,304 +0,0 @@
 | 
			
		||||
import systemTime from '@ohos.systemDateTime';
 | 
			
		||||
 | 
			
		||||
import { testKm2Items, testKm3Items } from '../../pages/judgeSDK/dataTest/index';
 | 
			
		||||
import { judgeConfig } from '../../pages/judgeSDK/utils/judgeConfig';
 | 
			
		||||
import { examCalcGpsDistance } from '../../pages/judgeSDK/api';
 | 
			
		||||
 | 
			
		||||
export const initJudgeUdp = async () => {
 | 
			
		||||
  globalThis.serialIndex = 0;
 | 
			
		||||
  globalThis.udpIndex = 0;
 | 
			
		||||
  const udp = await setJudgeUdp()
 | 
			
		||||
  globalThis.judgeUdp = udp
 | 
			
		||||
 | 
			
		||||
  const arrBlue = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00];
 | 
			
		||||
  const arrBlueBuffer = Array2Byte(arrBlue).buffer
 | 
			
		||||
 | 
			
		||||
  const lightLineUdp = await setTopLineUdp();
 | 
			
		||||
  if (lightLineUdp) {
 | 
			
		||||
    lightLineUdp.send(arrBlueBuffer);
 | 
			
		||||
  }
 | 
			
		||||
  globalThis.lightLineUdp = lightLineUdp
 | 
			
		||||
 | 
			
		||||
  let [prevJd, preWd] = [0, 0]
 | 
			
		||||
  globalThis.udpClient.onMessage_1(async (msg) => {
 | 
			
		||||
    const stachArr = msg.split(',')
 | 
			
		||||
    if (stachArr[0] != '#DN_GD') {
 | 
			
		||||
      return
 | 
			
		||||
    }
 | 
			
		||||
    const udpIndex = globalThis.udpIndex;
 | 
			
		||||
    const isJudge = globalThis.isJudge;
 | 
			
		||||
    if (udpIndex % 5 === 0 && !isJudge) {
 | 
			
		||||
      const bytes = await getMessageHeartbeat(msg);
 | 
			
		||||
      const msgArr = msg.split(',');
 | 
			
		||||
      const jd = convertGpsCoord2(msgArr[96] * 1);
 | 
			
		||||
      const wd = convertGpsCoord2(msgArr[95] * 1 || 0);
 | 
			
		||||
      udp.send(bytes)
 | 
			
		||||
      if (prevJd && msgArr[83] == 4) {
 | 
			
		||||
        const distance = await examCalcGpsDistance({
 | 
			
		||||
          jd1: prevJd,
 | 
			
		||||
          wd1: preWd,
 | 
			
		||||
          jd2: jd,
 | 
			
		||||
          wd2: wd,
 | 
			
		||||
          h: msgArr[90] * 1 || 1,
 | 
			
		||||
        })
 | 
			
		||||
        //@ts-ignore
 | 
			
		||||
        // globalThis.distanceClass?.setTimeData(((distance / 100).toFixed(2)) * 1)
 | 
			
		||||
      }
 | 
			
		||||
      prevJd = jd;
 | 
			
		||||
      preWd = wd;
 | 
			
		||||
    }
 | 
			
		||||
    globalThis.udpIndex += 1
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export const getMessageHeartbeat = async (msg) => {
 | 
			
		||||
  const carInfo = globalThis.carInfo;
 | 
			
		||||
  const { examSubject, plateNo } = carInfo;
 | 
			
		||||
  const ksyh = '0000000000000'
 | 
			
		||||
  const { fourInOneScreen:{ gpsDigit } } = judgeConfig
 | 
			
		||||
  const asclshArr = stringToASC(fillZero(
 | 
			
		||||
    globalThis.singlePlay
 | 
			
		||||
      ? '1111111111111'
 | 
			
		||||
      : globalThis.lsh,
 | 
			
		||||
    13));
 | 
			
		||||
  const ascksyhArr = stringToASC(fillZero(examSubject == 2 ? '0000000000000' : '1111111111111', 13))
 | 
			
		||||
  const ascsbxhArr = stringToASC('00000000')
 | 
			
		||||
  // const ascsbxhArr = stringToASC('153216400880')
 | 
			
		||||
  const serialIndex = globalThis.serialIndex
 | 
			
		||||
  const tempData = await getPlcData(msg);
 | 
			
		||||
  const examType = examSubject == 2 ? 2 : 3
 | 
			
		||||
  const { sensor, gps } = tempData;
 | 
			
		||||
  const { zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc, ssc, fsc, lb, mkg, aqd, ygq, cs, fdjzs, dw } = sensor
 | 
			
		||||
  const { jd, wd, hxj, fyj, hbg, sd } = gps
 | 
			
		||||
  const translateSignals = getTranslateSignals(
 | 
			
		||||
    [zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc, ssc, fsc, lb, mkg, aqd].concat(getDwStatusType(dw))
 | 
			
		||||
      .concat([0, 0, ygq, sensor.wd, 0])
 | 
			
		||||
  )
 | 
			
		||||
  const translateProject = getTranslateProject();
 | 
			
		||||
  //@ts-ignore
 | 
			
		||||
  const translateJd = convertGpsCoord2(wd).toFixed(gpsDigit) * Math.pow(10, gpsDigit);
 | 
			
		||||
  //@ts-ignore
 | 
			
		||||
  const translateWd = convertGpsCoord2(jd).toFixed(gpsDigit) * Math.pow(10, gpsDigit)
 | 
			
		||||
  //@ts-ignore
 | 
			
		||||
  const translateProjects = translateProject.map(numStr => string2Bytes(parseInt(numStr, 2), 8)[0])
 | 
			
		||||
  //@ts-ignore
 | 
			
		||||
  let tempSd = (sd * 1.852).toFixed(0) * 1
 | 
			
		||||
  if (tempSd < 1) {
 | 
			
		||||
    tempSd = 0
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const arr = [
 | 
			
		||||
  //考生号
 | 
			
		||||
    asclshArr.map(lsh => string2Bytes(lsh, 8)[0]),
 | 
			
		||||
    //考试员号
 | 
			
		||||
    ascksyhArr.map(ksyh => string2Bytes(ksyh, 8)[0]),
 | 
			
		||||
    //科目类型(0:未考试 1:科目二 2:科目三) + 考试开始时间
 | 
			
		||||
    string2Bytes(`${0}${'00:00:000'}`, 4 * 8),
 | 
			
		||||
    // 消息序号
 | 
			
		||||
    string2Bytes(serialIndex, 2 * 8),
 | 
			
		||||
    translateSignals,
 | 
			
		||||
    //@ts-ignore
 | 
			
		||||
    string2Bytes(tempSd * 100, 2 * 8), string2Bytes(fdjzs / 100, 8), string2Bytes(translateJd, 4 * 8),
 | 
			
		||||
    string2Bytes(translateWd, 4 * 8), string2Bytes(1, 8),
 | 
			
		||||
    //GPS东向距离
 | 
			
		||||
    string2Bytes(0, 4 * 8),
 | 
			
		||||
    //GPS北向距离
 | 
			
		||||
    string2Bytes(0, 4 * 8),
 | 
			
		||||
    //航向角                         俯仰角                   高程(海拔)
 | 
			
		||||
    //@ts-ignore
 | 
			
		||||
    string2Bytes((hxj) * 100, 2 * 8), string2Bytes(fyj * 100, 2 * 8), string2Bytes(hbg * 100, 4 * 8),
 | 
			
		||||
    //dddd
 | 
			
		||||
    translateProjects,
 | 
			
		||||
    //当前项目编号
 | 
			
		||||
    string2Bytes(0, 8),
 | 
			
		||||
    //场地设备编号
 | 
			
		||||
    ascsbxhArr.map(sbxh => string2Bytes(sbxh, 8)[0]),
 | 
			
		||||
    //本次考试行驶距离
 | 
			
		||||
    string2Bytes(0, 2 * 8),
 | 
			
		||||
    //扣分值
 | 
			
		||||
    string2Bytes(0, 2 * 8),
 | 
			
		||||
    //扣分数
 | 
			
		||||
    string2Bytes(0, 2 * 8),
 | 
			
		||||
    //扣分项数量
 | 
			
		||||
    string2Bytes(0, 8),
 | 
			
		||||
    //n个扣分序号
 | 
			
		||||
    [].map(kf => string2Bytes(kf.markcatalog, 8)),
 | 
			
		||||
    //牵引车第二gps精度、纬度
 | 
			
		||||
    string2Bytes(0, 4 * 8), string2Bytes(0, 4 * 8),
 | 
			
		||||
    //牵引车第二航向角
 | 
			
		||||
    string2Bytes(0, 2 * 8),
 | 
			
		||||
    //摩托压线 Byte[20],
 | 
			
		||||
    string2Bytes(0, 20 * 8),
 | 
			
		||||
    //考试用时
 | 
			
		||||
    string2Bytes(fillZero(0 + '', 4), 4 * 8),
 | 
			
		||||
    //项目用时
 | 
			
		||||
    string2Bytes(fillZero(0, 2), 2 * 8),
 | 
			
		||||
    //设备信号状态
 | 
			
		||||
    string2Bytes(0, 4 * 8),
 | 
			
		||||
  ]
 | 
			
		||||
  let tempArr = [];
 | 
			
		||||
  arr.forEach(itemArr => {
 | 
			
		||||
    tempArr = tempArr.concat(itemArr)
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  globalThis.serialIndex = 0;
 | 
			
		||||
  return Array2Byte(tempArr)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 中心plc实时信号转换成字节
 | 
			
		||||
const getTranslateSignals = (tempItems) => {
 | 
			
		||||
  const len = Math.floor(tempItems.length / 8);
 | 
			
		||||
  const arr = [];
 | 
			
		||||
  for (let i = 0; i < len; i++) {
 | 
			
		||||
    const temp = tempItems.slice(i * 8, (i + 1) * 8);
 | 
			
		||||
    arr.push(temp.join(''));
 | 
			
		||||
  }
 | 
			
		||||
  const temp = arr.map(numStr => parseInt(numStr, 2))
 | 
			
		||||
  return temp.map(item => string2Bytes(item, 8)[0])
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 中心所有项目转换
 | 
			
		||||
const getTranslateProject = () => {
 | 
			
		||||
  const examSubject = globalThis.examSubject;
 | 
			
		||||
 | 
			
		||||
  const tempItems = (examSubject == 2 ? testKm2Items : testKm3Items).map(code => {
 | 
			
		||||
    return {
 | 
			
		||||
      code, status: '0'
 | 
			
		||||
    }
 | 
			
		||||
  })
 | 
			
		||||
  const arr = [];
 | 
			
		||||
  for (let i = 0; i <= 4; i++) {
 | 
			
		||||
    const temp = tempItems.slice(i * 4, (i + 1) * 4);
 | 
			
		||||
    let tempArr = temp.map(item => item.status)
 | 
			
		||||
    if (i === 4) {
 | 
			
		||||
      tempArr = examSubject == 2
 | 
			
		||||
        //bit36-bit39保留
 | 
			
		||||
        ? tempArr.concat(['00', '00'])
 | 
			
		||||
        //bit30-bit39保留
 | 
			
		||||
        : tempArr.concat(['00', '00', '00'])
 | 
			
		||||
    }
 | 
			
		||||
    // if (i === 3 && examSubject == 3) {
 | 
			
		||||
    //   tempArr = tempArr.concat(['00'])
 | 
			
		||||
    // }
 | 
			
		||||
 | 
			
		||||
    arr.push(tempArr.join(''));
 | 
			
		||||
  }
 | 
			
		||||
  return arr
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 中心实时项目状态转换
 | 
			
		||||
const getCenterProjectStatus = (status) => {
 | 
			
		||||
  switch (status) {
 | 
			
		||||
  //不考
 | 
			
		||||
    case 0:
 | 
			
		||||
      return '00'
 | 
			
		||||
  //未考
 | 
			
		||||
    case 1:
 | 
			
		||||
      return '01'
 | 
			
		||||
  //已考
 | 
			
		||||
    case 2:
 | 
			
		||||
      return '10'
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// plc数据转换成对象
 | 
			
		||||
const getPlcData = async (plc: string) => {
 | 
			
		||||
  const time = await systemTime.getCurrentTime()
 | 
			
		||||
  const p = plc.split(',').map((val, key) => {
 | 
			
		||||
    if (key !== 27 && key !== 92) {
 | 
			
		||||
      //@ts-ignore
 | 
			
		||||
      return val * 1
 | 
			
		||||
    } else {
 | 
			
		||||
      return val
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  const tempData = {
 | 
			
		||||
    sensor: {
 | 
			
		||||
      //安全带     车门门开关   手刹        脚刹        副刹       离合器      喇叭      示宽灯     近光灯     远光灯
 | 
			
		||||
      aqd: p[19],
 | 
			
		||||
      mkg: p[14],
 | 
			
		||||
      ssc: p[13],
 | 
			
		||||
      jsc: p[12],
 | 
			
		||||
      fsc: p[18],
 | 
			
		||||
      lhq: p[17],
 | 
			
		||||
      lb: p[4],
 | 
			
		||||
      skd: p[9],
 | 
			
		||||
      jgd: p[7],
 | 
			
		||||
      ygd: p[8],
 | 
			
		||||
      //左方向灯   右方向灯     双跳灯      雾灯        雨刮器      点火1     点火2      发动机转速     档位       车速
 | 
			
		||||
      zfxd: p[2],
 | 
			
		||||
      yfxd: p[3],
 | 
			
		||||
      shtd: p[20],
 | 
			
		||||
      wd: p[10],
 | 
			
		||||
      ygq: p[11],
 | 
			
		||||
      dh1: p[5],
 | 
			
		||||
      dh2: p[6],
 | 
			
		||||
      fdjzs: p[25],
 | 
			
		||||
      dw: p[28],
 | 
			
		||||
      cs: p[23],
 | 
			
		||||
      //@ts-ignore 方向盘
 | 
			
		||||
      fxp: p[27].split('_')[0] * 1,
 | 
			
		||||
      //累计脉冲   溜车脉冲   超声波左后     超声波右后     超声波右前     超声波左前    座椅    仪表盘   后视镜   倒车镜   光照  雨量
 | 
			
		||||
      ljmc: p[24],
 | 
			
		||||
      lcmc: 0,
 | 
			
		||||
      csbzh: p[32],
 | 
			
		||||
      csbyh: p[30],
 | 
			
		||||
      csbyq: p[31],
 | 
			
		||||
      csbzq: p[29],
 | 
			
		||||
      zy: 0,
 | 
			
		||||
      tbp: 0,
 | 
			
		||||
      hsj: 0,
 | 
			
		||||
      dcj: 0,
 | 
			
		||||
      gx: 0,
 | 
			
		||||
      yl: 0
 | 
			
		||||
    },
 | 
			
		||||
    gps: {
 | 
			
		||||
      //TODO 办卡类型    定位差分状态
 | 
			
		||||
      bklx: p[56],
 | 
			
		||||
      dwzt: p[83],
 | 
			
		||||
      //@ts-ignore 角度差分状态
 | 
			
		||||
      jdzt: p[92].split('-')[0] * 1,
 | 
			
		||||
      //TODO gps数据
 | 
			
		||||
      //gps时间 经度      纬度       航向角      俯仰角      海拔高       高度差     速度
 | 
			
		||||
      sj: time,
 | 
			
		||||
      jd: p[96],
 | 
			
		||||
      wd: p[95],
 | 
			
		||||
      hxj: p[90],
 | 
			
		||||
      fyj: p[91],
 | 
			
		||||
      hbg: p[85],
 | 
			
		||||
      gdc: p[86],
 | 
			
		||||
      sd: p[97],
 | 
			
		||||
      //龄期      经度因子     纬度因子      定位搜星数
 | 
			
		||||
      age: p[87],
 | 
			
		||||
      jdyz: p[89],
 | 
			
		||||
      wdyz: p[88],
 | 
			
		||||
      dwsxs: p[84],
 | 
			
		||||
      //@ts-ignore 角度搜星数
 | 
			
		||||
      jdsxs: p[92].split('-')[1] * 1
 | 
			
		||||
    },
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return tempData
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const getDwStatusType = (dw) => {
 | 
			
		||||
  switch (dw) {
 | 
			
		||||
    case 0:
 | 
			
		||||
      return [0, 0, 0, 0]
 | 
			
		||||
    case 1:
 | 
			
		||||
      return [0, 0, 0, 1]
 | 
			
		||||
    case 2:
 | 
			
		||||
      return [0, 0, 1, 0]
 | 
			
		||||
    case 3:
 | 
			
		||||
      return [0, 0, 1, 1]
 | 
			
		||||
    case 4:
 | 
			
		||||
      return [0, 1, 0, 0]
 | 
			
		||||
    case 5:
 | 
			
		||||
      return [0, 1, 0, 1]
 | 
			
		||||
    case 9:
 | 
			
		||||
      return [1, 0, 0, 1]
 | 
			
		||||
    default:
 | 
			
		||||
      return [0, 0, 0, 0]
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -11,7 +11,7 @@ import FileUtils from '../FileUtils';
 | 
			
		||||
// 建表操作
 | 
			
		||||
export async function InitTable() {
 | 
			
		||||
  Object.keys(ParameterPlatform).forEach(async (item) => {
 | 
			
		||||
    await DB.executeSql(ParameterPlatform.get(item).sqlCreate);
 | 
			
		||||
    await DB.executeSql(ParameterPlatform[item].sqlCreate);
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -56,7 +56,7 @@ export function UpdateTableByArray(tableName: string, arr: Array<User>): Promise
 | 
			
		||||
//依据表名同步获取数据
 | 
			
		||||
export async function GetSyncData<T>(tableName: string): Promise<T[]> {
 | 
			
		||||
  return new Promise((resolve, reject) => {
 | 
			
		||||
    const columns: ColumnInfo[] = ParameterPlatform.get(tableName).columns.map((res: string) => {
 | 
			
		||||
    const columns: ColumnInfo[] = ParameterPlatform[tableName].columns.map((res: string) => {
 | 
			
		||||
      return {
 | 
			
		||||
        name: res,
 | 
			
		||||
        columnName: res,
 | 
			
		||||
@ -134,9 +134,9 @@ export async function InitializeTheCentralTable(params: InitializeTheCentralTabl
 | 
			
		||||
        arrList.push(res.initializationRsp.body[key])
 | 
			
		||||
      }
 | 
			
		||||
      const folderPath = await fileUtil.initFolder(`/config/tableList`);
 | 
			
		||||
      fileUtil.addFile(`${folderPath}/${RemappingTableName.get(key)}.txt`, JSON.stringify(arrList))
 | 
			
		||||
      fileUtil.addFile(`${folderPath}/${RemappingTableName[key]}.txt`, JSON.stringify(arrList))
 | 
			
		||||
      try {
 | 
			
		||||
        const result = await SqlInsertTable(RemappingTableName.get(key), arrList)
 | 
			
		||||
        const result = await SqlInsertTable(RemappingTableName[key], arrList)
 | 
			
		||||
        if (!result) {
 | 
			
		||||
          Prompt.showToast({
 | 
			
		||||
            message: '初始化数据库失败'
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user