package com.trs.web2frame.tool.tyjyh.tonglaozheng;
import com.alibaba.fastjson.JSON;
import com.trs.cms.CMSConstants;
import com.trs.web2frame.WCMServiceCaller;
import com.trs.web2frame.dispatch.Dispatch;
import com.trs.web2frame.tool.tyjyh.Log_Exception;
import net.sf.json.JSONObject;
import org.jsoup.Jsoup;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
/**
 * 视图类
 */
public class ViewMove {

    public static void main(String[] args) {
        ViewMove viewMove = new ViewMove();
        viewMove.getMoveViewList("");
    }
    /**
     * 获取栏目信息关系表
     * @param siteName
     */
    public void getMoveViewList(String siteName){
        ServiceImplKp serviceImplKp=new ServiceImplKp();
        List<Map<String, String>> maps = serviceImplKp.GetMoveViewList(siteName);
        for (Map<String,String> map : maps) {
            String kaipuid = map.get("kaipuid");
            String hycloud_id = map.get("hycloud_id");
            String view = map.get("view");
            if(view.equals("1")){
                if(kaipuid != "" && kaipuid != null && hycloud_id != "" && hycloud_id != null){
                    DataZhiXunByChannel(kaipuid,hycloud_id);
                }
            }
            if(view.equals("2")){
                if(kaipuid != "" && kaipuid != null && hycloud_id != "" && hycloud_id != null){
                    DataZWGKByChannel(kaipuid,hycloud_id);
                }
            }
            if(view.equals("3")){
                if(kaipuid != "" && kaipuid != null && hycloud_id != "" && hycloud_id != null){
                    DataZFGBByChannel(kaipuid,hycloud_id);
                }
            }
            if(view.equals("4")){
                if(kaipuid != "" && kaipuid != null && hycloud_id != "" && hycloud_id != null){
                    DataZFGBBQZByChannel(kaipuid,hycloud_id);
                }
            }
        }
    }
    /**
     * 资讯视图
     * @param kpChannelId
     * @param hyChannelId
     */
    public void DataZhiXunByChannel(String kpChannelId,String hyChannelId){
        String sServiceId = "gov_webdocument";
        String sMethodName = "saveDocumentInWeb";//自定义视图
        ServiceImplKp serviceImplKp=new ServiceImplKp();
        Annex annex = new Annex();
        try {
            List<Map<String,String>> allDocInfoFromKPDBdMaps = serviceImplKp.GetAllDocInfoFromKPDB(kpChannelId);
            try {
                List<Map<String, String>> maps = DataZhiXunByChannelGetAllDoc(kpChannelId);
                if(maps != null){
                    allDocInfoFromKPDBdMaps.addAll(maps);
                }
            }catch (Exception e){
                e.printStackTrace();
            }
            try {
                allDocInfoFromKPDBdMaps.sort(Comparator.comparing(map -> map.getOrDefault("seqNum", "")));
                Collections.reverse(allDocInfoFromKPDBdMaps);
            }catch (Exception e){
                e.printStackTrace();
            }
            if(allDocInfoFromKPDBdMaps!=null){
                //对map进行排序
                for (Map<String,String> map : allDocInfoFromKPDBdMaps) {
                    System.out.println("------------------------------------------------------------");
                    System.out.println(map);
                    Map<String,Object> oPostData=new HashMap<>();
                    oPostData.put("ObjectId", 0);
                    oPostData.put("ChannelId", Integer.parseInt(hyChannelId));// 目标栏目id
                    oPostData.put("CurrUserName", "dev");
                    oPostData.put("isShenhe", "1");
                    oPostData.put("DOCTYPE", CMSConstants.CONTENT_BODY_HTML);
                    DocumentData documentData = new DocumentData(map);
                    System.out.println(documentData);
                    String manuscriptIdOldDocId = documentData.getManuscriptId();
                    if(manuscriptIdOldDocId != null && manuscriptIdOldDocId != ""){
                        //查询海云的docid
                        String ObjectId = serviceImplKp.GetWcmMetaTableGovDocNewsMetaDataIdByOldDocId(manuscriptIdOldDocId,hyChannelId);
                        if(ObjectId != null && ObjectId != ""){
                            oPostData.put("ObjectId", ObjectId);
                        }
                    }
                    //标题-必填
                    if (documentData.getTitle() != null && documentData.getTitle() != "null") {
                        oPostData.put("DOCTITLE", Jsoup.parse(documentData.getTitle()).text()  );
                    }
                    //副标题
                    if (documentData.getSubTitle() != null && documentData.getSubTitle() != "null") {
                        oPostData.put("SUBDOCTITLE",Jsoup.parse(documentData.getSubTitle()).text() );
                    }
                    //短标题
                    if (documentData.getShortTitle() != null && documentData.getShortTitle() != "null") {
                        oPostData.put("SHORTTITLE",Jsoup.parse(documentData.getShortTitle()).text());
                    }
                    //关键词
                    if (documentData.getKEYWORD() != null  && documentData.getKEYWORD() != "") {
                        String keyword = documentData.getKEYWORD();
                        keyword = keyword.replaceAll("<br/>", "");//
                        keyword = keyword.replaceAll("<br>", "");//
                        oPostData.put("DOCKEYWORDS", keyword);
                    }
                    //发布时间
                    if (documentData.getPublishedTime() != null) {
                        oPostData.put("DOCRELTIME", documentData.getPublishedTime());
                    }
                    //创建时间
                    if (documentData.getCREATED_TIME() != null) {
                        oPostData.put("CRTIME", documentData.getCREATED_TIME());
                    }
                    //来源
                    if (documentData.getB_source() != null && documentData.getB_source() != "") {
                        oPostData.put("DOCSOURCENAME",documentData.getB_source());
                    }
                    //摘要
                    if (documentData.getMemo() != null && documentData.getMemo() != "") {
                        oPostData.put("DOCABSTRACT", documentData.getMemo());
                    }
                    if (documentData.getManuscriptId() != null) {
                        oPostData.put("oldDocid", documentData.getManuscriptId());
                    }
                    //处理附件
                    try {
                        if (documentData.getManuscriptId() != null) {
                            Map<String, Object> getRelFileInfoByDocId = annex.getZhiXunFileInfoByDocId(documentData.getManuscriptId());
                            if( getRelFileInfoByDocId.get("docRelFile") != null){
                                oPostData.put("docRelFile", getRelFileInfoByDocId.get("docRelFile"));
                            }
                            if( getRelFileInfoByDocId.get("docRelPic") != null){
                                oPostData.put("docRelPic", getRelFileInfoByDocId.get("docRelPic"));
                            }
                        }
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                    try {
                        // 内容中图片和附件需要特殊处理
                        if (documentData.getCurrentFilePathHtmlUrl()  != null) {
                            String  currentFilePathHtmlUrl = documentData.getCurrentFilePathHtmlUrl();
                            JsoupUtilsView jsoupUtils = new JsoupUtilsView();
                            String html = jsoupUtils.rexStringHtml(currentFilePathHtmlUrl);
                            oPostData.put("DOCHTMLCON", html);
                        } else {
                            oPostData.put("DocHtmlCon", "&nbsp;");
                            oPostData.put("DOCCONTENT", "&nbsp;");
                        }
                    }catch (Exception e){
                        oPostData.put("DocHtmlCon", "&nbsp;");
                        oPostData.put("DOCCONTENT", "&nbsp;");
                        e.printStackTrace();
                    }
                    //查询是否有重定向链接，如果有调用链接视图
                    if (documentData.getREDIRECT_URL() != null && documentData.getREDIRECT_URL() != "") {
                        oPostData.put("DOCTYPE", CMSConstants.CONTENT_BODY_LINK);
                        oPostData.put("DOCLINK", documentData.getREDIRECT_URL());
                    }
                    try {
                        Dispatch result = WCMServiceCaller.Call(sServiceId, sMethodName, oPostData, true);
                        if(result!=null){
                            JSONObject rObject = JSONObject.fromObject(result.getResponseText().toString());
                            if (rObject.get("ISSUCCESS").toString().equals("true")){
                            }else{
                                String serror = JSON.toJSONString(rObject);
                            }
                        }
                    }catch(Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            Log_Exception.Error_txt("DataZhiXunByChannel error"+e.getMessage());
        }
    }
    /**
     * 	政务公开
     * @param kpChannelId
     * @param hyChannelId
     */
    public void DataZWGKByChannel(String kpChannelId,String hyChannelId){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Log_Exception.Logger_txt("-------Start-------kpChannelId:" + kpChannelId + "--hyChannelId:" + hyChannelId + "---------Start--------");
        String sServiceId = "gov_webdocument";
        String sMethodName = "saveDocumentInOpenData";//自定义视图
        ServiceImplKp serviceImplKp=new ServiceImplKp();
        Annex annex = new Annex();
        try {
            List<Map<String,String>> allDocInfoFromKPDBdMaps = serviceImplKp.GetAllDocInfoFromKPDB(kpChannelId);
            try {
                List<Map<String, String>> maps = DataZhiXunByChannelGetAllDoc(kpChannelId);
                if(maps != null){
                    allDocInfoFromKPDBdMaps.addAll(maps);
                }
            }catch (Exception e){
                e.printStackTrace();
            }
            try {
                allDocInfoFromKPDBdMaps.sort(Comparator.comparing(map -> map.getOrDefault("seqNum", "")));
                Collections.reverse(allDocInfoFromKPDBdMaps);
            }catch (Exception e){
                e.printStackTrace();
            }
            if(allDocInfoFromKPDBdMaps!=null){
                int count=0;
                for (Map<String,String> map : allDocInfoFromKPDBdMaps) {
                    System.out.println("----------------------------"+map+"--------------------------------");
                    Map<String,Object> oPostData=new HashMap<>();
                    oPostData.put("ObjectId", 0);
                    oPostData.put("ChannelId", Integer.parseInt(hyChannelId));// 目标栏目id
                    oPostData.put("CurrUserName", "dev");
                    oPostData.put("isShenhe", "1");
                    oPostData.put("DOCTYPE",CMSConstants.CONTENT_BODY_HTML);
                    DocumentData documentData = new DocumentData(map);
                    System.out.println(documentData);
                    //标题-必填
                    if (documentData.getTitle() != null) {
                        oPostData.put("title",Jsoup.parse(documentData.getTitle()).text() );
                    }
                    // 内容
                    try {
                        // 内容中图片和附件需要特殊处理
                        if (documentData.getCurrentFilePathHtmlUrl() != null) {
                            String  currentFilePathHtmlUrl = documentData.getCurrentFilePathHtmlUrl();
                            JsoupUtilsView jsoupUtils = new JsoupUtilsView();
                            String html = jsoupUtils.rexStringHtml(currentFilePathHtmlUrl);
                            oPostData.put("UEDITOR", html);
                        } else {
                            oPostData.put("UEDITOR", "&nbsp;");
                        }
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                    //发文字号
                    if (documentData.getC_WJBH() != null) {
                        oPostData.put("docno",documentData.getC_WJBH());
                    }
                    //创建时间
                    if (documentData.getC_FWRQ() != null) {
                        try {
                            Date date1 = new Date(Long.parseLong(documentData.getC_FWRQ()));
                            try {
                                LocalDateTime localDateTime = date1.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
                                LocalDateTime after8Hours = localDateTime.plusHours(8);
                                date1 = Date.from(after8Hours.atZone(ZoneId.systemDefault()).toInstant());
                            }catch (Exception e){
                                e.printStackTrace();
                            }
                            oPostData.put("scrq",simpleDateFormat.format(date1));
                        }catch (Exception e){
                            e.printStackTrace();
                        }
                    }
                    //发布时间
                    if (documentData.getPublishedTime() != null) {
                        Date parse = simpleDateFormat.parse(documentData.getPublishedTime());
                        oPostData.put("DocRelTime", simpleDateFormat.format(parse));
                    }
                    //关键词
                    if (documentData.getKEYWORD() != null) {
                        String keyword = documentData.getKEYWORD();
                        keyword = keyword.replaceAll("<br/>", "");//
                        keyword = keyword.replaceAll("<br>", "");//
                        oPostData.put("DOCKEYWORDS", keyword);
                    }
                    //摘要
                    if (documentData.getMemo() != null) {
                        try {
                            oPostData.put("DOCABSTRACT","");
                        }catch (Exception e){
                            oPostData.put("DOCABSTRACT",documentData.getMemo());
                        }
                    }
                    //旧索引号
                    if (documentData.getC_SYH() != null) {
                        oPostData.put("oldidxid",documentData.getC_SYH());
                    }
                    //来源
                    if (documentData.getB_source() != null) {
                        oPostData.put("SOURCE", documentData.getB_source());
                    }
                    //首页标题
                    if (documentData.getShortTitle() != null) {
                        oPostData.put("SHORTTITLE",Jsoup.parse(documentData.getTitle()).text());
                    }
                    //副标题
                    if (documentData.getSubTitle() != null) {
                        oPostData.put("SUB_TITLE",Jsoup.parse(documentData.getSubTitle()).text());
                    }
                    //公文时效
                    if (documentData.getC_GKSX() != null && documentData.getC_GKSX() != "") {
                        oPostData.put("validity",documentData.getC_GKSX());
                    }
                    //机构分类
                    if (documentData.getC_FBJG()  != null) {
                        String jg = documentData.getC_FBJG();
                        if(jg != null && jg != ""){
                            //查询开普对应发布机构名称的海运的发布机构id
                            String kyid = serviceImplKp.GetKpFPJG(jg);
                            System.out.println("=====kyid======"+kyid);
                            if(kyid != "" && kyid != null){
                                oPostData.put("custcat",kyid);
                            }
                        }else{
                            oPostData.put("old_publish",documentData.getC_FBJG());
                        }
                    }
                    //主题分类
                    if (documentData.getC_FBJG()  != null) {
                        oPostData.put("ztword",documentData.getC_ZTC());
                    }
                    //处理附件
                    try {
                        if (documentData.getManuscriptId() != null) {
                            Map<String, Object> zfggFileInfoByDocId = annex.getZWGKFileInfoByDocId(documentData.getManuscriptId());
                            if(zfggFileInfoByDocId.get("qzbword") != null){
                                oPostData.put("qzbword", zfggFileInfoByDocId.get("qzbword"));
                            }
                            if(zfggFileInfoByDocId.get("wjyl") != null){
                                oPostData.put("wjyl", zfggFileInfoByDocId.get("wjyl"));
                            }
                        }
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                    //查询是否有重定向链接，如果有调用链接视图
                    if (documentData.getREDIRECT_URL() != null && documentData.getREDIRECT_URL() != "") {
                        oPostData.put("DOCTYPE", CMSConstants.CONTENT_BODY_LINK);
                        oPostData.put("DOCLINK", documentData.getREDIRECT_URL());
                    }
                    try {
                        System.out.println("==============="+oPostData);
                        System.out.println("==============="+sMethodName);
                        Dispatch result = WCMServiceCaller.Call(sServiceId, sMethodName, oPostData, true);
                        count++;
                        if(result!=null){
                            JSONObject rObject = JSONObject.fromObject(result.getResponseText().toString());
                        }
                    }catch(Exception e) {
                        e.printStackTrace();
                    }
                }

            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 	政府公报
     * @param kpChannelId
     * @param hyChannelId
     */
    public void DataZFGBByChannel(String kpChannelId,String hyChannelId){
        Log_Exception.Logger_txt("-------Start-------kpChannelId:" + kpChannelId + "--hyChannelId:" + hyChannelId + "---------Start--------");
        String sServiceId = "gov_webdocument";
        String sMethodName = "saveDocumentInOpenData";//自定义视图
        ServiceImplKp serviceImplKp=new ServiceImplKp();
        Annex annex = new Annex();
        try {
            List<Map<String,String>> allDocInfoFromKPDBdMaps = serviceImplKp.GetAllDocInfoFromKPDB(kpChannelId);
            try {
                List<Map<String, String>> maps = DataZhiXunByChannelGetAllDoc(kpChannelId);
                if(maps != null){
                    allDocInfoFromKPDBdMaps.addAll(maps);
                }
            }catch (Exception e){
                e.printStackTrace();
            }
            try {
                allDocInfoFromKPDBdMaps.sort(Comparator.comparing(map -> map.getOrDefault("seqNum", "")));
                Collections.reverse(allDocInfoFromKPDBdMaps);
            }catch (Exception e){
                e.printStackTrace();
            }
            System.out.println(allDocInfoFromKPDBdMaps);
            if(allDocInfoFromKPDBdMaps!=null){
                int count=0;
                for (Map<String,String> map : allDocInfoFromKPDBdMaps) {
                    Map<String,Object> oPostData=new HashMap<>();
                    oPostData.put("ObjectId", 0);
                    oPostData.put("ChannelId", Integer.parseInt(hyChannelId));// 目标栏目id
                    oPostData.put("CurrUserName", "dev");
                    oPostData.put("DOCTYPE",CMSConstants.CONTENT_BODY_HTML);
                    DocumentData documentData = new DocumentData(map);
                    oPostData.put("isShenhe", "1");
                    //标题-必填
                    if (documentData.getTitle() != null) {
                        oPostData.put("gbbt", Jsoup.parse(documentData.getTitle()).text());
                    }
                    try {
                        // 内容中图片和附件需要特殊处理
                        if (documentData.getCurrentFilePathHtmlUrl() != null) {
                            String  currentFilePathHtmlUrl = documentData.getCurrentFilePathHtmlUrl();
                            JsoupUtils jsoupUtils = new JsoupUtils();
                            String html = jsoupUtils.rexStringHtml(currentFilePathHtmlUrl);
                            oPostData.put("nrzw", html);
                        } else {
                            oPostData.put("nrzw", "&nbsp;");
                        }
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                    if (documentData.getC_FBJG() != null) {
                        oPostData.put("fwdw", documentData.getC_FBJG());
                    }
                    if (documentData.getPublishedTime()  != null ) {
                        oPostData.put("fbsj", documentData.getPublishedTime());
                    }
                    //关键词
                    if (documentData.getKEYWORD() != null) {
                        String keyword = documentData.getKEYWORD();
                        keyword = keyword.replaceAll("<br/>", "");//
                        keyword = keyword.replaceAll("<br>", "");//
                        oPostData.put("gjc", keyword);
                    }
                    //摘要
                    if (documentData.getMemo() != null) {
                        oPostData.put("DOCABSTRACT", documentData.getMemo());
                    }
                    //旧索引号
                    if (documentData.getC_SYH() != null) {
                        oPostData.put("zy", documentData.getC_SYH());
                    }

                    //副标题
                    if (documentData.getSubTitle() != null) {
                        oPostData.put("fbt",Jsoup.parse(documentData.getSubTitle()).text());
                    }
                    //处理附件
                    try {
                        if (documentData.getManuscriptId() != null) {
                            Map<String, Object> getRelFileInfoByDocId = annex.getZFGGFileInfoByDocId(documentData.getManuscriptId());
                            if( getRelFileInfoByDocId.get("GBFL") != null){
                                oPostData.put("GBFL", getRelFileInfoByDocId.get("GBFL"));
                            }
                        }
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                    //查询是否有重定向链接，如果有调用链接视图
                    if (documentData.getREDIRECT_URL() != null && documentData.getREDIRECT_URL() != "") {
                        oPostData.put("DOCTYPE", CMSConstants.CONTENT_BODY_LINK);
                        oPostData.put("DOCLINK", documentData.getREDIRECT_URL());
                    }
                    try {
                        System.out.println(oPostData);
                        System.out.println(sMethodName);
                        Dispatch result = WCMServiceCaller.Call(sServiceId, sMethodName, oPostData, true);
                        count++;
                        if(result!=null){
                            JSONObject rObject = JSONObject.fromObject(result.getResponseText().toString());
                            if (rObject.get("ISSUCCESS").toString().equals("true")){
                                System.out.println("DOCTITLE:"+documentData.getTitle());
                                System.out.println("count:"+count);
                                System.out.println("oldDocid:"+documentData.getManuscriptId());

                            }else{
                                String serror = JSON.toJSONString(rObject);
                                System.out.println(serror);
                            }
                        }
                    }catch(Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            Log_Exception.Error_txt("DataExchangeByChannel error"+e.getMessage());
        } finally {

        }
    }
    /**
     * 	政府公报全真版
     * @param kpChannelId
     * @param hyChannelId
     */
    public void DataZFGBBQZByChannel(String kpChannelId,String hyChannelId){
        Log_Exception.Logger_txt("-------Start-------kpChannelId:" + kpChannelId + "--hyChannelId:" + hyChannelId + "---------Start--------");
        String sServiceId = "gov_webdocument";
        String sMethodName = "saveDocumentInOpenData";//自定义视图
        ServiceImplKp serviceImplKp=new ServiceImplKp();
        Annex annex = new Annex();
        try {
            List<Map<String,String>> allDocInfoFromKPDBdMaps = serviceImplKp.GetAllDocInfoFromKPDB(kpChannelId);
            try {
                List<Map<String, String>> maps = DataZhiXunByChannelGetAllDoc(kpChannelId);
                if(maps != null){
                    allDocInfoFromKPDBdMaps.addAll(maps);
                }
            }catch (Exception e){
                e.printStackTrace();
            }
            try {
                allDocInfoFromKPDBdMaps.sort(Comparator.comparing(map -> map.getOrDefault("seqNum", "")));
                Collections.reverse(allDocInfoFromKPDBdMaps);
            }catch (Exception e){
                e.printStackTrace();
            }
            System.out.println(allDocInfoFromKPDBdMaps);
            if(allDocInfoFromKPDBdMaps!=null){
                int count=0;
                for (Map<String,String> map : allDocInfoFromKPDBdMaps) {
                    Map<String,Object> oPostData=new HashMap<>();
                    oPostData.put("ObjectId", 0);
                    oPostData.put("ChannelId", Integer.parseInt(hyChannelId));// 目标栏目id
                    oPostData.put("CurrUserName", "dev");
                    oPostData.put("DOCTYPE",CMSConstants.CONTENT_BODY_HTML);
                    DocumentData documentData = new DocumentData(map);
                    oPostData.put("isShenhe", "1");
                    //标题-必填
                    if (documentData.getTitle() != null) {
                        oPostData.put("title", Jsoup.parse(documentData.getTitle()).text());
                    }
                    //处理附件
                    try {
                        if (documentData.getManuscriptId() != null) {
                            Map<String, Object> getRelFileInfoByDocId = annex.getZFGGQZBFileInfoByDocId(documentData.getManuscriptId());
                            if( getRelFileInfoByDocId.get("qzb") != null){
                                oPostData.put("qzb", getRelFileInfoByDocId.get("qzb"));
                            }
                        }
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                    //查询是否有重定向链接，如果有调用链接视图
                    if (documentData.getREDIRECT_URL() != null && documentData.getREDIRECT_URL() != "") {
                        oPostData.put("DOCTYPE", CMSConstants.CONTENT_BODY_LINK);
                        oPostData.put("DOCLINK", documentData.getREDIRECT_URL());
                    }
                    try {
                        System.out.println(oPostData);
                        Dispatch result = WCMServiceCaller.Call(sServiceId, sMethodName, oPostData, true);
                        count++;
                        if(result!=null){
                            JSONObject rObject = JSONObject.fromObject(result.getResponseText().toString());
                            if (rObject.get("ISSUCCESS").toString().equals("true")){
                                System.out.println("DOCTITLE:"+documentData.getTitle());
                                System.out.println("count:"+count);
                                System.out.println("oldDocid:"+documentData.getManuscriptId());
                            }else{
                                String serror = JSON.toJSONString(rObject);
                                System.out.println(serror);
                            }
                        }
                    }catch(Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            Log_Exception.Error_txt("DataExchangeByChannel error"+e.getMessage());
        } finally {

        }
    }

    public List<Map<String, String>> DataZhiXunByChannelGetAllDoc(String kpChannelId){
        ServiceImplKp serviceImplKp=new ServiceImplKp();
        List<Map<String, String>> mapAllDocs = serviceImplKp.GetAllDocCmsCarbonCopy(kpChannelId);
        List<Map<String, String>> allDocInfoFromKPDBdMapsAllList = new ArrayList<Map<String, String>>();
        for (Map<String, String> mapAllDoc : mapAllDocs) {
            String manuscript_id = mapAllDoc.get("MANUSCRIPT_ID");
            List<Map<String, String>> allDocInfoFromKPDBdMaps = serviceImplKp.GetAllDocInfoFromByMANUSCRIPT_ID(manuscript_id);
            allDocInfoFromKPDBdMapsAllList.addAll(allDocInfoFromKPDBdMaps);
        }
        return allDocInfoFromKPDBdMapsAllList;
    }
}
