浏览代码

代码优化

gaodm 4 年之前
父节点
当前提交
d3fa2d3bd3

+ 19 - 18
src/main/java/com/diagbot/facade/ExportFacade.java

@@ -508,9 +508,9 @@ public class ExportFacade {
                     && StringUtil.isNotBlank(importDataVO.getOrderType())
                     && !importDataVO.getOrderType().equals("联合项目")
                     && StringUtil.isBlank(importDataVO.getStatus())) {
-//                if (!importDataVO.getNeoType().equals("7")) {
-//                    continue;
-//                }
+                //                if (!importDataVO.getNeoType().equals("7")) {
+                //                    continue;
+                //                }
                 if (importDataVO.getNeoType().equals("7")) {
                     if (importDataVO.getNeoName().trim().equals("本品成份")
                             || importDataVO.getNeoName().trim().equals("本品的成分")
@@ -1028,7 +1028,7 @@ public class ExportFacade {
                     }
                     klRuleService.save(klRule);
                     if (importDataVO.getOperationLevel().equals("2")) {
-                        Integer groupType = 0;
+                        Integer groupType = 1;
                         if (StringUtil.isNotBlank(importDataVO.getAgeAll())) {
                             groupType = analyDataDeal(map, importDataVO.getAgeAll(), klRule.getId(), 410, groupType);
                         }
@@ -1111,10 +1111,10 @@ public class ExportFacade {
     }
 
     private Integer klRuleAnalyVODeal(KlRuleAnalyVO klRuleAnalyVO, Map<String, KlConcept> map, Long ruleId, Integer condType, Integer noCondType, Integer groupType) {
+        List<KlRuleBase> klRuleBaseList = new ArrayList<>();
         if (ListUtil.isNotEmpty(klRuleAnalyVO.getCondList())) {
             for (KlRuleConditionVO klRuleConditionVO : klRuleAnalyVO.getCondList()) {
                 if (null != map.get(klRuleConditionVO.getName() + "_" + condType)) {
-                    groupType++;
                     KlRuleBase klRuleBase = new KlRuleBase();
                     klRuleBase.setType(2);
                     klRuleBase.setConceptId(map.get(klRuleConditionVO.getName() + "_" + condType).getId());
@@ -1145,32 +1145,33 @@ public class ExportFacade {
                     } else {
                         /*DO Nothing*/
                     }
-                    klRuleBaseService.save(klRuleBase);
-                    KlRuleCondition klRuleCondition = new KlRuleCondition();
-                    klRuleCondition.setGroupType(groupType);
-                    klRuleCondition.setRuleId(ruleId);
-                    klRuleCondition.setRuleBaseId(klRuleBase.getId());
-                    klRuleConditionService.save(klRuleCondition);
+                    klRuleBaseList.add(klRuleBase);
                 }
             }
         }
         if (ListUtil.isNotEmpty(klRuleAnalyVO.getNoCondList())) {
             for (String noCond : klRuleAnalyVO.getNoCondList()) {
                 if (null != map.get(noCond + "_" + noCondType)) {
-                    groupType++;
                     KlRuleBase klRuleBase = new KlRuleBase();
                     klRuleBase.setType(1);
                     klRuleBase.setConceptId(map.get(noCond + "_" + noCondType).getId());
                     klRuleBase.setDescription(noCond);
-                    klRuleBaseService.save(klRuleBase);
-                    KlRuleCondition klRuleCondition = new KlRuleCondition();
-                    klRuleCondition.setGroupType(groupType);
-                    klRuleCondition.setRuleId(ruleId);
-                    klRuleCondition.setRuleBaseId(klRuleBase.getId());
-                    klRuleConditionService.save(klRuleCondition);
+                    klRuleBaseList.add(klRuleBase);
                 }
             }
         }
+        if (ListUtil.isNotEmpty(klRuleBaseList)) {
+            klRuleBaseService.saveBatch(klRuleBaseList);
+            List<KlRuleCondition> klRuleConditionList = new ArrayList<>();
+            for (KlRuleBase klRuleBase : klRuleBaseList) {
+                KlRuleCondition klRuleCondition = new KlRuleCondition();
+                klRuleCondition.setGroupType(groupType++);
+                klRuleCondition.setRuleId(ruleId);
+                klRuleCondition.setRuleBaseId(klRuleBase.getId());
+                klRuleConditionList.add(klRuleCondition);
+            }
+            klRuleConditionService.saveBatch(klRuleConditionList);
+        }
         return groupType;
     }
 

+ 2 - 2
src/main/java/com/diagbot/repository/ExportNodeRepository.java

@@ -10,9 +10,9 @@ import java.util.List;
 
 public interface ExportNodeRepository extends Neo4jRepository<ExportNodeInfo, Long> {
 
-    @Query("MATCH (n:`医保疾病名称`)-[]->(m:`医保ICD_10代码`)RETURN distinct trim(n.name) as name ,case when n.sex is not null then n.sex else '3' end as sex,case when n.age is not null then n.age else '0-200' end as ageRange,trim(m.name) as icd10Code")
+    @Query("MATCH (n:`医保疾病名称`)-[]->(m:`医保ICD_10代码`)RETURN distinct trim(n.name) as name ,case when n.sex is not null then n.sex else '3' end as sex,case when n.age is null then '0-200'  when n.age ='-'  then  '0-200' else n.age end as ageRange,trim(m.name) as icd10Code")
     List<ExportNode> getDisease();
-    @Query("MATCH (n:`医保疾病名称`) RETURN distinct trim(n.name) as name ,case when n.sex is not null then n.sex else '3' end as sex,case when n.age is not null then n.age else '0-200' end as ageRange,\"\" as icd10Code")
+    @Query("MATCH (n:`医保疾病名称`) RETURN distinct trim(n.name) as name ,case when n.sex is not null then n.sex else '3' end as sex,case when n.age is null then '0-200'  when n.age ='-'  then  '0-200' else n.age end as ageRange,\"\" as icd10Code")
     List<ExportNode> getDisease2();
 
     @Query("MATCH (n:`药品通用名称`) RETURN distinct(trim(n.name)) as name")