package com.weaver.seconddev.interfaces.srmoa;

import com.weaver.seconddev.interfaces.prop.ConfigProp;
import org.apache.axis2.AxisFault;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.rmi.RemoteException;
import java.security.MessageDigest;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Set;
import com.weaver.common.i18n.tool.util.I18nContextUtil;
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.Util;
import com.weaver.verupgrade.general.BaseBean;
import org.springframework.stereotype.Component;

@Component
public class CallSrmCheckMallServices extends BaseBean {

	private static final org.slf4j.Logger logger_a0ca618e = LoggerFactory.getLogger(CallSrmCheckMallServices.class);

	private MallPurReqChkServiceServiceStub.MallPurReqIN resultin = null;

	public void setOainput(MallPurReqChkServiceServiceStub.MallPurReqIN oasrm) {
		this.resultin = oasrm;
	}

	@Autowired
	private ConfigProp configProp;

	public String[] call() throws RemoteException {
		logger_a0ca618e.error(String.valueOf("调用接口------------------------开始"));
		String[] rtInfo = new String[0];
		try {
			MallPurReqChkServiceServiceStub stub = null;
			String wsdlLocation = "";
			// wsdlLocation = "http://10.6.6.151:8088/srm/services/OaSrmCheckPriceService?wsdl";
//		wsdlLocation = Util.null2String(I18nContextUtilcus.getBean(Environment.class).getProperty("htsrmoasync.htshop")).trim();
			wsdlLocation = configProp.getHtshop();
			logger_a0ca618e.error("wsdlLocation--" + wsdlLocation);
			stub = new MallPurReqChkServiceServiceStub(wsdlLocation);
			stub._getServiceClient().getOptions().setProperty("__CHUNKED__", Boolean.FALSE);
			logger_a0ca618e.error("stub--" + stub);
			// 设置传入参数
			MallPurReqChkServiceServiceStub.MALL_OA_PUR_REQ_CHK_RESULTE createRequest = new MallPurReqChkServiceServiceStub.MALL_OA_PUR_REQ_CHK_RESULTE();
			MallPurReqChkServiceServiceStub.MALL_OA_PUR_REQ_CHK_RESULT oasrmresult = new MallPurReqChkServiceServiceStub.MALL_OA_PUR_REQ_CHK_RESULT();
			oasrmresult.setInputTab(resultin);
			logger_a0ca618e.error("oasrmresult--" + oasrmresult);
			createRequest.setMALL_OA_PUR_REQ_CHK_RESULT(oasrmresult);
			MallPurReqChkServiceServiceStub.MALL_OA_PUR_REQ_CHK_RESULTResponseE resp = null;
			resp = stub.mALL_OA_PUR_REQ_CHK_RESULT(createRequest);
			logger_a0ca618e.error(String.valueOf("调用接口------------------------完成"));
			MallPurReqChkServiceServiceStub.MallPurReqOUT resultout = resp.getMALL_OA_PUR_REQ_CHK_RESULTResponse().getOutputTab();
			// 封装返回
			rtInfo = new String[3];
			rtInfo[0] = resultout.getPrNo();
			rtInfo[1] = resultout.getIstat();
			rtInfo[2] = resultout.getSrmsage();
		} catch (Exception e) {
			e.printStackTrace();
			logger_a0ca618e.error("CallSrmCheckMallServices Exception" + e.getMessage());
		}
		return rtInfo;
	}
}
