From 9895be644e5f4d8b03170fcdfedb9fc57d90f2d8 Mon Sep 17 00:00:00 2001 From: zss <zss@example.com> Date: 星期三, 31 七月 2024 18:04:05 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java | 24 ++++++++++++++++-------- 1 files changed, 16 insertions(+), 8 deletions(-) diff --git a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java index e1c3b43..63e5676 100644 --- a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java +++ b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java @@ -29,15 +29,12 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import javax.servlet.ServletException; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.net.URLEncoder; import java.time.LocalDate; import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; import java.util.function.Predicate; @@ -130,9 +127,11 @@ insOrder.setAppointed(LocalDate.parse(appointed)); insOrder.setSendTime(LocalDateTime.now()); insOrderMapper.updateById(insOrder); - List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId).select(InsSample::getId)); + List<InsSample> insSamples = + insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId).select(InsSample::getId)); List<Integer> ids = insSamples.stream().map(a -> a.getId()).collect(Collectors.toList()); - List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().in(InsProduct::getInsSampleId, ids).eq(InsProduct::getState, 1).isNull(InsProduct::getInsFibersId).isNull(InsProduct::getInsFiberId).select(InsProduct::getSonLaboratory).groupBy(InsProduct::getSonLaboratory)); + List<InsProduct> insProducts = + insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().in(InsProduct::getInsSampleId, ids).eq(InsProduct::getState, 1).isNull(InsProduct::getInsFibersId).isNull(InsProduct::getInsFiberId).select(InsProduct::getSonLaboratory).groupBy(InsProduct::getSonLaboratory)); for (InsProduct insProduct : insProducts) { InsOrderState insOrderState = new InsOrderState(); insOrderState.setInsOrderId(orderId); @@ -631,12 +630,21 @@ // 杩欓噷URLEncoder.encode鍙互闃叉涓枃涔辩爜 褰撶劧鍜宔asyexcel娌℃湁鍏崇郴 String fileName = URLEncoder.encode("鏍峰搧璐圭敤缁熻瀵煎嚭", "UTF-8"); response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); + Map<String, List<CostStatisticsDto>> groupByCompany = + costStatisticsDtos.stream().filter(e -> StrUtil.isNotEmpty(e.getCompany())) + .collect(Collectors.groupingBy(CostStatisticsDto::getCompany)); try { // 鏂板缓ExcelWriter - ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).build(); + ExcelWriter excelWriter = + EasyExcel.write(response.getOutputStream()).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).build(); - WriteSheet mainSheet = EasyExcel.writerSheet("鏍峰搧璐圭敤缁熻瀵煎嚭").head(CostStatisticsDto.class).build(); - excelWriter.write(costStatisticsDtos, mainSheet); + for (Map.Entry<String, List<CostStatisticsDto>> companyDataEntry : groupByCompany.entrySet()) { + String sheetName = companyDataEntry.getKey(); + List<CostStatisticsDto> dataList = companyDataEntry.getValue(); + WriteSheet mainSheet = EasyExcel.writerSheet(sheetName).head(CostStatisticsDto.class).build(); + excelWriter.write(dataList, mainSheet); + } + // 鍏抽棴娴� excelWriter.finish(); -- Gitblit v1.9.3