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


/*
*
* 统一处理报错的文件
* */


import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.listener.PageReadListener;
import com.trs.web2frame.tool.tyjyh.Log_Exception;
import com.trs.web2frame.tool.tyjyh.tongliao.DocumentData;
import java.io.*;
import java.util.List;
import java.util.Map;

public class TongLiaoOutFile {


    public static void main(String[] args) {

    }

    public void outfile(){
        String fileUrlS[] = {
                "C:\\Users\\28799\\Desktop\\klx.xlsx",
                "C:\\Users\\28799\\Desktop\\keqqrmzf.xlsx",
                "C:\\Users\\28799\\Desktop\\hlgl.xlsx",
                "C:\\Users\\28799\\Desktop\\keqzyzq.xlsx",
                "C:\\Users\\28799\\Desktop\\keqhq.xlsx",
                "C:\\Users\\28799\\Desktop\\klq.xlsx",
                "C:\\Users\\28799\\Desktop\\zltq.xlsx",
                "C:\\Users\\28799\\Desktop\\tljjjskfq.xlsx",
                "C:\\Users\\28799\\Desktop\\nmqrmzf.xlsx",
        };
        for (String fileUrl : fileUrlS) {
            EasyExcel.read(fileUrl, DemoData.class, new PageReadListener<DemoData>(dataList -> {
                for (DemoData demoData : dataList) {
                    System.out.println(demoData);
                    ServiceImplKp serviceImplKp=new ServiceImplKp();
                    List<Map<String, Object>> maps = serviceImplKp.GetKpMEMOList(demoData.getKpChannelId());
                    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();
                        if(channel_id_kp.equals(demoData.getKpChannelId())){
                            ServiceImplKp serviceImplKpkk = new ServiceImplKp();
                            serviceImplKpkk.GetTestChannleMEMOUpdatae(manuscript_id,title,channel_id_kp,channel_name_kp,demoData.getHyChannelId(),demoData.getChannelName());
                        }
                    }

                }
            })).sheet().doRead();
        }
    }

    public static void  outPrintFile(){
        String sqlFilePath = "D:\\ruoyi\\index.txt";
        try (BufferedReader reader = new BufferedReader(new FileReader(sqlFilePath))) {
            String line;
            while ((line = reader.readLine()) != null) {
                ServiceImplKp serviceImplKp=new ServiceImplKp();
                try {
                    List<Map<String,Object>> allDocInfoFromKPDBdMaps = serviceImplKp.GetAllDocInfoFromKPDBOne(line);
                    System.out.println(allDocInfoFromKPDBdMaps);
                    if(allDocInfoFromKPDBdMaps!=null){
                        int count=0;
                        for (Map<String,Object> map : allDocInfoFromKPDBdMaps) {
                            System.out.println("------------------------------------------------------------");
                            DocumentData documentData = new DocumentData(map);
                            System.out.println(documentData);
                            String manuscriptId = line;
                            String title = documentData.getTitle();
                            String channelIdKp = documentData.getChannelId();
                            ServiceImplKp serviceImplKpkk = new ServiceImplKp();
                            String channelNameKp = documentData.getChannelName();
                            serviceImplKpkk.GetTestChannleMEMOInsert(manuscriptId,title,channelIdKp,channelNameKp,"","");
                            System.out.println("------------------------------------------------------------");
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    Log_Exception.Error_txt("DataZhiXunByChannel error"+e.getMessage());
                } finally {

                }

            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void outPrint(String sql){
        System.out.println(sql);
        try (
                BufferedWriter writer = new BufferedWriter(new FileWriter("D:\\data\\2222\\index2.txt",true))
        )
        {
            writer.write(sql);
            writer.newLine(); // 换行
        } catch (IOException e1) {
            e1.printStackTrace();
        }
    }

}
