package com.weaver.seconddev.interfaces.workflow.action;

import com.weaver.seconddev.interfaces.prop.ConfigProp;
import corp.openapicalls.contract.setapproval.request.PassengerDetail;
import  com.weaver.seconddev.interfaces.oactrip.OaCtrip;
import  com.weaver.seconddev.interfaces.swfa.BillFieldUtil;
import  com.weaver.seconddev.interfaces.swfa.sl.CallDTtripService;

import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import com.weaver.common.i18n.tool.util.I18nContextUtil;
import com.weaver.verupgrade.conn.CONN_TYPE;
import java.lang.*;

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.Map;
import java.util.HashMap;
import com.weaver.verupgrade.conn.RecordSet;
import com.weaver.verupgrade.general.BaseBean;
import com.weaver.verupgrade.general.Util;
import com.weaver.verupgrade.hrm.resource.ResourceComInfo;
import com.weaver.verupgrade.soa.workflow.request.Property;
import com.weaver.verupgrade.soa.workflow.request.DetailTable;
import com.weaver.verupgrade.soa.workflow.request.Row;
import com.weaver.verupgrade.soa.workflow.request.Cell;
import com.weaver.verupgrade.interfaces.workflow.action.Action;

/**
 * 出差申请接口--国外出差申请--qingf20160921
 *
 * @author Administrator
 */
@org.springframework.stereotype.Service("workflow_action_ZOA_SL_GW_Action")
public class ZOA_SL_GW_Action extends BaseBean implements Action, EsbServerlessRpcRemoteInterface {

