forked from harmony_car/subject-two
475 lines
17 KiB
Plaintext
475 lines
17 KiB
Plaintext
import router from '@ohos.router'
|
||
import prompt from '@ohos.prompt'
|
||
import common from '@ohos.app.ability.common';
|
||
|
||
import EndPoPup from './compontents/judge/end-popup'
|
||
import LoadingPopup from './compontents/judge/loading-popup'
|
||
|
||
import Judge from './judgeSDK/judge'
|
||
import FileLog from './judgeSDK/utils/file-log'
|
||
import {Project,ProjectObj,MarkRule,CDSBInfo} from './judgeSDK/api/judgeSDK.d'
|
||
|
||
import AccountTable from '../common/database/tables/AccountTable';
|
||
import MA_SYSTEMPARM from '../common/constants/MA_SYSTEMPARM';
|
||
import MA_SYSSET from '../common/constants/MA_SYSSET';
|
||
import MA_CDSBINFO from '../common/constants/MA_CDSBINFO'
|
||
import ES_CARINFO from '../common/constants/ES_CARINFO'
|
||
import {getCurrentTime,formatTime,chunkArr,getCurrentHourTime} from '../common/utils/tools'
|
||
|
||
import {
|
||
examJudgeEndExam
|
||
} from './judgeSDK/api/index'
|
||
|
||
import { getSyncData } from '../common/service/initable'
|
||
import SignDisplayCom from './compontents/signDisplayCom'
|
||
|
||
interface JudgeData{
|
||
xmmcStr:string,
|
||
carztStr:string,
|
||
kfArr:{xmmcStr:string,desc}[]
|
||
}
|
||
|
||
|
||
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(){
|
||
|
||
// globalThis.windowClass.setWindowSystemBarEnable([''])
|
||
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();
|
||
await this.initCar();
|
||
await this.initSystemParam();
|
||
await this.initMarkRules();
|
||
await this.initSysset();
|
||
await this.initCDSBInfo()
|
||
|
||
const {name,idCard,lsh,kszp} = this;
|
||
|
||
const fileLog = new FileLog(this.context);
|
||
const filePath = await fileLog.initFileLogo({
|
||
name,lsh,idCard
|
||
});
|
||
|
||
//断点续考
|
||
await this.goDdxkItems()
|
||
|
||
//初始化评判
|
||
const judge = await this.initJudge(fileLog);
|
||
this.judge = judge
|
||
}
|
||
|
||
//查询考车信息
|
||
async initCar(){
|
||
const db = new AccountTable(()=>{},ES_CARINFO)
|
||
const result = await getSyncData('ES_CARINFO')
|
||
const carInfo = result[0] || {};
|
||
this.carName = decodeURI(carInfo.carclass)
|
||
this.carType = carInfo.kscx
|
||
}
|
||
|
||
//获取考生信息
|
||
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;
|
||
}
|
||
|
||
//获取扣分代码信息
|
||
async initMarkRules(){
|
||
const markRuleParams = await getSyncData('MA_MARKRULE')
|
||
//@ts-ignore
|
||
markRuleParams.forEach(mark=>{
|
||
this.markRuleListObj[`${mark.itemno}_${mark.markserial}`] = {
|
||
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');
|
||
this.serialNumber = (serialNumberArr[0] && serialNumberArr[0].v_value) || '123456'
|
||
|
||
//TODO 杭州用到的特殊评判参数 211,603,660,671
|
||
const judgeNumbers = ['211','603','660','671','606'];
|
||
const judgeConfig = []
|
||
|
||
//@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();
|
||
}
|
||
}
|
||
|
||
// 获取场地设备信息
|
||
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('_')
|
||
this.cdsbInfoObj[newKey] = {
|
||
kdid:cdsb.kdid,
|
||
sbbh:cdsb.sbbh,
|
||
sbbm:cdsb.sbbm,
|
||
itemsno:key,
|
||
modelKey:newKey,
|
||
//@ts-ignore
|
||
xmdm:key.split('~')[0] * 1,
|
||
xmxh:key.split('~')[1],
|
||
}
|
||
})
|
||
}
|
||
|
||
// 评判相关初始化
|
||
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
|
||
}
|
||
|
||
// 断点续考判断
|
||
async goDdxkItems(){
|
||
//断点续考判断
|
||
let currentParams:any = router.getParams();
|
||
const examItems:string = currentParams?.examItems;
|
||
|
||
// 2024-01-03 16:29:26;0;20300,;2,4^2,4;null;
|
||
|
||
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);
|
||
}
|
||
}
|
||
}
|
||
|
||
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})
|
||
}.width('85%').height(70).justifyContent(FlexAlign.Center).alignItems(VerticalAlign.Center).border({width:3,color:'#4D4136',radius:15}).onClick(()=>{this.signDisplayComVisible = true})
|
||
|
||
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;
|
||
},
|
||
confirmFn:async ()=>{
|
||
this.endPopupVisible = false;
|
||
this.loadingPopupVisible = true
|
||
globalThis.isJudge = false
|
||
examJudgeEndExam();
|
||
clearInterval(this.timer);
|
||
clearInterval(globalThis.judgeTimer)
|
||
globalThis.windowClass.setWindowSystemBarEnable(['navigation'])
|
||
const judge= this.judge
|
||
await judge.endExam(true);
|
||
}
|
||
})
|
||
}
|
||
|
||
if(this.loadingPopupVisible){
|
||
LoadingPopup({
|
||
title:'正在生成考试记录,请稍后...',
|
||
})
|
||
}
|
||
|
||
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)')
|
||
}
|
||
}
|
||
.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;
|
||
}
|
||
}
|
||
|
||
//页面通用字体大小
|
||
@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 = []
|
||
|
||
}
|