| | |
| | | package com.gkhy.labRiskManage.domain.riskReport.service.impl; |
| | | |
| | | import com.gkhy.labRiskManage.api.controller.riskReport.dto.repDto.*; |
| | | import com.gkhy.labRiskManage.application.account.dto.respDto.UserEvaluateRespDTO; |
| | | import com.gkhy.labRiskManage.application.account.dto.respDto.UserIdentityRespDTO; |
| | | import com.gkhy.labRiskManage.application.riskReport.dto.bo.*; |
| | | import com.gkhy.labRiskManage.application.riskReport.dto.dto.RiskAssessAppQueryDTO; |
| | | import com.gkhy.labRiskManage.application.riskReport.dto.dto.RiskAssessAppQueryDTO_0223bak; |
| | |
| | | import com.gkhy.labRiskManage.domain.basic.service.BasicExperimentPersonService; |
| | | import com.gkhy.labRiskManage.domain.basic.service.BasicRiskUnitService; |
| | | import com.gkhy.labRiskManage.domain.basic.service.BasicRiskUnitTypeService; |
| | | import com.gkhy.labRiskManage.domain.experiment.entity.ExperimentInfo; |
| | | import com.gkhy.labRiskManage.domain.experiment.model.dto.ExperimentInfoDTO; |
| | | import com.gkhy.labRiskManage.domain.experiment.service.ExperimentInfoService; |
| | | import com.gkhy.labRiskManage.domain.riskReport.entity.*; |
| | | import com.gkhy.labRiskManage.domain.riskReport.model.bo.*; |
| | | import com.gkhy.labRiskManage.domain.riskReport.model.dto.*; |
| | | import com.gkhy.labRiskManage.domain.riskReport.repository.jpa.RiskAssessPlanEvaluateUserRepository; |
| | | import com.gkhy.labRiskManage.domain.riskReport.repository.jpa.RiskAssessPlanIdentificationUserRepository; |
| | | import com.gkhy.labRiskManage.domain.riskReport.repository.jpa.RiskAssessPlanRepository; |
| | | import com.gkhy.labRiskManage.domain.riskReport.service.*; |
| | | import com.gkhy.labRiskManage.domain.riskReport.utils.EvaluateAndIdentificationUtils; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | /** |
| | |
| | | private RiskAssessPlanIdentificationPhaService phaService; |
| | | @Autowired |
| | | private RiskAssessPlanIdentificationSclService sclService; |
| | | |
| | | @Autowired |
| | | private RiskAssessPlanIdentificationUserService planIdentificationUserService; |
| | | |
| | | @Autowired |
| | | private RiskAssessPlanEvaluateUserService evaluateUserService; |
| | | |
| | | @Autowired |
| | | private RiskAssessPlanEvaluateLecService lecService; |
| | |
| | | if (ObjectUtils.isEmpty(insertParam.getRiskType())){ |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "风险单元类型不能为空"); |
| | | } |
| | | if (ObjectUtils.isEmpty(insertParam.getIdentificationType())) { |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "辨识类型不能为空"); |
| | | } |
| | | RiskUnitQueryDTO riskUnitById = riskUnitService.getRiskUnitById(insertParam.getRiskUnitId()); |
| | | if (ObjectUtils.isEmpty(riskUnitById.getId())){ |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "风险单元不存在或已被删除"); |
| | |
| | | if (ObjectUtils.isEmpty(planUser)){ |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_DATA_NOT_EXISIST.getCode(), "计划制定人不存在或已被删除"); |
| | | } |
| | | List<Long> identificationUserInsert = insertParam.getIdentificationUserInsert(); |
| | | // 辨识专家 |
| | | if (ObjectUtils.isEmpty(insertParam.getIdentificationUserId())){ |
| | | if (ObjectUtils.isEmpty(identificationUserInsert)) { |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "辨识专家不能为空"); |
| | | } |
| | | UserInfoDomainDTO identificationUser = userDomainService.getUserInfoByIdAndSellInfo(insertParam.getIdentificationUserId(), "辨识专家"); |
| | | List<UserInfoDomainDTO> identificationUser = userDomainService.getUserInfoByIds(identificationUserInsert, "辨识专家"); |
| | | if (ObjectUtils.isEmpty(identificationUser)){ |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_DATA_NOT_EXISIST.getCode(), "辨识专家不存在或已被删除"); |
| | | } |
| | | if (identificationUser.size() != identificationUserInsert.size()) { |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_DATA_NOT_EXISIST.getCode(), "存在选中辨识专家不存在或已被删除"); |
| | | } |
| | | |
| | | List<Long> evaluateUserInsert = insertParam.getEvaluateUserInsert(); |
| | | // 评价专家 |
| | | if (ObjectUtils.isEmpty(insertParam.getEvaluateUserId())){ |
| | | if (ObjectUtils.isEmpty(evaluateUserInsert)) { |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "评价专家不能为空"); |
| | | } |
| | | UserInfoDomainDTO evaluateUser = userDomainService.getUserInfoByIdAndSellInfo(insertParam.getEvaluateUserId(), "评价专家"); |
| | | if (ObjectUtils.isEmpty(evaluateUser)){ |
| | | List<UserInfoDomainDTO> evaluateUserUser = userDomainService.getUserInfoByIds(evaluateUserInsert, "评价专家"); |
| | | if (ObjectUtils.isEmpty(evaluateUserUser)) { |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_DATA_NOT_EXISIST.getCode(), "评价专家不存在或已被删除"); |
| | | } |
| | | if (evaluateUserUser.size() != evaluateUserInsert.size()) { |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_DATA_NOT_EXISIST.getCode(), "存在选中评价专家不存在或已被删除"); |
| | | } |
| | | |
| | | // // 评价专家 |
| | | // if (ObjectUtils.isEmpty(insertParam.getEvaluateUserId())){ |
| | | // throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "评价专家不能为空"); |
| | | // } |
| | | // UserInfoDomainDTO evaluateUser = userDomainService.getUserInfoByIdAndSellInfo(insertParam.getEvaluateUserId(), "评价专家"); |
| | | // if (ObjectUtils.isEmpty(evaluateUser)){ |
| | | // throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_DATA_NOT_EXISIST.getCode(), "评价专家不存在或已被删除"); |
| | | // } |
| | | |
| | | BasicRiskUnitType riskUnitTypeById = riskUnitTypeService.getRiskUnitTypeById(riskUnitById.getRiskUnitTypeId()); |
| | | |
| | |
| | | riskAssessPlan.setPlanSellStatus(StatusEnum.PLAN_SELL_NOT.getCode().byteValue());//计划未派发 |
| | | riskAssessPlan.setPlanExecStatus(StatusEnum.PLAN_EXEC_NOT_START.getCode().byteValue());//计划执行未开始(执行阶段) |
| | | // riskAssessPlan.setPlanTimeStatus(StatusEnum.PLAN_STATUS_NOT_START.getCode().byteValue());//计划状态未开始 |
| | | riskAssessPlan.setIdentificationUserId(insertParam.getIdentificationUserId());//辨识专家id |
| | | riskAssessPlan.setIdentificationUser(identificationUser.getRealName());//辨识专家 |
| | | riskAssessPlan.setEvaluateUserId(insertParam.getEvaluateUserId());//评价专家id |
| | | riskAssessPlan.setEvaluateUser(evaluateUser.getRealName());//评价专家 |
| | | // riskAssessPlan.setIdentificationUserId(insertParam.getIdentificationUserId());//辨识专家id |
| | | // riskAssessPlan.setIdentificationUser(identificationUser.getRealName());//辨识专家 |
| | | // riskAssessPlan.setEvaluateUserId(insertParam.getEvaluateUserId());//评价专家id |
| | | // riskAssessPlan.setEvaluateUser(evaluateUser.getRealName());//评价专家 |
| | | |
| | | riskAssessPlan.setIdentificationMethod(MethodEnum.IDENTIFICATION_METHOD_PHA.getCode());//辨识方法 |
| | | riskAssessPlan.setEvaluateMethod(MethodEnum.EVALUATE_METHOD_LEC.getCode());//评价方法 |
| | | |
| | | RiskAssessPlan saveResult = assessPlanRepository.save(riskAssessPlan); |
| | | |
| | | //处理辨识专家 |
| | | saveIdentificationUser(saveResult.getId(), identificationUser, date, user.getId()); |
| | | //处理评价专家 |
| | | saveEvaUser(saveResult.getId(), evaluateUserUser, date, user.getId()); |
| | | //修改实验状态为评估中 |
| | | ExperimentInfoDTO experimentInfoDTO = experimentInfoService.updateExperimentStage(experimentById.getId(), StatusEnum.EXPERIMENT_STATUS_START.getCode().byteValue()); |
| | | if (ObjectUtils.isEmpty(experimentInfoDTO)){ |
| | |
| | | PlanInsertDTO planInsertDTO = BeanCopyUtils.copyBean(saveResult, PlanInsertDTO.class); |
| | | |
| | | return planInsertDTO; |
| | | } |
| | | |
| | | private void saveIdentificationUser(Long id, List<UserInfoDomainDTO> identificationUser, LocalDateTime date, Long userId) { |
| | | |
| | | // 处理辨识专家 |
| | | List<RiskAssessPlanIdentificationUser> saveList = new ArrayList<>(); |
| | | for (UserInfoDomainDTO userInfo : identificationUser) { |
| | | RiskAssessPlanIdentificationUser planIdentificationUser = new RiskAssessPlanIdentificationUser(); |
| | | planIdentificationUser.setRiskAssessPlanId(id); |
| | | planIdentificationUser.setIdentificationUserId(userInfo.getId()); |
| | | planIdentificationUser.setIdentificationUser(userInfo.getRealName()); |
| | | planIdentificationUser.setCreateTime(date); |
| | | planIdentificationUser.setCreateByUserId(userId); |
| | | planIdentificationUser.setDeleteStatus((byte)0); |
| | | saveList.add(planIdentificationUser); |
| | | } |
| | | planIdentificationUserService.InsertData(saveList); |
| | | } |
| | | |
| | | private void saveEvaUser(Long id, List<UserInfoDomainDTO> identificationUser, LocalDateTime date, Long userId) { |
| | | |
| | | // 处理辨识专家 |
| | | List<RiskAssessPlanEvaluateUser> saveList = new ArrayList<>(); |
| | | for (UserInfoDomainDTO userInfo : identificationUser) { |
| | | RiskAssessPlanEvaluateUser planIdentificationUser = new RiskAssessPlanEvaluateUser(); |
| | | planIdentificationUser.setRiskAssessPlanId(id); |
| | | planIdentificationUser.setEvaluateUserId(userInfo.getId()); |
| | | planIdentificationUser.setEvaluateUser(userInfo.getRealName()); |
| | | planIdentificationUser.setCreateTime(date); |
| | | planIdentificationUser.setCreateByUserId(userId); |
| | | planIdentificationUser.setDeleteStatus((byte)0); |
| | | saveList.add(planIdentificationUser); |
| | | } |
| | | evaluateUserService.InsertEvaluate(saveList); |
| | | } |
| | | |
| | | /** |
| | |
| | | if (queryParam.getExperimentId() != null){ |
| | | predicateList.add(criteriaBuilder.equal(root.get("experimentId"),queryParam.getExperimentId())); |
| | | } |
| | | Join<RiskAssessPlan, RiskAssessPlanIdentificationUser> identificationUserJoin = root.join("riskAssessPlanIdentificationUsers", JoinType.LEFT); |
| | | Join<RiskAssessPlan, RiskAssessPlanEvaluateUser> evaluateUserJoin = root.join("riskAssessPlanEvaluateUsers", JoinType.LEFT); |
| | | |
| | | if (roleTag == UserTagEnum.USER_TAG_0.getCode()){ |
| | | |
| | | //此处应有谁能查询:辨识专家,评价专家,实验负责人(此处未存相关信息,以实验id为条件查询) |
| | | predicateList.add(criteriaBuilder.or( |
| | | criteriaBuilder.equal(root.get("identificationUserId"), currentUserId), |
| | | criteriaBuilder.equal(root.get("evaluateUserId"), currentUserId), |
| | | criteriaBuilder.equal(identificationUserJoin.get("identificationUserId"), currentUserId), |
| | | criteriaBuilder.equal(evaluateUserJoin.get("evaluateUserId"), currentUserId), |
| | | criteriaBuilder.in(root.get("experimentId")).value(experimentIdList) |
| | | ) |
| | | ); |
| | | } |
| | | query.groupBy(root.get("id")); |
| | | predicateList.add(criteriaBuilder.equal(root.get("deleteStatus"),StatusEnum.DELETE_NOT.getCode())); |
| | | return criteriaBuilder.and(predicateList.toArray(new Predicate[0])); |
| | | } |
| | |
| | | if (riskUnit.getId() == assessPlanQueryDTO.getRiskUnitId()){ |
| | | assessPlanQueryDTO.setRiskUnitName(riskUnit.getRiskName()); |
| | | } |
| | | } |
| | | //todo 处理数据 |
| | | List<RiskAssessPlanIdentificationUser> riskAssessPlanIdentificationUsers = assessPlanQueryDTO.getRiskAssessPlanIdentificationUsers(); |
| | | if (!ObjectUtils.isEmpty(riskAssessPlanIdentificationUsers)) { |
| | | String identificationUsersString = riskAssessPlanIdentificationUsers.stream() |
| | | .map(RiskAssessPlanIdentificationUser::getIdentificationUser) |
| | | .collect(Collectors.joining(",")); |
| | | assessPlanQueryDTO.setIdentificationUser(identificationUsersString); |
| | | List<UserIdentityRespDTO> userIdentityRespDTOS = BeanCopyUtils.copyBeanList(riskAssessPlanIdentificationUsers, UserIdentityRespDTO.class); |
| | | assessPlanQueryDTO.setIdentityUsers(userIdentityRespDTOS); |
| | | assessPlanQueryDTO.setRiskAssessPlanIdentificationUsers(null); |
| | | } |
| | | |
| | | List<RiskAssessPlanEvaluateUser> riskAssessPlanEvaluateUsers = assessPlanQueryDTO.getRiskAssessPlanEvaluateUsers(); |
| | | if (!ObjectUtils.isEmpty(riskAssessPlanEvaluateUsers)) { |
| | | String identificationUsersString = riskAssessPlanEvaluateUsers.stream() |
| | | .map(RiskAssessPlanEvaluateUser::getEvaluateUser) |
| | | .collect(Collectors.joining(",")); |
| | | assessPlanQueryDTO.setEvaluateUser(identificationUsersString); |
| | | List<UserEvaluateRespDTO> userEvaluateRespDTOS = BeanCopyUtils.copyBeanList(riskAssessPlanEvaluateUsers, UserEvaluateRespDTO.class); |
| | | assessPlanQueryDTO.setEvaluateUsers(userEvaluateRespDTOS); |
| | | assessPlanQueryDTO.setRiskAssessPlanEvaluateUsers(null); |
| | | } |
| | | } |
| | | |
| | |
| | | if (ObjectUtils.isEmpty(planUser)){ |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_DATA_NOT_EXISIST.getCode(), "计划制定人不存在或已被删除"); |
| | | } |
| | | List<Long> identificationUserInsert = updateParam.getIdentificationUserInsert(); |
| | | // 辨识专家 |
| | | if (ObjectUtils.isEmpty(updateParam.getIdentificationUserId())){ |
| | | if (ObjectUtils.isEmpty(identificationUserInsert)) { |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "辨识专家不能为空"); |
| | | } |
| | | UserInfoDomainDTO identificationUser = userDomainService.getUserInfoByIdAndSellInfo(updateParam.getIdentificationUserId(), "辨识专家"); |
| | | List<UserInfoDomainDTO> identificationUser = userDomainService.getUserInfoByIds(identificationUserInsert, "辨识专家"); |
| | | if (ObjectUtils.isEmpty(identificationUser)){ |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_DATA_NOT_EXISIST.getCode(), "辨识专家不存在或已被删除"); |
| | | } |
| | | if (identificationUser.size() != identificationUserInsert.size()) { |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_DATA_NOT_EXISIST.getCode(), "存在选中辨识专家不存在或已被删除"); |
| | | } |
| | | // // 辨识专家 |
| | | // if (ObjectUtils.isEmpty(updateParam.getIdentificationUserId())){ |
| | | // throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "辨识专家不能为空"); |
| | | // } |
| | | // UserInfoDomainDTO identificationUser = userDomainService.getUserInfoByIdAndSellInfo(updateParam.getIdentificationUserId(), "辨识专家"); |
| | | // if (ObjectUtils.isEmpty(identificationUser)){ |
| | | // throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_DATA_NOT_EXISIST.getCode(), "辨识专家不存在或已被删除"); |
| | | // } |
| | | // 评价专家 |
| | | if (ObjectUtils.isEmpty(updateParam.getEvaluateUserId())){ |
| | | List<Long> evaluateUserInsert = updateParam.getEvaluateUserInsert(); |
| | | // 评价专家 |
| | | if (ObjectUtils.isEmpty(evaluateUserInsert)) { |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "评价专家不能为空"); |
| | | } |
| | | UserInfoDomainDTO evaluateUser = userDomainService.getUserInfoByIdAndSellInfo(updateParam.getEvaluateUserId(), "评价专家"); |
| | | if (ObjectUtils.isEmpty(evaluateUser)){ |
| | | List<UserInfoDomainDTO> evaluateUserUser = userDomainService.getUserInfoByIds(evaluateUserInsert, "评价专家"); |
| | | if (ObjectUtils.isEmpty(evaluateUserUser)) { |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_DATA_NOT_EXISIST.getCode(), "评价专家不存在或已被删除"); |
| | | } |
| | | if (evaluateUserUser.size() != evaluateUserInsert.size()) { |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_DATA_NOT_EXISIST.getCode(), "存在选中评价专家不存在或已被删除"); |
| | | } |
| | | // if (ObjectUtils.isEmpty(updateParam.getEvaluateUserId())){ |
| | | // throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "评价专家不能为空"); |
| | | // } |
| | | // UserInfoDomainDTO evaluateUser = userDomainService.getUserInfoByIdAndSellInfo(updateParam.getEvaluateUserId(), "评价专家"); |
| | | // if (ObjectUtils.isEmpty(evaluateUser)){ |
| | | // throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_DATA_NOT_EXISIST.getCode(), "评价专家不存在或已被删除"); |
| | | // } |
| | | |
| | | //获取需要的参数 |
| | | LocalDateTime date = LocalDateTime.now(); |
| | |
| | | assessPlanById.setAssessStartTime(updateParam.getAssessStartTime()); |
| | | assessPlanById.setAssessEndTime(updateParam.getAssessEndTime()); |
| | | // assessPlanById.setIdentificationMethod(updateParam.getIdentificationMethod());//辨识方法 |
| | | assessPlanById.setIdentificationUserId(updateParam.getIdentificationUserId());//辨识专家id |
| | | assessPlanById.setIdentificationUser(identificationUser.getRealName());//辨识专家 |
| | | // assessPlanById.setIdentificationUserId(updateParam.getIdentificationUserId());//辨识专家id |
| | | // assessPlanById.setIdentificationUser(identificationUser.getRealName());//辨识专家 |
| | | // assessPlanById.setEvaluateMethod(updateParam.getEvaluateMethod());//评价方法 |
| | | assessPlanById.setEvaluateUserId(updateParam.getEvaluateUserId());//评价专家id |
| | | assessPlanById.setEvaluateUser(evaluateUser.getRealName());//评价专家 |
| | | // assessPlanById.setEvaluateUserId(updateParam.getEvaluateUserId());//评价专家id |
| | | // assessPlanById.setEvaluateUser(evaluateUser.getRealName());//评价专家 |
| | | //处理风险数据 |
| | | planIdentificationUserService.deleteByPlanId(assessPlanById.getId(), date); |
| | | saveIdentificationUser(assessPlanById.getId(), identificationUser, date, userInfoById.getId()); |
| | | |
| | | //处理评价专家 |
| | | evaluateUserService.deleteRsByPlan(assessPlanById.getId(), date); |
| | | saveEvaUser(assessPlanById.getId(), evaluateUserUser, date, user.getId()); |
| | | |
| | | RiskAssessPlan saveResult = assessPlanRepository.save(assessPlanById); |
| | | |
| | |
| | | if (ObjectUtils.isEmpty(assessPlanById)){ |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR.getCode(), "要辨识的计划不存在或已被删除"); |
| | | } |
| | | if (!assessPlanById.getIdentificationUserId().equals(currentUserId)){ |
| | | List<RiskAssessPlanIdentificationUser> assessPlanIdentificationUserPlanId = planIdentificationUserService.getAssessPlanIdentificationUserPlanId(assessPlanById.getId(), currentUserId); |
| | | |
| | | if (ObjectUtils.isEmpty(assessPlanIdentificationUserPlanId)) { |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode() ,"不是辨识专家,无法操作"); |
| | | } |
| | | if (assessPlanById.getPlanSellStatus() == 1){ |
| | |
| | | if (date.isBefore(assessPlanById.getAssessStartTime())){ |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR.getCode(), "未到辨识时间"); |
| | | } |
| | | if (!assessPlanById.getIdentificationUserId().equals(userInfoById.getId())){ |
| | | List<RiskAssessPlanIdentificationUser> assessPlanIdentificationUser = |
| | | planIdentificationUserService.getAssessPlanIdentificationUserPlanId(assessPlanById.getId(), userInfoById.getId()); |
| | | |
| | | if (ObjectUtils.isEmpty(assessPlanIdentificationUser)) { |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR.getCode(), "您不是辨识人,无法进行辨识"); |
| | | } |
| | | |
| | |
| | | }else if (assessPlanById.getPlanExecStatus() > StatusEnum.PLAN_EXEC_IDENTIFICATION.getCode().byteValue()){ |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "辨识已完成,无需重复提交"); |
| | | } |
| | | if (!assessPlanById.getIdentificationUserId().equals(userInfoById.getId())){ |
| | | List<RiskAssessPlanIdentificationUser> assessPlanIdentificationUser = |
| | | planIdentificationUserService.getAssessPlanIdentificationUserPlanId(assessPlanById.getId(), userInfoById.getId()); |
| | | |
| | | if (ObjectUtils.isEmpty(assessPlanIdentificationUser)) { |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR.getCode(), "您不是辨识人,无法进行辨识结果提交"); |
| | | } |
| | | // 没有进行任何辨识,无法提交 |
| | |
| | | if (assessPlanById.getAssessEndTime().isBefore(date)){ |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR.getCode(), "风险评价必须在评估结束时间之前"); |
| | | } |
| | | if (!assessPlanById.getEvaluateUserId().equals(userInfoById.getId())){ |
| | | List<RiskAssessPlanEvaluateUser> assessPlanEvaluateUserPlanId = evaluateUserService.getAssessPlanEvaluateUserPlanId(assessPlanById.getId(), userInfoById.getId()); |
| | | if (ObjectUtils.isEmpty(assessPlanEvaluateUserPlanId)) { |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR.getCode(), "您不是评价人,无法进行评价"); |
| | | } |
| | | //设置必要参数 |
| | |
| | | if (assessPlanById.getAssessEndTime().isBefore(date)){ |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR.getCode(), "风险评价必须在评估结束时间之前"); |
| | | } |
| | | if (!assessPlanById.getEvaluateUserId().equals(userInfoById.getId())){ |
| | | List<RiskAssessPlanEvaluateUser> assessPlanEvaluateUserPlanId = evaluateUserService.getAssessPlanEvaluateUserPlanId(assessPlanById.getId(), userInfoById.getId()); |
| | | if (ObjectUtils.isEmpty(assessPlanEvaluateUserPlanId)) { |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR.getCode(), "您不是评价人,无法进行评价"); |
| | | } |
| | | //设置必要参数 |
| | |
| | | }else if (assessPlanById.getPlanExecStatus() > StatusEnum.PLAN_EXEC_EVALUATE.getCode().byteValue()){ |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "评价已完成,无需重复提交"); |
| | | } |
| | | if (!assessPlanById.getEvaluateUserId().equals(userInfoById.getId())){ |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR.getCode(), "您不是评价人,无法进行评价结果提交"); |
| | | List<RiskAssessPlanEvaluateUser> assessPlanEvaluateUserPlanId = evaluateUserService.getAssessPlanEvaluateUserPlanId(assessPlanById.getId(), userInfoById.getId()); |
| | | if (ObjectUtils.isEmpty(assessPlanEvaluateUserPlanId)) { |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR.getCode(), "您不是评价人,无法进行评价"); |
| | | } |
| | | // ExecStatusSubmitBO execStatusSubmitBO = new ExecStatusSubmitBO(); |
| | | // execStatusSubmitBO.setId(id); |
| | |
| | | predicateList.add(criteriaBuilder.in(root.get("id")).value(planIds)); |
| | | } |
| | | |
| | | Join<RiskAssessPlan, RiskAssessPlanIdentificationUser> identificationUserJoin = root.join("riskAssessPlanIdentificationUsers", JoinType.LEFT); |
| | | Join<RiskAssessPlan, RiskAssessPlanEvaluateUser> evaluateUserJoin = root.join("riskAssessPlanEvaluateUsers", JoinType.LEFT); |
| | | |
| | | if (roleTag == UserTagEnum.USER_TAG_0.getCode()){ |
| | | //此处应有谁能查询:辨识专家,评价专家,实验负责人(此处未存相关信息,以实验id为条件查询) |
| | | predicateList.add(criteriaBuilder.or( |
| | | criteriaBuilder.equal(root.get("identificationUserId"), currentUserId), |
| | | criteriaBuilder.equal(root.get("evaluateUserId"), currentUserId), |
| | | criteriaBuilder.equal(identificationUserJoin.get("identificationUserId"), currentUserId), |
| | | criteriaBuilder.equal(evaluateUserJoin.get("evaluateUserId"), currentUserId), |
| | | criteriaBuilder.in(root.get("experimentId")).value(experimentIdList) |
| | | ) |
| | | ); |
| | | // predicateList.add(criteriaBuilder.or( |
| | | // criteriaBuilder.equal(root.get("identificationUserId"), currentUserId), |
| | | // criteriaBuilder.equal(root.get("evaluateUserId"), currentUserId), |
| | | // criteriaBuilder.in(root.get("experimentId")).value(experimentIdList) |
| | | // ) |
| | | // ); |
| | | } |
| | | query.groupBy(root.get("id")); |
| | | predicateList.add(criteriaBuilder.equal(root.get("deleteStatus"),StatusEnum.DELETE_NOT.getCode())); |
| | | return criteriaBuilder.and(predicateList.toArray(new Predicate[0])); |
| | | } |
| | |
| | | |
| | | if (pageResult.getContent().size() > 0){ |
| | | for (RiskAssessPlan riskAssessPlan : pageResult.getContent()) { |
| | | |
| | | AssessQueryDTO assessQueryDTO = BeanCopyUtils.copyBean(riskAssessPlan, AssessQueryDTO.class); |
| | | for (RiskUnitListAppQueryDTO riskUnit : riskUnitListAppQueryDTOS) { |
| | | if (riskUnit.getId() == assessQueryDTO.getRiskUnitId()){ |
| | | assessQueryDTO.setRiskUnitName(riskUnit.getRiskName()); |
| | | } |
| | | } |
| | | List<RiskAssessPlanIdentificationUser> riskAssessPlanIdentificationUsers = riskAssessPlan.getRiskAssessPlanIdentificationUsers(); |
| | | if (!ObjectUtils.isEmpty(riskAssessPlanIdentificationUsers)) { |
| | | String identificationUsersString = riskAssessPlanIdentificationUsers.stream() |
| | | .map(RiskAssessPlanIdentificationUser::getIdentificationUser) |
| | | .collect(Collectors.joining(",")); |
| | | assessQueryDTO.setIdentificationUser(identificationUsersString); |
| | | List<UserIdentityRespDTO> userIdentityRespDTOS = BeanCopyUtils.copyBeanList(riskAssessPlanIdentificationUsers, UserIdentityRespDTO.class); |
| | | assessQueryDTO.setIdentityUsers(userIdentityRespDTOS); |
| | | |
| | | } |
| | | |
| | | List<RiskAssessPlanEvaluateUser> riskAssessPlanEvaluateUsers = riskAssessPlan.getRiskAssessPlanEvaluateUsers(); |
| | | if (!ObjectUtils.isEmpty(riskAssessPlanEvaluateUsers)) { |
| | | String identificationUsersString = riskAssessPlanEvaluateUsers.stream() |
| | | .map(RiskAssessPlanEvaluateUser::getEvaluateUser) |
| | | .collect(Collectors.joining(",")); |
| | | assessQueryDTO.setEvaluateUser(identificationUsersString); |
| | | List<UserEvaluateRespDTO> userEvaluateRespDTOS = BeanCopyUtils.copyBeanList(riskAssessPlanEvaluateUsers, UserEvaluateRespDTO.class); |
| | | assessQueryDTO.setEvaluateUsers(userEvaluateRespDTOS); |
| | | } |
| | | List<FactorQueryDTO> factorQueryDTOList = new ArrayList<>(); |
| | | List<PhaQueryDTO> phaList = new ArrayList<>(); |
| | |
| | | if (ObjectUtils.isEmpty(assessPlanById)){ |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR.getCode(), "辨识计划不存在,或已被删除"); |
| | | } |
| | | if (!assessPlanById.getIdentificationUserId().equals(currentUserId)){ |
| | | |
| | | List<RiskAssessPlanIdentificationUser> assessPlanIdentificationUserPlanId = planIdentificationUserService.getAssessPlanIdentificationUserPlanId(assessPlanById.getId(), currentUserId); |
| | | if (ObjectUtils.isEmpty(assessPlanIdentificationUserPlanId)) { |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode() ,"不是辨识专家,无法操作"); |
| | | } |
| | | if (ObjectUtils.isEmpty(assessPlanById.getIdentificationMethod())){ |
| | |
| | | List<RiskAssessPlan> assessPlanList = assessPlanRepository.getAssessPlanByExperimentId(experimentId); |
| | | return BeanCopyUtils.copyBeanList(assessPlanList, AssessPlanQueryDTO.class); |
| | | } |
| | | |
| | | /** |
| | | * 评估计划 - 查询已派发 |
| | | */ |
| | |
| | | } |
| | | return BeanCopyUtils.copyBeanList(riskAssessPlans, RiskAssessPlanListAppDTO.class); |
| | | } |
| | | |
| | | /** |
| | | * 评估计划 - 修改任务派发状态 |
| | | */ |
| | |
| | | |
| | | return tag; |
| | | } |
| | | |
| | | /** |
| | | * 风险评估计划 - 辨识专家拒绝 |
| | | */ |
| | |
| | | UserInfoDomainDTO user = userDomainService.getUserById(currentUserId); |
| | | |
| | | RiskAssessPlan assessPlanById = assessPlanRepository.getAssessPlanById(id); |
| | | if (!currentUserId.equals(assessPlanById.getEvaluateUserId())){ |
| | | List<RiskAssessPlanEvaluateUser> assessPlanEvaluateUserPlanId = evaluateUserService.getAssessPlanEvaluateUserPlanId(id, currentUserId); |
| | | if (ObjectUtils.isEmpty(assessPlanEvaluateUserPlanId)) { |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "不能拒绝其他专家的评价任务"); |
| | | } |
| | | if (assessPlanById.getPlanExecStatus().equals(StatusEnum.PLAN_EXEC_OVER.getCode())){ |
| | |
| | | if (ObjectUtils.isEmpty(assessPlanById)){ |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "辨识任务不存在"); |
| | | } |
| | | if (!assessPlanById.getIdentificationUserId().equals(currentUserId)){ |
| | | List<RiskAssessPlanIdentificationUser> assessPlanIdentificationUser = |
| | | planIdentificationUserService.getAssessPlanIdentificationUserPlanId(assessPlanById.getId(), currentUserId); |
| | | |
| | | if (ObjectUtils.isEmpty(assessPlanIdentificationUser)) { |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "只能修改自己的辨识任务"); |
| | | } |
| | | assessPlanById.setIdentificationMethod(updateReqDTO.getIdentificationMethodId()); |
| | |
| | | if (ObjectUtils.isEmpty(assessPlanById)){ |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "评价任务不存在"); |
| | | } |
| | | if (!assessPlanById.getEvaluateUserId().equals(currentUserId)){ |
| | | List<RiskAssessPlanEvaluateUser> assessPlanEvaluateUserPlanId = evaluateUserService.getAssessPlanEvaluateUserPlanId(assessPlanById.getId(), currentUserId); |
| | | if (ObjectUtils.isEmpty(assessPlanEvaluateUserPlanId)) { |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "只能修改自己的评价任务"); |
| | | } |
| | | assessPlanById.setEvaluateMethod(updateReqDTO.getEvaluateMethodId()); |
| | |
| | | return BeanCopyUtils.copyBean(save, AssessPlanUpdateDTO.class); |
| | | } |
| | | |
| | | @Override |
| | | public int appointNew(Long currentUserId, AppointUserTypeReBO appointUserReBO) { |
| | | if (appointUserReBO == null){ |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_DATA_NOT_EXISIST.getCode(), "数据错误"); |
| | | } |
| | | List<Long> userIds = appointUserReBO.getUserIds(); |
| | | if (ObjectUtils.isEmpty(userIds)){ |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_DATA_NOT_EXISIST.getCode(), "数据错误"); |
| | | } |
| | | RiskAssessPlan assessPlanById = assessPlanRepository.getAssessPlanById(appointUserReBO.getRiskAssessPlanId()); |
| | | if (ObjectUtils.isEmpty(assessPlanById)){ |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_DATA_NOT_EXISIST.getCode(), "评价计划不存在"); |
| | | } |
| | | String userType = appointUserReBO.getUserType(); |
| | | String userTypeName = userType == "1" ? "辨识专家" : "评价专家"; |
| | | |
| | | List<UserInfoDomainDTO> identificationUser = userDomainService.getUserInfoByIds(userIds, userTypeName); |
| | | if (ObjectUtils.isEmpty(identificationUser)) { |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_DATA_NOT_EXISIST.getCode(), userTypeName+"不存在或已被删除"); |
| | | } |
| | | if (identificationUser.size() != userIds.size()) { |
| | | throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_DATA_NOT_EXISIST.getCode(), "存在选中"+userTypeName+"不存在或已被删除"); |
| | | } |
| | | if (userType == "1"){ |
| | | planIdentificationUserService.deleteByPlanId(assessPlanById.getId(), LocalDateTime.now()); |
| | | saveIdentificationUser(assessPlanById.getId(), identificationUser, LocalDateTime.now(), currentUserId); |
| | | }else { |
| | | //处理评价专家 |
| | | evaluateUserService.deleteRsByPlan(assessPlanById.getId(), LocalDateTime.now()); |
| | | saveEvaUser(assessPlanById.getId(), identificationUser, LocalDateTime.now(), currentUserId); |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | } |