作者 shenhailong

快邮报文生成

修改报文生成逻辑为 预配批量发送 预配批量修改
... ... @@ -102,6 +102,11 @@
<artifactId>base</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.sunyo.wlpt</groupId>
<artifactId>base</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
... ...
package com.sunyo.wlpt.message.builder.controller;
import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT2201;
import com.sunyo.wlpt.message.builder.service.MT2201Service;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -7,7 +8,9 @@ import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
... ... @@ -19,22 +22,19 @@ public class MT2201Controller {
/**
* 生成报文
* @param map
* @param nmmsCustomMt2201List
* @return
*/
@PostMapping("/creatMt2201")
@ApiOperation(value = "生成报文")
@ResponseBody
public Map<String, Object> creatMt2201(@RequestBody Map<String, Object> map) {
public List<Map<String, Object>> creatMt2201(@RequestBody List<NMMS_CUSTOM_MT2201> nmmsCustomMt2201List) {
try {
return mt2201Service.creatMt2201(map);
return mt2201Service.creatMt2201(nmmsCustomMt2201List);
}catch (Exception e){
e.printStackTrace();
Map<String, Object> maps = new HashMap<>();
maps.put("status", "0");
return maps;
return null;
}
}
... ... @@ -42,16 +42,17 @@ public class MT2201Controller {
@PutMapping("/editMt2201")
@ApiOperation(value = "修改报文")
@ResponseBody
public Map<String, Object> editMt2201(@RequestBody Map<String, Object> map) {
public List<Map<String, Object>> editMt2201(@RequestBody List<NMMS_CUSTOM_MT2201> nmmsCustomMt2201List,
@RequestParam("reason")String reason,
@RequestParam("contactName")String contactName,
@RequestParam("contactTel")String contactTel) {
try {
return mt2201Service.editMt2201(map);
return mt2201Service.editMt2201(nmmsCustomMt2201List, reason, contactName, contactTel);
}catch (Exception e){
e.printStackTrace();
Map<String, Object> maps = new HashMap<>();
maps.put("status", "0");
return maps;
return null;
}
}
... ... @@ -62,7 +63,6 @@ public class MT2201Controller {
public Map<String, Object> removeMt2201(@RequestBody Map<String, Object> map) {
try {
return mt2201Service.removeMt2201(map);
}catch (Exception e){
e.printStackTrace();
... ...
... ... @@ -29,8 +29,7 @@ public class ExparessAwbaController {
public Map<String, Object> creatAwba(@RequestBody ExpAwba311 expAwba311){
try {
expressService.creatAwba(expAwba311);
return null;
return expressService.creatAwba(expAwba311);
}catch (Exception e){
e.printStackTrace();
return null;
... ...
package com.sunyo.wlpt.message.builder.expressSerivce.imp;
import com.sunyo.wlpt.message.builder.exparessModel.CustomResponse;
import com.sunyo.wlpt.message.builder.exparessModel.ExpAwba311;
import com.sunyo.wlpt.message.builder.exparessModel.ExpAwbh311;
import com.sunyo.wlpt.message.builder.expressSerivce.ExpressService;
... ... @@ -8,6 +9,7 @@ import com.tianbo.util.Date.DateUtil;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
... ... @@ -22,13 +24,52 @@ public class ExpressServiceImp extends CustomXmlMaker implements ExpressService
@Override
public Map<String, Object> creatAwba(ExpAwba311 expAwba311) throws IOException {
String cusResCode= "";
if ("ADD".equals(expAwba311.getOptype())){
cusResCode = "23";
}else {
cusResCode = "24";
}
List<ExpAwbh311> children = expAwba311.getChildren();
Map hashMap = new HashMap();
hashMap.put("awba", expAwba311);
hashMap.put("awbh", children);
makeXmlToFile("/express/add/EXP311.ftlx", expAwba311.getBillno()+ DateUtil.getDDTM() +".xml", hashMap, "");
if (makeXmlToFile("/express/add/EXP311.ftlx", expAwba311.getBillno()+ DateUtil.getDDTM() +".xml", hashMap, "")>0){
Map resultMap = new HashMap();
List list = new ArrayList();
CustomResponse customResponse = new CustomResponse();
// 航班日期
customResponse.setFlightdate(expAwba311.getFlightDate());
// 航班号
customResponse.setFlightno(expAwba311.getFlightNo());
// 主单号
customResponse.setAwbano(expAwba311.getBillno());
// 件数
customResponse.setBuspiece(expAwba311.getPackno());
// 重量
customResponse.setBusweight(expAwba311.getGrosswt());
// 操作类型
customResponse.setOpertype(expAwba311.getOptype());
customResponse.setCusrestext("快邮舱单报文发送成功");
customResponse.setCusrescode(cusResCode);
hashMap.put("customResponse", customResponse);
for (ExpAwbh311 expAwbh311: children){
CustomResponse customResponseAwbh = new CustomResponse();
customResponseAwbh.setAwbano(expAwbh311.getBillno());
customResponseAwbh.setAwbhno(expAwbh311.getAssbillno());
customResponseAwbh.setFlightno(expAwbh311.getFlightNo());
customResponseAwbh.setFlightdate(expAwbh311.getFlightDate());
customResponseAwbh.setBuspiece(expAwbh311.getPackno());
customResponseAwbh.setBusweight(expAwbh311.getGrosswt());
customResponseAwbh.setOpertype(expAwba311.getOptype());
customResponse.setCusrescode(cusResCode);
list.add(customResponseAwbh);
}
list.add(customResponse);
resultMap.put("result", list);
return resultMap;
}
return null;
}
}
... ...
... ... @@ -5,6 +5,7 @@ import org.omg.CORBA.OBJECT_NOT_EXIST;
import java.io.IOException;
import java.text.ParseException;
import java.util.List;
import java.util.Map;
public interface MT2201Service {
... ... @@ -21,9 +22,10 @@ public interface MT2201Service {
int updateByPrimaryKey(NMMS_CUSTOM_MT2201 record);
Map<String, Object> creatMt2201(Map<String, Object> map) throws IOException, ParseException;
List<Map<String, Object>> creatMt2201(List<NMMS_CUSTOM_MT2201> nmmsCustomMt2201List) throws IOException, ParseException;
Map<String, Object> editMt2201(Map<String, Object> map) throws IOException, ParseException;
List<Map<String, Object>> editMt2201(List<NMMS_CUSTOM_MT2201> nmmsCustomMt2201List,
String reason, String contactName, String contactTel) throws IOException, ParseException;
Map<String, Object> removeMt2201(Map<String, Object> map) throws IOException, ParseException;
... ...
... ... @@ -18,9 +18,7 @@ import java.io.IOException;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
@Service
public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service {
... ... @@ -62,30 +60,48 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service {
private String orgCode;
@Override
public Map<String, Object> creatMt2201(Map<String, Object> map) throws IOException, ParseException {
public List<Map<String, Object>> creatMt2201(List<NMMS_CUSTOM_MT2201> nmmsCustomMt2201List) throws IOException, ParseException {
List<Map<String, Object>> mapList = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
for (NMMS_CUSTOM_MT2201 nmmsCustomMt2201: nmmsCustomMt2201List){
map.put("templatePath", "/manifest/MT2201.ftlx");
map.put("sendPath", "./send/add/");
return mt2201(map);
map.put("mt2201", nmmsCustomMt2201);
Map<String, Object> map1 = mt2201(map);
mapList.add(map1);
}
return mapList;
}
@Override
public Map<String, Object> editMt2201(Map<String, Object> map) throws IOException, ParseException {
public List<Map<String, Object>> editMt2201(List<NMMS_CUSTOM_MT2201> nmmsCustomMt2201List,
String reason,
String contactName,
String contactTel) throws IOException, ParseException {
List<Map<String, Object>> mapList = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
map.put("reason", reason);
map.put("contactName", contactName);
map.put("contactTel", contactTel);
for (NMMS_CUSTOM_MT2201 nmmsCustomMt2201: nmmsCustomMt2201List){
map.put("templatePath", "/edit/MT2201.ftlx");
map.put("sendPath", "./send/edit/");
return mt2201(map);
map.put("mt2201", nmmsCustomMt2201);
Map<String, Object> map1 = mt2201(map);
mapList.add(map1);
}
return mapList;
}
@Override
public Map<String, Object> removeMt2201(Map<String, Object> map) throws IOException, ParseException {
String customCode = map.get("customCode").toString();
// 生成报文头部信息
CustomsXmlFactory customsXmlFactory = new CustomsXmlFactory();
CustomsXmlHeader message = customsXmlFactory.getCustomsXmlHeader("MESSAGE");
Map<String, Object> mt2201 = message.makeHeader(customCode, orgsn, map.get("awba").toString(), orgCode, "", "MT2201");
map.put("map", mt2201);
// 舱单传输人名称
map.put("orgCode", orgCode);
// 处理主单号-
... ... @@ -142,19 +158,16 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service {
// 处理主单号-
String awba = ReturnUtil.awbaReplace(custom_mt2201.getAwba());
map.put("awba", awba);
// 生成报文头部信息
CustomsXmlFactory customsXmlFactory = new CustomsXmlFactory();
CustomsXmlHeader message = customsXmlFactory.getCustomsXmlHeader("MESSAGE");
Map<String, Object> mt2201 = message.makeHeader(customCode, orgsn, custom_mt2201.getAwba(), orgCode, "", "MT2201");
map.put("map", mt2201);
String s = DateUtil.addDateMinut(new Date(), 6);
// 货物装卸时间
map.put("loadingDate",s);
// 舱单传输人名称
map.put("orgCode", orgCode);
Map<String, Object> maps = new HashMap<>();
// 生成报文
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 {
nmmsCustomResponse.setCusrestext("新增报发送成功");
maps.put("status", "1");
maps.put("customResponse", nmmsCustomResponse);
return maps;
}else {
map.put("functionCode", "5");
... ...
... ... @@ -8,7 +8,6 @@ import com.sunyo.wlpt.message.builder.factory.CustomsXmlHeader;
import com.sunyo.wlpt.message.builder.service.MT3201Service;
import com.sunyo.wlpt.message.builder.util.CustomXmlMaker;
import com.sunyo.wlpt.message.builder.util.ReturnUtil;
import com.tianbo.util.Date.DateUtil;
import com.tianbo.util.nmms.AwbaUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
... ...