|
@@ -1,22 +1,26 @@
|
|
|
package com.izouma.meta.web;
|
|
package com.izouma.meta.web;
|
|
|
|
|
|
|
|
import com.izouma.meta.config.Constants;
|
|
import com.izouma.meta.config.Constants;
|
|
|
|
|
+import com.izouma.meta.repo.MetaObjectMoveRepo;
|
|
|
import com.izouma.meta.websocket.MMOWebSocket;
|
|
import com.izouma.meta.websocket.MMOWebSocket;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.*;
|
|
import java.util.concurrent.*;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
|
@RequestMapping("/mmo/websocket")
|
|
@RequestMapping("/mmo/websocket")
|
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
|
|
|
+@CrossOrigin(origins = {"http://localhost:8081", "https://raex.vip", "https://test.raex.vip"})
|
|
|
public class MMOWebSocketController {
|
|
public class MMOWebSocketController {
|
|
|
|
|
|
|
|
- private MMOWebSocket mmoWebSocket;
|
|
|
|
|
|
|
+ private MMOWebSocket mmoWebSocket;
|
|
|
|
|
+ private MetaObjectMoveRepo metaObjectMoveRepo;
|
|
|
|
|
|
|
|
private final Map<String, ScheduledFuture<?>> tasks = new ConcurrentHashMap<>();
|
|
private final Map<String, ScheduledFuture<?>> tasks = new ConcurrentHashMap<>();
|
|
|
|
|
|
|
@@ -44,4 +48,28 @@ public class MMOWebSocketController {
|
|
|
mmoWebSocket.onMessage(Constants.META_ROBOT_NICK_NAME, Constants.META_ROBOT_USER_ID, String.format(Constants.META_ROBOT_MESSAGE_BODY, objectId), null);
|
|
mmoWebSocket.onMessage(Constants.META_ROBOT_NICK_NAME, Constants.META_ROBOT_USER_ID, String.format(Constants.META_ROBOT_MESSAGE_BODY, objectId), null);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/check")
|
|
|
|
|
+ public synchronized String check() {
|
|
|
|
|
+ List<Long> objectId = metaObjectMoveRepo.findAllRunningObjectId();
|
|
|
|
|
+ if (CollectionUtils.isEmpty(objectId)) {
|
|
|
|
|
+ if (tasks.isEmpty()) {
|
|
|
|
|
+ return "success";
|
|
|
|
|
+ }
|
|
|
|
|
+ return String.format("物体: %s 未结束广播坐标任务,请联系管理员处理", String.join(",", tasks.keySet()));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (tasks.isEmpty()) {
|
|
|
|
|
+ return String.format("物体: %s 未开启广播坐标任务,请联系管理员处理", objectId.stream().map(Object::toString).collect(Collectors.toList()));
|
|
|
|
|
+ }
|
|
|
|
|
+ StringBuffer str = new StringBuffer();
|
|
|
|
|
+ objectId.forEach(id -> {
|
|
|
|
|
+ if (!tasks.containsKey(String.valueOf(id))) {
|
|
|
|
|
+ str.append(",").append(id);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ if (StringUtils.isNotBlank(str)) {
|
|
|
|
|
+ return String.format("物体: %s 未开启广播坐标任务,请联系管理员处理", str);
|
|
|
|
|
+ }
|
|
|
|
|
+ return "success";
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|