// 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.HashMap;
import java.util.Map;
import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoFunction;
import com.sap.conn.jco.JCoTable;
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 com.weaver.verupgrade.conn.RecordSetTrans;
import com.weaver.verupgrade.general.BaseBean;
import com.weaver.verupgrade.interfaces.workflow.action.Action;

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

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

    public static final org.slf4j.Logger logger_fed97889 = LoggerFactory.getLogger(ZOA_FICO_ANLA_CHECK.class);

    private JCoDestination destination;

    public ZOA_FICO_ANLA_CHECK() {
        new SAPConn();
        destination = SAPConn.getJCoDestination();
    }

    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_fed97889.error("ZOA_FICO_ANLA_CHECK e: {}", e.getMessage());
            return  WeaResult.fail(500, "ZOA_FICO_ANLA_CHECK e {}"+ e, getResultMapForAction(weaverResultMap, "result",e.getMessage(), requestinfo.getRequestManager()));
        }
    }

    public Map<String, String> Getexecute(String gdzcdm, String gsdm) {
        Map<String, String> map = new HashMap<String, String>();
        BaseBean base = new BaseBean();
        map.put("estatus", "E");
        try {
            RecordSetTrans recordsettrans = I18nContextUtil.getBean(RecordSetTrans.class);
            recordsettrans.setAutoCommit(false);
            JCoFunction jcofunction = destination.getRepository().getFunction("ZOA_FICO_ANLA_CHECK");
            if (jcofunction == null) {
                logger_fed97889.error(String.valueOf("ZOA_FICO_ANLA_CHECK not found in SAP."));
                map.put("emessage", "ZOA_FICO_ANLA_CHECK not found in SAP.");
            } else {
                // 主资产号
                jcofunction.getImportParameterList().setValue("I_ANLN1", gdzcdm);
                // 公司代码
                jcofunction.getImportParameterList().setValue("I_BUKRS", gsdm);
                logger_fed97889.error(String.valueOf("ZOA_FICO_ANLA_CHECK接收gdzcdm:" + gdzcdm));
                logger_fed97889.error(String.valueOf("ZOA_FICO_ANLA_CHECK接收gsdm:" + gsdm));
                try {
                    jcofunction.execute(destination);
//                     String stat = jcofunction.getExportParameterList().getValue("E_ISTAT").toString();
//                     String msg = jcofunction.getExportParameterList().getValue("E_MESSAGE").toString();
                    String stat = "S";
                    String msg = "执行成功";
                    map.put("estatus", stat);
                    map.put("emessage", msg);
                    if ("S".equals(stat)) {
                        JCoTable localJCoTable1 = jcofunction.getTableParameterList().getTable("E_OUT");
                        if (localJCoTable1.getNumRows() > 0) {
                            localJCoTable1.setRow(1);
                            // 资产描述
                            map.put("TXT50", localJCoTable1.getString("TXT50").trim());
                            // 附加资产描述
                            map.put("TXA50", localJCoTable1.getString("TXA50").trim());
                            // 主资产号
                            map.put("ANLN1", localJCoTable1.getString("ANLN1").trim());
                            // 资产编号说明
                            map.put("ANLHTXT", localJCoTable1.getString("ANLHTXT").trim());
                            // 序列号
                            map.put("SERNR", localJCoTable1.getString("SERNR").trim());
                            // 存货号
                            map.put("INVNR", localJCoTable1.getString("INVNR").trim());
                            // 使用成本中心
                            map.put("KOSTL", localJCoTable1.getString("KOSTL").trim());
                            // 管理成本中心
                            map.put("KOSTLV", localJCoTable1.getString("KOSTLV").trim());
                            // 内部订单
                            map.put("CAUFN", localJCoTable1.getString("CAUFN").trim());
                            // 工厂
                            map.put("WERKS", localJCoTable1.getString("WERKS").trim());
                            // 责任人
                            map.put("RAUMN", localJCoTable1.getString("RAUMN").trim());
                            // 公司代码
                            map.put("BUKRS", localJCoTable1.getString("BUKRS").trim());
                            // 科目定位码
                            map.put("KTOGR", localJCoTable1.getString("KTOGR").trim());
                            // 数量
                            map.put("MENGE", localJCoTable1.getString("MENGE").trim());
                            // 基本计量单位
                            map.put("MEINS", localJCoTable1.getString("MEINS").trim());
                            // 资本化日期
                            map.put("AKTIV", localJCoTable1.getString("AKTIV").trim());
                            // 首次购置日期
                            map.put("ZUGDT", localJCoTable1.getString("ZUGDT").trim());
                            // 记录首次购置年度
                            map.put("ZUJHR", localJCoTable1.getString("ZUJHR").trim());
                            // 记录首次购置期间
                            map.put("ZUPER", localJCoTable1.getString("ZUPER").trim());
                            // 记录报废日期
                            map.put("DEAKT", localJCoTable1.getString("DEAKT").trim());
                            // 使用状态
                            map.put("ORD41", localJCoTable1.getString("ORD41").trim());
                            // 进口设备
                            map.put("ORD42", localJCoTable1.getString("ORD42").trim());
                            // 计划折旧年限
                            map.put("NDJAR", localJCoTable1.getString("NDJAR").trim());
                            // 计划折旧期间
                            map.put("NDPER", localJCoTable1.getString("NDPER").trim());
                            // 折旧开始日期
                            map.put("AFABG", localJCoTable1.getString("AFABG").trim());
                            // 已折旧年度
                            map.put("NDABJ", localJCoTable1.getString("NDABJ").trim());
                            // 已折旧期间
                            map.put("NDABP", localJCoTable1.getString("NDABP").trim());
                            // 资产分类
                            map.put("ANLKL", localJCoTable1.getString("ANLKL").trim());
                            // 资产次级编号
                            map.put("ANLN2", localJCoTable1.getString("ANLN2").trim());
                        }
                    }
                } catch (Exception e1) {
                    logger_fed97889.error("error1:" , e1);
                    map.put("emessage", e1.getMessage());
                }
            }
        } catch (Exception e2) {
            logger_fed97889.error("error2:" , e2.getMessage());
            map.put("emessage", e2.getMessage());
        }
        return map;
    }

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