    // 对应E9的请求信息对象
    @Autowired
    private RequestInfo requestInfoTemp;
    @Autowired
    private ConfigProp configProp;
    @Autowired
    private OaCtrip oactrip ;
    @Autowired
    private CallDTtripService dTtripService;

//    @Autowired
//    private CallSLServices callServices;
    private static final Logger logger_39ae6ef1 = LoggerFactory.getLogger(ZOA_SL_GW_Action.class);

    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 request = requestInfoTemp.getRequestInfo(requestIdTemp, userIdTemp);
        try {
            // 流程请求ID
            String reid = request.getRequestid();
            try {
                // 主体信息
                String sourceType = "";
                String sourceKey = "";
                String applyEmpNum = "";
                String errandEmpNum = "";
                String projectCode = "";
                String journeyType = "";
                String corporation = "";
                String costCentre = "";
                String contactName = "";
                String contactPhone = "";
                String contactEmail = "";
                String trafficExpense = "";
                String hotelExpense = "";
                String otherExpense = "";
                String reason = "";
                // 行程信息
                String seqNo = "";
                String fromCity = "";
                String toCity = "";
                String journeyType1 = "";
                String areaType = "";
                String trafficTool = "other";
                String startDate = "";
                String endDate = "";
                // 同行人信息
                String personnelType = "";
                String empNum = "";
                String personnelName = "";
                String passName = "";
                String passType = "";
                String passNum = "";
                String mobilePhone = "";
                String email = "";
                // 扩展信息
                String attribute2 = "";
                String attribute3 = "";
                String attribute4 = "";
                String attribute5 = "";
                String attribute6 = "";
                String attribute7 = "";
                String attribute8 = "";
                String attribute9 = "";
                String attribute10 = "";
                String attribute11 = "";
                String attribute12 = "";
                String attribute13 = "";
                String attribute14 = "";
                String attribute15 = "";
                String attribute16 = "";
                String attribute17 = "";
                String attribute18 = "";
                String attribute19 = "";
                String attribute20 = "";
                // 携程信息
                List<String> listNumber = new ArrayList<String>();
                // 审批单号请求ID
                String approvalnumber = "";
                // 员工编号
                String employeeid = "";
                // 申请日期
                String expiredtime = "";
                // 证件号码
                String sfzh = "";
                // 开始日期时间
                Date begindate = new Date();
                // 开始日期时间
                Date enddate = new Date();
                ArrayList<PassengerDetail> passengerdetails = new ArrayList<PassengerDetail>();
                ArrayList<PassengerDetail> gwpassengerdetails = new ArrayList<PassengerDetail>();
                String sqr = "";
                // 流程请求ID
                approvalnumber = reid;
                logger_39ae6ef1.info(String.valueOf("ZOA_SL_GW_Action-Request: " + reid + "开始"));
                RecordSet rs1 = I18nContextUtil.getBean(RecordSet.class);
                ResourceComInfo hr = I18nContextUtil.getBean(ResourceComInfo.class);
                BillFieldUtil unit = new BillFieldUtil();
                // 流程请求ID
                attribute2 = reid;
                // applyEmpNum = unit.getWorkcode(request.getCreatorid());//经办人工号
                // 行程类型INLAND国内、OVERSEAS国际
                journeyType = "OVERSEAS";
                // 所属项目
                projectCode = "OA";
                // 系统标识
                sourceType = "OA";
                // 原因
                reason = "";
                // 出差类型
                attribute7 = "国外";
                // EMPLOYEE员工,RELATIVE亲友
                personnelType = "EMPLOYEE";
                seqNo = "1";
                fromCity = "公司";
                toCity = "";
                // OW单程，RT往返
                journeyType1 = "RT";
                startDate = "";
                endDate = "";
                // 出差类型0国内，1国外
                String cclx = "1";
                // 申请部门
                String sqbm = "0";
                // 申请单位
                String sqdw = "0";
                // 调用商旅接口
//                CallSLServices callServices = new CallSLServices();
                // 定义单据主信息
                HashMap errandBill = new HashMap();
                // 定义单据扩展信息
                HashMap mapStrings = new HashMap();
                // 定义同行人信息
                ArrayList<HashMap> companionInfos = new ArrayList<HashMap>();
                HashMap companionInfo = new HashMap();
                // 定义行程信息
                ArrayList<HashMap> journeys = new ArrayList<HashMap>();
                HashMap journey = new HashMap();
                // 封装表单信息
                // 获取表单主字段信息
                Property[] properties = request.getMainTableInfo().getProperty();
                for (int i = 0; i < properties.length; i++) {
                    // 主表数据
                    // 字段名
                    String name = properties[i].getName().toLowerCase();
                    // 值
                    String value = Util.null2String(properties[i].getValue());
                    // 单据主信息使用
                    if (name.equals("lcbh")) {
                        // 流程编号
                        sourceKey = value;
                    }
                    if (name.equals("sqr")) {
                        // 经办人
                        sqr = value;
                        // 经办人工号
                        applyEmpNum = unit.getWorkcode(sqr);
                    }
                    if (name.equals("sqbm")) {
                        // 部门
                        sqbm = value;
                        // 部门名称
                        attribute4 = unit.getDepartmentname(sqbm);
                    }
                    if (name.equals("sqdw")) {
                        // 分部
                        sqdw = value;
                        // 分部名称
                        attribute5 = unit.getSubcompanyname(sqdw);
                    }
                    if (name.equals("cclx")) {
                        // 出差类型
                        cclx = value;
                        if (cclx.equals("0")) {
                            // 出差类型
                            attribute7 = "国内";
                            // 行程类型INLAND国内、OVERSEAS国际
                            journeyType = "INLAND";
                        }
                    }
                    if (name.equals("cfsy")) {
                        // 出访事由
                        reason = value;
                    }
                    if (name.equals("sqrq")) {
                        // 申请日期
                        attribute6 = value;
                        expiredtime = value;
                    }
                    if (name.equals("cfdd")) {
                        if (!value.equals("")) {
                            // 出发地点
                            fromCity = value;
                        }
                    }
                    if (name.equals("cfgj")) {
                        // 出访国家或地区
                        attribute8 = value;
                        // 出差地点
                        toCity = value;
                    }
                    if (name.equals("cfsjq")) {
                        // 开始日期
                        attribute9 = value;
                        // 出发日期
                        startDate = value;
                    }
                    if (name.equals("kssj")) {
                        // 开始时间
                        attribute10 = value;
                    }
                    if (name.equals("cfsjz")) {
                        // 结束日期
                        attribute11 = value;
                        // 结束日期
                        endDate = value;
                    }
                    if (name.equals("jssj")) {
                        // 结束时间
                        attribute12 = value;
                    }
                    if (name.equals("cfxl")) {
                        // 出访线路
                        attribute13 = value;
                    }
                    if (name.equals("cfys")) {
                        // 出访费用项目及预算
                        attribute14 = value;
                    }
                    if (name.equals("rcap")) {
                        // 日程安排
                        attribute15 = value;
                    }
                }
                // 出差申请写入HR系统
                if (attribute10.equals("")) {
                    attribute10 = "00:00";
                }
                if (attribute12.equals("")) {
                    attribute12 = "23:59";
                }
                String beginDateTime = attribute9 + " " + attribute10;
                String endDateTime = attribute11 + " " + attribute12;
                double qjss = 1.00;
                DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                try {
                    Date d1 = df.parse(beginDateTime);
                    Date d2 = df.parse(endDateTime);
                    double diff = d2.getTime() - d1.getTime();
                    double xs = diff / (1000 * 60 * 60);
                    DecimalFormat ss = new DecimalFormat("#.00");
                    String strss = ss.format(xs);
                    qjss = Double.parseDouble(strss);
                } catch (Exception e) {
                    System.err.println(e.toString());
                }
                // 同程差旅人信息
                List<Map<String, Object>> personList = new ArrayList<Map<String, Object>>();
                // 获取明细表
                String hzm = "";
                String hzh = "";
                DetailTable[] detailtable = request.getDetailTableInfo().getDetailTable();
                // 指定明细表
                DetailTable dtq = detailtable[0];
                // 当前明细表的所有数据,按行存储
                Row[] sq = dtq.getRow();
                for (int j = 0; j < sq.length; j++) {
                    // 指定行
                    Row rq = sq[j];
                    // 每行数据再按列存储
                    Cell[] cq = rq.getCell();
                    hzm = "";
                    hzh = "";
                    for (int k = 0; k < cq.length; k++) {
                        // 指定列
                        Cell cq1 = cq[k];
                        // 明细字段名称
                        String nameq = cq1.getName().toLowerCase();
                        // 明细字段的值
                        String valueq = Util.null2String(cq1.getValue());
                        // 姓名
                        if (nameq.equals("xm")) {
                            String xm = valueq;
                            if (!xm.equals("")) {
                                String dtgh = unit.getWorkcode(xm);
                                listNumber.add(dtgh);
                                String dtname = hr.getResourcename(xm);
                                if (errandEmpNum.equals("")) {
                                    // 出差人工号
                                    errandEmpNum = dtgh;
                                    // 出差人姓名
                                    attribute3 = dtname;
                                }
                                // 出差申请写入HR系统
                                // po.Getexecute(dtgh,"A11",beginDateTime,endDateTime,qjss);
                                HashMap companionInfo1 = new HashMap();
                                companionInfo1.put("personnelType", personnelType);
                                companionInfo1.put("empNum", dtgh);
                                companionInfo1.put("personnelName", dtname);
                                companionInfo1.put("passName", passName);
                                companionInfo1.put("passType", passType);
                                companionInfo1.put("passNum", passNum);
                                companionInfo1.put("mobilePhone", mobilePhone);
                                companionInfo1.put("email", email);
                                // 向arrayList中添加对象 循环中处理
                                companionInfos.add(companionInfo1);
                                // 携程接口出差人信息
                                PassengerDetail passengerdetail2 = new PassengerDetail();
                                passengerdetail2.setName(hr.getResourcename(xm));
                                sfzh = unit.getCredentialsNumber(xm);
                                if (sfzh.equals("")) {
                                    passengerdetail2.setCredentialsNumber("null");
                                } else {
                                    passengerdetail2.setCredentialsNumber(sfzh);
                                }
                                passengerdetails.add(passengerdetail2);
                                // 同程差旅人信息
                                Map<String, Object> person = new HashMap<String, Object>();
                                person.put("name", dtname);
                                person.put("relation", 0);
                                person.put("passengerType", 0);
                                person.put("outEmployeeId", dtgh);
                                personList.add(person);
                            }
                        }
                        // 护照名
                        if (nameq.equals("hzm")) {
                            if (!valueq.equals("")) {
                                hzm = valueq.trim();
                                hzm = hzm.replace("&#160;", " ");
                                hzm = hzm.replace("&nbsp;", " ");
                            }
                        }
                        // 护照号
                        if (nameq.equals("hzh")) {
                            if (!valueq.equals("")) {
                                hzh = valueq.trim();
                                hzh = hzh.replace("&#160;", " ");
                                hzh = hzh.replace("&nbsp;", " ");
                            }
                        }
                    }
                    logger_39ae6ef1.info(String.valueOf("----" + hzm + "----" + hzh + "----"));
                    if (!hzm.equals("") && !hzh.equals("")) {
                        PassengerDetail gwpassengerdetail = new PassengerDetail();
                        gwpassengerdetail.setName(hzm);
                        gwpassengerdetail.setCredentialsNumber(hzh);
                        gwpassengerdetails.add(gwpassengerdetail);
                        // writeLog("----" + xm + "----"+ zjhm + "----");
                        passengerdetails.add(gwpassengerdetail);
                    }
                }
                if (applyEmpNum.length() < 10) {
                    // 经办人工号
                    applyEmpNum = errandEmpNum;
                }
                // 写入携程系统的开始结束日期时间拼接
                employeeid = applyEmpNum;
                DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                begindate = dateFormat.parse(attribute9 + " " + attribute10 + ":00");
                enddate = dateFormat.parse(attribute11 + " " + attribute12 + ":59");
                logger_39ae6ef1.info(String.valueOf("传递出差单据信息"));
                errandBill.put("sourceType", sourceType);
                errandBill.put("sourceKey", sourceKey);
                errandBill.put("applyEmpNum", applyEmpNum);
                errandBill.put("errandEmpNum", errandEmpNum);
                errandBill.put("projectCode", projectCode);
                errandBill.put("journeyType", journeyType);
                errandBill.put("corporation", corporation);
                errandBill.put("costCentre", costCentre);
                errandBill.put("contactName", contactName);
                errandBill.put("contactPhone", contactPhone);
                errandBill.put("contactEmail", contactEmail);
                errandBill.put("trafficExpense", trafficExpense);
                errandBill.put("hotelExpense", hotelExpense);
                errandBill.put("otherExpense", otherExpense);
                errandBill.put("reason", reason);
                journey.put("seqNo", seqNo);
                journey.put("fromCity", fromCity);
                journey.put("toCity", toCity);
                journey.put("journeyType", journeyType1);
                journey.put("areaType", areaType);
                journey.put("trafficTool", trafficTool);
                journey.put("startDate", startDate);
                journey.put("endDate", endDate);
                // 向arrayList中添加对象 循环中处理
                journeys.add(journey);
                mapStrings.put("attribute2", attribute2);
                mapStrings.put("attribute3", attribute3);
                mapStrings.put("attribute4", attribute4);
                mapStrings.put("attribute5", attribute5);
                mapStrings.put("attribute6", attribute6);
                mapStrings.put("attribute7", attribute7);
                mapStrings.put("attribute8", attribute8);
                mapStrings.put("attribute9", attribute9);
                mapStrings.put("attribute10", attribute10);
                mapStrings.put("attribute11", attribute11);
                mapStrings.put("attribute12", attribute12);
                mapStrings.put("attribute13", attribute13);
                mapStrings.put("attribute14", attribute14);
                mapStrings.put("attribute15", attribute15);
                mapStrings.put("attribute16", attribute16);
                mapStrings.put("attribute17", attribute17);
                mapStrings.put("attribute18", attribute18);
                mapStrings.put("attribute19", attribute19);
                mapStrings.put("attribute20", attribute20);
                // 传递出差单据信息
//                callServices.setErrandBillInfo(errandBill);
//                // writeLog("errandBill完成 ");
//                // 传递单据扩展信息
//                callServices.setMapString(mapStrings);
//                // writeLog("mapStrings完成 ");
//                // 传递同行人信息
//                // writeLog("companionInfos 长度为 "+companionInfos.size());
//                callServices.setCompanionInfo(companionInfos);
//                // writeLog("companionInfos完成 ");
//                // 传递行程信息
//                callServices.setJourneyInfo(journeys);
                // writeLog("journeys完成 ");
                // writeLog("传递出差单据信息完成");
                String tablename = "";
                String status = "E";
                String message = "";
                String wfid = request.getWorkflowid();
//                tablename = unit.getTablename(wfid);
                tablename = request.getRequestManager().getBillTableName();
//                String isneedxzsl = I18nContextUtilcus.getBean(Environment.class).getProperty("htctripmt.isneedxzsl");
//                String isneedxzsl = configProp.getIsneedxzsl();
//                if ("1".equals(isneedxzsl)) {
//                    // 是否需要推送中兴商旅 1是 0否
//                    try {
//                        logger_39ae6ef1.info(String.valueOf("调用接口开始"));
//                        String[] strResult = callServices.call();
//                        // writeLog("ReturnCode:"+strResult[0]);
//                        // writeLog("ReturnERRORMessage:"+strResult[1]);
//                        // writeLog("ReturnPassword:"+strResult[2]);
//                        // writeLog("ReturnBillNum:"+strResult[3]);
//                        String returnCode = strResult[0];
//                        if (returnCode.equals("0000") || returnCode.equals("1304")) {
//                            status = "S";
//                        }
//                        message = "--商旅接口回写说明--ReturnCode:" + strResult[0] + "；ReturnERRORMessage:" + strResult[1] + "；ReturnPassword:" + strResult[2] + "；ReturnBillNum:" + strResult[3];
//                        message = message.replace("'", "’");
//                        if (!tablename.equals("")) {
//                            String logsql = "update " + tablename + " set status ='" + status + "', message = isnull(cast(message as varchar(8000)),'') + '" + message + "' where requestId = " + reid;
//                            logger_39ae6ef1.info(String.valueOf("logsql:" + logsql));
//                            String poolname = CONN_TYPE.workflow.getType();
//                            // TODO E10执行sql方法第二参数必须指定源，默认使用流程源，单体客户无需修改，微服务/组合客户需根据查询表所属服务切换源，或使用外部数据源
//                            rs1.executeSql(logsql, poolname);
//                        }
//                    } catch (Exception e) {
//                        logger_39ae6ef1.info(String.valueOf(reid + "商旅接口Exception:" + e.getMessage()));
//                        // e.printStackTrace();
//                    }
//                }
                try {
                    logger_39ae6ef1.info(String.valueOf("调用携程接口开始 "));
//                    OaCtrip oactrip = new OaCtrip();
                    oactrip.setPassengerDetails(passengerdetails);
                    oactrip.setGWPassengerDetails(gwpassengerdetails);
                    employeeid = unit.getEmployeeId("ZOA_SL_GW_Action", employeeid, listNumber);
                    String[] strreturn = oactrip.call(approvalnumber, employeeid, expiredtime, begindate, enddate, cclx);
                    if (status.equals("S")) {
                        status = strreturn[0];
                    }
                    message = "--携程接口回写说明--ReturnStatus:" + strreturn[0] + "；ReturnERRORMessage:" + strreturn[1] + "；ReturnErrorCode:" + strreturn[2];
                    message = message.replace("'", "’");
                    if (!tablename.equals("")) {
                        String logsql2 = "update " + tablename + " set status ='" + status + "', message = isnull(cast(message as varchar(8000)),'') + '" + message + "' where requestId = " + reid;
                        logger_39ae6ef1.info(String.valueOf("logsql2:" + logsql2));
                        String poolname_ym = CONN_TYPE.workflow.getType();
                        // TODO E10执行sql方法第二参数必须指定源，默认使用流程源，单体客户无需修改，微服务/组合客户需根据查询表所属服务切换源，或使用外部数据源
                        rs1.executeSql(logsql2, poolname_ym);
                    }
                } catch (Exception e) {
                    logger_39ae6ef1.info(String.valueOf(reid + "携程接口Exception:" + e.getMessage()));
                    // e.printStackTrace();
                }
                /*try {
                writeLog("调用亨通商旅接口开始 ");
                errandBill.remove("costCentre");
                journey.put("seqNo", reid);
                journey.remove("areaType");
                journey.remove("trafficTool");
                errandBill.put("sourceType", "");
                errandBill.put("sourceKey", "");
                errandBill.put("journeyInfo", journey);
                errandBill.put("companionInfos", companionInfos);
                List<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();
                list.add(errandBill);
                Map<String, Object> billInfo = new HashMap<String, Object>();
                billInfo.put("errandBillInfos", list);
                JSONObject jsonObject = new JSONObject(billInfo);
                CreateBill create = new CreateBill();
                String[] ret = create.call(jsonObject);
                writeLog("传亨通商旅接口数据：" + jsonObject.toJSONString());
                if (status.equals("S")) {
                    status = ret[0];
                }
                message = "--亨通商旅接口回写说明--ReturnStatus:" + ret[0] + "；ReturnERRORMessage:" + ret[1];
                message = message.replace("'", "’");
                if (!tablename.equals("")) {
                    String logsql3 = "update " + tablename + " set status ='" + status + "', message = isnull(cast(message as varchar(8000)),'') + '" + message + "' where requestId = " + reid;
                    writeLog("logsql3:" + logsql3);
                    rs1.execute(logsql3);
                }
            } catch (Exception e) {
                writeLog(reid+"亨通商旅接口Exception:" + e.getMessage());
            }*/
                try {
                    logger_39ae6ef1.info(String.valueOf("调用同程商旅接口开始 "));
                    Map<String, Object> map = new HashMap<String, Object>();
                    map.put("outTravelApplyNo", reid);
                    map.put("travelApplyType", 1);
                    String travelApplyTime = dateFormat.format(new Date());
                    map.put("travelApplyTime", travelApplyTime);
                    map.put("travelUpdateTime", travelApplyTime);
                    map.put("operationType", 1);
                    map.put("outEmployeeId", errandEmpNum);
                    map.put("travelDescription", reason);
                    map.put("bookableProducts", "1,2,3,4,5");
                    map.put("status", 1);
                    // 差旅内容
                    List<Map<String, String>> itemList = new ArrayList<Map<String, String>>();
                    Map<String, String> item = new HashMap<String, String>();
                    item.put("startDate", startDate.replaceAll("-", "/"));
                    item.put("endDate", endDate.replaceAll("-", "/"));
                    item.put("departCity", fromCity);
                    item.put("arriveCity", toCity);
                    itemList.add(item);
                    map.put("itemList", itemList);
                    map.put("personList", personList);
                    /*List<Map<String,Object>> preTravelPolicyList = new ArrayList<Map<String,Object>>();
                Map<String,Object> preTravelPolicy = new HashMap<String,Object>();
                preTravelPolicy.put("approveRuleType",0);
                preTravelPolicyList.add(preTravelPolicy);
                map.put("preTravelPolicyList",preTravelPolicyList);*/
//                    CallDTtripService dTtripService = new CallDTtripService();
                    String[] dTtrip = dTtripService.optForDTtrip(map);
                    message = "--同程接口回写说明--ReturnStatus:" + dTtrip[0] + "；ReturnMessage:" + dTtrip[1] + "；出差单号:" + dTtrip[2];
                    message = message.replace("'", "’");
                    String logsql4 = "update " + tablename + " set status ='" + dTtrip[0] + "', message = isnull(cast(message as varchar(8000)),'') + '" + message + "' where requestId = " + reid;
                    logger_39ae6ef1.info(String.valueOf("logsql4:" + logsql4));
                    String poolname_2f = CONN_TYPE.workflow.getType();
                    // TODO E10执行sql方法第二参数必须指定源，默认使用流程源，单体客户无需修改，微服务/组合客户需根据查询表所属服务切换源，或使用外部数据源
                    rs1.executeSql(logsql4, poolname_2f);
                } catch (Exception e) {
                    e.printStackTrace();
                    logger_39ae6ef1.info(String.valueOf(reid + "同程商旅接口Exception:" + e.getMessage()));
                }
                logger_39ae6ef1.info(String.valueOf("调用接口完成 "));
            } catch (Exception e) {
                logger_39ae6ef1.info(String.valueOf(reid + "Exception:" + e.getMessage()));
                // e.printStackTrace();
            }
            return WeaResult.success(getResultMapForAction(weaverResultMap, "result", Action.SUCCESS, request.getRequestManager()));
        } catch (Exception e) {
            e.printStackTrace();
            logger_39ae6ef1.error("ZOA_SL_GW_Action e: {}", e.getMessage());
            return WeaResult.success(getResultMapForAction(weaverResultMap, "result", WeaResult.fail(500, "执行异常", getResultMapForAction(weaverResultMap, "result", e.getMessage(), request.getRequestManager())), request.getRequestManager()));
        }
    }

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