作者 shenhailong

生成报文 装载 新增 删除

... ... @@ -2,11 +2,10 @@ package com.sunyo.wlpt.message.builder.controller;
import com.sunyo.wlpt.message.builder.service.MT4201Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.text.ParseException;
import java.util.Map;
... ... @@ -18,11 +17,23 @@ public class MT4201Controller {
MT4201Service mt4201Service;
@RequestMapping("/create4201")
@PostMapping("/createMt4201")
@ResponseBody
public int pffmcreate(@RequestBody Map<String, Object> map) throws IOException {
return mt4201Service.pffmcreate(map);
}
@PutMapping("/removeMt4201")
@ResponseBody
public int remove4201(@RequestBody Map<String, Object> map) throws IOException, ParseException {
return mt4201Service.remove4201(map);
}
}
... ...
... ... @@ -23,7 +23,7 @@ public class MT520XController {
* @return
*/
@RequestMapping("/520xcreate")
public Boolean create(@RequestBody Map<String, Object> map){
public int create(@RequestBody Map<String, Object> map){
try {
... ... @@ -31,7 +31,7 @@ public class MT520XController {
}catch (Exception e){
e.printStackTrace();
return false;
return 0;
}
}
... ...
package com.sunyo.wlpt.message.builder.service;
import java.io.IOException;
import java.text.ParseException;
import java.util.Map;
public interface MT4201Service {
int pffmcreate(Map<String, Object> map) throws IOException;
int remove4201(Map<String, Object> map) throws IOException, ParseException;
}
... ...
... ... @@ -7,6 +7,6 @@ import java.util.Map;
public interface MT520XService {
public Boolean create(Map<String, Object> map);
public int create(Map<String, Object> map);
}
... ...
... ... @@ -49,7 +49,7 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service {
}
@Value("${custom.custom-code}")
private String customCode;
private String orgsn;
@Value("${custom.org-code}")
private String orgCode;
... ... @@ -73,9 +73,9 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service {
String customCode = map.get("customCode").toString();
// 生成报文头部
String msgId = makeMsgID("MT2201", customCode, map.get("awba").toString());
String msgId = makeMsgID("MT2201", orgsn, map.get("awba").toString());
String msessageType = "MT2201";
String senderId = makeSenderID(customCode, customCode, "");
String senderId = makeSenderID(customCode, orgsn, "");
String receiverID = customCode;
map.put("msgId", msgId);
map.put("msessageType", msessageType);
... ... @@ -108,9 +108,9 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service {
map.put("mt", custom_mt2201);
map.put("awbAwbinfo", awbAwbinfo);
// 生成报文头部
String msgId = makeMsgID("MT2201", customCode, custom_mt2201.getAwba());
String msgId = makeMsgID("MT2201", orgsn, custom_mt2201.getAwba());
String msessageType = "MT2201";
String senderId = makeSenderID(customCode, customCode, "");
String senderId = makeSenderID(customCode, orgsn, "");
String receiverID = customCode;
map.put("msgId", msgId);
map.put("msessageType", msessageType);
... ...
... ... @@ -5,14 +5,21 @@ import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT4201;
import com.sunyo.wlpt.message.builder.service.MT4201Service;
import com.sunyo.wlpt.message.builder.util.CustomXmlMaker;
import com.tianbo.util.Date.DateUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.xml.crypto.Data;
import java.io.IOException;
import java.text.ParseException;
import java.util.Map;
@Service
public class MT4201ServiceImp extends CustomXmlMaker implements MT4201Service {
@Value("${custom.custom-code}")
private String orgsn;
@Override
public int pffmcreate(Map<String, Object> map) throws IOException {
... ... @@ -20,19 +27,17 @@ public class MT4201ServiceImp extends CustomXmlMaker implements MT4201Service {
ObjectMapper objectMapper = new ObjectMapper();
NMMS_CUSTOM_MT4201 customMt4201 = objectMapper.convertValue(map.get("mt4201"), NMMS_CUSTOM_MT4201.class);
// 关区代码
String customCode = customMt4201.getCustomcode();
// 报文头时间 精确到毫秒
map.put("sendTime", DateUtil.getCurrentTime17());
// 封装实体
map.put("mt", customMt4201);
// 生成报文头部
String msgId = makeMsgID("MT4201", "460470678920X", customMt4201.getAwba());
String msgId = makeMsgID("MT4201", orgsn, customMt4201.getAwba());
String msessageType = "MT4201";
String senderId = makeSenderID(customCode, "460470678920X", "DXPENT0000460002");
String senderId = makeSenderID(customCode, orgsn);
String receiverID = customCode;
map.put("msgId", msgId);
map.put("msessageType", msessageType);
... ... @@ -44,4 +49,30 @@ public class MT4201ServiceImp extends CustomXmlMaker implements MT4201Service {
return 0;
}
}
@Override
public int remove4201(Map<String, Object> map) throws IOException, ParseException {
// 关区代码
String customCode = map.get("customCode").toString();
// 报文头时间 精确到毫秒
map.put("sendTime", DateUtil.getCurrentTime17());
String flightDate = DateUtil.get_yyyyMMdd(map.get("flightDate").toString());
map.put("flightDate",flightDate);
// 生成报文头部
String msgId = makeMsgID("MT4201", orgsn, map.get("awba").toString());
String msessageType = "MT4201";
String senderId = makeSenderID(customCode, orgsn);
String receiverID = customCode;
map.put("msgId", msgId);
map.put("msessageType", msessageType);
map.put("senderId", senderId);
map.put("receiverID", receiverID);
if (makeXmlToFile("/remove/MT4201.ftlx", msgId+".xml", map, "./send/remove/")>0){
return 1;
}else {
return 0;
}
}
}
... ...
... ... @@ -5,6 +5,7 @@ import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT520X;
import com.sunyo.wlpt.message.builder.service.MT520XService;
import com.sunyo.wlpt.message.builder.util.CustomXmlMaker;
import com.tianbo.util.Date.DateUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.IOException;
... ... @@ -14,9 +15,11 @@ import java.util.Map;
@Service
public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{
@Value("${custom.custom-code}")
private String orgsn;
@Override
public Boolean create(Map<String, Object> map) {
public int create(Map<String, Object> map) {
try {
... ... @@ -32,6 +35,7 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{
hashMap.put("sendTime", DateUtil.getCurrentTime17());
// 封装实体
hashMap.put("mt", customMt520X);
if ("5201".equals(customMt520X.getExt1())){
// 生成报文头部
... ... @@ -51,25 +55,25 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{
}else {
// 生成报文头部
String msgId = makeMsgID("MT5202", "460470678920X", customMt520X.getAwba());
String msgId = makeMsgID("MT5202", orgsn, customMt520X.getAwba());
String msessageType = "MT5202";
String senderId = makeSenderID(customCode, "460470678920X", "DXPENT0000460002");
String senderId = makeSenderID(customCode, orgsn, "DXPENT0000460002");
String receiverID = customCode;
hashMap.put("msgId", msgId);
hashMap.put("msessageType", msessageType);
hashMap.put("senderId", senderId);
hashMap.put("receiverID", receiverID);
// if (makeXmlToFile("/manifest/MT5202.ftlx", msgId+".xml", hashMap)>0){
// return true;
// }else {
// return false;
// }
if (makeXmlToFile("/manifest/MT5202.ftlx", msgId+".xml", hashMap, "./send/add/")>0){
return 1;
}else {
return 0;
}
}
}catch (Exception e){
e.printStackTrace();
return false;
return 0;
}
return null;
return 0;
}
}
... ...
... ... @@ -24,6 +24,12 @@ public class CustomXmlMaker {
@Value("${tcs.mq-number}")
private String TCSMQNumber;
@Value("${custom.custom-code}")
private String customCode;
@Value("${custom.org-code}")
private String orgCode;
public CustomXmlMaker() {
if (freemakerTemplate==null){
this.freemakerTemplate = new Configuration();
... ... @@ -103,4 +109,5 @@ public class CustomXmlMaker {
public String makeSenderID(String customCode,String ORGSN){
return makeSenderID(customCode,ORGSN,TCSMQNumber);
}
}
... ...
... ... @@ -86,8 +86,8 @@
</Consignment>
<AdditionalInformation>
<Reason>${reason}</Reason>
<ContactName>${contacName}</ContactName>
<ContactTel>${contacTel}</ContactTel>
<ContactName>${contactName}</ContactName>
<ContactTel>${contactTel}</ContactTel>
</AdditionalInformation>
</Declaration>
</Manifest>
\ No newline at end of file
... ...
... ... @@ -23,8 +23,8 @@
<ID>${mt.awba}</ID>
</TransportContractDocument>
<LoadingLocation>
<ID>${mt.destinationstation}/${mt.customcode}</ID>
<LoadingDate>${mt.loadingtime?string('yyyyMMddHHmmssSSS')}</LoadingDate>
<ID>${mt.originstation}/${mt.customcode}</ID>
<LoadingDate>${mt.loadingtime?string('yyyyMMddHHmmss')}</LoadingDate>
</LoadingLocation>
<ConsignmentPackaging>
<QuantityQuantity>${mt.lodingpiece}</QuantityQuantity>
... ...
... ... @@ -26,7 +26,11 @@
<Reason>${reason}</Reason>
<ContactName>${contactName}</ContactName>
<ContactTel>${contactTel}</ContactTel>
<#if content ??>
<Content>${content}</Content>
<#else>
<Content></Content>
</#if>
</AdditionalInformation>
</Declaration>
</Manifest>
\ No newline at end of file
... ...
<Manifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:Declaration:datamodel:standard:CN:MT4201:1">
<Head>
<MessageID>${msgId}</MessageID>
<FunctionCode>3</FunctionCode>
<MessageType>${msessageType}</MessageType>
<SenderID>${senderId}</SenderID>
<ReceiverID>${receiverID}</ReceiverID>
<SendTime>${sendTime}</SendTime>
<Version>1.0</Version>
</Head>
<Declaration>
<BorderTransportMeans>
<JourneyID>${carrier}${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
... ...