ソースを参照

诊断依据后台维护开发分支

kongwz 5 年 前
コミット
8cfea12538

+ 10 - 1
graphdb/pom.xml

@@ -83,7 +83,16 @@
             <version>1.2.47</version>
             <scope>compile</scope>
         </dependency>
-
+        <dependency>
+            <groupId>org.diagbot</groupId>
+            <artifactId>public</artifactId>
+            <version>1.0.0</version>
+        </dependency>
+        <!--<dependency>-->
+            <!--<groupId>org.diagbot</groupId>-->
+            <!--<artifactId>nlp</artifactId>-->
+            <!--<version>1.0.0</version>-->
+        <!--</dependency>-->
     </dependencies>
 
     <build>

+ 41 - 0
graphdb/src/main/java/org/diagbot/pub/Ciku.java

@@ -0,0 +1,41 @@
+package org.diagbot.pub;
+
+public enum Ciku {
+    SYMPTOM("1","1,70"),VITAL_RESULT("2","35,70"),BIGlIS("3","12"),SUBLIS("subLis","13")
+    ,RESULTLIS("resultLis","14,70"),PACS("4","16"),RESULTPACS("resultPacs","17,70"),DISEASE("5","18")
+    ,HISTORY("6","18,70"),CAUSE("7","5,70"),PROGNOSIS("8","70"),OTHER("9","70");
+    private String name;
+    private String label;
+
+    Ciku(String name, String label) {
+        this.name = name;
+        this.label = label;
+    }
+    public static Ciku getEnum(String name) {
+        for (Ciku item : Ciku.values()) {
+            if (item.name.equals(name) ) {
+                return item;
+            }
+        }
+        return null;
+    }
+    public static String getLabel(String name) {
+        Ciku item = getEnum(name);
+        return item != null ? item.label : null;
+    }
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getLabel() {
+        return label;
+    }
+
+    public void setLabel(String label) {
+        this.label = label;
+    }
+}

+ 44 - 0
graphdb/src/main/java/org/diagbot/pub/Label.java

