From d7c032e1dd5416f0fd5abee69129e45668aca016 Mon Sep 17 00:00:00 2001 From: wangzhijiang Date: Thu, 4 May 2023 18:02:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E9=A1=B9=E7=9B=AE=E8=BF=9B?= =?UTF-8?q?=E5=BA=A6=E7=BB=9F=E8=AE=A1(=E7=8A=B6=E6=80=81=E5=AF=BC?= =?UTF-8?q?=E5=87=BA)=E5=BC=80=E5=8F=91=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectLibraryBaseController.java | 5 + .../service/IProjectLibraryBaseService.java | 8 + .../IProjectLibraryStatisticsService.java | 9 + .../impl/ProjectLibraryBaseServiceImpl.java | 513 ++++++++++++++++++ .../ProjectLibraryStatisticsServiceImpl.java | 120 +++- 5 files changed, 654 insertions(+), 1 deletion(-) diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/controller/ProjectLibraryBaseController.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/controller/ProjectLibraryBaseController.java index f49a2ca42..b870ca39e 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/controller/ProjectLibraryBaseController.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/controller/ProjectLibraryBaseController.java @@ -286,4 +286,9 @@ public class ProjectLibraryBaseController extends JeroController params) { + this.projectLibraryBaseService.exportProjectProgressStatisticsXls(response,request, params); + } } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/IProjectLibraryBaseService.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/IProjectLibraryBaseService.java index f68aa498e..34ea29c85 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/IProjectLibraryBaseService.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/IProjectLibraryBaseService.java @@ -159,4 +159,12 @@ public interface IProjectLibraryBaseService extends IService * @return */ JSONArray getProjectProgressInfo(); + + /** + * 导出项目进度统计(状态导出) + * @param response + * @param request + * @param params + */ + void exportProjectProgressStatisticsXls(HttpServletResponse response, HttpServletRequest request, Map params); } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/IProjectLibraryStatisticsService.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/IProjectLibraryStatisticsService.java index 0c23387e8..8bac94398 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/IProjectLibraryStatisticsService.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/IProjectLibraryStatisticsService.java @@ -1,5 +1,6 @@ package com.jero.modules.project.service; +import com.jero.modules.cert.collect.entity.ParamsCollectManifestEO; import com.jero.modules.project.entity.ProjectCertificationInventoryEO; import com.jero.modules.project.entity.ProjectLawsInventoryEO; @@ -73,4 +74,12 @@ public interface IProjectLibraryStatisticsService { * @return */ Map getPartCertificationProgressStatisticsGroupByTerritory(List datas, Map params); + + /** + * 获取认证参数收集-统计信息 + * @param datas + * @param params + * @return + */ + Map getParameterCollectingStatisticsGroupByTerritory(List datas, Map params); } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectLibraryBaseServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectLibraryBaseServiceImpl.java index 3fac21149..796352687 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectLibraryBaseServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectLibraryBaseServiceImpl.java @@ -14,6 +14,7 @@ import com.jero.common.system.vo.LoginUser; import com.jero.modules.cert.collect.entity.ParamsCollectManifestEO; import com.jero.modules.cert.collect.entity.ParamsManifestEO; import com.jero.modules.cert.collect.enums.CollectManifestStateEnum; +import com.jero.modules.cert.collect.enums.CollectManifestStatisticsStateEnum; import com.jero.modules.cert.collect.service.IParamsCollectManifestEOService; import com.jero.modules.cert.collect.service.IParamsManifestEOService; import com.jero.modules.dummy.enums.OrderEnum; @@ -53,6 +54,7 @@ import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.HorizontalAlignment; import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.util.CellRangeAddress; import org.apache.shiro.SecurityUtils; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; @@ -171,6 +173,8 @@ public class ProjectLibraryBaseServiceImpl extends ServiceImpl params) { + String fileName = ""; + String cut = (String) params.get("cut"); + String projectLibraryId = (String) params.get("projectLibraryId"); + if(StringUtils.isEmpty(projectLibraryId)){ + throw new JeroBootException("项目库id不能为空!"); + } + OutputStream ops = null; + HSSFWorkbook workbook = new HSSFWorkbook(); + this.exportRegulatoryManagement(workbook,params); + this.exportCertificationManagement(workbook,params); + this.exportParameterCollecting(workbook,params); + try { + response.setHeader("Content-Disposition", + "attachment; filename=" + fileName); + response.setContentType("application/force-download"); + ops = response.getOutputStream(); + workbook.write(ops); + ops.flush(); + }catch (IOException ex){ + if(CutEnum.CN.getValue().equals(cut)){ + throw new JeroBootException("下载文件失败"); + }else{ + throw new JeroBootException("Failed to download file"); + } + } + } + + /** + * 导出法规符合性管理 + * @param workbook + * @param params + */ + private void exportRegulatoryManagement(HSSFWorkbook workbook,Map params) { + String cut = (String) params.get("cut"); + String sheetName = "法规符合性管理"; + String firstTitle = "法规任务确认," + + "设计符合性确认," + + "验证符合性确认"; + String secondTitle = "责任领域(一级)," + + "未发起,待确认,接受,拒绝,完成度," + + "未发起,待确认,符合,不符合,完成度," + + "未发起,待确认,符合,不符合,完成度"; + if(StringUtils.equals(cut,CutEnum.EN.getValue())){ + sheetName = "Regulatory compliance management"; + firstTitle = "Regulatory task confirmation," + + "Design Conformity Verification," + + "Verification Conformity Confirmation"; + secondTitle = "Area of responsibility (level 1)," + + "Not launched,To be confirmed,Accept,Refuse,Degree of completion," + + "Not launched,To be confirmed,Meet,Not meet,Degree of completion," + + "Not launched,To be confirmed,Meet,Not meet,Degree of completion"; + } + HSSFSheet sheet = workbook.createSheet(sheetName); + //合并单元格 起始行,结束行,起始列,结束列 + CellRangeAddress region1 = new CellRangeAddress(0, 0, 1, 5); + sheet.addMergedRegion(region1); + CellRangeAddress region2 = new CellRangeAddress(0, 0, 6, 10); + sheet.addMergedRegion(region2); + CellRangeAddress region3 = new CellRangeAddress(0, 0, 11, 15); + sheet.addMergedRegion(region3); + + String[] firstTitleArr = firstTitle.split(","); + String[] secondTitleArr = secondTitle.split(","); + Row firstRow = sheet.createRow(0); + Row secondRow = sheet.createRow(1); + + CellStyle cellStyleTitle = workbook.createCellStyle(); + cellStyleTitle.setAlignment(HorizontalAlignment.CENTER); + for (int i = 0; i <= 15; i++){ + sheet.setColumnWidth(i, 3500); + Cell firstRowCell = firstRow.createCell(i); + firstRowCell.setCellStyle(cellStyleTitle); + if(i == 1){ + firstRowCell.setCellValue(firstTitleArr[0]); + }else if(i==6){ + firstRowCell.setCellValue(firstTitleArr[1]); + }else if(i==11){ + firstRowCell.setCellValue(firstTitleArr[2]); + } + + Cell secondRowCell = secondRow.createCell(i); + secondRowCell.setCellValue(secondTitleArr[i]); + } + + String projectLibraryId = (String) params.get("projectLibraryId"); + + QueryWrapper pliQueryWrap = new QueryWrapper<>(); + pliQueryWrap.lambda().eq(ProjectLawsInventoryEO::getProjectLibraryId,projectLibraryId); + List pliEOList = this.projectLawsInventoryEOMapper.selectList(pliQueryWrap); + List sysDictItems = new ArrayList<>(); + String pliDutyTerritoryStr = pliEOList.stream().map(ProjectLawsInventoryEO::getDutyTerritory).collect(Collectors.joining(",")); + if (StringUtils.isNotEmpty(pliDutyTerritoryStr)) { + List pliDutyTerritoryList = Arrays.asList(pliDutyTerritoryStr.split(",")).stream().distinct().collect(Collectors.toList()); + sysDictItems = this.sysDictItemServiceImpl.selectItemsAll().stream().filter(sysDictItem -> { + boolean flag = false; + for (String pliDutyTerritory : pliDutyTerritoryList) { + if(StringUtils.equals(sysDictItem.getItemValue(),pliDutyTerritory)){ + flag = true; + break; + } + } + return flag; + }).collect(Collectors.toList()); + } + + Map> firstLevelDutyTerritoryMap = this.sysDictItemServiceImpl.getFirstLevelSysDictItemByDictCode(DictCodeEnum.DUTY_TERRITORY.getValue(),sysDictItems); + if(ObjectUtils.isNotEmpty(firstLevelDutyTerritoryMap)){ + int dataIndex = 2; + for (Map.Entry> firstLevelMap : firstLevelDutyTerritoryMap.entrySet()) { + String key = firstLevelMap.getKey(); + List dutyTerritoryList = firstLevelMap.getValue(); + if(StringUtils.isEmpty(key) || CollectionUtils.isEmpty(dutyTerritoryList)){ + continue; + } + List pliEoList = pliEOList.stream().filter(pliEo -> { + boolean flag = false; + for (SysDictItem dutyTerritory : dutyTerritoryList) { + if (StringUtils.contains(pliEo.getDutyTerritory(), dutyTerritory.getItemValue())) { + flag = true; + break; + } + } + return flag; + }).collect(Collectors.toList()); + + this.exportRegulatoryManagementSetData(params, sheet, dataIndex ,key,pliEoList); + dataIndex ++; + } + } + } + + /** + * 导出法规符合性管理-设置数据 + * @param params + * @param sheet + * @param dataIndex + * @param key + * @param pliEoList + */ + private void exportRegulatoryManagementSetData(Map params, HSSFSheet sheet, int dataIndex, String key, List pliEoList) { + Row dataRow = sheet.createRow(dataIndex); + dataRow.createCell(0).setCellValue(key); + + Map taskConfirmMap= this.projectLibraryStatisticsService.getFGTaskToConfirmStatisticsGroupByTerritory(pliEoList, params); + Map taskConfirmNotStartedMap = (Map) taskConfirmMap.get(TaskAffirmStatusEnum.NOT_STARTED.getValue()); + double taskConfirmNotStartedAmount = (double) taskConfirmNotStartedMap.get("amount"); + Map taskConfirmToConfirmMap = (Map) taskConfirmMap.get(TaskAffirmStatusEnum.LIST_TO_CONFIRM.getValue()); + double taskConfirmToConfirmAmount = (double) taskConfirmToConfirmMap.get("amount"); + Map taskConfirmAcceptedMap = (Map) taskConfirmMap.get(TaskAffirmStatusEnum.ACCEPTED.getValue()); + double taskConfirmAcceptedAmount = (double) taskConfirmAcceptedMap.get("amount"); + Map taskConfirmRejectedMap = (Map) taskConfirmMap.get(TaskAffirmStatusEnum.REJECTED.getValue()); + double taskConfirmRejectedAmount = (double) taskConfirmRejectedMap.get("amount"); + dataRow.createCell(1).setCellValue(taskConfirmNotStartedAmount); + dataRow.createCell(2).setCellValue(taskConfirmToConfirmAmount); + dataRow.createCell(3).setCellValue(taskConfirmAcceptedAmount); + dataRow.createCell(4).setCellValue(taskConfirmRejectedAmount); + double taskConfirmCount = taskConfirmNotStartedAmount + taskConfirmToConfirmAmount + taskConfirmAcceptedAmount + taskConfirmRejectedAmount; + double taskConfirmPercentage = (taskConfirmAcceptedAmount / taskConfirmCount) * 100; + String taskConfirmPercentageStr = (taskConfirmPercentage != 0 && (taskConfirmCount !=0 )) ? df.format(taskConfirmPercentage) : "0"; + dataRow.createCell(5).setCellValue(taskConfirmPercentageStr + percentSign); + + Map designMap = this.projectLibraryStatisticsService.getDesignComplianceStatisticeGroupByTerritory(pliEoList, params); + Map designNotStartedMap = (Map) designMap.get(TaskAffirmStatusEnum.NOT_STARTED.getValue()); + double designNotStartedAmount = (double) designNotStartedMap.get("amount"); + Map designToConfirmMap = (Map) designMap.get(TaskAffirmStatusEnum.LIST_TO_CONFIRM.getValue()); + double designToConfirmAmount = (double) designToConfirmMap.get("amount"); + Map designComplianceMap = (Map) designMap.get(ComplianceFlowStatusEnum.CONFORMITY.getValue()); + double designComplianceAmount = (double) designComplianceMap.get("amount"); + Map designNonComplianceMap = (Map) designMap.get(ComplianceFlowStatusEnum.INCONFORMITY.getValue()); + double designNonComplianceAmount = (double) designNonComplianceMap.get("amount"); + dataRow.createCell(6).setCellValue(designNotStartedAmount); + dataRow.createCell(7).setCellValue(designToConfirmAmount); + dataRow.createCell(8).setCellValue(designComplianceAmount); + dataRow.createCell(9).setCellValue(designNonComplianceAmount); + double designCount = designNotStartedAmount + designToConfirmAmount + designComplianceAmount + designNonComplianceAmount; + double designPercentage = (designComplianceAmount / designCount) * 100; + String designPercentageStr = (designPercentage != 0 && (designCount !=0 )) ? df.format(designPercentage) : "0"; + dataRow.createCell(10).setCellValue(designPercentageStr + percentSign); + + Map verifyMap = this.projectLibraryStatisticsService.getVerifyComplianceStatisticeGroupByTerritory(pliEoList, params); + Map verifyNotStartedMap = (Map) verifyMap.get(TaskAffirmStatusEnum.NOT_STARTED.getValue()); + double verifyNotStartedAmount = (double) verifyNotStartedMap.get("amount"); + Map verifyToConfirmMap = (Map) verifyMap.get(TaskAffirmStatusEnum.LIST_TO_CONFIRM.getValue()); + double verifyToConfirmAmount = (double) verifyToConfirmMap.get("amount"); + Map verifyComplianceMap = (Map) verifyMap.get(ComplianceFlowStatusEnum.CONFORMITY.getValue()); + double verifyComplianceAmount = (double) verifyComplianceMap.get("amount"); + Map verifyNonComplianceMap = (Map) verifyMap.get(ComplianceFlowStatusEnum.INCONFORMITY.getValue()); + double verifyNonComplianceAmount = (double) verifyNonComplianceMap.get("amount"); + dataRow.createCell(11).setCellValue(verifyNotStartedAmount); + dataRow.createCell(12).setCellValue(verifyToConfirmAmount); + dataRow.createCell(13).setCellValue(verifyComplianceAmount); + dataRow.createCell(14).setCellValue(verifyNonComplianceAmount); + double verifyCount = verifyNotStartedAmount + verifyToConfirmAmount + verifyComplianceAmount + verifyNonComplianceAmount; + double verifyPercentage = (verifyComplianceAmount / verifyCount) * 100; + String verifyPercentageStr = (verifyPercentage != 0 && (verifyCount !=0 )) ? df.format(verifyPercentage) : "0"; + dataRow.createCell(15).setCellValue(verifyPercentageStr + percentSign); + } + + /** + * 导出认证活动管理 + * @param workbook + * @param params + */ + private void exportCertificationManagement(HSSFWorkbook workbook,Map params){ + String cut = (String) params.get("cut"); + String sheetName = "认证活动管理"; + String firstTitle = "认证任务确认," + + "Pre-Homo," + + "认证进度"; + String secondTitle = "责任领域(一级)," + + "未发起,待确认,接受,拒绝,完成度," + + "未发起,待确认,审查通过,审查退回,完成度," + + "未开始,进行中,实验通过,实验失败,部件报告未上传,部件报告已上传,部件报告已入库,完成度"; + if(StringUtils.equals(cut,CutEnum.EN.getValue())){ + sheetName = "Certification Activity Management"; + firstTitle = "Authentication task confirmation," + + "Pre-Homo," + + "Certification progress"; + secondTitle = "Area of responsibility (level 1)," + + "Not launched,To be confirmed,Accept,Refuse,Degree of completion," + + "Not launched,To be confirmed,Review of the adoption,Review return,Degree of completion," + + "Not started,In progress,Experiment passed,Experiment failed,Parts report not uploaded,Parts report uploaded,Parts report in stock,Degree of completion"; + } + HSSFSheet sheet = workbook.createSheet(sheetName); + + //合并单元格 起始行,结束行,起始列,结束列 + CellRangeAddress region1 = new CellRangeAddress(0, 0, 1, 5); + sheet.addMergedRegion(region1); + CellRangeAddress region2 = new CellRangeAddress(0, 0, 6, 10); + sheet.addMergedRegion(region2); + CellRangeAddress region3 = new CellRangeAddress(0, 0, 11, 18); + sheet.addMergedRegion(region3); + CellRangeAddress region4 = new CellRangeAddress(0, 0, 19, 23); + sheet.addMergedRegion(region4); + + String[] firstTitleArr = firstTitle.split(","); + String[] secondTitleArr = secondTitle.split(","); + Row firstRow = sheet.createRow(0); + Row secondRow = sheet.createRow(1); + + CellStyle cellStyleTitle = workbook.createCellStyle(); + cellStyleTitle.setAlignment(HorizontalAlignment.CENTER); + for (int i = 0; i <= 18; i++){ + sheet.setColumnWidth(i, 3500); + Cell firstRowCell = firstRow.createCell(i); + firstRowCell.setCellStyle(cellStyleTitle); + if(i == 1){ + firstRowCell.setCellValue(firstTitleArr[0]); + }else if(i==6){ + firstRowCell.setCellValue(firstTitleArr[1]); + }else if(i==11){ + firstRowCell.setCellValue(firstTitleArr[2]); + }else if(i==19){ + firstRowCell.setCellValue(firstTitleArr[3]); + } + Cell secondRowCell = secondRow.createCell(i); + secondRowCell.setCellValue(secondTitleArr[i]); + } + + String projectLibraryId = (String) params.get("projectLibraryId"); + QueryWrapper pciQueryWrap = new QueryWrapper<>(); + pciQueryWrap.lambda().eq(ProjectCertificationInventoryEO::getProjectLibraryId,projectLibraryId); + List projectCertificationInventoryEOList = this.projectCertificationInventoryEOService.list(pciQueryWrap); + String pciDutyTerritoryStr = projectCertificationInventoryEOList.stream().map(ProjectCertificationInventoryEO::getDutyTerritory).collect(Collectors.joining(",")); + List sysDictItems = new ArrayList<>(); + if (StringUtils.isNotEmpty(pciDutyTerritoryStr)) { + List pciDutyTerritoryList = Arrays.asList(pciDutyTerritoryStr.split(",")).stream().distinct().collect(Collectors.toList()); + sysDictItems = this.sysDictItemServiceImpl.selectItemsAll().stream().filter(sysDictItem -> { + boolean flag = false; + for (String pliDutyTerritory : pciDutyTerritoryList) { + if(StringUtils.equals(sysDictItem.getItemValue(),pliDutyTerritory)){ + flag = true; + break; + } + } + return flag; + }).collect(Collectors.toList()); + } + Map> firstLevelDutyTerritoryMap = this.sysDictItemServiceImpl.getFirstLevelSysDictItemByDictCode(DictCodeEnum.DUTY_TERRITORY.getValue(),sysDictItems); + if(ObjectUtils.isNotEmpty(firstLevelDutyTerritoryMap)){ + int dataIndex = 2; + for (Map.Entry> firstLevelMap : firstLevelDutyTerritoryMap.entrySet()) { + String key = firstLevelMap.getKey(); + List dutyTerritoryList = firstLevelMap.getValue(); + if(StringUtils.isEmpty(key) || CollectionUtils.isEmpty(dutyTerritoryList)){ + continue; + } + List pciEoList = projectCertificationInventoryEOList.stream().filter(pciEo -> { + boolean flag = false; + for (SysDictItem dutyTerritory : dutyTerritoryList) { + if (StringUtils.contains(pciEo.getDutyTerritory(), dutyTerritory.getItemValue())) { + flag = true; + break; + } + } + return flag; + }).collect(Collectors.toList()); + this.exportCertificationManagementSetData(params, sheet, dataIndex, key, pciEoList); + + dataIndex ++; + } + } + } + + /** + * 导出认证活动管理-设置数据 + * @param params + * @param sheet + * @param dataIndex + * @param key + * @param pciEoList + */ + private void exportCertificationManagementSetData(Map params, HSSFSheet sheet, int dataIndex, String key, List pciEoList) { + Row dataRow = sheet.createRow(dataIndex); + dataRow.createCell(0).setCellValue(key); + + Map taskConfirmMap = this.projectLibraryStatisticsService.getRZTaskToConfirmStatisticsGroupByTerritory(pciEoList, params); + Map taskConfirmNotStartedMap = (Map) taskConfirmMap.get(TaskAffirmStatusEnum.NOT_STARTED.getValue()); + double taskConfirmNotStartedAmount = (double) taskConfirmNotStartedMap.get("amount"); + Map taskConfirmToConfirmMap = (Map) taskConfirmMap.get(TaskAffirmStatusEnum.LIST_TO_CONFIRM.getValue()); + double taskConfirmToConfirmAmount = (double) taskConfirmToConfirmMap.get("amount"); + Map taskConfirmAcceptedMap = (Map) taskConfirmMap.get(TaskAffirmStatusEnum.ACCEPTED.getValue()); + double taskConfirmAcceptedAmount = (double) taskConfirmAcceptedMap.get("amount"); + Map taskConfirmRejectedMap = (Map) taskConfirmMap.get(TaskAffirmStatusEnum.REJECTED.getValue()); + double taskConfirmRejectedAmount = (double) taskConfirmRejectedMap.get("amount"); + dataRow.createCell(1).setCellValue(taskConfirmNotStartedAmount); + dataRow.createCell(2).setCellValue(taskConfirmToConfirmAmount); + dataRow.createCell(3).setCellValue(taskConfirmAcceptedAmount); + dataRow.createCell(4).setCellValue(taskConfirmRejectedAmount); + double taskConfirmCount = taskConfirmNotStartedAmount + taskConfirmToConfirmAmount + taskConfirmAcceptedAmount + taskConfirmRejectedAmount; + double taskConfirmPercentage = (taskConfirmAcceptedAmount / taskConfirmCount) * 100; + String taskConfirmPercentageStr = (taskConfirmPercentage != 0 && (taskConfirmCount !=0 )) ? df.format(taskConfirmPercentage) : "0"; + dataRow.createCell(5).setCellValue(taskConfirmPercentageStr + percentSign); + + Map prehomoMap = this.projectLibraryStatisticsService.getPrehomoStatisticeGroupByTerritory(pciEoList, params); + Map prehomoNotStartedMap = (Map) prehomoMap.get(TaskAffirmStatusEnum.NOT_STARTED.getValue()); + double prehomoNotStartedAmount = (double) prehomoNotStartedMap.get("amount"); + Map prehomoToConfirmMap = (Map) prehomoMap.get(TaskAffirmStatusEnum.LIST_TO_CONFIRM.getValue()); + double prehomoToConfirmAmount = (double) prehomoToConfirmMap.get("amount"); + Map prehomoAcceptedMap = (Map) prehomoMap.get(CertificationInventoryFlowStatusEnum.REVIEW_AND_PASS.getValue()); + double prehomoAcceptedAmount = (double) prehomoAcceptedMap.get("amount"); + Map prehomoRejectedMap = (Map) prehomoMap.get(CertificationInventoryFlowStatusEnum.REVIEW_AND_RETURN.getValue()); + double prehomoRejectedAmount = (double) prehomoRejectedMap.get("amount"); + dataRow.createCell(6).setCellValue(prehomoNotStartedAmount); + dataRow.createCell(7).setCellValue(prehomoToConfirmAmount); + dataRow.createCell(8).setCellValue(prehomoAcceptedAmount); + dataRow.createCell(9).setCellValue(prehomoRejectedAmount); + double prehomoCount = prehomoNotStartedAmount + prehomoToConfirmAmount + prehomoAcceptedAmount + prehomoRejectedAmount; + double prehomoPercentage = (prehomoAcceptedAmount / prehomoCount) * 100; + String prehomoPercentageStr = (prehomoPercentage != 0 && (prehomoCount !=0 )) ? df.format(prehomoPercentage) : "0"; + dataRow.createCell(10).setCellValue(prehomoPercentageStr + percentSign); + + Map certificationProgressMap = this.projectLibraryStatisticsService.getPartCertificationProgressStatisticsGroupByTerritory(pciEoList, params); + Map certificationProgressNotStartMap = (Map)certificationProgressMap.get(CertificationProgressEnum.NOT_START.getValue()); + double certificationProgressNotStartAmount = (double) certificationProgressNotStartMap.get("amount"); + Map certificationProgressInProgressMap = (Map)certificationProgressMap.get(CertificationProgressEnum.IN_PROGRESS.getValue()); + double certificationProgressInProgressAmount = (double) certificationProgressInProgressMap.get("amount"); + Map certificationProgressTestPassedMap = (Map)certificationProgressMap.get(CertificationProgressEnum.TEST_PASSED.getValue()); + double certificationProgressTestPassedAmount = (double) certificationProgressTestPassedMap.get("amount"); + Map certificationProgressTestFailedMap = (Map)certificationProgressMap.get(CertificationProgressEnum.TEST_FAILED.getValue()); + double certificationProgressTestFailedAmount = (double) certificationProgressTestFailedMap.get("amount"); + Map certificationProgressNotSubmitMap = (Map)certificationProgressMap.get(CertificationProgressEnum.COMPONENT_REPORT_NOT_SUBMITTED.getValue()); + double certificationProgressNotSubmitAmount = (double) certificationProgressNotSubmitMap.get("amount"); + Map certificationProgressSubmitMap = (Map)certificationProgressMap.get(CertificationProgressEnum.COMPONENT_REPORT_SUBMITTED.getValue()); + double certificationProgressSubmitAmount = (double) certificationProgressSubmitMap.get("amount"); + Map certificationProgressStoredMap = (Map)certificationProgressMap.get(CertificationProgressEnum.COMPONENT_REPORT_HAS_BEEN_STORED.getValue()); + double certificationProgressStoredAmount = (double) certificationProgressStoredMap.get("amount"); + dataRow.createCell(11).setCellValue(certificationProgressNotStartAmount); + dataRow.createCell(12).setCellValue(certificationProgressInProgressAmount); + dataRow.createCell(13).setCellValue(certificationProgressTestPassedAmount); + dataRow.createCell(14).setCellValue(certificationProgressTestFailedAmount); + dataRow.createCell(15).setCellValue(certificationProgressNotSubmitAmount); + dataRow.createCell(16).setCellValue(certificationProgressSubmitAmount); + dataRow.createCell(17).setCellValue(certificationProgressStoredAmount); + double certificationProgressCount = certificationProgressNotStartAmount + certificationProgressInProgressAmount + + certificationProgressTestPassedAmount + certificationProgressTestFailedAmount + + certificationProgressNotSubmitAmount + certificationProgressSubmitAmount + + certificationProgressStoredAmount; + double certificationProgressPercentage = (certificationProgressTestPassedAmount / certificationProgressCount) * 100; + String certificationProgressPercentageStr = (certificationProgressPercentage != 0 && (certificationProgressCount !=0 )) ? df.format(certificationProgressPercentage) : "0"; + dataRow.createCell(18).setCellValue(certificationProgressPercentageStr + percentSign); + } + + /** + * 导出认证参数收集 + * @param workbook + * @param params + */ + private void exportParameterCollecting(HSSFWorkbook workbook, Map params) { + String cut = (String) params.get("cut"); + String sheetName = "认证参数收集"; + String firstTitle = "认证参数收集"; + String secondTitle = "责任领域(一级),未开始,收集中,已提交,已同步至上报库,完成度"; + if(StringUtils.equals(cut,CutEnum.EN.getValue())){ + sheetName = "Authentication parameter collection"; + firstTitle = "Authentication parameter collection"; + secondTitle = "Area of responsibility (level 1),Not started,Collecting,Has submitted,Synced to the report library,Degree of completion"; + } + HSSFSheet sheet = workbook.createSheet(sheetName); + //合并单元格 起始行,结束行,起始列,结束列 + CellRangeAddress region1 = new CellRangeAddress(0, 0, 1, 5); + sheet.addMergedRegion(region1); + + String[] secondTitleArr = secondTitle.split(","); + Row firstRow = sheet.createRow(0); + Row secondRow = sheet.createRow(1); + + CellStyle cellStyleTitle = workbook.createCellStyle(); + cellStyleTitle.setAlignment(HorizontalAlignment.CENTER); + for (int i = 0; i <= 5; i++){ + sheet.setColumnWidth(i, 3500); + Cell firstRowCell = firstRow.createCell(i); + firstRowCell.setCellStyle(cellStyleTitle); + if(i == 1){ + firstRowCell.setCellValue(firstTitle); + } + + Cell secondRowCell = secondRow.createCell(i); + secondRowCell.setCellValue(secondTitleArr[i]); + } + + String projectLibraryId = (String) params.get("projectLibraryId"); + + QueryWrapper pmQueryWrap = new QueryWrapper<>(); + pmQueryWrap.lambda().eq(ParamsManifestEO::getProjectId,projectLibraryId); + List pmEoList = this.paramsManifestEOService.list(pmQueryWrap); + if(CollectionUtils.isNotEmpty(pmEoList)){ + List pmIdList = pmEoList.stream().map(ParamsManifestEO::getId).distinct().collect(Collectors.toList()); + QueryWrapper pcmQueryWrap = new QueryWrapper<>(); + pcmQueryWrap.lambda().in(ParamsCollectManifestEO::getParamsManifestId,pmIdList); + List pcmEoList = this.paramsCollectManifestEOService.list(pcmQueryWrap); + + List sysDictItems = new ArrayList<>(); + String pcmDutyTerritoryStr = pcmEoList.stream().map(ParamsCollectManifestEO::getDutyTerritory).collect(Collectors.joining(",")); + if (StringUtils.isNotEmpty(pcmDutyTerritoryStr)) { + List pcmDutyTerritoryList = Arrays.asList(pcmDutyTerritoryStr.split(",")).stream().distinct().collect(Collectors.toList()); + sysDictItems = this.sysDictItemServiceImpl.selectItemsAll().stream().filter(sysDictItem -> { + boolean flag = false; + for (String pcmDutyTerritory : pcmDutyTerritoryList) { + if(StringUtils.equals(sysDictItem.getItemValue(),pcmDutyTerritory)){ + flag = true; + break; + } + } + return flag; + }).collect(Collectors.toList()); + } + + Map> firstLevelDutyTerritoryMap = this.sysDictItemServiceImpl.getFirstLevelSysDictItemByDictCode(DictCodeEnum.DUTY_TERRITORY.getValue(),sysDictItems); + if(ObjectUtils.isNotEmpty(firstLevelDutyTerritoryMap)){ + int dataIndex = 2; + for (Map.Entry> firstLevelMap : firstLevelDutyTerritoryMap.entrySet()) { + String key = firstLevelMap.getKey(); + List dutyTerritoryList = firstLevelMap.getValue(); + if(StringUtils.isEmpty(key) || CollectionUtils.isEmpty(dutyTerritoryList)){ + continue; + } + List pcmEos = pcmEoList.stream().filter(pcmEo -> { + boolean flag = false; + for (SysDictItem dutyTerritory : dutyTerritoryList) { + if (StringUtils.contains(pcmEo.getDutyTerritory(), dutyTerritory.getItemValue())) { + flag = true; + break; + } + } + return flag; + }).collect(Collectors.toList()); + if(CollectionUtils.isNotEmpty(pcmEos)){ + this.exportParameterCollectingSetData(params, sheet, dataIndex ,key,pcmEos); + } + dataIndex ++; + } + } + } + } + + /** + * 导出认证参数收集-设置数据 + * @param params + * @param sheet + * @param dataIndex + * @param key + * @param pcmEos + */ + private void exportParameterCollectingSetData(Map params, HSSFSheet sheet, int dataIndex, String key, List pcmEos) { + Map parameterCollectingMap = this.projectLibraryStatisticsService.getParameterCollectingStatisticsGroupByTerritory(pcmEos,params); + Map notStartMap = (Map) parameterCollectingMap.get(CollectManifestStatisticsStateEnum.NOT_START.getValue()); + double notStartAmount = (double) notStartMap.get("amount"); + Map collectingMap = (Map) parameterCollectingMap.get(CollectManifestStatisticsStateEnum.COLLECTING.getValue()); + double collectingAmount = (double) collectingMap.get("amount"); + Map submitMap = (Map) parameterCollectingMap.get(CollectManifestStatisticsStateEnum.SUBMIT.getValue()); + double submitAmount = (double) submitMap.get("amount"); + Map syncReporMap = (Map) parameterCollectingMap.get(CollectManifestStatisticsStateEnum.SYNC_REPORT.getValue()); + double syncReporAmount = (double) syncReporMap.get("amount"); + + Row dataRow = sheet.createRow(dataIndex); + dataRow.createCell(0).setCellValue(key); + dataRow.createCell(1).setCellValue(notStartAmount); + dataRow.createCell(2).setCellValue(collectingAmount); + dataRow.createCell(3).setCellValue(submitAmount); + dataRow.createCell(4).setCellValue(syncReporAmount); + double parameterCollectingCount = notStartAmount + collectingAmount + submitAmount + syncReporAmount; + double parameterCollectingPercentage = (syncReporAmount / parameterCollectingCount) * 100; + String parameterCollectingPercentageStr = (parameterCollectingPercentage != 0 && (syncReporAmount !=0 )) ? df.format(parameterCollectingPercentage) : "0"; + dataRow.createCell(5).setCellValue(parameterCollectingPercentageStr + percentSign); + } + private JSONArray getNodeProgressList(TimeNodeVO nodeTnVo) { //根据节点获取对应进度和时间 JSONArray nodeList = new JSONArray(); diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectLibraryStatisticsServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectLibraryStatisticsServiceImpl.java index 60973d5a7..301eb8142 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectLibraryStatisticsServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectLibraryStatisticsServiceImpl.java @@ -1,5 +1,8 @@ package com.jero.modules.project.service.impl; +import com.jero.modules.cert.collect.entity.ParamsCollectManifestEO; +import com.jero.modules.cert.collect.enums.CollectManifestStateEnum; +import com.jero.modules.cert.collect.enums.CollectManifestStatisticsStateEnum; import com.jero.modules.project.entity.ProjectCertificationInventoryEO; import com.jero.modules.project.entity.ProjectLawsInventoryEO; import com.jero.modules.project.enums.CertificationInventoryFlowStatusEnum; @@ -34,7 +37,6 @@ public class ProjectLibraryStatisticsServiceImpl implements IProjectLibraryStati public Map getFGTaskToConfirmStatisticsGroupByTerritory(List datas, Map params) { Map result = new HashMap<>(); if(CollectionUtils.isNotEmpty(datas)){ - String status = (String) params.get("status"); Map notStartedMap = new HashMap<>(); Map toConfirmMap = new HashMap<>(); @@ -587,6 +589,10 @@ public class ProjectLibraryStatisticsServiceImpl implements IProjectLibraryStati Map notSubmitMap = new HashMap<>(); Map reportSubmitMap = new HashMap<>(); Map storedMap = new HashMap<>(); + Map notStartMap = new HashMap<>(); + Map inProgressMap = new HashMap<>(); + Map testPassedMap = new HashMap<>(); + Map testFailedMap = new HashMap<>(); // 部件报告未提交 List notSubmitPciEoList = datas.stream().filter(data -> { @@ -627,9 +633,121 @@ public class ProjectLibraryStatisticsServiceImpl implements IProjectLibraryStati storedMap.put("amount",storedCount); storedMap.put("percentage",storedPercentageStr + percentSign); + // 未开始 + List notStartPciEoList = datas.stream().filter(data -> { + boolean flag = ( + StringUtils.equals(data.getCertificationProgress(),CertificationProgressEnum.NOT_START.getValue()) + ); + return flag; + }).collect(Collectors.toList()); + double notStartCount = (double) notStartPciEoList.size(); + double notStartPercentage = (notStartCount / (datas.size())) * 100; + String notStartPercentageStr = notStartPercentage != 0 ? df.format(notStartPercentage) : "0"; + notStartMap.put("amount",notStartCount); + notStartMap.put("percentage",notStartPercentageStr + percentSign); + // 进行中 + List inProgressPciEoList = datas.stream().filter(data -> { + boolean flag = ( + StringUtils.equals(data.getCertificationProgress(),CertificationProgressEnum.IN_PROGRESS.getValue()) + ); + return flag; + }).collect(Collectors.toList()); + double inProgressCount = (double) inProgressPciEoList.size(); + double inProgressPercentage = (inProgressCount / (datas.size())) * 100; + String inProgressPercentageStr = inProgressPercentage != 0 ? df.format(inProgressPercentage) : "0"; + inProgressMap.put("amount",inProgressCount); + inProgressMap.put("percentage",inProgressPercentageStr + percentSign); + // 实验通过 + List testPassedPciEoList = datas.stream().filter(data -> { + boolean flag = ( + StringUtils.equals(data.getCertificationProgress(),CertificationProgressEnum.TEST_PASSED.getValue()) + ); + return flag; + }).collect(Collectors.toList()); + double testPassedCount = (double) testPassedPciEoList.size(); + double testPassedPercentage = (testPassedCount / (datas.size())) * 100; + String testPassedPercentageStr = testPassedPercentage != 0 ? df.format(testPassedPercentage) : "0"; + testPassedMap.put("amount",testPassedCount); + testPassedMap.put("percentage",testPassedPercentageStr + percentSign); + + // 实验失败 + List testFailedPciEoList = datas.stream().filter(data -> { + boolean flag = ( + StringUtils.equals(data.getCertificationProgress(),CertificationProgressEnum.TEST_FAILED.getValue()) + ); + return flag; + }).collect(Collectors.toList()); + double testFailedCount = (double) testFailedPciEoList.size(); + double testFailedPercentage = (testFailedCount / (datas.size())) * 100; + String testFailedPercentageStr = testFailedPercentage != 0 ? df.format(testFailedPercentage) : "0"; + testFailedMap.put("amount",testFailedCount); + testFailedMap.put("percentage",testFailedPercentageStr + percentSign); + result.put(CertificationProgressEnum.COMPONENT_REPORT_NOT_SUBMITTED.getValue(),notSubmitMap); result.put(CertificationProgressEnum.COMPONENT_REPORT_SUBMITTED.getValue(),reportSubmitMap); result.put(CertificationProgressEnum.COMPONENT_REPORT_HAS_BEEN_STORED.getValue(),storedMap); + result.put(CertificationProgressEnum.NOT_START.getValue(),notStartMap); + result.put(CertificationProgressEnum.IN_PROGRESS.getValue(),inProgressMap); + result.put(CertificationProgressEnum.TEST_PASSED.getValue(),testPassedMap); + result.put(CertificationProgressEnum.TEST_FAILED.getValue(),testFailedMap); + } + return result; + } + + @Override + public Map getParameterCollectingStatisticsGroupByTerritory(List datas, Map params) { + Map result = new HashMap<>(); + if(CollectionUtils.isNotEmpty(datas)){ + Map notStartMap = new HashMap<>(); + Map collectingMap = new HashMap<>(); + Map submitMap = new HashMap<>(); + Map syncReporMap = new HashMap<>(); + + List notStartPcmEoList = datas.stream().filter(data -> { + boolean flag = ( + StringUtils.equals(data.getState(), CollectManifestStateEnum.WAIT_COLLECT.getValue()) + || StringUtils.equals(data.getState(), CollectManifestStateEnum.SDT_BACK.getValue()) + || StringUtils.equals(data.getState(), CollectManifestStateEnum.CHANGE.getValue()) + ); + return flag; + }).collect(Collectors.toList()); + double notStartCount = (double) notStartPcmEoList.size(); + notStartMap.put("amount",notStartCount); + + List collectingPcmEoList = datas.stream().filter(data -> { + boolean flag = ( + StringUtils.equals(data.getState(), CollectManifestStateEnum.WAIT_FILL.getValue()) + || StringUtils.equals(data.getState(),CollectManifestStateEnum.WAIT_SDT.getValue()) + || StringUtils.equals(data.getState(),CollectManifestStateEnum.DRE_BACK.getValue()) + || StringUtils.equals(data.getState(),CollectManifestStateEnum.CERT_BACK.getValue()) + ); + return flag; + }).collect(Collectors.toList()); + double collectingCount = (double) collectingPcmEoList.size(); + collectingMap.put("amount",collectingCount); + + List submitPcmEoList = datas.stream().filter(data -> { + boolean flag = ( + StringUtils.equals(data.getState(), CollectManifestStateEnum.SUBMIT.getValue()) + ); + return flag; + }).collect(Collectors.toList()); + double submitCount = (double) submitPcmEoList.size(); + submitMap.put("amount",submitCount); + + List syncReporPcmEoList = datas.stream().filter(data -> { + boolean flag = ( + StringUtils.equals(data.getState(), CollectManifestStateEnum.SYNC_REPORT.getValue()) + ); + return flag; + }).collect(Collectors.toList()); + double syncReporCount = (double) syncReporPcmEoList.size(); + syncReporMap.put("amount",syncReporCount); + + result.put(CollectManifestStatisticsStateEnum.NOT_START.getValue(),notStartMap); + result.put(CollectManifestStatisticsStateEnum.COLLECTING.getValue(),collectingMap); + result.put(CollectManifestStatisticsStateEnum.SUBMIT.getValue(),submitMap); + result.put(CollectManifestStatisticsStateEnum.SYNC_REPORT.getValue(),syncReporMap); } return result; }