refactor: 移除未使用的工具方法,优化代码结构和导入逻辑
This commit is contained in:
parent
c4623c8345
commit
89db5301ec
@ -1,11 +1,11 @@
|
|||||||
import request from '../utils/Request';
|
import request from '../utils/Request';
|
||||||
import { getCurrentTime } from '../common/utils/tools';
|
|
||||||
import { getSyncData } from '../common/service/initable';
|
import { getSyncData } from '../common/service/initable';
|
||||||
import writeObjectOutNew from './judgeNew';
|
import writeObjectOutNew from './judgeNew';
|
||||||
import FileUtil from '../common/utils/File';
|
import FileUtil from '../common/utils/File';
|
||||||
import http from '@ohos.net.http';
|
import http from '@ohos.net.http';
|
||||||
import { MASYSSETTableType, RegulatoryInterfaceParams } from '../model';
|
import { MASYSSETTableType, RegulatoryInterfaceParams } from '../model';
|
||||||
import { GetSyncData } from '../utils/table/Operation';
|
import { GetSyncData } from '../utils/table/Operation';
|
||||||
|
import { GetCurrentTime } from '../utils/Common';
|
||||||
|
|
||||||
let baseHost: string = AppStorage.get('host');
|
let baseHost: string = AppStorage.get('host');
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ export async function uploadExamMileage(params: UploadExamMileage) {
|
|||||||
if (singlePlay) {
|
if (singlePlay) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const time = await getCurrentTime()
|
const time = await GetCurrentTime()
|
||||||
return request<object>({
|
return request<object>({
|
||||||
url: '/der2/services/exam/uploadExamMileage.ws',
|
url: '/der2/services/exam/uploadExamMileage.ws',
|
||||||
data: `<?xml version="1.0" encoding="UTF-8"?>
|
data: `<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import promptAction from '@ohos.promptAction'
|
import promptAction from '@ohos.promptAction'
|
||||||
import router from '@ohos.router'
|
import router from '@ohos.router'
|
||||||
import { dateFormat } from '../utils/tools'
|
|
||||||
import FileUtil from '../../common/utils/File'
|
import FileUtil from '../../common/utils/File'
|
||||||
import { deleteAllFileByPiC, takePhoto } from '../../service/videoService'
|
import { deleteAllFileByPiC, takePhoto } from '../../service/videoService'
|
||||||
import {
|
import {
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import { initCenterCache, initCenterCacheByKSPT, initEsModel, initialization } from '../../api/index';
|
import { initCenterCache, initCenterCacheByKSPT, initEsModel, initialization } from '../../api/index';
|
||||||
import { dateFormat } from '../utils/tools';
|
|
||||||
import AccountTable from '../database/tables/AccountTable';
|
import AccountTable from '../database/tables/AccountTable';
|
||||||
import MA_MARKRULE from '../constants/MA_MARKRULE';
|
import MA_MARKRULE from '../constants/MA_MARKRULE';
|
||||||
import MA_SYSTEMPARM from '../constants/MA_SYSTEMPARM';
|
import MA_SYSTEMPARM from '../constants/MA_SYSTEMPARM';
|
||||||
|
|||||||
@ -1,74 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file 日期工具
|
|
||||||
*/
|
|
||||||
|
|
||||||
const NINE = 9; // 这是数字9
|
|
||||||
|
|
||||||
export default class DateTimeUtil {
|
|
||||||
/**
|
|
||||||
* 时分秒
|
|
||||||
*/
|
|
||||||
getTime(): string {
|
|
||||||
const DATETIME = new Date();
|
|
||||||
return this.concatTime(
|
|
||||||
DATETIME.getHours(),
|
|
||||||
DATETIME.getMinutes(),
|
|
||||||
DATETIME.getSeconds()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 年月日
|
|
||||||
*/
|
|
||||||
getDate(): string {
|
|
||||||
const DATETIME = new Date();
|
|
||||||
return this.concatDate(
|
|
||||||
DATETIME.getFullYear(),
|
|
||||||
DATETIME.getMonth() + 1,
|
|
||||||
DATETIME.getDate()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 日期不足两位补充0
|
|
||||||
* @param value-数据值
|
|
||||||
*/
|
|
||||||
fill(value: number): string {
|
|
||||||
return (value > NINE ? '' : '0') + value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 年月日格式修饰
|
|
||||||
* @param year
|
|
||||||
* @param month
|
|
||||||
* @param date
|
|
||||||
*/
|
|
||||||
concatDate(year: number, month: number, date: number): string {
|
|
||||||
return `${year}${this.fill(month)}${this.fill(date)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 时分秒格式修饰
|
|
||||||
* @param hours
|
|
||||||
* @param minutes
|
|
||||||
* @param seconds
|
|
||||||
*/
|
|
||||||
concatTime(hours: number, minutes: number, seconds: number): string {
|
|
||||||
return `${this.fill(hours)}${this.fill(minutes)}${this.fill(seconds)}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
export default {
|
|
||||||
comoonfileWriteAddress:'/mnt/hmdfs/100/account/device_view/local/files',
|
|
||||||
videoSavePath:'/mnt/hmdfs/100/account/device_view/local/files/Videos/',
|
|
||||||
picSavePath:'/mnt/hmdfs/100/account/device_view/local/files/Pictures/'
|
|
||||||
}
|
|
||||||
@ -2,8 +2,6 @@
|
|||||||
import UdpClientByCenter from './UdpClientByCenter';
|
import UdpClientByCenter from './UdpClientByCenter';
|
||||||
import { getChuankouFn } from '../../common/service/indexService';
|
import { getChuankouFn } from '../../common/service/indexService';
|
||||||
import FileUtil from '../../common/utils/File';
|
import FileUtil from '../../common/utils/File';
|
||||||
import { GlobalConfig } from '../../config/index';
|
|
||||||
import { Array2Byte, string2Bytes } from './tools';
|
|
||||||
|
|
||||||
export async function sendMsg(val) {
|
export async function sendMsg(val) {
|
||||||
// globalThis.udpClient1&&globalThis.udpClient1.sendMsg(val)
|
// globalThis.udpClient1&&globalThis.udpClient1.sendMsg(val)
|
||||||
|
|||||||
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import hilog from '@ohos.hilog';
|
|
||||||
|
|
||||||
class Logger {
|
|
||||||
private domain: number;
|
|
||||||
private prefix: string;
|
|
||||||
private format: string = '%{public}s, %{public}s';
|
|
||||||
|
|
||||||
constructor(prefix: string) {
|
|
||||||
this.prefix = prefix;
|
|
||||||
this.domain = 0xff00;
|
|
||||||
}
|
|
||||||
|
|
||||||
debug(...args: string[]): void {
|
|
||||||
hilog.debug(this.domain, this.prefix, this.format, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
info(...args: string[]): void {
|
|
||||||
hilog.info(this.domain, this.prefix, this.format, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
warn(...args: string[]): void {
|
|
||||||
hilog.warn(this.domain, this.prefix, this.format, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
error(...args: string[]): void {
|
|
||||||
hilog.error(this.domain, this.prefix, this.format, args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default new Logger('[Samples_Camera]');
|
|
||||||
@ -3,7 +3,6 @@ import hilog from '@ohos.hilog';
|
|||||||
import { getTCP } from './GlobalTcp';
|
import { getTCP } from './GlobalTcp';
|
||||||
import prompt from '@ohos.prompt';
|
import prompt from '@ohos.prompt';
|
||||||
import FileUtil from './File';
|
import FileUtil from './File';
|
||||||
import { dateFormat } from './tools';
|
|
||||||
import App from '@system.app';
|
import App from '@system.app';
|
||||||
|
|
||||||
const TAG = 'socketTag[TcpDemo.TcpClient]'
|
const TAG = 'socketTag[TcpDemo.TcpClient]'
|
||||||
@ -13,8 +12,10 @@ export default class TcpClient {
|
|||||||
private localIpPort: string = ''
|
private localIpPort: string = ''
|
||||||
private oppositeIp: string = ''
|
private oppositeIp: string = ''
|
||||||
private oppositeIpPort: string = ''
|
private oppositeIpPort: string = ''
|
||||||
private num: number = 0//重连次数
|
private num: number = 0
|
||||||
private tcpSendNum: number = 0//重连次数
|
//重连次数
|
||||||
|
private tcpSendNum: number = 0
|
||||||
|
//重连次数
|
||||||
private folderPath
|
private folderPath
|
||||||
|
|
||||||
private tcp: any = null
|
private tcp: any = null
|
||||||
@ -50,7 +51,6 @@ export default class TcpClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bindTcp() {
|
bindTcp() {
|
||||||
this.writeLog({
|
this.writeLog({
|
||||||
time: dateFormat(new Date()),
|
time: dateFormat(new Date()),
|
||||||
@ -198,16 +198,19 @@ export default class TcpClient {
|
|||||||
// callback(value.message)
|
// callback(value.message)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async writeLog(param) {
|
async writeLog(param) {
|
||||||
// const fileUtil = new FileUtil(globalThis.context)
|
// const fileUtil = new FileUtil(globalThis.context)
|
||||||
// fileUtil.editFile(`${this.folderPath}/plcLog.txt`, JSON.stringify(param)+`\n`)
|
// fileUtil.editFile(`${this.folderPath}/plcLog.txt`, JSON.stringify(param)+`\n`)
|
||||||
}
|
}
|
||||||
|
|
||||||
async initPath() {
|
async initPath() {
|
||||||
return
|
return
|
||||||
const fileUtil = new FileUtil(globalThis.context)
|
const fileUtil = new FileUtil(globalThis.context)
|
||||||
const date = dateFormat(new Date).split(' ')[0]
|
const date = dateFormat(new Date).split(' ')[0]
|
||||||
this.folderPath = await fileUtil.initFolder(`/PLC/${date}`);
|
this.folderPath = await fileUtil.initFolder(`/PLC/${date}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
offTcp(callback) {
|
offTcp(callback) {
|
||||||
console.log(TAG, 'tcpofff')
|
console.log(TAG, 'tcpofff')
|
||||||
this.tcp.off('testTagofmessg', callback);
|
this.tcp.off('testTagofmessg', callback);
|
||||||
|
|||||||
@ -15,21 +15,19 @@
|
|||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import socket, { UDPSocket } from '@ohos.net.socket';
|
import socket, { UDPSocket } from '@ohos.net.socket';
|
||||||
import { Array2Byte } from '../utils/tools'
|
|
||||||
import FileUtil from '../../common/utils/File'
|
import FileUtil from '../../common/utils/File'
|
||||||
import { fillZero, string2Bytes } from '../utils/tools'
|
|
||||||
|
|
||||||
const TAG = '[UdpDemo.UdpClient]'
|
const TAG = '[UdpDemo.UdpClient]'
|
||||||
import hilog from '@ohos.hilog';
|
import hilog from '@ohos.hilog';
|
||||||
import prompt from '@ohos.prompt'
|
import prompt from '@ohos.prompt'
|
||||||
import promptAction from '@ohos.promptAction';
|
import promptAction from '@ohos.promptAction';
|
||||||
import { getUDP } from './GlobalUdp';
|
import { getUDP } from './GlobalUdp';
|
||||||
import { dateFormat } from '../utils/tools'
|
|
||||||
import { getSyncData } from '../service/initable';
|
import { getSyncData } from '../service/initable';
|
||||||
import App from '@system.app';
|
import App from '@system.app';
|
||||||
|
|
||||||
|
|
||||||
export default class UdpClientByCenter {
|
export default class UdpClientByCenter {
|
||||||
|
public currentValue: string = ''
|
||||||
private localIp: string = ''
|
private localIp: string = ''
|
||||||
private localIpPort: string = ''
|
private localIpPort: string = ''
|
||||||
private oppositeIp: string = ''
|
private oppositeIp: string = ''
|
||||||
@ -50,9 +48,6 @@ export default class UdpClientByCenter {
|
|||||||
private isWorking: Boolean = false
|
private isWorking: Boolean = false
|
||||||
private plcUdpError = false;
|
private plcUdpError = false;
|
||||||
private initParam
|
private initParam
|
||||||
private onMessage_1Callback: Function = () => {
|
|
||||||
}
|
|
||||||
public currentValue: string = ''
|
|
||||||
|
|
||||||
constructor(udplocalIp: string, udplocalIpPort: string, udpOppositeIp: string, udpOppositeIpPort: string) {
|
constructor(udplocalIp: string, udplocalIpPort: string, udpOppositeIp: string, udpOppositeIpPort: string) {
|
||||||
this.localIp = udplocalIp
|
this.localIp = udplocalIp
|
||||||
@ -129,9 +124,6 @@ export default class UdpClientByCenter {
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
//length消息体bufferlength id消息类型id bodyStr消息体string
|
|
||||||
// setMsyBody(id,bodyByte){
|
|
||||||
|
|
||||||
// {id: 31,list:[0,1,'0000000000000'],carNo:489,placeId:62}
|
// {id: 31,list:[0,1,'0000000000000'],carNo:489,placeId:62}
|
||||||
setWholeMsg(params) {
|
setWholeMsg(params) {
|
||||||
let head = this.setMsgHead(params);
|
let head = this.setMsgHead(params);
|
||||||
@ -144,6 +136,9 @@ export default class UdpClientByCenter {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//length消息体bufferlength id消息类型id bodyStr消息体string
|
||||||
|
// setMsyBody(id,bodyByte){
|
||||||
|
|
||||||
setMsgHead({ id, list, placeId=62, carNo=489 }) {
|
setMsgHead({ id, list, placeId=62, carNo=489 }) {
|
||||||
let a = string2Bytes(`${id}${fillZero(placeId, 3)}`, 2 * 8);
|
let a = string2Bytes(`${id}${fillZero(placeId, 3)}`, 2 * 8);
|
||||||
let b = string2Bytes(`${fillZero(carNo, 4)}${AppStorage.get('lshNo')}`, 4 * 8);
|
let b = string2Bytes(`${fillZero(carNo, 4)}${AppStorage.get('lshNo')}`, 4 * 8);
|
||||||
@ -399,6 +394,9 @@ export default class UdpClientByCenter {
|
|||||||
}, 2000)
|
}, 2000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private onMessage_1Callback: Function = () => {
|
||||||
|
}
|
||||||
|
|
||||||
// initHeartSendMsg(param,context){
|
// initHeartSendMsg(param,context){
|
||||||
// console.log('1111param',JSON.stringify(param))
|
// console.log('1111param',JSON.stringify(param))
|
||||||
// this.initParam=param
|
// this.initParam=param
|
||||||
|
|||||||
@ -1,11 +1,8 @@
|
|||||||
import systemTime from '@ohos.systemDateTime';
|
import systemTime from '@ohos.systemDateTime';
|
||||||
import { Array2Byte, fillZero, string2Bytes, stringToASC } from '../../common/utils/tools';
|
|
||||||
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 { convertGpsCoord2 } from '../utils/tools';
|
|
||||||
import { examCalcGpsDistance } from '../../pages/judgeSDK/api'
|
import { examCalcGpsDistance } from '../../pages/judgeSDK/api'
|
||||||
import GetDistance from '../utils/GetDistance'
|
|
||||||
|
|
||||||
export const initJudgeUdp = async () => {
|
export const initJudgeUdp = async () => {
|
||||||
AppStorage.setOrCreate('serialIndex', 0)
|
AppStorage.setOrCreate('serialIndex', 0)
|
||||||
|
|||||||
@ -1,11 +0,0 @@
|
|||||||
export default class SingleInterval{
|
|
||||||
private interval:number=-1
|
|
||||||
constructor(time:number,callback) {
|
|
||||||
this.interval = setInterval(()=>{
|
|
||||||
callback()
|
|
||||||
},time||6000)
|
|
||||||
}
|
|
||||||
clear(){
|
|
||||||
clearInterval(this.interval)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,278 +0,0 @@
|
|||||||
import systemTime from '@ohos.systemDateTime';
|
|
||||||
|
|
||||||
// export function isSevenDaysAgo(date, days = 2) {
|
|
||||||
// const today = new Date(); // 当前日期
|
|
||||||
// const target = new Date(date); // 需要判断的日期
|
|
||||||
// console.info("listFile succeed1", JSON.stringify(target));
|
|
||||||
//
|
|
||||||
// const diff = today.getTime() - target.getTime(); // 计算两个日期之间的毫秒数差异
|
|
||||||
// const diffDays = diff / (1000 * 60 * 60 * 24); // 将毫秒转换为天数
|
|
||||||
// console.info("listFile succeed2", JSON.stringify(diffDays));
|
|
||||||
// // 如果差异天数正好是2,则原日期是当前日期的前2天
|
|
||||||
// console.log('diffDays', diffDays, days)
|
|
||||||
// return diffDays >= (Number(days));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// export async function writeLog(path,param){
|
|
||||||
// return
|
|
||||||
// const fileUtil = new FileUtil(globalThis.context)
|
|
||||||
// const date=dateFormat(new Date).split(' ')[0]
|
|
||||||
// const folderPath = await fileUtil.initFolder(`/${path}/${date}`);
|
|
||||||
// fileUtil.editFile(`${folderPath}/plcLog.txt`, JSON.stringify(param)+`\n`)
|
|
||||||
// }
|
|
||||||
///**时间格式化*/
|
|
||||||
//export function dateFormat(fmt, date) {
|
|
||||||
// var ret;
|
|
||||||
// const opt = {
|
|
||||||
// "y+": date.getFullYear().toString(), // 年
|
|
||||||
// "m+": (date.getMonth() + 1).toString(), // 月
|
|
||||||
// "d+": date.getDate().toString(), // 日
|
|
||||||
// "H+": date.getHours().toString(), // 时
|
|
||||||
// "M+": date.getMinutes().toString(), // 分
|
|
||||||
// "S+": date.getSeconds().toString() // 秒
|
|
||||||
// // 有其他格式化字符需求可以继续添加,必须转化成字符串
|
|
||||||
// };
|
|
||||||
// for (var k in opt) {
|
|
||||||
// ret = new RegExp("(" + k + ")").exec(fmt);
|
|
||||||
// if (ret) {
|
|
||||||
// fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
|
|
||||||
// };
|
|
||||||
// };
|
|
||||||
// return fmt;
|
|
||||||
//}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 日期不足两位补 0
|
|
||||||
*
|
|
||||||
* @param {string} value - 数据值
|
|
||||||
* @return {string} - 日期不足两位补 0
|
|
||||||
*/
|
|
||||||
function fill(value: number) {
|
|
||||||
return (value > 9 ? '' : '0') + value;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function dateFormat(t) {
|
|
||||||
let year = t.getFullYear()
|
|
||||||
let month = t.getMonth() + 1
|
|
||||||
let day = t.getDate()
|
|
||||||
let hours = t.getHours()
|
|
||||||
let minutes = t.getMinutes()
|
|
||||||
let seconds = t.getSeconds()
|
|
||||||
return year + "-" + fill(month) + "-" + fill(day) + " " + fill(hours) + ":" + fill(minutes) + ":" + fill(seconds);
|
|
||||||
}
|
|
||||||
|
|
||||||
// export function dateVersionFormat(t) {
|
|
||||||
// let year = t.getFullYear()
|
|
||||||
// let month = t.getMonth() + 1
|
|
||||||
// let day = t.getDate()
|
|
||||||
// let hours = t.getHours()
|
|
||||||
// let minutes = t.getMinutes()
|
|
||||||
// let seconds = t.getSeconds()
|
|
||||||
// return year + "." + fill(month) + "." + fill(day) + "." + fill(hours);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
//同步时时间
|
|
||||||
// export async function timeSynchronize() {
|
|
||||||
// let date = new Date();
|
|
||||||
// console.info('jiangsong1:timeSynchronization begin ');
|
|
||||||
//
|
|
||||||
// let params = {
|
|
||||||
// time: dateFormat(date),
|
|
||||||
// deviceNo: AppStorage.get('deviceNo'),
|
|
||||||
// version: AppStorage.get('baseInfo').version,
|
|
||||||
// judgeVersion: AppStorage.get('baseInfo').judgeVersion
|
|
||||||
// }
|
|
||||||
// let res: any = await timeSynchronization(params)
|
|
||||||
// res = res.timeSynchronizationRsp;
|
|
||||||
// AppStorage.setOrCreate('timeInfo', res.body)
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// return res;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// export async function setCurrentTime(): Promise<void> {
|
|
||||||
// let res = await timeSynchronize();
|
|
||||||
// let currentTime = res.head.time;
|
|
||||||
// let times = new Date(currentTime).getTime();
|
|
||||||
// console.log('jiangsong:times==' + times);
|
|
||||||
// try {
|
|
||||||
// await systemTime.setTime(times);
|
|
||||||
// // systemTime.setTime(times).then(() => {
|
|
||||||
// // console.info(`Succeeded in setting time.`);
|
|
||||||
// // }).catch((error) => {
|
|
||||||
// // console.info(`Failed to set time. message: ${error.message}, code: ${error.code}`);
|
|
||||||
// // });
|
|
||||||
// } catch (e) {
|
|
||||||
// console.info(`Failed to set time. message: ${e.message}, code: ${e.code}`);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
enum timeType {
|
|
||||||
fulltime = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
//获取当前时间并转化
|
|
||||||
export async function getCurrentTime(type?: timeType): Promise<string> {
|
|
||||||
const date = await systemTime.getDate();
|
|
||||||
const year = date.getFullYear();
|
|
||||||
let month = date.getMonth() + 1;
|
|
||||||
month = month < 10 ? '0' + month : month;
|
|
||||||
let dates = date.getDate();
|
|
||||||
dates = dates < 10 ? '0' + dates : dates;
|
|
||||||
let h = date.getHours();
|
|
||||||
h = h < 10 ? '0' + h : h;
|
|
||||||
let m = date.getMinutes();
|
|
||||||
m = m < 10 ? '0' + m : m;
|
|
||||||
let s = date.getSeconds();
|
|
||||||
s = s < 10 ? '0' + s : s;
|
|
||||||
if (type === 1) {
|
|
||||||
return `${year}${month}${dates}${h}${m}${s}`
|
|
||||||
} else {
|
|
||||||
return `${year}-${month}-${dates} ${h}:${m}:${s}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//获取时分秒毫秒
|
|
||||||
// export async function getCurrentHourTime(): Promise<string> {
|
|
||||||
//
|
|
||||||
// const date = await systemTime.getDate();
|
|
||||||
// const year = date.getFullYear();
|
|
||||||
// let month = date.getMonth() + 1;
|
|
||||||
// let h = date.getHours();
|
|
||||||
// h = h < 10 ? '0' + h : h;
|
|
||||||
// let m = date.getMinutes();
|
|
||||||
// m = m < 10 ? '0' + m : m;
|
|
||||||
// let s = date.getSeconds();
|
|
||||||
// s = s < 10 ? '0' + s : s;
|
|
||||||
// let ss = date.getMilliseconds();
|
|
||||||
// let nowSS = ''
|
|
||||||
// if (ss < 10) {
|
|
||||||
// nowSS = '00' + ss
|
|
||||||
// }
|
|
||||||
// if (ss >= 10 && ss < 100) {
|
|
||||||
// nowSS = '0' + s
|
|
||||||
// }
|
|
||||||
// return `${h}${m}${s}${nowSS || ss}`
|
|
||||||
// }
|
|
||||||
|
|
||||||
//时间戳转日期
|
|
||||||
// export function formatTime(time: number): string {
|
|
||||||
// const h = parseInt(time / 3600)
|
|
||||||
// const minute = parseInt(time / 60 % 60)
|
|
||||||
// const second = Math.ceil(time % 60)
|
|
||||||
//
|
|
||||||
// const hours = h < 10 ? '0' + h : h
|
|
||||||
// const formatSecond = second > 59 ? 59 : second
|
|
||||||
// return `${hours > 0 ? `${hours}:` : `${hours}:`}${minute < 10 ? '0' + minute : minute}:${formatSecond < 10 ?
|
|
||||||
// '0' + formatSecond : formatSecond}`
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// 根据指定个数分割数组
|
|
||||||
export function chunkArr(arr, size: number) {
|
|
||||||
//判断如果不是数组(就没有length),或者size没有传值,size小于1,就返回空数组
|
|
||||||
if (!arr.length || !size || size < 1) {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
let [start, end, result] = [null, null, []]
|
|
||||||
for (let i = 0; i < Math.ceil(arr.length / size); i++) {
|
|
||||||
start = i * size
|
|
||||||
end = start + size
|
|
||||||
result.push(arr.slice(start, end))
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
//对象深拷贝
|
|
||||||
export function deepClone(target) {
|
|
||||||
// 如果是对象,且不是原始值null
|
|
||||||
if (typeof target === 'object' && target !== 'null') {
|
|
||||||
// 创建容器
|
|
||||||
const result = Array.isArray(target) ? [] : {};
|
|
||||||
const keys = Object.keys(target); //注解二
|
|
||||||
// Object.keys()会过滤掉原型链上的属性
|
|
||||||
keys.forEach(key => {
|
|
||||||
result[key] = deepClone(target[key])
|
|
||||||
})
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
// 如果是原始值,则直接返回
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function stringToASC(str) {
|
|
||||||
const tempStr = str + '';
|
|
||||||
const strArr = tempStr.split('');
|
|
||||||
return strArr.map(str => str.charCodeAt())
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export function fillZero(str, len) {
|
|
||||||
str = str + '';
|
|
||||||
if (str.length > len || !len) {
|
|
||||||
return str
|
|
||||||
}
|
|
||||||
|
|
||||||
let num = len - str.length;
|
|
||||||
let zeroStr = '';
|
|
||||||
for (var i = 0; i < num; i++) {
|
|
||||||
zeroStr = zeroStr + '0'
|
|
||||||
}
|
|
||||||
|
|
||||||
return zeroStr + str;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 字符串转字节
|
|
||||||
export function string2Bytes(number, len) {
|
|
||||||
let str = (Math.floor(+number)).toString(2);
|
|
||||||
if (str.length > len) {
|
|
||||||
console.log('数据长度不对~~');
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var byteString = fillZero(str, len);
|
|
||||||
|
|
||||||
var arrBytes = new Array();
|
|
||||||
for (var i = byteString.length; i > 0; ) {
|
|
||||||
let j = i - 8;
|
|
||||||
if (j < 0) {
|
|
||||||
j = 0
|
|
||||||
}
|
|
||||||
var s = byteString.slice(j, i);
|
|
||||||
var v = parseInt(s, 2);
|
|
||||||
arrBytes.push(v);
|
|
||||||
i = i - 8
|
|
||||||
|
|
||||||
}
|
|
||||||
return arrBytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
//数组数据转字节
|
|
||||||
export function Array2Byte(array) {
|
|
||||||
var buf = new ArrayBuffer(array.length);
|
|
||||||
var view = new Uint8Array(buf);
|
|
||||||
for (var i = 0; i != array.length; ++i) {
|
|
||||||
view[i] = array[i] & 0xFF;
|
|
||||||
}
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
//经纬度转换
|
|
||||||
export function convertGpsCoord2(num) {
|
|
||||||
const tempNum = Math.floor(num);
|
|
||||||
const du = Math.floor(tempNum / 100);
|
|
||||||
const fen = tempNum % 100 + num - tempNum;
|
|
||||||
return du + fen / 60
|
|
||||||
}
|
|
||||||
|
|
||||||
export function debounce(fn, delay) {
|
|
||||||
// 利用闭包定义定时器id变量存储
|
|
||||||
let timer = null;
|
|
||||||
return () => {
|
|
||||||
// 如果有值就清除定时器,重新计时
|
|
||||||
if (timer) {
|
|
||||||
clearTimeout(timer)
|
|
||||||
}
|
|
||||||
timer = setTimeout(fn, delay);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because one or more lines are too long
@ -3,7 +3,6 @@ import hilog from '@ohos.hilog';
|
|||||||
import window from '@ohos.window';
|
import window from '@ohos.window';
|
||||||
import relationalStore from '@ohos.data.relationalStore'
|
import relationalStore from '@ohos.data.relationalStore'
|
||||||
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
|
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
|
||||||
import { Array2Byte } from '../common/utils/tools'
|
|
||||||
import { GlobalConfig } from '../config/global'
|
import { GlobalConfig } from '../config/global'
|
||||||
import { tcpUtil } from '../common/utils/TcpRequest';
|
import { tcpUtil } from '../common/utils/TcpRequest';
|
||||||
import { initTable } from '../common/service/initable';
|
import { initTable } from '../common/service/initable';
|
||||||
@ -30,7 +29,6 @@ export default class EntryAbility extends UIAbility {
|
|||||||
|
|
||||||
onDestroy() {
|
onDestroy() {
|
||||||
const arrClose = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00]
|
const arrClose = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00]
|
||||||
const arrCloseBuffer = Array2Byte(arrClose).buffer
|
|
||||||
// TODO UDP缺失
|
// TODO UDP缺失
|
||||||
// globalThis?.lightLineUdp?.send(arrCloseBuffer);
|
// globalThis?.lightLineUdp?.send(arrCloseBuffer);
|
||||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
|
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
|
||||||
|
|||||||
@ -2,13 +2,13 @@ import router from '@ohos.router';
|
|||||||
import { carConfigurationInfo, uploadExamCarCheckResult } from '../api/checkCar';
|
import { carConfigurationInfo, uploadExamCarCheckResult } from '../api/checkCar';
|
||||||
import TopLogo from './compontents/TopLogo';
|
import TopLogo from './compontents/TopLogo';
|
||||||
import testNapi from '@ohos.hiserialsdk';
|
import testNapi from '@ohos.hiserialsdk';
|
||||||
import { dateFormat } from '../common/utils/tools';
|
|
||||||
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 } from '../model';
|
||||||
import { BusinessError } from '@ohos.base';
|
import { BusinessError } from '@ohos.base';
|
||||||
import { SpzdType } from '../model';
|
import { SpzdType } from '../model';
|
||||||
import { voiceService } from '../utils/Voice';
|
import { voiceService } from '../utils/Voice';
|
||||||
|
import dayTs from '../utils/Date';
|
||||||
|
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
@ -282,7 +282,7 @@ struct Index {
|
|||||||
}
|
}
|
||||||
let date = new Date();
|
let date = new Date();
|
||||||
const data: CarCheckDataType = {
|
const data: CarCheckDataType = {
|
||||||
time: dateFormat(date),
|
time: dayTs(date).format("YYYY-MM-DD HH:mm:ss"),
|
||||||
carId: this.carInfo.carId,
|
carId: this.carInfo.carId,
|
||||||
examinationRoomId: this.carInfo.examinationRoomId,
|
examinationRoomId: this.carInfo.examinationRoomId,
|
||||||
plateNo: this.carInfo.plateNo,
|
plateNo: this.carInfo.plateNo,
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import common from '@ohos.app.ability.common';
|
import common from '@ohos.app.ability.common';
|
||||||
import router from '@ohos.router';
|
import router from '@ohos.router';
|
||||||
|
|
||||||
import { getCurrentTime, string2Bytes } from '../common/utils/tools';
|
|
||||||
import { getEsCarModel, getSyncData, } from '../common/service/initable';
|
import { getEsCarModel, getSyncData, } from '../common/service/initable';
|
||||||
import { getUDP, getUDP2 } from '../common/utils/GlobalUdp';
|
import { getUDP, getUDP2 } from '../common/utils/GlobalUdp';
|
||||||
import { initJudgeUdp } from '../common/utils/UdpJudge';
|
import { initJudgeUdp } from '../common/utils/UdpJudge';
|
||||||
@ -9,7 +8,6 @@ import { judgeConfig } from './judgeSDK/utils/judgeConfig';
|
|||||||
import { getTCP } from '../common/utils/GlobalTcp';
|
import { getTCP } from '../common/utils/GlobalTcp';
|
||||||
import promptAction from '@ohos.promptAction';
|
import promptAction from '@ohos.promptAction';
|
||||||
import errorMsgDialog from './compontents/errorMsgDialog';
|
import errorMsgDialog from './compontents/errorMsgDialog';
|
||||||
import GetDistance from '../common/utils/GetDistance';
|
|
||||||
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';
|
||||||
@ -20,6 +18,8 @@ import { GetSyncData, InitializeTheCentralTable } from '../utils/table/Operation
|
|||||||
import { BusinessError } from '@ohos.base';
|
import { BusinessError } from '@ohos.base';
|
||||||
import { delPic } from '../utils/Video';
|
import { delPic } from '../utils/Video';
|
||||||
import { FileHelper } from '../utils/FileHelp';
|
import { FileHelper } from '../utils/FileHelp';
|
||||||
|
import GetDistance from '../utils/business/GetDistance';
|
||||||
|
import { GetCurrentTime, NumberToByteArray } from '../utils/Common';
|
||||||
|
|
||||||
|
|
||||||
@Entry
|
@Entry
|
||||||
@ -427,16 +427,16 @@ struct Index {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async heartMsg() {
|
async heartMsg() {
|
||||||
const signNum = AppStorage.get('signNum') as Number
|
const signNum = AppStorage.get('signNum') as number
|
||||||
const statue = AppStorage.get('statue') as Number
|
const statue = AppStorage.get('statue') as number
|
||||||
const lsh = AppStorage.get('lsh') as String
|
const lsh = AppStorage.get('lsh') as String
|
||||||
const arr = [signNum || 0, statue || 1]
|
const arr = [signNum || 0, statue || 1]
|
||||||
let tmpList: number[] = [];
|
let tmpList: number[] = [];
|
||||||
tmpList.push(string2Bytes(arr[0], 1 * 8)[0])
|
tmpList.push(NumberToByteArray(arr[0], 1 * 8)[0])
|
||||||
tmpList.push(string2Bytes(arr[1], 1 * 8)[0])
|
tmpList.push(NumberToByteArray(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(string2Bytes(str.charCodeAt(i), 1 * 8)[0])
|
tmpList.push(NumberToByteArray(str.charCodeAt(i), 1 * 8)[0])
|
||||||
}
|
}
|
||||||
// TODO 未改
|
// TODO 未改
|
||||||
// const param = {
|
// const param = {
|
||||||
@ -488,7 +488,7 @@ struct Index {
|
|||||||
|
|
||||||
async createAlbum() {
|
async createAlbum() {
|
||||||
this.fileHelper = new FileHelper();
|
this.fileHelper = new FileHelper();
|
||||||
const time = await getCurrentTime()
|
const time = await GetCurrentTime()
|
||||||
const date = time.split(' ')[0]
|
const date = time.split(' ')[0]
|
||||||
this.fileHelper.createAlbum('jt')
|
this.fileHelper.createAlbum('jt')
|
||||||
// this.fileHelper.createAlbum('2025-01-02')
|
// this.fileHelper.createAlbum('2025-01-02')
|
||||||
|
|||||||
@ -24,7 +24,6 @@ import {
|
|||||||
SYSTEMPARMARR
|
SYSTEMPARMARR
|
||||||
} from './judgeSDK/api/judgeSDK.d';
|
} from './judgeSDK/api/judgeSDK.d';
|
||||||
|
|
||||||
import { chunkArr, getCurrentTime } from '../common/utils/tools';
|
|
||||||
import { getSyncData } from '../common/service/initable';
|
import { getSyncData } from '../common/service/initable';
|
||||||
import { judgeConfig } from './judgeSDK/utils/judgeConfig';
|
import { judgeConfig } from './judgeSDK/utils/judgeConfig';
|
||||||
import FileUtil from '../common/utils/File';
|
import FileUtil from '../common/utils/File';
|
||||||
@ -47,6 +46,8 @@ import {
|
|||||||
} from '../model';
|
} from '../model';
|
||||||
import { GetSyncData } from '../utils/table/Operation';
|
import { GetSyncData } from '../utils/table/Operation';
|
||||||
import dayTs from '../utils/Date';
|
import dayTs from '../utils/Date';
|
||||||
|
import { GetCurrentTime } from '../utils/Common';
|
||||||
|
import { chunkArr } from './judgeSDK/utils/Common';
|
||||||
|
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
@ -158,17 +159,17 @@ struct Index {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async aboutToAppear() {
|
async aboutToAppear() {
|
||||||
const time = await getCurrentTime()
|
const time = await GetCurrentTime()
|
||||||
this.carInfo = AppStorage.get('carInfo')
|
this.carInfo = AppStorage.get('carInfo')
|
||||||
this.singlePlay = AppStorage.get('singlePlay')
|
this.singlePlay = AppStorage.get('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()
|
||||||
this.startTime = dayTs().format("HHmmssSSS")
|
this.startTime = dayTs().format("HHmmssSSS")
|
||||||
this.startExamTime = time
|
this.startExamTime = time
|
||||||
|
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
this.time = await getCurrentTime();
|
this.time = await GetCurrentTime();
|
||||||
this.examTime += 1;
|
this.examTime += 1;
|
||||||
}, 1000);
|
}, 1000);
|
||||||
//初始化数据库表
|
//初始化数据库表
|
||||||
@ -808,7 +809,7 @@ struct Index {
|
|||||||
})
|
})
|
||||||
|
|
||||||
//科目二
|
//科目二
|
||||||
if (this.examSubject == 2) {
|
if (this.examSubject == "2") {
|
||||||
Flex({ wrap: FlexWrap.Wrap, direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween }) {
|
Flex({ wrap: FlexWrap.Wrap, direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween }) {
|
||||||
List({}) {
|
List({}) {
|
||||||
ForEach(chunkArr(this.projects, 2), (item) => {
|
ForEach(chunkArr(this.projects, 2), (item) => {
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import TopLogo from './compontents/TopLogo'
|
import TopLogo from './compontents/TopLogo'
|
||||||
import { registrationDeviceNo } from '../api/checkCar'
|
import { registrationDeviceNo } from '../api/checkCar'
|
||||||
import { dateFormat } from '../common/utils/tools'
|
|
||||||
import deviceManager from '@ohos.distributedHardware.deviceManager'
|
import deviceManager from '@ohos.distributedHardware.deviceManager'
|
||||||
import promptAction from '@ohos.promptAction'
|
import promptAction from '@ohos.promptAction'
|
||||||
import FileUtil from '../common/utils/File'
|
import FileUtil from '../common/utils/File'
|
||||||
import common from '@ohos.app.ability.common'
|
import common from '@ohos.app.ability.common'
|
||||||
import { DeviceParamType, ApiResponseType } from '../model'
|
import { DeviceParamType, ApiResponseType } from '../model'
|
||||||
|
import dayTs from '../utils/Date'
|
||||||
|
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
@ -117,7 +117,7 @@ struct Index {
|
|||||||
async registrationDeviceNoFn() {
|
async registrationDeviceNoFn() {
|
||||||
const date = new Date()
|
const date = new Date()
|
||||||
const param: DeviceParamType = {
|
const param: DeviceParamType = {
|
||||||
time: dateFormat(date),
|
time: dayTs(date).format("YYYY-MM-DD HH:mm:ss"),
|
||||||
deviceName: this.ip,
|
deviceName: this.ip,
|
||||||
type: '1'
|
type: '1'
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,6 @@ import { examinationStuAbsent, getExaminationItem, getExaminationStudentInfo } f
|
|||||||
import router from '@ohos.router';
|
import router from '@ohos.router';
|
||||||
import TopLogo from './compontents/TopLogo';
|
import TopLogo from './compontents/TopLogo';
|
||||||
import Md5 from '../common/utils/md5';
|
import Md5 from '../common/utils/md5';
|
||||||
import { dateFormat, getCurrentTime, string2Bytes } from '../common/utils/tools';
|
|
||||||
import FaceCompare from './compontents/FaceCompare';
|
import FaceCompare from './compontents/FaceCompare';
|
||||||
import { writeObjectOut } from '../api/judge';
|
import { writeObjectOut } from '../api/judge';
|
||||||
import testNapi from '@ohos.idcard';
|
import testNapi from '@ohos.idcard';
|
||||||
@ -43,6 +42,7 @@ import { BusinessError } from '@ohos.base';
|
|||||||
import { GetSyncData } from '../utils/table/Operation';
|
import { GetSyncData } from '../utils/table/Operation';
|
||||||
import { GetCurrentUserKeyValue } from './UserInfo/utils';
|
import { GetCurrentUserKeyValue } from './UserInfo/utils';
|
||||||
import dayTs from '../utils/Date';
|
import dayTs from '../utils/Date';
|
||||||
|
import { GetCurrentTime, NumberToByteArray } from '../utils/Common';
|
||||||
|
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
@ -484,7 +484,7 @@ struct UserInfo {
|
|||||||
//考点端查询缺考指令内容消息请求
|
//考点端查询缺考指令内容消息请求
|
||||||
getqkFn() {
|
getqkFn() {
|
||||||
let tmpList: Array<number> = [];
|
let tmpList: Array<number> = [];
|
||||||
tmpList.push(string2Bytes(AppStorage.get('signNum'), 1 * 8)[0])
|
tmpList.push(NumberToByteArray(AppStorage.get('signNum'), 1 * 8)[0])
|
||||||
const param: QKParamType = {
|
const param: QKParamType = {
|
||||||
id: 41,
|
id: 41,
|
||||||
list: tmpList,
|
list: tmpList,
|
||||||
@ -804,8 +804,8 @@ struct UserInfo {
|
|||||||
examinationStuAbsent(param).then(res => {
|
examinationStuAbsent(param).then(res => {
|
||||||
const arr = [this.signNum || 0, 1]
|
const arr = [this.signNum || 0, 1]
|
||||||
let tmpList: number[] = [];
|
let tmpList: number[] = [];
|
||||||
tmpList.push(string2Bytes(arr[0], 1 * 8)[0])
|
tmpList.push(NumberToByteArray(arr[0], 1 * 8)[0])
|
||||||
tmpList.push(string2Bytes(arr[1], 1 * 8)[0])
|
tmpList.push(NumberToByteArray(arr[1], 1 * 8)[0])
|
||||||
|
|
||||||
const param: UDPParamType = {
|
const param: UDPParamType = {
|
||||||
id: 43,
|
id: 43,
|
||||||
@ -834,7 +834,7 @@ struct UserInfo {
|
|||||||
}
|
}
|
||||||
// const { carId, examinationRoomId } = this.carInfo;
|
// const { carId, examinationRoomId } = this.carInfo;
|
||||||
const examItems = await getExaminationItem({
|
const examItems = await getExaminationItem({
|
||||||
time: await getCurrentTime() || "",
|
time: await GetCurrentTime() || "",
|
||||||
carId: this.carInfo.carId,
|
carId: this.carInfo.carId,
|
||||||
lsh: this.currentUser.lsh || '',
|
lsh: this.currentUser.lsh || '',
|
||||||
examinationRoomId: this.carInfo.examinationRoomId
|
examinationRoomId: this.carInfo.examinationRoomId
|
||||||
@ -861,7 +861,7 @@ struct UserInfo {
|
|||||||
if (!this.singlePlay) {
|
if (!this.singlePlay) {
|
||||||
//获取已考项目
|
//获取已考项目
|
||||||
examItems = await getExaminationItem({
|
examItems = await getExaminationItem({
|
||||||
time: await getCurrentTime(),
|
time: await GetCurrentTime(),
|
||||||
carId: this.carInfo.carId,
|
carId: this.carInfo.carId,
|
||||||
lsh: this.currentUser.lsh || '',
|
lsh: this.currentUser.lsh || '',
|
||||||
examinationRoomId: this.carInfo.examinationRoomId
|
examinationRoomId: this.carInfo.examinationRoomId
|
||||||
@ -1036,7 +1036,7 @@ struct UserInfo {
|
|||||||
ksysfzmhm: this.currentUser.ksy1sfzmhm || '',
|
ksysfzmhm: this.currentUser.ksy1sfzmhm || '',
|
||||||
ksxl: this.currentUser.xldm,
|
ksxl: this.currentUser.xldm,
|
||||||
zp: photoBase64,
|
zp: photoBase64,
|
||||||
kssj: dateFormat(date) || '',
|
kssj: dayTs(date).format("YYYY-MM-DD HH:mm:ss") || '',
|
||||||
kchp: decodeURI(this.carInfo.plateNo),
|
kchp: decodeURI(this.carInfo.plateNo),
|
||||||
Ksy2sfzmhm: this.currentUser.ksy2sfzmhm || ''
|
Ksy2sfzmhm: this.currentUser.ksy2sfzmhm || ''
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,11 +3,11 @@ import { faceCompare } from '../../api/userInfo';
|
|||||||
import FileUtil from '../../common/utils/File';
|
import FileUtil from '../../common/utils/File';
|
||||||
import common from '@ohos.app.ability.common';
|
import common from '@ohos.app.ability.common';
|
||||||
|
|
||||||
import { string2Bytes } from '../../common/utils/tools';
|
|
||||||
import { takePhoto } from '../../service/videoService';
|
import { takePhoto } from '../../service/videoService';
|
||||||
import { GlobalConfig } from '../../config/index';
|
import { GlobalConfig } from '../../config/index';
|
||||||
import { VideoConfigData } from '../../mock';
|
import { VideoConfigData } from '../../mock';
|
||||||
import { CarInfoType, UDPParamType, VideoConfig } from '../../model';
|
import { CarInfoType, UDPParamType, VideoConfig } from '../../model';
|
||||||
|
import { NumberToByteArray } from '../../utils/Common';
|
||||||
|
|
||||||
interface ParamType {
|
interface ParamType {
|
||||||
id?: number;
|
id?: number;
|
||||||
@ -186,7 +186,7 @@ export default struct FaceCompare {
|
|||||||
|
|
||||||
getqkFn() {
|
getqkFn() {
|
||||||
let tmpList: number[] = [];
|
let tmpList: number[] = [];
|
||||||
tmpList.push(string2Bytes(AppStorage.get('signNum'), 1 * 8)[0])
|
tmpList.push(NumberToByteArray(AppStorage.get('signNum'), 1 * 8)[0])
|
||||||
const param: ParamType = {
|
const param: ParamType = {
|
||||||
id: 41,
|
id: 41,
|
||||||
list: tmpList,
|
list: tmpList,
|
||||||
@ -242,7 +242,7 @@ export default struct FaceCompare {
|
|||||||
const str = this.lsh
|
const str = this.lsh
|
||||||
console.log('this.lshbitbit', this.lsh, this.carInfo.carNo, this.carInfo.examinationRoomId)
|
console.log('this.lshbitbit', this.lsh, this.carInfo.carNo, this.carInfo.examinationRoomId)
|
||||||
for (let i = 0; i < str.length; i++) {
|
for (let i = 0; i < str.length; i++) {
|
||||||
tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0])
|
tmpList.push(NumberToByteArray(str.charCodeAt(i), 1 * 8)[0])
|
||||||
}
|
}
|
||||||
const param: UDPParamType = {
|
const param: UDPParamType = {
|
||||||
id: 46,
|
id: 46,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import router from '@ohos.router';
|
import router from '@ohos.router';
|
||||||
import { getCurrentTime } from '../../common/utils/tools';
|
import { GetCurrentTime } from '../../utils/Common';
|
||||||
import imageBtn from '../compontents/imageBtn';
|
import imageBtn from '../compontents/imageBtn';
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@ -51,9 +51,9 @@ export default struct TopLogo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async aboutToAppear() {
|
async aboutToAppear() {
|
||||||
this.timeText = await getCurrentTime();
|
this.timeText = await GetCurrentTime();
|
||||||
this.timer = setInterval(async () => {
|
this.timer = setInterval(async () => {
|
||||||
this.timeText = await getCurrentTime();
|
this.timeText = await GetCurrentTime();
|
||||||
}, 1000)
|
}, 1000)
|
||||||
// this.vocObj = new voiceService(async (status,val) => {
|
// this.vocObj = new voiceService(async (status,val) => {
|
||||||
// if (status == 'idle') {
|
// if (status == 'idle') {
|
||||||
|
|||||||
@ -3,12 +3,12 @@ import { judgeConfig } from '../../judgeSDK/utils/judgeConfig';
|
|||||||
import FileUtil from '../../../common/utils/File';
|
import FileUtil from '../../../common/utils/File';
|
||||||
import common from '@ohos.app.ability.common';
|
import common from '@ohos.app.ability.common';
|
||||||
import VoiceAnnounce from '../../judgeSDK/utils/voiceAnnouncements';
|
import VoiceAnnounce from '../../judgeSDK/utils/voiceAnnouncements';
|
||||||
import { getCurrentTime } from '../../../common/utils/tools';
|
|
||||||
import { MarkRule, SYSSET } from '../../judgeSDK/api/judgeSDK.d';
|
import { MarkRule, SYSSET } from '../../judgeSDK/api/judgeSDK.d';
|
||||||
import { writeObjectOut } from '../../../api/judge';
|
import { writeObjectOut } from '../../../api/judge';
|
||||||
import JudgeTask from '../../judgeSDK/utils/judgeTask';
|
import JudgeTask from '../../judgeSDK/utils/judgeTask';
|
||||||
import FilePhoto from '../../judgeSDK/utils/filePhoto';
|
import FilePhoto from '../../judgeSDK/utils/filePhoto';
|
||||||
import { CarInfoType } from '../../../model';
|
import { CarInfoType } from '../../../model';
|
||||||
|
import { GetCurrentTime } from '../../../utils/Common';
|
||||||
|
|
||||||
interface SEL {
|
interface SEL {
|
||||||
fontColor: string
|
fontColor: string
|
||||||
@ -215,7 +215,7 @@ export default struct DeductedPopup {
|
|||||||
const carInfo: CarInfoType = this.carInfo;
|
const carInfo: CarInfoType = this.carInfo;
|
||||||
const { examSubject, plateNo } = carInfo;
|
const { examSubject, plateNo } = carInfo;
|
||||||
const { serialNumber, lsh, idCard, ksxl, kslx, ksdd } = this
|
const { serialNumber, lsh, idCard, ksxl, kslx, ksdd } = this
|
||||||
const time = await getCurrentTime();
|
const time = await GetCurrentTime();
|
||||||
const beginData = {
|
const beginData = {
|
||||||
xtlb: '17',
|
xtlb: '17',
|
||||||
jkxlh: serialNumber,
|
jkxlh: serialNumber,
|
||||||
@ -245,7 +245,7 @@ export default struct DeductedPopup {
|
|||||||
const { serialNumber, lsh, idCard, ksdd, kfdmArr, getPhoto } = this;
|
const { serialNumber, lsh, idCard, ksdd, kfdmArr, getPhoto } = this;
|
||||||
const carInfo = this.carInfo;
|
const carInfo = this.carInfo;
|
||||||
const { examSubject, plateNo, carNo } = carInfo;
|
const { examSubject, plateNo, carNo } = carInfo;
|
||||||
const time = await getCurrentTime();
|
const time = await GetCurrentTime();
|
||||||
console.info('surenjun uploadProgressPhoto',)
|
console.info('surenjun uploadProgressPhoto',)
|
||||||
const photoBase64 = await getPhoto()
|
const photoBase64 = await getPhoto()
|
||||||
const photoData = {
|
const photoData = {
|
||||||
@ -276,7 +276,7 @@ export default struct DeductedPopup {
|
|||||||
const kf = kfdmArr[kfLen -1];
|
const kf = kfdmArr[kfLen -1];
|
||||||
const carInfo: CarInfoType = this.carInfo;
|
const carInfo: CarInfoType = this.carInfo;
|
||||||
const { examSubject } = this.carInfo;
|
const { examSubject } = this.carInfo;
|
||||||
const time = await getCurrentTime();
|
const time = await GetCurrentTime();
|
||||||
const kfData = {
|
const kfData = {
|
||||||
xtlb: '17',
|
xtlb: '17',
|
||||||
jkxlh: serialNumber,
|
jkxlh: serialNumber,
|
||||||
@ -303,7 +303,7 @@ export default struct DeductedPopup {
|
|||||||
const carInfo = this.carInfo;
|
const carInfo = this.carInfo;
|
||||||
const { examSubject, plateNo, carNo } = carInfo;
|
const { examSubject, plateNo, carNo } = carInfo;
|
||||||
const { lsh, idCard, serialNumber, ksdd, kslx, ksxl, } = this;
|
const { lsh, idCard, serialNumber, ksdd, kslx, ksxl, } = this;
|
||||||
const time = await getCurrentTime();
|
const time = await GetCurrentTime();
|
||||||
const endProjectData = {
|
const endProjectData = {
|
||||||
xtlb: '17',
|
xtlb: '17',
|
||||||
jkxlh: serialNumber,
|
jkxlh: serialNumber,
|
||||||
@ -329,7 +329,7 @@ export default struct DeductedPopup {
|
|||||||
const { serialNumber, lsh, idCard, score, getPhoto } = this;
|
const { serialNumber, lsh, idCard, score, getPhoto } = this;
|
||||||
const carInfo: CarInfoType = this.carInfo;
|
const carInfo: CarInfoType = this.carInfo;
|
||||||
const { examSubject, plateNo } = carInfo;
|
const { examSubject, plateNo } = carInfo;
|
||||||
const time = await getCurrentTime();
|
const time = await GetCurrentTime();
|
||||||
const photoBase64 = await getPhoto();
|
const photoBase64 = await getPhoto();
|
||||||
const endData = {
|
const endData = {
|
||||||
xtlb: '17',
|
xtlb: '17',
|
||||||
|
|||||||
@ -11,17 +11,7 @@ import FileUtil from '../../common/utils/File';
|
|||||||
import FileLog from './utils/fileLog';
|
import FileLog from './utils/fileLog';
|
||||||
import JudgeTask from './utils/judgeTask';
|
import JudgeTask from './utils/judgeTask';
|
||||||
import { judgeConfig } from './utils/judgeConfig';
|
import { judgeConfig } from './utils/judgeConfig';
|
||||||
import UsbService from '../../service/usbService';
|
|
||||||
import { KF, LANE } from '../judgeSDK/api/judgeSDK.d';
|
import { KF, LANE } from '../judgeSDK/api/judgeSDK.d';
|
||||||
import {
|
|
||||||
Array2Byte,
|
|
||||||
convertGpsCoord2,
|
|
||||||
deepClone,
|
|
||||||
fillZero,
|
|
||||||
getCurrentTime,
|
|
||||||
string2Bytes,
|
|
||||||
stringToASC
|
|
||||||
} from '../../common/utils/tools';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getCarStatus,
|
getCarStatus,
|
||||||
@ -54,6 +44,9 @@ import {
|
|||||||
import { writeObjectOut } from '../../api/judge';
|
import { writeObjectOut } from '../../api/judge';
|
||||||
import { saveStartRecordVideo } from '../../utils/Video';
|
import { saveStartRecordVideo } from '../../utils/Video';
|
||||||
import common from '@ohos.app.ability.common';
|
import common from '@ohos.app.ability.common';
|
||||||
|
import { Array2Byte, convertGpsCoord2, deepClone, fillZero, string2Bytes } from './utils/Common';
|
||||||
|
import { GetCurrentTime, StringToASCII } from '../../utils/Common';
|
||||||
|
import UsbService from '../../utils/USB';
|
||||||
|
|
||||||
const judgeTag = 'SURENJUN_JUDGE'
|
const judgeTag = 'SURENJUN_JUDGE'
|
||||||
|
|
||||||
@ -80,8 +73,8 @@ export default class Judge {
|
|||||||
const { carId, examinationRoomId } = carInfo
|
const { carId, examinationRoomId } = carInfo
|
||||||
const folderPath = fileLog.folderPath
|
const folderPath = fileLog.folderPath
|
||||||
const base64 = new util.Base64();
|
const base64 = new util.Base64();
|
||||||
const time = await getCurrentTime();
|
const time = await GetCurrentTime();
|
||||||
const endTime = await getCurrentTime(1)
|
const endTime = await GetCurrentTime(1)
|
||||||
let examDataBase64
|
let examDataBase64
|
||||||
//TODO try catch报错待优化
|
//TODO try catch报错待优化
|
||||||
const examDataStr: string = await fileUtil.readFile(`${folderPath}/wuxi_progress_data.txt`);
|
const examDataStr: string = await fileUtil.readFile(`${folderPath}/wuxi_progress_data.txt`);
|
||||||
@ -262,40 +255,6 @@ export default class Judge {
|
|||||||
private isExamEnd: boolean
|
private isExamEnd: boolean
|
||||||
// 是否发送udp
|
// 是否发送udp
|
||||||
private isUdpEnd: boolean = false
|
private isUdpEnd: boolean = false
|
||||||
// 处理udp plc信号
|
|
||||||
handleUdp = async (msg) => {
|
|
||||||
console.info('plc信号', msg)
|
|
||||||
// const { fileLog, getPlcData, usbService, isUdpEnd, isExamEnd, judgeUI } = this
|
|
||||||
const stachArr = msg.split(',')
|
|
||||||
if (stachArr[0] != '#DN_GD' || this.isUdpEnd) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const plcData = await this.getPlcData(msg);
|
|
||||||
// 4.过程数据
|
|
||||||
await this.fileLog.setExamJudgeData(plcData)
|
|
||||||
//检测到有无锡所设备接入,需要发送特定的数据,供检测
|
|
||||||
if (this.usbService.isWXUSBDevice) {
|
|
||||||
const str = await senorToWXDataStr(msg);
|
|
||||||
this.usbService.sendUSB(str)
|
|
||||||
}
|
|
||||||
const param350 = this.judgeUI.judgeConfigObj['350']
|
|
||||||
this.judgeUI.sd = ((param350 == 0 ? plcData.gps.sd : plcData.sensor.cs) as number * 1.852).toFixed(0) + ''
|
|
||||||
this.judgeUI.dw = (Math.floor(plcData.sensor.dw as number) || 0) + ''
|
|
||||||
//TODO 暂时关闭差分检测异常
|
|
||||||
// await this.checkDwzt(plcData.gps.dwzt,plcData.gps.jdzt);
|
|
||||||
if (!this.isExamEnd) {
|
|
||||||
await examJudgeRealExam(plcData)
|
|
||||||
}
|
|
||||||
let udpIndex = AppStorage.get('udpIndex') as number;
|
|
||||||
let [prevJd, preWd] = [0, 0]
|
|
||||||
if (udpIndex % 5 === 0 && !this.isUdpEnd) {
|
|
||||||
// TODO UPD缺失
|
|
||||||
// const judgeUdp = globalThis.judgeUdp
|
|
||||||
// const bytes = await this.getMessageHeartbeat(this.isExamEnd);
|
|
||||||
// judgeUdp.send(bytes)
|
|
||||||
}
|
|
||||||
AppStorage.setOrCreate('udpIndex', udpIndex++)
|
|
||||||
}
|
|
||||||
//是否手动结束考试
|
//是否手动结束考试
|
||||||
private isManual: boolean
|
private isManual: boolean
|
||||||
//UDP服务序列号
|
//UDP服务序列号
|
||||||
@ -482,6 +441,40 @@ export default class Judge {
|
|||||||
|
|
||||||
return tempData
|
return tempData
|
||||||
}
|
}
|
||||||
|
// 处理udp plc信号
|
||||||
|
handleUdp = async (msg) => {
|
||||||
|
console.info('plc信号', msg)
|
||||||
|
// const { fileLog, getPlcData, usbService, isUdpEnd, isExamEnd, judgeUI } = this
|
||||||
|
const stachArr = msg.split(',')
|
||||||
|
if (stachArr[0] != '#DN_GD' || this.isUdpEnd) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const plcData = await this.getPlcData(msg);
|
||||||
|
// 4.过程数据
|
||||||
|
await this.fileLog.setExamJudgeData(plcData)
|
||||||
|
//检测到有无锡所设备接入,需要发送特定的数据,供检测
|
||||||
|
if (this.usbService.isWXUSBDevice) {
|
||||||
|
const str = await senorToWXDataStr(msg);
|
||||||
|
this.usbService.sendUSB(str)
|
||||||
|
}
|
||||||
|
const param350 = this.judgeUI.judgeConfigObj['350']
|
||||||
|
this.judgeUI.sd = ((param350 == 0 ? plcData.gps.sd : plcData.sensor.cs) as number * 1.852).toFixed(0) + ''
|
||||||
|
this.judgeUI.dw = (Math.floor(plcData.sensor.dw as number) || 0) + ''
|
||||||
|
//TODO 暂时关闭差分检测异常
|
||||||
|
// await this.checkDwzt(plcData.gps.dwzt,plcData.gps.jdzt);
|
||||||
|
if (!this.isExamEnd) {
|
||||||
|
await examJudgeRealExam(plcData)
|
||||||
|
}
|
||||||
|
let udpIndex = AppStorage.get('udpIndex') as number;
|
||||||
|
let [prevJd, preWd] = [0, 0]
|
||||||
|
if (udpIndex % 5 === 0 && !this.isUdpEnd) {
|
||||||
|
// TODO UPD缺失
|
||||||
|
// const judgeUdp = globalThis.judgeUdp
|
||||||
|
// const bytes = await this.getMessageHeartbeat(this.isExamEnd);
|
||||||
|
// judgeUdp.send(bytes)
|
||||||
|
}
|
||||||
|
AppStorage.setOrCreate('udpIndex', udpIndex++)
|
||||||
|
}
|
||||||
// 处理轨迹plc信号
|
// 处理轨迹plc信号
|
||||||
handleTrajectoryUdp = async (strArr) => {
|
handleTrajectoryUdp = async (strArr) => {
|
||||||
// const { fileLog, setJudgeItem, setJudgeMark, endExam } = this;
|
// const { fileLog, setJudgeItem, setJudgeMark, endExam } = this;
|
||||||
@ -525,74 +518,13 @@ export default class Judge {
|
|||||||
private isTrajectoryOpen: boolean;
|
private isTrajectoryOpen: boolean;
|
||||||
// 调代理接口是否断网了
|
// 调代理接口是否断网了
|
||||||
private isJudgeDisConnect: boolean;
|
private isJudgeDisConnect: boolean;
|
||||||
// 考试过程照片
|
|
||||||
uploadProgressPhoto = async (ksxm) => {
|
|
||||||
const time = await getCurrentTime();
|
|
||||||
const { judgeUI, plcData, getPhoto, fileLog, filePath } = this;
|
|
||||||
const photoBase64 = await getPhoto();
|
|
||||||
const carInfo = AppStorage.get('carInfo');
|
|
||||||
const { examSubject, plateNo, carNo } = carInfo;
|
|
||||||
const { lsh, idCard, serialNumber, projectsObj, ksdd, judgeConfigObj } = judgeUI;
|
|
||||||
const { sensor, gps } = plcData
|
|
||||||
const project = projectsObj[ksxm]
|
|
||||||
|
|
||||||
const data = {
|
|
||||||
xtlb: '17',
|
|
||||||
jkxlh: serialNumber,
|
|
||||||
jkid: '17C54',
|
|
||||||
drvexam: {
|
|
||||||
lsh,
|
|
||||||
kskm: examSubject,
|
|
||||||
ksxm: project.projectCodeCenter,
|
|
||||||
sfzmhm: idCard,
|
|
||||||
kchp: encodeURI(plateNo),
|
|
||||||
zpsj: time,
|
|
||||||
zp: photoBase64,
|
|
||||||
cs: Math.floor((judgeConfigObj['350'] == 0 ? gps.sd : sensor.cs) * 1.852),
|
|
||||||
ksdd: encodeURI(ksdd)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { code } = await this.sendWriteObjectOut(data, filePath);
|
|
||||||
if (code === 2300007) {
|
|
||||||
this.isJudgeDisConnect = true
|
|
||||||
}
|
|
||||||
promptWxCode('17C54', code)
|
|
||||||
console.info(judgeTag, '上传照片 end')
|
|
||||||
}
|
|
||||||
private artSubject3ProjectsCodesArr: number[] = [3, 9, 4, 10, 12, 11]
|
|
||||||
private lane: LANE = {
|
|
||||||
road: '', num: 0, count: 0
|
|
||||||
}
|
|
||||||
private videoData: any
|
|
||||||
private disConnectNum: number = 0;
|
|
||||||
//调用监管接口
|
|
||||||
sendWriteObjectOut = async (data, filePath) => {
|
|
||||||
const temp = await writeObjectOut(data, filePath);
|
|
||||||
console.log("wzj", JSON.stringify(temp))
|
|
||||||
//断网&网络超时次数计算
|
|
||||||
if (temp.code == 2300007 || temp.code == 2300028) {
|
|
||||||
this.disConnectNum += 1;
|
|
||||||
if (this.disConnectNum < 5) {
|
|
||||||
return await this.sendWriteObjectOut(data, filePath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.disConnectNum >= 5) {
|
|
||||||
console.info('surenjun', '123')
|
|
||||||
this.judgeUI.errorMsg = '当前的考试过程信息网络传输异常,程序点击确认将重启!';
|
|
||||||
this.judgeUI.disConnectErrorOpen = true
|
|
||||||
}
|
|
||||||
|
|
||||||
this.disConnectNum = 0
|
|
||||||
return temp
|
|
||||||
}
|
|
||||||
// 项目开始接口同步
|
// 项目开始接口同步
|
||||||
beginProject = async (ksxm) => {
|
beginProject = async (ksxm) => {
|
||||||
const carInfo = AppStorage.get('carInfo');
|
const carInfo = AppStorage.get('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
|
||||||
const time = await getCurrentTime();
|
const time = await GetCurrentTime();
|
||||||
const project = projectsObj[ksxm]
|
const project = projectsObj[ksxm]
|
||||||
const sbxh = getSbbm(ksxm, xmxh)
|
const sbxh = getSbbm(ksxm, xmxh)
|
||||||
const data = {
|
const data = {
|
||||||
@ -628,7 +560,7 @@ export default class Judge {
|
|||||||
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
|
||||||
const time = await getCurrentTime();
|
const time = await GetCurrentTime();
|
||||||
const project = projectsObj[ksxm]
|
const project = projectsObj[ksxm]
|
||||||
const sbxh = examSubject == 3 ? undefined : getSbbm(ksxm, xmxh)
|
const sbxh = examSubject == 3 ? undefined : getSbbm(ksxm, xmxh)
|
||||||
|
|
||||||
@ -658,6 +590,67 @@ export default class Judge {
|
|||||||
console.info(judgeTag, '项目结束 end')
|
console.info(judgeTag, '项目结束 end')
|
||||||
promptWxCode('17C55', code)
|
promptWxCode('17C55', code)
|
||||||
}
|
}
|
||||||
|
private artSubject3ProjectsCodesArr: number[] = [3, 9, 4, 10, 12, 11]
|
||||||
|
private lane: LANE = {
|
||||||
|
road: '', num: 0, count: 0
|
||||||
|
}
|
||||||
|
private videoData: any
|
||||||
|
private disConnectNum: number = 0;
|
||||||
|
//调用监管接口
|
||||||
|
sendWriteObjectOut = async (data, filePath) => {
|
||||||
|
const temp = await writeObjectOut(data, filePath);
|
||||||
|
console.log("wzj", JSON.stringify(temp))
|
||||||
|
//断网&网络超时次数计算
|
||||||
|
if (temp.code == 2300007 || temp.code == 2300028) {
|
||||||
|
this.disConnectNum += 1;
|
||||||
|
if (this.disConnectNum < 5) {
|
||||||
|
return await this.sendWriteObjectOut(data, filePath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.disConnectNum >= 5) {
|
||||||
|
console.info('surenjun', '123')
|
||||||
|
this.judgeUI.errorMsg = '当前的考试过程信息网络传输异常,程序点击确认将重启!';
|
||||||
|
this.judgeUI.disConnectErrorOpen = true
|
||||||
|
}
|
||||||
|
|
||||||
|
this.disConnectNum = 0
|
||||||
|
return temp
|
||||||
|
}
|
||||||
|
// 考试过程照片
|
||||||
|
uploadProgressPhoto = async (ksxm) => {
|
||||||
|
const time = await GetCurrentTime();
|
||||||
|
const { judgeUI, plcData, getPhoto, fileLog, filePath } = this;
|
||||||
|
const photoBase64 = await getPhoto();
|
||||||
|
const carInfo = AppStorage.get('carInfo');
|
||||||
|
const { examSubject, plateNo, carNo } = carInfo;
|
||||||
|
const { lsh, idCard, serialNumber, projectsObj, ksdd, judgeConfigObj } = judgeUI;
|
||||||
|
const { sensor, gps } = plcData
|
||||||
|
const project = projectsObj[ksxm]
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
xtlb: '17',
|
||||||
|
jkxlh: serialNumber,
|
||||||
|
jkid: '17C54',
|
||||||
|
drvexam: {
|
||||||
|
lsh,
|
||||||
|
kskm: examSubject,
|
||||||
|
ksxm: project.projectCodeCenter,
|
||||||
|
sfzmhm: idCard,
|
||||||
|
kchp: encodeURI(plateNo),
|
||||||
|
zpsj: time,
|
||||||
|
zp: photoBase64,
|
||||||
|
cs: Math.floor((judgeConfigObj['350'] == 0 ? gps.sd : sensor.cs) * 1.852),
|
||||||
|
ksdd: encodeURI(ksdd)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { code } = await this.sendWriteObjectOut(data, filePath);
|
||||||
|
if (code === 2300007) {
|
||||||
|
this.isJudgeDisConnect = true
|
||||||
|
}
|
||||||
|
promptWxCode('17C54', code)
|
||||||
|
console.info(judgeTag, '上传照片 end')
|
||||||
|
}
|
||||||
|
|
||||||
constructor(judgeUI) {
|
constructor(judgeUI) {
|
||||||
this.serialIndex = 1;
|
this.serialIndex = 1;
|
||||||
@ -1141,7 +1134,7 @@ export default class Judge {
|
|||||||
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
|
||||||
const time = await getCurrentTime();
|
const time = await GetCurrentTime();
|
||||||
const project = getProjectInfo(ksxm);
|
const project = getProjectInfo(ksxm);
|
||||||
//科目三夜间行驶.模拟灯光、上车准备出现通用评判,ksxm为当前进行的项目
|
//科目三夜间行驶.模拟灯光、上车准备出现通用评判,ksxm为当前进行的项目
|
||||||
const checkProjects = ['17', '41', '1'];
|
const checkProjects = ['17', '41', '1'];
|
||||||
@ -1285,7 +1278,7 @@ export default class Judge {
|
|||||||
const { lsh, idCard, serialNumber, kssycs, totalScore, judgeConfigObj, isAllProjectsEnd, passingScore } = judgeUI
|
const { lsh, idCard, serialNumber, kssycs, totalScore, judgeConfigObj, isAllProjectsEnd, passingScore } = judgeUI
|
||||||
//TODO 断网考试结束补传
|
//TODO 断网考试结束补传
|
||||||
// await uploadDisConnectData();
|
// await uploadDisConnectData();
|
||||||
const time = await getCurrentTime();
|
const time = await GetCurrentTime();
|
||||||
const photoBase64 = await getPhoto();
|
const photoBase64 = await getPhoto();
|
||||||
const { d1, d2, d3, d4, d5 } = ksjs
|
const { d1, d2, d3, d4, d5 } = ksjs
|
||||||
const data = {
|
const data = {
|
||||||
@ -1492,12 +1485,12 @@ export default class Judge {
|
|||||||
const translateProject = getTranslateProject();
|
const translateProject = getTranslateProject();
|
||||||
const sbxh = getSbxh(xmdm, xmxh)
|
const sbxh = getSbxh(xmdm, xmxh)
|
||||||
const { carzt, dcjl, qjjl, dxjl, bxjl } = performInfo || {};
|
const { carzt, dcjl, qjjl, dxjl, bxjl } = performInfo || {};
|
||||||
const asclshArr = stringToASC(
|
const asclshArr = StringToASCII(
|
||||||
fillZero((singlePlay ? (examSubject == 2 ? '0000000000000' : '1111111111111') : lsh) || 0, 13)
|
fillZero((singlePlay ? (examSubject == 2 ? '0000000000000' : '1111111111111') : lsh) || 0, 13)
|
||||||
);
|
);
|
||||||
//13不足要补0
|
//13不足要补0
|
||||||
const ascksyhArr = stringToASC(fillZero(ksyh || 0, 13))
|
const ascksyhArr = StringToASCII(fillZero(ksyh || 0, 13))
|
||||||
const ascsbxhArr = stringToASC(sbxh)
|
const ascsbxhArr = StringToASCII(sbxh)
|
||||||
const translateSignals = getTranslateSignals(
|
const translateSignals = getTranslateSignals(
|
||||||
[zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc, ssc, fsc, lb, mkg, aqd].concat(getDwStatusType(dw))
|
[zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc, ssc, fsc, lb, mkg, aqd].concat(getDwStatusType(dw))
|
||||||
.concat(getCarStatusType(carzt)).concat([ygq, sensor.wd, 0])
|
.concat(getCarStatusType(carzt)).concat([ygq, sensor.wd, 0])
|
||||||
|
|||||||
80
entry/src/main/ets/pages/judgeSDK/utils/Common.ets
Normal file
80
entry/src/main/ets/pages/judgeSDK/utils/Common.ets
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
// 根据指定个数分割数组
|
||||||
|
export function chunkArr<T>(arr: T[], size: number): T[][] {
|
||||||
|
//判断如果不是数组(就没有length),或者size没有传值,size小于1,就返回空数组
|
||||||
|
if (!arr.length || !size || size < 1) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
let start = 0
|
||||||
|
let end = 0
|
||||||
|
let result: T[][] = []
|
||||||
|
for (let i = 0; i < Math.ceil(arr.length / size); i++) {
|
||||||
|
start = i * size
|
||||||
|
end = start + size
|
||||||
|
result.push(arr.slice(start, end))
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
//对象深拷贝
|
||||||
|
export function deepClone<T>(target: T): T {
|
||||||
|
// 如果是对象,且不是原始值null
|
||||||
|
if (typeof target === 'object' && target !== null) {
|
||||||
|
// 创建容器
|
||||||
|
const result: ESObject = Array.isArray(target) ? [] : {};
|
||||||
|
const keys = Object.keys(target) as Array<keyof T>; //注解二
|
||||||
|
keys.forEach(key => {
|
||||||
|
Reflect.set(result, key, deepClone(target[key]));
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
// 如果是原始值,则直接返回
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fillZero(str: string | number, len: number): string {
|
||||||
|
str = str.toString();
|
||||||
|
if (str.length >= len || len <= 0) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
const zeroStr = '0'.repeat(len - str.length);
|
||||||
|
return zeroStr + str;
|
||||||
|
}
|
||||||
|
|
||||||
|
//经纬度转换
|
||||||
|
export function convertGpsCoord2(num: number): number {
|
||||||
|
const tempNum = Math.floor(num);
|
||||||
|
const du = Math.floor(tempNum / 100);
|
||||||
|
const fen = tempNum % 100 + num - tempNum;
|
||||||
|
return du + fen / 60
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Array2Byte(array: number[]): Uint8Array {
|
||||||
|
const buf = new ArrayBuffer(array.length);
|
||||||
|
const view = new Uint8Array(buf);
|
||||||
|
for (let i = 0; i < array.length; i++) {
|
||||||
|
view[i] = array[i] & 0xFF;
|
||||||
|
}
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function string2Bytes(number: number, len: number): number[] | undefined {
|
||||||
|
let str = Math.floor(number).toString(2);
|
||||||
|
if (str.length > len) {
|
||||||
|
console.log('数据长度不对~~');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const byteString = fillZero(str, len);
|
||||||
|
|
||||||
|
const arrBytes: number[] = [];
|
||||||
|
for (let i = byteString.length; i > 0; ) {
|
||||||
|
let j = i - 8;
|
||||||
|
if (j < 0) {
|
||||||
|
j = 0;
|
||||||
|
}
|
||||||
|
const s = byteString.slice(j, i);
|
||||||
|
const v = parseInt(s, 2);
|
||||||
|
arrBytes.push(v);
|
||||||
|
i -= 8;
|
||||||
|
}
|
||||||
|
return arrBytes;
|
||||||
|
}
|
||||||
@ -1,11 +1,5 @@
|
|||||||
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'
|
|
||||||
import promptAction from '@ohos.promptAction'
|
|
||||||
import fileAccess from '@ohos.file.fileAccess'
|
|
||||||
import common from '@ohos.app.ability.common'
|
|
||||||
import Want from '@ohos.app.ability.Want'
|
|
||||||
import fs from '@ohos.file.fs'
|
|
||||||
import FileUtil from '../../../common/utils/File'
|
import FileUtil from '../../../common/utils/File'
|
||||||
import { getCurrentTime } from '../../../common/utils/tools'
|
import { GetCurrentTime } from '../../../utils/Common'
|
||||||
|
|
||||||
interface StuInfo {
|
interface StuInfo {
|
||||||
name: string
|
name: string
|
||||||
@ -16,11 +10,7 @@ interface StuInfo {
|
|||||||
const LOGTAG = 'LOGTAG'
|
const LOGTAG = 'LOGTAG'
|
||||||
|
|
||||||
export default class FileLog {
|
export default class FileLog {
|
||||||
//后续文件路径待替换
|
|
||||||
private fileUtil: FileUtil
|
|
||||||
private stuInfo: StuInfo
|
|
||||||
public folderPath: string
|
public folderPath: string
|
||||||
|
|
||||||
public progressDataFd: number = undefined
|
public progressDataFd: number = undefined
|
||||||
public examJudgeWuxiDataFd: number = undefined
|
public examJudgeWuxiDataFd: number = undefined
|
||||||
public examJudgeWuxiProgressDataFd: number = undefined
|
public examJudgeWuxiProgressDataFd: number = undefined
|
||||||
@ -31,93 +21,60 @@ export default class FileLog {
|
|||||||
public fourAndOneLogDataFd: number = undefined
|
public fourAndOneLogDataFd: number = undefined
|
||||||
public fourAndOneLogDataBytesFd: number = undefined
|
public fourAndOneLogDataBytesFd: number = undefined
|
||||||
public examLineDataFd: number = undefined
|
public examLineDataFd: number = undefined
|
||||||
|
|
||||||
|
|
||||||
constructor(context) {
|
|
||||||
const fileUtil = new FileUtil(context)
|
|
||||||
this.fileUtil = fileUtil
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 设置文件夹
|
|
||||||
public initFileLogo = async (stuInfo: StuInfo) => {
|
|
||||||
const {fileUtil,setExamLineData} = this
|
|
||||||
const {name,lsh,idCard} = stuInfo;
|
|
||||||
this.stuInfo = stuInfo;
|
|
||||||
const time = await getCurrentTime()
|
|
||||||
const date = time.split(' ')[0].split('-').join('_')
|
|
||||||
const hourTime = time.split(' ')[1].split(':').join('_')
|
|
||||||
const folderPath = await fileUtil.initFolder(`/logs/${date}/${date}_${hourTime}_${lsh}_${idCard}_${name}`);
|
|
||||||
this.folderPath = folderPath;
|
|
||||||
return folderPath
|
|
||||||
}
|
|
||||||
|
|
||||||
// 过程文件数据
|
// 过程文件数据
|
||||||
public setExamProgressData = async (str: Object) => {
|
public setExamProgressData = async (str: Object) => {
|
||||||
const { fileUtil, folderPath, progressDataFd } = this;
|
const { fileUtil, folderPath, progressDataFd } = this;
|
||||||
this.progressDataFd = await fileUtil.editFile(`${folderPath}/exam_progress_data.txt`, JSON.stringify(str), progressDataFd);
|
this.progressDataFd =
|
||||||
|
await fileUtil.editFile(`${folderPath}/exam_progress_data.txt`, JSON.stringify(str), progressDataFd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 无锡所接口数据
|
// 无锡所接口数据
|
||||||
public setExamJudgeWuxiData = async (str) => {
|
public setExamJudgeWuxiData = async (str) => {
|
||||||
const { fileUtil, folderPath, examJudgeWuxiDataFd } = this;
|
const { fileUtil, folderPath, examJudgeWuxiDataFd } = this;
|
||||||
this.examJudgeWuxiDataFd = await fileUtil.editFile(`${folderPath}/wuxi_exam_data.txt`, str, examJudgeWuxiDataFd);
|
this.examJudgeWuxiDataFd = await fileUtil.editFile(`${folderPath}/wuxi_exam_data.txt`, str, examJudgeWuxiDataFd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 无锡所过程数据
|
// 无锡所过程数据
|
||||||
public setExamJudgeWuxiProgressData = async (str) => {
|
public setExamJudgeWuxiProgressData = async (str) => {
|
||||||
const { fileUtil, folderPath, examJudgeWuxiProgressDataFd } = this;
|
const { fileUtil, folderPath, examJudgeWuxiProgressDataFd } = this;
|
||||||
this.examJudgeWuxiProgressDataFd = await fileUtil.editFile(`${folderPath}/wuxi_progress_data.txt`, str, examJudgeWuxiProgressDataFd);
|
this.examJudgeWuxiProgressDataFd =
|
||||||
|
await fileUtil.editFile(`${folderPath}/wuxi_progress_data.txt`, str, examJudgeWuxiProgressDataFd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// plc文件数据
|
// plc文件数据
|
||||||
public setPlcProgressData = async (str: Object) => {
|
public setPlcProgressData = async (str: Object) => {
|
||||||
const { fileUtil, folderPath, plcDataFd } = this;
|
const { fileUtil, folderPath, plcDataFd } = this;
|
||||||
this.plcDataFd = await fileUtil.editFile(`${folderPath}/plc_data.txt`, JSON.stringify(str), plcDataFd);
|
this.plcDataFd = await fileUtil.editFile(`${folderPath}/plc_data.txt`, JSON.stringify(str), plcDataFd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 过程评判json数据
|
// 过程评判json数据
|
||||||
public setExamJudgeData = async (str: Object) => {
|
public setExamJudgeData = async (str: Object) => {
|
||||||
const { fileUtil, folderPath, examJudgeDataFd } = this;
|
const { fileUtil, folderPath, examJudgeDataFd } = this;
|
||||||
this.examJudgeDataFd = await fileUtil.editFile(`${folderPath}/judge_exam_data.txt`, JSON.stringify(str), examJudgeDataFd);
|
this.examJudgeDataFd =
|
||||||
|
await fileUtil.editFile(`${folderPath}/judge_exam_data.txt`, JSON.stringify(str), examJudgeDataFd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 过程评判回调数据
|
// 过程评判回调数据
|
||||||
public setExamJudgeCallbackData = async (str: string) => {
|
public setExamJudgeCallbackData = async (str: string) => {
|
||||||
const { fileUtil, folderPath, examJudgeCallbackDataFd } = this;
|
const { fileUtil, folderPath, examJudgeCallbackDataFd } = this;
|
||||||
this.examJudgeCallbackDataFd = await fileUtil.editFile(`${folderPath}/judge_progress_callback_data.txt`, str, examJudgeCallbackDataFd);
|
this.examJudgeCallbackDataFd =
|
||||||
|
await fileUtil.editFile(`${folderPath}/judge_progress_callback_data.txt`, str, examJudgeCallbackDataFd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 过程评判日志调数据
|
// 过程评判日志调数据
|
||||||
public setExamJudgeLogData = async (str: string) => {
|
public setExamJudgeLogData = async (str: string) => {
|
||||||
const { fileUtil, folderPath, examJudgeLogDataFd } = this;
|
const { fileUtil, folderPath, examJudgeLogDataFd } = this;
|
||||||
this.examJudgeLogDataFd = await fileUtil.editFile(`${folderPath}/judge_log_data.txt`, str, examJudgeLogDataFd);
|
this.examJudgeLogDataFd = await fileUtil.editFile(`${folderPath}/judge_log_data.txt`, str, examJudgeLogDataFd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置四合一画面数据
|
// 设置四合一画面数据
|
||||||
public setFourAndOneLogData = async (str: string) => {
|
public setFourAndOneLogData = async (str: string) => {
|
||||||
const { fileUtil, folderPath, fourAndOneLogDataFd } = this;
|
const { fileUtil, folderPath, fourAndOneLogDataFd } = this;
|
||||||
this.fourAndOneLogDataFd = await fileUtil.editFile(`${folderPath}/four_one_log_data.txt`, str, fourAndOneLogDataFd);
|
this.fourAndOneLogDataFd = await fileUtil.editFile(`${folderPath}/four_one_log_data.txt`, str, fourAndOneLogDataFd);
|
||||||
}
|
}
|
||||||
|
|
||||||
public setFourAndOneLogDataBytes = async (str: string) => {
|
public setFourAndOneLogDataBytes = async (str: string) => {
|
||||||
const { fileUtil, folderPath, fourAndOneLogDataBytesFd } = this;
|
const { fileUtil, folderPath, fourAndOneLogDataBytesFd } = this;
|
||||||
this.fourAndOneLogDataBytesFd = await fileUtil.editFile(`${folderPath}/four_one_log_byte_data.txt`, str, fourAndOneLogDataBytesFd);
|
this.fourAndOneLogDataBytesFd =
|
||||||
|
await fileUtil.editFile(`${folderPath}/four_one_log_byte_data.txt`, str, fourAndOneLogDataBytesFd);
|
||||||
}
|
}
|
||||||
|
|
||||||
//关闭所有文件写入
|
|
||||||
public closeAllFiles = async () => {
|
|
||||||
const {fileUtil,folderPath,fourAndOneLogDataFd} = this;
|
|
||||||
['exam_progress_data', 'wuxi_exam_data', 'wuxi_progress_data', 'plc_data', 'judge_exam_data', 'judge_progress_callback_data', 'judge_log_data', 'four_one_log_data', 'four_one_log_byte_data'].forEach(path => {
|
|
||||||
fileUtil.closeFile(`${folderPath}/${path}.txt`);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 无锡所轨迹数据
|
// 无锡所轨迹数据
|
||||||
public setExamLineData = async (plcStr) => {
|
public setExamLineData = async (plcStr) => {
|
||||||
const { fileUtil, folderPath, examLineDataFd } = this;
|
const { fileUtil, folderPath, examLineDataFd } = this;
|
||||||
const plcData = plcStr.split(',');
|
const plcData = plcStr.split(',');
|
||||||
const time = await getCurrentTime();
|
const time = await GetCurrentTime();
|
||||||
const lineData = [
|
const lineData = [
|
||||||
/*帧头*/time,
|
/*帧头*/time,
|
||||||
/*卫星时间*/time,
|
/*卫星时间*/time,
|
||||||
@ -138,11 +95,43 @@ export default class FileLog {
|
|||||||
/*天向位置坐标*/'',
|
/*天向位置坐标*/'',
|
||||||
/*东向速度*/'',
|
/*东向速度*/'',
|
||||||
/*北向速度*/'',
|
/*北向速度*/'',
|
||||||
/*评判信号1*/[plcData[14], plcData[19], plcData[5], '', plcData[2], plcData[3], plcData[7], plcData[8], plcData[13], plcData[12], plcData[17], '', plcData[4], plcData[11], plcData[20], plcData[9], 0].join(','),
|
/*评判信号1*/[plcData[14], plcData[19], plcData[5], '', plcData[2], plcData[3], plcData[7], plcData[8],
|
||||||
|
plcData[13], plcData[12], plcData[17], '', plcData[4], plcData[11], plcData[20], plcData[9], 0].join(','),
|
||||||
/*评判信号2*/['', plcData[28], '', '', plcData[10], '', '', '', '', '', '', '', '', '', '', '', '', ''].join(','),
|
/*评判信号2*/['', plcData[28], '', '', plcData[10], '', '', '', '', '', '', '', '', '', '', '', '', ''].join(','),
|
||||||
/*发动机转速*/ plcData[25],
|
/*发动机转速*/ plcData[25],
|
||||||
/*结束符*/ time,
|
/*结束符*/ time,
|
||||||
];
|
];
|
||||||
this.examLineDataFd = await fileUtil.editFile(`${folderPath}/exam_wuxi_data.txt`, JSON.stringify(lineData), examLineDataFd);
|
this.examLineDataFd =
|
||||||
|
await fileUtil.editFile(`${folderPath}/exam_wuxi_data.txt`, JSON.stringify(lineData), examLineDataFd);
|
||||||
};
|
};
|
||||||
|
//后续文件路径待替换
|
||||||
|
private fileUtil: FileUtil
|
||||||
|
private stuInfo: StuInfo
|
||||||
|
// 设置文件夹
|
||||||
|
public initFileLogo = async (stuInfo: StuInfo) => {
|
||||||
|
const { fileUtil, setExamLineData } = this
|
||||||
|
const { name, lsh, idCard } = stuInfo;
|
||||||
|
this.stuInfo = stuInfo;
|
||||||
|
const time = await GetCurrentTime()
|
||||||
|
const date = time.split(' ')[0].split('-').join('_')
|
||||||
|
const hourTime = time.split(' ')[1].split(':').join('_')
|
||||||
|
const folderPath = await fileUtil.initFolder(`/logs/${date}/${date}_${hourTime}_${lsh}_${idCard}_${name}`);
|
||||||
|
this.folderPath = folderPath;
|
||||||
|
return folderPath
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(context) {
|
||||||
|
const fileUtil = new FileUtil(context)
|
||||||
|
this.fileUtil = fileUtil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//关闭所有文件写入
|
||||||
|
public closeAllFiles = async () => {
|
||||||
|
const { fileUtil, folderPath, fourAndOneLogDataFd } = this;
|
||||||
|
['exam_progress_data', 'wuxi_exam_data', 'wuxi_progress_data', 'plc_data', 'judge_exam_data',
|
||||||
|
'judge_progress_callback_data', 'judge_log_data', 'four_one_log_data', 'four_one_log_byte_data'].forEach(path => {
|
||||||
|
fileUtil.closeFile(`${folderPath}/${path}.txt`);
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
import { Array2Byte, string2Bytes } from '../../../common/utils/tools';
|
|
||||||
import { testMarkRules, testRealExam } from '../dataTest/index';
|
import { testMarkRules, testRealExam } from '../dataTest/index';
|
||||||
|
|
||||||
import systemTime from '@ohos.systemDateTime';
|
import systemTime from '@ohos.systemDateTime';
|
||||||
|
import { Array2Byte } from './Common';
|
||||||
|
|
||||||
//获取本地扣分项
|
//获取本地扣分项
|
||||||
export const getTestMarkRules = () => {
|
export const getTestMarkRules = () => {
|
||||||
@ -26,7 +26,7 @@ export const getTranslateSignals = (tempItems) => {
|
|||||||
arr.push(temp.join(''));
|
arr.push(temp.join(''));
|
||||||
}
|
}
|
||||||
const temp = arr.map(numStr => parseInt(numStr, 2))
|
const temp = arr.map(numStr => parseInt(numStr, 2))
|
||||||
return temp.map(item => string2Bytes(item, 8)[0])
|
return temp.map(item => NumberToByteArray(item, 8)[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
// c++评判考车行驶状态转换
|
// c++评判考车行驶状态转换
|
||||||
@ -4,7 +4,11 @@ enum timeType {
|
|||||||
fulltime = 1
|
fulltime = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取当前时间
|
/**
|
||||||
|
* 获取当前时间
|
||||||
|
* @param type
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
export function GetCurrentTime(type?: timeType): string {
|
export function GetCurrentTime(type?: timeType): string {
|
||||||
if (type === 1) {
|
if (type === 1) {
|
||||||
return dayTs().format("YYYYMMDDHHmmss")
|
return dayTs().format("YYYYMMDDHHmmss")
|
||||||
@ -13,7 +17,12 @@ export function GetCurrentTime(type?: timeType): string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//是否是多少天前
|
/**
|
||||||
|
* 是否是指定天数之前
|
||||||
|
* @param date
|
||||||
|
* @param days
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
export function IsDaysAgo(date: string | number | Date, days: number = 2): boolean {
|
export function IsDaysAgo(date: string | number | Date, days: number = 2): boolean {
|
||||||
const today = dayTs(); // 当前日期
|
const today = dayTs(); // 当前日期
|
||||||
const target = dayTs(date).format("YYYY-MM-DD HH:mm:ss.SSS"); // 需要判断的日期
|
const target = dayTs(date).format("YYYY-MM-DD HH:mm:ss.SSS"); // 需要判断的日期
|
||||||
@ -35,3 +44,73 @@ export function StringToBytes(str: string): Uint8Array {
|
|||||||
}
|
}
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
// import {
|
||||||
|
// Array2Byte,
|
||||||
|
// convertGpsCoord2,
|
||||||
|
// deepClone,
|
||||||
|
// fillZero,
|
||||||
|
// getCurrentTime,
|
||||||
|
// string2Bytes,
|
||||||
|
// stringToASC
|
||||||
|
// } from '../../common/utils/tools';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字符串转ASCII码
|
||||||
|
*/
|
||||||
|
export function StringToASCII(str: string): number[] {
|
||||||
|
const arr: number[] = [];
|
||||||
|
for (let i = 0; i < str.length; i++) {
|
||||||
|
arr.push(str.charCodeAt(i));
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数组转字节
|
||||||
|
*/
|
||||||
|
export function ArrayToByteArray(array: number[]): Uint8Array {
|
||||||
|
const buf = new ArrayBuffer(array.length);
|
||||||
|
const view = new Uint8Array(buf);
|
||||||
|
for (let i = 0; i < array.length; i++) {
|
||||||
|
view[i] = array[i] & 0xFF;
|
||||||
|
}
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字符串转字节数组
|
||||||
|
* @param number 要转换的数字
|
||||||
|
* @param len 字节数
|
||||||
|
* @returns 返回字节数组
|
||||||
|
*/
|
||||||
|
export function NumberToByteArray(number: number, len: number): number[] | undefined {
|
||||||
|
let str = Math.floor(number).toString(2);
|
||||||
|
if (str.length > len) {
|
||||||
|
console.log('数据长度不对~~');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const byteString = FillZero(str, len);
|
||||||
|
|
||||||
|
const arrBytes: number[] = [];
|
||||||
|
for (let i = byteString.length; i > 0; ) {
|
||||||
|
let j = i - 8;
|
||||||
|
if (j < 0) {
|
||||||
|
j = 0;
|
||||||
|
}
|
||||||
|
const s = byteString.slice(j, i);
|
||||||
|
const v = parseInt(s, 2);
|
||||||
|
arrBytes.push(v);
|
||||||
|
i -= 8;
|
||||||
|
}
|
||||||
|
return arrBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function FillZero(str: string | number, len: number): string {
|
||||||
|
str = str.toString();
|
||||||
|
if (str.length >= len || len <= 0) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
const zeroStr = '0'.repeat(len - str.length);
|
||||||
|
return zeroStr + str;
|
||||||
|
}
|
||||||
@ -1,28 +1,20 @@
|
|||||||
import FileUtil from './File'
|
import FileUtil from './File'
|
||||||
import {getCurrentTime} from './tools'
|
|
||||||
import { uploadHarmonyLiCheng } from '../../api/judge'
|
import { uploadHarmonyLiCheng } from '../../api/judge'
|
||||||
|
import { GetCurrentTime } from '../Common'
|
||||||
|
|
||||||
const LOGTAG = 'GetDistance'
|
const LOGTAG = 'GetDistance'
|
||||||
export default class GetDistance {
|
|
||||||
|
|
||||||
//后续文件路径待替换
|
export default class GetDistance {
|
||||||
private fileUtil: FileUtil
|
|
||||||
public folderPath: string
|
public folderPath: string
|
||||||
public timeStr: string
|
public timeStr: string
|
||||||
public totalDistance: number
|
public totalDistance: number
|
||||||
public totalTime: number
|
public totalTime: number
|
||||||
public date: string
|
public date: string
|
||||||
public fd: number
|
public fd: number
|
||||||
|
|
||||||
constructor(context) {
|
|
||||||
const fileUtil = new FileUtil(context)
|
|
||||||
this.fileUtil = fileUtil;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 设置文件夹
|
// 设置文件夹
|
||||||
public initFolder = async () => {
|
public initFolder = async () => {
|
||||||
const { fileUtil } = this
|
const { fileUtil } = this
|
||||||
const time = await getCurrentTime()
|
const time = await GetCurrentTime()
|
||||||
const folderPath = await fileUtil.initFolder(`/车辆行驶距离统计`);
|
const folderPath = await fileUtil.initFolder(`/车辆行驶距离统计`);
|
||||||
console.info('surenjun folderPath=>', folderPath);
|
console.info('surenjun folderPath=>', folderPath);
|
||||||
const date = time.split(' ')[0].split('-').join('_')
|
const date = time.split(' ')[0].split('-').join('_')
|
||||||
@ -33,10 +25,18 @@ export default class GetDistance {
|
|||||||
this.totalTime = 0;
|
this.totalTime = 0;
|
||||||
this.date = date;
|
this.date = date;
|
||||||
this.fd = await fileUtil.editFile(
|
this.fd = await fileUtil.editFile(
|
||||||
`${folderPath}/${date}.txt`,`程序启动时间:${timeStr} 累计行驶距离:${this.totalDistance}m 累计运行时常:${this.totalTime}min`,this.fd
|
`${folderPath}/${date}.txt`,
|
||||||
|
`程序启动时间:${timeStr} 累计行驶距离:${this.totalDistance}m 累计运行时常:${this.totalTime}min`, this.fd
|
||||||
);
|
);
|
||||||
return folderPath
|
return folderPath
|
||||||
}
|
}
|
||||||
|
//后续文件路径待替换
|
||||||
|
private fileUtil: FileUtil
|
||||||
|
|
||||||
|
constructor(context) {
|
||||||
|
const fileUtil = new FileUtil(context)
|
||||||
|
this.fileUtil = fileUtil;
|
||||||
|
}
|
||||||
|
|
||||||
// 过程文件数据
|
// 过程文件数据
|
||||||
public setTimeData = async (str: number) => {
|
public setTimeData = async (str: number) => {
|
||||||
@ -47,7 +47,9 @@ export default class GetDistance {
|
|||||||
console.info('surenjun contentArr', JSON.stringify(contentArr))
|
console.info('surenjun contentArr', JSON.stringify(contentArr))
|
||||||
this.totalDistance += (str * 1 > 200 ? 200 : str * 1)
|
this.totalDistance += (str * 1 > 200 ? 200 : str * 1)
|
||||||
this.totalTime += 1;
|
this.totalTime += 1;
|
||||||
contentArr[contentArr.length - 1] = `程序启动时间:${timeStr} 累计行驶距离:${(this.totalDistance).toFixed(2)}m 累计运行时常:${Math.ceil(this.totalTime/60)}min`+ '\n'
|
contentArr[contentArr.length - 1] =
|
||||||
|
`程序启动时间:${timeStr} 累计行驶距离:${(this.totalDistance).toFixed(2)}m 累计运行时常:${Math.ceil(this.totalTime /
|
||||||
|
60)}min` + '\n'
|
||||||
console.info('surenjun', contentArr.join('\n'))
|
console.info('surenjun', contentArr.join('\n'))
|
||||||
console.log('folderPath', folderPath, date)
|
console.log('folderPath', folderPath, date)
|
||||||
this.uploadData()
|
this.uploadData()
|
||||||
@ -56,7 +58,6 @@ export default class GetDistance {
|
|||||||
// `${folderPath}/${date}.txt`,contentArr.join('\n')
|
// `${folderPath}/${date}.txt`,contentArr.join('\n')
|
||||||
// );
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
//上传行驶里程数据
|
//上传行驶里程数据
|
||||||
uploadData = async () => {
|
uploadData = async () => {
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
@ -72,5 +73,4 @@ export default class GetDistance {
|
|||||||
})
|
})
|
||||||
}, 5000)
|
}, 5000)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user