Explorar el Código

自主游戏规则

kk hace 1 semana
padre
commit
1ff7f2819f

+ 16 - 5
game-business/src/main/java/com/game/business/task/AppGameHanaderTask.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.game.business.domain.AppGame;
 import com.game.business.service.IAppGameService;
 import com.game.business.websocket.server.WebSocketServer;
+import com.game.common.utils.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.scheduling.annotation.Async;
@@ -32,18 +33,28 @@ public class AppGameHanaderTask {
             return;
         }
 
-        AppGame appGame = appGameService.selectAppGameByCode(gameCode);
+        int countdown = 59;
 
-        if(appGame == null) return;
-
-        int countdown = 60;
+        boolean isStart = false;
 
         JSONObject jsonObject = new JSONObject();
 
         while (true){
 
-            try {
+            AppGame appGame = appGameService.selectAppGameByCode(gameCode);
+            if(appGame == null) return;
+
+            String ss = DateUtils.dateTimeNow(DateUtils.SS);
+            int miao = Integer.parseInt(ss);
 
+            try {
+                if(!isStart){
+                    if(miao != 0){
+                        isStart = true;
+                        Thread.sleep(1000L);
+                        continue;
+                    }
+                }
                 // 推送倒计时
                 jsonObject.put("type", "1");
                 jsonObject.put("countDown", countdown);

+ 1 - 0
game-common/src/main/java/com/game/common/utils/DateUtils.java

@@ -27,6 +27,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
 
     public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
+    public static String SS = "ss";
 
     private static String[] parsePatterns = {
             "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",