作者 shenhailong

修改生成报文 返回信息 response实体

@@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired; @@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
6 import org.springframework.web.bind.annotation.*; 6 import org.springframework.web.bind.annotation.*;
7 7
8 import java.io.IOException; 8 import java.io.IOException;
  9 +import java.text.ParseException;
9 import java.util.Map; 10 import java.util.Map;
10 11
11 @RestController 12 @RestController
@@ -23,7 +24,7 @@ public class MT2201Controller { @@ -23,7 +24,7 @@ public class MT2201Controller {
23 @PostMapping("/creatMt2201") 24 @PostMapping("/creatMt2201")
24 @ApiOperation(value = "生成报文") 25 @ApiOperation(value = "生成报文")
25 @ResponseBody 26 @ResponseBody
26 - public int creatMt2201(@RequestBody Map<String, Object> map) throws IOException { 27 + public Map<String, Object> creatMt2201(@RequestBody Map<String, Object> map) throws IOException, ParseException {
27 28
28 return mt2201Service.creatMt2201(map); 29 return mt2201Service.creatMt2201(map);
29 } 30 }
@@ -31,7 +32,7 @@ public class MT2201Controller { @@ -31,7 +32,7 @@ public class MT2201Controller {
31 @PutMapping("/editMt2201") 32 @PutMapping("/editMt2201")
32 @ApiOperation(value = "修改报文") 33 @ApiOperation(value = "修改报文")
33 @ResponseBody 34 @ResponseBody
34 - public int editMt2201(@RequestBody Map<String, Object> map) throws IOException { 35 + public Map<String, Object> editMt2201(@RequestBody Map<String, Object> map) throws IOException, ParseException {
35 36
36 return mt2201Service.editMt2201(map); 37 return mt2201Service.editMt2201(map);
37 } 38 }
@@ -39,7 +40,7 @@ public class MT2201Controller { @@ -39,7 +40,7 @@ public class MT2201Controller {
39 @PutMapping("/removeMt2201") 40 @PutMapping("/removeMt2201")
40 @ApiOperation(value = "删除报文") 41 @ApiOperation(value = "删除报文")
41 @ResponseBody 42 @ResponseBody
42 - public int removeMt2201(@RequestBody Map<String, Object> map) throws IOException { 43 + public Map<String, Object> removeMt2201(@RequestBody Map<String, Object> map) throws IOException, ParseException {
43 44
44 return mt2201Service.removeMt2201(map); 45 return mt2201Service.removeMt2201(map);
45 } 46 }
@@ -18,28 +18,28 @@ public class MT3201Controller { @@ -18,28 +18,28 @@ public class MT3201Controller {
18 18
19 @RequestMapping("/createMt3201") 19 @RequestMapping("/createMt3201")
20 @ResponseBody 20 @ResponseBody
21 - public int fohcreate(@RequestBody Map<String, Object> map){ 21 + public Map<String, Object> fohcreate(@RequestBody Map<String, Object> map){
22 22
23 try { 23 try {
24 24
25 return mt3201Service.fohcreate(map); 25 return mt3201Service.fohcreate(map);
26 }catch (Exception e){ 26 }catch (Exception e){
27 e.printStackTrace(); 27 e.printStackTrace();
28 - return 0; 28 + return null;
29 } 29 }
30 30
31 } 31 }
32 32
33 @PutMapping("/removeMt3201") 33 @PutMapping("/removeMt3201")
34 @ResponseBody 34 @ResponseBody
35 - public int remove(@RequestBody Map<String, Object> map){ 35 + public Map<String, Object> remove(@RequestBody Map<String, Object> map){
36 36
37 try { 37 try {
38 38
39 return mt3201Service.remove(map); 39 return mt3201Service.remove(map);
40 }catch (Exception e){ 40 }catch (Exception e){
41 e.printStackTrace(); 41 e.printStackTrace();
42 - return 0; 42 + return null;
43 } 43 }
44 44
45 } 45 }
@@ -19,7 +19,7 @@ public class MT4201Controller { @@ -19,7 +19,7 @@ public class MT4201Controller {
19 19
20 @PostMapping("/createMt4201") 20 @PostMapping("/createMt4201")
21 @ResponseBody 21 @ResponseBody
22 - public int pffmcreate(@RequestBody Map<String, Object> map) throws IOException { 22 + public Map<String, Object> pffmcreate(@RequestBody Map<String, Object> map) throws IOException, ParseException {
23 23
24 return mt4201Service.pffmcreate(map); 24 return mt4201Service.pffmcreate(map);
25 25
@@ -28,7 +28,7 @@ public class MT4201Controller { @@ -28,7 +28,7 @@ public class MT4201Controller {
28 28
29 @PutMapping("/removeMt4201") 29 @PutMapping("/removeMt4201")
30 @ResponseBody 30 @ResponseBody
31 - public int remove4201(@RequestBody Map<String, Object> map) throws IOException, ParseException { 31 + public Map<String, Object> remove4201(@RequestBody Map<String, Object> map) throws IOException, ParseException {
32 32
33 return mt4201Service.remove4201(map); 33 return mt4201Service.remove4201(map);
34 34
@@ -22,7 +22,7 @@ public class MT520XController { @@ -22,7 +22,7 @@ public class MT520XController {
22 */ 22 */
23 @RequestMapping("/createMt520x") 23 @RequestMapping("/createMt520x")
24 @ResponseBody 24 @ResponseBody
25 - public int create(@RequestBody Map<String, Object> map){ 25 + public Map<String, Object> create(@RequestBody Map<String, Object> map){
26 26
27 try { 27 try {
28 28
@@ -30,7 +30,7 @@ public class MT520XController { @@ -30,7 +30,7 @@ public class MT520XController {
30 30
31 }catch (Exception e){ 31 }catch (Exception e){
32 e.printStackTrace(); 32 e.printStackTrace();
33 - return 0; 33 + return null;
34 } 34 }
35 35
36 } 36 }
@@ -42,7 +42,7 @@ public class MT520XController { @@ -42,7 +42,7 @@ public class MT520XController {
42 */ 42 */
43 @PutMapping("/removeMt520x") 43 @PutMapping("/removeMt520x")
44 @ResponseBody 44 @ResponseBody
45 - public int remove520x(@RequestBody Map<String, Object> map){ 45 + public Map<String, Object> remove520x(@RequestBody Map<String, Object> map){
46 46
47 try { 47 try {
48 48
@@ -50,7 +50,7 @@ public class MT520XController { @@ -50,7 +50,7 @@ public class MT520XController {
50 50
51 }catch (Exception e){ 51 }catch (Exception e){
52 e.printStackTrace(); 52 e.printStackTrace();
53 - return 0; 53 + return null;
54 } 54 }
55 55
56 } 56 }
@@ -4,6 +4,7 @@ import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT2201; @@ -4,6 +4,7 @@ import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT2201;
4 import org.omg.CORBA.OBJECT_NOT_EXIST; 4 import org.omg.CORBA.OBJECT_NOT_EXIST;
5 5
6 import java.io.IOException; 6 import java.io.IOException;
  7 +import java.text.ParseException;
7 import java.util.Map; 8 import java.util.Map;
8 9
9 public interface MT2201Service { 10 public interface MT2201Service {
@@ -20,10 +21,10 @@ public interface MT2201Service { @@ -20,10 +21,10 @@ public interface MT2201Service {
20 21
21 int updateByPrimaryKey(NMMS_CUSTOM_MT2201 record); 22 int updateByPrimaryKey(NMMS_CUSTOM_MT2201 record);
22 23
23 - int creatMt2201(Map<String, Object> map) throws IOException; 24 + Map<String, Object> creatMt2201(Map<String, Object> map) throws IOException, ParseException;
24 25
25 - int editMt2201(Map<String, Object> map) throws IOException; 26 + Map<String, Object> editMt2201(Map<String, Object> map) throws IOException, ParseException;
26 27
27 - int removeMt2201(Map<String, Object> map) throws IOException; 28 + Map<String, Object> removeMt2201(Map<String, Object> map) throws IOException, ParseException;
28 29
29 } 30 }
@@ -3,11 +3,12 @@ package com.sunyo.wlpt.message.builder.service; @@ -3,11 +3,12 @@ package com.sunyo.wlpt.message.builder.service;
3 import sun.jvm.hotspot.oops.ObjectHeap; 3 import sun.jvm.hotspot.oops.ObjectHeap;
4 4
5 import java.io.IOException; 5 import java.io.IOException;
  6 +import java.text.ParseException;
6 import java.util.Map; 7 import java.util.Map;
7 8
8 public interface MT3201Service { 9 public interface MT3201Service {
9 10
10 - int fohcreate(Map<String, Object> map) throws IOException; 11 + Map<String, Object> fohcreate(Map<String, Object> map) throws IOException, ParseException;
11 12
12 - int remove(Map<String, Object> map) throws IOException; 13 + Map<String, Object> remove(Map<String, Object> map) throws IOException, ParseException;
13 } 14 }
@@ -6,8 +6,8 @@ import java.util.Map; @@ -6,8 +6,8 @@ import java.util.Map;
6 6
7 public interface MT4201Service { 7 public interface MT4201Service {
8 8
9 - int pffmcreate(Map<String, Object> map) throws IOException; 9 + Map<String, Object> pffmcreate(Map<String, Object> map) throws IOException, ParseException;
10 10
11 - int remove4201(Map<String, Object> map) throws IOException, ParseException; 11 + Map<String, Object> remove4201(Map<String, Object> map) throws IOException, ParseException;
12 12
13 } 13 }
@@ -3,13 +3,14 @@ package com.sunyo.wlpt.message.builder.service; @@ -3,13 +3,14 @@ package com.sunyo.wlpt.message.builder.service;
3 3
4 4
5 import java.io.IOException; 5 import java.io.IOException;
  6 +import java.text.ParseException;
6 import java.util.Map; 7 import java.util.Map;
7 8
8 public interface MT520XService { 9 public interface MT520XService {
9 10
10 11
11 - public int create(Map<String, Object> map); 12 + public Map<String, Object> create(Map<String, Object> map);
12 13
13 - public int remove520x(Map<String, Object> map) throws IOException; 14 + public Map<String, Object> remove520x(Map<String, Object> map) throws IOException, ParseException;
14 15
15 } 16 }
@@ -76,7 +76,7 @@ public class MT1201ServiceImp extends CustomXmlMaker implements MT1201Service{ @@ -76,7 +76,7 @@ public class MT1201ServiceImp extends CustomXmlMaker implements MT1201Service{
76 map.put("mt", customMt1201); 76 map.put("mt", customMt1201);
77 map.put("awbAwbinfo", awbAwbinfo); 77 map.put("awbAwbinfo", awbAwbinfo);
78 // 生成报文头部 78 // 生成报文头部
79 - String msgId = makeMsgID("MT2201", orgsn, customMt1201.getAwba()); 79 + String msgId = makeMsgID("MT1201", orgsn, customMt1201.getAwba());
80 String senderId = makeSenderID(customCode, orgsn, ""); 80 String senderId = makeSenderID(customCode, orgsn, "");
81 String receiverID = customCode; 81 String receiverID = customCode;
82 map.put("msgId", msgId); 82 map.put("msgId", msgId);
@@ -5,14 +5,19 @@ import com.fasterxml.jackson.databind.ObjectMapper; @@ -5,14 +5,19 @@ import com.fasterxml.jackson.databind.ObjectMapper;
5 import com.sunyo.wlpt.base.model.AWB_AWBINFO; 5 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.message.builder.service.MT2201Service; 9 import com.sunyo.wlpt.message.builder.service.MT2201Service;
9 import com.sunyo.wlpt.message.builder.util.CustomXmlMaker; 10 import com.sunyo.wlpt.message.builder.util.CustomXmlMaker;
  11 +import com.sunyo.wlpt.message.builder.util.ReturnUtil;
10 import com.tianbo.util.Date.DateUtil; 12 import com.tianbo.util.Date.DateUtil;
11 import org.springframework.beans.factory.annotation.Value; 13 import org.springframework.beans.factory.annotation.Value;
12 import org.springframework.cglib.beans.BeanMap; 14 import org.springframework.cglib.beans.BeanMap;
13 import org.springframework.stereotype.Service; 15 import org.springframework.stereotype.Service;
14 16
15 import java.io.IOException; 17 import java.io.IOException;
  18 +import java.math.BigDecimal;
  19 +import java.text.ParseException;
  20 +import java.util.HashMap;
16 import java.util.Map; 21 import java.util.Map;
17 22
18 @Service 23 @Service
@@ -55,21 +60,21 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service { @@ -55,21 +60,21 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service {
55 private String orgCode; 60 private String orgCode;
56 61
57 @Override 62 @Override
58 - public int creatMt2201(Map<String, Object> map) throws IOException{ 63 + public Map<String, Object> creatMt2201(Map<String, Object> map) throws IOException, ParseException {
59 map.put("templatePath", "/manifest/MT2201.ftlx"); 64 map.put("templatePath", "/manifest/MT2201.ftlx");
60 map.put("sendPath", "./send/add/"); 65 map.put("sendPath", "./send/add/");
61 return mt2201(map); 66 return mt2201(map);
62 } 67 }
63 68
64 @Override 69 @Override
65 - public int editMt2201(Map<String, Object> map) throws IOException { 70 + public Map<String, Object> editMt2201(Map<String, Object> map) throws IOException, ParseException {
66 map.put("templatePath", "/edit/MT2201.ftlx"); 71 map.put("templatePath", "/edit/MT2201.ftlx");
67 map.put("sendPath", "./send/edit/"); 72 map.put("sendPath", "./send/edit/");
68 return mt2201(map); 73 return mt2201(map);
69 } 74 }
70 75
71 @Override 76 @Override
72 - public int removeMt2201(Map<String, Object> map) throws IOException { 77 + public Map<String, Object> removeMt2201(Map<String, Object> map) throws IOException, ParseException {
73 78
74 String customCode = map.get("customCode").toString(); 79 String customCode = map.get("customCode").toString();
75 // 生成报文头部 80 // 生成报文头部
@@ -83,16 +88,25 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service { @@ -83,16 +88,25 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service {
83 map.put("sendTime", DateUtil.getCurrentTime17()); 88 map.put("sendTime", DateUtil.getCurrentTime17());
84 // 舱单传输人名称 89 // 舱单传输人名称
85 map.put("orgCode", orgCode); 90 map.put("orgCode", orgCode);
  91 +
  92 + Map<String, Object> hashMap = new HashMap<>();
86 // 生成报文 93 // 生成报文
87 if (makeXmlToFile("/remove/MT2201.ftlx", msgId+".xml", map, "./send/remove/")>0){ 94 if (makeXmlToFile("/remove/MT2201.ftlx", msgId+".xml", map, "./send/remove/")>0){
88 - return 1; 95 + map.put("functionCode", "3");
  96 + map.put("busType","MT2201");
  97 + System.out.println();
  98 + NMMS_CUSTOM_RESPONSE nmmsCustomResponse = ReturnUtil.nmmsCustomResponse(map);
  99 + hashMap.put("status", "1");
  100 + hashMap.put("customResponse", nmmsCustomResponse);
  101 + return hashMap;
89 }else { 102 }else {
90 - return 0; 103 + hashMap.put("staus", "0");
  104 + return hashMap;
91 } 105 }
92 } 106 }
93 107
94 108
95 - public int mt2201(Map<String, Object> map) throws IOException { 109 + public Map<String, Object> mt2201(Map<String, Object> map) throws IOException, ParseException {
96 ObjectMapper objectMapper = new ObjectMapper(); 110 ObjectMapper objectMapper = new ObjectMapper();
97 // 预配 111 // 预配
98 NMMS_CUSTOM_MT2201 custom_mt2201 = objectMapper.convertValue(map.get("mt2201"), NMMS_CUSTOM_MT2201.class); 112 NMMS_CUSTOM_MT2201 custom_mt2201 = objectMapper.convertValue(map.get("mt2201"), NMMS_CUSTOM_MT2201.class);
@@ -114,11 +128,34 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service { @@ -114,11 +128,34 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service {
114 map.put("receiverID", receiverID); 128 map.put("receiverID", receiverID);
115 // 舱单传输人名称 129 // 舱单传输人名称
116 map.put("orgCode", orgCode); 130 map.put("orgCode", orgCode);
  131 +
  132 + Map<String, Object> maps = new HashMap<>();
117 // 生成报文 133 // 生成报文
118 if (makeXmlToFile(map.get("templatePath").toString(), msgId+".xml", map, map.get("sendPath").toString())>0){ 134 if (makeXmlToFile(map.get("templatePath").toString(), msgId+".xml", map, map.get("sendPath").toString())>0){
119 - return 1; 135 + map.put("functionCode", "9");
  136 + map.put("busType","MT2201");
  137 + NMMS_CUSTOM_RESPONSE nmmsCustomResponse = ReturnUtil.nmmsCustomResponse(map);
  138 + // 航班日期
  139 + nmmsCustomResponse.setFlightdate(custom_mt2201.getFlightdate());
  140 + // 航班号
  141 + nmmsCustomResponse.setFlightno(custom_mt2201.getFlightno());
  142 + // 航班承运人
  143 + nmmsCustomResponse.setCarrier(custom_mt2201.getCarrier());
  144 + // 主单号
  145 + nmmsCustomResponse.setAwbano(custom_mt2201.getAwba());
  146 + // 分单号
  147 + nmmsCustomResponse.setAwbhno(custom_mt2201.getAwbh());
  148 + // 件数
  149 + nmmsCustomResponse.setBuspiece(Integer.valueOf(custom_mt2201.getPiece().toString()));
  150 + // 重量
  151 + nmmsCustomResponse.setBusweight(Long.valueOf(custom_mt2201.getWeight().toString()));
  152 + maps.put("status", "1");
  153 + maps.put("customResponse", nmmsCustomResponse);
  154 +
  155 + return maps;
120 }else { 156 }else {
121 - return 0; 157 + maps.put("status", "0");
  158 + return maps;
122 } 159 }
123 } 160 }
124 } 161 }
@@ -2,13 +2,16 @@ package com.sunyo.wlpt.message.builder.service.imp; @@ -2,13 +2,16 @@ package com.sunyo.wlpt.message.builder.service.imp;
2 2
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.message.builder.service.MT3201Service; 6 import com.sunyo.wlpt.message.builder.service.MT3201Service;
6 import com.sunyo.wlpt.message.builder.util.CustomXmlMaker; 7 import com.sunyo.wlpt.message.builder.util.CustomXmlMaker;
  8 +import com.sunyo.wlpt.message.builder.util.ReturnUtil;
7 import com.tianbo.util.Date.DateUtil; 9 import com.tianbo.util.Date.DateUtil;
8 import org.springframework.beans.factory.annotation.Value; 10 import org.springframework.beans.factory.annotation.Value;
9 import org.springframework.stereotype.Service; 11 import org.springframework.stereotype.Service;
10 12
11 import java.io.IOException; 13 import java.io.IOException;
  14 +import java.text.ParseException;
12 import java.util.HashMap; 15 import java.util.HashMap;
13 import java.util.Map; 16 import java.util.Map;
14 17
@@ -22,7 +25,7 @@ public class MT3201ServiceImp extends CustomXmlMaker implements MT3201Service { @@ -22,7 +25,7 @@ public class MT3201ServiceImp extends CustomXmlMaker implements MT3201Service {
22 private String orgCode; 25 private String orgCode;
23 26
24 @Override 27 @Override
25 - public int fohcreate(Map<String, Object> map) throws IOException { 28 + public Map<String, Object> fohcreate(Map<String, Object> map) throws IOException, ParseException {
26 29
27 ObjectMapper objectMapper = new ObjectMapper(); 30 ObjectMapper objectMapper = new ObjectMapper();
28 31
@@ -40,15 +43,39 @@ public class MT3201ServiceImp extends CustomXmlMaker implements MT3201Service { @@ -40,15 +43,39 @@ public class MT3201ServiceImp extends CustomXmlMaker implements MT3201Service {
40 map.put("msgId", msgId); 43 map.put("msgId", msgId);
41 map.put("senderId", senderId); 44 map.put("senderId", senderId);
42 map.put("receiverID", receiverID); 45 map.put("receiverID", receiverID);
  46 +
  47 + Map<String, Object> map3201= new HashMap<>();
43 if (makeXmlToFile("/manifest/MT3201.ftlx", msgId+".xml", map,"./send/add/")>0){ 48 if (makeXmlToFile("/manifest/MT3201.ftlx", msgId+".xml", map,"./send/add/")>0){
44 - return 1; 49 + map.put("functionCode", "9");
  50 + map.put("busType","MT3201");
  51 + NMMS_CUSTOM_RESPONSE nmmsCustomResponse = ReturnUtil.nmmsCustomResponse(map);
  52 + System.out.println();
  53 + // 航班日期
  54 + nmmsCustomResponse.setFlightdate(customMt3201.getFlightdate());
  55 + // 航班号
  56 + nmmsCustomResponse.setFlightno(customMt3201.getFlightno());
  57 + // 航班承运人
  58 + nmmsCustomResponse.setCarrier(customMt3201.getCarrier());
  59 + // 主单号
  60 + nmmsCustomResponse.setAwbano(customMt3201.getAwba());
  61 + // 分单号
  62 + nmmsCustomResponse.setAwbhno(customMt3201.getAwbh());
  63 + // 件数
  64 + nmmsCustomResponse.setBuspiece(Integer.valueOf(customMt3201.getPiece().toString()));
  65 + // 重量
  66 + nmmsCustomResponse.setBusweight(Long.valueOf(customMt3201.getWeight().toString()));
  67 + map3201.put("status", "1");
  68 + map3201.put("customResponse", nmmsCustomResponse);
  69 +
  70 + return map3201;
45 }else { 71 }else {
46 - return 0; 72 + map3201.put("status", "0");
  73 + return map3201;
47 } 74 }
48 } 75 }
49 76
50 @Override 77 @Override
51 - public int remove(Map<String, Object> map) throws IOException { 78 + public Map<String, Object> remove(Map<String, Object> map) throws IOException, ParseException {
52 // 关区代码 79 // 关区代码
53 String customCode = map.get("customCode").toString(); 80 String customCode = map.get("customCode").toString();
54 // 报文头时间 精确到毫秒 81 // 报文头时间 精确到毫秒
@@ -60,10 +87,17 @@ public class MT3201ServiceImp extends CustomXmlMaker implements MT3201Service { @@ -60,10 +87,17 @@ public class MT3201ServiceImp extends CustomXmlMaker implements MT3201Service {
60 map.put("msgId", msgId); 87 map.put("msgId", msgId);
61 map.put("senderId", senderId); 88 map.put("senderId", senderId);
62 map.put("receiverID", receiverID); 89 map.put("receiverID", receiverID);
  90 + Map<String, Object> map3201 = new HashMap<>();
63 if (makeXmlToFile("/remove/MT3201.ftlx", msgId+".xml", map,"./send/remove/")>0){ 91 if (makeXmlToFile("/remove/MT3201.ftlx", msgId+".xml", map,"./send/remove/")>0){
64 - return 1; 92 + map.put("functionCode", "3");
  93 + map.put("busType","MT3201");
  94 + NMMS_CUSTOM_RESPONSE nmmsCustomResponse = ReturnUtil.nmmsCustomResponse(map);
  95 + map3201.put("status", "1");
  96 + map3201.put("customResponse", nmmsCustomResponse);
  97 + return map3201;
65 }else { 98 }else {
66 - return 0; 99 + map3201.put("staus", "0");
  100 + return map3201;
67 } 101 }
68 } 102 }
69 103
@@ -2,8 +2,10 @@ package com.sunyo.wlpt.message.builder.service.imp; @@ -2,8 +2,10 @@ package com.sunyo.wlpt.message.builder.service.imp;
2 2
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.message.builder.service.MT4201Service; 6 import com.sunyo.wlpt.message.builder.service.MT4201Service;
6 import com.sunyo.wlpt.message.builder.util.CustomXmlMaker; 7 import com.sunyo.wlpt.message.builder.util.CustomXmlMaker;
  8 +import com.sunyo.wlpt.message.builder.util.ReturnUtil;
7 import com.tianbo.util.Date.DateUtil; 9 import com.tianbo.util.Date.DateUtil;
8 import org.springframework.beans.factory.annotation.Value; 10 import org.springframework.beans.factory.annotation.Value;
9 import org.springframework.stereotype.Service; 11 import org.springframework.stereotype.Service;
@@ -11,6 +13,7 @@ import org.springframework.stereotype.Service; @@ -11,6 +13,7 @@ import org.springframework.stereotype.Service;
11 import javax.xml.crypto.Data; 13 import javax.xml.crypto.Data;
12 import java.io.IOException; 14 import java.io.IOException;
13 import java.text.ParseException; 15 import java.text.ParseException;
  16 +import java.util.HashMap;
14 import java.util.Map; 17 import java.util.Map;
15 18
16 @Service 19 @Service
@@ -21,7 +24,7 @@ public class MT4201ServiceImp extends CustomXmlMaker implements MT4201Service { @@ -21,7 +24,7 @@ public class MT4201ServiceImp extends CustomXmlMaker implements MT4201Service {
21 private String orgsn; 24 private String orgsn;
22 25
23 @Override 26 @Override
24 - public int pffmcreate(Map<String, Object> map) throws IOException { 27 + public Map<String, Object> pffmcreate(Map<String, Object> map) throws IOException, ParseException {
25 28
26 29
27 ObjectMapper objectMapper = new ObjectMapper(); 30 ObjectMapper objectMapper = new ObjectMapper();
@@ -41,23 +44,44 @@ public class MT4201ServiceImp extends CustomXmlMaker implements MT4201Service { @@ -41,23 +44,44 @@ public class MT4201ServiceImp extends CustomXmlMaker implements MT4201Service {
41 map.put("msgId", msgId); 44 map.put("msgId", msgId);
42 map.put("senderId", senderId); 45 map.put("senderId", senderId);
43 map.put("receiverID", receiverID); 46 map.put("receiverID", receiverID);
  47 +
  48 + Map<String, Object> map4201 = new HashMap<>();
44 if (makeXmlToFile("/manifest/MT4201.ftlx", msgId+".xml", map, "./send/add/")>0){ 49 if (makeXmlToFile("/manifest/MT4201.ftlx", msgId+".xml", map, "./send/add/")>0){
45 - return 1; 50 + map.put("functionCode", "2");
  51 + map.put("busType","MT4201");
  52 + NMMS_CUSTOM_RESPONSE nmmsCustomResponse = ReturnUtil.nmmsCustomResponse(map);
  53 + System.out.println();
  54 + // 航班日期
  55 + nmmsCustomResponse.setFlightdate(customMt4201.getFlightdate());
  56 + // 航班号
  57 + nmmsCustomResponse.setFlightno(customMt4201.getFlightno());
  58 + // 航班承运人
  59 + nmmsCustomResponse.setCarrier(customMt4201.getCarrier());
  60 + // 主单号
  61 + nmmsCustomResponse.setAwbano(customMt4201.getAwba());
  62 + // 分单号
  63 + nmmsCustomResponse.setAwbhno(customMt4201.getAwbh());
  64 + // 件数
  65 + nmmsCustomResponse.setBuspiece(Integer.valueOf(customMt4201.getLodingpiece().toString()));
  66 + // 重量
  67 + nmmsCustomResponse.setBusweight(Long.valueOf(customMt4201.getLodingweight().toString()));
  68 + map4201.put("status", "1");
  69 + map4201.put("customResponse", nmmsCustomResponse);
  70 +
  71 + return map4201;
46 }else { 72 }else {
47 - return 0; 73 + map4201.put("status", "0");
  74 + return map4201;
48 } 75 }
49 } 76 }
50 77
51 78
52 @Override 79 @Override
53 - public int remove4201(Map<String, Object> map) throws IOException, ParseException { 80 + public Map<String, Object> remove4201(Map<String, Object> map) throws IOException, ParseException {
54 // 关区代码 81 // 关区代码
55 String customCode = map.get("customCode").toString(); 82 String customCode = map.get("customCode").toString();
56 // 报文头时间 精确到毫秒 83 // 报文头时间 精确到毫秒
57 map.put("sendTime", DateUtil.getCurrentTime17()); 84 map.put("sendTime", DateUtil.getCurrentTime17());
58 -  
59 - String flightDate = DateUtil.get_yyyyMMdd(map.get("flightDate").toString());  
60 - map.put("flightDate",flightDate);  
61 // 生成报文头部 85 // 生成报文头部
62 String msgId = makeMsgID("MT4201", orgsn, map.get("awba").toString()); 86 String msgId = makeMsgID("MT4201", orgsn, map.get("awba").toString());
63 String senderId = makeSenderID(customCode, orgsn); 87 String senderId = makeSenderID(customCode, orgsn);
@@ -65,10 +89,17 @@ public class MT4201ServiceImp extends CustomXmlMaker implements MT4201Service { @@ -65,10 +89,17 @@ public class MT4201ServiceImp extends CustomXmlMaker implements MT4201Service {
65 map.put("msgId", msgId); 89 map.put("msgId", msgId);
66 map.put("senderId", senderId); 90 map.put("senderId", senderId);
67 map.put("receiverID", receiverID); 91 map.put("receiverID", receiverID);
  92 + Map<String, Object> map4201 = new HashMap<>();
68 if (makeXmlToFile("/remove/MT4201.ftlx", msgId+".xml", map, "./send/remove/")>0){ 93 if (makeXmlToFile("/remove/MT4201.ftlx", msgId+".xml", map, "./send/remove/")>0){
69 - return 1; 94 + map.put("functionCode", "3");
  95 + map.put("busType","MT4201");
  96 + NMMS_CUSTOM_RESPONSE nmmsCustomResponse = ReturnUtil.nmmsCustomResponse(map);
  97 + map4201.put("status", "1");
  98 + map4201.put("customResponse", nmmsCustomResponse);
  99 + return map4201;
70 }else { 100 }else {
71 - return 0; 101 + map4201.put("staus", "0");
  102 + return map4201;
72 } 103 }
73 } 104 }
74 } 105 }
@@ -2,13 +2,16 @@ package com.sunyo.wlpt.message.builder.service.imp; @@ -2,13 +2,16 @@ package com.sunyo.wlpt.message.builder.service.imp;
2 2
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.message.builder.service.MT520XService; 6 import com.sunyo.wlpt.message.builder.service.MT520XService;
6 import com.sunyo.wlpt.message.builder.util.CustomXmlMaker; 7 import com.sunyo.wlpt.message.builder.util.CustomXmlMaker;
  8 +import com.sunyo.wlpt.message.builder.util.ReturnUtil;
7 import com.tianbo.util.Date.DateUtil; 9 import com.tianbo.util.Date.DateUtil;
8 import org.springframework.beans.factory.annotation.Value; 10 import org.springframework.beans.factory.annotation.Value;
9 import org.springframework.stereotype.Service; 11 import org.springframework.stereotype.Service;
10 12
11 import java.io.IOException; 13 import java.io.IOException;
  14 +import java.text.ParseException;
12 import java.util.HashMap; 15 import java.util.HashMap;
13 import java.util.Map; 16 import java.util.Map;
14 17
@@ -22,7 +25,7 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{ @@ -22,7 +25,7 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{
22 private String orgCode; 25 private String orgCode;
23 26
24 @Override 27 @Override
25 - public int create(Map<String, Object> map) { 28 + public Map<String, Object> create(Map<String, Object> map) {
26 29
27 try { 30 try {
28 31
@@ -51,11 +54,11 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{ @@ -51,11 +54,11 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{
51 hashMap.put("msessageType", msessageType); 54 hashMap.put("msessageType", msessageType);
52 hashMap.put("senderId", senderId); 55 hashMap.put("senderId", senderId);
53 hashMap.put("receiverID", receiverID); 56 hashMap.put("receiverID", receiverID);
54 - if (makeXmlToFile("/manifest/MT5201.ftlx", msgId+".xml", hashMap, "./send/add/")>0){  
55 - return 1;  
56 - }else {  
57 - return 0;  
58 - } 57 +// if (makeXmlToFile("/manifest/MT5201.ftlx", msgId+".xml", hashMap, "./send/add/")>0){
  58 +// return 1;
  59 +// }else {
  60 +// return 0;
  61 +// }
59 }else { 62 }else {
60 63
61 // 生成报文头部 64 // 生成报文头部
@@ -67,22 +70,46 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{ @@ -67,22 +70,46 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{
67 hashMap.put("msessageType", msessageType); 70 hashMap.put("msessageType", msessageType);
68 hashMap.put("senderId", senderId); 71 hashMap.put("senderId", senderId);
69 hashMap.put("receiverID", receiverID); 72 hashMap.put("receiverID", receiverID);
  73 + Map<String, Object> maps = new HashMap<>();
70 if (makeXmlToFile("/manifest/MT5202.ftlx", msgId+".xml", hashMap, "./send/add/")>0){ 74 if (makeXmlToFile("/manifest/MT5202.ftlx", msgId+".xml", hashMap, "./send/add/")>0){
71 - return 1; 75 +
  76 + hashMap.put("functionCode", "2");
  77 + hashMap.put("busType","MT5202");
  78 + NMMS_CUSTOM_RESPONSE nmmsCustomResponse = ReturnUtil.nmmsCustomResponse(hashMap);
  79 + // 航班日期
  80 + nmmsCustomResponse.setFlightdate(customMt520X.getFlightdate());
  81 + // 航班号
  82 + nmmsCustomResponse.setFlightno(customMt520X.getFlightno());
  83 + // 航班承运人
  84 + nmmsCustomResponse.setCarrier(customMt520X.getCarrier());
  85 + // 主单号
  86 + nmmsCustomResponse.setAwbano(customMt520X.getAwba());
  87 + // 分单号
  88 + nmmsCustomResponse.setAwbhno(customMt520X.getAwbh());
  89 + // 件数
  90 + nmmsCustomResponse.setBuspiece(customMt520X.getPiece());
  91 + // 重量
  92 + nmmsCustomResponse.setBusweight(customMt520X.getWeight());
  93 + maps.put("status", "1");
  94 + maps.put("customResponse", nmmsCustomResponse);
  95 +
  96 + return maps;
72 }else { 97 }else {
73 - return 0; 98 + maps.put("staus", "0");
  99 + return maps;
74 } 100 }
75 } 101 }
76 }catch (Exception e){ 102 }catch (Exception e){
77 103
78 e.printStackTrace(); 104 e.printStackTrace();
79 - return 0; 105 + return null;
80 } 106 }
  107 + return null;
81 108
82 } 109 }
83 110
84 @Override 111 @Override
85 - public int remove520x(Map<String, Object> map) throws IOException { 112 + public Map<String, Object> remove520x(Map<String, Object> map) throws IOException, ParseException {
86 113
87 String customCode = map.get("customCode").toString(); 114 String customCode = map.get("customCode").toString();
88 map.put("customCode", customCode); 115 map.put("customCode", customCode);
@@ -96,11 +123,13 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{ @@ -96,11 +123,13 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{
96 map.put("msgId", msgId); 123 map.put("msgId", msgId);
97 map.put("senderId", senderId); 124 map.put("senderId", senderId);
98 map.put("receiverID", receiverID); 125 map.put("receiverID", receiverID);
99 - if (makeXmlToFile("/remove/MT5201.ftlx", msgId+".xml", map, "./send/remove/")>0){  
100 - return 1;  
101 - }else {  
102 - return 0;  
103 - } 126 +// if (makeXmlToFile("/remove/MT5201.ftlx", msgId+".xml", map, "./send/remove/")>0){
  127 +//
  128 +//
  129 +// return 1;
  130 +// }else {
  131 +// return 0;
  132 +// }
104 }else { 133 }else {
105 // 生成报文头部 134 // 生成报文头部
106 String msgId = makeMsgID("MT5202", orgsn, map.get("awba").toString()); 135 String msgId = makeMsgID("MT5202", orgsn, map.get("awba").toString());
@@ -109,12 +138,21 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{ @@ -109,12 +138,21 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{
109 map.put("msgId", msgId); 138 map.put("msgId", msgId);
110 map.put("senderId", senderId); 139 map.put("senderId", senderId);
111 map.put("receiverID", receiverID); 140 map.put("receiverID", receiverID);
  141 + Map<String, Object> maps = new HashMap<>();
112 if (makeXmlToFile("/remove/MT5202.ftlx", msgId+".xml", map, "./send/remove/")>0){ 142 if (makeXmlToFile("/remove/MT5202.ftlx", msgId+".xml", map, "./send/remove/")>0){
113 - return 1; 143 +
  144 + map.put("functionCode", "3");
  145 + map.put("busType","MT5202");
  146 + NMMS_CUSTOM_RESPONSE nmmsCustomResponse = ReturnUtil.nmmsCustomResponse(map);
  147 + maps.put("status", "1");
  148 + maps.put("customResponse", nmmsCustomResponse);
  149 +
  150 + return maps;
114 }else { 151 }else {
115 - return 0; 152 + maps.put("staus", "0");
  153 + return maps;
116 } 154 }
117 } 155 }
  156 + return null;
118 } 157 }
119 -  
120 } 158 }
  1 +package com.sunyo.wlpt.message.builder.util;
  2 +
  3 +import com.sunyo.wlpt.base.model.NMMS_CUSTOM_RESPONSE;
  4 +
  5 +import java.text.ParseException;
  6 +import java.text.SimpleDateFormat;
  7 +import java.util.Date;
  8 +import java.util.Map;
  9 +
  10 +public class ReturnUtil {
  11 +
  12 + /**
  13 + * 报文发送序号
  14 + * 回执发送者id
  15 + * 回执接送者id
  16 + * 对应海关的functioncode业务代码
  17 + * 业务件数
  18 + * 报文发送时间
  19 + * 业务重量
  20 + * 业务类型
  21 + * 主单号
  22 + * 分单号
  23 + * 航班号
  24 + * 航班日期
  25 + * @param map
  26 + * @return
  27 + * @throws ParseException
  28 + */
  29 + public static NMMS_CUSTOM_RESPONSE nmmsCustomResponse(Map<String, Object> map) throws ParseException {
  30 +
  31 + NMMS_CUSTOM_RESPONSE nmmsCustomResponse = new NMMS_CUSTOM_RESPONSE();
  32 +
  33 + if (map.containsKey("msgId")){
  34 + nmmsCustomResponse.setCusmsgid(map.get("msgId").toString());
  35 + }
  36 + if (map.containsKey("senderId")){
  37 + nmmsCustomResponse.setCussenderid(map.get("senderId").toString());
  38 + }
  39 + if (map.containsKey("receiverID")){
  40 + nmmsCustomResponse.setCusreciverid(map.get("receiverID").toString());
  41 + }
  42 + if (map.containsKey("functionCode")){
  43 + nmmsCustomResponse.setCusfunctioncode(map.get("functionCode").toString());
  44 + }
  45 + nmmsCustomResponse.setCusversion("1.0");
  46 + nmmsCustomResponse.setBusdate(new Date());
  47 + if (map.containsKey("piece")){
  48 + nmmsCustomResponse.setBuspiece(Integer.valueOf(map.get("piece").toString()));
  49 + }
  50 + if (map.containsKey("weight")){
  51 + nmmsCustomResponse.setBusweight(Long.valueOf(map.get("weight").toString()));
  52 + }
  53 + nmmsCustomResponse.setBustype(map.get("busType").toString());
  54 + if (map.containsKey("awba")){
  55 + nmmsCustomResponse.setAwbano(map.get("awba").toString());
  56 + }
  57 + if (map.containsKey("awbh")){
  58 + nmmsCustomResponse.setAwbhno(map.get("awbh").toString());
  59 + }
  60 + if (map.containsKey("flightNo")){
  61 + nmmsCustomResponse.setFlightno(map.get("flightNo").toString());
  62 + }
  63 + if (map.containsKey("flightDate")){
  64 + String flightDate = map.get("flightDate").toString();
  65 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  66 + Date parse = simpleDateFormat.parse(flightDate);
  67 + nmmsCustomResponse.setFlightdate(parse);
  68 + }
  69 + if (map.containsKey("reason")){
  70 + nmmsCustomResponse.setOperreason(map.get("reason").toString());
  71 + }
  72 + if (map.containsKey("contactName")){
  73 + nmmsCustomResponse.setOperperson(map.get("contactName").toString());
  74 + }
  75 + if (map.containsKey("contactTel")) {
  76 + nmmsCustomResponse.setOpertel(map.get("contactTel").toString());
  77 + }
  78 +
  79 + return nmmsCustomResponse;
  80 + }
  81 +
  82 +
  83 +
  84 +}
@@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
31 <#if mt['awbh']??> 31 <#if mt['awbh']??>
32 <#if mt.awbh?length gt 1> 32 <#if mt.awbh?length gt 1>
33 <AssociatedTransportDocument> 33 <AssociatedTransportDocument>
34 - <ID>${mt.awba}_${mtawbh}</ID> 34 + <ID>${mt.awba}_${mt.awbh}</ID>
35 </AssociatedTransportDocument> 35 </AssociatedTransportDocument>
36 </#if> 36 </#if>
37 </#if> 37 </#if>
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>${map.msgId}</MessageID> 3 + <MessageID>${msgId}</MessageID>
4 <FunctionCode>3</FunctionCode> 4 <FunctionCode>3</FunctionCode>
5 <MessageType>MT5202</MessageType> 5 <MessageType>MT5202</MessageType>
6 - <SenderID>${map.senderId}</SenderID>  
7 - <ReceiverID>${map.receiverID}</ReceiverID>  
8 - <SendTime>${map.sendTime}</SendTime> 6 + <SenderID>${senderId}</SenderID>
  7 + <ReceiverID>${receiverID}</ReceiverID>
  8 + <SendTime>${sendTime}</SendTime>
9 <Version>1.0</Version> 9 <Version>1.0</Version>
10 </Head> 10 </Head>
11 <Declaration> 11 <Declaration>
12 - <DeclarationOfficeID>${map.customCode}</DeclarationOfficeID> 12 + <DeclarationOfficeID>${customCode}</DeclarationOfficeID>
13 <BorderTransportMeans> 13 <BorderTransportMeans>
14 - <JourneyID>${map.flightNo}/${map.flightDate}</JourneyID> 14 + <JourneyID>${flightNo}/${flightDate}</JourneyID>
15 </BorderTransportMeans> 15 </BorderTransportMeans>
16 <Consignment> 16 <Consignment>
17 <TransportContractDocument> 17 <TransportContractDocument>
18 - <ID>${map.awba}</ID> 18 + <ID>${awba}</ID>
19 </TransportContractDocument> 19 </TransportContractDocument>
20 - <#if map.map['awbh']??>  
21 - <#if map.awbh?length gt 1> 20 + <#if awbh?length gt 1>
22 <AssociatedTransportDocument> 21 <AssociatedTransportDocument>
23 - <ID>${map.awba}_${map.awbh}</ID> 22 + <ID>${awba}_${awbh}</ID>
24 </AssociatedTransportDocument> 23 </AssociatedTransportDocument>
25 </#if> 24 </#if>
26 - </#if>  
27 </Consignment> 25 </Consignment>
28 <AdditionalInformation> 26 <AdditionalInformation>
29 - <Reason>${map.reason}</Reason>  
30 - <ContactName>${map.contactName}</ContactName>  
31 - <ContactTel>${map.contactTel}</ContactTel> 27 + <Reason>${reason}</Reason>
  28 + <ContactName>${contactName}</ContactName>
  29 + <ContactTel>${contactTel}</ContactTel>
32 <#if content?length gt 1> 30 <#if content?length gt 1>
33 <Content>${content}</Content> 31 <Content>${content}</Content>
34 </#if> 32 </#if>