From 9e5729b7f4c92110fb90b5a04050381397d4ea4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AB=B9=E5=A4=A9=E5=8D=AB?= <15010051933@139.com> Date: Thu, 29 Apr 2021 16:27:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BA-=E5=A7=94=E6=89=98=E5=8D=95?= =?UTF-8?q?=E8=BF=9B=E5=B1=95=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/xml/DataStatisticsMapper.xml | 4 +- .../impl/DataStatisticsServiceImpl.java | 41 ++++++++++--------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/cement-business/src/main/java/cn/wise/sc/cement/business/mapper/xml/DataStatisticsMapper.xml b/cement-business/src/main/java/cn/wise/sc/cement/business/mapper/xml/DataStatisticsMapper.xml index 3b3042c..6f87bfe 100644 --- a/cement-business/src/main/java/cn/wise/sc/cement/business/mapper/xml/DataStatisticsMapper.xml +++ b/cement-business/src/main/java/cn/wise/sc/cement/business/mapper/xml/DataStatisticsMapper.xml @@ -166,7 +166,7 @@ left join project p on p.id = e.project_id left join client c on c.id = e.client_id left join sys_user su on su.id = e.user_id - where e.status != 0 and e.project_type is not null + where e.status != 0 and e.status < 9 and e.project_type is not null <if test="params.clientId != null"> and e.clientId = #{clientId} </if> @@ -261,7 +261,7 @@ left join client c on c.id = e.client_id left join sys_user su on su.id = e.user_id ,(select @i:=0)aa - where e.status != 0 and e.project_type is not null + where e.status != 0 and e.status < 9 and e.project_type is not null <if test="params.clientId != null"> and e.clientId = #{clientId} </if> diff --git a/cement-business/src/main/java/cn/wise/sc/cement/business/service/impl/DataStatisticsServiceImpl.java b/cement-business/src/main/java/cn/wise/sc/cement/business/service/impl/DataStatisticsServiceImpl.java index e9e2f48..47ff4c6 100644 --- a/cement-business/src/main/java/cn/wise/sc/cement/business/service/impl/DataStatisticsServiceImpl.java +++ b/cement-business/src/main/java/cn/wise/sc/cement/business/service/impl/DataStatisticsServiceImpl.java @@ -399,11 +399,13 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { QueryWrapper<Sample> queryWrapper = new QueryWrapper<>(); queryWrapper.in("entrust_id", queryList); List<Sample> sampleList = sampleService.list(queryWrapper); + List<Integer> sampleIdList = sampleList.stream().filter(x -> x.getCementCode().equals(x.getParallelCode())).map(Sample::getId).collect(Collectors.toList()); //4.æŸ¥è¯¢æ‰€æœ‰çš„æ´¾å‘æ£€æµ‹é¡¹ QueryWrapper<SampleDistribution> sdqueryWrapper = new QueryWrapper<>(); sdqueryWrapper.in("entrust_id", queryList); - sdqueryWrapper.in("sample_id", sampleList.stream().filter(x -> x.getCementCode().equals(x.getParallelCode())).map(Sample::getId).collect(Collectors.toList())); + sdqueryWrapper.in("sample_id", sampleIdList); List<SampleDistribution> sampleDistributions = sampleDistributionService.list(sdqueryWrapper); + //5.分组并统计 Map<Integer, List<SampleDistribution>> groupByEntrustId = sampleDistributions.stream().collect(Collectors.groupingBy(SampleDistribution::getEntrustId, Collectors.toList())); //6.开始填充数æ®ã€‚首先填充表头 @@ -432,28 +434,28 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { //å¡«å……æ•°æ®,从第二行开始 int rownum = 2; for (int j = 0; j < entrustList.size(); j++) { - Map<String, Object> entrust = entrustList.get(j); int entrustId = Integer.parseInt(entrust.get("entrustId").toString()); - if (groupByEntrustId.get(entrustId) != null) { - XSSFRow row0 = sheet.createRow(rownum++); - Map<Integer, List<SampleDistribution>> sampleDistribuGroup = groupByEntrustId.get(entrustId).stream().collect(Collectors.groupingBy(SampleDistribution::getTeamId, Collectors.toList())); - //处ç†å§”托人信æ¯è¡¨å¤´ - for (int i = 0; i < infoHeader.size(); i++) { - XSSFCell tempCell = row0.createCell(i); - if(infoHeader.get(i).equals("实际产值")){ - Double outPutValue = sampleList - .stream() - .filter(x -> x.getCementCode().equals(x.getParallelCode()) && x.getEntrustId() == entrustId ) - .mapToDouble(item -> item.getOutputValue().doubleValue()).sum(); - tempCell.setCellValue(outPutValue == null ? "" : outPutValue.toString()); - tempCell.setCellStyle(style); - }else{ - tempCell.setCellValue(entrust.get(infoHeader.get(i)) == null ? "" : entrust.get(infoHeader.get(i)).toString()); - tempCell.setCellStyle(style); - } + //åªè¦è¯„审通过的å•å 都å¯ä»¥å¯¼å‡º + XSSFRow row0 = sheet.createRow(rownum++); + //处ç†å§”托人信æ¯è¡¨å¤´ + for (int i = 0; i < infoHeader.size(); i++) { + XSSFCell tempCell = row0.createCell(i); + if(infoHeader.get(i).equals("实际产值")){ + Double outPutValue = sampleList + .stream() + .filter(x -> x.getCementCode().equals(x.getParallelCode()) && x.getEntrustId() == entrustId ) + .mapToDouble(item -> item.getOutputValue().doubleValue()).sum(); + tempCell.setCellValue(outPutValue == null ? "" : outPutValue.toString()); + tempCell.setCellStyle(style); + }else{ + tempCell.setCellValue(entrust.get(infoHeader.get(i)) == null ? "" : entrust.get(infoHeader.get(i)).toString()); + tempCell.setCellStyle(style); } + } + if (groupByEntrustId.get(entrustId) != null) { + Map<Integer, List<SampleDistribution>> sampleDistribuGroup = groupByEntrustId.get(entrustId).stream().collect(Collectors.groupingBy(SampleDistribution::getTeamId, Collectors.toList())); //å¤„ç†æ£€æµ‹é¡¹æ€»äº§å€¼è¡¨å¤´ for (int i = infoHeader.size(); i < teamList.size() + infoHeader.size(); i++) { XSSFCell tempCell = row0.createCell(i); @@ -479,6 +481,7 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { tempCell2.setCellStyle(style); } } + } ExcelUtil.excelExportNew(fileName == null || fileName.trim().length() <= 0 ? "委托å•进展统计" : fileName, wb, response); -- 2.18.1