From a27162cb82ef0cabf9b43cbfd1f3eb8c177d1e14 Mon Sep 17 00:00:00 2001
From: heheng <heheng@123456>
Date: Mon, 13 Jan 2025 15:22:44 +0800
Subject: [PATCH] 修改问题
---
src/main/java/com/gkhy/labRiskManage/domain/experiment/service/impl/ExperimentInfoServiceImpl.java | 156 +++++++++++++++++++++++++++++++++++++--------------
1 files changed, 112 insertions(+), 44 deletions(-)
diff --git a/src/main/java/com/gkhy/labRiskManage/domain/experiment/service/impl/ExperimentInfoServiceImpl.java b/src/main/java/com/gkhy/labRiskManage/domain/experiment/service/impl/ExperimentInfoServiceImpl.java
index f3b5b59..150d579 100644
--- a/src/main/java/com/gkhy/labRiskManage/domain/experiment/service/impl/ExperimentInfoServiceImpl.java
+++ b/src/main/java/com/gkhy/labRiskManage/domain/experiment/service/impl/ExperimentInfoServiceImpl.java
@@ -43,6 +43,7 @@
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;
@@ -76,31 +77,32 @@
@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(),"请选择实验负责人!");
}
@@ -177,6 +179,7 @@
}
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);
@@ -193,33 +196,58 @@
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(operator.getName());
+ experimentInfo.setLiabilityUserId(currentUserId);
+ 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(),"请填写实验负责人手机号!");
}
@@ -304,6 +332,7 @@
}
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());
@@ -319,6 +348,30 @@
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(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
@@ -532,6 +585,14 @@
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) {
@@ -543,9 +604,9 @@
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()+'%'));
}
@@ -555,7 +616,10 @@
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()){
Join<ExperimentInfo, RiskAssessPlan> experimentJion = root.join("riskAssessPlans", JoinType.LEFT);
predicateList.add(criteriaBuilder.or(
criteriaBuilder.equal(root.get("liabilityUserId"), currentUserId),
@@ -564,6 +628,10 @@
);
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])));
--
Gitblit v1.9.2