Ver Fonte

样本送检、基因定制支持多状态查询

陈长荣 há 1 dia atrás
pai
commit
c12839b1c0

+ 7 - 0
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/constants/GeneStatusEnum.java

@@ -64,6 +64,13 @@ public enum GeneStatusEnum {
         );
     }
 
+    public static List<Pair<String, String>> getGeneAuditStatusList() {
+        return Arrays.asList(GENE_EDITING.toPair(),
+                PROJECT_LEADER.toPair(),
+                PROJECT_MANAGEMENT.toPair()
+        );
+    }
+
     /**
      * 样本送检流程状态列表
      */

+ 2 - 0
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/controller/FlowController.java

@@ -7,6 +7,7 @@ import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.jfcloud.common.core.constant.enums.YesNoEnum;
+import com.github.jfcloud.common.core.encrypt.EncryptContextHolder;
 import com.github.jfcloud.common.core.util.R;
 import com.github.jfcloud.gene.cache.UserIdNameCache;
 import com.github.jfcloud.gene.constants.GeneStatusEnum;
@@ -46,6 +47,7 @@ public class FlowController {
     @Operation(summary = "列表查询")
     @GetMapping("/page")
     public R<Page<FlowPageDto>> page(FlowPageVo vo) {
+        EncryptContextHolder.disable();
         return R.ok(flowInfoService.getPage(vo));
     }
 

+ 29 - 9
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/service/impl/FlowInfoServiceImpl.java

@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DatePattern;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.lang.Assert;
+import cn.hutool.core.lang.Pair;
 import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
@@ -98,18 +99,24 @@ public class FlowInfoServiceImpl extends ServiceImpl<FlowInfoMapper, FlowInfo> i
                 .orderByDesc(FlowInfo::getCreateTime);
 
         DataScope dataScope = DataScope.of();
-        //选择了审核状态,则只能看到自己审核的
+        if (StrUtil.isNotBlank(vo.getStatus())) {
+            if (vo.getStatus().contains(",")) {
+                vo.getStatusList().addAll(Arrays.asList(vo.getStatus().split(",")));
+            } else {
+                vo.getStatusList().add(vo.getStatus());
+            }
+            vo.setStatus(null);
+        }
+
         if (CollUtil.isNotEmpty(vo.getStatusList())) {
-            if (GeneStatusEnum.GENE_EDITING.getStatus().equals(vo.getStatusList().get(0))) {
-                lqw.eq(FlowInfo::getGeneEditPlId, UserUtil.getUserId());
-                dataScope = null;
-            } else if (GeneStatusEnum.PROJECT_LEADER.getStatus().equals(vo.getStatusList().get(0))) {
-                lqw.eq(FlowInfo::getProjectLeaderId, UserUtil.getUserId());
-                dataScope = null;
-            } else if (GeneStatusEnum.PROJECT_MANAGEMENT.getStatus().equals(vo.getStatusList().get(0))) {
-                lqw.eq(FlowInfo::getProjectManageId, UserUtil.getUserId());
+            Optional<Pair<String, String>> opt = GeneStatusEnum.getGeneAuditStatusList().stream()
+                    .filter(x -> vo.getStatusList().contains(x.getKey()))
+                    .findAny();
+            if (opt.isPresent()) {
                 dataScope = null;
+                lqw.and(x -> queryStatus(vo.getStatusList(), x));
             }
+
         }
 
         Page<FlowInfo> page = baseMapper.selectPageByScope(pageQuery, lqw, dataScope);
@@ -133,6 +140,19 @@ public class FlowInfoServiceImpl extends ServiceImpl<FlowInfoMapper, FlowInfo> i
         return pageDto.setRecords(records);
     }
 
+    private void queryStatus(List<String> statusList, LambdaQueryWrapper<FlowInfo> lqw2) {
+        //选择了审核状态,则只能看到自己审核的
+        for (String sta : statusList) {
+            if (GeneStatusEnum.GENE_EDITING.getStatus().equals(sta)) {
+                lqw2.or(x -> x.eq(FlowInfo::getGeneEditPlId, UserUtil.getUserId()));
+            } else if (GeneStatusEnum.PROJECT_LEADER.getStatus().equals(sta)) {
+                lqw2.or(x -> x.eq(FlowInfo::getProjectLeaderId, UserUtil.getUserId()));
+            } else if (GeneStatusEnum.PROJECT_MANAGEMENT.getStatus().equals(sta)) {
+                lqw2.or(x -> x.eq(FlowInfo::getProjectManageId, UserUtil.getUserId()));
+            }
+        }
+    }
+
     @Override
     public FlowDetailDto getDetail(Long id) {
         FlowInfo flowInfo = getById(id);

+ 1 - 0
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/vo/FlowPageVo.java

@@ -41,6 +41,7 @@ public class FlowPageVo {
      */
     @Schema(description = "状态列表")
     private List<String> statusList = new ArrayList<>();
+    private String status;
 
     /**
      * 批准编号

+ 8 - 1
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/sample/service/impl/SampleInfoServiceImpl.java

@@ -193,10 +193,17 @@ public class SampleInfoServiceImpl extends ServiceImpl<SampleInfoMapper, SampleI
         Page<SampleInfo> pageQuery = new Page<>(vo.getCurrent(), vo.getSize());
         LambdaQueryWrapper<SampleInfo> wrapper = new LambdaQueryWrapper<>(SampleInfo.class)
                 .eq(StrUtil.isNotBlank(vo.getType()), SampleInfo::getType, vo.getType())
-                .eq(StrUtil.isNotBlank(vo.getStatus()), SampleInfo::getStatus, vo.getStatus())
                 .eq(Objects.nonNull(vo.getApplicantId()), SampleInfo::getApplicantId, vo.getApplicantId())
                 .eq(SampleInfo::getDeleted, YesNoEnum.NO.getCode())
                 .orderByDesc(SampleInfo::getApplyTime, SampleInfo::getCreateTime);
+        if (StrUtil.isNotBlank(vo.getStatus())) {
+            if (vo.getStatus().contains(",")) {
+                wrapper.in(SampleInfo::getStatus, vo.getStatus().split(","));
+            } else {
+                wrapper.eq(SampleInfo::getStatus, vo.getStatus());
+            }
+        }
+
         if (StrUtil.isNotBlank(vo.getProject())) {
             wrapper.and(i -> i.like(SampleInfo::getProjectNo, vo.getProject()).or()
                     .like(SampleInfo::getProjectName, vo.getProject()));