Commit cc82472f authored by 单奇雲's avatar 单奇雲

修改预案文件查看接口,新增liqubase脚本

parent db3cdd14
...@@ -213,7 +213,7 @@ public class FileController extends BaseController { ...@@ -213,7 +213,7 @@ public class FileController extends BaseController {
return new CommonResponse(SUCCESS, "访问的文件不存在!", "查询成功"); return new CommonResponse(SUCCESS, "访问的文件不存在!", "查询成功");
} }
if (fileName.endsWith(".doc") || fileName.endsWith(".docx")) { if (fileName.endsWith(".doc") || fileName.endsWith(".docx")) {
String htmlFileName = fileName.substring(0, fileName.indexOf(".")) + ".html"; String htmlFileName = fileName.substring(0, fileName.lastIndexOf(".")) + ".html";
File htmlFile = new File(htmlFileName); File htmlFile = new File(htmlFileName);
String data = WordConverterUtils.wordToHtmlString(fileName, readUrl); String data = WordConverterUtils.wordToHtmlString(fileName, readUrl);
Map<String, Object> processData = null; Map<String, Object> processData = null;
......
...@@ -72,69 +72,73 @@ public class TopographyController { ...@@ -72,69 +72,73 @@ 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 topographyParam) { public CommonResponse savedonghuanNodes(@ApiParam(value = "", required = false) @RequestBody JSONObject topographyParam) {
String appId = topographyParam.getString("appId") != null ? topographyParam.getString("appId") : null; synchronized (TopographyController.class) {
String type = topographyParam.getString("type");
//节点 String appId = topographyParam.getString("appId") != null ? topographyParam.getString("appId") : null;
JSONArray nodes = topographyParam.getJSONArray("nodeData"); String type = topographyParam.getString("type");
List<TopographyNode> nodeData = JSON.parseArray(JSON.toJSONString(nodes), TopographyNode.class); //节点
HashMap<String, String> convertKeyMap = new HashMap<>(); JSONArray nodes = topographyParam.getJSONArray("nodeData");
int curSize = nodeService.queryMaxKeyByAppIdAndType(appId,type); List<TopographyNode> nodeData = JSON.parseArray(JSON.toJSONString(nodes), TopographyNode.class);
for(TopographyNode e:nodeData){ HashMap<String, String> convertKeyMap = new HashMap<>();
if(Integer.valueOf(e.getKey()) < 0) { int curSize = nodeService.queryMaxKeyByAppIdAndType(appId,type);
curSize = curSize + 1 ; for(TopographyNode e:nodeData){
String newKey = String.format("%05d", curSize); if(Integer.valueOf(e.getKey()) < 0) {
convertKeyMap.put(e.getKey(), newKey); curSize = curSize + 1 ;
e.setKey(newKey); String newKey = String.format("%05d", curSize);
e.setType(type); convertKeyMap.put(e.getKey(), newKey);
e.setAppId(appId); e.setKey(newKey);
if(e.getGroup() == null) { e.setType(type);
e.setGroup(""); e.setAppId(appId);
}else if(Integer.valueOf(e.getGroup()) < 0){//修改新节点组 if(e.getGroup() == null) {
e.setGroup(convertKeyMap.get(e.getGroup())); 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 -> {//修改新增节点之间线的连接 JSONArray links = topographyParam.getJSONArray("linkData");
if(Integer.parseInt(l.getFrom()) < 0) { List<TopographyLine> lineData = JSON.parseArray(JSON.toJSONString(links), TopographyLine.class);
l.setFrom(convertKeyMap.get(l.getFrom())); lineData.forEach(l -> {//修改新增节点之间线的连接
} if(Integer.parseInt(l.getFrom()) < 0) {
if(Integer.parseInt(l.getTo()) < 0) { l.setFrom(convertKeyMap.get(l.getFrom()));
l.setTo(convertKeyMap.get(l.getTo())); }
} if(Integer.parseInt(l.getTo()) < 0) {
if(l.getCategory() == null) { l.setTo(convertKeyMap.get(l.getTo()));
l.setCategory(""); }
} if(l.getCategory() == null) {
if(l.getAppId() == null) { l.setCategory("");
l.setAppId(appId); }
l.setType(type); if(l.getAppId() == null) {
} l.setAppId(appId);
}); l.setType(type);
}
nodeService.saveNodes(nodeData); });
lineService.saveLines(lineData);
nodeService.saveNodes(nodeData);
//节点详情 lineService.saveLines(lineData);
JSONObject nodeDetailJson = topographyParam.getJSONObject("nodeDetail");
if(nodeDetailJson != null) { //节点详情
TopographyNodeDetail nodeDetail = JSON.parseObject(JSON.toJSONString(nodeDetailJson), TopographyNodeDetail.class);
String nodekey = nodeDetail.getNodekey(); JSONObject nodeDetailJson = topographyParam.getJSONObject("nodeDetail");
if(nodekey != null && Integer.parseInt(nodekey) < 0) { if(nodeDetailJson != null) {
TopographyNode node = nodeService.queryByKeyAndAppIdAndType(convertKeyMap.get(nodekey),appId,type); TopographyNodeDetail nodeDetail = JSON.parseObject(JSON.toJSONString(nodeDetailJson), TopographyNodeDetail.class);
nodeDetail.setNodeid(node.getId()); String nodekey = nodeDetail.getNodekey();
} if(nodekey != null && Integer.parseInt(nodekey) < 0) {
nodeService.saveNodeDetail(nodeDetail); TopographyNode node = nodeService.queryByKeyAndAppIdAndType(convertKeyMap.get(nodekey),appId,type);
nodeDetail.setNodeid(node.getId());
}
nodeService.saveNodeDetail(nodeDetail);
}
//返回保存后的数据
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);
return CommonResponseUtil.success(results);
} }
//返回保存后的数据
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);
return CommonResponseUtil.success(results);
} }
@ApiOperation(value = "根据nodeid查询节点详情", notes = "根据nodeid查询节点详情") @ApiOperation(value = "根据nodeid查询节点详情", notes = "根据nodeid查询节点详情")
......
...@@ -313,5 +313,60 @@ ...@@ -313,5 +313,60 @@
ALTER TABLE `f_topography_line` ADD COLUMN `category` varchar(32) DEFAULT '' COMMENT '类别'; ALTER TABLE `f_topography_line` ADD COLUMN `category` varchar(32) DEFAULT '' COMMENT '类别';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="shanqiyun" id="1586742391611-1">
<preConditions onFail="MARK_RAN">
<not>
<tableExists tableName="f_text_plan"/>
</not>
</preConditions>
<comment>create f_text_plan</comment>
<sql>
CREATE TABLE `f_text_plan` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`app_id` varchar(255) NOT NULL COMMENT '预案id',
`text_name` varchar(255) NOT NULL DEFAULT '' COMMENT '文本预案名称',
`file_path` varchar(255) NOT NULL COMMENT '预案路径',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
`create_date` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=101 DEFAULT CHARSET=utf8mb4 COMMENT='文本预案';
</sql>
</changeSet>
<changeSet author="shanqiyun" id="1586742391611-2">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="f_topography_line" columnName="from_port"/>
</not>
</preConditions>
<comment>f_topography_line add column from_port</comment>
<sql>
ALTER TABLE `f_topography_line` ADD COLUMN `from_port` varchar(32) DEFAULT NULL;
</sql>
</changeSet>
<changeSet author="shanqiyun" id="1586742391611-3">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="f_topography_line" columnName="to_port"/>
</not>
</preConditions>
<comment>f_topography_line add column to_port</comment>
<sql>
ALTER TABLE `f_topography_line` ADD COLUMN `to_port` varchar(32) DEFAULT NULL;
</sql>
</changeSet>
<changeSet author="shanqiyun" id="1586742391611-4">
<preConditions onFail="MARK_RAN">
<columnExists tableName="f_topography_node_detail " columnName="nodeid"/>
</preConditions>
<comment>"f_topography_node_detail " change column nodeid</comment>
<sql>
ALTER TABLE `f_topography_node_detail`
MODIFY COLUMN `nodeid` varchar(36) DEFAULT NULL;
</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