济南修改 #25
@ -157,6 +157,7 @@ export async function getSingleCenterTable(param) {
|
||||
// .catch(err => {
|
||||
// reslove(false)
|
||||
// })
|
||||
console.log('联网更新失败,请检查网络后重新更新')
|
||||
promptAction.showToast({
|
||||
message: `联网更新失败,请检查网络后重新更新`,
|
||||
duration: 3000
|
||||
|
||||
@ -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/fileModel';
|
||||
import FileModel from '../../pages/judgeSDK/utils/file-model';
|
||||
// @ts-nocheck
|
||||
//读表
|
||||
//参数平台
|
||||
@ -361,7 +361,7 @@ export async function upDataZhongxinginitialization(param){
|
||||
}
|
||||
console.log('daihai2')
|
||||
|
||||
initialization(str).then((res)=>{
|
||||
initialization(str).then(async (res)=>{
|
||||
console.log('daihai3',JSON.stringify(res))
|
||||
if(!res){
|
||||
resolve(false)
|
||||
@ -374,21 +374,14 @@ export async function upDataZhongxinginitialization(param){
|
||||
if(!centerToMap[key]){
|
||||
continue
|
||||
}
|
||||
setSyncCenterSqlData(key,res,param).then((flag) => {
|
||||
if(!flag){
|
||||
resolve(false)
|
||||
return
|
||||
}{
|
||||
resolve(true)
|
||||
}
|
||||
}).catch ((error) => {
|
||||
const data= await setSyncCenterSqlData(key,res,param)
|
||||
if(!data){
|
||||
resolve(false)
|
||||
console.log(error)
|
||||
})
|
||||
}
|
||||
}
|
||||
console.log('daihai4')
|
||||
|
||||
resolve(true)
|
||||
|
||||
|
||||
console.log('resposestart')
|
||||
|
||||
}).catch((Error)=>{
|
||||
|
||||
@ -46,22 +46,22 @@ export default class FileUtil{
|
||||
*
|
||||
*/
|
||||
public addFile = async (filePath:string,content:string,type?:string)=>{
|
||||
const { READ_WRITE,CREATE,APPEND,TRUNC }= fs.OpenMode
|
||||
const { READ_WRITE,CREATE,APPEND }= fs.OpenMode
|
||||
const isExit = fs.accessSync(filePath);
|
||||
//文件存在先删除
|
||||
if(isExit){
|
||||
fs.unlinkSync(filePath);
|
||||
}
|
||||
try {
|
||||
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)
|
||||
let file = fs.openSync(filePath, READ_WRITE | CREATE);
|
||||
//追加写入文件
|
||||
fs.writeSync(file.fd,content)
|
||||
fs.closeSync(file)
|
||||
console.error(LOGTAG,'写入文件成功')
|
||||
return true
|
||||
|
||||
}catch (e){
|
||||
console.error(LOGTAG,JSON.stringify(e))
|
||||
console.error(LOGTAG,'写入失败',JSON.stringify(e))
|
||||
}
|
||||
}
|
||||
/*
|
||||
@ -72,6 +72,15 @@ 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)
|
||||
|
||||
@ -18,9 +18,9 @@ export async function getTCP() {
|
||||
await globalThis.TcpClient.onMessage((val)=>{
|
||||
setTimeout(()=>{
|
||||
globalThis.TcpClient.sendMsg('1002')//1002
|
||||
if(val&&!globalThis.closeUDPSocket){
|
||||
if(val){
|
||||
// const msg=val.substring(5,val.length-1)
|
||||
console.log('socketTag[PLC.UdpClient]closeUDPSocket',globalThis.closeUDPSocket)
|
||||
console.log('socketTag[PLC.UdpClient] status:',globalThis.udpClient.getStatus())
|
||||
globalThis.udpClient?.sendMsg(val)
|
||||
}
|
||||
},1000)
|
||||
@ -40,11 +40,10 @@ export async function getTCP() {
|
||||
hilog.info(0x0000, 'testTag', "valvalval2" + JSON.stringify(val));
|
||||
setTimeout(()=>{
|
||||
globalThis.TcpClient.sendMsg('1002')//1002
|
||||
if(globalThis.udpClient && val&&!globalThis.closeUDPSocket){
|
||||
if(val&& globalThis.udpClient?.sendMsg){
|
||||
// const msg=val.substring(5,val.length-1)
|
||||
console.log('socketTag[PLC.UdpClient]closeUDPSocket',globalThis.closeUDPSocket)
|
||||
|
||||
globalThis.udpClient.sendMsg&&globalThis.udpClient?.sendMsg(val)
|
||||
globalThis.udpClient?.sendMsg(val)
|
||||
}
|
||||
},1000)
|
||||
|
||||
|
||||
@ -1,65 +1,84 @@
|
||||
import UdpClient from './UdpClient';
|
||||
//import UdpClient from './UdpClient';
|
||||
import UdpClientByCenter from './UdpClientByCenter';
|
||||
import { getSyncData} from '../service/initable'
|
||||
import { dateFormat } from '../../common/utils/tools'
|
||||
import prompt from '@ohos.prompt'
|
||||
import TcpClient from './TcpClient';
|
||||
import {string2Bytes} from '../../common/utils/tools'
|
||||
import {getChuankouFn} from '../../common/service/indexService'
|
||||
export async function sendMsg(val){
|
||||
// globalThis.udpClient1&&globalThis.udpClient1.sendMsg(val)
|
||||
}
|
||||
export async function getUDP() {
|
||||
getSyncData('IpConfigTable').then((result:Array<any>)=>{
|
||||
if(result.length){
|
||||
if(globalThis.udpClient&&!globalThis.closeUDPSocket){
|
||||
globalThis.udpClient.closeUdp(()=>{
|
||||
setTimeout(()=>{
|
||||
globalThis.udpClient.rebindUdp(result[0].udplocalIp, result[0].udplocalIpPort,result[0].udpOppositeIp,result[0].udpOppositeIpPort)
|
||||
globalThis.udpClient.sendMsg('111')
|
||||
globalThis.host=`http://${result[0].centerIp}:${result[0].centerPort}`
|
||||
globalThis.udpClient.onError(globalThis.udpClient.onMessage?globalThis.udpClient.onMessage:()=>{})
|
||||
|
||||
},1000)
|
||||
})
|
||||
}else{
|
||||
const udpClient: UdpClient =new UdpClient(result[0].udplocalIp, result[0].udplocalIpPort,result[0].udpOppositeIp,result[0].udpOppositeIpPort)
|
||||
console.log(` getUDP enter`);
|
||||
getSyncData('IpConfigTable').then((result:Array<any>)=>
|
||||
{
|
||||
if(result.length)
|
||||
{
|
||||
console.log(` getUDP has IPConfigTable `);
|
||||
if(globalThis.udpClient&&globalThis.udpClient.closeUdp)
|
||||
{
|
||||
console.log(` getUDP has udclent close and rebind `);
|
||||
globalThis.udpClient.closeUdp(()=>{
|
||||
setTimeout(()=>{
|
||||
globalThis.udpClient.rebindUdp(result[0].udplocalIp, result[0].udplocalIpPort,result[0].udpOppositeIp,result[0].udpOppositeIpPort)
|
||||
globalThis.udpClient.sendMsg('111',null)
|
||||
globalThis.host=`http://${result[0].centerIp}:${result[0].centerPort}`
|
||||
// globalThis.udpClient.onError_resend(globalThis.udpClient.onMessage?globalThis.udpClient.onMessage:()=>{})
|
||||
},1000)
|
||||
})
|
||||
}
|
||||
else{
|
||||
// 未绑定
|
||||
console.log(` getUDP has no udclent and bind `);
|
||||
const udpClient: UdpClientByCenter =new UdpClientByCenter(result[0].udplocalIp, result[0].udplocalIpPort,result[0].udpOppositeIp,result[0].udpOppositeIpPort)
|
||||
udpClient.bindUdp()
|
||||
udpClient.sendMsg('111')
|
||||
globalThis.udpClient = udpClient
|
||||
globalThis.host=`http://${result[0].centerIp}:${result[0].centerPort}`
|
||||
globalThis.udpClient.onError(globalThis.udpClient.onMessage?globalThis.udpClient.onMessage:()=>{})
|
||||
|
||||
// udpClient.onError_resend(globalThis.udpClient.onMessage?globalThis.udpClient.onMessage:()=>{})
|
||||
globalThis.udpClient = udpClient
|
||||
getChuankouFn()
|
||||
}
|
||||
|
||||
}else{
|
||||
}else
|
||||
{
|
||||
console.log(` getUDP has no IPConfigTable `);
|
||||
// if(globalThis.udpClient)
|
||||
// {
|
||||
// console.log(` getUDP2 has IPConfigTable ,has udpClient ,close it`);
|
||||
// globalThis.udpClient.closeUdp(async ()=>{ })
|
||||
// }
|
||||
globalThis.udpClient={}
|
||||
globalThis.udpClient.onMessage=()=>{}
|
||||
globalThis.udpClient.onMessage_1=()=>{}
|
||||
globalThis.host=''
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export async function getUDP2() {
|
||||
console.log(` getUDP2 enter`);
|
||||
getSyncData('IpConfigTable').then(async (result:Array<any>)=>{
|
||||
if(result.length){
|
||||
if(globalThis.udpClient2&&!globalThis.closeHeartSocket){
|
||||
if(result.length)
|
||||
{
|
||||
console.log(` getUDP2 has IPConfigTable `);
|
||||
if(globalThis.udpClient2)
|
||||
{
|
||||
console.log(` getUDP2 has udclent ,close and rebind `);
|
||||
globalThis.udpClient2.closeUdp(async ()=>{
|
||||
setTimeout(()=>{
|
||||
globalThis.udpClient2.rebindUdp(result[0].udplocalIp, '8800',globalThis.carInfo?.udpAddress,globalThis.carInfo?.messagePort)
|
||||
//保留原来的
|
||||
// globalThis.udpClient2.onMessage((val)=>{ })
|
||||
// globalThis.udpClient2.onError()
|
||||
// globalThis.udpClient2.setMsgCallBack=()=>{}
|
||||
},1000)
|
||||
})
|
||||
}
|
||||
else
|
||||
{
|
||||
// 未绑定
|
||||
console.log(` getUDP2 has no udclent and bind `);
|
||||
const udpClient2: UdpClientByCenter =new UdpClientByCenter(result[0].udplocalIp, '8800',globalThis.carInfo?.udpAddress,globalThis.carInfo?.messagePort)
|
||||
|
||||
globalThis.udpClient2.closeUdp(async ()=>{
|
||||
setTimeout(()=>{
|
||||
globalThis.udpClient2.rebindUdp(result[0].udplocalIp, '8800',globalThis.carInfo?.udpAddress,globalThis.carInfo?.messagePort)
|
||||
globalThis.udpClient2.onMessage((val)=>{
|
||||
})
|
||||
globalThis.udpClient2.onError()
|
||||
globalThis.udpClient2.setMsgCallBack=()=>{}
|
||||
},1000)
|
||||
|
||||
})
|
||||
}else{
|
||||
const udpClient: UdpClientByCenter =new UdpClientByCenter(result[0].udplocalIp, '8800',globalThis.carInfo?.udpAddress,globalThis.carInfo?.messagePort)
|
||||
globalThis.udpClient2 = udpClient
|
||||
globalThis.udpClient2.bindUdp()
|
||||
globalThis.udpClient2.onError()
|
||||
globalThis.udpClient2.onMessage((val)=>{
|
||||
udpClient2.bindUdp()
|
||||
udpClient2.onError_Callback()
|
||||
udpClient2.onMessage_1((val)=>{
|
||||
if(val.id=='32'){
|
||||
globalThis.signNum=val.body[1]
|
||||
|
||||
@ -73,10 +92,17 @@ export async function getUDP2() {
|
||||
globalThis.udpClient2.send(param)
|
||||
}
|
||||
})
|
||||
globalThis.udpClient2 = udpClient2
|
||||
}
|
||||
}else{
|
||||
console.log(` getUDP2 has no IPConfigTable `);
|
||||
if(globalThis.udpClient2)
|
||||
{
|
||||
console.log(` getUDP2 has IPConfigTable ,has udpClient ,close it`);
|
||||
globalThis.udpClient2.closeUdp(async ()=>{ })
|
||||
}
|
||||
globalThis.udpClient2={}
|
||||
globalThis.udpClient2.onMessage=()=>{}
|
||||
globalThis.udpClient2.onMessage_2=()=>{}
|
||||
globalThis.udpClient2.setMsgCallBack=()=>{}
|
||||
}
|
||||
})
|
||||
@ -111,16 +137,19 @@ export async function setJudgeUdp(){
|
||||
|
||||
if(config && config[0] && config[0].udplocalIp){
|
||||
const {udplocalIp} = config[0];
|
||||
const udpClient: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '8080',globalThis.carInfo?.gpsAddress,globalThis.carInfo?.hintPort)
|
||||
udpClient.bindUdp()
|
||||
udpClient.onMessage((val)=>{
|
||||
const udpClientbyCenter: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '8080',globalThis.carInfo?.gpsAddress,globalThis.carInfo?.hintPort)
|
||||
udpClientbyCenter.bindUdp()
|
||||
udpClientbyCenter.onMessage_1((val)=>{
|
||||
console.log('valval',val)
|
||||
})
|
||||
globalThis.judgeUdpClient = udpClient;
|
||||
// globalThis.judgeUdpClient = udpClientbyCenter;
|
||||
return {
|
||||
send(bytes){
|
||||
if(udpIndex > currentUdpIndex){
|
||||
udpClient.sendMsg({id:45,list:bytes,carNo:globalThis.carInfo.carNo,placeId:globalThis.carInfo.examinationRoomId})
|
||||
udpClientbyCenter.sendMsgExt({id:45,
|
||||
list:bytes,
|
||||
carNo:globalThis.carInfo.carNo,
|
||||
placeId:globalThis.carInfo.examinationRoomId})
|
||||
currentUdpIndex = udpIndex
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)}, err => {
|
||||
let promise=this.tcp.bind({ address: this.localIp, port:parseInt(this.localIpPort), family: 1 }, 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) }, err => {
|
||||
let promise=this.tcp.bind({ address: this.localIp, port:parseInt(this.localIpPort), family: 1 }, 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)} , timeout: 6000});
|
||||
let promise = this.tcp.connect({ address: {address: this.oppositeIp, port: parseInt(this.oppositeIpPort), family: 1} , timeout: 6000});
|
||||
promise.then(() => {
|
||||
|
||||
this.tcp.setExtraOptions({
|
||||
|
||||
@ -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)
|
||||
address: this.localIp, port: parseInt(this.localIpPort), family: 1
|
||||
});
|
||||
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)
|
||||
address: this.localIp, port: parseInt(this.localIpPort), family: 1
|
||||
});
|
||||
promise.then(() => {
|
||||
globalThis.closeUDPSocket=false
|
||||
@ -97,6 +97,7 @@ export default class UdpClient {
|
||||
// port: 20022,
|
||||
address: this.oppositeIp,
|
||||
port: parseInt(this.oppositeIpPort),
|
||||
family: 1
|
||||
}
|
||||
});
|
||||
promise.then(() => {
|
||||
@ -125,7 +126,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) {
|
||||
@ -178,12 +179,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
|
||||
@ -203,8 +204,6 @@ export default class UdpClient {
|
||||
globalThis.closeUDPSocket=false
|
||||
|
||||
} else {
|
||||
hilog.info(0x0000,TAG, 'udpCLient', 'closeonSuccess');
|
||||
|
||||
globalThis.closeUDPSocket=true
|
||||
|
||||
this.udp.getState((err, data) => {
|
||||
|
||||
@ -13,17 +13,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import socket from '@ohos.net.socket';
|
||||
import fs from '@ohos.file.fs'
|
||||
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
|
||||
import socket ,{UDPSocket} from '@ohos.net.socket';
|
||||
import { Array2Byte } from '../utils/tools'
|
||||
import FileUtil from '../../common/utils/File'
|
||||
import {fillZero,string2Bytes} from '../utils/tools'
|
||||
import { GlobalConfig } from '../../config/index'
|
||||
const TAG = '[UdpDemo.UdpClient]'
|
||||
// import common from '@ohos.app.ability.common';
|
||||
import hilog from '@ohos.hilog';
|
||||
import prompt from '@ohos.prompt'
|
||||
import call from '@ohos.telephony.call';
|
||||
|
||||
|
||||
export default class UdpClientByCenter {
|
||||
@ -34,12 +30,14 @@ export default class UdpClientByCenter {
|
||||
private udpMsg: any=''
|
||||
private num:number = 0
|
||||
private fileUtil: FileUtil
|
||||
private udp: any = null
|
||||
private udp: UDPSocket = null
|
||||
private sendId: any = 0
|
||||
private lsh: string = null
|
||||
private context
|
||||
private stashFn:StashFunction
|
||||
private headLenth:number=9 //消息头长度
|
||||
private isWorking:Boolean = false
|
||||
private plcUdpError = false;
|
||||
private initParam
|
||||
constructor(udplocalIp: string, udplocalIpPort:string,udpOppositeIp: string,udpOppositeIpPort:string) {
|
||||
this.localIp = udplocalIp
|
||||
@ -49,6 +47,10 @@ export default class UdpClientByCenter {
|
||||
this.stashFn=()=>{}
|
||||
this.udp = socket.constructUDPSocketInstance();
|
||||
}
|
||||
getStatus()
|
||||
{
|
||||
return this.isWorking
|
||||
}
|
||||
rebindUdp(localIp: string, localIpPort:string,oppositeIp: string,oppositeIpPort:string){
|
||||
this.localIp = localIp
|
||||
this.oppositeIp = oppositeIp
|
||||
@ -61,27 +63,27 @@ export default class UdpClientByCenter {
|
||||
});
|
||||
|
||||
promise.then(() => {
|
||||
globalThis.closeHeartSocket=false
|
||||
// globalThis.closeHeartSocket=false
|
||||
this.isWorking = true
|
||||
console.log(`${TAG} udp bind success`);
|
||||
}).catch(err => {
|
||||
globalThis.closeHeartSocket=true
|
||||
//globalThis.closeHeartSocket=true
|
||||
this.isWorking = false
|
||||
console.log(`${TAG} udp bind failed:${JSON.stringify(err)}`);
|
||||
});
|
||||
}
|
||||
initHeartSendMsg(param,context){
|
||||
console.log('1111param',JSON.stringify(param))
|
||||
this.initParam=param
|
||||
this.context=context
|
||||
}
|
||||
|
||||
bindUdp() {
|
||||
let promise = this.udp.bind({
|
||||
address: this.localIp, port: parseInt(this.localIpPort), family: 1
|
||||
});
|
||||
promise.then(() => {
|
||||
globalThis.closeHeartSocket=false
|
||||
// /globalThis.closeHeartSocket=false
|
||||
this.isWorking = true
|
||||
console.log(`${TAG} udp bind success`);
|
||||
}).catch(err => {
|
||||
globalThis.closeHeartSocket=true
|
||||
// globalThis.closeHeartSocket=true
|
||||
this.isWorking = false
|
||||
console.log(`${TAG} udp bind failed:${JSON.stringify(err)}`);
|
||||
});
|
||||
}
|
||||
@ -136,72 +138,78 @@ export default class UdpClientByCenter {
|
||||
}
|
||||
|
||||
sendHeadMsg(msgData){
|
||||
console.log('sendsnd1')
|
||||
//udpOppositeIp
|
||||
let promise = this.udp.send({
|
||||
data: msgData,
|
||||
address: {
|
||||
address: this.oppositeIp,
|
||||
port: parseInt(this.oppositeIpPort),
|
||||
console.log('sendHeadMsg enter')
|
||||
this.sendMsg(msgData,null)
|
||||
console.log('sendHeadMsg exit')
|
||||
}
|
||||
|
||||
sendMsg(msg,sendCallback?) {
|
||||
console.log(TAG,'sendMsg enter status:'+this.isWorking+' ip:'+this.oppositeIp+' port:'+this.oppositeIpPort)
|
||||
if(!this.isWorking)
|
||||
{
|
||||
console.log(TAG,'sendMsg has not working ,just return status:'+this.isWorking+' ip:'+this.oppositeIp+' port:'+this.oppositeIpPort)
|
||||
if(sendCallback){
|
||||
sendCallback()
|
||||
}
|
||||
});
|
||||
promise.then(() => {
|
||||
console.log(`${TAG} udpLine send success:`);
|
||||
}).catch(err => {
|
||||
console.log(`${TAG} udpLine send fail:${JSON.stringify(err)}`);
|
||||
}
|
||||
this.udp.getState((err, data) => {
|
||||
if (err) {
|
||||
//globalThis.closeHeartSocket=true
|
||||
this.isWorking = false
|
||||
console.log('sendMsg getState fail ip:'+this.oppositeIp+' port:'+this.oppositeIpPort);
|
||||
return;
|
||||
} else {
|
||||
let promise = this.udp.send({
|
||||
data: msg,
|
||||
address: {
|
||||
address: this.oppositeIp,
|
||||
port: parseInt(this.oppositeIpPort),
|
||||
}
|
||||
});
|
||||
promise.then(() => {
|
||||
if(sendCallback){
|
||||
sendCallback()
|
||||
}
|
||||
console.log(`${TAG}udpCLient udp send success:oppositeIp${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort,${this.localIpPort}`);
|
||||
}).catch(err => {
|
||||
console.log(`${TAG}udpCLient udp send fail:oppositeIp${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort,${this.localIpPort}`);
|
||||
});
|
||||
}
|
||||
console.log('getState success:' + JSON.stringify(data));
|
||||
})
|
||||
}
|
||||
sendMsgExt(param,context?) {
|
||||
console.log('sendMsgExt enter');
|
||||
if(context){
|
||||
this.context=context
|
||||
}
|
||||
this.sendId=param.id
|
||||
const msgData=this.setWholeMsg(param)
|
||||
this.sendMsg(msgData,param.sendCallback)
|
||||
}
|
||||
onError_Callback(callback?){
|
||||
this.udp.on('error',async err => {
|
||||
this.isWorking = false;
|
||||
console.log('UdpClientByCenter onError err:' + JSON.stringify(err));
|
||||
callback&&callback()
|
||||
});
|
||||
}
|
||||
onError(callback?){
|
||||
onError_resend(callback?){
|
||||
this.udp.on('error',async err => {
|
||||
globalThis.closeHeartSocket=true
|
||||
this.isWorking = false;
|
||||
console.log(TAG,'udpError',JSON.stringify(err))
|
||||
// await this.bindUdp()
|
||||
// await this.sendMsg('111',null)
|
||||
//await this.onMessage_1(callback)
|
||||
callback&&callback()
|
||||
// callback&&callback()
|
||||
// this.closeUdp(()=>{
|
||||
// this.bindUdp()
|
||||
// })
|
||||
});
|
||||
}
|
||||
setMsgCallBack(callback){
|
||||
this.stashFn=callback?callback:()=>{}
|
||||
}
|
||||
sendMsg(param,context?) {
|
||||
this.udp.getState((err, data) => {
|
||||
if (err) {
|
||||
globalThis.closeHeartSocket=true
|
||||
return;
|
||||
}else{
|
||||
console.log('paramparam',JSON.stringify(param))
|
||||
if(context){
|
||||
this.context=context
|
||||
}
|
||||
this.sendId=param.id
|
||||
console.log('sendMsg',JSON.stringify(param))
|
||||
const msgData=this.setWholeMsg(param)
|
||||
// const msgData=this.setMsyBody('31','010000000000000')
|
||||
let promise = this.udp.send({
|
||||
data: msgData,
|
||||
address: {
|
||||
address: this.oppositeIp,
|
||||
port: parseInt(this.oppositeIpPort),
|
||||
}
|
||||
});
|
||||
promise.then(() => {
|
||||
if(param.sendCallback){
|
||||
param.sendCallback()
|
||||
}
|
||||
// if(this.sendId=='46'&¶m.callback){
|
||||
// param.callback()
|
||||
// }
|
||||
console.log(`${TAG} udp send success:`);
|
||||
}).catch(err => {
|
||||
console.log(`${TAG} udp send fail:${JSON.stringify(err)}`);
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
onMessage(callback,type?) {
|
||||
this.udp.on('message', value => {
|
||||
onMessage_2(callback,type?) {
|
||||
this.udp.on('message', (value,remoteInfo) => {
|
||||
console.log('UdpClientByCenter onMessage msg:' + JSON.stringify(value));
|
||||
let arr=[]
|
||||
let dataView = new DataView(value.message)
|
||||
for (let i = 0;i < dataView?.byteLength; ++i) {
|
||||
@ -222,35 +230,120 @@ export default class UdpClientByCenter {
|
||||
});
|
||||
}
|
||||
|
||||
closeUdp(callback) {
|
||||
this.udp.close(err=>{
|
||||
if(err){
|
||||
|
||||
}else{
|
||||
this.udp.getState((err, data) => {
|
||||
if (err) {
|
||||
return;
|
||||
}else{
|
||||
globalThis.closeHeartSocket=true
|
||||
if(!data.isisClose){
|
||||
setTimeout(()=>{
|
||||
callback()
|
||||
},1000)
|
||||
}
|
||||
}
|
||||
})
|
||||
// let promise = this.udp.getState({});
|
||||
// promise.then(data => {
|
||||
//
|
||||
// console.log('getState success:' + JSON.stringify(data));
|
||||
// }).catch(err => {
|
||||
// callback()
|
||||
// console.log('getState fail');
|
||||
// });
|
||||
closeUdp(callback?) {
|
||||
console.log('UdpClientByCenter enter closeUdp ip:' +this.localIp+' port:'+this.localIpPort);
|
||||
this.udp.on('close', () => {
|
||||
console.log('UdpClientByCenter onClose ip:' + this.localIp + ' port:' + this.localIpPort);
|
||||
this.isWorking = false
|
||||
if (callback!=null) {
|
||||
callback()
|
||||
}
|
||||
});
|
||||
}
|
||||
)
|
||||
this.udp.close(err=> {
|
||||
if (err) {
|
||||
console.log('UdpClientByCenter closeUdp failed ip:'+this.localIp+' port:'+this.localIpPort+' err:' + JSON.stringify(err));
|
||||
} else {
|
||||
console.log('UdpClientByCenter closeUdp succeed ip:' +this.localIp+' port:'+this.localIpPort );
|
||||
}
|
||||
})
|
||||
// globalThis.closeHeartSocket=true
|
||||
//
|
||||
// this.udp.close(err=>{
|
||||
// if(err){
|
||||
//
|
||||
// }else{
|
||||
// this.udp.getState((err, data) => {
|
||||
// if (err) {
|
||||
// return;
|
||||
// }else{
|
||||
// globalThis.closeHeartSocket=true
|
||||
// if(!data.isisClose){
|
||||
// setTimeout(()=>{
|
||||
// callback()
|
||||
// },1000)
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// });
|
||||
|
||||
}
|
||||
onMessage_1(callback?) {
|
||||
this.udp.on('message', value => {
|
||||
console.log(TAG,'udponmessage')
|
||||
// 收到的是ArrayBuffer 需要进行转换解析
|
||||
this.plcUdpError = false
|
||||
if (value) {
|
||||
let dataView = new DataView(value.message)
|
||||
let str = ""
|
||||
for (let i = 0; i < dataView?.byteLength; ++i) {
|
||||
let c = String.fromCharCode(dataView?.getUint8(i))
|
||||
if (c !== "\n") {
|
||||
str += c
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`${TAG} udp on message array buffer:${str}`);
|
||||
let strachArr = str.split(',')
|
||||
if (strachArr[0] != '#DN_GD') {
|
||||
return
|
||||
}
|
||||
console.log(`${TAG} udp222 on message array buffer:${str}`);
|
||||
|
||||
strachArr[28]=globalThis.chuankoMsg||'0'
|
||||
// this.stashFn(str)
|
||||
const newArr=JSON.parse(JSON.stringify(strachArr))
|
||||
// this.stashFn=()=>{}
|
||||
callback&&callback(newArr.toString())
|
||||
|
||||
} else {
|
||||
callback&&callback('')
|
||||
}
|
||||
console.log('messageTimeEnd')
|
||||
this.testIfUdpConnetced(callback)
|
||||
});
|
||||
}
|
||||
testIfUdpConnetced(callback)
|
||||
{
|
||||
const arrRed = [0x55, 0xaa, 0x01, 0x01, 0x02, 0x00, 0x03, 0x00];
|
||||
const arrBlue = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00];
|
||||
const arrGreen = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x00, 0x03, 0x01];
|
||||
const arrBlueBuffer = Array2Byte(arrBlue).buffer
|
||||
const arrRedBuffer = Array2Byte(arrRed).buffer
|
||||
const arrGreenBugger = Array2Byte(arrGreen).buffer
|
||||
let num=0
|
||||
//监听udp是否断开
|
||||
clearInterval(globalThis.messageTimer)
|
||||
globalThis.messageTimer = setInterval(() => {
|
||||
const lightLineUdp = globalThis.lightLineUdp
|
||||
const isJudge = globalThis.isJudge
|
||||
setTimeout(async () => {
|
||||
//程序断开
|
||||
lightLineUdp?.send(this.plcUdpError ? arrRedBuffer : (isJudge ? arrGreenBugger : arrBlueBuffer));
|
||||
if (this.plcUdpError) {
|
||||
num++
|
||||
console.log(TAG,'plc udp信号丢失')
|
||||
if(num==3){
|
||||
await this.bindUdp()
|
||||
await this.sendMsg('111',null)
|
||||
await this.onMessage_1(callback)
|
||||
num=0
|
||||
}
|
||||
prompt.showToast({
|
||||
message: 'plc udp信号丢失',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
this.plcUdpError = true;
|
||||
}, 2000)
|
||||
}, 3000)
|
||||
}
|
||||
// initHeartSendMsg(param,context){
|
||||
// console.log('1111param',JSON.stringify(param))
|
||||
// this.initParam=param
|
||||
// this.context=context
|
||||
// }
|
||||
}
|
||||
interface StashFunction {
|
||||
(params: { id: number; length: number; body: any[]; sendId: string }): void;
|
||||
|
||||
@ -21,7 +21,7 @@ export const initJudgeUdp = async () => {
|
||||
globalThis.lightLineUdp = lightLineUdp
|
||||
/*******************************************/
|
||||
|
||||
globalThis.udpClient.onMessage(async (msg) => {
|
||||
globalThis.udpClient.onMessage_1(async (msg) => {
|
||||
const stachArr = msg.split(',')
|
||||
if (stachArr[0] != '#DN_GD') {
|
||||
return
|
||||
|
||||
@ -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/judgeCommon';
|
||||
import { sendGreen } from '../../pages/judgeSDK/utils/judge-common';
|
||||
import {GlobalConfig} from '../../config/index'
|
||||
const config = {
|
||||
host:GlobalConfig.host,
|
||||
@ -41,7 +41,7 @@ export default async function request(req: any) {
|
||||
console.info('surenjun',baseUrl)
|
||||
const {result,responseCode} = await httpRequest.request(`${baseUrl}${url}${paramsStr}`, options);
|
||||
console.log('daihai5')
|
||||
let res:any = xml ? xmlToJson(result) : result;
|
||||
let res:any = xml ? xmlToJson(result,url) : result;
|
||||
console.log('daihai55')
|
||||
|
||||
console.log('响应头地址' + JSON.stringify(res))
|
||||
@ -108,8 +108,8 @@ export default async function request(req: any) {
|
||||
}
|
||||
|
||||
//xml格式转JSON
|
||||
function xmlToJson(result) {
|
||||
console.log("xmlToJson begin");
|
||||
function xmlToJson(result,url) {
|
||||
console.log("xmlToJson begin",url);
|
||||
let xmlOptions = {trim : false, declarationKey:"_declaration",
|
||||
instructionKey : "_instruction", attributesKey : "_attributes",
|
||||
textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype",
|
||||
@ -125,7 +125,7 @@ function xmlToJson(result) {
|
||||
let {_elements:xmlArr} = conv.convertToJSObject(strXml, xmlOptions);
|
||||
console.log("xmlToJson deeml begin");
|
||||
let res = deeml(xmlArr);
|
||||
console.log("xmlToJson end");
|
||||
console.log("xmlToJson end",url);
|
||||
return res
|
||||
}
|
||||
|
||||
|
||||
@ -31,8 +31,6 @@ 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'
|
||||
|
||||
@ -166,7 +166,7 @@ export default struct Index {
|
||||
|
||||
getPLCInfo() {
|
||||
const that = this
|
||||
globalThis.udpClient && globalThis.udpClient.onMessage((msg) => {
|
||||
globalThis.udpClient && globalThis.udpClient.onMessage_1((msg) => {
|
||||
if (!this.breakFlag) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -216,9 +216,7 @@ struct Index {
|
||||
}
|
||||
|
||||
async testXMLToJSONInWorker() {
|
||||
let workerInstance = new worker.ThreadWorker('entry/ets/workers/worker.ts', {
|
||||
name: 'FriendsMoments Worker'
|
||||
});
|
||||
let workerInstance = new worker.ThreadWorker('entry/ets/workers/worker.ts');
|
||||
const param = {
|
||||
carId: globalThis.carInfo?.carId,
|
||||
examinationRoomId: globalThis.carInfo?.examinationRoomId,
|
||||
@ -231,12 +229,15 @@ struct Index {
|
||||
workerInstance.postMessage(param);
|
||||
workerInstance.onmessage = (e: MessageEvents): void => {
|
||||
console.log("baoyihu after postMessage :", JSON.stringify(e.data));
|
||||
if (e.data.isComplete) {
|
||||
let workData: WorkData = e.data;
|
||||
if (workData.isComplete) {
|
||||
router.pushUrl({
|
||||
url: 'pages/ExaminerLogin',
|
||||
}, router.RouterMode.Single)
|
||||
}
|
||||
this.loading = false
|
||||
workerInstance.terminate();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -258,8 +259,8 @@ struct Index {
|
||||
placeId: globalThis.carInfo.examinationRoomId
|
||||
}
|
||||
// globalThis.udpClient2.initHeartSendMsg(param,this.context)
|
||||
if (!globalThis.closeHeartSocket) {
|
||||
globalThis.udpClient2.sendMsg(param, this.context)
|
||||
if (globalThis.udpClient2.getStatus()) {
|
||||
globalThis.udpClient2.sendMsgExt(param, this.context)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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//judgeCommon';
|
||||
import { defaultJudgeConfigObj } from './judgeSDK/utils//judge-common';
|
||||
import {
|
||||
CARINFO,
|
||||
CDSBInfo,
|
||||
@ -21,13 +21,86 @@ 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/judgeConfig';
|
||||
import { judgeConfig } from './judgeSDK/utils/judge-config';
|
||||
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([''])
|
||||
@ -127,9 +200,10 @@ struct Index {
|
||||
NoCancelId: mark.nocancelid * 1,
|
||||
GPS_SID: mark.gps_sid == 0 ? false : true
|
||||
}
|
||||
const markserial = mark.markserial * 1;
|
||||
|
||||
//筛选出人工评判的扣分
|
||||
if (Number(tempObj.markserial) > 100 && Number(tempObj.markserial) < 200) {
|
||||
if (markserial > 100 && markserial < 200) {
|
||||
this.manualMarkRules.push(tempObj)
|
||||
}
|
||||
this.markRuleListObj[`${mark.itemno}_${mark.markserial}`] = {
|
||||
@ -170,33 +244,6 @@ 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;
|
||||
@ -253,8 +300,7 @@ 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) => {
|
||||
@ -492,7 +538,7 @@ struct Index {
|
||||
if (this.examSubject == 3) {
|
||||
Row() {
|
||||
Text('考试路线:').fontColor('#E5CCA1').fontSize(this.FONTSIZE)
|
||||
Text(`线路${this.wayno}`).fontColor('#FFAD33').fontSize(this.FONTSIZE)
|
||||
Text(`线路${globalThis.carInfo.wayno}`).fontColor('#FFAD33').fontSize(this.FONTSIZE)
|
||||
}
|
||||
}
|
||||
|
||||
@ -532,6 +578,7 @@ struct Index {
|
||||
|
||||
Row() {
|
||||
Flex({ direction: FlexDirection.Column }) {
|
||||
|
||||
if (this.kfArr.length) {
|
||||
List({}) {
|
||||
ForEach(this.kfArr, (item) => {
|
||||
@ -858,7 +905,6 @@ 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 !== ''),
|
||||
@ -915,13 +961,11 @@ 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
|
||||
}
|
||||
@ -930,7 +974,6 @@ struct Index {
|
||||
return false
|
||||
}
|
||||
|
||||
//@ts-ignore
|
||||
if (param348 == '0' && projectsObj['9']?.type == 2) {
|
||||
return index === 0 ? true : false
|
||||
}
|
||||
@ -942,76 +985,4 @@ 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;
|
||||
//已考的考试项目
|
||||
}
|
||||
|
||||
@ -24,6 +24,7 @@ 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
|
||||
}
|
||||
})
|
||||
@ -56,8 +57,10 @@ export default struct Index {
|
||||
const roadArr = Reflect.ownKeys(this.roadObj).map((roadKey) => {
|
||||
return this.roadObj[roadKey]
|
||||
});
|
||||
const wayno = roadArr[Math.floor(Math.random()*roadArr.length)];
|
||||
this.goJudge(wayno)
|
||||
globalThis.carInfo.wayno = roadArr[Math.floor(Math.random()*roadArr.length)];
|
||||
router.pushUrl({
|
||||
url: 'pages/Judge',
|
||||
}, router.RouterMode.Single);
|
||||
})
|
||||
ForEach(Reflect.ownKeys(this.roadObj), (roadIndex) => {
|
||||
ListItem() {
|
||||
@ -78,7 +81,10 @@ export default struct Index {
|
||||
.height(220)
|
||||
.margin({ left: 5, bottom: 10 })
|
||||
.onClick(async () => {
|
||||
this.goJudge(this.roadObj[roadIndex])
|
||||
globalThis.carInfo.wayno = this.roadObj[roadIndex];
|
||||
router.pushUrl({
|
||||
url: 'pages/Judge',
|
||||
}, router.RouterMode.Single);
|
||||
})
|
||||
})
|
||||
}.lanes(8).margin({ top: 50, left: 15 })
|
||||
@ -89,18 +95,6 @@ export default struct Index {
|
||||
|
||||
}
|
||||
|
||||
goJudge(wayno) {
|
||||
let currentParams: any = router.getParams() || {};
|
||||
const {sczb,kfdm} = currentParams;
|
||||
router.replaceUrl({
|
||||
url: 'pages/Judge',
|
||||
params:{
|
||||
sczb,
|
||||
kfdm,
|
||||
wayno
|
||||
}
|
||||
}, router.RouterMode.Single);
|
||||
|
||||
outClick() {
|
||||
}
|
||||
outClick(){}
|
||||
}
|
||||
@ -4,8 +4,8 @@ import ethernet from '@ohos.net.ethernet';
|
||||
import prompt from '@ohos.prompt'
|
||||
import { upDateTableByArray} from '../common/service/initable'
|
||||
import { getSyncData} from '../common/service/initable'
|
||||
// import { getUDP, getUDP2 } from '../common/utils/GlobleUdp';
|
||||
// import { getTCP } from '../common/utils/GlobleTcp';
|
||||
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct Index {
|
||||
|
||||
@ -14,9 +14,8 @@ 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 {
|
||||
@ -35,10 +34,6 @@ 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> = []
|
||||
@ -199,9 +194,7 @@ struct UserInfo {
|
||||
this.qkFn()
|
||||
}
|
||||
|
||||
async initData() {
|
||||
this.sczbkf = []
|
||||
this.isFirstBoardPrePareSetPopupBtnShow = false;
|
||||
initData() {
|
||||
this.stepFlag = false
|
||||
this.faceCompareSucess = 0
|
||||
this.showFaceCompare = false
|
||||
@ -223,15 +216,6 @@ 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() {
|
||||
@ -262,7 +246,7 @@ struct UserInfo {
|
||||
placeId: globalThis.carInfo.examinationRoomId
|
||||
}
|
||||
|
||||
globalThis.udpClient2.sendMsg(param, this.context)
|
||||
globalThis.udpClient2.sendMsgExt(param, this.context)
|
||||
}
|
||||
|
||||
async initSysset() {
|
||||
@ -413,7 +397,7 @@ struct UserInfo {
|
||||
placeId: globalThis.carInfo.examinationRoomId
|
||||
}
|
||||
|
||||
globalThis.udpClient2.sendMsg(param, this.context)
|
||||
globalThis.udpClient2.sendMsgExt(param, this.context)
|
||||
if (res.examinationStuAbsentRsp.head.resultCode == '0') {
|
||||
this.pageIndex = 0
|
||||
this.qkFlag = false
|
||||
@ -547,7 +531,6 @@ struct UserInfo {
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
|
||||
TopLogo({ outFlag: $outFlag }).margin({ bottom: 10 })
|
||||
Row() {
|
||||
Row() {
|
||||
@ -644,72 +627,54 @@ struct UserInfo {
|
||||
.onClick(() => {
|
||||
this.qkFlag = true
|
||||
})
|
||||
|
||||
if( this.isBoardPrePareSetPopupOpen && !this.isFirstBoardPrePareSetPopupBtnShow){
|
||||
//上车准备
|
||||
Image($r('app.media.sczb_btn')).commStyle().onClick(()=>{
|
||||
this.isBoardPrePareSetPopupShow = true;
|
||||
this.isFirstBoardPrePareSetPopupBtnShow = 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()
|
||||
}
|
||||
})
|
||||
}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()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -754,19 +719,6 @@ 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%')
|
||||
|
||||
@ -172,7 +172,7 @@ export default struct FaceCompare {
|
||||
carNo: globalThis.carInfo.carNo,
|
||||
placeId: globalThis.carInfo.examinationRoomId
|
||||
}
|
||||
globalThis.udpClient2.sendMsg(param, this.context)
|
||||
globalThis.udpClient2.sendMsgExt(param, this.context)
|
||||
}
|
||||
|
||||
async faceComparFn() {
|
||||
@ -229,7 +229,7 @@ export default struct FaceCompare {
|
||||
this.callBackFlag = true
|
||||
}
|
||||
}
|
||||
globalThis.udpClient2 && globalThis.udpClient2.sendMsg(param, this.context)
|
||||
globalThis.udpClient2 && globalThis.udpClient2.sendMsgExt(param, this.context)
|
||||
clearInterval(this.interval)
|
||||
this.interval = setInterval(() => {
|
||||
if (this.callBackFlag) {
|
||||
@ -239,7 +239,7 @@ export default struct FaceCompare {
|
||||
carNo: globalThis.carInfo.carNo,
|
||||
placeId: globalThis.carInfo.examinationRoomId,
|
||||
}
|
||||
globalThis.udpClient2 && globalThis.udpClient2.sendMsg(param2, this.context)
|
||||
globalThis.udpClient2 && globalThis.udpClient2.sendMsgExt(param2, this.context)
|
||||
}
|
||||
}, 1000)
|
||||
globalThis.udpClient2.setMsgCallBack((val) => {
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import router from '@ohos.router';
|
||||
import UdpClient from '../../common/utils/UdpClient';
|
||||
import FileLog from '../judgeSDK/utils/fileLog';
|
||||
import FileLog from '../judgeSDK/utils/file-log';
|
||||
import RealTime from '../compontents/judge/RealTime';
|
||||
import { GPSData, SignalData } from '../../mock';
|
||||
import { SignalDataType } from '../../model';
|
||||
@ -21,7 +20,6 @@ export default struct SignDisplayCom {
|
||||
@State @Watch('outClick') outFlag: boolean = false;
|
||||
@State url: string = ''
|
||||
private timer = null
|
||||
private udpClient: UdpClient = null
|
||||
private FileLog: FileLog
|
||||
private vocObj = null;
|
||||
|
||||
@ -308,13 +306,15 @@ export default struct SignDisplayCom {
|
||||
|
||||
|
||||
if (showBack) {
|
||||
globalThis.udpClient.onMessage((msg) => {
|
||||
this.ratio=1.2
|
||||
globalThis.udpClient&&globalThis.udpClient.onMessage_1((msg) => {
|
||||
console.log('msgmsg', msg)
|
||||
if (msg) {
|
||||
getSignal(msg)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.ratio=1
|
||||
clearInterval(globalThis.signalTimer)
|
||||
globalThis.signalTimer = setInterval(() => {
|
||||
const msgStr = globalThis.msgStr
|
||||
@ -333,7 +333,7 @@ export default struct SignDisplayCom {
|
||||
const that = this
|
||||
const showBack = this.showBack;
|
||||
if (showBack) {
|
||||
globalThis.udpClient.onMessage((msg) => {
|
||||
globalThis.udpClient.onMessage_1((msg) => {
|
||||
getSignal(msg)
|
||||
})
|
||||
} else {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import apiJudgeSdk from 'libJudgeSdk.so';
|
||||
import Judge from '../../judgeSDK/utils/judgeReal';
|
||||
import Judge from '../../judgeSDK/utils/judge-real';
|
||||
import { MarkRule, Project, ProjectObj } from '../../judgeSDK/api/judgeSDK.d';
|
||||
import common from '@ohos.app.ability.common';
|
||||
|
||||
|
||||
@ -131,7 +131,6 @@ export function handleLog(level,infoStr, len){
|
||||
*
|
||||
*/
|
||||
export async function examJudgeEndExam(){
|
||||
console.info('surenjun','考试结束调用')
|
||||
const temp = libJudgeSdk.examJudgeEndExam();
|
||||
return await handle(temp,'examJudgeEndExam')
|
||||
}
|
||||
@ -171,26 +170,6 @@ 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通用处理函数
|
||||
*
|
||||
|
||||
@ -16,8 +16,7 @@ export interface MarkRule{
|
||||
itemno?:number
|
||||
markcatalog?:string
|
||||
markshow?:string
|
||||
markserial?:string
|
||||
markstandard?:number,
|
||||
markserial?:number
|
||||
markreal?:number
|
||||
kfxh?:string
|
||||
onlyoneid?:number
|
||||
@ -119,8 +118,7 @@ export interface EXAMDATA{
|
||||
sound:{
|
||||
xmdm:number,
|
||||
//语音播放文件代码
|
||||
code:string,
|
||||
type:number
|
||||
code:string
|
||||
},
|
||||
//模拟灯光
|
||||
mndg:string
|
||||
@ -140,9 +138,7 @@ export interface SOUND {
|
||||
//项目代码
|
||||
xmdm:number
|
||||
//语音播放提示代码
|
||||
code:string,
|
||||
//0:普通,1:模拟灯光
|
||||
type:number
|
||||
code:string
|
||||
}
|
||||
export interface SYSSET {
|
||||
v_no:string,
|
||||
@ -151,7 +147,7 @@ export interface SYSSET {
|
||||
}
|
||||
|
||||
export interface ProjectObj {
|
||||
[k:string]:Project
|
||||
[k:any]:Project
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,16 +2,19 @@ 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/voiceAnnouncements';
|
||||
import FileModel from './utils/fileModel';
|
||||
import FilePhoto from './utils/filePhoto';
|
||||
import FileUtil from '../../common/utils/File';
|
||||
import FileLog from './utils/fileLog';
|
||||
|
||||
import JudgeTask from './utils/judgeTask';
|
||||
import { judgeConfig } from './utils/judgeConfig';
|
||||
import VoiceAnnounce from './utils/voice-announcements';
|
||||
import FileModel from './utils/file-model';
|
||||
import FilePhoto from './utils/file-photo';
|
||||
import FileUtil from '../../common/utils/File';
|
||||
import FileLog from '../judgeSDK/utils/file-log';
|
||||
|
||||
import JudgeTask from './utils/judge-task';
|
||||
import SimulateLights from './utils/simulate-lights';
|
||||
import { judgeConfig } from './utils/judge-config';
|
||||
|
||||
import { uploadExamProgressData, writeObjectOut } from '../../api/judge';
|
||||
import {
|
||||
@ -33,33 +36,35 @@ import {
|
||||
plcStrToWXJson,
|
||||
promptWxCode,
|
||||
senorToWXDataStr
|
||||
} from './utils/judgeCommon';
|
||||
} from './utils/judge-common';
|
||||
import {
|
||||
examJudgeArtificialItem,
|
||||
examJudgeArtificialMark,
|
||||
examJudgeBeginExam,
|
||||
examJudgeEndExam,
|
||||
examJudgeInit,
|
||||
examJudgeSoundEnd,
|
||||
examJudgeMapSetParam,
|
||||
examJudgeMapSetScaling,
|
||||
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);
|
||||
//文件工具
|
||||
@ -128,7 +133,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)
|
||||
@ -136,7 +141,6 @@ export default class Judge {
|
||||
globalThis.isJudgeInitBool = true
|
||||
console.info(judgeTag, '4.评判初始化完成')
|
||||
} else {
|
||||
await fileLog.setExamJudgeData(initInfo)
|
||||
}
|
||||
|
||||
globalThis.isJudge = true
|
||||
@ -153,19 +157,24 @@ 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')
|
||||
|
||||
console.info(judgeTag, '6.开始考试注册完成')
|
||||
|
||||
avPlayer.playAudio(['voice/ksks.WAV'])
|
||||
|
||||
await examJudgeMapSetParam(640, 480); //设置参数宽、高
|
||||
await examJudgeMapSetScaling(120); //设置缩放比例,一般默认填100(就是100%的意思) ,数字越大视野越大,数字越小视野越小,不能为0
|
||||
|
||||
this.judgeUI.draw = true
|
||||
|
||||
// 处理轨迹plc信息
|
||||
@ -176,117 +185,13 @@ export default class Judge {
|
||||
|
||||
|
||||
// 处理实时udp里的plc信号
|
||||
globalThis.udpClient.onMessage(async (msg) => {
|
||||
globalThis.udpClient.onMessage_1(async (msg) => {
|
||||
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;
|
||||
@ -427,28 +332,28 @@ export default class Judge {
|
||||
fileLog.setExamJudgeWuxiData(data)
|
||||
console.info(judgeTag, '上传照片 end')
|
||||
}
|
||||
|
||||
// 评判语音提示
|
||||
goJudgeVoice = async (sound: SOUND) => {
|
||||
const {avPlayer,fileLog} = this;
|
||||
const {xmdm,code,type} = sound;
|
||||
const {avPlayer} = this;
|
||||
const {xmdm,code} = sound;
|
||||
//判断是不是模拟灯光语音
|
||||
console.info(judgeTag,JSON.stringify(sound))
|
||||
if(type == 1){
|
||||
const isLight = code.slice(0, 3) === '417';
|
||||
if (isLight) {
|
||||
console.info(judgeTag, '模拟灯光开始播放:' + code)
|
||||
}
|
||||
avPlayer.playAudio([`voice/${code}.mp3`], true, () => {
|
||||
if (type == 1) {
|
||||
if (isLight) {
|
||||
console.info(judgeTag, '播放结束:' + code)
|
||||
examJudgeSoundEnd({itemno:xmdm,code,type})
|
||||
fileLog.setExamJudgeData({
|
||||
method: 'examJudgeSoundEnd',
|
||||
itemno: xmdm,
|
||||
code,
|
||||
type,
|
||||
setTimeout(() => {
|
||||
this.wav = 1;
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 处理考试结束
|
||||
public handEndExam = async (isManual?: Boolean) => {
|
||||
const {isExam,judgeUI,endExam,handleSEP,avPlayer} = this;
|
||||
@ -481,6 +386,26 @@ 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;
|
||||
@ -530,23 +455,55 @@ export default class Judge {
|
||||
}, 3000)
|
||||
|
||||
}
|
||||
// 当前项目转换
|
||||
getDqxmStr = (type) => {
|
||||
const projectsObj = this.judgeUI.projectsObj
|
||||
return projectsObj[type]?.abbreviation || '通用评判'
|
||||
}
|
||||
// 扣分项目转换
|
||||
getKfStr = (code) => {
|
||||
const markRuleListObj = this.judgeUI.markRuleListObj;
|
||||
const thisMark = markRuleListObj[code]
|
||||
|
||||
// 获取评判初始化数据
|
||||
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 {
|
||||
desc: thisMark.markshow,
|
||||
score: thisMark.markreal,
|
||||
markcatalog: thisMark.markcatalog,
|
||||
markserial: thisMark.markserial,
|
||||
kfxh: thisMark.kfxh
|
||||
...initInfo,
|
||||
...km3Config,
|
||||
}
|
||||
}
|
||||
|
||||
// 消息心跳发送
|
||||
getMessageHeartbeat = async (isEnd?: Boolean) => {
|
||||
const carInfo = globalThis.carInfo;
|
||||
@ -646,6 +603,66 @@ 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;
|
||||
@ -660,6 +677,7 @@ export default class Judge {
|
||||
const sbxh = currentCdsb.sbbh || '00000000'
|
||||
return sbxh
|
||||
}
|
||||
|
||||
getSbbm = (ksxm, xmxh) => {
|
||||
const {judgeUI} = this;
|
||||
const {cdsbInfoObj,projectsObj} = judgeUI;
|
||||
@ -672,6 +690,7 @@ export default class Judge {
|
||||
const sbxh = currentCdsb.sbbm || '00000000'
|
||||
return sbxh
|
||||
}
|
||||
|
||||
// 中心所有项目转换
|
||||
getTranslateProject = () => {
|
||||
// const {testKmItems} = this;
|
||||
@ -694,11 +713,13 @@ 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
|
||||
@ -729,6 +750,7 @@ export default class Judge {
|
||||
itemno: itemno * 1,
|
||||
type: 1
|
||||
})
|
||||
|
||||
console.info(judgeTag, `人工评判进入项目-${itemno}`)
|
||||
|
||||
}
|
||||
@ -848,6 +870,8 @@ export default class Judge {
|
||||
|
||||
}
|
||||
}
|
||||
public plcStr: string
|
||||
private judgeUI
|
||||
// 更改考试状态
|
||||
goVoiceAnnounce = async (event, xmdm, kf, xmjs) => {
|
||||
const {projectsObj,judgeConfigObj} = this.judgeUI;
|
||||
@ -913,14 +937,17 @@ export default class Judge {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// 获取plc数据
|
||||
getPlcData = async (plc: string) => {
|
||||
const {fileLog,mndgStr,rmndg} = this;
|
||||
const {fileLog,mndgStr,rmndg,wav} = this;
|
||||
await fileLog.setPlcProgressData(plc)
|
||||
//plc字符串转化成评判初始化数据
|
||||
const tempData = await plcStrToJson(plc);
|
||||
//模拟灯光回放时刻
|
||||
tempData.sensor.rmndg = rmndg;
|
||||
//模拟灯光单个灯光结束时刻
|
||||
tempData.sensor.wav = wav;
|
||||
//模拟灯灯光灯光项目
|
||||
tempData.sensor.mndg = mndgStr;
|
||||
//plc字符串转化成无锡所过程数据
|
||||
@ -931,6 +958,7 @@ export default class Judge {
|
||||
this.plcStr = plc;
|
||||
this.mndgStr = '';
|
||||
this.rmndg = 0;
|
||||
this.wav = 0;
|
||||
globalThis.msgStr = plc
|
||||
|
||||
return tempData
|
||||
@ -938,6 +966,7 @@ export default class Judge {
|
||||
// 处理轨迹plc信号
|
||||
handleTrajectoryUdp = async (strArr) => {
|
||||
const {fileLog} = this;
|
||||
console.log('kkkkk')
|
||||
let num = 2;
|
||||
const {usbService} = this;
|
||||
const judgeTimer = setInterval(async () => {
|
||||
@ -1065,8 +1094,7 @@ export default class Judge {
|
||||
judgeUI.projectsObj = deepClone(copyProjectsObj)
|
||||
}
|
||||
}
|
||||
public plcStr: string
|
||||
private judgeUI
|
||||
|
||||
private fileLog
|
||||
private totalScore: number
|
||||
private folderPath: string
|
||||
@ -1074,6 +1102,7 @@ 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) => {
|
||||
|
||||
@ -3,7 +3,6 @@ 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,10 +32,5 @@ export default class FilePhoto{
|
||||
}
|
||||
|
||||
public async getPhoto(){
|
||||
const {params,context,fileUtil} = this;
|
||||
return new Promise(async (reslove)=>{
|
||||
const data=await takePhoto(params,context,'jt/',1)
|
||||
reslove(data.base64)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -35,6 +35,7 @@ workerPort.onmessage = (e: MessageEvents): void => {
|
||||
workerPort.postMessage({ isComplete: true });
|
||||
}else{
|
||||
workerPort.postMessage({ isComplete: false });
|
||||
|
||||
}
|
||||
})
|
||||
}else if(param.mode=='3'){
|
||||
@ -42,6 +43,10 @@ workerPort.onmessage = (e: MessageEvents): void => {
|
||||
getDoubleCeneterTable(param).then((ret)=>{
|
||||
if (ret) {
|
||||
workerPort.postMessage({ isComplete: true });
|
||||
|
||||
}else{
|
||||
workerPort.postMessage({ isComplete: false });
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user