作者 shenhailong

生成报文

正在显示 31 个修改的文件 包含 147 行增加4 行删除
1 package com.sunyo.wlpt.message.builder.controller; 1 package com.sunyo.wlpt.message.builder.controller;
2 2
3 -import com.sunyo.wlpt.message.builder.service.MT1201Service;  
4 -import com.sunyo.wlpt.message.builder.service.MT3201Service;  
5 -import com.sunyo.wlpt.message.builder.service.MT4201Service;  
6 -import com.sunyo.wlpt.message.builder.service.MT520XService; 3 +import com.sunyo.wlpt.message.builder.service.*;
7 import org.springframework.beans.factory.annotation.Autowired; 4 import org.springframework.beans.factory.annotation.Autowired;
8 import org.springframework.web.bind.annotation.RequestBody; 5 import org.springframework.web.bind.annotation.RequestBody;
9 import org.springframework.web.bind.annotation.RequestMapping; 6 import org.springframework.web.bind.annotation.RequestMapping;
@@ -27,6 +24,9 @@ public class CreateftlxController { @@ -27,6 +24,9 @@ public class CreateftlxController {
27 @Autowired 24 @Autowired
28 MT4201Service mt4201Service; 25 MT4201Service mt4201Service;
29 26
  27 + @Autowired
  28 + MT8205Service mt8205Service;
  29 +
30 /** 30 /**
31 * 进出港理货 31 * 进出港理货
32 * @param map 32 * @param map
@@ -89,4 +89,18 @@ public class CreateftlxController { @@ -89,4 +89,18 @@ public class CreateftlxController {
89 89
90 } 90 }
91 91
  92 + @RequestMapping("/8205create")
  93 + public Boolean create8205(@RequestBody Map<String, Object> map){
  94 +
  95 + try {
  96 +
  97 + return mt8205Service.create8205(map);
  98 + }catch (Exception e){
  99 + e.printStackTrace();
  100 + return false;
  101 + }
  102 +
  103 + }
  104 +
  105 +
92 } 106 }
  1 +package com.sunyo.wlpt.message.builder.service;
  2 +
  3 +import java.io.IOException;
  4 +import java.util.Map;
  5 +
  6 +public interface MT8205Service {
  7 +
  8 + Boolean create8205(Map<String, Object> map) throws IOException;
  9 +
  10 +}
  1 +package com.sunyo.wlpt.message.builder.service.imp;
  2 +
  3 +import com.fasterxml.jackson.databind.ObjectMapper;
  4 +import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT1201;
  5 +import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT2201;
  6 +import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT8205;
  7 +import com.sunyo.wlpt.message.builder.service.MT8205Service;
  8 +import com.sunyo.wlpt.message.builder.util.CustomXmlMaker;
  9 +import com.tianbo.util.Date.DateUtil;
  10 +import org.springframework.beans.factory.annotation.Autowired;
  11 +import org.springframework.stereotype.Service;
  12 +
  13 +import java.io.IOException;
  14 +import java.util.Map;
  15 +
  16 +@Service
  17 +public class MT8205ServiceImp extends CustomXmlMaker implements MT8205Service {
  18 +
  19 +
  20 +
  21 + @Override
  22 + public Boolean create8205(Map<String, Object> map) throws IOException {
  23 + ObjectMapper objectMapper = new ObjectMapper();
  24 + // 转运记录
  25 + NMMS_CUSTOM_MT8205 customMt8205 = objectMapper.convertValue(map.get("mt8205"), NMMS_CUSTOM_MT8205.class);
  26 + // 进港原始
  27 + NMMS_CUSTOM_MT1201 customMt1201 = objectMapper.convertValue(map.get("mt1201"), NMMS_CUSTOM_MT1201.class);
  28 + // 出港预配
  29 + NMMS_CUSTOM_MT2201 customMt2201 = objectMapper.convertValue(map.get("mt2201"), NMMS_CUSTOM_MT2201.class);
  30 +
  31 + // 关区代码
  32 + String customCode = customMt8205.getCustomcode();
  33 + // 报文头时间 精确到毫秒
  34 + map.put("sendTime", DateUtil.getCurrentTime17());
  35 + // 封装实体
  36 + map.put("mt8205", customMt8205);
  37 + map.put("mt1201", customMt1201);
  38 + map.put("mt2201", customMt2201);
  39 +
  40 + // 生成报文头部
  41 + String msgId = makeMsgID("MT8205", "460470678920X", "");
  42 + String msessageType = "MT8205";
  43 + String senderId = makeSenderID(customCode, "460470678920X", "DXPENT0000460002");
  44 + String receiverID = customCode;
  45 + map.put("msgId", msgId);
  46 + map.put("msessageType", msessageType);
  47 + map.put("senderId", senderId);
  48 + map.put("receiverID", receiverID);
  49 +
  50 + if (makeXmlToFile("/manifest/MT8205.ftlx", msgId+".xml", map)>0){
  51 + return true;
  52 + }else {
  53 + return false;
  54 + }
  55 + }
  56 +}
  1 +<Manifest xmlns="urn:Declaration:datamodel:standard:CN:MT8205:1" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  2 + <Head>
  3 + <MessageID>${msgId}</MessageID>
  4 + <FunctionCode>2</FunctionCode>
  5 + <MessageType>${msessageType}</MessageType>
  6 + <SenderID>${senderId}</SenderID>
  7 + <ReceiverID>${receiverID}</ReceiverID>
  8 + <SendTime>${sendTime}</SendTime>
  9 + <Version>1.0</Version>
  10 + </Head>
  11 + <Declaration>
  12 + <DeclarationOfficeID>${mt1201.customcode}</DeclarationOfficeID>
  13 + <Relation>
  14 + <ImportInformation>
  15 + <RepresentativePerson>
  16 + <Name>460470678920X</Name>
  17 + </RepresentativePerson>
  18 + <BorderTransportMeans>
  19 + <JourneyID>${mt1201.carrier}${mt1201.flightno}/${mt1201.flightdate?string('yyyyMMdd')}</JourneyID>
  20 + </BorderTransportMeans>
  21 + <Consignment>
  22 + <TransportContractDocument>
  23 + <ID>${mt1201.awba}</ID>
  24 + </TransportContractDocument>
  25 + <LoadingLocation>
  26 + <ID>${mt1201.originstation}</ID>
  27 + </LoadingLocation>
  28 + <ConsignmentPackaging>
  29 + <QuantityQuantity>${mt1201.piece}</QuantityQuantity>
  30 + <TypeCode>PK</TypeCode>
  31 + </ConsignmentPackaging>
  32 + <TotalGrossMassMeasure>${mt1201.weight}</TotalGrossMassMeasure>
  33 + <ConsignmentItem>
  34 + <Commodity>
  35 + <CargoDescription>${mt1201.goodsname}</CargoDescription>
  36 + </Commodity>
  37 + </ConsignmentItem>
  38 + </Consignment>
  39 + </ImportInformation>
  40 + <ExportInformation>
  41 + <RepresentativePerson>
  42 + <Name>460470678920X</Name>
  43 + </RepresentativePerson>
  44 + <BorderTransportMeans>
  45 + <JourneyID>${mt2201.carrier}${mt2201.flightno}/${mt2201.flightdate?string('yyyyMMdd')}</JourneyID>
  46 + </BorderTransportMeans>
  47 + <Consignment>
  48 + <TransportContractDocument>
  49 + <ID>${mt2201.awba}</ID>
  50 + </TransportContractDocument>
  51 + <UnloadingLocation>
  52 + <ID>${mt2201.destinationstation}</ID>
  53 + </UnloadingLocation>
  54 + <ConsignmentPackaging>
  55 + <QuantityQuantity>${mt8205.transpiece}</QuantityQuantity>
  56 + <TypeCode>${mt8205.goodspackage}</TypeCode>
  57 + </ConsignmentPackaging>
  58 + <TotalGrossMassMeasure>${mt8205.transweight}</TotalGrossMassMeasure>
  59 + </Consignment>
  60 + </ExportInformation>
  61 + </Relation>
  62 + </Declaration>
  63 +</Manifest>