Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/push-dev-diagnose' into push-debug

kongwz 6 gadi atpakaļ
vecāks
revīzija
8edf4a16b1

+ 4 - 2
graphdb/src/main/java/org/diagbot/repository/DiseaseRepository.java

@@ -33,7 +33,7 @@ public interface DiseaseRepository extends Neo4jRepository<Disease, Long> {
     @Query("match(d:Disease)<-[r:排除]-(l) where d.disId={0} detach delete l")
     void deleteRelation4(Long disId);
     //删除排除关系5
-    @Query("match(d:Disease)-[r:表现]->(j)-[r1:属于]-(k) where d.disId={0} detach delete r")
+    @Query("match(d:Disease)-[r:表现]->(j)-[r1:属于]->(k) where d.disId={0} detach delete r")
     void deleteRelation5(Long disId);
     //删除排除关系6
     @Query("match(d:Disease)-[r:表现]->(j) where d.disId={0} detach delete r")
@@ -47,7 +47,9 @@ public interface DiseaseRepository extends Neo4jRepository<Disease, Long> {
     //删除排除关系9
     @Query("match(d:Disease)-[r:鉴别诊断]->(b) where d.disId={0} detach delete r")
     void deleteRelation9(Long disId);
-
+    //删除排除关系10
+    @Query("match(c:Condition) where c.name={0} detach delete c")
+    void deleteRelation10(String conditionName);
     //更新图谱
     //存储疾病
     @Query("merge(d:Disease{name:{0},disId:{1},emergency:{2}})")

+ 60 - 5
graphdb/src/main/java/org/diagbot/service/impl/KnowledgeServiceImpl.java

@@ -1423,6 +1423,8 @@ public class    KnowledgeServiceImpl implements KnowledgeService {
     public RespDTO updateNeoDisease(NeoParamVO singleDisease) {
         RespDTO respDTO = RespDTO.onSuc(true);;
         Long disId = singleDisease.getId();
+        //先删除
+        this.neo4jDelete(disId);
         String disName = this.getDisName(disId);
         if(StringUtils.isNotEmpty(disName)){
             diseaseRepository.mergeDis(disName,disId,0);
@@ -1687,6 +1689,12 @@ public class    KnowledgeServiceImpl implements KnowledgeService {
                 }else if(ni.contains("任五")){
                     path = 5;
                     rel = "任五";
+                }else if(ni.contains("任六")){
+                    path = 6;
+                    rel = "任六";
+                }else if(ni.contains("任七")){
+                    path = 7;
+                    rel = "任七";
                 }else {
                     path = 1;
                     rel = "任一";
@@ -2046,20 +2054,67 @@ public class    KnowledgeServiceImpl implements KnowledgeService {
         Long disId = singleDisease.getId();
         RespDTO respDTO = null;
         if(disId != null){
+            this.neo4jDelete(disId);
+            respDTO = RespDTO.onSuc(true);
+        }else {
+            respDTO = RespDTO.onError(disId +" 删除失败!!!");
+        }
+        return respDTO;
+    }
+    //删除
+    public void neo4jDelete(Long disId) {
+        if (disId != null) {
             diseaseRepository.deleteRelation1(disId);
             diseaseRepository.deleteRelation2(disId);
             diseaseRepository.deleteRelation3(disId);
             diseaseRepository.deleteRelation4(disId);
-            diseaseRepository.deleteRelation5(disId);
+//            diseaseRepository.deleteRelation5(disId);
             diseaseRepository.deleteRelation6(disId);
             diseaseRepository.deleteRelation7(disId);
             diseaseRepository.deleteRelation8(disId);
             diseaseRepository.deleteRelation9(disId);
-            respDTO = RespDTO.onSuc(true);
-        }else {
-            respDTO = RespDTO.onError(disId +" 删除失败!!!");
+            List<String> allCode = this.getAllCode(disId);
+            if(allCode.size()>0){
+                for (String conName:allCode) {
+                    diseaseRepository.deleteRelation10(conName);
+                }
+            }
+
         }
-        return respDTO;
+    }
+
+    /**
+     * 获取一个诊断依据的全部code
+     * @param disId
+     * @return
+     */
+    public List<String> getAllCode(Long disId){
+        List<String> codeList = new ArrayList<>();
+        conn = this.getConn();
+        Statement st = null;
+        ResultSet rs = null;
+        try {
+            String code ,name;
+            String sql = "SELECT dis_name,code FROM `kl_diagnose_detail` where diagnose_id="+disId+" and code != \"\"";
+            st = conn.createStatement();
+            rs = st.executeQuery(sql);
+            while (rs.next()){
+                name = rs.getString("dis_name");
+                code = rs.getString("code");
+                codeList.add(name+code);
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                rs.close();
+                st.close();
+            } catch (SQLException e) {
+                e.printStackTrace();
+            }
+        }
+        return codeList;
     }
 
     @Override