475 lines
17 KiB
Plaintext
Raw Normal View History

2024-01-05 11:11:15 +08:00
import router from '@ohos.router'
2024-02-21 14:53:53 +08:00
import prompt from '@ohos.prompt'
import common from '@ohos.app.ability.common';
2024-01-05 11:11:15 +08:00
import EndPoPup from './compontents/judge/end-popup'
import LoadingPopup from './compontents/judge/loading-popup'
2024-02-21 14:53:53 +08:00
2024-01-05 11:11:15 +08:00
import Judge from './judgeSDK/judge'
2024-02-21 14:53:53 +08:00
import FileLog from './judgeSDK/utils/file-log'
2024-01-05 11:11:15 +08:00
import {Project,ProjectObj,MarkRule,CDSBInfo} from './judgeSDK/api/judgeSDK.d'
2024-02-21 14:53:53 +08:00
import AccountTable from '../common/database/tables/AccountTable';
2024-01-05 11:11:15 +08:00
import MA_SYSTEMPARM from '../common/constants/MA_SYSTEMPARM';
2024-01-31 14:35:16 +08:00
import MA_SYSSET from '../common/constants/MA_SYSSET';
2024-01-05 11:11:15 +08:00
import MA_CDSBINFO from '../common/constants/MA_CDSBINFO'
2024-01-31 14:35:16 +08:00
import ES_CARINFO from '../common/constants/ES_CARINFO'
2024-02-21 14:53:53 +08:00
import {getCurrentTime,formatTime,chunkArr,getCurrentHourTime} from '../common/utils/tools'
2024-01-05 11:11:15 +08:00
import {
2024-02-21 14:53:53 +08:00
examJudgeEndExam
2024-01-05 11:11:15 +08:00
} from './judgeSDK/api/index'
import { getSyncData } from '../common/service/initable'
2024-01-31 14:35:16 +08:00
import SignDisplayCom from './compontents/signDisplayCom'
2024-02-21 14:53:53 +08:00
2024-01-05 11:11:15 +08:00
interface JudgeData{
xmmcStr:string,
carztStr:string,
kfArr:{xmmcStr:string,desc}[]
}
2024-01-31 14:35:16 +08:00
2024-01-05 11:11:15 +08:00
let LOGTAG = 'LOGTAG'
@Entry
@Component
struct Index {
scroller: Scroller = new Scroller()
private context = getContext(this) as common.UIAbilityContext;
private img:ImageBitmap = new ImageBitmap("/resources/base/media/1.png")
async aboutToAppear(){
2024-01-31 14:35:16 +08:00
// globalThis.windowClass.setWindowSystemBarEnable([''])
2024-01-05 11:11:15 +08:00
const time = await getCurrentTime()
this.startTime = time.split(' ')[1]
this.startFullTime = await getCurrentTime(1);
this.startHourTime = await getCurrentHourTime()
setInterval(async()=>{
this.time = await getCurrentTime();
this.examTime += 1;
},1000);
await this.initStudent();
2024-01-31 14:35:16 +08:00
await this.initCar();
await this.initSystemParam();
2024-01-05 11:11:15 +08:00
await this.initMarkRules();
2024-01-31 14:35:16 +08:00
await this.initSysset();
2024-01-05 11:11:15 +08:00
await this.initCDSBInfo()
2024-01-31 14:35:16 +08:00
2024-01-05 11:11:15 +08:00
const {name,idCard,lsh,kszp} = this;
const fileLog = new FileLog(this.context);
const filePath = await fileLog.initFileLogo({
name,lsh,idCard
});
2024-01-31 14:35:16 +08:00
//断点续考
await this.goDdxkItems()
2024-01-31 14:42:14 +08:00
//初始化评判
2024-01-05 11:11:15 +08:00
const judge = await this.initJudge(fileLog);
this.judge = judge
}
2024-01-31 14:35:16 +08:00
//查询考车信息
async initCar(){
2024-02-21 14:53:53 +08:00
const db = new AccountTable(()=>{},ES_CARINFO)
2024-01-31 14:35:16 +08:00
const result = await getSyncData('ES_CARINFO')
const carInfo = result[0] || {};
2024-02-21 14:53:53 +08:00
this.carName = decodeURI(carInfo.carclass)
this.carType = carInfo.kscx
2024-01-05 11:11:15 +08:00
}
2024-01-31 14:35:16 +08:00
//获取考生信息
async initStudent(){
const students = await getSyncData('USER')
const stuInfo = students[0] || {};
const {xm,sfzmhm,lsh,kszp,ksdd,kssycs,kslx} = stuInfo;
this.name = xm;
this.idCard = sfzmhm;
this.lsh = lsh;
this.kszp = kszp;
this.ksdd = ksdd;
this.kssycs = kssycs;
this.kslx = kslx;
2024-01-05 11:11:15 +08:00
}
//获取扣分代码信息
async initMarkRules(){
const markRuleParams = await getSyncData('MA_MARKRULE')
//@ts-ignore
markRuleParams.forEach(mark=>{
2024-01-31 14:35:16 +08:00
this.markRuleListObj[`${mark.itemno}_${mark.markserial}`] = {
2024-01-05 11:11:15 +08:00
itemno:mark.itemno*1,
markcatalog:mark.markcatalog,
markshow:decodeURI(mark.markshow),
markreal:mark.markreal*1,
markserial:mark.markserial,
kfxh:mark.kfxh
};
})
}
// 获取sysset表信息
async initSysset(){
const db = new AccountTable(()=>{},MA_SYSSET);
const syssetParams = await getSyncData('MA_SYSSET')
//@ts-ignore
const serialNumberArr = syssetParams.filter(sys => sys.v_no === '901');
2024-01-31 14:35:16 +08:00
this.serialNumber = (serialNumberArr[0] && serialNumberArr[0].v_value) || '123456'
2024-01-31 14:42:14 +08:00
//TODO 杭州用到的特殊评判参数 211603660671
2024-01-31 14:35:16 +08:00
const judgeNumbers = ['211','603','660','671','606'];
const judgeConfig = []
2024-01-31 14:42:14 +08:00
2024-01-31 14:35:16 +08:00
//@ts-ignore
syssetParams.forEach((sys)=>{
if(judgeNumbers.includes(sys.v_no)){
judgeConfig.push({
key:sys.v_no*1,
value:decodeURIComponent(sys.v_value),
name:decodeURI(sys.v_name)
})
}
});
this.judgeConfig = judgeConfig;
}
//初始化systemParam表
async initSystemParam(){
const db = new AccountTable(()=>{},MA_SYSTEMPARM);
const systemParms:any = await getSyncData('MA_SYSTEMPARM')
const carName = this.carName;
let carNo2 = '',allItems = [];
systemParms.forEach((systemParm)=>{
const {no1,no2,no3} = systemParm;
//获取当前考车的no2
if(no1 == 3 && no3 == 1){
const txt1 = decodeURI(systemParm.txt1)
if(txt1 === carName){
carNo2 = no2;
}
}
//获取当前考车的考试项目
if(carNo2 !== '' && no2 == carNo2 && no3 == 10){
allItems = decodeURIComponent(systemParm.txt1).split(',')
}
// 存储当前考车考试项目
if(allItems.length && no1 == 6 && allItems.includes(no2)){
const txt2 = decodeURIComponent(systemParm.txt2)
const currentProject = {
name:decodeURI(systemParm.txt1),
abbreviation:decodeURI(systemParm.txt3),
projectCode:no2,
projectCodeCenter:txt2
// sbxh:project.type
}
this.projectsObj[no2] = currentProject
this.projectsCenterObj[txt2] = currentProject
this.projects.push(currentProject)
}
})
const projects = this.projects;
if(!projects.length){
prompt.showToast({
message: '读取数据库信息失败,请重新考试!',
duration: 8000
});
router.back();
}
2024-01-05 11:11:15 +08:00
}
// 获取场地设备信息
async initCDSBInfo(){
const db = new AccountTable(()=>{},MA_CDSBINFO);
const cdsbParams = await getSyncData('MA_CDSBINFO')
//@ts-ignore
cdsbParams.forEach((cdsb)=>{
const key = decodeURI(cdsb.itemsno);
const newKey = key.split('~').join('_')
2024-01-31 14:35:16 +08:00
this.cdsbInfoObj[newKey] = {
2024-01-05 11:11:15 +08:00
kdid:cdsb.kdid,
sbbh:cdsb.sbbh,
sbbm:cdsb.sbbm,
2024-01-31 14:35:16 +08:00
itemsno:key,
modelKey:newKey,
//@ts-ignore
xmdm:key.split('~')[0] * 1,
xmxh:key.split('~')[1],
2024-01-05 11:11:15 +08:00
}
})
}
// 评判相关初始化
async initJudge(fileLog){
const judge = new Judge(this,fileLog);
await judge.onJudgeFn(async (judgeData)=>{
const {xmmcStr,carztStr,kfArr} = judgeData;
this.xmmcStr = xmmcStr;
this.carztStr = carztStr;
this.kfArr = kfArr;
});
return judge
}
2024-01-31 14:42:14 +08:00
2024-01-31 14:35:16 +08:00
// 断点续考判断
async goDdxkItems(){
//断点续考判断
let currentParams:any = router.getParams();
const examItems:string = currentParams?.examItems;
2024-02-21 14:53:53 +08:00
// 2024-01-03 16:29:26;0;20300,;2,4^2,4;null;
2024-01-31 14:42:14 +08:00
2024-01-31 14:35:16 +08:00
if(examItems !== '' && examItems !== undefined){
const examItemsArrs = examItems.split(';');
const startTime = examItemsArrs[0]
const ddxkKsxmArr = examItemsArrs[2]?.split(',').filter(item => item) || []
const ddxkKfArr = examItemsArrs[3]?.split('^').filter(item => item) || []
if(ddxkKsxmArr?.length){
this.isDdxk = true
ddxkKsxmArr.forEach(xmdm => {
const projectCode = this.projectsCenterObj[xmdm].projectCode
this.projectsObj[projectCode].type = '3'
})
ddxkKfArr.forEach((kf)=>{
const [xmdm,kfdm] = kf.split(',')
const currentKf = this.markRuleListObj[`${xmdm}_${kfdm}`]
const currentProject = this.projectsObj[xmdm]
this.projectsObj[xmdm].type = '4'
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.ddxkKsxmArr = ddxkKsxmArr
this.ddxkKfArr = ddxkKfArr
this.ddxkTime = Date.parse(startTime);
}
}
}
2024-01-05 11:11:15 +08:00
build() {
Column() {
Row() {
Row(){
Image($rawfile('judge/signal_logoS.png')).width(65).height(25)
Text(this.time).fontColor('#CCB48F').fontSize(this.FONTSIZE).padding({left:10,right:5})
Image($rawfile('judge/xh_green.png')).width(25).height(20)
}
Row(){
Text(`当前项目:${this.xmmcStr || '无'} `).fontColor('#E5CCA1').fontSize(this.FONTSIZE)
}
}
.width('100%').height('50').backgroundColor('#001A33').padding({left:15,right:15}).justifyContent(FlexAlign.SpaceBetween).alignItems(VerticalAlign.Center)
Row(){
Row(){
Column(){
Row(){
Column(){
Row(){
Text('考生姓名:').fontColor('#E5CCA1').fontSize(this.FONTSIZE)
Text(this.name).fontColor('#FFF').fontSize(this.FONTSIZE)
}.margin({bottom:10})
Row(){
Text('开始时间:').fontColor('#E5CCA1').fontSize(this.FONTSIZE)
Text(this.startTime).fontColor('#FFF').fontSize(this.FONTSIZE)
}
}.width('45%').alignItems(HorizontalAlign.Start)
Column(){
Row(){
Text('身份证号:').fontColor('#E5CCA1').fontSize(this.FONTSIZE)
Text(this.idCard).fontColor('#FFF').fontSize(this.FONTSIZE)
}.margin({bottom:10})
Row(){
Text('考试用时:').fontColor('#E5CCA1').fontSize(this.FONTSIZE)
Text(formatTime(this.examTime)).fontColor('#FFF').fontSize(this.FONTSIZE)
}
}.alignItems(HorizontalAlign.Start)
}.width('100%')
Column(){
Text(this.carztStr).fontColor('#FFA500').fontSize(this.FONTSIZE)
Row(){
Flex({direction:FlexDirection.Column}){
List({}){
ForEach(this.kfArr,(item)=>{
ListItem(){
Column(){
Row(){
Text(item.xmmcStr).fontSize(this.BIGFONTSIZE).fontColor('#FFF')
Text(`${item.score}分`).fontSize(this.BIGFONTSIZE).fontColor('#FFF')
}.width('100%').backgroundColor('#38260B').justifyContent(FlexAlign.SpaceBetween).padding({top:12,bottom:12,left:8,right:5})
Text(item.desc).fontSize(this.BIGFONTSIZE).fontColor('#E5CBA1').margin({top:10,bottom:8,left:5,right:5})
}.margin({top:10}).alignItems(HorizontalAlign.Start)
}
})
}
}.backgroundImage($rawfile('judge/score_bg.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).width('40%').height('100%').padding({top:18,bottom:15,left:12,right:15})
Flex({wrap:FlexWrap.Wrap,direction:FlexDirection.Row,justifyContent:FlexAlign.SpaceBetween}){
List({}){
ForEach(chunkArr(this.projects,2),(item)=>{
ListItem(){
Row(){
Row(){
//#FF7566 #00FFD5 #E6DECF
// Text(this.projectsObj[item[0].projectCode])
Text(item[0].abbreviation).fontSize(item[0].abbreviation.length > 5?15:22).fontColor(this.getProjectColor(this.projectsObj[item[0].projectCode].type))
}.backgroundImage($rawfile('judge/project_item.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).width('48.5%').height(75).margin({bottom:5}).justifyContent(FlexAlign.Center)
if(item[1]){
Row(){
//#FF7566 #00FFD5 #E6DECF
Text(item[1].abbreviation).fontSize(item[1].abbreviation.length > 5?15:22).fontColor(this.getProjectColor(this.projectsObj[item[1].projectCode].type))
}.backgroundImage($rawfile('judge/project_item.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).width('48.5%').height(75).margin({left:5,bottom:5}).justifyContent(FlexAlign.Center)
}
}
}
});
}
}.backgroundImage($rawfile('judge/project_bg.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).width('57%').height('100%').padding(30).margin({right:10})
}.margin({top:15}).height('80%').justifyContent(FlexAlign.SpaceBetween)
}.width('100%').height('100%').alignItems(HorizontalAlign.Start).margin({top:10})
}.height('100%').alignItems(HorizontalAlign.Start)
}.width('75%').height('100%')
Column(){
Column(){
Row(){
Text(this.totalScore+'').fontColor('#FFEECC').fontSize(30)
Text('分').fontColor('#FFEECC').fontSize(18).padding({top:5})
2024-01-31 14:35:16 +08:00
}.width('85%').height(70).justifyContent(FlexAlign.Center).alignItems(VerticalAlign.Center).border({width:3,color:'#4D4136',radius:15}).onClick(()=>{this.signDisplayComVisible = true})
2024-01-05 11:11:15 +08:00
Row(){
Image(this.kszp).width('85%').height('85%')
}.width('65%').height(150).backgroundImage($rawfile('judge/photo_bg.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).justifyContent(FlexAlign.Center).alignItems(VerticalAlign.Center).margin({top:30})
}
Row(){ }.width('86%').height(65).backgroundImage($rawfile('judge/anniu_nor.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).onClick(()=>{this.endPopupVisible = true})
}.width('25%').height('100%').justifyContent(FlexAlign.SpaceBetween).alignItems(HorizontalAlign.Center).margin({bottom:20})
}.height('90%').justifyContent(FlexAlign.Start).padding({top:20,left:30,bottom:10,right:30})
//结束考试弹窗
if(this.endPopupVisible){
EndPoPup({
title:'确定结束考试吗?',
cancelFn:()=>{
this.endPopupVisible = false;
},
2024-01-31 14:35:16 +08:00
confirmFn:async ()=>{
2024-01-05 11:11:15 +08:00
this.endPopupVisible = false;
2024-01-31 14:35:16 +08:00
this.loadingPopupVisible = true
2024-01-05 11:11:15 +08:00
globalThis.isJudge = false
examJudgeEndExam();
clearInterval(this.timer);
clearInterval(globalThis.judgeTimer)
globalThis.windowClass.setWindowSystemBarEnable(['navigation'])
const judge= this.judge
2024-01-31 14:35:16 +08:00
await judge.endExam(true);
2024-01-05 11:11:15 +08:00
}
})
}
if(this.loadingPopupVisible){
LoadingPopup({
title:'正在生成考试记录,请稍后...',
})
}
2024-01-31 14:35:16 +08:00
if(this.signDisplayComVisible){
Column() {
SignDisplayCom({
showBack:false,
scaleNum:0.95,
msgStr:this.judge.plcStr || ''
}).margin({top:50})
Row(){}
.width(60).height(60).position({x:'80%',y:80}).backgroundImage($rawfile('judge/close.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'33.33%',height:'33.33%'})
.onClick(()=>{this.signDisplayComVisible = false})
}.width('100%').height('100%').position({y:0}).backgroundColor('rgba(0,0,0,0.6)')
}
2024-01-05 11:11:15 +08:00
}
.height('100%').backgroundColor('#000').justifyContent(FlexAlign.Start)
}
getProjectColor(type:string){
switch (type){
case '1': return '#E6DECF';break;
case '2': return '#FFAD33';break;
case '3': return '#00FFD5';break;
case '4': return '#FF7566';break;
default : return '#E6DECF';break;
}
}
2024-01-31 14:35:16 +08:00
//页面通用字体大小
@State FONTSIZE:number = 18
@State BIGFONTSIZE:number = 20
//结束考试弹窗
@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 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:any = []
//流水号
@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 judge:any = {}
//已考的考试项目
private wantInfos = []
2024-01-05 11:11:15 +08:00
}