|
@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
@Component
|
|
|
@Slf4j
|
|
@@ -30,27 +31,69 @@ public abstract class GeneralDataStrategy implements MessageStrategy {
|
|
|
|
|
|
Map<Integer, InterferPlatform> InterferMap = dataManager.getMap(InterferPlatform.class);
|
|
|
Map<Integer, RadarPlatform> radarMap = dataManager.getMap(RadarPlatform.class);
|
|
|
- if(InterferMap.containsKey(from) && InterferMap.containsKey(to)){
|
|
|
- clazz= InterferPlatform.class;
|
|
|
- }else if(radarMap.containsKey(from) && radarMap.containsKey(to)){
|
|
|
- clazz = RadarPlatform.class;
|
|
|
+
|
|
|
+ boolean interferFlag = false;
|
|
|
+ boolean radarFlag = false;
|
|
|
+
|
|
|
+ if(InterferMap.get(from) != null){
|
|
|
+ interferFlag = "合作条件".equals(InterferMap.get(from).getCooperationStatus());
|
|
|
}
|
|
|
- else {
|
|
|
- return false;
|
|
|
+ if(radarMap.get(from) != null){
|
|
|
+ radarFlag = "合作条件".equals(radarMap.get(from).getCooperationStatus());
|
|
|
}
|
|
|
+ if(interferFlag || radarFlag){
|
|
|
+ Platform fromPlat = null;
|
|
|
+ Platform toPlat = null;
|
|
|
|
|
|
- Platform fromPlat = dataManager.getData(clazz,from);
|
|
|
- Platform toPlat = dataManager.getData(clazz,to);
|
|
|
+ if (InterferMap.containsKey(from)) {
|
|
|
+ fromPlat = dataManager.getData(InterferPlatform.class,from);
|
|
|
+ } else if (radarMap.containsKey(from)) {
|
|
|
+ fromPlat = dataManager.getData(RadarPlatform.class,from);
|
|
|
+ }
|
|
|
|
|
|
- if(fromPlat != null && toPlat != null
|
|
|
- && fromPlat.isGrouped() && toPlat.isGrouped()
|
|
|
- && fromPlat.getGroupId().equals(toPlat.getGroupId())){
|
|
|
- NetworkGroup networkGroup = dataManager.getData(NetworkGroup.class, fromPlat.getGroupId());
|
|
|
- return networkGroup.addHistoryMsg(message);
|
|
|
- }
|
|
|
- else {
|
|
|
- log.error("消息不合法"+message);
|
|
|
- return false;
|
|
|
+ if (InterferMap.containsKey(to)) {
|
|
|
+ toPlat = dataManager.getData(InterferPlatform.class,to);
|
|
|
+ } else if (radarMap.containsKey(to)) {
|
|
|
+ toPlat = dataManager.getData(RadarPlatform.class,to);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(fromPlat != null && toPlat != null
|
|
|
+ && fromPlat.isGrouped() && toPlat.isGrouped()
|
|
|
+ && fromPlat.getGroupId().equals(toPlat.getGroupId())){
|
|
|
+ NetworkGroup networkGroup = dataManager.getData(NetworkGroup.class, fromPlat.getGroupId());
|
|
|
+ return networkGroup.addHistoryMsg(message);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ log.error("消息不合法"+message);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if(InterferMap.containsKey(from) && InterferMap.containsKey(to)){
|
|
|
+ clazz= InterferPlatform.class;
|
|
|
+ }else if(radarMap.containsKey(from) && radarMap.containsKey(to)){
|
|
|
+ clazz = RadarPlatform.class;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ Platform fromPlat = dataManager.getData(clazz,from);
|
|
|
+ Platform toPlat = dataManager.getData(clazz,to);
|
|
|
+
|
|
|
+ if(fromPlat != null && toPlat != null
|
|
|
+ && fromPlat.isGrouped() && toPlat.isGrouped()
|
|
|
+ && fromPlat.getGroupId().equals(toPlat.getGroupId())){
|
|
|
+ NetworkGroup networkGroup = dataManager.getData(NetworkGroup.class, fromPlat.getGroupId());
|
|
|
+ return networkGroup.addHistoryMsg(message);
|
|
|
+ } else if (fromPlat != null && toPlat != null && Objects.equals(fromPlat.getParams().getTeamID(), toPlat.getParams().getTeamID())) {
|
|
|
+ NetworkGroup networkGroup = dataManager.getData(NetworkGroup.class, fromPlat.getGroupId());
|
|
|
+ if(message.getFrom().equals(networkGroup.getMainStation()) && message.getTo().equals(networkGroup.getMainStation())){
|
|
|
+ return networkGroup.addHistoryMsg(message);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("消息不合法"+message);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return false;
|