// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)
// Source File Name:   ZOA_MM_PR_CREATE.java
package com.weaver.seconddev.interfaces.workflow.action;

import java.util.Map;
import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoFunction;
import com.weaver.common.i18n.tool.util.I18nContextUtil;
import java.lang.*;
import java.util.*;
import com.weaver.verupgrade.workflow.request.RequestManager;
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
import com.weaver.common.base.entity.result.WeaResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import com.weaver.verupgrade.soa.workflow.request.RequestInfo;
import java.util.HashMap;
import com.weaver.verupgrade.conn.RecordSetTrans;
import com.weaver.verupgrade.general.BaseBean;
import com.weaver.verupgrade.interfaces.workflow.action.Action;

// Referenced classes of package  com.weaver.seconddev.interfaces.workflow.action:
// SAPConn, Action
@org.springframework.stereotype.Service("workflow_action_ZOA_FICO_COC_CHANGE")
public class ZOA_FICO_COC_CHANGE implements Action, EsbServerlessRpcRemoteInterface {

    // 对应E9的请求信息对象
    @Autowired
    private RequestInfo requestInfoTemp;

    private static final Logger logger_d83cdf56 = LoggerFactory.getLogger(ZOA_FICO_COC_CHANGE.class);

    private JCoDestination destination;

    private String[] retstr;

    public ZOA_FICO_COC_CHANGE() {
        new SAPConn();
        destination = SAPConn.getJCoDestination();
        retstr = null;
    }

    public WeaResult<Map<String, Object>> execute(Map<String, Object> requestInfoMap) {
        Map<String, Object> weaverResultMap = new HashMap<>();
        Long requestIdTemp = Long.parseLong(String.valueOf(requestInfoMap.getOrDefault("requestid", -1)));
        Long userIdTemp = Long.parseLong(String.valueOf(requestInfoMap.getOrDefault("userid", -1)));
        RequestInfo requestinfo = requestInfoTemp.getRequestInfo(requestIdTemp, userIdTemp);
        try {
            return WeaResult.success(getResultMapForAction(weaverResultMap, "result", "1", requestinfo.getRequestManager()));
        } catch (Exception e) {
            e.printStackTrace();
            logger_d83cdf56.error("ZOA_FICO_COC_CHANGE e: {}", e.getMessage());
            return  WeaResult.fail(500, "ZOA_FICO_COC_CHANGE e {}"+ e, getResultMapForAction(weaverResultMap, "result",e.getMessage(), requestinfo.getRequestManager()));
        }
    }

    public String[] Getexecute(Map<String, String> map) {
        retstr = new String[4];
        try {
            RecordSetTrans recordsettrans = I18nContextUtil.getBean(RecordSetTrans.class);
            BaseBean base = new BaseBean();
            recordsettrans.setAutoCommit(false);
            JCoFunction jcofunction = destination.getRepository().getFunction("ZOA_FICO_COC_CHANGE");
            if (jcofunction == null) {
                logger_d83cdf56.error(String.valueOf("ZOA_FICO_COC_CHANGE not found in SAP."));
                retstr[0] = "E";
                retstr[1] = "ZOA_FICO_COC_CHANGE not found in SAP.";
            } else {
                // 成本中心编码
                jcofunction.getImportParameterList().setValue("I_KOSTL", map.get("CBZXDM"));
                // 名称
                jcofunction.getImportParameterList().setValue("I_KTEXT", map.get("CBZXMCGH"));
                // 描述
                jcofunction.getImportParameterList().setValue("I_LTEXT", map.get("CBZXMSGH"));
                // 负责人
                jcofunction.getImportParameterList().setValue("I_VERAK", map.get("FZRGH"));
                logger_d83cdf56.error(String.valueOf("ZOA_FICO_COC_CHANGE接收kostl:" + map.get("CBZXDM")));
                logger_d83cdf56.error(String.valueOf("ZOA_FICO_COC_CHANGE接收ktext:" + map.get("CBZXMCGH")));
                logger_d83cdf56.error(String.valueOf("ZOA_FICO_COC_CHANGE接收ltext:" + map.get("CBZXMSGH")));
                logger_d83cdf56.error(String.valueOf("ZOA_FICO_COC_CHANGE接收verak:" + map.get("FZRGH")));
                try {
                    jcofunction.execute(destination);
                    retstr[0] = jcofunction.getExportParameterList().getValue("E_ISTAT").toString();
                    retstr[1] = jcofunction.getExportParameterList().getValue("E_MESSAGE").toString();
                    retstr[2] = jcofunction.getExportParameterList().getValue("E_KOSTL").toString();
                    retstr[3] = jcofunction.getExportParameterList().getValue("E_DATAB").toString();
                    logger_d83cdf56.error(String.valueOf("ZOA_FICO_COC_CHANGE执行success,得到返回值 [E_ISTAT=" + retstr[0] + "][E_MESSSAGE=" + retstr[1] + "]"));
                } catch (Exception exception1) {
                    retstr[0] = "E";
                    retstr[1] = exception1.getMessage();
                    logger_d83cdf56.error(String.valueOf("ZOA_FICO_COC_CHANGE异常：" + exception1.toString()));
                }
            }
            return retstr;
        } catch (Exception exception) {
            retstr[0] = "E";
            retstr[1] = exception.getMessage();
        }
        return retstr;
    }

    Map<String, Object> getResultMapForAction(Map<String, Object> map, String key, Object value, RequestManager requestManager) {
        if (key != null && !key.isEmpty()) {
            map.put(key, value);
        }
        String msgContent = requestManager.getMessagecontent();
        if (msgContent != null && !msgContent.isEmpty()) {
            map.put("msgContent", msgContent);
        }
        String msgId = requestManager.getMessageid();
        if (msgId != null && !msgId.isEmpty()) {
            map.put("msgId", msgId);
        }
        return map;
    }
}
