From a05869a12d95375df2333459c8fa4079de7e5953 Mon Sep 17 00:00:00 2001 From: heheng <475597332@qq.com> Date: 星期三, 21 五月 2025 17:09:49 +0800 Subject: [PATCH] 变动大幅度版本 --- src/main/java/com/gkhy/labRiskManage/domain/riskReport/service/impl/ReportRiskAssessInfoServiceImpl.java | 69 ++++++++++++++++++++++++++++------ 1 files changed, 56 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/gkhy/labRiskManage/domain/riskReport/service/impl/ReportRiskAssessInfoServiceImpl.java b/src/main/java/com/gkhy/labRiskManage/domain/riskReport/service/impl/ReportRiskAssessInfoServiceImpl.java index b106467..77c0e7f 100644 --- a/src/main/java/com/gkhy/labRiskManage/domain/riskReport/service/impl/ReportRiskAssessInfoServiceImpl.java +++ b/src/main/java/com/gkhy/labRiskManage/domain/riskReport/service/impl/ReportRiskAssessInfoServiceImpl.java @@ -60,8 +60,7 @@ import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; @@ -284,7 +283,7 @@ */ @Transactional @Override - public ReportInsertDTO insertRiskReport(Long currentUserId, Long id) { + public ReportInsertDTO insertRiskReport(Long currentUserId, Long id,String reSubmit) { if (currentUserId < 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode() ,"当前用户无效,请重新登陆"); @@ -305,9 +304,20 @@ if (roleTag == 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode() ,"不是管理员,无权生成报告"); } - if (experimentById.getStage() == StatusEnum.EXPERIMENT_STATUS_REPORT.getCode().byteValue()){ - throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode() ,"该实验已经生成报告,无需重复操作"); + if (!ObjectUtils.isEmpty(reSubmit) && "1".equals(reSubmit) && experimentById.getStage() >= StatusEnum.EXPERIMENT_STATUS_FINISH.getCode().byteValue()){ + //删除已生成的报告数据 + delReportData(id,currentUserId); + }else { + if (experimentById.getStage() == StatusEnum.EXPERIMENT_STATUS_REPORT.getCode().byteValue()){ + throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode() ,"该实验已经生成报告,无需重复操作"); + } } + + ReportRiskAssessInfo byExperimentId = reportRepository.getByExperimentId(id); + if (!ObjectUtils.isEmpty(byExperimentId)){ + throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode() ,"该实验已经生成报告,请勿重复操作"); + } + //定义初始风险等级0级 Byte level = 0; //获取该实验的所有计划信息 @@ -327,14 +337,16 @@ if (tag == 1){ throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR.getCode() ,"该实验有未完成的评估计划" + info); } - - UserInfoDomainDTO liabilityUser = userDomainService.getUserInfoById(experimentById.getLiabilityUserId()); - if (ObjectUtils.isEmpty(liabilityUser)){ - throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR.getCode() ,"实验责任人信息不存在"); - } +//20250520实验责任人去掉验证 +// UserInfoDomainDTO liabilityUser = userDomainService.getUserInfoById(experimentById.getLiabilityUserId()); +// if (ObjectUtils.isEmpty(liabilityUser)){ +// throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR.getCode() ,"实验责任人信息不存在"); +// } //检查该实验所有的评价结果,遍历评价结果等级 + + Set<Byte> riskLevelList = new HashSet<>(); int a = 1; StringBuilder analysis = new StringBuilder(); List<RiskAssessPlanEvaluateLec> lecByIds = lecService.getLecByIds(assessPlanIds); @@ -345,6 +357,7 @@ if (lecByIds .size() > 0){ for (RiskAssessPlanEvaluateLec lecById : lecByIds) { if (lecById.getRiskLevel() > level){ + riskLevelList.add(lecById.getRiskLevel()); level = lecById.getRiskLevel(); analysis.append(a + lecById.getSafeRiskAnalysis() + ";");//todo 安全风险分析 a++; @@ -354,6 +367,7 @@ if (lsByIds .size() > 0){ for (RiskAssessPlanEvaluateLs lsById : lsByIds) { if (lsById.getRiskLevel() > level){ + riskLevelList.add(lsById.getRiskLevel()); level = lsById.getRiskLevel(); analysis.append(a + lsById.getSafeRiskAnalysis() + ";"); a++; @@ -363,6 +377,7 @@ if (mesByIds .size() > 0){ for (RiskAssessPlanEvaluateMes mesById : mesByIds) { if (mesById.getRiskLevel() > level){ + riskLevelList.add(mesById.getRiskLevel()); level = mesById.getRiskLevel(); analysis.append(a + mesById.getSafeRiskAnalysis() + ";"); a++; @@ -373,6 +388,7 @@ if (rsByIds .size() > 0){ for (RiskAssessPlanEvaluateRs rsById : rsByIds) { if (rsById.getRiskLevel() > level){ + riskLevelList.add(rsById.getRiskLevel()); level = rsById.getRiskLevel(); analysis.append(a + rsById.getSafeRiskAnalysis() + ";"); a++; @@ -405,9 +421,26 @@ reportInfo.setSafeRiskAnalysis(analysis.toString()); reportInfo.setAssessPerson(null); - reportInfo.setAssessLevel(null); - reportInfo.setDepId(null); //todo 不确定是否需要部门 - reportInfo.setSafeRiskAnalysis(null); //todo 安全风险分析,暂时不知道数据来源,先设空 + if (ObjectUtils.isEmpty(riskLevelList)){ + reportInfo.setAssessLevel(StatusEnum.REPORT_LEVEL_4.getCode().byteValue()); + }else { + byte b = riskLevelList.stream().max(Comparator.comparing(Integer::valueOf)).get(); + if (b == StatusEnum.REPORT_LEVEL_1.getCode().byteValue()){ + reportInfo.setAssessLevel(StatusEnum.REPORT_LEVEL_4.getCode().byteValue()); + }else if (b == StatusEnum.REPORT_LEVEL_2.getCode().byteValue()){ + reportInfo.setAssessLevel(StatusEnum.REPORT_LEVEL_3.getCode().byteValue()); + }else if (b == StatusEnum.REPORT_LEVEL_3.getCode().byteValue()){ + reportInfo.setAssessLevel(StatusEnum.REPORT_LEVEL_2.getCode().byteValue()); + }else if (b == StatusEnum.REPORT_LEVEL_4.getCode().byteValue()){ + reportInfo.setAssessLevel(StatusEnum.REPORT_LEVEL_1.getCode().byteValue()); + } + + } + + //todo 不确定是否需要部门 + reportInfo.setDepId(null); +// reportInfo.setSafeRiskAnalysis(null); + //修改实验 4 生成报告, @@ -492,6 +525,16 @@ } + private void delReportData(Long id,Long userId){ + ReportRiskAssessInfo byExperimentId = reportRepository.getByExperimentId(id); + if (!ObjectUtils.isEmpty(byExperimentId)){ + reportRepository.delReport(userId, byExperimentId.getId()); + reportExperimentSiteService.delReportData(byExperimentId.getId()); + reportSourceTypeService.delReportData(byExperimentId.getId()); + + } + } + /** * 风险评估报告 - 填报信息 */ -- Gitblit v1.9.2