200 lines
6.1 KiB
TypeScript
200 lines
6.1 KiB
TypeScript
import request from "../common/utils/request"
|
|
import { getCurrentTime } from '../common/utils/tools'
|
|
import { getSyncData } from '../common/service/initable';
|
|
import writeObjectOutNew from './judgeNew'
|
|
import FileUtil from '../common/utils/File';
|
|
let baseHost = globalThis.host;
|
|
|
|
|
|
// 下载模型
|
|
export async function download() {
|
|
return await request({
|
|
host: baseHost,
|
|
url: '/para/initEsModel.ws',
|
|
method: 'post',
|
|
xml: false
|
|
})
|
|
}
|
|
|
|
interface WR{
|
|
message?:string
|
|
code?:number
|
|
keystr?:string
|
|
}
|
|
// 通用监管接口
|
|
export async function writeObjectOut(params,filePath?:string): Promise<WR> {
|
|
const singlePlay = globalThis.singlePlay
|
|
if (singlePlay) {
|
|
return {code:1}
|
|
}
|
|
//获取监管接口地址路径
|
|
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))
|
|
}
|
|
})
|
|
}
|
|
const {xtlb,jkxlh,jkid,drvexam} = params;
|
|
|
|
//新监管调用
|
|
if (globalThis.isJGNew) {
|
|
return await writeObjectOutNew(params,filePath)
|
|
}
|
|
drvexam.zp = drvexam.zp === undefined ? undefined : encodeURIComponent( drvexam.zp)
|
|
|
|
const drvexamArrs = Reflect.ownKeys(drvexam)
|
|
.filter(dKey => drvexam[dKey] != undefined)
|
|
.map((key: string) => (
|
|
`<${key}>${drvexam[key]}</${key}>`));
|
|
|
|
console.log('surenjun filePath=>',filePath);
|
|
if(filePath){
|
|
const fileUtil = new FileUtil(globalThis.context);
|
|
await fileUtil.initFolder(filePath);
|
|
fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`,JSON.stringify({
|
|
xtlb,jkxlh,jkid,drvexam:{...drvexam,zp:''},
|
|
}) +`\n`);
|
|
}
|
|
|
|
//对象转换成xml
|
|
const temp = await request({
|
|
host: globalThis.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>${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>`,
|
|
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
|
|
}
|
|
|
|
// 过程文件上传
|
|
export async function uploadExamProgressData(params) {
|
|
const singlePlay = globalThis.singlePlay
|
|
const {carId,examinationRoomId,type,time,cardNo,examData,examStartTime,examEndTime} = params
|
|
if (singlePlay) {
|
|
return
|
|
}
|
|
return await request({
|
|
url: '/der2/services/exam/uploadExamDataFile.ws',
|
|
data: `<?xml version="1.0" encoding="UTF-8"?>
|
|
<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>`,
|
|
method: 'post',
|
|
xml: true
|
|
})
|
|
}
|
|
|
|
// 上传考试里程
|
|
export async function uploadExamMileage(params) {
|
|
const singlePlay = globalThis.singlePlay
|
|
if (singlePlay) {
|
|
return
|
|
}
|
|
const time = await getCurrentTime()
|
|
return await request({
|
|
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: 'post',
|
|
xml: true
|
|
})
|
|
}
|
|
|
|
// 上传考试成绩
|
|
export async function uploadExamGrade(params) {
|
|
const singlePlay = globalThis.singlePlay
|
|
if (singlePlay) {
|
|
return
|
|
}
|
|
const paramsArrs = Reflect.ownKeys(params).map((key: string) => (`<${key}>${params[key]}</${key}>`))
|
|
const time = await getCurrentTime()
|
|
return await request({
|
|
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: 'post',
|
|
xml: true
|
|
})
|
|
}
|
|
|
|
function validateIP(path: string) {
|
|
const reg = new RegExp(/(\w+):\/\/([^/:]+)(:\d*)?/)
|
|
const result = path.match(reg);
|
|
return result[0]
|
|
}
|
|
|
|
// 上传运行时常
|
|
export async function uploadHarmonyLiCheng(data) {
|
|
return await request({
|
|
url: '/der2/services/data/harmonyLiCheng.ws',
|
|
data,
|
|
method: 'post',
|
|
})
|
|
}
|
|
|