package com.gyee.wisdom.report.service;

import com.gyee.wisdom.report.utils.ExcelUtil;
import lombok.extern.slf4j.Slf4j;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.*;
import java.net.URLEncoder;
import java.util.*;

@Service
@Slf4j
public class ReportService {



    public Map<Integer, List<String[]>> commonReport(MultipartFile file) {

        Map<Integer, List<String[]>> map = new HashMap<>();
        try {
            //获取原始的文件名
            String originalFilename = file.getOriginalFilename();
            //获取文件类型
            String fileType = originalFilename.substring(originalFilename.lastIndexOf(".") + 1, originalFilename.length());
            //默认从第一行开始读取
            Integer startRows = 1;
            //获取输入流
            InputStream is = file.getInputStream();
            //Excel导入导出的单元类
            map = ExcelUtil.readData(fileType, startRows, true, is);
        }
        catch (IOException e) {
            log.info(e.getMessage(),"获取文件失败");
        }finally {
            return map;
        }
    }

}
