2025-04-10 10:28:07 +08:00
|
|
|
import request from '../utils/Request';
|
|
|
|
|
import writeObjectOutNew from './judgeNew';
|
|
|
|
|
import http from '@ohos.net.http';
|
|
|
|
|
import { MASYSSETTableType, RegulatoryInterfaceParams, WuxiExamType } from '../model';
|
|
|
|
|
import { GetSyncData } from '../utils/table/Operation';
|
|
|
|
|
import { GetCurrentTime } from '../utils/Common';
|
|
|
|
|
import FileUtils from '../utils/FileUtils';
|
|
|
|
|
import common from '@ohos.app.ability.common';
|
|
|
|
|
|
|
|
|
|
let baseHost: string = AppStorage.get<string>('host')!;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 下载模型
|
|
|
|
|
export async function download() {
|
|
|
|
|
return request<object>({
|
|
|
|
|
host: baseHost as string,
|
|
|
|
|
url: '/para/initEsModel.ws',
|
|
|
|
|
method: http.RequestMethod.POST,
|
|
|
|
|
xml: false,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface WR {
|
|
|
|
|
message?: string
|
|
|
|
|
code?: number
|
|
|
|
|
keystr?: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 通用监管接口
|
|
|
|
|
export async function writeObjectOut(params: RegulatoryInterfaceParams, filePath: string,
|
2025-05-22 17:04:06 +08:00
|
|
|
context: common.UIAbilityContext): Promise<WR> {
|
2025-04-10 10:28:07 +08:00
|
|
|
|
|
|
|
|
const singlePlay: boolean = AppStorage.get<boolean>('singlePlay') || false
|
|
|
|
|
if (singlePlay) {
|
|
|
|
|
return { code: 1 }
|
|
|
|
|
}
|
|
|
|
|
let JGHOST: string = AppStorage.get<string>("JGHOST") || ""
|
|
|
|
|
//获取监管接口地址路径
|
|
|
|
|
if (!JGHOST) {
|
|
|
|
|
const syssetParams: MASYSSETTableType[] = await GetSyncData<MASYSSETTableType>("MA_SYSSET");
|
|
|
|
|
|
|
|
|
|
syssetParams.forEach(sys => {
|
|
|
|
|
if (sys.v_no == '839') {
|
|
|
|
|
//是否是新监管
|
|
|
|
|
// globalThis.isJGNew = sys.v_value == '3'
|
|
|
|
|
AppStorage.setOrCreate('isJGNew', sys.v_value == '3')
|
|
|
|
|
}
|
|
|
|
|
if (sys.v_no == '900') {
|
|
|
|
|
// globalThis.JGHOST = validateIP(decodeURIComponent(sys.v_value))
|
2025-05-22 17:04:06 +08:00
|
|
|
AppStorage.setOrCreate('JGHOST', validateIP(decodeURIComponent(sys.v_value || "")))
|
2025-04-10 10:28:07 +08:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// const { xtlb, jkxlh, jkid, drvexam } = params;
|
|
|
|
|
const isJGNew: boolean = AppStorage.get<boolean>('isJGNew') || false
|
|
|
|
|
//新监管调用
|
|
|
|
|
if (isJGNew) {
|
|
|
|
|
return await writeObjectOutNew(params, filePath, context)
|
|
|
|
|
}
|
|
|
|
|
params.drvexam = params.drvexam ?? {};
|
|
|
|
|
params.drvexam.zp = params.drvexam.zp === undefined ? undefined : encodeURIComponent(params.drvexam.zp);
|
|
|
|
|
|
|
|
|
|
const drvexamArrs = Object.entries(params.drvexam)
|
|
|
|
|
.filter((item: [string, string]) => item[1] != undefined)
|
|
|
|
|
.map((item: [string, object]) => `<${item[0]}>${item[1]}</${item[0]}>`)
|
|
|
|
|
// const drvexamArrs = Reflect.ownKeys(params.drvexam)
|
|
|
|
|
// .filter(dKey => Reflect.get(params.drvexam, dKey) != undefined)
|
|
|
|
|
// .map((key: string) => (
|
|
|
|
|
// `<${key}>${Reflect.get(params.drvexam, key)}</${key}>`));
|
|
|
|
|
|
|
|
|
|
if (filePath) {
|
|
|
|
|
const fileUtil = new FileUtils(context);
|
|
|
|
|
await fileUtil.initFolder(filePath);
|
|
|
|
|
|
|
|
|
|
let obj: WuxiExamType = {
|
|
|
|
|
xtlb: params.xtlb,
|
|
|
|
|
jkxlh: params.jkxlh,
|
|
|
|
|
jkid: params.jkid,
|
|
|
|
|
drvexam: {
|
|
|
|
|
zp: "",
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`, JSON.stringify(obj) + `\n`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//对象转换成xml
|
|
|
|
|
JGHOST = AppStorage.get<string>("JGHOST") || ""
|
|
|
|
|
const temp = await request<object>({
|
|
|
|
|
host: JGHOST,
|
|
|
|
|
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">
|
|
|
|
|
<xtlb>${params.xtlb}</xtlb>
|
|
|
|
|
<jkxlh>${params.jkxlh}</jkxlh>
|
|
|
|
|
<jkid>${params.jkid}</jkid>
|
|
|
|
|
<UTF8XmlDoc>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
<?xm lversion="1.0 "encoding="GBK"?>
|
|
|
|
|
<root>
|
|
|
|
|
<drvexam>
|
|
|
|
|
${drvexamArrs}
|
|
|
|
|
</drvexam>
|
|
|
|
|
</root>
|
|
|
|
|
]]>
|
|
|
|
|
</UTF8XmlDoc>
|
|
|
|
|
</writeObjectOut>
|
|
|
|
|
</SOAP-ENV:Body>
|
|
|
|
|
</SOAP-ENV:Envelope>`,
|
|
|
|
|
method: http.RequestMethod.POST,
|
|
|
|
|
xml: true
|
|
|
|
|
},)
|
|
|
|
|
if (filePath) {
|
|
|
|
|
const fileUtil = new FileUtils(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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface UploadExamProgressDataParams {
|
|
|
|
|
carId: string
|
|
|
|
|
examinationRoomId: string
|
|
|
|
|
type: number
|
|
|
|
|
time: string
|
|
|
|
|
cardNo: string
|
|
|
|
|
examData: string
|
|
|
|
|
examStartTime: string
|
|
|
|
|
examEndTime: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 过程文件上传
|
|
|
|
|
export async function uploadExamProgressData(params: UploadExamProgressDataParams) {
|
|
|
|
|
const singlePlay: boolean = AppStorage.get<boolean>('singlePlay') || false
|
|
|
|
|
if (singlePlay) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
return request<object>({
|
|
|
|
|
url: '/der2/services/exam/uploadExamDataFile.ws',
|
|
|
|
|
data: `<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
<uploadExamDataFileReq>
|
|
|
|
|
<head><time>${params.time}</time></head>
|
|
|
|
|
<body>
|
|
|
|
|
<carId>${params.carId}</carId>
|
|
|
|
|
<examinationRoomId>${params.examinationRoomId}</examinationRoomId>
|
|
|
|
|
<examData>${params.examData}</examData>
|
|
|
|
|
<type>${params.type}</type>
|
|
|
|
|
<cardNo>${params.cardNo}</cardNo>
|
|
|
|
|
<examStartTime>${params.examStartTime}</examStartTime>
|
|
|
|
|
<examEndTime>${params.examEndTime}</examEndTime>
|
|
|
|
|
</body>
|
|
|
|
|
</uploadExamDataFileReq>`,
|
|
|
|
|
method: http.RequestMethod.POST,
|
|
|
|
|
xml: true
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface UploadExamProgressDataParams2 {
|
|
|
|
|
carId: string
|
|
|
|
|
examinationRoomId: string
|
|
|
|
|
type: string
|
|
|
|
|
time: string
|
|
|
|
|
cardNo: string
|
|
|
|
|
examData: string
|
|
|
|
|
examStartTime: string
|
|
|
|
|
examEndTime: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function uploadExamProgressData2(params: UploadExamProgressDataParams2) {
|
|
|
|
|
// const singlePlay = globalThis.singlePlay
|
|
|
|
|
const singlePlay: boolean = AppStorage.get<boolean>('singlePlay') || false
|
|
|
|
|
if (singlePlay) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
return request<object>({
|
|
|
|
|
url: '/der2/services/exam/uploadExamDataFile.ws',
|
|
|
|
|
data: `<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
<uploadExamDataFileReq>
|
|
|
|
|
<head><time>${params.time}</time></head>
|
|
|
|
|
<body>
|
|
|
|
|
<carId>${params.carId}</carId>
|
|
|
|
|
<examinationRoomId>${params.examinationRoomId}</examinationRoomId>
|
|
|
|
|
<examData>${params.examData}</examData>
|
|
|
|
|
<type>${params.type}</type>
|
|
|
|
|
<cardNo>${params.cardNo}</cardNo>
|
|
|
|
|
<examStartTime>${params.examStartTime}</examStartTime>
|
|
|
|
|
<examEndTime>${params.examEndTime}</examEndTime>
|
|
|
|
|
</body>
|
|
|
|
|
</uploadExamDataFileReq>`,
|
|
|
|
|
method: http.RequestMethod.POST,
|
|
|
|
|
xml: true
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface UploadExamMileage {
|
|
|
|
|
carId: string
|
|
|
|
|
examinationRoomId: string
|
|
|
|
|
lsh: string
|
|
|
|
|
kslc: number
|
|
|
|
|
kskssj: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 上传考试里程
|
|
|
|
|
export async function uploadExamMileage(params: UploadExamMileage) {
|
|
|
|
|
// const singlePlay = globalThis.singlePlay
|
|
|
|
|
const singlePlay: boolean = AppStorage.get<boolean>('singlePlay') || false
|
|
|
|
|
|
|
|
|
|
if (singlePlay) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
const time = GetCurrentTime()
|
|
|
|
|
return request<object>({
|
|
|
|
|
url: '/der2/services/exam/uploadExamMileage.ws',
|
|
|
|
|
data: `<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
<uploadExamMileageReq>
|
|
|
|
|
<head><time>${time}</time></head>
|
|
|
|
|
<body>
|
|
|
|
|
<carId>${params.carId}<carId>
|
|
|
|
|
<examinationRoomId>${params.examinationRoomId}<examinationRoomId>
|
|
|
|
|
<lsh>${params.lsh}<lsh>
|
|
|
|
|
<kskssj>${params.examinationRoomId}<kskssj>
|
|
|
|
|
<kslc>${params.kslc}<kslc>
|
|
|
|
|
</body>
|
|
|
|
|
</uploadExamMileageReq>`,
|
|
|
|
|
method: http.RequestMethod.POST,
|
|
|
|
|
xml: true
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 上传考试成绩
|
|
|
|
|
// export async function uploadExamGrade(params: ESObject) {
|
|
|
|
|
// // const singlePlay = globalThis.singlePlay
|
|
|
|
|
// const singlePlay: boolean = AppStorage.get<boolean>('singlePlay') || false
|
|
|
|
|
// if (singlePlay) {
|
|
|
|
|
// return
|
|
|
|
|
// }
|
|
|
|
|
// const paramsArrs = Reflect.ownKeys(params).map((key) => (`<${key}>${params[key]}</${key}>`))
|
|
|
|
|
// const time = GetCurrentTime()
|
|
|
|
|
// return request<object>({
|
|
|
|
|
// url: '/der2/services/exam/uploadExamGrade.ws',
|
|
|
|
|
// data: `<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
// <uploadExamGradeReq>
|
|
|
|
|
// <head><time>${time}</time></head>
|
|
|
|
|
// <body>
|
|
|
|
|
// ${paramsArrs}
|
|
|
|
|
// </body>
|
|
|
|
|
// </uploadExamGradeReq>`,
|
|
|
|
|
// method: http.RequestMethod.POST,
|
|
|
|
|
// xml: true
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
function validateIP(path: string) {
|
|
|
|
|
const reg = new RegExp(`(\w+):\/\/([^/:]+)(:\d*)?`)
|
|
|
|
|
const result = path.match(reg);
|
|
|
|
|
return result ? result[0] : "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 上传运行时常
|
|
|
|
|
export async function uploadHarmonyLiCheng(data: object) {
|
|
|
|
|
return request<object>({
|
|
|
|
|
url: '/der2/services/data/harmonyLiCheng.ws',
|
|
|
|
|
data,
|
|
|
|
|
method: http.RequestMethod.POST,
|
|
|
|
|
xml: false
|
|
|
|
|
})
|
|
|
|
|
}
|