作者 shenhailong

生成报文 拆分 controller 2201 生成报

@@ -9,85 +9,12 @@ import org.springframework.web.bind.annotation.RestController; @@ -9,85 +9,12 @@ import org.springframework.web.bind.annotation.RestController;
9 import java.util.Map; 9 import java.util.Map;
10 10
11 @RestController 11 @RestController
12 -@RequestMapping("/mtcreate") 12 +@RequestMapping("/mt8205")
13 public class CreateftlxController { 13 public class CreateftlxController {
14 14
15 @Autowired 15 @Autowired
16 - MT520XService mt520XService;  
17 -  
18 - @Autowired  
19 - MT1201Service mt1201Service;  
20 -  
21 - @Autowired  
22 - MT3201Service mt3201Service;  
23 -  
24 - @Autowired  
25 - MT4201Service mt4201Service;  
26 -  
27 - @Autowired  
28 MT8205Service mt8205Service; 16 MT8205Service mt8205Service;
29 17
30 - /**  
31 - * 进出港理货  
32 - * @param map  
33 - * @return  
34 - */  
35 - @RequestMapping("/520xcreate")  
36 - public Boolean create(@RequestBody Map<String, Object> map){  
37 -  
38 - try {  
39 -  
40 - return mt520XService.create(map);  
41 -  
42 - }catch (Exception e){  
43 - e.printStackTrace();  
44 - return false;  
45 - }  
46 -  
47 - }  
48 -  
49 - /**  
50 - * 原始 FFm  
51 - * @param map  
52 - * @return  
53 - */  
54 - @RequestMapping("/1201create")  
55 - public Boolean ffmcreate(@RequestBody Map<String, Object> map){  
56 -  
57 - try {  
58 -  
59 - return true;  
60 - }catch (Exception e){  
61 - e.printStackTrace();  
62 - return false;  
63 - }  
64 - }  
65 -  
66 - @RequestMapping("/3201create")  
67 - public Boolean fohcreate(@RequestBody Map<String, Object> map){  
68 -  
69 - try {  
70 -  
71 - return mt3201Service.fohcreate(map);  
72 - }catch (Exception e){  
73 - e.printStackTrace();  
74 - return false;  
75 - }  
76 -  
77 - }  
78 -  
79 - @RequestMapping("/4201create")  
80 - public Boolean pffmcreate(@RequestBody Map<String, Object> map){  
81 -  
82 - try {  
83 -  
84 - return mt4201Service.pffmcreate(map);  
85 - }catch (Exception e){  
86 - e.printStackTrace();  
87 - return false;  
88 - }  
89 -  
90 - }  
91 18
92 @RequestMapping("/8205create") 19 @RequestMapping("/8205create")
93 public Boolean create8205(@RequestBody Map<String, Object> map){ 20 public Boolean create8205(@RequestBody Map<String, Object> map){
  1 +package com.sunyo.wlpt.message.builder.controller;
  2 +
  3 +import com.sunyo.wlpt.message.builder.service.MT1201Service;
  4 +import org.springframework.beans.factory.annotation.Autowired;
  5 +import org.springframework.web.bind.annotation.RequestBody;
  6 +import org.springframework.web.bind.annotation.RequestMapping;
  7 +import org.springframework.web.bind.annotation.RestController;
  8 +
  9 +import java.util.Map;
  10 +
  11 +@RestController
  12 +@RequestMapping("/mt1201")
  13 +public class MT1201Controller {
  14 +
  15 + @Autowired
  16 + MT1201Service mt1201Service;
  17 +
  18 + /**
  19 + * 原始 FFm
  20 + * @param map
  21 + * @return
  22 + */
  23 + @RequestMapping("/1201create")
  24 + public Boolean ffmcreate(@RequestBody Map<String, Object> map){
  25 +
  26 + try {
  27 +
  28 + return true;
  29 + }catch (Exception e){
  30 + e.printStackTrace();
  31 + return false;
  32 + }
  33 + }
  34 +
  35 +}
  1 +package com.sunyo.wlpt.message.builder.controller;
  2 +
  3 +import com.sunyo.wlpt.message.builder.service.MT2201Service;
  4 +import org.springframework.beans.factory.annotation.Autowired;
  5 +import org.springframework.web.bind.annotation.RequestBody;
  6 +import org.springframework.web.bind.annotation.RequestMapping;
  7 +import org.springframework.web.bind.annotation.RestController;
  8 +
  9 +import java.util.Map;
  10 +
  11 +@RestController
  12 +@RequestMapping(value = "/mt2201")
  13 +public class MT2201Controller {
  14 +
  15 + @Autowired
  16 + private MT2201Service mt2201Service;
  17 +
  18 + @RequestMapping("/creatMt2201")
  19 + public int creatMt2201(@RequestBody Map<String, Object> map){
  20 +
  21 + int i = mt2201Service.creatMt2201(map);
  22 + return 0;
  23 + }
  24 +
  25 +}
  1 +package com.sunyo.wlpt.message.builder.controller;
  2 +
  3 +
  4 +import com.sunyo.wlpt.message.builder.service.MT3201Service;
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.web.bind.annotation.RequestBody;
  7 +import org.springframework.web.bind.annotation.RequestMapping;
  8 +import org.springframework.web.bind.annotation.RestController;
  9 +
  10 +import java.util.Map;
  11 +
  12 +@RestController
  13 +@RequestMapping("/mt3201")
  14 +public class MT3201Controller {
  15 +
  16 + @Autowired
  17 + MT3201Service mt3201Service;
  18 +
  19 +
  20 + @RequestMapping("/3201create")
  21 + public Boolean fohcreate(@RequestBody Map<String, Object> map){
  22 +
  23 + try {
  24 +
  25 + return mt3201Service.fohcreate(map);
  26 + }catch (Exception e){
  27 + e.printStackTrace();
  28 + return false;
  29 + }
  30 +
  31 + }
  32 +
  33 +
  34 +}
  1 +package com.sunyo.wlpt.message.builder.controller;
  2 +
  3 +import com.sunyo.wlpt.message.builder.service.MT4201Service;
  4 +import org.springframework.beans.factory.annotation.Autowired;
  5 +import org.springframework.web.bind.annotation.RequestBody;
  6 +import org.springframework.web.bind.annotation.RequestMapping;
  7 +import org.springframework.web.bind.annotation.RestController;
  8 +
  9 +import java.util.Map;
  10 +
  11 +
  12 +@RestController
  13 +@RequestMapping("/mt4201")
  14 +public class MT4201Controller {
  15 +
  16 + @Autowired
  17 + MT4201Service mt4201Service;
  18 +
  19 +
  20 + @RequestMapping("/4201create")
  21 + public Boolean pffmcreate(@RequestBody Map<String, Object> map){
  22 +
  23 + try {
  24 +
  25 + return mt4201Service.pffmcreate(map);
  26 + }catch (Exception e){
  27 + e.printStackTrace();
  28 + return false;
  29 + }
  30 +
  31 + }
  32 +
  33 +}
  1 +package com.sunyo.wlpt.message.builder.controller;
  2 +
  3 +import com.sunyo.wlpt.message.builder.service.MT520XService;
  4 +import org.springframework.beans.factory.annotation.Autowired;
  5 +import org.springframework.web.bind.annotation.RequestBody;
  6 +import org.springframework.web.bind.annotation.RequestMapping;
  7 +import org.springframework.web.bind.annotation.RestController;
  8 +
  9 +import java.util.Map;
  10 +
  11 +
  12 +@RestController
  13 +@RequestMapping("/mt520x")
  14 +public class MT520XController {
  15 +
  16 +
  17 + @Autowired
  18 + MT520XService mt520XService;
  19 +
  20 + /**
  21 + * 进出港理货
  22 + * @param map
  23 + * @return
  24 + */
  25 + @RequestMapping("/520xcreate")
  26 + public Boolean create(@RequestBody Map<String, Object> map){
  27 +
  28 + try {
  29 +
  30 + return mt520XService.create(map);
  31 +
  32 + }catch (Exception e){
  33 + e.printStackTrace();
  34 + return false;
  35 + }
  36 +
  37 + }
  38 +}
  1 +package com.sunyo.wlpt.message.builder.service;
  2 +
  3 +import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT2201;
  4 +
  5 +import java.util.Map;
  6 +
  7 +public interface MT2201Service {
  8 +
  9 + int deleteByPrimaryKey(String uuid);
  10 +
  11 + int insert(NMMS_CUSTOM_MT2201 record);
  12 +
  13 + int insertSelective(NMMS_CUSTOM_MT2201 record);
  14 +
  15 + NMMS_CUSTOM_MT2201 selectByPrimaryKey(String uuid);
  16 +
  17 + int updateByPrimaryKeySelective(NMMS_CUSTOM_MT2201 record);
  18 +
  19 + int updateByPrimaryKey(NMMS_CUSTOM_MT2201 record);
  20 +
  21 + int creatMt2201(Map<String, Object> map);
  22 +
  23 +}
  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_MT2201;
  5 +import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT4201;
  6 +import com.sunyo.wlpt.message.builder.service.MT2201Service;
  7 +import com.sunyo.wlpt.message.builder.util.CustomXmlMaker;
  8 +import com.tianbo.util.Date.DateUtil;
  9 +import org.springframework.stereotype.Service;
  10 +
  11 +import java.util.Map;
  12 +
  13 +@Service
  14 +public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service {
  15 +
  16 + @Override
  17 + public int deleteByPrimaryKey(String uuid) {
  18 + return 0;
  19 + }
  20 +
  21 + @Override
  22 + public int insert(NMMS_CUSTOM_MT2201 record) {
  23 + return 0;
  24 + }
  25 +
  26 + @Override
  27 + public int insertSelective(NMMS_CUSTOM_MT2201 record) {
  28 + return 0;
  29 + }
  30 +
  31 + @Override
  32 + public NMMS_CUSTOM_MT2201 selectByPrimaryKey(String uuid) {
  33 + return null;
  34 + }
  35 +
  36 + @Override
  37 + public int updateByPrimaryKeySelective(NMMS_CUSTOM_MT2201 record) {
  38 + return 0;
  39 + }
  40 +
  41 + @Override
  42 + public int updateByPrimaryKey(NMMS_CUSTOM_MT2201 record) {
  43 + return 0;
  44 + }
  45 +
  46 + @Override
  47 + public int creatMt2201(Map<String, Object> map) {
  48 +
  49 +
  50 +
  51 + ObjectMapper objectMapper = new ObjectMapper();
  52 +
  53 + NMMS_CUSTOM_MT2201 custom_mt2201 = objectMapper.convertValue(map.get("mt2201"), NMMS_CUSTOM_MT2201.class);
  54 +
  55 + // 关区代码
  56 + String customCode = custom_mt2201.getCustomcode();
  57 + // 报文头时间 精确到毫秒
  58 + map.put("sendTime", DateUtil.getCurrentTime17());
  59 + // 封装实体
  60 + map.put("mt", custom_mt2201);
  61 +
  62 + // 生成报文头部
  63 + String msgId = makeMsgID("MT2201", "460470678920X", custom_mt2201.getAwba());
  64 + String msessageType = "MT4201";
  65 + String senderId = makeSenderID(customCode, "460470678920X", "DXPENT0000460002");
  66 + String receiverID = customCode;
  67 + map.put("msgId", msgId);
  68 + map.put("msessageType", msessageType);
  69 + map.put("senderId", senderId);
  70 + map.put("receiverID", receiverID);
  71 +// if (makeXmlToFile("/manifest/MT4201.ftlx", msgId+".xml", map)>0){
  72 +// return true;
  73 +// }else {
  74 +// return false;
  75 +// }
  76 +
  77 + return 0;
  78 + }
  79 +}
  1 +<Manifest xmlns="urn:Declaration:datamodel:standard:CN:MT2201:1" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  2 + <Head>
  3 + <MessageID>${msgId}</MessageID>
  4 + <FunctionCode>9</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 + <RepresentativePerson>
  13 + <Name>舱单书传输人名称</Name>
  14 + </RepresentativePerson>
  15 + <ExitCustomsOffice>
  16 + <ID>${mt.originstation}</ID>
  17 + </ExitCustomsOffice>
  18 + <Carrier>
  19 + <ID>${mt.carrier}</ID>
  20 + </Carrier>
  21 + <BorderTransportMeans>
  22 + <JourneyID>${mt.carrier}${mt.flightno}/${mt.flightdate?string('yyyyMMdd')}</JourneyID>
  23 + <TypeCode>4</TypeCode>
  24 + </BorderTransportMeans>
  25 + <Consignment>
  26 + <TransportContractDocument>
  27 + <ID>${mt.awba}</ID>
  28 + <ConditionCode>10</ConditionCode>
  29 + </TransportContractDocument>
  30 + <AssociatedTransportDocument>
  31 + <ID>${mt.awba}_${mt.awbh}</ID>
  32 + </AssociatedTransportDocument>
  33 + <LoadingLocation>
  34 + <ID>${mt.originstation}/${mt.customcode}</ID>
  35 + <LoadingDate>201911070600086</LoadingDate>
  36 + </LoadingLocation>
  37 + <UnloadingLocation>
  38 + <ID>${mt.destinationstation}</ID>
  39 + </UnloadingLocation>
  40 + <GoodsConsignedPlace>
  41 + <!-- “货物托运的地点或者国家代码” 必填 这里取航班起始站代码-->
  42 + <ID>货物托运地点或国家代码${mt.destinationstation}</ID>
  43 + </GoodsConsignedPlace>
  44 + <!-- “货物海关状态代码” 必填-->
  45 + <CustomsStatusCode>货物海关状态代码</CustomsStatusCode>
  46 + <TransportSplitIndicator>0</TransportSplitIndicator>
  47 + <FreightPayment>
  48 + <MethodCode>PP</MethodCode>
  49 + </FreightPayment>
  50 + <ConsignmentPackaging>
  51 + <QuantityQuantity>1</QuantityQuantity>
  52 + </ConsignmentPackaging>
  53 + <TotalGrossMassMeasure>2.5</TotalGrossMassMeasure>
  54 + <Consignee>
  55 + <Name>CGN</Name>
  56 + <Address>
  57 + <Line>UPS FREIGHT CENTER 5 AIRPORT COLOGN</Line>
  58 + <CountryCode>DE</CountryCode>
  59 + </Address>
  60 + <Communication>
  61 + <ID>22414912705</ID>
  62 + <TypeID>TE</TypeID>
  63 + </Communication>
  64 + </Consignee>
  65 + <Consignor>
  66 + <Name>UPS PARCEL DELIVERY (GUANGDONG) CO LTD ZHENGZHOU BRANCH</Name>
  67 + <Address>
  68 + <Line>NO59TH 1F,ZHENGWEI ROAD ECONOMIC DEVELOP AREA ZHENGZHOU CHINA. 45116</Line>
  69 + <CountryCode>CN</CountryCode>
  70 + </Address>
  71 + <Communication>
  72 + <ID>86-371-68512160</ID>
  73 + <TypeID>TE</TypeID>
  74 + </Communication>
  75 + </Consignor>
  76 + <ConsignmentItem>
  77 + <SequenceNumeric>1</SequenceNumeric>
  78 + <ConsignmentItemPackaging>
  79 + <QuantityQuantity>1</QuantityQuantity>
  80 + </ConsignmentItemPackaging>
  81 + <Commodity>
  82 + <CargoDescription>2</CargoDescription>
  83 + </Commodity>
  84 + <GoodsMeasure>
  85 + <GrossMassMeasure>2.5</GrossMassMeasure>
  86 + </GoodsMeasure>
  87 + </ConsignmentItem>
  88 + </Consignment>
  89 + </Declaration>
  90 +</Manifest>