浏览代码

修改改代码

yangdr 1 周之前
父节点
当前提交
265a488197

二进制
knowledgeMap.zip


+ 1 - 0
package.json

@@ -9,6 +9,7 @@
     "dayjs": "^1.11.13",
     "es3ify-loader": "^0.2.0",
     "jquery": "^1.12.4",
+    "jquery-ui-dist": "^1.13.3",
     "poplar-annotation": "^2.0.3",
     "umy-ui": "1.0",
     "vue": "^2.6.11",

+ 17 - 2
src/css/home.less

@@ -11,7 +11,7 @@
 
     .el-header {
       height: 60px !important;
-background-image: linear-gradient(2deg, #dbe9fd, #e5f0fb, #eef7f8, #f7fef6);
+      background-image: linear-gradient(2deg, #dbe9fd, #e5f0fb, #eef7f8, #f7fef6);
 
       // background-color: #3871B8;
       // background-color: linear-gradient(#f2fcfe 10%, #1c92d2 100%);
@@ -119,7 +119,7 @@ background-image: linear-gradient(2deg, #dbe9fd, #e5f0fb, #eef7f8, #f7fef6);
 
             &:is(.is-active) {
               // background-color: #0793FF !important;
-                background-color: #cae3fc !important;
+              background-color: #cae3fc !important;
             }
 
             .submenu-text {
@@ -824,4 +824,19 @@ background-image: linear-gradient(2deg, #dbe9fd, #e5f0fb, #eef7f8, #f7fef6);
 .icon-add {
   .icon();
   background-image: url("./img/add.png");
+}
+
+.ui-widget-overlay {
+  opacity: 0.5 !important;
+  /* 确保遮罩层的 z-index 比其他元素高 */
+  z-index: 1000;
+
+}
+
+.ui-dialog {
+  /* 使用 CSS 居中 */
+  top: 40% !important;
+  left: 50% !important;
+  transform: translate(-50%, -50%) !important;
+
 }

+ 43 - 13
src/css/selfKnowledgeGraph.less

@@ -19,36 +19,46 @@
       }
     }
   }
-  .main-box {
+
+  .top-op {
+    padding: 10px 20px 0px;
+  }
+
+  .graph-card {
     display: flex;
     flex-wrap: wrap;
     gap: 10px;
+
     .knowledgeCard {
       margin: 20px;
-    width: 300px;
-    height: 200px;
-    text-align: center;
-    line-height: 200px;
-    background-color: #f9f9f9;
-    border: 1px solid #ccc;
-    border-radius: 5px;
-    padding: 10px;
-    &:hover {
-      box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
+      width: 300px;
+      height: 200px;
+      text-align: center;
+      line-height: 200px;
+      background-color: #f9f9f9;
+      border: 1px solid #ccc;
+      border-radius: 5px;
+      padding: 10px;
+      position: relative;
+
+      &:hover {
+        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
+      }
     }
   }
-  }
+
   .back {
     position: absolute;
     top: 10px;
     left: 130px;
     z-index: 1000;
-    color:#40a1ff;
+    color: #40a1ff;
     background-color: #eef6ff;
     border: 1px solid #ccc;
     border-radius: 5px;
     padding: 5px 10px;
     cursor: pointer;
+
     &:hover {
       background-color: #40a1ff;
       color: #fff;
@@ -56,5 +66,25 @@
 
   }
 
+  .selection {
+    width: 1em;
+    height: 1em;
+    // padding: ;
+    border: 1px solid #DCDFE6;
+    border-radius: 50%;
+    display: inline-block;
+    vertical-align: middle;
+    color: #fff;
+    line-height: 1em;
+
 
+    &:is(.selected) {
+      background-color: #409EFF;
+      border-color: #409EFF;
+    }
+
+    position: absolute;
+    top: 5px;
+    right: 5px;
+  }
 }

+ 10 - 8
src/css/selfKnowledgeUpdate.less

@@ -1,11 +1,12 @@
 // #app {
-  // width: 100%;
-  // height: 100%;
-  .main-box {
-    display: flex;
-    flex-wrap: wrap;
-    gap: 10px;
-    .knowledgeCard {
+// width: 100%;
+// height: 100%;
+.main-box {
+  display: flex;
+  flex-wrap: wrap;
+  gap: 10px;
+
+  .knowledgeCard {
     margin: 20px;
     width: 300px;
     height: 200px;
@@ -15,11 +16,12 @@
     border: 1px solid #ccc;
     border-radius: 5px;
     padding: 10px;
+
     &:hover {
       box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
     }
   }
-  }
+}
 
 
 // }

+ 3 - 0
src/html/home.html

@@ -477,6 +477,9 @@
       </span>
     </el-dialog>
   </div>
+  <div id="dialog-confirm" title="图谱融合" style="display: none;">
+    <p>你确定要继续吗?</p>
+  </div>
 </body>
 <script>
 

+ 13 - 18
src/html/selfKnowledgeGraph.html

@@ -9,6 +9,7 @@
 		<%= htmlWebpackPlugin.options.title %>
 	</title>
 	<link href="../resources/favicon.ico" rel="shortcut icon">
+	<link rel="stylesheet" href="/elementUI/2.7.2/theme-chalk/index.css">
 	<style>
 		.node_name {
 			color: #333333;
@@ -21,9 +22,18 @@
 <body>
 	<div id="app" v-cloak>
 		<div class="main-box" v-if="!isShowKG">
-			<div class="knowledgeCard" id="knowledgeCard" v-for="item in listData" :key="item.graph_id"
-				@click="showKnowledgeGraph(item.graph_id)">
-				{{ item.graph_name }}
+			<div class="top-op">
+				<el-button type="primary" @click="handleMergeBtnClick" size="mini">融合</el-button>
+				<el-button type="primary" @click="handleRefresh" size="mini">刷新</el-button>
+			</div>
+			<div class="graph-card">
+				<div class="knowledgeCard" id="knowledgeCard" v-for="(item,index) in listData" :key="index"
+					@click="isMerge?null: showKnowledgeGraph(item.graph_id)">
+					{{ item.graph_name }}
+					<span :class="item.selected?'selection selected':'selection'" @click.stop="handleMergeSelect(index)">
+						<i v-show="item.selected">√</i>
+					</span>
+				</div>
 			</div>
 		</div>
 		<div v-else class="knowledgeMapWrapper wrappper">
@@ -110,23 +120,8 @@
 				</div>
 
 			</div>
-
 		</div>
 	</div>
-
-	<!-- <div class="footer ltLogo" style="display: none;">
-		杭州朗通信息技术有限公司 & 浙江省卫生健康委&nbsp;&nbsp;&nbsp;联合开发
-	</div> -->
-
 </body>
-<!-- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
-<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
-<script>
-	$(document).ready(function () {
-		$("#dragMe").draggable({
-			containment: "#main"  // 限制拖拽范围在 #container 元素内
-		});
-	});
-</script> -->
 
 </html>

+ 26 - 24
src/js/api.js

@@ -1,33 +1,34 @@
 
 const api = {
-  getGraph: '/api/kg/getGraph',
+  getGraph: '/healsphere/kg/getGraph',
+  getNewGraph: "/knowledge/getGraph",
   getSelfGraph: '/open-platform/kb/graph_data',
-  getNode: '/api/kg/getNode',
-  getSchema: '/api/ltkg/kg/getSchema',
-  getTree: '/api/kg/getTree',
-  entity_predict: '/api/ltkg/nlp/getNlp',
-  getMrInfo: '/api/ltkg/presetInfo/getMrInfo',
-  getAnswer: '/api/ltkg/qa/charBot',
-  getTerm: '/api/ltkg/term/getTerm',
+  getNode: '/healsphere/kg/getNode',
+  getSchema: '/healsphere/ltkg/kg/getSchema',
+  getTree: '/healsphere/kg/getTree',
+  entity_predict: '/healsphere/ltkg/nlp/getNlp',
+  getMrInfo: '/healsphere/ltkg/presetInfo/getMrInfo',
+  getAnswer: '/healsphere/ltkg/qa/charBot',
+  getTerm: '/healsphere/ltkg/term/getTerm',
   check: 'http://192.168.2.121:7010/test/testStandConvert',
-  findEntity: "/api/entity/findEntity", //实体详情查询(根据id查询实体)
-  deleteEntity: "/api/entity/deleteEntity", //批量删除实体
-  mergeEntity: "/api/entity/mergeEntity",//实体合并
-  createEntity: "/api/entity/createEntity",//批量新增实体
+  findEntity: "/healsphere/entity/findEntity", //实体详情查询(根据id查询实体)
+  deleteEntity: "/healsphere/entity/deleteEntity", //批量删除实体
+  mergeEntity: "/healsphere/entity/mergeEntity",//实体合并
+  createEntity: "/healsphere/entity/createEntity",//批量新增实体
 
-  updateEntityName: "/api/entity/updateEntityName",
+  updateEntityName: "/healsphere/entity/updateEntityName",
 
-  createRelationship: "/api/relationship/createRelationship",
-  findRelationshipType: "/api/relationship/findRelationshipType", //根据名称模糊查询关系
-  updateRelationshipType: "/api/relationship/updateRelationshipType",
-  createEntityProperty: "/api/property/createEntityProperty", //批量新增实体属性
-  deleteRelationship: "/api/relationship/deleteRelationship",//批量删除关系
-  findEntityListByName: "/api/entity/findEntityListByName", //实体列表查询(根据标签和名字模糊查询实体)
-  updateEntityProperty: "/api/property/updateEntityProperty", //更新实体属性
-  deleteEntityProperty: "/api/property/deleteEntityProperty", //删除实体属性
+  createRelationship: "/healsphere/relationship/createRelationship",
+  findRelationshipType: "/healsphere/relationship/findRelationshipType", //根据名称模糊查询关系
+  updateRelationshipType: "/healsphere/relationship/updateRelationshipType",
+  createEntityProperty: "/healsphere/property/createEntityProperty", //批量新增实体属性
+  deleteRelationship: "/healsphere/relationship/deleteRelationship",//批量删除关系
+  findEntityListByName: "/healsphere/entity/findEntityListByName", //实体列表查询(根据标签和名字模糊查询实体)
+  updateEntityProperty: "/healsphere/property/updateEntityProperty", //更新实体属性
+  deleteEntityProperty: "/healsphere/property/deleteEntityProperty", //删除实体属性
 
-  getCountList: "/api/kg/count/getCountList",
-  getCountInfo: "/api/kg/count/getCountInfo",
+  getCountList: "/healsphere/kg/count/getCountList",
+  getCountInfo: "/healsphere/kg/count/getCountInfo",
   userGraphs: "/open-platform/kb/user_sub_graphs",
   getSelfTreeByUser: "/open-platform/kb/tree_structure",
   getSelfNode: '/open-platform/graph_mg/entity/search',
@@ -45,7 +46,8 @@ const api = {
   createCustomProperty: '/open-platform/graph_mg/property/create', //新建实体属性
   deleteCustomProperty: '/open-platform/graph_mg/property/delete', //删除实体属性
   updateCustomProperty: '/open-platform/graph_mg/property/update', //更新实体属性
-  graphCategories: "/open-platform/kb/graph_categories"//查询类型列表
+  graphCategories: "/open-platform/kb/graph_categories",//查询类型列表
+  graphMerge: "/open-platform/agent/job"//知识图谱融合
 
 };
 $(".goto-homeStatic").on("click", function () {

+ 7 - 26
src/js/graphMap.js

@@ -6,7 +6,6 @@ const iconDown = require('./../resources/images/iconDown.png');
 const clientHei = $(window).height()
 const contentHei = clientHei - 80
 let disease = getUrlArgObject("disease")
-// console.log("disease", disease);
 
 //关系图
 function getGraph(val, type) {
@@ -24,12 +23,6 @@ function getGraph(val, type) {
 
             if (res.data.code === 200) {
                 let records = res.data.records[0].records || []
-                // for (let i = 0; i < records.node.length; i++) {
-                //     records.node[i].label = records.node[i].name
-                //     records.node[i].name = (i + 1).toString()
-                // }
-                // console.log("getSelfGraph", records.node)
-                // select_type = select_type_noSearch
                 $('#searchInp').val(val)
                 window.graphTxt = val
                 window.refreshTree = true
@@ -50,17 +43,18 @@ function getGraph(val, type) {
             }
         })
     } else {
-        url = api.getGraph
+        url = api.getNewGraph
         params = {
-            "inputStr": val,
-            "labelName": type
+            "input_str": val,
+            "label_name": type
         }
         return post(url, params).then(res => {
             console.log("getGraph", res)
-            if (res.data.code == 0) {
+            const { data, success } = res.data
+            if (success) {
                 // select_type = select_type_noSearch
                 $('#searchInp').val(val)
-                drawGraph(res.data.data, null)
+                drawGraph(data, null)
                 window.graphTxt = val
                 window.refreshTree = true
 
@@ -230,9 +224,6 @@ function reDrawGraph(name, label) {
             }
         })
     }
-
-
-
 }
 function reShowLegendNum() {
     window.knowledgeMapSetting.showLegendNum = 0;
@@ -856,13 +847,6 @@ function rightEntityNode(data) {
                             }
                         }
                         if (!isEntityNode) entityNodes.push(entityNode);
-
-                        // entity_node_str += `
-                        // <div class="text" nodeIndex="${entityNode.name}" nodeId="${entityNode.nodeId}" label="${entityNode.type}">
-                        //     <p class='select-sign'><span class='icon-rect-select'></span>&nbsp;</p>
-                        //     <p class="text-key">${entityNode.type}:</p>
-                        //     <p class="text-value">${entityNode.properties.name}</p>
-                        // </div>`
                     }
                 }
             })
@@ -1166,7 +1150,7 @@ function drawTree(data, showNodeName) {
 }
 // 定位到当前疾病
 function selectedZTreeNode(nodeName) {
-     console.log("selectedZTreeNode", nodeName)
+    console.log("selectedZTreeNode", nodeName)
     const zTreeObj = $.fn.zTree.getZTreeObj("tree")
     // zTreeObj.expandAll()
     // console.log("zTreeObj", zTreeObj)
@@ -1566,9 +1550,6 @@ function hideSlide(expectClass) {
 }
 
 function expandProperty(data, flag) {
-    // console.log("expandProperty", data)
-
-    // window.graphMapUpdatedData
 
     //检验是否要展开属性
     let checkHasProperties = Object.keys(data.properties).filter(key => key !== "name" || key !== "is_deleted").length > 0

+ 6 - 3
src/js/home.js

@@ -1,16 +1,19 @@
 require("../css/home.less");
 require("./../css/common.less");
+
+const $ = require("jquery");
+require('jquery-ui-dist/jquery-ui.min.css');
+require('jquery-ui-dist/jquery-ui.min.js')
 const { post, api, getUrlArgObject } = require("./api.js");
 const { saveLocalVar, getLocalVar } = require("../js/utils.js");
 const Vue = require("vue/dist/vue.esm.js").default;
 const ElementUI = require("../public/elementUI/2.7.2/index");
-console.log(ElementUI);
-const $ = require("jquery");
+Vue.use(ElementUI);
 const dayjs = require("dayjs");
 // 引入dayjs的中文
 require("dayjs/locale/zh-cn");
 const echarts = require("echarts");
-Vue.use(ElementUI);
+
 let myChart = null;
 let timer = null; //计时器标志
 

+ 2 - 22
src/js/knowledgeUpdate.js

@@ -3,22 +3,7 @@ require("babel-polyfill");
 const echarts = require("echarts");
 require("./../css/knowledgeUpdate.less");
 require("./../css/common.less");
-// require("ztree");
-require('./../resources/images/icon.png');
-require('./../resources/images/iconOpen.png');
-require('./../resources/images/iconClose.png');
-require('./../resources/images/node.png');
-require('./../resources/images/radioUnSelect.png');
-require('./../resources/images/radioSelect.png');
-require('./../resources/images/iconSlideUp.png');
-require('./../resources/images/iconSlideDown.png');
-require('./../resources/images/iconSelect.png');
-require('./../resources/images/syflogo.png');
-require('./../resources/images/logo.png');
-require('./../resources/images/logo_shaoyifu.png');
-require('./../resources/zTree/js/jquery.ztree.core.min.js');
-require('./../resources/zTree/js/jquery.ztree.excheck.min.js')
-require('./../resources/zTree/css/zTreeStyle/zTreeStyle.css');
+
 const iconUp = require('./../resources/images/iconUp.png');
 const iconDown = require('./../resources/images/iconDown.png');
 const { post, api, ifHideLogo, getUrlArgObject } = require('./api.js');
@@ -324,9 +309,7 @@ $(".dropdown[select='off'] .selectList .selectItem").on("click", function () {
 
 // 自定义的菜单和部分下拉框的操作
 function menuOperation(opType, data) {
-
   data.width = ""
-  // console.log("menuOperationData", data);
   let selectedName = ""
   let searchInp = ""
   const parentURL = window.location.protocol + "//" + window.location.hostname + ":" + window.location.port + "/home.html";
@@ -372,7 +355,6 @@ function menuOperation(opType, data) {
       break
     case "expandRelationships": //右键展开关系
       if (data.data.name === 0 || data.data.expanded) return;
-
       post(api.getGraph, {
         "inputStr": data.data.properties.name,
         "labelName": data.data.type
@@ -532,8 +514,7 @@ function nodeAllCloseAndExpand(flag) {
       data: window.graphMapUpdatedData.node,  // 更新节点数据
       links: window.graphMapUpdatedData.links,  // 更新边数据
     }]
-  }, false);  //
-
+  }, false);
 }
 
 //重新隐藏之前的节点
@@ -614,7 +595,6 @@ $(document).on("click", ".content .right .entity-node .delete-entity", function
     }).catch(err => {
       console.log("deleteEntity接口报错", err)
     })
-    // console.log("entityNodeId", entityNodeId)
   }
 
 })

+ 94 - 10
src/js/selfKnowledgeGraph.js

@@ -1,6 +1,8 @@
 const $ = require("jquery");
+require('jquery-ui-dist/jquery-ui.min.css');
+require('jquery-ui-dist/jquery-ui.min.js')
 require("babel-polyfill");
-const echarts = require("echarts");
+
 require("./../css/knowledgeMap.less");
 require("./../css/common.less");
 require("../css/selfKnowledgeGraph.less");
@@ -21,6 +23,7 @@ require("./../resources/zTree/js/jquery.ztree.excheck.min.js");
 require("./../resources/zTree/css/zTreeStyle/zTreeStyle.css");
 const iconUp = require("./../resources/images/iconUp.png");
 const iconDown = require("./../resources/images/iconDown.png");
+
 const {
   drawGraph,
   updateTree,
@@ -95,7 +98,6 @@ $(".selectList .selectItem").click(function () {
   const txt = $(this).text();
   const oldTxt = $(".selectedName").html();
   setSelectName(txt);
-
   $("#searchInp").attr("placeholder", `请输入${txt}名称`);
   if (txt != oldTxt) {
     $("#searchInp").val("");
@@ -111,7 +113,6 @@ $("html").click(function () {
 });
 
 let toggleTabHtml = "";
-
 function bindRightAsideCollapse() {
   $(".right-aside-collapse").on("click", function () {
     isRightCollapse = !isRightCollapse;
@@ -138,8 +139,6 @@ function bindRightAsideCollapse() {
   });
 }
 
-
-
 window.addEventListener("message", function (event) {
   if (event.data.operation == "left-collapse") {
     const contentWidth = $(".content").width();
@@ -155,8 +154,6 @@ window.addEventListener("message", function (event) {
   }
 });
 
-
-
 setHei();
 ifHideLogo();
 function setHei() {
@@ -182,6 +179,7 @@ const vm = new Vue({
   data() {
     return {
       isShowKG: false,
+      isMerge: false,
       currentKnowledgeGraph: {
         label: "症状",
         name: "头痛",
@@ -270,11 +268,97 @@ const vm = new Vue({
           console.log(e);
         });
     },
+    handleMergeSelect(index) {
+      let copyData = JSON.parse(JSON.stringify(this.listData[index]))
+      copyData.selected = !(copyData.selected)
+      this.listData.splice(index, 1, copyData)
+    },
+    clearSelection() {
+      this.listData.forEach(it => {
+        it.selected = false
+      });
+      this.listData = [...this.listData]
+    },
+    handleSelectionBtnClick() {
+      if (this.isMerge) {
+        this.clearSelection()
+      }
+      this.isMerge = !this.isMerge
+    },
+    handleMergeBtnClick() {
+      const that = this
+      $("#dialog-confirm", parent.document).dialog({
+        resizable: false,
+        height: 200,
+        modal: true,
+        show: {
+          effect: "blind",
+          duration: 200
+        },
+        // hide: {
+        //   effect: "explode",
+        //   duration: 1000
+        // },
+        position: { my: "center", at: "center", of: window }, // 设置对话框居中
+        buttons: {
+          "确认": function () {
+            let jobDetails = { master_id: '', slave_id: [] }
+            let i = 0
+            that.listData.forEach((it, index) => {
+              if (it.selected) {
+                if (i === 0) {
+                  jobDetails['master_id'] = it.graph_id
+                  i++
+                } else {
+                  jobDetails['slave_id'].push(it.graph_id)
+                }
+              }
+            })
+            jobDetails['slave_id'] = jobDetails['slave_id'].join(',')
+            console.log(JSON.stringify(jobDetails).replace(/"/g, '\\"'))
+            post(api.graphMerge, {
+              "action": "create_job",
+              "id": "xxxxxxx",
+              "params": [
+                {
+                  "name": "job_name",
+                  "value": "合并图谱"
+                },
+                {
+                  "name": "job_category",
+                  "value": "SYSTEM_MERGE_GRAPHS"
+                },
+                {
+                  "name": "job_details",
+                  "value": JSON.stringify(jobDetails)
+                },
+                {
+                  "name": "queue_name",
+                  "value": "MERGE_GRAPHS"
+                }
+              ]
+            }).then(res => {
+              const { code, data, msg } = res.data
+              if (code === 200) {
+                $(this).dialog("close");
+              }
+            }).catch(err => {
+              $(this).dialog("close");
+              console.log(err)
+            })
+
+          },
+          "取消": function () {
+            $(this).dialog("close");
+          }
+        }
+      });
+    },
+    handleRefresh() {
+      this.getUserGraphs()
+    }
   },
   computed: {
-    kgUrl() {
-      return `./knowledgeGraph.html?self=true&input=${this.currentKnowledgeGraph.name}&label=${this.currentKnowledgeGraph.label}`;
-    },
   },
   watch: {},
   mounted() {

+ 3 - 2
src/js/selfgraphMap.js

@@ -1038,8 +1038,9 @@ function drawTree(data, showNodeName) {
                     return false;
                 } else {
                     const treeNodeName = treeNode.name
-                    let index = treeNodeName.indexOf(' ')
-                    const name = treeNodeName.substring(index + 1)
+                    // let index = treeNodeName.indexOf(' ')
+                    // const name = treeNodeName.substring(index + 1)
+                    const name = treeNodeName
                     if (select_type != select_type_noSearch) {
                         select_type_noSearch = select_type
                         setSelectName(select_type)

+ 8 - 6
webpack.config.js

@@ -7,7 +7,7 @@ const CopyWebpackPlugin = require('copy-webpack-plugin');
 const ExtractTextPlugin = require("extract-text-webpack-plugin");
 const webpack = require('webpack');
 // const proxyHost = "http://173.18.12.195:5050";
-const proxyHost = "http://173.18.12.205:8086/healsphere";
+const proxyHost = "http://173.18.12.205:8086";
 // const proxyHost = "http://192.18.1.235:8000/open-platform"
 // const proxyHost = "http://192.18.1.235:8000";
 // const proxyHost = "http://173.18.12.192:5050";
@@ -300,14 +300,16 @@ module.exports = {
   // devtool: 'cheap-module-eval-source-map', //开发环境cheap-module-eval-source-map   //生产环境cheap-module-source-map
   mode: 'development',
   devServer: {
-    // host: "172.16.8.57",
+    host: "172.16.8.57",
     contentBase: "./dist", //静态文件根目录
     proxy: {
-      '/api': {
+      '/healsphere': {
         target: proxyHost,
-        pathRewrite: {
-          '^/api': ''  // 重写路径,去掉/api前缀
-        },
+        changeOrigin: true,
+      },
+      '/knowledge': {
+        target: "http://192.18.1.141:8081",
+        changeOrigin: true,
       },
       '/open-platform': { //知识图谱统计API
         target: "http://173.18.12.205:8005",