|
@@ -7,6 +7,7 @@ import org.jeecg.modules.jixiaoPersonPrice.entity.JixiaoPersonPrice;
|
|
import org.jeecg.modules.jixiaoPersonPrice.mapper.JixiaoPersonPriceMapper;
|
|
import org.jeecg.modules.jixiaoPersonPrice.mapper.JixiaoPersonPriceMapper;
|
|
import org.jeecg.modules.jixiaoPersonPrice.service.IJixiaoPersonPriceService;
|
|
import org.jeecg.modules.jixiaoPersonPrice.service.IJixiaoPersonPriceService;
|
|
import org.jeecgframework.poi.excel.ExcelExportUtil;
|
|
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.def.NormalExcelConstants;
|
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity;
|
|
import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity;
|
|
@@ -39,12 +40,25 @@ public class JixiaoPersonPriceServiceImpl extends ServiceImpl<JixiaoPersonPriceM
|
|
private String upLoadPath;
|
|
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<List<Map>> list = jixiaoPersonPriceMapper.exportPersonJX(dto);
|
|
List<Map> mapList = list.get(1);
|
|
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 {
|
|
public void downloadExcel1(HttpServletResponse response, String outputName, HSSFWorkbook hssfWorkbook) throws IOException {
|
|
response.setContentType("application/octet-stream");
|
|
response.setContentType("application/octet-stream");
|
|
//attachment为以附件方式下载
|
|
//attachment为以附件方式下载
|
|
@@ -60,34 +74,28 @@ public class JixiaoPersonPriceServiceImpl extends ServiceImpl<JixiaoPersonPriceM
|
|
/**
|
|
/**
|
|
* 人员绩效——按时间导出excel
|
|
* 人员绩效——按时间导出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();
|
|
// LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
|
|
|
- List<ExcelExportEntity> mapList = new ArrayList<>();//这部分可修改为按选择字段导出
|
|
|
|
|
|
+ List<ExcelExportEntity> entity = new ArrayList<ExcelExportEntity>();
|
|
if(exportList != null && !exportList.isEmpty()){
|
|
if(exportList != null && !exportList.isEmpty()){
|
|
Map map = exportList.get(0);
|
|
Map map = exportList.get(0);
|
|
// 打印键集合
|
|
// 打印键集合
|
|
for (Object key : map.keySet()) {
|
|
for (Object key : map.keySet()) {
|
|
System.out.println((String) key);
|
|
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();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|