Commit 43ec3fe6 authored by 单奇雲's avatar 单奇雲

新增topo图接口

parent a37159ca
package com.yeejoin.amos.fas.dao.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
import com.yeejoin.amos.op.core.entity.BusinessEntity;
/**
* 拓扑图连线
*
*/
@Entity
@Table(name = "f_topography_line")
public class TopographyLine extends BusinessEntity{
/**
* id
*/
@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
@Column(name = "id", nullable = false, length = 36)
protected String id;
/**
*
*/
@Column(name = "`from`", columnDefinition = "varchar(32) COMMENT '起点'")
private String from;
/**
*
*/
@Column(name = "`to`", columnDefinition = "varchar(32) COMMENT '终点'")
private String to;
/**
*
*/
@Column(name = "app_id", columnDefinition = "varchar(32) COMMENT 'appid'")
private String appId;
/**
*
*/
@Column(name = "clickable", columnDefinition = "bit COMMENT '可点击'")
private Boolean clickable;
/**
*
*/
@Column(name = "has_arrow", columnDefinition = "bit COMMENT '有箭头'")
private Boolean hasArrow;
/**
*
*/
@Column(name = "is_dash", columnDefinition = "bit COMMENT '是虚线'")
private Boolean isDash;
/**
*
*/
@Column(name = "line_color", columnDefinition = "int COMMENT '线颜色'")
private Integer lineColor;
@Column(name = "from_port", columnDefinition = "varchar(32) COMMENT '起点'")
private String fromPort;
@Column(name = "to_port", columnDefinition = "varchar(32) COMMENT '终点'")
private String toPort;
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 String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public Boolean getClickable() {
return clickable;
}
public void setClickable(Boolean clickable) {
this.clickable = clickable;
}
public Boolean getHasArrow() {
return hasArrow;
}
public void setHasArrow(Boolean hasArrow) {
this.hasArrow = hasArrow;
}
public Boolean getIsDash() {
return isDash;
}
public void setIsDash(Boolean isDash) {
this.isDash = isDash;
}
public Integer getLineColor() {
return lineColor;
}
public void setLineColor(Integer lineColor) {
this.lineColor = lineColor;
}
public String getFromPort() {
return fromPort;
}
public void setFromPort(String fromPort) {
this.fromPort = fromPort;
}
public String getToPort() {
return toPort;
}
public void setToPort(String toPort) {
this.toPort = toPort;
}
}
package com.yeejoin.amos.fas.dao.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
import com.yeejoin.amos.op.core.entity.BusinessEntity;
/**
* 拓扑图
*
*/
@Entity
@Table(name = "f_topography_node")
public class TopographyNode extends BusinessEntity{
/**
* id
*/
@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
@Column(name = "id", nullable = false, length = 36)
protected String id;
/**
*
*/
@Column(name = "`key`", columnDefinition = "varchar(32) COMMENT 'key'")
private String key;
/**
*
*/
@Column(name = "category", columnDefinition = "varchar(32) COMMENT '类别'")
private String category;
/**
*
*/
@Column(name = "`group`", columnDefinition = "varchar(32) COMMENT '分组'")
private String group;
/**
*
*/
@Column(name = "loc", columnDefinition = "varchar(255) COMMENT '位置'")
private String loc;
/**
*
*/
@Column(name = "text", columnDefinition = "varchar(32) COMMENT '文本'")
private String text;
/**
*
*/
@Column(name = "size", columnDefinition = "varchar(32) COMMENT '大小'")
private String size;
/**
*
*/
@Column(name = "is_group", columnDefinition = "bit COMMENT '是否是组'")
private Boolean isGroup;
/**
*
*/
@Column(name = "picture", columnDefinition = "varchar(32) COMMENT '图片'")
private String picture;
/**
*
*/
@Column(name = "app_id", columnDefinition = "varchar(32) COMMENT 'appid'")
private String appId;
@Column(name = "source_id", columnDefinition = "varchar(32) COMMENT '资源id'")
private String sourceId;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getGroup() {
return group;
}
public void setGroup(String group) {
this.group = group;
}
public String getLoc() {
return loc;
}
public void setLoc(String loc) {
this.loc = loc;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getSize() {
return size;
}
public void setSize(String size) {
this.size = size;
}
public Boolean getIsGroup() {
return isGroup;
}
public void setIsGroup(Boolean isGroup) {
this.isGroup = isGroup;
}
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getPicture() {
return picture;
}
public void setPicture(String picture) {
this.picture = picture;
}
public String getSourceId() {
return sourceId;
}
public void setSourceId(String sourceId) {
this.sourceId = sourceId;
}
}
package com.yeejoin.amos.fas.dao.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
import com.yeejoin.amos.op.core.entity.BusinessEntity;
/**
* 拓扑图-节点详情
*
*/
@Entity
@Table(name = "f_topography_node_detail")
public class TopographyNodeDetail extends BusinessEntity{
/**
* id
*/
@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
@Column(name = "id", nullable = false, length = 36)
protected String id;
/**
*
*/
@Column(name = "nodeid", columnDefinition = "varchar(32) COMMENT '节点id'")
private String nodeid;
/**
*
*/
@Column(name = "nodeDetail", columnDefinition = "text COMMENT '详情'")
private String nodeDetail;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getNodeid() {
return nodeid;
}
public void setNodeid(String nodeid) {
this.nodeid = nodeid;
}
public String getNodeDetail() {
return nodeDetail;
}
public void setNodeDetail(String nodeDetail) {
this.nodeDetail = nodeDetail;
}
}
package com.yeejoin.amos.fas.business.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.fas.business.service.intfc.ITopographyLineService;
import com.yeejoin.amos.fas.business.service.intfc.ITopographyNodeDetailService;
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.TopographyNodeDetail;
import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.op.core.util.CommonResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@RestController
@RequestMapping(value = "/api/Topography")
@Api(tags="Topography API")
public class TopographyController {
@Autowired
private ITopographyNodeService nodeService;
@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);
Map<String,Object> results = new HashMap<>();
results.put("nodeData", nodes);
results.put("linkData", links);
return CommonResponseUtil.success(results);
}
/**
* 保存拓扑图
*
* @return
*/
@PostMapping(value = "/updateTopo", produces = "application/json;charset=UTF-8")
@ApiOperation(value = "保存拓扑图", notes = "保存拓扑图")
public CommonResponse savedonghuanNodes(@ApiParam(value = "", required = false) @RequestBody JSONObject topography) {
JSONArray nodes = topography.getJSONArray("nodeData");
List<TopographyNode> nodeData = JSON.parseArray(JSON.toJSONString(nodes), TopographyNode.class);
nodeService.saveNodes(nodeData);
return CommonResponseUtil.success();
}
@ApiOperation(value = "根据nodeid查询节点详情", notes = "根据nodeid查询节点详情")
@GetMapping(value = "/detail/{nodeid}")
public CommonResponse getNodeDatilByNodeId(@PathVariable(value = "nodeid") String nodeid) {
TopographyNodeDetail detail = nodeService.getNodeDetailById(nodeid);
if(detail != null) {
// String items = detail.getNodeDetail();
return CommonResponseUtil.success(detail);
}
return CommonResponseUtil.success();
}
@ApiOperation(value = "保存节点详情", notes = "保存节点详情")
@PostMapping(value = "/detail")
public CommonResponse saveNodeDatil(@RequestBody TopographyNodeDetail nodeDetail) {
if(nodeDetail.getNodeid() !=null) {
TopographyNodeDetail saveNodeDetail = nodeService.saveNodeDetail(nodeDetail);
return CommonResponseUtil.success(saveNodeDetail);
}else {
return CommonResponseUtil.failure("请选择节点!");
}
}
}
package com.yeejoin.amos.fas.business.dao.repository;
import java.util.List;
import org.springframework.stereotype.Repository;
import com.yeejoin.amos.fas.dao.entity.TopographyLine;
@Repository("iTopographyLineDao")
public interface ITopographyLineDao extends BaseDao<TopographyLine, Long> {
List<TopographyLine> findByAppId(String appId);
}
package com.yeejoin.amos.fas.business.dao.repository;
import java.util.List;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import com.yeejoin.amos.fas.dao.entity.TopographyNode;
@Repository("iTopographyNodeDao")
public interface ITopographyNodeDao extends BaseDao<TopographyNode, Long> {
List<TopographyNode> findByAppId(String appId);
@Query(value = "select * from f_topography_node " + " where id in (?1)",nativeQuery = true)
List<TopographyNode> findAllByIds(@Param("ids") List<String> ids);
}
package com.yeejoin.amos.fas.business.dao.repository;
import org.springframework.stereotype.Repository;
import com.yeejoin.amos.fas.dao.entity.TopographyNodeDetail;
@Repository("iTopographyNodeDetailDao")
public interface ITopographyNodeDetailDao extends BaseDao<TopographyNodeDetail, Long> {
TopographyNodeDetail findByNodeid(String nodeid);
}
package com.yeejoin.amos.fas.business.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yeejoin.amos.fas.business.dao.repository.ITopographyLineDao;
import com.yeejoin.amos.fas.business.service.intfc.ITopographyLineService;
import com.yeejoin.amos.fas.dao.entity.TopographyLine;
@Service("topographyLineService")
public class ITopographyLineServiceImpl implements ITopographyLineService{
@Autowired
private ITopographyLineDao topographyLineDao;
@Override
public List<TopographyLine> getLinksByAppId(String appId) {
return topographyLineDao.findByAppId(appId);
}
}
package com.yeejoin.amos.fas.business.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yeejoin.amos.fas.business.dao.repository.ITopographyNodeDetailDao;
import com.yeejoin.amos.fas.business.service.intfc.ITopographyNodeDetailService;
@Service("topographyNodeDetailService")
public class ITopographyNodeDetailServiceImpl implements ITopographyNodeDetailService{
@Autowired
private ITopographyNodeDetailDao topographyNodeDetailDao;
}
package com.yeejoin.amos.fas.business.service.impl;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yeejoin.amos.fas.business.dao.repository.ITopographyNodeDao;
import com.yeejoin.amos.fas.business.dao.repository.ITopographyNodeDetailDao;
import com.yeejoin.amos.fas.business.service.intfc.ITopographyNodeService;
import com.yeejoin.amos.fas.dao.entity.TopographyNode;
import com.yeejoin.amos.fas.dao.entity.TopographyNodeDetail;
@Service("topographyNodeService")
public class ITopographyNodeServiceImpl implements ITopographyNodeService{
@Autowired
private ITopographyNodeDao topographyNodeDao;
@Autowired
private ITopographyNodeDetailDao nodeDetailDao;
@Override
public List<TopographyNode> getNodesByAppId(String appId) {
return topographyNodeDao.findByAppId(appId);
}
@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);
}
@Override
public TopographyNodeDetail getNodeDetailById(String nodeid) {
return nodeDetailDao.findByNodeid(nodeid);
}
@Override
public TopographyNodeDetail saveNodeDetail(TopographyNodeDetail nodeDetail) {
TopographyNodeDetail curNodeDetail = nodeDetailDao.findByNodeid(nodeDetail.getNodeid());
if(curNodeDetail == null) {
curNodeDetail = new TopographyNodeDetail();
curNodeDetail.setNodeid(nodeDetail.getNodeid());
}
curNodeDetail.setNodeDetail(nodeDetail.getNodeDetail());
TopographyNodeDetail save = nodeDetailDao.save(curNodeDetail);
return save;
}
}
package com.yeejoin.amos.fas.business.service.intfc;
import java.util.List;
import com.yeejoin.amos.fas.dao.entity.TopographyLine;
public interface ITopographyLineService {
public List<TopographyLine> getLinksByAppId(String appId);
}
package com.yeejoin.amos.fas.business.service.intfc;
public interface ITopographyNodeDetailService {
}
package com.yeejoin.amos.fas.business.service.intfc;
import java.util.List;
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 void saveNodes(List<TopographyNode> nodeData);
public TopographyNodeDetail getNodeDetailById(String nodeid);
public TopographyNodeDetail saveNodeDetail(TopographyNodeDetail nodeDetail);
}
...@@ -125,5 +125,84 @@ ...@@ -125,5 +125,84 @@
ALTER TABLE `f_fmea` ADD COLUMN `identify_method` varchar(255) DEFAULT NULL COMMENT '辨识方法'; ALTER TABLE `f_fmea` ADD COLUMN `identify_method` varchar(255) DEFAULT NULL COMMENT '辨识方法';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="shanqiyun" id="1583217856000-1">
<preConditions onFail="MARK_RAN">
<not>
<tableExists tableName="f_topography_node"/>
</not>
</preConditions>
<comment>create f_topography_node</comment>
<sql>
CREATE TABLE `f_topography_node` (
`id` varchar(36) NOT NULL,
`create_date` datetime DEFAULT NULL,
`create_user` varchar(255) DEFAULT NULL,
`is_delete` bit(1) DEFAULT NULL,
`update_date` datetime DEFAULT NULL,
`update_user` varchar(255) DEFAULT NULL,
`category` varchar(32) DEFAULT NULL COMMENT '类别',
`group` varchar(32) DEFAULT '' COMMENT '分组',
`is_group` bit(1) DEFAULT NULL COMMENT '是否是组',
`key` varchar(32) DEFAULT NULL COMMENT 'key',
`loc` varchar(255) DEFAULT NULL COMMENT '位置',
`picture` varchar(32) DEFAULT NULL COMMENT '图片',
`size` varchar(32) DEFAULT NULL COMMENT '大小',
`source_id` varchar(32) DEFAULT NULL COMMENT '资源id',
`text` varchar(32) DEFAULT NULL COMMENT '文本',
`app_id` varchar(32) DEFAULT NULL COMMENT 'appid',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
</sql>
</changeSet>
<changeSet author="shanqiyun" id="1583217856000-2">
<preConditions onFail="MARK_RAN">
<not>
<tableExists tableName="f_topography_line"/>
</not>
</preConditions>
<comment>create f_topography_line</comment>
<sql>
CREATE TABLE `f_topography_line` (
`id` varchar(36) NOT NULL,
`create_date` datetime DEFAULT NULL,
`create_user` varchar(255) DEFAULT NULL,
`is_delete` bit(1) DEFAULT NULL,
`update_date` datetime DEFAULT NULL,
`update_user` varchar(255) DEFAULT NULL,
`app_id` varchar(32) DEFAULT NULL COMMENT 'appid',
`clickable` bit(1) DEFAULT NULL COMMENT '可点击',
`from` varchar(32) DEFAULT NULL COMMENT '起点',
`has_arrow` bit(1) DEFAULT NULL COMMENT '有箭头',
`is_dash` bit(1) DEFAULT NULL COMMENT '是虚线',
`line_color` int(11) DEFAULT NULL COMMENT '线颜色',
`to` varchar(32) DEFAULT NULL COMMENT '终点',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
</sql>
</changeSet>
<changeSet author="shanqiyun" id="1583217856000-3">
<preConditions onFail="MARK_RAN">
<not>
<tableExists tableName="f_topography_node_detail"/>
</not>
</preConditions>
<comment>create f_topography_node_detail</comment>
<sql>
CREATE TABLE `f_topography_node_detail` (
`id` varchar(36) NOT NULL,
`create_date` datetime DEFAULT NULL,
`create_user` varchar(255) DEFAULT NULL,
`is_delete` bit(1) DEFAULT NULL,
`update_date` datetime DEFAULT NULL,
`update_user` varchar(255) DEFAULT NULL,
`node_detail` text COMMENT '详情',
`nodeid` varchar(32) DEFAULT NULL COMMENT '节点id',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
</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