dev #63
@ -4,6 +4,7 @@ import { getSyncData } from '../service/initable'
|
||||
import { getChuankouFn } from '../../common/service/indexService'
|
||||
import FileUtil from '../../common/utils/File'
|
||||
import { GlobalConfig } from '../../config/index'
|
||||
import {Array2Byte,fillZero,string2Bytes}from './tools'
|
||||
import emitter from '@ohos.events.emitter';
|
||||
|
||||
export async function sendMsg(val) {
|
||||
@ -167,6 +168,7 @@ export async function getUDP2(context,errorFlag?) {
|
||||
// 未绑定
|
||||
console.log(` getUDP2 has no udclent and bind `);
|
||||
const udpClient2: UdpClientByCenter = new UdpClientByCenter(result.udplocalIp, '8800', globalThis.carInfo?.udpAddress, globalThis.carInfo?.messagePort)
|
||||
console.info('surenjun udp2=> ', globalThis.carInfo?.messagePort)
|
||||
await udpClient2.bindUdp()
|
||||
await udpClient2.onError_Callback(()=>{
|
||||
getUDP2(context,true);
|
||||
@ -180,17 +182,21 @@ export async function getUDP2(context,errorFlag?) {
|
||||
if (val.id == '32') {
|
||||
globalThis.signNum = val.body[1]
|
||||
if(val.body[0] == 5){
|
||||
|
||||
console.info('surenjun', `接收到平台扣分请求,请求指令为:${val.body[1]}`)
|
||||
globalThis.udpEvent.sendOnKf(val.body[1])
|
||||
}
|
||||
if(val.body[0] == 11){
|
||||
console.info('surenjun','GlobalUdp收到beginExam事件')
|
||||
globalThis.udpEvent.sendBeginExam()
|
||||
globalThis.udpEvent.sendBeginExam(val.body[1])
|
||||
}
|
||||
if(val.body[0] == 12){
|
||||
console.info('surenjun','GlobalUdp收到endExam事件')
|
||||
globalThis.udpEvent.sendEndExam()
|
||||
globalThis.udpEvent.sendEndExam(val.body[1])
|
||||
}
|
||||
|
||||
}if (val.id == '36'){
|
||||
//获取远程扣分内容
|
||||
console.info('surenjun','考车收到远程扣分项目内容,扣分代码:' + val.body[0])
|
||||
globalThis.udpEvent.sendKfContent(val.body[0])
|
||||
} else if (val.id == '46') {
|
||||
let tmpList = []
|
||||
const str = globalThis.lsh
|
||||
@ -315,6 +321,7 @@ export async function setJudgeUdp() {
|
||||
globalThis.carInfo?.udpAddress,
|
||||
globalThis.carInfo?.hintPort
|
||||
)
|
||||
console.info('surenjun hintPort=> ',globalThis.carInfo?.hintPort)
|
||||
|
||||
await udpClientbyCenter.onError_Callback(()=>{})
|
||||
await udpClientbyCenter.bindUdp()
|
||||
@ -336,16 +343,29 @@ export async function setJudgeUdp() {
|
||||
}
|
||||
},
|
||||
|
||||
//远程查询扣分项
|
||||
//远程确认扣分
|
||||
confirmKF(){
|
||||
|
||||
//申请远程扣分查询
|
||||
askKf(directives){
|
||||
globalThis.udpClient2.sendMsgExt({
|
||||
id: 35,
|
||||
list: [directives],
|
||||
carNo: globalThis.carInfo.carNo,
|
||||
placeId: globalThis.carInfo.examinationRoomId,
|
||||
})
|
||||
console.info('surenjun', `考车查询扣分项目内容,请求指令为:${directives}`)
|
||||
},
|
||||
|
||||
//确定远程扣分
|
||||
confirmKf(directives,code){
|
||||
globalThis.udpClient2.sendMsgExt({
|
||||
id: 37,
|
||||
list: Array2Byte([string2Bytes(directives,8),string2Bytes(code,8)]),
|
||||
carNo: globalThis.carInfo.carNo,
|
||||
placeId: globalThis.carInfo.examinationRoomId
|
||||
})
|
||||
console.info('surenjun', `考车发送确定扣分指令,指令为:${directives}`)
|
||||
},
|
||||
//远程开始考试
|
||||
//远程结束考试
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// globalThis.udpClient.bindUdp()
|
||||
|
||||
@ -13,6 +13,7 @@ export default class TcpClient {
|
||||
private oppositeIp: string = ''
|
||||
private oppositeIpPort: string = ''
|
||||
private num: number = 0//重连次数
|
||||
private folderPath
|
||||
|
||||
private tcp: any = null
|
||||
|
||||
@ -23,6 +24,7 @@ export default class TcpClient {
|
||||
this.oppositeIpPort = tcpOppositePort
|
||||
console.log(TAG, 'new Tcp', this.localIp, this.localIpPort, this.oppositeIp, this.oppositeIpPort)
|
||||
this.tcp = socket.constructTCPSocketInstance();
|
||||
this.initPath()
|
||||
}
|
||||
|
||||
onError(callback?) {
|
||||
@ -31,6 +33,10 @@ export default class TcpClient {
|
||||
// time:dateFormat(new Date()),
|
||||
// PLC:`${TAG} tcpOnerror ${JSON.stringify(err)}`,
|
||||
// })
|
||||
this.writeLog({
|
||||
time:dateFormat(new Date()),
|
||||
message: `${TAG} tcponerror localIp${JSON.stringify(err)}`,
|
||||
})
|
||||
console.log(TAG, 'tcpOnerror', JSON.stringify(err))
|
||||
setTimeout(async () => {
|
||||
getTCP()
|
||||
@ -52,10 +58,18 @@ export default class TcpClient {
|
||||
address: this.localIp, port: parseInt(this.localIpPort), family: 1
|
||||
}, err => {
|
||||
if (err) {
|
||||
this.writeLog({
|
||||
time:dateFormat(new Date()),
|
||||
message: `${TAG} tcprebind tcpreBinderror${JSON.stringify(err)}`,
|
||||
})
|
||||
globalThis.getCloseTcp = true
|
||||
hilog.info(0x0000, 'testTag', "tcpreBinderror:" + JSON.stringify(err));
|
||||
resolve(true)
|
||||
}
|
||||
this.writeLog({
|
||||
time:dateFormat(new Date()),
|
||||
message: `${TAG} tcprebind success`,
|
||||
})
|
||||
console.log('testTag,rebindtestTag tcp bind success');
|
||||
globalThis.getCloseTcp = false
|
||||
resolve(false)
|
||||
@ -72,6 +86,10 @@ export default class TcpClient {
|
||||
}
|
||||
|
||||
bindTcp() {
|
||||
this.writeLog({
|
||||
time:dateFormat(new Date()),
|
||||
message: `${TAG} tcpbind localIp${this.localIp} ${this.localIpPort}`,
|
||||
})
|
||||
console.log(TAG, 'tcpbind', this.localIp, 'localIp', this.localIpPort)
|
||||
return new Promise((resolve, reject) => {
|
||||
let promise = this.tcp.bind({
|
||||
@ -82,6 +100,10 @@ export default class TcpClient {
|
||||
// time:dateFormat(new Date()),
|
||||
// PLC:`${TAG} testTag tcp bind faile ${JSON.stringify(err)}`,
|
||||
// })
|
||||
this.writeLog({
|
||||
time:dateFormat(new Date()),
|
||||
message: `${TAG} tcpbind error ${JSON.stringify(err)}`,
|
||||
})
|
||||
console.log('testTag tcp bind faile');
|
||||
globalThis.getCloseTcp = true
|
||||
hilog.info(0x0000, 'testTag', "tcpBinderror:" + JSON.stringify(err));
|
||||
@ -109,6 +131,10 @@ export default class TcpClient {
|
||||
}
|
||||
|
||||
connectTcp() {
|
||||
this.writeLog({
|
||||
time:dateFormat(new Date()),
|
||||
message: `${TAG} tcpConnect oppositeIp ${ this.oppositeIp} ${this.oppositeIpPort}`,
|
||||
})
|
||||
console.log(TAG, 'tcpConnect', this.oppositeIp, 'localIp', this.oppositeIpPort)
|
||||
return new Promise((resolve, reject) => {
|
||||
let promise = this.tcp.connect({
|
||||
@ -122,6 +148,10 @@ export default class TcpClient {
|
||||
keepAlive: true,
|
||||
}, err => {
|
||||
if (err) {
|
||||
this.writeLog({
|
||||
time:dateFormat(new Date()),
|
||||
message: `${TAG} TCPconnect error ${JSON.stringify(err)}`,
|
||||
})
|
||||
// this.writeLog({
|
||||
// time:dateFormat(new Date()),
|
||||
// PLC:`${TAG} tcp connect rebind success`,
|
||||
@ -130,17 +160,26 @@ export default class TcpClient {
|
||||
return
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.writeLog({
|
||||
time:dateFormat(new Date()),
|
||||
message: `${TAG} tcp重连`,
|
||||
})
|
||||
getTCP()
|
||||
resolve(false)
|
||||
}, 2000)
|
||||
return;
|
||||
}
|
||||
});
|
||||
console.log('testTagtestTag000,success')
|
||||
console.log('socketTag','success')
|
||||
|
||||
globalThis.getCloseTcp = false
|
||||
resolve(true)
|
||||
}).catch(err => {
|
||||
console.log('socketTag','error')
|
||||
this.writeLog({
|
||||
time:dateFormat(new Date()),
|
||||
message: `${TAG} TCPconnect error2 ${JSON.stringify(err)}`,
|
||||
})
|
||||
globalThis.getCloseTcp = true
|
||||
this.num++
|
||||
if(this.num>3){
|
||||
@ -167,6 +206,10 @@ export default class TcpClient {
|
||||
promise.then(() => {
|
||||
reslove(true)
|
||||
}).catch(err => {
|
||||
this.writeLog({
|
||||
time:dateFormat(new Date()),
|
||||
message: `${TAG} TCPsend error ${JSON.stringify(err)}`,
|
||||
})
|
||||
reslove(false)
|
||||
});
|
||||
})
|
||||
@ -180,7 +223,10 @@ export default class TcpClient {
|
||||
// })
|
||||
console.log(TAG, 'Tcponmessage', value)
|
||||
globalThis.tcpUdpError = false
|
||||
|
||||
this.writeLog({
|
||||
time:dateFormat(new Date()),
|
||||
message: `${TAG} Tcponmessage ,${value}`,
|
||||
})
|
||||
// console.log('messageLengt',,value.message.length))
|
||||
console.log('testTagtcpmsg')
|
||||
// console.log("on message, message:" + value.message+ ", remoteInfo:" )
|
||||
@ -195,27 +241,32 @@ export default class TcpClient {
|
||||
}
|
||||
clearInterval(globalThis.intervaltcp)
|
||||
globalThis.intervaltcp=setInterval(()=>{
|
||||
//程序断开
|
||||
if (globalThis.tcpUdpError) {
|
||||
console.log(TAG,'tcp信号丢失')
|
||||
getTCP()
|
||||
prompt.showToast({
|
||||
message: 'tcp信号丢失',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
globalThis.tcpUdpError = true;
|
||||
//程序断开
|
||||
if (globalThis.tcpUdpError) {
|
||||
console.log(TAG,'tcp信号丢失')
|
||||
getTCP()
|
||||
prompt.showToast({
|
||||
message: 'tcp信号丢失',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
this.writeLog({
|
||||
time:dateFormat(new Date()),
|
||||
message: `${TAG} tcp信号丢失`,
|
||||
})
|
||||
globalThis.tcpUdpError = true;
|
||||
},3000)
|
||||
// callback(value.message)
|
||||
});
|
||||
}
|
||||
async writeLog(param){
|
||||
// return
|
||||
// const fileUtil = new FileUtil(globalThis.context)
|
||||
// const date=dateFormat(new Date).split(' ')[0]
|
||||
// const folderPath = await fileUtil.initFolder(`/PLC/${date}`);
|
||||
// fileUtil.editFile(`${folderPath}/plcLog.txt`, JSON.stringify(param)+`\n`)
|
||||
|
||||
async writeLog(param){
|
||||
const fileUtil = new FileUtil(globalThis.context)
|
||||
fileUtil.editFile(`${this.folderPath}/plcLog.txt`, JSON.stringify(param)+`\n`)
|
||||
}
|
||||
async initPath(){
|
||||
const fileUtil = new FileUtil(globalThis.context)
|
||||
const date=dateFormat(new Date).split(' ')[0]
|
||||
this.folderPath = await fileUtil.initFolder(`/PLC/${date}`);
|
||||
}
|
||||
offTcp(callback) {
|
||||
console.log(TAG, 'tcpofff')
|
||||
@ -225,17 +276,24 @@ export default class TcpClient {
|
||||
}
|
||||
|
||||
closeTcp(callback) {
|
||||
|
||||
return new Promise((reslove, reject) => {
|
||||
console.log(TAG, 'tcpClose')
|
||||
let promise = this.tcp.close();
|
||||
promise.then(() => {
|
||||
globalThis.getCloseTcp = true
|
||||
|
||||
this.writeLog({
|
||||
time:dateFormat(new Date()),
|
||||
message: `${TAG} tcp closeSuccess`,
|
||||
})
|
||||
console.log(TAG, 'tcpCloseSuccess')
|
||||
callback()
|
||||
reslove(true)
|
||||
}).catch(err => {
|
||||
console.log(TAG, 'tcpClosefailed')
|
||||
this.writeLog({
|
||||
time:dateFormat(new Date()),
|
||||
message: `${TAG} tcpclose error ${JSON.stringify(err)}`,
|
||||
})
|
||||
reslove(false)
|
||||
});
|
||||
})
|
||||
|
||||
@ -2,72 +2,129 @@ import emitter from '@ohos.events.emitter';
|
||||
|
||||
export const EVENTID = {
|
||||
//远程扣分处理
|
||||
kfEventId:35,
|
||||
kfEventId: 35,
|
||||
//远程扣分查询
|
||||
kfAskEventId:36,
|
||||
kfAskEventId: 36,
|
||||
//远程扣分确认
|
||||
kfConfirmEventId:37,
|
||||
kfConfirmEventId: 37,
|
||||
|
||||
//远程开始考试
|
||||
beginExamEventId:11,
|
||||
beginExamEventId: 11,
|
||||
//远程结束考试
|
||||
endExamEventId:12
|
||||
endExamEventId: 12
|
||||
}
|
||||
|
||||
export default class JudgeEmitter{
|
||||
export default class JudgeEmitter {
|
||||
private beginExamCallBack: Function = () => {}
|
||||
private endExamCallBack: Function = () => {}
|
||||
private confirmExamCallBack: Function = () => {}
|
||||
private kfContent: Function = () => {}
|
||||
|
||||
private beginExamCallBack:Function = ()=>{}
|
||||
private endExamCallBack:Function = ()=>{}
|
||||
private directives: string
|
||||
|
||||
constructor() {
|
||||
this.init()
|
||||
}
|
||||
|
||||
init = async ()=>{
|
||||
console.info('surenjun','开始注册udp事件')
|
||||
emitter.on({eventId:EVENTID.beginExamEventId}, () => {
|
||||
init = async () => {
|
||||
console.info('surenjun', '开始注册udp事件')
|
||||
emitter.off(EVENTID.beginExamEventId)
|
||||
emitter.off(EVENTID.endExamEventId)
|
||||
emitter.off(EVENTID.kfConfirmEventId)
|
||||
emitter.off(EVENTID.kfEventId)
|
||||
|
||||
emitter.on({
|
||||
eventId: EVENTID.beginExamEventId
|
||||
}, () => {
|
||||
this?.beginExamCallBack()
|
||||
});
|
||||
emitter.on({eventId:EVENTID.endExamEventId}, () => {
|
||||
|
||||
emitter.on({
|
||||
eventId: EVENTID.endExamEventId
|
||||
}, () => {
|
||||
this?.endExamCallBack()
|
||||
});
|
||||
emitter.on({eventId:EVENTID.kfEventId}, () => {
|
||||
this?.endExamCallBack()
|
||||
|
||||
emitter.on({
|
||||
eventId: EVENTID.kfEventId
|
||||
}, (data) => {
|
||||
console.info('surenjun EVENTID.kfEvent' + JSON.stringify(data))
|
||||
this?.kfContent(data)
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//监听开始考试
|
||||
public onBeginExam = async (callBack?:Function)=>{
|
||||
console.info('surenjun','userInfo注册onBeginExam事件')
|
||||
public onBeginExam = async (callBack?: Function) => {
|
||||
console.info('surenjun', '注册远程开始考试事件')
|
||||
this.beginExamCallBack = callBack
|
||||
}
|
||||
|
||||
//监听结束考试
|
||||
public onEndExam = async (callBack?:Function)=>{
|
||||
public onEndExam = async (callBack?: Function) => {
|
||||
console.info('surenjun', '注册远程结束考试事件')
|
||||
this.endExamCallBack = callBack
|
||||
}
|
||||
|
||||
//监听扣分处理
|
||||
public onKfExam= async (callBack?:Function)=>{
|
||||
this.endExamCallBack = callBack
|
||||
public onKfExam = async (callBack?: Function) => {
|
||||
console.info('surenjun', '注册远程扣分考试事件')
|
||||
this.kfContent = callBack
|
||||
}
|
||||
|
||||
//开始考试
|
||||
public sendBeginExam = async(content:string)=>{
|
||||
emitter.emit({eventId:EVENTID.beginExamEventId}, {
|
||||
data:{ content }
|
||||
public sendBeginExam = async (content: string) => {
|
||||
emitter.emit({
|
||||
eventId: EVENTID.beginExamEventId
|
||||
}, {
|
||||
data: {
|
||||
directives: content
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//结束考试
|
||||
public sendEndExam = async(content:string)=>{
|
||||
emitter.emit({eventId:EVENTID.endExamEventId}, {
|
||||
data:{content}
|
||||
public sendEndExam = async (content: string) => {
|
||||
emitter.emit({
|
||||
eventId: EVENTID.endExamEventId
|
||||
}, {
|
||||
data: {
|
||||
directives: content
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//扣分
|
||||
public sendKfContent = async (kfxh: string) => {
|
||||
const directives = this.directives
|
||||
console.info('surenjun', `udpEvent收到扣分事件。kfxh=>${kfxh};directives=>${directives}`)
|
||||
emitter.emit({
|
||||
eventId: EVENTID.kfEventId
|
||||
}, {
|
||||
data: {
|
||||
directives,
|
||||
kfxh
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//监听扣分指令
|
||||
public sendOnKf = async (directives: string) => {
|
||||
//TODO 临时存储指令编号
|
||||
this.directives = directives
|
||||
globalThis.judgeUdp.askKf(directives)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 获取扣分项目编号
|
||||
public onConfirmKf = async (kfxh: string) => {
|
||||
const directives = this.directives;
|
||||
emitter.emit({
|
||||
eventId: EVENTID.kfConfirmEventId
|
||||
}, {
|
||||
data: {
|
||||
kfxh, directives
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@ export default async function request(req: any) {
|
||||
//处理中心服务code
|
||||
if(res.Envelope){
|
||||
const msgXml = res.Envelope.Body.writeObjectOutResponse.return;
|
||||
//Envelope.Body.writeObjectOutResponse.return
|
||||
//Envelope.Body.writeObjectOutResponse.return
|
||||
const dd = handleCenterCode(msgXml,isNewCenter);
|
||||
return dd
|
||||
}
|
||||
@ -170,7 +170,6 @@ function handleCenterCode(msgXml,isNewCenter){
|
||||
const patternArr = pattern.exec(msgXml);
|
||||
return patternArr && patternArr[1]
|
||||
});
|
||||
console.info('surenjun =>request-prev',keystr)
|
||||
|
||||
if(code != '1'){
|
||||
prompt.showToast({
|
||||
@ -182,7 +181,6 @@ function handleCenterCode(msgXml,isNewCenter){
|
||||
// globalThis.errorDialog.open()
|
||||
return {code,message:decodeURIComponent(message)}
|
||||
}else{
|
||||
console.info('surenjun =>request',keystr)
|
||||
return { code ,keystr, message }
|
||||
}
|
||||
}
|
||||
|
||||
@ -539,7 +539,6 @@ struct Index {
|
||||
carId,examinationRoomId,
|
||||
lsh,kskssj,kslc
|
||||
})
|
||||
console.info('surenjun 考试里程上传成功')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements';
|
||||
import { judgeConfig } from './judgeSDK/utils/judgeConfig';
|
||||
import { initJudgeUdp } from '../common/utils/UdpJudge';
|
||||
import errorMsgDialog from './compontents/errorMsgDialog'
|
||||
|
||||
import { getCurrentHourTime } from '../common/utils/tools';
|
||||
@Entry
|
||||
@Component
|
||||
struct UserInfo {
|
||||
@ -203,6 +203,16 @@ struct UserInfo {
|
||||
this.avPlayer = new VoiceAnnounce();
|
||||
initJudgeUdp()
|
||||
|
||||
//监听远程开始考试
|
||||
globalThis.udpEvent.onBeginExam(async ()=>{
|
||||
console.info('surenjun','userInfo收到UdpEvent事件')
|
||||
if (this.isBoardPrePareSetPopupOpen && !this.isFirstBoardPrePareSetPopupBtnShow) {
|
||||
await this.prePareSCZB()
|
||||
}else{
|
||||
await this.prePareExam()
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
//身份证读卡器初始化
|
||||
@ -461,7 +471,7 @@ struct UserInfo {
|
||||
|
||||
//人脸比对窗口关闭
|
||||
changeFaceCompareSuccess() {
|
||||
this.ksksLimit = false
|
||||
this.ksksLimit = false
|
||||
console.log('this.faceCompareSuces', this.faceCompareSucess, JSON.stringify(this.currentUser))
|
||||
if (this.faceCompareSucess > 0) {
|
||||
//人脸比对通过
|
||||
@ -797,6 +807,7 @@ struct UserInfo {
|
||||
const {carId,examinationRoomId} = carInfo;
|
||||
const { examSubject,plateNo } = carInfo;
|
||||
const date = new Date()
|
||||
globalThis.startHourTime = await getCurrentHourTime()
|
||||
const photoBase64 = await this.getPhoto();
|
||||
const drvexam = {
|
||||
lsh: this.currentUser.lsh || '',
|
||||
@ -826,7 +837,7 @@ struct UserInfo {
|
||||
}
|
||||
|
||||
//开始上车准备
|
||||
prePareSCZB = async () => {
|
||||
prePareSCZB = async () => {
|
||||
try {
|
||||
await this.checkSignal()
|
||||
this.isExamStart = true
|
||||
@ -887,15 +898,6 @@ struct UserInfo {
|
||||
|
||||
aboutToDisappear() {
|
||||
this.outClick()
|
||||
//监听远程开始考试
|
||||
globalThis.udpEvent.onBeginExam(async ()=>{
|
||||
console.info('surenjun','userInfo收到UdpEvent事件')
|
||||
if (this.isBoardPrePareSetPopupOpen && !this.isFirstBoardPrePareSetPopupBtnShow) {
|
||||
await this.prePareSCZB()
|
||||
}else{
|
||||
await this.prePareExam()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
outClick() {
|
||||
|
||||
@ -96,7 +96,6 @@ export default struct RealTime {
|
||||
Row(){
|
||||
Image($rawfile('judge/big.png')).width(60).onClick(()=>{
|
||||
this.scaleFn( -this.getScaleNum() )
|
||||
console.info('surenjun getScaleNum',-this.getScaleNum())
|
||||
})
|
||||
Image($rawfile('judge/small.png')).width(60).onClick(()=>{
|
||||
this.scaleFn( this.getScaleNum() )
|
||||
@ -184,7 +183,6 @@ export default struct RealTime {
|
||||
|
||||
scaleFn = async (num)=>{
|
||||
const scaleNum = this.scaleNum
|
||||
console.info('surenjun getScaleNum',scaleNum)
|
||||
if(scaleNum >0 && scaleNum < 5000){
|
||||
this.scaleNum += num;
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ export default class Judge {
|
||||
//开始评判
|
||||
private async judging(callBack: Function) {
|
||||
const {judgeUI} = this;
|
||||
const { name, lsh, idCard,kssycs} = judgeUI;
|
||||
const { name, lsh, idCard,kssycs,manualMarkRules} = judgeUI;
|
||||
const fileLog = new FileLog(judgeUI.context);
|
||||
const filePath = await fileLog.initFileLogo({
|
||||
name, lsh, idCard
|
||||
@ -122,7 +122,7 @@ export default class Judge {
|
||||
strArr = str.split('\n')
|
||||
}
|
||||
//日志回调
|
||||
console.info(judgeTag, '1.进入评判入口')
|
||||
console.info(judgeTag, '1.进入评判入口1')
|
||||
await examJudgeSetLogCallback(3, async (level, info, len) => {
|
||||
console.log('评判日志:' + info)
|
||||
await fileLog.setExamJudgeLogData(info);
|
||||
@ -151,7 +151,11 @@ export default class Judge {
|
||||
console.info('评判实时数据', info)
|
||||
const performInfo = JSON.parse(info)
|
||||
this.performInfo = performInfo
|
||||
this.judgeUI.jl = Math.floor((performInfo.qjjl + performInfo.dcjl) / 100)
|
||||
const jl = Math.floor((performInfo.qjjl + performInfo.dcjl) / 100);
|
||||
if(jl > this.judgeUI.examMileage){
|
||||
this.checkExamIsEnd()
|
||||
}
|
||||
this.judgeUI.jl = jl
|
||||
//TODO 待优化 跨组件传值不生效
|
||||
globalThis.laneData = performInfo.lane;
|
||||
})
|
||||
@ -199,10 +203,25 @@ export default class Judge {
|
||||
handDistance();
|
||||
}
|
||||
})
|
||||
globalThis.udpEvent.onBeginExam(async ()=>{
|
||||
|
||||
//监听远程结束考试
|
||||
globalThis.udpEvent.onEndExam(async ()=>{
|
||||
this.checkExamIsEnd(true);
|
||||
})
|
||||
//TODO 监听远程扣分
|
||||
|
||||
console.info(judgeTag,JSON.stringify(manualMarkRules))
|
||||
//监听远程扣分
|
||||
globalThis.udpEvent.onKfExam(async (content)=>{
|
||||
console.info('评判收到远程扣分项目内容' + JSON.stringify(content))
|
||||
const { kfxh , directives } = content.data;
|
||||
console.info(judgeTag ,'评判收到远程扣分项目内容,扣分序号:' + `kfxh=>${kfxh}; directives=>${directives}`)
|
||||
//根据扣分序号找扣分代码
|
||||
const currentKf = manualMarkRules.filter(mark => mark.kfxh == kfxh)[0];
|
||||
console.info(judgeTag, '扣分项目:' + JSON.stringify(currentKf))
|
||||
this.setJudgeMark(currentKf.itemno, currentKf.markserial, 2);
|
||||
globalThis.judgeUdp.confirmKf(directives , 1)
|
||||
})
|
||||
|
||||
}
|
||||
//实时计算gps经纬度距离
|
||||
handDistance= async ()=>{
|
||||
@ -413,7 +432,8 @@ export default class Judge {
|
||||
})
|
||||
this.judgeUI.totalScore += thisKf.score * 1;
|
||||
if(kf.xmdm != 20){
|
||||
judgeUI.projectsObj[kf.xmdm].type = '5';
|
||||
const type = judgeUI.projectsObj[kf.xmdm].type;
|
||||
judgeUI.projectsObj[kf.xmdm].type = (type == 3 || type == 4) ? '4' : '5';
|
||||
}
|
||||
break;
|
||||
|
||||
@ -437,7 +457,7 @@ export default class Judge {
|
||||
const xmdm = xmqx.xmdm;
|
||||
const xmmcCode = judgeUI.projectsObj[xmdm].projectCodeCenter;
|
||||
const voiceCode = getKmProjectCancelVoice(examSubject,xmmcCode);
|
||||
avPlayer.playAudio([`voice/${voiceCode}.mp3`],true)
|
||||
// avPlayer.playAudio([`voice/${voiceCode}.mp3`],true)
|
||||
this.judgeUI.projectsObj[xmdm].type = '1';
|
||||
this.testKmItems[xmmcCode].status = '1';
|
||||
break;
|
||||
@ -466,10 +486,10 @@ export default class Judge {
|
||||
const {xmdm} = precast;
|
||||
const xmmcCode = judgeUI.projectsObj[xmdm].projectCodeCenter;
|
||||
const xmmcSingleCode = judgeUI.projectsObj[xmdm].projectCode;
|
||||
if(examSubject == 2 && ((xmdm == 0 && f == 1) || (xmdm == 1 && s == 1) || xmdm == 3)){
|
||||
//倒车入库/桩考/侧方停车
|
||||
avPlayer.playAudio([`voice/${xmmcCode}.mp3`],false)
|
||||
}
|
||||
// if(examSubject == 2 && ((xmdm == 0 && f == 1) || (xmdm == 1 && s == 1) || xmdm == 3)){
|
||||
// //倒车入库/桩考/侧方停车
|
||||
// avPlayer.playAudio([`voice/${xmmcCode}.mp3`],false)
|
||||
// }
|
||||
this.testKmItems[xmmcCode].status = 2;
|
||||
this.xmmcStr = xmmcStr;
|
||||
this.xmmcCode = xmmcCode;
|
||||
@ -528,13 +548,13 @@ export default class Judge {
|
||||
const code = projectsObj[xmdm].projectCodeCenter;
|
||||
const isEnd = projectsObj[xmdm].isEnd;
|
||||
const kmCode = getKmProjectVoice(code, 1, judgeConfigObj, lane,xmxh)
|
||||
if (!ignoreVoiceCodeArr.includes(code)) {
|
||||
if(examSubject == 2 && ((xmdm == 0 && f == 2) || (xmdm == 1 && s == 2) || xmdm == 3)){
|
||||
//倒出入库、桩考\进项目语音控制
|
||||
}else{
|
||||
kmCode && avPlayer.playAudio([`voice/${kmCode}.mp3`],true)
|
||||
}
|
||||
}
|
||||
// if (!ignoreVoiceCodeArr.includes(code)) {
|
||||
// if(examSubject == 2 && ((xmdm == 0 && f == 2) || (xmdm == 1 && s == 2) || xmdm == 3)){
|
||||
// //倒出入库、桩考\进项目语音控制
|
||||
// }else{
|
||||
// kmCode && avPlayer.playAudio([`voice/${kmCode}.mp3`],true)
|
||||
// }
|
||||
// }
|
||||
setTimeout(()=>{if(param512[7] != 0){this.judgeUI.isDeductedPopShow = true}},200)
|
||||
//项目已考不上传监管信息
|
||||
if (!isEnd) {
|
||||
@ -555,9 +575,9 @@ export default class Judge {
|
||||
const endCode = projectsObj[xmdm].projectCodeCenter;
|
||||
const projectIsEnd = projectsObj[xmdm].isEnd;
|
||||
const endKmCode = getKmProjectVoice(endCode, 2, judgeConfigObj, lane,xmxh)
|
||||
if (!ignoreVoiceCodeArr.includes(endCode) && examSubject == 3) {
|
||||
endKmCode && avPlayer.playAudio([`voice/${endKmCode}.mp3`])
|
||||
}
|
||||
// if (!ignoreVoiceCodeArr.includes(endCode) && examSubject == 3) {
|
||||
// endKmCode && avPlayer.playAudio([`voice/${endKmCode}.mp3`])
|
||||
// }
|
||||
const isStart = await checkProjectIsStart(xmdm,1);
|
||||
if(isStart){
|
||||
//项目结束了就不再生成数据
|
||||
@ -581,7 +601,6 @@ export default class Judge {
|
||||
const currentKf = kf[kfLen -1];
|
||||
if (judgeConfig.kfVoiceOpen ||(examSubject == 2 && judgeConfigObj['618'] == '1') || (examSubject== 3&& judgeConfigObj['418'] == '1') ) {
|
||||
avPlayer.playAudio([`voice/${currentKf.markcatalog}.mp3`,`voice/mark_${Math.abs(currentKf.score)}.mp3`])
|
||||
|
||||
}
|
||||
const isStart = await checkProjectIsStart(currentKf.xmdm,2,currentKf);
|
||||
if(isStart){
|
||||
@ -815,29 +834,30 @@ export default class Judge {
|
||||
goJudgeVoice = async (sound: SOUND) => {
|
||||
const {avPlayer,fileLog} = this;
|
||||
const {xmdm,code,type} = sound;
|
||||
console.info('surenjun code=>',JSON.stringify(code))
|
||||
//判断是不是模拟灯光语音
|
||||
if (type == 1) {
|
||||
avPlayer.playAudio([`voice/${code}.mp3`], false, () => {
|
||||
avPlayer.playAudio([`voice/${code[0]}.mp3`], false, () => {
|
||||
examJudgeSoundEnd({
|
||||
itemno: xmdm, code, type
|
||||
itemno: xmdm, code:code[0], type
|
||||
})
|
||||
fileLog.setExamJudgeData({
|
||||
method: 'examJudgeSoundEnd',
|
||||
itemno: xmdm,
|
||||
code,
|
||||
code:code[0],
|
||||
type,
|
||||
})
|
||||
})
|
||||
}else{
|
||||
avPlayer.playAudio([`voice/${code}.mp3`])
|
||||
avPlayer.playAudio([`voice/${code[0]}.mp3`])
|
||||
}
|
||||
}
|
||||
|
||||
// 校验考试是否结束
|
||||
checkExamIsEnd =
|
||||
async (isManual?: boolean) => {
|
||||
const {judgeUI,avPlayer,isExamEnd,isEndTip} = this;
|
||||
const {isAllProjectsEnd,examSubject,singlePlay,totalScore,judgeConfigObj,passingScore} = judgeUI;
|
||||
const {judgeUI,avPlayer,isExamEnd,isEndTip,ksjs} = this;
|
||||
const {isAllProjectsEnd,examSubject,singlePlay,totalScore,judgeConfigObj,passingScore,examMileage,jl} = judgeUI;
|
||||
|
||||
if (isExamEnd) {
|
||||
return
|
||||
@ -857,7 +877,7 @@ export default class Judge {
|
||||
//单机模式
|
||||
if (singlePlay) {
|
||||
console.info(judgeTag + ' isAllProjectsEnd => ',isAllProjectsEnd)
|
||||
if (isAllProjectsEnd) {
|
||||
if (isAllProjectsEnd && jl >= examMileage) {
|
||||
//成绩合格
|
||||
if(totalScore >= passingGrade && !isEndTip) {
|
||||
if (examSubject == 3 && (param342 == 0 || param342 == 2) && (param302 != 6 || param302 != 7 || param302 != 8)) {
|
||||
@ -874,7 +894,7 @@ export default class Judge {
|
||||
return
|
||||
}
|
||||
}else{
|
||||
if(examSubject == 3 && param302 == 4){
|
||||
if(examSubject == 3 && (param302 == 4 || param302 == 5 || param302 == 7 || param302 == 8)){
|
||||
await examJudgeEndExam()
|
||||
this.isExamEnd = true
|
||||
return
|
||||
@ -895,6 +915,7 @@ export default class Judge {
|
||||
this.isExamEnd = true
|
||||
return
|
||||
}
|
||||
|
||||
//成绩合格
|
||||
if (isAllProjectsEnd && totalScore >= passingGrade && !isEndTip) {
|
||||
if(examSubject == 2){
|
||||
@ -902,8 +923,14 @@ export default class Judge {
|
||||
this.isExamEnd = true
|
||||
return
|
||||
}
|
||||
|
||||
//考试里程判断
|
||||
if(examSubject == 3 && jl < examMileage){
|
||||
return
|
||||
}
|
||||
|
||||
//考试合格自动退出
|
||||
if(examSubject == 3 && param302 == 4){
|
||||
if(examSubject == 3 && (param302 == 4)){
|
||||
await examJudgeEndExam()
|
||||
this.isExamEnd = true
|
||||
return
|
||||
@ -1195,15 +1222,13 @@ export default class Judge {
|
||||
tempSd = 0
|
||||
}
|
||||
|
||||
fileLog.setFourAndOneLogData(`${translateJd},${translateWd}`);
|
||||
|
||||
const arr = [
|
||||
//考生号
|
||||
asclshArr.map(lsh => string2Bytes(lsh, 8)[0]),
|
||||
//考试员号
|
||||
ascksyhArr.map(ksyh => string2Bytes(ksyh, 8)[0]),
|
||||
//科目类型(0:未考试 1:科目二 2:科目三) + 考试开始时间
|
||||
string2Bytes(`${examType}${startHourTime}`, 4 * 8),
|
||||
string2Bytes(`${examType}${globalThis.startHourTime || startHourTime}`, 4 * 8),
|
||||
// TODO 消息序号从1开始,0结束
|
||||
string2Bytes(isEnd ? 0 : serialIndex, 2 * 8),
|
||||
/*左向灯 右向灯 双跳灯 远光灯 近光灯 视宽灯 点火1 点火2 离合器 脚刹 手刹 副刹 喇叭 门开关 安全带 档位 车辆状态 雨刮器 雾灯 0*/
|
||||
@ -1250,6 +1275,9 @@ export default class Judge {
|
||||
tempArr = tempArr.concat(itemArr)
|
||||
})
|
||||
this.serialIndex += 1;
|
||||
fileLog.setFourAndOneLogData(`${startHourTime},${translateJd},${translateWd}`);
|
||||
fileLog.setFourAndOneLogDataBytes(tempArr.toString());
|
||||
|
||||
return Array2Byte(tempArr)
|
||||
}
|
||||
//获取场地序号
|
||||
@ -1459,10 +1487,7 @@ export default class Judge {
|
||||
if (udpIndex % 5 === 0 && !isUdpEnd) {
|
||||
const judgeUdp = globalThis.judgeUdp
|
||||
const bytes = await this.getMessageHeartbeat(isExamEnd);
|
||||
console.info(judgeTag,JSON.stringify(bytes))
|
||||
console.info(judgeTag,'udp-prev-send')
|
||||
judgeUdp.send(bytes)
|
||||
console.info(judgeTag,'udp-prev-end')
|
||||
}
|
||||
globalThis.udpIndex += 1
|
||||
}
|
||||
@ -1566,6 +1591,8 @@ export default class Judge {
|
||||
}
|
||||
}
|
||||
})
|
||||
console.info(judgeTag,'项目状态projectsObj:' + JSON.stringify(projectsObj));
|
||||
console.info(judgeTag,'所有考试项目数量:' + allProjectNum)
|
||||
console.info(judgeTag,'必考项目数量:' + projectNum)
|
||||
console.info(judgeTag,'必考项目已考数量:' + endProjectsNum)
|
||||
//必考项目除靠边停车是否全部完成
|
||||
@ -1581,13 +1608,17 @@ export default class Judge {
|
||||
checkDwzt = async (dwzt,jdzt) => {
|
||||
const {avPlayer} = this;
|
||||
const judgeConfig = this.judgeUI.judgeConfig;
|
||||
// const param499 = judgeConfig['499']
|
||||
const param499 = judgeConfig['499'] || '';
|
||||
if(param499 == '' || param499 == undefined){
|
||||
return
|
||||
}
|
||||
//10秒内dwzt不为4;
|
||||
const dwztNum = this.dwztNum
|
||||
if(dwztNum != 0 && (dwztNum % (5 * 10) == 0)){
|
||||
if(dwztNum != 0 && (dwztNum % (5 * 10) == 0) && (param499 !== '' || param499 !== undefined)){
|
||||
this.judgeUI.dwztErrorVisible = true;
|
||||
avPlayer.playAudio([`voice/差分状态异常.mp3`],true)
|
||||
}
|
||||
|
||||
if(dwzt != 4 || jdzt != 3){
|
||||
this.dwztNum += 1
|
||||
}else{
|
||||
|
||||
@ -98,6 +98,8 @@ export function getKmProjectVoice(
|
||||
const param544Str = judgeConfig['544']?.split(',') || [];
|
||||
const param405Str = judgeConfig['405'] || 0;
|
||||
|
||||
console.info('surenjun => param544Str.length',param544Str.length)
|
||||
|
||||
const {num,count,road} = lane
|
||||
if(examSubject == 2){
|
||||
return projectCode
|
||||
@ -121,10 +123,12 @@ export function getKmProjectVoice(
|
||||
: undefined
|
||||
//直线行驶
|
||||
case 40700 : return type === 1 ? 407001 : undefined
|
||||
|
||||
//通过学校 结束param544Str
|
||||
case 41100 : return type === 1
|
||||
? (param512Str[2] ==3 ? 411001 : undefined)
|
||||
: (param544Str.includes(xmxh) ? undefined : 411004)
|
||||
: (param544Str.includes(xmxh) ? undefined : (param544Str.length === 0 ? undefined : 411004))
|
||||
|
||||
//通过车站
|
||||
case 41200 : return type === 1 ? (param512Str[2] ==3 ? 412001 : undefined):undefined
|
||||
//通过人行横道
|
||||
|
||||
@ -20,7 +20,7 @@ export const judgeConfig = {
|
||||
//四合一画面配置
|
||||
fourInOneScreen:{
|
||||
//gps位数
|
||||
gpsDigit:6
|
||||
gpsDigit:7
|
||||
},
|
||||
//后置机类型 0=>三代机 1=>一体机 2=>二代机
|
||||
rearEndUnitsType:0,
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user