导出项目进度统计(状态导出)开发。

This commit is contained in:
wangzhijiang
2023-05-04 18:02:43 +08:00
parent be786db064
commit d7c032e1dd
5 changed files with 654 additions and 1 deletions
@@ -286,4 +286,9 @@ public class ProjectLibraryBaseController extends JeroController<ProjectLibraryB
return Result.OK(resList);
}
// 导出项目进度统计(状态导出)
@RequestMapping(value = "/exportProjectProgressStatisticsXls")
public void exportProjectProgressStatisticsXls(HttpServletResponse response,HttpServletRequest request, @RequestParam Map<String,Object> params) {
this.projectLibraryBaseService.exportProjectProgressStatisticsXls(response,request, params);
}
}
@@ -159,4 +159,12 @@ public interface IProjectLibraryBaseService extends IService<ProjectLibraryBase>
* @return
*/
JSONArray getProjectProgressInfo();
/**
* 导出项目进度统计(状态导出)
* @param response
* @param request
* @param params
*/
void exportProjectProgressStatisticsXls(HttpServletResponse response, HttpServletRequest request, Map<String, Object> params);
}
@@ -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<String, Object> getPartCertificationProgressStatisticsGroupByTerritory(List<ProjectCertificationInventoryEO> datas, Map<String, Object> params);
/**
* 获取认证参数收集-统计信息
* @param datas
* @param params
* @return
*/
Map<String, Object> getParameterCollectingStatisticsGroupByTerritory(List<ParamsCollectManifestEO> datas, Map<String, Object> params);
}
@@ -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<ProjectLibraryBas
private IProjectLibraryStatisticsService projectLibraryStatisticsService;
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
private static DecimalFormat df = new DecimalFormat("#.00");
private static String percentSign = "%";
/**
* 保存
@@ -2398,6 +2402,515 @@ public class ProjectLibraryBaseServiceImpl extends ServiceImpl<ProjectLibraryBas
return resList;
}
@Override
public void exportProjectProgressStatisticsXls(HttpServletResponse response, HttpServletRequest request, Map<String, Object> 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<String,Object> 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<ProjectLawsInventoryEO> pliQueryWrap = new QueryWrapper<>();
pliQueryWrap.lambda().eq(ProjectLawsInventoryEO::getProjectLibraryId,projectLibraryId);
List<ProjectLawsInventoryEO> pliEOList = this.projectLawsInventoryEOMapper.selectList(pliQueryWrap);
List<SysDictItem> sysDictItems = new ArrayList<>();
String pliDutyTerritoryStr = pliEOList.stream().map(ProjectLawsInventoryEO::getDutyTerritory).collect(Collectors.joining(","));
if (StringUtils.isNotEmpty(pliDutyTerritoryStr)) {
List<String> 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<String, List<SysDictItem>> firstLevelDutyTerritoryMap = this.sysDictItemServiceImpl.getFirstLevelSysDictItemByDictCode(DictCodeEnum.DUTY_TERRITORY.getValue(),sysDictItems);
if(ObjectUtils.isNotEmpty(firstLevelDutyTerritoryMap)){
int dataIndex = 2;
for (Map.Entry<String, List<SysDictItem>> firstLevelMap : firstLevelDutyTerritoryMap.entrySet()) {
String key = firstLevelMap.getKey();
List<SysDictItem> dutyTerritoryList = firstLevelMap.getValue();
if(StringUtils.isEmpty(key) || CollectionUtils.isEmpty(dutyTerritoryList)){
continue;
}
List<ProjectLawsInventoryEO> 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<String, Object> params, HSSFSheet sheet, int dataIndex, String key, List<ProjectLawsInventoryEO> pliEoList) {
Row dataRow = sheet.createRow(dataIndex);
dataRow.createCell(0).setCellValue(key);
Map<String, Object> taskConfirmMap= this.projectLibraryStatisticsService.getFGTaskToConfirmStatisticsGroupByTerritory(pliEoList, params);
Map<String,Object> taskConfirmNotStartedMap = (Map<String, Object>) taskConfirmMap.get(TaskAffirmStatusEnum.NOT_STARTED.getValue());
double taskConfirmNotStartedAmount = (double) taskConfirmNotStartedMap.get("amount");
Map<String,Object> taskConfirmToConfirmMap = (Map<String, Object>) taskConfirmMap.get(TaskAffirmStatusEnum.LIST_TO_CONFIRM.getValue());
double taskConfirmToConfirmAmount = (double) taskConfirmToConfirmMap.get("amount");
Map<String,Object> taskConfirmAcceptedMap = (Map<String, Object>) taskConfirmMap.get(TaskAffirmStatusEnum.ACCEPTED.getValue());
double taskConfirmAcceptedAmount = (double) taskConfirmAcceptedMap.get("amount");
Map<String,Object> taskConfirmRejectedMap = (Map<String, Object>) 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<String, Object> designMap = this.projectLibraryStatisticsService.getDesignComplianceStatisticeGroupByTerritory(pliEoList, params);
Map<String,Object> designNotStartedMap = (Map<String, Object>) designMap.get(TaskAffirmStatusEnum.NOT_STARTED.getValue());
double designNotStartedAmount = (double) designNotStartedMap.get("amount");
Map<String,Object> designToConfirmMap = (Map<String, Object>) designMap.get(TaskAffirmStatusEnum.LIST_TO_CONFIRM.getValue());
double designToConfirmAmount = (double) designToConfirmMap.get("amount");
Map<String,Object> designComplianceMap = (Map<String, Object>) designMap.get(ComplianceFlowStatusEnum.CONFORMITY.getValue());
double designComplianceAmount = (double) designComplianceMap.get("amount");
Map<String,Object> designNonComplianceMap = (Map<String, Object>) 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<String, Object> verifyMap = this.projectLibraryStatisticsService.getVerifyComplianceStatisticeGroupByTerritory(pliEoList, params);
Map<String,Object> verifyNotStartedMap = (Map<String, Object>) verifyMap.get(TaskAffirmStatusEnum.NOT_STARTED.getValue());
double verifyNotStartedAmount = (double) verifyNotStartedMap.get("amount");
Map<String,Object> verifyToConfirmMap = (Map<String, Object>) verifyMap.get(TaskAffirmStatusEnum.LIST_TO_CONFIRM.getValue());
double verifyToConfirmAmount = (double) verifyToConfirmMap.get("amount");
Map<String,Object> verifyComplianceMap = (Map<String, Object>) verifyMap.get(ComplianceFlowStatusEnum.CONFORMITY.getValue());
double verifyComplianceAmount = (double) verifyComplianceMap.get("amount");
Map<String,Object> verifyNonComplianceMap = (Map<String, Object>) 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<String,Object> 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<ProjectCertificationInventoryEO> pciQueryWrap = new QueryWrapper<>();
pciQueryWrap.lambda().eq(ProjectCertificationInventoryEO::getProjectLibraryId,projectLibraryId);
List<ProjectCertificationInventoryEO> projectCertificationInventoryEOList = this.projectCertificationInventoryEOService.list(pciQueryWrap);
String pciDutyTerritoryStr = projectCertificationInventoryEOList.stream().map(ProjectCertificationInventoryEO::getDutyTerritory).collect(Collectors.joining(","));
List<SysDictItem> sysDictItems = new ArrayList<>();
if (StringUtils.isNotEmpty(pciDutyTerritoryStr)) {
List<String> 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<String, List<SysDictItem>> firstLevelDutyTerritoryMap = this.sysDictItemServiceImpl.getFirstLevelSysDictItemByDictCode(DictCodeEnum.DUTY_TERRITORY.getValue(),sysDictItems);
if(ObjectUtils.isNotEmpty(firstLevelDutyTerritoryMap)){
int dataIndex = 2;
for (Map.Entry<String, List<SysDictItem>> firstLevelMap : firstLevelDutyTerritoryMap.entrySet()) {
String key = firstLevelMap.getKey();
List<SysDictItem> dutyTerritoryList = firstLevelMap.getValue();
if(StringUtils.isEmpty(key) || CollectionUtils.isEmpty(dutyTerritoryList)){
continue;
}
List<ProjectCertificationInventoryEO> 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<String, Object> params, HSSFSheet sheet, int dataIndex, String key, List<ProjectCertificationInventoryEO> pciEoList) {
Row dataRow = sheet.createRow(dataIndex);
dataRow.createCell(0).setCellValue(key);
Map<String, Object> taskConfirmMap = this.projectLibraryStatisticsService.getRZTaskToConfirmStatisticsGroupByTerritory(pciEoList, params);
Map<String,Object> taskConfirmNotStartedMap = (Map<String, Object>) taskConfirmMap.get(TaskAffirmStatusEnum.NOT_STARTED.getValue());
double taskConfirmNotStartedAmount = (double) taskConfirmNotStartedMap.get("amount");
Map<String,Object> taskConfirmToConfirmMap = (Map<String, Object>) taskConfirmMap.get(TaskAffirmStatusEnum.LIST_TO_CONFIRM.getValue());
double taskConfirmToConfirmAmount = (double) taskConfirmToConfirmMap.get("amount");
Map<String,Object> taskConfirmAcceptedMap = (Map<String, Object>) taskConfirmMap.get(TaskAffirmStatusEnum.ACCEPTED.getValue());
double taskConfirmAcceptedAmount = (double) taskConfirmAcceptedMap.get("amount");
Map<String,Object> taskConfirmRejectedMap = (Map<String, Object>) 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<String, Object> prehomoMap = this.projectLibraryStatisticsService.getPrehomoStatisticeGroupByTerritory(pciEoList, params);
Map<String, Object> prehomoNotStartedMap = (Map<String, Object>) prehomoMap.get(TaskAffirmStatusEnum.NOT_STARTED.getValue());
double prehomoNotStartedAmount = (double) prehomoNotStartedMap.get("amount");
Map<String, Object> prehomoToConfirmMap = (Map<String, Object>) prehomoMap.get(TaskAffirmStatusEnum.LIST_TO_CONFIRM.getValue());
double prehomoToConfirmAmount = (double) prehomoToConfirmMap.get("amount");
Map<String, Object> prehomoAcceptedMap = (Map<String, Object>) prehomoMap.get(CertificationInventoryFlowStatusEnum.REVIEW_AND_PASS.getValue());
double prehomoAcceptedAmount = (double) prehomoAcceptedMap.get("amount");
Map<String, Object> prehomoRejectedMap = (Map<String, Object>) 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<String, Object> certificationProgressMap = this.projectLibraryStatisticsService.getPartCertificationProgressStatisticsGroupByTerritory(pciEoList, params);
Map<String, Object> certificationProgressNotStartMap = (Map<String, Object>)certificationProgressMap.get(CertificationProgressEnum.NOT_START.getValue());
double certificationProgressNotStartAmount = (double) certificationProgressNotStartMap.get("amount");
Map<String, Object> certificationProgressInProgressMap = (Map<String, Object>)certificationProgressMap.get(CertificationProgressEnum.IN_PROGRESS.getValue());
double certificationProgressInProgressAmount = (double) certificationProgressInProgressMap.get("amount");
Map<String, Object> certificationProgressTestPassedMap = (Map<String, Object>)certificationProgressMap.get(CertificationProgressEnum.TEST_PASSED.getValue());
double certificationProgressTestPassedAmount = (double) certificationProgressTestPassedMap.get("amount");
Map<String, Object> certificationProgressTestFailedMap = (Map<String, Object>)certificationProgressMap.get(CertificationProgressEnum.TEST_FAILED.getValue());
double certificationProgressTestFailedAmount = (double) certificationProgressTestFailedMap.get("amount");
Map<String, Object> certificationProgressNotSubmitMap = (Map<String, Object>)certificationProgressMap.get(CertificationProgressEnum.COMPONENT_REPORT_NOT_SUBMITTED.getValue());
double certificationProgressNotSubmitAmount = (double) certificationProgressNotSubmitMap.get("amount");
Map<String, Object> certificationProgressSubmitMap = (Map<String, Object>)certificationProgressMap.get(CertificationProgressEnum.COMPONENT_REPORT_SUBMITTED.getValue());
double certificationProgressSubmitAmount = (double) certificationProgressSubmitMap.get("amount");
Map<String, Object> certificationProgressStoredMap = (Map<String, Object>)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<String, Object> 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<ParamsManifestEO> pmQueryWrap = new QueryWrapper<>();
pmQueryWrap.lambda().eq(ParamsManifestEO::getProjectId,projectLibraryId);
List<ParamsManifestEO> pmEoList = this.paramsManifestEOService.list(pmQueryWrap);
if(CollectionUtils.isNotEmpty(pmEoList)){
List<String> pmIdList = pmEoList.stream().map(ParamsManifestEO::getId).distinct().collect(Collectors.toList());
QueryWrapper<ParamsCollectManifestEO> pcmQueryWrap = new QueryWrapper<>();
pcmQueryWrap.lambda().in(ParamsCollectManifestEO::getParamsManifestId,pmIdList);
List<ParamsCollectManifestEO> pcmEoList = this.paramsCollectManifestEOService.list(pcmQueryWrap);
List<SysDictItem> sysDictItems = new ArrayList<>();
String pcmDutyTerritoryStr = pcmEoList.stream().map(ParamsCollectManifestEO::getDutyTerritory).collect(Collectors.joining(","));
if (StringUtils.isNotEmpty(pcmDutyTerritoryStr)) {
List<String> 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<String, List<SysDictItem>> firstLevelDutyTerritoryMap = this.sysDictItemServiceImpl.getFirstLevelSysDictItemByDictCode(DictCodeEnum.DUTY_TERRITORY.getValue(),sysDictItems);
if(ObjectUtils.isNotEmpty(firstLevelDutyTerritoryMap)){
int dataIndex = 2;
for (Map.Entry<String, List<SysDictItem>> firstLevelMap : firstLevelDutyTerritoryMap.entrySet()) {
String key = firstLevelMap.getKey();
List<SysDictItem> dutyTerritoryList = firstLevelMap.getValue();
if(StringUtils.isEmpty(key) || CollectionUtils.isEmpty(dutyTerritoryList)){
continue;
}
List<ParamsCollectManifestEO> 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<String, Object> params, HSSFSheet sheet, int dataIndex, String key, List<ParamsCollectManifestEO> pcmEos) {
Map<String, Object> parameterCollectingMap = this.projectLibraryStatisticsService.getParameterCollectingStatisticsGroupByTerritory(pcmEos,params);
Map<String, Object> notStartMap = (Map<String, Object>) parameterCollectingMap.get(CollectManifestStatisticsStateEnum.NOT_START.getValue());
double notStartAmount = (double) notStartMap.get("amount");
Map<String, Object> collectingMap = (Map<String, Object>) parameterCollectingMap.get(CollectManifestStatisticsStateEnum.COLLECTING.getValue());
double collectingAmount = (double) collectingMap.get("amount");
Map<String, Object> submitMap = (Map<String, Object>) parameterCollectingMap.get(CollectManifestStatisticsStateEnum.SUBMIT.getValue());
double submitAmount = (double) submitMap.get("amount");
Map<String, Object> syncReporMap = (Map<String, Object>) 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();
@@ -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<String, Object> getFGTaskToConfirmStatisticsGroupByTerritory(List<ProjectLawsInventoryEO> datas, Map<String, Object> params) {
Map<String, Object> result = new HashMap<>();
if(CollectionUtils.isNotEmpty(datas)){
String status = (String) params.get("status");
Map<String,Object> notStartedMap = new HashMap<>();
Map<String,Object> toConfirmMap = new HashMap<>();
@@ -587,6 +589,10 @@ public class ProjectLibraryStatisticsServiceImpl implements IProjectLibraryStati
Map<String,Object> notSubmitMap = new HashMap<>();
Map<String,Object> reportSubmitMap = new HashMap<>();
Map<String,Object> storedMap = new HashMap<>();
Map<String,Object> notStartMap = new HashMap<>();
Map<String,Object> inProgressMap = new HashMap<>();
Map<String,Object> testPassedMap = new HashMap<>();
Map<String,Object> testFailedMap = new HashMap<>();
// 部件报告未提交
List<ProjectCertificationInventoryEO> notSubmitPciEoList = datas.stream().filter(data -> {
@@ -627,9 +633,121 @@ public class ProjectLibraryStatisticsServiceImpl implements IProjectLibraryStati
storedMap.put("amount",storedCount);
storedMap.put("percentage",storedPercentageStr + percentSign);
// 未开始
List<ProjectCertificationInventoryEO> 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<ProjectCertificationInventoryEO> 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<ProjectCertificationInventoryEO> 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<ProjectCertificationInventoryEO> 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<String, Object> getParameterCollectingStatisticsGroupByTerritory(List<ParamsCollectManifestEO> datas, Map<String, Object> params) {
Map<String, Object> result = new HashMap<>();
if(CollectionUtils.isNotEmpty(datas)){
Map<String,Object> notStartMap = new HashMap<>();
Map<String,Object> collectingMap = new HashMap<>();
Map<String,Object> submitMap = new HashMap<>();
Map<String,Object> syncReporMap = new HashMap<>();
List<ParamsCollectManifestEO> 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<ParamsCollectManifestEO> 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<ParamsCollectManifestEO> 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<ParamsCollectManifestEO> 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;
}