From 6d6f2f9fe9ee5e0d2b1b63bb7cde575f2a93876b Mon Sep 17 00:00:00 2001
From: heheng <475597332@qq.com>
Date: Wed, 21 May 2025 16:14:52 +0800
Subject: [PATCH] 变动大幅度版本
---
src/main/java/com/gkhy/labRiskManage/domain/riskReport/service/impl/ReportRiskAssessInfoServiceImpl.java | 89 ++++++++++++++++++++++++++++++++++++++------
1 files changed, 76 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 235f60e..5fb1326 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
@@ -1,5 +1,7 @@
package com.gkhy.labRiskManage.domain.riskReport.service.impl;
+import com.gkhy.labRiskManage.api.controller.basic.dto.respDto.OldRiskAssessResDTO;
+import com.gkhy.labRiskManage.api.controller.experiment.dto.req.ExperimentAndPersonInsertReqBO;
import com.gkhy.labRiskManage.api.controller.riskReport.dto.repDto.ReportReqBO;
import com.gkhy.labRiskManage.api.controller.riskReport.dto.respDto.ReportExperimentSiteQueryRespDTO;
import com.gkhy.labRiskManage.api.controller.riskReport.dto.respDto.ReportPersonQueryRespDTO;
@@ -19,10 +21,12 @@
import com.gkhy.labRiskManage.domain.account.model.dto.UserInfoDomainDTO;
import com.gkhy.labRiskManage.domain.account.service.UserDomainService;
import com.gkhy.labRiskManage.domain.basic.entity.BasicRiskUnitType;
+import com.gkhy.labRiskManage.domain.basic.entity.OldRiskAssess;
import com.gkhy.labRiskManage.domain.basic.model.dto.SiteQueryDTO;
import com.gkhy.labRiskManage.domain.basic.service.BasicExperimentPersonService;
import com.gkhy.labRiskManage.domain.basic.service.BasicExperimentSiteService;
import com.gkhy.labRiskManage.domain.basic.service.BasicRiskUnitTypeService;
+import com.gkhy.labRiskManage.domain.basic.service.OldRiskAssessService;
import com.gkhy.labRiskManage.domain.experiment.entity.ExperimentAndSite;
import com.gkhy.labRiskManage.domain.experiment.entity.ExperimentAssessLog;
import com.gkhy.labRiskManage.domain.experiment.entity.ExperimentInfo;
@@ -30,6 +34,7 @@
import com.gkhy.labRiskManage.domain.experiment.enums.ExperimentRectifyStatusEnum;
import com.gkhy.labRiskManage.domain.experiment.model.dto.ExperimentInfoDTO;
import com.gkhy.labRiskManage.domain.experiment.service.ExperimentAndSiteService;
+import com.gkhy.labRiskManage.domain.experiment.service.ExperimentAndTypeService;
import com.gkhy.labRiskManage.domain.experiment.service.ExperimentAssessLogService;
import com.gkhy.labRiskManage.domain.experiment.service.ExperimentInfoService;
import com.gkhy.labRiskManage.domain.riskReport.entity.*;
@@ -48,6 +53,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
+import org.springframework.util.StringUtils;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
@@ -56,6 +62,7 @@
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
+import java.util.stream.Collectors;
/**
@@ -103,6 +110,12 @@
private RiskAssessPlanEvaluateMesService mesService;
@Autowired
private RiskAssessPlanEvaluateRsService rsService;
+
+ @Autowired
+ private ExperimentAndTypeService experimentAndTypeService;
+
+ @Autowired
+ private OldRiskAssessService oldRiskAssessService;
/**
@@ -191,6 +204,8 @@
List<ReportAppQueryDTO> reportAppQueryDTOS = BeanCopyUtils.copyBeanList(reportQueryDTOS, ReportAppQueryDTO.class);
List<UserInfoDomainDTO> userList = userDomainService.getUserList();
+
+
for (ReportAppQueryDTO reportQueryDTO : reportAppQueryDTOS) {
//获取审批人员
List<ReportPersonQueryRespDTO> personByReportId = reportPersonService.listPersonByReportId(reportQueryDTO.getId());
@@ -205,12 +220,19 @@
//获取评估计划
List<AssessPlanQueryDTO> assessPlanByExperimentId = assessPlanService.getAssessPlanByExperimentId(reportQueryDTO.getExperimentId());
reportQueryDTO.setEvaluateTime(experimentById.getCreateTime());
+ if (!ObjectUtils.isEmpty(experimentById.getProcess())){
+ reportQueryDTO.setProcess(experimentById.getProcess());
+ }
+
if (!ObjectUtils.isEmpty(assessPlanByExperimentId)){
for (AssessPlanQueryDTO assessPlan : assessPlanByExperimentId) {
- if (reportQueryDTO.getEvaluateTime().isBefore(assessPlan.getEvaluateTime())){
- reportQueryDTO.setEvaluateTime(assessPlan.getEvaluateTime());
+ if (assessPlan.getEvaluateTime() != null){
+ if (reportQueryDTO.getEvaluateTime().isBefore(assessPlan.getEvaluateTime())){
+ reportQueryDTO.setEvaluateTime(assessPlan.getEvaluateTime());
+ }
}
+
}
}
@@ -225,6 +247,16 @@
}
if (!ObjectUtils.isEmpty(siteByReportId)){
reportQueryDTO.setExperimentSite(BeanCopyUtils.copyBeanList(siteByReportId, ReportExperimentSiteQueryRespDTO.class));
+ if (queryBO.getExperimentId() != null){
+ List<ReportExperimentSiteQueryRespDTO> experimentSite = reportQueryDTO.getExperimentSite();
+ List<String> collect = experimentSite.stream().map(ReportExperimentSiteQueryRespDTO::getSiteName).collect(Collectors.toList());
+ List<OldRiskAssessResDTO> oldRiskAssessListByRegion = oldRiskAssessService.getOldRiskAssessListByRegion(collect);
+ if (!ObjectUtils.isEmpty(oldRiskAssessListByRegion)){
+
+ reportQueryDTO.setOldRiskAssess(oldRiskAssessListByRegion);
+ }
+ reportQueryDTO.setExperimentAndType(experimentAndTypeService.getByExperimentId(reportQueryDTO.getExperimentId()));
+ }
}
reportQueryDTO.setExperimentCode(experimentById.getExperimentCode());
@@ -236,6 +268,9 @@
reportQueryDTO.setUpdateByUserName(userInfo.getRealName());
}
}
+
+
+
}
searchResult.setData(reportAppQueryDTOS);
@@ -243,12 +278,13 @@
return searchResult;
}
+
/**
* 风险评估报告 - 生成报告信息
*/
@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() ,"当前用户无效,请重新登陆");
@@ -269,9 +305,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_REPORT.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;
//获取该实验的所有计划信息
@@ -291,11 +338,11 @@
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() ,"实验责任人信息不存在");
+// }
//检查该实验所有的评价结果,遍历评价结果等级
@@ -369,9 +416,11 @@
reportInfo.setSafeRiskAnalysis(analysis.toString());
reportInfo.setAssessPerson(null);
- reportInfo.setAssessLevel(null);
- reportInfo.setDepId(null); //todo 不确定是否需要部门
- reportInfo.setSafeRiskAnalysis(null); //todo 安全风险分析,暂时不知道数据来源,先设空
+ reportInfo.setAssessLevel(StatusEnum.REPORT_LEVEL_1.getCode().byteValue());
+ //todo 不确定是否需要部门
+ reportInfo.setDepId(null);
+// reportInfo.setSafeRiskAnalysis(null);
+
//修改实验 4 生成报告,
@@ -454,6 +503,16 @@
return BeanCopyUtils.copyBean(saveResult, ReportInsertDTO.class);
+ }
+
+ 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());
+
+ }
}
/**
@@ -557,6 +616,9 @@
reportById.setAssessPerson(reportUpdateBO.getAssessPerson());
reportById.setAssessLevel(reportUpdateBO.getAssessLevel());
reportById.setDescription(reportUpdateBO.getDescription());
+ if(!ObjectUtils.isEmpty(reportUpdateBO.getSafeRiskAnalysis())){
+ reportById.setSafeRiskAnalysis(reportUpdateBO.getSafeRiskAnalysis());
+ }
reportById.setUpdateTime(LocalDateTime.now());
reportById.setUpdateByUserId(currentUserId);
@@ -724,6 +786,7 @@
* 风险评估报告 - 报告审核 - 新 - 单次审核
*/
@Override
+ @Transactional
public int reportNew(Long currentUserId, ReportReqBO reportReqBO) {
if (currentUserId < 0){
--
Gitblit v1.9.2