zsy 1 жил өмнө
parent
commit
6fa6ca8bca

+ 2 - 2
src/main/java/com/rf/kjb/chat/rest/ChatController.java

@@ -132,9 +132,9 @@ public class ChatController extends BaseController {
                     questionEntity = this.questionService.findByIdAndLabelAndNum("9", label, num);
                 }else if (score <= -20 && score > -40){
                     questionEntity = this.questionService.findByIdAndLabelAndNum("7", label, num);
-                }else if (score <= 0 && score > -20){
+                }else if (score <= -1 && score > -20){
                     questionEntity = this.questionService.findByIdAndLabelAndNum("5", label, num);
-                }else if (score <= 20 && score > 0){
+                }else if (score <= 20 && score > -1){
                     questionEntity = this.questionService.findByIdAndLabelAndNum("4", label, num);
                 }else if (score <= 40 && score > 20){
                     questionEntity = this.questionService.findByIdAndLabelAndNum("6", label, num);

+ 29 - 10
src/main/java/com/rf/kjb/scale/dao/model/GameRecordEntity.java

@@ -24,13 +24,13 @@ import javax.persistence.Table;
 @DynamicUpdate
 public class GameRecordEntity extends BaseEntry {
 
-    @Column(name = "identifier" ,columnDefinition = "varchar(20) not null  comment '编号'")
-    private String identifier;
+    @Column(name = "type" ,columnDefinition = "varchar(2) not null  comment '1是单人模式 2是双人模式'")
+    private String type;
 
     @Column(name = "game_scene",columnDefinition = "varchar(255) not null comment '游戏场景'")
     private String gameScene;
 
-    @Column(name = "equipment_type",columnDefinition = "varchar(10) not null comment '设备类型'")
+    @Column(name = "equipment_type",columnDefinition = "varchar(10) not null comment '设备类型:心电、脑电'")
     private String equipmentType;
 
     @Column(name = "game_difficulty",columnDefinition = "varchar(20) not null comment '游戏难度'")
@@ -39,15 +39,34 @@ public class GameRecordEntity extends BaseEntry {
     @Column(name = "game_time",columnDefinition = "varchar(20) not null comment '游戏时间'")
     private String gameTime;
 
-    @Column(name = "animation_source_list",columnDefinition = "text not null comment '原始数据'")
-    private String animationSourceList;
+    @Column(name = "target_type" ,columnDefinition = "varchar(10) not null  comment '选择的指标'")
+    private String targetType;
 
-    @Column(name = "animation_target",columnDefinition = "text not null comment '指标数据'")
-    private String animationTarget;
+    @Column(name = "num1",columnDefinition = "varchar(20) not null comment '第一个人的编号'")
+    private String num1;
 
-    @Column(name = "save_time",columnDefinition = "varchar(50) not null comment '保存指标时间'")
+    @Column(name = "num2",columnDefinition = "varchar(20) null comment '第二个人的编号'")
+    private String num2;
+
+    @Column(name = "animation_source_list1",columnDefinition = "text not null comment '第一个人的原始数据'")
+    private String animationSourceList1;
+
+    @Column(name = "animation_source_list2",columnDefinition = "text null comment '第二个人的原始数据'")
+    private String animationSourceList2;
+
+    @Column(name = "animation_target1",columnDefinition = "text not null comment '显示指标数据1'")
+    private String animationTarget1;
+
+    @Column(name = "animation_target2",columnDefinition = "text null comment '显示指标数据2'")
+    private String animationTarget2;
+
+    @Column(name = "file_name1",columnDefinition = "varchar(100) not null comment '文件名1'")
+    private String fileName1;
+
+    @Column(name = "file_name2",columnDefinition = "varchar(100) null comment '文件名2'")
+    private String fileName2;
+
+    @Column(name = "saveTime" ,columnDefinition = "varchar(50) not null  comment '保存数据的时间'")
     private String saveTime;
 
-    @Column(name = "file_name",columnDefinition = "varchar(100) not null comment '文件名'")
-    private String fileName;
 }

+ 1 - 1
src/main/java/com/rf/kjb/scale/rest/DataDownloadController.java

@@ -1742,7 +1742,7 @@ public class DataDownloadController {
         return wb;
     }*/
 
-    private static void deleteDirectoryStream(Path path) {
+    public static void deleteDirectoryStream(Path path) {
         try {
             Files.delete(path);
             //System.out.printf("删除文件成功:%s%n",path.toString());

+ 269 - 2
src/main/java/com/rf/kjb/scale/rest/GameRecordController.java

@@ -1,17 +1,35 @@
 package com.rf.kjb.scale.rest;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.rf.kjb.base.rest.BaseController;
 import com.rf.kjb.scale.dao.model.GameRecordEntity;
+import com.rf.kjb.scale.dao.model.RecordEntity;
 import com.rf.kjb.scale.service.GameRecordService;
+import com.rf.kjb.utils.Constant;
 import com.rf.kjb.utils.Result;
+import com.rf.kjb.utils.ZipUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.io.FileUtils;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.text.SimpleDateFormat;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Stream;
+
 /**
  * @Author:zzf
  * @Date:2023/6/7:09:55
@@ -28,14 +46,263 @@ public class GameRecordController extends BaseController {
     @PostMapping("/save")
     public Result save(@RequestBody String json){
         GameRecordEntity gameRecordEntity = JSONObject.parseObject(json).toJavaObject(GameRecordEntity.class);
+        gameRecordEntity.setCreateTime(new Date());
         this.gameRecordService.save(gameRecordEntity);
         return success();
     }
 
-    @ApiOperation(value = "查询",notes = "id:游戏记录id;identifier:编号;gameScene:游戏场景;equipmentType:设备类型;gameDifficulty:游戏难度;gameTime:游戏时间;fileName:文件名;pageNum:页数,默认1;pageSize:每页记录数,默认10")
-    @GetMapping("/find")
+    @ApiOperation(value = "查询",notes = "id:游戏记录id;type:1是单人模式 2是双人模式;num1:编号;gameScene:游戏场景;equipmentType:设备类型;gameDifficulty:游戏难度;gameTime:游戏时间;startDate:开始时间;endDate:结束时间;pageNum:页数,默认1;pageSize:每页记录数,默认10")
+    @PostMapping("/find")
     public Result find(@RequestBody String json){
         Page<GameRecordEntity> page = this.gameRecordService.find(json);
         return success(page);
     }
+
+    @ApiOperation(value = "原始信号单个和批量下载")
+    @GetMapping("/download/originalSignal")
+    public String downloadOriginalSignal(@RequestParam(value = "ids", required = false) List<String> recordingIds, HttpServletResponse response) throws Exception {
+        //原始记录文件
+        File file1 = null;
+        File file2 = null;
+        //原始记录复制后文件
+        File destFile1 = null;
+        File destFile2 = null;
+        //所有记录汇总后文件夹,用来压缩
+        String filePath ="./心理检测/生物反馈原始信号";
+        //原始记录文件存放路径
+        String userHome = System.getProperty("user.home");
+        for (int i = 0; i < recordingIds.size(); i++) {
+            GameRecordEntity gameRecordEntity = this.gameRecordService.findById(recordingIds.get(i));
+            if (gameRecordEntity != null){
+                file1 = new File(userHome+"/rzgy/"+gameRecordEntity.getFileName1()+".txt");
+                if (file1.exists()){
+                    destFile1 = new File(filePath+"/"+gameRecordEntity.getNum1()+"/"+gameRecordEntity.getSaveTime()+"/"+gameRecordEntity.getFileName1()+".txt");
+                    //将原始文件进行复制
+                    FileUtils.copyFile(file1, destFile1);
+                }
+                if (gameRecordEntity.getFileName2() != null && !gameRecordEntity.getFileName2().equals("")){
+                    file2 = new File(userHome+"/rzgy/"+gameRecordEntity.getFileName2()+".txt");
+                    if (file2.exists()){
+                        destFile2 = new File(filePath+"/"+gameRecordEntity.getNum1()+"/"+gameRecordEntity.getSaveTime()+"/"+gameRecordEntity.getFileName2()+".txt");
+                        //将原始文件进行复制
+                        FileUtils.copyFile(file2, destFile2);
+                    }
+                }
+            }
+        }
+        //将复制后的整个文件夹打包
+        ZipUtils.createZip(filePath, filePath + ".zip", true);
+        File zipFile = new File(filePath + ".zip");
+        //下载压缩后文件
+        if (zipFile.exists()) {
+            return com.rf.kjb.utils.FileUtils.downloadFile(zipFile,filePath,"originalSignal"+new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date())+".zip",response);
+        }
+        return "下载失败";
+    }
+
+    @ApiOperation(value = "原始信号全部下载",notes = "id:游戏记录id;type:1是单人模式 2是双人模式;num1:编号;gameScene:游戏场景;equipmentType:设备类型;gameDifficulty:游戏难度;gameTime:游戏时间;startDate:开始时间;endDate:结束时间;pageNum:页数,默认1;pageSize:每页记录数,默认10")
+    @PostMapping("/download/originalSignalAll")
+    public String downloadOriginalSignalAll(@RequestBody String json, HttpServletResponse response) throws IOException {
+        Page<GameRecordEntity> page = this.gameRecordService.find(json);
+        List<GameRecordEntity> gameRecordEntityList = page.getContent();
+        //原始记录文件
+        File file1 = null;
+        File file2 = null;
+        //原始记录复制后文件
+        File destFile1 = null;
+        File destFile2 = null;
+        //所有记录汇总后文件夹,用来压缩
+        String filePath ="./心理检测/生物反馈原始信号";
+        //原始记录文件存放路径
+        String userHome = System.getProperty("user.home");
+        for (int i = 0; i < gameRecordEntityList.size(); i++) {
+            GameRecordEntity gameRecordEntity = gameRecordEntityList.get(i);
+            if (gameRecordEntity != null){
+                file1 = new File(userHome+"/rzgy/"+gameRecordEntity.getFileName1()+".txt");
+                if (file1.exists()){
+                    destFile1 = new File(filePath+"/"+gameRecordEntity.getNum1()+"/"+gameRecordEntity.getSaveTime()+"/"+gameRecordEntity.getFileName1()+".txt");
+                    //将原始文件进行复制
+                    FileUtils.copyFile(file1, destFile1);
+                }
+                if (gameRecordEntity.getFileName2() != null && !gameRecordEntity.getFileName2().equals("")){
+                    file2 = new File(userHome+"/rzgy/"+gameRecordEntity.getFileName2()+".txt");
+                    if (file2.exists()){
+                        destFile2 = new File(filePath+"/"+gameRecordEntity.getNum1()+"/"+gameRecordEntity.getSaveTime()+"/"+gameRecordEntity.getFileName2()+".txt");
+                        //将原始文件进行复制
+                        FileUtils.copyFile(file2, destFile2);
+                    }
+                }
+            }
+        }
+        //将复制后的整个文件夹打包
+        ZipUtils.createZip(filePath, filePath + ".zip", true);
+        File zipFile = new File(filePath + ".zip");
+        //下载压缩后文件
+        if (zipFile.exists()) {
+            return com.rf.kjb.utils.FileUtils.downloadFile(zipFile,filePath,"originalSignal"+new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date())+".zip",response);
+        }
+        return "下载失败";
+    }
+
+    @ApiOperation(value = "生物反馈训练记录单个下载")
+    @GetMapping("/download/trainingRecord")
+    public String downloadTrainingRecord(String id, HttpServletResponse response) throws IOException {
+        if (id != null) {
+            GameRecordEntity gameRecordEntity = this.gameRecordService.findById(id);
+            if (gameRecordEntity == null){
+                return "该记录异常,下载失败";
+            }
+            String destFileName ="./心理检测/生物反馈记录/"+new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
+            String destFileName2 = destFileName+"/"+gameRecordEntity.getNum1()+"-"+new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date())+".xlsx";
+            createFile(gameRecordEntity,destFileName2);
+            File file = new File(destFileName2);
+            return com.rf.kjb.utils.FileUtils.downloadFile(file,destFileName,file.getName(),response);
+        }
+        return "下载失败";
+    }
+
+    @ApiOperation(value = "生物反馈训练记录批量下载")
+    @GetMapping("/download/trainingRecords")
+    public String downloadTrainingRecords(@RequestParam(value = "ids", required = false) List<String> recordingIds, HttpServletResponse response) throws Exception {
+        String destFileName ="./心理检测/生物反馈记录/"+new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
+        for (int i = 0; i < recordingIds.size(); i++) {
+            GameRecordEntity gameRecordEntity = this.gameRecordService.findById(recordingIds.get(i));
+            if (gameRecordEntity != null){
+                String destFileName2 = destFileName+"/"+gameRecordEntity.getNum1()+"-"+new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date())+".xlsx";
+                createFile(gameRecordEntity,destFileName2);
+            }
+        }
+        //将复制后的整个文件夹打包
+        ZipUtils.createZip(destFileName, destFileName + ".zip", true);
+        File zipFile = new File(destFileName + ".zip");
+        //下载压缩后文件
+        if (zipFile.exists()) {
+            return com.rf.kjb.utils.FileUtils.downloadFile(zipFile,destFileName,"trainingRecord"+new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date())+".zip",response);
+        }
+        return "下载失败";
+    }
+
+    @ApiOperation(value = "生物反馈训练记录全部下载",notes = "id:游戏记录id;type:1是单人模式 2是双人模式;num1:编号;gameScene:游戏场景;equipmentType:设备类型;gameDifficulty:游戏难度;gameTime:游戏时间;startDate:开始时间;endDate:结束时间;pageNum:页数,默认1;pageSize:每页记录数,默认10")
+    @PostMapping("/download/trainingRecordsAll")
+    public String downloadTrainingRecordsAll(@RequestBody String json, HttpServletResponse response) throws IOException {
+        String destFileName ="./心理检测/生物反馈记录/"+new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
+        Page<GameRecordEntity> page = this.gameRecordService.find(json);
+        List<GameRecordEntity> gameRecordEntityList = page.getContent();
+        for (int i = 0; i < gameRecordEntityList.size(); i++) {
+            GameRecordEntity gameRecordEntity = gameRecordEntityList.get(i);
+            if (gameRecordEntity != null){
+                String destFileName2 = destFileName+"/"+gameRecordEntity.getNum1()+"-"+new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date())+".xlsx";
+                createFile(gameRecordEntity,destFileName2);
+            }
+        }
+        //将复制后的整个文件夹打包
+        ZipUtils.createZip(destFileName, destFileName + ".zip", true);
+        File zipFile = new File(destFileName + ".zip");
+        //下载压缩后文件
+        if (zipFile.exists()) {
+            return com.rf.kjb.utils.FileUtils.downloadFile(zipFile,destFileName,"trainingRecord"+new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date())+".zip",response);
+        }
+        return "下载失败";
+    }
+
+    public static Workbook createExcelFile(Workbook wb,GameRecordEntity gameRecordEntity,String []title,JSONArray jsonData,String type) {
+        String num;
+        //1:单人获取num1;2双人获取num2
+        if (type.equals("1")) {
+            num = gameRecordEntity.getNum1();
+        }else {
+            num = gameRecordEntity.getNum2();
+        }
+        Sheet downSheet = wb.createSheet(num);
+        //获取表头行
+        Row titleRow = downSheet.createRow(0);
+        //创建单元格,设置style居中,字体,单元格大小等
+        CellStyle style = wb.createCellStyle();
+        //设置水平对齐的样式为居中对齐;
+        style.setAlignment(HorizontalAlignment.CENTER);
+        //设置垂直对齐的样式为居中对齐;
+        style.setVerticalAlignment(VerticalAlignment.CENTER);
+        Cell cell;
+        //把已经写好的标题行写入excel文件中
+        for (int k = 0; k < title.length; k++) {
+            cell = titleRow.createCell(k);
+            cell.setCellValue(title[k]);
+            cell.setCellStyle(style);
+        }
+        Row row = downSheet.createRow(1);
+        row.createCell(0).setCellValue(num);
+        row.createCell(1).setCellValue(gameRecordEntity.getGameScene());
+        row.createCell(2).setCellValue(gameRecordEntity.getEquipmentType());
+        row.createCell(3).setCellValue(gameRecordEntity.getTargetType());
+        row.createCell(4).setCellValue(gameRecordEntity.getGameDifficulty());
+        row.createCell(5).setCellValue(gameRecordEntity.getGameTime());
+        for (int m = 0; m < jsonData.size(); m++) {
+            if (m == 0){
+                row.createCell(6).setCellValue(jsonData.getDoubleValue(m));
+            }else {
+                Row row2 = downSheet.createRow(m + 1);
+                row2.createCell(6).setCellValue(jsonData.getDoubleValue(m));
+            }
+        }
+        return wb;
+    }
+
+    public static void createFile(GameRecordEntity gameRecordEntity,String destFileName2) throws IOException {
+        Workbook wb = new XSSFWorkbook();
+        String []title;
+        title = new String[7];
+        title[0] = "用户编号";
+        String [] temp = {"场景名称","设备类型","所选指标","游戏难度","游戏时长"};
+        System.arraycopy(temp,0,title,1,temp.length);
+        if(gameRecordEntity.getEquipmentType().equals("心电")){
+            title[6] = "heartRate";
+        }else{
+            if (gameRecordEntity.getTargetType().equals("专注度")){
+                title[6] = "attention";
+            }else {
+                title[6] = "meditation";
+            }
+        }
+
+        JSONArray jsonData ;
+        JSONArray jsonData2 ;
+        if(gameRecordEntity.getType().equals("1")){
+            if(gameRecordEntity.getEquipmentType().equals("心电")){
+                jsonData = JSONObject.parseArray(gameRecordEntity.getAnimationTarget1());
+            }else {
+                if (gameRecordEntity.getTargetType().equals("专注度")){
+                    jsonData = JSONObject.parseObject(gameRecordEntity.getAnimationSourceList1()).getJSONArray("attentionDataAll");
+                }else {
+                    jsonData = JSONObject.parseObject(gameRecordEntity.getAnimationSourceList1()).getJSONArray("meditationDataAll");
+                }
+            }
+            wb = createExcelFile(wb,gameRecordEntity,title,jsonData,"1");
+        }else {
+            if(gameRecordEntity.getEquipmentType().equals("心电")){
+                jsonData = JSONObject.parseArray(gameRecordEntity.getAnimationTarget1());
+                jsonData2 = JSONObject.parseArray(gameRecordEntity.getAnimationTarget2());
+            }else {
+                if (gameRecordEntity.getTargetType().equals("专注度")){
+                    jsonData = JSONObject.parseObject(gameRecordEntity.getAnimationSourceList1()).getJSONArray("attentionDataAll");
+                    jsonData2 = JSONObject.parseObject(gameRecordEntity.getAnimationSourceList2()).getJSONArray("attentionDataAll");
+                }else {
+                    jsonData = JSONObject.parseObject(gameRecordEntity.getAnimationSourceList1()).getJSONArray("meditationDataAll");
+                    jsonData2 = JSONObject.parseObject(gameRecordEntity.getAnimationSourceList2()).getJSONArray("meditationDataAll");
+                }
+            }
+            wb = createExcelFile(wb,gameRecordEntity,title,jsonData,"1");
+            wb = createExcelFile(wb,gameRecordEntity,title,jsonData2,"2");
+
+        }
+        File destFile = new File(destFileName2);
+        File fileParent = destFile.getParentFile();
+        if(!fileParent.exists()){
+            fileParent.mkdirs();
+        }
+        destFile.createNewFile();
+        OutputStream fileOut = Files.newOutputStream(destFile.toPath());
+        wb.write(fileOut);
+        fileOut.close();
+    }
+
 }

+ 2 - 0
src/main/java/com/rf/kjb/scale/service/GameRecordService.java

@@ -7,4 +7,6 @@ public interface GameRecordService {
     void save(GameRecordEntity gameRecordEntity);
 
     Page<GameRecordEntity> find(String json);
+
+    GameRecordEntity findById(String id);
 }

+ 30 - 7
src/main/java/com/rf/kjb/scale/service/impl/GameRecordServiceImpl.java

@@ -13,7 +13,10 @@ import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 
 import javax.persistence.criteria.Predicate;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -42,13 +45,14 @@ public class GameRecordServiceImpl implements GameRecordService {
         if(jsonObject.containsKey("pageSize")&&jsonObject.getIntValue("pageSize")>0){
             pageSize = jsonObject.getIntValue("pageSize");
         }
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         Specification<RecordPhyEntry> specification = (root, query, cb) -> {
             List<Predicate> predicateList = new ArrayList<>();
             if(jsonObject.containsKey("id")&& StringUtils.isNotBlank(jsonObject.getString("id"))){
                 predicateList.add(cb.equal(root.get("id"),jsonObject.getString("id")));
             }
-            if(jsonObject.containsKey("identifier") && StringUtils.isNotBlank(jsonObject.getString("identifier"))){
-                predicateList.add(cb.equal(root.get("identifier"),jsonObject.getString("identifier")));
+            if(jsonObject.containsKey("num1") && StringUtils.isNotBlank(jsonObject.getString("num1"))){
+                predicateList.add(cb.like(root.get("num1"),"%"+jsonObject.getString("num1")+"%"));
             }
             if(jsonObject.containsKey("gameScene") && StringUtils.isNotBlank(jsonObject.getString("gameScene"))){
                 predicateList.add(cb.equal(root.get("gameScene"),jsonObject.getString("gameScene")));
@@ -56,19 +60,38 @@ public class GameRecordServiceImpl implements GameRecordService {
             if(jsonObject.containsKey("equipmentType") && StringUtils.isNotBlank(jsonObject.getString("equipmentType"))){
                 predicateList.add(cb.equal(root.get("equipmentType"),jsonObject.getString("equipmentType")));
             }
-            if(jsonObject.containsKey("fileName") && StringUtils.isNotBlank(jsonObject.getString("fileName"))){
-                predicateList.add(cb.like(root.get("fileName"),"%"+jsonObject.getString("fileName")+"%"));
+            if(jsonObject.containsKey("gameDifficulty") && StringUtils.isNotBlank(jsonObject.getString("gameDifficulty"))){
+                predicateList.add(cb.like(root.get("gameDifficulty"),jsonObject.getString("gameDifficulty")));
             }
-            if(jsonObject.containsKey("gameDifficulty")){
-                predicateList.add(cb.equal(root.get("gameDifficulty"),jsonObject.getString("gameDifficulty")));
+            if(jsonObject.containsKey("type") && StringUtils.isNotBlank(jsonObject.getString("type"))){
+                predicateList.add(cb.equal(root.get("type"),jsonObject.getString("type")));
             }
-            if(jsonObject.containsKey("gameTime")){
+            if(jsonObject.containsKey("gameTime") && StringUtils.isNotBlank(jsonObject.getString("gameTime"))){
                 predicateList.add(cb.equal(root.get("gameTime"),jsonObject.getString("gameTime")));
             }
+            if(jsonObject.containsKey("startDate") && StringUtils.isNotBlank(jsonObject.getString("startDate"))){
+                try {
+                    predicateList.add(cb.greaterThanOrEqualTo(root.get("createTime"),simpleDateFormat.parse(jsonObject.getString("startDate")+" 00:00:00")));
+                } catch (ParseException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+            if(jsonObject.containsKey("endDate") && StringUtils.isNotBlank(jsonObject.getString("endDate"))){
+                try {
+                    predicateList.add(cb.lessThanOrEqualTo(root.get("createTime"),simpleDateFormat.parse(jsonObject.getString("endDate")+" 23:59:59")));
+                } catch (ParseException e) {
+                    throw new RuntimeException(e);
+                }
+            }
             query.where(cb.and(predicateList.toArray(new Predicate[0])));
             query.orderBy(cb.desc(root.get("saveTime")));
             return query.getRestriction();
         };
         return this.gameRecordRepository.findAll(specification, PageRequest.of(pageNum-1,pageSize));
     }
+
+    @Override
+    public GameRecordEntity findById(String id) {
+        return this.gameRecordRepository.findById(id).get();
+    }
 }