//package com.ruoyi.utils.excel.easyexcel.controller;
//
//import cn.stylefeng.guns.core.pojo.response.ResponseData;
//import cn.stylefeng.guns.modular.business.custom.util.excel.easyexcel.ExcelUtil;
//import cn.stylefeng.guns.modular.business.custom.util.excel.easyexcel.vo.ExportExcelVo;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.multipart.MultipartFile;
//
//import javax.servlet.http.HttpServletResponse;
//import java.net.MalformedURLException;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * 事件控制器
// */
//@Slf4j
//@RestController
//@RequestMapping("")
//public class ExcelController {
//
//    /**
//     * excel模板下载
//     */
//    @RequestMapping(value = "/api/excel/template", method = RequestMethod.GET)
//    public ResponseData<String> template(HttpServletResponse response){
//        String fileName = "导入模板下载" + System.currentTimeMillis();
//        try {
//            ExcelUtil.export(fileName, null, ExportExcelVo.class, response);
//        } catch (Exception e) {
//            return ResponseData.error("模板下载失败" + e.getMessage());
//        }
//        return ResponseData.success("模板下载成功！");
//    }
//
//    /**
//     * Excel批量导入数据
//     * @param file 导入文件
//     */
//    @RequestMapping(value = "/api/excel/import", method = RequestMethod.POST)
//    public ResponseData<String> importEvents(MultipartFile file){
//        try {
//            List<?> list = ExcelUtil.importExcel(file, ExportExcelVo.class);
//            System.out.println(list);
//            return ResponseData.success("数据导入完成");
//        } catch (Exception e) {
//            return ResponseData.error("数据导入失败！" + e.getMessage());
//        }
//    }
//
//
//    /**
//     * excel数据导出
//     * @param size  导出条数， 也可以是用户需要导出数据的条件
//     * @return
//     */
//    @RequestMapping(value = "/api/excel/export", method = RequestMethod.GET)
//    public ResponseData<String> export(Long size, HttpServletResponse response) throws MalformedURLException {
//        // 模拟根据条件在数据库查询数据
//        ArrayList<ExportExcelVo> excelVos = new ArrayList<>();
//        for (int i = 1; i <= size; i++) {
//            ExportExcelVo excelVo = new ExportExcelVo();
////            excelVo.setContact(String.valueOf(10000000000L + i));
////            excelVo.setName("公司名称" + i);
////            excelVo.setCreditCode("社会性用代码" + i);
////            excelVo.setProvince("地区" + i);
////            excelVo.setLegalPerson("法人" + i);
////            excelVo.setFormerName("曾用名" + i);
////            excelVo.setStockholder("投资人" + i);
////            excelVo.setSex(i%3);
////            excelVo.setSex2(i%3);
////            excelVo.setCreateTime(new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒").format(new Date()));
////            excelVo.setInspectionReportUrl(new URL("https://cos-1311593864.cos.ap-nanjing.myqcloud.com/wxFile/YsdSF2fSB41674971124698.JPG"));
//            excelVos.add(excelVo);
//        }
//
//        String fileName = "数据导出" + System.currentTimeMillis();
//
//        try {
//            ExcelUtil.export(fileName, excelVos, ExportExcelVo.class, response);
//        } catch (Exception e) {
//            return ResponseData.error("数据导出成功" + e.getMessage());
//        }
//        return ResponseData.success("数据导出失败！");
//    }
//
//
//}
