MT2201Controller.java
1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.sunyo.wlpt.message.builder.controller;
import com.sunyo.wlpt.message.builder.model.CUSTOM_RESPONSE;
import com.sunyo.wlpt.message.builder.util.CustomXmlMaker;
import freemarker.template.Configuration;
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 java.util.Date;
import java.util.Map;
@RestController
@RequestMapping("/mt2201")
public class MT2201Controller extends CustomXmlMaker {
@Autowired
private Configuration freemakerTemplate;
private static String businessType = "MT2201";
/**
* MAP包含运单实体与舱单实体
* @param awb_manifest {awb:AWB_AWBINFO,man:}
* @return
* @throws Exception
*/
@RequestMapping("/send")
public Boolean mt1201New(@RequestBody Map awb_manifest) throws Exception{
try {
CUSTOM_RESPONSE response = new CUSTOM_RESPONSE();
response.setAwbano("17212345678");
response.setCusfunctioncode("2");
response.setCusreciverid("4604");
response.setCusversion("1.2");
response.setBusdate(new Date());
response.setBustype(businessType);
String msgId = makeMsgID(businessType,"460470678920X","17212345678");
response.setCusmsgid(msgId);
response.setCussenderid(makeSenderID("4604","460470678920X"));
String filename = response.getCusmsgid()+".xml";
makeXmlToFile("/manifest/MT2201.ftlx",filename,awb_manifest);
}catch (Exception e){
e.printStackTrace();
return false;
}
return true;
}
}