From 8485affcb0d4de05059d80cb1e844d6b18291654 Mon Sep 17 00:00:00 2001
From: heheng <475597332@qq.com>
Date: 星期五, 16 五月 2025 14:35:49 +0800
Subject: [PATCH] 修正

---
 src/main/java/com/gkhy/labRiskManage/domain/experiment/service/impl/ExperimentInfoServiceImpl.java |  177 ++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 122 insertions(+), 55 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 c9d64fb..d5ab93f 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,9 +179,10 @@
         }
         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());
@@ -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(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(),"请填写实验负责人手机号!");
         }
@@ -304,9 +332,10 @@
         }
         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());
@@ -319,6 +348,32 @@
         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
@@ -551,11 +606,14 @@
                 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.getExperimentId())){
+                    predicateList.add(criteriaBuilder.equal(root.get("id"), queryBO.getExperimentId()));
                 }
                 if (!ObjectUtils.isEmpty(queryBO.getStartTime())){
                     predicateList.add(criteriaBuilder.greaterThanOrEqualTo(root.get("createTime"), queryBO.getStartTime()));
@@ -566,14 +624,23 @@
                 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),
-                            criteriaBuilder.equal(experimentJion.get("identificationUserId"), currentUserId),
-                            criteriaBuilder.equal(experimentJion.get("evaluateUserId"), currentUserId))
-                    );
-                    query.groupBy(root.get("id"));
+                if (ObjectUtils.isEmpty(queryBO.getExperimentId())){
+                    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("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()));
                 }
 
                 //返回组装的条件

--
Gitblit v1.9.2