From 37b0d2560607d1e0bfd5247a59a154704cac60f8 Mon Sep 17 00:00:00 2001
From: heheng <heheng@123456>
Date: 星期四, 07 十一月 2024 09:17:43 +0800
Subject: [PATCH] 修改暂存和详情暂时及列表数据处理

---
 src/main/java/com/gkhy/labRiskManage/domain/experiment/service/impl/ExperimentInfoServiceImpl.java |  142 +++++++++++++++++++++++++++++++++--------------
 1 files changed, 99 insertions(+), 43 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..c32183a 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
@@ -76,31 +76,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 +178,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 +195,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 +331,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 +347,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
@@ -551,9 +603,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()+'%'));
                 }
@@ -575,6 +627,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