| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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.*; |
| | | import com.gkhy.labRiskManage.domain.riskReport.model.bo.ReportQueryBO; |
| | | import com.gkhy.labRiskManage.domain.riskReport.model.bo.RiskPlanMethodBO; |
| | | import com.gkhy.labRiskManage.domain.riskReport.model.bo.UpdateExperimentInfoBO; |
| | | import com.gkhy.labRiskManage.domain.riskReport.model.dto.*; |
| | | import com.gkhy.labRiskManage.domain.riskReport.repository.jpa.ReportRiskAssessInfoRepository; |
| | |
| | | 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; |
| | | 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; |
| | | |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private RiskAssessPlanEvaluateRsService rsService; |
| | | |
| | | @Autowired |
| | | private ExperimentAndTypeService experimentAndTypeService; |
| | | |
| | | @Autowired |
| | | private OldRiskAssessService oldRiskAssessService; |
| | | |
| | | |
| | | @Autowired |
| | | private RiskAssessPlanIdentificationAnalogyService analogyService; |
| | | @Autowired |
| | | private RiskAssessPlanIdentificationHazopService hazopService; |
| | | @Autowired |
| | | private RiskAssessPlanIdentificationJhaService jhaService; |
| | | @Autowired |
| | | private RiskAssessPlanIdentificationPhaService phaService; |
| | | @Autowired |
| | | private RiskAssessPlanIdentificationSclService sclService; |
| | | |
| | | |
| | | /** |
| | | * 风险评估报告 - 查询 |
| | |
| | | if (ObjectUtils.isEmpty(queryBO.getTag())){ |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR.getCode() ,"查询报告类别参数缺失"); |
| | | } |
| | | if (queryBO.getExperimentName() == "null"){ |
| | | if (queryBO.getExperimentName() == ""){ |
| | | queryBO.setExperimentName(null); |
| | | } |
| | | if (queryBO.getExportTag() == null){ |
| | | queryBO.setExportTag(false); |
| | | } |
| | | UserInfoDomainDTO user = userDomainService.getUserById(currentUserId); |
| | | if (ObjectUtils.isEmpty(user)){ |
| | |
| | | predicateList.add(criteriaBuilder.equal(root.get("experimentId"),queryParam.getExperimentId())); |
| | | } |
| | | if (!ObjectUtils.isEmpty(queryParam.getExperimentName())){ |
| | | predicateList.add(criteriaBuilder.equal(root.get("experimentName"), queryParam.getExperimentName())); |
| | | predicateList.add(criteriaBuilder.like(root.get("experimentName"),"%"+queryParam.getExperimentName()+"%")); |
| | | } |
| | | if (roleTag == UserTagEnum.USER_TAG_0.getCode()){ |
| | | predicateList.add(criteriaBuilder.equal(root.get("personUserId"), currentUserId)); |
| | |
| | | if (queryParam.getTag() == 1){ |
| | | predicateList.add(criteriaBuilder.isNull(root.get("assessPerson"))); |
| | | }else if (queryParam.getTag() == 2){ |
| | | predicateList.add(criteriaBuilder.isNotNull(root.get("assessPerson"))); |
| | | predicateList.add(criteriaBuilder.isNotNull(root.get("assessPerson")) |
| | | ); |
| | | } |
| | | //现在领导能查看所有的报告 |
| | | // if (roleTag == UserTagEnum.USER_TAG_2.getCode()){ |
| | |
| | | List<ReportAppQueryDTO> reportAppQueryDTOS = BeanCopyUtils.copyBeanList(reportQueryDTOS, ReportAppQueryDTO.class); |
| | | |
| | | List<UserInfoDomainDTO> userList = userDomainService.getUserList(); |
| | | |
| | | |
| | | for (ReportAppQueryDTO reportQueryDTO : reportAppQueryDTOS) { |
| | | //获取审批人员 |
| | | List<ReportPersonQueryRespDTO> personByReportId = reportPersonService.listPersonByReportId(reportQueryDTO.getId()); |
| | |
| | | //获取评估计划 |
| | | 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 (queryBO.getExportTag()){ |
| | | reportQueryDTO.setRiskPlanMethodBO(getRiskPlanMethodBO(assessPlanByExperimentId)); |
| | | } |
| | | for (AssessPlanQueryDTO assessPlan : assessPlanByExperimentId) { |
| | | |
| | | if (assessPlan.getEvaluateTime() != null){ |
| | | if (reportQueryDTO.getEvaluateTime().isBefore(assessPlan.getEvaluateTime())){ |
| | | reportQueryDTO.setEvaluateTime(assessPlan.getEvaluateTime()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | if (!ObjectUtils.isEmpty(riskSourceByReportId)){ |
| | |
| | | } |
| | | 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()); |
| | | |
| | | for (UserInfoDomainDTO userInfo : userList) { |
| | | if (userInfo.getId() == reportQueryDTO.getCreateByUserId()){ |
| | | if (Objects.equals(userInfo.getId(), reportQueryDTO.getCreateByUserId())){ |
| | | reportQueryDTO.setCreateByUserName(userInfo.getRealName()); |
| | | } |
| | | if (userInfo.getId() == reportQueryDTO.getUpdateByUserId()){ |
| | | if (Objects.equals(userInfo.getId(), reportQueryDTO.getUpdateByUserId())){ |
| | | reportQueryDTO.setUpdateByUserName(userInfo.getRealName()); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | searchResult.setData(reportAppQueryDTOS); |
| | |
| | | return searchResult; |
| | | } |
| | | |
| | | private List<RiskPlanMethodBO> getRiskPlanMethodBO(List<AssessPlanQueryDTO> assessPlanByExperimentId) { |
| | | |
| | | List<RiskPlanMethodBO> riskPlanMethodBOList = new ArrayList<>(); |
| | | for (AssessPlanQueryDTO assessPlanQueryDTO : assessPlanByExperimentId) { |
| | | //辨识方法 1-PHA; |
| | | if (assessPlanQueryDTO.getIdentificationMethod() == 1) { |
| | | List<PhaQueryDTO> phaQueryDTOS = phaService.listPhaByPlanId(assessPlanQueryDTO.getId()); |
| | | if (ObjectUtils.isEmpty(phaQueryDTOS)){ |
| | | continue; |
| | | } |
| | | for (PhaQueryDTO phaQueryDTO : phaQueryDTOS) { |
| | | RiskPlanMethodBO riskPlanMethodBO = new RiskPlanMethodBO(); |
| | | riskPlanMethodBO.setAssessPlanName(assessPlanQueryDTO.getAssessPlanName()); |
| | | riskPlanMethodBO.setCheckItem(phaQueryDTO.getPhaCheckItem()); |
| | | riskPlanMethodBO.setRiskFactor(phaQueryDTO.getPhaRiskFactor()); |
| | | riskPlanMethodBO.setResult(phaQueryDTO.getPhaResult()); |
| | | riskPlanMethodBO.setIdentificationMethod(assessPlanQueryDTO.getIdentificationMethod()); |
| | | riskPlanMethodBO.setEvaluateMethod(assessPlanQueryDTO.getEvaluateMethod()); |
| | | dealRiskPlanMethodBO(assessPlanQueryDTO,riskPlanMethodBO,phaQueryDTO.getId()); |
| | | riskPlanMethodBOList.add(riskPlanMethodBO); |
| | | } |
| | | |
| | | //辨识方法 2-JHA; |
| | | } else if (assessPlanQueryDTO.getIdentificationMethod() == 2) { |
| | | List<JhaQueryDTO> jhaQueryDTOS = jhaService.listJhaByPlanId(assessPlanQueryDTO.getId()); |
| | | if (ObjectUtils.isEmpty(jhaQueryDTOS)){ |
| | | continue; |
| | | } |
| | | for (JhaQueryDTO jhaQueryDTO : jhaQueryDTOS) { |
| | | RiskPlanMethodBO riskPlanMethodBO = new RiskPlanMethodBO(); |
| | | riskPlanMethodBO.setAssessPlanName(assessPlanQueryDTO.getAssessPlanName()); |
| | | riskPlanMethodBO.setCheckItem(jhaQueryDTO.getJhaCheckItem()); |
| | | riskPlanMethodBO.setRiskFactor(jhaQueryDTO.getJhaRiskFactor()); |
| | | riskPlanMethodBO.setResult(jhaQueryDTO.getJhaResult()); |
| | | riskPlanMethodBO.setIdentificationMethod(assessPlanQueryDTO.getIdentificationMethod()); |
| | | riskPlanMethodBO.setEvaluateMethod(assessPlanQueryDTO.getEvaluateMethod()); |
| | | dealRiskPlanMethodBO(assessPlanQueryDTO,riskPlanMethodBO,jhaQueryDTO.getId()); |
| | | riskPlanMethodBOList.add(riskPlanMethodBO); |
| | | } |
| | | |
| | | //辨识方法 3-SCL; |
| | | } else if (assessPlanQueryDTO.getIdentificationMethod() == 3) { |
| | | List<SclQueryDTO> sclQueryDTOS = sclService.listSclByPlanId(assessPlanQueryDTO.getId()); |
| | | if (ObjectUtils.isEmpty(sclQueryDTOS)){ |
| | | continue; |
| | | } |
| | | for (SclQueryDTO sclQueryDTO : sclQueryDTOS) { |
| | | RiskPlanMethodBO riskPlanMethodBO = new RiskPlanMethodBO(); |
| | | riskPlanMethodBO.setAssessPlanName(assessPlanQueryDTO.getAssessPlanName()); |
| | | riskPlanMethodBO.setCheckItem(sclQueryDTO.getSclCheckItem()); |
| | | riskPlanMethodBO.setRiskFactor(sclQueryDTO.getSclCheckStandard()); |
| | | riskPlanMethodBO.setResult(sclQueryDTO.getSclCheckResult()); |
| | | riskPlanMethodBO.setIdentificationMethod(assessPlanQueryDTO.getIdentificationMethod()); |
| | | riskPlanMethodBO.setEvaluateMethod(assessPlanQueryDTO.getEvaluateMethod()); |
| | | dealRiskPlanMethodBO(assessPlanQueryDTO,riskPlanMethodBO,sclQueryDTO.getId()); |
| | | riskPlanMethodBOList.add(riskPlanMethodBO); |
| | | } |
| | | //辨识方法 4-HAZOP; |
| | | } else if (assessPlanQueryDTO.getIdentificationMethod() == 4) { |
| | | List<HazopQueryDTO> hazopQueryDTOS = hazopService.listHazopByPlanId(assessPlanQueryDTO.getId()); |
| | | if (ObjectUtils.isEmpty(hazopQueryDTOS)){ |
| | | continue; |
| | | } |
| | | for (HazopQueryDTO hazopQueryDTO : hazopQueryDTOS) { |
| | | RiskPlanMethodBO riskPlanMethodBO = new RiskPlanMethodBO(); |
| | | riskPlanMethodBO.setAssessPlanName(assessPlanQueryDTO.getAssessPlanName()); |
| | | riskPlanMethodBO.setCheckItem(hazopQueryDTO.getHazopNode()); |
| | | riskPlanMethodBO.setRiskFactor(hazopQueryDTO.getHazopParam()); |
| | | riskPlanMethodBO.setResult(hazopQueryDTO.getHazopResult()); |
| | | riskPlanMethodBO.setIdentificationMethod(assessPlanQueryDTO.getIdentificationMethod()); |
| | | riskPlanMethodBO.setEvaluateMethod(assessPlanQueryDTO.getEvaluateMethod()); |
| | | dealRiskPlanMethodBO(assessPlanQueryDTO,riskPlanMethodBO,hazopQueryDTO.getId()); |
| | | riskPlanMethodBOList.add(riskPlanMethodBO); |
| | | } |
| | | //5-类比法 analogy; |
| | | } else if (assessPlanQueryDTO.getIdentificationMethod() == 5) { |
| | | List<AnalogyQueryDTO> analogyQueryDTOS = analogyService.listAnalogyByPlanId(assessPlanQueryDTO.getId()); |
| | | if (ObjectUtils.isEmpty(analogyQueryDTOS)){ |
| | | continue; |
| | | } |
| | | for (AnalogyQueryDTO analogyQueryDTO : analogyQueryDTOS) { |
| | | RiskPlanMethodBO riskPlanMethodBO = new RiskPlanMethodBO(); |
| | | riskPlanMethodBO.setAssessPlanName(assessPlanQueryDTO.getAssessPlanName()); |
| | | riskPlanMethodBO.setCheckItem(analogyQueryDTO.getAnalogyCheckItem()); |
| | | riskPlanMethodBO.setRiskFactor(analogyQueryDTO.getAnalogyRiskFactor()); |
| | | riskPlanMethodBO.setResult(analogyQueryDTO.getAnalogyResult()); |
| | | riskPlanMethodBO.setIdentificationMethod(assessPlanQueryDTO.getIdentificationMethod()); |
| | | riskPlanMethodBO.setEvaluateMethod(assessPlanQueryDTO.getEvaluateMethod()); |
| | | dealRiskPlanMethodBO(assessPlanQueryDTO,riskPlanMethodBO,analogyQueryDTO.getId()); |
| | | riskPlanMethodBOList.add(riskPlanMethodBO); |
| | | } |
| | | } |
| | | } |
| | | return riskPlanMethodBOList; |
| | | } |
| | | |
| | | private void dealRiskPlanMethodBO(AssessPlanQueryDTO assessPlanQueryDTO, RiskPlanMethodBO riskPlanMethodBO,Long dataId) { |
| | | //lec 方法 |
| | | if (assessPlanQueryDTO.getEvaluateMethod() == 1){ |
| | | List<RiskAssessPlanEvaluateLec> riskAssessPlanEvaluateLecs = |
| | | lecService.listLecByParam(assessPlanQueryDTO.getId(), dataId, assessPlanQueryDTO.getIdentificationMethod()); |
| | | if (!ObjectUtils.isEmpty(riskAssessPlanEvaluateLecs)){ |
| | | riskPlanMethodBO.setRiskLevel(riskAssessPlanEvaluateLecs.get(0).getRiskLevel()); |
| | | riskPlanMethodBO.setEvaluateDesc(riskAssessPlanEvaluateLecs.get(0).getEvaluateDesc()); |
| | | } |
| | | }else if (assessPlanQueryDTO.getEvaluateMethod() == 2){ |
| | | List<RiskAssessPlanEvaluateLs> riskAssessPlanEvaluateLs = lsService.listLsByParam(assessPlanQueryDTO.getId(), dataId, assessPlanQueryDTO.getIdentificationMethod()); |
| | | if (!ObjectUtils.isEmpty(riskAssessPlanEvaluateLs)){ |
| | | riskPlanMethodBO.setRiskLevel(riskAssessPlanEvaluateLs.get(0).getRiskLevel()); |
| | | riskPlanMethodBO.setEvaluateDesc(riskAssessPlanEvaluateLs.get(0).getEvaluateDesc()); |
| | | } |
| | | }else if (assessPlanQueryDTO.getEvaluateMethod() == 3){ |
| | | List<RiskAssessPlanEvaluateMes> riskAssessPlanEvaluateMes = mesService.listMesByParam(assessPlanQueryDTO.getId(), dataId, assessPlanQueryDTO.getIdentificationMethod()); |
| | | if (!ObjectUtils.isEmpty(riskAssessPlanEvaluateMes)){ |
| | | riskPlanMethodBO.setRiskLevel(riskAssessPlanEvaluateMes.get(0).getRiskLevel()); |
| | | riskPlanMethodBO.setEvaluateDesc(riskAssessPlanEvaluateMes.get(0).getEvaluateDesc()); |
| | | } |
| | | |
| | | }else if (assessPlanQueryDTO.getEvaluateMethod() == 4){ |
| | | List<RiskAssessPlanEvaluateRs> riskAssessPlanEvaluateRs = rsService.listRsByParam(assessPlanQueryDTO.getId(), dataId, assessPlanQueryDTO.getIdentificationMethod()); |
| | | if (!ObjectUtils.isEmpty(riskAssessPlanEvaluateRs)){ |
| | | riskPlanMethodBO.setRiskLevel(riskAssessPlanEvaluateRs.get(0).getRiskLevel()); |
| | | riskPlanMethodBO.setEvaluateDesc(riskAssessPlanEvaluateRs.get(0).getEvaluateDesc()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 风险评估报告 - 生成报告信息 |
| | | */ |
| | | @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() ,"当前用户无效,请重新登陆"); |
| | |
| | | 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; |
| | | //获取该实验的所有计划信息 |
| | | List<AssessPlanQueryDTO> assessPlanList = assessPlanService.getAssessPlanByExperimentId(id); |
| | | Map<Long, String> assessPlanMap = assessPlanList.stream() |
| | | .collect(Collectors.toMap( |
| | | AssessPlanQueryDTO::getId, |
| | | AssessPlanQueryDTO::getAssessPlanName |
| | | )); |
| | | int tag = 0; |
| | | StringBuilder info = new StringBuilder(); |
| | | List<Long> assessPlanIds = new ArrayList<>(); |
| | |
| | | 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); |
| | |
| | | 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 安全风险分析 |
| | | analysis.append(a +(ObjectUtils.isEmpty(assessPlanMap.get(lecById.getAssessPlanId())) ? "" : assessPlanMap.get(lecById.getAssessPlanId()))+ lecById.getSafeRiskAnalysis() + ";");//todo 安全风险分析 |
| | | a++; |
| | | } |
| | | } |
| | |
| | | if (lsByIds .size() > 0){ |
| | | for (RiskAssessPlanEvaluateLs lsById : lsByIds) { |
| | | if (lsById.getRiskLevel() > level){ |
| | | riskLevelList.add(lsById.getRiskLevel()); |
| | | level = lsById.getRiskLevel(); |
| | | analysis.append(a + lsById.getSafeRiskAnalysis() + ";"); |
| | | analysis.append(a +(ObjectUtils.isEmpty(assessPlanMap.get(lsById.getAssessPlanId())) ? "" : assessPlanMap.get(lsById.getAssessPlanId()))+ lsById.getSafeRiskAnalysis() + ";"); |
| | | a++; |
| | | } |
| | | } |
| | |
| | | if (mesByIds .size() > 0){ |
| | | for (RiskAssessPlanEvaluateMes mesById : mesByIds) { |
| | | if (mesById.getRiskLevel() > level){ |
| | | riskLevelList.add(mesById.getRiskLevel()); |
| | | level = mesById.getRiskLevel(); |
| | | analysis.append(a + mesById.getSafeRiskAnalysis() + ";"); |
| | | analysis.append(a +(ObjectUtils.isEmpty(assessPlanMap.get(mesById.getAssessPlanId())) ? "" : assessPlanMap.get(mesById.getAssessPlanId()))+ mesById.getSafeRiskAnalysis() + ";"); |
| | | a++; |
| | | } |
| | | } |
| | |
| | | if (rsByIds .size() > 0){ |
| | | for (RiskAssessPlanEvaluateRs rsById : rsByIds) { |
| | | if (rsById.getRiskLevel() > level){ |
| | | riskLevelList.add(rsById.getRiskLevel()); |
| | | level = rsById.getRiskLevel(); |
| | | analysis.append(a + rsById.getSafeRiskAnalysis() + ";"); |
| | | analysis.append(a +(ObjectUtils.isEmpty(assessPlanMap.get(rsById.getAssessPlanId())) ? "" : assessPlanMap.get(rsById.getAssessPlanId()))+ rsById.getSafeRiskAnalysis() + ";"); |
| | | a++; |
| | | } |
| | | } |
| | |
| | | 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 生成报告, |
| | |
| | | |
| | | 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()); |
| | | |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | reportById.setAssessPerson(reportUpdateBO.getAssessPerson()); |
| | | reportById.setAssessLevel(reportUpdateBO.getAssessLevel()); |
| | | // reportById.setSafeRiskAnalysis(reportUpdateBO.getSafeRiskAnalysis()); |
| | | reportById.setDescription(reportUpdateBO.getDescription()); |
| | | if(!ObjectUtils.isEmpty(reportUpdateBO.getSafeRiskAnalysis())){ |
| | | reportById.setSafeRiskAnalysis(reportUpdateBO.getSafeRiskAnalysis()); |
| | | } |
| | | reportById.setUpdateTime(LocalDateTime.now()); |
| | | reportById.setUpdateByUserId(currentUserId); |
| | | |
| | |
| | | * 风险评估报告 - 报告审核 - 新 - 单次审核 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public int reportNew(Long currentUserId, ReportReqBO reportReqBO) { |
| | | |
| | | if (currentUserId < 0){ |