@@ -0,0 +1,44 @@
+package org.diagbot.pub;
+
+public enum Label {
+    SYMPTOM("1","Symptom"),VITAL_RESULT("2","Vital"),LIS("3","LIS"),PACS("4","PACS"),
+    DISEASE("5","Disease"),HISTORY("6","History"),CAUSE("7","Cause"),PROGNOSIS("8","Other"),
+    OTHER("9","Other"),CONDITION("诊断依据","Condition"),NI("92","Condition"),QUE("91","Condition"),
+    HIGH("93","Condition"),DELETE("94","Condition"),
+    LISRESULT("化验结果","LISResult"),PACSRESULT("辅检结果","PACSResult");
+    private String name;
+    private String label;
+
+    Label(String name, String label) {
+        this.name = name;
+        this.label = label;
+    }
+    public static Label getEnum(String name) {
+        for (Label item : Label.values()) {
+            if (item.name.equals(name) ) {
+                return item;
+            }
+        }
+        return null;
+    }
+    public static String getLabel(String name) {
+        Label item = getEnum(name);
+        return item != null ? item.label : null;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getLabel() {
+        return label;
+    }
+
+    public void setLabel(String label) {
+        this.label = label;
+    }
+}

+ 46 - 0
graphdb/src/main/java/org/diagbot/pub/Type.java

@@ -0,0 +1,46 @@
+package org.diagbot.pub;
+
+/**
+ * excel
+ * 类型(1:症状,2:体征,3:化验,4:辅检,5:鉴别诊断,6:病史,7:诱因,8:病程,9:其他,91:确诊,92:拟诊,93:警惕)
+ */
+public enum Type {
+    SYMPTOM(1,"症状"),VITAL_RESULT(2,"体征结果"),LIS(3,"化验"),PACS(4,"辅检"),
+    DISEASE(5,"鉴别诊断"),HISTORY(6,"病史"),CAUSE(7,"诱因"),PROGNOSIS(8,"病程"),
+    OTHER(9,"其他"),QUE(91,"确诊"),NI(92,"拟诊"),HIGH(93,"警惕"),DELETE(94,"删除条件");
+    private Integer key;
+    private String name;
+
+    Type(Integer key, String name) {
+        this.key = key;
+        this.name = name;
+    }
+    public static Type getEnum(Integer key) {
+        for (Type item : Type.values()) {
+            if (item.key == key) {
+                return item;
+            }
+        }
+        return null;
+    }
+    public static String getName(Integer key) {
+        Type item = getEnum(key);
+        return item != null ? item.name : null;
+    }
+
+    public Integer getKey() {
+        return key;
+    }
+
+    public void setKey(Integer key) {
+        this.key = key;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

+ 61 - 0
graphdb/src/main/java/org/diagbot/repository/DiseaseRepository.java

@@ -18,4 +18,65 @@ public interface DiseaseRepository extends Neo4jRepository<Disease, Long> {
     @Query("match(d:Disease) where d.name in {0} return d.name as name, d.high_risk as risk")
     List<Map<String, Object>> getHighRisk(List diagList);
 
+
+    //删除诊断依据
+    //删除关系1
+    @Query("match(d:Disease)<-[r:拟诊|:确诊|:警惕]-(c:Condition)<-[r1]-(k:Condition)<-[r2]-(h:Condition) where d.disId={0} detach delete c,k,h")
+    void deleteRelation1(Integer disId);
+    //删除关系2
+    @Query("match(d:Disease)<-[r:拟诊|:确诊|:警惕]-(c:Condition)<-[r1]-(k:Condition) where d.disId={0} detach delete c,k")
+    void deleteRelation2(Integer disId);
+    //删除关系3
+    @Query("match(d:Disease)<-[r:拟诊|:确诊|:警惕]-(c:Condition) where d.disId={0} detach delete r")
+    void deleteRelation3(Integer disId);
+    //删除排除关系4
+    @Query("match(d:Disease)<-[r:排除]-(l) where d.disId={0} detach delete l")
+    void deleteRelation4(Integer disId);
+    //删除排除关系5
+    @Query("match(d:Disease)-[r:表现]->(j)-[r1:属于]-(k) where d.disId={0} detach delete r")
+    void deleteRelation5(Integer disId);
+    //删除排除关系6
+    @Query("match(d:Disease)-[r:表现]->(j) where d.disId={0} detach delete r")
+    void deleteRelation6(Integer disId);
+    //删除排除关系7
+    @Query("match(d:Disease)-[r:推荐]->(j:LIS) where d.disId={0} detach delete r")
+    void deleteRelation7(Integer disId);
+    //删除排除关系8
+    @Query("match(d:Disease)-[r:推荐]->(j:PACS) where d.disId={0} detach delete r")
+    void deleteRelation8(Integer disId);
+    //删除排除关系9
+    @Query("match(d:Disease)-[r:鉴别诊断]->(b) where d.disId={0} detach delete r")
+    void deleteRelation9(Integer disId);
+
+    //更新图谱
+    //存储疾病
+    @Query("merge(d:Disease{name:{0},disId:{1},emergency:{2}})")
+    void mergeDis(String name,Integer disId,Integer emergency);
+    //存储确诊,拟诊,警惕
+    @Query( "merge(c:Condition{name:{0},path:{1}})")
+    void mergeCondition(String disName,Integer path);
+    @Query("match(c:Condition{name:{0}}),(d:Disease{disId:{1}})" +
+            " merge(c)-[:确诊]->(d)")
+    void mergeQueNiHigh(String conditionName,Integer disId);
+    @Query("match(c:Condition{name:{0}}),(d:Disease{disId:{1}})" +
+            " merge(c)-[:拟诊]->(d)")
+    void mergeNiHigh(String conditionName,Integer disId);
+    @Query("match(c:Condition{name:{0}}),(d:Disease{disId:{1}})" +
+            " merge(c)-[:警惕]->(d)")
+    void mergeHigh(String conditionName,Integer disId);
+    //任几的condition
+    @Query("merge(c:Condition{name:{0},path:{1},relation:{2}})")
+    void mergeRenCondition(String conditionName,Integer path,String relation);
+    @Query("match(c:Condition{name:{0}}),(s:Condition{name:{1}}) merge(c)-[r:诊断依据]->(s)")
+    void mergeRenCondition(String c1,String c2);
+    //具体code Condition
+    @Query("merge(c:Condition{name:{0},path:1,relation:'任一'})")
+    void mergeNUMCondition(String disName);
+    @Query("match(c:Condition{name:{0}}),(s:Condition{name:{1}}) merge(c)-[r:诊断依据]->(s)")
+    void mergeNUMCondition(String c1,String c2);
+    //开始添加所有的词语
+    //添加标准词
+    @Query("merge(d:Symptom{name:?2})")
+    void mergeStandard(String name);
+
 }

+ 6 - 3
graphdb/src/main/java/org/diagbot/service/KnowledgeService.java

@@ -5,9 +5,7 @@ import org.diagbot.entity.node.Symptom;
 import org.diagbot.vo.*;
 import org.diagbot.entity.node.Disease;
 import org.diagbot.entity.node.base.BaseNode;
-import org.diagbot.vo.domain.FeatureRate;
-import org.diagbot.vo.domain.ResponseData;
-import org.diagbot.vo.domain.SearchData;
+import org.diagbot.vo.domain.*;
 
 import java.util.List;
 import java.util.Map;
@@ -54,4 +52,9 @@ public interface KnowledgeService {
     List<Symptom> selectAllSymptom(PageVo pageVo);
     List<LIS> selectAllLIS(PageVo pageVo);
 
+    //更新图谱
+    RespDTO updateNeoDisease(NeoParamVO singleDisease);
+    //删除图谱
+    Integer deleteNeoDisease(NeoParamVO singleDisease);
+
 }

+ 372 - 3
graphdb/src/main/java/org/diagbot/service/impl/KnowledgeServiceImpl.java

@@ -6,6 +6,9 @@ import org.apache.commons.lang3.StringUtils;
 import org.diagbot.entity.node.LIS;
 import org.diagbot.entity.node.Symptom;
 import org.diagbot.mapper.KnowledgeMapper;
+import org.diagbot.pub.Label;
+import org.diagbot.pub.Type;
+import org.diagbot.pub.jdbc.MysqlJdbc;
 import org.diagbot.service.KnowledgeService;
 import org.diagbot.vo.*;
 import org.diagbot.entity.node.Disease;
@@ -24,12 +27,16 @@ import org.springframework.data.domain.Sort;
 import org.springframework.stereotype.Service;
 
 import java.math.RoundingMode;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
 import java.text.NumberFormat;
 import java.util.*;
 
 
 @Service
-public class KnowledgeServiceImpl implements KnowledgeService {
+public class    KnowledgeServiceImpl implements KnowledgeService {
     Logger logger = LoggerFactory.getLogger(KnowledgeServiceImpl.class);
     @Autowired
     private SymptomRepository symptomRepository;
@@ -49,7 +56,14 @@ public class KnowledgeServiceImpl implements KnowledgeService {
     private List<BaseNode> baseNodes;
 
     private Pageable pageable;
-
+    private Connection conn = null;
+    private MysqlJdbc nlpJdbc = new MysqlJdbc("root", "lantone", "jdbc:mysql://192.168.2.236:3306/med?useSSL=false&useUnicode=true&characterEncoding=UTF-8");
+    public Connection getConn(){
+        if(conn == null){
+            conn = nlpJdbc.connect();
+        }
+        return conn;
+    }
     /**
      * 处理症状节点相关的申请
      */
@@ -378,7 +392,7 @@ public class KnowledgeServiceImpl implements KnowledgeService {
     @Override
     public Map<String, List<FeatureRate>> getLisPacs(SearchData searchData) {
         String[] featureArray = StringUtils.split(searchData.getFeatureType(), ",");
-        List<String> featureList = Arrays.asList(featureArray);
+        List<String> featureList = Arrays.asList(searchData.getFeatureTypes());
         Map<String, List<FeatureRate>> lisPacsFeature = new HashMap<>();
         String webDiag = searchData.getDiag();
         List<String> webDiagList = null;
@@ -1398,6 +1412,361 @@ public class KnowledgeServiceImpl implements KnowledgeService {
         return indicators1;
     }
 
+    /**
+     * 更新图谱
+     * @param singleDisease
+     * @return
+     * 类型(1:症状,2:体征,3:化验,4:辅检,5:鉴别诊断,6:病史,7:诱因,8:病程,9:其他,91:确诊,92:拟诊,93:警惕)
+     */
+    @Override
+    public RespDTO updateNeoDisease(NeoParamVO singleDisease) {
+        RespDTO respDTO = new RespDTO();
+        respDTO.data=true;
+        respDTO.code="1";
+        Integer disId = singleDisease.getDisId();
+        String disName = this.getDisName(disId);
+        if(StringUtils.isNotEmpty(disName)){
+            diseaseRepository.mergeDis(disName,disId,0);
+        }else {
+            respDTO.code="0";
+            respDTO.msg="在数据库中没有找个这个疾病!!!";
+        }
+        //获取每个诊断依据的全部数据
+        List<Map<String, String>> allData = this.getAllData(disId);
+        //获取拟诊,确诊,警惕组合
+        Map<String, List<String>> allNiQueZhenCollection = this.getAllNiQueZhenCollection(disId);
+        this.saveNiQue2Neo(allData,allNiQueZhenCollection,disName,disId);
+        this.saveData2Neo4j(allData,disId,disName);
+
+        System.out.println();
+
+
+
+        return respDTO;
+    }
+
+    /**
+     * 把一个完整的诊断依据封装到list中,list中存的是map,一行一个map
+     * @param disId
+     * @return
+     */
+    public List<Map<String,String>> getAllData(Integer disId){
+        List<Map<String,String>> contentList = new ArrayList<>();
+        conn = this.getConn();
+        Statement st = null;
+        ResultSet rs = null;
+        try {
+            String type, code ,standard,relation,result,formula,name;
+            String sql = "SELECT diagnose_id,dis_name,`type`,`code`,standard,relation,result,formula FROM `kl_diagnose_detail` where diagnose_id = "+disId+"";
+            st = conn.createStatement();
+            rs = st.executeQuery(sql);
+            while (rs.next()){
+                Map<String,String> content = new HashMap<>();
+                type = rs.getString(3);
+                code = rs.getString("code");
+                standard = rs.getString("standard");
+                relation = rs.getString("relation");
+                result = rs.getString("result");
+                formula = rs.getString("formula");
+                name = Type.getName(Integer.parseInt(type));
+                content.put("type",type);
+                content.put("typeName",name);
+                content.put("code",code);
+                content.put("standard",standard);
+                content.put("relation",relation);
+                content.put("result",result);
+                content.put("formula",formula);
+                contentList.add(content);
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                rs.close();
+                st.close();
+            } catch (SQLException e) {
+                e.printStackTrace();
+            }
+        }
+        return contentList;
+    }
+
+    /**
+     * 获取一个诊断依据的确诊,拟诊,警惕集合
+     * @param disId
+     * @return
+     */
+    public Map<String,List<String>> getAllNiQueZhenCollection(Integer disId)  {
+        Map<String,List<String>> queNiMap = new HashMap<>();
+        conn = this.getConn();
+        Statement st = null;
+        ResultSet rs = null;
+        List<String> queList = new ArrayList<>();
+        List<String> niList = new ArrayList<>();
+        List<String> highList = new ArrayList<>();
+        try {
+            String type, formula,  label,name;
+            String sql = "SELECT type,formula FROM `kl_diagnose_detail` where diagnose_id = "+disId+" and type in (91,92,93)";
+            st = conn.createStatement();
+            rs = st.executeQuery(sql);
+            while (rs.next()) {
+                type = rs.getString(1);
+                formula = rs.getString(2);
+                name = Type.getName(Integer.parseInt(type));
+                if("拟诊".equals(name)){
+                    niList.add(formula);
+                }else if("确诊".equals(name)){
+                    queList.add(formula);
+                }else if("警惕".equals(name)){
+                    highList.add(formula);
+                }
+                if(queList != null){
+                    for (String que:queList) {
+                        if(que.contains("拟诊")){
+                            for (String ni:niList
+                                    ) {
+                                String newNi = que.replaceAll("拟诊", ni);
+                                queList.add(newNi);
+                            }
+                            queList.remove(que);
+                        }
+                    }
+                }
+                queNiMap.put("拟诊",niList);
+                queNiMap.put("确诊",queList);
+                queNiMap.put("警惕",highList);
+
+            }
+        }catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                rs.close();
+                st.close();
+            } catch (SQLException e) {
+                e.printStackTrace();
+            }
+        }
+        return queNiMap;
+    }
+
+    /**
+     * 获取疾病名
+     * @param disId
+     * @return
+     */
+    public String getDisName(Integer disId){
+        Statement st = null;
+        ResultSet rs = null;
+        conn = this.getConn();
+        String name="";
+        try {
+            String sql = "SELECT dis_name FROM `kl_diagnose_detail` where diagnose_id = "+disId+"";
+            st = conn.createStatement();
+            rs = st.executeQuery(sql);
+            while (rs.next()) {
+                name = rs.getString(1);
+            }
+        }catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                rs.close();
+                st.close();
+            } catch (SQLException e) {
+                e.printStackTrace();
+            }
+            return name;
+        }
+    }
+    /**
+     * 把确诊,拟诊,警惕存入图谱
+     */
+    public void saveNiQue2Neo(List<Map<String, String>> allData,Map<String, List<String>> allNiQueZhenCollection,String disName,Integer disId){
+        List<String> stringList =null;
+        String[] types = {"确诊","拟诊","警惕"};
+        Integer path = 1;
+        String[] nisplits;
+        for (String type:types) {
+            if("确诊".equals(type)){
+                stringList = allNiQueZhenCollection.get(type);
+                if(stringList != null){
+                    for(int i =0;i<stringList.size();i++){
+                        nisplits = stringList.get(i).split("\\+");
+                        path = nisplits.length;
+                        diseaseRepository.mergeCondition(disName+"-"+type+"组块"+(i+1),path);
+                        diseaseRepository.mergeQueNiHigh(disName+"-"+type+"组块"+(i+1),disId);
+                    }
+                }
+            }else if("拟诊".equals(type)){
+                stringList = allNiQueZhenCollection.get(type);
+                if(stringList != null){
+                    for(int i =0;i<stringList.size();i++){
+                        nisplits = stringList.get(i).split("\\+");
+                        path = nisplits.length;
+                        diseaseRepository.mergeCondition(disName+"-"+type+"组块"+(i+1),path);
+                        diseaseRepository.mergeNiHigh(disName+"-"+type+"组块"+(i+1),disId);
+                        this.splitConditionContent(nisplits,disName,disName+"-"+type+"组块"+(i+1),allData);
+                    }
+                }
+            }else if("警惕".equals(type)){
+                stringList = allNiQueZhenCollection.get(type);
+                if(stringList != null){
+                    for(int i =0;i<stringList.size();i++){
+                        nisplits = stringList.get(i).split("\\+");
+                        path = nisplits.length;
+                        diseaseRepository.mergeCondition(disName+"-"+type+"组块"+(i+1),path);
+                        diseaseRepository.mergeHigh(disName+"-"+type+"组块"+(i+1),disId);
+                        this.splitConditionContent(nisplits,disName,disName+"-"+type+"组块"+(i+1),allData);
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * 处理任几
+     * @param nisplits
+     * @param disName
+     * @param startNode
+     * @param allData
+     */
+    public void splitConditionContent(String[] nisplits,String disName,String startNode,List<Map<String, String>> allData){
+        Integer path = 1;
+        String rel = "";
+        for (String ni:nisplits) {
+            if(ni.contains("/")){
+                if(ni.contains("任一")){
+                    path = 1;
+                    rel = "任一";
+                }else if(ni.contains("任二")){
+                    path = 2;
+                    rel = "任二";
+                }else if(ni.contains("任三")){
+                    path = 3;
+                    rel = "任三";
+                }else if(ni.contains("任四")){
+                    path = 4;
+                    rel = "任四";
+                }else if(ni.contains("任五")){
+                    path = 5;
+                    rel = "任五";
+                }else {
+                    path = 1;
+                    rel = "任一";
+                }
+                diseaseRepository.mergeRenCondition(disName+ni,path,rel);
+                diseaseRepository.mergeRenCondition(disName+ni,startNode);
+                //获取这个任几集合的数字集合
+                List<String> numList = this.getNumList(ni);
+                if(numList != null && numList.size()>0){
+                    for (String num:numList
+                            ) {
+                        this.processDetailNum(disName,num,disName+ni,allData);
+                    }
+                }
+            }else {
+                this.processDetailNum(disName,ni,disName+ni,allData);
+            }
+        }
+    }
+
+    /**
+     * 获取任几集合的code列表
+     * @return
+     */
+    public List<String> getNumList(String renCondition){
+        List<String> numList = new ArrayList<>();
+        String[] numSplits = renCondition.split("/");
+        if(numSplits.length>0){
+            for (int i=0;i<numSplits.length;i++){
+                if(i == 0){
+                    numList.add(numSplits[i].replaceAll("\\(",""));
+                }else if(i == numSplits.length-1){
+                    String numSplit = numSplits[i];
+                    int i1 = numSplit.indexOf(")");
+                    System.out.println(numSplit+"\t"+i1);
+                    numList.add(numSplits[i].substring(0,numSplits[i].indexOf(")")));
+                }else {
+                    numList.add(numSplits[i]);
+                }
+            }
+        }
+        return numList;
+    }
+    public void processDetailNum(String disName,String num,String renCondition,List<Map<String, String>> allData){
+        String[] types = {"化验","辅检","排除条件"};
+        for (Map<String, String> row:allData) {
+            String code = row.get("code");//编码
+            String type = row.get("type");//类型
+            String typeName = row.get("typeName");//类型对应的中文名
+            String relation = row.get("relation");//关联词
+            String result = row.get("result");//结果
+            if(num.equals(code)){
+                if(Arrays.asList(types).indexOf(typeName) <0){
+                    diseaseRepository.mergeNUMCondition(disName+code);
+                    diseaseRepository.mergeNUMCondition(disName+code,renCondition);
+                }else if("化验".equals(typeName) && !"".equals(result)){
+                    diseaseRepository.mergeNUMCondition(disName+code);
+                    diseaseRepository.mergeNUMCondition(disName+code,renCondition);
+                }else if("辅检".equals(typeName) && !"".equals(relation)){
+                    diseaseRepository.mergeNUMCondition(disName+code);
+                    diseaseRepository.mergeNUMCondition(disName+code,renCondition);
+                }
+            }
+        }
+    }
+
+    /**
+     * 保存完整的诊断依据入知识图谱
+     * @param allData
+     * @param disId
+     * @param disName
+     */
+    public void saveData2Neo4j(List<Map<String, String>> allData,Integer disId,String disName){
+//        Map<String, Map<String, String>> standard_info_synonym_map = NlpCache.standard_info_synonym_map;
+        for (Map<String,String> row:allData) {
+            String code = row.get("code");//编码
+            String type = row.get("type");//类型
+            String typeName = row.get("typeName");//类型对应的中文名
+            String standard = row.get("standard");//标准词
+            String relation = row.get("relation");//关联词
+            String result = row.get("result");//结果
+            if(StringUtils.isNotEmpty(type)){
+                if(!"3".equals(type) && !"4".equals(type) && !"5".equals(type)){
+                    //添加词语之前,要找标准词
+                    //添加standard
+                    diseaseRepository.mergeStandard(Label.getLabel(type),standard);
+
+                }
+
+            }
+        }
+
+    }
+    /**
+     * 在图谱中删除诊断依据
+     * @param singleDisease
+     * @return
+     */
+    @Override
+    public Integer deleteNeoDisease(NeoParamVO singleDisease) {
+        Integer disId = singleDisease.getDisId();
+        if(disId != null){
+            diseaseRepository.deleteRelation1(disId);
+            diseaseRepository.deleteRelation2(disId);
+            diseaseRepository.deleteRelation3(disId);
+            diseaseRepository.deleteRelation4(disId);
+            diseaseRepository.deleteRelation5(disId);
+            diseaseRepository.deleteRelation6(disId);
+            diseaseRepository.deleteRelation7(disId);
+            diseaseRepository.deleteRelation8(disId);
+            diseaseRepository.deleteRelation9(disId);
+        }
+        return 1;
+    }
+
     @Override
     public List<Map<String, Object>> getRecommendItem(QueryVo queryVo) {
         List<Map<String, Object>> list = relationRepository.getRecommendItem(queryVo.getDiseaselist());

+ 27 - 0
graphdb/src/main/java/org/diagbot/vo/domain/NeoParamVO.java

@@ -0,0 +1,27 @@
+package org.diagbot.vo.domain;
+
+public class NeoParamVO {
+    private  Integer disId; //诊断依据id,是唯一的
+
+    public Integer getDisId() {
+        return disId;
+    }
+
+    public void setDisId(Integer disId) {
+        this.disId = disId;
+    }
+
+    public NeoParamVO() {
+    }
+
+    public NeoParamVO(Integer disId) {
+        this.disId = disId;
+    }
+
+    @Override
+    public String toString() {
+        return "NeoParamVO{" +
+                "disId=" + disId +
+                '}';
+    }
+}

+ 38 - 0
graphdb/src/main/java/org/diagbot/vo/domain/RespDTO.java

@@ -0,0 +1,38 @@
+package org.diagbot.vo.domain;
+
+import java.io.Serializable;
+
+/**
+ * @Description: 通用返回格式
+ * @author: gaodm
+ * @time: 2018/8/1 14:55
+ */
+public class RespDTO<T> implements Serializable {
+
+
+    public String code = "0";
+    public String msg = "";
+    public T data;
+
+    public static RespDTO onSuc(Object data) {
+        RespDTO resp = new RespDTO();
+        resp.data = data;
+        return resp;
+    }
+
+    public static RespDTO onError(String errMsg) {
+        RespDTO resp = new RespDTO();
+        resp.code = "-1";
+        resp.msg = errMsg;
+        return resp;
+    }
+
+    @Override
+    public String toString() {
+        return "RespDTO{" +
+                "code=" + code +
+                ", error='" + msg + '\'' +
+                ", data=" + data +
+                '}';
+    }
+}

+ 36 - 12
graphdb/src/main/java/org/diagbot/web/KnowledgeController.java

@@ -185,17 +185,41 @@ public class KnowledgeController {
         return knowledgeService.getScale(queryVo);
     }
 
-    /*
-    @RequestMapping("/actedIn/{personId}/{movieId}")
-    public TJ actedIn(@PathVariable("personId")String personId, @PathVariable("movieId")String movieId){
-        Person person=diseaseServer.findOnePerson(Long.parseLong(personId));
-        Disease disease =diseaseServer.findOneMovie(Long.parseLong(movieId));
-        TJ TJ =new TJ();
-        TJ.setRoles("龙套");
-        TJ.setStartNode(person);
-        TJ.setEndNode(disease);
-        return diseaseServer.actedIn(TJ);
-    }
-    */
+    /**
+     * 给定诊断依据的id,删除图谱中对应的诊断依据
+     * @param disease
+     * @return
+     */
+    @RequestMapping("/deleteDisease")
+    public RespDTO deleteDiseaseData(@Valid @RequestBody NeoParamVO disease){
+        String code = "1";
+        String mess = "";
+        RespDTO respDTO = new RespDTO();
+        Integer integer = knowledgeService.deleteNeoDisease(disease);
+        if(integer == 1){
+            code = "1";
+            mess = disease.getDisId()+"删除成功!!!!!!!!";
+        }else {
+            code = "0";
+            mess = disease.getDisId()+"删除失败!!!!!!!";
+        }
+        respDTO.code = code;
+        respDTO.msg = mess;
+        respDTO.data = true;
+        return respDTO;
+    }
 
+    /**
+     * 给定诊断依据的id,更新图谱中对应的诊断依据
+     * @param disease
+     * @return
+     */
+    @RequestMapping("/updateDisease")
+    public RespDTO updateDiseaseData(@Valid @RequestBody NeoParamVO disease){
+        String code = "1";
+        String mess = "";
+        RespDTO respDTO = knowledgeService.updateNeoDisease(disease);
+
+        return respDTO;
+    }
 }

+ 4 - 4
graphdb/src/main/resources/application.yml

@@ -6,16 +6,16 @@ spring:
     active: local
   data:
     neo4j:
-      uri: bolt://192.168.2.233:7687
+      uri: bolt://192.168.3.180:7687
       username: neo4j
-      password: root
+      password: 123456
 
 # 驱动配置信息
   datasource:
     driver-class-name: org.neo4j.jdbc.Driver
-    url: jdbc:neo4j:http://192.168.2.233:7474
+    url: jdbc:neo4j:http://192.168.3.180:7474
     username: neo4j
-    password: root
+    password: 123456
     #定义初始连接数
     initialSize: 0
     #定义最大连接数