package com.weaver.seconddev.interfaces.easoa;

import com.weaver.seconddev.interfaces.prop.ConfigProp;
import org.apache.axis2.kernel.http.HTTPConstants;
import org.apache.axis2.transport.http.HttpTransportProperties;
import  com.weaver.seconddev.interfaces.easoa.SI_FeeApplicationSync_OUTServiceStub.CostStandardHead;
import  com.weaver.seconddev.interfaces.easoa.SI_FeeApplicationSync_OUTServiceStub.CostStandardSynchronization;
import  com.weaver.seconddev.interfaces.easoa.SI_FeeApplicationSync_OUTServiceStub.CostStandardSynchronizationService;
import  com.weaver.seconddev.interfaces.easoa.SI_FeeApplicationSync_OUTServiceStub.CostStandardSynchronizationServiceResponse;
import com.weaver.common.i18n.tool.util.I18nContextUtil;
import org.apache.axis2.transport.http.impl.httpclient4.HttpTransportPropertiesImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import java.lang.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.weaver.verupgrade.general.BaseBean;
import com.weaver.verupgrade.general.Util;
import org.springframework.stereotype.Component;

@Component
public class FeeApplicationService extends BaseBean {

    private static final org.slf4j.Logger logger_2817d3b0 = LoggerFactory.getLogger(FeeApplicationService.class);
    @Autowired
    private ConfigProp configProp; //注入
    public CostStandardSynchronizationServiceResponse call(CostStandardHead param) throws Exception {
//        String url = Util.null2String(I18nContextUtilcus.getBean(Environment.class).getProperty("hteasoasync.FeeApplication")).trim();
        String url = configProp.getFeeApplication();
        logger_2817d3b0.error(String.valueOf("调用报账系统话费交通费接口开始"+ url));
        SI_FeeApplicationSync_OUTServiceStub stub = new SI_FeeApplicationSync_OUTServiceStub(url);
//        stub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
        stub._getServiceClient().getOptions().setProperty("__CHUNKED__", Boolean.FALSE);
        stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(300000);
        stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT,300000);
        stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT,300000);
//        HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
////        auth.setUsername(Util.null2String(I18nContextUtilcus.getBean(Environment.class).getProperty("htportaloaUrl.po_user")).trim());
////        auth.setPassword(Util.null2String(I18nContextUtilcus.getBean(Environment.class).getProperty("htportaloaUrl.po_password")).trim());
//        auth.setUsername(configProp.getPo_user());
//        auth.setPassword(configProp.getPo_password());

        HttpTransportPropertiesImpl.Authenticator auth = new HttpTransportPropertiesImpl.Authenticator();
        auth.setUsername(configProp.getPo_user());
        auth.setPassword(configProp.getPo_password());
        logger_2817d3b0.error(String.valueOf("getPo_user" + configProp.getPo_user()));
        logger_2817d3b0.error(String.valueOf("getPo_password" + configProp.getPo_password()));
//        stub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
        stub._getServiceClient().getOptions().setProperty(org.apache.axis2.kernel.http.HTTPConstants.AUTHENTICATE,auth);
        CostStandardSynchronizationService req = new CostStandardSynchronizationService();
        CostStandardSynchronization info = new CostStandardSynchronization();
        CostStandardHead[] arr = new CostStandardHead[1];
        arr[0] = param;
        info.setITFID("HT01BZ024");
        info.setSENDID("");
        info.setSYSID("SYS006");
        info.setCostStandardHead(arr);
        req.setCostStandardSynchronization(info);
        CostStandardSynchronizationServiceResponse res = stub.sI_FeeApplicationSync_OUT(req);
        logger_2817d3b0.error(String.valueOf("调用报账系统话费交通费接口接口结束" + res));
        return res;
    }
}
