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
bc7c3367
Commit
bc7c3367
authored
Jun 23, 2022
by
qiuchaofei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
关系添加属性:“颜色”
parent
b88c8fd5
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
18 deletions
+50
-18
DataRelationAnalyController.java
...adataRelation/controller/DataRelationAnalyController.java
+3
-1
Excel2Neo4jServiceImpl.java
...metadataRelation/service/impl/Excel2Neo4jServiceImpl.java
+42
-16
MetadataServiceImpl.java
...ta/metadataRelation/service/impl/MetadataServiceImpl.java
+5
-1
No files found.
src/main/java/com/keymobile/metadata/metadataRelation/controller/DataRelationAnalyController.java
View file @
bc7c3367
...
...
@@ -144,7 +144,9 @@ public class DataRelationAnalyController {
filePath
=
"D:\\dev\\neo4j-community-3.3.5\\systemRelation.xlsx"
;
}
return
excel2Neo4jService
.
generalRelationFromExcel
(
filePath
)
;
excel2Neo4jService
.
generalRelationFromExcel
(
filePath
)
;
logger
.
info
(
"从excel生成neo4j的节点与关系完成。"
);
return
""
;
}
}
src/main/java/com/keymobile/metadata/metadataRelation/service/impl/Excel2Neo4jServiceImpl.java
View file @
bc7c3367
...
...
@@ -54,25 +54,46 @@ public class Excel2Neo4jServiceImpl implements Excel2Neo4jService {
workbook
=
new
XSSFWorkbook
(
is
);
}
Map
<
String
,
String
>
colorMap
=
new
HashMap
<>();
// 第一个sheet是 node,先解析入neo4j。
// 第二个sheet 是 关系,
if
(
workbook
!=
null
)
{
// 开始循环sheet页 从0开始(workbook.getNumberOfSheets()获取sheet页的数量)
for
(
int
sheetIndex
=
0
;
sheetIndex
<
workbook
.
getNumberOfSheets
();
sheetIndex
++)
{
Sheet
sheet
=
workbook
.
getSheetAt
(
sheetIndex
);
if
(
sheet
==
null
)
{
Sheet
yanseSHeet
=
workbook
.
getSheet
(
"形式颜色"
);
{
int
firstRowNum
=
yanseSHeet
.
getFirstRowNum
();
int
lastRowNum
=
yanseSHeet
.
getLastRowNum
();
for
(
int
rowNum
=
firstRowNum
+
1
;
rowNum
<=
lastRowNum
;
rowNum
++)
{
// 获得当前行
Row
row
=
yanseSHeet
.
getRow
(
rowNum
);
if
(
row
==
null
)
{
continue
;
}
if
(
"系统节点"
.
equals
(
sheet
.
getSheetName
())){
// 获得当前行的开始列
int
firstCellNum
=
row
.
getFirstCellNum
();
// 获得当前行的列数
int
lastCellNum
=
row
.
getLastCellNum
();
String
[]
cells
=
new
String
[
row
.
getLastCellNum
()];
// 循环当前行
String
typeName
=
getCellValue
(
row
.
getCell
(
1
));
String
color
=
getCellValue
(
row
.
getCell
(
2
));
colorMap
.
put
(
typeName
,
color
);
}
}
Sheet
jiedianSHeet
=
workbook
.
getSheet
(
"系统节点"
);
{
// 获得当前sheet的开始行
int
firstRowNum
=
sh
eet
.
getFirstRowNum
();
int
firstRowNum
=
jiedianSH
eet
.
getFirstRowNum
();
// 获得当前sheet的结束行
int
lastRowNum
=
sh
eet
.
getLastRowNum
();
int
lastRowNum
=
jiedianSH
eet
.
getLastRowNum
();
// 循环除第一行外的所有行
for
(
int
rowNum
=
firstRowNum
+
1
;
rowNum
<=
lastRowNum
;
rowNum
++)
{
// 获得当前行
Row
row
=
sh
eet
.
getRow
(
rowNum
);
Row
row
=
jiedianSH
eet
.
getRow
(
rowNum
);
if
(
row
==
null
)
{
continue
;
}
...
...
@@ -102,15 +123,18 @@ public class Excel2Neo4jServiceImpl implements Excel2Neo4jService {
}
systemNodeList
.
add
(
systemNode
);
}
}
else
if
(
"关系"
.
equals
(
sheet
.
getSheetName
())){
}
Sheet
guanxiSHeet
=
workbook
.
getSheet
(
"关系"
);
{
// 获得当前sheet的开始行
int
firstRowNum
=
sh
eet
.
getFirstRowNum
();
int
firstRowNum
=
guanxiSH
eet
.
getFirstRowNum
();
// 获得当前sheet的结束行
int
lastRowNum
=
sh
eet
.
getLastRowNum
();
int
lastRowNum
=
guanxiSH
eet
.
getLastRowNum
();
// 循环除第一行外的所有行
for
(
int
rowNum
=
firstRowNum
+
1
;
rowNum
<=
lastRowNum
;
rowNum
++)
{
// 获得当前行
Row
row
=
sh
eet
.
getRow
(
rowNum
);
Row
row
=
guanxiSH
eet
.
getRow
(
rowNum
);
if
(
row
==
null
)
{
continue
;
}
...
...
@@ -126,7 +150,10 @@ public class Excel2Neo4jServiceImpl implements Excel2Neo4jService {
systemRelation
.
setFrom
(
fromId
);
systemRelation
.
setTo
(
toId
);
systemRelation
.
getAttributeMap
().
put
(
"形式"
,
getCellValue
(
row
.
getCell
(
3
)));
String
xingshi
=
getCellValue
(
row
.
getCell
(
3
));
systemRelation
.
getAttributeMap
().
put
(
"形式"
,
xingshi
);
String
color
=
colorMap
.
get
(
xingshi
);
systemRelation
.
getAttributeMap
().
put
(
"颜色"
,
color
);
systemRelation
.
getAttributeMap
().
put
(
"协议"
,
getCellValue
(
row
.
getCell
(
4
)));
...
...
@@ -137,8 +164,6 @@ public class Excel2Neo4jServiceImpl implements Excel2Neo4jService {
}
}
}
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
...
...
@@ -172,6 +197,7 @@ public class Excel2Neo4jServiceImpl implements Excel2Neo4jService {
String
fromId
=
relation
.
getFrom
();
String
toId
=
relation
.
getTo
();
String
type
=
relation
.
getAttributeMap
().
get
(
"形式"
);
String
yanse
=
relation
.
getAttributeMap
().
get
(
"颜色"
);
String
xieyi
=
relation
.
getAttributeMap
().
get
(
"协议"
);
String
zubie
=
relation
.
getAttributeMap
().
get
(
"业务类别"
);
String
shujujiegou
=
relation
.
getAttributeMap
().
get
(
"数据结构"
);
...
...
@@ -179,7 +205,7 @@ public class Excel2Neo4jServiceImpl implements Excel2Neo4jService {
String
addRelationCypher
=
" match( a:softplatform {name:\""
+
fromId
+
"\"} ),(b:softplatform {name:\""
+
toId
+
"\"} ) "
+
" merge (a)-[r:"
+
type
+
"]-> (b) "
+
"set r.协议=\""
+
xieyi
+
"\" ,r.业务类别 = \""
+
zubie
+
"\" ,r.数据结构= \""
+
shujujiegou
+
"\",r.业务说明= \""
+
yewushuoming
+
"\" "
+
"set r.协议=\""
+
xieyi
+
"\" ,
r.颜色=\""
+
yanse
+
"\" ,
r.业务类别 = \""
+
zubie
+
"\" ,r.数据结构= \""
+
shujujiegou
+
"\",r.业务说明= \""
+
yewushuoming
+
"\" "
+
" return r "
;
neo4jSession
.
run
(
addRelationCypher
);
}
...
...
src/main/java/com/keymobile/metadata/metadataRelation/service/impl/MetadataServiceImpl.java
View file @
bc7c3367
...
...
@@ -564,7 +564,6 @@ public class MetadataServiceImpl implements IMetadataService {
Map
<
String
,
ReturnEdge
>
returnEdgeMap
=
new
HashMap
<>();
int
size
=
300
;
while
(
statementResult
.
hasNext
())
{
Record
record
=
statementResult
.
next
();
List
<
Value
>
values
=
record
.
values
();
...
...
@@ -606,6 +605,7 @@ public class MetadataServiceImpl implements IMetadataService {
// relationship.id();
//
String
xieyi
=
""
+
relationship
.
asMap
().
get
(
"协议"
);
String
yanse
=
""
+
relationship
.
asMap
().
get
(
"颜色"
);
String
yewuleibie
=
""
+
relationship
.
asMap
().
get
(
"业务类别"
);
String
shujujiegou
=
""
+
relationship
.
asMap
().
get
(
"数据结构"
);
String
yewushuoming
=
""
+
relationship
.
asMap
().
get
(
"业务说明"
);
...
...
@@ -630,6 +630,7 @@ public class MetadataServiceImpl implements IMetadataService {
edge
.
getAttributeMaps
().
put
(
"业务类别"
,
yewuleibie
);
edge
.
getAttributeMaps
().
put
(
"数据结构"
,
shujujiegou
);
edge
.
getAttributeMaps
().
put
(
"业务说明"
,
yewushuoming
);
edge
.
getAttributeMaps
().
put
(
"颜色"
,
yanse
);
returnEdgeMap
.
put
(
edgeId
,
edge
);
}
...
...
@@ -1384,6 +1385,9 @@ public class MetadataServiceImpl implements IMetadataService {
while
(
tableCursor
.
hasNext
())
{
Document
tableDocument
=
tableCursor
.
next
();
String
tableId
=(
String
)
tableDocument
.
get
(
"_id"
);
if
(
"Table=1=0c0553306fd24e34897a172338ccb38f"
.
equals
(
tableId
)){
System
.
out
.
println
(
"Table=1=4e048d23a0c0477e9f67792b34e51df7"
);
}
//存在了,就不写入
if
(
tableIdMapFromNeo4j
.
containsKey
(
tableId
)){
tableIdMapFromNeo4j
.
remove
(
tableId
);
...
...
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