Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YeeAmosFireAutoSysRoot
Project
Project
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
station
YeeAmosFireAutoSysRoot
Commits
a26ffd3b
Commit
a26ffd3b
authored
Mar 10, 2020
by
单奇雲
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.修改TOPO查询保存接口,2.新增删除功能
parent
3287f94c
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
138 additions
and
12 deletions
+138
-12
TopographyNodeDetail.java
...com/yeejoin/amos/fas/dao/entity/TopographyNodeDetail.java
+10
-1
TopographyController.java
...in/amos/fas/business/controller/TopographyController.java
+65
-3
ITopographyLineDao.java
.../amos/fas/business/dao/repository/ITopographyLineDao.java
+6
-0
ITopographyNodeDao.java
.../amos/fas/business/dao/repository/ITopographyNodeDao.java
+4
-0
ITopographyLineServiceImpl.java
...fas/business/service/impl/ITopographyLineServiceImpl.java
+12
-0
ITopographyNodeServiceImpl.java
...fas/business/service/impl/ITopographyNodeServiceImpl.java
+31
-8
ITopographyLineService.java
...os/fas/business/service/intfc/ITopographyLineService.java
+4
-0
ITopographyNodeService.java
...os/fas/business/service/intfc/ITopographyNodeService.java
+5
-0
fas-1.0.2.xml
...utoSysStart/src/main/resources/db/changelog/fas-1.0.2.xml
+1
-0
No files found.
YeeAmosFireAutoSysCommon/src/main/java/com/yeejoin/amos/fas/dao/entity/TopographyNodeDetail.java
View file @
a26ffd3b
...
@@ -29,7 +29,7 @@ public class TopographyNodeDetail extends BusinessEntity{
...
@@ -29,7 +29,7 @@ public class TopographyNodeDetail extends BusinessEntity{
/**
/**
*
*
*/
*/
@Column
(
name
=
"nodeid"
,
columnDefinition
=
"varchar(3
2
) COMMENT '节点id'"
)
@Column
(
name
=
"nodeid"
,
columnDefinition
=
"varchar(3
6
) COMMENT '节点id'"
)
private
String
nodeid
;
private
String
nodeid
;
/**
/**
*
*
...
@@ -37,6 +37,9 @@ public class TopographyNodeDetail extends BusinessEntity{
...
@@ -37,6 +37,9 @@ public class TopographyNodeDetail extends BusinessEntity{
@Column
(
name
=
"nodeDetail"
,
columnDefinition
=
"text COMMENT '详情'"
)
@Column
(
name
=
"nodeDetail"
,
columnDefinition
=
"text COMMENT '详情'"
)
private
String
nodeDetail
;
private
String
nodeDetail
;
@Column
(
name
=
"nodekey"
,
columnDefinition
=
"varchar(32) COMMENT '节点key'"
)
private
String
nodekey
;
public
String
getId
()
{
public
String
getId
()
{
return
id
;
return
id
;
}
}
...
@@ -55,4 +58,10 @@ public class TopographyNodeDetail extends BusinessEntity{
...
@@ -55,4 +58,10 @@ public class TopographyNodeDetail extends BusinessEntity{
public
void
setNodeDetail
(
String
nodeDetail
)
{
public
void
setNodeDetail
(
String
nodeDetail
)
{
this
.
nodeDetail
=
nodeDetail
;
this
.
nodeDetail
=
nodeDetail
;
}
}
public
String
getNodekey
()
{
return
nodekey
;
}
public
void
setNodekey
(
String
nodekey
)
{
this
.
nodekey
=
nodekey
;
}
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/controller/TopographyController.java
View file @
a26ffd3b
package
com
.
yeejoin
.
amos
.
fas
.
business
.
controller
;
package
com
.
yeejoin
.
amos
.
fas
.
business
.
controller
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
@@ -57,11 +60,59 @@ public class TopographyController {
...
@@ -57,11 +60,59 @@ public class TopographyController {
*/
*/
@PostMapping
(
value
=
"/updateTopo"
,
produces
=
"application/json;charset=UTF-8"
)
@PostMapping
(
value
=
"/updateTopo"
,
produces
=
"application/json;charset=UTF-8"
)
@ApiOperation
(
value
=
"保存拓扑图"
,
notes
=
"保存拓扑图"
)
@ApiOperation
(
value
=
"保存拓扑图"
,
notes
=
"保存拓扑图"
)
public
CommonResponse
savedonghuanNodes
(
@ApiParam
(
value
=
""
,
required
=
false
)
@RequestBody
JSONObject
topography
)
{
public
CommonResponse
savedonghuanNodes
(
@ApiParam
(
value
=
""
,
required
=
false
)
@RequestBody
JSONObject
topographyParam
)
{
JSONArray
nodes
=
topography
.
getJSONArray
(
"nodeData"
);
String
appId
=
topographyParam
.
getString
(
"appId"
);
//节点
JSONArray
nodes
=
topographyParam
.
getJSONArray
(
"nodeData"
);
List
<
TopographyNode
>
nodeData
=
JSON
.
parseArray
(
JSON
.
toJSONString
(
nodes
),
TopographyNode
.
class
);
List
<
TopographyNode
>
nodeData
=
JSON
.
parseArray
(
JSON
.
toJSONString
(
nodes
),
TopographyNode
.
class
);
HashMap
<
String
,
String
>
convertKeyMap
=
new
HashMap
<>();
int
curSize
=
nodeData
.
stream
().
filter
(
e
->
Integer
.
parseInt
(
e
.
getKey
())
>
0
).
collect
(
Collectors
.
toList
()).
size
();
for
(
TopographyNode
e:
nodeData
){
if
(
Integer
.
valueOf
(
e
.
getKey
())
<
0
)
{
curSize
=
curSize
+
1
;
String
newKey
=
String
.
format
(
"%05d"
,
curSize
);
convertKeyMap
.
put
(
e
.
getKey
(),
newKey
);
e
.
setKey
(
newKey
);
e
.
setAppId
(
appId
);
e
.
setGroup
(
""
);
}
};
//线
JSONArray
links
=
topographyParam
.
getJSONArray
(
"linkData"
);
List
<
TopographyLine
>
lineData
=
JSON
.
parseArray
(
JSON
.
toJSONString
(
links
),
TopographyLine
.
class
);
lineData
.
forEach
(
l
->
{
if
(
Integer
.
parseInt
(
l
.
getFrom
())
<
0
)
{
l
.
setFrom
(
convertKeyMap
.
get
(
l
.
getFrom
()));
}
if
(
Integer
.
parseInt
(
l
.
getTo
())
<
0
)
{
l
.
setTo
(
convertKeyMap
.
get
(
l
.
getTo
()));
}
if
(
l
.
getAppId
()
==
null
)
{
l
.
setAppId
(
appId
);
}
});
nodeService
.
saveNodes
(
nodeData
);
nodeService
.
saveNodes
(
nodeData
);
return
CommonResponseUtil
.
success
();
lineService
.
saveLines
(
lineData
);
//节点详情
JSONObject
nodeDetailJson
=
topographyParam
.
getJSONObject
(
"nodeDetail"
);
if
(
nodeDetailJson
!=
null
)
{
TopographyNodeDetail
nodeDetail
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
nodeDetailJson
),
TopographyNodeDetail
.
class
);
String
nodekey
=
nodeDetail
.
getNodekey
();
if
(
nodekey
!=
null
&&
Integer
.
parseInt
(
nodekey
)
<
0
)
{
TopographyNode
node
=
nodeService
.
queryByKeyAndAppId
(
convertKeyMap
.
get
(
nodekey
),
appId
);
nodeDetail
.
setNodeid
(
node
.
getId
());
}
nodeService
.
saveNodeDetail
(
nodeDetail
);
}
List
<
TopographyNode
>
newNodes
=
nodeService
.
getNodesByAppId
(
appId
);
List
<
TopographyLine
>
newLinks
=
lineService
.
getLinksByAppId
(
appId
);
Map
<
String
,
Object
>
results
=
new
HashMap
<>();
results
.
put
(
"nodeData"
,
newNodes
);
results
.
put
(
"linkData"
,
newLinks
);
return
CommonResponseUtil
.
success
(
results
);
}
}
@ApiOperation
(
value
=
"根据nodeid查询节点详情"
,
notes
=
"根据nodeid查询节点详情"
)
@ApiOperation
(
value
=
"根据nodeid查询节点详情"
,
notes
=
"根据nodeid查询节点详情"
)
...
@@ -86,4 +137,15 @@ public class TopographyController {
...
@@ -86,4 +137,15 @@ public class TopographyController {
}
}
}
}
@ApiOperation
(
value
=
"删除节点/线"
,
notes
=
"删除节点/线"
)
@DeleteMapping
(
value
=
"/{type}/{id}"
)
public
CommonResponse
deleteTopo
(
@PathVariable
(
"type"
)
String
type
,
@PathVariable
(
"id"
)
String
id
)
{
if
(
"Link"
.
equals
(
type
))
{
lineService
.
deleteLine
(
id
);
}
else
{
nodeService
.
deleteNode
(
id
);
}
return
CommonResponseUtil
.
success
();
}
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/dao/repository/ITopographyLineDao.java
View file @
a26ffd3b
...
@@ -2,6 +2,7 @@ package com.yeejoin.amos.fas.business.dao.repository;
...
@@ -2,6 +2,7 @@ package com.yeejoin.amos.fas.business.dao.repository;
import
java.util.List
;
import
java.util.List
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
import
com.yeejoin.amos.fas.dao.entity.TopographyLine
;
import
com.yeejoin.amos.fas.dao.entity.TopographyLine
;
...
@@ -11,4 +12,9 @@ public interface ITopographyLineDao extends BaseDao<TopographyLine, Long> {
...
@@ -11,4 +12,9 @@ public interface ITopographyLineDao extends BaseDao<TopographyLine, Long> {
List
<
TopographyLine
>
findByAppId
(
String
appId
);
List
<
TopographyLine
>
findByAppId
(
String
appId
);
TopographyLine
findById
(
String
id
);
@Query
(
value
=
"select * from f_topography_line "
+
" where `from` = (?1) or `to` = (?1)"
,
nativeQuery
=
true
)
List
<
TopographyLine
>
findByKey
(
String
key
);
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/dao/repository/ITopographyNodeDao.java
View file @
a26ffd3b
...
@@ -16,4 +16,8 @@ public interface ITopographyNodeDao extends BaseDao<TopographyNode, Long> {
...
@@ -16,4 +16,8 @@ public interface ITopographyNodeDao extends BaseDao<TopographyNode, Long> {
@Query
(
value
=
"select * from f_topography_node "
+
" where id in (?1)"
,
nativeQuery
=
true
)
@Query
(
value
=
"select * from f_topography_node "
+
" where id in (?1)"
,
nativeQuery
=
true
)
List
<
TopographyNode
>
findAllByIds
(
@Param
(
"ids"
)
List
<
String
>
ids
);
List
<
TopographyNode
>
findAllByIds
(
@Param
(
"ids"
)
List
<
String
>
ids
);
TopographyNode
findById
(
String
id
);
TopographyNode
findByKeyAndAppId
(
String
nodekey
,
String
appId
);
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/ITopographyLineServiceImpl.java
View file @
a26ffd3b
...
@@ -18,7 +18,19 @@ public class ITopographyLineServiceImpl implements ITopographyLineService{
...
@@ -18,7 +18,19 @@ public class ITopographyLineServiceImpl implements ITopographyLineService{
@Override
@Override
public
List
<
TopographyLine
>
getLinksByAppId
(
String
appId
)
{
public
List
<
TopographyLine
>
getLinksByAppId
(
String
appId
)
{
return
topographyLineDao
.
findByAppId
(
appId
);
return
topographyLineDao
.
findByAppId
(
appId
);
}
@Override
public
void
saveLines
(
List
<
TopographyLine
>
lineData
)
{
topographyLineDao
.
save
(
lineData
);
}
@Override
public
void
deleteLine
(
String
id
)
{
TopographyLine
line
=
topographyLineDao
.
findById
(
id
);
if
(
line
!=
null
)
{
topographyLineDao
.
delete
(
line
);
}
}
}
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/ITopographyNodeServiceImpl.java
View file @
a26ffd3b
...
@@ -6,9 +6,11 @@ import java.util.stream.Collectors;
...
@@ -6,9 +6,11 @@ import java.util.stream.Collectors;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.yeejoin.amos.fas.business.dao.repository.ITopographyLineDao
;
import
com.yeejoin.amos.fas.business.dao.repository.ITopographyNodeDao
;
import
com.yeejoin.amos.fas.business.dao.repository.ITopographyNodeDao
;
import
com.yeejoin.amos.fas.business.dao.repository.ITopographyNodeDetailDao
;
import
com.yeejoin.amos.fas.business.dao.repository.ITopographyNodeDetailDao
;
import
com.yeejoin.amos.fas.business.service.intfc.ITopographyNodeService
;
import
com.yeejoin.amos.fas.business.service.intfc.ITopographyNodeService
;
import
com.yeejoin.amos.fas.dao.entity.TopographyLine
;
import
com.yeejoin.amos.fas.dao.entity.TopographyNode
;
import
com.yeejoin.amos.fas.dao.entity.TopographyNode
;
import
com.yeejoin.amos.fas.dao.entity.TopographyNodeDetail
;
import
com.yeejoin.amos.fas.dao.entity.TopographyNodeDetail
;
...
@@ -16,24 +18,28 @@ import com.yeejoin.amos.fas.dao.entity.TopographyNodeDetail;
...
@@ -16,24 +18,28 @@ import com.yeejoin.amos.fas.dao.entity.TopographyNodeDetail;
public
class
ITopographyNodeServiceImpl
implements
ITopographyNodeService
{
public
class
ITopographyNodeServiceImpl
implements
ITopographyNodeService
{
@Autowired
@Autowired
private
ITopographyNodeDao
topographyN
odeDao
;
private
ITopographyNodeDao
n
odeDao
;
@Autowired
@Autowired
private
ITopographyNodeDetailDao
nodeDetailDao
;
private
ITopographyNodeDetailDao
nodeDetailDao
;
@Autowired
private
ITopographyLineDao
lineDao
;
@Override
@Override
public
List
<
TopographyNode
>
getNodesByAppId
(
String
appId
)
{
public
List
<
TopographyNode
>
getNodesByAppId
(
String
appId
)
{
return
topographyN
odeDao
.
findByAppId
(
appId
);
return
n
odeDao
.
findByAppId
(
appId
);
}
}
@Override
@Override
public
void
saveNodes
(
List
<
TopographyNode
>
nodeData
)
{
public
void
saveNodes
(
List
<
TopographyNode
>
nodeData
)
{
List
<
TopographyNode
>
list
=
topographyNodeDao
.
findAllByIds
(
nodeData
.
stream
().
map
(
n
->
n
.
getId
()).
collect
(
Collectors
.
toList
()));
// List<TopographyNode> list = topographyNodeDao.findAllByIds(nodeData.stream().map(n->n.getId()).collect(Collectors.toList()));
for
(
TopographyNode
topographyNode
:
list
)
{
// for (TopographyNode topographyNode : list) {
TopographyNode
node
=
nodeData
.
stream
().
filter
(
n
->
topographyNode
.
getId
().
equals
(
n
.
getId
())).
findFirst
().
get
();
// TopographyNode node = nodeData.stream().filter(n->topographyNode.getId().equals(n.getId())).findFirst().get();
topographyNode
.
setLoc
(
node
.
getLoc
());
// topographyNode.setLoc(node.getLoc());
}
// }
topographyNodeDao
.
save
(
list
);
// topographyNodeDao.save(list);
nodeDao
.
save
(
nodeData
);
}
}
...
@@ -54,6 +60,23 @@ public class ITopographyNodeServiceImpl implements ITopographyNodeService{
...
@@ -54,6 +60,23 @@ public class ITopographyNodeServiceImpl implements ITopographyNodeService{
return
save
;
return
save
;
}
}
@Override
public
void
deleteNode
(
String
id
)
{
TopographyNode
node
=
nodeDao
.
findById
(
id
);
if
(
node
!=
null
)
{
String
key
=
node
.
getKey
();
nodeDao
.
delete
(
node
);
List
<
TopographyLine
>
lines
=
lineDao
.
findByKey
(
key
);
if
(
lines
!=
null
&&
lines
.
size
()
>
0
)
{
lineDao
.
delete
(
lines
);
}
}
}
@Override
public
TopographyNode
queryByKeyAndAppId
(
String
nodekey
,
String
appId
)
{
return
nodeDao
.
findByKeyAndAppId
(
nodekey
,
appId
);
}
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/intfc/ITopographyLineService.java
View file @
a26ffd3b
...
@@ -8,4 +8,8 @@ public interface ITopographyLineService {
...
@@ -8,4 +8,8 @@ public interface ITopographyLineService {
public
List
<
TopographyLine
>
getLinksByAppId
(
String
appId
);
public
List
<
TopographyLine
>
getLinksByAppId
(
String
appId
);
public
void
saveLines
(
List
<
TopographyLine
>
lineData
);
public
void
deleteLine
(
String
id
);
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/intfc/ITopographyNodeService.java
View file @
a26ffd3b
...
@@ -2,6 +2,7 @@ package com.yeejoin.amos.fas.business.service.intfc;
...
@@ -2,6 +2,7 @@ package com.yeejoin.amos.fas.business.service.intfc;
import
java.util.List
;
import
java.util.List
;
import
com.yeejoin.amos.fas.dao.entity.TopographyLine
;
import
com.yeejoin.amos.fas.dao.entity.TopographyNode
;
import
com.yeejoin.amos.fas.dao.entity.TopographyNode
;
import
com.yeejoin.amos.fas.dao.entity.TopographyNodeDetail
;
import
com.yeejoin.amos.fas.dao.entity.TopographyNodeDetail
;
...
@@ -15,4 +16,8 @@ public interface ITopographyNodeService {
...
@@ -15,4 +16,8 @@ public interface ITopographyNodeService {
public
TopographyNodeDetail
saveNodeDetail
(
TopographyNodeDetail
nodeDetail
);
public
TopographyNodeDetail
saveNodeDetail
(
TopographyNodeDetail
nodeDetail
);
public
void
deleteNode
(
String
id
);
public
TopographyNode
queryByKeyAndAppId
(
String
nodekey
,
String
appId
);
}
}
YeeAmosFireAutoSysStart/src/main/resources/db/changelog/fas-1.0.2.xml
View file @
a26ffd3b
...
@@ -260,6 +260,7 @@
...
@@ -260,6 +260,7 @@
`update_user` varchar(255) DEFAULT NULL,
`update_user` varchar(255) DEFAULT NULL,
`node_detail` text COMMENT '详情',
`node_detail` text COMMENT '详情',
`nodeid` varchar(32) DEFAULT NULL COMMENT '节点id',
`nodeid` varchar(32) DEFAULT NULL COMMENT '节点id',
`nodekey` varchar(32) DEFAULT NULL COMMENT '节点key',
PRIMARY KEY (`id`)
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
</sql>
</sql>
...
...
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