作者 shenhailong

快邮报文生成

修改报文生成逻辑为 预配批量发送 预配批量修改
@@ -102,6 +102,11 @@ @@ -102,6 +102,11 @@
102 <artifactId>base</artifactId> 102 <artifactId>base</artifactId>
103 <version>1.0-SNAPSHOT</version> 103 <version>1.0-SNAPSHOT</version>
104 </dependency> 104 </dependency>
  105 + <dependency>
  106 + <groupId>com.sunyo.wlpt</groupId>
  107 + <artifactId>base</artifactId>
  108 + <version>1.0-SNAPSHOT</version>
  109 + </dependency>
105 110
106 <dependency> 111 <dependency>
107 <groupId>org.springframework.cloud</groupId> 112 <groupId>org.springframework.cloud</groupId>
1 package com.sunyo.wlpt.message.builder.controller; 1 package com.sunyo.wlpt.message.builder.controller;
2 2
  3 +import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT2201;
3 import com.sunyo.wlpt.message.builder.service.MT2201Service; 4 import com.sunyo.wlpt.message.builder.service.MT2201Service;
4 import io.swagger.annotations.ApiOperation; 5 import io.swagger.annotations.ApiOperation;
5 import org.springframework.beans.factory.annotation.Autowired; 6 import org.springframework.beans.factory.annotation.Autowired;
@@ -7,7 +8,9 @@ import org.springframework.web.bind.annotation.*; @@ -7,7 +8,9 @@ import org.springframework.web.bind.annotation.*;
7 8
8 import java.io.IOException; 9 import java.io.IOException;
9 import java.text.ParseException; 10 import java.text.ParseException;
  11 +import java.util.ArrayList;
10 import java.util.HashMap; 12 import java.util.HashMap;
  13 +import java.util.List;
