This commit is contained in:
wangzhongjie 2024-02-23 10:10:38 +08:00
parent 38d48e778b
commit a1ff0e8d2c

View File

@ -4,7 +4,7 @@ import TopLogo from './compontents/topLogo'
import Md5 from '../common/utils/md5';
import AccountTable from '../common/database/tables/AccountTable';
import USER from '../common/constants/USER';
import { dateFormat,getCurrentTime } from '../common/utils/tools';
import { dateFormat, getCurrentTime } from '../common/utils/tools';
import MA_SYSSET from '../common//constants/MA_SYSSET';
import FaceCompare from './compontents/faceCompareByhaikang'
import { initJudgeUdp } from '../common/utils/UdpJudge'
@ -38,7 +38,6 @@ struct UserInfo {
@State dataList: Array<User> = []
@State list: Array<User> = []
@State param: VideoConfig = {
videoNum:'1',
spls: '',
faceFlag: false,
pztd: '2',
@ -55,16 +54,14 @@ struct UserInfo {
videoRecord2: false,
videoRecord3: false,
videoRecord4: false,
rlls:'1'
rlls: '1'
}
private AccountTable = new AccountTable(() => {
}, USER);
private context = getContext(this) as common.UIAbilityContext;
@State name: string = 'initName';
@State sex: string = '';
@State callBackFlag:boolean=false;
@State callBackFlag: boolean = false;
@State born?: string = '';
@State address: string = '';
@State nation: string = '';
@ -73,22 +70,18 @@ struct UserInfo {
@State effectDate: string = '';
@State interval: any = null;
@State interval2: any = null;
@State interval3: any = null;
@State studentRefreshStatue: string = '0';
@State photo: string = 'data:image/bmp;base64,';
@State numCount: number = 0;
@State signNum: number = 0;
@State isCanClick: boolean = true;
subscriber;
@State faceCatchImg:string=''
@State faceCatchImg: string = ''
onPageShow() {
//打开读卡器
this.openChuankouDeviceFn()
//语音功能
this.stepFlag=false
this.initData()
this.initSysset()
initJudgeUdp()
this.stepFlag = false
new WebRTCVoice(this.context);
this.faceCompareSucess = 0
this.showFaceCompare = false
@ -127,47 +120,33 @@ struct UserInfo {
this.list = CandidateData
this.pageIndex = 0
this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4)
this.currentUser=this.dataList[0]
this.lsh=this.currentUser.lsh
globalThis.ksyh=this.currentUser.ksy1sfzmhm||this.currentUser.ksy2sfzmhm
globalThis.lsh=this.lsh
this.currentUser = this.dataList[0]
this.lsh = this.currentUser.lsh
globalThis.ksyh = this.currentUser.ksy1sfzmhm || this.currentUser.ksy2sfzmhm
globalThis.lsh = this.lsh
return
}else{
} else {
// this.getExaminationStudentInfoFn()
}
this.initSysset()
initJudgeUdp()
}
//初始化reset data
initData(){
this.lsh='0000000000000'
this.faceCompareSucess=0
this.showFaceCompare=false
globalThis.lsh = this.lsh
this.currentUser= {
sfzmhm: '',
xm: '',
lsh: '',
ksy1: '',
id: '',
kszp: '',
ksmjzp: '',
bz1: '',
jxmc: '',
kchp: '',
kscx: '',
ksdd: '',
kssycs: '',
ksxl: '',
ksy1sfzmhm: '',
kszt: '',
xb: '',
xh: '',
xldm: '',
yycs: ''
changeQkfn() {
this.qkFn()
}
getqkFn() {
let tmpList = [];
tmpList.push(this.string2Bytes(globalThis.signNum, 1 * 8)[0])
const param = {
id: 41,
list: tmpList,
carNo: globalThis.carInfo.carNo,
placeId: globalThis.carInfo.examinationRoomId
}
globalThis.statue=2
this.numCount=0
this.callBackFlag=false
globalThis.udpClient2.sendMsg(param, this.context)
}
async heartMsg(context) {
@ -232,12 +211,12 @@ struct UserInfo {
this.sfbdinterfaceFn()
}
}
//读卡器阅读
onReadCard(ret) {
console.info(`zzctest xx Read Card ret =${ret.status}`)
let thisVar = globalThis.indexComponent;
if(ret.status == 0) { // status = 1 为读到身份证信息; status = 1 为身份证离开读卡器
if (ret.status == 0) { // status = 1 为读到身份证信息; status = 1 为身份证离开读卡器
// 收到身份证离开读卡器的事件通知,根据实际业务需要决定是否需要清空之前已读取的身份证信息。
// 如果身份证卡片离开读卡器时需要继续保留UI界面上已读取到的身份信息以下代码可以注释掉。
thisVar.name = "";
@ -264,9 +243,9 @@ struct UserInfo {
thisVar.born = baseInfos[3];
thisVar.address = baseInfos[4];
thisVar.idCard = baseInfos[5];
setTimeout(()=>{
setTimeout(() => {
thisVar.getCurrentStudent(baseInfos[5])
},1000)
}, 1000)
}
// 身份证照片数据处理
@ -274,7 +253,7 @@ struct UserInfo {
let dataView = new DataView(ret.photo)
console.info(`Read Card ret = length = ${dataView.byteLength}`)
let str = ""
for (let i = 0;i < dataView.byteLength; ++i) {
for (let i = 0; i < dataView.byteLength; ++i) {
let c = String.fromCharCode(dataView.getUint8(i))
if (c !== "\n") {
str += c
@ -346,27 +325,27 @@ struct UserInfo {
getCurrentStudent(id) {
let flag = false
this.pageIndex
this.list.map((res,index)=>{
if(res.sfzmhm==id){
flag=true
this.currentUser=res
this.lsh=this.currentUser.lsh
globalThis.lsh=this.currentUser.lsh
globalThis.ksyh=this.currentUser.ksy1sfzmhm||this.currentUser.ksy2sfzmhm
this.list.map((res, index) => {
if (res.sfzmhm == id) {
flag = true
this.currentUser = res
this.lsh = this.currentUser.lsh
globalThis.lsh = this.currentUser.lsh
globalThis.ksyh = this.currentUser.ksy1sfzmhm || this.currentUser.ksy2sfzmhm
// this.currentUser.kszp=this.photo+res.kszp
// this.currentUser.ksmjzp=this.photo+this.currentUser.ksmjzp
if(globalThis.singlePlay){
if (globalThis.singlePlay) {
testNapi.StopReadCard();
// globalThis.statue=4
router.pushUrl({
url: 'pages/Judge',
},router.RouterMode.Single);
}, router.RouterMode.Single);
return
}
this.showFaceCompare=true
this.pageIndex=Math.floor(index/4)
this.showFaceCompare = true
this.pageIndex = Math.floor(index / 4)
}
})
this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4)
@ -440,11 +419,6 @@ struct UserInfo {
const zeroStr = '0'.repeat(num);
return zeroStr + str;
}
//考点端查询缺考指令内容消息请求
getqkFn(){
let tmpList = [];
tmpList.push(string2Bytes(globalThis.signNum, 1 * 8)[0])
const param= {id: 41,list:tmpList,carNo: globalThis.carInfo.carNo,placeId: globalThis.carInfo.examinationRoomId}
string2Bytes(number, len) {
const str = (+number).toString(2);
@ -460,7 +434,24 @@ struct UserInfo {
});
return arrBytes;
}
//车载端学员缺考
getPhotosForOtherFn(data, type) {
const date = new Date()
const param = {
time: dateFormat(date),
ksrq: dateFormat(date).split(' ')[0],
sfzmhm: data.sfzmhm,
zptype: type
}
getPhotosForOther(param).then(res => {
if (type == '1') {
this.currentUser.kszp = 'data:image/jpg;base64,' + res.getBmzpRsp.body.kszp
} else {
this.currentUser.ksmjzp = 'data:image/jpg;base64,' + res.getBmzpRsp.body.ksmjzp
}
})
}
qkFn() {
this.faceCompareSucess = 0
if (globalThis.singlePlay) {
@ -469,10 +460,10 @@ struct UserInfo {
}
console.log('JsonJson', JSON.stringify(this.currentUser))
const param = `<?xml version="1.0" encoding="UTF-8" ?><examinationStuAbsentReq><body><carId>${globalThis.carInfo.carId}</carId><cardNo>${this.currentUser.sfzmhm}</cardNo><examinationRoomId>${globalThis.carInfo.examinationRoomId}</examinationRoomId><examinerName>${globalThis.username}</examinerName><lsh>${this.lsh}</lsh></body></examinationStuAbsentReq>`
console.log('carNo1111',param)
console.log('carNo1111', param)
examinationStuAbsent(param).then(res => {
const arr = [this.signNum||0,1]
const arr = [this.signNum || 0, 1]
let tmpList = [];
tmpList.push(this.string2Bytes(arr[0], 1 * 8)[0])
tmpList.push(this.string2Bytes(arr[1], 1 * 8)[0])
@ -485,7 +476,7 @@ struct UserInfo {
}
globalThis.udpClient2.sendMsg(param, this.context)
if (res.examinationStuAbsentRsp.head.resultCode=='0') {
if (res.examinationStuAbsentRsp.head.resultCode == '0') {
this.pageIndex = 0
this.qkFlag = false
this.currentUser = EmptyCandidateObject
@ -497,164 +488,27 @@ struct UserInfo {
})
}
async heartMsg(context) {
let tmpList=[]
const str =globalThis.lsh
for (let i = 0;i < str.length; i++) {
tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0])
}
outClick() {
testNapi.StopReadCard();
}
facePass(){
if(!this.stepFlag){
this.sfbdinterfaceFn()
}
}
changefaceCompareSucess() {
if(this.faceCompareSucess>0){
this.sfbdinterfaceFn()
}
}
nextClick() {
if (this.list.length <= 4||this.pageIndex==Math.floor(this.list.length/4)) {
return
}
this.pageIndex++;
this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4)
}
prevClick() {
if (this.list.length <= 4||this.pageIndex==0) {
return
}
this.pageIndex--;
this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4)
}
//获取下载学员接口
getExaminationStudentInfoFn() {
if(globalThis.singlePlay){
return
}
const param = `<getExaminationStudentInfoReq><head><checkCode>${Md5.Instance.get_md5(globalThis.carInfo.carId + globalThis.carInfo.examinationRoomId + globalThis.username)}</checkCode></head><body><carId>${globalThis.carInfo.carId}</carId><examinationRoomId>${globalThis.carInfo.examinationRoomId}</examinationRoomId><examinerName>${globalThis.username}</examinerName></body></getExaminationStudentInfoReq>`
getExaminationStudentInfo(param).then(res => {
if (!res) {
this.dataList=[]
this.currentUser={
sfzmhm: '',
xm: '',
lsh: '',
ksy1: '',
id: '',
kszp: '',
ksmjzp: '',
bz1: '',
jxmc: '',
kchp: '',
kscx: '',
ksdd: '',
kssycs: '',
ksxl: '',
ksy1sfzmhm: '',
kszt: '',
xb: '',
xh: '',
xldm: '',
yycs: ''
}
console.log('currentUser',JSON.stringify(this.currentUser))
this.errorMsg = decodeURI(res.getExaminationStudentInfoRsp.head.resultMessage)
return
}
let dataList = []
this.list=[]
for (let key in res.getExaminationStudentInfoRsp.body) {
const a = res.getExaminationStudentInfoRsp.body[key]
if(a instanceof Array){
dataList=a
}else{
dataList=[a]
}
}
if(dataList.length){
this.numCount=0
}
this.list=JSON.parse(JSON.stringify(dataList))
if (dataList.length > 4) {
dataList = dataList.slice(this.pageIndex * 4, this.pageIndex * 4 + 4)
} else {
dataList = dataList
}
dataList.forEach(listData=>{
for(let i in listData){
listData[i]= decodeURI(listData[i])
}
listData.kszp=this.photo+listData.kszp
listData.ksmjzp=this.photo+listData.ksmjzp
})
this.dataList = dataList
if(this.dataList.length){
this.currentUser = this.dataList[0]
}else{
this.currentUser={
sfzmhm: '',
xm: '',
lsh: '',
ksy1: '',
id: '',
kszp: '',
ksmjzp: '',
bz1: '',
jxmc: '',
kchp: '',
kscx: '',
ksdd: '',
kssycs: '',
ksxl: '',
ksy1sfzmhm: '',
kszt: '',
xb: '',
xh: '',
xldm: '',
yycs: ''
}
}
this.lsh=this.currentUser.lsh
globalThis.lsh=this.lsh
globalThis.ksyh=this.currentUser.ksy1sfzmhm||this.currentUser.ksy2sfzmhm
console.log('this.currentUse3' + JSON.stringify(this.currentUser))
this.pageIndex = 0
}).catch((error) => {
console.log('error12error' + error)
})
}
//身份比对
async sfbdinterfaceFn(){
this.stepFlag=true
console.info('surenjun',this.currentUser.lsh)
async sfbdinterfaceFn() {
this.stepFlag = true
console.info('surenjun', this.currentUser.lsh)
const carInfo = globalThis.carInfo;
const {carId,examinationRoomId} = carInfo;
const examItems = await getExaminationItem({
time:getCurrentTime(),
time: getCurrentTime(),
carId,
lsh:this.currentUser.lsh || '',
lsh: this.currentUser.lsh || '',
examinationRoomId
});
//获取已考项目
console.log('goroute')
const date = new Date()
this.showFaceCompare=false
this.showFaceCompare = false
const { examSubject,plateNo } = carInfo;
const drvexam = {
lsh: this.currentUser.lsh || '',
@ -662,7 +516,7 @@ struct UserInfo {
ksxtbh: this.ksxtbh || '222',
sfzmhm: this.currentUser.sfzmhm || '',
ksysfzmhm: this.currentUser.ksy1sfzmhm || '',
zp:encodeURIComponent(this.faceCatchImg ||''),
zp: encodeURIComponent(this.faceCatchImg || ''),
kssj: dateFormat(date) || '',
kchp: decodeURI(plateNo),
Ksy2sfzmhm: this.currentUser.ksy2sfzmhm || ''
@ -688,7 +542,7 @@ struct UserInfo {
this.stepFlag = false
router.pushUrl({
url: 'pages/Judge',
params:{examItems:examItems?.getExaminationItemRsp?.body?.ykxx}
params: { examItems: examItems?.getExaminationItemRsp?.body?.ykxx }
}, router.RouterMode.Single);
testNapi.StopReadCard();
})
@ -699,16 +553,16 @@ struct UserInfo {
this.stepFlag = false
router.pushUrl({
url: 'pages/Judge',
params:{examItems:examItems?.getExaminationItemRsp?.body?.ykxx}
params: { examItems: examItems?.getExaminationItemRsp?.body?.ykxx }
}, router.RouterMode.Single);
globalThis.statue=4
globalThis.statue = 4
testNapi.StopReadCard();
})
})
}
})
}else{
this.stepFlag=false
} else {
this.stepFlag = false
}
}
@ -733,7 +587,7 @@ struct UserInfo {
build() {
Column() {
TopLogo({outFlag:$outFlag}).margin({ bottom: 10 })
TopLogo({ outFlag: $outFlag }).margin({ bottom: 10 })
Row() {
Row() {
ForEach(this.dataList, (item) => {
@ -753,7 +607,7 @@ struct UserInfo {
}
.width(165 * this.ratio)
.height(85 * this.ratio)
.backgroundImage(item.sfzmhm != this.currentUser.sfzmhm? $r('app.media.userbox2') : $r('app.media.userboxbg'))
.backgroundImage(item.sfzmhm != this.currentUser.sfzmhm ? $r('app.media.userbox2') : $r('app.media.userboxbg'))
.backgroundImageSize({ width: '100%', height: '100%' })
.onClick(() => {
this.currentUser = item
@ -764,7 +618,7 @@ struct UserInfo {
Image($r('app.media.dk_prev'))
.width(90 * this.ratio)
.height(70 * this.ratio)
.margin({ left: 65 * this.ratio, right:10 * this.ratio })
.margin({ left: 65 * this.ratio, right: 10 * this.ratio })
.onClick(() => {
this.prevClick()
})
@ -849,12 +703,12 @@ struct UserInfo {
Image($r('app.media.ksks_btn'))
.commStyle()
.onClick(() => {
this.faceCompareSucess=0
globalThis.statue=2
if(!this.currentUser.xm){
this.faceCompareSucess = 0
globalThis.statue = 2
if (!this.currentUser.xm) {
return
}
if(globalThis.singlePlay){
if (globalThis.singlePlay) {
this.AccountTable.query('0', (result) => {
if (result.length == 0) {
this.AccountTable.insertData(this.currentUser, (id) => {
@ -862,7 +716,7 @@ struct UserInfo {
console.log(result)
router.pushUrl({
url: 'pages/Judge',
},router.RouterMode.Single);
}, router.RouterMode.Single);
testNapi.StopReadCard();
})
})
@ -871,7 +725,7 @@ struct UserInfo {
this.AccountTable.query('0', (result) => {
router.pushUrl({
url: 'pages/Judge',
},router.RouterMode.Single);
}, router.RouterMode.Single);
testNapi.StopReadCard();
})
})
@ -883,13 +737,24 @@ struct UserInfo {
})
}
}
if(this.showFaceCompare) {
FaceCompare({ sfzh: this.currentUser.sfzmhm, firstImage:this.currentUser.kszp,faceCompareSucess: $faceCompareSucess,getqkFlag:$getqkFlag,faceCatchImg:$faceCatchImg,lsh:globalThis.lsh })
if (this.showFaceCompare) {
FaceCompare({
showFaceCompare: $showFaceCompare,
sfzh: this.currentUser.sfzmhm,
firstImage: this.currentUser.kszp,
faceCompareSucess: $faceCompareSucess,
getqkFlag: $getqkFlag,
faceCatchImg: $faceCatchImg,
lsh: globalThis.lsh
})
}
if(this.qkFlag){
Column(){
Text('确认考生:'+this.currentUser.xm+'是否缺考').fontSize(28*this.ratio).position({x:160*this.ratio,y:122*this.ratio})
Row(){
if (this.qkFlag) {
Column() {
Text('确认考生:' + this.currentUser.xm + '是否缺考')
.fontSize(28 * this.ratio)
.position({ x: 160 * this.ratio, y: 122 * this.ratio })
Row() {
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Text(' 取 消 ').fontSize(24 * this.ratio).fontColor('#fff').width(100 * this.ratio)
}
@ -897,6 +762,7 @@ struct UserInfo {
.onClick(() => {
this.qkFlag = false
})
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Text(' 确 定 ').fontSize(24 * this.ratio).fontColor('#fff').width(100 * this.ratio)
}
@ -904,16 +770,15 @@ struct UserInfo {
.onClick(() => {
this.qkFn()
})
}.position({y:265*this.ratio,x:115*this.ratio})
}.position({ y: 265 * this.ratio, x: 115 * this.ratio })
}.width(660 * this.ratio)
}
.width(660 * this.ratio)
.height(360 * this.ratio)
.position({ x: 150 * this.ratio, y: 98 * this.ratio })
.backgroundColor('#E6E3DF')
.borderRadius(19 * this.ratio)
}
}
.height('100%')
.width('100%')