fix: 添加获取考车信息的参数类型定义,优化相关函数调用
This commit is contained in:
parent
deafc59c77
commit
e040b707dd
@ -1,6 +1,6 @@
|
||||
import request from "../utils/Request"
|
||||
import http from "@ohos.net.http"
|
||||
import { InitializeTheCentralTableType, ResponseDataType } from "../model"
|
||||
import { InitializeTheCentralTableType, ObtainCarExamInfoParams, ResponseDataType } from "../model"
|
||||
|
||||
interface timeSynchronizationParams {
|
||||
time: string
|
||||
@ -50,13 +50,9 @@ export async function timeSynchronizationHTTP(params: timeSynchronizationHTTPPar
|
||||
})
|
||||
}
|
||||
|
||||
interface obtainCarExamInfoParams {
|
||||
time: string
|
||||
deviceNo: string
|
||||
}
|
||||
|
||||
//获取考车信息
|
||||
export async function obtainCarExamInfo(params: obtainCarExamInfoParams) {
|
||||
export async function obtainCarExamInfo(params: ObtainCarExamInfoParams) {
|
||||
return request<object>({
|
||||
url: '/der2/services/exam/obtainCarExamInfo.ws',
|
||||
data: `<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
|
||||
//考官登录信息
|
||||
// export async function examinerLoginService(params) {
|
||||
// let res: any = await examinerLogin(params)
|
||||
// AppStorage.setOrCreate('examinerInfo', res?.examinerLoginRsp?.body)
|
||||
// console.log('jiangsong1: examinerLoginService' + JSON.stringify(res))
|
||||
// //{"examinerLoginRsp":{"head":{"resultCode":"0","resultMessage":"%E8%80%83%E8%AF%95%E5%91%98%E7%99%BB%E5%BD%95-%E6%88%90%E5%8A%9F","time":"2023-06-01 10:06:39"},"body":{"code":"006","name":"%E8%80%836","statusRgpp":"1"}}}
|
||||
// return res
|
||||
// }
|
||||
|
||||
//获取考车信息
|
||||
// export async function initParseCarInfo(params) {
|
||||
// let res: any = await initCarInfoCache(params)
|
||||
// console.log('jiangsong1: examinerLoginService' + JSON.stringify(res))
|
||||
// //{"examinerLoginRsp":{"head":{"resultCode":"0","resultMessage":"%E8%80%83%E8%AF%95%E5%91%98%E7%99%BB%E5%BD%95-%E6%88%90%E5%8A%9F","time":"2023-06-01 10:06:39"},"body":{"code":"006","name":"%E8%80%836","statusRgpp":"1"}}}
|
||||
// return res
|
||||
// }
|
||||
@ -1,10 +1,8 @@
|
||||
// @ts-nocheck
|
||||
import promptAction from '@ohos.promptAction'
|
||||
import router from '@ohos.router'
|
||||
import { dateFormat } from '../utils/tools'
|
||||
import FileUtil from '../../common/utils/File'
|
||||
import { deleteAllFileByPiC, takePhoto } from '../../service/videoService'
|
||||
// import { VideoConfigData } from '../../mock';
|
||||
import {
|
||||
delSyncTable,
|
||||
getDataBaseTable,
|
||||
@ -90,7 +88,6 @@ export async function setVideoParam() {
|
||||
|
||||
}
|
||||
|
||||
let fileFd
|
||||
|
||||
//配置流水号
|
||||
export async function setliushuiNum() {
|
||||
@ -277,7 +274,6 @@ export async function takePhotoFn(context) {
|
||||
}, 3000)
|
||||
}
|
||||
|
||||
let fd
|
||||
const devPath = "/dev/ttyS3"
|
||||
let chuankoufd
|
||||
|
||||
|
||||
@ -1,48 +0,0 @@
|
||||
import { obtainCarExamInfo } from '../../api/index'
|
||||
import { dateFormat } from '../utils/tools'
|
||||
import promptAction from '@ohos.promptAction'
|
||||
import { GlobalConfig } from '../../config/index'
|
||||
import FileUtil from '../../common/utils/File'
|
||||
|
||||
//获取设备信息
|
||||
export async function getDeviceInfo(context) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const fileUtil = new FileUtil(context)
|
||||
const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/deviceNo.txt');
|
||||
if (data === '' || data === undefined) {
|
||||
promptAction.showToast({
|
||||
message: `请先进行设备注册`,
|
||||
duration: 3000
|
||||
});
|
||||
AppStorage.setOrCreate('type', 1)
|
||||
AppStorage.setOrCreate('title', '请先进行设备注册')
|
||||
globalThis.errorDialog.open()
|
||||
resolve('')
|
||||
} else {
|
||||
const fileData = JSON.parse(data)
|
||||
|
||||
AppStorage.setOrCreate('deviceNo', fileData.deviceName)
|
||||
// getCarInfo()
|
||||
resolve(fileData.deviceName)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//获取考车信息
|
||||
export async function getCarInfo() {
|
||||
let date = new Date();
|
||||
|
||||
let params = { time: dateFormat(date), deviceNo: AppStorage.get('deviceNo') };
|
||||
let res: any = await obtainCarExamInfo(params)
|
||||
if (!res?.obtainCarExamInfoRsp?.body) {
|
||||
// router.pushUrl({
|
||||
// url: 'pages/Register',
|
||||
// }, router.RouterMode.Single);
|
||||
} else {
|
||||
const carInfo=res.obtainCarExamInfoRsp.body
|
||||
carInfo.plateNo= decodeURIComponent(carInfo.plateNo)
|
||||
AppStorage.setOrCreate('carInfo',carInfo)
|
||||
|
||||
}
|
||||
return res
|
||||
}
|
||||
@ -78,4 +78,12 @@ export interface InitializeTheCentralTableType {
|
||||
host?: string
|
||||
videoVersion?: string
|
||||
context?: common.UIAbilityContext
|
||||
}
|
||||
|
||||
// 以下是各个表的类型
|
||||
export interface MASYSSETTableType {
|
||||
id?: string
|
||||
v_no?: string
|
||||
v_name?: string
|
||||
v_value?: string
|
||||
}
|
||||
@ -77,3 +77,8 @@ interface CarConfigurationInfoResponseBody {
|
||||
interface ES_CHECK_CAR_ITEMItem {
|
||||
ITEMS: string;
|
||||
}
|
||||
|
||||
export interface ObtainCarExamInfoParams {
|
||||
time: string
|
||||
deviceNo: string
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import common from '@ohos.app.ability.common';
|
||||
import router from '@ohos.router';
|
||||
import { getCarInfo, getDeviceInfo } from '../common/service/terminalService';
|
||||
|
||||
import { getCurrentTime, setCurrentTime, string2Bytes } from '../common/utils/tools';
|
||||
import { FileHelper } from '../common/service/FileHelper';
|
||||
import { getEsCarModel, getSyncData, } from '../common/service/initable';
|
||||
@ -14,15 +14,15 @@ import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
|
||||
import promptAction from '@ohos.promptAction';
|
||||
import errorMsgDialog from './compontents/errorMsgDialog';
|
||||
import GetDistance from '../common/utils/GetDistance';
|
||||
import UdpEvent from '../common/utils/UdpEvent';
|
||||
import { delPic } from '../service/videoService';
|
||||
import imageBtn from './compontents/imageBtn';
|
||||
import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements';
|
||||
import { BaseInfoType } from '../model/Common';
|
||||
import { CarInfoType } from '../model/CarCheck';
|
||||
import { TimeInfo } from '../model';
|
||||
import { MASYSSETTableType, TimeInfo } from '../model';
|
||||
import { GetCarInfo, GetDeviceInfo } from './index/utils';
|
||||
import { GetSyncData } from '../utils/table/Operation';
|
||||
|
||||
// import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
@ -364,29 +364,19 @@ struct Index {
|
||||
this.angle = 0
|
||||
this.loading = false
|
||||
AppStorage.set('lsh', '1111111111111')
|
||||
globalThis.errorDialog = this.errorDialog
|
||||
globalThis.udpEvent = new UdpEvent();
|
||||
getSyncData('MA_SYSSET').then(async data => {
|
||||
data.forEach(async sys => {
|
||||
//判断是否能点开始考试
|
||||
if (sys.v_no === '305') {
|
||||
console.log('syssyssyssys')
|
||||
// this.delLoading=true
|
||||
// globalThis.param854Str=sys.v_value
|
||||
delPic(Number(sys.v_value), 1)
|
||||
delPic(Number(sys.v_value), 2)
|
||||
// this.delLoading=false
|
||||
|
||||
// globalThis.errorDialog = this.errorDialog
|
||||
// globalThis.udpEvent = new UdpEvent();
|
||||
GetSyncData<MASYSSETTableType>("MA_SYSSET").then((res: MASYSSETTableType[]) => {
|
||||
res.forEach((element) => {
|
||||
if (element.v_no === "305") {
|
||||
delPic(Number(element.v_value), 1)
|
||||
delPic(Number(element.v_value), 2)
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
aboutToDisappear() {
|
||||
// this.vocObj && this.vocObj.releasePlayer()
|
||||
}
|
||||
|
||||
async testXMLToJSONInWorker() {
|
||||
if (this.loading) {
|
||||
return
|
||||
@ -594,9 +584,8 @@ struct Index {
|
||||
//设置plc udp 同步requesthost
|
||||
await getUDP(this.context, false)
|
||||
this.loading = false
|
||||
await getDeviceInfo(this.context)
|
||||
|
||||
await getCarInfo()
|
||||
await GetDeviceInfo(this.context)
|
||||
await GetCarInfo()
|
||||
await getUDP2(this.context, false)
|
||||
getTCP()
|
||||
this.carInfo = AppStorage.get('carInfo')
|
||||
|
||||
42
entry/src/main/ets/pages/index/utils.ets
Normal file
42
entry/src/main/ets/pages/index/utils.ets
Normal file
@ -0,0 +1,42 @@
|
||||
import common from "@ohos.app.ability.common";
|
||||
import FileUtil from "../../common/utils/File";
|
||||
import { GlobalConfig } from "../../config";
|
||||
import Prompt from "@system.prompt";
|
||||
import { CarConfigurationParamsType, ObtainCarExamInfoParams } from "../../model";
|
||||
import dayTs from "../../utils/Date";
|
||||
import { obtainCarExamInfo } from "../../api";
|
||||
|
||||
//获取设备信息
|
||||
export async function GetDeviceInfo(context: common.UIAbilityContext): Promise<string> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const fileUtil = new FileUtil(context)
|
||||
const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/deviceNo.txt');
|
||||
if (data === '' || data === undefined) {
|
||||
Prompt.showToast({
|
||||
message: "请先进行设备注册!",
|
||||
duration: 3000
|
||||
})
|
||||
AppStorage.setOrCreate('type', 1)
|
||||
AppStorage.setOrCreate('title', '请先进行设备注册')
|
||||
resolve("")
|
||||
} else {
|
||||
const fileData: CarConfigurationParamsType = JSON.parse(data)
|
||||
AppStorage.setOrCreate('deviceNo', fileData.deviceName)
|
||||
resolve(fileData.deviceName)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export async function GetCarInfo() {
|
||||
let date = new Date();
|
||||
let params: ObtainCarExamInfoParams = {
|
||||
time: dayTs(date).format("YYYY-MM-DD HH:mm:ss"),
|
||||
deviceNo: AppStorage.get('deviceNo')
|
||||
};
|
||||
let res: ESObject = await obtainCarExamInfo(params)
|
||||
if (res.obtainCarExamInfoRsp.body) {
|
||||
const carInfo: ESObject = res?.obtainCarExamInfoRsp?.body
|
||||
carInfo.plateNo = decodeURIComponent(carInfo.plateNo)
|
||||
AppStorage.setOrCreate('carInfo', carInfo)
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,7 @@ import { FileHelper } from '../common/service/FileHelper';
|
||||
import FileUtil from '../common/utils/File';
|
||||
import { GlobalConfig } from '../config';
|
||||
import promptAction from '@ohos.promptAction';
|
||||
import common from '@ohos.app.ability.common';
|
||||
|
||||
const rtsp_server = record.createServer();
|
||||
//开始录屏
|
||||
@ -82,7 +83,7 @@ export async function endRecordVideo(record_handleObj) {
|
||||
|
||||
export async function saveStartRecordVideo(path) {
|
||||
return new Promise(async (reslove, reject) => {
|
||||
const context=AppStorage.get('context')
|
||||
const context = AppStorage.get('context')
|
||||
const fileUtil = new FileUtil(context)
|
||||
const fileHelper = new FileHelper();
|
||||
const date = dateFormat(new Date).split(' ')[0]
|
||||
@ -110,7 +111,7 @@ export async function saveStartRecordVideo(path) {
|
||||
async function getfilehandleCode(td, param, dir, path, index) {
|
||||
return new Promise(async (reslove, reject) => {
|
||||
console.log('pathpath1', path)
|
||||
const context=AppStorage.get('context')
|
||||
const context = AppStorage.get('context')
|
||||
|
||||
const record_handle = await startRecordVideo(param, td, context, dir, path, index)
|
||||
// this.rocordHandleObj['rocord_handle'+td] = record_handle
|
||||
@ -132,7 +133,7 @@ export async function getUserAlbumItemByDisplayName(displayName: string, day?,
|
||||
fetchColumns: [],
|
||||
predicates: predicates
|
||||
};
|
||||
const context=AppStorage.get('context')
|
||||
const context = AppStorage.get('context')
|
||||
const userFileMgr = photoAccessHelper.getPhotoAccessHelper(context);
|
||||
|
||||
fetchResult =
|
||||
@ -182,8 +183,8 @@ interface takePhotoParam {
|
||||
*/
|
||||
const fileHelper = new FileHelper();
|
||||
|
||||
export async function delPic(day, type) {
|
||||
const context=AppStorage.get('context')
|
||||
export async function delPic(day: number, type: number) {
|
||||
const context: common.UIAbilityContext = AppStorage.get('context')
|
||||
let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
|
||||
console.info('albumGetAssetsDemoCallback');
|
||||
let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
|
||||
@ -255,7 +256,7 @@ export async function takePhoto(param, context, dir, flag = 1, callback?) {
|
||||
|
||||
export async function deleteAllPicturesFn() {
|
||||
fileHelper.deleteAllPictures();
|
||||
const context=AppStorage.get('context')
|
||||
const context = AppStorage.get('context')
|
||||
deleteAllVideos(context, photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.VIDEO)
|
||||
|
||||
}
|
||||
|
||||
@ -6,7 +6,6 @@ import Prompt from '@system.prompt';
|
||||
import { initialization } from '../../api';
|
||||
import FileUtil from '../../common/utils/File';
|
||||
import { GlobalConfig } from '../../config';
|
||||
import { sqlInsertCommonFn } from '../../common/service/initable';
|
||||
|
||||
// 建表操作
|
||||
export async function InitTable() {
|
||||
@ -54,7 +53,7 @@ export function UpdateTableByArray(tableName: string, arr: Array<User>): Promise
|
||||
|
||||
|
||||
//依据表名同步获取数据
|
||||
export async function GetSyncData(tableName: string): Promise<boolean> {
|
||||
export async function GetSyncData<T>(tableName: string): Promise<T[]> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const columns: ColumnInfo[] = ParameterPlatform[tableName].columns.map((res: string) => {
|
||||
return {
|
||||
@ -62,14 +61,13 @@ export async function GetSyncData(tableName: string): Promise<boolean> {
|
||||
columnName: res,
|
||||
type: ColumnType.STRING
|
||||
} as ColumnInfo
|
||||
})
|
||||
// TODO 需要完善此处类型
|
||||
DB.queryListBySql<ESObject>(`select * from ${tableName}`, columns).then(() => {
|
||||
resolve(true)
|
||||
});
|
||||
DB.queryListBySql<T>(`select * from ${tableName}`, columns).then((res: T[]) => {
|
||||
resolve(res);
|
||||
}).catch((err: BusinessError) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// TODO 后续废弃这个方法,直接调用DB.deleteByName
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user