审查视图

src/main/java/com/tianbo/analysis/handle/AgentXmlHandle.java 2.0 KB
1 2 3
package com.tianbo.analysis.handle;

4
import com.tianbo.analysis.bean.SpringBeanUtitl;
5 6 7 8 9 10
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;
11
import org.springframework.context.annotation.Bean;
12 13 14 15 16 17 18 19 20 21 22 23 24
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;
25 26 27 28 29 30 31 32 33 34 35
    @Autowired
    RestTemplate restTemplate;

    @PostConstruct
    public void init() {
        agentXmlHandle = this;

        agentXmlHandle.restTemplate = this.restTemplate;

        // 初使化时将已静态化的testService实例化
    }
36 37 38 39 40 41 42 43 44 45 46

    public  void  Http_resolver(CustomReception customReception){
        try{
            String secondSplit = "_";
            String waybillnosecondary="";
            if (customReception.getWayBillSecond()!=null && customReception.getWayBillSecond().contains(secondSplit)){
                //取分单号
                String[] awbhArr = customReception.getWayBillSecond().split("_");
                waybillnosecondary = awbhArr[1];
            }
47
            Agent_Notice notice = agentXmlHandle.restTemplate.getForObject("http://10.50.3.73:1983/agent/receipt/a0608c4054662dd902e1314f7e450e3eaa81c114?message_type={1}&waybillNo={2}&waybillNoSub={3}&response_code={4}&response_text={5}"
48
                    , Agent_Notice.class,"MT2201", AWBTools.awbFormat(customReception.getWayBillMaster()),waybillnosecondary,customReception.getResponseCode(),customReception.getResponseText());
49
50 51 52 53 54 55 56 57
            log.info(notice.toString());
        }catch (Exception e){
            log.error("链接代理人服务器超时或者接口异常,{}",e);
        }

    }

}