فهرست منبع

动物样本委托列表、送检申请单根据勾选项保存

陈长荣 2 ماه پیش
والد
کامیت
ba63ba340a

+ 54 - 0
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/sample/enums/PathogenSampleTypeEnum.java

@@ -0,0 +1,54 @@
+package com.github.jfcloud.gene.sample.enums;
+
+import cn.hutool.core.util.StrUtil;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * 病原样本类型
+ */
+public enum PathogenSampleTypeEnum {
+    PIG("新入驻猪送检"),
+    RODENT("啮齿类检测"),
+    MONKEY("猴检测"),
+    DOG("犬检测"),
+    CAT("猫检测"),
+    GOAT("羊检测"),
+    MATERIAL("物料环境检测");
+
+    private final String description;
+
+    PathogenSampleTypeEnum(String description) {
+        this.description = description;
+    }
+
+    public static PathogenSampleTypeEnum resolve(String type) {
+        for (PathogenSampleTypeEnum value : values()) {
+            if (value.name().equals(type)) {
+                return value;
+            }
+        }
+        return null;
+    }
+
+    public static List<String> resolveList(String type) {
+        if (StrUtil.isBlank(type)) {
+            return Collections.emptyList();
+        }
+        List<String> list = new ArrayList<>();
+        for (String s : type.split(",")) {
+            PathogenSampleTypeEnum item = resolve(s);
+            if (item != null) {
+                list.add(item.name().toLowerCase());
+            }
+        }
+
+        return list;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+}

+ 51 - 0
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/sample/enums/ScientificSampleTypeEnum.java

@@ -0,0 +1,51 @@
+package com.github.jfcloud.gene.sample.enums;
+
+import cn.hutool.core.util.StrUtil;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * 科研项目送检样本类型
+ */
+public enum ScientificSampleTypeEnum {
+    elisa("ELISA样本送检"),
+    urine("尿常规样本送检"),
+    blood("血常规样本送检"),
+    serum("血清样本送检");
+
+    private final String description;
+
+    ScientificSampleTypeEnum(String description) {
+        this.description = description;
+    }
+
+    public static ScientificSampleTypeEnum resolve(String type) {
+        for (ScientificSampleTypeEnum value : values()) {
+            if (value.name().equals(type)) {
+                return value;
+            }
+        }
+        return null;
+    }
+
+    public static List<String> resolveList(String type) {
+        if (StrUtil.isBlank(type)) {
+            return Collections.emptyList();
+        }
+        List<String> list = new ArrayList<>();
+        for (String s : type.split(",")) {
+            ScientificSampleTypeEnum item = resolve(s);
+            if (item != null) {
+                list.add(item.name().toLowerCase());
+            }
+        }
+
+        return list;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+}

+ 6 - 2
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/sample/service/biz/SampleAnimalServiceImpl.java

@@ -26,7 +26,9 @@ import com.github.jfcloud.gene.flow.entity.FlowAudit;
 import com.github.jfcloud.gene.flow.service.FlowAuditService;
 import com.github.jfcloud.gene.flow.service.NotifyService;
 import com.github.jfcloud.gene.sample.entity.*;
+import com.github.jfcloud.gene.sample.enums.PathogenSampleTypeEnum;
 import com.github.jfcloud.gene.sample.enums.SampleTypeEnum;
+import com.github.jfcloud.gene.sample.enums.ScientificSampleTypeEnum;
 import com.github.jfcloud.gene.sample.mapper.InspectionCommissionMapper;
 import com.github.jfcloud.gene.sample.mapper.SampleAnimalMapper;
 import com.github.jfcloud.gene.sample.mapper.SampleCheckOrderMapper;
@@ -115,9 +117,10 @@ public class SampleAnimalServiceImpl extends ServiceImpl<SampleAnimalMapper, Sam
         sampleAnimal.insert();
 
         //保存委托列表,通过JSON序列化转为列表
+        List<String> paTypes = PathogenSampleTypeEnum.resolveList(vo.getAnimal().getPathogenSampleType());
         CommissionObjVo commissionObj = vo.getAnimal().getCommission();
         JSONObject commissionJson = JSON.parseObject(JSON.toJSONString(commissionObj, SerializerFeature.WriteMapNullValue));
-        for (String fieldName : commissionJson.keySet()) {
+        for (String fieldName : paTypes) {
             JSONObject fieldJson = commissionJson.getJSONObject(fieldName);
             if (fieldJson == null) {
                 continue;
@@ -144,9 +147,10 @@ public class SampleAnimalServiceImpl extends ServiceImpl<SampleAnimalMapper, Sam
         }
 
         //保存送检申请单
+        List<String> scTypes = ScientificSampleTypeEnum.resolveList(vo.getAnimal().getScientificSampleType());
         CheckOrderObjVo orderObj = vo.getAnimal().getOrder();
         JSONObject orderJson = JSON.parseObject(JSON.toJSONString(orderObj, SerializerFeature.WriteMapNullValue));
-        for (String fieldName : orderJson.keySet()) {
+        for (String fieldName : scTypes) {
             JSONObject fieldJson = orderJson.getJSONObject(fieldName);
             if (fieldJson == null) {
                 continue;