AgentXmlHandle.java 2.0 KB
package com.tianbo.analysis.handle;


import com.tianbo.analysis.bean.SpringBeanUtitl;
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.context.annotation.Bean;
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;

    @Autowired
    RestTemplate restTemplate;

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

        agentXmlHandle.restTemplate = this.restTemplate;

        // 初使化时将已静态化的testService实例化
    }

    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];
            }

            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}"
                    , Agent_Notice.class,"MT2201", AWBTools.awbFormat(customReception.getWayBillMaster()),waybillnosecondary,customReception.getResponseCode(),customReception.getResponseText());

            log.info(notice.toString());
        }catch (Exception e){
            log.error("链接代理人服务器超时或者接口异常,{}",e);
        }

    }

}