作者 shenhailong

生成报文 。。。。。。。。。。

正在显示 23 个修改的文件 包含 364 行增加33 行删除
... ... @@ -20,14 +20,14 @@ public class MT1201Controller {
*/
@RequestMapping("/createMt1201")
@ResponseBody
public int ffmcreate(@RequestBody Map<String, Object> map){
public Map<String, Object> ffmcreate(@RequestBody Map<String, Object> map){
try {
return mt1201Service.ffmcreate(map);
}catch (Exception e){
e.printStackTrace();
return 0;
return null;
}
}
... ... @@ -39,28 +39,28 @@ public class MT1201Controller {
*/
@PutMapping("/editMt1201")
@ResponseBody
public int editMt1201(@RequestBody Map<String, Object> map){
public Map<String, Object> editMt1201(@RequestBody Map<String, Object> map){
try {
return mt1201Service.editMt1201(map);
}catch (Exception e){
e.printStackTrace();
return 0;
return null;
}
}
@PutMapping("/removeMt1201")
@ResponseBody
public int removeMt1201(@RequestBody Map<String, Object> map){
public Map<String, Object> removeMt1201(@RequestBody Map<String, Object> map){
try {
return mt1201Service.removeMt1201(map);
}catch (Exception e){
e.printStackTrace();
return 0;
return null;
}
}
... ...
package com.sunyo.wlpt.message.builder.controller;
import com.sunyo.wlpt.message.builder.service.MT3202Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RestController
@RequestMapping(value = "/mt3202")
public class MT3202Controller {
@Autowired
private MT3202Service mt3202Service;
@PostMapping("/createMt3202")
@ResponseBody
public Map<String, Object> createMt3201(@RequestBody Map<String, Object> map){
try {
return mt3202Service.createMt3202(map);
}catch (Exception e){
e.printStackTrace();
return null;
}
}
@PutMapping("/removeMt3202")
@ResponseBody
public Map<String, Object> remove(@RequestBody Map<String, Object> map){
try {
return mt3202Service.removeMt3202(map);
}catch (Exception e){
e.printStackTrace();
return null;
}
}
}
... ...
... ... @@ -20,7 +20,7 @@ public class MT520XController {
* @param map
* @return
*/
@RequestMapping("/createMt520x")
@PostMapping("/createMt520x")
@ResponseBody
public Map<String, Object> create(@RequestBody Map<String, Object> map){
... ...
... ... @@ -15,7 +15,7 @@ public class MT6202Controller {
@Autowired
private MT6202Service mt6202Service;
@PostMapping(value = "/creatMt6202")
@PostMapping(value = "/createMt6202")
@ResponseBody
public Map<String, Object> creatMt8205(@RequestBody Map<String, Object> map) throws IOException, ParseException {
... ...
package com.sunyo.wlpt.message.builder.service;
import java.io.IOException;
import java.text.ParseException;
import java.util.Map;
public interface MT1201Service {
int ffmcreate (Map<String, Object> map) throws IOException;
Map<String, Object> ffmcreate (Map<String, Object> map) throws IOException, ParseException;
int editMt1201 (Map<String, Object> map) throws IOException;
Map<String, Object> editMt1201 (Map<String, Object> map) throws IOException, ParseException;
int removeMt1201 (Map<String, Object> map) throws IOException;
Map<String, Object> removeMt1201 (Map<String, Object> map) throws IOException, ParseException;
}
... ...
package com.sunyo.wlpt.message.builder.service;
import java.io.IOException;
import java.text.ParseException;
import java.util.Map;
public interface MT3202Service {
Map<String, Object> createMt3202(Map<String, Object> map) throws ParseException, IOException;
Map<String, Object> removeMt3202(Map<String, Object> map) throws IOException, ParseException;
}
... ...
package com.sunyo.wlpt.message.builder.service;
import java.io.IOException;
import java.text.ParseException;
import java.util.Map;
public interface MT6202Service {
Map<String, Object> creatMt6202(Map<String, Object> map) throws IOException, ParseException;
Map<String, Object> removeMt6202(Map<String, Object> map) throws IOException, ParseException;
}
... ...
package com.sunyo.wlpt.message.builder.service;
import java.io.IOException;
import java.text.ParseException;
import java.util.Map;
public interface MT8205Service {
Boolean create8205(Map<String, Object> map) throws IOException;
Map<String, Object> create8205(Map<String, Object> map) throws IOException, ParseException;
}
... ...
... ... @@ -3,13 +3,17 @@ package com.sunyo.wlpt.message.builder.service.imp;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sunyo.wlpt.base.model.AWB_AWBINFO;
import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT1201;
import com.sunyo.wlpt.base.model.NMMS_CUSTOM_RESPONSE;
import com.sunyo.wlpt.message.builder.service.MT1201Service;
import com.sunyo.wlpt.message.builder.util.CustomXmlMaker;
import com.sunyo.wlpt.message.builder.util.ReturnUtil;
import com.tianbo.util.Date.DateUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.text.ParseException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
... ... @@ -23,7 +27,7 @@ public class MT1201ServiceImp extends CustomXmlMaker implements MT1201Service{
private String orgCode;
@Override
public int ffmcreate(Map<String, Object> map) throws IOException {
public Map<String, Object> ffmcreate(Map<String, Object> map) throws IOException, ParseException {
map.put("templatePath", "/manifest/MT1201.ftlx");
map.put("sendPath", "./send/add/");
... ... @@ -31,7 +35,7 @@ public class MT1201ServiceImp extends CustomXmlMaker implements MT1201Service{
}
@Override
public int editMt1201(Map<String, Object> map) throws IOException {
public Map<String, Object> editMt1201(Map<String, Object> map) throws IOException, ParseException {
map.put("templatePath", "/edit/MT1201.ftlx");
map.put("sendPath", "./send/edit/");
... ... @@ -39,7 +43,7 @@ public class MT1201ServiceImp extends CustomXmlMaker implements MT1201Service{
}
@Override
public int removeMt1201(Map<String, Object> map) throws IOException {
public Map<String, Object> removeMt1201(Map<String, Object> map) throws IOException, ParseException {
String customCode = map.get("customCode").toString();
// 生成报文头部
... ... @@ -54,15 +58,27 @@ public class MT1201ServiceImp extends CustomXmlMaker implements MT1201Service{
// 舱单传输人名称
map.put("orgCode", orgCode);
// 生成报文
Map<String, Object> hashMap = new HashMap<>();
// 生成报文
if (makeXmlToFile("/remove/MT1201.ftlx", msgId+".xml", map, "./send/remove/")>0){
return 1;
map.put("functionCode", "3");
map.put("busType","MT1201");
NMMS_CUSTOM_RESPONSE nmmsCustomResponse = ReturnUtil.nmmsCustomResponse(map);
// 操作类型
nmmsCustomResponse.setOpertype("删除");
nmmsCustomResponse.setCusrescode("24");
nmmsCustomResponse.setCusrestext("删除报发送成功");
hashMap.put("status", "1");
hashMap.put("customResponse", nmmsCustomResponse);
return hashMap;
}else {
return 0;
hashMap.put("staus", "0");
return hashMap;
}
}
public int mt1201(Map<String, Object> map) throws IOException {
public Map<String, Object> mt1201(Map<String, Object> map) throws IOException, ParseException {
ObjectMapper objectMapper = new ObjectMapper();
// 预配
NMMS_CUSTOM_MT1201 customMt1201 = objectMapper.convertValue(map.get("mt1201"), NMMS_CUSTOM_MT1201.class);
... ... @@ -72,6 +88,13 @@ public class MT1201ServiceImp extends CustomXmlMaker implements MT1201Service{
String customCode = customMt1201.getCustomcode();
// 报文头时间 精确到毫秒
map.put("sendTime", DateUtil.getCurrentTime17());
// 航班起飞时间 sendTime(海关接受时间) + 1小时
String s = DateUtil.addDateMinut(new Date(), 1);
// 航班到达时间 航班起飞时间 + 2小时
String ss = DateUtil.addDateMinut(new Date(), 3);
map.put("arrivalDateTime", s);
map.put("departureDateTime", ss);
// 封装实体
map.put("mt", customMt1201);
map.put("awbAwbinfo", awbAwbinfo);
... ... @@ -84,11 +107,73 @@ public class MT1201ServiceImp extends CustomXmlMaker implements MT1201Service{
map.put("receiverID", receiverID);
// 舱单传输人名称
map.put("orgCode", orgCode);
Map<String, Object> maps = new HashMap<>();
// 生成报文
if (makeXmlToFile(map.get("templatePath").toString(), msgId+".xml", map, map.get("sendPath").toString())>0){
return 1;
if (!map.containsKey("reason")){
map.put("functionCode", "9");
map.put("busType","MT1201");
NMMS_CUSTOM_RESPONSE nmmsCustomResponse = ReturnUtil.nmmsCustomResponse(map);
// 航班日期
nmmsCustomResponse.setFlightdate(customMt1201.getFlightdate());
// 航班号
nmmsCustomResponse.setFlightno(customMt1201.getFlightno());
// 航班承运人
nmmsCustomResponse.setCarrier(customMt1201.getCarrier());
// 主单号
nmmsCustomResponse.setAwbano(customMt1201.getAwba());
if (!"".equals(customMt1201.getAwbh())){
// 分单号
nmmsCustomResponse.setAwbhno(customMt1201.getAwbh());
}else {
nmmsCustomResponse.setAwbhno(null);
}
// 件数
nmmsCustomResponse.setBuspiece(Integer.valueOf(customMt1201.getPiece().toString()));
// 重量
nmmsCustomResponse.setBusweight(Long.valueOf(customMt1201.getWeight().toString()));
// 操作类型
nmmsCustomResponse.setOpertype("新增");
nmmsCustomResponse.setCusrescode("23");
nmmsCustomResponse.setCusrestext("新增报发送成功");
maps.put("status", "1");
maps.put("customResponse", nmmsCustomResponse);
return maps;
}else {
map.put("functionCode", "5");
map.put("busType","MT1201");
NMMS_CUSTOM_RESPONSE nmmsCustomResponse = ReturnUtil.nmmsCustomResponse(map);
// 航班日期
nmmsCustomResponse.setFlightdate(customMt1201.getFlightdate());
// 航班号
nmmsCustomResponse.setFlightno(customMt1201.getFlightno());
// 航班承运人
nmmsCustomResponse.setCarrier(customMt1201.getCarrier());
// 主单号
nmmsCustomResponse.setAwbano(customMt1201.getAwba());
if (!"".equals(customMt1201.getAwbh())){
// 分单号
nmmsCustomResponse.setAwbhno(customMt1201.getAwbh());
}else {
nmmsCustomResponse.setAwbhno(null);
}
// 件数
nmmsCustomResponse.setBuspiece(Integer.valueOf(customMt1201.getPiece().toString()));
// 重量
nmmsCustomResponse.setBusweight(Long.valueOf(customMt1201.getWeight().toString()));
// 操作类型
nmmsCustomResponse.setOpertype("修改");
nmmsCustomResponse.setCusrescode("25");
nmmsCustomResponse.setCusrestext("修改报发送成功");
maps.put("status", "1");
maps.put("customResponse", nmmsCustomResponse);
return maps;
}
}else {
return 0;
maps.put("status", "0");
return maps;
}
}
}
... ...
package com.sunyo.wlpt.message.builder.service.imp;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sunyo.wlpt.base.model.NMMS_CUSTOM_RESPONSE;
import com.sunyo.wlpt.base.model.NMMS_CUSTOM_TRANS;
import com.sunyo.wlpt.message.builder.service.MT3202Service;
import com.sunyo.wlpt.message.builder.util.CustomXmlMaker;
import com.sunyo.wlpt.message.builder.util.ReturnUtil;
import com.tianbo.util.Date.DateUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
@Service
public class MT3202ServiceImp extends CustomXmlMaker implements MT3202Service {
@Value("${custom.custom-code}")
private String orgsn;
@Override
public Map<String, Object> createMt3202(Map<String, Object> map) throws ParseException, IOException {
ObjectMapper objectMapper = new ObjectMapper();
// 转运记录
NMMS_CUSTOM_TRANS nmmsCustomTrans = objectMapper.convertValue(map.get("mt3202"), NMMS_CUSTOM_TRANS.class);
// 关区代码
String customCode = nmmsCustomTrans.getCustomcode();
// 报文头时间 精确到毫秒
map.put("sendTime", DateUtil.getCurrentTime17());
// 封装实体
map.put("mt", nmmsCustomTrans);
// 生成报文头部
String msgId = makeMsgID("MT3202", orgsn, nmmsCustomTrans.getAwba());
String msessageType = "MT3202";
String senderId = makeSenderID(customCode, orgsn, "");
String receiverID = customCode;
map.put("msgId", msgId);
map.put("msessageType", msessageType);
map.put("senderId", senderId);
map.put("receiverID", receiverID);
Map<String, Object> map3202 = new HashMap<>();
if (makeXmlToFile("/manifest/MT3202.ftlx", msgId+".xml", map, "./send/add/")>0){
map.put("functionCode", "2");
map.put("busType","MT3202");
NMMS_CUSTOM_RESPONSE nmmsCustomResponse = ReturnUtil.nmmsCustomResponse(map);
// 航班日期
nmmsCustomResponse.setFlightdate(nmmsCustomTrans.getFlightdate());
// 航班号
nmmsCustomResponse.setFlightno(nmmsCustomTrans.getFlightno());
// 航班承运人
nmmsCustomResponse.setCarrier(nmmsCustomTrans.getCarrier());
// 主单号
nmmsCustomResponse.setAwbano(nmmsCustomTrans.getAwba());
// 件数
nmmsCustomResponse.setBuspiece(Integer.valueOf(nmmsCustomTrans.getTurnpiece().toString()));
// 重量
nmmsCustomResponse.setBusweight(Long.valueOf(nmmsCustomTrans.getTurnweight().toString()));
// 操作类型
nmmsCustomResponse.setOpertype("新增");
nmmsCustomResponse.setCusrescode("23");
nmmsCustomResponse.setCusrestext("新增报发送成功");
map3202.put("status", "1");
map3202.put("customResponse", nmmsCustomResponse);
return map3202;
}else {
map3202.put("status", "0");
return map3202;
}
}
@Override
public Map<String, Object> removeMt3202(Map<String, Object> map) throws IOException, ParseException {
// 关区代码
String customCode = map.get("customCode").toString();
// 报文头时间 精确到毫秒
map.put("sendTime", DateUtil.getCurrentTime17());
// 生成报文头部
String msgId = makeMsgID("MT3202", orgsn, map.get("awba").toString());
String senderId = makeSenderID(customCode, orgsn, "");
String receiverID = customCode;
map.put("msgId", msgId);
map.put("senderId", senderId);
map.put("receiverID", receiverID);
Map<String, Object> map3201 = new HashMap<>();
if (makeXmlToFile("/remove/MT3202.ftlx", msgId+".xml", map,"./send/remove/")>0){
map.put("functionCode", "3");
map.put("busType","MT3202");
NMMS_CUSTOM_RESPONSE nmmsCustomResponse = ReturnUtil.nmmsCustomResponse(map);
// 操作类型
nmmsCustomResponse.setOpertype("删除");
nmmsCustomResponse.setCusrescode("24");
nmmsCustomResponse.setCusrestext("删除报发送成功");
map3201.put("status", "1");
map3201.put("customResponse", nmmsCustomResponse);
return map3201;
}else {
map3201.put("staus", "0");
return map3201;
}
}
}
... ...
... ... @@ -66,7 +66,6 @@ public class MT4201ServiceImp extends CustomXmlMaker implements MT4201Service {
// 分单号
nmmsCustomResponse.setAwbhno(null);
}
// 件数
nmmsCustomResponse.setBuspiece(Integer.valueOf(customMt4201.getLodingpiece().toString()));
// 重量
... ...
... ... @@ -42,7 +42,7 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{
// 封装实体
hashMap.put("mt", customMt520X);
hashMap.put("orgCode", orgCode);
if ("5201".equals(customMt520X.getRcfdep())){
if ("MT5201".equals(customMt520X.getRcfdep())){
// 生成报文头部
String msgId = makeMsgID("MT5201", orgsn, customMt520X.getAwba());
String msessageType = "MT5201";
... ... @@ -150,7 +150,7 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{
map.put("customCode", customCode);
// 报文头时间 精确到毫秒
map.put("sendTime", DateUtil.getCurrentTime17());
if ("5201".equals(map.get("rcfdep").toString())){
if ("MT5201".equals(map.get("rcfdep").toString())){
// 生成报文头部
String msgId = makeMsgID("MT5201", orgsn, map.get("awba").toString());
String senderId = makeSenderID(customCode, orgsn, "");
... ...
... ... @@ -66,6 +66,9 @@ public class ReturnUtil {
if (map.containsKey("flightNo")){
nmmsCustomResponse.setFlightno(map.get("flightNo").toString());
}
if (map.containsKey("carrier")){
nmmsCustomResponse.setCarrier(map.get("carrier").toString());
}
if (map.containsKey("flightDate")){
String flightDate = map.get("flightDate").toString();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
... ...
... ... @@ -22,8 +22,8 @@
<JourneyID>${mt.carrier}${mt.flightno}/${mt.flightdate?string('yyyyMMdd')}</JourneyID>
<TypeCode>4</TypeCode>
<FirstArrivalLocationID>${mt.destinationstation}</FirstArrivalLocationID>
<ArrivalDateTime>20200224171901086</ArrivalDateTime>
<DepartureDateTime>20200224151901086</DepartureDateTime>
<ArrivalDateTime>${arrivalDateTime}</ArrivalDateTime>
<DepartureDateTime>${departureDateTime}</DepartureDateTime>
</BorderTransportMeans>
<Consignment>
<TransportContractDocument>
... ...
... ... @@ -49,7 +49,7 @@
</GoodsConsignedPlace>
<TransportSplitIndicator>${mt.splitcode}</TransportSplitIndicator>
<FreightPayment>
<MethodCode>${awbAwbinfo.paymodel}</MethodCode>
<MethodCode>${awbAwbinfo.collected}</MethodCode>
</FreightPayment>
<ConsignmentPackaging>
<QuantityQuantity>${awbAwbinfo.pcs}</QuantityQuantity>
... ...
... ... @@ -22,8 +22,8 @@
<JourneyID>${mt.carrier}${mt.flightno}/${mt.flightdate?string('yyyyMMdd')}</JourneyID>
<TypeCode>4</TypeCode>
<FirstArrivalLocationID>${mt.destinationstation}</FirstArrivalLocationID>
<ArrivalDateTime>20200121053117086</ArrivalDateTime>
<DepartureDateTime>20200121033117086</DepartureDateTime>
<ArrivalDateTime>${arrivalDateTime}</ArrivalDateTime>
<DepartureDateTime>${departureDateTime}</DepartureDateTime>
</BorderTransportMeans>
<Consignment>
<TransportContractDocument>
... ...
... ... @@ -45,7 +45,7 @@
<CustomsStatusCode>${awbAwbinfo.awbtype}</CustomsStatusCode>
<TransportSplitIndicator>${mt.splitcode}</TransportSplitIndicator>
<FreightPayment>
<MethodCode>${awbAwbinfo.paymodel}</MethodCode>
<MethodCode>${awbAwbinfo.collected}</MethodCode>
</FreightPayment>
<ConsignmentPackaging>
<QuantityQuantity>${awbAwbinfo.pcs}</QuantityQuantity>
... ...
<?xml version="1.0" encoding="utf-8"?>
<Manifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:Declaration:datamodel:standard:CN:MT3202:1">
<Head>
<MessageID>${msgId}</MessageID>
<FunctionCode>2</FunctionCode>
<MessageType>MT3202</MessageType>
<SenderID>${senderId}</SenderID>
<ReceiverID>${receiverID}</ReceiverID>
<SendTime>${sendTime}</SendTime>
<Version>1.0</Version>
</Head>
<Declaration>
<DeclarationOfficeID>${mt.customcode}</DeclarationOfficeID>
<BorderTransportMeans>
<JourneyID>${mt.carrier}${mt.flightno}/${mt.flightdate?string('yyyyMMdd')}</JourneyID>
<TypeCode>4</TypeCode>
</BorderTransportMeans>
<UnloadingLocation>
<ID>${mt.turnunloading}</ID>
<ArrivalDate>${mt.flightno}</ArrivalDate>
</UnloadingLocation>
<Consignment>
<TransportContractDocument>
<ID>${mt.awba}</ID>
</TransportContractDocument>
<ConsignmentPackaging>
<QuantityQuantity>${mt.turnpiece}</QuantityQuantity>
</ConsignmentPackaging>
<TotalGrossMassMeasure>${mt.turnweight}</TotalGrossMassMeasure>
<ConsignmentItem>
<SequenceNumeric>1</SequenceNumeric>
<Commodity>
<CargoDescription>${mt.goodsname}</CargoDescription>
</Commodity>
</ConsignmentItem>
</Consignment>
</Declaration>
</Manifest>
\ No newline at end of file
... ...
... ... @@ -30,7 +30,7 @@
</TransportContractDocument>
<#if mt.awbh?length gt 1>
<AssociatedTransportDocument>
<ID>${mt.awba}_${mtawbh}</ID>
<ID>${mt.awba}_${mt.awbh}</ID>
</AssociatedTransportDocument>
</#if>
<ConsignmentPackaging>
... ...
... ... @@ -15,7 +15,7 @@
<TypeCode>4</TypeCode>
<CargoFacilityLocation>${mt.turnunloading}</CargoFacilityLocation>
<UnloadingLocation>
<ID>CGO/${mt.customcode}</ID>
<ID>${mt.ext2}</ID>
</UnloadingLocation>
</BorderTransportMeans>
<Consignment>
... ...
... ... @@ -14,7 +14,7 @@
<Name>${orgCode}</Name>
</RepresentativePerson>
<BorderTransportMeans>
<JourneyID>${flightNo}/${flightDate}</JourneyID>
<JourneyID>${carrier}${flightNo}/${flightDate}</JourneyID>
</BorderTransportMeans>
<Consignment>
<TransportContractDocument>
... ...
<Manifest xmlns="urn:Declaration:datamodel:standard:CN:MT5202:1" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Head>
<MessageID>${msgId}</MessageID>
<FunctionCode>3</FunctionCode>
<MessageType>MT3202</MessageType>
<SenderID>${senderId}</SenderID>
<ReceiverID>${receiverID}</ReceiverID>
<SendTime>${sendTime}</SendTime>
<Version>1.0</Version>
</Head>
<Declaration>
<BorderTransportMeans>
<JourneyID>${flightNo}/${flightDate}</JourneyID>
</BorderTransportMeans>
<Consignment>
<TransportContractDocument>
<ID>${awba}</ID>
</TransportContractDocument>
</Consignment>
<AdditionalInformation>
<Reason>${reason}</Reason>
<ContactName>${contactName}</ContactName>
<ContactTel>${contactTel}</ContactTel>
</AdditionalInformation>
</Declaration>
</Manifest>
\ No newline at end of file
... ...
... ... @@ -11,7 +11,7 @@
<Declaration>
<DeclarationOfficeID>${customCode}</DeclarationOfficeID>
<BorderTransportMeans>
<JourneyID>${flightNo}/${flightDate}</JourneyID>
<JourneyID>${carrier}${flightNo}/${flightDate}</JourneyID>
</BorderTransportMeans>
<Consignment>
<TransportContractDocument>
... ...