fix: 补全日志
This commit is contained in:
parent
0ee2b76130
commit
46730847ee
@ -71,5 +71,9 @@ export const StartExamTag = '[StartExam]'
|
||||
|
||||
//人脸对比
|
||||
export const FaceCompareTag = '[FaceCompare]';
|
||||
|
||||
//过程数据处理
|
||||
export const ProcessDataTag = '[ProcessData]';
|
||||
|
||||
// 日志
|
||||
export const LogTag = '[LogWorker]';
|
||||
|
||||
@ -206,6 +206,7 @@ struct JudgePage {
|
||||
}
|
||||
|
||||
async aboutToAppear() {
|
||||
dConsole.log(JudgeTag, "JudgePage aboutToAppear")
|
||||
this.carInfo = AppStorage.get<CarInfoType>('carInfo')!
|
||||
this.singlePlay = AppStorage.get<boolean>('singlePlay')!
|
||||
this.startFullTime = dayTs().format("YYYYMMDDHHmmss");
|
||||
|
||||
@ -12,13 +12,19 @@ export default struct MessageComponent {
|
||||
@Prop jl: number
|
||||
@Prop wayno: number
|
||||
@Prop judgeConfigObj: DefaultJudgeConfigObj
|
||||
@State timer: number = -1
|
||||
|
||||
aboutToAppear(): void {
|
||||
setInterval(async () => {
|
||||
this.timer = setInterval(async () => {
|
||||
this.examTime += 1;
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
clearInterval(this.timer)
|
||||
this.timer = -1
|
||||
}
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Column() {
|
||||
|
||||
@ -166,6 +166,7 @@ struct UserInfoPage {
|
||||
]
|
||||
//开始考试准备
|
||||
prePareExam = async () => {
|
||||
dConsole.log(StartExamTag, 'prePareExam')
|
||||
try {
|
||||
// await this.checkSignal()
|
||||
await CheckSignal(this.systemParam, this.avPlayer)
|
||||
@ -175,14 +176,16 @@ struct UserInfoPage {
|
||||
if (!this.currentUser.xm) {
|
||||
return
|
||||
}
|
||||
// 单机
|
||||
if (this.singlePlay) {
|
||||
this.currentUser.id = '0'
|
||||
dConsole.log('开始考试3')
|
||||
dConsole.log(StartExamTag, '开始考试3', this.currentUser)
|
||||
SqlInsertTable('USER', [this.currentUser]).catch((e: BusinessError) => {
|
||||
dConsole.log("error", JSON.stringify(e))
|
||||
dConsole.log(StartExamTag, "error", JSON.stringify(e))
|
||||
})
|
||||
// 初始化开始考试过程数据文件夹
|
||||
InitializeExamProcessData(this.currentUser)
|
||||
dConsole.log(StartExamTag, '开始考试4')
|
||||
router.pushUrl({
|
||||
url: this.carInfo.examSubject == '3' ? 'pages/Roads' : 'pages/Judge',
|
||||
params: {
|
||||
@ -193,7 +196,7 @@ struct UserInfoPage {
|
||||
this.stopDeviceById()
|
||||
return
|
||||
}
|
||||
dConsole.log('this.FaceOpenStatuethis.FaceOpenStatue', this.FaceOpenStatue)
|
||||
dConsole.log(StartExamTag, 'this.FaceOpenStatuethis.FaceOpenStatue', this.FaceOpenStatue)
|
||||
if (this.FaceOpenStatue != '0') {
|
||||
// 同一学员连续第二次考试时不再验证身份
|
||||
if (this.currentUser.kssycs == '1' && this.systemParam.Param830Str == '1') {
|
||||
@ -205,7 +208,7 @@ struct UserInfoPage {
|
||||
this.sfbdinterfaceFn()
|
||||
}
|
||||
} catch (e) {
|
||||
dConsole.info('Throw Error', JSON.stringify(e))
|
||||
dConsole.error(UserInfoTag, 'Throw Error', JSON.stringify(e))
|
||||
}
|
||||
|
||||
}
|
||||
@ -292,7 +295,7 @@ struct UserInfoPage {
|
||||
// TODO UDP更改
|
||||
//监听远程开始考试
|
||||
JudgeEmitterInstance.onBeginExam(async () => {
|
||||
dConsole.info('surenjun', 'userInfo收到UdpEvent事件')
|
||||
dConsole.log('surenjun', 'userInfo收到UdpEvent事件')
|
||||
if (this.isBoardPrePareSetPopupOpen && !this.isFirstBoardPrePareSetPopupBtnShow) {
|
||||
await this.prePareSCZB()
|
||||
} else {
|
||||
@ -315,7 +318,7 @@ struct UserInfoPage {
|
||||
if (ret == 0) {
|
||||
testNapi.StartReadCard(this.onReadCard);
|
||||
} else {
|
||||
dConsole.error("zzctest Failed to Open Device");
|
||||
dConsole.error(UserInfoTag, " Failed to Open Device");
|
||||
}
|
||||
}
|
||||
|
||||
@ -380,7 +383,7 @@ struct UserInfoPage {
|
||||
}
|
||||
|
||||
onReadCard(ret: IDCardSDK.IDCardInfo) {
|
||||
dConsole.info(`zzctest xx Read Card ret =${ret.status}`)
|
||||
dConsole.log(`zzctest xx Read Card ret =${ret.status}`)
|
||||
let thisVar: IdCard = AppStorage.get('indexComponent')!;
|
||||
|
||||
if (ret.status == 0) { // status = 1 为读到身份证信息; status = 1 为身份证离开读卡器
|
||||
@ -399,10 +402,10 @@ struct UserInfoPage {
|
||||
|
||||
if (ret.baseInfo.length > 2) {
|
||||
// 收到身份证信息,填充页面
|
||||
dConsole.info(`zzctest Read Card 1`);
|
||||
dConsole.log(`zzctest Read Card 1`);
|
||||
let subIndex = ret.baseInfo.indexOf(":")
|
||||
let baseInfo: string = ret.baseInfo.substring(subIndex + 1, ret.baseInfo.length - 1);
|
||||
dConsole.info(`zzctest Read Card 2 baseInfo=${baseInfo}`);
|
||||
dConsole.log(`zzctest Read Card 2 baseInfo=${baseInfo}`);
|
||||
let baseInfos: string[] = baseInfo.split("|");
|
||||
thisVar.name = baseInfos[0];
|
||||
thisVar.sex = baseInfos[1];
|
||||
@ -418,7 +421,7 @@ struct UserInfoPage {
|
||||
// 身份证照片数据处理
|
||||
if (ret.photo instanceof ArrayBuffer) {
|
||||
let dataView = new DataView(ret.photo)
|
||||
dConsole.info(`Read Card ret = length = ${dataView.byteLength}`)
|
||||
dConsole.log(`Read Card ret = length = ${dataView.byteLength}`)
|
||||
let str = ""
|
||||
for (let i = 0; i < dataView.byteLength; ++i) {
|
||||
let c = String.fromCharCode(dataView.getUint8(i))
|
||||
@ -428,7 +431,7 @@ struct UserInfoPage {
|
||||
}
|
||||
thisVar.photo += str;
|
||||
}
|
||||
dConsole.info(`zzctest Read Card end`);
|
||||
dConsole.log(`zzctest Read Card end`);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -880,9 +883,9 @@ struct UserInfoPage {
|
||||
this.startExamDialogController.open()
|
||||
|
||||
avPlayer.playAudio([`voice/监管通信中.mp3`], false, async () => {
|
||||
dConsole.info('surenjun', '播放结束开始考试接口调用')
|
||||
dConsole.log(StartExamTag, '播放结束开始考试接口调用')
|
||||
const res = await this.beginExam()
|
||||
dConsole.info('surenjun', '开始考试接口调用结束', JSON.stringify(res))
|
||||
dConsole.log(StartExamTag, '开始考试接口调用结束', res)
|
||||
//TODO code转换
|
||||
if (res.code != 1) {
|
||||
avPlayer.playAudio([res.code == -200 ? 'voice/photo_error.mp3' : 'voice/监管审核未通过.mp3']);
|
||||
@ -895,12 +898,18 @@ struct UserInfoPage {
|
||||
return
|
||||
}
|
||||
this.currentUser.id = '0'
|
||||
// await upDateTableByArray('USER', [this.currentUser])
|
||||
dConsole.log(StartExamTag, '插入用户表1')
|
||||
try {
|
||||
await SqlInsertTable('USER', [this.currentUser])
|
||||
} catch (e) {
|
||||
dConsole.error(StartExamTag, '插入用户表失败', e)
|
||||
}
|
||||
dConsole.log(StartExamTag, '插入用户表结束', res)
|
||||
this.stepFlag = false
|
||||
this.startExamDialogController.close()
|
||||
// 初始化开始考试过程数据文件夹
|
||||
InitializeExamProcessData(this.currentUser)
|
||||
|
||||
router.pushUrl({
|
||||
url: 'pages/Judge',
|
||||
params: {
|
||||
@ -923,6 +932,7 @@ struct UserInfoPage {
|
||||
const startHourTime = dayTs().format("HHmmssSSS")
|
||||
AppStorage.setOrCreate('startHourTime', startHourTime)
|
||||
const photoBase64 = await GetPhotoBase64(this.context);
|
||||
dConsole.log(StartExamTag, "开始考试拍照完成")
|
||||
if (photoBase64 == '') {
|
||||
dConsole.log(StartExamTag, "拍照失败")
|
||||
this.startExamDialogController.close()
|
||||
@ -949,7 +959,7 @@ struct UserInfoPage {
|
||||
//接口标识
|
||||
jkid: '17C51',
|
||||
}
|
||||
dConsole.info('surenjunjianguan', JSON.stringify(param))
|
||||
dConsole.log(StartExamTag, "开始考试上传中心参数", param)
|
||||
const temp = await writeObjectOut(param, "", this.context);
|
||||
AppStorage.setOrCreate('lsh', this.currentUser.lsh)
|
||||
this.examinerLoginInfo.ksyh = this.currentUser.ksy1sfzmhm
|
||||
@ -1136,6 +1146,7 @@ struct UserInfoPage {
|
||||
dConsole.log(UserInfoTag, "不给开始考试")
|
||||
return
|
||||
}
|
||||
dConsole.log(StartExamTag, "开始考试按钮点击")
|
||||
await this.prePareExam()
|
||||
})
|
||||
}
|
||||
|
||||
@ -15,8 +15,20 @@ export enum ColumnType {
|
||||
}
|
||||
|
||||
class DbUtils {
|
||||
private static instance: DbUtils | null = null;
|
||||
rdbStore: relationalStore.RdbStore | undefined = undefined
|
||||
|
||||
private constructor() {
|
||||
console.log(DbTag, "DbUtils instance created.");
|
||||
}
|
||||
|
||||
public static getInstance(): DbUtils {
|
||||
if (!DbUtils.instance) {
|
||||
DbUtils.instance = new DbUtils();
|
||||
}
|
||||
return DbUtils.instance;
|
||||
}
|
||||
|
||||
// 初始化 无需记录日志
|
||||
init(context: common.UIAbilityContext) {
|
||||
let config: relationalStore.StoreConfig = {
|
||||
@ -27,6 +39,7 @@ class DbUtils {
|
||||
relationalStore.getRdbStore(context, config)
|
||||
.then(rdbStore => {
|
||||
this.rdbStore = rdbStore
|
||||
console.log(DbTag, "rdbStore:", JSON.stringify(rdbStore))
|
||||
console.log(DbTag, "db rdbStore init success")
|
||||
resolve()
|
||||
})
|
||||
@ -60,6 +73,7 @@ class DbUtils {
|
||||
clearTable(tableName: string): Promise<void> {
|
||||
let sql = `DELETE FROM ${tableName}`
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log(DbTag, "sql clearTable", JSON.stringify(this.rdbStore))
|
||||
if (this.rdbStore) {
|
||||
this.rdbStore?.executeSql(sql).then(() => {
|
||||
console.log(DbTag, "sql clearTable success", sql)
|
||||
@ -242,6 +256,7 @@ class DbUtils {
|
||||
}
|
||||
}
|
||||
|
||||
let DB: DbUtils = new DbUtils()
|
||||
// let DB: DbUtils = new DbUtils()
|
||||
const DB: DbUtils = DbUtils.getInstance();
|
||||
|
||||
export default DB
|
||||
|
||||
@ -70,6 +70,7 @@ function getDataFn(config: EnvironmentConfigurationType) {
|
||||
// 需要观察
|
||||
console.log(WorkerTag, "后置机消息", data)
|
||||
const res = await SerialPortService.getData()
|
||||
console.log(SerialPortTag, "档位原始数据", res)
|
||||
if (res.length > 0) {
|
||||
const dataArray = data.split(",");
|
||||
// 替换data的第28位
|
||||
|
||||
@ -1,13 +1,6 @@
|
||||
import worker, { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope } from '@ohos.worker';
|
||||
import { GlobalConfig } from '../config';
|
||||
import {
|
||||
FileQueueType,
|
||||
LogFileFd,
|
||||
LogPathType,
|
||||
LogWorkerMessage,
|
||||
ProcessDataEnumType,
|
||||
WorkerMessageType
|
||||
} from '../model';
|
||||
import { GlobalConfig, LogTag } from '../config';
|
||||
import { FileQueueType, LogPathType, LogWorkerMessage, ProcessDataEnumType, WorkerMessageType } from '../model';
|
||||
import { CreateDir, CreateFile, EditFile, IsExit } from '../utils/Common';
|
||||
import dayTs from '../utils/Date';
|
||||
import fs from '@ohos.file.fs';
|
||||
@ -20,7 +13,7 @@ let fileFdArr: number[] = []
|
||||
let writeQueue: Array<FileQueueType> = [];
|
||||
let isProcessing = false;
|
||||
workerPort.onmessage = (e: MessageEvents) => {
|
||||
console.log("日志系统worker收到消息")
|
||||
console.log(LogTag, "日志系统worker收到消息")
|
||||
// 日志文件目录
|
||||
let logPaths: LogPathType = {
|
||||
log: `${GlobalConfig.commonFileWriteAddress}/logs/${dayTs().format("YYYY_MM_DD")}/log/log.log`,
|
||||
@ -80,7 +73,7 @@ async function InitLog() {
|
||||
|
||||
// 初始化学员过程数据目录
|
||||
async function InitExam(dirName: string) {
|
||||
console.log("初始化过程", dirName)
|
||||
console.log(LogTag, "初始化过程", dirName)
|
||||
let date = dayTs().format("YYYY_MM_DD")
|
||||
const path = `${GlobalConfig.commonFileWriteAddress}/logs/${date}/${dirName}`
|
||||
const nameDirIsExit = await IsExit(path)
|
||||
@ -90,7 +83,7 @@ async function InitExam(dirName: string) {
|
||||
// 创建几个文件
|
||||
fileNameArr.forEach(async (item: string, index: number) => {
|
||||
let filePath = path + "/" + item
|
||||
console.log("创建文件", filePath)
|
||||
console.log(LogTag, "创建文件", filePath)
|
||||
let result = await CreateFile(filePath)
|
||||
fileFdArr[index] = result
|
||||
})
|
||||
@ -132,7 +125,6 @@ async function WriteProcessData(type: ProcessDataEnumType, data: string) {
|
||||
} else {
|
||||
writeQueue.push({ type, data });
|
||||
}
|
||||
|
||||
if (!isProcessing) {
|
||||
processQueue();
|
||||
}
|
||||
@ -153,7 +145,7 @@ function CloseProcessData() {
|
||||
fileFdArr.forEach((item: number) => {
|
||||
fs.closeSync(item)
|
||||
})
|
||||
console.log("关闭过程数据")
|
||||
console.log(LogTag, "关闭过程数据")
|
||||
}
|
||||
|
||||
workerPort.onmessageerror = (e: MessageEvents) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user