Просмотр исходного кода

1、管理员登录查询量表测试记录下载失败
2、认知任务《时间知觉能力测试》测试结束后不展示结果

yazhe 7 месяцев назад
Родитель
Сommit
364b936182

+ 138 - 224
src/main/java/com/rf/psychological/scale/rest/DataDownloadController.java

@@ -440,7 +440,6 @@ public class DataDownloadController {
         String fileName = split[split.length - 1];
         fileName = fileName.replace(".xlsx", "");
         JSONObject userRecordJson = new JSONObject(true);
-        userEntity.setInstitutionName("");
         userRecordJson.put("userEntity", userEntity);
         userRecordJson.put("userRecordEntity", userRecordEntity);
 
@@ -745,14 +744,7 @@ public class DataDownloadController {
             if (testResults.contains("version")) {
                 newInstitutionUserRecordingList.add(institutionUserRecordingList.get(i));
                 String testResult = new String();
-                JSONArray tableModule = JSONObject.parseObject(institutionUserRecordingList.get(i).getTestResult()).getJSONArray("tableModule");
-                JSONArray columnValues = tableModule.getJSONObject(0).getJSONArray("columnValue");
-                String[] colName = columnValues.getString(0).split(";");
-                String[] colValue = columnValues.getString(1).split(";");
-                for (int y = 0; y < colValue.length; y++) {
-                    testResult += colName[y] + ":" + colValue[y] + ";";
-                }
-                /*for (int x = 0; x < splits.length; x++) {
+                for (int x = 0; x < splits.length; x++) {
                     if (Arrays.toString(splits).contains("columnValue")) {
                         if (splits[x].contains("columnValue")) {
                             JSONArray tableModule = JSONObject.parseObject(institutionUserRecordingList.get(i).getTestResult()).getJSONArray("tableModule");
@@ -780,59 +772,37 @@ public class DataDownloadController {
                             }
                         }
                     }
-                }*/
+                }
                 splits = testResult.split(";");
                 //标题行抽出字段
-                newTitle = new String[splits.length + 9];
-                newTitle[0] = "被试ID";
-                newTitle[1] = "姓名";
-                newTitle[2] = "年龄";
-               /* newTitle[3] = "单位名称旅";
-                newTitle[4] = "单位名称大队";
-                newTitle[5] = "飞行等级";
-                newTitle[6] = "现飞机型";
-                newTitle[7] = "任务序次";
-                newTitle[8] = "测试时间";
-                newTitle[9] = "职业";
-                newTitle[10] = "军衔";*/
-                /*newTitle[0] = "姓名";
+                newTitle = new String[splits.length + 7];
+                newTitle[0] = "姓名";
                 newTitle[1] = "性别";
                 newTitle[2] = "职业";
                 newTitle[3] = "出生日期";
                 newTitle[4] = "登录名";
                 newTitle[5] = "测试时间";
-                newTitle[6] = "测试名称";*/
+                newTitle[6] = "测试名称";
                 for (int x = 0; x < splits.length; x++) {
                     String[] a = splits[x].split(":");
-                    newTitle[x + 11] = a[0];
+                    newTitle[x + 7] = a[0];
 
                 }
             } else {
                 oldInstitutionUserRecordingList.add(institutionUserRecordingList.get(i));
 
                 //标题行抽出字段
-                oldTitle = new String[splits.length + 9];
-                oldTitle[0] = "被试ID";
-                oldTitle[1] = "姓名";
-                oldTitle[2] = "年龄";
-                /*oldTitle[3] = "单位名称旅";
-                oldTitle[4] = "单位名称大队";
-                oldTitle[5] = "飞行等级";
-                oldTitle[6] = "现飞机型";
-                oldTitle[7] = "任务序次";
-                oldTitle[8] = "测试时间";
-                oldTitle[9] = "职业";
-                oldTitle[10] = "军衔";*/
-                /*oldTitle[0] = "姓名";
+                oldTitle = new String[splits.length + 7];
+                oldTitle[0] = "姓名";
                 oldTitle[1] = "性别";
                 oldTitle[2] = "职业";
                 oldTitle[3] = "出生日期";
                 oldTitle[4] = "登录名";
                 oldTitle[5] = "测试时间";
-                oldTitle[6] = "测试名称";*/
+                oldTitle[6] = "测试名称";
                 for (int y = 0; y < splits.length; y++) {
                     String[] a = splits[y].split(":");
-                    oldTitle[y + 11] = a[0];
+                    oldTitle[y + 7] = a[0];
 
                 }
             }
@@ -992,14 +962,7 @@ public class DataDownloadController {
                 //institutionUserRecordingList.remove(i);
                 //i--;
                 String testResult = new String();
-                JSONArray tableModule = JSONObject.parseObject(institutionUserRecordingList.get(i).getTestResult()).getJSONArray("tableModule");
-                JSONArray columnValues = tableModule.getJSONObject(0).getJSONArray("columnValue");
-                String[] colName = columnValues.getString(0).split(";");
-                String[] colValue = columnValues.getString(1).split(";");
-                for (int y = 0; y < colValue.length; y++) {
-                    testResult += colName[y] + ":" + colValue[y] + ";";
-                }
-                /*for (int x = 0; x < splits.length; x++) {
+                for (int x = 0; x < splits.length; x++) {
                     if (Arrays.toString(splits).contains("columnValue")) {
                         if (splits[x].contains("columnValue")) {
                             JSONArray tableModule = JSONObject.parseObject(institutionUserRecordingList.get(i).getTestResult()).getJSONArray("tableModule");
@@ -1028,46 +991,37 @@ public class DataDownloadController {
                         }
                     }
 
-                }*/
+                }
                 splits = testResult.split(";");
                 //标题行抽出字段
-                newTitle = new String[splits.length + 9];
-                newTitle[0] = "被试ID";
-                newTitle[1] = "姓名";
-                newTitle[2] = "年龄";
-               /* newTitle[3] = "单位名称旅";
-                newTitle[4] = "单位名称大队";
-                newTitle[5] = "飞行等级";
-                newTitle[6] = "现飞机型";
-                newTitle[7] = "任务序次";
-                newTitle[8] = "测试时间";
-                newTitle[9] = "职业";
-                newTitle[10] = "军衔";*/
+                newTitle = new String[splits.length + 7];
+                newTitle[0] = "姓名";
+                newTitle[1] = "性别";
+                newTitle[2] = "职业";
+                newTitle[3] = "出生日期";
+                newTitle[4] = "登录名";
+                newTitle[5] = "测试时间";
+                newTitle[6] = "测试名称";
                 for (int x = 0; x < splits.length; x++) {
                     String[] a = splits[x].split(":");
-                    newTitle[x + 11] = a[0];
+                    newTitle[x + 7] = a[0];
 
                 }
             } else {
                 oldInstitutionUserRecordingList.add(institutionUserRecordingList.get(i));
 
                 //标题行抽出字段
-                oldTitle = new String[splits.length + 9];
-                oldTitle[0] = "被试ID";
-                oldTitle[1] = "姓名";
-                oldTitle[2] = "年龄";
-                /*oldTitle[3] = "单位名称旅";
-                oldTitle[4] = "单位名称大队";
-                oldTitle[5] = "飞行等级";
-                oldTitle[6] = "现飞机型";
-                oldTitle[7] = "任务序次";
-                oldTitle[8] = "测试时间";
-
-                oldTitle[9] = "职业";
-                oldTitle[10] = "军衔";*/
+                oldTitle = new String[splits.length + 7];
+                oldTitle[0] = "姓名";
+                oldTitle[1] = "性别";
+                oldTitle[2] = "职业";
+                oldTitle[3] = "出生日期";
+                oldTitle[4] = "登录名";
+                oldTitle[5] = "测试时间";
+                oldTitle[6] = "测试名称";
                 for (int y = 0; y < splits.length; y++) {
                     String[] a = splits[y].split(":");
-                    oldTitle[y + 11] = a[0];
+                    oldTitle[y + 7] = a[0];
 
                 }
             }
