Browse Source

no message

贾艺驰 4 years ago
parent
commit
94168bb6fa

+ 3 - 2
base/src/main/java/com/api/base/config/auth/handler/GoAuthenticationSuccessHandler.java

@@ -11,6 +11,7 @@ import org.springframework.security.core.Authentication;
 import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
 import org.springframework.stereotype.Component;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.Console;
@@ -21,7 +22,6 @@ import java.util.Map;
 @Component
 public class GoAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
 
-
     private JwtTokenUtil jwtTokenUtil;
 
     public GoAuthenticationSuccessHandler(JwtTokenUtil jwtTokenUtil) {
@@ -38,7 +38,8 @@ public class GoAuthenticationSuccessHandler implements AuthenticationSuccessHand
         String jwtToken = jwtTokenUtil.generateToken(userDetails.getUsername());
         System.out.println(jwtToken);
         userDetails.setPassword("");
-        res.put("info",userDetails);
+
+        res.put("info", userDetails);
         res.put("token", jwtToken);
 
         Result result = ResultGenerator.genResultAndData(ResultEnum.LOGIN_SUCCESS,res);

+ 12 - 27
games/src/main/java/com/api/games/controller/GameLogController.java

@@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
+import java.text.NumberFormat;
 import java.util.*;
 
 
@@ -159,6 +160,9 @@ public class GameLogController extends Ctrl {
                 cellRowName.setCellStyle(columnTopStyle); // 设置列头单元格样式
             }
 
+            NumberFormat ddf1 = NumberFormat.getNumberInstance() ;
+            ddf1.setMaximumFractionDigits(2);
+
             // 将查询出的数据设置到sheet对应的单元格中
             for (int i = 0; i < rowCount; i++) {
                 XSSFRow row = sheet.createRow(i + 2);   // 创建所需的行数
@@ -239,11 +243,11 @@ public class GameLogController extends Ctrl {
                                     if (itemSize == 0){
                                         text = gameAnswer.getShowNum().toString();
                                     }else if(itemSize == 1){
-                                        text = gameAnswer.getAnswer() == 1 ? "按下" : "沒按下";
+                                        text = gameAnswer.getAnswer() == 1 ? "press" : "N-press";
                                     }else if(itemSize == 2){
-                                        text = gameAnswer.getCorrect() == 1 ? "正確" : gameAnswer.getCorrect() == 2 ? "錯誤" : "錯失";
+                                        text = gameAnswer.getCorrect() == 1 ? "true" : gameAnswer.getCorrect() == 2 ? "false" : "omission";
                                     }else if(itemSize == 3){
-                                        text = gameAnswer.getReaction().floatValue() + "ms";
+                                        text = ddf1.format(gameAnswer.getReaction().floatValue());
                                     }
                                 }
                                 break;
@@ -258,30 +262,11 @@ public class GameLogController extends Ctrl {
 
             // 让列宽随着导出的列长自动适应
             for (int colNum = 0; colNum <= column; colNum++) {
-                int columnWidth = sheet.getColumnWidth(colNum) / 256;
-                for (int rowNum = 0; rowNum < sheet.getLastRowNum(); rowNum++) {
-                    XSSFRow currentRow;
-                    // 当前行未被使用过
-                    if (sheet.getRow(rowNum) == null) {
-                        currentRow = sheet.createRow(rowNum);
-                    } else {
-                        currentRow = sheet.getRow(rowNum);
-                    }
-                    if (currentRow.getCell(colNum) != null) {
-                        XSSFCell currentCell = currentRow.getCell(colNum);
-                        if (currentCell.getCellType() == CellType.STRING) {
-                            int length = currentCell.getStringCellValue()
-                                    .getBytes().length;
-                            if (columnWidth < length) {
-                                columnWidth = length;
-                            }
-                        }
-                    }
-                }
-                if (colNum == 0) {
-                    sheet.setColumnWidth(colNum, (columnWidth - 2) * 256);
-                } else {
-                    sheet.setColumnWidth(colNum, (columnWidth + 4) * 256);
+                int colWidth = sheet.getColumnWidth(colNum) * 2;
+                if(colWidth < 255 * 256){
+                    sheet.setColumnWidth(colNum, colWidth < 3000 ? 3000 : colWidth);
+                }else{
+                    sheet.setColumnWidth(colNum,6000);
                 }
             }
             workbook.write(out);

+ 7 - 26
games/src/main/java/com/api/games/controller/PushLogController.java

@@ -107,8 +107,8 @@ public class PushLogController extends Ctrl {
     }
 
     @PostMapping(value = "/delay/game", name = "推迟游戏")
-    public Result delay(@RequestParam Long gamePlayTimeId, @RequestParam Long gameConfigId, @RequestParam int delayMin, @RequestParam String deviceId){
-        return pushLogService.delayGame(gamePlayTimeId, gameConfigId, delayMin, deviceId);
+    public Result delay(@RequestParam Long gamePlayTimeId, @RequestParam Long gameConfigId, @RequestParam int delayMin, @RequestParam String deviceId, @RequestParam Boolean trueDelay){
+        return pushLogService.delayGame(gamePlayTimeId, gameConfigId, delayMin, deviceId, trueDelay);
     }
 
     @PostMapping(value = "/delay/scale", name = "推迟量表")
@@ -239,30 +239,11 @@ public class PushLogController extends Ctrl {
 
             // 让列宽随着导出的列长自动适应
             for (int colNum = 0; colNum <= column; colNum++) {
-                int columnWidth = sheet.getColumnWidth(colNum) / 256;
-                for (int rowNum = 0; rowNum < sheet.getLastRowNum(); rowNum++) {
-                    XSSFRow currentRow;
-                    // 当前行未被使用过
-                    if (sheet.getRow(rowNum) == null) {
-                        currentRow = sheet.createRow(rowNum);
-                    } else {
-                        currentRow = sheet.getRow(rowNum);
-                    }
-                    if (currentRow.getCell(colNum) != null) {
-                        XSSFCell currentCell = currentRow.getCell(colNum);
-                        if (currentCell.getCellType() == CellType.STRING) {
-                            int length = currentCell.getStringCellValue()
-                                    .getBytes().length;
-                            if (columnWidth < length) {
-                                columnWidth = length;
-                            }
-                        }
-                    }
-                }
-                if (colNum == 0) {
-                    sheet.setColumnWidth(colNum, (columnWidth - 2) * 256);
-                } else {
-                    sheet.setColumnWidth(colNum, (columnWidth + 4) * 256);
+                int colWidth = sheet.getColumnWidth(colNum) * 2;
+                if(colWidth < 255 * 256){
+                    sheet.setColumnWidth(colNum, colWidth < 3000 ? 3000 : colWidth);
+                }else{
+                    sheet.setColumnWidth(colNum,6000);
                 }
             }
             workbook.write(out);

+ 17 - 36
games/src/main/java/com/api/games/controller/ScaleLogController.java

@@ -72,32 +72,32 @@ public class ScaleLogController extends Ctrl {
         AuthUser authUser = (AuthUser) authentication.getPrincipal();
         ScaleLog scaleLog = new ScaleLog();
         scaleLog.setUserId(authUser.getId());
-        int success = 0;
-        if(contact != null && !contact.equals("")){
+        float success = 0;
+        if(contact != null && !contact.equals("沒做")){
             success += 1;
             scaleLog.setContact(contact);
         } else
-            scaleLog.setContact("沒做");
-        if(dinner != null && !dinner.equals("")){
+            scaleLog.setContact("0");
+        if(dinner != null && !dinner.equals("沒做")){
             success += 1;
             scaleLog.setDinner(dinner);
         } else
-            scaleLog.setDinner("沒做");
-        if(getUp != null && !getUp.equals("")){
+            scaleLog.setDinner("0");
+        if(getUp != null && !getUp.equals("沒做")){
             success += 1;
             scaleLog.setGetUp(getUp);
         } else
-            scaleLog.setGetUp("沒做");
-        if(sleep != null && !sleep.equals("")){
+            scaleLog.setGetUp("0");
+        if(sleep != null && !sleep.equals("沒做")){
             success += 1;
             scaleLog.setSleep(sleep);
         } else
-            scaleLog.setSleep("沒做");
-        if(work !=null && !work.equals("")){
+            scaleLog.setSleep("0");
+        if(work !=null && !work.equals("沒做")){
             success += 1;
             scaleLog.setWork(work);
         } else
-            scaleLog.setWork("沒做");
+            scaleLog.setWork("0");
         scaleLog.setSchedule(BigDecimal.valueOf(success == 0 ? 1 : success / 5));
         scaleLog.setStartDate(UtilFun.StringToDate(startDate, UtilFun.YYYYMMDDHHMMSS));
         scaleLog.setCreateDate(UtilFun.StringToDate(endDate, UtilFun.YYYYMMDDHHMMSS));
@@ -158,7 +158,7 @@ public class ScaleLogController extends Ctrl {
             }
         }
         //计算完成度
-        scaleLog.setSchedule(BigDecimal.valueOf( success / 5));
+        scaleLog.setSchedule(BigDecimal.valueOf( success / 5f));
         scaleLogService.save(scaleLog);
         return ResultGenerator.genSuccessResult();
     }
@@ -356,30 +356,11 @@ public class ScaleLogController extends Ctrl {
 
             // 让列宽随着导出的列长自动适应
             for (int colNum = 0; colNum <= column; colNum++) {
-                int columnWidth = sheet.getColumnWidth(colNum) / 256;
-                for (int rowNum = 0; rowNum < sheet.getLastRowNum(); rowNum++) {
-                    XSSFRow currentRow;
-                    // 当前行未被使用过
-                    if (sheet.getRow(rowNum) == null) {
-                        currentRow = sheet.createRow(rowNum);
-                    } else {
-                        currentRow = sheet.getRow(rowNum);
-                    }
-                    if (currentRow.getCell(colNum) != null) {
-                        XSSFCell currentCell = currentRow.getCell(colNum);
-                        if (currentCell.getCellType() == CellType.STRING) {
-                            int length = currentCell.getStringCellValue()
-                                    .getBytes().length;
-                            if (columnWidth < length) {
-                                columnWidth = length;
-                            }
-                        }
-                    }
-                }
-                if (colNum == 0) {
-                    sheet.setColumnWidth(colNum, (columnWidth - 2) * 256);
-                } else {
-                    sheet.setColumnWidth(colNum, (columnWidth + 4) * 256);
+                int colWidth = sheet.getColumnWidth(colNum) * 2;
+                if(colWidth < 255 * 256){
+                    sheet.setColumnWidth(colNum, colWidth < 3000 ? 3000 : colWidth);
+                }else{
+                    sheet.setColumnWidth(colNum,6000);
                 }
             }
             workbook.write(out);

+ 7 - 26
games/src/main/java/com/api/games/controller/UserConfigController.java

@@ -256,11 +256,11 @@ public class UserConfigController extends Ctrl {
                                 break;
                             }
                             case 4: {
-                                text = res.get(i).get("scaleStart").toString();
+                                text = res.get(i).get("scaleStart").toString().split(" ")[1];
                                 break;
                             }
                             case 5: {
-                                text = res.get(i).get("scaleEnd").toString();
+                                text = res.get(i).get("scaleEnd").toString().split(" ")[1];
                                 break;
                             }
                             case 6: {
@@ -320,30 +320,11 @@ public class UserConfigController extends Ctrl {
 
             // 让列宽随着导出的列长自动适应
             for (int colNum = 0; colNum <= column; colNum++) {
-                int columnWidth = sheet.getColumnWidth(colNum) / 256;
-                for (int rowNum = 0; rowNum < sheet.getLastRowNum(); rowNum++) {
-                    XSSFRow currentRow;
-                    // 当前行未被使用过
-                    if (sheet.getRow(rowNum) == null) {
-                        currentRow = sheet.createRow(rowNum);
-                    } else {
-                        currentRow = sheet.getRow(rowNum);
-                    }
-                    if (currentRow.getCell(colNum) != null) {
-                        XSSFCell currentCell = currentRow.getCell(colNum);
-                        if (currentCell.getCellType() == CellType.STRING) {
-                            int length = currentCell.getStringCellValue()
-                                    .getBytes().length;
-                            if (columnWidth < length) {
-                                columnWidth = length;
-                            }
-                        }
-                    }
-                }
-                if (colNum == 0) {
-                    sheet.setColumnWidth(colNum, (columnWidth - 2) * 256);
-                } else {
-                    sheet.setColumnWidth(colNum, (columnWidth + 4) * 256);
+                int colWidth = sheet.getColumnWidth(colNum) * 2;
+                if(colWidth < 255 * 256){
+                    sheet.setColumnWidth(colNum, colWidth < 3000 ? 3000 : colWidth);
+                }else{
+                    sheet.setColumnWidth(colNum,6000);
                 }
             }
             workbook.write(out);

+ 1 - 0
games/src/main/java/com/api/games/dao/mapper/GamePlayTimeMapper.xml

@@ -6,6 +6,7 @@
         <result column="uid" jdbcType="BIGINT" property="uid" />
         <result column="game_time" jdbcType="VARCHAR" property="gameTime" />
         <result column="type" jdbcType="INTEGER" property="type" />
+        <result column="delay" jdbcType="INTEGER" property="delay" />
     </resultMap>
     <delete id="deleteUid">
       delete from game_play_time where uid = #{uid}

+ 13 - 0
games/src/main/java/com/api/games/dao/mapper/PushLogMapper.xml

@@ -36,5 +36,18 @@
       <if test="params.type!=null and params.type!=''">
         and push_log.type = #{params.type}
       </if>
+      order by 1
+      <if test="order.nickname!=null">
+        ,u.nickname #{order.nickname}
+      </if>
+      <if test="order.pushTime!=null">
+        ,pushTime #{order.pushTime}
+      </if>
+      <if test="order.status!=null">
+        ,status #{order.status}
+      </if>
+      <if test="order.type!=null">
+        ,type #{order.type}
+      </if>
     </select>
 </mapper>

+ 1 - 0
games/src/main/java/com/api/games/model/GameConfig.java

@@ -18,6 +18,7 @@ public class GameConfig implements Serializable {
     @Column(name = "end_time")
     private String endTime;
 
+    @Column(name = "uid")
     private Long uid;
 
     @Column(name = "message_id")

+ 11 - 0
games/src/main/java/com/api/games/model/GamePlayTime.java

@@ -16,6 +16,7 @@ public class GamePlayTime implements Serializable {
         this.uid = uid;
         this.gameTime = gameTime;
         this.type = type;
+        this.delay = 0;
     }
 
     @Id
@@ -30,6 +31,8 @@ public class GamePlayTime implements Serializable {
     @Column(name = "type")
     private Integer type;
 
+    private Integer delay;
+
     public Long getUid() {
         return uid;
     }
@@ -57,4 +60,12 @@ public class GamePlayTime implements Serializable {
     public Long getId() {
         return id;
     }
+
+    public Integer getDelay() {
+        return delay;
+    }
+
+    public void setDelay(Integer delay) {
+        this.delay = delay;
+    }
 }

+ 7 - 0
games/src/main/java/com/api/games/result/GameInfoResult.java

@@ -1,5 +1,10 @@
 package com.api.games.result;
 
+import com.api.common.UtilFun;
+
+import java.util.Calendar;
+import java.util.Date;
+
 public class GameInfoResult {
 
     public static final int GAME_VERSION_ONE = 1;
@@ -20,6 +25,8 @@ public class GameInfoResult {
     public long practiseDuration; //用戶熱身時長
     public int practiseRightNumber;
     public int practiseOccurrenceNumber;//用戶熱身數字出現次數
+    public String date = UtilFun.DateToString(Calendar.getInstance().getTime(), UtilFun.YYYYMMDDHHMMSS);
+    public int delay = 0;
 
     public static int convertVersion(String version){
         if (version.equals("A"))

+ 1 - 1
games/src/main/java/com/api/games/service/PushLogService.java

@@ -20,7 +20,7 @@ public interface PushLogService extends Service<PushLog> {
 
     List<Map<String, Object>> download(String search, String order);
 
-    Result delayGame(Long gamePlayTimeId, Long gameConfigId, int delayMin, String deviceId);
+    Result delayGame(Long gamePlayTimeId, Long gameConfigId, int delayMin, String deviceId, Boolean trueDelay);
 
     Result delayScale(Long gamePlayTimeId, int delayMin, String deviceId);
 

+ 13 - 6
games/src/main/java/com/api/games/service/impl/GameLogServiceImpl.java

@@ -21,6 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.sql.Timestamp;
+import java.text.NumberFormat;
 import java.util.*;
 
 
@@ -157,26 +158,32 @@ public class GameLogServiceImpl extends AbstractService<GameLog> implements Game
             Map<String, Object> gameLog = gameLogs.get(i);
             item.nickName = gameLog.get("nickname").toString();
 
+            NumberFormat ddf1 = NumberFormat.getNumberInstance() ;
+            ddf1.setMaximumFractionDigits(2);
+
             Date date = new Date(((Timestamp) gameLog.get("startTime")).getTime());
             Date endDate = new Date(((Timestamp) gameLog.get("endTime")).getTime());
             item.date = UtilFun.DateToString(date, UtilFun.YMD);
             item.sign = gameLog.get("sign").toString();
             item.version = gameLog.get("version").toString();
-            item.rightRate = (((BigDecimal)gameLog.get("realCorrectRate")).setScale(2, BigDecimal.ROUND_HALF_UP).floatValue() * 100) + "%";
-            item.right = (((BigDecimal)gameLog.get("correctRate")).setScale(2, BigDecimal.ROUND_HALF_UP).floatValue() * 100) + "%";
-            item.trust = (((BigDecimal)gameLog.get("confidence")).setScale(2, BigDecimal.ROUND_HALF_UP).floatValue() * 100) + "%";
+            item.rightRate = ddf1.format(((BigDecimal)gameLog.get("realCorrectRate")).setScale(2, BigDecimal.ROUND_HALF_UP).floatValue() * 100);
+            item.right = ddf1.format(((BigDecimal)gameLog.get("correctRate")).setScale(2, BigDecimal.ROUND_HALF_UP).floatValue() * 100);
+            item.trust = ddf1.format(((BigDecimal)gameLog.get("confidence")).setScale(2, BigDecimal.ROUND_HALF_UP).floatValue() * 100);
             item.startTime = UtilFun.DateToString(date, UtilFun.HHMMSS);
             item.finishTime = UtilFun.DateToString(endDate, UtilFun.HHMMSS);
             item.finish =  (((BigDecimal)gameLog.get("schedule")).setScale(2, BigDecimal.ROUND_HALF_UP).floatValue() * 100) + "%";
             item.deviceId = gameLog.get("deviceId").toString();
             item.number = gameLog.get("selected").toString();
 
+
+
             item.gameAnswers = gameAnswerMapper.listByGameIdNew(((Long)gameLog.get("id")).intValue());
 
-            item.wrongRate = (getRate(item.gameAnswers, 2) * 100) + "%";
-            item.missRate = (getRate(item.gameAnswers, 3) * 100) + "%";
 
-            item.reaction = getAvgReaction(item.gameAnswers) + " ms";
+            item.wrongRate =  ddf1.format(getRate(item.gameAnswers, 2) * 100);
+            item.missRate = ddf1.format(getRate(item.gameAnswers, 3) * 100);
+
+            item.reaction = ddf1.format(getAvgReaction(item.gameAnswers));
 
             result.add(item);
         }

+ 50 - 47
games/src/main/java/com/api/games/service/impl/PushLogServiceImpl.java

@@ -146,22 +146,23 @@ public class PushLogServiceImpl extends AbstractService<PushLog> implements Push
 
                     //量表逻辑处理
                     Calendar startDate = Calendar.getInstance();
-                    startDate.set(Calendar.HOUR_OF_DAY, 0);
-                    startDate.set(Calendar.MINUTE, 0);
-                    startDate.set(Calendar.SECOND, 0);
-                    startDate.set(Calendar.MILLISECOND, 0);
+                    startDate.add(Calendar.HOUR_OF_DAY, -2);
                     Calendar endDate = Calendar.getInstance();
                     List<GamePlayTime> gamePlayTime = gamePlayTimeMapper.getScalePlayTime(userId, simpleDateFormatScale.format(startDate.getTime()), simpleDateFormatScale.format(endDate.getTime()));
                     if (gamePlayTime != null && gamePlayTime.size() > 0){
                         GamePlayTime playTime = gamePlayTime.get(0);
-                        if (pushedThreeTimes(playTime.getId()))
+                        if (playTime.getDelay() > 3)
                             return ResultGenerator.genSuccessResult(result);
 
                         System.out.println(userId + "此用户需要做量表");
 
+                        result.delay = playTime.getDelay();
                         result.needDoGame = true;
                         result.playGameType = 1;
                         result.playGameId = playTime.getId();
+                        Calendar today = Calendar.getInstance();
+                        today.add(Calendar.DATE, -1);
+                        result.date = UtilFun.DateToString(today.getTime(), UtilFun.YYYYMMDDHHMMSS);
 
                         return ResultGenerator.genSuccessResult(result);
                     }
@@ -177,46 +178,44 @@ public class PushLogServiceImpl extends AbstractService<PushLog> implements Push
     @Override
     public Result delayScale(Long gamePlayTimeId, int delayMin, String deviceId) {
         if (gamePlayTimeId != null){
-            if (pushedThreeTimes(gamePlayTimeId)){
-                return new Result("已經推遲過三次,請盡快完成量表");
-            }else{
-                GamePlayTime gamePlayTime = gamePlayTimeMapper.selectByPrimaryKey(gamePlayTimeId);
-
-                Calendar playCalendar = Calendar.getInstance();
-                Date playDate = UtilFun.StringToDate(gamePlayTime.getGameTime(), UtilFun.YYYYMMDDHHMMSS);
-                if (playDate != null) {
-                    playCalendar.setTime(playDate);
-                    Calendar newTime = Calendar.getInstance();
-                    newTime.add(Calendar.MINUTE, delayMin);
-                    if (newTime.get(Calendar.DAY_OF_YEAR) != playCalendar.get(Calendar.DAY_OF_YEAR)){
-                        return new Result("無法推遲相應時間,請盡快完成量表");
-                    }else{
-                        PushLog pushLog = new PushLog();
+            GamePlayTime gamePlayTime = gamePlayTimeMapper.selectByPrimaryKey(gamePlayTimeId);
+
+            Calendar playCalendar = Calendar.getInstance();
+            Date playDate = UtilFun.StringToDate(gamePlayTime.getGameTime(), UtilFun.YYYYMMDDHHMMSS);
+            if (playDate != null) {
+                playCalendar.setTime(playDate);
+                Calendar newTime = Calendar.getInstance();
+                newTime.add(Calendar.MINUTE, delayMin);
+                if (newTime.get(Calendar.DAY_OF_YEAR) != playCalendar.get(Calendar.DAY_OF_YEAR) && delayMin != 0){
+                    return new Result("無法推遲相應時間,請盡快完成量表");
+                }else{
+                    PushLog pushLog = new PushLog();
+                    pushLog.setPushTime(new Date());
+                    pushLog.setUid(gamePlayTime.getUid());
+                    pushLog.setType(2);
+                    pushLog.setDeviceId(deviceId);
+                    pushLog.setMsgId(gamePlayTimeId + "");
+                    pushLog.setStatus(ConstUser.PUSH_DELAY);
+                    pushLogMapper.insert(pushLog);
+                    gamePlayTime.setGameTime(UtilFun.DateToString(newTime.getTime(), UtilFun.YYYYMMDDHHMMSS));
+                    gamePlayTime.setDelay(gamePlayTime.getDelay() + 1);
+                    gamePlayTimeMapper.updateByPrimaryKey(gamePlayTime);
+
+                    if (gamePlayTime.getDelay() > 3){
+                        pushLog = new PushLog();
                         pushLog.setPushTime(new Date());
                         pushLog.setUid(gamePlayTime.getUid());
                         pushLog.setType(2);
                         pushLog.setDeviceId(deviceId);
                         pushLog.setMsgId(gamePlayTimeId + "");
-                        pushLog.setStatus(ConstUser.PUSH_DELAY);
+                        pushLog.setStatus(ConstUser.PUSH_NO);
                         pushLogMapper.insert(pushLog);
-                        gamePlayTime.setGameTime(UtilFun.DateToString(newTime.getTime(), UtilFun.YYYYMMDDHHMMSS));
-                        gamePlayTimeMapper.updateByPrimaryKey(gamePlayTime);
-
-                        if (pushedThreeTimes(gamePlayTimeId)){
-                            pushLog = new PushLog();
-                            pushLog.setPushTime(new Date());
-                            pushLog.setUid(gamePlayTime.getUid());
-                            pushLog.setType(2);
-                            pushLog.setDeviceId(deviceId);
-                            pushLog.setMsgId(gamePlayTimeId + "");
-                            pushLog.setStatus(ConstUser.PUSH_NO);
-                            pushLogMapper.insert(pushLog);
-                        }
-
-                        return ResultGenerator.genSuccessResult();
                     }
+
+                    return ResultGenerator.genSuccessResult();
                 }
             }
+
         }
 
         return ResultGenerator.genFailResult();
@@ -237,7 +236,7 @@ public class PushLogServiceImpl extends AbstractService<PushLog> implements Push
     }
 
     @Override
-    public Result delayGame(Long gamePlayTimeId, Long gameConfigId, int delayMin, String deviceId) {
+    public Result delayGame(Long gamePlayTimeId, Long gameConfigId, int delayMin, String deviceId, Boolean trueDelay) {
         if (gamePlayTimeId != null && gameConfigId != null){
             GamePlayTime gamePlayTime = gamePlayTimeMapper.selectByPrimaryKey(gamePlayTimeId);
             GameConfig gameConfig = gameConfigMapper.selectByPrimaryKey(gameConfigId);
@@ -267,16 +266,20 @@ public class PushLogServiceImpl extends AbstractService<PushLog> implements Push
                         gamePlayTimeMapper.updateByPrimaryKey(gamePlayTime);
                         return ResultGenerator.genSuccessResult();
                     }else {
-                        PushLog pushLog = new PushLog();
-                        pushLog.setPushTime(new Date());
-                        pushLog.setUid(gameConfig.getUid());
-                        pushLog.setType(1);
-                        pushLog.setDeviceId(deviceId);
-                        pushLog.setMsgId(gamePlayTimeId + "");
-                        pushLog.setStatus(ConstUser.PUSH_NO);
-                        pushLogMapper.insert(pushLog);
-                        gamePlayTimeMapper.deleteByPrimaryKey(gamePlayTime.getId());
-                        return new Result("你選擇的延遲的時間點已超過該時間段結束前10分鐘,該時間段結束前10分鐘,將停止推送,無法進入該時間段的測試");
+                        if(trueDelay) {
+                            PushLog pushLog = new PushLog();
+                            pushLog.setPushTime(new Date());
+                            pushLog.setUid(gameConfig.getUid());
+                            pushLog.setType(1);
+                            pushLog.setDeviceId(deviceId);
+                            pushLog.setMsgId(gamePlayTimeId + "");
+                            pushLog.setStatus(ConstUser.PUSH_NO);
+                            pushLogMapper.insert(pushLog);
+                            gamePlayTimeMapper.deleteByPrimaryKey(gamePlayTime.getId());
+                            return ResultGenerator.genSuccessResult();
+                        }else{
+                            return new Result("1");
+                        }
                     }
 
 

+ 2 - 0
games/src/main/java/com/api/games/service/impl/ScaleLogServiceImpl.java

@@ -75,7 +75,9 @@ public class ScaleLogServiceImpl extends AbstractService<ScaleLog> implements Sc
 
         PageHelper.startPage(page, size);
         List<Map<String, Object>> res = scaleLogMapper.list(params, order);
+
         PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(res);
+
         return ResultGenerator.genSuccessResult(pageInfo);
     }
 

+ 41 - 5
games/src/main/java/com/api/games/service/impl/UserConfigServiceImpl.java

@@ -108,6 +108,10 @@ public class UserConfigServiceImpl extends AbstractService<UserConfig> implement
 
         List<GameConfig> gameConfigs = JSONUtils.json2list(configs, GameConfig.class);
 
+        for (GameConfig gameConfig : gameConfigs)
+            if (lessThan20Minute(gameConfig))
+                return new Result("时间间隔必须大于20分钟");
+
         user.setType(ConstUser.USER_NORMAL);
         user.setCreateTime(new Date());
         user.setUsername(user.getNickname());
@@ -363,8 +367,21 @@ public class UserConfigServiceImpl extends AbstractService<UserConfig> implement
         return ResultGenerator.genSuccessResult();
     }
 
+    private boolean lessThan20Minute(GameConfig gameConfig){
+        try {
+            Calendar scaleStartCalendar = Calendar.getInstance();
+            scaleStartCalendar.setTime(sdfScaleDate.parse(gameConfig.getStartTime()));
+            Calendar scaleEndCalendar = Calendar.getInstance();
+            scaleEndCalendar.setTime(sdfScaleDate.parse(gameConfig.getEndTime()));
+
+            return scaleEndCalendar.getTimeInMillis() - scaleStartCalendar.getTimeInMillis() < 20 * 60 * 1000;
+        } catch (Exception e){
+            return true;
+        }
+    }
+
     private List<GamePlayTime> generateGamePlayTime(long uid, String scaleStart, String scaleEnd, String startTime, String endTime){
-        List<GamePlayTime> result = new ArrayList<>();
+        List<GamePlayTime> result = new ArrayList<GamePlayTime>();
         try {
             Calendar scaleStartCalendar = Calendar.getInstance();
             scaleStartCalendar.setTime(sdfScaleDate.parse(scaleStart));
@@ -375,7 +392,7 @@ public class UserConfigServiceImpl extends AbstractService<UserConfig> implement
                 result.add(new GamePlayTime(uid, sdfScaleDate.format(mergeDate(scaleStartCalendar, getRandomTime(sdfGameTime.parse(startTime), sdfGameTime.parse(endTime))).getTime()), GamePlayTime.TYPE_GAME));
             else
                 while (before(scaleStartCalendar, scaleEndCalendar)){
-                    result.add(new GamePlayTime(uid, sdfScaleDate.format(mergeDate(scaleStartCalendar, getRandomTime(sdfGameTime.parse(startTime), sdfGameTime.parse(endTime))).getTime()), GamePlayTime.TYPE_GAME));
+                    result.add(new GamePlayTime(uid, sdfScaleDate.format(mergeDate(scaleStartCalendar, getRandomTime(sdfGameTime.parse(startTime), sdfGameTime.parse(endTime), 10 * 60 * 1000)).getTime()), GamePlayTime.TYPE_GAME));
                     scaleStartCalendar.add(Calendar.DATE, 1);
                 }
         } catch (Exception e){
@@ -420,18 +437,37 @@ public class UserConfigServiceImpl extends AbstractService<UserConfig> implement
     }
 
     private boolean before(Calendar left, Calendar right){
-        return left.get(Calendar.YEAR) <= right.get(Calendar.YEAR)
-            && left.get(Calendar.MONTH) <= right.get(Calendar.MONTH)
-            && left.get(Calendar.DAY_OF_MONTH) <= right.get(Calendar.DAY_OF_MONTH);
+        if (left.get(Calendar.YEAR) < right.get(Calendar.YEAR))
+            return true;
+        else if (left.get(Calendar.YEAR) > right.get(Calendar.YEAR))
+            return false;
+        else{
+            if (left.get(Calendar.MONTH) < right.get(Calendar.MONTH))
+                return true;
+            else if(left.get(Calendar.MONTH) > right.get(Calendar.MONTH))
+                return false;
+            else{
+                if (left.get(Calendar.DAY_OF_MONTH) <= right.get(Calendar.DAY_OF_MONTH))
+                    return true;
+                else
+                    return false;
+            }
+        }
     }
 
     private Date getRandomTime(Date startTime, Date endTime){
+        return getRandomTime(startTime, endTime, 0);
+    }
+
+    private Date getRandomTime(Date startTime, Date endTime, long diff){
         Long startL = startTime.getTime();
         Long endL = endTime.getTime();
 
         Date middle;
         if (startL.longValue() != endL.longValue()) {
             long middleL = (long) (startL + (endL - startL) * Math.random());
+            if (diff != 0 && endL - middleL < diff)
+                return getRandomTime(startTime, endTime, diff);
             middle = new Date(middleL);
         }else
             middle = startTime;