package com.trs.web2frame.tool.tyjyh.tonglaozheng;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.listener.PageReadListener;
import com.alibaba.fastjson.JSON;
import com.sun.deploy.util.ArrayUtil;
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 com.trs.web2frame.tool.tyjyh.tongliao.*;
import net.sf.json.JSONObject;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
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.updateMetaViewId();
    }
    public void updateMetaViewId(){

        Map<String,String> h = new HashMap<String,String>();
        h.put("4482","de9acace33964ebdaa8a65dbc09bd1c4");
        h.put("4482","c7dfe173c3bd4b4cb2dc3b29ad444ec4");
        h.put("4482","84fccdf0222545ff86a59449e2dd9ada");
        h.put("4454","53db26fe590e46e2b27cc8b9ddef5aca");
        h.put("4727","019ee296cf48410583425e691186533f");
        h.put("4450","1c577e5ac63a4e4b92f3ef01714af2f1");
        h.put("4450","46b686f488a94431b280adfd1616bf93");
        h.put("4450","05b3c57c6222443a97dad9290260c1a2");
        h.put("4450","ea21930949a1405781b049de5c3315e6");
        h.put("4450","b3499f31006649df8747e3ad94b789a1");
        h.put("4450","6dd77bdd28524656ab6057ff1bd45d31");
        h.put("4450","d2a68d0d69fd42e29c75e6fa784845b6");
        h.put("4450","4b3ab9874b2b412b8f2b0088576f4543");
        h.put("4450","e8153760afc845719199824400cafe54");
        h.put("4450","9ae4d377fb4f4eb59c167e5baf9f3253");
        h.put("4450","c9538a0903e8402d817f6a00f4d6a1f1");
        h.put("4450","39d3bfed37364087b7cf9dc6f9c5d26f");
        h.put("4450","1dca5344145e4edca8a8e3e9f5f1aea3");
        h.put("4456","b54c1a2ded354d63a6ad681bb5fb4f57");
        h.put("4547","8293af23fbe649e885164e410d8f9af2");
        h.put("4781","e1a146a9ada4494297d33e106eb4b2db");
        h.put("4801","c49f9640c6f24dadb5a8d7f5413b461f");
        h.put("4450","6f3a0c5a07e54fbe94f5705203e0ea63");
        h.put("4450","f4a261bae64f402b929bdad40c9f4e92");
        h.put("11935","a23e679aebdd41979154603b2bfdb4e6");
        h.put("11948","019ee296cf48410583425e691186533f");
        h.put("11951","25ef2556a30f4e94a499890e6a537d68");
        h.put("11954","c734ac2c4e4e44128497bca49e110ac1");
        h.put("4492","f82d42d07f0a48caacce27c044cf118a");
        h.put("4535","fd6f3ef0101c439a99ef997caf20ebf5");
        h.put("4537","8bcde314f0714919a52f8e544bb2c42e");
        h.put("4538","2812fdbfccd647e29140dcd6285d545d");
        h.put("4714","a23e679aebdd41979154603b2bfdb4e6");
        h.put("4730","25ef2556a30f4e94a499890e6a537d68");
        h.put("4761","50d319078c9448d7b7b0d665768a2843");
        h.put("4774","6d6369ee060c4eab8d62c6be1ebd4805");
        h.put("4455","1c577e5ac63a4e4b92f3ef01714af2f1");
        h.put("4455","46b686f488a94431b280adfd1616bf93");
        h.put("4455","05b3c57c6222443a97dad9290260c1a2");
        h.put("4455","ea21930949a1405781b049de5c3315e6");
        h.put("4455","b3499f31006649df8747e3ad94b789a1");
        h.put("4455","6dd77bdd28524656ab6057ff1bd45d31");
        h.put("4455","d2a68d0d69fd42e29c75e6fa784845b6");
        h.put("4455","4b3ab9874b2b412b8f2b0088576f4543");
        h.put("4455","e8153760afc845719199824400cafe54");
        h.put("4455","9ae4d377fb4f4eb59c167e5baf9f3253");
        h.put("4455","c9538a0903e8402d817f6a00f4d6a1f1");
        h.put("4455","39d3bfed37364087b7cf9dc6f9c5d26f");
        h.put("4455","1dca5344145e4edca8a8e3e9f5f1aea3");
        h.put("4455","6f3a0c5a07e54fbe94f5705203e0ea63");
        h.put("4455","f4a261bae64f402b929bdad40c9f4e92");
        h.put("5367","f49fadba8a0640ba9841b444e27ba76d");
        h.put("5367","754fc0591fd9484e99ea5daeb09f71e0");
        h.put("5367","e0ead815d5a84180b5e880a4f84fec7c");
        h.put("5367","fb79aeae8ba74c0cb4fcd153f5686c6d");
        h.put("5367","0f303ac845074a1fb24a23477c7cd16e");
        h.put("5367","8ba100767a694dbf954cbf836aa90151");
        h.put("5374","82c84aa980a84b16887d9ffc54fdcbed");
        h.put("5374","ce7a827525d743558e33758dd6cb6c04");

        Iterator iter = h.entrySet().iterator();
        while (iter.hasNext()) {
            Map.Entry entry = (Map.Entry) iter.next();
            String key = (String) entry.getKey();
            String val = (String) entry.getValue();
            ViewMove viewMove = new ViewMove();
            viewMove.DataZhiXunByChannelOne(key,val);
        }


    }



    public static void move(){
        ServiceImplKp serviceImplKp=new ServiceImplKp();
        List<Map<String, Object>> maps = serviceImplKp.GetKpMEMOListAll();

        for (Map<String, Object> map : maps) {
            String manuscript_id = map.get("manuscript_id").toString();
            String title = map.get("title").toString();
            String channel_id_kp = map.get("channel_id_kp").toString();
            String channel_name_kp = map.get("channel_name_kp").toString();
            String channel_id_hy = map.get("channel_id_hy").toString();
            String channel_name_hy = map.get("channel_name_hy").toString();
            ViewMove viewMove = new ViewMove();
            if(manuscript_id != null && manuscript_id != ""){
                if(channel_id_hy != null && channel_id_hy != ""){
                    viewMove.DataZhiXunByChannelOne(channel_id_hy,manuscript_id);
                }
            }
        }
    }

    public static void groupBy(){
        ServiceImplKp serviceImplKp=new ServiceImplKp();
        List<Map<String, Object>> maps = serviceImplKp.GetKpMEMOListAll();
        Collections.reverse(maps);
        for (Map<String, Object> map : maps) {
            String manuscript_id = map.get("manuscript_id").toString();
            String title = map.get("title").toString();
            String channel_id_kp = map.get("channel_id_kp").toString();
            String channel_name_kp = map.get("channel_name_kp").toString();
            String channel_id_hy = map.get("channel_id_hy").toString();
            String channel_name_hy = map.get("channel_name_hy").toString();
            ViewMove viewMove = new ViewMove();
            if(manuscript_id != null && manuscript_id != ""){
                if(channel_id_hy != null && channel_id_hy != ""){
                    ServiceImplKp serviceImplKp111111111=new ServiceImplKp();
                    serviceImplKp111111111.orderBy(channel_id_hy);
                }
            }
        }
    }
    /**
     * 资讯视图
     * @param kpChannelId
     * @param hyChannelId
     */
    public void DataZhiXunByChannel(String kpChannelId,String hyChannelId){
        Log_Exception.Logger_txt("-------Start-------kpChannelId:" + kpChannelId + "--hyChannelId:" + hyChannelId + "---------Start--------");
        String sServiceId = "gov_webdocument";
        String sMethodName = "saveDocumentInWeb";//自定义视图
        ServiceImplKp serviceImplKp=new ServiceImplKp();
        Annex annex = new Annex();
        try {
            List<Map<String,Object>> allDocInfoFromKPDBdMaps = serviceImplKp.GetAllDocInfoFromKPDB(kpChannelId);
            if(allDocInfoFromKPDBdMaps!=null){
                int count=0;
                for (Map<String,Object> map : allDocInfoFromKPDBdMaps) {
                    System.out.println("------------------------------------------------------------");
                    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 && documentData.getTitle() != "null") {
                        /*String text = Jsoup.parse(documentData.getTitle()).text();
                        int ff = text.indexOf("发展规划");
                        if(ff >= 0){
                            continue;
                        }*/
                        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();
                            System.out.println("===================start=======================");
                            System.out.println(currentFilePathHtmlUrl);
                            JsoupUtilsView jsoupUtils = new JsoupUtilsView();
                            String html = jsoupUtils.rexStringHtml(currentFilePathHtmlUrl);
                            System.out.println("==============================================");
                            System.out.println(html);
                            System.out.println("===================end========================");
                            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 {
                        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());
                                try {
                                    //处理引用文章
                                    String manuscriptId = documentData.getManuscriptId();
                                    if(manuscriptId != null && manuscriptId != ""){
                                        ColumnMapping columnMapping = new ColumnMapping();
                                        columnMapping.ColumnMappingCheck(manuscriptId);
                                    }
                                }catch (Exception ee){
                                    ee.printStackTrace();
                                }
                            }else{
                                String serror = JSON.toJSONString(rObject);
                                System.out.println(serror);
                                outPrint(serror,documentData.getManuscriptId(),count);
                            }
                        }
                    }catch(Exception e) {
                        outPrint("",documentData.getManuscriptId(),count);
                        e.printStackTrace();
                    }
                    System.out.println("------------------------------------------------------------");
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            Log_Exception.Error_txt("DataZhiXunByChannel error"+e.getMessage());
        } finally {

        }
    }

    public void moveMp4(){
        ServiceImplKp serviceImplKp=new ServiceImplKp();
        List<Map<String,Object>> allDocInfoFromKPDBdMaps = serviceImplKp.GetAllDocInfoFromMp4();
        for (Map<String, Object> allDocInfoFromKPDBdMap : allDocInfoFromKPDBdMaps) {
            String channelID = allDocInfoFromKPDBdMap.get("ChannelID").toString();
            String oldDocid = allDocInfoFromKPDBdMap.get("oldDocid").toString();
            if(channelID != "" && channelID != null){
                ViewMove viewMove = new ViewMove();
                viewMove.DataZhiXunByChannelOneNotUpdate(channelID,oldDocid);
            }

        }

    }


    public void DataZhiXunByChannelOne(String hyChannelId,String manuscriptIdStr){
        Log_Exception.Logger_txt("-------Start-------kpChannelId:" + "--hyChannelId:" + hyChannelId + "---------Start--------");
        String sServiceId = "gov_webdocument";
        String sMethodName = "saveDocumentInWeb";//自定义视图
        ServiceImplKp serviceImplKp=new ServiceImplKp();
        Annex annex = new Annex();
        try {
            List<Map<String,Object>> allDocInfoFromKPDBdMaps = serviceImplKp.GetAllDocInfoFromKPDBOne(manuscriptIdStr);
            if(allDocInfoFromKPDBdMaps!=null){
                int count=0;
                for (Map<String,Object> map : allDocInfoFromKPDBdMaps) {
                    System.out.println("------------------------------------------------------------");
                    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") {
                        /*String text = Jsoup.parse(documentData.getTitle()).text();
                        int ff = text.indexOf("发展规划");
                        if(ff >= 0){
                            continue;
                        }*/
                        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();
                            System.out.println("===================start=======================");
                            System.out.println(currentFilePathHtmlUrl);
                            JsoupUtilsView jsoupUtils = new JsoupUtilsView();
                            String html = jsoupUtils.rexStringHtml(currentFilePathHtmlUrl);
                            System.out.println("==============================================");
                            System.out.println(html);
                            System.out.println("===================end========================");
                            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 {

                        oPostData.put("ISSHENHE", "1");
                        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());
                                try {
                                    //处理引用文章
                                    String manuscriptId = documentData.getManuscriptId();
                                    if(manuscriptId != null && manuscriptId != ""){
                                        ColumnMapping columnMapping = new ColumnMapping();
                                        columnMapping.ColumnMappingCheck(manuscriptId);
                                    }
                                }catch (Exception ee){
                                    ee.printStackTrace();
                                }
                            }else{
                                String serror = JSON.toJSONString(rObject);
                                System.out.println(serror);
                                outPrint(serror,documentData.getManuscriptId(),count);
                            }
                        }
                    }catch(Exception e) {
                        outPrint("",documentData.getManuscriptId(),count);
                        e.printStackTrace();
                    }
                    System.out.println("------------------------------------------------------------");
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            Log_Exception.Error_txt("DataZhiXunByChannel error"+e.getMessage());
        } finally {

        }
    }

    public void DataZhiXunByChannelOneNotUpdate(String hyChannelId,String manuscriptIdStr){
        Log_Exception.Logger_txt("-------Start-------kpChannelId:" + "--hyChannelId:" + hyChannelId + "---------Start--------");
        String sServiceId = "gov_webdocument";
        String sMethodName = "saveDocumentInWeb";//自定义视图
        ServiceImplKp serviceImplKp=new ServiceImplKp();
        Annex annex = new Annex();
        try {
            List<Map<String,Object>> allDocInfoFromKPDBdMaps = serviceImplKp.GetAllDocInfoFromKPDBOne(manuscriptIdStr);
            if(allDocInfoFromKPDBdMaps!=null){
                int count=0;
                for (Map<String,Object> map : allDocInfoFromKPDBdMaps) {
                    System.out.println("------------------------------------------------------------");
                    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") {
                        /*String text = Jsoup.parse(documentData.getTitle()).text();
                        int ff = text.indexOf("发展规划");
                        if(ff >= 0){
                            continue;
                        }*/
                        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();
                            System.out.println("===================start=======================");
                            System.out.println(currentFilePathHtmlUrl);
                            JsoupUtilsView jsoupUtils = new JsoupUtilsView();
                            String html = jsoupUtils.rexStringHtml(currentFilePathHtmlUrl);
                            System.out.println("==============================================");
                            System.out.println(html);
                            System.out.println("===================end========================");
                            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 {
                        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());
                                try {
                                    //处理引用文章
                                    String manuscriptId = documentData.getManuscriptId();
                                    if(manuscriptId != null && manuscriptId != ""){
                                        ColumnMapping columnMapping = new ColumnMapping();
                                        columnMapping.ColumnMappingCheck(manuscriptId);
                                    }
                                }catch (Exception ee){
                                    ee.printStackTrace();
                                }
                            }else{
                                String serror = JSON.toJSONString(rObject);
                                System.out.println(serror);
                                outPrint(serror,documentData.getManuscriptId(),count);
                            }
                        }
                    }catch(Exception e) {
                        outPrint("",documentData.getManuscriptId(),count);
                        e.printStackTrace();
                    }
                    System.out.println("------------------------------------------------------------");
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            Log_Exception.Error_txt("DataZhiXunByChannel error"+e.getMessage());
        } finally {

        }
    }
    /**
     * 资讯视图 - 抄送栏目数据迁移
     * @param kpChannelId
     * @param hyChannelId
     */
    public void DataZhiXunByChannelGetAllDoc(String kpChannelId,String hyChannelId){
        Log_Exception.Logger_txt("-------Start-------kpChannelId:" + kpChannelId + "--hyChannelId:" + hyChannelId + "---------Start--------");
        String sServiceId = "gov_webdocument";
        String sMethodName = "saveDocumentInWeb";//自定义视图
        ServiceImplKp serviceImplKp=new ServiceImplKp();
        Annex annex = new Annex();
        List<Map<String, String>> mapAllDocs = serviceImplKp.GetAllDocCmsCarbonCopy(kpChannelId);
        for (Map<String, String> mapAllDoc : mapAllDocs) {
            String manuscript_id = mapAllDoc.get("MANUSCRIPT_ID");
            List<Map<String, Object>> allDocInfoFromKPDBdMaps = serviceImplKp.GetAllDocInfoFromByMANUSCRIPT_ID(manuscript_id);
            System.out.println(allDocInfoFromKPDBdMaps);
            if(allDocInfoFromKPDBdMaps!=null){
                int count=0;
                for (Map<String,Object> map : allDocInfoFromKPDBdMaps) {
                    System.out.println("------------------------------------------------------------");
                    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 && 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();
                            System.out.println("===================start=======================");
                            System.out.println(currentFilePathHtmlUrl);
                            JsoupUtilsView jsoupUtils = new JsoupUtilsView();
                            String html = jsoupUtils.rexStringHtml(currentFilePathHtmlUrl);
                            System.out.println("==============================================");
                            System.out.println(html);
                            System.out.println("===================end========================");
                            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 {
                        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());
                                try {
                                    //处理引用文章
                                    String manuscriptId = documentData.getManuscriptId();
                                    if(manuscriptId != null && manuscriptId != ""){
                                        ColumnMapping columnMapping = new ColumnMapping();
                                        columnMapping.ColumnMappingCheck(manuscriptId);
                                    }
                                }catch (Exception ee){
                                    ee.printStackTrace();
                                }
                            }else{
                                String serror = JSON.toJSONString(rObject);
                                System.out.println(serror);
                                outPrint(serror,documentData.getManuscriptId(),count);
                            }
                        }
                    }catch(Exception e) {
                        outPrint("",documentData.getManuscriptId(),count);
                        e.printStackTrace();
                    }
                    System.out.println("------------------------------------------------------------");
                }
            }

        }


    }

    public void DataZhiXunByChannelGetAllDocUpdate(String kpChannelId,String hyChannelId){
        Log_Exception.Logger_txt("-------Start-------kpChannelId:" + kpChannelId + "--hyChannelId:" + hyChannelId + "---------Start--------");
        String sServiceId = "gov_webdocument";
        String sMethodName = "saveDocumentInWeb";//自定义视图
        ServiceImplKp serviceImplKp=new ServiceImplKp();
        Annex annex = new Annex();
        List<Map<String, String>> mapAllDocs = serviceImplKp.GetAllDocCmsCarbonCopy(kpChannelId);
        for (Map<String, String> mapAllDoc : mapAllDocs) {
            String manuscript_id = mapAllDoc.get("MANUSCRIPT_ID");
            List<Map<String, Object>> allDocInfoFromKPDBdMaps = serviceImplKp.GetAllDocInfoFromByMANUSCRIPT_ID(manuscript_id);
            System.out.println(allDocInfoFromKPDBdMaps);
            if(allDocInfoFromKPDBdMaps!=null){
                int count=0;
                for (Map<String,Object> map : allDocInfoFromKPDBdMaps) {
                    System.out.println("------------------------------------------------------------");
                    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);
                    String manuscriptIdOldDocId = documentData.getManuscriptId();
                    if(manuscriptIdOldDocId != null && manuscriptIdOldDocId != ""){
                        //查询海云的docid
                        String ObjectId = serviceImplKp.GetWcmMetaTableGovDocNewsMetaDataIdByOldDocId(manuscriptIdOldDocId,hyChannelId);
                        if(ObjectId != null && ObjectId != ""){
                            oPostData.put("ObjectId", ObjectId);
                            continue;
                        }
                    }
                    System.out.println(documentData);
                    System.out.println(documentData);
                    //标题-必填
                    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();
                            System.out.println("===================start=======================");
                            System.out.println(currentFilePathHtmlUrl);
                            JsoupUtilsView jsoupUtils = new JsoupUtilsView();
                            String html = jsoupUtils.rexStringHtml(currentFilePathHtmlUrl);
                            System.out.println("==============================================");
                            System.out.println(html);
                            System.out.println("===================end========================");
                            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 {
                        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());
                                try {
                                    //处理引用文章
                                    String manuscriptId = documentData.getManuscriptId();
                                    if(manuscriptId != null && manuscriptId != ""){
                                        ColumnMapping columnMapping = new ColumnMapping();
                                        columnMapping.ColumnMappingCheck(manuscriptId);
                                    }
                                }catch (Exception ee){
                                    ee.printStackTrace();
                                }
                            }else{
                                String serror = JSON.toJSONString(rObject);
                                System.out.println(serror);
                                outPrint(serror,documentData.getManuscriptId(),count);
                            }
                        }
                    }catch(Exception e) {
                        outPrint("",documentData.getManuscriptId(),count);
                        e.printStackTrace();
                    }
                    System.out.println("------------------------------------------------------------");
                }
            }

        }
        //对hyChannelId的内容进行排序
        serviceImplKp.orderBy(hyChannelId);
    }
    /**
     * 资讯视图 - 多栏目数据迁移
     * @param kpChannelIdList,hyChannelId
     * @param hyChannelId
     */
    public void DataZhiXunByChannelGetAllDocAll(String []kpChannelIdList,String hyChannelId){
        Log_Exception.Logger_txt("-------Start-------kpChannelId:" + kpChannelIdList + "--hyChannelId:" + hyChannelId + "---------Start--------");
        String sServiceId = "gov_webdocument";
        String sMethodName = "saveDocumentInWeb";//自定义视图
        ServiceImplKp serviceImplKp=new ServiceImplKp();
        Annex annex = new Annex();
        List<Map<String, String>> allDocInfoFromKPDBdMaps = serviceImplKp.GetAllDocCmsCarbonCopyAll(kpChannelIdList);
        if(allDocInfoFromKPDBdMaps!=null){
            int count=0;
            for (Map<String,String> map : allDocInfoFromKPDBdMaps) {
                System.out.println("------------------------------------------------------------");
                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);
                DocumentDataStr documentData = new DocumentDataStr(map);
                System.out.println(documentData);
                //标题-必填
                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();
                        System.out.println("===================start=======================");
                        System.out.println(currentFilePathHtmlUrl);
                        JsoupUtilsView jsoupUtils = new JsoupUtilsView();
                        String html = jsoupUtils.rexStringHtml(currentFilePathHtmlUrl);
                        System.out.println("==============================================");
                        System.out.println(html);
                        System.out.println("===================end========================");
                        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() != "") {
                   /* System.out.println(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());
                            try {
                                //处理引用文章
                                String manuscriptId = documentData.getManuscriptId();
                                if(manuscriptId != null && manuscriptId != ""){
                                    ColumnMapping columnMapping = new ColumnMapping();
                                    columnMapping.ColumnMappingCheck(manuscriptId);
                                }
                            }catch (Exception ee){
                                ee.printStackTrace();
                            }
                        }else{
                            String serror = JSON.toJSONString(rObject);
                            System.out.println(serror);
                            outPrint(serror,documentData.getManuscriptId(),count);
                        }
                    }
                }catch(Exception e) {
                    outPrint("",documentData.getManuscriptId(),count);
                    e.printStackTrace();
                }
                System.out.println("------------------------------------------------------------");
            }
        }


    }
    /**
     * 资讯视图 - 增量数据迁移
     * 开普系统的文档id 对应 海运系统当中的 oldDocid 去海云里面查询对应的文档对应的docid，将docid设置到对应的ObjectId即可完成更新
     *
     * @param kpChannelId
     * @param hyChannelId
     */
    public void DataZhiXunByChannelAddOrUpdate(String kpChannelId,String hyChannelId){
        Log_Exception.Logger_txt("-------Start-------kpChannelId:" + kpChannelId + "--hyChannelId:" + hyChannelId + "---------Start--------");
        String sServiceId = "gov_webdocument";
        String sMethodName = "saveDocumentInWeb";//自定义视图
        ServiceImplKp serviceImplKp=new ServiceImplKp();
        Annex annex = new Annex();
        try {
            List<Map<String,Object>> allDocInfoFromKPDBdMaps = serviceImplKp.GetAllDocInfoFromKPDB(kpChannelId);
            if(allDocInfoFromKPDBdMaps!=null){
                int count=0;
                for (Map<String,Object> map : allDocInfoFromKPDBdMaps) {
                    System.out.println("------------------------------------------------------------");
                    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);
                    oPostData.put("isShenhe", "1");
                    DocumentData documentData = new DocumentData(map);
                    String manuscriptIdOldDocId = documentData.getManuscriptId();
                    if(manuscriptIdOldDocId != null && manuscriptIdOldDocId != ""){
                        //查询海云的docid
                        String ObjectId = serviceImplKp.GetWcmMetaTableGovDocNewsMetaDataIdByOldDocId(manuscriptIdOldDocId,hyChannelId);
                        if(ObjectId != null && ObjectId != ""){
                            oPostData.put("ObjectId", ObjectId);
                        }
                    }
                    System.out.println(documentData);
                    //标题-必填
                    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();
                            System.out.println("===================start=======================");
                            System.out.println(currentFilePathHtmlUrl);
                            JsoupUtilsView jsoupUtils = new JsoupUtilsView();
                            String html = jsoupUtils.rexStringHtml(currentFilePathHtmlUrl);
                            System.out.println("==============================================");
                            System.out.println(html);
                            System.out.println("===================end========================");
                            //oPostData.put("DOCHTMLCON", html);
                            oPostData.put("DOCTYPE", CMSConstants.CONTENT_BODY_LINK);
                            oPostData.put("DOCLINK", 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 {
                        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());
                                try {
                                    //处理引用文章
                                    String manuscriptId = documentData.getManuscriptId();
                                    if(manuscriptId != null && manuscriptId != ""){
                                        ColumnMapping columnMapping = new ColumnMapping();
                                        columnMapping.ColumnMappingCheck(manuscriptId);
                                    }
                                }catch (Exception ee){
                                    ee.printStackTrace();
                                }
                            }else{
                                String serror = JSON.toJSONString(rObject);
                                System.out.println(serror);
                                outPrint(serror,documentData.getManuscriptId(),count);

                                try {
                                    oPostData.put("ObjectId", 0);
                                    Dispatch result1 = WCMServiceCaller.Call(sServiceId, sMethodName, oPostData, true);
                                }catch (Exception e1){

                                }
                            }
                        }
                    }catch(Exception e) {
                        outPrint("",documentData.getManuscriptId(),count);
                        e.printStackTrace();
                    }
                    System.out.println("------------------------------------------------------------");
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            Log_Exception.Error_txt("DataZhiXunByChannel error"+e.getMessage());
        } finally {
        }
    }

    /**
     * 资讯视图 - 增量数据迁移
     * 开普系统的文档id 对应 海运系统当中的 oldDocid 去海云里面查询对应的文档对应的docid，将docid设置到对应的ObjectId即可完成更新
     *
     * @param kpChannelId
     * @param hyChannelId
     */
    public void DataZhiXunByChannelAddOrUpdateNoUpdate(String kpChannelId,String hyChannelId){
        Log_Exception.Logger_txt("-------Start-------kpChannelId:" + kpChannelId + "--hyChannelId:" + hyChannelId + "---------Start--------");
        String sServiceId = "gov_webdocument";
        String sMethodName = "saveDocumentInWeb";//自定义视图
        ServiceImplKp serviceImplKp=new ServiceImplKp();
        Annex annex = new Annex();
        try {
            List<Map<String,Object>> allDocInfoFromKPDBdMaps = serviceImplKp.GetAllDocInfoFromKPDB(kpChannelId);
            if(allDocInfoFromKPDBdMaps!=null){
                int count=0;
                for (Map<String,Object> map : allDocInfoFromKPDBdMaps) {
                    System.out.println("------------------------------------------------------------");
                    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);
                    oPostData.put("isShenhe", "1");
                    DocumentData documentData = new DocumentData(map);
                    String manuscriptIdOldDocId = documentData.getManuscriptId();
                    if(manuscriptIdOldDocId != null && manuscriptIdOldDocId != ""){
                        //查询海云的docid
                        String ObjectId = serviceImplKp.GetWcmMetaTableGovDocNewsMetaDataIdByOldDocId(manuscriptIdOldDocId,hyChannelId);
                        System.out.println(ObjectId);
                        if(ObjectId != null && ObjectId != ""){
                            oPostData.put("ObjectId", ObjectId);
                            continue;
                        }
                    }
                    System.out.println(documentData);
                    //标题-必填
                    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();
                            System.out.println("===================start=======================");
                            System.out.println(currentFilePathHtmlUrl);
                            JsoupUtilsView jsoupUtils = new JsoupUtilsView();
                            String html = jsoupUtils.rexStringHtml(currentFilePathHtmlUrl);
                            System.out.println("==============================================");
                            System.out.println(html);
                            System.out.println("===================end========================");
                            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 {
                        oPostData.put("isShenhe", "1");
                        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());
                                try {
                                    //处理引用文章
                                    String manuscriptId = documentData.getManuscriptId();
                                    if(manuscriptId != null && manuscriptId != ""){
                                        ColumnMapping columnMapping = new ColumnMapping();
                                        columnMapping.ColumnMappingCheck(manuscriptId);
                                    }
                                }catch (Exception ee){
                                    ee.printStackTrace();
                                }
                            }else{
                                String serror = JSON.toJSONString(rObject);
                                System.out.println(serror);
                                outPrint(serror,documentData.getManuscriptId(),count);

                                try {
                                    oPostData.put("ObjectId", 0);
                                    Dispatch result1 = WCMServiceCaller.Call(sServiceId, sMethodName, oPostData, true);
                                }catch (Exception e1){

                                }
                            }
                        }
                    }catch(Exception e) {
                        outPrint("",documentData.getManuscriptId(),count);
                        e.printStackTrace();
                    }
                    System.out.println("------------------------------------------------------------");
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            Log_Exception.Error_txt("DataZhiXunByChannel error"+e.getMessage());
        } finally {
        }
        //对hyChannelId的内容进行排序
        //serviceImplKp.orderBy(hyChannelId);
         DataZhiXunByChannelGetAllDocUpdate(kpChannelId,hyChannelId);
    }
    /**
     * 资讯视图 - 抄送增量栏目数据迁移
     * @param kpChannelId
     * @param hyChannelId
     */
    public void DataZhiXunByChannelGetAllDocAddOrUpdate(String kpChannelId,String hyChannelId){
        Log_Exception.Logger_txt("-------Start-------kpChannelId:" + kpChannelId + "--hyChannelId:" + hyChannelId + "---------Start--------");
        String sServiceId = "gov_webdocument";
        String sMethodName = "saveDocumentInWeb";//自定义视图
        ServiceImplKp serviceImplKp=new ServiceImplKp();
        Annex annex = new Annex();
        List<Map<String, String>> mapAllDocs = serviceImplKp.GetAllDocCmsCarbonCopy(kpChannelId);
        for (Map<String, String> mapAllDoc : mapAllDocs) {
            String manuscript_id = mapAllDoc.get("MANUSCRIPT_ID");
            List<Map<String, Object>> allDocInfoFromKPDBdMaps = serviceImplKp.GetAllDocInfoFromByMANUSCRIPT_ID(manuscript_id);
            System.out.println(allDocInfoFromKPDBdMaps);
            if(allDocInfoFromKPDBdMaps!=null){
                int count=0;
                for (Map<String,Object> map : allDocInfoFromKPDBdMaps) {
                    System.out.println("------------------------------------------------------------");
                    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);
                    String manuscriptIdOldDocId = documentData.getManuscriptId();
                    if(manuscriptIdOldDocId != null && manuscriptIdOldDocId != ""){
                        //查询海云的docid
                        String ObjectId = serviceImplKp.GetWcmMetaTableGovDocNewsMetaDataIdByOldDocId(manuscriptIdOldDocId,hyChannelId);
                        if(ObjectId != null && ObjectId != ""){
                            oPostData.put("ObjectId", ObjectId);
                        }
                    }
                    System.out.println(documentData);
                    //标题-必填
                    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();
                            System.out.println("===================start=======================");
                            System.out.println(currentFilePathHtmlUrl);
                            JsoupUtilsView jsoupUtils = new JsoupUtilsView();
                            String html = jsoupUtils.rexStringHtml(currentFilePathHtmlUrl);
                            System.out.println("==============================================");
                            System.out.println(html);
                            System.out.println("===================end========================");
                            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 {
                        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());
                                try {
                                    //处理引用文章
                                    String manuscriptId = documentData.getManuscriptId();
                                    if(manuscriptId != null && manuscriptId != ""){
                                        ColumnMapping columnMapping = new ColumnMapping();
                                        columnMapping.ColumnMappingCheck(manuscriptId);
                                    }
                                }catch (Exception ee){
                                    ee.printStackTrace();
                                }
                            }else{
                                String serror = JSON.toJSONString(rObject);
                                System.out.println(serror);
                                outPrint(serror,documentData.getManuscriptId(),count);
                            }
                        }
                    }catch(Exception e) {
                        outPrint("",documentData.getManuscriptId(),count);
                        e.printStackTrace();
                    }
                    System.out.println("------------------------------------------------------------");
                }
            }

        }
    }
    /**
     * 	政务公开
     * @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,Object>> allDocInfoFromKPDBdMaps = serviceImplKp.GetAllDocInfoFromKPDB(kpChannelId);
            System.out.println(allDocInfoFromKPDBdMaps);
            if(allDocInfoFromKPDBdMaps!=null){
                int count=0;
                for (Map<String,Object> 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());
                            System.out.println(zfggFileInfoByDocId);
                           /* if(zfggFileInfoByDocId.get("DOCRELPIC") != null){
                                oPostData.put("DOCRELPIC", zfggFileInfoByDocId.get("DOCRELPIC"));
                            }
                            if(zfggFileInfoByDocId.get("DOCATTACHFILEFIELD") != null){
                                oPostData.put("DOCATTACHFILEFIELD", zfggFileInfoByDocId.get("DOCATTACHFILEFIELD"));
                            }
                            if(zfggFileInfoByDocId.get("DOCATTACHPICFIELD") != null){
                                oPostData.put("DOCATTACHPICFIELD", zfggFileInfoByDocId.get("DOCATTACHPICFIELD"));
                            }
                            if(zfggFileInfoByDocId.get("DOCRELAPPENDIX") != null){
                                oPostData.put("DOCRELAPPENDIX", zfggFileInfoByDocId.get("DOCRELAPPENDIX"));
                            }*/
                            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());
                            if (rObject.get("ISSUCCESS").toString().equals("true")){
                                System.out.println("DOCTITLE:"+documentData.getTitle());
                                System.out.println("count:"+count);
                                System.out.println("oldDocid:"+documentData.getManuscriptId());
                                try {
                                    //处理引用文章
                                    String manuscriptId = documentData.getManuscriptId();
                                    if(manuscriptId != null && manuscriptId != ""){
                                        ColumnMapping columnMapping = new ColumnMapping();
                                        columnMapping.ColumnMappingCheck(manuscriptId);
                                    }
                                }catch (Exception ee){
                                    ee.printStackTrace();
                                }
                            }else{
                                String serror = JSON.toJSONString(rObject);
                                System.out.println(serror);
                                outPrint(serror,documentData.getManuscriptId(),count);
                            }
                        }
                    }catch(Exception e) {
                        outPrint("",documentData.getManuscriptId(),count);
                        e.printStackTrace();
                    }
                }

            }
        } catch (Exception e) {
            e.printStackTrace();
            Log_Exception.Error_txt("DataExchangeByChannel方法异常！"+e.getMessage());
        } finally {
        }
    }

     /**
     * 	政务公开
     * @param kpChannelId
     * @param hyChannelId
     */
    public void DataZWGKByChannelByTitle(String kpChannelId,String hyChannelId,String viewName){
        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,Object>> allDocInfoFromKPDBdMaps = serviceImplKp.GetAllDocInfoFromKPDB(kpChannelId);
            System.out.println(allDocInfoFromKPDBdMaps);
            if(allDocInfoFromKPDBdMaps!=null){
                int count=0;
                for (Map<String,Object> map : allDocInfoFromKPDBdMaps) {
                    System.out.println("----------------------------"+map+"--------------------------------");
                    Map<String,Object> oPostData=new HashMap<>();
                    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() );
                        //通过标题去海云当中查询文章MetaDataID
                        String MetaDataID =  serviceImplKp.getHyMetaDataIDByTitle(viewName,Jsoup.parse(documentData.getTitle()).text(),hyChannelId);
                        if(MetaDataID != null || MetaDataID == ""){
                            continue;
                        }

                        oPostData.put("ObjectId",MetaDataID);
                    }
                    // 内容
                    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());
                        long pubtime = parse.getTime();
                        Date date1 = new Date(pubtime);
                        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){
                        }
                        oPostData.put("DocRelTime", simpleDateFormat.format(date1));
                    }
                    //关键词
                    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());
                            System.out.println(zfggFileInfoByDocId);
                           /* if(zfggFileInfoByDocId.get("DOCRELPIC") != null){
                                oPostData.put("DOCRELPIC", zfggFileInfoByDocId.get("DOCRELPIC"));
                            }
                            if(zfggFileInfoByDocId.get("DOCATTACHFILEFIELD") != null){
                                oPostData.put("DOCATTACHFILEFIELD", zfggFileInfoByDocId.get("DOCATTACHFILEFIELD"));
                            }
                            if(zfggFileInfoByDocId.get("DOCATTACHPICFIELD") != null){
                                oPostData.put("DOCATTACHPICFIELD", zfggFileInfoByDocId.get("DOCATTACHPICFIELD"));
                            }
                            if(zfggFileInfoByDocId.get("DOCRELAPPENDIX") != null){
                                oPostData.put("DOCRELAPPENDIX", zfggFileInfoByDocId.get("DOCRELAPPENDIX"));
                            }*/
                            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());
                            if (rObject.get("ISSUCCESS").toString().equals("true")){
                                System.out.println("DOCTITLE:"+documentData.getTitle());
                                System.out.println("count:"+count);
                                System.out.println("oldDocid:"+documentData.getManuscriptId());
                                try {
                                    //处理引用文章
                                    String manuscriptId = documentData.getManuscriptId();
                                    if(manuscriptId != null && manuscriptId != ""){
                                        ColumnMapping columnMapping = new ColumnMapping();
                                        columnMapping.ColumnMappingCheck(manuscriptId);
                                    }
                                }catch (Exception ee){
                                    ee.printStackTrace();
                                }
                            }else{
                                String serror = JSON.toJSONString(rObject);
                                System.out.println(serror);
                                outPrint(serror,documentData.getManuscriptId(),count);
                            }
                        }
                    }catch(Exception e) {
                        outPrint("",documentData.getManuscriptId(),count);
                        e.printStackTrace();
                    }
                }

            }
        } catch (Exception e) {
            e.printStackTrace();
            Log_Exception.Error_txt("DataExchangeByChannel方法异常！"+e.getMessage());
        } finally {
        }
    }
      /**
     * 	政务公开-只迁移一篇文章
     * @param kpChannelId
     * @param hyChannelId
     */
    public void DataZWGKByChannelOne(String kpChannelId,String hyChannelId,String manuscriptIdStr){
        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,Object>> allDocInfoFromKPDBdMaps = serviceImplKp.GetAllDocInfoFromKPDBOne(kpChannelId,manuscriptIdStr);
            System.out.println(allDocInfoFromKPDBdMaps);
            if(allDocInfoFromKPDBdMaps!=null){
                int count=0;
                for (Map<String,Object> 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());
                        long pubtime = parse.getTime();
                        Date date1 = new Date(pubtime);
                        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){
                        }
                        oPostData.put("DocRelTime", simpleDateFormat.format(date1));
                    }
                    //关键词
                    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());
                            System.out.println(zfggFileInfoByDocId);
                           /* if(zfggFileInfoByDocId.get("DOCRELPIC") != null){
                                oPostData.put("DOCRELPIC", zfggFileInfoByDocId.get("DOCRELPIC"));
                            }
                            if(zfggFileInfoByDocId.get("DOCATTACHFILEFIELD") != null){
                                oPostData.put("DOCATTACHFILEFIELD", zfggFileInfoByDocId.get("DOCATTACHFILEFIELD"));
                            }
                            if(zfggFileInfoByDocId.get("DOCATTACHPICFIELD") != null){
                                oPostData.put("DOCATTACHPICFIELD", zfggFileInfoByDocId.get("DOCATTACHPICFIELD"));
                            }
                            if(zfggFileInfoByDocId.get("DOCRELAPPENDIX") != null){
                                oPostData.put("DOCRELAPPENDIX", zfggFileInfoByDocId.get("DOCRELAPPENDIX"));
                            }*/
                            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());
                            if (rObject.get("ISSUCCESS").toString().equals("true")){
                                System.out.println("DOCTITLE:"+documentData.getTitle());
                                System.out.println("count:"+count);
                                System.out.println("oldDocid:"+documentData.getManuscriptId());
                                try {
                                    //处理引用文章
                                    String manuscriptId = documentData.getManuscriptId();
                                    if(manuscriptId != null && manuscriptId != ""){
                                        ColumnMapping columnMapping = new ColumnMapping();
                                        columnMapping.ColumnMappingCheck(manuscriptId);
                                    }
                                }catch (Exception ee){
                                    ee.printStackTrace();
                                }
                            }else{
                                String serror = JSON.toJSONString(rObject);
                                System.out.println(serror);
                                outPrint(serror,documentData.getManuscriptId(),count);
                            }
                        }
                    }catch(Exception e) {
                        outPrint("",documentData.getManuscriptId(),count);
                        e.printStackTrace();
                    }
                }

            }
        } catch (Exception e) {
            e.printStackTrace();
            Log_Exception.Error_txt("DataExchangeByChannel方法异常！"+e.getMessage());
        } finally {
        }
    }
    /**
     * 	政府公报
     * @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,Object>> allDocInfoFromKPDBdMaps = serviceImplKp.GetAllDocInfoFromKPDB(kpChannelId);
            System.out.println(allDocInfoFromKPDBdMaps);
            if(allDocInfoFromKPDBdMaps!=null){
                int count=0;
                for (Map<String,Object> 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());
                                try {
                                    //处理引用文章
                                    String manuscriptId = documentData.getManuscriptId();
                                    if(manuscriptId != null && manuscriptId != ""){
                                        ColumnMapping columnMapping = new ColumnMapping();
                                        columnMapping.ColumnMappingCheck(manuscriptId);
                                    }
                                }catch (Exception ee){
                                    ee.printStackTrace();
                                }
                            }else{
                                String serror = JSON.toJSONString(rObject);
                                System.out.println(serror);
                                outPrint(serror,documentData.getManuscriptId(),count);
                            }
                        }
                    }catch(Exception e) {
                        outPrint("",documentData.getManuscriptId(),count);
                        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,Object>> allDocInfoFromKPDBdMaps = serviceImplKp.GetAllDocInfoFromKPDB(kpChannelId);
            System.out.println(allDocInfoFromKPDBdMaps);
            if(allDocInfoFromKPDBdMaps!=null){
                int count=0;
                for (Map<String,Object> 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());
                                try {
                                    //处理引用文章
                                    String manuscriptId = documentData.getManuscriptId();
                                    if(manuscriptId != null && manuscriptId != ""){
                                        ColumnMapping columnMapping = new ColumnMapping();
                                        columnMapping.ColumnMappingCheck(manuscriptId);
                                    }
                                }catch (Exception ee){
                                    ee.printStackTrace();
                                }
                            }else{
                                String serror = JSON.toJSONString(rObject);
                                System.out.println(serror);
                                outPrint(serror,documentData.getManuscriptId(),count);
                            }
                        }
                    }catch(Exception e) {
                        outPrint("",documentData.getManuscriptId(),count);
                        e.printStackTrace();
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            Log_Exception.Error_txt("DataExchangeByChannel error"+e.getMessage());
        } finally {

        }
    }
    /**
     * 	政府公报全真版
     * @param kpChannelId
     * @param hyChannelId
     */
    public void DataZFGBBQZByChannelOne(String kpChannelId,String hyChannelId,String manuscriptIdStr){
        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,Object>> allDocInfoFromKPDBdMaps = serviceImplKp.GetAllDocInfoFromKPDBOne(kpChannelId,manuscriptIdStr);
            System.out.println(allDocInfoFromKPDBdMaps);
            if(allDocInfoFromKPDBdMaps!=null){
                int count=0;
                for (Map<String,Object> 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());
                                try {
                                    //处理引用文章
                                    String manuscriptId = documentData.getManuscriptId();
                                    if(manuscriptId != null && manuscriptId != ""){
                                        ColumnMapping columnMapping = new ColumnMapping();
                                        columnMapping.ColumnMappingCheck(manuscriptId);
                                    }
                                }catch (Exception ee){
                                    ee.printStackTrace();
                                }
                            }else{
                                String serror = JSON.toJSONString(rObject);
                                System.out.println(serror);
                                outPrint(serror,documentData.getManuscriptId(),count);
                            }
                        }
                    }catch(Exception e) {
                        outPrint("",documentData.getManuscriptId(),count);
                        e.printStackTrace();
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            Log_Exception.Error_txt("DataExchangeByChannel error"+e.getMessage());
        } finally {

        }
    }


    public void moveVedio(){
        String sServiceId = "gov_webdocument";
        String sMethodName = "saveDocumentInWeb";//自定义视图
        ServiceImplKp serviceImplKp=new ServiceImplKp();
        Annex annex = new Annex();
        try {
            List<Map<String,Object>> allDocInfoFromKPDBdMaps = serviceImplKp.getMetatablegovdocnewsAllMp4();
            if(allDocInfoFromKPDBdMaps!=null){
                int count=0;
                for (Map<String,Object> map : allDocInfoFromKPDBdMaps) {
                    System.out.println("------------------------------------------------------------");
                    DocumentDataView documentData = new DocumentDataView(map);

                    Map<String,Object> oPostData=new HashMap<>();
                    oPostData.put("ObjectId",documentData.getMetaDataId());
                    oPostData.put("ChannelId", Integer.parseInt(documentData.getChannelId()));// 目标栏目id
                    oPostData.put("CurrUserName", "dev");
                    oPostData.put("isShenhe", "1");
                    oPostData.put("DOCTYPE", CMSConstants.CONTENT_BODY_HTML);
                    System.out.println(documentData);
                    //标题-必填
                    if (documentData.getDocTitle() != null && documentData.getDocTitle() != "null") {
                        oPostData.put("DOCTITLE",documentData.getDocTitle());
                    }
                    if (documentData.getShortTitle() != null && documentData.getShortTitle() != "null") {
                        oPostData.put("SHORTTITLE",documentData.getShortTitle()  );
                    }
                    if (documentData.getDocHtmlCon() != null && documentData.getDocHtmlCon() != "null") {
                        Document parse = Jsoup.parse(documentData.getDocHtmlCon());
                        Elements iframe = parse.select("iframe");
                        iframe.select("iframe").attr("style","width:640px; height:480px;border: 0;display:block;margin:auto");
                        iframe.select("iframe").attr("width","640");
                        iframe.select("iframe").attr("height","480");
                        oPostData.put("DOCHTMLCON", parse.html());
                    }

                    if (documentData.getSUBDOCTITLE() != null && documentData.getSUBDOCTITLE() != "null") {
                        oPostData.put("SUBDOCTITLE", documentData.getSUBDOCTITLE() );
                    }
                    if (documentData.getDOCSOURCENAME() != null && documentData.getDOCSOURCENAME() != "null") {
                        oPostData.put("DOCSOURCENAME", documentData.getDOCSOURCENAME()  );
                    }
                   if (documentData.getDOCAUTHOR() != null && documentData.getDOCAUTHOR() != "null") {
                        oPostData.put("DOCAUTHOR", documentData.getDOCAUTHOR()  );
                    }

                   if (documentData.getDOCKEYWORDS() != null && documentData.getDOCKEYWORDS() != "null") {
                        oPostData.put("KEYWORDTEXT", documentData.getDOCKEYWORDS() );
                    }

                    if (documentData.getDOCABSTRACT() != null && documentData.getDOCABSTRACT() != "null") {
                        oPostData.put("DOCABSTRACT", documentData.getDOCABSTRACT()  );
                    }
                    if (documentData.getDOCRELTIME() != null && documentData.getDOCRELTIME() != "null") {
                        oPostData.put("DOCRELTIME", documentData.getDOCRELTIME()  );
                    }
                    if (documentData.getGUANLIANCODE() != null && documentData.getGUANLIANCODE() != "null") {
                        oPostData.put("GUANLIANCODE", documentData.getGUANLIANCODE() );
                    }
                    if (documentData.getGLTYPE() != null && documentData.getGLTYPE() != "null") {
                        oPostData.put("GLTYPE", documentData.getGLTYPE()  );
                    }

                    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("===========");
                            }else{
                                String serror = JSON.toJSONString(rObject);
                                System.out.println(serror);
                            }
                        }
                    }catch(Exception e) {
                        e.printStackTrace();
                    }
                    System.out.println("------------------------------------------------------------");
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            Log_Exception.Error_txt("DataZhiXunByChannel error"+e.getMessage());
        } finally {
        }
    }

    public void moveZhiXun(String ChannelId){

        String sServiceId = "gov_webdocument";
        String sMethodName = "saveDocumentInWeb";//自定义视图
        ServiceImplKp serviceImplKp=new ServiceImplKp();
        Annex annex = new Annex();
        try {
            List<Map<String,Object>> allDocInfoFromKPDBdMaps = serviceImplKp.getMetatablegovdocnewsZhiXun(ChannelId);
            if(allDocInfoFromKPDBdMaps!=null){
                int count=0;
                for (Map<String,Object> map : allDocInfoFromKPDBdMaps) {
                    System.out.println("------------------------------------------------------------");
                    DocumentDataView documentData = new DocumentDataView(map);

                    Map<String,Object> oPostData=new HashMap<>();
                    oPostData.put("ObjectId",documentData.getMetaDataId());
                    oPostData.put("ChannelId", Integer.parseInt(documentData.getChannelId()));// 目标栏目id
                    oPostData.put("CurrUserName", "dev");
                    oPostData.put("isShenhe", "1");
                    oPostData.put("DOCTYPE", CMSConstants.CONTENT_BODY_HTML);
                    System.out.println(documentData);
                    //标题-必填
                    if (documentData.getDocTitle() != null && documentData.getDocTitle() != "null") {
                        oPostData.put("DOCTITLE",Jsoup.parse(documentData.getDocTitle()).text()   );
                    }
                    if (documentData.getShortTitle() != null && documentData.getShortTitle() != "null") {
                        oPostData.put("SHORTTITLE",Jsoup.parse(documentData.getShortTitle()).text()   );
                    }
                    if (documentData.getDocHtmlCon() != null && documentData.getDocHtmlCon() != "null") {
                        oPostData.put("DOCHTMLCON", documentData.getDocHtmlCon());
                    }

                    if (documentData.getSUBDOCTITLE() != null && documentData.getSUBDOCTITLE() != "null") {
                        oPostData.put("SUBDOCTITLE", Jsoup.parse(documentData.getSUBDOCTITLE()).text()  );
                    }
                    if (documentData.getDOCSOURCENAME() != null && documentData.getDOCSOURCENAME() != "null") {
                        oPostData.put("DOCSOURCENAME", documentData.getDOCSOURCENAME()  );
                    }
                    if (documentData.getDOCAUTHOR() != null && documentData.getDOCAUTHOR() != "null") {
                        oPostData.put("DOCAUTHOR", documentData.getDOCAUTHOR()  );
                    }

                    if (documentData.getDOCKEYWORDS() != null && documentData.getDOCKEYWORDS() != "null") {
                        oPostData.put("KEYWORDTEXT", documentData.getDOCKEYWORDS() );
                    }

                    if (documentData.getDOCABSTRACT() != null && documentData.getDOCABSTRACT() != "null") {
                        oPostData.put("DOCABSTRACT", documentData.getDOCABSTRACT()  );
                    }
                    if (documentData.getDOCRELTIME() != null && documentData.getDOCRELTIME() != "null") {
                        oPostData.put("DOCRELTIME", documentData.getDOCRELTIME()  );
                    }
                    if (documentData.getGUANLIANCODE() != null && documentData.getGUANLIANCODE() != "null") {
                        oPostData.put("GUANLIANCODE", documentData.getGUANLIANCODE() );
                    }
                    if (documentData.getGLTYPE() != null && documentData.getGLTYPE() != "null") {
                        oPostData.put("GLTYPE", documentData.getGLTYPE()  );
                    }

                    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("===========");
                            }else{
                                String serror = JSON.toJSONString(rObject);
                                System.out.println(serror);
                            }
                        }
                    }catch(Exception e) {
                        e.printStackTrace();
                    }
                    System.out.println("------------------------------------------------------------");
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            Log_Exception.Error_txt("DataZhiXunByChannel error"+e.getMessage());
        } finally {

        }

    }

    public void outPrint(String serror,String ManuscriptId,int count){
        try (
                BufferedWriter writer = new BufferedWriter(new FileWriter(ColumnConfig.outPrintFile,true))
        )
        {
            writer.write(serror+","+ManuscriptId+","+count+",");
            writer.newLine(); // 换行
        } catch (IOException e1) {
            e1.printStackTrace();
        }
    }

    public String getJg(String jgmc)
    {

        String code = null;
        List<DemoDataJiGou> list = new ArrayList<>();
        EasyExcel.read(ColumnConfig.fileName, DemoDataJiGou.class, new PageReadListener<DemoDataJiGou>(dataList -> {
            for (DemoDataJiGou demoDataJiGou : dataList) {
                String jgName = demoDataJiGou.getJgName();
                if(jgName != null && jgName != ""){
                    list.add(demoDataJiGou);
                }
            }
        })).sheet().doRead();
        for (DemoDataJiGou demoDataJiGou : list) {
            if(demoDataJiGou.getJgName().equals(jgmc)){
                code = demoDataJiGou.getCode();
            }
        }
        return code;
    }
}
