feat:更新

This commit is contained in:
surenjun 2024-12-31 17:51:25 +08:00
parent c7dd0aa000
commit 17ef3ce4be
6 changed files with 68 additions and 49 deletions

View File

@ -42,6 +42,7 @@ export async function writeObjectOut(params,filePath?:string): Promise<WR> {
})
}
const {xtlb,jkxlh,jkid,drvexam} = params;
//新监管调用
if (globalThis.isJGNew) {
return await writeObjectOutNew(params,filePath)
@ -51,8 +52,9 @@ export async function writeObjectOut(params,filePath?:string): Promise<WR> {
const drvexamArrs = Reflect.ownKeys(drvexam)
.filter(dKey => drvexam[dKey] != undefined)
.map((key: string) => (
`<${key}>${drvexam[key]}</${key}>`));
`<${key}>${drvexam[key]}</${key}>`));
console.log('surenjun filePath=>',filePath);
if(filePath){
const fileUtil = new FileUtil(globalThis.context);
await fileUtil.initFolder(filePath);
@ -61,7 +63,6 @@ export async function writeObjectOut(params,filePath?:string): Promise<WR> {
}) +`\n`);
}
console.info('surenjun','调用旧监管')
//对象转换成xml
const temp = await request({
host: globalThis.JGHOST,
@ -92,12 +93,18 @@ export async function writeObjectOut(params,filePath?:string): Promise<WR> {
</SOAP-ENV:Envelope>`,
method: 'post',
xml: true
})
},)
if(filePath){
const fileUtil = new FileUtil(globalThis.context);
await fileUtil.initFolder(filePath);
fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`,JSON.stringify(temp) +`\n`);
}
// const {code} = temp;
// if(code == '2300007' || code == '2300028'){
// return await writeObjectOut(params,filePath)
// }else{
// return temp
// }
return temp
}

View File

