subject-two/entry/src/main/ets/pages/compontents/judge/BoardPrePareSetPopup.ets

566 lines
18 KiB
Plaintext
Raw Normal View History

2025-04-09 09:28:18 +08:00
import { JudgeConfig } from '../../judgeSDK/utils/judgeConfig';
2025-03-26 13:43:47 +08:00
2024-07-05 09:34:03 +08:00
import common from '@ohos.app.ability.common';
import VoiceAnnounce from '../../judgeSDK/utils/voiceAnnouncements';
import { MarkRule } from '../../judgeSDK/api/judgeSDK.d';
2025-02-19 13:24:07 +08:00
import { writeObjectOut } from '../../../api/judge';
2024-07-31 13:47:40 +08:00
import JudgeTask from '../../judgeSDK/utils/judgeTask';
import FilePhoto from '../../judgeSDK/utils/filePhoto';
import { CarInfoType, MASYSSETTableType, RegulatoryInterfaceParams, User } from '../../../model';
import { GetCurrentTime } from '../../../utils/Common';
2025-03-26 13:43:47 +08:00
import FileUtils from '../../../utils/FileUtils';
import { GetSyncData } from '../../../utils/table/Operation';
2024-07-05 09:34:03 +08:00
interface SEL {
fontColor: string
bgColor: string
}
interface kfdmItemType {
xmdm: number,
kfdm: string,
markreal: number,
markcatalog: string
score: number
}
2024-07-31 13:47:40 +08:00
//考前模拟人工扣分
2024-07-05 09:34:03 +08:00
@Component
export default struct DeductedPopup {
@State name: string = ''
@State idCard: string = ''
@State lsh: string = ''
@State kszp: string = ''
@State ksdd: string = ''
@State kssycs: string = ''
@State kslx: string = ''
2024-07-31 13:47:40 +08:00
@State ksxl: string = ''
@State score: number = 100;
@State judgeConfigObj: Record<string, string> = {}
@State kfdmArr: kfdmItemType[] = []
2024-07-05 09:34:03 +08:00
//开始考试前判绕车一周评判是否开启
@State isOpen: boolean = false
//监管序列号
@State serialNumber: number = 0;
@State examSubject: number = 2;
@State markRuleListObj: MarkRule = {}
2024-12-05 18:31:06 +08:00
@State fontSize: number = 28
2024-07-05 09:34:03 +08:00
@State unselected: SEL = { fontColor: '#000000', bgColor: '#CCC4B8' }
@State selected: SEL = { fontColor: '#FFAD33', bgColor: '#26231E' }
@State currentIndex: number = 0
@State currentPageIndex: number = 0
//通用评判扣分
@State currentUniversalPageIndex: number = 0;
@State universalMarkRules: MarkRule[] = []
@State manualMarkRules: MarkRule[] = []
@State lineBg: Array<string> = ['#4D4136', '#26231E']
@State selectedLine: number = -1
2025-02-19 13:24:07 +08:00
@State carInfo: CarInfoType = {
2025-02-18 13:43:20 +08:00
carId: '',
examinationRoomId: '',
plateNo: '',
isNeedCheck: '',
2025-02-19 13:24:07 +08:00
examSubject: '',
2025-02-18 13:43:20 +08:00
}
2025-02-13 15:30:48 +08:00
@State singlePlay: boolean = false
2024-07-05 09:34:03 +08:00
@State selectedLineStyle: SEL = {
fontColor: '#FFF',
bgColor: '#B36E00'
}
private context = getContext(this) as common.UIAbilityContext;
private judgeTask!: JudgeTask
private filePhoto!: FilePhoto
2025-02-19 13:24:07 +08:00
// 过程照片拍照
getPhoto = async (empty?: boolean) => {
//单机模式返回空照片
if (this.singlePlay) {
return ''
} else {
const photoBase64: string = await this.filePhoto.getPhoto() || "";
2025-02-19 13:24:07 +08:00
return photoBase64
}
}
private avPlayer!: VoiceAnnounce
2024-07-05 09:34:03 +08:00
2024-07-31 13:47:40 +08:00
async aboutToAppear() {
this.carInfo = AppStorage.get<CarInfoType>('carInfo')!
this.singlePlay = AppStorage.get<boolean>('singlePlay')!
this.avPlayer = new VoiceAnnounce(this.context);
2024-07-31 13:47:40 +08:00
this.judgeTask = new JudgeTask();
const mediaTest = new FilePhoto(this.context);
this.filePhoto = mediaTest
2024-07-05 09:34:03 +08:00
//上车准备
// this.universalMarkRules = this.markRules.filter(item => this.currentItems.includes(item.itemno+''))
// const { isTrajectoryOpen } = judgeConfig;
2025-04-09 09:28:18 +08:00
if (JudgeConfig.isTrajectoryOpen) {
2024-07-31 13:47:40 +08:00
await this.initDb()
2024-07-05 09:34:03 +08:00
} else {
2024-07-31 13:47:40 +08:00
await this.initSysset()
await this.initMarkRules()
await this.initStudent()
2024-07-05 09:34:03 +08:00
}
2024-07-31 13:47:40 +08:00
// const {judgeTask} = this;
// judgeTask.addTask(async () => {
// await this.beginProject();
// }, { isDelay: true })
// judgeTask.addTask(async () => {
// await this.uploadProgressPhoto();
// }, { isDelay: true })
2024-07-05 09:34:03 +08:00
}
//本地数据初始化
async initDb() {
// const { isTrajectoryOpen, trajectoryPath } = judgeConfig
2025-02-19 13:24:07 +08:00
const examSubject = this.carInfo.examSubject;
2024-07-05 09:34:03 +08:00
//轨迹回放读取 systemparam表、markrule表
2025-03-26 13:43:47 +08:00
const fileUtil = new FileUtils(this.context);
2025-04-09 09:28:18 +08:00
const folderPath = await fileUtil.initFolder(JudgeConfig.trajectoryPath);
2024-07-05 09:34:03 +08:00
const str = await fileUtil.readFile(folderPath);
const strArr = str.split('\n');
// const [initData, beginData] = [strArr[0], strArr[1]];
const initData = strArr[0];
const beginData = strArr[1];
// TODO 补全类型
const initDataObj: ESObject = JSON.parse(initData);
2025-04-09 09:28:18 +08:00
this.examSubject = Number(JudgeConfig.isTrajectoryOpen ? (initDataObj.kskm * 1) : examSubject);
2024-07-05 09:34:03 +08:00
await this.initMarkRules(initDataObj.mark);
await this.initSysset(initDataObj.sysset);
await this.initStudent()
}
2024-07-31 13:47:40 +08:00
// 扣分操作
async pointsDedute() {
const index = this.currentIndex ? this.currentUniversalPageIndex : this.currentPageIndex;
const mark = this.universalMarkRules[index * 7 + this.selectedLine];
// const { judgeConfigObj, kssycs, avPlayer, judgeTask } = this;
2024-11-26 15:35:05 +08:00
this.kfdmArr.push({
xmdm: 1,
kfdm: mark.markserial || "",
markreal: mark.markreal || 0,
markcatalog: mark.markcatalog || "",
score: mark.score || 0
2024-11-26 15:35:05 +08:00
})
2024-07-31 13:47:40 +08:00
const kfdmArr = this.kfdmArr
//计算总扣分
let score = kfdmArr.reduce((p, n) => {
p += n.markreal * 1
return p
}, 0);
this.score = score
// this.confirmMark(this.kfdmArr.map((kf) => ({
// xmdm: kf.xmdm.toString(),
// kfdm: kf.kfdm,
// })))
2024-07-31 13:47:40 +08:00
if (this.judgeConfigObj['418'] == '1' || JudgeConfig.kfVoiceOpen) {
this.avPlayer.playAudio([`voice/${mark.markcatalog}.mp3`, `voice/mark_${Math.abs(mark.score!)}.mp3`], false,
() => {
this.closePopup(true)
});
2024-07-31 13:47:40 +08:00
return
}
2024-09-03 19:28:07 +08:00
this.closePopup();
2024-07-31 13:47:40 +08:00
return;
}
//项目开始
async beginProject() {
//项目开始 //过程照片 //扣分 //结束考试
// const carInfo: CarInfoType = this.carInfo;
// const { examSubject, plateNo } = carInfo;
// const { serialNumber, lsh, idCard, ksxl, kslx, ksdd } = this
const time = GetCurrentTime();
const beginData: RegulatoryInterfaceParams = {
2025-02-19 13:24:07 +08:00
xtlb: '17',
jkxlh: this.serialNumber.toString(),
2025-02-19 13:24:07 +08:00
jkid: '17C52',
2024-07-31 13:47:40 +08:00
drvexam: {
// 考试科目 身份证号码
lsh: this.lsh,
kskm: this.carInfo.examSubject,
sfzmhm: this.idCard,
2024-07-31 13:47:40 +08:00
ksxm: '40100',
ksxl: this.ksxl,
kchp: decodeURI(this.carInfo.plateNo || ""),
ksdd: decodeURI(this.ksdd),
kslx: decodeURI(this.kslx) || '',
2024-07-31 13:47:40 +08:00
kssj: time
},
}
const code = await writeObjectOut(beginData)
//TODO code待处理
2024-08-12 10:19:31 +08:00
// if (code == 1) {
//
// }
2024-07-31 13:47:40 +08:00
}
//过程照片
async uploadProgressPhoto() {
// const { serialNumber, lsh, idCard, ksdd, kfdmArr, getPhoto } = this;
// const carInfo = this.carInfo;
// const { examSubject, plateNo, carNo } = carInfo;
const time = GetCurrentTime();
2024-07-31 13:47:40 +08:00
console.info('surenjun uploadProgressPhoto',)
const photoBase64 = await this.getPhoto()
const photoData: RegulatoryInterfaceParams = {
2025-02-19 13:24:07 +08:00
xtlb: '17',
jkxlh: this.serialNumber.toString(),
2025-02-19 13:24:07 +08:00
jkid: '17C54',
2024-07-31 13:47:40 +08:00
drvexam: {
lsh: this.lsh,
kskm: this.carInfo.examSubject,
2024-07-31 13:47:40 +08:00
ksxm: '40100',
sfzmhm: this.idCard,
kchp: decodeURI(this.carInfo.plateNo || ""),
2024-07-31 13:47:40 +08:00
zpsj: time,
// zp: encodeURIComponent(photoBase64),
zp: photoBase64,
cs: 0,
ksdd: decodeURI(this.ksdd)
2024-07-31 13:47:40 +08:00
}
};
const code = await writeObjectOut(photoData);
console.info('surenjun uploadProgressPhoto end',)
}
// 扣分
async kfFn() {
const kfLen = this.kfdmArr.length;
const kf = this.kfdmArr[kfLen -1];
const time = GetCurrentTime();
const kfData: RegulatoryInterfaceParams = {
2025-02-19 13:24:07 +08:00
xtlb: '17',
jkxlh: this.serialNumber.toString(),
2025-02-19 13:24:07 +08:00
jkid: '17C53',
2024-07-31 13:47:40 +08:00
drvexam: {
lsh: this.lsh,
kskm: this.carInfo.examSubject,
2024-07-31 13:47:40 +08:00
// 通用评判科二10000科三30000
ksxm: "40100",
2024-07-31 13:47:40 +08:00
kfxm: kf.markcatalog,
kfxmmx: `${'1'},${kf.kfdm}`,
sfzmhm: this.idCard,
kchp: decodeURI(this.carInfo.plateNo || ""),
2024-07-31 13:47:40 +08:00
kffs: 2,
ksdd: decodeURI(this.ksdd),
2024-07-31 13:47:40 +08:00
kfsj: time
}
}
const code = await writeObjectOut(kfData);
}
// 项目结束
async endProject() {
const time = GetCurrentTime();
const endProjectData: RegulatoryInterfaceParams = {
2025-02-19 13:24:07 +08:00
xtlb: '17',
jkxlh: this.serialNumber.toString(),
2025-02-19 13:24:07 +08:00
jkid: '17C55',
2024-07-31 13:47:40 +08:00
drvexam: {
lsh: this.lsh,
kskm: this.carInfo.examSubject,
sfzmhm: this.idCard,
2024-07-31 13:47:40 +08:00
ksxm: '40100',
czlx: '1',
ksxl: this.ksxl,
kchp: decodeURI(this.carInfo.plateNo || ""),
ksdd: decodeURI(this.ksdd),
kslx: encodeURI(this.kslx) || '',
2024-07-31 13:47:40 +08:00
jssj: time
}
}
const code = await writeObjectOut(endProjectData);
}
//考试结束
async endFn() {
const time = GetCurrentTime();
const photoBase64 = await this.getPhoto()
const endData: RegulatoryInterfaceParams = {
2025-02-19 13:24:07 +08:00
xtlb: '17',
jkxlh: this.serialNumber.toString(),
2025-02-19 13:24:07 +08:00
jkid: '17C56',
2024-07-31 13:47:40 +08:00
drvexam: {
lsh: this.lsh,
kchp: decodeURI(this.carInfo.plateNo || ""),
kskm: this.carInfo.examSubject,
sfzmhm: this.idCard,
2024-07-31 13:47:40 +08:00
// zp: encodeURIComponent(photoBase64),
zp: photoBase64,
jssj: time,
kscj: (this.score * 1) > 0 ? this.score : 0,
2024-07-31 13:47:40 +08:00
kslc: 0,
dwlc: '',
}
}
const code = await writeObjectOut(endData);
}
2024-07-05 09:34:03 +08:00
//获取sysset表数据
async initSysset(sysset?: MASYSSETTableType[]) {
const syssetParams = sysset || await GetSyncData<MASYSSETTableType>('MA_SYSSET');
2024-07-31 13:47:40 +08:00
console.info('surenjun syssetParams', JSON.stringify(syssetParams));
2024-07-05 09:34:03 +08:00
syssetParams.forEach(sys => {
//监管序列号
2024-07-10 19:39:13 +08:00
if (sys.v_no == '901') {
this.serialNumber = Number(sys.v_value) || 123456
2024-07-05 09:34:03 +08:00
}
//364 绕车一周评判时机(1-开始考试后判 2-开始考试前判)
2024-07-10 19:39:13 +08:00
if (sys.v_no == '364') {
const isOpen = sys.v_value == "2"
2024-07-05 09:34:03 +08:00
if (isOpen) {
this.avPlayer.playAudio(['voice/上车准备.mp3'])
}
}
if (sys.v_no) {
this.judgeConfigObj[sys.v_no] = decodeURIComponent(sys.v_value || '');
}
2024-07-05 09:34:03 +08:00
})
}
//获取markrule表数据
async initMarkRules(markRules ?: MarkRule[]) {
const markRuleParams = markRules || (await GetSyncData('MA_MARKRULE') as MarkRule[])
2024-07-05 09:34:03 +08:00
markRuleParams.forEach(mark => {
const tempObj: MarkRule = {
itemno: Number(mark.itemno),
2024-07-05 09:34:03 +08:00
markcatalog: mark.markcatalog,
markshow: decodeURI(mark.markshow || ""),
markreal: Number(mark.markreal),
markstandard: Number(mark.markstandard),
2024-07-05 09:34:03 +08:00
markserial: mark.markserial,
kfxh: mark.kfxh,
OnlyOneKind: Number(mark.onlyoneid),
NoCancelId: Number(mark.nocancelid),
2024-07-05 09:34:03 +08:00
GPS_SID: mark.gps_sid == 0 ? false : true
}
2024-07-10 19:39:13 +08:00
if (mark.itemno == 1 && Number(mark.markserial) > 100 && Number(mark.markserial) < 200) {
2024-07-05 09:34:03 +08:00
this.markRuleListObj[`${mark.itemno}_${mark.markserial}`] = {
itemno: tempObj.itemno,
markcatalog: tempObj.markcatalog,
markshow: tempObj.markshow,
markreal: tempObj.markreal,
markstandard: tempObj.markstandard,
2024-07-05 09:34:03 +08:00
markserial: mark.markserial,
kfxh: tempObj.kfxh,
OnlyOneKind: tempObj.OnlyOneKind,
NoCancelId: tempObj.NoCancelId,
GPS_SID: tempObj.GPS_SID,
2024-07-05 09:34:03 +08:00
};
2024-07-05 09:34:03 +08:00
this.universalMarkRules.push(tempObj)
}
})
}
// 获取考生信息
async initStudent() {
const students = await GetSyncData<User>('USER')
const stuInfo: User = students[0];
// const { xm, sfzmhm, lsh, kszp, ksdd, kssycs, kslx, ksxl } = stuInfo;
this.name = stuInfo.xm || '测试考生';
this.idCard = stuInfo.sfzmhm || '01234567891010';
this.lsh = stuInfo.lsh;
this.kszp = stuInfo.kszp;
this.ksdd = stuInfo.ksdd;
this.kssycs = stuInfo.kssycs;
this.kslx = stuInfo.kslx || "";
this.ksxl = stuInfo.ksxl;
2024-07-05 09:34:03 +08:00
}
//上一页 下一页
goPage(typeIndex: number) {
2024-07-05 09:34:03 +08:00
const currentIndex = this.currentIndex
if (currentIndex) {
//通用评判
typeIndex ? (this.currentUniversalPageIndex += 1) : (this.currentUniversalPageIndex -= 1)
} else {
typeIndex ? (this.currentPageIndex += 1) : (this.currentPageIndex -= 1)
}
this.selectedLine = -1
}
//选中扣分项
getSelectedLine(index: number) {
if (this.selectedLine === index) {
return this.selectedLineStyle.bgColor
2024-07-05 09:34:03 +08:00
}
if (index % 2 === 0) {
return this.lineBg[0]
2024-07-05 09:34:03 +08:00
} else {
return this.lineBg[1]
2024-07-05 09:34:03 +08:00
}
}
//获取当前页的数据
getCurrentMarkRuleList() {
if (this.currentIndex) {
2024-07-05 09:34:03 +08:00
//通用评判
return this.universalMarkRules.slice(this.currentUniversalPageIndex * 7, (this.currentUniversalPageIndex + 1) * 7)
2024-07-05 09:34:03 +08:00
} else {
return this.universalMarkRules.slice(this.currentPageIndex * 7, (this.currentPageIndex + 1) * 7)
2024-07-05 09:34:03 +08:00
}
}
build() {
Column() {
Column() {
Column() {
Row() {
Row() {
ForEach(['人工评判'], (text: string, index) => {
2024-07-05 09:34:03 +08:00
Row() {
Text(text)
.fontColor(index === this.currentIndex ? this.selected.fontColor : this.unselected.fontColor)
.fontSize(this.fontSize)
.fontWeight(500)
}
.width(180)
.height(70)
.backgroundColor(index === this.currentIndex ? this.selected.bgColor : this.unselected.bgColor)
.justifyContent(FlexAlign.Center)
.justifyContent(FlexAlign.Center)
.borderRadius({ topLeft: 20, topRight: 20 })
.margin({ right: 10 })
.onClick(() => {
this.currentIndex = index;
this.selectedLine = -1;
// if(index === 1) {
// this.universalMarkRules = this.markRules.filter(item => item.itemno == 20 )
// }else{
// this.universalMarkRules = this.markRules.filter(item => this.currentItems.includes(item.itemno+''))
// }
})
})
}
Row() {
if (
2025-02-19 13:24:07 +08:00
(Math.ceil(this.universalMarkRules.length / 7 - 1)) >=
(this.currentIndex ? this.currentUniversalPageIndex : this.currentPageIndex) &&
2024-07-05 09:34:03 +08:00
(this.currentIndex ? this.currentUniversalPageIndex : this.currentPageIndex) > 0
) {
Row() {
Row() {
2024-12-05 18:31:06 +08:00
}.width(40).height(36).backgroundImage($rawfile(`judge/km3/zuo_nor.png`)).margin({ left: 24, top: 4 })
2024-07-05 09:34:03 +08:00
Text('上一页') {
}.fontColor('#FFF').fontSize(this.fontSize)
}
.width(160)
.height(80)
.justifyContent(FlexAlign.Start)
.alignItems(VerticalAlign.Center)
.backgroundImage($rawfile(`judge/km3/button_nor.png`))
.backgroundImageSize({ width: '100%', height: '100%' })
.onClick(() => {
this.goPage(0)
})
}
if (
2025-02-19 13:24:07 +08:00
(Math.ceil(this.universalMarkRules.length / 7 - 1)) >
(this.currentIndex ? this.currentUniversalPageIndex : this.currentPageIndex)
2024-07-05 09:34:03 +08:00
) {
Row() {
Text('下一页') {
}.fontColor('#FFF').fontSize(this.fontSize).padding({ left: 30 })
Row() {
2024-12-05 18:31:06 +08:00
}.width(40).height(36).backgroundImage($rawfile(`judge/km3/you_nor.png`)).margin({ left: 4, top: 4 })
2024-07-05 09:34:03 +08:00
}
.width(160)
.height(80)
.justifyContent(FlexAlign.Start)
.alignItems(VerticalAlign.Center)
.backgroundImage($rawfile(`judge/km3/button_nor.png`))
.backgroundImageSize({ width: '100%', height: '100%' })
.onClick(() => {
this.goPage(1)
})
}
Row() {
Text('扣 分') {
}.fontColor('#FFF').fontSize(this.fontSize).padding({ left: 49 })
}
2024-12-05 18:31:06 +08:00
.width(180)
2024-07-05 09:34:03 +08:00
.height(80)
.justifyContent(FlexAlign.Start)
.alignItems(VerticalAlign.Center)
.backgroundImage($rawfile(`judge/km3/button_nor.png`))
.backgroundImageSize({ width: '100%', height: '100%' })
2024-07-31 13:47:40 +08:00
.onClick(async () => {
this.pointsDedute()
2024-07-05 09:34:03 +08:00
})
}
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
Column() {
ForEach(this.getCurrentMarkRuleList(), (item: MarkRule, index) => {
2024-07-05 09:34:03 +08:00
Row() {
Text(`${item.markshow} (${item.markcatalog})`).fontColor('#FFF').fontSize(this.fontSize).fontWeight(500)
Row() {
Text(item.markreal + '').fontColor('#FFF').fontSize(this.fontSize).fontWeight(500)
}
}
.width('100%')
.height(75)
.justifyContent(FlexAlign.SpaceBetween)
.alignItems(VerticalAlign.Center)
.padding({ left: 20, right: 20 })
.backgroundColor(this.getSelectedLine(index))
.onClick(() => {
this.selectedLine = index
})
})
}
}
}
.width(1300)
.height(710)
2024-08-05 09:47:44 +08:00
.position({ x: '10%', y: '10%' })
2024-07-05 09:34:03 +08:00
.backgroundColor('#E6E3DF')
2025-02-19 13:24:07 +08:00
.padding({
top: 15,
bottom: 15,
left: 25,
right: 25
})
2024-07-05 09:34:03 +08:00
.borderRadius(20)
Row() {
}
.width(100)
.height(100)
.position({ y: '85%', x: '50%' })
.backgroundImage($rawfile('judge/km3/close_nor.png'))
.backgroundImageSize({ width: '100%', height: '100%' })
2024-07-31 13:47:40 +08:00
.onClick(async () => {
//没有扣分项目通过
this.closePopup(this.kfdmArr.length ? true : false)
2025-02-19 13:24:07 +08:00
// judgeTask.addTask(async () => {
// await this.endProject()
// }, { isDelay: true })
2024-07-31 13:47:40 +08:00
2024-07-05 09:34:03 +08:00
})
}.width('100%').height('100%').position({ y: 0 }).backgroundColor('rgba(0,0,0,0.7)')
}
2025-02-19 13:24:07 +08:00
private closePopup: Function = () => {
}
private confirmMark: Function = (itemno: number, serial: string) => {
}
private endLoading: Function = () => {
}
2024-07-05 09:34:03 +08:00
}