Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
neo4jRelation
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qiuchaofei
neo4jRelation
Commits
2e5f32ae
Commit
2e5f32ae
authored
Jun 22, 2022
by
qiuchaofei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1提供系统总图结构,2从excel导入数据
parent
144dfcf6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
201 additions
and
14 deletions
+201
-14
pom.xml
pom.xml
+22
-6
DataRelationAnalyController.java
...adataRelation/controller/DataRelationAnalyController.java
+16
-4
SystemNode.java
.../keymobile/metadata/metadataRelation/pojo/SystemNode.java
+28
-0
SystemRelation.java
...mobile/metadata/metadataRelation/pojo/SystemRelation.java
+46
-0
ReturnEdge.java
...metadata/metadataRelation/pojo/returnBean/ReturnEdge.java
+13
-0
Excel2Neo4jService.java
...metadata/metadataRelation/service/Excel2Neo4jService.java
+7
-0
Excel2Neo4jServiceImpl.java
...metadataRelation/service/impl/Excel2Neo4jServiceImpl.java
+0
-0
MetadataServiceImpl.java
...ta/metadataRelation/service/impl/MetadataServiceImpl.java
+69
-4
No files found.
pom.xml
View file @
2e5f32ae
...
...
@@ -41,6 +41,7 @@
<version>
${auth.version}
</version>
</dependency>
<!-- 添加neo4j的jar包 -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
...
...
@@ -59,13 +60,13 @@
<version>0.3.1</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ogm-bolt-driver</artifactId>
<version>3.0.0</version>
</dependency>
-->
-->
<dependency>
<groupId>
org.neo4j
</groupId>
<artifactId>
neo4j-ogm-bolt-driver
</artifactId>
<version>
3.0.0
</version>
</dependency>
<dependency>
<groupId>
org.neo4j
</groupId>
<artifactId>
neo4j-ogm-embedded-driver
</artifactId>
...
...
@@ -77,6 +78,21 @@
<version>
1.7.5
</version>
</dependency>
<!-- excel文件解析依赖 -->
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi
</artifactId>
<version>
4.1.0
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi-ooxml
</artifactId>
<version>
4.1.0
</version>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger2
</artifactId>
...
...
src/main/java/com/keymobile/metadata/metadataRelation/controller/DataRelationAnalyController.java
View file @
2e5f32ae
...
...
@@ -2,10 +2,7 @@ package com.keymobile.metadata.metadataRelation.controller;
import
com.keymobile.metadata.metadataRelation.pojo.returnBean.ReturnNode
;
import
com.keymobile.metadata.metadataRelation.pojo.returnBean.ReturnReslult
;
import
com.keymobile.metadata.metadataRelation.service.DataRelationAnalyService
;
import
com.keymobile.metadata.metadataRelation.service.ISchemaService
;
import
com.keymobile.metadata.metadataRelation.service.ISystemService
;
import
com.keymobile.metadata.metadataRelation.service.ITableService
;
import
com.keymobile.metadata.metadataRelation.service.*
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.slf4j.Logger
;
...
...
@@ -31,6 +28,8 @@ public class DataRelationAnalyController {
@Autowired
private
ITableService
tableService
;
@Autowired
private
Excel2Neo4jService
excel2Neo4jService
;
@Autowired
private
ISchemaService
schemaService
;
...
...
@@ -135,4 +134,17 @@ public class DataRelationAnalyController {
logger
.
info
(
"子节点id找出父节点。子节点id:"
+
childId
);
return
tableService
.
getParentByChildId
(
childId
);
}
//解析excel,存入neo4j
@ApiOperation
(
tags
=
""
,
value
=
"从excel生成neo4j的节点与关系。"
)
@RequestMapping
(
path
=
"/generalRelationFromExcel"
,
method
=
RequestMethod
.
GET
)
public
String
generalRelationFromExcel
(
String
filePath
)
{
logger
.
info
(
"从excel生成neo4j的节点与关系:"
+
filePath
);
if
(
filePath
==
null
||
""
.
equals
(
filePath
)
){
filePath
=
"D:\\dev\\neo4j-community-3.3.5\\systemRelation.xlsx"
;
}
return
excel2Neo4jService
.
generalRelationFromExcel
(
filePath
)
;
}
}
src/main/java/com/keymobile/metadata/metadataRelation/pojo/SystemNode.java
0 → 100644
View file @
2e5f32ae
package
com
.
keymobile
.
metadata
.
metadataRelation
.
pojo
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
SystemNode
{
private
String
name
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
Map
<
String
,
String
>
getNodeAttributeMap
()
{
return
nodeAttributeMap
;
}
public
void
setNodeAttributeMap
(
Map
<
String
,
String
>
nodeAttributeMap
)
{
this
.
nodeAttributeMap
=
nodeAttributeMap
;
}
private
Map
<
String
,
String
>
nodeAttributeMap
=
new
HashMap
<>();
}
src/main/java/com/keymobile/metadata/metadataRelation/pojo/SystemRelation.java
0 → 100644
View file @
2e5f32ae
package
com
.
keymobile
.
metadata
.
metadataRelation
.
pojo
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
SystemRelation
{
private
String
id
;
private
String
from
;
private
String
to
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getFrom
()
{
return
from
;
}
public
void
setFrom
(
String
from
)
{
this
.
from
=
from
;
}
public
String
getTo
()
{
return
to
;
}
public
void
setTo
(
String
to
)
{
this
.
to
=
to
;
}
public
Map
<
String
,
String
>
getAttributeMap
()
{
return
attributeMap
;
}
public
void
setAttributeMap
(
Map
<
String
,
String
>
attributeMap
)
{
this
.
attributeMap
=
attributeMap
;
}
private
Map
<
String
,
String
>
attributeMap
=
new
HashMap
<>();
}
src/main/java/com/keymobile/metadata/metadataRelation/pojo/returnBean/ReturnEdge.java
View file @
2e5f32ae
package
com
.
keymobile
.
metadata
.
metadataRelation
.
pojo
.
returnBean
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
ReturnEdge
{
private
String
edgeId
;
...
...
@@ -9,6 +12,16 @@ public class ReturnEdge {
private
String
type
;
public
Map
<
String
,
String
>
getAttributeMaps
()
{
return
attributeMaps
;
}
public
void
setAttributeMaps
(
Map
<
String
,
String
>
attributeMaps
)
{
this
.
attributeMaps
=
attributeMaps
;
}
private
Map
<
String
,
String
>
attributeMaps
=
new
HashMap
<>();
public
String
getEdgeId
()
{
return
edgeId
;
}
...
...
src/main/java/com/keymobile/metadata/metadataRelation/service/Excel2Neo4jService.java
0 → 100644
View file @
2e5f32ae
package
com
.
keymobile
.
metadata
.
metadataRelation
.
service
;
public
interface
Excel2Neo4jService
{
String
generalRelationFromExcel
(
String
filePath
);
}
src/main/java/com/keymobile/metadata/metadataRelation/service/impl/Excel2Neo4jServiceImpl.java
0 → 100644
View file @
2e5f32ae
This diff is collapsed.
Click to expand it.
src/main/java/com/keymobile/metadata/metadataRelation/service/impl/MetadataServiceImpl.java
View file @
2e5f32ae
...
...
@@ -535,7 +535,6 @@ public class MetadataServiceImpl implements IMetadataService {
ReturnNode
returnNode
=
new
ReturnNode
();
returnNode
.
setId
(
neo4jSystem
.
getMetadataId
());
returnNode
.
setName
(
neo4jSystem
.
getName
());
returnNode
.
setIcon
(
modelName
);
if
(!
metaModelMap
.
containsKey
(
modelName
))
{
MetaModel
model
=
new
MetaModel
();
...
...
@@ -560,7 +559,6 @@ public class MetadataServiceImpl implements IMetadataService {
String
cypher
=
"match data=(na:softplatform)<-[r]->(nb:softplatform) return data "
;
StatementResult
statementResult
=
session
.
run
(
cypher
);
String
modelName
=
SystemModelName
;
Map
<
Long
,
ReturnNode
>
nodesMap
=
new
HashMap
<>();
Map
<
String
,
MetaModel
>
metaModelMap
=
new
HashMap
<>();
int
size
=
300
;
...
...
@@ -571,10 +569,10 @@ public class MetadataServiceImpl implements IMetadataService {
if
(
value
.
type
().
name
().
equals
(
"PATH"
))
{
Path
p
=
value
.
asPath
();
Iterable
<
Node
>
nodes
=
p
.
nodes
();
getNodesMapFromNeo4j
(
size
,
modelName
,
nodesMap
,
metaModelMap
,
nodes
);
getNodesMapFromNeo4j
System
(
nodesMap
,
metaModelMap
,
nodes
);
Iterable
<
Relationship
>
relationships
=
p
.
relationships
();
getRelationFromneo4jRelation
(
returnReslult
,
nodesMap
,
relationships
);
getRelationFromneo4jRelation
System
(
returnReslult
,
nodesMap
,
relationships
);
}
}
}
...
...
@@ -587,6 +585,73 @@ public class MetadataServiceImpl implements IMetadataService {
return
returnReslult
;
}
private
void
getRelationFromneo4jRelationSystem
(
ReturnReslult
returnReslult
,
Map
<
Long
,
ReturnNode
>
nodesMap
,
Iterable
<
Relationship
>
relationships
)
{
for
(
Relationship
relationship
:
relationships
)
{
Long
startID
=
relationship
.
startNodeId
();
Long
endID
=
relationship
.
endNodeId
();
String
rType
=
relationship
.
type
();
/**
* asMap 相当于 节点的properties属性信息
*/
// relationship.id();
//
String
xieyi
=
""
+
relationship
.
asMap
().
get
(
"协议"
);
String
yewuleibie
=
""
+
relationship
.
asMap
().
get
(
"业务类别"
);
String
shujujiegou
=
""
+
relationship
.
asMap
().
get
(
"数据结构"
);
String
yewushuoming
=
""
+
relationship
.
asMap
().
get
(
"业务说明"
);
String
startMetaId
=
""
;
String
endMEtaId
=
""
;
if
(
nodesMap
.
containsKey
(
startID
))
{
startMetaId
=
nodesMap
.
get
(
startID
).
getId
();
}
if
(
nodesMap
.
containsKey
(
endID
))
{
endMEtaId
=
nodesMap
.
get
(
endID
).
getId
();
}
if
(!
StringUtils
.
isBlank
(
startMetaId
)
&&
!
StringUtils
.
isBlank
(
endMEtaId
)){
ReturnEdge
edge
=
new
ReturnEdge
();
edge
.
setEdgeId
(
String
.
valueOf
(
relationship
.
id
()));
edge
.
setFromId
(
startMetaId
);
edge
.
setToId
(
endMEtaId
);
edge
.
setType
(
rType
);
edge
.
getAttributeMaps
().
put
(
"协议"
,
xieyi
);
edge
.
getAttributeMaps
().
put
(
"业务说明"
,
yewushuoming
);
edge
.
getAttributeMaps
().
put
(
"数据结构"
,
shujujiegou
);
edge
.
getAttributeMaps
().
put
(
"业务说明"
,
yewushuoming
);
returnReslult
.
getEdges
().
add
(
edge
);
}
}
}
private
void
getNodesMapFromNeo4jSystem
(
Map
<
Long
,
ReturnNode
>
nodesMap
,
Map
<
String
,
MetaModel
>
metaModelMap
,
Iterable
<
Node
>
nodes
)
{
for
(
Node
node
:
nodes
)
{
Map
<
String
,
Object
>
stringObjectMap
=
node
.
asMap
();
Neo4jSystem
neo4jSystem
=
new
Neo4jSystem
();
Neo4jTool
.
transMap2Bean
(
stringObjectMap
,
neo4jSystem
);
// metaDataList.add(data);
if
(
neo4jSystem
.
getMetadataId
()
==
null
){
neo4jSystem
.
setMetadataId
(
SystemModelEqual
+
neo4jSystem
.
getName
());
}
ReturnNode
returnNode
=
new
ReturnNode
();
returnNode
.
setId
(
neo4jSystem
.
getMetadataId
());
returnNode
.
setName
(
neo4jSystem
.
getName
());
returnNode
.
getAttributeMaps
().
put
(
"内外部系统"
,
""
+
stringObjectMap
.
get
(
"内外部系统"
));
returnNode
.
getAttributeMaps
().
put
(
"行"
,
""
+
stringObjectMap
.
get
(
"行"
));
returnNode
.
getAttributeMaps
().
put
(
"列"
,
""
+
stringObjectMap
.
get
(
"列"
));
returnNode
.
setType
(
"Neo4jSystem"
);
nodesMap
.
put
(
node
.
id
(),
returnNode
);
}
}
@Override
public
Map
<
String
,
String
>
getAutoMatchByInput
(
String
name
,
int
countInt
,
int
offsetInt
)
{
logger
.
info
(
"开始模糊查找:"
+
name
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment