|
@@ -1,9 +1,13 @@
|
|
|
package com.dc.datachange.networkGroup.controller;
|
|
|
|
|
|
+import com.dc.datachange.core.entity.NetworkGroup;
|
|
|
+import com.dc.datachange.core.entity.graph.EdgeVo;
|
|
|
+import com.dc.datachange.core.entity.graph.NodeVo;
|
|
|
import com.dc.datachange.core.entity.platformInfo.InterferPlatform;
|
|
|
import com.dc.datachange.core.entity.platformInfo.Platform;
|
|
|
import com.dc.datachange.core.entity.platformInfo.RadarPlatform;
|
|
|
import com.dc.datachange.core.exchange.DataManager;
|
|
|
+import com.dc.datachange.core.exchange.SendExecutor;
|
|
|
import com.dc.datachange.exception.IllegalTypeException;
|
|
|
import com.dc.datachange.exception.NameDuplicatedException;
|
|
|
import com.dc.datachange.exception.NetworkCreateException;
|
|
@@ -21,12 +25,16 @@ import java.util.List;
|
|
|
import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import static com.dc.datachange.utils.MessageUtils.getEdgesFromPlatform;
|
|
|
+
|
|
|
@RestController
|
|
|
@Slf4j
|
|
|
@RequestMapping("/network")
|
|
|
public class NetworkController {
|
|
|
@Autowired
|
|
|
private DataManager dataManager;
|
|
|
+ @Autowired
|
|
|
+ private SendExecutor sendExecutor;
|
|
|
|
|
|
@GetMapping("allGroup")
|
|
|
public R getAllGroup() {
|
|
@@ -75,6 +83,10 @@ public class NetworkController {
|
|
|
|
|
|
@GetMapping("delete")
|
|
|
public R deleteNetworkGroup(@RequestParam Integer id) {
|
|
|
+ NetworkGroup data = dataManager.getData(NetworkGroup.class, id);
|
|
|
+ if(data.getPlatformSet()!=null){
|
|
|
+ deleteNetworkParams(id);
|
|
|
+ }
|
|
|
if (dataManager.deleteData(NetworkGroup.class, id)) {
|
|
|
return R.ok();
|
|
|
} else {
|
|
@@ -116,6 +128,7 @@ public class NetworkController {
|
|
|
networkGroup.getPlatformSet().forEach(x->x.grouped(null));
|
|
|
networkGroup.setPlatformSet(collect);
|
|
|
collect.forEach(x->x.grouped(networkGroup.getId()));
|
|
|
+ sendExecutor.sendNetGroupMsg();
|
|
|
return R.ok();
|
|
|
}
|
|
|
else{
|
|
@@ -129,6 +142,7 @@ public class NetworkController {
|
|
|
return R.error(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
+ sendExecutor.sendNetGroupMsg();
|
|
|
return R.ok();
|
|
|
} else return R.error("目标网络组不存在");
|
|
|
}
|
|
@@ -139,6 +153,7 @@ public class NetworkController {
|
|
|
networkGroup.setParams(null);
|
|
|
networkGroup.getPlatformSet().forEach(x->x.grouped(null));
|
|
|
networkGroup.setPlatformSet(new HashSet<>());
|
|
|
+ sendExecutor.sendNetGroupMsg();
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
@@ -158,165 +173,32 @@ public class NetworkController {
|
|
|
}
|
|
|
@GetMapping("/getInterferChartInfo")
|
|
|
public R getInterferChartInfo(){
|
|
|
- List<NodeVo> nodes = dataManager.getInterferPlatforms().stream()
|
|
|
+ List<NodeVo> nodes = dataManager.getAllData(InterferPlatform.class).stream()
|
|
|
.map(x -> new NodeVo(x.getId(), x.getId()))
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
List<EdgeVo> edgeList =new ArrayList<>();
|
|
|
- for(NetworkGroup networkGroup: dataManager.getNetworkGroups()){
|
|
|
+ for(NetworkGroup networkGroup: dataManager.getAllData(NetworkGroup.class)){
|
|
|
if(networkGroup.getType().equals("interference")) {
|
|
|
- getEdgesFromGroup(edgeList, networkGroup);
|
|
|
+ getEdgesFromPlatform(edgeList, networkGroup.getPlatformSet());
|
|
|
}
|
|
|
}
|
|
|
return R.ok().put("nodes",nodes).put("edges",edgeList);
|
|
|
}
|
|
|
@GetMapping("/getRadarChartInfo")
|
|
|
public R getRadarChartInfo(){
|
|
|
- List<NodeVo> nodes = dataManager.getRadarPlatforms().stream()
|
|
|
+ List<NodeVo> nodes = dataManager.getAllData(RadarPlatform.class).stream()
|
|
|
.map(x -> new NodeVo(x.getId(), x.getId()))
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
List<EdgeVo> edgeList =new ArrayList<>();
|
|
|
- for(NetworkGroup networkGroup: dataManager.getNetworkGroups()){
|
|
|
+ for(NetworkGroup networkGroup: dataManager.getAllData(NetworkGroup.class)){
|
|
|
if(networkGroup.getType().equals("radar")) {
|
|
|
- getEdgesFromGroup(edgeList, networkGroup);
|
|
|
+ getEdgesFromPlatform(edgeList, networkGroup.getPlatformSet());
|
|
|
}
|
|
|
}
|
|
|
return R.ok().put("nodes",nodes).put("edges",edgeList);
|
|
|
}
|
|
|
|
|
|
- private void getEdgesFromGroup(List<EdgeVo> edgeList, NetworkGroup networkGroup) {
|
|
|
- List<Platform> list = new ArrayList<>(networkGroup.getPlatformSet());
|
|
|
- int size = list.size();
|
|
|
- for(int i=0;i<size-1;i++){
|
|
|
- for(int j=i+1;j<size;j++){
|
|
|
- edgeList.add(new EdgeVo(list.get(i).getId(),list.get(j).getId()));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-//
|
|
|
-// @PostMapping("update")
|
|
|
-// public R updateNetworkGroup(@RequestParam Map<String, Object> params){
|
|
|
-// String name = params.get("name").toString();
|
|
|
-// String type = params.get("type").toString();
|
|
|
-// String mainStation = params.get("mainStation").toString();
|
|
|
-// String communication = params.get("communication").toString();
|
|
|
-// // 修改列表中的对象
|
|
|
-// for (NetworkGroup networkGroup: networkGroupList){
|
|
|
-// if(networkGroup.getName().equals(name) && networkGroup.getType().equals(type)){
|
|
|
-// networkGroup.setMainStation(mainStation);
|
|
|
-// networkGroup.setCommunication(communication);
|
|
|
-// //获取station数组,用于配置参数的链路设置,如果更新为enable,就加入list中
|
|
|
-// addStation(type, communication, mainStation, name);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// return R.ok();
|
|
|
-// }
|
|
|
-//
|
|
|
-// @PostMapping("delete")
|
|
|
-// public R deleteNetworkGroup(@RequestBody NetworkGroup networkGroup){
|
|
|
-// networkGroupList.removeIf(group -> group.getId() == networkGroup.getId());
|
|
|
-// idList.removeIf(map -> map.get("value").equals(networkGroup.getId()));
|
|
|
-// radarStationList.removeIf(sourceStation -> sourceStation.get("name").equals(networkGroup.getMainStation()));
|
|
|
-// interferenceStationList.removeIf(targetStation -> targetStation.get("name").equals(networkGroup.getMainStation()));
|
|
|
-// return R.ok();
|
|
|
-// }
|
|
|
-//
|
|
|
-// @GetMapping("paramsList")
|
|
|
-// public R paramsList(@RequestParam(defaultValue = "1") int page,
|
|
|
-// @RequestParam(defaultValue = "10") int limit){
|
|
|
-//
|
|
|
-// System.out.println("networkParamsList" + networkParamsList);
|
|
|
-// // 计算总记录数
|
|
|
-// int totalCount = networkParamsList.size();
|
|
|
-//
|
|
|
-// // 计算分页数据
|
|
|
-// int fromIndex = (page - 1) * limit;
|
|
|
-// int toIndex = Math.min(fromIndex + limit, totalCount);
|
|
|
-// List<NetworkParams> paginatedList = networkParamsList.subList(fromIndex, toIndex);
|
|
|
-//
|
|
|
-// // 创建 PageUtils 实例
|
|
|
-// PageUtils page1 = new PageUtils(paginatedList, totalCount, limit, page);
|
|
|
-//
|
|
|
-// return R.ok().put("page", page1);
|
|
|
-// }
|
|
|
-// @PostMapping("addParam")
|
|
|
-// public R addNetworkParam(@RequestParam Map<String, Object> params){
|
|
|
-// String link = params.get("link").toString();
|
|
|
-// int groupId = Integer.parseInt(params.get("groupId").toString());
|
|
|
-// String parameter = params.get("parameter").toString();
|
|
|
-// String sourceStation = params.get("sourceStation").toString();
|
|
|
-// String targetStation = params.get("targetStation").toString();
|
|
|
-// for (NetworkParams networkParam: networkParamsList){
|
|
|
-// if(networkParam.getLink().equals(link) && networkParam.getGroupId() == groupId){
|
|
|
-// return R.error("链路已存在");
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// NetworkParams networkParam = new NetworkParams();
|
|
|
-// networkParam.setGroupId(groupId);
|
|
|
-// networkParam.setLink(link);
|
|
|
-// networkParam.setParameter(parameter);
|
|
|
-// networkParam.setSourceStation(sourceStation);
|
|
|
-// networkParam.setTargetStation(targetStation);
|
|
|
-// networkParamsList.add(networkParam);
|
|
|
-// return R.ok();
|
|
|
-// }
|
|
|
-//
|
|
|
-// @PostMapping("updateParam")
|
|
|
-// public R updateNetworkParam(@RequestParam Map<String, Object> params){
|
|
|
-// String link = params.get("link").toString();
|
|
|
-// int groupId = Integer.parseInt(params.get("groupId").toString());
|
|
|
-// String parameter = params.get("parameter").toString();
|
|
|
-// String sourceStation = params.get("sourceStation").toString();
|
|
|
-// String targetStation = params.get("targetStation").toString();
|
|
|
-// // 修改列表中的对象
|
|
|
-// for (NetworkParams networkParam: networkParamsList){
|
|
|
-// if(networkParam.getLink().equals(link) && networkParam.getGroupId() == groupId){
|
|
|
-// return R.error("链路已存在");
|
|
|
-// }
|
|
|
-// if(networkParam.getGroupId() == groupId){
|
|
|
-// networkParam.setLink(link);
|
|
|
-// networkParam.setParameter(parameter);
|
|
|
-// networkParam.setSourceStation(sourceStation);
|
|
|
-// networkParam.setTargetStation(targetStation);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// return R.ok();
|
|
|
-// }
|
|
|
-//
|
|
|
-// @PostMapping("deleteParam")
|
|
|
-// public R deleteNetworkParam(@RequestBody int id){
|
|
|
-// networkParamsList.removeIf(networkParams -> networkParams.getId() == id);
|
|
|
-// return R.ok();
|
|
|
-// }
|
|
|
-//
|
|
|
-// //添加主站
|
|
|
-// private void addStation(String type, String communication, String mainStation, String groupName) {
|
|
|
-// // 检查 communication 是否为 "enabled"
|
|
|
-// if ("enabled".equals(communication)) {
|
|
|
-// Map<String, Object> stationMap = new HashMap<>();
|
|
|
-// stationMap.put("name", mainStation);
|
|
|
-// stationMap.put("groupName", groupName);
|
|
|
-//
|
|
|
-// // 根据 type 将 stationMap 添加到相应的列表中
|
|
|
-// if ("radar".equals(type)) {
|
|
|
-// // 检查是否已存在于 radarStationList 中
|
|
|
-// if (!isStationExists(radarStationList, mainStation)) {
|
|
|
-// radarStationList.add(stationMap);
|
|
|
-// }
|
|
|
-// } else if ("interference".equals(type)) {
|
|
|
-// // 检查是否已存在于 interferenceStationList 中
|
|
|
-// if (!isStationExists(interferenceStationList, mainStation)) {
|
|
|
-// interferenceStationList.add(stationMap);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 辅助方法:检查站点是否已存在
|
|
|
-// private boolean isStationExists(List<Map<String, Object>> stationList, String mainStation) {
|
|
|
-// return stationList.stream()
|
|
|
-// .anyMatch(station -> mainStation.equals(station.get("name")));
|
|
|
-// }
|
|
|
+
|
|
|
}
|