Compare commits
	
		
			5 Commits
		
	
	
		
			df6ccfa689
			...
			63f4248e9f
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					63f4248e9f | ||
| 
						 | 
					232926e9c7 | ||
| 
						 | 
					fa24528306 | ||
| 
						 | 
					524eecb149 | ||
| 
						 | 
					05cd7eff24 | 
@ -87,7 +87,8 @@ export async function initCarInfoCache(params: initCarInfoCacheParams) {
 | 
			
		||||
 | 
			
		||||
//参数下发读表接口
 | 
			
		||||
export async function initCenterCache(params: object, url: string) {
 | 
			
		||||
  const timeInfo: TimeSynchronizationRspBody = AppStorage.get<TimeSynchronizationRspBody>('timeInfo')
 | 
			
		||||
  const timeInfo: TimeSynchronizationRspBody =
 | 
			
		||||
    AppStorage.get<TimeSynchronizationRspBody>('timeInfo') ?? { /* default values */ };
 | 
			
		||||
  return await request<object>({
 | 
			
		||||
    url: '/para/initCenterCache.ws',
 | 
			
		||||
    data: params,
 | 
			
		||||
@ -112,7 +113,8 @@ export async function initCenterCacheByKSPT(params: object, url: string) {
 | 
			
		||||
//从参数平台获取模型
 | 
			
		||||
// TODO 类型需要补全
 | 
			
		||||
export async function initEsModel(params: InitModelParams) {
 | 
			
		||||
  const timeInfo: TimeSynchronizationRspBody = AppStorage.get<TimeSynchronizationRspBody>('timeInfo')
 | 
			
		||||
  const timeInfo: TimeSynchronizationRspBody =
 | 
			
		||||
    AppStorage.get<TimeSynchronizationRspBody>('timeInfo') ?? { /* default values */ };
 | 
			
		||||
  return await request<InitModelResponse>({
 | 
			
		||||
    url: '/para/initEsModel.ws',
 | 
			
		||||
    data: params,
 | 
			
		||||
 | 
			
		||||
@ -5,7 +5,6 @@ import { GlobalConfig } from '../config/global';
 | 
			
		||||
import Want from '@ohos.app.ability.Want';
 | 
			
		||||
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
 | 
			
		||||
import { BaseInfoType, CarInfoType, EnvironmentConfigurationType, 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';
 | 
			
		||||
@ -42,7 +41,6 @@ export default class EntryAbility extends UIAbility {
 | 
			
		||||
  async onWindowStageCreate(windowStage: window.WindowStage) {
 | 
			
		||||
    // Main window is created, set main page for this ability
 | 
			
		||||
    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
 | 
			
		||||
    await tcpUtil.init()
 | 
			
		||||
 | 
			
		||||
    AppStorage.setOrCreate<CarInfoType>('carInfo', {})
 | 
			
		||||
    AppStorage.setOrCreate<ExaminerInfoType>('examinerInfo', {})
 | 
			
		||||
@ -52,8 +50,8 @@ export default class EntryAbility extends UIAbility {
 | 
			
		||||
    AppStorage.setOrCreate<string>('deviceNo', "") //设备号
 | 
			
		||||
    AppStorage.setOrCreate<BaseInfoType>('baseInfo', {
 | 
			
		||||
      hasAuth: false,
 | 
			
		||||
      version: GlobalConfig.version.jn.km3[0],
 | 
			
		||||
      judgeVersion: GlobalConfig.version.jn.km3[1],
 | 
			
		||||
      version: GlobalConfig.version.jn.km3[0] || "",
 | 
			
		||||
      judgeVersion: GlobalConfig.version.jn.km3[1] || "",
 | 
			
		||||
      tcpSendNum: 0,
 | 
			
		||||
      videoVersion: '1.0',
 | 
			
		||||
      ratio: 1700 / 960, //适配比例
 | 
			
		||||
 | 
			
		||||
@ -90,10 +90,11 @@ export interface BaseInfoType {
 | 
			
		||||
  deviceNo?: string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface kfdmObj{
 | 
			
		||||
  xmdm:number
 | 
			
		||||
  kfdm:string
 | 
			
		||||
interface kfdmObj {
 | 
			
		||||
  xmdm: number
 | 
			
		||||
  kfdm: string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 路由参数
 | 
			
		||||
export interface RouteParamsType {
 | 
			
		||||
  sczb?: string;
 | 
			
		||||
@ -150,7 +151,7 @@ export interface GlobalConfigType {
 | 
			
		||||
  picSavePath?: string
 | 
			
		||||
  videoSavePath?: string
 | 
			
		||||
  host?: string
 | 
			
		||||
  version?: VersionType
 | 
			
		||||
  version: VersionType
 | 
			
		||||
  //   几代机
 | 
			
		||||
  modelNo?: string
 | 
			
		||||
}
 | 
			
		||||
@ -172,6 +173,6 @@ interface VersionInfo {
 | 
			
		||||
export interface centerCallBackMsgType {
 | 
			
		||||
  id: number;
 | 
			
		||||
  length: number;
 | 
			
		||||
  body:number[];
 | 
			
		||||
  sendId:number;
 | 
			
		||||
  body: number[];
 | 
			
		||||
  sendId: number;
 | 
			
		||||
}
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -1,7 +1,7 @@
 | 
			
		||||
import TopLogo from './compontents/TopLogo';
 | 
			
		||||
import { getSyncData } from '../common/service/initable';
 | 
			
		||||
import router from '@ohos.router';
 | 
			
		||||
import { MASYSTEMPARMType, RouteParamsType } from '../model';
 | 
			
		||||
import { GetSyncData } from '../utils/table/Operation';
 | 
			
		||||
 | 
			
		||||
const cBg = $rawfile('judge/km3/road/luxian_pre.png');
 | 
			
		||||
const lBg = $rawfile('judge/km3/road/luxian_nor.png');
 | 
			
		||||
@ -17,7 +17,7 @@ struct Index {
 | 
			
		||||
 | 
			
		||||
  async aboutToAppear() {
 | 
			
		||||
    //读取systemparam表的no1等于4的
 | 
			
		||||
    const systemParms: Array<MASYSTEMPARMType> = await getSyncData('MA_SYSTEMPARM') as MASYSTEMPARMType[];
 | 
			
		||||
    const systemParms: Array<MASYSTEMPARMType> = await GetSyncData('MA_SYSTEMPARM') as MASYSTEMPARMType[];
 | 
			
		||||
    systemParms.forEach((systemParm: MASYSTEMPARMType) => {
 | 
			
		||||
      //TODO 字段名称待修改
 | 
			
		||||
      // const { no1, no2, no3, txt1, txt2 } = systemParm;
 | 
			
		||||
 | 
			
		||||
@ -8,7 +8,7 @@ import IDCardSDK from '@ohos.idcard';
 | 
			
		||||
import common from '@ohos.app.ability.common';
 | 
			
		||||
import promptAction from '@ohos.promptAction';
 | 
			
		||||
import FilePhoto from './judgeSDK/utils/filePhoto';
 | 
			
		||||
// import { sqlInsertCommonFn, upDateTableByArray } from '../common/service/initable';
 | 
			
		||||
 | 
			
		||||
import { CandidateData, EmptyCandidateObject } from '../mock/CandidateData';
 | 
			
		||||
import BoardPrePareSetPopup from './compontents/judge/BoardPrePareSetPopup';
 | 
			
		||||
import LoadingPopup from './compontents/judge/LoadingPopup';
 | 
			
		||||
@ -209,20 +209,6 @@ struct UserInfo {
 | 
			
		||||
    { label: '考试员名', key: 'ksy2' },
 | 
			
		||||
  ]
 | 
			
		||||
 | 
			
		||||
  private onCenterMsg = (val: centerCallBackMsgType) => {
 | 
			
		||||
    if (val.id == 32) {
 | 
			
		||||
      AppStorage.setOrCreate('signNum', val.body[1])
 | 
			
		||||
      if (val.body[0] == 7) {
 | 
			
		||||
        //缺考处理
 | 
			
		||||
        this.getqkFn()
 | 
			
		||||
        this.signNum = val.body[1]
 | 
			
		||||
      }
 | 
			
		||||
    } else if (val.id == 42) {
 | 
			
		||||
      //收到中心缺考确认消息
 | 
			
		||||
      this.qkFn()
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  aboutToAppear() {
 | 
			
		||||
    this.avPlayer = new VoiceAnnounce();
 | 
			
		||||
  }
 | 
			
		||||
@ -1341,6 +1327,20 @@ struct UserInfo {
 | 
			
		||||
    .backgroundImage($r('app.media.bg'))
 | 
			
		||||
    .backgroundImageSize({ width: '100%', height: '100%' })
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private onCenterMsg = (val: centerCallBackMsgType) => {
 | 
			
		||||
    if (val.id == 32) {
 | 
			
		||||
      AppStorage.setOrCreate('signNum', val.body[1])
 | 
			
		||||
      if (val.body[0] == 7) {
 | 
			
		||||
        //缺考处理
 | 
			
		||||
        this.getqkFn()
 | 
			
		||||
        this.signNum = val.body[1]
 | 
			
		||||
      }
 | 
			
		||||
    } else if (val.id == 42) {
 | 
			
		||||
      //收到中心缺考确认消息
 | 
			
		||||
      this.qkFn()
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 头像组件
 | 
			
		||||
 | 
			
		||||
@ -1,15 +1,15 @@
 | 
			
		||||
import { voiceService } from '../../service/voiceService';
 | 
			
		||||
import { faceCompare } from '../../api/userInfo';
 | 
			
		||||
 | 
			
		||||
import common from '@ohos.app.ability.common';
 | 
			
		||||
 | 
			
		||||
import { takePhoto } from '../../service/videoService';
 | 
			
		||||
import { GlobalConfig } from '../../config/index';
 | 
			
		||||
import { VideoConfigData } from '../../mock';
 | 
			
		||||
import { CarInfoType, UDPParamType, VideoConfig } from '../../model';
 | 
			
		||||
import { NumberToByteArray } from '../../utils/Common';
 | 
			
		||||
import FileUtils from '../../utils/FileUtils';
 | 
			
		||||
import { CenterUDPClientInstance } from '../../utils/business/CenterUdpBusiness';
 | 
			
		||||
import { takePhoto } from '../../utils/Video';
 | 
			
		||||
import { voiceService } from '../../utils/Voice';
 | 
			
		||||
 | 
			
		||||
interface ParamType {
 | 
			
		||||
  id?: number;
 | 
			
		||||
@ -257,7 +257,7 @@ export default struct FaceCompare {
 | 
			
		||||
        CenterUDPClientInstance.sendData(param2)
 | 
			
		||||
      }
 | 
			
		||||
    }, 1000)
 | 
			
		||||
    CenterUDPClientInstance.getData((val)=>{
 | 
			
		||||
    CenterUDPClientInstance.onMsg((val) => {
 | 
			
		||||
      if (AppStorage.get('statue') != 3) {
 | 
			
		||||
        return
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
@ -2,7 +2,7 @@ import router from '@ohos.router';
 | 
			
		||||
import RealTime from '../compontents/judge/RealTime';
 | 
			
		||||
import { GPSData, SignalData } from '../../mock';
 | 
			
		||||
import { SignalDataType } from '../../model';
 | 
			
		||||
import { ObtainSignalData } from '../../utils/business/ObtainSignalData';
 | 
			
		||||
import { ObtainUdpBusinessInstance } from '../../utils/business/ObtainUdpBusiness';
 | 
			
		||||
 | 
			
		||||
@Component
 | 
			
		||||
export default struct SignDisplayCom {
 | 
			
		||||
@ -327,15 +327,13 @@ export default struct SignDisplayCom {
 | 
			
		||||
    // const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/ipConfig.txt')
 | 
			
		||||
    // this.udplocalIp=JSON.parse(data)?.udplocalIp||'192.168.7.170'
 | 
			
		||||
    this.ratio = this.ratio * (this.scaleNum || 1);
 | 
			
		||||
    const that = this
 | 
			
		||||
    const { showBack, getSignal } = this
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    if (showBack) {
 | 
			
		||||
    if (this.showBack) {
 | 
			
		||||
      this.ratio = 1.4
 | 
			
		||||
      ObtainSignalData.getData((msg)=>{
 | 
			
		||||
      ObtainUdpBusinessInstance.onMsg((msg) => {
 | 
			
		||||
        if (msg) {
 | 
			
		||||
            getSignal(msg)
 | 
			
		||||
          this.getSignal(msg)
 | 
			
		||||
        }
 | 
			
		||||
      })
 | 
			
		||||
 | 
			
		||||
@ -344,7 +342,7 @@ export default struct SignDisplayCom {
 | 
			
		||||
      this.signalTimer = setInterval(() => {
 | 
			
		||||
        const msgStr = AppStorage.get<string>('msgStr')
 | 
			
		||||
        if (msgStr) {
 | 
			
		||||
          getSignal(msgStr)
 | 
			
		||||
          this.getSignal(msgStr)
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
      }, 200)
 | 
			
		||||
@ -353,10 +351,9 @@ export default struct SignDisplayCom {
 | 
			
		||||
 | 
			
		||||
  onPageShow() {
 | 
			
		||||
    const getSignal = this.getSignal;
 | 
			
		||||
    const that = this
 | 
			
		||||
    const showBack = this.showBack;
 | 
			
		||||
    if (showBack) {
 | 
			
		||||
      ObtainSignalData.getData((msg)=>{
 | 
			
		||||
      ObtainUdpBusinessInstance.onMsg((msg) => {
 | 
			
		||||
        if (msg) {
 | 
			
		||||
          getSignal(msg)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -2,11 +2,13 @@
 | 
			
		||||
export default struct imageBtn {
 | 
			
		||||
  //状态变量unPressed,用于控制按钮的状态
 | 
			
		||||
  @State unPressed: boolean = true
 | 
			
		||||
  btnWidth: string | number
 | 
			
		||||
  btnHeight: string | number
 | 
			
		||||
  imgSrc:Resource
 | 
			
		||||
  opacityNum:number=1
 | 
			
		||||
  @Styles customStyle(){
 | 
			
		||||
  btnWidth?: string | number
 | 
			
		||||
  btnHeight?: string | number
 | 
			
		||||
  imgSrc?: Resource
 | 
			
		||||
  opacityNum: number = 1
 | 
			
		||||
 | 
			
		||||
  @Styles
 | 
			
		||||
  customStyle(){
 | 
			
		||||
    .width('100%')
 | 
			
		||||
    .height('100%')
 | 
			
		||||
  }
 | 
			
		||||
@ -20,8 +22,7 @@ export default struct imageBtn {
 | 
			
		||||
            // 判断当前组件为放开状态
 | 
			
		||||
            if (this.unPressed) {
 | 
			
		||||
              // 插入Row组件,配置过渡效果
 | 
			
		||||
              Image(this.imgSrc)
 | 
			
		||||
                // 水波纹扩散动画:Row组件backgroundColor属性变更(#fff -> #ccc),系统插入动画过渡效果,从组建的中心点开始放大,scale{0,0}变更scale{1,1}
 | 
			
		||||
              Image(this.imgSrc)// 水波纹扩散动画:Row组件backgroundColor属性变更(#fff -> #ccc),系统插入动画过渡效果,从组建的中心点开始放大,scale{0,0}变更scale{1,1}
 | 
			
		||||
                .transition({
 | 
			
		||||
                  type: TransitionType.Insert,
 | 
			
		||||
                  opacity: 0,
 | 
			
		||||
@ -38,10 +39,11 @@ export default struct imageBtn {
 | 
			
		||||
                    duration: 500,
 | 
			
		||||
                    // 聚拢动画播放完成后,需要衔接扩散动画,此时Row组件backgroundColor属性变更(#fff -> #ccc),插入动画过渡效果,scale{0,0}变化为scale{1,1}
 | 
			
		||||
                    onFinish: () => {
 | 
			
		||||
                      this.opacityNum=1
 | 
			
		||||
                    } },
 | 
			
		||||
                      this.opacityNum = 1
 | 
			
		||||
                    }
 | 
			
		||||
                  },
 | 
			
		||||
                    () => {
 | 
			
		||||
                      this.opacityNum=0.2
 | 
			
		||||
                      this.opacityNum = 0.2
 | 
			
		||||
                    })
 | 
			
		||||
                })
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
@ -134,7 +134,7 @@ class DbUtils {
 | 
			
		||||
        this.rdbStore.querySql(sql, []).then((res: relationalStore.ResultSet) => {
 | 
			
		||||
          console.log(DbTag, "sql query", JSON.stringify(res))
 | 
			
		||||
          if (res.rowCount <= 0) {
 | 
			
		||||
            resolve(null)
 | 
			
		||||
            resolve(0 as T)
 | 
			
		||||
          } else {
 | 
			
		||||
            res.goToNextRow()
 | 
			
		||||
            resolve(res.getLong(0) as T)
 | 
			
		||||
 | 
			
		||||
@ -7,7 +7,7 @@ import { BusinessError } from '@ohos.base'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export default class FileUtils {
 | 
			
		||||
  public destFile: string
 | 
			
		||||
  public destFile?: string
 | 
			
		||||
  public filePathFdObj: Record<string, fs.File> = {}
 | 
			
		||||
  private context: common.UIAbilityContext
 | 
			
		||||
  private absolutePath = '/mnt/hmdfs/100/account/device_view/local/files/duolun'
 | 
			
		||||
@ -59,6 +59,7 @@ export default class FileUtils {
 | 
			
		||||
      return file.fd
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
      this.handleError('editFile文件失败', e, filePath)
 | 
			
		||||
      return undefined
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -6,14 +6,14 @@ import { VoiceTag } from '../config';
 | 
			
		||||
type AVPlayerCallback = (status: string, val?: string) => void;
 | 
			
		||||
 | 
			
		||||
export class voiceService {
 | 
			
		||||
  private avPlayer: media.AVPlayer = null;
 | 
			
		||||
  private avPlayer: media.AVPlayer | null = null;
 | 
			
		||||
  private fileSize: number = -1;
 | 
			
		||||
  private fd: number = 0;
 | 
			
		||||
  private playerName: string = '';
 | 
			
		||||
  private type: number = 1;
 | 
			
		||||
  private endFlag: Boolean = false;
 | 
			
		||||
  private mediaArray: Array<string> = [];
 | 
			
		||||
  private callBack: AVPlayerCallback = null;
 | 
			
		||||
  private callBack: AVPlayerCallback | null = null;
 | 
			
		||||
 | 
			
		||||
  constructor(callBack: AVPlayerCallback) {
 | 
			
		||||
    // 创建avPlayer实例对象
 | 
			
		||||
@ -30,14 +30,14 @@ export class voiceService {
 | 
			
		||||
    console.log(VoiceTag, ' avPlayerFdSrc setAVPlayerCallback begin')
 | 
			
		||||
 | 
			
		||||
    // error回调监听函数,当avPlayer在操作过程中出现错误时调用reset接口触发重置流程
 | 
			
		||||
    this.avPlayer.on('error', (err: BusinessError) => {
 | 
			
		||||
    this.avPlayer!.on('error', (err: BusinessError) => {
 | 
			
		||||
      console.error(VoiceTag, `Invoke avPlayer failed, code is ${err.code}, message is ${err.message}`);
 | 
			
		||||
      this.avPlayer.reset(); // 调用reset重置资源,触发idle状态
 | 
			
		||||
      this.avPlayer!.reset(); // 调用reset重置资源,触发idle状态
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // 状态机变化回调函数
 | 
			
		||||
    this.avPlayer.on('stateChange', async (state, reason) => {
 | 
			
		||||
    this.avPlayer!.on('stateChange', async (state, reason) => {
 | 
			
		||||
      switch (state) {
 | 
			
		||||
        case 'idle': // 成功调用reset接口后触发该状态机上报
 | 
			
		||||
          // callBack('idle');
 | 
			
		||||
@ -55,7 +55,7 @@ export class voiceService {
 | 
			
		||||
          break;
 | 
			
		||||
        case 'initialized': // avplayer 设置播放源后触发该状态上报
 | 
			
		||||
          console.info(VoiceTag, ' AVPlayerstate initialized called.');
 | 
			
		||||
          this.avPlayer.prepare().then(() => {
 | 
			
		||||
          this.avPlayer!.prepare().then(() => {
 | 
			
		||||
            console.info(VoiceTag, ' AVPlayer prepare succeeded.');
 | 
			
		||||
          }, (err: BusinessError) => {
 | 
			
		||||
            console.error(VoiceTag, ` Invoke prepare failed, code is ${err.code}, message is ${err.message}`);
 | 
			
		||||
@ -63,7 +63,7 @@ export class voiceService {
 | 
			
		||||
          callBack('initialized');
 | 
			
		||||
          break;
 | 
			
		||||
        case 'prepared': // prepare调用成功后上报该状态机
 | 
			
		||||
          this.avPlayer.play();
 | 
			
		||||
          this.avPlayer!.play();
 | 
			
		||||
          callBack('prepared');
 | 
			
		||||
          break;
 | 
			
		||||
        case 'playing': // play成功调用后触发该状态机上报
 | 
			
		||||
@ -74,12 +74,12 @@ export class voiceService {
 | 
			
		||||
          break;
 | 
			
		||||
        case 'completed': // 播放结束后触发该状态机上报
 | 
			
		||||
          console.info(VoiceTag, ' AVPlayer state completed called.');
 | 
			
		||||
          this.avPlayer.stop(); //调用播放结束接口
 | 
			
		||||
          this.avPlayer!.stop(); //调用播放结束接口
 | 
			
		||||
 | 
			
		||||
          break;
 | 
			
		||||
        case 'stopped': // stop接口成功调用后触发该状态机上报
 | 
			
		||||
          console.info(VoiceTag, ' AVPlayer state stopped called.');
 | 
			
		||||
          this.avPlayer.reset(); // 调用reset接口初始化avplayer状态
 | 
			
		||||
          this.avPlayer!.reset(); // 调用reset接口初始化avplayer状态
 | 
			
		||||
          // callBack('stopped');
 | 
			
		||||
          break;
 | 
			
		||||
        case 'released':
 | 
			
		||||
@ -97,14 +97,18 @@ export class voiceService {
 | 
			
		||||
  // 以下为使用资源管理接口获取打包在HAP内的媒体资源文件并通过fdSrc属性进行播放示例
 | 
			
		||||
  avPlayerFdSrc(name: string) {
 | 
			
		||||
    const context: common.UIAbilityContext = AppStorage.get('context')
 | 
			
		||||
    if (!context) {
 | 
			
		||||
      console.log(VoiceTag, ' context is null');
 | 
			
		||||
      return
 | 
			
		||||
    }
 | 
			
		||||
    context.resourceManager.getRawFd(name, async (error, value) => {
 | 
			
		||||
      if (error != null) {
 | 
			
		||||
        console.log(VoiceTag, ` callback getRawFd failed error code: ${error.code}, message: ${error.message}.`);
 | 
			
		||||
      } else {
 | 
			
		||||
        console.log(VoiceTag, this.avPlayer)
 | 
			
		||||
        if (this.avPlayer) {
 | 
			
		||||
          await this.avPlayer.reset()
 | 
			
		||||
          this.avPlayer.fdSrc = value;
 | 
			
		||||
          await this.avPlayer!.reset()
 | 
			
		||||
          this.avPlayer!.fdSrc = value;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 为fdSrc赋值触发initialized状态机上报
 | 
			
		||||
@ -116,15 +120,15 @@ export class voiceService {
 | 
			
		||||
 | 
			
		||||
  // 以下为通过url设置网络地址来实现播放直播码流的
 | 
			
		||||
  avPlayerLive(url: string) {
 | 
			
		||||
    this.avPlayer.url = url
 | 
			
		||||
    this.avPlayer!.url = url
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  releasePlayer() {
 | 
			
		||||
    this.avPlayer && this.avPlayer.release();
 | 
			
		||||
    this.avPlayer && this.avPlayer!.release();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  avPlayerStop() {
 | 
			
		||||
    this.avPlayer && this.avPlayer.stop((err: BusinessError) => {
 | 
			
		||||
    this.avPlayer && this.avPlayer!.stop((err: BusinessError) => {
 | 
			
		||||
      if (err == null) {
 | 
			
		||||
        this.endFlag = true
 | 
			
		||||
        console.info(VoiceTag, 'stop success');
 | 
			
		||||
 | 
			
		||||
@ -3,26 +3,26 @@ import dayTs from '../Date';
 | 
			
		||||
import FileUtils from '../FileUtils';
 | 
			
		||||
 | 
			
		||||
class drivingDataStorage {
 | 
			
		||||
  public folderPath: string
 | 
			
		||||
  public time: string
 | 
			
		||||
  public totalDistance: number
 | 
			
		||||
  public totalTime: number
 | 
			
		||||
  public date: string
 | 
			
		||||
  public fd: number
 | 
			
		||||
  private fileUtil: FileUtils
 | 
			
		||||
  public folderPath?: string
 | 
			
		||||
  public time?: string
 | 
			
		||||
  public totalDistance?: number
 | 
			
		||||
  public totalTime?: number
 | 
			
		||||
  public date?: string
 | 
			
		||||
  public fd?: number
 | 
			
		||||
  private fileUtil?: FileUtils
 | 
			
		||||
 | 
			
		||||
  constructor() {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //   初始化文件夹
 | 
			
		||||
  async initializeTheDrivingDataFolder() {
 | 
			
		||||
    const folderPath = await this.fileUtil.initFolder(`/车辆行驶距离统计`);
 | 
			
		||||
    const folderPath = await this.fileUtil!.initFolder(`/车辆行驶距离统计`);
 | 
			
		||||
    this.time = dayTs().format("HH:mm:ss")
 | 
			
		||||
    this.date = dayTs().format("YYYY_MM_DD")
 | 
			
		||||
    this.folderPath = folderPath;
 | 
			
		||||
    this.totalDistance = 0;
 | 
			
		||||
    this.totalTime = 0;
 | 
			
		||||
    this.fd = await this.fileUtil.editFile(
 | 
			
		||||
    this.fd = await this.fileUtil!.editFile(
 | 
			
		||||
      `${folderPath}/${this.date}.txt`,
 | 
			
		||||
      `程序启动时间:${this.time} 累计行驶距离:${this.totalDistance}m 累计运行时常:${this.totalTime}min`)
 | 
			
		||||
    return folderPath
 | 
			
		||||
@ -30,12 +30,13 @@ class drivingDataStorage {
 | 
			
		||||
 | 
			
		||||
  // 设置行驶过程数据
 | 
			
		||||
  async setDrivingProcessData(str: number) {
 | 
			
		||||
    const content = await this.fileUtil.readFile(`${this.folderPath}/${this.date}.txt`) || '';
 | 
			
		||||
    const content = await this.fileUtil!.readFile(`${this.folderPath}/${this.date}.txt`) || '';
 | 
			
		||||
    const contentArr = content.split('\n').filter(item => item)
 | 
			
		||||
    this.totalDistance += (str * 1 > 200 ? 200 : str * 1)
 | 
			
		||||
    this.totalTime += 1;
 | 
			
		||||
    this.totalDistance = (this.totalDistance || 0) + (str * 1 > 200 ? 200 : str * 1);
 | 
			
		||||
    this.totalTime = (this.totalTime || 0) + 1;
 | 
			
		||||
    contentArr[contentArr.length - 1] =
 | 
			
		||||
      `程序启动时间:${this.time} 累计行驶距离:${(this.totalDistance).toFixed(2)}m 累计运行时常:${Math.ceil(this.totalTime /
 | 
			
		||||
      `程序启动时间:${this.time} 累计行驶距离:${(this.totalDistance ||
 | 
			
		||||
        0).toFixed(2)}m 累计运行时常:${Math.ceil((this.totalTime || 0) /
 | 
			
		||||
        60)}min` + '\n'
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -46,7 +47,7 @@ class drivingDataStorage {
 | 
			
		||||
 | 
			
		||||
  //   关闭文件读写
 | 
			
		||||
  public close() {
 | 
			
		||||
    this.fileUtil.closeFile(`${this.folderPath}/${this.date}.txt`)
 | 
			
		||||
    this.fileUtil!.closeFile(`${this.folderPath}/${this.date}.txt`)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -11,7 +11,10 @@ import FileUtils from '../FileUtils';
 | 
			
		||||
// 建表操作
 | 
			
		||||
export async function InitTable() {
 | 
			
		||||
  Object.keys(ParameterPlatform).forEach(async (item) => {
 | 
			
		||||
    await DB.executeSql(ParameterPlatform.get(item).sqlCreate);
 | 
			
		||||
    const platformItem = ParameterPlatform.get(item);
 | 
			
		||||
    if (platformItem) {
 | 
			
		||||
      await DB.executeSql(platformItem.sqlCreate);
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -56,12 +59,16 @@ 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 platform = ParameterPlatform.get(tableName);
 | 
			
		||||
    if (!platform || !platform.columns) {
 | 
			
		||||
      throw new Error(`Invalid tableName or columns not found for table: ${tableName}`);
 | 
			
		||||
    }
 | 
			
		||||
    const columns: ColumnInfo[] = platform.columns.map((res: string) => {
 | 
			
		||||
      return {
 | 
			
		||||
        name: res,
 | 
			
		||||
        columnName: res,
 | 
			
		||||
        type: ColumnType.STRING
 | 
			
		||||
      } as ColumnInfo
 | 
			
		||||
      } as ColumnInfo;
 | 
			
		||||
    });
 | 
			
		||||
    DB.queryListBySql<T>(`select * from ${tableName}`, columns).then((res: T[]) => {
 | 
			
		||||
      resolve(res);
 | 
			
		||||
@ -87,7 +94,7 @@ export async function DeleteSyncTable(tableName: string): Promise<boolean> {
 | 
			
		||||
// 初始化中心表
 | 
			
		||||
export async function InitializeTheCentralTable(params: InitializeTheCentralTableType): Promise<boolean> {
 | 
			
		||||
  return new Promise(async (resolve, reject) => {
 | 
			
		||||
    const fileUtil = new FileUtils(params.context)
 | 
			
		||||
    const fileUtil = new FileUtils(params.context!);
 | 
			
		||||
    let flag = false
 | 
			
		||||
    // 单机模式
 | 
			
		||||
    if (params.singlePlay) {
 | 
			
		||||
@ -119,9 +126,10 @@ export async function InitializeTheCentralTable(params: InitializeTheCentralTabl
 | 
			
		||||
      host: params.host
 | 
			
		||||
    }
 | 
			
		||||
    const res: ResponseDataType = await initialization(str)
 | 
			
		||||
    if (!res || res.initializationRsp.head.resultCode == "1") {
 | 
			
		||||
      resolve(false)
 | 
			
		||||
    if (!res || !res.initializationRsp || res.initializationRsp.head.resultCode === "1") {
 | 
			
		||||
      resolve(false);
 | 
			
		||||
    }
 | 
			
		||||
    if (res.initializationRsp && res.initializationRsp.body) {
 | 
			
		||||
      for (const key of Object.keys(res.initializationRsp.body)) {
 | 
			
		||||
        if (CenterMap[key]) {
 | 
			
		||||
          continue
 | 
			
		||||
@ -136,7 +144,7 @@ export async function InitializeTheCentralTable(params: InitializeTheCentralTabl
 | 
			
		||||
        const folderPath = await fileUtil.initFolder(`/config/tableList`);
 | 
			
		||||
        fileUtil.addFile(`${folderPath}/${RemappingTableName.get(key)}.txt`, JSON.stringify(arrList))
 | 
			
		||||
        try {
 | 
			
		||||
        const result = await SqlInsertTable(RemappingTableName.get(key), arrList)
 | 
			
		||||
          const result = await SqlInsertTable(RemappingTableName.get(key)!, arrList);
 | 
			
		||||
          if (!result) {
 | 
			
		||||
            Prompt.showToast({
 | 
			
		||||
              message: '初始化数据库失败'
 | 
			
		||||
@ -147,6 +155,7 @@ export async function InitializeTheCentralTable(params: InitializeTheCentralTabl
 | 
			
		||||
          reject(e)
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user