报文示例
简易html生成XML报文并压缩zip文件的示例
车辆进出境确报
载货车辆进境确报申报样例报文
.hmtl:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>https://shootchat.top的确报示例</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.6.0/jszip.min.js"></script>
</head>
<body>
<h1>https://shootchat.top的确报示例</h1>
<form id="xmlForm" onsubmit="generateAndDownload(); return false;">
<label for="declarationOfficeID">DeclarationOfficeID:</label>
<input type="text" id="declarationOfficeID" value="5301"><br><br>
<label for="ID">ID:</label>
<input type="text" id="ID" value="4400123456789"><br><br>
<label for="arrivalDateTime">ArrivalDateTime:</label>
<input type="text" id="arrivalDateTime" value="20231009000000"><br><br>
<button type="submit">生成报文</button>
<br/>
<br/>
<br>请复制到文件夹确报</br>
<br>(默认地址C:\ImpPath\Rmft\OutBox)</br>
</form>
<script>
function getCurrentTimestamp() {
const date = new Date();
const timestamp = date.toISOString().replace(/-|:|\.|T|Z/g, '');
return timestamp;
}
function getCurrentDate() {
const date = new Date();
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
return `${year}${month}${day}`;
}
function generateXML() {
const declarationOfficeID = document.getElementById('declarationOfficeID').value;
const ID = document.getElementById('ID').value;
const arrivalDateTime = document.getElementById('arrivalDateTime').value;
const sendTime = getCurrentTimestamp();
return `<?xml version="1.0" encoding="UTF-8"?>
<Manifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:Declaration:datamodel:standard:CN:MT4401:1">
<Head>
<MessageID>EPORT_MT4401_1p0_0000123456789_${sendTime}</MessageID>
<FunctionCode>2</FunctionCode>
<MessageType>MT4401</MessageType>
<SenderID>0000123456789_0000000000</SenderID>
<ReceiverID>EPORT</ReceiverID>
<SendTime>${sendTime}</SendTime>
<Version>1.0</Version>
</Head>
<Declaration>
<DeclarationOfficeID>${declarationOfficeID}</DeclarationOfficeID>
<ID>${ID}</ID>
<Consignment>
<BorderTransportMeans>
<ArrivalDateTime>${arrivalDateTime}</ArrivalDateTime>
<ID>5300000000</ID>
<Name>粤ZOOOO港</Name>
<TypeCode>3</TypeCode>
<RoutingCountryCode>HK</RoutingCountryCode>
<Master>
<ID>54000000</ID>
<Name>张三</Name>
<NumStaffMember>1</NumStaffMember>
<HealthStatus>1</HealthStatus>
<Vaccinate>1</Vaccinate>
</Master>
</BorderTransportMeans>
</Consignment>
<RepresentativePerson>
<Name>深圳某某公司</Name>
</RepresentativePerson>
</Declaration>
</Manifest>`;
}
function generateAndDownload() {
const xmlData = generateXML();
const zip = new JSZip();
zip.file('data.xml', xmlData);
zip.generateAsync({ type: 'blob' })
.then(function (blob) {
const a = document.createElement('a');
const url = URL.createObjectURL(blob);
a.href = url;
a.download = 'data.zip';
a.click();
URL.revokeObjectURL(url);
});
}
</script>
</body>
</html>
生成的XML文件并压缩成zip包
<Manifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:Declaration:datamodel:standard:CN:MT4401:1">
<Head>
<MessageID>EPORT_MT4401_1p0_0000123456789_20231009080729219</MessageID>
<FunctionCode>2</FunctionCode>
<MessageType>MT4401</MessageType>
<SenderID>0000123456789_0000000000</SenderID>
<ReceiverID>EPORT</ReceiverID>
<SendTime>20231009080729219</SendTime>
<Version>1.0</Version>
</Head>
<Declaration>
<DeclarationOfficeID>5301</DeclarationOfficeID>
<ID>4400123456789</ID>
<Consignment>
<BorderTransportMeans>
<ArrivalDateTime>20231009000000</ArrivalDateTime>
<ID>5300000000</ID>
<Name>粤ZOOOO港</Name>
<TypeCode>3</TypeCode>
<RoutingCountryCode>HK</RoutingCountryCode>
<Master>
<ID>54000000</ID>
<Name>张三</Name>
<NumStaffMember>1</NumStaffMember>
<HealthStatus>1</HealthStatus>
<Vaccinate>1</Vaccinate>
</Master>
</BorderTransportMeans>
</Consignment>
<RepresentativePerson>
<Name>深圳某某公司</Name>
</RepresentativePerson>
</Declaration>
</Manifest>