| | |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.data.jpa.domain.Specification; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | |
| | | @Override |
| | | public ExperimentInfoDTO save(Long currentUserId, ExperimentAppInsertBO experimentAppInsertBO) { |
| | | UserInfoDomainDTO operator = userDomainService.getUserInfoById(currentUserId); |
| | | //验证权限 |
| | | List<SysUserRoleBindDomainDTO> roles = operator.getRoles(); |
| | | boolean flag = false; |
| | | if(roles != null && roles.size() > 0){ |
| | | for (SysUserRoleBindDomainDTO role : roles){ |
| | | if (role.getRoleName().equals(UserRoleEnum.USER_ROLE_1.getDesc())) { |
| | | flag = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (!flag){ |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"该账号无权限录入实验信息!"); |
| | | } |
| | | // 20211105去掉权限验证 |
| | | // //验证权限 |
| | | // List<SysUserRoleBindDomainDTO> roles = operator.getRoles(); |
| | | // boolean flag = false; |
| | | // if(roles != null && roles.size() > 0){ |
| | | // for (SysUserRoleBindDomainDTO role : roles){ |
| | | // if (role.getRoleName().equals(UserRoleEnum.USER_ROLE_1.getDesc())) { |
| | | // flag = true; |
| | | // break; |
| | | // } |
| | | // } |
| | | // } |
| | | // if (!flag){ |
| | | // throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"该账号无权限录入实验信息!"); |
| | | // } |
| | | |
| | | //验证 |
| | | if(ObjectUtils.isEmpty(experimentAppInsertBO.getExperimentName())){ |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"请填写实验名称!"); |
| | | } |
| | | if(ObjectUtils.isEmpty(experimentAppInsertBO.getExperimentType())){ |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_ILLEGAL.getCode(),"请选择实验类型!"); |
| | | } |
| | | if(ObjectUtils.isEmpty(ExperimentTypeEnum.prase(experimentAppInsertBO.getExperimentType()))){ |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_ILLEGAL.getCode(),"实验类型非法!"); |
| | | } |
| | | // if(ObjectUtils.isEmpty(experimentAppInsertBO.getExperimentType())){ |
| | | // throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_ILLEGAL.getCode(),"请选择实验类型!"); |
| | | // } |
| | | // if(ObjectUtils.isEmpty(ExperimentTypeEnum.prase(experimentAppInsertBO.getExperimentType()))){ |
| | | // throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_ILLEGAL.getCode(),"实验类型非法!"); |
| | | // } |
| | | if(ObjectUtils.isEmpty(experimentAppInsertBO.getLiabilityUserId())){ |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"请选择实验负责人!"); |
| | | } |
| | |
| | | } |
| | | ExperimentInfo experimentInfo = new ExperimentInfo(); |
| | | BeanUtils.copyProperties(experimentAppInsertBO, experimentInfo); |
| | | experimentInfo.setStagingTag(ExperimentStagingEnum.SAVE.getValue()); |
| | | experimentInfo.setDeleteStatus(StatusEnum.DELETE_NOT.getCode().byteValue()); |
| | | experimentInfo.setLiabilityUser(operator.getName()); |
| | | experimentInfo.setLiabilityUserId(currentUserId); |
| | | // experimentInfo.setLiabilityUser(operator.getName()); |
| | | // experimentInfo.setLiabilityUserId(currentUserId); |
| | | experimentInfo.setStage(ExperimentStageEnum.NOT_EVALUATION.getValue()); |
| | | experimentInfo.setStatus(ExperimentStatusEnum.NOT_APPLY.getValue()); |
| | | experimentInfo.setExperimentTag(ExperimentTagEnum.NEW_CREATE.getValue()); |
| | |
| | | |
| | | return converter.getExperimentInfoDTO(experiment); |
| | | } |
| | | |
| | | @Override |
| | | public ExperimentInfoDTO temporary(Long currentUserId, ExperimentAppInsertBO experimentAppInsertBO) { |
| | | UserInfoDomainDTO operator = userDomainService.getUserInfoById(currentUserId); |
| | | ExperimentInfo experimentInfo = new ExperimentInfo(); |
| | | BeanUtils.copyProperties(experimentAppInsertBO, experimentInfo); |
| | | experimentInfo.setStagingTag(ExperimentStagingEnum.NOT_SAVE.getValue()); |
| | | experimentInfo.setDeleteStatus(StatusEnum.DELETE_NOT.getCode().byteValue()); |
| | | experimentInfo.setLiabilityUser(experimentAppInsertBO.getLiabilityUser()); |
| | | experimentInfo.setLiabilityUserId(experimentAppInsertBO.getLiabilityUserId()); |
| | | experimentInfo.setStage(ExperimentStageEnum.NOT_EVALUATION.getValue()); |
| | | experimentInfo.setStatus(ExperimentStatusEnum.NOT_APPLY.getValue()); |
| | | experimentInfo.setExperimentTag(ExperimentTagEnum.NEW_CREATE.getValue()); |
| | | experimentInfo.setRectifyStatus(ExperimentRectifyStatusEnum.NOT_RECTIFY.getValue()); |
| | | experimentInfo.setExperimentCode(generateTestNumber()); |
| | | experimentInfo.setCreateByUserId(currentUserId); |
| | | experimentInfo.setInformant(operator == null?"":operator.getName()); |
| | | experimentInfo.setUpdateByUserId(currentUserId); |
| | | experimentInfo.setApprovalStatus(ExperimentApprovalStatusEnum.NOT_APPROVAL.getValue()); |
| | | ExperimentInfo experiment = repository.save(experimentInfo); |
| | | |
| | | return converter.getExperimentInfoDTO(experiment); |
| | | } |
| | | |
| | | @Override |
| | | public ExperimentInfoDTO developSave(Long currentUserId, ExperimentAppInsertBO experimentAppInsertBO) { |
| | | UserInfoDomainDTO operator = userDomainService.getUserInfoById(currentUserId); |
| | | //验证权限 |
| | | List<SysUserRoleBindDomainDTO> roles = operator.getRoles(); |
| | | boolean flag = false; |
| | | if(roles != null && roles.size() > 0){ |
| | | for (SysUserRoleBindDomainDTO role : roles){ |
| | | if (role.getRoleName().equals(UserRoleEnum.USER_ROLE_1.getDesc())) { |
| | | flag = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (!flag){ |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"该账号无权限录入实验信息!"); |
| | | } |
| | | // 20211105去掉权限验证 |
| | | // //验证权限 |
| | | // List<SysUserRoleBindDomainDTO> roles = operator.getRoles(); |
| | | // boolean flag = false; |
| | | // if(roles != null && roles.size() > 0){ |
| | | // for (SysUserRoleBindDomainDTO role : roles){ |
| | | // if (role.getRoleName().equals(UserRoleEnum.USER_ROLE_1.getDesc())) { |
| | | // flag = true; |
| | | // break; |
| | | // } |
| | | // } |
| | | // } |
| | | // if (!flag){ |
| | | // throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"该账号无权限录入实验信息!"); |
| | | // } |
| | | //验证 |
| | | if(ObjectUtils.isEmpty(experimentAppInsertBO.getExperimentName())){ |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"请填写实验名称!"); |
| | | } |
| | | if(ObjectUtils.isEmpty(experimentAppInsertBO.getExperimentType())){ |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_ILLEGAL.getCode(),"请选择实验类型!"); |
| | | } |
| | | if(ObjectUtils.isEmpty(ExperimentTypeEnum.prase(experimentAppInsertBO.getExperimentType()))){ |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_ILLEGAL.getCode(),"实验类型非法!"); |
| | | } |
| | | // if(ObjectUtils.isEmpty(experimentAppInsertBO.getExperimentType())){ |
| | | // throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_ILLEGAL.getCode(),"请选择实验类型!"); |
| | | // } |
| | | // if(ObjectUtils.isEmpty(ExperimentTypeEnum.prase(experimentAppInsertBO.getExperimentType()))){ |
| | | // throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_ILLEGAL.getCode(),"实验类型非法!"); |
| | | // } |
| | | if(ObjectUtils.isEmpty(experimentAppInsertBO.getLiabilityUserPhone())){ |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"请填写实验负责人手机号!"); |
| | | } |
| | |
| | | } |
| | | ExperimentInfo experimentInfo = new ExperimentInfo(); |
| | | BeanUtils.copyProperties(experimentAppInsertBO, experimentInfo); |
| | | experimentInfo.setStagingTag(ExperimentStagingEnum.SAVE.getValue()); |
| | | experimentInfo.setDeleteStatus(StatusEnum.DELETE_NOT.getCode().byteValue()); |
| | | experimentInfo.setLiabilityUserId(currentUserId); |
| | | experimentInfo.setLiabilityUser(operator.getName()); |
| | | // experimentInfo.setLiabilityUserId(currentUserId); |
| | | // experimentInfo.setLiabilityUser(operator.getName()); |
| | | experimentInfo.setStage(ExperimentStageEnum.NOT_EVALUATION.getValue()); |
| | | experimentInfo.setStatus(ExperimentStatusEnum.NOT_APPLY.getValue()); |
| | | experimentInfo.setExperimentTag(ExperimentTagEnum.AREADLY_DEVELOP.getValue()); |
| | |
| | | ExperimentInfo experiment = repository.save(experimentInfo); |
| | | |
| | | return converter.getExperimentInfoDTO(experiment); |
| | | } |
| | | |
| | | @Override |
| | | public ExperimentInfoDTO developTemporary(Long currentUserId, ExperimentAppInsertBO experimentAppInsertBO) { |
| | | UserInfoDomainDTO operator = userDomainService.getUserInfoById(currentUserId); |
| | | ExperimentInfo experimentInfo = new ExperimentInfo(); |
| | | BeanUtils.copyProperties(experimentAppInsertBO, experimentInfo); |
| | | experimentInfo.setStagingTag(ExperimentStagingEnum.NOT_SAVE.getValue()); |
| | | experimentInfo.setDeleteStatus(StatusEnum.DELETE_NOT.getCode().byteValue()); |
| | | experimentInfo.setLiabilityUserId(experimentAppInsertBO.getLiabilityUserId()); |
| | | experimentInfo.setLiabilityUser(experimentAppInsertBO.getLiabilityUser()); |
| | | // experimentInfo.setLiabilityUserId(currentUserId); |
| | | // experimentInfo.setLiabilityUser(operator.getName()); |
| | | experimentInfo.setStage(ExperimentStageEnum.NOT_EVALUATION.getValue()); |
| | | experimentInfo.setStatus(ExperimentStatusEnum.NOT_APPLY.getValue()); |
| | | experimentInfo.setExperimentTag(ExperimentTagEnum.AREADLY_DEVELOP.getValue()); |
| | | experimentInfo.setRectifyStatus(ExperimentRectifyStatusEnum.NOT_RECTIFY.getValue()); |
| | | experimentInfo.setExperimentCode(generateTestNumber()); |
| | | experimentInfo.setCreateByUserId(currentUserId); |
| | | experimentInfo.setInformant(operator == null?"":operator.getName()); |
| | | experimentInfo.setUpdateByUserId(currentUserId); |
| | | experimentInfo.setApprovalStatus(ExperimentApprovalStatusEnum.NOT_APPROVAL.getValue()); |
| | | ExperimentInfo experiment = repository.save(experimentInfo); |
| | | |
| | | return converter.getExperimentInfoDTO(experiment); |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | ExperimentInfoQueryBO queryBO = pageQuery.getSearchParams(); |
| | | UserInfoDomainDTO user = userDomainService.getUserById(currentUserId); |
| | | int roleTag = GetRoleTagUtils.GetRoleTagUtils(user); |
| | | |
| | | // TODO: 2023/11/10 |
| | | List<ReportRiskAssessInfo> byLevel = reportRiskAssessInfoRepository.getByLevel(queryBO.getAssessLevel()); |
| | | List<Long> ids = new ArrayList<>(); |
| | | for (ReportRiskAssessInfo reportRiskAssessInfo : byLevel) { |
| | | ids.add(reportRiskAssessInfo.getExperimentId()); |
| | | } |
| | | |
| | | Specification<ExperimentInfo> specification = new Specification<ExperimentInfo>() { |
| | | @Override |
| | | public Predicate toPredicate(Root<ExperimentInfo> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) { |
| | |
| | | if(!ObjectUtils.isEmpty(ExperimentTagEnum.prase(queryBO.getExperimentTag()))){ |
| | | predicateList.add(criteriaBuilder.equal(root.get("experimentTag"),queryBO.getExperimentTag())); |
| | | } |
| | | if (!ObjectUtils.isEmpty(ExperimentTypeEnum.prase(queryBO.getExperimentType()))){ |
| | | predicateList.add(criteriaBuilder.equal(root.get("experimentType"), queryBO.getExperimentType())); |
| | | } |
| | | // if (!ObjectUtils.isEmpty(ExperimentTypeEnum.prase(queryBO.getExperimentType()))){ |
| | | // predicateList.add(criteriaBuilder.equal(root.get("experimentType"), queryBO.getExperimentType())); |
| | | // } |
| | | if (StrUtil.isNotBlank(queryBO.getExperimentName())){ |
| | | predicateList.add(criteriaBuilder.like(root.get("experimentName"), '%'+ queryBO.getExperimentName()+'%')); |
| | | } |
| | |
| | | if (!ObjectUtils.isEmpty(queryBO.getEndTime())){ |
| | | predicateList.add(criteriaBuilder.lessThanOrEqualTo(root.get("createTime"), queryBO.getEndTime())); |
| | | } |
| | | if(roleTag == UserTagEnum.USER_TAG_0.getCode()){ // todo |
| | | if (!ObjectUtils.isEmpty(queryBO.getAssessLevel())){ |
| | | predicateList.add(criteriaBuilder.in(root.get("id")).value(ids)); |
| | | } |
| | | if(roleTag == UserTagEnum.USER_TAG_0.getCode() || roleTag == UserTagEnum.USER_TAG_1.getCode()){ |
| | | Join<ExperimentInfo, RiskAssessPlan> experimentJion = root.join("riskAssessPlans", JoinType.LEFT); |
| | | //criteriaBuilder.equal(root.get("liabilityUserId"), currentUserId), |
| | | predicateList.add(criteriaBuilder.or( |
| | | criteriaBuilder.equal(root.get("liabilityUserId"), currentUserId), |
| | | criteriaBuilder.equal(root.get("safeLiabilityUserId"), currentUserId), |
| | | criteriaBuilder.equal(experimentJion.get("identificationUserId"), currentUserId), |
| | | criteriaBuilder.equal(experimentJion.get("evaluateUserId"), currentUserId)) |
| | | ); |
| | | query.groupBy(root.get("id")); |
| | | } |
| | | |
| | | if (!ObjectUtils.isEmpty(ExperimentTypeEnum.prase(queryBO.getExperimentType()))){ |
| | | Join<ExperimentInfo, ExperimentAndType> typeJoin = root.join("types", JoinType.LEFT); |
| | | predicateList.add(criteriaBuilder.equal(typeJoin.get("typeId"), queryBO.getExperimentType())); |
| | | } |
| | | |
| | | //返回组装的条件 |
| | | return criteriaBuilder.and(predicateList.toArray(predicateList.toArray(new Predicate[0]))); |
| | | } |