Commit bd69375a authored by shanqiyun's avatar shanqiyun

修改领导架构TOPO图接口,新增文本预案删除接口

parent 65e84da4
......@@ -143,4 +143,22 @@ public class PlanVisual3dController extends BaseController {
public CommonResponse getResourceList(){
return CommonResponseUtil.success(planVisual3dService.getResourceTypeList());
}
@ApiOperation(value = "预案应用树", notes = "预案应用树")
@GetMapping(value = "/plan/textPlanTree/{appId}")
public CommonResponse getPlanTree(@PathVariable("appId") String appId) {
return CommonResponseUtil.success(planVisual3dService.getTextPlanBySubjectId(appId));
}
@ApiOperation(value = "删除预案文件", notes = "删除预案文件")
@DeleteMapping(value = "/plan/textPlan/{id}")
public CommonResponse deleteTextPlanFile(@PathVariable("id") Long id) {
try {
planVisual3dService.deleteTextPlanFile(id);
return CommonResponseUtil.success();
} catch (Exception e) {
return CommonResponseUtil.failure(e.getMessage());
}
}
}
......@@ -53,6 +53,17 @@ public class TopographyController {
return CommonResponseUtil.success(results);
}
@ApiOperation(value = "根据type查询节点及线", notes = "根据type查询节点及线")
@GetMapping(value = "/query/{type}")
public CommonResponse getTextPlanByType(@PathVariable(value = "type") String type) {
List<TopographyNode> nodes = nodeService.getNodesByType(type);
List<TopographyLine> links = lineService.getLinesByType(type);
Map<String,Object> results = new HashMap<>();
results.put("nodeData", nodes);
results.put("linkData", links);
return CommonResponseUtil.success(results);
}
/**
* 保存拓扑图
*
......@@ -61,7 +72,7 @@ public class TopographyController {
@PostMapping(value = "/updateTopo", produces = "application/json;charset=UTF-8")
@ApiOperation(value = "保存拓扑图", notes = "保存拓扑图")
public CommonResponse savedonghuanNodes(@ApiParam(value = "", required = false) @RequestBody JSONObject topographyParam) {
String appId = topographyParam.getString("appId");
String appId = topographyParam.getString("appId") != null ? topographyParam.getString("appId") : null;
String type = topographyParam.getString("type");
//节点
JSONArray nodes = topographyParam.getJSONArray("nodeData");
......@@ -119,6 +130,7 @@ public class TopographyController {
//返回保存后的数据
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);
......
......@@ -17,4 +17,6 @@ public interface ITopographyLineDao extends BaseDao<TopographyLine, Long> {
@Query(value = "select * from f_topography_line " + " where `from` = (?1) or `to` = (?1)",nativeQuery = true)
List<TopographyLine> findByKey(String key);
List<TopographyLine> findByType(String type);
}
......@@ -25,4 +25,9 @@ public interface ITopographyNodeDao extends BaseDao<TopographyNode, Long> {
List<TopographyNode> findByGroupAndAppIdAndType(String key, String appId, String type);
List<TopographyNode> findByType(String type);
@Query(value = "select max(`key`) from f_topography_node where type = (?1)",nativeQuery = true)
Integer queryMaxKeyByType(String type);
}
......@@ -17,6 +17,9 @@ public class ITopographyLineServiceImpl implements ITopographyLineService{
@Override
public List<TopographyLine> getLinesByAppIdAndType(String appId,String type) {
if(appId == null) {
return topographyLineDao.findByType(type);
}
return topographyLineDao.findByAppIdAndType(appId,type);
}
......@@ -33,5 +36,10 @@ public class ITopographyLineServiceImpl implements ITopographyLineService{
}
}
@Override
public List<TopographyLine> getLinesByType(String type) {
return topographyLineDao.findByType(type);
}
}
......@@ -28,6 +28,9 @@ public class ITopographyNodeServiceImpl implements ITopographyNodeService{
@Override
public List<TopographyNode> getNodesByAppIdAndType(String appId,String type) {
if(appId == null) {
return nodeDao.findByType(type);
}
return nodeDao.findByAppIdAndType(appId,type);
}
......@@ -78,7 +81,12 @@ public class ITopographyNodeServiceImpl implements ITopographyNodeService{
@Override
public int queryMaxKeyByAppIdAndType(String appId,String type) {
Integer maxKey = nodeDao.queryMaxKeyByAppIdAndType(appId,type);
Integer maxKey;
if(null == appId) {
maxKey = nodeDao.queryMaxKeyByType(type);
}else {
maxKey = nodeDao.queryMaxKeyByAppIdAndType(appId,type);
}
if(maxKey == null) {
maxKey = 0;
}
......@@ -90,5 +98,10 @@ public class ITopographyNodeServiceImpl implements ITopographyNodeService{
return nodeDao.findById(id);
}
@Override
public List<TopographyNode> getNodesByType(String type) {
return nodeDao.findByType(type);
}
}
......@@ -197,5 +197,26 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
return list;
}
@Override
public List<TreeSubjectVo> getTextPlanBySubjectId(String appId) {
//关联文字预案
List<TreeSubjectVo> subjectVos = new ArrayList<>();
List<TextPlan> textPlans = iTextPlanDao.findByAppId(appId);
textPlans.forEach(t -> {
TreeSubjectVo textTreeSubjectVo = new TreeSubjectVo();
textTreeSubjectVo.setParentId(String.valueOf(t.getAppId()));
textTreeSubjectVo.setTreeName(t.getTextName());
textTreeSubjectVo.setId(String.valueOf(t.getId()));
textTreeSubjectVo.setType("textNode");
subjectVos.add(textTreeSubjectVo);
});
return subjectVos;
}
@Override
public void deleteTextPlanFile(Long id) {
iTextPlanDao.delete(id);
}
}
......@@ -36,4 +36,8 @@ public interface IPlanVisual3dService {
List<Map<String,Object>> getResourceById(String type,Long id);
List<Map<String,Object>> getResourceTypeList();
List<TreeSubjectVo> getTextPlanBySubjectId(String appId);
void deleteTextPlanFile(Long id);
}
......@@ -12,4 +12,6 @@ public interface ITopographyLineService {
public void deleteLine(String id);
public List<TopographyLine> getLinesByType(String type);
}
......@@ -23,4 +23,6 @@ public interface ITopographyNodeService {
public TopographyNode queryById(String id);
public List<TopographyNode> getNodesByType(String type);
}
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