Commit 89341cd3 authored by 单奇雲's avatar 单奇雲

修改TOPO图 查询保存删除接口

parent ff9d0ebf
......@@ -68,6 +68,12 @@ public class TopographyLine extends BusinessEntity{
@Column(name = "to_port", columnDefinition = "varchar(32) COMMENT '终点'")
private String toPort;
@Column(name = "type", columnDefinition = "varchar(32) COMMENT '1 领导架构 | 2 任务流程'")
private String type;
@Column(name = "category", columnDefinition = "varchar(32) COMMENT '类别'")
private String category;
public String getId() {
return id;
}
......@@ -128,6 +134,18 @@ public class TopographyLine extends BusinessEntity{
public void setToPort(String toPort) {
this.toPort = toPort;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
}
......@@ -75,6 +75,9 @@ public class TopographyNode extends BusinessEntity{
@Column(name = "source_id", columnDefinition = "varchar(32) COMMENT '资源id'")
private String sourceId;
@Column(name = "type", columnDefinition = "varchar(32) COMMENT '1 领导架构 | 2 任务流程'")
private String type;
public String getId() {
return id;
}
......@@ -141,4 +144,10 @@ public class TopographyNode extends BusinessEntity{
public void setSourceId(String sourceId) {
this.sourceId = sourceId;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
......@@ -42,11 +42,11 @@ public class TopographyController {
@Autowired
private ITopographyLineService lineService;
@ApiOperation(value = "根据appID查询节点及线", notes = "根据appID查询节点及线")
@GetMapping(value = "/{appId}")
public CommonResponse getTextPlanById(@PathVariable(value = "appId") String appId) {
List<TopographyNode> nodes = nodeService.getNodesByAppId(appId);
List<TopographyLine> links = lineService.getLinksByAppId(appId);
@ApiOperation(value = "根据appId查询节点及线", notes = "根据appID查询节点及线")
@GetMapping(value = "/query/{type}/{appId}")
public CommonResponse getTextPlanByIdAndType(@PathVariable(value = "appId") String appId,@PathVariable(value = "type") String type) {
List<TopographyNode> nodes = nodeService.getNodesByAppIdAndType(appId,type);
List<TopographyLine> links = lineService.getLinesByAppIdAndType(appId,type);
Map<String,Object> results = new HashMap<>();
results.put("nodeData", nodes);
results.put("linkData", links);
......@@ -62,33 +62,43 @@ public class TopographyController {
@ApiOperation(value = "保存拓扑图", notes = "保存拓扑图")
public CommonResponse savedonghuanNodes(@ApiParam(value = "", required = false) @RequestBody JSONObject topographyParam) {
String appId = topographyParam.getString("appId");
String type = topographyParam.getString("type");
//节点
JSONArray nodes = topographyParam.getJSONArray("nodeData");
List<TopographyNode> nodeData = JSON.parseArray(JSON.toJSONString(nodes), TopographyNode.class);
HashMap<String, String> convertKeyMap = new HashMap<>();
int curSize = nodeService.queryMaxKeyByAppId(appId);
int curSize = nodeService.queryMaxKeyByAppIdAndType(appId,type);
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.setType(type);
e.setAppId(appId);
e.setGroup("");
if(e.getGroup() == null) {
e.setGroup("");
}else if(Integer.valueOf(e.getGroup()) < 0){//修改新节点组
e.setGroup(convertKeyMap.get(e.getGroup()));
}
}
};
//线
JSONArray links = topographyParam.getJSONArray("linkData");
List<TopographyLine> lineData = JSON.parseArray(JSON.toJSONString(links), TopographyLine.class);
lineData.forEach(l -> {
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.getCategory() == null) {
l.setCategory("");
}
if(l.getAppId() == null) {
l.setAppId(appId);
l.setType(type);
}
});
......@@ -101,14 +111,14 @@ public class TopographyController {
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);
TopographyNode node = nodeService.queryByKeyAndAppIdAndType(convertKeyMap.get(nodekey),appId,type);
nodeDetail.setNodeid(node.getId());
}
nodeService.saveNodeDetail(nodeDetail);
}
List<TopographyNode> newNodes = nodeService.getNodesByAppId(appId);
List<TopographyLine> newLinks = lineService.getLinksByAppId(appId);
//返回保存后的数据
List<TopographyNode> newNodes = nodeService.getNodesByAppIdAndType(appId,type);
List<TopographyLine> newLinks = lineService.getLinesByAppIdAndType(appId,type);
Map<String,Object> results = new HashMap<>();
results.put("nodeData", newNodes);
results.put("linkData", newLinks);
......@@ -143,7 +153,8 @@ public class TopographyController {
if("Link".equals(type)) {
lineService.deleteLine(id);
}else {
nodeService.deleteNode(id);
TopographyNode node = nodeService.queryById(id);
nodeService.deleteNode(node);
}
return CommonResponseUtil.success();
}
......
......@@ -10,7 +10,7 @@ import com.yeejoin.amos.fas.dao.entity.TopographyLine;
@Repository("iTopographyLineDao")
public interface ITopographyLineDao extends BaseDao<TopographyLine, Long> {
List<TopographyLine> findByAppId(String appId);
List<TopographyLine> findByAppIdAndType(String appId,String type);
TopographyLine findById(String id);
......
......@@ -11,16 +11,18 @@ import com.yeejoin.amos.fas.dao.entity.TopographyNode;
@Repository("iTopographyNodeDao")
public interface ITopographyNodeDao extends BaseDao<TopographyNode, Long> {
List<TopographyNode> findByAppId(String appId);
List<TopographyNode> findByAppIdAndType(String appId,String type);
@Query(value = "select * from f_topography_node " + " where id in (?1)",nativeQuery = true)
List<TopographyNode> findAllByIds(@Param("ids") List<String> ids);
TopographyNode findById(String id);
TopographyNode findByKeyAndAppId(String nodekey, String appId);
TopographyNode findByKeyAndAppIdAndType(String nodekey, String appId,String type);
@Query(value = "select max(`key`) from f_topography_node where app_id = (?1)",nativeQuery = true)
Integer queryMaxKeyByAppId(String appId);
@Query(value = "select max(`key`) from f_topography_node where app_id = (?1) and type = (?2)",nativeQuery = true)
Integer queryMaxKeyByAppIdAndType(String appId,String type);
List<TopographyNode> findByGroupAndAppIdAndType(String key, String appId, String type);
}
......@@ -16,8 +16,8 @@ public class ITopographyLineServiceImpl implements ITopographyLineService{
private ITopographyLineDao topographyLineDao;
@Override
public List<TopographyLine> getLinksByAppId(String appId) {
return topographyLineDao.findByAppId(appId);
public List<TopographyLine> getLinesByAppIdAndType(String appId,String type) {
return topographyLineDao.findByAppIdAndType(appId,type);
}
@Override
......
......@@ -27,20 +27,13 @@ public class ITopographyNodeServiceImpl implements ITopographyNodeService{
private ITopographyLineDao lineDao;
@Override
public List<TopographyNode> getNodesByAppId(String appId) {
return nodeDao.findByAppId(appId);
public List<TopographyNode> getNodesByAppIdAndType(String appId,String type) {
return nodeDao.findByAppIdAndType(appId,type);
}
@Override
public void saveNodes(List<TopographyNode> nodeData) {
// List<TopographyNode> list = topographyNodeDao.findAllByIds(nodeData.stream().map(n->n.getId()).collect(Collectors.toList()));
// for (TopographyNode topographyNode : list) {
// TopographyNode node = nodeData.stream().filter(n->topographyNode.getId().equals(n.getId())).findFirst().get();
// topographyNode.setLoc(node.getLoc());
// }
// topographyNodeDao.save(list);
nodeDao.save(nodeData);
}
@Override
......@@ -61,8 +54,8 @@ public class ITopographyNodeServiceImpl implements ITopographyNodeService{
}
@Override
public void deleteNode(String id) {
TopographyNode node = nodeDao.findById(id);
public void deleteNode(TopographyNode node) {
// TopographyNode node = nodeDao.findById(id);
if(node != null) {
String key = node.getKey();
nodeDao.delete(node);
......@@ -70,17 +63,27 @@ public class ITopographyNodeServiceImpl implements ITopographyNodeService{
if(lines != null && lines.size() > 0) {
lineDao.delete(lines);
}
if(node.getIsGroup() != null && node.getIsGroup()) {
List<TopographyNode> childNodes = nodeDao.findByGroupAndAppIdAndType(node.getKey(),node.getAppId(),node.getType());
childNodes.forEach(c -> deleteNode(c));
}
return;
}
}
@Override
public TopographyNode queryByKeyAndAppId(String nodekey, String appId) {
return nodeDao.findByKeyAndAppId(nodekey,appId);
public TopographyNode queryByKeyAndAppIdAndType(String nodekey, String appId,String type) {
return nodeDao.findByKeyAndAppIdAndType(nodekey,appId,type);
}
@Override
public int queryMaxKeyByAppIdAndType(String appId,String type) {
return nodeDao.queryMaxKeyByAppIdAndType(appId,type);
}
@Override
public int queryMaxKeyByAppId(String appId) {
return nodeDao.queryMaxKeyByAppId(appId);
public TopographyNode queryById(String id) {
return nodeDao.findById(id);
}
......
......@@ -6,7 +6,7 @@ import com.yeejoin.amos.fas.dao.entity.TopographyLine;
public interface ITopographyLineService {
public List<TopographyLine> getLinksByAppId(String appId);
public List<TopographyLine> getLinesByAppIdAndType(String appId,String type);
public void saveLines(List<TopographyLine> lineData);
......
......@@ -2,13 +2,12 @@ package com.yeejoin.amos.fas.business.service.intfc;
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.TopographyNodeDetail;
public interface ITopographyNodeService {
public List<TopographyNode> getNodesByAppId(String appId);
public List<TopographyNode> getNodesByAppIdAndType(String appId,String type);
public void saveNodes(List<TopographyNode> nodeData);
......@@ -16,10 +15,12 @@ public interface ITopographyNodeService {
public TopographyNodeDetail saveNodeDetail(TopographyNodeDetail nodeDetail);
public void deleteNode(String id);
public void deleteNode(TopographyNode node);
public TopographyNode queryByKeyAndAppId(String nodekey, String appId);
public TopographyNode queryByKeyAndAppIdAndType(String nodekey, String appId,String type);
public int queryMaxKeyByAppId(String appId);
public int queryMaxKeyByAppIdAndType(String appId,String type);
public TopographyNode queryById(String id);
}
......@@ -277,5 +277,41 @@
ALTER TABLE `f_fmea_equipment_point` ADD COLUMN `important_equipment_id` bigint(20) NOT NULL COMMENT '所属重点设备id';
</sql>
</changeSet>
<changeSet author="shanqiyun" id="1583983706412-1">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="f_topography_node" columnName="type"/>
</not>
</preConditions>
<comment>f_topography_node add column type</comment>
<sql>
ALTER TABLE `f_topography_node` ADD COLUMN `type` varchar(32) DEFAULT NULL COMMENT '1 领导架构 | 2 任务流程';
</sql>
</changeSet>
<changeSet author="shanqiyun" id="1583983706412-2">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="f_topography_line" columnName="type"/>
</not>
</preConditions>
<comment>f_topography_line add column type</comment>
<sql>
ALTER TABLE `f_topography_line` ADD COLUMN `type` varchar(32) DEFAULT NULL COMMENT '1 领导架构 | 2 任务流程';
</sql>
</changeSet>
<changeSet author="shanqiyun" id="1583983706412-3">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="f_topography_line" columnName="category"/>
</not>
</preConditions>
<comment>f_topography_line add column category</comment>
<sql>
ALTER TABLE `f_topography_line` ADD COLUMN `category` varchar(32) DEFAULT '' COMMENT '类别';
</sql>
</changeSet>
</databaseChangeLog>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment