|
@@ -1,20 +1,21 @@
|
|
|
package org.jeecg.modules.ctop.controller;
|
|
|
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.io.OutputStream;
|
|
|
+import java.util.*;
|
|
|
import java.io.IOException;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLDecoder;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import cn.com.ctop.common.module.utils.ExportExcelUtils;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAgentAccount;
|
|
|
import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAgentAccountService;
|
|
|
-import java.util.Date;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -180,7 +181,7 @@ public class KuaishouAgentAccountController {
|
|
|
* @param response
|
|
|
*/
|
|
|
@RequestMapping(value = "/exportXls")
|
|
|
- public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ public void exportXls(HttpServletRequest request, HttpServletResponse response) throws Exception{
|
|
|
// Step.1 组装查询条件
|
|
|
QueryWrapper<KuaishouAgentAccount> queryWrapper = null;
|
|
|
try {
|
|
@@ -197,14 +198,62 @@ public class KuaishouAgentAccountController {
|
|
|
//Step.2 AutoPoi 导出Excel
|
|
|
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
|
|
List<KuaishouAgentAccount> pageList = kuaishouAgentAccountService.list(queryWrapper);
|
|
|
- //导出文件名称
|
|
|
- mv.addObject(NormalExcelConstants.FILE_NAME, "快手代理商账户表列表");
|
|
|
- mv.addObject(NormalExcelConstants.CLASS, KuaishouAgentAccount.class);
|
|
|
- mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("快手代理商账户表列表数据", "导出人:Jeecg", "导出信息"));
|
|
|
- mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
|
|
- return mv;
|
|
|
+ List<List<Object>> result = new ArrayList<>();
|
|
|
+ if(pageList != null && pageList.size() > 0){
|
|
|
+ for (KuaishouAgentAccount kuaishouAgentAccount : pageList){
|
|
|
+ List<Object> rowData = new ArrayList<>();
|
|
|
+ rowData.add(kuaishouAgentAccount.getId());
|
|
|
+ rowData.add(kuaishouAgentAccount.getUserId());
|
|
|
+ rowData.add(kuaishouAgentAccount.getAccountName());
|
|
|
+ rowData.add(kuaishouAgentAccount.getBalance());
|
|
|
+ rowData.add(kuaishouAgentAccount.getCreditBalance());
|
|
|
+ rowData.add(kuaishouAgentAccount.getRebate());
|
|
|
+ rowData.add(kuaishouAgentAccount.getContractRebate());
|
|
|
+ rowData.add(kuaishouAgentAccount.getDirectRebate());
|
|
|
+ rowData.add(kuaishouAgentAccount.getTotalBalance());
|
|
|
+ rowData.add(kuaishouAgentAccount.getCorporationName());
|
|
|
+ if(kuaishouAgentAccount.getReviewStatus() == 1){
|
|
|
+ rowData.add("审核中");
|
|
|
+ }else if(kuaishouAgentAccount.getReviewStatus() == 2){
|
|
|
+ rowData.add("审核通过");
|
|
|
+ }else if(kuaishouAgentAccount.getReviewStatus() == 3){
|
|
|
+ rowData.add("审核拒绝");
|
|
|
+ }
|
|
|
+ result.add(rowData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String[] accountHeaders = {"广告主ID", "用户ID", "广告主名称", "现金余额", "信用余额", "返点余额", "框返余额", "激励余额", "总余额", "公司名称", "审核状态"};
|
|
|
+ OutputStream os = response.getOutputStream();
|
|
|
+ ExportExcelUtils eeu = new ExportExcelUtils();
|
|
|
+ XSSFWorkbook workbook = new XSSFWorkbook();
|
|
|
+ eeu.exportExcel(workbook, 0, "账户列表", accountHeaders, result);
|
|
|
+ this.setResponseHeader(response, "快手代理商账户列表.xls");
|
|
|
+ workbook.write(os);
|
|
|
+ os.flush();
|
|
|
+ os.close();
|
|
|
+// //导出文件名称
|
|
|
+// mv.addObject(NormalExcelConstants.FILE_NAME, "快手代理商账户表列表");
|
|
|
+// mv.addObject(NormalExcelConstants.CLASS, KuaishouAgentAccount.class);
|
|
|
+// mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("快手代理商账户表列表数据", "导出人:Jeecg", "导出信息"));
|
|
|
+// mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
|
|
+// return mv;
|
|
|
}
|
|
|
-
|
|
|
+ //发送响应流方法
|
|
|
+ public void setResponseHeader(HttpServletResponse response, String fileName) {
|
|
|
+ try {
|
|
|
+ try {
|
|
|
+ fileName = new String(fileName.getBytes(), "ISO8859-1");
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ response.setContentType("application/octet-stream;charset=ISO8859-1");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
|
|
|
+ response.addHeader("Pargam", "no-cache");
|
|
|
+ response.addHeader("Cache-Control", "no-cache");
|
|
|
+ } catch (Exception ex) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
/**
|
|
|
* 通过excel导入数据
|
|
|
*
|