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

import com.google.gson.Gson;
import  com.weaver.seconddev.interfaces.oames.CallMesNewMaterialCertificationService;
import  com.weaver.seconddev.interfaces.oames.OA_KSJXCL_SERVICEStub;
import  com.weaver.seconddev.interfaces.swfa.BillFieldUtil;
import com.weaver.common.i18n.tool.util.I18nContextUtil;
import com.weaver.verupgrade.conn.CONN_TYPE;
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.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.Cell;
import com.weaver.verupgrade.soa.workflow.request.DetailTable;
import com.weaver.verupgrade.soa.workflow.request.Property;
import com.weaver.verupgrade.soa.workflow.request.Row;
import com.weaver.verupgrade.interfaces.workflow.action.Action;

/**
 * HTGD-JS06-新材料小批量认证总结报告
 */
@org.springframework.stereotype.Service("workflow_action_OaMesNewMaterialCertificationAction")
public class OaMesNewMaterialCertificationAction extends BaseBean implements Action, EsbServerlessRpcRemoteInterface {

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

    private static final Logger logger_7ab25493 = LoggerFactory.getLogger(OaMesNewMaterialCertificationAction.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 {
            try {
                String[][] prdetail = null;
                String[][] prdetail1 = null;
                String[][] prdetail2 = null;
                // 申请部门
                String sqbm = " ";
                // 流程编号
                String lcbh = " ";
                // 产品（项目）名称
                String cpmc = " ";
                // 项目类别
                String xmlb = " ";
                // 项目责任人
                String xmzrr = " ";
                // 项目参与人
                String xmcyr = " ";
                // 调试截止时间
                String tsqssj2 = " ";
                // 调试起始时间
                String tsqssj = " ";
                // 调试产品规格
                String tscpgg = " ";
                // 生产机台
                String scjt = " ";
                // 工装模具
                String gzmj = " ";
                // 工艺参数
                String gycs = " ";
                // 小批量试制结论
                String xplszjl = " ";
                // 设备工装投资
                String sbgztz = " ";
                // 材料投资
                String cltz = " ";
                // 人工投资
                String rgtz = " ";
                // 水电投资
                String sdtz = " ";
                // 其他投资
                String qttz = " ";
                // 新供应商开发
                String xgyskf = " ";
                // 新供应商开发原因说明
                String xgysyysm = " ";
                // 1.原材料关键指标是否达到说明及建议
                String yclgjzb = " ";
                // 2.调试是否达需认证需求（对应立项申请中认证内容）说明及建议
                String tsrzxq = " ";
                // 3.其它说明及建议
                String qtsmjy = " ";
                // 合计总投资
                String hjztz = " ";
                // 项目申请人
                String xmsqr = " ";
                // 供应商1
                String gys1 = " ";
                // 供应商2
                String gys2 = " ";
                // 供应商3
                String gys3 = " ";
                // 供应商4
                String gys4 = " ";
                // 供应商5
                String gys5 = " ";
                // 供应商
                String gys6 = " ";
                // 流程请求ID
                String requestId = request.getRequestid();
                // 主表字段赋值
                // 获取表单主字段信息
                Property[] properties = request.getMainTableInfo().getProperty();
                for (int i = 0; i < properties.length; i++) {
                    // 主表数据
                    // 字段名
                    String name = properties[i].getName().toUpperCase();
                    // 值
                    String value = Util.null2String(properties[i].getValue());
                    if (name.equals("CPMC")) {
                        // 产品名称
                        cpmc = value.trim();
                    }
                    if (name.equals("XMSQR")) {
                        // 项目申请人
                        xmsqr = value.trim();
                    }
                    if (name.equals("LCBH")) {
                        // 流程编号
                        lcbh = value.trim();
                    }
                    if (name.equals("SQBM")) {
                        // 申请部门
                        sqbm = value.trim();
                    }
                    if (name.equals("XMLB")) {
                        // 项目类别
                        xmlb = value.trim();
                    }
                    if (name.equals("CPMC")) {
                        // 产品名称
                        cpmc = value.trim();
                    }
                    if (name.equals("XMZRR")) {
                        // 项目责任人
                        xmzrr = value.trim();
                    }
                    if (name.equals("XMCYR")) {
                        // 项目参与人
                        xmcyr = value.trim();
                    }
                    if (name.equals("TSQSSJ2")) {
                        // 调试截止时间
                        tsqssj2 = value.trim();
                    }
                    if (name.equals("TSQSSJ")) {
                        // 调试起始时间
                        tsqssj = value.trim();
                    }
                    if (name.equals("TSCPGG")) {
                        // 调试产品规格
                        tscpgg = value.trim();
                    }
                    if (name.equals("SCJT")) {
                        // 生产机台
                        scjt = value.trim();
                    }
                    if (name.equals("GZMJ")) {
                        // 工装模具
                        gzmj = value.trim();
                    }
                    if (name.equals("GYCS")) {
                        // 工艺参数
                        gycs = value.trim();
                    }
                    if (name.equals("XPLSZJL")) {
                        // 小批量试制结论
                        xplszjl = value.trim();
                    }
                    if (name.equals("SBGZTZ")) {
                        // 设备工装投资
                        sbgztz = value.trim();
                    }
                    if (name.equals("CLTZ")) {
                        // 材料投资
                        cltz = value.trim();
                    }
                    if (name.equals("RGTZ")) {
                        // 人工投资
                        rgtz = value.trim();
                    }
                    if (name.equals("SDTZ")) {
                        // 水电投资
                        sdtz = value.trim();
                    }
                    if (name.equals("QTTZ")) {
                        // 其他投资
                        qttz = value.trim();
                    }
                    if (name.equals("XGYSKF")) {
                        // 新供应商开发
                        xgyskf = value.trim();
                        ;
                    }
                    if (name.equals("XGYSYYSM")) {
                        // 新供应商开发说明
                        xgysyysm = value.trim();
                        ;
                    }
                    if (name.equals("YCLGJZB")) {
                        // 原材料关键指标是否达到说明及建议
                        yclgjzb = value.trim();
                        ;
                    }
                    if (name.equals("TSRZXQ")) {
                        // 调试是否达需认证需求
                        tsrzxq = value.trim();
                        ;
                    }
                    if (name.equals("QTSMJY")) {
                        // 其他说明及建议
                        qtsmjy = value.trim();
                        ;
                    }
                    if (name.equals("HJZTZ")) {
                        // 合计总投资
                        hjztz = value.trim();
                    }
                    if (name.equals("GYS1")) {
                        // 供应商1
                        gys1 = value.trim();
                        ;
                    }
                    if (name.equals("GYS2")) {
                        // 供应商2
                        gys2 = value.trim();
                        ;
                    }
                    if (name.equals("GYS3")) {
                        // 供应商3
                        gys3 = value.trim();
                        ;
                    }
                    if (name.equals("GYS4")) {
                        // 供应商4
                        gys4 = value.trim();
                        ;
                    }
                    if (name.equals("GYS5")) {
                        // 供应商5
                        gys5 = value.trim();
                        ;
                    }
                    if (name.equals("GYS6")) {
                        // 供应商6
                        gys6 = value.trim();
                        ;
                    }
                }
                // 将申请人信息由代号转换为真实信息
                ResourceComInfo hr = I18nContextUtil.getBean(ResourceComInfo.class);
                BillFieldUtil unit = new BillFieldUtil();
                String Id = request.getWorkflowid();
                logger_7ab25493.error(String.valueOf("新材料小批量认证"));
                logger_7ab25493.error(String.valueOf("开始 将申请人信息由代号转换为真实信息"));
                if (!xmsqr.equals("")) {
                    // 获取项目申请人姓名
                    xmsqr = hr.getResourcename(xmsqr);
                }
                if (!xmcyr.equals("")) {
                    // 获取项目参与人姓名
                    xmcyr = hr.getResourcename(xmcyr);
                }
                if (!xmzrr.equals("")) {
                    // 获取项目责任人姓名
                    xmzrr = hr.getResourcename(xmzrr);
                }
                if (!sqbm.equals("")) {
                    // 获取项目申请人姓名
                    sqbm = unit.getDepartmentname(sqbm);
                }
                logger_7ab25493.error(String.valueOf("代号转为真实信息结束" + "\t" + "申请人" + xmsqr));
                // 获取明细表0
                logger_7ab25493.error(String.valueOf("明细表0开始取值！"));
                OA_KSJXCL_SERVICEStub.ArrayOfOA_XCLRZZJBGLC_ITEMSA_TYPE arrayItems = new OA_KSJXCL_SERVICEStub.ArrayOfOA_XCLRZZJBGLC_ITEMSA_TYPE();
                DetailTable[] detailtable = request.getDetailTableInfo().getDetailTable();
                // 指定明细表
                DetailTable dtq = detailtable[0];
                // 当前明细表的所有数据,按行存储
                Row[] sq = dtq.getRow();
                prdetail = new String[sq.length][5];
                for (int j = 0; j < sq.length; j++) {
                    OA_KSJXCL_SERVICEStub.OA_XCLRZZJBGLC_ITEMSA_TYPE item = new OA_KSJXCL_SERVICEStub.OA_XCLRZZJBGLC_ITEMSA_TYPE();
                    // 指定行
                    Row rq = sq[j];
                    // 每行数据再按列存储
                    Cell[] cq = rq.getCell();
                    for (int k = 0; k < cq.length; k++) {
                        // 指定列
                        Cell cq1 = cq[k];
                        // 明细字段名称
                        String nameq = cq1.getName().toUpperCase();
                        // 明细字段的值
                        String valueq = Util.null2String(cq1.getValue());
                        // 材料批号
                        if (nameq.equals("CLPH")) {
                            prdetail[j][0] = valueq.trim();
                        }
                        // 材料名称
                        if (nameq.equals("CLMC")) {
                            prdetail[j][1] = valueq.trim();
                        }
                        // 材料厂家
                        if (nameq.equals("CLCJ")) {
                            prdetail[j][2] = valueq.trim();
                        }
                        // 使用数量
                        if (nameq.equals("SYSL")) {
                            prdetail[j][3] = valueq.trim();
                        }
                        // 型号规格
                        if (nameq.equals("XHGG")) {
                            prdetail[j][4] = valueq.trim();
                        }
                    }
                    try {
                        // 明细表1赋值
                        logger_7ab25493.error(String.valueOf("明细表0开始赋值"));
                        item.setCLPH(prdetail[j][0]);
                        item.setCLMC(prdetail[j][1]);
                        item.setCLCJ(prdetail[j][2]);
                        item.setSYSL(prdetail[j][3]);
                        item.setXHGG(prdetail[j][4]);
                        arrayItems.addOA_XCLRZZJBGLC_ITEMSA_TYPE(item);
                        logger_7ab25493.error("明细表赋值完成，如：使用数量" + item.getSYSL() + "\t" + "材料名称" + item.getCLMC());
                    } catch (NumberFormatException e) {
                        System.err.println(e.toString());
                        logger_7ab25493.error(String.valueOf("明细表0传值报错 " + e.toString()));
                    }
                }
                // 获取明细表1
                OA_KSJXCL_SERVICEStub.ArrayOfOA_XCLRZZJBGLC_ITEMSC_TYPE arrayItems1 = new OA_KSJXCL_SERVICEStub.ArrayOfOA_XCLRZZJBGLC_ITEMSC_TYPE();
                DetailTable[] detailtable1 = request.getDetailTableInfo().getDetailTable();
                // 指定明细表
                DetailTable dtq1 = detailtable1[1];
                // 当前明细表的所有数据,按行存储
                Row[] sq1 = dtq1.getRow();
                prdetail1 = new String[sq1.length][2];
                logger_7ab25493.error(String.valueOf("明细表1开始取值"));
                for (int j = 0; j < sq1.length; j++) {
                    OA_KSJXCL_SERVICEStub.OA_XCLRZZJBGLC_ITEMSC_TYPE item1 = new OA_KSJXCL_SERVICEStub.OA_XCLRZZJBGLC_ITEMSC_TYPE();
                    // 指定行
                    Row rq = sq1[j];
                    // 每行数据再按列存储
                    Cell[] cq = rq.getCell();
                    for (int k = 0; k < cq.length; k++) {
                        // 指定列
                        Cell cq1 = cq[k];
                        // 明细字段名称
                        String nameq = cq1.getName().toUpperCase();
                        // 明细字段的值
                        String valueq = Util.null2String(cq1.getValue());
                        // 评估标准
                        if (nameq.equals("PGBZ")) {
                            prdetail1[j][0] = valueq.trim();
                            // 明细表赋值
                            item1.setPGBZ(prdetail1[j][0]);
                        }
                        // 完成情况
                        if (nameq.equals("WCQK")) {
                            prdetail1[j][1] = valueq.trim();
                            // 明细表赋值
                            item1.setWCQK(prdetail1[j][1]);
                            logger_7ab25493.error("明细表1赋值,完成情况      " + item1.getWCQK());
                        }
                    }
                    try {
                        arrayItems1.addOA_XCLRZZJBGLC_ITEMSC_TYPE(item1);
                        logger_7ab25493.error(String.valueOf("明细表item1 的值存到arrayItem1当中"));
                    } catch (NumberFormatException e) {
                        System.err.println(e.toString());
                        logger_7ab25493.error(String.valueOf("item1 的值存到arrayItem1当中报错 " + e.toString()));
                    }
                }

                OA_KSJXCL_SERVICEStub.OA_XCLRZZJBGLC_HEADER_TYPE param_data = new OA_KSJXCL_SERVICEStub.OA_XCLRZZJBGLC_HEADER_TYPE();
                OA_KSJXCL_SERVICEStub.ArrayOfOA_XCLRZZJBGLC_HEADER_TYPE param_datas = new OA_KSJXCL_SERVICEStub.ArrayOfOA_XCLRZZJBGLC_HEADER_TYPE();
                OA_KSJXCL_SERVICEStub.OA_XCLRZZJBGLC resultin = new OA_KSJXCL_SERVICEStub.OA_XCLRZZJBGLC();

                // 获取明细表2
                OA_KSJXCL_SERVICEStub.ArrayOfOA_XCLRZZJBGLC_ITEMSB_TYPE arrayItems2 = new OA_KSJXCL_SERVICEStub.ArrayOfOA_XCLRZZJBGLC_ITEMSB_TYPE();
                DetailTable[] detailtable2 = request.getDetailTableInfo().getDetailTable();
                Gson gson = new Gson();
                logger_7ab25493.error("detailtable2----" + gson.toJson(detailtable2));
                logger_7ab25493.error("detailtable2长度----" +detailtable2.length);
                //判断明细表3是否存在
              if(detailtable2.length==3) {
                  // 指定明细表
                  DetailTable dtq2 = detailtable2[2];
                  logger_7ab25493.error("dtq2----" + gson.toJson(dtq2));
                  // 当前明细表的所有数据,按行存储
                  Row[] sq2 = dtq2.getRow();
                  prdetail2 = new String[sq.length][5];
                  for (int j = 0; j < sq2.length; j++) {
                      OA_KSJXCL_SERVICEStub.OA_XCLRZZJBGLC_ITEMSB_TYPE item2 = new OA_KSJXCL_SERVICEStub.OA_XCLRZZJBGLC_ITEMSB_TYPE();
                      // 指定行
                      Row rq = sq2[j];

                      // 每行数据再按列存储
                      Cell[] cq = rq.getCell();

                      for (int k = 0; k < cq.length; k++) {
                          // 指定列
                          Cell cq1 = cq[k];
                          // 明细字段名称
                          String nameq = cq1.getName().toUpperCase();
                          // 明细字段的值
                          String valueq = Util.null2String(cq1.getValue());
                          // 技术情况
                          if (nameq.equals("JSQK")) {
                              prdetail2[j][0] = valueq.trim();
                          }
                          // 材料应用方向
                          if (nameq.equals("CLYYFX")) {
                              prdetail2[j][1] = valueq.trim();
                          }
                          // 创新内容
                          if (nameq.equals("CXNR")) {
                              prdetail2[j][2] = valueq.trim();
                          }
                          // 经济效益
                          if (nameq.equals("JJXY")) {
                              prdetail2[j][3] = valueq.trim();
                          }
                          // 其他说明
                          if (nameq.equals("QTSM")) {
                              prdetail2[j][4] = valueq.trim();
                          }
                      }
                      try {
                          // 明细表赋值到item2
                          logger_7ab25493.error(String.valueOf("明细表2开始赋值 "));
                          item2.setJSQK(prdetail2[j][0]);
                          item2.setCLYYFX(prdetail2[j][1]);
                          item2.setCXNR(prdetail2[j][2]);
                          item2.setJJXY(prdetail2[j][3]);
                          item2.setQTSM(prdetail2[j][4]);
                          arrayItems2.addOA_XCLRZZJBGLC_ITEMSB_TYPE(item2);
                          logger_7ab25493.error("明细表item2 赋值结束，如：经济效益：       " + item2.getJJXY());
                      } catch (NumberFormatException e) {
                          System.err.println(e.toString());
                          logger_7ab25493.error(String.valueOf("明细表2传值报错 " + e.toString()));
                      }
                  }
              }

//                OA_KSJXCL_SERVICEStub.OA_XCLRZZJBGLC_HEADER_TYPE param_data = new OA_KSJXCL_SERVICEStub.OA_XCLRZZJBGLC_HEADER_TYPE();
//                OA_KSJXCL_SERVICEStub.ArrayOfOA_XCLRZZJBGLC_HEADER_TYPE param_datas = new OA_KSJXCL_SERVICEStub.ArrayOfOA_XCLRZZJBGLC_HEADER_TYPE();
//                OA_KSJXCL_SERVICEStub.OA_XCLRZZJBGLC resultin = new OA_KSJXCL_SERVICEStub.OA_XCLRZZJBGLC();

                try {
                    // TODO custom long转换问题
//                    param_data.setID(Integer.parseInt(Id));
                    // TODO custom long转换问题
//                    param_data.setREQUESTID(Integer.parseInt(requestId));
                    param_data.setBH(lcbh);
                    param_data.setCPMC(cpmc);
                    param_data.setXMLB(xmlb);
                    param_data.setXMZRR(xmzrr);
                    param_data.setXMCYR(xmcyr);
                    // 项目申请人
                    param_data.setSQR(xmsqr);
                    param_data.setSKH("GDBJ/BQ-0042A");
                    param_data.setSQBM(sqbm);
                    param_data.setTSQSSJ2(tsqssj2);
                    param_data.setTSQZSJ(tsqssj);
                    param_data.setTSCPGG(tscpgg);
                    param_data.setSCJT(scjt);
                    param_data.setGZMJ(gzmj);
                    param_data.setGYCS(gycs);
                    param_data.setXPLSZJL(xplszjl);
                    param_data.setXGYSKF(xgyskf);
                    param_data.setXGYSYYSM(xgysyysm);
                    param_data.setYCLGJZB(yclgjzb);
                    param_data.setTSRZXQ(tsrzxq);
                    param_data.setQTSMJY(qtsmjy);
                    param_data.setGYS1(gys1);
                    param_data.setGYS2(gys2);
                    param_data.setGYS3(gys3);
                    param_data.setGYS4(gys4);
                    param_data.setGYS5(gys5);
                    param_data.setGYS6(gys6);
                    try {
                        logger_7ab25493.error(String.valueOf("主表开始强制转换 "));
                        param_data.setSBGZTZ(Double.parseDouble(sbgztz));
                        param_data.setCLTZ(Double.parseDouble(cltz));
                        param_data.setRGTZ(Double.parseDouble(rgtz));
                        param_data.setSDTZ(Double.parseDouble(sdtz));
                        param_data.setQTTZ(Double.parseDouble(qttz));
                        param_data.setHJZTZ(Double.parseDouble(hjztz));
                        logger_7ab25493.error(String.valueOf("强制转换报错   "));
                    } catch (NumberFormatException e) {
                        System.err.println(e.toString());
                        logger_7ab25493.error(String.valueOf("主表强制转换报错 " + e.toString()));
                    }
                } catch (NumberFormatException e) {
                    System.err.println(e.toString());
                    logger_7ab25493.error(String.valueOf("主表强制转换传值报错 " + e.toString()));
                }
                try {
                    // 封装信息
                    param_data.setITEMSA(arrayItems);
                    param_data.setITEMSB(arrayItems2);
                    param_data.setITEMSC(arrayItems1);
                    param_datas.addOA_XCLRZZJBGLC_HEADER_TYPE(param_data);
                    resultin.setITFID("IFTIF001");
                    resultin.setWERKS("A000");
                    resultin.setDATAS(param_datas);
                } catch (NumberFormatException e) {
                    System.err.println(e.toString());
                    logger_7ab25493.error(String.valueOf("封装报错 " + e.toString()));
                }
                logger_7ab25493.error(String.valueOf("调用接口开始0 "));
                logger_7ab25493.error(String.valueOf("调用接口完成RequestId--" + requestId + "--项目责任人--" + xmzrr + "--流程编号--" + lcbh + "项目申请人" + xmsqr + "--申请部门-" + sqbm));
                String sta = "";
                String meg = "";
                CallMesNewMaterialCertificationService mes = new CallMesNewMaterialCertificationService();
                // 修改过
                mes.setOainput(resultin);
                String[] rtInfo = mes.call();
                logger_7ab25493.error(String.valueOf("调用接口完成RequestId--" + rtInfo[0] + "--Istat--" + rtInfo[1] + "--Srmsage--" + rtInfo[2]));
                sta = rtInfo[1];
                meg = rtInfo[2].replace("'", "’");
                String tablename = "";
                String wfid = request.getWorkflowid();
//                tablename = unit.getTablename(wfid);
                tablename = request.getRequestManager().getBillTableName();
                String logsql = "update e10_core_business.dbo." + tablename + " set sta ='" + sta + "', meg = '" + meg + "' where id = " + requestId;
                logger_7ab25493.error(String.valueOf("logsql:" + logsql));
                RecordSet rs = I18nContextUtil.getBean(RecordSet.class);
                String poolname = CONN_TYPE.workflow.getType();
                // TODO E10执行sql方法第二参数必须指定源，默认使用流程源，单体客户无需修改，微服务/组合客户需根据查询表所属服务切换源，或使用外部数据源
                boolean b = rs.executeSql(logsql, poolname);
                logger_7ab25493.error("b--"+b);
                logger_7ab25493.error(String.valueOf("CallMesNewMaterialCertificationAction-Request: " + requestId + "完成"));
                if (!sta.equals("S")) {
                    request.getRequestManager().setMessageid("100001");
                    request.getRequestManager().setMessagecontent(meg);
                    return  WeaResult.fail(500, "OaMesNewMaterialCertificationAction meg"+ meg, getResultMapForAction(weaverResultMap, "result",meg, request.getRequestManager()));

                }
                System.out.println(meg);
            } catch (Exception e) {
                System.err.println(e.toString());
                logger_7ab25493.error(String.valueOf("调用接口报错 " + e.toString()));
                return  WeaResult.fail(500, "OaMesNewMaterialCertificationAction err"+ e, getResultMapForAction(weaverResultMap, "result",e.getMessage(), request.getRequestManager()));

            }
            return WeaResult.success(getResultMapForAction(weaverResultMap, "result", Action.SUCCESS, request.getRequestManager()));
        } catch (Exception e) {
            e.printStackTrace();
            logger_7ab25493.error("OaMesNewMaterialCertificationAction e: {}", e.getMessage());
            return  WeaResult.fail(500, "OaMesNewMaterialCertificationAction e: {}"+ e, getResultMapForAction(weaverResultMap, "result",e.getMessage(), 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;
    }
}
