济南修改

This commit is contained in:
lvyuankang 2024-07-05 18:10:12 +08:00
parent 97768c336d
commit 92aa41bacc
18 changed files with 438 additions and 395 deletions

View File

@ -28,7 +28,7 @@ import DeviceInfoTable from '../constants/DeviceInfoTable'
import USER from '../constants/USER'
import util from '@ohos.util';
import zlib from '@ohos.zlib';
import FileModel from '../../pages/judgeSDK/utils/file-model';
import FileModel from '../../pages/judgeSDK/utils/fileModel';
// @ts-nocheck
//读表
//参数平台

View File

@ -46,22 +46,22 @@ export default class FileUtil{
*
*/
public addFile = async (filePath:string,content:string,type?:string)=>{
const { READ_WRITE,CREATE,APPEND }= fs.OpenMode
const isExit = fs.accessSync(filePath);
//文件存在先删除
if(isExit){
fs.unlinkSync(filePath);
}
const { READ_WRITE,CREATE,APPEND,TRUNC }= fs.OpenMode
try {
let file = fs.openSync(filePath, READ_WRITE | CREATE);
//追加写入文件
fs.writeSync(file.fd,content)
console.log('content',content)
let file = fs.openSync(filePath, TRUNC|READ_WRITE |CREATE|APPEND);
const option={
offset:0,
length:content.length,
encoding:'utf-8'
}
fs.writeSync(file.fd,content,option)
fs.closeSync(file)
console.error(LOGTAG,'写入文件成功')
return true
}catch (e){
console.error(LOGTAG,'写入失败',JSON.stringify(e))
console.error(LOGTAG,JSON.stringify(e))
}
}
/*
@ -72,15 +72,6 @@ export default class FileUtil{
const { READ_WRITE,CREATE,APPEND }= fs.OpenMode
try {
let file = fs.openSync(filePath, READ_WRITE | APPEND |CREATE);
let index
// if(type=='overWrite'){
// //文件覆蓋
// index=0
// }else{
// //文件追加
// const str = fs.readTextSync(filePath);
// index= str.length
// }
const newStr = content + '\n'
//追加写入文件
fs.writeSync(file.fd,newStr)

View File

@ -40,11 +40,11 @@ export async function getTCP() {
hilog.info(0x0000, 'testTag', "valvalval2" + JSON.stringify(val));
setTimeout(()=>{
globalThis.TcpClient.sendMsg('1002')//1002
if(val&&!globalThis.closeUDPSocket){
if(globalThis.udpClient && val&&!globalThis.closeUDPSocket){
// const msg=val.substring(5,val.length-1)
console.log('socketTag[PLC.UdpClient]closeUDPSocket',globalThis.closeUDPSocket)
globalThis.udpClient?.sendMsg(val)
globalThis.udpClient.sendMsg&&globalThis.udpClient?.sendMsg(val)
}
},1000)

View File

@ -11,7 +11,7 @@ export async function sendMsg(val){
export async function getUDP() {
getSyncData('IpConfigTable').then((result:Array<any>)=>{
if(result.length){
if(globalThis.udpClient&&globalThis.udpClient.closeUdp){
if(globalThis.udpClient&&!globalThis.closeUDPSocket){
globalThis.udpClient.closeUdp(()=>{
setTimeout(()=>{
globalThis.udpClient.rebindUdp(result[0].udplocalIp, result[0].udplocalIpPort,result[0].udpOppositeIp,result[0].udpOppositeIpPort)
@ -42,7 +42,7 @@ export async function getUDP() {
export async function getUDP2() {
getSyncData('IpConfigTable').then(async (result:Array<any>)=>{
if(result.length){
if(globalThis.udpClient2&&globalThis.closeHeartSocket){
if(globalThis.udpClient2&&!globalThis.closeHeartSocket){
globalThis.udpClient2.closeUdp(async ()=>{
setTimeout(()=>{

View File

@ -37,7 +37,7 @@ export default class TcpClient {
this.localIpPort = localIpPort
this.oppositeIpPort = oppositeIpPort
console.log(TAG,'tcpreBind', this.localIp,this.localIpPort)
let promise=this.tcp.bind({ address: this.localIp, port:parseInt(this.localIpPort), family: 1 }, err => {
let promise=this.tcp.bind({ address: this.localIp, port:parseInt(this.localIpPort)}, err => {
if (err) {
globalThis.getCloseTcp=true
hilog.info(0x0000, 'testTag', "tcpreBinderror:" + JSON.stringify(err));
@ -60,7 +60,7 @@ export default class TcpClient {
bindTcp() {
console.log(TAG,'tcpbind',this.localIp,'localIp',this.localIpPort)
return new Promise((resolve,reject)=>{
let promise=this.tcp.bind({ address: this.localIp, port:parseInt(this.localIpPort), family: 1 }, err => {
let promise=this.tcp.bind({ address: this.localIp, port:parseInt(this.localIpPort) }, err => {
if (err) {
console.log('testTag tcp bind faile');
globalThis.getCloseTcp=true
@ -86,7 +86,7 @@ export default class TcpClient {
connectTcp(){
console.log(TAG,'tcpConnect',this.oppositeIp,'localIp',this.oppositeIpPort)
return new Promise((resolve,reject)=>{
let promise = this.tcp.connect({ address: {address: this.oppositeIp, port: parseInt(this.oppositeIpPort), family: 1} , timeout: 6000});
let promise = this.tcp.connect({ address: {address: this.oppositeIp, port: parseInt(this.oppositeIpPort)} , timeout: 6000});
promise.then(() => {
this.tcp.setExtraOptions({

View File

@ -50,7 +50,7 @@ export default class UdpClient {
this.localIpPort = localIpPort
this.oppositeIpPort = oppositeIpPort
let promise = this.udp.bind({
address: this.localIp, port: parseInt(this.localIpPort), family: 1
address: this.localIp, port: parseInt(this.localIpPort)
});
promise.then(() => {
globalThis.closeUDPSocket=false
@ -67,7 +67,7 @@ export default class UdpClient {
let promise = this.udp.bind({
// address: '192.168.7.170', port: 20122, family: 1
// address: '192.168.7.170', port: 31013, family: 1
address: this.localIp, port: parseInt(this.localIpPort), family: 1
address: this.localIp, port: parseInt(this.localIpPort)
});
promise.then(() => {
globalThis.closeUDPSocket=false
@ -97,7 +97,6 @@ export default class UdpClient {
// port: 20022,
address: this.oppositeIp,
port: parseInt(this.oppositeIpPort),
family: 1
}
});
promise.then(() => {
@ -126,7 +125,7 @@ export default class UdpClient {
onMessage(callback?) {
this.udp.on('message', value => {
console.log(TAG,'udponmessage')
// console.log(TAG,'udponmessage')
// 收到的是ArrayBuffer 需要进行转换解析
globalThis.plcUdpError = false
if (value) {
@ -179,12 +178,12 @@ export default class UdpClient {
if (globalThis.plcUdpError) {
num++
console.log(TAG,'plc udp信号丢失')
if(num==3){
await this.bindUdp()
await this.sendMsg('111')
await this.onMessage(callback)
num=0
}
// if(num==3){
// await this.bindUdp()
// await this.sendMsg('111')
// await this.onMessage(callback)
// num=0
// }
prompt.showToast({
message: 'plc udp信号丢失',
duration: 2000
@ -204,6 +203,8 @@ export default class UdpClient {
globalThis.closeUDPSocket=false
} else {
hilog.info(0x0000,TAG, 'udpCLient', 'closeonSuccess');
globalThis.closeUDPSocket=true
this.udp.getState((err, data) => {

View File

@ -223,7 +223,6 @@ export default class UdpClientByCenter {
}
closeUdp(callback) {
globalThis.closeHeartSocket=true
this.udp.close(err=>{
if(err){

View File

@ -1,7 +1,7 @@
import http from '@ohos.net.http';
import convertxml from '@ohos.convertxml';
import prompt from '@ohos.prompt'
import { sendGreen } from '../../pages/judgeSDK/utils/judge-common';
import { sendGreen } from '../../pages/judgeSDK/utils/judgeCommon';
import {GlobalConfig} from '../../config/index'
const config = {
host:GlobalConfig.host,

View File

@ -31,6 +31,8 @@ export default class EntryAbility extends UIAbility {
globalThis.version = '2024.11.22.14'
globalThis.judgeVersion = '2024.11.22.14'
globalThis.videoVersion= '1.0'
globalThis.closeUDPSocket=true
globalThis.closeHeartSocket=true
// globalThis.version = '2023.12.13.01'
// globalThis.judgeVersion = '2023.09.30.1'
// globalThis.videoVersion= '1.0'

View File

@ -6,7 +6,7 @@ import LoadingPopup from './compontents/judge/LoadingPopup';
import DeductedPopup from './compontents/judge/DeductionPopup';
import AmplifyPopup from './compontents/judge/AmplifyPopup';
import Judge from './judgeSDK/judge';
import { defaultJudgeConfigObj } from './judgeSDK/utils//judge-common';
import { defaultJudgeConfigObj } from './judgeSDK/utils//judgeCommon';
import {
CARINFO,
CDSBInfo,
@ -21,86 +21,13 @@ import {
import { chunkArr, formatTime, getCurrentHourTime, getCurrentTime } from '../common/utils/tools';
import { examJudgeEndExam } from './judgeSDK/api/index';
import { getSyncData } from '../common/service/initable';
import { judgeConfig } from './judgeSDK/utils/judge-config';
import { judgeConfig } from './judgeSDK/utils/judgeConfig';
import FileUtil from '../common/utils/File';
import SignDisplayCom from './compontents/signDisplayCom';
@Entry
@Component
struct Index {
scroller: Scroller = new Scroller()
//页面通用字体大小
@State FONTSIZE: number = 28
@State BIGFONTSIZE: number = 28
//结束考试弹窗
@State endPopupVisible: boolean = false
//等待弹窗(考试及格,考试不及格使用)
@State loadingPopupVisible: boolean = false
//实时轨迹弹窗
@State signDisplayComVisible: boolean = false
@State isDdxk: boolean = false;
@State time: string = ''
//考试用时
@State examTime: number = 0
//开始时间
@State startTime: string = '00:00:00'
@State startFullTime: string = ''
@State startHourTime: string = ''
//科目类型
@State examSubject: 2 | 3 = 3;
@State ddxkTime: number = 0;
@State ddxkKsxmArr: string[] = ['']
@State ddxkKfArr: string[] = ['']
@State xmmcStr: string = ''
@State carztStr: string = ''
@State kfArr: {
xmmcStr?: string,
score: string,
desc: string
}[] = []
@State name: string = ''
@State idCard: string = ''
@State totalScore: number = 100
//模拟考试项目
@State projects: Project[] = []
@State projectsObj: ProjectObj = {}
@State projectsCenterObj: ProjectObj = {}
@State markRuleListObj: MarkRule = {}
@State cdsbInfoObj: CDSBInfo = {}
@State timer: number = 0
@State judgeConfig: { [k: string]: string }[] = []
@State judgeConfigObj: { [k: string]: any } = defaultJudgeConfigObj
//流水号
@State lsh: string = ''
@State kszp: string = ''
@State ksdd: string = ''
@State kssycs: string = ''
@State kslx: string = ''
//监管接口序列号
@State serialNumber: number = 0
@State carType: string = ''
@State carName: string = ''
@State isDeductedPopShow: boolean = false
@State isAmplifyPopShow: boolean = false
@State amplifiedImgIndex: number = 0
@State judge: any = {}
//行驶距离
@State jl: number = 0
//应考里程
@State examMileage: string = '0'
@State artSubject3Projects: string[] = ['直线', '会车', '变道', '超车', '掉头', '停车']
@State artSubject3ProjectsCodesArr: string[] = ['3', '9', '4', '10', '12', '11']
@State manualMarkRules: MarkRule[] = []
//科目三评判初始化数据
@State systemparmArr: SYSTEMPARMARR[] = []
@State mapPointItemArr: MAPITEMPOINTITEM[] = []
@State carinfoArrr: CARINFO[] = []
@State mapPointArr: MAPPOINT[] = []
private context = getContext(this) as common.UIAbilityContext;
private img: ImageBitmap = new ImageBitmap("/resources/base/media/1.png")
//已考的考试项目
private wantInfos = []
async aboutToAppear() {
globalThis.windowClass.setWindowSystemBarEnable([''])
@ -200,10 +127,9 @@ struct Index {
NoCancelId: mark.nocancelid * 1,
GPS_SID: mark.gps_sid == 0 ? false : true
}
const markserial = mark.markserial * 1;
//筛选出人工评判的扣分
if (markserial > 100 && markserial < 200) {
if (Number(tempObj.markserial) > 100 && Number(tempObj.markserial) < 200) {
this.manualMarkRules.push(tempObj)
}
this.markRuleListObj[`${mark.itemno}_${mark.markserial}`] = {
@ -244,6 +170,33 @@ struct Index {
this.examMileage = sys.v_value + '';
}
//364 绕车一周评判时机(1-开始考试后判 2-开始考试前判)
if(sys.v_no == '364' && sys.v_value == 2 ){
let currentParams: any = router.getParams();
const {sczb,kfdm} = currentParams;
kfdm.forEach(kf => {
const {xmdm, kfdm} = kf
const currentKf = this.markRuleListObj[`${xmdm}_${kfdm}`];
const currentProject = this.projectsObj[xmdm]
this.kfArr.push({
//扣分项目名称
xmmcStr: currentProject.name,
//@ts-ignore
xmdm,
desc: currentKf.markshow,
score: currentKf.markreal,
markcatalog: currentKf.markcatalog,
markserial: currentKf.markserial,
kfxh: currentKf.kfxh
})
this.totalScore += currentKf.markreal * 1;
})
this.projectsObj['1'].type = kfdm.length ? '4':'3';
this.projectsObj = {
...this.projectsObj
}
}
this.judgeConfigObj[sys.v_no] = value
});
this.judgeConfig = syssetJudgeConfigArr;
@ -300,7 +253,8 @@ struct Index {
//初始化systemParam表
async initSystemKm3Param(sysParam?: SYSTEMPARMARR[]) {
const systemParms: any = sysParam || await getSyncData('MA_SYSTEMPARM')
let currentParams: any = router.getParams();
this.wayno = currentParams.wayno
const {isTrajectoryOpen} = judgeConfig
systemParms.forEach((systemParm) => {
@ -538,7 +492,7 @@ struct Index {
if (this.examSubject == 3) {
Row() {
Text('考试路线:').fontColor('#E5CCA1').fontSize(this.FONTSIZE)
Text(`线路${globalThis.carInfo.wayno}`).fontColor('#FFAD33').fontSize(this.FONTSIZE)
Text(`线路${this.wayno}`).fontColor('#FFAD33').fontSize(this.FONTSIZE)
}
}
@ -578,7 +532,6 @@ struct Index {
Row() {
Flex({ direction: FlexDirection.Column }) {
if (this.kfArr.length) {
List({}) {
ForEach(this.kfArr, (item) => {
@ -905,6 +858,7 @@ struct Index {
if (this.isDeductedPopShow) {
DeductedPopup({
currentItems: Reflect.ownKeys(this.projectsObj).map(projectKey => {
//@ts-ignore
const project = this.projectsObj[projectKey]
return project.type == '2' ? project.projectCode : ''
}).filter(project => project !== ''),
@ -961,11 +915,13 @@ struct Index {
// 获取是否能人工进项目
getIsExitManualProject = (index: number) => {
const {judgeConfigObj,artSubject3ProjectsCodesArr,projectsObj} = this;
//不允许人工触发的项目列表,以","分隔
const unExitManualProjects = judgeConfigObj['332'].split(',') || [];
//直线行驶中不进其他考试项目(0-否 1-是)
const param348 = judgeConfigObj['348'] || '0';
//里程不够允许手工点靠边停车0-否 1-是)
const param387 = judgeConfigObj['387'] || '0';
//车上是否能进行人工操作(0-能1-不能人工评判2-不能人工进项目3-都不能)
if (judgeConfigObj['342'] === '3' || judgeConfigObj['342'] === '2') {
return false
}
@ -974,6 +930,7 @@ struct Index {
return false
}
//@ts-ignore
if (param348 == '0' && projectsObj['9']?.type == 2) {
return index === 0 ? true : false
}
@ -985,4 +942,76 @@ struct Index {
return true
}
scroller: Scroller = new Scroller()
//页面通用字体大小
@State wayno:number = 0
@State FONTSIZE: number = 28
@State BIGFONTSIZE: number = 28
//结束考试弹窗
@State endPopupVisible: boolean = false
//等待弹窗(考试及格,考试不及格使用)
@State loadingPopupVisible: boolean = false
//实时轨迹弹窗
@State signDisplayComVisible: boolean = false
@State isDdxk: boolean = false;
@State time: string = ''
//考试用时
@State examTime: number = 0
//开始时间
@State startTime: string = '00:00:00'
@State startFullTime: string = ''
@State startHourTime: string = ''
//科目类型
@State examSubject: 2 | 3 = 3;
@State ddxkTime: number = 0;
@State ddxkKsxmArr: string[] = ['']
@State ddxkKfArr: string[] = ['']
@State xmmcStr: string = ''
@State carztStr: string = ''
@State kfArr: {
xmmcStr?: string,
score: string,
desc: string
}[] = []
@State name: string = ''
@State idCard: string = ''
@State totalScore: number = 100
//模拟考试项目
@State projects: Project[] = []
@State projectsObj: ProjectObj = {}
@State projectsCenterObj: ProjectObj = {}
@State markRuleListObj: MarkRule = {}
@State cdsbInfoObj: CDSBInfo = {}
@State timer: number = 0
@State judgeConfig: { [k: string]: string }[] = []
@State judgeConfigObj: { [k: string]: any } = defaultJudgeConfigObj
//流水号
@State lsh: string = ''
@State kszp: string = ''
@State ksdd: string = ''
@State kssycs: string = ''
@State kslx: string = ''
//监管接口序列号
@State serialNumber: number = 0
@State carType: string = ''
@State carName: string = ''
@State isDeductedPopShow: boolean = false
@State isAmplifyPopShow: boolean = false
@State amplifiedImgIndex: number = 0
@State judge: any = {}
//行驶距离
@State jl: number = 0
//应考里程
@State examMileage: string = '0'
@State artSubject3Projects: string[] = ['直线', '会车', '变道', '超车', '掉头', '停车']
@State artSubject3ProjectsCodesArr: string[] = ['3', '9', '4', '10', '12', '11']
@State manualMarkRules: MarkRule[] = []
//科目三评判初始化数据
@State systemparmArr: SYSTEMPARMARR[] = []
@State mapPointItemArr: MAPITEMPOINTITEM[] = []
@State carinfoArrr: CARINFO[] = []
@State mapPointArr: MAPPOINT[] = []
private context = getContext(this) as common.UIAbilityContext;
//已考的考试项目
}

View File

@ -24,7 +24,6 @@ export default struct Index {
const {no1,no2,no3,txt1,txt2} = systemParm;
if (no1 == 4) {
const temp = { no2, no3, txt1: decodeURI(txt1), txt2 }
console.info('surenjun', JSON.stringify(temp))
this.roadObj[no2] = no2
}
})
@ -57,10 +56,8 @@ export default struct Index {
const roadArr = Reflect.ownKeys(this.roadObj).map((roadKey) => {
return this.roadObj[roadKey]
});
globalThis.carInfo.wayno = roadArr[Math.floor(Math.random()*roadArr.length)];
router.pushUrl({
url: 'pages/Judge',
}, router.RouterMode.Single);
const wayno = roadArr[Math.floor(Math.random()*roadArr.length)];
this.goJudge(wayno)
})
ForEach(Reflect.ownKeys(this.roadObj), (roadIndex) => {
ListItem() {
@ -81,10 +78,7 @@ export default struct Index {
.height(220)
.margin({ left: 5, bottom: 10 })
.onClick(async () => {
globalThis.carInfo.wayno = this.roadObj[roadIndex];
router.pushUrl({
url: 'pages/Judge',
}, router.RouterMode.Single);
this.goJudge(this.roadObj[roadIndex])
})
})
}.lanes(8).margin({ top: 50, left: 15 })
@ -95,6 +89,18 @@ export default struct Index {
}
outClick() {
goJudge(wayno) {
let currentParams: any = router.getParams() || {};
const {sczb,kfdm} = currentParams;
router.replaceUrl({
url: 'pages/Judge',
params:{
sczb,
kfdm,
wayno
}
}, router.RouterMode.Single);
}
outClick(){}
}

View File

@ -14,8 +14,9 @@ import common from '@ohos.app.ability.common';
import { User } from './interfaces';
import WebRTCVoice from './webRTC/';
import promptAction from '@ohos.promptAction';
import { getSyncData } from '../common/service/initable';
import { CandidateData, EmptyCandidateObject } from '../mock/CandidateData';
import BoardPrePareSetPopup from './compontents/judge/BoardPrePareSetPopup'
@Entry
@Component
struct UserInfo {
@ -34,6 +35,10 @@ struct UserInfo {
@State url: string = ''
@State lsh: string = ''
@State qkFlag: boolean = false
@State isBoardPrePareSetPopupOpen: boolean = false
@State isFirstBoardPrePareSetPopupBtnShow: boolean = false
@State isBoardPrePareSetPopupShow: boolean = false
@State sczbkf:{xmdm:number,kfdm:string}[] = []
@State currentUser: User = EmptyCandidateObject
@State dataList: Array<User> = []
@State list: Array<User> = []
@ -194,7 +199,9 @@ struct UserInfo {
this.qkFn()
}
initData() {
async initData() {
this.sczbkf = []
this.isFirstBoardPrePareSetPopupBtnShow = false;
this.stepFlag = false
this.faceCompareSucess = 0
this.showFaceCompare = false
@ -216,6 +223,15 @@ struct UserInfo {
} else {
// this.getExaminationStudentInfoFn()
}
const syssetParams = await getSyncData('MA_SYSSET');
//@ts-ignore
syssetParams.forEach(sys => {
//364 绕车一周评判时机(1-开始考试后判 2-开始考试前判)
if(sys.v_no === '364'){
this.isBoardPrePareSetPopupOpen = true;
}
})
}
async heartMsg() {
@ -531,6 +547,7 @@ struct UserInfo {
build() {
Column() {
TopLogo({ outFlag: $outFlag }).margin({ bottom: 10 })
Row() {
Row() {
@ -627,54 +644,72 @@ struct UserInfo {
.onClick(() => {
this.qkFlag = true
})
Image($r('app.media.ksks_btn'))
.commStyle()
.onClick(() => {
this.faceCompareSucess = 0
globalThis.statue = 2
if (!this.currentUser.xm) {
return
}
// if(globalThis.spzdFlag){
// promptAction.showToast({
// message: '摄像头被遮挡',
// duration: 2000
// });
// return
// }
//TODO 科目三先写死
globalThis.carInfo.examSubject = 3;
if (globalThis.singlePlay) {
const {examSubject} = globalThis.carInfo;
this.AccountTable.query('0', (result) => {
if (result.length == 0) {
this.AccountTable.insertData(this.currentUser, (id) => {
this.AccountTable.query('0', (result) => {
router.pushUrl({
url: examSubject == 3 ? 'pages/Roads':'pages/Judge',
}, router.RouterMode.Single);
this.stopDeviceById()
})
})
} else {
this.AccountTable.updateData(this.currentUser, (id) => {
this.AccountTable.query('0', (result) => {
router.pushUrl({
url: examSubject == 3?'pages/Roads':'pages/Judge',
}, router.RouterMode.Single);
this.stopDeviceById()
})
})
}
})
return
}
if (this.FaceOpenStatue != '0') {
this.showFaceCompare = true
} else {
this.sfbdinterfaceFn()
}
if( this.isBoardPrePareSetPopupOpen && !this.isFirstBoardPrePareSetPopupBtnShow){
//上车准备
Image($r('app.media.sczb_btn')).commStyle().onClick(()=>{
this.isBoardPrePareSetPopupShow = true;
this.isFirstBoardPrePareSetPopupBtnShow = true;
})
}else{
Image($r('app.media.ksks_btn'))
.commStyle()
.onClick(() => {
this.faceCompareSucess = 0
globalThis.statue = 2
if (!this.currentUser.xm) {
return
}
// if(globalThis.spzdFlag){
// promptAction.showToast({
// message: '摄像头被遮挡',
// duration: 2000
// });
// return
// }
//TODO 科目三先写死
globalThis.carInfo.examSubject = 3;
if (globalThis.singlePlay) {
const {examSubject} = globalThis.carInfo;
this.AccountTable.query('0', (result) => {
if (result.length == 0) {
this.AccountTable.insertData(this.currentUser, (id) => {
this.AccountTable.query('0', (result) => {
router.pushUrl({
url: examSubject == 3 ? 'pages/Roads':'pages/Judge',
params:{
sczb:Number(this.isBoardPrePareSetPopupOpen),
kfdm:this.sczbkf
}
}, router.RouterMode.Single);
this.stopDeviceById()
})
})
} else {
this.AccountTable.updateData(this.currentUser, (id) => {
this.AccountTable.query('0', (result) => {
router.pushUrl({
url: examSubject == 3?'pages/Roads':'pages/Judge',
params:{
sczb:Number(this.isBoardPrePareSetPopupOpen),
kfdm:this.sczbkf
}
}, router.RouterMode.Single);
this.stopDeviceById()
})
})
}
})
return
}
if (this.FaceOpenStatue != '0') {
this.showFaceCompare = true
} else {
this.sfbdinterfaceFn()
}
})
}
}
}
@ -719,6 +754,19 @@ struct UserInfo {
.backgroundColor('#E6E3DF')
.borderRadius(19 * this.ratio)
}
// 上车准备
if(this.isBoardPrePareSetPopupShow){
BoardPrePareSetPopup({
closePopup:()=>{
this.isBoardPrePareSetPopupShow = false
},
confirmMark:(kfdm)=>{
this.sczbkf= kfdm
}
})
}
}
.height('100%')
.width('100%')

View File

@ -1,6 +1,6 @@
import router from '@ohos.router';
import UdpClient from '../../common/utils/UdpClient';
import FileLog from '../judgeSDK/utils/file-log';
import FileLog from '../judgeSDK/utils/fileLog';
import RealTime from '../compontents/judge/RealTime';
import { GPSData, SignalData } from '../../mock';
import { SignalDataType } from '../../model';

View File

@ -1,5 +1,5 @@
import apiJudgeSdk from 'libJudgeSdk.so';
import Judge from '../../judgeSDK/utils/judge-real';
import Judge from '../../judgeSDK/utils/judgeReal';
import { MarkRule, Project, ProjectObj } from '../../judgeSDK/api/judgeSDK.d';
import common from '@ohos.app.ability.common';

View File

@ -131,6 +131,7 @@ export function handleLog(level,infoStr, len){
*
*/
export async function examJudgeEndExam(){
console.info('surenjun','考试结束调用')
const temp = libJudgeSdk.examJudgeEndExam();
return await handle(temp,'examJudgeEndExam')
}
@ -170,6 +171,26 @@ export async function examJudgeSetPerformCallback(fn){
const temp = libJudgeSdk.examJudgeSetPerformCallback(fn);
return await handle(temp,'examJudgeSetPerformCallback')
}
/**
*
* @desc
* /
*/
export async function examJudgeSoundEnd(param:{
//项目代码
itemno:number,
//语音码
code:string,
//语音类型
type:number,
}){
const {itemno,code,type} = param;
const temp = libJudgeSdk.examJudgeSoundEnd(itemno,code,type);
return await handle(temp,'examJudgeSoundEnd')
}
/*
* @desc通用处理函数
*

View File

@ -16,7 +16,8 @@ export interface MarkRule{
itemno?:number
markcatalog?:string
markshow?:string
markserial?:number
markserial?:string
markstandard?:number,
markreal?:number
kfxh?:string
onlyoneid?:number
@ -118,7 +119,8 @@ export interface EXAMDATA{
sound:{
xmdm:number,
//语音播放文件代码
code:string
code:string,
type:number
},
//模拟灯光
mndg:string
@ -138,7 +140,9 @@ export interface SOUND {
//项目代码
xmdm:number
//语音播放提示代码
code:string
code:string,
//0:普通1:模拟灯光
type:number
}
export interface SYSSET {
v_no:string,
@ -147,7 +151,7 @@ export interface SYSSET {
}
export interface ProjectObj {
[k:any]:Project
[k:string]:Project
}

View File

@ -2,19 +2,16 @@ import systemTime from '@ohos.systemDateTime';
import router from '@ohos.router';
import util from '@ohos.util';
import buffer from '@ohos.buffer';
import { testKmItems, testMarkRules } from './dataTest/index';
import { EXAMDATA, SOUND } from './api/judgeSDK';
import VoiceAnnounce from './utils/voice-announcements';
import FileModel from './utils/file-model';
import FilePhoto from './utils/file-photo';
import VoiceAnnounce from './utils/voiceAnnouncements';
import FileModel from './utils/fileModel';
import FilePhoto from './utils/filePhoto';
import FileUtil from '../../common/utils/File';
import FileLog from '../judgeSDK/utils/file-log';
import FileLog from './utils/fileLog';
import JudgeTask from './utils/judge-task';
import SimulateLights from './utils/simulate-lights';
import { judgeConfig } from './utils/judge-config';
import JudgeTask from './utils/judgeTask';
import { judgeConfig } from './utils/judgeConfig';
import { uploadExamProgressData, writeObjectOut } from '../../api/judge';
import {
@ -36,35 +33,33 @@ import {
plcStrToWXJson,
promptWxCode,
senorToWXDataStr
} from './utils/judge-common';
} from './utils/judgeCommon';
import {
examJudgeArtificialItem,
examJudgeArtificialMark,
examJudgeBeginExam,
examJudgeEndExam,
examJudgeInit,
examJudgeMapSetParam,
examJudgeMapSetScaling,
examJudgeSoundEnd,
examJudgeRealExam,
examJudgeSetLogCallback,
examJudgeSetPerformCallback,
examJudgeSetRealExamCallback
} from './api/index';
import UsbService from '../../common/service/usbService';
import Prompt from '@system.prompt';
const judgeTag = 'SURENJUN_JUDGE'
export default class Judge {
constructor(judgeUI) {
this.serialIndex = 1;
this.judgeUI = judgeUI
//语音播放工具
this.avPlayer = new VoiceAnnounce();
new SimulateLights(this.avPlayer)
//模型工具
this.fileModel = new FileModel(judgeUI.context);
//文件工具
@ -133,7 +128,7 @@ export default class Judge {
console.info(judgeTag, '2.注册日志回调完成')
let initInfo = isTrajectoryOpen ? JSON.parse(strArr[0]) : await this.getJudgeInitData();
console.log('SURENJUN_JUDGE',isJudgeInitBool,isTrajectoryOpen,JSON.stringify(initInfo))
//相关评判初始化只做一次
if (!isJudgeInitBool) {
await fileLog.setExamJudgeData(initInfo)
@ -141,6 +136,7 @@ export default class Judge {
globalThis.isJudgeInitBool = true
console.info(judgeTag, '4.评判初始化完成')
} else {
await fileLog.setExamJudgeData(initInfo)
}
globalThis.isJudge = true
@ -157,24 +153,19 @@ export default class Judge {
this.performInfo = performInfo
this.judgeUI.jl = Math.ceil((performInfo.qjjl + performInfo.dcjl) / 100)
})
// 3.开始考试
let beginExamInfo = isTrajectoryOpen ? {
...JSON.parse(strArr[1]),
replay: 1
} : await getJudgeBeginData()
console.log(judgeTag,'22222',JSON.stringify(beginExamInfo),strArr[1])
await fileLog.setExamJudgeData(beginExamInfo)
console.log(judgeTag,'333333')
await examJudgeBeginExam(beginExamInfo);
console.log(judgeTag,'4444444')
await fileLog.setExamJudgeData(beginExamInfo)
await examJudgeBeginExam(beginExamInfo);
console.info(judgeTag, '6.开始考试注册完成')
avPlayer.playAudio(['voice/ksks.WAV'])
await examJudgeMapSetParam(640, 480); //设置参数宽、高
await examJudgeMapSetScaling(120); //设置缩放比例一般默认填100就是100%的意思) 数字越大视野越大数字越小视野越小不能为0
this.judgeUI.draw = true
// 处理轨迹plc信息
@ -189,9 +180,113 @@ export default class Judge {
handleUdp(msg)
})
}
// 获取评判初始化数据
getJudgeInitData = async () => {
const {getModelData,getKm3JudgeInitConfig} = this
const carInfo = globalThis.carInfo;
const { examSubject,plateNo,carId } = carInfo;
const {fileLog} = this
const judgeUI = this.judgeUI
const {projectsObj,cdsbInfoObj,markRuleListObj,carType,carName} = judgeUI
const examType = examSubject == 2 ? 'km2' : 'km3'
let allitems = [];
if (examSubject == 2) {
allitems = Reflect.ownKeys(cdsbInfoObj).map(cdsbKey => {
const cdsb = cdsbInfoObj[cdsbKey];
const {xmdm,xmxh,modelKey} = cdsb
return {
xmdm, xmxh, model: getModelData(`${examType}/${modelKey}.txt`)
}
})
}
const initInfo = {
kskm: examSubject * 1,
kchp: plateNo,
kchm: carId * 1,
kscx: carType,
cxcode: '1',
name: carName,
carmodel: getModelData(`${examType}/${carType}.txt`),
allitems,
mark: Reflect.ownKeys(markRuleListObj).map(ruleKey => (markRuleListObj[ruleKey])) || testMarkRules,
sysset: judgeUI.judgeConfig,
};
let km3Config = {}
if (examSubject) {
km3Config = await getKm3JudgeInitConfig();
}
// 获取科目三的评判配置
console.info(judgeTag, '3.获取评判初始化数据完成')
return {
...initInfo,
...km3Config,
}
}
// 获取开始考试数据
getJudgeBeginData = async () => {
const {code,name:examinerName} = globalThis.examinerInfo;
let currentParams: any = router.getParams();
const {sczb,kfdm} = currentParams;
const {isExam} = this;
const judgeUI = this.judgeUI
const {projects,carType,isDdxk,ddxkTime,projectsCenterObj,ddxkKsxmArr,ddxkKfArr} = judgeUI;
const beginInfo = {
kgid: '012',
kgxm: decodeURI(examinerName || ''),
exam: isExam ? 1 : 0,
//是否回放
replay: 0,
//生成的轨迹文件
track: '',
xm: judgeUI.name,
sex: 0,
kslsh: judgeUI.lsh,
sfzmhm: judgeUI.idCard,
ksyy: '',
kscx: carType,
kkcs: 1,
sfyk: 0,
ykkkcs: 1,
wayno: judgeUI.wayno * 1,
czlx: 0,
kskssj: await systemTime.getCurrentTime(),
ksxm: projects.map(project => {
return {
xmdm: project.projectCode * 1,
xmxh: '',
}
}),
//断点续考
ddxk: isDdxk ? 1 : 0,
ddkssj: ddxkTime,
ykxm: isDdxk ? (ddxkKsxmArr?.map(projectCenterCode => (projectsCenterObj[projectCenterCode]?.projectCode) * 1)) : [],
kfxm: isDdxk ? (ddxkKfArr?.map(kf => {
const [xmdm, kfdm] = kf.split(',')
return {
xmdm: xmdm * 1,
kfdm
}
})) : [],
yklc: 0,
special: [],
//TODO 科目三参数临时写死
sczb: (sczb === undefined || sczb == 0)?0:1,
sczbkf:kfdm,
dmndg: false,
nitem1: false,
nitem41: false,
mfxx: false,
mfxxn: false
}
console.info(judgeTag, '5.获取开始考试数据完成')
return beginInfo
}
// 项目开始接口同步
beginProject = async (ksxm) => {
const carInfo = globalThis.carInfo;
@ -332,28 +427,28 @@ export default class Judge {
fileLog.setExamJudgeWuxiData(data)
console.info(judgeTag, '上传照片 end')
}
// 评判语音提示
goJudgeVoice = async (sound: SOUND) => {
const {avPlayer} = this;
const {xmdm,code} = sound;
const {avPlayer,fileLog} = this;
const {xmdm,code,type} = sound;
//判断是不是模拟灯光语音
const isLight = code.slice(0, 3) === '417';
if (isLight) {
console.info(judgeTag,JSON.stringify(sound))
if(type == 1){
console.info(judgeTag, '模拟灯光开始播放:' + code)
}
avPlayer.playAudio([`voice/${code}.mp3`], true, () => {
if (isLight) {
if (type == 1) {
console.info(judgeTag, '播放结束:' + code)
setTimeout(() => {
this.wav = 1;
examJudgeSoundEnd({itemno:xmdm,code,type})
fileLog.setExamJudgeData({
method: 'examJudgeSoundEnd',
itemno: xmdm,
code,
type,
})
}
})
}
// 处理考试结束
public handEndExam = async (isManual?: Boolean) => {
const {isExam,judgeUI,endExam,handleSEP,avPlayer} = this;
@ -386,26 +481,6 @@ export default class Judge {
}
}
// 当前项目转换
getDqxmStr = (type) => {
const projectsObj = this.judgeUI.projectsObj
return projectsObj[type]?.abbreviation || '通用评判'
}
// 扣分项目转换
getKfStr = (code) => {
const markRuleListObj = this.judgeUI.markRuleListObj;
const thisMark = markRuleListObj[code]
return {
desc: thisMark.markshow,
score: thisMark.markreal,
markcatalog: thisMark.markcatalog,
markserial: thisMark.markserial,
kfxh: thisMark.kfxh
}
}
// 考试结束
public endExam = async (isManual?: Boolean) => {
const carInfo = globalThis.carInfo;
@ -455,55 +530,23 @@ export default class Judge {
}, 3000)
}
// 获取评判初始化数据
getJudgeInitData = async () => {
const {getModelData,getKm3JudgeInitConfig} = this
const carInfo = globalThis.carInfo;
const { examSubject,plateNo,carId } = carInfo;
const {fileLog} = this
const judgeUI = this.judgeUI
const {projectsObj,cdsbInfoObj,markRuleListObj,carType,carName} = judgeUI
const examType = examSubject == 2 ? 'km2' : 'km3'
let allitems = [];
if (examSubject == 2) {
allitems = Reflect.ownKeys(cdsbInfoObj).map(cdsbKey => {
const cdsb = cdsbInfoObj[cdsbKey];
const {xmdm,xmxh,modelKey} = cdsb
return {
xmdm, xmxh, model: getModelData(`${examType}/${modelKey}.txt`)
}
})
}
const initInfo = {
kskm: examSubject * 1,
kchp: plateNo,
kchm: carId * 1,
kscx: carType,
cxcode: '1',
name: carName,
carmodel: getModelData(`${examType}/${carType}.txt`),
allitems,
mark: Reflect.ownKeys(markRuleListObj).map(ruleKey => (markRuleListObj[ruleKey])) || testMarkRules,
sysset: judgeUI.judgeConfig,
};
let km3Config = {}
if (examSubject) {
km3Config = await getKm3JudgeInitConfig();
}
// 获取科目三的评判配置
console.info(judgeTag, '3.获取评判初始化数据完成')
// 当前项目转换
getDqxmStr = (type) => {
const projectsObj = this.judgeUI.projectsObj
return projectsObj[type]?.abbreviation || '通用评判'
}
// 扣分项目转换
getKfStr = (code) => {
const markRuleListObj = this.judgeUI.markRuleListObj;
const thisMark = markRuleListObj[code]
return {
...initInfo,
...km3Config,
desc: thisMark.markshow,
score: thisMark.markreal,
markcatalog: thisMark.markcatalog,
markserial: thisMark.markserial,
kfxh: thisMark.kfxh
}
}
// 消息心跳发送
getMessageHeartbeat = async (isEnd?: Boolean) => {
const carInfo = globalThis.carInfo;
@ -603,66 +646,6 @@ export default class Judge {
this.serialIndex += 1;
return Array2Byte(tempArr)
}
// 获取开始考试数据
getJudgeBeginData = async () => {
console.log('globalThis.carInfo.wayno',globalThis.carInfo.wayno)
const {code,name:examinerName} = globalThis.examinerInfo;
const {isExam,isTrajectoryOpen} = this;
const judgeUI = this.judgeUI
const {projects,carType,isDdxk,ddxkTime,projectsCenterObj,ddxkKsxmArr,ddxkKfArr} = judgeUI;
const beginInfo = {
kgid: '012',
kgxm: decodeURI(examinerName || ''),
exam: isExam ? 1 : 0,
//是否回放
replay: 0,
//生成的轨迹文件
track: '',
xm: judgeUI.name,
sex: 0,
kslsh: judgeUI.lsh,
sfzmhm: judgeUI.idCard,
ksyy: '',
kscx: carType,
kkcs: 1,
sfyk: 0,
ykkkcs: 1,
wayno: Number(globalThis.carInfo.wayno)|| 0,
czlx: 0,
kskssj: await systemTime.getCurrentTime(),
ksxm: projects.map(project => {
return {
xmdm: project.projectCode * 1,
xmxh: '',
}
}),
//断点续考
ddxk: isDdxk ? 1 : 0,
ddkssj: ddxkTime,
ykxm: isDdxk ? (ddxkKsxmArr?.map(projectCenterCode => (projectsCenterObj[projectCenterCode]?.projectCode) * 1)) : [],
kfxm: isDdxk ? (ddxkKfArr?.map(kf => {
const [xmdm, kfdm] = kf.split(',')
return {
xmdm: xmdm * 1,
kfdm
}
})) : [],
yklc: 0,
special: [],
//TODO 科目三参数临时写死
sczb: 0,
sczbkf: [],
dmndg: false,
nitem1: false,
nitem41: false,
mfxx: false,
mfxxn: false
}
console.info(judgeTag, '5.获取开始考试数据完成')
return beginInfo
}
//获取场地序号
getSbxh = (ksxm, xmxh) => {
const {judgeUI} = this;
@ -677,7 +660,6 @@ export default class Judge {
const sbxh = currentCdsb.sbbh || '00000000'
return sbxh
}
getSbbm = (ksxm, xmxh) => {
const {judgeUI} = this;
const {cdsbInfoObj,projectsObj} = judgeUI;
@ -690,7 +672,6 @@ export default class Judge {
const sbxh = currentCdsb.sbbm || '00000000'
return sbxh
}
// 中心所有项目转换
getTranslateProject = () => {
// const {testKmItems} = this;
@ -713,13 +694,11 @@ export default class Judge {
}
return arr.map(numStr => parseInt(numStr, 2));
}
// 获取考试项目详情
getProjectInfo = (projectCode) => {
const judgeUI = this.judgeUI;
return judgeUI.projectsObj[projectCode]
}
// 获取模型数据
getModelData = (modelName) => {
const modelPath = this.modelPath
@ -750,7 +729,6 @@ export default class Judge {
itemno: itemno * 1,
type: 1
})
console.info(judgeTag, `人工评判进入项目-${itemno}`)
}
@ -870,8 +848,6 @@ export default class Judge {
}
}
public plcStr: string
private judgeUI
// 更改考试状态
goVoiceAnnounce = async (event, xmdm, kf, xmjs) => {
const {projectsObj,judgeConfigObj} = this.judgeUI;
@ -937,17 +913,14 @@ export default class Judge {
break
}
}
// 获取plc数据
getPlcData = async (plc: string) => {
const {fileLog,mndgStr,rmndg,wav} = this;
const {fileLog,mndgStr,rmndg} = this;
await fileLog.setPlcProgressData(plc)
//plc字符串转化成评判初始化数据
const tempData = await plcStrToJson(plc);
//模拟灯光回放时刻
tempData.sensor.rmndg = rmndg;
//模拟灯光单个灯光结束时刻
tempData.sensor.wav = wav;
//模拟灯灯光灯光项目
tempData.sensor.mndg = mndgStr;
//plc字符串转化成无锡所过程数据
@ -958,7 +931,6 @@ export default class Judge {
this.plcStr = plc;
this.mndgStr = '';
this.rmndg = 0;
this.wav = 0;
globalThis.msgStr = plc
return tempData
@ -966,7 +938,6 @@ export default class Judge {
// 处理轨迹plc信号
handleTrajectoryUdp = async (strArr) => {
const {fileLog} = this;
console.log('kkkkk')
let num = 2;
const {usbService} = this;
const judgeTimer = setInterval(async () => {
@ -1094,7 +1065,8 @@ export default class Judge {
judgeUI.projectsObj = deepClone(copyProjectsObj)
}
}
public plcStr: string
private judgeUI
private fileLog
private totalScore: number
private folderPath: string
@ -1102,7 +1074,6 @@ export default class Judge {
private avPlayer
private carztStr: string
private rmndg: 0 | 1
private wav: 0 | 1
private mndgStr: string | undefined
// 模拟灯光
setMndg = async (mndgStr: string) => {

View File

@ -3,6 +3,7 @@ import onvifclient from '@ohos.onvifclient';
import fs from '@ohos.file.fs'
import util from '@ohos.util';
import FileUtil from '../../../common/utils/File'
import { takePhoto } from '../../../common/service/videoService';
interface Params{
userName:string
@ -33,39 +34,9 @@ export default class FilePhoto{
public async getPhoto(){
const {params,context,fileUtil} = this;
const {userName,pwd,ip,port,rlls} = params;
const mediaTest = mediaLibrary.getMediaLibrary(context);
let mediaType = mediaLibrary.MediaType.IMAGE;
let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_IMAGE;
const path = await mediaTest.getPublicDirectory(DIR_DOCUMENTS);
return new Promise(async (resolve)=>{
mediaTest.createAsset(mediaType, 'judge_face.jpg', path,(error,asset)=>{
asset.open('rw', (error, fd) => {
if (fd > 0) {
const file_path = "/mnt/hmdfs/100/account/device_view/local/files/Pictures/judge_face.jpg"
const result3 = onvifclient.getVideoSnapshot(`rtsp://${userName}:${pwd}@${ip}:${port}/h264/ch${rlls}/main/av_stream`,file_path,fd);
fs.closeSync(fd);
asset.close(fd);
fs.lstat(file_path).then((stat) => {
console.info("get link status succeed, the size of file is" + stat.size);
let file = fs.openSync(file_path, fs.OpenMode.READ_WRITE);
const size=Number(stat.size)+100
let buf = new ArrayBuffer(size);
let num = fs.readSync(file.fd, buf);
const that = new util.Base64();
const array = new Uint8Array(buf);
const result = that.encodeToStringSync(array);//base64圖片
fileUtil.deleteF(file_path,3)
resolve(result)
}).catch((err) => {
console.info("get link status failed with error message: " + err.message + ", error code: " + err.code);
});
} else {
console.error('baoyihu getVideoSnapshot File Open failed with error: ' + error);
}
});
});
return new Promise(async (reslove)=>{
const data=await takePhoto(params,context,'jt/',1)
reslove(data.base64)
})
}
}