package com.weaver.seconddev.interfaces.gdwmsoa;

import com.weaver.common.i18n.tool.util.I18nContextUtil;
import com.weaver.seconddev.interfaces.prop.ConfigProp;
import org.apache.axis2.kernel.http.HTTPConstants;
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 ZMES_OA_SUBMIT_SERVICE extends BaseBean {

    private static final org.slf4j.Logger logger_b6665baf = LoggerFactory.getLogger(ZMES_OA_SUBMIT_SERVICE.class);
    @Autowired
    private ConfigProp configProp;
    public String[] call(ZMES_OA_SUBMIT_SERVICEStub.ArrayOfZMES_OA_SUBMIT_ITEM_TYPE param, String requestid, String cfxt) {
        String[] str = new String[2];
        try {
            String url = "";
            if ("1".equals(cfxt)) {
//                url = Util.null2String(I18nContextUtilcus.getBean(Environment.class).getProperty("htwmsoasync.wllynmg_url")).trim();
                url = configProp.getWllynmg_url();
            } else {
//                url = Util.null2String(I18nContextUtilcus.getBean(Environment.class).getProperty("htwmsoasync.wlly_url")).trim();
                url = configProp.getWlly_url();
            }
            logger_b6665baf.error(String.valueOf(requestid + " url:" + url));
            ZMES_OA_SUBMIT_SERVICEStub stub = new ZMES_OA_SUBMIT_SERVICEStub(url);
            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);
            ZMES_OA_SUBMIT_SERVICEStub.ZMES_OA_SUBMIT req = new ZMES_OA_SUBMIT_SERVICEStub.ZMES_OA_SUBMIT();
            ZMES_OA_SUBMIT_SERVICEStub.ZMES_OA_SUBMIT_HEADER_TYPE header = new ZMES_OA_SUBMIT_SERVICEStub.ZMES_OA_SUBMIT_HEADER_TYPE();
            header.setITFID("");
            header.setSENDID("");
            header.setSYSID("SYS013");
            header.setDATAS(param);
            req.setHeader(header);
            ZMES_OA_SUBMIT_SERVICEStub.ZMES_OA_SUBMITResponse res = stub.zMES_OA_SUBMIT(req);
            ZMES_OA_SUBMIT_SERVICEStub.ZMES_OA_SUBMIT_RETURN_TYPE returntype = res.getZMES_OA_SUBMITResult();
            ZMES_OA_SUBMIT_SERVICEStub.ArrayOfZMES_OA_SUBMIT_RETURNITEM_TYPE ret = returntype.getRETURN();
            ZMES_OA_SUBMIT_SERVICEStub.ZMES_OA_SUBMIT_RETURNITEM_TYPE[] result = ret.getZMES_OA_SUBMIT_RETURNITEM_TYPE();
            if (result.length > 0) {
                str[0] = result[0].getIstat();
                str[1] = result[0].getMessage();
                logger_b6665baf.error(String.valueOf(requestid + "调用光导物料领用返回审批结果接口返回值：" + str[0] + "-" + str[1]));
            } else {
                str[0] = "E";
                str[1] = "调用光导物料领用返回审批结果接口出错,请联系管理员。";
                logger_b6665baf.error(String.valueOf(requestid + "调用光导物料领用返回审批结果接口出错,请联系管理员。"));
            }
        } catch (Exception e) {
            str[0] = "E";
            str[1] = e.toString();
            logger_b6665baf.error(String.valueOf(e));
            logger_b6665baf.error(String.valueOf(requestid + "调用光导物料领用返回审批结果接口出错：" + e.toString()));
        }
        return str;
    }
}