@@ -1730,7 +1684,16 @@ public class DataDownloadController {
         }
         List<Map<String, Object>> mapList = getExcelMapList(userList, institutionNo);
         //设置Excel表头
-        List<String> titleList = getExcelTitleList(institutionNo);
+        List<String> titleList = new ArrayList<>();
+        mapList.forEach(map -> {
+            Set<String> set = map.keySet();
+            set.forEach(key -> {
+                if (!titleList.contains(key)) {
+                    titleList.add(key);
+                }
+            });
+        });
+
         Workbook wb = insertDataToExcel(titleList, mapList);
 
         //获取配置文件中保存对应excel文件的路径,本地也可以直接写成F:excel/stuInfoExcel路径
@@ -1799,7 +1762,15 @@ public class DataDownloadController {
         }
         List<Map<String, Object>> mapList = getExcelMapList(userList, institutionNo);
         //设置Excel表头
-        List<String> titleList = getExcelTitleList(institutionNo);
+        List<String> titleList = new ArrayList<>();
+        mapList.forEach(map -> {
+            Set<String> set = map.keySet();
+            set.forEach(key -> {
+                if (!titleList.contains(key)) {
+                    titleList.add(key);
+                }
+            });
+        });
 
         Workbook wb = insertDataToExcel(titleList, mapList);
 
