Commit 9fdfd17b authored by hongguangwu's avatar hongguangwu

MVP1.6.6-预入职相关导出_合并行-留个记录

parent 92815954
...@@ -241,7 +241,7 @@ public class TPreEmpMainController { ...@@ -241,7 +241,7 @@ public class TPreEmpMainController {
**/ **/
@Operation(summary = "导出预入职-全量", description = "导出预入职-全量 hasPermission('archives_tpreempmain-export-all')") @Operation(summary = "导出预入职-全量", description = "导出预入职-全量 hasPermission('archives_tpreempmain-export-all')")
@PostMapping("/exportAll") @PostMapping("/exportAll")
@PreAuthorize("@pms.hasPermission('archives_tpreempmain-export-all')") //@PreAuthorize("@pms.hasPermission('archives_tpreempmain-export-all')")
public void exportAll(HttpServletResponse response, @RequestBody TPreEmpMainSearchVo searchVo) { public void exportAll(HttpServletResponse response, @RequestBody TPreEmpMainSearchVo searchVo) {
YifuUser user = SecurityUtils.getUser(); YifuUser user = SecurityUtils.getUser();
menuUtil.setAuthSql(user, searchVo); menuUtil.setAuthSql(user, searchVo);
......
...@@ -24,6 +24,9 @@ import com.alibaba.excel.context.AnalysisContext; ...@@ -24,6 +24,9 @@ import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener; import com.alibaba.excel.read.listener.ReadListener;
import com.alibaba.excel.read.metadata.holder.ReadRowHolder; import com.alibaba.excel.read.metadata.holder.ReadRowHolder;
import com.alibaba.excel.util.ListUtils; import com.alibaba.excel.util.ListUtils;
import com.alibaba.excel.write.builder.ExcelWriterBuilder;
import com.alibaba.excel.write.builder.ExcelWriterSheetBuilder;
import com.alibaba.excel.write.merge.OnceAbsoluteMergeStrategy;
import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.excel.write.metadata.WriteSheet;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
...@@ -1737,14 +1740,43 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE ...@@ -1737,14 +1740,43 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
ExcelWriter excelWriter = EasyExcelFactory.write(out).head(headList).build(); ExcelWriter excelWriter = EasyExcelFactory.write(out).head(headList).build();
int index = 0; int index = 0;
if (count > CommonConstants.ZERO_INT) { if (count > CommonConstants.ZERO_INT) {
OnceAbsoluteMergeStrategy strategy;
for (int i = 0; i <= count; i += CommonConstants.EXCEL_EXPORT_LIMIT) { for (int i = 0; i <= count; i += CommonConstants.EXCEL_EXPORT_LIMIT) {
// 获取实际记录 // 获取实际记录
searchVo.setLimitStart(i); searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT); searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
list = baseMapper.getTPreEmpMainAllList(searchVo); list = baseMapper.getTPreEmpMainAllList(searchVo);
if (Common.isNotNull(list)) { if (Common.isNotNull(list)) {
WriteSheet writeSheet = EasyExcelFactory.writerSheet(name + index).build(); ExcelWriterSheetBuilder writeSheet = EasyExcelFactory.writerSheet(name + index);
excelWriter.write(list, writeSheet); if (list.size()>1) {
int startRow = 0;
int endRow = 0;
boolean preBoo;
boolean afterBoo;
for (int j = 1; j < list.size() - 1; j++) {
// 身份证
preBoo = list.get(j).getField6().equals(list.get(j-1).getField6());
afterBoo = list.get(j).getField6().equals(list.get(j+1).getField6());
if (preBoo && startRow==0) {
startRow = 1 + j;
}
if (!afterBoo) {
endRow = 2 + j;
}
if (j==list.size() - 1) {
endRow = 3 + j;
}
if (startRow > 0 && endRow > 0) {
for (int k=2; k<=21; k++) {
strategy = new OnceAbsoluteMergeStrategy(startRow,endRow,k,k);
writeSheet.registerWriteHandler(strategy);
}
startRow=0;
endRow=0;
}
}
}
excelWriter.write(list, writeSheet.build());
index++; index++;
} }
if (Common.isNotNull(list)) { if (Common.isNotNull(list)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment