作者 shenhailong

生成报文

正在显示 31 个修改的文件 包含 147 行增加4 行删除
package com.sunyo.wlpt.message.builder.controller;
import com.sunyo.wlpt.message.builder.service.MT1201Service;
import com.sunyo.wlpt.message.builder.service.MT3201Service;
import com.sunyo.wlpt.message.builder.service.MT4201Service;
import com.sunyo.wlpt.message.builder.service.MT520XService;
import com.sunyo.wlpt.message.builder.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
... ... @@ -27,6 +24,9 @@ public class CreateftlxController {
@Autowired
MT4201Service mt4201Service;
@Autowired
MT8205Service mt8205Service;
/**
* 进出港理货
* @param map
... ... @@ -89,4 +89,18 @@ public class CreateftlxController {
}
@RequestMapping("/8205create")
public Boolean create8205(@RequestBody Map<String, Object> map){
try {
return mt8205Service.create8205(map);
}catch (Exception e){
e.printStackTrace();
return false;
}
}
}
... ...
package com.sunyo.wlpt.message.builder.service;
import java.io.IOException;
import java.util.Map;
public interface MT8205Service {
Boolean create8205(Map<String, Object> map) throws IOException;
}
... ...
package com.sunyo.wlpt.message.builder.service.imp;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT1201;
import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT2201;
import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT8205;
import com.sunyo.wlpt.message.builder.service.MT8205Service;
import com.sunyo.wlpt.message.builder.util.CustomXmlMaker;
import com.tianbo.util.Date.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.Map;
@Service
public class MT8205ServiceImp extends CustomXmlMaker implements MT8205Service {
@Override
public Boolean create8205(Map<String, Object> map) throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
// 转运记录
NMMS_CUSTOM_MT8205 customMt8205 = objectMapper.convertValue(map.get("mt8205"), NMMS_CUSTOM_MT8205.class);
// 进港原始
NMMS_CUSTOM_MT1201 customMt1201 = objectMapper.convertValue(map.get("mt1201"), NMMS_CUSTOM_MT1201.class);
// 出港预配
NMMS_CUSTOM_MT2201 customMt2201 = objectMapper.convertValue(map.get("mt2201"), NMMS_CUSTOM_MT2201.class);
// 关区代码
String customCode = customMt8205.getCustomcode();
// 报文头时间 精确到毫秒
map.put("sendTime", DateUtil.getCurrentTime17());
// 封装实体
map.put("mt8205", customMt8205);
map.put("mt1201", customMt1201);
map.put("mt2201", customMt2201);
// 生成报文头部
String msgId = makeMsgID("MT8205", "460470678920X", "");
String msessageType = "MT8205";
String senderId = makeSenderID(customCode, "460470678920X", "DXPENT0000460002");
String receiverID = customCode;
map.put("msgId", msgId);
map.put("msessageType", msessageType);
map.put("senderId", senderId);
map.put("receiverID", receiverID);
if (makeXmlToFile("/manifest/MT8205.ftlx", msgId+".xml", map)>0){
return true;
}else {
return false;
}
}
}
... ...
<Manifest xmlns="urn:Declaration:datamodel:standard:CN:MT8205:1" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Head>
<MessageID>${msgId}</MessageID>
<FunctionCode>2</FunctionCode>
<MessageType>${msessageType}</MessageType>
<SenderID>${senderId}</SenderID>
<ReceiverID>${receiverID}</ReceiverID>
<SendTime>${sendTime}</SendTime>
<Version>1.0</Version>
</Head>
<Declaration>
<DeclarationOfficeID>${mt1201.customcode}</DeclarationOfficeID>
<Relation>
<ImportInformation>
<RepresentativePerson>
<Name>460470678920X</Name>
</RepresentativePerson>
<BorderTransportMeans>
<JourneyID>${mt1201.carrier}${mt1201.flightno}/${mt1201.flightdate?string('yyyyMMdd')}</JourneyID>
</BorderTransportMeans>
<Consignment>
<TransportContractDocument>
<ID>${mt1201.awba}</ID>
</TransportContractDocument>
<LoadingLocation>
<ID>${mt1201.originstation}</ID>
</LoadingLocation>
<ConsignmentPackaging>
<QuantityQuantity>${mt1201.piece}</QuantityQuantity>
<TypeCode>PK</TypeCode>
</ConsignmentPackaging>
<TotalGrossMassMeasure>${mt1201.weight}</TotalGrossMassMeasure>
<ConsignmentItem>
<Commodity>
<CargoDescription>${mt1201.goodsname}</CargoDescription>
</Commodity>
</ConsignmentItem>
</Consignment>
</ImportInformation>
<ExportInformation>
<RepresentativePerson>
<Name>460470678920X</Name>
</RepresentativePerson>
<BorderTransportMeans>
<JourneyID>${mt2201.carrier}${mt2201.flightno}/${mt2201.flightdate?string('yyyyMMdd')}</JourneyID>
</BorderTransportMeans>
<Consignment>
<TransportContractDocument>
<ID>${mt2201.awba}</ID>
</TransportContractDocument>
<UnloadingLocation>
<ID>${mt2201.destinationstation}</ID>
</UnloadingLocation>
<ConsignmentPackaging>
<QuantityQuantity>${mt8205.transpiece}</QuantityQuantity>
<TypeCode>${mt8205.goodspackage}</TypeCode>
</ConsignmentPackaging>
<TotalGrossMassMeasure>${mt8205.transweight}</TotalGrossMassMeasure>
</Consignment>
</ExportInformation>
</Relation>
</Declaration>
</Manifest>
\ No newline at end of file
... ...