199 lines
6.1 KiB
TypeScript
Raw Normal View History

2024-01-05 11:11:15 +08:00
import request from "../common/utils/request"
2024-07-31 13:47:40 +08:00
import { getCurrentTime } from '../common/utils/tools'
import { getSyncData } from '../common/service/initable';
import writeObjectOutNew from './judgeNew'
2024-08-05 09:47:44 +08:00
import FileUtil from '../common/utils/File';
2024-07-31 13:47:40 +08:00
let baseHost = globalThis.host;
2024-01-05 11:11:15 +08:00
// 下载模型
2024-07-31 13:47:40 +08:00
export async function download() {
2025-01-07 15:50:48 +08:00
return request({
2024-07-31 13:47:40 +08:00
host: baseHost,
url: '/para/initEsModel.ws',
method: 'post',
xml: false
2024-01-05 11:11:15 +08:00
})
}
2024-08-12 10:19:31 +08:00
interface WR{
message?:string
2024-08-19 10:11:22 +08:00
code?:number
keystr?:string
2024-08-12 10:19:31 +08:00
}
2024-01-05 11:11:15 +08:00
// 通用监管接口
2024-08-12 10:19:31 +08:00
export async function writeObjectOut(params,filePath?:string): Promise<WR> {
2024-01-05 11:11:15 +08:00
const singlePlay = globalThis.singlePlay
2024-07-31 13:47:40 +08:00
if (singlePlay) {
2024-08-12 10:19:31 +08:00
return {code:1}
2024-07-31 13:47:40 +08:00
}
//获取监管接口地址路径
if (!globalThis.JGPATH) {
const syssetParams = await getSyncData('MA_SYSSET') || [];
//@ts-ignore
syssetParams.forEach(sys => {
if (sys.v_no == '839') {
//是否是新监管
globalThis.isJGNew = sys.v_value == '3'
}
if (sys.v_no == '900') {
globalThis.JGHOST = validateIP(decodeURIComponent(sys.v_value))
}
})
2024-01-05 11:11:15 +08:00
}
2024-07-31 13:47:40 +08:00
const {xtlb,jkxlh,jkid,drvexam} = params;
2024-12-31 17:51:25 +08:00
2024-07-31 13:47:40 +08:00
//新监管调用
if (globalThis.isJGNew) {
2024-08-05 09:47:44 +08:00
return await writeObjectOutNew(params,filePath)
2024-07-31 13:47:40 +08:00
}
2024-08-12 10:19:31 +08:00
drvexam.zp = drvexam.zp === undefined ? undefined : encodeURIComponent( drvexam.zp)
2024-08-15 09:01:09 +08:00
const drvexamArrs = Reflect.ownKeys(drvexam)
.filter(dKey => drvexam[dKey] != undefined)
.map((key: string) => (
2024-12-31 17:51:25 +08:00
`<${key}>${drvexam[key]}</${key}>`));
2024-08-05 09:47:44 +08:00
2024-12-31 17:51:25 +08:00
console.log('surenjun filePath=>',filePath);
2024-08-05 09:47:44 +08:00
if(filePath){
const fileUtil = new FileUtil(globalThis.context);
await fileUtil.initFolder(filePath);
fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`,JSON.stringify({
2024-08-19 10:11:22 +08:00
xtlb,jkxlh,jkid,drvexam:{...drvexam,zp:''},
2024-08-20 14:49:22 +08:00
}) +`\n`);
2024-08-05 09:47:44 +08:00
}
2024-01-05 11:11:15 +08:00
//对象转换成xml
2025-01-07 15:50:48 +08:00
const temp = request({
2024-07-31 13:47:40 +08:00
host: globalThis.JGHOST,
url: '/dems_ws/services/TmriOutAccess?wsdl',
data: `<?xml version="1.0"?>
2024-01-05 11:11:15 +08:00
<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>${xtlb}</xtlb>
<jkxlh>${jkxlh}</jkxlh>
<jkid>${jkid}</jkid>
<UTF8XmlDoc>
<![CDATA[
<?xm lversion="1.0 "encoding="GBK"?>
<root>
<drvexam>
${drvexamArrs}
</drvexam>
</root>
]]>
</UTF8XmlDoc>
</writeObjectOut>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>`,
2024-07-31 13:47:40 +08:00
method: 'post',
xml: true
2024-12-31 17:51:25 +08:00
},)
2024-08-20 14:49:22 +08:00
if(filePath){
const fileUtil = new FileUtil(globalThis.context);
await fileUtil.initFolder(filePath);
fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`,JSON.stringify(temp) +`\n`);
}
2024-12-31 17:51:25 +08:00
// const {code} = temp;
// if(code == '2300007' || code == '2300028'){
// return await writeObjectOut(params,filePath)
// }else{
// return temp
// }
2024-07-31 13:47:40 +08:00
return temp
2024-01-05 11:11:15 +08:00
}
// 过程文件上传
2024-07-31 13:47:40 +08:00
export async function uploadExamProgressData(params) {
2024-01-05 11:11:15 +08:00
const singlePlay = globalThis.singlePlay
const {carId,examinationRoomId,type,time,cardNo,examData,examStartTime,examEndTime} = params
2024-07-31 13:47:40 +08:00
if (singlePlay) {
2024-01-05 11:11:15 +08:00
return
}
2025-01-07 15:50:48 +08:00
return request({
2024-07-31 13:47:40 +08:00
url: '/der2/services/exam/uploadExamDataFile.ws',
data: `<?xml version="1.0" encoding="UTF-8"?>
2024-01-05 11:11:15 +08:00
<uploadExamDataFileReq>
<head><time>${time}</time></head>
<body>
<carId>${carId}</carId>
<examinationRoomId>${examinationRoomId}</examinationRoomId>
<examData>${examData}</examData>
<type>${type}</type>
<cardNo>${cardNo}</cardNo>
<examStartTime>${examStartTime}</examStartTime>
<examEndTime>${examEndTime}</examEndTime>
</body>
</uploadExamDataFileReq>`,
2024-07-31 13:47:40 +08:00
method: 'post',
xml: true
2024-01-05 11:11:15 +08:00
})
}
// 上传考试里程
2024-07-31 13:47:40 +08:00
export async function uploadExamMileage(params) {
2024-01-05 11:11:15 +08:00
const singlePlay = globalThis.singlePlay
2024-07-31 13:47:40 +08:00
if (singlePlay) {
2024-01-05 11:11:15 +08:00
return
}
const time = await getCurrentTime()
2025-01-07 15:50:48 +08:00
return request({
2024-07-31 13:47:40 +08:00
url: '/der2/services/exam/uploadExamMileage.ws',
data: `<?xml version="1.0" encoding="UTF-8"?>
2024-01-05 11:11:15 +08:00
<uploadExamMileageReq>
<head><time>${time}</time></head>
<body>
2024-07-31 13:47:40 +08:00
<carId>${params.carId}<carId>
<examinationRoomId>${params.examinationRoomId}<examinationRoomId>
<lsh>${params.lsh}<lsh>
<kskssj>${params.examinationRoomId}<kskssj>
<kslc>${params.kslc}<kslc>
2024-01-05 11:11:15 +08:00
</body>
</uploadExamMileageReq>`,
2024-07-31 13:47:40 +08:00
method: 'post',
xml: true
2024-01-05 11:11:15 +08:00
})
}
2024-07-31 13:47:40 +08:00
2024-01-05 11:11:15 +08:00
// 上传考试成绩
2024-07-31 13:47:40 +08:00
export async function uploadExamGrade(params) {
2024-01-05 11:11:15 +08:00
const singlePlay = globalThis.singlePlay
2024-07-31 13:47:40 +08:00
if (singlePlay) {
2024-01-05 11:11:15 +08:00
return
}
2024-07-31 13:47:40 +08:00
const paramsArrs = Reflect.ownKeys(params).map((key: string) => (`<${key}>${params[key]}</${key}>`))
2024-01-05 11:11:15 +08:00
const time = await getCurrentTime()
2025-01-07 15:50:48 +08:00
return request({
2024-07-31 13:47:40 +08:00
url: '/der2/services/exam/uploadExamGrade.ws',
data: `<?xml version="1.0" encoding="UTF-8"?>
2024-01-05 11:11:15 +08:00
<uploadExamGradeReq>
<head><time>${time}</time></head>
<body>
${paramsArrs}
</body>
</uploadExamGradeReq>`,
2024-07-31 13:47:40 +08:00
method: 'post',
xml: true
2024-01-05 11:11:15 +08:00
})
}
2024-07-31 13:47:40 +08:00
function validateIP(path: string) {
const reg = new RegExp(/(\w+):\/\/([^/:]+)(:\d*)?/)
const result = path.match(reg);
return result[0]
}
2024-10-11 13:47:24 +08:00
// 上传运行时常
export async function uploadHarmonyLiCheng(data) {
2025-01-07 15:50:48 +08:00
return request({
2024-10-11 13:47:24 +08:00
url: '/der2/services/data/harmonyLiCheng.ws',
data,
method: 'post',
})
}