AgentXmlHandle.java
1.9 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
package com.tianbo.analysis.handle;
import com.tianbo.analysis.model.Agent_Notice;
import com.tianbo.analysis.model.CustomReception;
import com.tianbo.analysis.tools.AWBTools;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import javax.annotation.PostConstruct;
@Slf4j
@Component
public class AgentXmlHandle {
private static AgentXmlHandle agentXmlHandle;
public void Http_resolver(CustomReception customReception){
try{
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
requestFactory.setConnectTimeout(5000);
requestFactory.setReadTimeout(5000);
RestTemplate restTemplate = new RestTemplate(requestFactory);
String secondSplit = "_";
String waybillnosecondary="";
if (customReception.getWayBillSecond()!=null && customReception.getWayBillSecond().contains(secondSplit)){
//取分单号
String[] awbhArr = customReception.getWayBillSecond().split("_");
waybillnosecondary = awbhArr[1];
}
Agent_Notice notice = restTemplate.getForObject("http://10.50.3.73:1983/agent/receipt/a0608c4054662dd902e1314f7e450e3eaa81c114?message_type={1}&waybillNo={2}&waybillNoSub={3}&response_code={4}&response_text={5}"
, Agent_Notice.class,"MT2201", AWBTools.awbFormat(customReception.getWayBillMaster()),waybillnosecondary,customReception.getResponseCode(),customReception.getResponseText());
log.info(notice.toString());
}catch (Exception e){
log.error("链接代理人服务器超时或者接口异常,{}",e);
}
}
}