@ -4,9 +4,6 @@ let baseHost = globalThis.host;
import FileUtil from '../common/utils/File';
import FileLog from '../pages/judgeSDK/utils/fileLog';
//新监管接口
//监管接口序列号映射
const gjxlhObj = {
'17C51': '02-21-000009',
@ -21,6 +18,7 @@ interface WR{
message?:string
code:number
}
export default async function writeObjectOutNew(data,filePath): Promise<WR> {
const fileUtil = new FileUtil(globalThis.context);
const {jkid , drvexam} = data;
@ -28,12 +26,17 @@ export default async function writeObjectOutNew(data,filePath): Promise<WR> {
const params = await getParams(jkid, drvexam);
const {wglb,jkxlh,glbm,jgbh,sjbs} = basic;
console.info('surenjun filePath=>',filePath)
fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`,JSON.stringify({
wglb,jkxlh,glbm,jgbh,sjbs,
data:params.data,
file:{...params.file,param:[]},
}));
if(filePath){
fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`,JSON.stringify({
wglb,jkxlh,glbm,jgbh,sjbs,
data:params.data,
file:{...params.file,param:[]},
}));
}
// let connectTimeout = sjbs === '02-21-000014' ?60000:1
console.info('surenjun','调用旧监管')
const temp = await request({
host: globalThis.JGHOST,
@ -66,7 +69,13 @@ export default async function writeObjectOutNew(data,filePath): Promise<WR> {
await fileUtil.initFolder(filePath);
fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`,JSON.stringify(temp) +`\n`);
}
return temp
const {code} = temp;
if(code == '2300007' || code == '2300028'){
return await writeObjectOutNew(params,filePath)
}else{
return temp
}
}
export async function getParams(jkid, drvexam) {

View File

@ -10,8 +10,6 @@ const config = {
host:GlobalConfig.host,
}
/**
* @author: Renjun Su
* @date: 2023/2/20
@ -22,6 +20,7 @@ const config = {
* @param {params} get请求的数据
*
*/
// let httpRequest = http.createHttp();
export default async function request(req: any) {
const {url,params = {},data = {},xml,method = 'get',host,isNewCenter = false} = req;
@ -32,7 +31,6 @@ export default async function request(req: any) {
'Content-Type': xml ? 'text/xml' : 'application/json'
},
extraData: xml ? data : JSON.stringify(data),
connectTimeout:120000,
}
//params转url拼接参数
let paramsStr = Reflect.ownKeys(params).reduce((p: string, n: string) => (`${p}${n}=${params[n]}&`), '?') || '';
@ -41,9 +39,8 @@ export default async function request(req: any) {
try {
let baseUrl=host?host:globalThis.host
// let baseUrl=host?config.csptHost:config.host'
console.log('optionsoptions',JSON.stringify(data).length)
console.log('响应头地址' + baseUrl,url)
const {result,responseCode} = await httpRequest.request(`${baseUrl}${url}${paramsStr}`, options);
const {result,responseCode} = await httpRequest.request(`${baseUrl}${url}${paramsStr}`, {...options});
// fileUtil.editFile(`${folderPath}/request.txt`, JSON.stringify(arrList))
// writeLog({
// time:dateFormat(new Date()),
@ -65,6 +62,7 @@ export default async function request(req: any) {
const msgXml = res.Envelope.Body.writeObjectOutResponse.return;
//Envelope.Body.writeObjectOutResponse.return
const dd = handleCenterCode(msgXml,isNewCenter);
httpRequest.destroy();
return dd
}
@ -85,32 +83,35 @@ export default async function request(req: any) {
}
console.info('jiangsong:res in request' + url + JSON.stringify(resObj))
if(resObj.resultCode === '0') {
httpRequest.destroy();
return res
}else {
prompt.showToast({
message: decodeURIComponent(resObj.resultMessage),
duration: 3000
});
httpRequest.destroy();
return res
}
} catch (e) {
console.info('test-error' + url + ' error:resp: '+ JSON.stringify(e))
if(!e||!(e?.message)){
return false
return {code:-1}
}
const code = e?.code;
prompt.showToast({
message: e?.message,
duration: 5000
});
httpRequest.destroy();
switch (code){
//断网
case 2300007: return 2300007
// 超时
case 2300028: return 2300028
default:
}
httpRequest.destroy();
return false
return {code:e.code}
}
}
@ -120,6 +121,8 @@ async function writeLog(param){
fileUtil.editFile(`${folderPath}/request.txt`, JSON.stringify(param)+`\n`)
}
//xml格式转JSON
function xmlToJson(result,url) {
console.log("xmlToJson begin",url);

View File

@ -41,8 +41,6 @@ struct Index {
}
async aboutToAppear() {
this.vocObj = new voiceService(async (status, val, next) => {
});
globalThis.windowClass.setWindowSystemBarEnable([])
const time = await getCurrentTime()
@ -761,10 +759,10 @@ struct Index {
.height(118 * 0.95)
.margin({ bottom: 8 })
.onClick(() => {
this.vocObj.playAudio({
type: 1,
name: 'button_media.wav'
})
// this.vocObj.playAudio({
// type: 1,
// name: 'button_media.wav'
// })
this.setManualProjectFn(index)
})
})
@ -797,10 +795,10 @@ struct Index {
.alignItems(VerticalAlign.Center)
.border({ width: 5, color: '#4D4136', radius: 30 })
.onClick(() => {
this.vocObj.playAudio({
type: 1,
name: 'button_media.wav'
})
// this.vocObj.playAudio({
// type: 1,
// name: 'button_media.wav'
// })
this.signDisplayComVisible = true
})
@ -836,10 +834,10 @@ struct Index {
.backgroundImageSize({ width: '100%', height: '100%' })
.margin({ bottom: 10 })
.onClick(() => {
this.vocObj.playAudio({
type: 1,
name: 'button_media.wav'
})
// this.vocObj.playAudio({
// type: 1,
// name: 'button_media.wav'
// })
this.isDeductedPopShow = true
})
}
@ -869,10 +867,10 @@ struct Index {
.backgroundImage($rawfile('judge/anniu_nor.png'), ImageRepeat.NoRepeat)
.backgroundImageSize({ width: '100%', height: '100%' })
.onClick(() => {
this.vocObj.playAudio({
type: 1,
name: 'button_media.wav'
})
// this.vocObj.playAudio({
// type: 1,
// name: 'button_media.wav'
// })
if (this.judgeConfigObj['353'] == '0') {
this.endPopupVisible = true
} else {
@ -936,10 +934,10 @@ struct Index {
.backgroundImage($rawfile('judge/close.png'), ImageRepeat.NoRepeat)
.backgroundImageSize({ width: '33.33%', height: '33.33%' })
.onClick(() => {
this.vocObj.playAudio({
type: 1,
name: 'button_media.wav'
})
// this.vocObj.playAudio({
// type: 1,
// name: 'button_media.wav'
// })
this.signDisplayComVisible = false
})
}.width('100%').height('100%').position({ y: 0 }).backgroundColor('rgba(0,0,0,0.6)')

View File

@ -730,19 +730,21 @@ struct UserInfo {
this.currentUser.id = '1'
const avPlayer = this.avPlayer;
this.isLoadingPopupVisible = true
avPlayer.playAudio([`voice/监管通信中.mp3`], false, async () => {
console.info('surenjun','播放结束开始考试接口调用')
const {code,keystr,message} = await this.beginExam();
const {code,keystr,message} = await this.beginExam() || {};
console.info('surenjun','开始考试接口调用结束')
// console.info('surenjun',code +'')
//@ts-ignore TODO code转换
if (code != 1) {
avPlayer.playAudio(['voice/监管审核未通过.mp3']);
this.isLoadingPopupVisible = false
this.isExamStart = false
promptAction.showToast({
message,
duration: 4000
})
avPlayer.playAudio(['voice/监管审核未通过.mp3']);
this.isLoadingPopupVisible = false
this.isExamStart = false
return
}
this.currentUser.id = '0'

View File

@ -200,7 +200,7 @@ export default class Judge {
handleUdp(msg)
const udpIndex = globalThis.udpIndex;
if (udpIndex % 5 === 0) {
handDistance();
// handDistance();
}
})
@ -1044,7 +1044,7 @@ export default class Judge {
dwlc: [d1,d2,d3,d4,d5].map((d,index) => `${index+1},${Math.floor(d /100)}`).join(';'),
}
}
const {code,keystr,message} = await writeObjectOut(data,filePath);
const {code,keystr,message} = await writeObjectOut(data,filePath) ;
promptWxCode('17C56', code)
if(code != 1){