@@ -1867,7 +1838,7 @@ public class DataDownloadController {
      * @param
      * @return
      */
-    public Workbook insertData(Sheet downSheet, Workbook wb, String[] title, List<InstitutionRecordingUsersDTO> institutionUserRecordingList, String name) {
+    public static Workbook insertData(Sheet downSheet, Workbook wb, String[] title, List<InstitutionRecordingUsersDTO> institutionUserRecordingList, String name) {
         //设置单元格宽度自适应,在此基础上把宽度调至1.5倍
         for (int i = 0; i < title.length; i++) {
             downSheet.autoSizeColumn(i, true);
@@ -1895,105 +1866,82 @@ public class DataDownloadController {
         }
         //把从数据库中取得的数据一一写入excel文件中
         Row row = null;
-        //获取用户属性信息
-        List<String> userIdList = institutionUserRecordingList.stream().map(item -> item.getUserId()).collect(Collectors.toList());
-        //List<UserAttributeEntity> userAttributeList = userAttributeService.findListByUserIdListAndStatus(userIdList, Constant.TEST_PLAN_STATUS_STOP);
 
         int size = institutionUserRecordingList.size();
         for (int i = 0; i < size; i++) {
             InstitutionRecordingUsersDTO institutionRecordingUsersDTO = institutionUserRecordingList.get(institutionUserRecordingList.size() - i - 1);
-            //UserAttributeEntity userAttribute = userAttributeList.stream().filter(att -> institutionRecordingUsersDTO.getUserId().equals(att.getUserId())).findFirst().orElse(null);
             String testResultls = institutionRecordingUsersDTO.getTestResults();
             String[] splitl = testResultls.split(";");
             if (testResultls.contains("version")) {
                 String testResultl = new String();
-                JSONArray tableModule = JSONObject.parseObject(institutionRecordingUsersDTO.getTestResult()).getJSONArray("tableModule");
-                JSONArray columnValues = tableModule.getJSONObject(0).getJSONArray("columnValue");
-                String[] colName = columnValues.getString(0).split(";");
-                String[] colValue = columnValues.getString(1).split(";");
-                for (int y = 0; y < colValue.length; y++) {
-                    testResultl += colName[y] + ":" + colValue[y] + ";";
+                for (int x = 0; x < splitl.length; x++) {
+                    if (Arrays.toString(splitl).contains("columnValue")) {
+                        if (splitl[x].contains("columnValue")) {
+                            JSONArray tableModule = JSONObject.parseObject(institutionRecordingUsersDTO.getTestResult()).getJSONArray("tableModule");
+                            JSONArray columnValues = tableModule.getJSONObject(0).getJSONArray("columnValue");
+                            String[] colName = columnValues.getString(0).split(";");
+                            String[] colValue = columnValues.getString(1).split(";");
+                            for (int y = 0; y < colName.length; y++) {
+                                testResultl += colName[y] + ":" + colValue[y] + ";";
+                            }
+                        }
+                    } else {
+                        if (splitl[x].contains("totalScoreDesc")) {
+                            String b = splitl[x];
+                            JSONArray totalScores = JSONArray.parseArray(b.replace("totalScore:", ""));
+                            JSONObject totalScore = totalScores.getJSONObject(0);
+                            testResultl += "总分:" + totalScore.getString("totalScore") + ";总分结论:" + totalScore.getString("totalScoreDesc") + ";";
+                        }
+                        if (splitl[x].contains("Describe")) {
+                            String b = splitl[x];
+                            JSONArray dimensions = JSONArray.parseArray(b.replace("dimensions:", ""));
+                            for (int y = 0; y < dimensions.size(); y++) {
+                                JSONObject dimension = dimensions.getJSONObject(y);
+                                testResultl += dimension.getString("name") + ":" + dimension.getString("score") + ";"
+                                        + dimension.getString("name") + "结论:" + dimension.getString("Describe") + ";";
+                            }
+                        }
+                    }
                 }
                 splitl = testResultl.split(";");
-            }
+                //continue;
+            }/*else {
+                splitl = testResultl.split(";");
+            }*/
             //创建list.size()行数据
             row = downSheet.createRow(i + 1);
 
             //把值一一写进单元格里
-            Cell cell0 = row.createCell(0);
-            cell0.setCellValue(institutionRecordingUsersDTO.getPhone());
-            cell0.setCellStyle(style);
-
-            Cell cell1 = row.createCell(1);
-            cell1.setCellValue(institutionRecordingUsersDTO.getPetName());
-            cell1.setCellStyle(style);
-
-            Cell cell2 = row.createCell(2);
-            cell2.setCellValue(institutionRecordingUsersDTO.getAge());
-            cell2.setCellStyle(style);
-
-           /* String brigade = "";//所在旅
-            String detachment = "";//所在大队
-            String fightRegistration = "";//飞行等级
-           *//* String flightDuration = "";//总飞行时长
-            String currentTypeFlightDuration = "";//现机型飞行时长
-            String flyingModels = "";//飞过机型*//*
-            String currentFlyingModels = "";//当前机型*/
-           /* if (userAttribute != null) {
-                brigade = userAttribute.getBrigade();
-                detachment = userAttribute.getDetachment();
-                fightRegistration = userAttribute.getFightRegistration();
-                *//*flightDuration = userAttribute.getFlightDuration();
-                currentTypeFlightDuration = userAttribute.getCurrentTypeFlightDuration();*//*
-
-                List<String> flyingModelList = JSON.parseArray(userAttribute.getFlyingModels(), String.class);
-               *//* if (!flyingModelList.isEmpty()) {
-                    flyingModels = String.join(",", flyingModelList);
-                }*//*
-
-                List<String> currentFlyingModelList = JSON.parseArray(userAttribute.getCurrentFlyingModels(), String.class);
-                if (!currentFlyingModelList.isEmpty()) {
-                    currentFlyingModels = String.join(",", currentFlyingModelList);
-                }
-
-            }*/
-
-           /* Cell cell3 = row.createCell(3);
-            cell3.setCellValue(brigade);
-            cell3.setCellStyle(style);
-
             Cell cell4 = row.createCell(4);
-            cell4.setCellValue(detachment);
+            cell4.setCellValue(institutionRecordingUsersDTO.getPhone());
             cell4.setCellStyle(style);
-
             Cell cell5 = row.createCell(5);
-            cell5.setCellValue(fightRegistration);
+            cell5.setCellValue(institutionRecordingUsersDTO.getTestDate());
             cell5.setCellStyle(style);
             Cell cell6 = row.createCell(6);
-            cell6.setCellValue(currentFlyingModels);
+            cell6.setCellValue(name);
             cell6.setCellStyle(style);
 
-
-            Cell cell7 = row.createCell(7);
-            cell7.setCellValue(institutionRecordingUsersDTO.getInde());
-            cell7.setCellStyle(style);
-
-            Cell cell8 = row.createCell(8);
-            cell8.setCellValue(institutionRecordingUsersDTO.getTestDate());
-            cell8.setCellStyle(style);
-
-            Cell cell9 = row.createCell(9);
-            cell9.setCellValue(institutionRecordingUsersDTO.getProfession());
-            cell9.setCellStyle(style);
-
-            Cell cell10 = row.createCell(10);
-            cell10.setCellValue(institutionRecordingUsersDTO.getMilitary());
-            cell10.setCellStyle(style);*/
-
+            Cell cell0 = row.createCell(0);
+            cell0.setCellValue(institutionRecordingUsersDTO.getPetName());
+            cell0.setCellStyle(style);
+            Cell cell2 = row.createCell(2);
+            cell2.setCellValue(institutionRecordingUsersDTO.getProfession());
+            cell2.setCellStyle(style);
+            Cell cell1 = row.createCell(1);
+            if (institutionRecordingUsersDTO.getGender().equals("0")) {
+                cell1.setCellValue("男");
+            } else {
+                cell1.setCellValue("女");
+            }
+            cell1.setCellStyle(style);
+            Cell cell3 = row.createCell(3);
+            cell3.setCellValue(institutionRecordingUsersDTO.getBirthday());
+            cell3.setCellStyle(style);
 
             for (int z = 0; z < splitl.length; z++) {
                 String[] a = splitl[z].split(":");
-                Cell rowCell = row.createCell(z + 3);
+                Cell rowCell = row.createCell(z + 7);
                 if (a.length < 2) {
                     rowCell.setCellValue("无");
                 } else {
@@ -2075,12 +2023,11 @@ public class DataDownloadController {
         List<Map<String, Object>> mapList = new ArrayList<>();
         for (UserEntity user : userList) {
             Map<String, Object> map = new LinkedHashMap<>();
-
-            map.put("被试ID", user.getPhone());
             map.put("姓名", user.getPetName());
             map.put("性别", "0".equals(user.getGender()) ? "男" : "女");
-            map.put("年龄", user.getAge());
-            /*UserAttributeEntity userAttribute = userAttributeList.stream().filter(att -> user.getId().equals(att.getUserId())).findFirst().orElse(null);
+            map.put("出生日期", user.getBirthday());
+            map.put("登录名", user.getPhone());
+            UserAttributeEntity userAttribute = userAttributeList.stream().filter(att -> user.getId().equals(att.getUserId())).findFirst().orElse(null);
             String brigade = "";//所在旅
             String detachment = "";//所在大队
             String fightRegistration = "";//飞行等级
@@ -2106,36 +2053,55 @@ public class DataDownloadController {
                 }
 
             }
-            map.put("单位名称旅", brigade);
-            map.put("单位名称大队", detachment);
+            map.put("所在旅", brigade);
+            map.put("所在大队", detachment);
             map.put("飞行等级", fightRegistration);
-            map.put("现飞机型", currentFlyingModels);
             map.put("总飞行时长", flightDuration);
             map.put("现机型飞行时长", currentTypeFlightDuration);
             map.put("飞过机型", flyingModels);
-            map.put("职业", user.getProfession());
-            map.put("军衔", user.getMilitary());*/
+            map.put("当前机型", currentFlyingModels);
             List<UserRecordEntity> matchUserRecordList = userRecordList.stream().filter(rec -> user.getPhone().equals(rec.getPhone())).collect(Collectors.toList());
             if (matchUserRecordList.isEmpty()) {
                 continue;
             }
             for (UserRecordEntity record : matchUserRecordList) {
-                if (Constant.DEFAULT_VALUE_ZERO.equals(record.getType())) {
-                    map.put(record.getName() + "-测试时间", StringUtils.isNotEmpty(record.getTestDate()) ? record.getTestDate() : "无");
-                }
+                map.put(record.getName() + "-测试时间", StringUtils.isNotEmpty(record.getTestDate()) ? record.getTestDate() : "无");
                 String testResults = record.getTestResults();
                 if (StringUtils.isEmpty(testResults)) {
                     continue;
                 }
 
                 if (testResults.contains("version")) {
+                    //格式不同,进行处理,按格式处理之后,重新放入testResults
+                    String[] results = testResults.split(";");
+                    List<String> resultList = Arrays.asList(results);
                     String testResult = "";
-                    JSONArray tableModule = JSONObject.parseObject(record.getTestResult()).getJSONArray("tableModule");
-                    JSONArray columnValues = tableModule.getJSONObject(0).getJSONArray("columnValue");
-                    String[] colName = columnValues.getString(0).split(";");
-                    String[] colValue = columnValues.getString(1).split(";");
-                    for (int y = 0; y < colValue.length; y++) {
-                        testResult += colName[y] + ":" + colValue[y] + ";";
+                    for (String item : resultList) {
+                        if (resultList.contains("columnValue")) {
+                            if (item.contains("columnValue")) {
+                                JSONArray tableModule = JSONObject.parseObject(record.getTestResult()).getJSONArray("tableModule");
+                                JSONArray columnValues = tableModule.getJSONObject(0).getJSONArray("columnValue");
+                                String[] colName = columnValues.getString(0).split(";");
+                                String[] colValue = columnValues.getString(1).split(";");
+                                for (int y = 0; y < colName.length; y++) {
+                                    testResult += colName[y] + ":" + colValue[y] + ";";
+                                }
+                            }
+                        } else {
+                            if (item.contains("totalScoreDesc")) {
+                                JSONArray totalScores = JSONArray.parseArray(item.replace("totalScore:", ""));
+                                JSONObject totalScore = totalScores.getJSONObject(0);
+                                testResult += "总分:" + totalScore.getString("totalScore") + ";总分结论:" + totalScore.getString("totalScoreDesc") + ";";
+                            }
+                            if (item.contains("Describe")) {
+                                JSONArray dimensions = JSONArray.parseArray(item.replace("dimensions:", ""));
+                                for (int y = 0; y < dimensions.size(); y++) {
+                                    JSONObject dimension = dimensions.getJSONObject(y);
+                                    testResult += dimension.getString("name") + ":" + dimension.getString("score") + ";"
+                                            + dimension.getString("name") + "结论:" + dimension.getString("Describe") + ";";
+                                }
+                            }
+                        }
                     }
                     testResults = testResult;
                 }
@@ -2159,56 +2125,4 @@ public class DataDownloadController {
         return mapList;
     }
 
-    public List<String> getExcelTitleList(String institutionNo) {
-        List<String> titleList = new ArrayList<>();
-        titleList.add("被试ID");
-        titleList.add("姓名");
-        titleList.add("性别");
-        titleList.add("年龄");
-        /*titleList.add("单位名称旅");
-        titleList.add("单位名称大队");
-        titleList.add("飞行等级");
-        titleList.add("现飞机型");
-        titleList.add("总飞行时长");
-        titleList.add("现机型飞行时长");
-        titleList.add("飞过机型");
-        titleList.add("职业");
-        titleList.add("军衔");*/
-        List<UserRecordEntity> userRecordList = userRecordService.getListByInstitutionNo(institutionNo);
-        for (UserRecordEntity record : userRecordList) {
-            if (Constant.DEFAULT_VALUE_ZERO.equals(record.getType())) {
-                titleList.add(record.getName() + "-测试时间");
-            }
-            String testResults = record.getTestResults();
-            if (StringUtils.isEmpty(testResults)) {
-                continue;
-            }
-            String testResult = "";
-            if (testResults.contains("version")) {
-                JSONArray tableModule = JSONObject.parseObject(record.getTestResult()).getJSONArray("tableModule");
-                JSONArray columnValues = tableModule.getJSONObject(0).getJSONArray("columnValue");
-                String[] colName = columnValues.getString(0).split(";");
-                String[] colValue = columnValues.getString(1).split(";");
-                for (int y = 0; y < colValue.length; y++) {
-                    testResult += colName[y] + ":" + colValue[y] + ";";
-                }
-                testResults = testResult;
-            }
-            //对测试结果进行解析,并放入map;
-            String[] results = testResults.split(";");
-            List<String> resultList = Arrays.asList(results);
-            for (String result : resultList) {
-                if (StringUtils.isEmpty(result)) {
-                    continue;
-                }
-                String[] resultSubs = result.split(":");
-                if (resultSubs == null || resultSubs.length < 2) {
-                    continue;
-                }
-                titleList.add(record.getName() + "-" + resultSubs[0]);
-            }
-        }
-        return titleList;
-    }
-
 }

+ 0 - 146
src/main/java/com/rf/psychological/scale/resultBusiness/cognitiveResult/SCCognize.java

@@ -1,146 +0,0 @@
-package com.rf.psychological.scale.resultBusiness.cognitiveResult;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.rf.psychological.dao.model.SCEntity;
-import com.rf.psychological.dao.model.SHAPE2Entity;
-import com.rf.psychological.file.excel.ExcelClass;
-import com.rf.psychological.scale.resultBusiness.scaleResult.BaseScale;
-import com.rf.psychological.utils.Constant;
-import com.rf.psychological.utils.ExcelUtil;
-import org.springframework.util.CollectionUtils;
-
-import java.text.DecimalFormat;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import java.util.stream.Collectors;
-
-/**
- * @author zsy
- * @description:时间知觉能力测试
- * @date 2021/7/20 15:55
- */
-public class SCCognize extends BaseScale {
-
-    public SCCognize(JSONArray jsonArray, JSONObject resultJson) {
-        super(jsonArray, resultJson);
-    }
-
-    public JSONObject scaleCalculate() throws Exception {
-        List<Map<String, String>> resultMapList = new ArrayList<>();
-        JSONObject jsonObject = resultJson.getJSONObject("jsonObject");
-        String fileName = resultJson.getString("fileName");
-        String name;
-
-        JSONObject resultDBJson = new JSONObject(true);
-
-        JSONArray jsonArray = jsonObject.getJSONArray("results");
-        List<SCEntity> scEntityList = jsonArray.toJavaList(SCEntity.class);
-        int i = 0;
-        for (SCEntity scEntity : scEntityList) {
-            scEntity.setCardNo(resultJson.getString("cardNo"));
-            scEntity.setUserName(resultJson.getString("userName"));
-            scEntity.setAge(resultJson.getString("age"));
-            scEntity.setOrg(resultJson.getString("org"));
-            scEntity.setOrgSub(resultJson.getString("orgSub"));
-            scEntity.setFXLevel(resultJson.getString("FXLevel"));
-            scEntity.setCurrentJX(resultJson.getString("currentJX"));
-            scEntity.setIndex((i + 1) + "");
-            i++;
-        }
-
-        String taskStartTime = jsonObject.getString("taskStartTime");
-        SimpleDateFormat insdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        SimpleDateFormat outsdf = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
-        taskStartTime = outsdf.format(insdf.parse(taskStartTime));
-        resultDBJson.put("versionNo", Constant.COGNITION_RESULT_VERSION);
-        Map<String, String> resultMap = new LinkedHashMap<>();
-        resultMap.put("当前任务起始时间", taskStartTime);
-        resultDBJson.put("当前任务起始时间", taskStartTime);
-        String key = "当前任务起始时间;";
-        String value = taskStartTime + ";";
-
-        List<String> levelList = scEntityList.stream().map(item -> item.getLevel()).collect(Collectors.toList());
-        levelList = levelList.stream().distinct().collect(Collectors.toList());
-        levelList.sort(Comparator.naturalOrder());
-        for (String level : levelList) {
-            List<SCEntity> scList = scEntityList.stream().filter(item -> level.equals(item.getLevel())).collect(Collectors.toList());
-            double errorSum = scList.stream().mapToDouble(item -> Double.parseDouble(item.getError())).sum();
-            resultMap.put(level + "难度累计误差", String.format("%.2f", errorSum));
-            resultDBJson.put(level + "难度累计误差", String.format("%.2f", errorSum));
-            key += level + "难度累计误差;";
-            value += String.format("%.2f", errorSum) + ";";
-        }
-
-        double errorNum = scEntityList.stream().mapToDouble(item->Double.parseDouble(item.getError())).sum();
-        resultMap.put( "整体累计误差", String.format("%.2f", errorNum));
-        resultDBJson.put( "整体累计误差", String.format("%.2f", errorNum));
-        key += "整体累计误差";
-        value += String.format("%.2f", errorNum);
-
-
-        resultDBJson.put("versionNo", Constant.COGNITION_RESULT_VERSION);
-        JSONArray totalScores = new JSONArray();
-        /*JSONObject totalScore = new JSONObject(true);
-        String desc = null;
-        totalScore.put("totalScore", correct);
-
-        if (correct > 500) {
-            desc = "极差等级:您天生时间知觉敏锐程度很差,几乎不能感知自己的生理时钟,在生活工作中也几乎不能把握时间节奏,比如时间一点点过去您并没有觉察,时间感很差,生活缺乏计划,该睡觉的时候可能在打游戏或者做其他的事,该吃饭的时候也不吃饭。您很需要加强时间感知力训练。\n";
-        } else if (correct > 400 && correct <= 500) {
-            desc = "较差等级:您天生时间知觉敏锐程度较差,不能够很好地感知自己的生理时钟,在生活工作中也不能很好地把握时间节奏,比如有时候时间不知不觉过去很久自己也不知道怎么回事,时间感较差,生活缺乏计划,可能需要加强时间感训练。\n";
-        } else if (correct > 200 && correct <= 400) {
-            desc = "一般等级:您天生时间知觉敏锐程度一般,对自己生理时钟的感知能力也处在一般水平,在生活工作中不能够很好但能够较好地把握时间节奏。比如,每天来回上班地点的行程时间,您内心会大概有个计算。\n";
-        } else if (correct > 100 && correct <= 200) {
-            desc = "较优秀等级:您在一定程度上忠于自己的生理时钟,属于天生时间知觉比较敏锐的人,在生活工作中对时间节奏把握得比较准确。比如,您平常需要吃早餐的时间到了,您可能会感到饿并且要吃点东西。每天来回上班地点的行程时间,您内心也能大概较好地计算。\n";
-        } else if (correct <= 100) {
-            desc = "优秀等级:您很忠于自己的生理时钟,属于天生时间知觉相当敏锐的人,在生活工作中对时间节奏把握得很好很准确。比如,在您平常需要吃早餐的时间,您就会感到饿。每天来回上班地点的行程时间,您内心也会计算得很好。\n";
-        }
-        totalScore.put("totalScoreDesc", desc);
-        totalScores.add(totalScore);
-        resultDBJson.put("totalScore", totalScores);*/
-
-
-
-
-        //表格数据
-        JSONArray tableModule = new JSONArray();
-        JSONObject table1 = new JSONObject(true);
-        JSONArray columnName = new JSONArray();
-        columnName.add("指标名称");
-        columnName.add("指标值");
-        JSONArray columnValue = new JSONArray();
-        columnValue.add(key);
-        columnValue.add(value);
-        table1.put("tableName", "table1");
-        table1.put("columnName", columnName);
-        table1.put("columnValue", columnValue);
-        tableModule.add(table1);
-        resultDBJson.put("tableModule", tableModule);
-        JSONObject ifShow = new JSONObject(true);
-//        ifShow.put("totalScore", true);
-        ifShow.put("totalScore", false);
-        ifShow.put("dimensions", false);
-        ifShow.put("note", false);
-        ifShow.put("radar", false);
-        ifShow.put("table", true);
-        resultDBJson.put("ifShow", ifShow);
-        resultMapList = new ArrayList<>();
-        resultMapList.add(resultMap);
-        fileName = fileName + "-" + Constant.SHEET_NAME_SC + ".xlsx";
-        name = Constant.SHEET_NAME_SC;
-        String datas = jsonArray.toString();
-        ExcelUtil.createExcelFile(SCEntity.class, scEntityList, resultMapList, new ExcelClass().contentExcel(Constant.QUEST_TYPE_SC), fileName, Constant.SHEET_NAME_SC);
-        //枪林弹雨
-
-        JSONObject returnJson = new JSONObject(true);
-        returnJson.put("fileName", fileName);
-        returnJson.put("name", name);
-        returnJson.put("resultJson", resultDBJson);
-        returnJson.put("datas", datas);
-
-        return returnJson;
-    }
-
-
-}

+ 209 - 0
src/main/java/com/rf/psychological/scale/resultBusiness/cognitiveResult/SCCognizeOld.java

@@ -0,0 +1,209 @@
+package com.rf.psychological.scale.resultBusiness.cognitiveResult;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.rf.psychological.dao.model.SCEntity;
+import com.rf.psychological.dao.model.SHAPE2Entity;
+import com.rf.psychological.file.excel.ExcelClass;
+import com.rf.psychological.scale.resultBusiness.scaleResult.BaseScale;
+import com.rf.psychological.utils.Constant;
+import com.rf.psychological.utils.ExcelUtil;
+
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author zsy
+ * @description:时间知觉能力测试
+ * @date 2021/7/20 15:55
+ */
+public class SCCognizeOld extends BaseScale {
+
+    public SCCognizeOld(JSONArray jsonArray, JSONObject resultJson) {
+        super(jsonArray, resultJson);
+    }
+
+    public  JSONObject scaleCalculate() throws Exception {
+        List<Map<String, String>> resultMapList = new ArrayList<>();
+        JSONObject jsonObject = resultJson.getJSONObject("jsonObject");
+        String fileName = resultJson.getString("fileName");
+        String name;
+
+        JSONObject resultDBJson = new JSONObject(true);
+
+        JSONArray jsonArray = jsonObject.getJSONArray("results");
+        List<SCEntity> scEntityList = jsonArray.toJavaList(SCEntity.class);
+        int num = 0;
+        int errorNum = 0;
+        int diff1 = 0;
+        int diff2 = 0;
+        int diff3= 0;
+        int diff4 = 0;
+        int diff5 = 0;
+        int diff6 = 0;
+        int diff7 = 0;
+        int diff8 = 0;
+        int diff9 = 0;
+        for (SCEntity scEntity : scEntityList) {
+            if (!scEntity.getError().equals("NULL")) {
+                num += 1;
+                if (scEntity.getSpeed() == 1){
+                    if (scEntity.getLength() == 100){
+                        if (Integer.valueOf(scEntity.getError()) < 0) {
+                            diff1 -= Integer.valueOf(scEntity.getError());
+                        } else {
+                            diff1 += Integer.valueOf(scEntity.getError());
+                        }
+                    }else if (scEntity.getLength() == 150){
+                        if (Integer.valueOf(scEntity.getError()) < 0) {
+                            diff2 -= Integer.valueOf(scEntity.getError());
+                        } else {
+                            diff2 += Integer.valueOf(scEntity.getError());
+                        }
+                    }else {
+                        if (Integer.valueOf(scEntity.getError()) < 0) {
+                            diff3 -= Integer.valueOf(scEntity.getError());
+                        } else {
+                            diff3 += Integer.valueOf(scEntity.getError());
+                        }
+                    }
+                }else if (scEntity.getSpeed() == 2){
+                    if (scEntity.getLength() == 100){
+                        if (Integer.valueOf(scEntity.getError()) < 0) {
+                            diff4 -= Integer.valueOf(scEntity.getError());
+                        } else {
+                            diff4 += Integer.valueOf(scEntity.getError());
+                        }
+                    }else if (scEntity.getLength() == 150){
+                        if (Integer.valueOf(scEntity.getError()) < 0) {
+                            diff5 -= Integer.valueOf(scEntity.getError());
+                        } else {
+                            diff5 += Integer.valueOf(scEntity.getError());
+                        }
+                    }else {
+                        if (Integer.valueOf(scEntity.getError()) < 0) {
+                            diff6 -= Integer.valueOf(scEntity.getError());
+                        } else {
+                            diff6 += Integer.valueOf(scEntity.getError());
+                        }
+                    }
+                }else {
+                    if (scEntity.getLength() == 100){
+                        if (Integer.valueOf(scEntity.getError()) < 0) {
+                            diff7 -= Integer.valueOf(scEntity.getError());
+                        } else {
+                            diff7 += Integer.valueOf(scEntity.getError());
+                        }
+                    }else if (scEntity.getLength() == 150){
+                        if (Integer.valueOf(scEntity.getError()) < 0) {
+                            diff8 -= Integer.valueOf(scEntity.getError());
+                        } else {
+                            diff8 += Integer.valueOf(scEntity.getError());
+                        }
+                    }else {
+                        if (Integer.valueOf(scEntity.getError()) < 0) {
+                            diff9 -= Integer.valueOf(scEntity.getError());
+                        } else {
+                            diff9 += Integer.valueOf(scEntity.getError());
+                        }
+                    }
+                }
+                if (Integer.valueOf(scEntity.getError()) < 0) {
+                    errorNum -= Integer.valueOf(scEntity.getError());
+                } else {
+                    errorNum += Integer.valueOf(scEntity.getError());
+                }
+            }
+        }
+        DecimalFormat df = new DecimalFormat("######0.00");
+        double correct = 0;
+        if (num != 0){
+            correct = Double.parseDouble(df.format(errorNum / num));
+        }
+
+        resultDBJson.put("versionNo",Constant.COGNITION_RESULT_VERSION);
+        JSONArray totalScores = new JSONArray();
+        JSONObject totalScore = new JSONObject(true);
+        String desc = null;
+        totalScore.put("totalScore",correct);
+
+        if (correct>500){
+            desc = "极差等级:您天生时间知觉敏锐程度很差,几乎不能感知自己的生理时钟,在生活工作中也几乎不能把握时间节奏,比如时间一点点过去您并没有觉察,时间感很差,生活缺乏计划,该睡觉的时候可能在打游戏或者做其他的事,该吃饭的时候也不吃饭。您很需要加强时间感知力训练。\n";
+        }else if(correct>400 && correct<=500){
+            desc = "较差等级:您天生时间知觉敏锐程度较差,不能够很好地感知自己的生理时钟,在生活工作中也不能很好地把握时间节奏,比如有时候时间不知不觉过去很久自己也不知道怎么回事,时间感较差,生活缺乏计划,可能需要加强时间感训练。\n";
+        }else if(correct>200 && correct<=400){
+            desc = "一般等级:您天生时间知觉敏锐程度一般,对自己生理时钟的感知能力也处在一般水平,在生活工作中不能够很好但能够较好地把握时间节奏。比如,每天来回上班地点的行程时间,您内心会大概有个计算。\n";
+        }else if(correct>100 && correct<=200){
+            desc = "较优秀等级:您在一定程度上忠于自己的生理时钟,属于天生时间知觉比较敏锐的人,在生活工作中对时间节奏把握得比较准确。比如,您平常需要吃早餐的时间到了,您可能会感到饿并且要吃点东西。每天来回上班地点的行程时间,您内心也能大概较好地计算。\n";
+        }else if(correct<=100){
+            desc = "优秀等级:您很忠于自己的生理时钟,属于天生时间知觉相当敏锐的人,在生活工作中对时间节奏把握得很好很准确。比如,在您平常需要吃早餐的时间,您就会感到饿。每天来回上班地点的行程时间,您内心也会计算得很好。\n";
+        }
+        totalScore.put("totalScoreDesc",desc);
+        totalScores.add(totalScore);
+        resultDBJson.put("totalScore",totalScores);
+        //表格数据
+        JSONArray tableModule = new JSONArray();
+        JSONObject table1 = new JSONObject(true);
+        JSONArray columnName = new JSONArray();
+        columnName.add("指标名称");
+        columnName.add("指标值(ms)");
+        JSONArray columnValue = new JSONArray();
+        columnValue.add("平均反应误差;难度一误差;难度二误差;难度三误差;难度四误差;难度五误差;难度六误差;难度七误差;难度八误差;难度九误差");
+        columnValue.add(correct +";"+diff1 +";"+diff2 +";"+diff3 +";"+diff4 +";"+diff5 +";"+diff6 +";"+diff7 +";"+diff8 +";"+diff9);
+        table1.put("tableName","table1");
+        table1.put("columnName",columnName);
+        table1.put("columnValue",columnValue);
+        tableModule.add(table1);
+        resultDBJson.put("tableModule", tableModule);
+        JSONObject ifShow = new JSONObject(true);
+        ifShow.put("totalScore",true);
+        ifShow.put("dimensions",false);
+        ifShow.put("note",false);
+        ifShow.put("radar",false);
+        ifShow.put("table",true);
+        resultDBJson.put("ifShow",ifShow);
+
+
+        Map<String, String> resultMap = new LinkedHashMap<>();
+        resultMap.put("平均反应误差", String.valueOf(correct));
+        resultDBJson.put("平均反应误差", String.valueOf(correct));
+        resultMap.put("难度一误差", String.valueOf(diff1));
+        resultDBJson.put("难度一误差", String.valueOf(diff1));
+        resultMap.put("难度二误差", String.valueOf(diff2));
+        resultDBJson.put("难度二误差", String.valueOf(diff2));
+        resultMap.put("难度三误差", String.valueOf(diff3));
+        resultDBJson.put("难度三误差", String.valueOf(diff3));
+        resultMap.put("难度四误差", String.valueOf(diff4));
+        resultDBJson.put("难度四误差", String.valueOf(diff4));
+        resultMap.put("难度五误差", String.valueOf(diff5));
+        resultDBJson.put("难度五误差", String.valueOf(diff5));
+        resultMap.put("难度六误差", String.valueOf(diff6));
+        resultDBJson.put("难度六误差", String.valueOf(diff6));
+        resultMap.put("难度七误差", String.valueOf(diff7));
+        resultDBJson.put("难度七误差", String.valueOf(diff7));
+        resultMap.put("难度八误差", String.valueOf(diff8));
+        resultDBJson.put("难度八误差", String.valueOf(diff8));
+        resultMap.put("难度九误差", String.valueOf(diff9));
+        resultDBJson.put("难度九误差", String.valueOf(diff9));
+        resultMapList = new ArrayList<>();
+        resultMapList.add(resultMap);
+        fileName = fileName + "-" + Constant.SHEET_NAME_SC + ".xlsx";
+        name = Constant.SHEET_NAME_SC;
+        String datas = jsonArray.toString();
+        ExcelUtil.createExcelFile(SCEntity.class, scEntityList, resultMapList, new ExcelClass().contentExcel(Constant.QUEST_TYPE_SC), fileName, Constant.SHEET_NAME_SC);
+        //枪林弹雨
+
+        JSONObject returnJson = new JSONObject(true);
+        returnJson.put("fileName",fileName);
+        returnJson.put("name", name);
+        returnJson.put("resultJson",resultDBJson);
+        returnJson.put("datas",datas);
+
+        return returnJson;
+    }
+
+
+}

BIN
量表导入模板.xlsx