package com.gkhy.labRiskManage.application.riskReport.service.impl; import com.gkhy.labRiskManage.api.controller.riskReport.dto.repDto.*; import com.gkhy.labRiskManage.api.controller.riskReport.dto.respDto.RiskAssessPlanListRespDTO; import com.gkhy.labRiskManage.api.controller.riskReport.dto.respDto.RiskUnitListQueryRespDTO; import com.gkhy.labRiskManage.application.riskReport.dto.bo.*; import com.gkhy.labRiskManage.application.riskReport.dto.dto.*; import com.gkhy.labRiskManage.application.riskReport.service.RiskAccessAppService; import com.gkhy.labRiskManage.commons.domain.SearchResult; import com.gkhy.labRiskManage.commons.enums.ResultCode; import com.gkhy.labRiskManage.commons.enums.StatusEnum; import com.gkhy.labRiskManage.commons.enums.UserRoleEnum; import com.gkhy.labRiskManage.commons.exception.BusinessException; import com.gkhy.labRiskManage.commons.utils.BeanCopyUtils; import com.gkhy.labRiskManage.domain.account.model.dto.SysUserRoleBindDomainDTO; import com.gkhy.labRiskManage.domain.account.model.dto.UserInfoDomainDTO; import com.gkhy.labRiskManage.domain.account.service.UserDomainService; import com.gkhy.labRiskManage.domain.basic.model.dto.PersonQueryDTO; import com.gkhy.labRiskManage.domain.basic.model.dto.RiskUnitBasicQueryDTO; import com.gkhy.labRiskManage.domain.experiment.model.dto.ExperimentInfoDTO; import com.gkhy.labRiskManage.domain.riskReport.entity.*; import com.gkhy.labRiskManage.domain.riskReport.model.bo.AssessLSInsertBO; import com.gkhy.labRiskManage.domain.riskReport.model.bo.AssessLecInsertBO; import com.gkhy.labRiskManage.domain.riskReport.model.bo.AssessMesInsertBO; import com.gkhy.labRiskManage.domain.riskReport.model.bo.AssessRsInsertBO; import com.gkhy.labRiskManage.domain.riskReport.model.dto.*; import com.gkhy.labRiskManage.domain.basic.service.BasicExperimentPersonService; import com.gkhy.labRiskManage.domain.basic.service.BasicRiskUnitService; import com.gkhy.labRiskManage.domain.experiment.service.ExperimentInfoService; import com.gkhy.labRiskManage.domain.riskReport.service.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.ObjectUtils; import java.math.BigDecimal; import java.util.List; @Service public class RiskAccessAppServiceImpl implements RiskAccessAppService { @Autowired private RiskAssessPlanService assessPlanService; @Autowired private RiskUnitService riskUnitService; @Autowired private ExperimentInfoService experimentInfoService; @Autowired private BasicRiskUnitService basicRiskUnitService; @Autowired private BasicExperimentPersonService basicExperimentPersonService; @Autowired private RiskAssessPlanIdentificationAnalogyService analogyService; @Autowired private RiskAssessPlanIdentificationHazopService hazopService; @Autowired private RiskAssessPlanIdentificationJhaService jhaService; @Autowired private RiskAssessPlanIdentificationPhaService phaService; @Autowired private RiskAssessPlanIdentificationSclService sclService; @Autowired private RiskAssessPlanEvaluateLecService lecService; @Autowired private RiskAssessPlanEvaluateLsService lsService; @Autowired private RiskAssessPlanEvaluateMesService mesService; @Autowired private RiskAssessPlanEvaluateRsService rsService; @Autowired private UserDomainService userDomainService; /** * 风险评估计划 - 插入 */ @Override public int insertAssessPlan(Long currentUserId, RiskAssessPlanInsertReqBO assessPlanInsertReqDTO) { if (currentUserId < 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录"); } // RiskUnitQueryDTO riskUnitById = riskUnitService.getRiskUnitById(assessPlanInsertReqDTO.getRiskUnitId()); // UserInfoDomainDTO userInfoById = userDomainService.getUserInfoById(currentUserId); // if (!userInfoById.getId().equals(riskUnitById.getLiabilityUserId())){ // throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "只有实验负责人,才能修改实验风险单元"); // } RiskAssessPlanAppInsertBO insertParam = BeanCopyUtils.copyBean(assessPlanInsertReqDTO, RiskAssessPlanAppInsertBO.class); PlanInsertDTO planInsertDTO = assessPlanService.insertAssessPlan(currentUserId, insertParam); if (ObjectUtils.isEmpty(planInsertDTO)){ return StatusEnum.FAIL.getCode(); } return StatusEnum.SUCCESS.getCode(); } /** * 风险评估计划 - 查询 */ @Override public SearchResult selectAssessPlanPage(Long currentUserId, RiskAssessPlanQueryReqBO queryReqBO) { SearchResult searchResult = new SearchResult<>(); RiskAssessPlanAppQueryBO queryParam = BeanCopyUtils.copyBean(queryReqBO, RiskAssessPlanAppQueryBO.class); SearchResult queryResult = assessPlanService.selectAssessPlanPage(currentUserId, queryParam); searchResult.setPageIndex(queryResult.getPageIndex()); searchResult.setPageSize(queryResult.getPageSize()); searchResult.setTotal(queryResult.getTotal()); searchResult.setData(BeanCopyUtils.copyRiskAssessPlanAppQueryList(queryResult.getData(), RiskAssessPlanAppQueryDTO.class)); return searchResult; } /** * 风险评估计划 - 修改 */ @Override public int updateAssessPlan(Long currentUserId, RiskAssessPlanUpdateReqBO updateReqBO) { if (currentUserId < 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录"); } RiskAssessPlanUpdateReqBO updateParam = BeanCopyUtils.copyBean(updateReqBO, RiskAssessPlanUpdateReqBO.class); AssessPlanUpdateDTO assessPlanUpdateDTO = assessPlanService.updateAssessPlan(currentUserId, updateParam); if (ObjectUtils.isEmpty(assessPlanUpdateDTO)){ return StatusEnum.FAIL.getCode(); } return StatusEnum.SUCCESS.getCode(); } /** * 风险评估计划 - 删除 */ @Override public int deleteAssessPlan(Long currentUserId, Long id) { if (currentUserId < 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录"); } AssessPlanDeleteDTO deleteResult = assessPlanService.deleteAssessPlan(currentUserId, id); if (ObjectUtils.isEmpty(deleteResult)){ return StatusEnum.FAIL.getCode(); } return StatusEnum.SUCCESS.getCode(); } /** * 风险评估计划 - 派发任务 */ @Override public int sellAssessPlan(Long currentUserId, Long id) { if (currentUserId < 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录"); } AssessPlanUpdateDTO sellResult = assessPlanService.sellAssessPlan(currentUserId, id); if (ObjectUtils.isEmpty(sellResult)){ return StatusEnum.FAIL.getCode(); } return StatusEnum.SUCCESS.getCode(); } /** * 风险评估计划 - 辨识 */ @Override @Transactional public FactorQueryDTO identification(Long currentUserId, RiskAssessPlanIdentificationInsertReqBO identificationReqBO) { if (currentUserId < 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录"); } RiskAssessPlanAppIdentificationBO identificationParam = BeanCopyUtils.copyBean(identificationReqBO, RiskAssessPlanAppIdentificationBO.class); int tag = 1; FactorQueryDTO factorQueryDTO = new FactorQueryDTO(); PhaInsertDTO phaInsertDTO = new PhaInsertDTO(); JhaInsertDTO jhaInsertDTO = new JhaInsertDTO(); SclInsertDTO sclInsertDTO = new SclInsertDTO(); HazopInsertDTO hazopInsertDTO = new HazopInsertDTO(); AnalogyInsertDTO analogyInsertDTO = new AnalogyInsertDTO(); //分发参数到不同的服务进行处理 //辨识方法 1-PHA; if (identificationParam.getIdentificationMethod() == 1){ RiskAssessPlanIdentificationPha pha = BeanCopyUtils.copyBean(identificationParam, RiskAssessPlanIdentificationPha.class); pha.setAssessPlanId(identificationParam.getId()); phaInsertDTO = phaService.insertPha(currentUserId, pha); if (ObjectUtils.isEmpty(phaInsertDTO)){ tag = 0; } factorQueryDTO = BeanCopyUtils.copyBean(phaInsertDTO, FactorQueryDTO.class); factorQueryDTO.setPhaId(phaInsertDTO.getId()); //辨识方法 2-JHA; }else if (identificationParam.getIdentificationMethod() == 2){ RiskAssessPlanIdentificationJha jha = BeanCopyUtils.copyBean(identificationParam, RiskAssessPlanIdentificationJha.class); jha.setAssessPlanId(identificationParam.getId()); jhaInsertDTO = jhaService.insertJha(currentUserId, jha); if (ObjectUtils.isEmpty(jhaInsertDTO)){ tag = 0; } factorQueryDTO = BeanCopyUtils.copyBean(jhaInsertDTO, FactorQueryDTO.class); factorQueryDTO.setJhaId(jhaInsertDTO.getId()); //辨识方法 3-SCL; }else if (identificationParam.getIdentificationMethod() == 3){ RiskAssessPlanIdentificationScl scl = BeanCopyUtils.copyBean(identificationParam, RiskAssessPlanIdentificationScl.class); scl.setAssessPlanId(identificationParam.getId()); sclInsertDTO = sclService.insertScl(currentUserId, scl); if (ObjectUtils.isEmpty(sclInsertDTO)){ tag = 0; } factorQueryDTO = BeanCopyUtils.copyBean(sclInsertDTO, FactorQueryDTO.class); factorQueryDTO.setSclId(sclInsertDTO.getId()); //辨识方法 4-HAZOP; }else if (identificationParam.getIdentificationMethod() == 4){ RiskAssessPlanIdentificationHazop hazop = BeanCopyUtils.copyBean(identificationParam, RiskAssessPlanIdentificationHazop.class); hazop.setAssessPlanId(identificationParam.getId()); hazopInsertDTO = hazopService.insertHazop(currentUserId, hazop); if (ObjectUtils.isEmpty(hazopInsertDTO)){ tag = 0; } factorQueryDTO = BeanCopyUtils.copyBean(hazopInsertDTO, FactorQueryDTO.class); factorQueryDTO.setHazopId(hazopInsertDTO.getId()); //5-类比法 nalogy; }else if (identificationParam.getIdentificationMethod() == 5){ RiskAssessPlanIdentificationAnalogy analogy = BeanCopyUtils.copyBean(identificationParam, RiskAssessPlanIdentificationAnalogy.class); analogy.setAssessPlanId(identificationParam.getId()); analogyInsertDTO = analogyService.insertAnalogy(currentUserId, analogy); if (ObjectUtils.isEmpty(analogyInsertDTO)){ tag = 0; } factorQueryDTO = BeanCopyUtils.copyBean(analogyInsertDTO, FactorQueryDTO.class); factorQueryDTO.setAnalogyId(analogyInsertDTO.getId()); }else { throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR.getCode(), "请选择正确的辨识方法"); } //处理评估计划表 AssessPlanIdentificationDTO identificationResult = assessPlanService.identification(currentUserId, identificationParam); if (ObjectUtils.isEmpty(identificationResult) && tag == 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR.getCode(), "新增辨识失败"); } return factorQueryDTO; } /** * 风险评估计划 - 辨识修改 */ @Transactional @Override public FactorQueryDTO updateIdentification(Long currentUserId, RiskAssessPlanIdentificationUpdateReqBO updateReqBO) { if (currentUserId < 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录"); } RiskAssessPlanIdentificationAppUpdateBO updateParam = BeanCopyUtils.copyBean(updateReqBO, RiskAssessPlanIdentificationAppUpdateBO.class); int tag = 1; FactorQueryDTO factorQueryDTO = new FactorQueryDTO(); //分发参数到不同的服务进行处理 //辨识方法 1-PHA; if (updateParam.getIdentificationMethod() == 1){ RiskAssessPlanIdentificationPha pha = BeanCopyUtils.copyBean(updateParam, RiskAssessPlanIdentificationPha.class); pha.setAssessPlanId(updateParam.getId()); pha.setId(updateParam.getPhaId()); PhaInsertDTO phaInsertDTO = phaService.updatePha(currentUserId, pha); if (ObjectUtils.isEmpty(phaInsertDTO)){ tag = 0; } factorQueryDTO = BeanCopyUtils.copyBean(phaInsertDTO, FactorQueryDTO.class); factorQueryDTO.setPhaId(phaInsertDTO.getId()); //辨识方法 2-JHA; }else if (updateParam.getIdentificationMethod() == 2){ RiskAssessPlanIdentificationJha jha = BeanCopyUtils.copyBean(updateParam, RiskAssessPlanIdentificationJha.class); jha.setAssessPlanId(updateParam.getId()); jha.setId(updateParam.getJhaId()); JhaInsertDTO jhaInsertDTO = jhaService.updateJha(currentUserId, jha); if (ObjectUtils.isEmpty(jhaInsertDTO)){ tag = 0; } factorQueryDTO = BeanCopyUtils.copyBean(jhaInsertDTO, FactorQueryDTO.class); factorQueryDTO.setJhaId(jhaInsertDTO.getId()); //辨识方法 3-SCL; }else if (updateParam.getIdentificationMethod() == 3){ RiskAssessPlanIdentificationScl scl = BeanCopyUtils.copyBean(updateParam, RiskAssessPlanIdentificationScl.class); scl.setAssessPlanId(updateParam.getId()); scl.setId(updateParam.getSclId()); SclInsertDTO sclInsertDTO = sclService.updateScl(currentUserId, scl); if (ObjectUtils.isEmpty(sclInsertDTO)){ tag = 0; } factorQueryDTO = BeanCopyUtils.copyBean(sclInsertDTO, FactorQueryDTO.class); factorQueryDTO.setSclId(sclInsertDTO.getId()); //辨识方法 4-HAZOP; }else if (updateParam.getIdentificationMethod() == 4){ RiskAssessPlanIdentificationHazop hazop = BeanCopyUtils.copyBean(updateParam, RiskAssessPlanIdentificationHazop.class); hazop.setAssessPlanId(updateParam.getId()); hazop.setId(updateParam.getHazopId()); HazopInsertDTO hazopInsertDTO = hazopService.updateHazop(currentUserId, hazop); if (ObjectUtils.isEmpty(hazopInsertDTO)){ tag = 0; } factorQueryDTO = BeanCopyUtils.copyBean(hazopInsertDTO, FactorQueryDTO.class); factorQueryDTO.setHazopId(hazopInsertDTO.getId()); //5-类比法 nalogy; }else if (updateParam.getIdentificationMethod() == 5){ RiskAssessPlanIdentificationAnalogy analogy = BeanCopyUtils.copyBean(updateParam, RiskAssessPlanIdentificationAnalogy.class); analogy.setAssessPlanId(updateParam.getId()); analogy.setId(updateParam.getAnalogyId()); AnalogyInsertDTO analogyInsertDTO = analogyService.updateAnalogy(currentUserId, analogy); if (ObjectUtils.isEmpty(analogyInsertDTO)){ tag = 0; } factorQueryDTO = BeanCopyUtils.copyBean(analogyInsertDTO, FactorQueryDTO.class); factorQueryDTO.setAnalogyId(analogyInsertDTO.getId()); }else { throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR.getCode(), "请选择正确的辨识方法"); } RiskAssessPlanAppIdentificationBO riskAssessPlanAppIdentificationBO = BeanCopyUtils.copyBean(updateReqBO, RiskAssessPlanAppIdentificationBO.class); //处理评估计划表 AssessPlanIdentificationDTO identificationResult = assessPlanService.identification(currentUserId, riskAssessPlanAppIdentificationBO); if (ObjectUtils.isEmpty(identificationResult) && tag == 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR.getCode(), "修改辨识失败"); } return factorQueryDTO; } /** * 风险评估计划 - 辨识删除 */ @Override public int deleteIdentification(Long currentUserId, RiskAssessPlanIdentificationDeleteReqBO deleteReqBO) { if (currentUserId < 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录"); } AssessPlanUpdateDTO deleteResult = assessPlanService.deleteIdentification(currentUserId, deleteReqBO); if (ObjectUtils.isEmpty(deleteResult)){ return StatusEnum.FAIL.getCode(); } return StatusEnum.SUCCESS.getCode(); } /** * 风险评估计划 - 辨识结果提交 */ @Override public int identificationSubmit(Long currentUserId, Long id) { if (currentUserId < 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录"); } AssessPlanUpdateDTO identificationSubmitResult= assessPlanService.identificationSubmit(currentUserId, id); if (ObjectUtils.isEmpty(identificationSubmitResult)){ return StatusEnum.FAIL.getCode(); } return StatusEnum.SUCCESS.getCode(); } /** * 风险评估计划 - 评价 */ @Transactional @Override public FactorQueryDTO evaluate(Long currentUserId, RiskAssessPlanEvaluateInsertReqBO evaluateReqBO) { if (currentUserId < 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录"); } RiskAssessPlanAppEvaluateBO evaluateParam = BeanCopyUtils.copyBean(evaluateReqBO, RiskAssessPlanAppEvaluateBO.class); AssessPlanQueryDTO assessPlanById = assessPlanService.getAssessPlanById(evaluateParam.getId()); int tag = 1; FactorQueryDTO factorQueryDTO = new FactorQueryDTO(); //分发参数到不同的服务进行处理 // todo ,1、将参数与结果值传入,2计算比对前端传来的结果值是否正确,3相同存入,不同抛异常 //辨识方法1 - LEC if (assessPlanById.getEvaluateMethod() == 1){ AssessLecInsertBO lecInsertBO = BeanCopyUtils.copyBean(evaluateReqBO, AssessLecInsertBO.class); lecInsertBO.setAssessPlanId(evaluateParam.getId()); lecInsertBO.setIdentificationId(evaluateReqBO.getIdentificationId()); lecInsertBO.setIdentificationMethod(assessPlanById.getIdentificationMethod()); LecInsertDTO lecInsertDTO = lecService.insertLec(currentUserId, lecInsertBO); if (ObjectUtils.isEmpty(lecInsertDTO)){ throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "写入评价结果失败"); } factorQueryDTO = BeanCopyUtils.copyBean(lecInsertDTO, FactorQueryDTO.class); factorQueryDTO.setLecId(lecInsertDTO.getId()); factorQueryDTO.setEvaluateMethod(assessPlanById.getEvaluateMethod()); //辨识方法2 - LS }else if (assessPlanById.getEvaluateMethod() == 2){ AssessLSInsertBO lsInsertBO = BeanCopyUtils.copyBean(evaluateReqBO, AssessLSInsertBO.class); lsInsertBO.setAssessPlanId(evaluateParam.getId()); lsInsertBO.setIdentificationId(evaluateReqBO.getIdentificationId()); lsInsertBO.setIdentificationMethod(assessPlanById.getIdentificationMethod()); LsInsertDTO lsInsertDTO = lsService.insertLs(currentUserId, lsInsertBO); if (ObjectUtils.isEmpty(lsInsertDTO)){ throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "写入评价结果失败"); } factorQueryDTO = BeanCopyUtils.copyBean(lsInsertDTO, FactorQueryDTO.class); factorQueryDTO.setLsId(lsInsertDTO.getId()); factorQueryDTO.setEvaluateMethod(assessPlanById.getEvaluateMethod()); //辨识方法3 - MES }else if (assessPlanById.getEvaluateMethod() == 3){ AssessMesInsertBO mesInsertBO = BeanCopyUtils.copyBean(evaluateReqBO, AssessMesInsertBO.class); mesInsertBO.setAssessPlanId(evaluateParam.getId()); mesInsertBO.setIdentificationId(evaluateReqBO.getIdentificationId()); mesInsertBO.setIdentificationMethod(assessPlanById.getIdentificationMethod()); MesInsertDTO mesInsertDTO = mesService.InsertMes(currentUserId, mesInsertBO); if (ObjectUtils.isEmpty(mesInsertDTO)){ throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "写入评价结果失败"); } factorQueryDTO = BeanCopyUtils.copyBean(mesInsertDTO, FactorQueryDTO.class); factorQueryDTO.setMesId(mesInsertDTO.getId()); factorQueryDTO.setEvaluateMethod(assessPlanById.getEvaluateMethod()); //辨识方法4 - RS }else if (assessPlanById.getEvaluateMethod() == 4){ AssessRsInsertBO rsInsertBO = BeanCopyUtils.copyBean(evaluateReqBO, AssessRsInsertBO.class); rsInsertBO.setAssessPlanId(evaluateParam.getId()); rsInsertBO.setIdentificationId(evaluateReqBO.getIdentificationId()); rsInsertBO.setIdentificationMethod(assessPlanById.getIdentificationMethod()); RsInsertDTO rsInsertDTO = rsService.InsertRs(currentUserId, rsInsertBO); if (ObjectUtils.isEmpty(rsInsertDTO)){ throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "写入评价结果失败"); } factorQueryDTO = BeanCopyUtils.copyBean(rsInsertDTO, FactorQueryDTO.class); factorQueryDTO.setRsId(rsInsertDTO.getId()); factorQueryDTO.setEvaluateMethod(assessPlanById.getEvaluateMethod()); }else { throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR.getCode(), "请选择正确的评价方法"); } //处理评估计划表 AssessPlanEvaluateDTO evaluateResult = assessPlanService.evaluate(currentUserId, evaluateParam); if (ObjectUtils.isEmpty(evaluateResult)){ throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR.getCode(), "写入失败"); } return factorQueryDTO; } /** * 风险评估计划 - 评价修改 */ @Transactional @Override public FactorQueryDTO updateEvaluate(Long currentUserId, RiskAssessPlanEvaluateUpdateReqBO updateReqBO) { if (currentUserId < 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录"); } RiskAssessPlanEvaluateUpdateReqBO updateParam = BeanCopyUtils.copyBean(updateReqBO, RiskAssessPlanEvaluateUpdateReqBO.class); AssessPlanQueryDTO assessPlanById = assessPlanService.getAssessPlanById(updateReqBO.getId()); int tag = 1; FactorQueryDTO factorQueryDTO = new FactorQueryDTO(); //分发参数到不同的服务进行处理 // 1、将参数与结果值传入,2计算比对前端传来的结果值是否正确,3相同存入,不同抛异常 //辨识方法1 - LEC if (assessPlanById.getEvaluateMethod() == 1){ AssessLecInsertBO lecInsertBO = BeanCopyUtils.copyBean(updateParam, AssessLecInsertBO.class); lecInsertBO.setAssessPlanId(updateParam.getId()); lecInsertBO.setId(updateParam.getLecId()); lecInsertBO.setIdentificationMethod(assessPlanById.getIdentificationMethod()); LecInsertDTO lecInsertDTO = lecService.updateLec(currentUserId, lecInsertBO); if (ObjectUtils.isEmpty(lecInsertDTO)){ throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "修改评价结果失败"); } factorQueryDTO = BeanCopyUtils.copyBean(lecInsertDTO, FactorQueryDTO.class); factorQueryDTO.setLecId(lecInsertDTO.getId()); factorQueryDTO.setEvaluateMethod(assessPlanById.getEvaluateMethod()); //辨识方法2 - LS }else if (assessPlanById.getEvaluateMethod() == 2){ AssessLSInsertBO lsInsertBO = BeanCopyUtils.copyBean(updateParam, AssessLSInsertBO.class); lsInsertBO.setAssessPlanId(updateParam.getId()); lsInsertBO.setId(updateParam.getLsId()); lsInsertBO.setIdentificationMethod(assessPlanById.getIdentificationMethod()); LecInsertDTO lsInsertDTO = lsService.updateLs(currentUserId, lsInsertBO); if (ObjectUtils.isEmpty(lsInsertDTO)){ throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "修改评价结果失败"); } factorQueryDTO = BeanCopyUtils.copyBean(lsInsertDTO, FactorQueryDTO.class); factorQueryDTO.setLsId(lsInsertDTO.getId()); factorQueryDTO.setEvaluateMethod(assessPlanById.getEvaluateMethod()); //辨识方法3 - MES }else if (assessPlanById.getEvaluateMethod() == 3){ AssessMesInsertBO mesInsertBO = BeanCopyUtils.copyBean(updateParam, AssessMesInsertBO.class); mesInsertBO.setAssessPlanId(updateParam.getId()); mesInsertBO.setId(updateParam.getMesId()); mesInsertBO.setIdentificationMethod(assessPlanById.getIdentificationMethod()); MesInsertDTO mesInsertDTO = mesService.updateMes(currentUserId, mesInsertBO); if (ObjectUtils.isEmpty(mesInsertDTO)){ throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "写入评价结果失败"); } factorQueryDTO = BeanCopyUtils.copyBean(mesInsertDTO, FactorQueryDTO.class); factorQueryDTO.setMesId(mesInsertDTO.getId()); factorQueryDTO.setEvaluateMethod(assessPlanById.getEvaluateMethod()); //辨识方法4 - RS }else if (assessPlanById.getEvaluateMethod() == 4){ AssessRsInsertBO rsInsertBO = BeanCopyUtils.copyBean(updateParam, AssessRsInsertBO.class); rsInsertBO.setAssessPlanId(updateParam.getId()); rsInsertBO.setId(updateParam.getRsId()); rsInsertBO.setIdentificationMethod(assessPlanById.getIdentificationMethod()); RsInsertDTO rsInsertDTO = rsService.updateRs(currentUserId, rsInsertBO); if (ObjectUtils.isEmpty(rsInsertDTO)){ throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "写入评价结果失败"); } factorQueryDTO = BeanCopyUtils.copyBean(rsInsertDTO, FactorQueryDTO.class); factorQueryDTO.setRsId(rsInsertDTO.getId()); factorQueryDTO.setEvaluateMethod(assessPlanById.getEvaluateMethod()); } RiskAssessPlanAppEvaluateBO evaluateParam = BeanCopyUtils.copyBean(updateReqBO, RiskAssessPlanAppEvaluateBO.class); //处理评估计划表 AssessPlanEvaluateDTO evaluateResult = assessPlanService.evaluateUpdate(currentUserId, evaluateParam); return factorQueryDTO; } /** * 风险评估计划 - 评价删除 */ @Override public int deleteEvaluate(Long currentUserId, RiskAssessPlanEvaluateDeleteReqBO deleteReqBO) { if (currentUserId < 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录"); } AssessPlanUpdateDTO deleteResult= assessPlanService.deleteEvaluate(currentUserId, deleteReqBO); if (ObjectUtils.isEmpty(deleteResult)){ return StatusEnum.FAIL.getCode(); } return StatusEnum.SUCCESS.getCode(); } /** * 风险评估计划 - 评价结果提交 */ @Transactional @Override public int evaluateSubmit(Long currentUserId, Long id) { if (currentUserId < 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录"); } //提交评价结果 AssessPlanUpdateDTO evaluateSubmitResult= assessPlanService.evaluateSubmit(currentUserId, id); if (ObjectUtils.isEmpty(evaluateSubmitResult)){ return StatusEnum.FAIL.getCode(); } return StatusEnum.SUCCESS.getCode(); } /** * 风险辨识与评价 - 查询 */ @Override public SearchResult selectAssessPage(Long currentUserId, RiskAssessQueryReqBO queryReqBO) { SearchResult searchResult = new SearchResult<>(); RiskAssessAppQueryBO queryBO = BeanCopyUtils.copyBean(queryReqBO, RiskAssessAppQueryBO.class); SearchResult queryResult = assessPlanService.selectAssessPage(currentUserId, queryBO); searchResult.setPageIndex(queryResult.getPageIndex()); searchResult.setPageSize(queryResult.getPageSize()); searchResult.setCount(queryResult.getCount()); searchResult.setTotal(queryResult.getTotal()); searchResult.setData(queryResult.getData()); return searchResult; } /** * 实验风险单元 - 插入 */ @Transactional @Override public int insertRiskUnit(Long currentUserId, RiskUnitInsertReqBO riskUnitInsertReqBO) { if (currentUserId < 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录"); } int roleTag = 0; UserInfoDomainDTO user = userDomainService.getUserById(currentUserId); for (SysUserRoleBindDomainDTO role : user.getRoles()) { if (role.getRoleId() == UserRoleEnum.USER_ROLE_4.getCode().byteValue()){ roleTag = 1; } } if (roleTag != 1){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户不是管理人员,无权限添加"); } if (ObjectUtils.isEmpty(riskUnitInsertReqBO.getExperimentId())){ throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "所选实验不能为空"); } ExperimentInfoDTO experimentById = experimentInfoService.getExperimentById(riskUnitInsertReqBO.getExperimentId()); if (ObjectUtils.isEmpty(experimentById)){ throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "所选实验不存在或实验已被删除"); } if (ObjectUtils.isEmpty(riskUnitInsertReqBO.getLiabilityUserId())){ throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "责任人不能为空"); } PersonQueryDTO basicExperimentPersonById = basicExperimentPersonService.getBasicExperimentPersonById(riskUnitInsertReqBO.getLiabilityUserId()); if (ObjectUtils.isEmpty(basicExperimentPersonById)){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR.getCode(), "责任人不存在,或已被删除"); } RiskUnitAppInsertBO insertParam = BeanCopyUtils.copyBean(riskUnitInsertReqBO, RiskUnitAppInsertBO.class); RiskUnitInsertDTO riskUnitInsertDTO = riskUnitService.insertRiskUnit(currentUserId, insertParam); if (ObjectUtils.isEmpty(riskUnitInsertDTO)){ return StatusEnum.FAIL.getCode(); } return StatusEnum.SUCCESS.getCode(); } /** * 固有风险单元 - 插入 */ @Override public int insertInherentRiskUnit(Long currentUserId, InherentRiskUnitInsertReqBO insertReqBO) { if (currentUserId < 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录"); } int roleTag = 0; UserInfoDomainDTO user = userDomainService.getUserById(currentUserId); for (SysUserRoleBindDomainDTO role : user.getRoles()) { if (role.getRoleId() == UserRoleEnum.USER_ROLE_4.getCode().byteValue()){ roleTag = 1; } } if (roleTag != 1){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户不是管理人员,无权限添加"); } if (ObjectUtils.isEmpty(insertReqBO.getExperimentId())){ throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "所选实验不能为空,或实验已被删除"); } ExperimentInfoDTO experimentById = experimentInfoService.getExperimentById(insertReqBO.getExperimentId()); if (ObjectUtils.isEmpty(experimentById)){ throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "所选实验不存在或实验已被删除"); } RiskUnitBasicQueryDTO basicRiskUnitById = basicRiskUnitService.getBasicRiskUnitById(insertReqBO.getBasicRiskUnitId()); //封装插入需要的数据 InherentRiskUnitAppInsertBO insertParam = BeanCopyUtils.copyBean(basicRiskUnitById, InherentRiskUnitAppInsertBO.class); insertParam.setExperimentId(insertReqBO.getExperimentId()); insertParam.setBasicRiskUnitId(basicRiskUnitById.getId()); RiskUnitInsertDTO riskUnitInsertDTO = riskUnitService.insertInherentRiskUnit(currentUserId, insertParam); if (ObjectUtils.isEmpty(riskUnitInsertDTO)){ return StatusEnum.FAIL.getCode(); } return StatusEnum.SUCCESS.getCode(); } /** * 风险单元 - 分页查询 */ @Override public SearchResult selectRiskUnitPage(Long currentUserId, RiskUnitQueryReqBO queryReqBO) { SearchResult searchResult = new SearchResult<>(); RiskUnitAppQueryBO queryParam = BeanCopyUtils.copyBean(queryReqBO, RiskUnitAppQueryBO.class); SearchResult queryResult = riskUnitService.selectRiskUnitPage(currentUserId, queryParam); searchResult.setPageIndex(queryResult.getPageIndex()); searchResult.setPageSize(queryResult.getPageSize()); searchResult.setTotal(queryResult.getTotal()); searchResult.setData(BeanCopyUtils.copyExperimentRiskUnitAppQueryList(queryResult.getData(), RiskUnitBasicQueryDTO.class)); return searchResult; } /** * 风险单元 - 修改 */ @Override public int updateRiskUnit(Long currentUserId, RiskUnitUpdateReqBO updateReqBO) { if (currentUserId < 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录"); } int roleTag = 0; UserInfoDomainDTO user = userDomainService.getUserById(currentUserId); for (SysUserRoleBindDomainDTO role : user.getRoles()) { if (role.getRoleId() == UserRoleEnum.USER_ROLE_4.getCode().byteValue()){ roleTag = 1; } } if (roleTag != 1){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户不是管理人员,无权限修改"); } if (ObjectUtils.isEmpty(updateReqBO.getExperimentId())){ throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "所选实验不能为空,或实验已被删除"); } ExperimentInfoDTO experimentById = experimentInfoService.getExperimentById(updateReqBO.getExperimentId()); if (ObjectUtils.isEmpty(experimentById)){ throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "所选实验不存在或实验已被删除"); } if (ObjectUtils.isEmpty(updateReqBO.getLiabilityUserId())){ throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "责任人不能为空"); } PersonQueryDTO basicExperimentPersonById = basicExperimentPersonService.getBasicExperimentPersonById(updateReqBO.getLiabilityUserId()); if (ObjectUtils.isEmpty(basicExperimentPersonById)){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR.getCode(), "责任人不存在,或已被删除"); } RiskUnitAppUpdateBO updateParam = BeanCopyUtils.copyBean(updateReqBO, RiskUnitAppUpdateBO.class); RiskUnitInsertDTO riskUnitUpdateDTO = riskUnitService.updateRiskUnit(currentUserId, updateParam); if (ObjectUtils.isEmpty(riskUnitUpdateDTO)){ return StatusEnum.FAIL.getCode(); } return StatusEnum.SUCCESS.getCode(); } /** * 风险单元 - 删除 */ @Override public int deleteRiskUnit(Long currentUserId, Long id) { if (currentUserId < 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录"); } RiskUnitQueryDTO riskUnitById = riskUnitService.getRiskUnitById(id); if (ObjectUtils.isEmpty(riskUnitById)){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前要删除的实验不存在,或已被删除"); } int roleTag = 0; UserInfoDomainDTO user = userDomainService.getUserById(currentUserId); for (SysUserRoleBindDomainDTO role : user.getRoles()) { if (role.getRoleId() == UserRoleEnum.USER_ROLE_4.getCode().byteValue()){ roleTag = 1; } } if (roleTag != 1){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户不是管理人员,无权限添加"); } RiskUnitDeleteDTO deleteResult = riskUnitService.deleteRiskUnit(currentUserId, id); if (ObjectUtils.isEmpty(deleteResult)){ return StatusEnum.FAIL.getCode(); } return StatusEnum.SUCCESS.getCode(); } /** * 基础风险单元管理 - 列表查询 */ @Override public SearchResult listRiskUnit(Long currentUserId) { SearchResult result = new SearchResult(); List riskUnitListAppQueryDTOS = riskUnitService.listRiskUnit(currentUserId); result.setData(BeanCopyUtils.copyBeanList(riskUnitListAppQueryDTOS, RiskUnitListQueryRespDTO.class)); result.setCount(riskUnitListAppQueryDTOS.size()); return result; } /** * 风险单元 - 列表查询 */ @Override public SearchResult listRiskUnitByExperiment(Long currentUserId, RiskUnitListReqBO reqBO) { SearchResult result = new SearchResult(); List riskUnitListAppQueryDTOS = riskUnitService.listRiskUnitByExperiment(currentUserId, reqBO); result.setData(BeanCopyUtils.copyBeanList(riskUnitListAppQueryDTOS, RiskUnitListQueryRespDTO.class)); result.setCount(riskUnitListAppQueryDTOS.size()); return result; } /** * 评估计划 - 列表查询 */ @Override public SearchResult listAssessPlan() { SearchResult result = new SearchResult(); Byte status = StatusEnum.PLAN_SELL.getCode().byteValue(); List riskAssessPlanListAppDTO = assessPlanService.listAssessPlan(status); result.setData(BeanCopyUtils.copyBeanList(riskAssessPlanListAppDTO, RiskAssessPlanListRespDTO.class)); result.setCount(riskAssessPlanListAppDTO.size()); return result; } /** * 评估计划 - 风险值计算 */ @Override public BigDecimal riskValue(RiskValueReqBO valueReqBO) { if (valueReqBO.getValue3() == null){ BigDecimal value = valueReqBO.getValue1().multiply(valueReqBO.getValue2()); return value; } BigDecimal value = valueReqBO.getValue1().multiply(valueReqBO.getValue2()).multiply(valueReqBO.getValue3()); return value; } /** * 风险评估计划 - 辨识专家拒绝 */ @Override public AssessPlanUpdateDTO identificationRefuse(Long currentUserId, Long id) { if (currentUserId < 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录"); } AssessPlanUpdateDTO assessPlanUpdateDTO = assessPlanService.identificationRefuse(currentUserId, id); return assessPlanUpdateDTO; } /** * 风险评估计划 - 评价专家拒绝 */ @Override public AssessPlanUpdateDTO evaluateRefuse(Long currentUserId, Long id) { if (currentUserId < 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录"); } AssessPlanUpdateDTO assessPlanUpdateDTO = assessPlanService.evaluateRefuse(currentUserId, id); return assessPlanUpdateDTO; } /** * 风险评估计划 - 修改辨识方法 */ @Override public AssessPlanUpdateDTO identificationUpdateMethod(Long currentUserId, MethodUpdateReqDTO updateReqDTO) { if (currentUserId < 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录"); } AssessPlanUpdateDTO assessPlanUpdateDTO = assessPlanService.identificationUpdateMethod(currentUserId, updateReqDTO); return assessPlanUpdateDTO; } /** * 风险评估计划 - 评价方法修改 */ @Override public AssessPlanUpdateDTO evaluateUpdateMethod(Long currentUserId, MethodUpdateReqDTO updateReqDTO) { if (currentUserId < 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录"); } AssessPlanUpdateDTO assessPlanUpdateDTO = assessPlanService.evaluateUpdateMethod(currentUserId, updateReqDTO); return assessPlanUpdateDTO; } /** * 风险评估计划 - 重新指定专家 */ @Override public AssessPlanUpdateDTO appoint(Long currentUserId, AppointUserReBO appointUserReBO) { if (currentUserId < 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录"); } AssessPlanUpdateDTO assessPlanUpdateDTO = assessPlanService.appoint(currentUserId, appointUserReBO); return assessPlanUpdateDTO; } }