11 import java.util.Map; 14 import java.util.Map;
12 15
13 @RestController 16 @RestController
@@ -19,22 +22,19 @@ public class MT2201Controller { @@ -19,22 +22,19 @@ public class MT2201Controller {
19 22
20 /** 23 /**
21 * 生成报文 24 * 生成报文
22 - * @param map 25 + * @param nmmsCustomMt2201List
23 * @return 26 * @return
24 */ 27 */
25 @PostMapping("/creatMt2201") 28 @PostMapping("/creatMt2201")
26 @ApiOperation(value = "生成报文") 29 @ApiOperation(value = "生成报文")
27 @ResponseBody 30 @ResponseBody
28 - public Map<String, Object> creatMt2201(@RequestBody Map<String, Object> map) { 31 + public List<Map<String, Object>> creatMt2201(@RequestBody List<NMMS_CUSTOM_MT2201> nmmsCustomMt2201List) {
29 32
30 try { 33 try {
31 -  
32 - return mt2201Service.creatMt2201(map); 34 + return mt2201Service.creatMt2201(nmmsCustomMt2201List);
33 }catch (Exception e){ 35 }catch (Exception e){
34 e.printStackTrace(); 36 e.printStackTrace();
35 - Map<String, Object> maps = new HashMap<>();  
36 - maps.put("status", "0");  
37 - return maps; 37 + return null;
38 } 38 }
39 39
40 } 40 }
@@ -42,16 +42,17 @@ public class MT2201Controller { @@ -42,16 +42,17 @@ public class MT2201Controller {
42 @PutMapping("/editMt2201") 42 @PutMapping("/editMt2201")
43 @ApiOperation(value = "修改报文") 43 @ApiOperation(value = "修改报文")
44 @ResponseBody 44 @ResponseBody
45 - public Map<String, Object> editMt2201(@RequestBody Map<String, Object> map) { 45 + public List<Map<String, Object>> editMt2201(@RequestBody List<NMMS_CUSTOM_MT2201> nmmsCustomMt2201List,
  46 + @RequestParam("reason")String reason,
  47 + @RequestParam("contactName")String contactName,
  48 + @RequestParam("contactTel")String contactTel) {
46 49
47 try { 50 try {
48 51
49 - return mt2201Service.editMt2201(map); 52 + return mt2201Service.editMt2201(nmmsCustomMt2201List, reason, contactName, contactTel);
50 }catch (Exception e){ 53 }catch (Exception e){
51 e.printStackTrace(); 54 e.printStackTrace();
52 - Map<String, Object> maps = new HashMap<>();  
53 - maps.put("status", "0");  
54 - return maps; 55 + return null;
55 } 56 }
56 57
57 } 58 }
@@ -62,7 +63,6 @@ public class MT2201Controller { @@ -62,7 +63,6 @@ public class MT2201Controller {
62 public Map<String, Object> removeMt2201(@RequestBody Map<String, Object> map) { 63 public Map<String, Object> removeMt2201(@RequestBody Map<String, Object> map) {
63 64
64 try { 65 try {
65 -  
66 return mt2201Service.removeMt2201(map); 66 return mt2201Service.removeMt2201(map);
67 }catch (Exception e){ 67 }catch (Exception e){
68 e.printStackTrace(); 68 e.printStackTrace();
@@ -29,8 +29,7 @@ public class ExparessAwbaController { @@ -29,8 +29,7 @@ public class ExparessAwbaController {
29 public Map<String, Object> creatAwba(@RequestBody ExpAwba311 expAwba311){ 29 public Map<String, Object> creatAwba(@RequestBody ExpAwba311 expAwba311){
30 30
31 try { 31 try {
32 - expressService.creatAwba(expAwba311);  
33 - return null; 32 + return expressService.creatAwba(expAwba311);
34 }catch (Exception e){ 33 }catch (Exception e){
35 e.printStackTrace(); 34 e.printStackTrace();
36 return null; 35 return null;
1 package com.sunyo.wlpt.message.builder.expressSerivce.imp; 1 package com.sunyo.wlpt.message.builder.expressSerivce.imp;
2 2
  3 +import com.sunyo.wlpt.message.builder.exparessModel.CustomResponse;
3 import com.sunyo.wlpt.message.builder.exparessModel.ExpAwba311; 4 import com.sunyo.wlpt.message.builder.exparessModel.ExpAwba311;
4 import com.sunyo.wlpt.message.builder.exparessModel.ExpAwbh311; 5 import com.sunyo.wlpt.message.builder.exparessModel.ExpAwbh311;
5 import com.sunyo.wlpt.message.builder.expressSerivce.ExpressService; 6 import com.sunyo.wlpt.message.builder.expressSerivce.ExpressService;
@@ -8,6 +9,7 @@ import com.tianbo.util.Date.DateUtil; @@ -8,6 +9,7 @@ import com.tianbo.util.Date.DateUtil;
8 import org.springframework.stereotype.Service; 9 import org.springframework.stereotype.Service;
9 10
10 import java.io.IOException; 11 import java.io.IOException;
  12 +import java.util.ArrayList;
11 import java.util.HashMap; 13 import java.util.HashMap;
12 import java.util.List; 14 import java.util.List;
13 import java.util.Map; 15 import java.util.Map;
@@ -22,13 +24,52 @@ public class ExpressServiceImp extends CustomXmlMaker implements ExpressService @@ -22,13 +24,52 @@ public class ExpressServiceImp extends CustomXmlMaker implements ExpressService
22 24
23 @Override 25 @Override
24 public Map<String, Object> creatAwba(ExpAwba311 expAwba311) throws IOException { 26 public Map<String, Object> creatAwba(ExpAwba311 expAwba311) throws IOException {
  27 + String cusResCode= "";
  28 + if ("ADD".equals(expAwba311.getOptype())){
  29 + cusResCode = "23";
  30 + }else {
  31 + cusResCode = "24";
  32 + }
25 33
26 List<ExpAwbh311> children = expAwba311.getChildren(); 34 List<ExpAwbh311> children = expAwba311.getChildren();
27 Map hashMap = new HashMap(); 35 Map hashMap = new HashMap();
28 hashMap.put("awba", expAwba311); 36 hashMap.put("awba", expAwba311);
29 hashMap.put("awbh", children); 37 hashMap.put("awbh", children);
30 - makeXmlToFile("/express/add/EXP311.ftlx", expAwba311.getBillno()+ DateUtil.getDDTM() +".xml", hashMap, "");  
31 - 38 + if (makeXmlToFile("/express/add/EXP311.ftlx", expAwba311.getBillno()+ DateUtil.getDDTM() +".xml", hashMap, "")>0){
  39 + Map resultMap = new HashMap();
  40 + List list = new ArrayList();
  41 + CustomResponse customResponse = new CustomResponse();
  42 + // 航班日期
  43 + customResponse.setFlightdate(expAwba311.getFlightDate());
  44 + // 航班号
  45 + customResponse.setFlightno(expAwba311.getFlightNo());
  46 + // 主单号
  47 + customResponse.setAwbano(expAwba311.getBillno());
  48 + // 件数
  49 + customResponse.setBuspiece(expAwba311.getPackno());
  50 + // 重量
  51 + customResponse.setBusweight(expAwba311.getGrosswt());
  52 + // 操作类型
  53 + customResponse.setOpertype(expAwba311.getOptype());
  54 + customResponse.setCusrestext("快邮舱单报文发送成功");
  55 + customResponse.setCusrescode(cusResCode);
  56 + hashMap.put("customResponse", customResponse);
  57 + for (ExpAwbh311 expAwbh311: children){
  58 + CustomResponse customResponseAwbh = new CustomResponse();
  59 + customResponseAwbh.setAwbano(expAwbh311.getBillno());
  60 + customResponseAwbh.setAwbhno(expAwbh311.getAssbillno());
  61 + customResponseAwbh.setFlightno(expAwbh311.getFlightNo());
  62 + customResponseAwbh.setFlightdate(expAwbh311.getFlightDate());
  63 + customResponseAwbh.setBuspiece(expAwbh311.getPackno());
  64 + customResponseAwbh.setBusweight(expAwbh311.getGrosswt());
  65 + customResponseAwbh.setOpertype(expAwba311.getOptype());
  66 + customResponse.setCusrescode(cusResCode);
  67 + list.add(customResponseAwbh);
  68 + }
  69 + list.add(customResponse);
  70 + resultMap.put("result", list);
  71 + return resultMap;
  72 + }
32 return null; 73 return null;
33 } 74 }
34 } 75 }
@@ -5,6 +5,7 @@ import org.omg.CORBA.OBJECT_NOT_EXIST; @@ -5,6 +5,7 @@ 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.text.ParseException;
  8 +import java.util.List;
8 import java.util.Map; 9 import java.util.Map;
9 10
10 public interface MT2201Service { 11 public interface MT2201Service {
@@ -21,9 +22,10 @@ public interface MT2201Service { @@ -21,9 +22,10 @@ public interface MT2201Service {
21 22
22 int updateByPrimaryKey(NMMS_CUSTOM_MT2201 record); 23 int updateByPrimaryKey(NMMS_CUSTOM_MT2201 record);
23 24
24 - Map<String, Object> creatMt2201(Map<String, Object> map) throws IOException, ParseException; 25 + List<Map<String, Object>> creatMt2201(List<NMMS_CUSTOM_MT2201> nmmsCustomMt2201List) throws IOException, ParseException;
25 26
26 - Map<String, Object> editMt2201(Map<String, Object> map) throws IOException, ParseException; 27 + List<Map<String, Object>> editMt2201(List<NMMS_CUSTOM_MT2201> nmmsCustomMt2201List,
  28 + String reason, String contactName, String contactTel) throws IOException, ParseException;
27 29
28 Map<String, Object> removeMt2201(Map<String, Object> map) throws IOException, ParseException; 30 Map<String, Object> removeMt2201(Map<String, Object> map) throws IOException, ParseException;
29 31
@@ -18,9 +18,7 @@ import java.io.IOException; @@ -18,9 +18,7 @@ import java.io.IOException;
18 import java.math.BigDecimal; 18 import java.math.BigDecimal;
19 import java.text.ParseException; 19 import java.text.ParseException;
20 import java.text.SimpleDateFormat; 20 import java.text.SimpleDateFormat;
21 -import java.util.Date;  
22 -import java.util.HashMap;  
23 -import java.util.Map; 21 +import java.util.*;
24 22
25 @Service 23 @Service
26 public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service { 24 public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service {
@@ -62,30 +60,48 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service { @@ -62,30 +60,48 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service {
62 private String orgCode; 60 private String orgCode;
63 61
64 @Override 62 @Override
65 - public Map<String, Object> creatMt2201(Map<String, Object> map) throws IOException, ParseException {  
66 - map.put("templatePath", "/manifest/MT2201.ftlx");  
67 - map.put("sendPath", "./send/add/");  
68 - return mt2201(map); 63 + public List<Map<String, Object>> creatMt2201(List<NMMS_CUSTOM_MT2201> nmmsCustomMt2201List) throws IOException, ParseException {
  64 + List<Map<String, Object>> mapList = new ArrayList<>();
  65 + Map<String, Object> map = new HashMap<>();
  66 + for (NMMS_CUSTOM_MT2201 nmmsCustomMt2201: nmmsCustomMt2201List){
  67 + map.put("templatePath", "/manifest/MT2201.ftlx");
  68 + map.put("sendPath", "./send/add/");
  69 + map.put("mt2201", nmmsCustomMt2201);
  70 + Map<String, Object> map1 = mt2201(map);
  71 + mapList.add(map1);
  72 + }
  73 + return mapList;
69 } 74 }
70 75
71 @Override 76 @Override
72 - public Map<String, Object> editMt2201(Map<String, Object> map) throws IOException, ParseException {  
73 - map.put("templatePath", "/edit/MT2201.ftlx");  
74 - map.put("sendPath", "./send/edit/");  
75 - return mt2201(map); 77 + public List<Map<String, Object>> editMt2201(List<NMMS_CUSTOM_MT2201> nmmsCustomMt2201List,
  78 + String reason,
  79 + String contactName,
  80 + String contactTel) throws IOException, ParseException {
  81 + List<Map<String, Object>> mapList = new ArrayList<>();
  82 + Map<String, Object> map = new HashMap<>();
  83 + map.put("reason", reason);
  84 + map.put("contactName", contactName);
  85 + map.put("contactTel", contactTel);
  86 + for (NMMS_CUSTOM_MT2201 nmmsCustomMt2201: nmmsCustomMt2201List){
  87 + map.put("templatePath", "/edit/MT2201.ftlx");
  88 + map.put("sendPath", "./send/edit/");
  89 + map.put("mt2201", nmmsCustomMt2201);
  90 + Map<String, Object> map1 = mt2201(map);
  91 + mapList.add(map1);
  92 + }
  93 + return mapList;
76 } 94 }
77 95
78 @Override 96 @Override
79 public Map<String, Object> removeMt2201(Map<String, Object> map) throws IOException, ParseException { 97 public Map<String, Object> removeMt2201(Map<String, Object> map) throws IOException, ParseException {
80 98
81 String customCode = map.get("customCode").toString(); 99 String customCode = map.get("customCode").toString();
82 -  
83 // 生成报文头部信息 100 // 生成报文头部信息
84 CustomsXmlFactory customsXmlFactory = new CustomsXmlFactory(); 101 CustomsXmlFactory customsXmlFactory = new CustomsXmlFactory();
85 CustomsXmlHeader message = customsXmlFactory.getCustomsXmlHeader("MESSAGE"); 102 CustomsXmlHeader message = customsXmlFactory.getCustomsXmlHeader("MESSAGE");
86 Map<String, Object> mt2201 = message.makeHeader(customCode, orgsn, map.get("awba").toString(), orgCode, "", "MT2201"); 103 Map<String, Object> mt2201 = message.makeHeader(customCode, orgsn, map.get("awba").toString(), orgCode, "", "MT2201");
87 map.put("map", mt2201); 104 map.put("map", mt2201);
88 -  
89 // 舱单传输人名称 105 // 舱单传输人名称
90 map.put("orgCode", orgCode); 106 map.put("orgCode", orgCode);
91 // 处理主单号- 107 // 处理主单号-
@@ -142,19 +158,16 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service { @@ -142,19 +158,16 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service {
142 // 处理主单号- 158 // 处理主单号-
143 String awba = ReturnUtil.awbaReplace(custom_mt2201.getAwba()); 159 String awba = ReturnUtil.awbaReplace(custom_mt2201.getAwba());
144 map.put("awba", awba); 160 map.put("awba", awba);
145 -  
146 // 生成报文头部信息 161 // 生成报文头部信息
147 CustomsXmlFactory customsXmlFactory = new CustomsXmlFactory(); 162 CustomsXmlFactory customsXmlFactory = new CustomsXmlFactory();
148 CustomsXmlHeader message = customsXmlFactory.getCustomsXmlHeader("MESSAGE"); 163 CustomsXmlHeader message = customsXmlFactory.getCustomsXmlHeader("MESSAGE");
149 Map<String, Object> mt2201 = message.makeHeader(customCode, orgsn, custom_mt2201.getAwba(), orgCode, "", "MT2201"); 164 Map<String, Object> mt2201 = message.makeHeader(customCode, orgsn, custom_mt2201.getAwba(), orgCode, "", "MT2201");
150 map.put("map", mt2201); 165 map.put("map", mt2201);
151 -  
152 String s = DateUtil.addDateMinut(new Date(), 6); 166 String s = DateUtil.addDateMinut(new Date(), 6);
153 // 货物装卸时间 167 // 货物装卸时间
154 map.put("loadingDate",s); 168 map.put("loadingDate",s);
155 // 舱单传输人名称 169 // 舱单传输人名称
156 map.put("orgCode", orgCode); 170 map.put("orgCode", orgCode);
157 -  
158 Map<String, Object> maps = new HashMap<>(); 171 Map<String, Object> maps = new HashMap<>();
159 // 生成报文 172 // 生成报文
160 if (makeXmlToFile(map.get("templatePath").toString(), mt2201.get("messageID")+".xml", map, map.get("sendPath").toString())>0){ 173 if (makeXmlToFile(map.get("templatePath").toString(), mt2201.get("messageID")+".xml", map, map.get("sendPath").toString())>0){
@@ -182,7 +195,6 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service { @@ -182,7 +195,6 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service {
182 nmmsCustomResponse.setCusrestext("新增报发送成功"); 195 nmmsCustomResponse.setCusrestext("新增报发送成功");
183 maps.put("status", "1"); 196 maps.put("status", "1");
184 maps.put("customResponse", nmmsCustomResponse); 197 maps.put("customResponse", nmmsCustomResponse);
185 -  
186 return maps; 198 return maps;
187 }else { 199 }else {
188 map.put("functionCode", "5"); 200 map.put("functionCode", "5");
@@ -8,7 +8,6 @@ import com.sunyo.wlpt.message.builder.factory.CustomsXmlHeader; @@ -8,7 +8,6 @@ import com.sunyo.wlpt.message.builder.factory.CustomsXmlHeader;
8 import com.sunyo.wlpt.message.builder.service.MT3201Service; 8 import com.sunyo.wlpt.message.builder.service.MT3201Service;
9 import com.sunyo.wlpt.message.builder.util.CustomXmlMaker; 9 import com.sunyo.wlpt.message.builder.util.CustomXmlMaker;
10 import com.sunyo.wlpt.message.builder.util.ReturnUtil; 10 import com.sunyo.wlpt.message.builder.util.ReturnUtil;
11 -import com.tianbo.util.Date.DateUtil;  
12 import com.tianbo.util.nmms.AwbaUtils; 11 import com.tianbo.util.nmms.AwbaUtils;
13 import org.springframework.beans.factory.annotation.Value; 12 import org.springframework.beans.factory.annotation.Value;
14 import org.springframework.stereotype.Service; 13 import org.springframework.stereotype.Service;