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

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

parent ff9d0ebf
...@@ -68,6 +68,12 @@ public class TopographyLine extends BusinessEntity{ ...@@ -68,6 +68,12 @@ public class TopographyLine extends BusinessEntity{
@Column(name = "to_port", columnDefinition = "varchar(32) COMMENT '终点'") @Column(name = "to_port", columnDefinition = "varchar(32) COMMENT '终点'")
private String toPort; 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() { public String getId() {
return id; return id;
} }
...@@ -128,6 +134,18 @@ public class TopographyLine extends BusinessEntity{ ...@@ -128,6 +134,18 @@ public class TopographyLine extends BusinessEntity{
public void setToPort(String toPort) { public void setToPort(String toPort) {
this.toPort = 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{ ...@@ -75,6 +75,9 @@ public class TopographyNode extends BusinessEntity{
@Column(name = "source_id", columnDefinition = "varchar(32) COMMENT '资源id'") @Column(name = "source_id", columnDefinition = "varchar(32) COMMENT '资源id'")
private String sourceId; private String sourceId;
@Column(name = "type", columnDefinition = "varchar(32) COMMENT '1 领导架构 | 2 任务流程'")
private String type;
public String getId() { public String getId() {
return id; return id;
} }
...@@ -141,4 +144,10 @@ public class TopographyNode extends BusinessEntity{ ...@@ -141,4 +144,10 @@ public class TopographyNode extends BusinessEntity{
public void setSourceId(String sourceId) { public void setSourceId(String sourceId) {
this.sourceId = sourceId; this.sourceId = sourceId;
} }
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
} }
...@@ -42,11 +42,11 @@ public class TopographyController { ...@@ -42,11 +42,11 @@ public class TopographyController {
@Autowired @Autowired
private ITopographyLineService lineService; private ITopographyLineService lineService;
@ApiOperation(value = "根据appID查询节点及线", notes = "根据appID查询节点及线") @ApiOperation(value = "根据appId查询节点及线", notes = "根据appID查询节点及线")
@GetMapping(value = "/{appId}") @GetMapping(value = "/query/{type}/{appId}")
public CommonResponse getTextPlanById(@PathVariable(value = "appId") String appId) { public CommonResponse getTextPlanByIdAndType(@PathVariable(value = "appId") String appId,@PathVariable(value = "type") String type) {
List<TopographyNode> nodes = nodeService.getNodesByAppId(appId); List<TopographyNode> nodes = nodeService.getNodesByAppIdAndType(appId,type);
List<TopographyLine> links = lineService.getLinksByAppId(appId); List<TopographyLine> links = lineService.getLinesByAppIdAndType(appId,type);
Map<String,Object> results = new HashMap<>(); Map<String,Object> results = new HashMap<>();
results.put("nodeData", nodes); results.put("nodeData", nodes);
results.put("linkData", links); results.put("linkData", links);
...@@ -62,33 +62,43 @@ public class TopographyController { ...@@ -62,33 +62,43 @@ public class TopographyController {
@ApiOperation(value = "保存拓扑图", notes = "保存拓扑图") @ApiOperation(value = "保存拓扑图", notes = "保存拓扑图")
public CommonResponse savedonghuanNodes(@ApiParam(value = "", required = false) @RequestBody JSONObject topographyParam) { public CommonResponse savedonghuanNodes(@ApiParam(value = "", required = false) @RequestBody JSONObject topographyParam) {
String appId = topographyParam.getString("appId"); String appId = topographyParam.getString("appId");
String type = topographyParam.getString("type");
//节点 //节点
JSONArray nodes = topographyParam.getJSONArray("nodeData"); 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<>(); HashMap<String, String> convertKeyMap = new HashMap<>();
int curSize = nodeService.queryMaxKeyByAppId(appId); int curSize = nodeService.queryMaxKeyByAppIdAndType(appId,type);
for(TopographyNode e:nodeData){ for(TopographyNode e:nodeData){
if(Integer.valueOf(e.getKey()) < 0) { if(Integer.valueOf(e.getKey()) < 0) {
curSize = curSize + 1 ; curSize = curSize + 1 ;
String newKey = String.format("%05d", curSize); String newKey = String.format("%05d", curSize);
convertKeyMap.put(e.getKey(), newKey); convertKeyMap.put(e.getKey(), newKey);
e.setKey(newKey); e.setKey(newKey);
e.setType(type);
e.setAppId(appId); 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"); JSONArray links = topographyParam.getJSONArray("linkData");
List<TopographyLine> lineData = JSON.parseArray(JSON.toJSONString(links), TopographyLine.class); List<TopographyLine> lineData = JSON.parseArray(JSON.toJSONString(links), TopographyLine.class);
lineData.forEach(l -> { lineData.forEach(l -> {//修改新增节点之间线的连接
if(Integer.parseInt(l.getFrom()) < 0) { if(Integer.parseInt(l.getFrom()) < 0) {
l.setFrom(convertKeyMap.get(l.getFrom())); l.setFrom(convertKeyMap.get(l.getFrom()));
} }
if(Integer.parseInt(l.getTo()) < 0) { if(Integer.parseInt(l.getTo()) < 0) {
l.setTo(convertKeyMap.get(l.getTo())); l.setTo(convertKeyMap.get(l.getTo()));
} }
if(l.getCategory() == null) {
l.setCategory("");
}
if(l.getAppId() == null) { if(l.getAppId() == null) {
l.setAppId(appId); l.setAppId(appId);
l.setType(type);
} }
}); });
...@@ -101,14 +111,14 @@ public class TopographyController { ...@@ -101,14 +111,14 @@ public class TopographyController {
TopographyNodeDetail nodeDetail = JSON.parseObject(JSON.toJSONString(nodeDetailJson), TopographyNodeDetail.class); TopographyNodeDetail nodeDetail = JSON.parseObject(JSON.toJSONString(nodeDetailJson), TopographyNodeDetail.class);
String nodekey = nodeDetail.getNodekey(); String nodekey = nodeDetail.getNodekey();
if(nodekey != null && Integer.parseInt(nodekey) < 0) { 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()); nodeDetail.setNodeid(node.getId());
} }
nodeService.saveNodeDetail(nodeDetail); nodeService.saveNodeDetail(nodeDetail);
} }
//返回保存后的数据
List<TopographyNode> newNodes = nodeService.getNodesByAppId(appId); List<TopographyNode> newNodes = nodeService.getNodesByAppIdAndType(appId,type);
List<TopographyLine> newLinks = lineService.getLinksByAppId(appId); List<TopographyLine> newLinks = lineService.getLinesByAppIdAndType(appId,type);
Map<String,Object> results = new HashMap<>(); Map<String,Object> results = new HashMap<>();
results.put("nodeData", newNodes); results.put("nodeData", newNodes);
results.put("linkData", newLinks); results.put("linkData", newLinks);
...@@ -143,7 +153,8 @@ public class TopographyController { ...@@ -143,7 +153,8 @@ public class TopographyController {
if("Link".equals(type)) { if("Link".equals(type)) {
lineService.deleteLine(id); lineService.deleteLine(id);
}else { }else {
nodeService.deleteNode(id); TopographyNode node = nodeService.queryById(id);
nodeService.deleteNode(node);
} }
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} }
......
...@@ -10,7 +10,7 @@ import com.yeejoin.amos.fas.dao.entity.TopographyLine; ...@@ -10,7 +10,7 @@ import com.yeejoin.amos.fas.dao.entity.TopographyLine;
@Repository("iTopographyLineDao") @Repository("iTopographyLineDao")
public interface ITopographyLineDao extends BaseDao<TopographyLine, Long> { public interface ITopographyLineDao extends BaseDao<TopographyLine, Long> {
List<TopographyLine> findByAppId(String appId); List<TopographyLine> findByAppIdAndType(String appId,String type);
TopographyLine findById(String id); TopographyLine findById(String id);
......
...@@ -11,16 +11,18 @@ import com.yeejoin.amos.fas.dao.entity.TopographyNode; ...@@ -11,16 +11,18 @@ import com.yeejoin.amos.fas.dao.entity.TopographyNode;
@Repository("iTopographyNodeDao") @Repository("iTopographyNodeDao")
public interface ITopographyNodeDao extends BaseDao<TopographyNode, Long> { 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) @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 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) @Query(value = "select max(`key`) from f_topography_node where app_id = (?1) and type = (?2)",nativeQuery = true)
Integer queryMaxKeyByAppId(String appId); Integer queryMaxKeyByAppIdAndType(String appId,String type);
List<TopographyNode> findByGroupAndAppIdAndType(String key, String appId, String type);
} }
...@@ -16,8 +16,8 @@ public class ITopographyLineServiceImpl implements ITopographyLineService{ ...@@ -16,8 +16,8 @@ public class ITopographyLineServiceImpl implements ITopographyLineService{
private ITopographyLineDao topographyLineDao; private ITopographyLineDao topographyLineDao;
@Override @Override
public List<TopographyLine> getLinksByAppId(String appId) { public List<TopographyLine> getLinesByAppIdAndType(String appId,String type) {
return topographyLineDao.findByAppId(appId); return topographyLineDao.findByAppIdAndType(appId,type);
} }
@Override @Override
......
...@@ -27,20 +27,13 @@ public class ITopographyNodeServiceImpl implements ITopographyNodeService{ ...@@ -27,20 +27,13 @@ public class ITopographyNodeServiceImpl implements ITopographyNodeService{
private ITopographyLineDao lineDao; private ITopographyLineDao lineDao;
@Override @Override
public List<TopographyNode> getNodesByAppId(String appId) { public List<TopographyNode> getNodesByAppIdAndType(String appId,String type) {
return nodeDao.findByAppId(appId); return nodeDao.findByAppIdAndType(appId,type);
} }
@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()));
// 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); nodeDao.save(nodeData);
} }
@Override @Override
...@@ -61,8 +54,8 @@ public class ITopographyNodeServiceImpl implements ITopographyNodeService{ ...@@ -61,8 +54,8 @@ public class ITopographyNodeServiceImpl implements ITopographyNodeService{
} }
@Override @Override
public void deleteNode(String id) { public void deleteNode(TopographyNode node) {
TopographyNode node = nodeDao.findById(id); // TopographyNode node = nodeDao.findById(id);
if(node != null) { if(node != null) {
String key = node.getKey(); String key = node.getKey();
nodeDao.delete(node); nodeDao.delete(node);
...@@ -70,17 +63,27 @@ public class ITopographyNodeServiceImpl implements ITopographyNodeService{ ...@@ -70,17 +63,27 @@ public class ITopographyNodeServiceImpl implements ITopographyNodeService{
if(lines != null && lines.size() > 0) { if(lines != null && lines.size() > 0) {
lineDao.delete(lines); 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 @Override
public TopographyNode queryByKeyAndAppId(String nodekey, String appId) { public TopographyNode queryByKeyAndAppIdAndType(String nodekey, String appId,String type) {
return nodeDao.findByKeyAndAppId(nodekey,appId); return nodeDao.findByKeyAndAppIdAndType(nodekey,appId,type);
}
@Override
public int queryMaxKeyByAppIdAndType(String appId,String type) {
return nodeDao.queryMaxKeyByAppIdAndType(appId,type);
} }
@Override @Override
public int queryMaxKeyByAppId(String appId) { public TopographyNode queryById(String id) {
return nodeDao.queryMaxKeyByAppId(appId); return nodeDao.findById(id);
} }
......
...@@ -6,7 +6,7 @@ import com.yeejoin.amos.fas.dao.entity.TopographyLine; ...@@ -6,7 +6,7 @@ import com.yeejoin.amos.fas.dao.entity.TopographyLine;
public interface ITopographyLineService { public interface ITopographyLineService {
public List<TopographyLine> getLinksByAppId(String appId); public List<TopographyLine> getLinesByAppIdAndType(String appId,String type);
public void saveLines(List<TopographyLine> lineData); public void saveLines(List<TopographyLine> lineData);
......
...@@ -2,13 +2,12 @@ package com.yeejoin.amos.fas.business.service.intfc; ...@@ -2,13 +2,12 @@ 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;
public interface ITopographyNodeService { public interface ITopographyNodeService {
public List<TopographyNode> getNodesByAppId(String appId); public List<TopographyNode> getNodesByAppIdAndType(String appId,String type);
public void saveNodes(List<TopographyNode> nodeData); public void saveNodes(List<TopographyNode> nodeData);
...@@ -16,10 +15,12 @@ public interface ITopographyNodeService { ...@@ -16,10 +15,12 @@ public interface ITopographyNodeService {
public TopographyNodeDetail saveNodeDetail(TopographyNodeDetail nodeDetail); 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 @@ ...@@ -277,5 +277,41 @@
ALTER TABLE `f_fmea_equipment_point` ADD COLUMN `important_equipment_id` bigint(20) NOT NULL COMMENT '所属重点设备id'; ALTER TABLE `f_fmea_equipment_point` ADD COLUMN `important_equipment_id` bigint(20) NOT NULL COMMENT '所属重点设备id';
</sql> </sql>
</changeSet> </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> </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