234 lines
6.5 KiB
Plaintext
234 lines
6.5 KiB
Plaintext
import { getSyncData } from '../common/service/initable';
|
|
import request from '../utils/Request';
|
|
|
|
|
|
import http from '@ohos.net.http';
|
|
import common from '@ohos.app.ability.common';
|
|
import { DrvexamType, GetJudgeParamsType } from '../model';
|
|
import FileUtils from '../utils/FileUtils';
|
|
|
|
//监管接口序列号映射
|
|
const gjxlhObj: Record<string, string> = {
|
|
'17C51': '02-21-000009',
|
|
'17C52': '02-21-000010',
|
|
'17C53': '02-21-000011',
|
|
'17C54': '02-21-000012',
|
|
'17C55': '02-21-000013',
|
|
'17C56': '02-21-000014',
|
|
}
|
|
|
|
interface WR {
|
|
message?: string
|
|
code: number
|
|
}
|
|
|
|
export default async function writeObjectOutNew(data, filePath: string): Promise<WR> {
|
|
const context: common.UIAbilityContext = AppStorage.get('context')
|
|
const fileUtil = new FileUtils(context);
|
|
// const { jkid, drvexam } = data;
|
|
const basic = await getBasicConfig(data.jkid);
|
|
const params = await getParams(data.jkid, data.drvexam);
|
|
// const { wglb, jkxlh, glbm, jgbh, sjbs } = basic;
|
|
|
|
if (filePath) {
|
|
await fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`, JSON.stringify({
|
|
wglb: basic.wglb,
|
|
jkxlh: basic.jkxlh,
|
|
glbm: basic.glbm,
|
|
jgbh: basic.jgbh,
|
|
sjbs: basic.sjbs,
|
|
data: params.data,
|
|
file: {
|
|
...params.file, param: []
|
|
},
|
|
}));
|
|
}
|
|
|
|
// let connectTimeout = sjbs === '02-21-000014' ?60000:1
|
|
console.info('surenjun', '调用新监管')
|
|
let temp: WR
|
|
try {
|
|
temp = await request<WR>({
|
|
host: globalThis.JGHOST as string,
|
|
method: http.RequestMethod.POST,
|
|
//是否是新中心
|
|
isNewCenter: true,
|
|
xml: true,
|
|
url: '/dems_ws/services/TmriOutAccess?wsdl',
|
|
data: `<?xml version="1.0"?>
|
|
<SOAP-ENV:Envelope
|
|
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
|
|
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
|
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
|
|
>
|
|
<SOAP-ENV:Body>
|
|
<writeObjectOut xmlns="http://service.es.doron">
|
|
<wglb>${basic.wglb}</wglb>
|
|
<jkxlh>${basic.jkxlh}</jkxlh>
|
|
<glbm>${basic.glbm}</glbm>
|
|
<jgbh>${basic.jgbh}</jgbh>
|
|
<sjbs>${basic.sjbs}</sjbs>
|
|
<data>${JSON.stringify(params.data)}</data>
|
|
<file>${JSON.stringify(params.file)}</file>
|
|
</writeObjectOut>
|
|
</SOAP-ENV:Body>
|
|
</SOAP-ENV:Envelope>`,
|
|
})
|
|
} catch (e) {
|
|
console.log("新监管错误")
|
|
temp = e
|
|
}
|
|
console.log("temp message: ", JSON.stringify(temp))
|
|
if (filePath) {
|
|
await fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`, JSON.stringify(temp) + `\n`);
|
|
}
|
|
return temp
|
|
}
|
|
|
|
export async function getParams(jkid: string, drvexam: DrvexamType): Promise<GetJudgeParamsType> {
|
|
const examSubject: number = globalThis.carInfo.examSubject;
|
|
switch (jkid) {
|
|
//开始考试
|
|
case '17C51':
|
|
return {
|
|
data: {
|
|
sjbs: gjxlhObj[jkid],
|
|
param: {
|
|
sfzmhm: drvexam.sfzmhm,
|
|
kchp: decodeURI(drvexam.kchp),
|
|
kskm: examSubject.toString(),
|
|
ksxl: examSubject == 3 ? drvexam.ksxl : undefined,
|
|
kssj: drvexam.kssj
|
|
}
|
|
},
|
|
file: {
|
|
sjbs: gjxlhObj[jkid],
|
|
// param: [{ field: '', data: examSubject == 2 ? encodeURIComponent(drvexam.zp) : drvexam.zp }]
|
|
param: [
|
|
{
|
|
field: '',
|
|
data: drvexam.zp
|
|
}
|
|
]
|
|
}
|
|
}
|
|
//项目开始
|
|
case '17C52':
|
|
return {
|
|
data: {
|
|
sjbs: gjxlhObj[jkid],
|
|
param: {
|
|
sfzmhm: drvexam.sfzmhm,
|
|
kskm: drvexam.kskm,
|
|
ksxl: examSubject == 3 ? drvexam.ksxl : undefined,
|
|
kchp: decodeURI(drvexam.kchp),
|
|
//TODO 待验证 科目三无
|
|
sbbh: examSubject == 3 ? undefined : drvexam.sbxh,
|
|
kssj: drvexam.kssj,
|
|
ksxm: drvexam.ksxm,
|
|
}
|
|
},
|
|
file: {
|
|
sjbs: gjxlhObj[jkid],
|
|
param: [{ field: '', data: '' }]
|
|
}
|
|
}
|
|
//扣分
|
|
case '17C53':
|
|
return {
|
|
data: {
|
|
sjbs: gjxlhObj[jkid],
|
|
param: {
|
|
kffs: drvexam.kffs,
|
|
kfsj: drvexam.kfsj,
|
|
kfxm: drvexam.kfxm,
|
|
kfxmmx: drvexam.kfxmmx,
|
|
kskm: examSubject.toString(),
|
|
ksxm: drvexam.ksxm,
|
|
sfzmhm: drvexam.sfzmhm
|
|
}
|
|
},
|
|
file: {
|
|
sjbs: gjxlhObj[jkid],
|
|
param: [{ field: '', data: '' }]
|
|
}
|
|
}
|
|
//过程照片
|
|
case '17C54':
|
|
return {
|
|
data: {
|
|
sjbs: gjxlhObj[jkid],
|
|
param: {
|
|
cs: drvexam.cs,
|
|
kskm: drvexam.kskm,
|
|
ksxm: drvexam.ksxm,
|
|
sfzmhm: drvexam.sfzmhm,
|
|
zpsj: drvexam.zpsj
|
|
}
|
|
},
|
|
file: {
|
|
sjbs: gjxlhObj[jkid],
|
|
param: [{ field: '', data: drvexam.zp }]
|
|
}
|
|
}
|
|
//项目结束
|
|
case '17C55':
|
|
return {
|
|
data: {
|
|
param: {
|
|
czlx: drvexam.czlx,
|
|
jssj: drvexam.jssj,
|
|
kskm: examSubject.toString(),
|
|
ksxl: drvexam.ksxl,
|
|
sbbh: examSubject == 3 ? undefined : drvexam.sbxh,
|
|
ksxm: drvexam.ksxm,
|
|
sfzmhm: drvexam.sfzmhm
|
|
},
|
|
sjbs: gjxlhObj[jkid],
|
|
},
|
|
file: { sjbs: gjxlhObj[jkid], param: [{ field: '', data: '' }] }
|
|
}
|
|
//考试结束
|
|
case '17C56':
|
|
return {
|
|
data: {
|
|
sjbs: gjxlhObj[jkid],
|
|
param: {
|
|
dwlc: drvexam.dwlc,
|
|
ghks: "0",
|
|
jssj: drvexam.jssj,
|
|
kscj: drvexam.kscj,
|
|
kskm: examSubject.toString(),
|
|
kslc: drvexam.kslc,
|
|
sfzmhm: drvexam.sfzmhm
|
|
},
|
|
},
|
|
file: { sjbs: gjxlhObj[jkid], param: [{ field: '', data: drvexam.zp }] }
|
|
}
|
|
|
|
default:
|
|
return {}
|
|
}
|
|
}
|
|
|
|
//获取基础信息
|
|
async function getBasicConfig(jkid) {
|
|
const examSubject = globalThis.carInfo.examSubject;
|
|
const syssetParam = await getSyncData('MA_SYSSET');
|
|
let syssetObj = {};
|
|
syssetParam.forEach(sys => {
|
|
syssetObj[sys.v_no] = decodeURIComponent(sys.v_value)
|
|
});
|
|
return {
|
|
//外挂类别
|
|
wglb: examSubject == 2 ? "700203" : "700204",
|
|
//监管接口序列号
|
|
jkxlh: syssetObj['901'],
|
|
//管理部门
|
|
glbm: syssetObj['903'],
|
|
//考场序号
|
|
jgbh: syssetObj['905'],
|
|
//接口id
|
|
sjbs: gjxlhObj[jkid],
|
|
}
|
|
} |