瀏覽代碼

fix绩效导出

LLL 1 年之前
父節點
當前提交
9d63fef189

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

@@ -42,7 +42,7 @@ public class JixiaoPersonPriceController extends JeecgController<JixiaoPersonPri
 	/**查询导出的人员绩效*/
 	@ApiOperation("查询导出的人员绩效——查询数据")
 	@GetMapping(value = "/exportPersonJX")
-	public List<Map> exportPersonJX(JixiaoPersonPriceExportDTO dto){
+	public List<Map<String,String>> exportPersonJX(JixiaoPersonPriceExportDTO dto){
 		return jixiaoPersonPriceService.exportPersonJX(dto);
 	}
 
@@ -55,7 +55,7 @@ public class JixiaoPersonPriceController extends JeecgController<JixiaoPersonPri
 		JixiaoPersonPriceExportDTO dto = new JixiaoPersonPriceExportDTO();
 		dto.setBeginDate(beginDate);
 		dto.setEndDate(endDate);
-		List<Map> list = jixiaoPersonPriceService.exportPersonJX(dto);
+		List<Map<String,String>> list = jixiaoPersonPriceService.exportPersonJX(dto);
 		jixiaoPersonPriceService.exportXlsByTime(response, list, "人员绩效提成");
 	}
 

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

@@ -30,12 +30,12 @@ import java.util.Map;
 public interface IJixiaoPersonPriceService extends IService<JixiaoPersonPrice> {
 
     /**查询导出的人员绩效*/
-    public List<Map> exportPersonJX(JixiaoPersonPriceExportDTO dto);
+    public List<Map<String,String>> exportPersonJX(JixiaoPersonPriceExportDTO dto);
 
     /**
      * 人员绩效——按时间导出excel
      *
      */
-    public ModelAndView exportXlsByTime(HttpServletResponse response, List<Map> exportList, String title);
+    public void exportXlsByTime(HttpServletResponse response, List<Map<String,String>> exportList, String title);
 
 }

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

@@ -7,6 +7,7 @@ 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;
 import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity;
@@ -39,12 +40,25 @@ public class JixiaoPersonPriceServiceImpl extends ServiceImpl<JixiaoPersonPriceM
     private String upLoadPath;
 
     /**查询导出的人员绩效*/
-    public List<Map> exportPersonJX(JixiaoPersonPriceExportDTO dto){
+    public List<Map<String,String>> exportPersonJX(JixiaoPersonPriceExportDTO dto){
         List<List<Map>> list = jixiaoPersonPriceMapper.exportPersonJX(dto);
         List<Map> mapList = list.get(1);
-        return mapList;
+        List<Map<String,String>> mapList1 = mapList.stream().map(i->{
+                    //todo 遍历map转化成Map<String,String>优化?
+                    Map<String,String> map = new HashMap<>();
+                    Set<Map.Entry> set=i.entrySet();
+                    set.stream().forEach(x -> map.put(x.getKey().toString(), x.getValue().toString()));
+                    Map<String, String> map1 = new HashMap<>();
+                    for (Map.Entry str : set) {
+                        map1.put(str.getKey().toString(), str.getValue().toString());
+                    }
+                    return map1;
+                }
+        ).collect(Collectors.toList());
+        return mapList1;
     }
 
+
     public void downloadExcel1(HttpServletResponse response, String outputName, HSSFWorkbook hssfWorkbook) throws IOException {
         response.setContentType("application/octet-stream");
         //attachment为以附件方式下载
@@ -60,34 +74,28 @@ public class JixiaoPersonPriceServiceImpl extends ServiceImpl<JixiaoPersonPriceM
     /**
      * 人员绩效——按时间导出excel
      */
-    public ModelAndView exportXlsByTime(HttpServletResponse response,List<Map> exportList, String title) {
+    public void exportXlsByTime(HttpServletResponse response,List<Map<String,String>> exportList, String title) {
 //        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 
-        List<ExcelExportEntity> mapList = new ArrayList<>();//这部分可修改为按选择字段导出
+        List<ExcelExportEntity> entity = new ArrayList<ExcelExportEntity>();
         if(exportList != null && !exportList.isEmpty()){
             Map map = exportList.get(0);
             // 打印键集合
             for (Object key : map.keySet()) {
                 System.out.println((String) key);
-                mapList.add(new ExcelExportEntity((String) key, key));
+                entity.add(new ExcelExportEntity((String) key, key));
             }
 
         }
 
-        // Step.3 AutoPoi 导出Excel
-        ModelAndView mv = new ModelAndView(new JeecgMapExcelView());
-        //此处设置的filename无效 ,前端会重更新设置一下
-        mv.addObject(NormalExcelConstants.FILE_NAME, title);
-//        mv.addObject(NormalExcelConstants.MAP_LIST, mapList);
-//        mv.addObject(NormalExcelConstants.CLASS, clazz);
-        //update-begin--Author:liusq  Date:20210126 for:图片导出报错,ImageBasePath未设置--------------------
-//        ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title);
-        ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + "LLL", 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;
+        HSSFWorkbook workbook = (HSSFWorkbook) ExcelExportUtil.exportExcel(new ExportParams(
+                title, title), entity, exportList);
+
+        try {
+            downloadExcel1(response, title+".xls", workbook);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
     }
 
 }