LLL 1 éve%!(EXTRA string=óta)
szülő
commit
5e23a44000

+ 2 - 2
itdmServer/module-iTDM/src/main/java/org/jeecg/modules/jixiaoPersonPrice/controller/JixiaoPersonPriceController.java

@@ -51,12 +51,12 @@ public class JixiaoPersonPriceController extends JeecgController<JixiaoPersonPri
 	 */
 	@ApiOperation("人员绩效——按时间导出excel")
 	@RequestMapping(value = "/exportXlsByTime")
-	public void exportXlsByTime(HttpServletResponse response, String beginDate,String endDate) {
+	public ModelAndView exportXlsByTime(HttpServletResponse response, String beginDate,String endDate) {
 		JixiaoPersonPriceExportDTO dto = new JixiaoPersonPriceExportDTO();
 		dto.setBeginDate(beginDate);
 		dto.setEndDate(endDate);
 		List<Map<String,String>> list = jixiaoPersonPriceService.exportPersonJX(dto);
-		jixiaoPersonPriceService.exportXlsByTime(response, list, "人员绩效提成");
+		return jixiaoPersonPriceService.exportXlsByTime(response, list, "人员绩效提成");
 	}
 
 	 /**

+ 1 - 1
itdmServer/module-iTDM/src/main/java/org/jeecg/modules/jixiaoPersonPrice/service/IJixiaoPersonPriceService.java

@@ -36,6 +36,6 @@ public interface IJixiaoPersonPriceService extends IService<JixiaoPersonPrice> {
      * 人员绩效——按时间导出excel
      *
      */
-    public void exportXlsByTime(HttpServletResponse response, List<Map<String,String>> exportList, String title);
+    public ModelAndView exportXlsByTime(HttpServletResponse response, List<Map<String,String>> exportList, String title);
 
 }

+ 20 - 27
itdmServer/module-iTDM/src/main/java/org/jeecg/modules/jixiaoPersonPrice/service/impl/JixiaoPersonPriceServiceImpl.java

@@ -2,11 +2,12 @@ package org.jeecg.modules.jixiaoPersonPrice.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.jixiaoPersonPrice.dto.JixiaoPersonPriceExportDTO;
 import org.jeecg.modules.jixiaoPersonPrice.entity.JixiaoPersonPrice;
 import org.jeecg.modules.jixiaoPersonPrice.mapper.JixiaoPersonPriceMapper;
 import org.jeecg.modules.jixiaoPersonPrice.service.IJixiaoPersonPriceService;
-import org.jeecgframework.poi.excel.ExcelExportUtil;
 import org.jeecgframework.poi.excel.def.MapExcelConstants;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
 import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -58,44 +59,36 @@ public class JixiaoPersonPriceServiceImpl extends ServiceImpl<JixiaoPersonPriceM
         return mapList1;
     }
 
-
-    public void downloadExcel1(HttpServletResponse response, String outputName, HSSFWorkbook hssfWorkbook) throws IOException {
-        response.setContentType("application/octet-stream");
-        //attachment为以附件方式下载
-        response.setHeader("Content-Disposition", "attachment;filename=" +
-                URLEncoder.encode(outputName, "utf-8"));
-        response.setHeader("Cache-Control", "No-cache");
-        response.flushBuffer();
-
-        hssfWorkbook.write(response.getOutputStream());
-        hssfWorkbook.close();
-    }
-
     /**
      * 人员绩效——按时间导出excel
      */
-    public void exportXlsByTime(HttpServletResponse response,List<Map<String,String>> exportList, String title) {
-//        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+    public ModelAndView exportXlsByTime(HttpServletResponse response,List<Map<String,String>> exportList, String title) {
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        String exportPerson = "未知";
+        if(sysUser!=null)  exportPerson=sysUser.getRealname();
 
-        List<ExcelExportEntity> entity = new ArrayList<ExcelExportEntity>();
+        // 设置表头样式
+        List<ExcelExportEntity> filedsList = new ArrayList<>();
         if(exportList != null && !exportList.isEmpty()){
             Map map = exportList.get(0);
             // 打印键集合
             for (Object key : map.keySet()) {
                 System.out.println((String) key);
-                entity.add(new ExcelExportEntity((String) key, key));
+                filedsList.add(new ExcelExportEntity((String) key, (String)key));
             }
-
         }
 
-        HSSFWorkbook workbook = (HSSFWorkbook) ExcelExportUtil.exportExcel(new ExportParams(
-                title, title), entity, exportList);
-
-        try {
-            downloadExcel1(response, title+".xls", workbook);
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
+        // Step.3 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgMapExcelView());
+        mv.addObject(NormalExcelConstants.FILE_NAME, title);//此处设置的filename无效 ,前端会重更新设置一下
+        mv.addObject(MapExcelConstants.ENTITY_LIST, filedsList);
+        //update-begin--Author:liusq  Date:20210126 for:图片导出报错,ImageBasePath未设置--------------------
+        ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + exportPerson, title);
+        exportParams.setImageBasePath(upLoadPath);
+        //update-end--Author:liusq  Date:20210126 for:图片导出报错,ImageBasePath未设置----------------------
+        mv.addObject(NormalExcelConstants.PARAMS,exportParams);
+        mv.addObject(NormalExcelConstants.MAP_LIST, exportList);
+        return mv;
     }
 
 }