设备注册修改

This commit is contained in:
lvyuankang 2024-07-17 10:19:16 +08:00
parent a3f04ed436
commit 43a673fa4f
4 changed files with 51 additions and 41 deletions

View File

@ -3,26 +3,29 @@ import { obtainCarExamInfo} from '../../api/index'
import { dateFormat } from '../utils/tools'
import router from '@ohos.router'
import { getSyncData } from '../../common/service/initable'
import { GlobalConfig } from '../../config/index'
import FileUtil from '../../common/utils/File'
//获取设备信息
export async function getDeviceInfo() {
export async function getDeviceInfo(context) {
// globalThis.deviceNo = '153216400880'; //科目三设备
globalThis.deviceNo = '150667400235'; //科目三设备
return new Promise((resolve, reject) => {
getSyncData('DeviceInfoTable').then((result: Array<any>) => {
if (result.length) {
globalThis.deviceNo = result[0].deviceId
getCarInfo()
resolve(result[0].deviceId)
} else {
// router.pushUrl({
// url: 'pages/Register',
// }, router.RouterMode.Single);
return
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) {
router.pushUrl({
url: 'pages/Register',
}, router.RouterMode.Single);
resolve('')
} else {
const fileData=JSON.parse(data)
globalThis.deviceNo = fileData.deviceName
getCarInfo()
resolve(fileData.deviceName)
}
})
})
}
//获取考车信息

View File

@ -10,5 +10,5 @@ export const GlobalConfig={
comoonfileWriteAddress:'/mnt/hmdfs/100/account/device_view/local/files',
picSavePath:'/storage/cloud/100/files/Photo/',
videoSavePath:'/storage/cloud/100/files/Videos/',
host:'http://172.37.55.191:8082'
host:'http://172.37.55.1912:8082'
}

View File

@ -161,7 +161,7 @@ struct Index {
)
)
Text('考车号:' + globalThis.deviceNo)
Text('考车号:' + this.deviceId)
.fontColor('#CCAE7A')
.fontSize(22 * globalThis.ratio)
.margin({ right: 24 })
@ -212,7 +212,6 @@ struct Index {
}
aboutToAppear() {
globalThis.ratio = 1700 / 960
this.angle = 0
this.loading = false
this.vocObj = new voiceService(async (status, val, next) => {
@ -338,13 +337,14 @@ struct Index {
async initParams() {
this.loading = false
await getDeviceInfo()
getCarInfo()
this.deviceId=await getDeviceInfo(this.context) || ''
await getCarInfo()
await setCurrentTime();
this.carNum = globalThis.carInfo.plateNo;
this.version = globalThis.version;
this.hasAuth = globalThis.hasAuth;
initJudgeUdp()
console.log('deviceIddeviceId',globalThis.deviceNo,this.deviceNo)
//下载模型
// await this.getModel()
// const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00]

View File

@ -4,6 +4,8 @@ import { dateFormat } from '../common/utils/tools'
import deviceManager from '@ohos.distributedHardware.deviceManager'
import { upDateTableByArray } from '../common/service/initable'
import promptAction from '@ohos.promptAction'
import FileUtil from '../common/utils/File'
import common from '@ohos.app.ability.common';
@Entry
@Component
@ -17,6 +19,7 @@ export default struct Index {
@State plateNo: string = ''
@State @Watch('outClick') outFlag: boolean = false;
@State subType: string = '2';
private context = getContext(this) as common.UIAbilityContext;
onPageShow() {
// this.plateNo=globalThis.carInfo.plateNo
@ -111,15 +114,19 @@ export default struct Index {
outClick() {
}
registrationDeviceNoFn() {
async registrationDeviceNoFn() {
const date = new Date()
const param = {
time: dateFormat(date),
deviceName: this.ip,
type: '1'
}
const fileUtil = new FileUtil(this.context)
const folderPath = await fileUtil.initFolder(`/config`);
fileUtil.addFile(`${folderPath}/deviceNo.txt`, JSON.stringify(param))
globalThis.deviceNo = this.ip
upDateTableByArray('DeviceInfoTable', [{ deviceId: this.ip }])
console.log('globalThis.deviceNo',globalThis.deviceNo)
// upDateTableByArray('DeviceInfoTable', [{ deviceId: this.ip }])
registrationDeviceNo(param).then(res => {
if (res.registrationDeviceNoRsp.head.resultCode == '0') {
promptAction.showToast({