fix: 优化代码格式,统一空格和分号使用

This commit is contained in:
wangzhongjie 2025-04-01 11:22:17 +08:00
parent fca24538d0
commit 6984855346
3 changed files with 91 additions and 94 deletions

View File

@ -2,7 +2,7 @@ import common from '@ohos.app.ability.common';
// ------------------------------ // ------------------------------
// 基础共用类型 // 基础共用类型
// ------------------------------ // ------------------------------
import { MA_SYSTEMPARMType } from './Table' import { MA_SYSTEMPARMType } from './Table';
/** 基础考试字段 */ /** 基础考试字段 */
interface BaseExamFields { interface BaseExamFields {
@ -214,9 +214,9 @@ export interface Plc {
extend: object extend: object
//轨迹回放需要 //轨迹回放需要
method?: string method?: string
itemno: string itemno?: string
type: 1 | 2 type?: 1 | 2
serial: 1 | 2 serial?: 1 | 2
} }
interface Qfsj { interface Qfsj {
@ -381,7 +381,7 @@ export interface MarkRule {
score?: number score?: number
xmmcStr?: string xmmcStr?: string
desc?: string desc?: string
type?: 0|1|2 type?: 0 | 1 | 2
} }
export interface UploadExamMileage { export interface UploadExamMileage {
@ -677,12 +677,12 @@ export interface JudgeEventKf {
nocancelid?: number nocancelid?: number
NoCancelId?: number NoCancelId?: number
gps_sid?: number, gps_sid?: number,
GPS_SID?:boolean GPS_SID?: boolean
score?:number score?: number
xmmcStr?: string xmmcStr?: string
desc?: string desc?: string
xmdm?: number xmdm?: number
type?: 0 | 1 | 2 |3 type?: 0 | 1 | 2 | 3
} }
export interface JudgeKsjs { export interface JudgeKsjs {
@ -719,54 +719,55 @@ export interface JudgeNongps {
type: 0 | 1 | 2 | 3 | 4 type: 0 | 1 | 2 | 3 | 4
} }
interface UdpKf{ interface UdpKf {
kfxh:string kfxh: string
directives:string directives: string
} }
export interface JudgeUdpKf { export interface JudgeUdpKf {
data:UdpKf data: UdpKf
} }
export interface JudgePerformInfo { export interface JudgePerformInfo {
time: number time: number
carzt:-1 | 0 |1 carzt: -1 | 0 | 1
grade:number grade: number
qjjl:number qjjl: number
dcjl:number dcjl: number
dxjl:number dxjl: number
bxjl:number bxjl: number
hint:string hint: string
lane:PerLane lane: PerLane
} }
interface PerLane{ interface PerLane {
MapRoad_Code_No:string MapRoad_Code_No: string
MapRoad_Name:string MapRoad_Name: string
TouchLineType:number TouchLineType: number
TouchDir:number TouchDir: number
TouchLineTypeCS:number TouchLineTypeCS: number
TouchLineDirCS:number TouchLineDirCS: number
BasePointInLaneNo:number BasePointInLaneNo: number
BaseLaneCount:number BaseLaneCount: number
FrontPointLaneNo:number FrontPointLaneNo: number
FrontPointLaneCount:number FrontPointLaneCount: number
Body_LF_ToLeftEdge:number Body_LF_ToLeftEdge: number
Body_LB_ToLeftEdge:number Body_LB_ToLeftEdge: number
Body_RF_ToRightEdge:number Body_RF_ToRightEdge: number
Body_RB_ToRightEdge:number Body_RB_ToRightEdge: number
Wheel_RF_ToRightEdge:number Wheel_RF_ToRightEdge: number
Wheel_RB_ToRightEdge:number Wheel_RB_ToRightEdge: number
Wheel_RF_ToBaseLine:number Wheel_RF_ToBaseLine: number
Wheel_LF_ToRightEdge:number Wheel_LF_ToRightEdge: number
Wheel_LB_ToRightEdge:number Wheel_LB_ToRightEdge: number
Wheel_LF_ToBaseLine:number Wheel_LF_ToBaseLine: number
Wheel_LB_ToBaseLine:number Wheel_LB_ToBaseLine: number
BasePointInLaneDir:string BasePointInLaneDir: string
CrossLineAttr:number CrossLineAttr: number
InShapeAttr:number InShapeAttr: number
ShapeNo:number ShapeNo: number
CrossPointNo:number CrossPointNo: number
} }
export interface JudgeCallBackData { export interface JudgeCallBackData {

View File

@ -8,7 +8,6 @@ interface StuInfo {
idCard: string idCard: string
} }
const LOGTAG = 'LOGTAG'
export default class FileLog { export default class FileLog {
public folderPath: string public folderPath: string
@ -27,48 +26,46 @@ export default class FileLog {
// 过程文件数据 // 过程文件数据
public setExamProgressData = async (str: Object) => { public setExamProgressData = async (str: Object) => {
this.progressDataFd = this.progressDataFd =
await this.fileUtil.editFile(`${this.folderPath}/exam_progress_data.txt`, JSON.stringify(str), await this.fileUtil.editFile(`${this.folderPath}/exam_progress_data.txt`, JSON.stringify(str));
this.progressDataFd);
} }
// 无锡所接口数据 // 无锡所接口数据
public setExamJudgeWuxiData = async (str: string) => { public setExamJudgeWuxiData = async (str: string) => {
this.examJudgeWuxiDataFd = this.examJudgeWuxiDataFd =
await this.fileUtil.editFile(`${this.folderPath}/wuxi_exam_data.txt`, str, this.examJudgeWuxiDataFd); await this.fileUtil.editFile(`${this.folderPath}/wuxi_exam_data.txt`, str);
} }
// 无锡所过程数据 // 无锡所过程数据
public setExamJudgeWuxiProgressData = async (str: string) => { public setExamJudgeWuxiProgressData = async (str: string) => {
this.examJudgeWuxiProgressDataFd = this.examJudgeWuxiProgressDataFd =
await this.fileUtil.editFile(`${this.folderPath}/wuxi_progress_data.txt`, str, this.examJudgeWuxiProgressDataFd); await this.fileUtil.editFile(`${this.folderPath}/wuxi_progress_data.txt`, str);
} }
// plc文件数据 // plc文件数据
public setPlcProgressData = async (str: Object) => { public setPlcProgressData = async (str: Object) => {
this.plcDataFd = this.plcDataFd =
await this.fileUtil.editFile(`${this.folderPath}/plc_data.txt`, JSON.stringify(str), this.plcDataFd); await this.fileUtil.editFile(`${this.folderPath}/plc_data.txt`, JSON.stringify(str));
} }
// 过程评判json数据 // 过程评判json数据
public setExamJudgeData = async (str: string) => { public setExamJudgeData = async (str: string) => {
this.examJudgeDataFd = this.examJudgeDataFd =
await this.fileUtil.editFile(`${this.folderPath}/judge_exam_data.txt`, str, this.examJudgeDataFd); await this.fileUtil.editFile(`${this.folderPath}/judge_exam_data.txt`, str);
} }
// 过程评判回调数据 // 过程评判回调数据
public setExamJudgeCallbackData = async (str: string) => { public setExamJudgeCallbackData = async (str: string) => {
this.examJudgeCallbackDataFd = this.examJudgeCallbackDataFd =
await this.fileUtil.editFile(`${this.folderPath}/judge_progress_callback_data.txt`, str, await this.fileUtil.editFile(`${this.folderPath}/judge_progress_callback_data.txt`, str);
this.examJudgeCallbackDataFd);
} }
// 过程评判日志调数据 // 过程评判日志调数据
public setExamJudgeLogData = async (str: string) => { public setExamJudgeLogData = async (str: string) => {
this.examJudgeLogDataFd = this.examJudgeLogDataFd =
await this.fileUtil.editFile(`${this.folderPath}/judge_log_data.txt`, str, this.examJudgeLogDataFd); await this.fileUtil.editFile(`${this.folderPath}/judge_log_data.txt`, str);
} }
// 设置四合一画面数据 // 设置四合一画面数据
public setFourAndOneLogData = async (str: string) => { public setFourAndOneLogData = async (str: string) => {
this.fourAndOneLogDataFd = this.fourAndOneLogDataFd =
await this.fileUtil.editFile(`${this.folderPath}/four_one_log_data.txt`, str, this.fourAndOneLogDataFd); await this.fileUtil.editFile(`${this.folderPath}/four_one_log_data.txt`, str);
} }
public setFourAndOneLogDataBytes = async (str: string) => { public setFourAndOneLogDataBytes = async (str: string) => {
this.fourAndOneLogDataBytesFd = this.fourAndOneLogDataBytesFd =
await this.fileUtil.editFile(`${this.folderPath}/four_one_log_byte_data.txt`, str, this.fourAndOneLogDataBytesFd); await this.fileUtil.editFile(`${this.folderPath}/four_one_log_byte_data.txt`, str);
} }
// 无锡所轨迹数据 // 无锡所轨迹数据
public setExamLineData = async (plcStr: string) => { public setExamLineData = async (plcStr: string) => {
@ -101,13 +98,12 @@ export default class FileLog {
/*结束符*/ time, /*结束符*/ time,
]; ];
this.examLineDataFd = this.examLineDataFd =
await this.fileUtil.editFile(`${this.folderPath}/exam_wuxi_data.txt`, JSON.stringify(lineData), await this.fileUtil.editFile(`${this.folderPath}/exam_wuxi_data.txt`, JSON.stringify(lineData));
this.examLineDataFd);
}; };
private stuInfo: StuInfo // private stuInfo: StuInfo
// 设置文件夹 // 设置文件夹
public initFileLogo = async (stuInfo: StuInfo) => { public initFileLogo = async (stuInfo: StuInfo) => {
this.stuInfo = stuInfo; // this.stuInfo = stuInfo;
const time = GetCurrentTime() const time = GetCurrentTime()
const date = time.split(' ')[0].split('-').join('_') const date = time.split(' ')[0].split('-').join('_')
const hourTime = time.split(' ')[1].split(':').join('_') const hourTime = time.split(' ')[1].split(':').join('_')

View File

@ -1,17 +1,17 @@
import { testMarkRules, testRealExam } from '../dataTest/index'; import { testRealExam } from '../dataTest/index';
import { GetCurrentTime, NumberToByteArray } from '../../../utils/Common'; import { NumberToByteArray } from '../../../utils/Common';
import systemTime from '@ohos.systemDateTime'; import systemTime from '@ohos.systemDateTime';
import { Array2Byte } from './Common'; import { Array2Byte } from './Common';
import { CarInfoType } from '../../../model'; import { CarInfoType } from '../../../model';
import { Gps, Lane,Plc,Vision,Radar, Sensor,DefaultJudgeConfigObj, JudgeLane} from '../../../model/Judge' import { DefaultJudgeConfigObj, Gps, JudgeLane, Plc, Radar, Sensor, Vision } from '../../../model/Judge';
interface Extend {} interface Extend {}
// 中心信号转换 // 中心信号转换
export const getTranslateSignals = (tempItems:number[]) => { export const getTranslateSignals = (tempItems: number[]) => {
const len = Math.floor(tempItems.length / 8); const len = Math.floor(tempItems.length / 8);
const arr:string[] = []; const arr: string[] = [];
for (let i = 0; i < len; i++) { for (let i = 0; i < len; i++) {
const temp = tempItems.slice(i * 8, (i + 1) * 8); const temp = tempItems.slice(i * 8, (i + 1) * 8);
arr.push(temp.join('')); arr.push(temp.join(''));
@ -35,7 +35,7 @@ export function getCarStatus(status: -1 | 0 | 1): string {
} }
// 当前考车中心状态转换 // 当前考车中心状态转换
export function getCarStatusType(carzt?:number) { export function getCarStatusType(carzt?: number) {
switch (carzt) { switch (carzt) {
case -1: case -1:
return [1, 0] return [1, 0]
@ -49,7 +49,7 @@ export function getCarStatusType(carzt?:number) {
} }
// 获取档位信号 // 获取档位信号
export function getDwStatusType(dw?:number) { export function getDwStatusType(dw?: number) {
switch (dw) { switch (dw) {
case 0: case 0:
return [0, 0, 0, 0] return [0, 0, 0, 0]
@ -72,7 +72,7 @@ export function getDwStatusType(dw?:number) {
// 中心实时项目状态转换 // 中心实时项目状态转换
export function getCenterProjectStatus(status?:number):string { export function getCenterProjectStatus(status?: number): string {
switch (status) { switch (status) {
//不考 //不考
case 0: case 0:
@ -94,19 +94,19 @@ export function getCenterProjectStatus(status?:number):string {
//获取科目三开始项目、结束项目语音 //获取科目三开始项目、结束项目语音
export function getKmProjectVoice( export function getKmProjectVoice(
projectCode:string, projectCode: string,
// 1:项目开始 2:项目结束 // 1:项目开始 2:项目结束
type: 1 | 2, type: 1 | 2,
judgeConfig:object, judgeConfig: object,
lane:JudgeLane, lane: JudgeLane,
xmxh:string xmxh: string
) { ) {
const carInfo = AppStorage.get<CarInfoType>('carInfo'); const carInfo = AppStorage.get<CarInfoType>('carInfo');
const examSubject = carInfo.examSubject; const examSubject = carInfo.examSubject;
const param506Str:number[] = ( Reflect.get(judgeConfig,'506')?.split(',') ) || [] const param506Str: number[] = (Reflect.get(judgeConfig, '506')?.split(',')) || []
const param512Str:number[] = ( Reflect.get(judgeConfig,'512')?.split(',') ) || [] const param512Str: number[] = (Reflect.get(judgeConfig, '512')?.split(',')) || []
const param544Str:number[] = ( Reflect.get(judgeConfig,'544')?.split(',') ) || [] const param544Str: number[] = (Reflect.get(judgeConfig, '544')?.split(',')) || []
const param405Str:number = Reflect.get(judgeConfig,'405') || 0; const param405Str: number = Reflect.get(judgeConfig, '405') || 0;
console.info('surenjun => param544Str.length', param544Str.length) console.info('surenjun => param544Str.length', param544Str.length)
@ -147,7 +147,7 @@ export function getKmProjectVoice(
case 41100: case 41100:
return type === 1 return type === 1
? (param512Str[2] == 3 ? 411001 : undefined) ? (param512Str[2] == 3 ? 411001 : undefined)
: (param544Str.includes(xmxh) ? undefined : (param544Str.length === 0 ? undefined : 411004)) : (param544Str.includes(Number(xmxh)) ? undefined : (param544Str.length === 0 ? undefined : 411004))
//通过车站 //通过车站
case 41200: case 41200:
@ -173,7 +173,7 @@ export function getKmProjectVoice(
//获取科目三&科目三取消项目语音 //获取科目三&科目三取消项目语音
export function getKmProjectCancelVoice(examSubject:number, projectCode:number) { export function getKmProjectCancelVoice(examSubject: number, projectCode: number) {
if (examSubject == 2) { if (examSubject == 2) {
return 'xmqx' return 'xmqx'
} }
@ -459,7 +459,7 @@ export const plcStrToJson = async (plc: string) => {
const time = await systemTime.getCurrentTime() const time = await systemTime.getCurrentTime()
const sensor:Sensor = { const sensor: Sensor = {
//安全带 车门门开关 手刹 脚刹 副刹 离合器 喇叭 示宽灯 近光灯 远光灯 //安全带 车门门开关 手刹 脚刹 副刹 离合器 喇叭 示宽灯 近光灯 远光灯
aqd: p[19], aqd: p[19],
mkg: p[14], mkg: p[14],
@ -505,11 +505,11 @@ export const plcStrToJson = async (plc: string) => {
wav: 0, wav: 0,
mndg: '' mndg: ''
} }
const gps2:Gps =testRealExam.gps2 const gps2: Gps = testRealExam.gps2
const radar:Radar =testRealExam.radar const radar: Radar = testRealExam.radar
const vision:Vision =testRealExam.vision const vision: Vision = testRealExam.vision
const extend:Extend = {}; const extend: Extend = {};
const tempData:Plc = { const tempData: Plc = {
sensor: { sensor: {
//安全带 车门门开关 手刹 脚刹 副刹 离合器 喇叭 示宽灯 近光灯 远光灯 //安全带 车门门开关 手刹 脚刹 副刹 离合器 喇叭 示宽灯 近光灯 远光灯
aqd: p[19], aqd: p[19],
@ -561,7 +561,7 @@ export const plcStrToJson = async (plc: string) => {
bklx: p[56], bklx: p[56],
dwzt: p[83], dwzt: p[83],
// 角度差分状态 // 角度差分状态
jdzt: Number(plcArr[92].split('-')[0]), jdzt: Number(plcArr[92].split('-')[0]),
//gps数据 //gps数据
//gps时间 经度 纬度 航向角 俯仰角 海拔高 高度差 速度 //gps时间 经度 纬度 航向角 俯仰角 海拔高 高度差 速度
sj: time, sj: time,
@ -596,7 +596,7 @@ export const plcStrToWXJson = async (plc: string) => {
} }
}); });
const timeStr = p[93] + '' + p[94]; const timeStr = p[93] + '' + p[94];
const gps:Gps = { const gps: Gps = {
//办卡类型 定位差分状态 //办卡类型 定位差分状态
bklx: p[56], bklx: p[56],
dwzt: p[83], dwzt: p[83],
@ -636,19 +636,19 @@ export const plcStrToWXJson = async (plc: string) => {
//前天线可用星数 后天线可用星数 东向坐标位置 北向位置坐标 天向位置坐标 东向速度 北向速度 天向速度 //前天线可用星数 后天线可用星数 东向坐标位置 北向位置坐标 天向位置坐标 东向速度 北向速度 天向速度
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
// 评判信号1 评判信号2 发动机转速 // 评判信号1 评判信号2 发动机转速
judgeSignalNum.toString(16),judgeAnotherSignalNum.toString(16), p[25], judgeSignalNum.toString(16), judgeAnotherSignalNum.toString(16), p[25],
'0xFFFFFFF' '0xFFFFFFF'
] ]
const wuXiDataStr = wuXiData.join(',') const wuXiDataStr = wuXiData.join(',')
return wuXiDataStr return wuXiDataStr
} }
export const senorToWXDataStr = async (tempData:Plc) => { export const senorToWXDataStr = async (tempData: Plc) => {
const sensor = tempData.sensor const sensor = tempData.sensor
const gps = tempData.gps const gps = tempData.gps
const timeStr = await getTimeStr() const timeStr = await getTimeStr()
const judgeSignal:number[] = [ const judgeSignal: number[] = [
//车门 安全带 熄火 发动机启动 左转向 右转向 前照灯近灯 前照灯远灯 //车门 安全带 熄火 发动机启动 左转向 右转向 前照灯近灯 前照灯远灯
sensor.mkg, sensor.aqd, sensor.dh1, sensor.dh2, sensor.zfxd, sensor.yfxd, sensor.jgd, sensor.ygd, sensor.mkg, sensor.aqd, sensor.dh1, sensor.dh2, sensor.zfxd, sensor.yfxd, sensor.jgd, sensor.ygd,
// 注车制动 行车制动 离合器 副制动 喇叭 雨刷 危险报警灯 示廓灯 系统未涉及的传感器信号 // 注车制动 行车制动 离合器 副制动 喇叭 雨刷 危险报警灯 示廓灯 系统未涉及的传感器信号
@ -714,7 +714,7 @@ export function sendRed() {
} }
export const defaultJudgeConfigObj:DefaultJudgeConfigObj = { export const defaultJudgeConfigObj: DefaultJudgeConfigObj = {
//结束考试方式 0-不合格继续 1-考试不合格报靠边停车 2-不合格不报靠边 3-训练不合格报靠边 4-自动退出 5-不合格自动退出 //结束考试方式 0-不合格继续 1-考试不合格报靠边停车 2-不合格不报靠边 3-训练不合格报靠边 4-自动退出 5-不合格自动退出
param_302: '5', param_302: '5',
param_332: '', param_332: '',