作者 shenhailong

修改所有出港生成报文报文头部信息 添加工厂模式

@@ -132,8 +132,9 @@ custom: @@ -132,8 +132,9 @@ custom:
132 send-path: ./send/ 132 send-path: ./send/
133 #海关备案编码 133 #海关备案编码
134 custom-code: 460470678920X 134 custom-code: 460470678920X
135 - #企业备案编码 135 + #舱单传输人名称
136 org-code: 9141010070678920XJ 136 org-code: 9141010070678920XJ
137 tcs: 137 tcs:
  138 + #企业备案编码
138 mq-number: DXPENT0000460002 139 mq-number: DXPENT0000460002
139 140
@@ -59,7 +59,6 @@ public class MT1201Controller { @@ -59,7 +59,6 @@ public class MT1201Controller {
59 @PutMapping("/removeMt1201") 59 @PutMapping("/removeMt1201")
60 @ResponseBody 60 @ResponseBody
61 public Map<String, Object> removeMt1201(@RequestBody Map<String, Object> map){ 61 public Map<String, Object> removeMt1201(@RequestBody Map<String, Object> map){
62 -  
63 try { 62 try {
64 63
65 return mt1201Service.removeMt1201(map); 64 return mt1201Service.removeMt1201(map);
  1 +package com.sunyo.wlpt.message.builder.factory;
  2 +
  3 +import com.sunyo.wlpt.message.builder.util.CustomXmlMaker;
  4 +import com.tianbo.util.Date.DateUtil;
  5 +
  6 +import java.util.HashMap;
  7 +import java.util.Map;
  8 +
  9 +/**
  10 + * shenhailong
  11 + * 2020/4/22/18:25
  12 + */
  13 +public class CustomsXmlAnalysisHeader implements CustomsXmlHeader {
  14 +
  15 + /**
  16 + * 生成所有报文头部信息
  17 + * @param customCode 关区代码
  18 + * @param orgsn 海关备案编码
  19 + * @param waylbillNo 主单号
  20 + * @param orgCode 舱单传输人名称
  21 + * @param tcssn 企业备案编码
  22 + * @return
  23 + */
  24 + @Override
  25 + public Map<String, Object> makeHeader(String customCode, String orgsn, String waylbillNo, String orgCode, String tcssn, String mtType) {
  26 + Map<String, Object> map = new HashMap<>();
  27 + CustomXmlMaker customXmlMaker = new CustomXmlMaker();
  28 + // 报文头部信息 messageId
  29 + String messageId = customXmlMaker.makeMsgID(mtType, orgsn, waylbillNo);
  30 + // 报文头部信息
  31 + String senderID = customXmlMaker.makeSenderID(customCode, orgsn, tcssn);
  32 + // 报文头部信息 customCode就是ReceiverID
  33 + // 报文头部信息 sendTime
  34 + String sendTime = DateUtil.getCurrentTime17();
  35 +
  36 + map.put("messageID", messageId);
  37 + map.put("senderID", senderID);
  38 + map.put("receiverID", customCode);
  39 + map.put("sendTime", sendTime);
  40 + return map;
  41 + }
  42 +}
  1 +package com.sunyo.wlpt.message.builder.factory;
  2 +
  3 +/**
  4 + * shenhailong
  5 + * 2020/4/23/09:37
  6 + */
  7 +public class CustomsXmlFactory {
  8 +
  9 + public CustomsXmlHeader getCustomsXmlHeader(String customsXmlHeaderType){
  10 +
  11 + if (customsXmlHeaderType == null && "".equals(customsXmlHeaderType)){
  12 + return null;
  13 + }
  14 +
  15 + if ("MESSAGE".equalsIgnoreCase(customsXmlHeaderType)){
  16 + return new CustomsXmlAnalysisHeader();
  17 + }
  18 +
  19 + return null;
  20 +
  21 + }
  22 +
  23 +}
  1 +package com.sunyo.wlpt.message.builder.factory;
  2 +
  3 +import java.util.Map;
  4 +
  5 +public interface CustomsXmlHeader {
  6 +
  7 + Map<String, Object> makeHeader(String customCode, String orgsn, String waylbillNo, String orgCode, String tcssn, String mtType);
  8 +
  9 +}
@@ -89,6 +89,7 @@ public class MT1201ServiceImp extends CustomXmlMaker implements MT1201Service{ @@ -89,6 +89,7 @@ public class MT1201ServiceImp extends CustomXmlMaker implements MT1201Service{
89 89
90 90
91 public Map<String, Object> mt1201(Map<String, Object> map) throws IOException, ParseException { 91 public Map<String, Object> mt1201(Map<String, Object> map) throws IOException, ParseException {
  92 +
92 ObjectMapper objectMapper = new ObjectMapper(); 93 ObjectMapper objectMapper = new ObjectMapper();
93 // 预配 94 // 预配
94 NMMS_CUSTOM_MT1201 customMt1201 = objectMapper.convertValue(map.get("mt1201"), NMMS_CUSTOM_MT1201.class); 95 NMMS_CUSTOM_MT1201 customMt1201 = objectMapper.convertValue(map.get("mt1201"), NMMS_CUSTOM_MT1201.class);
@@ -110,11 +111,9 @@ public class MT1201ServiceImp extends CustomXmlMaker implements MT1201Service{ @@ -110,11 +111,9 @@ public class MT1201ServiceImp extends CustomXmlMaker implements MT1201Service{
110 // 封装实体 111 // 封装实体
111 map.put("mt", customMt1201); 112 map.put("mt", customMt1201);
112 map.put("awbAwbinfo", awbAwbinfo); 113 map.put("awbAwbinfo", awbAwbinfo);
113 -  
114 // 处理主单号- 114 // 处理主单号-
115 String awba = ReturnUtil.awbaReplace(customMt1201.getAwba()); 115 String awba = ReturnUtil.awbaReplace(customMt1201.getAwba());
116 map.put("awba", awba); 116 map.put("awba", awba);
117 -  
118 // 生成报文头部 117 // 生成报文头部
119 String msgId = makeMsgID("MT1201", orgsn, customMt1201.getAwba()); 118 String msgId = makeMsgID("MT1201", orgsn, customMt1201.getAwba());
120 String senderId = makeSenderID(customCode, orgsn, ""); 119 String senderId = makeSenderID(customCode, orgsn, "");
@@ -6,6 +6,8 @@ import com.sunyo.wlpt.base.model.AWB_AWBINFO; @@ -6,6 +6,8 @@ import com.sunyo.wlpt.base.model.AWB_AWBINFO;
6 import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT2201; 6 import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT2201;
7 import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT4201; 7 import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT4201;
8 import com.sunyo.wlpt.base.model.NMMS_CUSTOM_RESPONSE; 8 import com.sunyo.wlpt.base.model.NMMS_CUSTOM_RESPONSE;
  9 +import com.sunyo.wlpt.message.builder.factory.CustomsXmlFactory;
  10 +import com.sunyo.wlpt.message.builder.factory.CustomsXmlHeader;
9 import com.sunyo.wlpt.message.builder.service.MT2201Service; 11 import com.sunyo.wlpt.message.builder.service.MT2201Service;
10 import com.sunyo.wlpt.message.builder.util.CustomXmlMaker; 12 import com.sunyo.wlpt.message.builder.util.CustomXmlMaker;
11 import com.sunyo.wlpt.message.builder.util.ReturnUtil; 13 import com.sunyo.wlpt.message.builder.util.ReturnUtil;
@@ -79,27 +81,23 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service { @@ -79,27 +81,23 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service {
79 public Map<String, Object> removeMt2201(Map<String, Object> map) throws IOException, ParseException { 81 public Map<String, Object> removeMt2201(Map<String, Object> map) throws IOException, ParseException {
80 82
81 String customCode = map.get("customCode").toString(); 83 String customCode = map.get("customCode").toString();
82 - // 生成报文头部  
83 - String msgId = makeMsgID("MT2201", orgsn, map.get("awba").toString());  
84 - String senderId = makeSenderID(customCode, orgsn, "");  
85 - String receiverID = customCode;  
86 - map.put("msgId", msgId);  
87 - map.put("senderId", senderId);  
88 - map.put("receiverID", receiverID);  
89 - // 报文头时间 精确到毫秒  
90 - map.put("sendTime", DateUtil.getCurrentTime17()); 84 +
  85 + // 生成报文头部信息
  86 + CustomsXmlFactory customsXmlFactory = new CustomsXmlFactory();
  87 + CustomsXmlHeader message = customsXmlFactory.getCustomsXmlHeader("MESSAGE");
  88 + Map<String, Object> mt2201 = message.makeHeader(customCode, orgsn, map.get("awba").toString(), orgCode, "", "MT2201");
  89 + map.put("map", mt2201);
  90 +
91 // 舱单传输人名称 91 // 舱单传输人名称
92 map.put("orgCode", orgCode); 92 map.put("orgCode", orgCode);
93 // 处理主单号- 93 // 处理主单号-
94 String awba = ReturnUtil.awbaReplace(map.get("awba").toString()); 94 String awba = ReturnUtil.awbaReplace(map.get("awba").toString());
95 map.put("awbas", awba); 95 map.put("awbas", awba);
96 -  
97 String flightDate = ReturnUtil.awbaReplace(map.get("flightDate").toString()); 96 String flightDate = ReturnUtil.awbaReplace(map.get("flightDate").toString());
98 map.put("flightDates",flightDate); 97 map.put("flightDates",flightDate);
99 -  
100 Map<String, Object> hashMap = new HashMap<>(); 98 Map<String, Object> hashMap = new HashMap<>();
101 // 生成报文 99 // 生成报文
102 - if (makeXmlToFile("/remove/MT2201.ftlx", msgId+".xml", map, "./send/remove/")>0){ 100 + if (makeXmlToFile("/remove/MT2201.ftlx", mt2201.get("messageID").toString()+".xml", map, "./send/remove/")>0){
103 map.put("functionCode", "3"); 101 map.put("functionCode", "3");
104 map.put("busType","MT2201"); 102 map.put("busType","MT2201");
105 System.out.println(); 103 System.out.println();
@@ -126,16 +124,6 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service { @@ -126,16 +124,6 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service {
126 AWB_AWBINFO awbAwbinfo = custom_mt2201.getAwbinfo(); 124 AWB_AWBINFO awbAwbinfo = custom_mt2201.getAwbinfo();
127 // 关区代码 125 // 关区代码
128 String customCode = custom_mt2201.getCustomcode(); 126 String customCode = custom_mt2201.getCustomcode();
129 - // 报文头时间 精确到毫秒  
130 - map.put("sendTime", DateUtil.getCurrentTime17());  
131 - // 处理 预付0 PP 到付 1 CC  
132 - if(awbAwbinfo.getCollected() != null && awbAwbinfo.getCollected() != ""){  
133 - if ("0".equals(awbAwbinfo.getCollected())){  
134 - awbAwbinfo.setCollected("PP");  
135 - }else {  
136 - awbAwbinfo.setCollected("CC");  
137 - }  
138 - }  
139 // 封装实体 127 // 封装实体
140 map.put("mt", custom_mt2201); 128 map.put("mt", custom_mt2201);
141 map.put("awbAwbinfo", awbAwbinfo); 129 map.put("awbAwbinfo", awbAwbinfo);
@@ -143,13 +131,12 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service { @@ -143,13 +131,12 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service {
143 String awba = ReturnUtil.awbaReplace(custom_mt2201.getAwba()); 131 String awba = ReturnUtil.awbaReplace(custom_mt2201.getAwba());
144 map.put("awba", awba); 132 map.put("awba", awba);
145 133
146 - // 生成报文头部  
147 - String msgId = makeMsgID("MT2201", orgsn, custom_mt2201.getAwba());  
148 - String senderId = makeSenderID(customCode, orgsn, "");  
149 - String receiverID = customCode;  
150 - map.put("msgId", msgId);  
151 - map.put("senderId", senderId);  
152 - map.put("receiverID", receiverID); 134 + // 生成报文头部信息
  135 + CustomsXmlFactory customsXmlFactory = new CustomsXmlFactory();
  136 + CustomsXmlHeader message = customsXmlFactory.getCustomsXmlHeader("MESSAGE");
  137 + Map<String, Object> mt2201 = message.makeHeader(customCode, orgsn, custom_mt2201.getAwba(), orgCode, "", "MT2201");
  138 + map.put("map", mt2201);
  139 +
153 String s = DateUtil.addDateMinut(new Date(), 6); 140 String s = DateUtil.addDateMinut(new Date(), 6);
154 // 货物装卸时间 141 // 货物装卸时间
155 map.put("loadingDate",s); 142 map.put("loadingDate",s);
@@ -158,7 +145,7 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service { @@ -158,7 +145,7 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service {
158 145
159 Map<String, Object> maps = new HashMap<>(); 146 Map<String, Object> maps = new HashMap<>();
160 // 生成报文 147 // 生成报文
161 - if (makeXmlToFile(map.get("templatePath").toString(), msgId+".xml", map, map.get("sendPath").toString())>0){ 148 + if (makeXmlToFile(map.get("templatePath").toString(), mt2201.get("messageID")+".xml", map, map.get("sendPath").toString())>0){
162 if (!map.containsKey("reason")){ 149 if (!map.containsKey("reason")){
163 map.put("functionCode", "9"); 150 map.put("functionCode", "9");
164 map.put("busType","MT2201"); 151 map.put("busType","MT2201");
@@ -3,6 +3,8 @@ package com.sunyo.wlpt.message.builder.service.imp; @@ -3,6 +3,8 @@ package com.sunyo.wlpt.message.builder.service.imp;
3 import com.fasterxml.jackson.databind.ObjectMapper; 3 import com.fasterxml.jackson.databind.ObjectMapper;
4 import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT3201; 4 import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT3201;
5 import com.sunyo.wlpt.base.model.NMMS_CUSTOM_RESPONSE; 5 import com.sunyo.wlpt.base.model.NMMS_CUSTOM_RESPONSE;
  6 +import com.sunyo.wlpt.message.builder.factory.CustomsXmlFactory;
  7 +import com.sunyo.wlpt.message.builder.factory.CustomsXmlHeader;
6 import com.sunyo.wlpt.message.builder.service.MT3201Service; 8 import com.sunyo.wlpt.message.builder.service.MT3201Service;
7 import com.sunyo.wlpt.message.builder.util.CustomXmlMaker; 9 import com.sunyo.wlpt.message.builder.util.CustomXmlMaker;
8 import com.sunyo.wlpt.message.builder.util.ReturnUtil; 10 import com.sunyo.wlpt.message.builder.util.ReturnUtil;
@@ -26,31 +28,29 @@ public class MT3201ServiceImp extends CustomXmlMaker implements MT3201Service { @@ -26,31 +28,29 @@ public class MT3201ServiceImp extends CustomXmlMaker implements MT3201Service {
26 @Value("${custom.org-code}") 28 @Value("${custom.org-code}")
27 private String orgCode; 29 private String orgCode;
28 30
  31 + @Value("${tcs.mq-number}")
  32 + private String tcss;
  33 +
29 @Override 34 @Override
30 public Map<String, Object> fohcreate(Map<String, Object> map) throws IOException, ParseException { 35 public Map<String, Object> fohcreate(Map<String, Object> map) throws IOException, ParseException {
31 36
32 ObjectMapper objectMapper = new ObjectMapper(); 37 ObjectMapper objectMapper = new ObjectMapper();
33 -  
34 NMMS_CUSTOM_MT3201 customMt3201 = objectMapper.convertValue(map.get("mt3201"), NMMS_CUSTOM_MT3201.class); 38 NMMS_CUSTOM_MT3201 customMt3201 = objectMapper.convertValue(map.get("mt3201"), NMMS_CUSTOM_MT3201.class);
35 // 关区代码 39 // 关区代码
36 String customCode = customMt3201.getCustomcode(); 40 String customCode = customMt3201.getCustomcode();
37 - // 报文头时间 精确到毫秒  
38 - map.put("sendTime", DateUtil.getCurrentTime17());  
39 -  
40 String awba = ReturnUtil.awbaReplace(customMt3201.getAwba()); 41 String awba = ReturnUtil.awbaReplace(customMt3201.getAwba());
41 map.put("awba", awba); 42 map.put("awba", awba);
42 // 封装实体 43 // 封装实体
43 map.put("mt", customMt3201); 44 map.put("mt", customMt3201);
44 - // 生成报文头部  
45 - String msgId = makeMsgID("MT3201", orgsn, customMt3201.getAwba());  
46 - String senderId = makeSenderID(customCode, orgsn, "");  
47 - String receiverID = customCode;  
48 - map.put("msgId", msgId);  
49 - map.put("senderId", senderId);  
50 - map.put("receiverID", receiverID); 45 +
  46 + // 生成报文头部信息
  47 + CustomsXmlFactory customsXmlFactory = new CustomsXmlFactory();
  48 + CustomsXmlHeader message = customsXmlFactory.getCustomsXmlHeader("MESSAGE");
  49 + Map<String, Object> mt3201 = message.makeHeader(customCode, orgsn, customMt3201.getAwba(), orgCode, tcss, "MT3201");
  50 + map.put("map", mt3201);
51 51
52 Map<String, Object> map3201= new HashMap<>(); 52 Map<String, Object> map3201= new HashMap<>();
53 - if (makeXmlToFile("/manifest/MT3201.ftlx", msgId+".xml", map,"./send/add/")>0){ 53 + if (makeXmlToFile("/manifest/MT3201.ftlx", mt3201.get("messageID")+".xml", map,"./send/add/")>0){
54 map.put("functionCode", "9"); 54 map.put("functionCode", "9");
55 map.put("busType","MT3201"); 55 map.put("busType","MT3201");
56 NMMS_CUSTOM_RESPONSE nmmsCustomResponse = ReturnUtil.nmmsCustomResponse(map); 56 NMMS_CUSTOM_RESPONSE nmmsCustomResponse = ReturnUtil.nmmsCustomResponse(map);
@@ -88,24 +88,21 @@ public class MT3201ServiceImp extends CustomXmlMaker implements MT3201Service { @@ -88,24 +88,21 @@ public class MT3201ServiceImp extends CustomXmlMaker implements MT3201Service {
88 public Map<String, Object> remove(Map<String, Object> map) throws IOException, ParseException { 88 public Map<String, Object> remove(Map<String, Object> map) throws IOException, ParseException {
89 // 关区代码 89 // 关区代码
90 String customCode = map.get("customCode").toString(); 90 String customCode = map.get("customCode").toString();
91 - // 报文头时间 精确到毫秒  
92 - map.put("sendTime", DateUtil.getCurrentTime17());  
93 - // 生成报文头部  
94 - String msgId = makeMsgID("MT3201", orgsn, map.get("awba").toString());  
95 - String senderId = makeSenderID(customCode, orgsn, "");  
96 - String receiverID = customCode;  
97 - map.put("msgId", msgId);  
98 - map.put("senderId", senderId);  
99 - map.put("receiverID", receiverID);  
100 91
101 String awba = ReturnUtil.awbaReplace(map.get("awba").toString()); 92 String awba = ReturnUtil.awbaReplace(map.get("awba").toString());
102 map.put("awbas", awba); 93 map.put("awbas", awba);
103 94
104 String flightDate = ReturnUtil.awbaReplace(map.get("flightDate").toString()); 95 String flightDate = ReturnUtil.awbaReplace(map.get("flightDate").toString());
105 map.put("flightDates",flightDate); 96 map.put("flightDates",flightDate);
106 -  
107 Map<String, Object> map3201 = new HashMap<>(); 97 Map<String, Object> map3201 = new HashMap<>();
108 - if (makeXmlToFile("/remove/MT3201.ftlx", msgId+".xml", map,"./send/remove/")>0){ 98 +
  99 + // 生成报文头部信息
  100 + CustomsXmlFactory customsXmlFactory = new CustomsXmlFactory();
  101 + CustomsXmlHeader message = customsXmlFactory.getCustomsXmlHeader("MESSAGE");
  102 + Map<String, Object> mt3201 = message.makeHeader(customCode, orgsn, map.get("awba").toString(), orgCode, tcss, "MT3201");
  103 + map.put("map", mt3201);
  104 +
  105 + if (makeXmlToFile("/remove/MT3201.ftlx", mt3201.get("messageID")+".xml", map,"./send/remove/")>0){
109 map.put("functionCode", "3"); 106 map.put("functionCode", "3");
110 map.put("busType","MT3201"); 107 map.put("busType","MT3201");
111 NMMS_CUSTOM_RESPONSE nmmsCustomResponse = ReturnUtil.nmmsCustomResponse(map); 108 NMMS_CUSTOM_RESPONSE nmmsCustomResponse = ReturnUtil.nmmsCustomResponse(map);
@@ -3,6 +3,8 @@ package com.sunyo.wlpt.message.builder.service.imp; @@ -3,6 +3,8 @@ package com.sunyo.wlpt.message.builder.service.imp;
3 import com.fasterxml.jackson.databind.ObjectMapper; 3 import com.fasterxml.jackson.databind.ObjectMapper;
4 import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT4201; 4 import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT4201;
5 import com.sunyo.wlpt.base.model.NMMS_CUSTOM_RESPONSE; 5 import com.sunyo.wlpt.base.model.NMMS_CUSTOM_RESPONSE;
  6 +import com.sunyo.wlpt.message.builder.factory.CustomsXmlFactory;
  7 +import com.sunyo.wlpt.message.builder.factory.CustomsXmlHeader;
6 import com.sunyo.wlpt.message.builder.service.MT4201Service; 8 import com.sunyo.wlpt.message.builder.service.MT4201Service;
7 import com.sunyo.wlpt.message.builder.util.CustomXmlMaker; 9 import com.sunyo.wlpt.message.builder.util.CustomXmlMaker;
8 import com.sunyo.wlpt.message.builder.util.ReturnUtil; 10 import com.sunyo.wlpt.message.builder.util.ReturnUtil;
@@ -34,23 +36,21 @@ public class MT4201ServiceImp extends CustomXmlMaker implements MT4201Service { @@ -34,23 +36,21 @@ public class MT4201ServiceImp extends CustomXmlMaker implements MT4201Service {
34 NMMS_CUSTOM_MT4201 customMt4201 = objectMapper.convertValue(map.get("mt4201"), NMMS_CUSTOM_MT4201.class); 36 NMMS_CUSTOM_MT4201 customMt4201 = objectMapper.convertValue(map.get("mt4201"), NMMS_CUSTOM_MT4201.class);
35 // 关区代码 37 // 关区代码
36 String customCode = customMt4201.getCustomcode(); 38 String customCode = customMt4201.getCustomcode();
37 - // 报文头时间 精确到毫秒  
38 - map.put("sendTime", DateUtil.getCurrentTime17());  
39 // 封装实体 39 // 封装实体
40 map.put("mt", customMt4201); 40 map.put("mt", customMt4201);
41 // 处理主单号 - 41 // 处理主单号 -
42 String awba = ReturnUtil.awbaReplace(customMt4201.getAwba()); 42 String awba = ReturnUtil.awbaReplace(customMt4201.getAwba());
43 map.put("awba", awba); 43 map.put("awba", awba);
44 - // 生成报文头部  
45 - String msgId = makeMsgID("MT4201", orgsn, customMt4201.getAwba());  
46 - String senderId = makeSenderID(customCode, orgsn);  
47 - String receiverID = customCode;  
48 - map.put("msgId", msgId);  
49 - map.put("senderId", senderId);  
50 - map.put("receiverID", receiverID); 44 +
  45 + // 生成报文头部信息
  46 + CustomsXmlFactory customsXmlFactory = new CustomsXmlFactory();
  47 + CustomsXmlHeader message = customsXmlFactory.getCustomsXmlHeader("MESSAGE");
  48 + Map<String, Object> mt4201 = message.makeHeader(customCode, orgsn, customMt4201.getAwba(), "", "", "MT4201");
  49 + map.put("map", mt4201);
  50 +
51 51
52 Map<String, Object> map4201 = new HashMap<>(); 52 Map<String, Object> map4201 = new HashMap<>();
53 - if (makeXmlToFile("/manifest/MT4201.ftlx", msgId+".xml", map, "./send/add/")>0){ 53 + if (makeXmlToFile("/manifest/MT4201.ftlx", map.get("messageID").toString()+".xml", map, "./send/add/")>0){
54 map.put("functionCode", "2"); 54 map.put("functionCode", "2");
55 map.put("busType","MT4201"); 55 map.put("busType","MT4201");
56 NMMS_CUSTOM_RESPONSE nmmsCustomResponse = ReturnUtil.nmmsCustomResponse(map); 56 NMMS_CUSTOM_RESPONSE nmmsCustomResponse = ReturnUtil.nmmsCustomResponse(map);
@@ -88,24 +88,21 @@ public class MT4201ServiceImp extends CustomXmlMaker implements MT4201Service { @@ -88,24 +88,21 @@ public class MT4201ServiceImp extends CustomXmlMaker implements MT4201Service {
88 public Map<String, Object> remove4201(Map<String, Object> map) throws IOException, ParseException { 88 public Map<String, Object> remove4201(Map<String, Object> map) throws IOException, ParseException {
89 // 关区代码 89 // 关区代码
90 String customCode = map.get("customCode").toString(); 90 String customCode = map.get("customCode").toString();
91 - // 报文头时间 精确到毫秒  
92 - map.put("sendTime", DateUtil.getCurrentTime17());  
93 - // 生成报文头部  
94 - String msgId = makeMsgID("MT4201", orgsn, map.get("awba").toString());  
95 - String senderId = makeSenderID(customCode, orgsn);  
96 - String receiverID = customCode;  
97 - map.put("msgId", msgId);  
98 - map.put("senderId", senderId);  
99 - map.put("receiverID", receiverID); 91 +
  92 + // 生成报文头部信息
  93 + CustomsXmlFactory customsXmlFactory = new CustomsXmlFactory();
  94 + CustomsXmlHeader message = customsXmlFactory.getCustomsXmlHeader("MESSAGE");
  95 + Map<String, Object> mt4201 = message.makeHeader(customCode, orgsn, map.get("awba").toString(), "", "", "MT4201");
  96 + map.put("map", mt4201);
  97 +
100 // 处理主单号 - 98 // 处理主单号 -
101 String awba = ReturnUtil.awbaReplace(map.get("awba").toString()); 99 String awba = ReturnUtil.awbaReplace(map.get("awba").toString());
102 map.put("awbas", awba); 100 map.put("awbas", awba);
103 101
104 String flightDate = ReturnUtil.awbaReplace(map.get("flightDate").toString()); 102 String flightDate = ReturnUtil.awbaReplace(map.get("flightDate").toString());
105 map.put("flightDates",flightDate); 103 map.put("flightDates",flightDate);
106 -  
107 Map<String, Object> map4201 = new HashMap<>(); 104 Map<String, Object> map4201 = new HashMap<>();
108 - if (makeXmlToFile("/remove/MT4201.ftlx", msgId+".xml", map, "./send/remove/")>0){ 105 + if (makeXmlToFile("/remove/MT4201.ftlx", mt4201.get("messageID").toString()+".xml", map, "./send/remove/")>0){
109 map.put("functionCode", "3"); 106 map.put("functionCode", "3");
110 map.put("busType","MT4201"); 107 map.put("busType","MT4201");
111 NMMS_CUSTOM_RESPONSE nmmsCustomResponse = ReturnUtil.nmmsCustomResponse(map); 108 NMMS_CUSTOM_RESPONSE nmmsCustomResponse = ReturnUtil.nmmsCustomResponse(map);
@@ -3,6 +3,8 @@ package com.sunyo.wlpt.message.builder.service.imp; @@ -3,6 +3,8 @@ package com.sunyo.wlpt.message.builder.service.imp;
3 import com.fasterxml.jackson.databind.ObjectMapper; 3 import com.fasterxml.jackson.databind.ObjectMapper;
4 import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT520X; 4 import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT520X;
5 import com.sunyo.wlpt.base.model.NMMS_CUSTOM_RESPONSE; 5 import com.sunyo.wlpt.base.model.NMMS_CUSTOM_RESPONSE;
  6 +import com.sunyo.wlpt.message.builder.factory.CustomsXmlFactory;
  7 +import com.sunyo.wlpt.message.builder.factory.CustomsXmlHeader;
6 import com.sunyo.wlpt.message.builder.service.MT520XService; 8 import com.sunyo.wlpt.message.builder.service.MT520XService;
7 import com.sunyo.wlpt.message.builder.util.CustomXmlMaker; 9 import com.sunyo.wlpt.message.builder.util.CustomXmlMaker;
8 import com.sunyo.wlpt.message.builder.util.ReturnUtil; 10 import com.sunyo.wlpt.message.builder.util.ReturnUtil;
@@ -40,11 +42,8 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{ @@ -40,11 +42,8 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{
40 hashMap.put("awba", awba); 42 hashMap.put("awba", awba);
41 // 关区代码 43 // 关区代码
42 String customCode = customMt520X.getCustomcode(); 44 String customCode = customMt520X.getCustomcode();
43 - // 报文头时间 精确到毫秒  
44 - hashMap.put("sendTime", DateUtil.getCurrentTime17());  
45 // 封装实体 45 // 封装实体
46 hashMap.put("mt", customMt520X); 46 hashMap.put("mt", customMt520X);
47 -  
48 hashMap.put("orgCode", orgCode); 47 hashMap.put("orgCode", orgCode);
49 if ("MT5201".equals(customMt520X.getRcfdep())){ 48 if ("MT5201".equals(customMt520X.getRcfdep())){
50 // 生成报文头部 49 // 生成报文头部
@@ -89,17 +88,14 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{ @@ -89,17 +88,14 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{
89 } 88 }
90 }else { 89 }else {
91 90
92 - // 生成报文头部  
93 - String msgId = makeMsgID("MT5202", orgsn, customMt520X.getAwba());  
94 - String msessageType = "MT5202";  
95 - String senderId = makeSenderID(customCode, orgsn, "");  
96 - String receiverID = customCode;  
97 - hashMap.put("msgId", msgId);  
98 - hashMap.put("msessageType", msessageType);  
99 - hashMap.put("senderId", senderId);  
100 - hashMap.put("receiverID", receiverID); 91 + // 生成报文头部信息
  92 + CustomsXmlFactory customsXmlFactory = new CustomsXmlFactory();
  93 + CustomsXmlHeader message = customsXmlFactory.getCustomsXmlHeader("MESSAGE");
  94 + Map<String, Object> mt520x = message.makeHeader(customCode, orgsn, customMt520X.getAwba(), orgCode, "", "MT5202");
  95 + hashMap .put("map", mt520x);
  96 +
101 Map<String, Object> maps = new HashMap<>(); 97 Map<String, Object> maps = new HashMap<>();
102 - if (makeXmlToFile("/manifest/MT5202.ftlx", msgId+".xml", hashMap, "./send/add/")>0){ 98 + if (makeXmlToFile("/manifest/MT5202.ftlx", mt520x.get("messageID").toString()+".xml", hashMap, "./send/add/")>0){
103 99
104 hashMap.put("functionCode", "2"); 100 hashMap.put("functionCode", "2");
105 hashMap.put("busType","MT5202"); 101 hashMap.put("busType","MT5202");
@@ -173,15 +169,15 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{ @@ -173,15 +169,15 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{
173 return maps; 169 return maps;
174 } 170 }
175 }else { 171 }else {
176 - // 生成报文头部  
177 - String msgId = makeMsgID("MT5202", orgsn, map.get("awba").toString());  
178 - String senderId = makeSenderID(customCode, orgsn, "");  
179 - String receiverID = customCode;  
180 - map.put("msgId", msgId);  
181 - map.put("senderId", senderId);  
182 - map.put("receiverID", receiverID); 172 +
  173 + // 生成报文头部信息
  174 + CustomsXmlFactory customsXmlFactory = new CustomsXmlFactory();
  175 + CustomsXmlHeader message = customsXmlFactory.getCustomsXmlHeader("MESSAGE");
  176 + Map<String, Object> mt520x = message.makeHeader(customCode, orgsn, map.get("awba").toString(), orgCode, "", "MT5202");
  177 + map.put("map", mt520x);
  178 +
183 Map<String, Object> maps = new HashMap<>(); 179 Map<String, Object> maps = new HashMap<>();
184 - if (makeXmlToFile("/remove/MT5202.ftlx", msgId+".xml", map, "./send/remove/")>0){ 180 + if (makeXmlToFile("/remove/MT5202.ftlx", mt520x.get("messageID")+".xml", map, "./send/remove/")>0){
185 181
186 map.put("functionCode", "3"); 182 map.put("functionCode", "3");
187 map.put("busType","MT5202"); 183 map.put("busType","MT5202");
@@ -12,6 +12,8 @@ import org.springframework.ui.freemarker.FreeMarkerTemplateUtils; @@ -12,6 +12,8 @@ import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
12 12
13 import java.io.File; 13 import java.io.File;
14 import java.io.IOException; 14 import java.io.IOException;
  15 +import java.util.HashMap;
  16 +import java.util.Map;
15 17
16 @Component 18 @Component
17 public class CustomXmlMaker { 19 public class CustomXmlMaker {
@@ -103,11 +105,14 @@ public class CustomXmlMaker { @@ -103,11 +105,14 @@ public class CustomXmlMaker {
103 sb.append(customCode) 105 sb.append(customCode)
104 .append(ORGSN) 106 .append(ORGSN)
105 .append("_") 107 .append("_")
106 - .append(TCSMQNumber); 108 + .append(TCSSN);
107 return sb.toString(); 109 return sb.toString();
108 } 110 }
  111 +
109 public String makeSenderID(String customCode,String ORGSN){ 112 public String makeSenderID(String customCode,String ORGSN){
110 return makeSenderID(customCode,ORGSN,TCSMQNumber); 113 return makeSenderID(customCode,ORGSN,TCSMQNumber);
111 } 114 }
112 115
  116 +
  117 +
113 } 118 }
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <Manifest xmlns="urn:Declaration:datamodel:standard:CN:MT2201:1" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 2 <Manifest xmlns="urn:Declaration:datamodel:standard:CN:MT2201:1" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3 <Head> 3 <Head>
4 - <MessageID>${msgId}</MessageID> 4 + <MessageID>${map.messageID}</MessageID>
5 <FunctionCode>5</FunctionCode> 5 <FunctionCode>5</FunctionCode>
6 <MessageType>MT2201</MessageType> 6 <MessageType>MT2201</MessageType>
7 - <SenderID>${senderId}</SenderID>  
8 - <ReceiverID>${receiverID}</ReceiverID>  
9 - <SendTime>${sendTime}</SendTime> 7 + <SenderID>${map.senderID}</SenderID>
  8 + <ReceiverID>${map.receiverID}</ReceiverID>
  9 + <SendTime>${map.sendTime}</SendTime>
10 <Version>1.0</Version> 10 <Version>1.0</Version>
11 </Head> 11 </Head>
12 <Declaration> 12 <Declaration>
@@ -48,7 +48,7 @@ @@ -48,7 +48,7 @@
48 </GoodsConsignedPlace> 48 </GoodsConsignedPlace>
49 <TransportSplitIndicator>${mt.splitcode}</TransportSplitIndicator> 49 <TransportSplitIndicator>${mt.splitcode}</TransportSplitIndicator>
50 <FreightPayment> 50 <FreightPayment>
51 - <MethodCode>${awbAwbinfo.collected}</MethodCode> 51 + <MethodCode>${awbAwbinfo.paymodel}</MethodCode>
52 </FreightPayment> 52 </FreightPayment>
53 <ConsignmentPackaging> 53 <ConsignmentPackaging>
54 <QuantityQuantity>${awbAwbinfo.pcs}</QuantityQuantity> 54 <QuantityQuantity>${awbAwbinfo.pcs}</QuantityQuantity>
1 <Manifest xmlns="urn:Declaration:datamodel:standard:CN:MT2201:1" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 1 <Manifest xmlns="urn:Declaration:datamodel:standard:CN:MT2201:1" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
2 <Head> 2 <Head>
3 - <MessageID>${msgId}</MessageID> 3 + <MessageID>${map.messageID}</MessageID>
4 <FunctionCode>9</FunctionCode> 4 <FunctionCode>9</FunctionCode>
5 <MessageType>MT2201</MessageType> 5 <MessageType>MT2201</MessageType>
6 - <SenderID>${senderId}</SenderID>  
7 - <ReceiverID>${receiverID}</ReceiverID>  
8 - <SendTime>${sendTime}</SendTime> 6 + <SenderID>${map.senderID}</SenderID>
  7 + <ReceiverID>${map.receiverID}</ReceiverID>
  8 + <SendTime>${map.sendTime}</SendTime>
9 <Version>1.0</Version> 9 <Version>1.0</Version>
10 </Head> 10 </Head>
11 <Declaration> 11 <Declaration>
@@ -47,7 +47,7 @@ @@ -47,7 +47,7 @@
47 <CustomsStatusCode>${awbAwbinfo.awbtype}</CustomsStatusCode> 47 <CustomsStatusCode>${awbAwbinfo.awbtype}</CustomsStatusCode>
48 <TransportSplitIndicator>${mt.splitcode}</TransportSplitIndicator> 48 <TransportSplitIndicator>${mt.splitcode}</TransportSplitIndicator>
49 <FreightPayment> 49 <FreightPayment>
50 - <MethodCode>${awbAwbinfo.collected}</MethodCode> 50 + <MethodCode>${awbAwbinfo.paymodel}</MethodCode>
51 </FreightPayment> 51 </FreightPayment>
52 <ConsignmentPackaging> 52 <ConsignmentPackaging>
53 <QuantityQuantity>${awbAwbinfo.pcs}</QuantityQuantity> 53 <QuantityQuantity>${awbAwbinfo.pcs}</QuantityQuantity>
1 <Manifest xmlns="urn:Declaration:datamodel:standard:CN:MT3201:1" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 1 <Manifest xmlns="urn:Declaration:datamodel:standard:CN:MT3201:1" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
2 <Head> 2 <Head>
3 - <MessageID>${msgId}</MessageID> 3 + <MessageID>${map.messageID}</MessageID>
4 <FunctionCode>2</FunctionCode> 4 <FunctionCode>2</FunctionCode>
5 <MessageType>MT3201</MessageType> 5 <MessageType>MT3201</MessageType>
6 - <SenderID>${senderId}</SenderID>  
7 - <ReceiverID>${receiverID}</ReceiverID>  
8 - <SendTime>${sendTime}</SendTime> 6 + <SenderID>${map.senderID}</SenderID>
  7 + <ReceiverID>${map.receiverID}</ReceiverID>
  8 + <SendTime>${map.sendTime}</SendTime>
9 <Version>1.0</Version> 9 <Version>1.0</Version>
10 </Head> 10 </Head>
11 <Declaration> 11 <Declaration>
1 <Manifest xmlns="urn:Declaration:datamodel:standard:CN:MT4201:1" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 1 <Manifest xmlns="urn:Declaration:datamodel:standard:CN:MT4201:1" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
2 <Head> 2 <Head>
3 - <MessageID>${msgId}</MessageID> 3 + <MessageID>${map.messageID}</MessageID>
4 <FunctionCode>2</FunctionCode> 4 <FunctionCode>2</FunctionCode>
5 <MessageType>MT4201</MessageType> 5 <MessageType>MT4201</MessageType>
6 - <SenderID>${senderId}</SenderID>  
7 - <ReceiverID>${receiverID}</ReceiverID>  
8 - <SendTime>${sendTime}</SendTime> 6 + <SenderID>${map.senderID}</SenderID>
  7 + <ReceiverID>${map.receiverID}</ReceiverID>
  8 + <SendTime>${map.sendTime}</SendTime>
9 <Version>1.0</Version> 9 <Version>1.0</Version>
10 </Head> 10 </Head>
11 <Declaration> 11 <Declaration>
1 <Manifest xmlns="urn:Declaration:datamodel:standard:CN:MT5202:1" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 1 <Manifest xmlns="urn:Declaration:datamodel:standard:CN:MT5202:1" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
2 <Head> 2 <Head>
3 - <MessageID>${msgId}</MessageID> 3 + <MessageID>${map.messageID}</MessageID>
4 <FunctionCode>2</FunctionCode> 4 <FunctionCode>2</FunctionCode>
5 <MessageType>MT5202</MessageType> 5 <MessageType>MT5202</MessageType>
6 - <SenderID>${senderId}</SenderID>  
7 - <ReceiverID>${receiverID}</ReceiverID>  
8 - <SendTime>${sendTime}</SendTime> 6 + <SenderID>${map.senderID}</SenderID>
  7 + <ReceiverID>${map.receiverID}</ReceiverID>
  8 + <SendTime>${map.sendTime}</SendTime>
9 <Version>1.0</Version> 9 <Version>1.0</Version>
10 </Head> 10 </Head>
11 <Declaration> 11 <Declaration>
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <Manifest xmlns="urn:Declaration:datamodel:standard:CN:MT2201:1" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 2 <Manifest xmlns="urn:Declaration:datamodel:standard:CN:MT2201:1" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3 <Head> 3 <Head>
4 - <MessageID>${msgId}</MessageID> 4 + <MessageID>${map.messageID}</MessageID>
5 <FunctionCode>3</FunctionCode> 5 <FunctionCode>3</FunctionCode>
6 <MessageType>MT2201</MessageType> 6 <MessageType>MT2201</MessageType>
7 - <SenderID>${senderId}</SenderID>  
8 - <ReceiverID>${receiverID}</ReceiverID>  
9 - <SendTime>${sendTime}</SendTime> 7 + <SenderID>${map.senderID}</SenderID>
  8 + <ReceiverID>${map.receiverID}</ReceiverID>
  9 + <SendTime>${map.sendTime}</SendTime>
10 <Version>1.0</Version> 10 <Version>1.0</Version>
11 </Head> 11 </Head>
12 <Declaration> 12 <Declaration>
1 <Manifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:Declaration:datamodel:standard:CN:MT3201:1"> 1 <Manifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:Declaration:datamodel:standard:CN:MT3201:1">
2 <Head> 2 <Head>
3 - <MessageID>${msgId}</MessageID> 3 + <MessageID>${map.messageID}</MessageID>
4 <FunctionCode>3</FunctionCode> 4 <FunctionCode>3</FunctionCode>
5 <MessageType>MT3201</MessageType> 5 <MessageType>MT3201</MessageType>
6 - <SenderID>${senderId}</SenderID>  
7 - <ReceiverID>${receiverID}</ReceiverID>  
8 - <SendTime>${sendTime}</SendTime> 6 + <SenderID>${map.senderID}</SenderID>
  7 + <ReceiverID>${map.receiverID}</ReceiverID>
  8 + <SendTime>${map.sendTime}</SendTime>
9 <Version>1.0</Version> 9 <Version>1.0</Version>
10 </Head> 10 </Head>
11 <Declaration> 11 <Declaration>
1 <Manifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:Declaration:datamodel:standard:CN:MT4201:1"> 1 <Manifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:Declaration:datamodel:standard:CN:MT4201:1">
2 <Head> 2 <Head>
3 - <MessageID>${msgId}</MessageID> 3 + <MessageID>${map.messageID}</MessageID>
4 <FunctionCode>3</FunctionCode> 4 <FunctionCode>3</FunctionCode>
5 <MessageType>MT4201</MessageType> 5 <MessageType>MT4201</MessageType>
6 - <SenderID>${senderId}</SenderID>  
7 - <ReceiverID>${receiverID}</ReceiverID>  
8 - <SendTime>${sendTime}</SendTime> 6 + <SenderID>${map.senderID}</SenderID>
  7 + <ReceiverID>${map.receiverID}</ReceiverID>
  8 + <SendTime>${map.sendTime}</SendTime>
9 <Version>1.0</Version> 9 <Version>1.0</Version>
10 </Head> 10 </Head>
11 <Declaration> 11 <Declaration>
1 <Manifest xmlns="urn:Declaration:datamodel:standard:CN:MT5202:1" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 1 <Manifest xmlns="urn:Declaration:datamodel:standard:CN:MT5202:1" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
2 <Head> 2 <Head>
3 - <MessageID>${msgId}</MessageID> 3 + <MessageID>${map.messageID}</MessageID>
4 <FunctionCode>3</FunctionCode> 4 <FunctionCode>3</FunctionCode>
5 <MessageType>MT5202</MessageType> 5 <MessageType>MT5202</MessageType>
6 - <SenderID>${senderId}</SenderID>  
7 - <ReceiverID>${receiverID}</ReceiverID>  
8 - <SendTime>${sendTime}</SendTime> 6 + <SenderID>${map.senderID}</SenderID>
  7 + <ReceiverID>${map.receiverID}</ReceiverID>
  8 + <SendTime>${map.sendTime}</SendTime>
9 <Version>1.0</Version> 9 <Version>1.0</Version>
10 </Head> 10 </Head>
11 <Declaration> 11 <Declaration>