|
@@ -1,20 +1,32 @@
|
|
package org.jeecg.ctop.finance.settlement.controller;
|
|
package org.jeecg.ctop.finance.settlement.controller;
|
|
|
|
|
|
|
|
+import cn.afterturn.easypoi.cache.manager.POICacheManager;
|
|
|
|
+import cn.afterturn.easypoi.entity.ImageEntity;
|
|
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
|
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
|
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
|
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
|
|
|
+import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportBytedanceVo;
|
|
import org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportBytedanceVo;
|
|
import org.jeecg.ctop.finance.settlement.service.IReportSettlementService;
|
|
import org.jeecg.ctop.finance.settlement.service.IReportSettlementService;
|
|
|
|
+import org.jeecg.ctop.finance.settlement.service.serviceImpl.FileLoaderImpl;
|
|
|
|
+import org.jeecg.ctop.finance.utils.SettlementUtil;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.awt.*;
|
|
|
|
+import java.io.BufferedOutputStream;
|
|
|
|
+import java.io.FileInputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.io.OutputStream;
|
|
import java.net.URLEncoder;
|
|
import java.net.URLEncoder;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -35,13 +47,19 @@ public class ExportReportController {
|
|
@GetMapping(value = "/exportSettlementReport")
|
|
@GetMapping(value = "/exportSettlementReport")
|
|
public Result exportSettlementReport(HttpServletResponse response) {
|
|
public Result exportSettlementReport(HttpServletResponse response) {
|
|
|
|
|
|
|
|
+ // byte[] img = SettlementUtil.getByteImgByUrl("https://media-1301855440.cos.ap-chongqing.myqcloud.com/image/2021-08-05/2-1628129040416.jpg");
|
|
|
|
+
|
|
List<SettlementReportBytedanceVo> list = reportSettlementService.getAccountTransactionDayBytedance();
|
|
List<SettlementReportBytedanceVo> list = reportSettlementService.getAccountTransactionDayBytedance();
|
|
|
|
|
|
- Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("个人信息", "这是sheet名称"), SettlementReportBytedanceVo.class, list);
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("这是表头", "这是sheet名称"), SettlementReportBytedanceVo.class, list);
|
|
|
|
+
|
|
|
|
+
|
|
try {
|
|
try {
|
|
response.setCharacterEncoding("UTF-8");
|
|
response.setCharacterEncoding("UTF-8");
|
|
response.setHeader("content-Type", "application/vnd.ms-excel");
|
|
response.setHeader("content-Type", "application/vnd.ms-excel");
|
|
- response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("文件名称", "UTF-8"));
|
|
|
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("文件名称.xlsx", "UTF-8"));
|
|
workbook.write(response.getOutputStream());
|
|
workbook.write(response.getOutputStream());
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
throw new RuntimeException(e);
|
|
throw new RuntimeException(e);
|
|
@@ -53,4 +71,65 @@ public class ExportReportController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ @ApiOperation(value="财务结算-结算单导出", notes="财务结算-结算单导出")
|
|
|
|
+ @GetMapping(value = "/exportImg")
|
|
|
|
+ public String exportImg(HttpServletResponse response) throws Exception {
|
|
|
|
+
|
|
|
|
+ // byte[] img = SettlementUtil.getByteImgByUrl("https://media-1301855440.cos.ap-chongqing.myqcloud.com/image/2021-08-05/2-1628129040416.jpg");
|
|
|
|
+
|
|
|
|
+ TemplateExportParams params = new TemplateExportParams("C://Users//Administrator//Desktop//bytedance.xlsx",true);
|
|
|
|
+
|
|
|
|
+ // 重要代码
|
|
|
|
+ //POICacheManager.setFileLoader(new FileLoaderImpl());
|
|
|
|
+ POICacheManager.setFileLoder(new FileLoaderImpl());
|
|
|
|
+
|
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
|
+ List<SettlementReportBytedanceVo> list = reportSettlementService.getAccountTransactionDayBytedance();
|
|
|
|
+ List<Map<String, Object>> pictureList = new ArrayList<Map<String, Object>>() ;
|
|
|
|
+
|
|
|
|
+ Map<String,Object> picture1 = new HashMap<String, Object>();
|
|
|
|
+ Map<String,Object> picture2 = new HashMap<String, Object>();
|
|
|
|
+ byte[] datas = SettlementUtil.getByteImgByUrl("https://media-1301855440.cos.ap-chongqing.myqcloud.com/image/2021-08-05/2-1628129040416.jpg");
|
|
|
|
+ ImageEntity img = new ImageEntity();
|
|
|
|
+ img.setUrl("https://media-1301855440.cos.ap-chongqing.myqcloud.com/image/2021-08-05/2-1628129040416.jpg");
|
|
|
|
+ //img.setUrl("C:\\Users\\Administrator\\Desktop\\汇创\\20210507161223.jpg");
|
|
|
|
+ img.setHeight(1000);
|
|
|
|
+ img.setWidth(500);
|
|
|
|
+ picture1.put("imag", img);
|
|
|
|
+ picture2.put("imag", img);
|
|
|
|
+ pictureList.add(picture1);
|
|
|
|
+ pictureList.add(picture2);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
+ resultMap.put("l",list);
|
|
|
|
+ resultMap.put("p",pictureList);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(params, resultMap);
|
|
|
|
+
|
|
|
|
+ response.setCharacterEncoding("UTF-8");
|
|
|
|
+ response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
|
|
|
+ response.setHeader("Pragma", "no-cache");
|
|
|
|
+ response.setHeader("Cache-Control", "no-cache");
|
|
|
|
+ response.setDateHeader("Expires", 0);
|
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("文件名称.xlsx", "UTF-8"));
|
|
|
|
+ OutputStream output = response.getOutputStream();
|
|
|
|
+ BufferedOutputStream bufferedOutPut = new BufferedOutputStream(output);
|
|
|
|
+ workbook.write(bufferedOutPut);
|
|
|
|
+ bufferedOutPut.flush();
|
|
|
|
+ bufferedOutPut.close();
|
|
|
|
+ output.close();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return "123";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|