Procházet zdrojové kódy

修改记录下载提交

zsy před 11 měsíci
rodič
revize
49d684fda1

+ 2 - 0
build.gradle

@@ -79,6 +79,8 @@ dependencies {
     implementation 'com.github.xiaoymin:knife4j-spring-boot-starter:3.0.3'
     // https://mvnrepository.com/artifact/io.springfox/springfox-boot-starter
     implementation 'io.springfox:springfox-boot-starter:3.0.0'
+    // https://mvnrepository.com/artifact/io.github.fanyong920/jvppeteer
+    implementation "io.github.fanyong920:jvppeteer:1.1.5"
 
 
 

+ 1 - 1
src/main/java/com/rf/kjb/filter/JWTInterceptorConfig.java

@@ -26,7 +26,7 @@ public class JWTInterceptorConfig implements WebMvcConfigurer {
         //定义排除swagger访问的路径配置
         String[] swaggerExcludes = new String[]{"/swagger*/**", "/v3/api-docs", "/webjars/**","/doc.html"};
         String[] user = new String[]{"/v1/user/login", "/v1/user/register","/v1/user/**/checkUser","/v1/user/hello"};
-        String[] record = new String[]{"/v1/record/download/**","/v1/recordPhy/download","/v1/recordPhy/export/all/pulse/target"};
+        String[] record = new String[]{"/v1/record/download/**","/result/download/**","/v1/recordPhy/download","/v1/recordPhy/export/all/pulse/target"};
         String[] faqImport = new String[]{"/chat/import/**/faq"};
         registry.addInterceptor(jwtInterceptor)
                 .addPathPatterns("/**")

+ 9 - 7
src/main/java/com/rf/kjb/intelligentDialogue/dao/repository/IntelligentDialogueRepository.java

@@ -17,15 +17,17 @@ public interface IntelligentDialogueRepository extends BaseRepository<Intelligen
             "or if(:searchKey is not null and :searchKey!='',t1.user_name like CONCAT('%',:searchKey,'%')  ,1=1)) and " +
             "if(:beginTime is not null and :beginTime!='',t1.create_time>:beginTime ,1=1)  and if(:endTime is not null and :endTime!='', t1.create_time<:endTime ,1=1)" +
             "limit :pageNum ,:pageSize ", nativeQuery = true)*/
-    @Query(value = "SELECT t1.* FROM t_intelligent_dialogue t1 INNER JOIN (SELECT MAX(id) AS id FROM t_intelligent_dialogue GROUP BY identifier ) t2 ON t1.id = t2.id " +
-            "where 1=1 and ( if(:searchKey is not null and :searchKey!='',t1.identifier like CONCAT('%',:searchKey,'%')  ,1=1) " +
-            "or if(:searchKey is not null and :searchKey!='',t1.user_name like CONCAT('%',:searchKey,'%')  ,1=1)) ",
-            countQuery = "SELECT t1.* FROM t_intelligent_dialogue t1 INNER JOIN (SELECT MAX(id) AS id FROM t_intelligent_dialogue GROUP BY identifier ) t2 ON t1.id = t2.id " +
+    @Query(value = "SELECT t1.* FROM t_intelligent_dialogue t1 INNER JOIN (SELECT MAX(id) AS id FROM t_intelligent_dialogue where type = :type GROUP BY identifier ) t2 ON t1.id = t2.id " +
+            "where 1 = 1 and ( if(:searchKey is not null and :searchKey!='',t1.identifier like CONCAT('%',:searchKey,'%')  ,1=1) " +
+            "or if(:searchKey is not null and :searchKey!='',t1.user_name like CONCAT('%',:searchKey,'%')  ,1=1)) and " +
+            "if(:beginTime is not null and :beginTime!='',t1.create_time>=:beginTime ,1=1)  and if(:endTime is not null and :endTime!='', t1.create_time<=:endTime ,1=1) ",
+            countQuery = "SELECT t1.* FROM t_intelligent_dialogue t1 INNER JOIN (SELECT MAX(id) AS id FROM t_intelligent_dialogue where type = :type GROUP BY identifier ) t2 ON t1.id = t2.id " +
                     "where 1=1 and ( if(:searchKey is not null and :searchKey!='',t1.identifier like CONCAT('%',:searchKey,'%')  ,1=1) " +
-                    "or if(:searchKey is not null and :searchKey!='',t1.user_name like CONCAT('%',:searchKey,'%')  ,1=1)) ", nativeQuery = true)
-    Page<IntelligentDialogueEntity> getIntelligentDialogueList(Pageable pageable, @Param("searchKey") String searchKey);
+                    "or if(:searchKey is not null and :searchKey!='',t1.user_name like CONCAT('%',:searchKey,'%')  ,1=1)) and " +
+                    "if(:beginTime is not null and :beginTime!='',t1.create_time>=:beginTime ,1=1)  and if(:endTime is not null and :endTime!='', t1.create_time<=:endTime ,1=1) ", nativeQuery = true)
+    Page<IntelligentDialogueEntity> getIntelligentDialogueList(Pageable pageable, @Param("searchKey") String searchKey,@Param("beginTime") String beginTime,@Param("endTime") String endTime,@Param("type") String type);
 
-    List<IntelligentDialogueEntity> findByIdentifier(String identifier);
+    List<IntelligentDialogueEntity> findByIdentifierAndType(String identifier, String type);
 
     @Query(value = "SELECT t1.* FROM t_intelligent_dialogue t1 INNER JOIN (SELECT MAX(id) AS id FROM t_intelligent_dialogue GROUP BY identifier ) t2 ON t1.id = t2.id ", nativeQuery = true)
     List<IntelligentDialogueEntity> findAllIdentifier();

+ 8 - 8
src/main/java/com/rf/kjb/intelligentDialogue/rest/IntelligentDialogueController.java

@@ -104,26 +104,26 @@ public class IntelligentDialogueController extends BaseController {
 
     @GetMapping("/dialogueList")
     @ApiOperation(value = "智能对话列表", notes = "identifier:编号;beginDate:查询起始日期;endDate:查询结束日期;pageNum:页数;pageSize:每页记录数")
-    public Result getChatList(String identifier, int pageNum, int pageSize) {
-        Page<IntelligentDialogueEntity> intelligentDialogueEntities = this.intelligentDialogueService.find(identifier, pageNum, pageSize);
+    public Result getChatList(String identifier, int pageNum, int pageSize, String beginDate, String endDate, String type) {
+        Page<IntelligentDialogueEntity> intelligentDialogueEntities = this.intelligentDialogueService.find(identifier, pageNum, pageSize, beginDate, endDate, type);
         return success(intelligentDialogueEntities);
     }
 
 
     @ApiOperation(value = "对话记录下载")
     @GetMapping("/dialogueRecord/download")
-    public Result chatRecordDownload(String identifier, HttpServletResponse response) throws Exception {
+    public Result chatRecordDownload(String type,String identifier, HttpServletResponse response) throws Exception {
         if (identifier != null || !identifier.equals("")) {
-            List<IntelligentDialogueEntity> intelligentDialogueEntityList = this.intelligentDialogueService.findByIdentifier(identifier);
+            List<IntelligentDialogueEntity> intelligentDialogueEntityList = this.intelligentDialogueService.findByIdentifierAndType(identifier,type);
             if (intelligentDialogueEntityList != null && intelligentDialogueEntityList.size() > 0) {
-                String filePath = "./对话记录/" + identifier + "-智能对话记录-" + DateUtil.getNowTime_CN() + ".xlsx";
+                String filePath = "./对话记录/" + identifier + "-记录-" + DateUtil.getNowTime_CN() + ".xlsx";
                 File file = new File(filePath);
                 if (!file.exists()) {
                     file.createNewFile();
                 }
                 XSSFWorkbook workbook = new XSSFWorkbook();
                 ExcelUtil.createFont(workbook);
-                XSSFSheet sheet = workbook.createSheet("智能对话记录");
+                XSSFSheet sheet = workbook.createSheet("记录");
                 XSSFRow titleRow = sheet.createRow(0);
                 XSSFCell cellOrder = titleRow.createCell(0);
                 cellOrder.setCellValue("角色");
@@ -190,7 +190,7 @@ public class IntelligentDialogueController extends BaseController {
         return fail(ErrorCode.FAILED);
     }
 
-    @SneakyThrows
+    /*@SneakyThrows
     @ApiOperation(value = "智能对话记录批量下载接口")
     @GetMapping("/dialogueRecord/batchDownload")
     public Result chatRecordBatchDownload(@RequestParam(value = "identifiers", required = false) List<String> identifiers, HttpServletResponse response) {
@@ -427,6 +427,6 @@ public class IntelligentDialogueController extends BaseController {
                     .forEach(ChatController::deleteDirectoryStream);
         }
         return fail(ErrorCode.FAILED);
-    }
+    }*/
 
 }

+ 2 - 2
src/main/java/com/rf/kjb/intelligentDialogue/service/IntelligentDialogueService.java

@@ -9,9 +9,9 @@ import java.util.List;
 public interface IntelligentDialogueService {
     void save(IntelligentDialogueEntity intelligentDialogue);
 
-    Page<IntelligentDialogueEntity> find(String identifier, int pageNum, int pageSize);
+    Page<IntelligentDialogueEntity> find(String identifier, int pageNum, int pageSize, String beginDate, String endDate, String type);
 
-    List<IntelligentDialogueEntity> findByIdentifier(String identifier);
+    List<IntelligentDialogueEntity> findByIdentifierAndType(String identifier, String type);
 
     List<IntelligentDialogueEntity> findAllIdentifier();
 

+ 7 - 4
src/main/java/com/rf/kjb/intelligentDialogue/service/impl/IntelligentDialogueServiceImpl.java

@@ -26,8 +26,11 @@ public class IntelligentDialogueServiceImpl implements IntelligentDialogueServic
     }
 
     @Override
-    public Page<IntelligentDialogueEntity> find(String searchKey, int pageNum, int pageSize) {
-        return this.repository.getIntelligentDialogueList(PageRequest.of(pageNum - 1, pageSize), searchKey);
+    public Page<IntelligentDialogueEntity> find(String searchKey, int pageNum, int pageSize, String beginDate, String endDate, String type) {
+        if (endDate != null && !endDate.equals("")){
+            endDate = endDate + " 23:59:59";
+        }
+        return this.repository.getIntelligentDialogueList(PageRequest.of(pageNum - 1, pageSize), searchKey, beginDate, endDate, type);
         /*Specification<IntelligentDialogueEntity> specification = (root, query, cb) -> {
             List<javax.persistence.criteria.Predicate> predicateList = new ArrayList<>();
             if(StringUtils.isNotBlank(identifier)){
@@ -58,8 +61,8 @@ public class IntelligentDialogueServiceImpl implements IntelligentDialogueServic
     }
 
     @Override
-    public List<IntelligentDialogueEntity> findByIdentifier(String identifier) {
-        return this.repository.findByIdentifier(identifier);
+    public List<IntelligentDialogueEntity> findByIdentifierAndType(String identifier, String type) {
+        return this.repository.findByIdentifierAndType(identifier, type);
     }
 
     @Override

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

@@ -0,0 +1,1754 @@
+package com.rf.kjb.scale.rest;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+//import com.rf.psychological.dao.dto.InstitutionRecordingUsersDTO;
+//import com.rf.psychological.scale.dao.dto.SubjectEntityDto2;
+//import com.rf.psychological.scale.dao.model.ScaleEntity;
+//import com.rf.psychological.scale.dao.model.SubjectEntity;
+//import com.rf.psychological.scale.dao.model.UserRecordEntity;
+//import com.rf.psychological.scale.service.*;
+//import com.rf.psychological.user.dao.model.UserEntity;
+//import com.rf.psychological.user.dao.model.UserFileEntity;
+//import com.rf.psychological.user.service.UserFileService;
+//import com.rf.psychological.user.service.UserService;
+//import com.rf.psychological.utils.*;
+//import com.rf.psychological.wxpay.model.PromotionInfo;
+//import com.rf.psychological.wxpay.service.PromotionInfoService;
+//import com.rf.psychological.wxpay.service.WxPayService;
+import com.rf.kjb.scale.dao.model.RecordEntity;
+import com.rf.kjb.scale.dao.model.SubjectEntity;
+import com.rf.kjb.scale.service.RecordService;
+import com.rf.kjb.scale.service.ScaleService;
+import com.rf.kjb.scale.service.SubjectService;
+import com.rf.kjb.user.dao.model.UserEntry;
+import com.rf.kjb.user.service.UserService;
+import com.rf.kjb.utils.Constant;
+import com.rf.kjb.utils.FileUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+//import jodd.util.StringUtil;
+import lombok.SneakyThrows;
+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.context.annotation.Profile;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+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.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import static com.rf.kjb.utils.FileUtil.html2pdf;
+
+//import static com.rf.psychological.utils.FileUtil.html2pdf;
+
+@Slf4j
+@RestController
+@RequestMapping("/result/download")
+@Api(tags = "数据下载接口")
+public class DataDownloadController {
+
+    @Autowired
+    private SubjectService subjectService;
+
+    @Autowired
+    private RecordService userRecordService;
+
+    @Autowired
+    private UserService userService;
+
+    @Autowired
+    private ScaleService scaleService;
+
+    /*@Autowired
+    private UserFileService userFileService;
+
+    @Autowired(required = false)
+    private WxPayService wxPayService;
+
+    @Autowired
+    private PromotionInfoService promotionInfoService;*/
+
+    /*@Value("${spring.profiles.active}")
+    private String profile;*/
+
+
+    //@SafetyProcess
+    @ApiOperation(value = "测试结果下载")
+    @GetMapping("/testResult")
+    public String downloadTestResult(String id, HttpServletResponse response) throws Exception {
+        if (id != null) {
+            RecordEntity userRecordEntity = this.userRecordService.getUserRecordById(id);
+            if (userRecordEntity == null) {
+                return "该记录异常,下载失败";
+            }
+            File file = null;
+            if (new File(userRecordEntity.getFileName()).exists()) {
+                file = new File(userRecordEntity.getFileName());
+                response.reset();
+                response.setContentType("application/octet-stream");
+                response.setCharacterEncoding("utf-8");
+                response.setContentLength((int) file.length());
+                response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(file.getName(), "UTF-8"));
+
+                byte[] buffer = new byte[1024];
+                FileInputStream fis = null;
+                BufferedInputStream bis = null;
+                try {
+                    fis = new FileInputStream(file);
+                    bis = new BufferedInputStream(fis);
+                    OutputStream os = response.getOutputStream();
+                    int i = bis.read(buffer);
+                    while (i != -1) {
+                        os.write(buffer, 0, i);
+                        i = bis.read(buffer);
+                    }
+                    return "下载成功";
+                } catch (Exception e) {
+                    e.printStackTrace();
+                } finally {
+                    if (bis != null) {
+                        try {
+                            bis.close();
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                    if (fis != null) {
+                        try {
+                            fis.close();
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+            } else {
+
+                String fileName = userRecordEntity.getFileName();
+                String testDate = userRecordEntity.getTestDate();
+                String name = subjectService.getSubjectByFlag(userRecordEntity.getFlag()).getName();
+                testDate = testDate.substring(0, 10);
+                testDate = testDate.replace("年", "-");
+                testDate = testDate.replace("月", "-");
+                //设置文件路径
+                file = new File("./心理检测/检测结果/" + testDate + "/" + name + "/" + fileName);
+                if (file.exists()) {
+                    response.reset();
+                    response.setContentType("application/octet-stream");
+                    response.setCharacterEncoding("utf-8");
+                    response.setContentLength((int) file.length());
+                    response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(fileName, "UTF-8"));
+
+                    byte[] buffer = new byte[1024];
+                    FileInputStream fis = null;
+                    BufferedInputStream bis = null;
+                    try {
+                        fis = new FileInputStream(file);
+                        bis = new BufferedInputStream(fis);
+                        OutputStream os = response.getOutputStream();
+                        int i = bis.read(buffer);
+                        while (i != -1) {
+                            os.write(buffer, 0, i);
+                            i = bis.read(buffer);
+                        }
+                        return "下载成功";
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    } finally {
+                        if (bis != null) {
+                            try {
+                                bis.close();
+                            } catch (IOException e) {
+                                e.printStackTrace();
+                            }
+                        }
+                        if (fis != null) {
+                            try {
+                                fis.close();
+                            } catch (IOException e) {
+                                e.printStackTrace();
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return "下载失败";
+    }
+
+    @ApiOperation(value = "下载PDF测试报告")
+    @GetMapping("/testResultPdf")
+    public String downloadTestResultPdf(String id, HttpServletResponse response) {
+        if (id != null) {
+            RecordEntity userRecordEntity = this.userRecordService.getUserRecordById(id);
+            if (userRecordEntity == null) {
+                return "该记录异常,下载失败";
+            }
+            String PDFPath = generatePDFRecord(userRecordEntity,"pdf");
+            if (PDFPath.equals("false")) {
+                return "报告版本较早,暂无法下载";
+            }
+            List<String> htmlFilePathList = new ArrayList<>();
+            htmlFilePathList.add(PDFPath);
+
+            //生成PDF测试记录
+            try {
+                html2pdf(htmlFilePathList);
+            } catch (Exception e) {
+                log.error("生成测试文件失败" + e.getMessage());
+                e.printStackTrace();
+                return "下载失败";
+            }
+            String[] split = userRecordEntity.getFileName().split("/");
+            String fileName = split[split.length - 1];
+            String PDFName = fileName.replace(".xlsx", ".pdf");
+            //下载PDF文件
+            File z = new File("./h2p/export_pdf/PDFReport/" + PDFName);
+            if (!z.exists()) return "下载失败";
+            try {
+                FileUtil.downloadFile(response, z, PDFName, true);
+                return "下载成功";
+            } catch (UnsupportedEncodingException e) {
+                log.error("下载文件失败:" + e.getMessage());
+                e.printStackTrace();
+                return "下载失败";
+            }
+        }
+        return "下载失败";
+    }
+
+    /*@Profile({"public"})
+    @ApiOperation(value = "下载量表测试报告图片")
+    @GetMapping("/testResultPng")
+    public String downloadTestResultPng(String id, HttpServletResponse response) {
+        if (id != null) {
+            UserRecordEntity userRecordEntity = this.userRecordService.getUserRecordById(id);
+            if (userRecordEntity == null) {
+                return "该记录异常,下载失败";
+            }
+            String link = null;
+            //if ("public".equals(profile)) {
+                link = this.wxPayService.generateWxCode("scaleTestResults/testResults/index",userRecordEntity.getId(),"release");
+            //}
+            userRecordEntity.setImg(link);
+            String PNGPath = generatePDFRecord(userRecordEntity,"trpng");
+            if (PNGPath.equals("false")) {
+                return "报告版本较早,暂无法下载";
+            }
+            List<String> htmlFilePathList = new ArrayList<>();
+            htmlFilePathList.add(PNGPath);
+
+            //生成图片测试记录
+            try {
+                Html2PNG.html2png(htmlFilePathList);
+            } catch (Exception e) {
+                log.error("生成测试文件失败" + e.getMessage());
+                e.printStackTrace();
+                return "下载失败";
+            }
+            String[] split = userRecordEntity.getFileName().split("/");
+            String fileName = split[split.length - 1];
+            String PNGName = fileName.replace(".xlsx", ".png");
+            //下载图片文件
+            File z = new File("./h2p/export_pdf/PDFReport/" + PNGName);
+            if (!z.exists()) return "下载失败";
+            try {
+                FileUtil.downloadFile(response, z, PNGName, true);
+                return "下载成功";
+            } catch (UnsupportedEncodingException e) {
+                log.error("下载文件失败:" + e.getMessage());
+                e.printStackTrace();
+                return "下载失败";
+            }
+        }
+        return "下载失败";
+    }
+
+    @ApiOperation(value = "下载量表详情图片")
+    @GetMapping("/scaleDetailPng")
+    public String downloadScaleDetailPng(String flag, HttpServletResponse response) {
+        SubjectEntity subjectEntity = this.subjectService.getSubjectEntityByFlag(flag);
+        if (subjectEntity != null) {
+            SubjectEntityDto2 subjectEntityDto2 = new SubjectEntityDto2(subjectEntity);
+            PromotionInfo infoBySubjectId = this.promotionInfoService.findInfoBySubjectId(subjectEntity.getId());
+            subjectEntityDto2.setPrice(infoBySubjectId == null ? 0.0:infoBySubjectId.getPrice());
+            List<ScaleEntity> scaleEntityList = this.scaleService.getScaleByFlag(subjectEntity.getFlag());
+            subjectEntityDto2.setTitleNum(scaleEntityList.size());
+            int estimatedTime = scaleEntityList.size() / Constant.TEST_PLAN_STATUS_RUNNING + (scaleEntityList.size() % Constant.TEST_PLAN_STATUS_RUNNING != 0 ? 1 : 0);
+            subjectEntityDto2.setEstimatedTime(estimatedTime);
+            JSONObject userRecordJson = new JSONObject(true);
+            userRecordJson.put("subjectEntityDto2",subjectEntityDto2);
+            userRecordJson.put("name",subjectEntityDto2.getName());
+            userRecordJson.put("link",this.wxPayService.generateWxCode("scalePage/beginTest/index",subjectEntityDto2.getFlag(),"release"));
+            String PNGPath = generateHTMLRecord(userRecordJson,"sdpng");
+            List<String> htmlFilePathList = new ArrayList<>();
+            htmlFilePathList.add(PNGPath);
+
+            //生成图片测试记录
+            try {
+                Html2PNG.html2png(htmlFilePathList);
+            } catch (Exception e) {
+                log.error("生成测试文件失败" + e.getMessage());
+                e.printStackTrace();
+                return "下载失败";
+            }
+            String[] split = PNGPath.split("/");
+            String fileName = split[split.length - 1];
+            String PNGName = fileName.replace(".html", ".png");
+            //下载图片文件
+            File z = new File("./h2p/export_pdf/PDFReport/" + PNGName);
+            if (!z.exists()) return "下载失败";
+            try {
+                FileUtil.downloadFile(response, z, PNGName, true);
+                return "下载成功";
+            } catch (UnsupportedEncodingException e) {
+                log.error("下载文件失败:" + e.getMessage());
+                e.printStackTrace();
+                return "下载失败";
+            }
+        }
+        return "下载失败";
+    }
+
+    @ApiOperation(value = "用户PDF报告全部下载")
+    @GetMapping("/allUserPDFReds")
+    public String downloadAllPDFTestResult(String institutionNo, String name, String searchKey, String beginTime, String endTime, String groupId, HttpServletResponse response) {
+        List<InstitutionRecordingUsersDTO> institutionUserRecordingList = this.userRecordService.getInstitution(institutionNo, name, searchKey, beginTime, endTime, groupId)
+                .stream().sorted(Comparator.comparing(InstitutionRecordingUsersDTO::getTestDate)).collect(Collectors.toList());
+        if (institutionUserRecordingList.isEmpty()) {
+            return "无测试记录";
+        }
+        List<String> htmlFilePathList = new ArrayList<>();
+        String PDFPath;
+        for (int i = 0; i < institutionUserRecordingList.size(); i++) {
+            UserRecordEntity userRecordEntity = new UserRecordEntity();
+            userRecordEntity.setFlag(institutionUserRecordingList.get(i).getFlag());
+            userRecordEntity.setPhone(institutionUserRecordingList.get(i).getPhone());
+            userRecordEntity.setInstitutionNo(institutionUserRecordingList.get(i).getInstitutionNo());
+            userRecordEntity.setFileName(institutionUserRecordingList.get(i).getFileName());
+            userRecordEntity.setName(institutionUserRecordingList.get(i).getName());
+            userRecordEntity.setTestResult(institutionUserRecordingList.get(i).getTestResult());
+            userRecordEntity.setType(institutionUserRecordingList.get(i).getType());
+            userRecordEntity.setTestResults(institutionUserRecordingList.get(i).getTestResults());
+            PDFPath = generatePDFRecord(userRecordEntity,"pdf");
+            if (!PDFPath.equals("false")) {
+                htmlFilePathList.add(PDFPath);
+            }
+        }
+        if (htmlFilePathList.size() < 1) {
+            return "下载失败";
+        }
+        String flag = h2pdownload(htmlFilePathList, response);
+        return flag;
+    }
+
+    @ApiOperation(value = "用户PDF报告批量下载")
+    @GetMapping("/userPDFReds")
+    public String downloadPDFTestResult(@RequestParam(value = "ids", required = false) List<String> recordingIds, HttpServletResponse response) {
+        List<String> htmlFilePathList = new ArrayList<>();
+        String PDFPath;
+        for (int i = 0; i < recordingIds.size(); i++) {
+            InstitutionRecordingUsersDTO recordingUsersDTO = this.userRecordService.getRecordingUsersDTOById(recordingIds.get(i));
+            if (recordingUsersDTO != null) {
+                UserRecordEntity userRecordEntity = new UserRecordEntity();
+                userRecordEntity.setFlag(recordingUsersDTO.getFlag());
+                userRecordEntity.setPhone(recordingUsersDTO.getPhone());
+                userRecordEntity.setInstitutionNo(recordingUsersDTO.getInstitutionNo());
+                userRecordEntity.setFileName(recordingUsersDTO.getFileName());
+                userRecordEntity.setName(recordingUsersDTO.getName());
+                userRecordEntity.setTestResult(recordingUsersDTO.getTestResult());
+                userRecordEntity.setType(recordingUsersDTO.getType());
+                userRecordEntity.setTestResults(recordingUsersDTO.getTestResults());
+                PDFPath = generatePDFRecord(userRecordEntity,"pdf");
+                if (!PDFPath.equals("false")) {
+                    htmlFilePathList.add(PDFPath);
+                }
+            }
+        }
+        if (htmlFilePathList.size() < 1) {
+            return "下载失败";
+        }
+        String flag = h2pdownload(htmlFilePathList, response);
+        return flag;
+    }*/
+
+    /**
+     * h2p并下载压缩包
+     * @param htmlFilePathList
+     * @return html 测试结果文件路径列表
+     */
+    /*private String h2pdownload(List<String> htmlFilePathList, HttpServletResponse response) {
+        //生成PDF测试记录
+        try {
+            html2pdf(htmlFilePathList);
+        } catch (Exception e) {
+            log.error("生成测试文件失败"+e.getMessage());
+            e.printStackTrace();
+            return "下载失败";
+        }
+        //打包PDF
+        String ZIPNAme = "PDFReport.zip";
+        ZipUtils.createZip("./h2p/export_pdf/PDFReport","./h2p/export_pdf/"+ZIPNAme,true);
+        //下载PDF压缩包
+        File z = new File("./h2p/export_pdf/"+ZIPNAme);
+        if(!z.exists())return "下载失败";
+        try {
+            FileUtil.downloadFile(response,z,ZIPNAme,true);
+        } catch (UnsupportedEncodingException  e) {
+            log.error("下载文件失败:"+e.getMessage());
+            e.printStackTrace();
+            return "下载失败";
+        }
+        return "下载成功";
+    }*/
+
+    /**
+     * 处理PDF报告数据格式
+     * @param userRecordEntity
+     * @return html 测试结果文件路径列表
+     */
+    private String generatePDFRecord(RecordEntity userRecordEntity,String type) {
+        UserEntry userEntity = this.userService.findByIdentifier(userRecordEntity.getIdentifier());
+        /*UserFileEntity userFileEntity = this.userFileService.findByUserId(userEntity.getId());
+        if (userFileEntity != null){
+            userEntity.setAvatarUrl(userFileEntity.getPath());
+        }*/
+        String[] split = userRecordEntity.getFileName().split("/");
+        String fileName = split[split.length-1];
+        fileName = fileName.replace(".xlsx","");
+        JSONObject userRecordJson = new JSONObject(true);
+        userRecordJson.put("userEntity",userEntity);
+        userRecordJson.put("userRecordEntity",userRecordEntity);
+
+        //测试记录文件名
+        userRecordJson.put("fileName",fileName);
+        //量表或认知任务名称
+        userRecordJson.put("name",subjectService.getSubjectByFlag(userRecordEntity.getFlag()).getName());
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String beginTime = df.format(new Date());
+        userRecordJson.put("reportTime",beginTime);
+        if (type.equals("trpng")){
+            userRecordJson.put("userInfo",userEntity);
+            userRecordJson.put("link",userRecordEntity.getImg());
+            userRecordEntity.setImg("");
+        }
+        String testResult = userRecordEntity.getTestResult();
+        //量表
+        //if (userRecordEntity.getType().equals(Constant.DEFAULT_VALUE_ZERO)){
+            JSONArray resultList = JSONArray.parseArray(testResult);
+            JSONObject resultJson = resultList.getJSONObject(0);
+            SubjectEntity subjectEntity = this.subjectService.getSubjectByFlag(userRecordEntity.getFlag());
+            userRecordJson.put("subject",subjectEntity);
+            if (testResult.contains("newTableContext") && resultJson.getInteger("version") == 2){
+                JSONObject newTableContext = resultJson.getJSONObject("newTableContext");
+                JSONArray result = newTableContext.getJSONArray("result");
+                userRecordJson.put("result",result);
+            }else {
+                if (testResult.contains("tableContext")){
+                    JSONArray tableContext = resultJson.getJSONArray("tableContext");
+                    userRecordJson.put("tableContext",tableContext);
+                }else {
+                    return "false";
+                }
+            }
+            //认知任务
+        /*}else {
+            String testResults = userRecordEntity.getTestResults();
+            String[] splits = testResults.split(";");
+            if (testResults.contains("version")){
+                JSONObject testResultJson = new JSONObject(true);
+                    int a = 0;
+                for (int x = 0; x < splits.length; x++) {
+                    if (a < 1 && (splits[x].contains("totalScoreDesc") || splits[x].contains("totalScore"))){
+                        String b = splits[x];
+                        JSONArray totalScores = JSONArray.parseArray(b.replace("totalScore:", ""));
+                        JSONObject totalScore = totalScores.getJSONObject(0);
+                        testResultJson.put("总分",totalScore.getString("totalScore"));
+                        testResultJson.put("总分结论",totalScore.getString("totalScoreDesc"));
+                        a ++;
+                    }
+                    if (splits[x].contains("Describe")){
+                        String b = splits[x];
+                        JSONArray dimensions = JSONArray.parseArray(b.replace("dimensions:", ""));
+                        for (int y = 0; y < dimensions.size(); y++) {
+                            JSONObject dimension = dimensions.getJSONObject(y);
+                            testResultJson.put(dimension.getString("name"),dimension.getString("score"));
+                            testResultJson.put(dimension.getString("name") + "结论",dimension.getString("Describe"));
+                        }
+                        a ++;
+                    }
+                    if (a < 1 && splits[x].contains("columnValue")){
+                        JSONArray tableModule = JSONObject.parseObject(userRecordEntity.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++){
+                            testResultJson.put(colName[y],colValue[y]);
+                        }
+                    }
+                }
+                Set<String> keys = testResultJson.keySet();
+                JSONArray tableContext = new JSONArray();
+                // 获取第一层每个key对应的值 的类型
+                for (String key : keys) {
+                    //列值
+                    List colValue = new ArrayList();
+                    colValue.add(testResultJson.get(key));
+                    JSONObject row = new JSONObject();
+                    row.put("name", key);
+                    row.put("value", colValue);
+                    tableContext.add(row);
+                }
+                userRecordJson.put("tableContext",tableContext);
+            }else {
+                if (testResult.contains("tableContext")){
+                    JSONArray tableContext = JSONArray.parseArray(testResult).getJSONObject(0).getJSONArray("tableContext");
+                    userRecordJson.put("tableContext",tableContext);
+                }else {
+                    return "false";
+                }
+            }
+
+
+
+        }*/
+
+        System.out.println("11:"+userRecordJson);
+        return generateHTMLRecord(userRecordJson,type);
+
+    }
+
+
+    /**
+     * 创建HTML测试结果
+     * @param userRecordJson
+     * @return html 测试结果文件路径列表
+     */
+    private String generateHTMLRecord(JSONObject userRecordJson,String type) {
+        BufferedReader in = null;
+        PrintWriter out = null;
+        File temp = new File("./h2p/export_pdf/PDFReport");
+        String link = null;
+        //模板html
+        String resourceFilePath;
+        //目标html
+        String destFilePath;
+        if (type.equals("pdf")){
+            resourceFilePath = "./h2p/export_pdf/export.html";
+            destFilePath = "./h2p/export_pdf/"+userRecordJson.getString("fileName")+".html";
+        }else if (type.equals("trpng")){
+            link = userRecordJson.getString("link");
+            userRecordJson.remove("link");
+            resourceFilePath = "./h2p/export_pdf/miniprogramReport.html";
+            destFilePath = "./h2p/export_pdf/"+userRecordJson.getString("fileName")+".html";
+        }else {
+            link = userRecordJson.getString("link");
+            userRecordJson.remove("link");
+            resourceFilePath = "./h2p/export_pdf/miniprogramScaleDetail.html";
+            destFilePath = "./h2p/export_pdf/"+userRecordJson.getString("name")+"-"+new SimpleDateFormat("yyyy年MM月dd日HH时mm分ss秒").format(new Date())+".html";
+        }
+        if (!temp.exists()) {
+            temp.mkdirs();
+        }
+        try {
+            in = new BufferedReader(new FileReader(resourceFilePath));
+            String line;
+            int count=1;
+            out = new PrintWriter(new BufferedWriter(new FileWriter(destFilePath)));
+            while((line=in.readLine())!=null){
+                if (type.equals("pdf")){
+                    if(count==313){
+                        out.println(line.replace("ReplaceData", JSON.toJSONString(userRecordJson)));  //替换
+                    }else{
+                        out.println(line);
+                    }
+                }else if (type.equals("trpng")){
+                    if(count==592){
+                        out.println(line.replace("ReplaceData", JSON.toJSONString(userRecordJson)));  //替换
+                    }else if (count==593){
+                        out.println(line.replace("base64img", JSON.toJSONString(link)));  //替换
+                    }else {
+                        out.println(line);
+                    }
+                }else {
+                    if(count==352){
+                        out.println(line.replace("scaleDetail", JSON.toJSONString(userRecordJson.get("subjectEntityDto2"))));  //替换
+                    }else if (count==353){
+                        out.println(line.replace("base64img", JSON.toJSONString(link)));  //替换
+                    }else{
+                        out.println(line);
+                    }
+                }
+                count++;
+            }
+            return destFilePath;
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }finally {
+            try {
+                assert in != null;
+                in.close();
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+            assert out != null;
+            out.close();
+        }
+    }
+
+    /*@ApiOperation(value = "认知任务图片下载")
+    @GetMapping("/CDTImg")
+    public String downloadCDTImg(String id, HttpServletResponse response) throws Exception {
+        if (id != null) {
+            UserRecordEntity userRecordEntity = this.userRecordService.getUserRecordById(id);
+            if (userRecordEntity == null) {
+                return "该记录异常,下载失败";
+            }
+            String fileName = userRecordEntity.getImg();
+            String name = userRecordEntity.getImg();
+            String[] names = name.split("/");
+            name = names[(names.length-1)];
+
+            File file = null;
+            file = new File(fileName);
+
+            if (file.exists()) {
+                response.reset();
+                response.setContentType("application/octet-stream");
+                response.setCharacterEncoding("utf-8");
+                response.setContentLength((int) file.length());
+                response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(name, "UTF-8"));
+
+                byte[] buffer = new byte[1024];
+                FileInputStream fis = null;
+                BufferedInputStream bis = null;
+                try {
+                    fis = new FileInputStream(file);
+                    bis = new BufferedInputStream(fis);
+                    OutputStream os = response.getOutputStream();
+                    int i = bis.read(buffer);
+                    while (i != -1) {
+                        os.write(buffer, 0, i);
+                        i = bis.read(buffer);
+                    }
+                    return "下载成功";
+                } catch (Exception e) {
+                    e.printStackTrace();
+                } finally {
+                    if (bis != null) {
+                        try {
+                            bis.close();
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                    if (fis != null) {
+                        try {
+                            fis.close();
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+            }
+        }
+        return "下载失败";
+    }*/
+
+    /*@ApiOperation(value = "用户测试结果全部下载")
+    @GetMapping("/allUserReds")
+    public String downloadAllTestResult(String institutionNo, String name, String searchKey, String beginTime, String endTime, String groupId, HttpServletResponse response) throws Exception {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+        Workbook wb = new XSSFWorkbook();
+        //循环往excel中放数据时先放的在下面,所以这里升序,往excel放数据时候就是降序
+        List<InstitutionRecordingUsersDTO> institutionUserRecordingList = this.userRecordService.getInstitution(institutionNo, name, searchKey, beginTime, endTime, groupId)
+                .stream().sorted(Comparator.comparing(InstitutionRecordingUsersDTO::getTestDate)).collect(Collectors.toList());
+        if (institutionUserRecordingList.isEmpty()) {
+            return "无测试记录";
+        }
+        List<InstitutionRecordingUsersDTO> newInstitutionUserRecordingList = new ArrayList<>();
+        List<InstitutionRecordingUsersDTO> oldInstitutionUserRecordingList = new ArrayList<>();
+        String[] newTitle = new String[0];
+        String[] oldTitle = new String[0];
+        for (int i = 0; i < institutionUserRecordingList.size(); i++) {
+            String testResults = institutionUserRecordingList.get(i).getTestResults();
+            String[] splits = testResults.split(";");
+            if (testResults.contains("version")){
+                newInstitutionUserRecordingList.add(institutionUserRecordingList.get(i));
+                String testResult = new String();
+                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");
+                            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 (splits[x].contains("totalScoreDesc")){
+                            String b = splits[x];
+                            JSONArray totalScores = JSONArray.parseArray(b.replace("totalScore:", ""));
+                            JSONObject totalScore = totalScores.getJSONObject(0);
+                            testResult += "总分:" + totalScore.getString("totalScore")+";总分结论:"+totalScore.getString("totalScoreDesc")+";";
+                        }
+                        if (splits[x].contains("Describe")){
+                            String b = splits[x];
+                            JSONArray dimensions = JSONArray.parseArray(b.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") + ";";
+                            }
+                        }
+                    }
+                }
+                splits = testResult.split(";");
+                //标题行抽出字段
+                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 + 7] = a[0];
+
+                }
+            }else {
+                oldInstitutionUserRecordingList.add(institutionUserRecordingList.get(i));
+
+                //标题行抽出字段
+                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 + 7] = a[0];
+
+                }
+            }
+        }
+
+        //设置sheet名称,并创建新的sheet对象
+        String newSheetName = "用户测试结果新结构导出";
+        String oldSheetName = "用户测试结果老结构导出";
+        if (newInstitutionUserRecordingList.size() > 0){
+            Sheet newDownSheet = wb.createSheet(newSheetName);
+            wb = insertData(newDownSheet,wb,newTitle,newInstitutionUserRecordingList,name);
+        }
+        if (oldInstitutionUserRecordingList.size() > 0){
+            Sheet oldDownSheet = wb.createSheet(oldSheetName);
+            wb = insertData(oldDownSheet,wb,oldTitle,oldInstitutionUserRecordingList,name);
+        }
+
+
+        String foldDir = null;
+        //获取配置文件中保存对应excel文件的路径,本地也可以直接写成F:excel/stuInfoExcel路径
+        foldDir = "./心理检测/检测结果/" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + "/" + "用户测试结果导出";
+        //创建上传文件目录
+        File fileDir = new File(foldDir);
+
+        //如果文件夹不存在创建对应的文件夹
+        if (!fileDir.exists()) {
+            fileDir.mkdirs();
+        }
+        String testTime = new SimpleDateFormat("yyyy年MM月dd日HH时mm分ss秒").format(new Date());
+        //设置文件名
+        String fileName = institutionNo + "-" + name + "-" + testTime + ".xlsx";
+
+        OutputStream fileOut = new FileOutputStream(foldDir + "/" + fileName);
+        wb.write(fileOut);
+        fileOut.close();
+
+        File file = new File(foldDir + "/" + fileName);
+        if (file.exists()) {
+            if (name.equals(Constant.SHEET_NAME_CDT) || name.equals(Constant.SHEET_NAME_DSST)) {
+                File[] srcFiles = new File[institutionUserRecordingList.size() + 1];
+                int size = institutionUserRecordingList.size();
+                for (int i = 0; i < size; i++) {
+                    if (!StringUtil.isEmpty(institutionUserRecordingList.get(i).getImg())) {
+                        srcFiles[i] = new File(institutionUserRecordingList.get(i).getImg());
+                    }
+                }
+
+                srcFiles[institutionUserRecordingList.size()] = new File(foldDir + "/" + fileName);
+                File zipFile = new File(foldDir + "/" + name + ".zip");
+                // 调用压缩方法
+                zipFiles(srcFiles, zipFile);
+                response.reset();
+                response.setContentType("application/octet-stream");
+                response.setCharacterEncoding("utf-8");
+                response.setContentLength((int) zipFile.length());
+                response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(name + ".zip", "UTF-8"));
+
+                byte[] buffer = new byte[1024];
+                FileInputStream fis = null;
+                BufferedInputStream bis = null;
+                try {
+                    fis = new FileInputStream(zipFile);
+                    bis = new BufferedInputStream(fis);
+                    OutputStream os = response.getOutputStream();
+                    int i = bis.read(buffer);
+                    while (i != -1) {
+                        os.write(buffer, 0, i);
+                        i = bis.read(buffer);
+                    }
+                    return "下载成功";
+                } catch (Exception e) {
+                    e.printStackTrace();
+                } finally {
+                    if (bis != null) {
+                        try {
+                            bis.close();
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                    if (fis != null) {
+                        try {
+                            fis.close();
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+            } else {
+                response.reset();
+                response.setContentType("application/octet-stream");
+                response.setCharacterEncoding("utf-8");
+                response.setContentLength((int) file.length());
+                response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(fileName, "UTF-8"));
+
+                byte[] buffer = new byte[1024];
+                FileInputStream fis = null;
+                BufferedInputStream bis = null;
+                try {
+                    fis = new FileInputStream(file);
+                    bis = new BufferedInputStream(fis);
+                    OutputStream os = response.getOutputStream();
+                    int i = bis.read(buffer);
+                    while (i != -1) {
+                        os.write(buffer, 0, i);
+                        i = bis.read(buffer);
+                    }
+                    return "下载成功";
+                } catch (Exception e) {
+                    e.printStackTrace();
+                } finally {
+                    if (bis != null) {
+                        try {
+                            bis.close();
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                    if (fis != null) {
+                        try {
+                            fis.close();
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+            }
+        }
+
+        return "下载失败";
+    }
+
+    @ApiOperation(value = "用户测试结果批量导出下载")
+    @GetMapping("/userReds")
+    public String downloadTestResult(@RequestParam(value = "ids", required = false) List<String> recordingIds, String institutionNo, String name, HttpServletResponse response) throws Exception {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+        Workbook wb = new XSSFWorkbook();
+        List<InstitutionRecordingUsersDTO> institutionUserRecordingList = new ArrayList<>();
+        for (int i = 0; i < recordingIds.size(); i++) {
+            InstitutionRecordingUsersDTO recordingUsersDTO = this.userRecordService.getRecordingUsersDTOById(recordingIds.get(recordingIds.size()-i-1));
+            if (recordingUsersDTO != null){
+                institutionUserRecordingList.add(recordingUsersDTO);
+            }
+        }
+        institutionUserRecordingList.stream().sorted(Comparator.comparing(InstitutionRecordingUsersDTO::getTestDate)).collect(Collectors.toList());
+
+
+        List<InstitutionRecordingUsersDTO> newInstitutionUserRecordingList = new ArrayList<>();
+        List<InstitutionRecordingUsersDTO> oldInstitutionUserRecordingList = new ArrayList<>();
+        String[] newTitle = new String[0];
+        String[] oldTitle = new String[0];
+        for (int i = 0; i < institutionUserRecordingList.size(); i++) {
+            String testResults = institutionUserRecordingList.get(i).getTestResults();
+            String[] splits = testResults.split(";");
+            if (testResults.contains("version")){
+                newInstitutionUserRecordingList.add(institutionUserRecordingList.get(i));
+                //institutionUserRecordingList.remove(i);
+                //i--;
+                String testResult = new String();
+                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");
+                            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 (splits[x].contains("totalScoreDesc")){
+                            String b = splits[x];
+                            JSONArray totalScores = JSONArray.parseArray(b.replace("totalScore:", ""));
+                            JSONObject totalScore = totalScores.getJSONObject(0);
+                            testResult += "总分:" + totalScore.getString("totalScore")+";总分结论:"+totalScore.getString("totalScoreDesc")+";";
+                        }
+                        if (splits[x].contains("Describe")){
+                            String b = splits[x];
+                            JSONArray dimensions = JSONArray.parseArray(b.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") + ";";
+                            }
+                        }
+                    }
+
+                }
+                splits = testResult.split(";");
+                //标题行抽出字段
+                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 + 7] = a[0];
+
+                }
+            }else {
+                oldInstitutionUserRecordingList.add(institutionUserRecordingList.get(i));
+
+                //标题行抽出字段
+                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 + 7] = a[0];
+
+                }
+            }
+        }
+
+        //设置sheet名称,并创建新的sheet对象
+        String newSheetName = "用户测试结果新结构导出";
+        String oldSheetName = "用户测试结果老结构导出";
+        if (newInstitutionUserRecordingList.size() > 0){
+            Sheet newDownSheet = wb.createSheet(newSheetName);
+            wb = insertData(newDownSheet,wb,newTitle,newInstitutionUserRecordingList,name);
+        }
+        if (oldInstitutionUserRecordingList.size() > 0){
+            Sheet oldDownSheet = wb.createSheet(oldSheetName);
+            wb = insertData(oldDownSheet,wb,oldTitle,oldInstitutionUserRecordingList,name);
+        }
+
+        String foldDir = null;
+        //获取配置文件中保存对应excel文件的路径,本地也可以直接写成F:excel/stuInfoExcel路径
+        foldDir = "./心理检测/检测结果/" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + "/" + "用户测试结果导出";
+        //创建上传文件目录
+        File fileDir = new File(foldDir);
+
+        //如果文件夹不存在创建对应的文件夹
+        if (!fileDir.exists()) {
+            fileDir.mkdirs();
+        }
+        String testTime = new SimpleDateFormat("yyyy年MM月dd日HH时mm分ss秒").format(new Date());
+        //设置文件名
+        String fileName = institutionNo + "-" + name + "-" + testTime + ".xlsx";
+
+        OutputStream fileOut = new FileOutputStream(foldDir + "/" + fileName);
+        wb.write(fileOut);
+        fileOut.close();
+
+        File file = new File(foldDir + "/" + fileName);
+        if (file.exists()) {
+            if (name.equals(Constant.SHEET_NAME_CDT) || name.equals(Constant.SHEET_NAME_DSST)) {
+                File[] srcFiles = new File[institutionUserRecordingList.size() + 1];
+                int size = institutionUserRecordingList.size();
+                for (int i = 0; i < size; i++) {
+                    if (!StringUtil.isEmpty(institutionUserRecordingList.get(i).getImg())) {
+                        srcFiles[i] = new File(institutionUserRecordingList.get(i).getImg());
+                    }
+                }
+
+                srcFiles[institutionUserRecordingList.size()] = new File(foldDir + "/" + fileName);
+                //srcFiles[recordingIds.size()] = new File(foldDir + "/" + fileName);
+                File zipFile = new File(foldDir + "/" + name + ".zip");
+                // 调用压缩方法
+                zipFiles(srcFiles, zipFile);
+                response.reset();
+                response.setContentType("application/octet-stream");
+                response.setCharacterEncoding("utf-8");
+                response.setContentLength((int) zipFile.length());
+                response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(name + ".zip", "UTF-8"));
+
+                byte[] buffer = new byte[1024];
+                FileInputStream fis = null;
+                BufferedInputStream bis = null;
+                try {
+                    fis = new FileInputStream(zipFile);
+                    bis = new BufferedInputStream(fis);
+                    OutputStream os = response.getOutputStream();
+                    int i = bis.read(buffer);
+                    while (i != -1) {
+                        os.write(buffer, 0, i);
+                        i = bis.read(buffer);
+                    }
+                    return "下载成功";
+                } catch (Exception e) {
+                    e.printStackTrace();
+                } finally {
+                    if (bis != null) {
+                        try {
+                            bis.close();
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                    if (fis != null) {
+                        try {
+                            fis.close();
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+            } else {
+                response.reset();
+                response.setContentType("application/octet-stream");
+                response.setCharacterEncoding("utf-8");
+                response.setContentLength((int) file.length());
+                response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(fileName, "UTF-8"));
+
+                byte[] buffer = new byte[1024];
+                FileInputStream fis = null;
+                BufferedInputStream bis = null;
+                try {
+                    fis = new FileInputStream(file);
+                    bis = new BufferedInputStream(fis);
+                    OutputStream os = response.getOutputStream();
+                    int i = bis.read(buffer);
+                    while (i != -1) {
+                        os.write(buffer, 0, i);
+                        i = bis.read(buffer);
+                    }
+                    return "下载成功";
+                } catch (Exception e) {
+                    e.printStackTrace();
+                } finally {
+                    if (bis != null) {
+                        try {
+                            bis.close();
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                    if (fis != null) {
+                        try {
+                            fis.close();
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+            }
+
+        }
+
+        return "下载失败";
+    }
+
+    @SneakyThrows
+    @ApiOperation(value = "原始数据批量下载接口")
+    @GetMapping("/planResultBatch")
+    public String downloadPlanResultBatch(@RequestParam(value = "ids", required = false) List<String> recordingIds,HttpServletResponse response) {
+
+        //原始记录文件
+        File file = null;
+        //原始记录复制后文件
+        File destFile = null;
+        //查找原始记录路径文件夹名称
+        String testDate;
+        //查找原始记录路径文件夹名称
+        String folderName = null;
+        //所有记录汇总后文件夹,用来压缩
+        String filePath ="./心理检测/答题记录";
+        //原始记录文件名
+        String fileName = null;
+        for (int i = 0; i < recordingIds.size(); i++) {
+            UserRecordEntity userRecordEntity = this.userRecordService.getUserRecordById(recordingIds.get(i));
+            String[] split = userRecordEntity.getFileName().split("/");
+            if (split.length > 1){
+                //if (new File(userRecordEntity.getFileName()).exists()){
+                fileName = split[split.length-1];
+            }else {
+                fileName = userRecordEntity.getFileName();
+            }
+            testDate = userRecordEntity.getTestDate();
+            folderName = userRecordEntity.getName();
+            testDate = testDate.substring(0, 10);
+            testDate = testDate.replace("年", "-");
+            testDate = testDate.replace("月", "-");
+            //设置文件路径
+            file = new File("./心理检测/检测结果/" + testDate + "/" + folderName + "/" + fileName);
+            if (file.exists()){
+                destFile = new File(filePath+"/"+folderName+"/"+userRecordEntity.getPhone()+"-"+userRecordEntity.getTestDate()+"-"+folderName+".xlsx");
+                //将原始文件进行复制
+                FileUtils.copyFile(file, destFile);
+            }
+
+        }
+
+        //将复制后的整个文件夹打包
+        ZipUtils.createZip(filePath, filePath + ".zip", true);
+
+        File zipFile = new File(filePath + ".zip");
+        //下载压缩后文件
+        if (zipFile.exists()) {
+            response.reset();
+            response.setContentType("application/octet-stream");
+            response.setCharacterEncoding("utf-8");
+            response.setContentLength((int) zipFile.length());
+            response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode("answerRecord.zip", "UTF-8"));
+
+            byte[] buffer = new byte[1024];
+            FileInputStream fis = null;
+            BufferedInputStream bis = null;
+            try {
+                fis = new FileInputStream(zipFile);
+                bis = new BufferedInputStream(fis);
+                OutputStream os = response.getOutputStream();
+                int i = bis.read(buffer);
+                while (i != -1) {
+                    os.write(buffer, 0, i);
+                    i = bis.read(buffer);
+                }
+
+                return "下载成功";
+            } catch (Exception e) {
+                e.printStackTrace();
+            } finally {
+                if (bis != null) {
+                    try {
+                        bis.close();
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                }
+                if (fis != null) {
+                    try {
+                        fis.close();
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                }
+                //将复制后的整个文件夹删除
+                Path path = Paths.get(filePath);
+                try (Stream<Path> walk = Files.walk(path)) {
+                    walk.sorted(Comparator.reverseOrder())
+                            .forEach(DataDownloadController::deleteDirectoryStream);
+                }
+                //删除生成的压缩包
+                Files.delete(Paths.get(filePath + ".zip"));
+            }
+        }
+
+        //删除生成的压缩包
+        Files.delete(Paths.get(filePath + ".zip"));
+        //将复制后的整个文件夹删除
+        Path path = Paths.get(filePath);
+        try (Stream<Path> walk = Files.walk(path)) {
+            walk.sorted(Comparator.reverseOrder())
+                    .forEach(DataDownloadController::deleteDirectoryStream);
+        }
+
+        return "下载失败";
+    }
+
+
+    @SneakyThrows
+    @ApiOperation(value = "原始数据全部下载接口")
+    @GetMapping("/planResultAll")
+    public String downloadPlanResultAll(String institutionNo, String name, String searchKey, String beginTime, String endTime, String groupId, HttpServletResponse response) {
+
+        //原始记录文件
+        File file = null;
+        //原始记录复制后文件
+        File destFile = null;
+        //查找原始记录路径文件夹名称
+        String testDate;
+        //查找原始记录路径文件夹名称
+        String folderName = null;
+        //所有记录汇总后文件夹,用来压缩
+        String filePath ="./心理检测/答题记录";
+        //原始记录文件名
+        String fileName = null;
+        List<InstitutionRecordingUsersDTO> institutionUserRecordingList = this.userRecordService.getInstitution(institutionNo, name, searchKey, beginTime, endTime, groupId)
+                .stream().sorted(Comparator.comparing(InstitutionRecordingUsersDTO::getTestDate)).collect(Collectors.toList());
+        if (institutionUserRecordingList.isEmpty()) {
+            return "无测试记录";
+        }
+        for (int i = 0; i < institutionUserRecordingList.size(); i++) {
+            InstitutionRecordingUsersDTO userRecordEntity = institutionUserRecordingList.get(i);
+
+            if (new File(userRecordEntity.getFileName()).exists()){
+                String[] split = userRecordEntity.getFileName().split("/");
+                fileName = split[split.length-1];
+            }else {
+                fileName = userRecordEntity.getFileName();
+            }
+
+            testDate = userRecordEntity.getTestDate();
+            folderName = userRecordEntity.getName();
+            testDate = testDate.substring(0,10);
+            testDate = testDate.replace("年","-");
+            testDate = testDate.replace("月","-");
+            //设置文件路径
+            file = new File("./心理检测/检测结果/" + testDate + "/" + folderName + "/" + fileName);
+            destFile = new File(filePath+"/"+folderName+"/"+userRecordEntity.getPhone()+"-"+userRecordEntity.getTestDate()+"-"+folderName+".xlsx");
+
+            //将原始文件进行复制
+            FileUtils.copyFile(file, destFile);
+
+        }
+
+        //将复制后的整个文件夹打包
+        ZipUtils.createZip(filePath,filePath+".zip",true);
+
+        File zipFile = new File(filePath+".zip");
+        //下载压缩后文件
+        if (zipFile.exists()) {
+            response.reset();
+            response.setContentType("application/octet-stream");
+            response.setCharacterEncoding("utf-8");
+            response.setContentLength((int) zipFile.length());
+            response.setHeader("Content-Disposition", "attachment;filename="+ java.net.URLEncoder.encode("answerRecord.zip", "UTF-8"));
+
+            byte[] buffer = new byte[1024];
+            FileInputStream fis = null;
+            BufferedInputStream bis = null;
+            try {
+                fis = new FileInputStream(zipFile);
+                bis = new BufferedInputStream(fis);
+                OutputStream os = response.getOutputStream();
+                int i = bis.read(buffer);
+                while (i != -1) {
+                    os.write(buffer, 0, i);
+                    i = bis.read(buffer);
+                }
+
+                return "下载成功";
+            } catch (Exception e) {
+                e.printStackTrace();
+            } finally {
+                if (bis != null) {
+                    try {
+                        bis.close();
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                }
+                if (fis != null) {
+                    try {
+                        fis.close();
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                }
+                //将复制后的整个文件夹删除
+                Path path = Paths.get(filePath);
+                try (Stream<Path> walk = Files.walk(path)) {
+                    walk.sorted(Comparator.reverseOrder())
+                            .forEach(DataDownloadController::deleteDirectoryStream);
+                }
+                //删除生成的压缩包
+                Files.delete(Paths.get(filePath+".zip"));
+            }
+        }
+
+        //删除生成的压缩包
+        Files.delete(Paths.get(filePath+".zip"));
+        //将复制后的整个文件夹删除
+        Path path = Paths.get(filePath);
+        try (Stream<Path> walk = Files.walk(path)) {
+            walk.sorted(Comparator.reverseOrder())
+                    .forEach(DataDownloadController::deleteDirectoryStream);
+        }
+
+        return "下载失败";
+
+    }*/
+
+
+    /*@SneakyThrows
+    @ApiOperation(value = "答题记录合并批量下载接口")
+    @GetMapping("/answerRecordBatch")
+    public String downloadAnswerRecordBatch(@RequestParam(value = "ids", required = false) List<String> recordingIds,HttpServletResponse response) {
+
+        //原始记录文件
+        File file = null;
+        //汇总后文件路径
+        String destFilePath = null;
+        //查找原始记录路径文件夹名称
+        String testDate;
+        //查找原始记录路径文件夹名称
+        String folderName = null;
+        //所有记录汇总后文件夹,用来压缩
+        String filePath ="./心理检测";
+        //原始记录文件名
+        String fileName = null;
+
+        List<String> headList = new ArrayList<>();
+        List<List<String>> contentList = new ArrayList<>();
+        for (int i = 0; i < recordingIds.size(); i++) {
+            UserRecordEntity userRecordEntity = this.userRecordService.getUserRecordById(recordingIds.get(i));
+            String[] split = userRecordEntity.getFileName().split("/");
+            if (split.length > 1){
+                //if (new File(userRecordEntity.getFileName()).exists()){
+                fileName = split[split.length-1];
+            }else {
+                fileName = userRecordEntity.getFileName();
+            }
+            testDate = userRecordEntity.getTestDate();
+            folderName = userRecordEntity.getName();
+            testDate = testDate.substring(0, 10);
+            testDate = testDate.replace("年", "-");
+            testDate = testDate.replace("月", "-");
+            //设置文件路径
+            file = new File("./心理检测/检测结果/" + testDate + "/" + folderName + "/" + fileName);
+            if (file.exists()){
+                try {
+                    List<List<List<Object>>> datas = ExcelUtil.getBankListByExcelSheetV2(new FileInputStream(file.getAbsolutePath()), file.getName());
+                    List<String> content2 = new ArrayList<>();
+                    List<List<Object>> sheet0 = datas.get(0);
+                    for (int y = 0; y < sheet0.size(); y++) {
+                        List<Object> scales = sheet0.get(y);
+                        //创建表头
+                        if (i == 0){
+                            if (y == (sheet0.size() - 2)){
+                                for (Object scale : scales){
+                                    headList.add(scale.toString());
+                                }
+                            }else if (y == (sheet0.size() - 1)){
+
+                            }else {
+                                headList.add(scales.get(1).toString());
+                            }
+                        }
+                        //创建数据
+                        if (y == (sheet0.size() - 2)){
+
+                        }else if (y == (sheet0.size() - 1)){
+                            for (Object scale : scales){
+                                content2.add(scale.toString());
+                            }
+                        }else {
+                            content2.add(scales.get(2).toString());
+                        }
+                    }
+                    contentList.add(content2);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        WriteToExcel.setSheet(folderName);                        //创建sheet页
+        WriteToExcel.createHead(headList);                         //设置表头
+        WriteToExcel.createContent(contentList);                   //设置内容
+        destFilePath = filePath+"/"+new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())+"/"+folderName+".xls";
+        WriteToExcel.writeToFile(destFilePath);         //写入文件
+
+        File destFile = new File(destFilePath);
+        response.reset();
+        response.setContentType("application/octet-stream");
+        response.setCharacterEncoding("utf-8");
+        response.setContentLength((int) destFile.length());
+        response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(destFile.getName(), "UTF-8"));
+
+        byte[] buffer = new byte[1024];
+        FileInputStream fis = null;
+        BufferedInputStream bis = null;
+        try {
+            fis = new FileInputStream(destFile);
+            bis = new BufferedInputStream(fis);
+            OutputStream os = response.getOutputStream();
+            int i = bis.read(buffer);
+            while (i != -1) {
+                os.write(buffer, 0, i);
+                i = bis.read(buffer);
+            }
+            return "下载成功";
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (bis != null) {
+                try {
+                    bis.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (fis != null) {
+                try {
+                    fis.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            //删除生成的文件
+            Files.delete(Paths.get(destFilePath));
+        }
+        return "下载失败";
+    }
+
+    @SneakyThrows
+    @ApiOperation(value = "答题记录合并全部下载接口")
+    @GetMapping("/answerRecordAll")
+    public String downloadAnswerRecordAll(String institutionNo, String name, String searchKey, String beginTime, String endTime, String groupId, HttpServletResponse response) {
+
+        //原始记录文件
+        File file = null;
+        //汇总后文件路径
+        String destFilePath = null;
+        //查找原始记录路径文件夹名称
+        String testDate;
+        //查找原始记录路径文件夹名称
+        String folderName = null;
+        //所有记录汇总后文件夹,用来压缩
+        String filePath ="./心理检测";
+        //原始记录文件名
+        String fileName = null;
+
+        List<String> headList = new ArrayList<>();
+        List<List<String>> contentList = new ArrayList<>();
+
+        List<InstitutionRecordingUsersDTO> institutionUserRecordingList = this.userRecordService.getInstitution(institutionNo, name, searchKey, beginTime, endTime, groupId)
+                .stream().sorted(Comparator.comparing(InstitutionRecordingUsersDTO::getTestDate)).collect(Collectors.toList());
+        if (institutionUserRecordingList.isEmpty()) {
+            return "无测试记录";
+        }
+        for (int i = 0; i < institutionUserRecordingList.size(); i++) {
+            InstitutionRecordingUsersDTO userRecordEntity = institutionUserRecordingList.get(i);
+            String[] split = userRecordEntity.getFileName().split("/");
+            if (split.length > 1){
+                //if (new File(userRecordEntity.getFileName()).exists()){
+                fileName = split[split.length-1];
+            }else {
+                fileName = userRecordEntity.getFileName();
+            }
+            testDate = userRecordEntity.getTestDate();
+            folderName = userRecordEntity.getName();
+            testDate = testDate.substring(0, 10);
+            testDate = testDate.replace("年", "-");
+            testDate = testDate.replace("月", "-");
+            //设置文件路径
+            file = new File("./心理检测/检测结果/" + testDate + "/" + folderName + "/" + fileName);
+            if (file.exists()){
+                try {
+                    List<List<List<Object>>> datas = ExcelUtil.getBankListByExcelSheetV2(new FileInputStream(file.getAbsolutePath()), file.getName());
+                    List<String> content2 = new ArrayList<>();
+                    List<List<Object>> sheet0 = datas.get(0);
+                    for (int y = 0; y < sheet0.size(); y++) {
+                        List<Object> scales = sheet0.get(y);
+                        //创建表头
+                        if (i == 0){
+                            if (y == (sheet0.size() - 2)){
+                                for (Object scale : scales){
+                                    headList.add(scale.toString());
+                                }
+                            }else if (y == (sheet0.size() - 1)){
+
+                            }else {
+                                headList.add(scales.get(1).toString());
+                            }
+                        }
+                        //创建数据
+                        if (y == (sheet0.size() - 2)){
+
+                        }else if (y == (sheet0.size() - 1)){
+                            for (Object scale : scales){
+                                content2.add(scale.toString());
+                            }
+                        }else {
+                            content2.add(scales.get(2).toString());
+                        }
+                    }
+                    contentList.add(content2);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        WriteToExcel.setSheet(folderName);                        //创建sheet页
+        WriteToExcel.createHead(headList);                         //设置表头
+        WriteToExcel.createContent(contentList);                   //设置内容
+        destFilePath = filePath+"/"+folderName+"-"+new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())+".xls";
+        WriteToExcel.writeToFile(destFilePath);         //写入文件
+
+        File destFile = new File(destFilePath);
+        response.reset();
+        response.setContentType("application/octet-stream");
+        response.setCharacterEncoding("utf-8");
+        response.setContentLength((int) destFile.length());
+        response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(destFile.getName(), "UTF-8"));
+
+        byte[] buffer = new byte[1024];
+        FileInputStream fis = null;
+        BufferedInputStream bis = null;
+        try {
+            fis = new FileInputStream(destFile);
+            bis = new BufferedInputStream(fis);
+            OutputStream os = response.getOutputStream();
+            int i = bis.read(buffer);
+            while (i != -1) {
+                os.write(buffer, 0, i);
+                i = bis.read(buffer);
+            }
+            return "下载成功";
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (bis != null) {
+                try {
+                    bis.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (fis != null) {
+                try {
+                    fis.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            //删除生成的文件
+            Files.delete(Paths.get(destFilePath));
+        }
+        return "下载失败";
+    }*/
+
+    public static void zipFiles(File[] srcFiles, File zipFile) {
+        // 判断压缩后的文件存在不,不存在则创建
+        if (!zipFile.exists()) {
+            try {
+                zipFile.createNewFile();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        // 创建 FileOutputStream 对象
+        FileOutputStream fileOutputStream = null;
+        // 创建 ZipOutputStream
+        ZipOutputStream zipOutputStream = null;
+        // 创建 FileInputStream 对象
+        FileInputStream fileInputStream = null;
+
+        try {
+            // 实例化 FileOutputStream 对象
+            fileOutputStream = new FileOutputStream(zipFile);
+            // 实例化 ZipOutputStream 对象
+            zipOutputStream = new ZipOutputStream(fileOutputStream);
+            // 创建 ZipEntry 对象
+            ZipEntry zipEntry = null;
+            // 遍历源文件数组
+            for (int i = 0; i < srcFiles.length; i++) {
+                // 将源文件数组中的当前文件读入 FileInputStream 流中
+                fileInputStream = new FileInputStream(srcFiles[i]);
+                // 实例化 ZipEntry 对象,源文件数组中的当前文件
+                zipEntry = new ZipEntry(srcFiles[i].getName());
+                zipOutputStream.putNextEntry(zipEntry);
+                // 该变量记录每次真正读的字节个数
+                int len;
+                // 定义每次读取的字节数组
+                byte[] buffer = new byte[1024];
+                while ((len = fileInputStream.read(buffer)) > 0) {
+                    zipOutputStream.write(buffer, 0, len);
+                }
+            }
+            zipOutputStream.closeEntry();
+            zipOutputStream.close();
+            fileInputStream.close();
+            fileOutputStream.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+    }
+
+    /**
+     * 将Map字符串转换为Map
+     *
+     * @param
+     * @return
+     */
+    /*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);
+            int colWidth = downSheet.getColumnWidth(i) * 2;
+            if (colWidth < 255 * 256) {
+                downSheet.setColumnWidth(i, Math.max(colWidth, 3000));
+            } else {
+                downSheet.setColumnWidth(i, 6000);
+            }
+        }
+        //获取表头行
+        Row titleRow = downSheet.createRow(0);
+        //创建单元格,设置style居中,字体,单元格大小等
+        CellStyle style = wb.createCellStyle();
+        //设置水平对齐的样式为居中对齐;
+        style.setAlignment(HorizontalAlignment.CENTER);
+        //设置垂直对齐的样式为居中对齐;
+        style.setVerticalAlignment(VerticalAlignment.CENTER);
+        Cell cell = null;
+        //把已经写好的标题行写入excel文件中
+        for (int i = 0; i < title.length; i++) {
+            cell = titleRow.createCell(i);
+            cell.setCellValue(title[i]);
+            cell.setCellStyle(style);
+        }
+        //把从数据库中取得的数据一一写入excel文件中
+        Row row = null;
+
+        int size = institutionUserRecordingList.size();
+        for (int i = 0; i < size; i++) {
+            InstitutionRecordingUsersDTO institutionRecordingUsersDTO = institutionUserRecordingList.get(institutionUserRecordingList.size() - i - 1);
+            String testResultls = institutionRecordingUsersDTO.getTestResults();
+            String[] splitl = testResultls.split(";");
+            if (testResultls.contains("version")){
+                String testResultl = new String();
+                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 cell4 = row.createCell(4);
+            cell4.setCellValue(institutionRecordingUsersDTO.getPhone());
+            cell4.setCellStyle(style);
+            Cell cell5 = row.createCell(5);
+            cell5.setCellValue(institutionRecordingUsersDTO.getTestDate());
+            cell5.setCellStyle(style);
+            Cell cell6 = row.createCell(6);
+            cell6.setCellValue(name);
+            cell6.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 + 7);
+                if (a.length < 2){
+                    rowCell.setCellValue("无");
+                }else {
+                    rowCell.setCellValue(a[1]);
+                }
+                rowCell.setCellStyle(style);
+            }
+        }
+
+        return wb;
+    }*/
+
+    private static void deleteDirectoryStream(Path path) {
+        try {
+            Files.delete(path);
+            //System.out.printf("删除文件成功:%s%n",path.toString());
+        } catch (IOException e) {
+            //System.err.printf("无法删除的路径 %s%n%s", path, e);
+        }
+    }
+
+}

+ 51 - 101
src/main/java/com/rf/kjb/scale/scaleResult/C16PFTScaleNEW.java

@@ -14,6 +14,8 @@ import java.text.DecimalFormat;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import static com.rf.kjb.scale.scaleResult.NEWCOMMONScaleNEW.commonComputeDimensionScore;
+
 /**
  * @Author: GaoYiXuan
  * @Description:
@@ -31,7 +33,7 @@ public class C16PFTScaleNEW extends BaseScale {
         //总分
         double score = 0;
         DecimalFormat df = new DecimalFormat("######0.00");
-        //结果列表
+
         Map<String, String> resultMap0 = new LinkedHashMap<>();
         List<Map<String, String>> resultMapList = new ArrayList<>();
         //新版本数据格式
@@ -43,56 +45,29 @@ public class C16PFTScaleNEW extends BaseScale {
         List<ScaleMarksEntity> scaleMarksEntities = (List<ScaleMarksEntity>) resultJson.get("scaleMarksEntities");
         //获取维度信息列表
         List<DimensionEntity> dimensionEntities = (List<DimensionEntity>) resultJson.get("dimensionEntities");
-        //获取特殊维度信息:这些维度需要根据已有维度进行计算
-        dimensionEntities.add(new DimensionEntity("心理健康者的人格因素", "", "20211020112514", "1"));
-        dimensionEntities.add(new DimensionEntity("从事专业而有成就者的人格因素", "", "20211020112514", "1"));
-        dimensionEntities.add(new DimensionEntity("创造力强者的人格因素", "", "20211020112514", "1"));
-        dimensionEntities.add(new DimensionEntity("在新的环境中有成长能力的人格因素", "", "20211020112514", "1"));
-        dimensionEntities.add(new DimensionEntity("适应与焦虑性", "", "20211020112514", "1"));
-        dimensionEntities.add(new DimensionEntity("内向与外向性", "", "20211020112514", "1"));
-        dimensionEntities.add(new DimensionEntity("感情用事与安祥机警性", "", "20211020112514", "1"));
-        dimensionEntities.add(new DimensionEntity("怯懦与果断性", "", "20211020112514", "1"));
         //计算每个维度得分dimensionEntities
         double[] dimensionScore = new double[dimensionEntities.size()];
+        Map<String,Double> dimensionScoreMap = new HashMap<>();
         //jsonArray:用户自己选择的题目选项
         for (int i = 0; i < jsonArray.size(); i++) {
             JSONObject jsonObject1 = jsonArray.getJSONObject(i);
             //计算总分
             for (AnswerEntity answerEntity : answerEntities) {
                 if (answerEntity.getQuestionNo().equals(jsonObject1.getString("questionNo"))) {
-                    if (answerEntity.getName().equals(jsonObject1.getString("checkItems"))) {
+                    if (answerEntity.getName().replaceAll("\\s", "").equals(jsonObject1.getString("checkItems").replaceAll("\\s", ""))) {
                         score += Double.parseDouble(answerEntity.getScore());
                         break;
                     }
                 }
             }
-
             //计算维度分数
             for (int y = 0; y < dimensionEntities.size(); y++) {
                 //获取维度信息
                 DimensionEntity dimensionEntity = dimensionEntities.get(y);
                 //获取该维度下有哪些选项
                 String questionNos = dimensionEntity.getQuestionNo();
-                //得到选择题号
-                String[] questionNo = questionNos.split(";");
-                //处理特殊的维度分数
-                if ("心理健康者的人格因素".equals(dimensionEntity.getName())){
-                    dimensionScore[y] = dimensionScore[2] + dimensionScore[4] + (11 - dimensionScore[11]) + (11 - dimensionScore[15]);
-                } else if ("从事专业而有成就者的人格因素".equals(dimensionEntity.getName())){
-                    dimensionScore[y] = 2 * dimensionScore[14] + 2 * dimensionScore[5] + 2 * dimensionScore[2] + dimensionScore[3] + dimensionScore[10] + dimensionScore[13] + dimensionScore[12];
-                } else if ("创造力强者的人格因素".equals(dimensionEntity.getName())){
-                    dimensionScore[y] = 2 * (11 - dimensionScore[0]) + 2 * dimensionScore[1] + dimensionScore[3] + 2 * (11 - dimensionScore[4]) + dimensionScore[6] + 2 * dimensionScore[7] + dimensionScore[9] + (11 - dimensionScore[10]) + dimensionScore[12] + 2 * dimensionScore[13];
-                } else if ("在新的环境中有成长能力的人格因素".equals(dimensionEntity.getName())){
-                    dimensionScore[y] = dimensionScore[1] + dimensionScore[5] + dimensionScore[14] + (11 - dimensionScore[4]);
-                } else if ("适应与焦虑性".equals(dimensionEntity.getName())){
-                    dimensionScore[y] =((38 + 2 * dimensionScore[8] + 3 * dimensionScore[11] + 4 * dimensionScore[15]) - (2 * dimensionScore[2] + 2 * dimensionScore[6] + 2 * dimensionScore[14])) / 10;
-                } else if ("内向与外向性".equals(dimensionEntity.getName())){
-                    dimensionScore[y] =((2 * dimensionScore[0] + 3 * dimensionScore[3] + 4 * dimensionScore[4] + 5 * dimensionScore[6]) - (2 * dimensionScore[13] + 11)) / 10;
-                } else if ("感情用事与安祥机警性".equals(dimensionEntity.getName())){
-                    dimensionScore[y] =((77 + 2 * dimensionScore[2] + 2 * dimensionScore[3] + 2 * dimensionScore[4] + 2 * dimensionScore[10]) - (4 * dimensionScore[0] + 6*dimensionScore[7] + 2 * dimensionScore[9])) / 10;
-                } else if ("怯懦与果断性".equals(dimensionEntity.getName())){
-                    dimensionScore[y] = ((4 * dimensionScore[3] + 3 * dimensionScore[9] + 4 * dimensionScore[12] + 4 * dimensionScore[13]) - (3 * dimensionScore[0] + 2 * dimensionScore[5])) / 10;
-                }
+                //删除空白字符后得到进行划分得到选择题号
+                String[] questionNo = questionNos.replaceAll("\\s", "").split(";");
                 //计算每道题的得分
                 for (String question : questionNo) {
                     if (question.equals(jsonObject1.getString("questionNo"))) {
@@ -100,7 +75,8 @@ public class C16PFTScaleNEW extends BaseScale {
                         List<AnswerEntity> nowQuestionAnswerList = answerEntities.stream().filter(answerEntity -> answerEntity.getQuestionNo().equals(question)).collect(Collectors.toList());
                         //本题目的正确答案与自己的选项进行对比,正确的话相应分数进行相加
                         for (AnswerEntity answerEntity : nowQuestionAnswerList) {
-                            if (answerEntity.getName().equals(jsonObject1.getString("checkItems"))) {
+                            if (answerEntity.getName().replaceAll("\\s", "").equals(jsonObject1.getString("checkItems").replaceAll("\\s", ""))) {
+                                dimensionScoreMap.put(dimensionEntity.getId(),dimensionScoreMap.get(dimensionEntity.getId())==null?Double.parseDouble(answerEntity.getScore()):(dimensionScoreMap.get(dimensionEntity.getId()) +Double.parseDouble(answerEntity.getScore())));
                                 dimensionScore[y] += Double.parseDouble(answerEntity.getScore());
                                 break;
                             }
@@ -108,31 +84,52 @@ public class C16PFTScaleNEW extends BaseScale {
                     }
                 }
             }
+            resultJson.put("dimensionScoreMap",dimensionScoreMap);
         }
-        //将量表总维度根据维度名称进行分组
-        Map<String, List<ScaleMarksEntity>> scaleMarksMap = scaleMarksEntities.stream().collect(Collectors.groupingBy(ScaleMarksEntity::getName));
+        //计算标准分
+        for (int y = 0; y < dimensionEntities.size(); y++) {
+            for (int i = 0; i < scaleMarksEntities.size(); i++) {
+                if (dimensionEntities.get(y).getName().equals(scaleMarksEntities.get(i).getName())) {
+                    String[] splits = scaleMarksEntities.get(i).getReference().split("±");
+                    double a = Double.valueOf(splits[0]);
+                    double b = Double.valueOf(splits[1]);
+                    dimensionScore[y] = Math.floor(((dimensionScore[y] - a)/b)*1.5 + 5.5);
+                    break;
+                }
+            }
+        }
+
         //返回值以及存数据库格式
         List<NewResultDto> newResultDtos = new ArrayList<>();
-        resultMap0.put("总分", df.format(score));
-        resultJson.put("总分", df.format(score));
-        BigDecimal scoreDecimal = new BigDecimal(df.format(score));
-        //如果没有总分这一栏,需要手动赋值返回
-        List<ScaleMarksEntity> totalScore = scaleMarksMap.get("总分");
-        if (totalScore == null) {
-            newResultDtos.add(new NewResultDto("总分", df.format(score), "无", "无",
-                    "无", "无", "无", "无", "是"));
-        } else {
-            for (ScaleMarksEntity tempTotalScore : totalScore) {
-                BigDecimal scoreStart = new BigDecimal(tempTotalScore.getScoreStart());
-                BigDecimal scoreEnd = new BigDecimal(tempTotalScore.getScoreEnd());
-                if (scoreDecimal.compareTo(scoreEnd) <= 0 && scoreDecimal.compareTo(scoreStart) >= 0) {
-                    newResultDtos.add(new NewResultDto("总分", df.format(score), tempTotalScore.getSymptom(), tempTotalScore.getImprovementSuggestions(),
-                            tempTotalScore.getFlag(), tempTotalScore.getReference(), tempTotalScore.getNameExplain(), tempTotalScore.getSuggestion(), tempTotalScore.getIsTotalScoreExplain()));
+
+        //判断最高分
+        double[] dimensionScores = new double[dimensionScore.length];
+        for (int y = 0; y < dimensionScore.length; y++) {
+            dimensionScores[y] = dimensionScore[y];
+        }
+        Arrays.sort(dimensionScores);
+        JSONObject jsonObject = new JSONObject(true);
+        for (int y = 0; y < dimensionScore.length; y++) {
+            if (dimensionScore[y] == dimensionScores[dimensionScores.length-1]){
+                jsonObject.put(dimensionEntities.get(y).getName(),dimensionScores[dimensionScores.length-1]);
+            }
+        }
+        Set<String> keys = jsonObject.keySet();
+        List<DimensionEntity> dimensionEntitieList = new ArrayList<>();
+        int b = 0;
+        for (String key : keys) {
+            for (DimensionEntity dimensionEntity : dimensionEntities) {
+                if (dimensionEntity.getName().equals(key)){
+                    dimensionEntitieList.add(dimensionEntity);
+                    dimensionScore[b] = jsonObject.getInteger(key);
+                    b++;
                 }
             }
         }
 
 
+        //将量表总维度根据维度名称进行分组
+        Map<String, List<ScaleMarksEntity>> scaleMarksMap = scaleMarksEntities.stream().collect(Collectors.groupingBy(ScaleMarksEntity::getName));
         JSONObject iconInfo = new JSONObject();
         //雷达图需要的维度以及最大值
         List<Map<String, Object>> indicator = new LinkedList<>();
@@ -140,56 +137,8 @@ public class C16PFTScaleNEW extends BaseScale {
         LinkedList<String> reference = new LinkedList<>();
         //雷达图需要的分数
         LinkedList<String> scoreList = new LinkedList<>();
-        for (int y = 0; y < dimensionEntities.size(); y++) {
-            Map<String, Object> indicatorMap = new HashMap<>();
-            DimensionEntity dimensionEntity = dimensionEntities.get(y);
-            NewResultDto newResultDto1 = new NewResultDto();
-            //存放该维度总分
-            resultMap0.put(dimensionEntity.getName() + "得分", df.format(dimensionScore[y]));
-            resultJson.put(dimensionEntity.getName() + "得分", df.format(dimensionScore[y]));
-            newResultDto1.setScore(df.format(dimensionScore[y]));
-            newResultDtos.add(newResultDto1);
-            BigDecimal dimensionScoreDecimal = new BigDecimal(df.format(dimensionScore[y]));
-            //获取当前维度的评分规则
-            List<ScaleMarksEntity> scaleMarksEntities1 = scaleMarksMap.get(dimensionEntity.getName());
-            if (scaleMarksEntities1 != null) {
-                //循环遍历判断得分在哪个区间
-                for (ScaleMarksEntity scaleMarksEntity : scaleMarksEntities1) {
-                    BigDecimal decimalScoreEnd = new BigDecimal(scaleMarksEntity.getScoreEnd());
-                    BigDecimal decimalScoreStart = new BigDecimal(scaleMarksEntity.getScoreStart());
-                    if (dimensionScoreDecimal.compareTo(decimalScoreEnd) <= 0 && dimensionScoreDecimal.compareTo(decimalScoreStart) >= 0) {
-                        putDimResult(resultMap0, resultJson, dimensionEntity, newResultDto1, scaleMarksEntity);
-                        //需要进行图表展示的维度放入map
-                        if ("1".equals(dimensionEntity.getIsIconFlag())) {
-                            indicatorMap.put("text", dimensionEntity.getName());
-                            //将当前维度按照分数的结尾值来进行排序scaleMarksEntities1
-                            List<ScaleMarksEntity> collect = scaleMarksEntities1.stream().sorted(Comparator.comparing(ScaleMarksEntity::getScoreEnd, Comparator.comparingInt(Integer::parseInt))
-                                    .reversed()).collect(Collectors.toList());
-                            //排序完成后第一个的scoreEnd最大,也就是该维度最大的
-                            indicatorMap.put("max", collect.get(0).getScoreEnd());
-                            indicator.add(indicatorMap);
-                            if ("无".equals(scaleMarksEntity.getReference()) || "无".equals(scaleMarksEntity.getStandardDeviation())) {
-                                //常模参考值设为0
-                                reference.add("0");
-                            } else {
-                                reference.add(scaleMarksEntity.getReference());
-                            }
-                            scoreList.add(String.valueOf(dimensionScore[y]));
-                        }
-                    }
-                }
-            } else {
-                //如果分数规则表中无维度,而维度表中有相应维度,则只显示维度分数
-                newResultDto1.setFlag("无");
-                newResultDto1.setImprovementSuggestions("无");
-                newResultDto1.setName(dimensionEntity.getName());
-                newResultDto1.setReference("无");
-                newResultDto1.setNameExplain("无");
-                newResultDto1.setSuggestion("无");
-                newResultDto1.setIsTotalScoreExplain("否");
-                newResultDto1.setSymptom("无");
-            }
-        }
+        //计算维度所在评分区间
+        commonComputeDimensionScore(df, resultMap0, resultJson, dimensionEntitieList, dimensionScore, scaleMarksMap, newResultDtos, indicator, reference, scoreList);
         //需要图表展示的
         iconInfo.put("indicator", indicator);
         //判断是否有常模参考值,即reference的内容如果全为0,则不进行返回
@@ -202,14 +151,15 @@ public class C16PFTScaleNEW extends BaseScale {
         } else {
             newResult.put("iconInfo", iconInfo);
         }
+
         newResult.put("result", newResultDtos);
         resultMapList.add(resultMap0);
-
         JSONObject returnJson = new JSONObject(true);
         returnJson.put("resultMapList", resultMapList);
         returnJson.put("resultJson", resultJson);
         returnJson.put(ScaleConstant.ResultEnum.RESULT_NEW_FIELD.getKeyword(), newResult);
 
+
         return returnJson;
     }
 

+ 10 - 1
src/main/java/com/rf/kjb/scale/scaleResult/MBTIScaleNEW.java

@@ -208,11 +208,20 @@ public class MBTIScaleNEW extends BaseScale {
             LinkedList<String> reference = new LinkedList<>();
             //雷达图需要的分数
             LinkedList<String> scoreList = new LinkedList<>();
+            Map<String,Double> dimensionScoreMap = new HashMap<>();
             NEWCOMMONScale.commonComputeDimensionScore(null, resultMap0, resultJson, "外倾-内倾", dimensionScore[0], true, scaleMarksMap, newResultDtos, indicator, reference, scoreList);
             NEWCOMMONScale.commonComputeDimensionScore(null, resultMap0, resultJson, "感觉-直觉", dimensionScore[1], true, scaleMarksMap, newResultDtos, indicator, reference, scoreList);
             NEWCOMMONScale.commonComputeDimensionScore(null, resultMap0, resultJson, "思维-情感", dimensionScore[2], true, scaleMarksMap, newResultDtos, indicator, reference, scoreList);
             NEWCOMMONScale.commonComputeDimensionScore(null, resultMap0, resultJson, "判断-知觉", dimensionScore[3], true, scaleMarksMap, newResultDtos, indicator, reference, scoreList);
-
+            dimensionScoreMap.put("8af1788589de8b880189de8bb1eb0008",dimensionScore[0]);
+            dimensionScoreMap.put("8af1788589de8b880189de8bb2230009",dimensionScore[1]);
+            dimensionScoreMap.put("8af1788589de8b880189de8bb25a000a",dimensionScore[2]);
+            dimensionScoreMap.put("8af1788589de8b880189de8bb28f000b",dimensionScore[3]);
+//            dimensionScoreMap.put("2c91f37d7bec0878017c9bc8586f57dc",dimensionScore[4]);
+//            dimensionScoreMap.put("2c91f37d7bec0878017c9bc858a757dd",dimensionScore[5]);
+//            dimensionScoreMap.put("2c91f37d7bec0878017c9bc858df57de",dimensionScore[6]);
+//            dimensionScoreMap.put("2c91f37d7bec0878017c9bc8591857df",dimensionScore[7]);
+            resultJson.put("dimensionScoreMap",dimensionScoreMap);
             //需要图表展示的
             iconInfo.put("indicator", indicator);
             //判断是否有常模参考值,即reference的内容如果全为0,则不进行返回

+ 2 - 1
src/main/java/com/rf/kjb/scale/scaleResult/NEWCOMMONScaleNEW.java

@@ -337,7 +337,7 @@ public class NEWCOMMONScaleNEW extends BaseScale {
 
 
     private static void putDimResult(Map<String, String> resultMap0, JSONObject resultJson, String dimensionName, NewResultDto newResultDto1, ScaleMarksEntity scaleMarksEntity) {
-        resultMap0.put(dimensionName + "常模参考值", scaleMarksEntity.getReference());
+        //resultMap0.put(dimensionName + "常模参考值", scaleMarksEntity.getReference());
         resultMap0.put(dimensionName + "症状", scaleMarksEntity.getSymptom());
         resultJson.put(dimensionName + "结论", scaleMarksEntity.getSymptom());
         resultMap0.put(dimensionName + "因子解释", scaleMarksEntity.getNameExplain());
@@ -346,6 +346,7 @@ public class NEWCOMMONScaleNEW extends BaseScale {
         resultJson.put(dimensionName + "指导语", scaleMarksEntity.getImprovementSuggestions());
         resultMap0.put(dimensionName + "建议", scaleMarksEntity.getSuggestion());
         resultJson.put(dimensionName + "建议", scaleMarksEntity.getSuggestion());
+        BeanUtils.copyProperties(scaleMarksEntity, newResultDto1);
     }
 
 }

+ 52 - 32
src/main/java/com/rf/kjb/scale/scaleResult/PSQIScale.java

@@ -127,49 +127,69 @@ public class PSQIScale extends BaseScale {
             resultMap0.put("总分", String.valueOf(score));
             resultJson.put("总分", String.valueOf(score));
             if (score >= 0 && score <= 12) {
-                newResultDtos.add(new NewResultDto("总分", String.valueOf(score), "睡眠质量很好。", "睡眠质量,很好,入睡速度非常快,夜间不会有频繁醒来的情况,早上起床之后精神状态良好", "无",
-                        "无", "无", "无", "是"));
+                newResultDtos.add(new NewResultDto("总分", String.valueOf(score), "睡眠质量很好。",
+                        "你的睡眠质量很好,入睡时间很快,睡眠时长充足,在睡眠过程当中能进入深度睡眠状态。不容易被惊醒,夜间不易频繁醒来。早上起床后感觉清爽醒脑。疲惫感一扫而空。在白天精力更充沛,能够更好地应对工作和学习。情绪也很稳定,不易发脾气暴躁。注意力集中和思维敏捷,工作和学习效率较高。足够的睡眠有助于增强免疫系统,预防感冒和其他疾病。身体的各项指标基本处于正常水平。",
+                        "无",
+                        "无",
+                        "匹兹堡睡眠质量指数(Pittsburghsleepqualityindex,PSQI)是美国匹兹堡大学精神科医生Buysse博士等人于1989年编制的。该量表适用于睡眠障碍患者、精神障碍患者评价睡眠质量,同时也适用于一般人睡眠质量的评估。得分越高,睡眠质量越差。",
+                        "继续保持良好的状态。睡眠质量的改善将在日常生活中展现出更好的精神状态、身体健康和工作学习表现。同时也要建立规律的作息时间: 尽量保持每天相似的起床和就寝时间,帮助身体建立规律的生物钟。营造舒适的睡眠环境: 确保卧室安静、黑暗、凉爽、舒适,可以考虑使用眼罩和耳塞等辅助工具。避免刺激性食物和饮料: 晚餐尽量不要吃太油腻或刺激性食物,如咖啡因和酒精等。放松身心: 可以尝试进行放松的活动,如瑜伽、深呼吸练习、冥想或温水浴,有助于缓解压力和焦虑。",
+                        "是"));
                 resultMap0.put("总分症状", "睡眠质量很好。");
-                resultMap0.put("总分指导语", "睡眠质量,很好,入睡速度非常快,夜间不会有频繁醒来的情况,早上起床之后精神状态良好");
-                resultMap0.put("总分因子解释", "无");
-                resultMap0.put("总分建议", "无");
+                resultMap0.put("总分指导语", "你的睡眠质量很好,入睡时间很快,睡眠时长充足,在睡眠过程当中能进入深度睡眠状态。不容易被惊醒,夜间不易频繁醒来。早上起床后感觉清爽醒脑。疲惫感一扫而空。在白天精力更充沛,能够更好地应对工作和学习。情绪也很稳定,不易发脾气暴躁。注意力集中和思维敏捷,工作和学习效率较高。足够的睡眠有助于增强免疫系统,预防感冒和其他疾病。身体的各项指标基本处于正常水平。");
+                resultMap0.put("总分因子解释", "匹兹堡睡眠质量指数(Pittsburghsleepqualityindex,PSQI)是美国匹兹堡大学精神科医生Buysse博士等人于1989年编制的。该量表适用于睡眠障碍患者、精神障碍患者评价睡眠质量,同时也适用于一般人睡眠质量的评估。得分越高,睡眠质量越差。");
+                resultMap0.put("总分建议", "继续保持良好的状态。睡眠质量的改善将在日常生活中展现出更好的精神状态、身体健康和工作学习表现。同时也要建立规律的作息时间: 尽量保持每天相似的起床和就寝时间,帮助身体建立规律的生物钟。营造舒适的睡眠环境: 确保卧室安静、黑暗、凉爽、舒适,可以考虑使用眼罩和耳塞等辅助工具。避免刺激性食物和饮料: 晚餐尽量不要吃太油腻或刺激性食物,如咖啡因和酒精等。放松身心: 可以尝试进行放松的活动,如瑜伽、深呼吸练习、冥想或温水浴,有助于缓解压力和焦虑。");
                 resultJson.put("总分症状", "睡眠质量很好。");
-                resultJson.put("总分指导语", "睡眠质量,很好,入睡速度非常快,夜间不会有频繁醒来的情况,早上起床之后精神状态良好");
-                resultJson.put("总分因子解释", "");
-                resultJson.put("总分建议", "");
+                resultJson.put("总分指导语", "你的睡眠质量很好,入睡时间很快,睡眠时长充足,在睡眠过程当中能进入深度睡眠状态。不容易被惊醒,夜间不易频繁醒来。早上起床后感觉清爽醒脑。疲惫感一扫而空。在白天精力更充沛,能够更好地应对工作和学习。情绪也很稳定,不易发脾气暴躁。注意力集中和思维敏捷,工作和学习效率较高。足够的睡眠有助于增强免疫系统,预防感冒和其他疾病。身体的各项指标基本处于正常水平。");
+                resultJson.put("总分因子解释", "匹兹堡睡眠质量指数(Pittsburghsleepqualityindex,PSQI)是美国匹兹堡大学精神科医生Buysse博士等人于1989年编制的。该量表适用于睡眠障碍患者、精神障碍患者评价睡眠质量,同时也适用于一般人睡眠质量的评估。得分越高,睡眠质量越差。");
+                resultJson.put("总分建议", "继续保持良好的状态。睡眠质量的改善将在日常生活中展现出更好的精神状态、身体健康和工作学习表现。同时也要建立规律的作息时间: 尽量保持每天相似的起床和就寝时间,帮助身体建立规律的生物钟。营造舒适的睡眠环境: 确保卧室安静、黑暗、凉爽、舒适,可以考虑使用眼罩和耳塞等辅助工具。避免刺激性食物和饮料: 晚餐尽量不要吃太油腻或刺激性食物,如咖啡因和酒精等。放松身心: 可以尝试进行放松的活动,如瑜伽、深呼吸练习、冥想或温水浴,有助于缓解压力和焦虑。");
             } else if (score >= 13 && score <= 26) {
-                newResultDtos.add(new NewResultDto("总分", String.valueOf(score), "睡眠质量还行", "睡眠质量一般,健康状况有所下降,如果再不引起足够的重视,您的状况会向一般发展。", "无",
-                        "无", "无", "坚持有规律的作息时间,在周末不要睡得太晚,睡前不要暴饮暴食,也不要喝太多的水。", "是"));
+                newResultDtos.add(new NewResultDto("总分", String.valueOf(score), "睡眠质量还行",
+                        "你的睡眠质量较好,你在晚上上床后通常能够迅速入睡,不需要花费太长时间来入睡。整晚能够保持睡眠状态,不会频繁醒来或在夜间醒来后难以再次入睡。在早晨醒来时,通常感到清爽和精力充沛,没有明显的困倦感。白天能够保持较高的注意力和精力,不容易因为疲劳而感到困倦。情绪较为稳定,不容易因为睡眠问题而出现情绪波动或焦虑。身体较健康,有健康的体重、健康的心血管系统和免疫系统。",
+                        "无",
+                        "无",
+                        "匹兹堡睡眠质量指数(Pittsburghsleepqualityindex,PSQI)是美国匹兹堡大学精神科医生Buysse博士等人于1989年编制的。该量表适用于睡眠障碍患者、精神障碍患者评价睡眠质量,同时也适用于一般人睡眠质量的评估。得分越高,睡眠质量越差。",
+                        "继续保持良好的状态。睡眠质量良好的人在生活中表现出更好的身体状态、心理状态和认知能力,能够更好地适应和享受日常生活。同时也要建立规律的作息时间: 尽量保持每天相似的起床和就寝时间,帮助身体建立规律的生物钟。营造舒适的睡眠环境: 确保卧室安静、黑暗、凉爽、舒适,可以考虑使用眼罩和耳塞等辅助工具。避免刺激性食物和饮料: 晚餐尽量不要吃太油腻或刺激性食物,如咖啡因和酒精等。放松身心: 可以尝试进行放松的活动,如瑜伽、深呼吸练习、冥想或温水浴,有助于缓解压力和焦虑。",
+                        "是"));
                 resultMap0.put("总分症状", "睡眠质量还行");
-                resultMap0.put("总分指导语", "睡眠质量一般,健康状况有所下降,如果再不引起足够的重视,您的状况会向一般发展。");
-                resultMap0.put("总分因子解释", "无");
-                resultMap0.put("总分建议", "坚持有规律的作息时间,在周末不要睡得太晚,睡前不要暴饮暴食,也不要喝太多的水。");
+                resultMap0.put("总分指导语", "你的睡眠质量较好,你在晚上上床后通常能够迅速入睡,不需要花费太长时间来入睡。整晚能够保持睡眠状态,不会频繁醒来或在夜间醒来后难以再次入睡。在早晨醒来时,通常感到清爽和精力充沛,没有明显的困倦感。白天能够保持较高的注意力和精力,不容易因为疲劳而感到困倦。情绪较为稳定,不容易因为睡眠问题而出现情绪波动或焦虑。身体较健康,有健康的体重、健康的心血管系统和免疫系统。");
+                resultMap0.put("总分因子解释", "匹兹堡睡眠质量指数(Pittsburghsleepqualityindex,PSQI)是美国匹兹堡大学精神科医生Buysse博士等人于1989年编制的。该量表适用于睡眠障碍患者、精神障碍患者评价睡眠质量,同时也适用于一般人睡眠质量的评估。得分越高,睡眠质量越差。");
+                resultMap0.put("总分建议", "继续保持良好的状态。睡眠质量良好的人在生活中表现出更好的身体状态、心理状态和认知能力,能够更好地适应和享受日常生活。同时也要建立规律的作息时间: 尽量保持每天相似的起床和就寝时间,帮助身体建立规律的生物钟。营造舒适的睡眠环境: 确保卧室安静、黑暗、凉爽、舒适,可以考虑使用眼罩和耳塞等辅助工具。避免刺激性食物和饮料: 晚餐尽量不要吃太油腻或刺激性食物,如咖啡因和酒精等。放松身心: 可以尝试进行放松的活动,如瑜伽、深呼吸练习、冥想或温水浴,有助于缓解压力和焦虑。");
                 resultJson.put("总分症状", "睡眠质量还行");
-                resultJson.put("总分指导语", "睡眠质量一般,健康状况有所下降,如果再不引起足够的重视,您的状况会向一般发展。");
-                resultJson.put("总分因子解释", "");
-                resultJson.put("总分建议", "坚持有规律的作息时间,在周末不要睡得太晚,睡前不要暴饮暴食,也不要喝太多的水。");
+                resultJson.put("总分指导语", "你的睡眠质量较好,你在晚上上床后通常能够迅速入睡,不需要花费太长时间来入睡。整晚能够保持睡眠状态,不会频繁醒来或在夜间醒来后难以再次入睡。在早晨醒来时,通常感到清爽和精力充沛,没有明显的困倦感。白天能够保持较高的注意力和精力,不容易因为疲劳而感到困倦。情绪较为稳定,不容易因为睡眠问题而出现情绪波动或焦虑。身体较健康,有健康的体重、健康的心血管系统和免疫系统。");
+                resultJson.put("总分因子解释", "匹兹堡睡眠质量指数(Pittsburghsleepqualityindex,PSQI)是美国匹兹堡大学精神科医生Buysse博士等人于1989年编制的。该量表适用于睡眠障碍患者、精神障碍患者评价睡眠质量,同时也适用于一般人睡眠质量的评估。得分越高,睡眠质量越差。");
+                resultJson.put("总分建议", "继续保持良好的状态。睡眠质量良好的人在生活中表现出更好的身体状态、心理状态和认知能力,能够更好地适应和享受日常生活。同时也要建立规律的作息时间: 尽量保持每天相似的起床和就寝时间,帮助身体建立规律的生物钟。营造舒适的睡眠环境: 确保卧室安静、黑暗、凉爽、舒适,可以考虑使用眼罩和耳塞等辅助工具。避免刺激性食物和饮料: 晚餐尽量不要吃太油腻或刺激性食物,如咖啡因和酒精等。放松身心: 可以尝试进行放松的活动,如瑜伽、深呼吸练习、冥想或温水浴,有助于缓解压力和焦虑。");
             } else if (score >= 27 && score <= 40) {
-                newResultDtos.add(new NewResultDto("总分", String.valueOf(score), "睡眠质量一般", "睡眠质量比较糟糕,健康状况明显受损,容易被一些声音吵醒,饮食起居失去规律。在不引起重视的话,会发展到更严重的地步", "无",
-                        "无", "无", "舒缓的心情就可以让患者早日睡眠,还有就是患者要积极锻炼,在肌体劳累之时就可以很快入眠。", "是"));
+                newResultDtos.add(new NewResultDto("总分", String.valueOf(score), "睡眠质量一般",
+                        "睡眠质量比较糟糕,健康状况明显受损,容易被一些声音吵醒,饮食起居失去规律。白天感到疲倦、精力不足,可能需要依赖咖啡因或其他方式来提神。夜间经常醒来,或者早晨醒来时感觉没有完全恢复精力。早晨醒来时感到困难,需要更长的时间才能完全清醒。情绪容易波动,容易烦躁或易怒。在工作或学习中难以集中注意力,容易分散或无法持续关注。睡眠质量差可能导致身心压力增加,对应付生活中的挑战更困难。长期睡眠质量一般可能影响免疫系统的功能,增加患病的风险。再不引起重视的话,会发展到更严重的地步。",
+                        "无",
+                        "无",
+                        "匹兹堡睡眠质量指数(Pittsburghsleepqualityindex,PSQI)是美国匹兹堡大学精神科医生Buysse博士等人于1989年编制的。该量表适用于睡眠障碍患者、精神障碍患者评价睡眠质量,同时也适用于一般人睡眠质量的评估。得分越高,睡眠质量越差。",
+                        "舒缓的心情就可以让患者早日睡眠,还有就是患者要积极锻炼,在肌体劳累之时就可以很快入眠。适度的规律运动对睡眠有益,但应避免在临睡前进行剧烈运动。避免使用手机、电脑等发出蓝光的屏幕,可以选择阅读、听音乐等有助于放松的活动。睡眠质量的评估是一个相对主观的过程,因为每个人的需求和反应都有所不同。如果你对自己的睡眠质量有疑虑,建议咨询医生或专业睡眠机构,以获取更准确的评估和建议。",
+                        "是"));
                 resultMap0.put("总分症状", "睡眠质量一般");
-                resultMap0.put("总分指导语", "睡眠质量比较糟糕,健康状况明显受损,容易被一些声音吵醒,饮食起居失去规律。在不引起重视的话,会发展到更严重的地步");
-                resultMap0.put("总分因子解释", "无");
-                resultMap0.put("总分建议", "舒缓的心情就可以让患者早日睡眠,还有就是患者要积极锻炼,在肌体劳累之时就可以很快入眠。");
+                resultMap0.put("总分指导语", "睡眠质量比较糟糕,健康状况明显受损,容易被一些声音吵醒,饮食起居失去规律。白天感到疲倦、精力不足,可能需要依赖咖啡因或其他方式来提神。夜间经常醒来,或者早晨醒来时感觉没有完全恢复精力。早晨醒来时感到困难,需要更长的时间才能完全清醒。情绪容易波动,容易烦躁或易怒。工作或学习中难以集中注意力,容易分散或无法持续关注。睡眠质量差可能导致身心压力增加,对应付生活中的挑战更困难。长期睡眠质量一般可能影响免疫系统的功能,增加患病的风险。再不引起重视的话,会发展到更严重的地步");
+                resultMap0.put("总分因子解释", "匹兹堡睡眠质量指数(Pittsburghsleepqualityindex,PSQI)是美国匹兹堡大学精神科医生Buysse博士等人于1989年编制的。该量表适用于睡眠障碍患者、精神障碍患者评价睡眠质量,同时也适用于一般人睡眠质量的评估。得分越高,睡眠质量越差。");
+                resultMap0.put("总分建议", "舒缓的心情就可以让患者早日睡眠,还有就是患者要积极锻炼,在肌体劳累之时就可以很快入眠。适度的规律运动对睡眠有益,但应避免在临睡前进行剧烈运动。避免使用手机、电脑等发出蓝光的屏幕,可以选择阅读、听音乐等有助于放松的活动。睡眠质量的评估是一个相对主观的过程,因为每个人的需求和反应都有所不同。如果你对自己的睡眠质量有疑虑,建议咨询医生或专业睡眠机构,以获取更准确的评估和建议。");
                 resultJson.put("总分症状", "睡眠质量一般");
-                resultJson.put("总分指导语", "睡眠质量比较糟糕,健康状况明显受损,容易被一些声音吵醒,饮食起居失去规律。在不引起重视的话,会发展到更严重的地步");
-                resultJson.put("总分因子解释", "");
-                resultJson.put("总分建议", "舒缓的心情就可以让患者早日睡眠,还有就是患者要积极锻炼,在肌体劳累之时就可以很快入眠。");
+                resultJson.put("总分指导语", "睡眠质量比较糟糕,健康状况明显受损,容易被一些声音吵醒,饮食起居失去规律。白天感到疲倦、精力不足,可能需要依赖咖啡因或其他方式来提神。夜间经常醒来,或者早晨醒来时感觉没有完全恢复精力。早晨醒来时感到困难,需要更长的时间才能完全清醒。情绪容易波动,容易烦躁或易怒。工作或学习中难以集中注意力,容易分散或无法持续关注。睡眠质量差可能导致身心压力增加,对应付生活中的挑战更困难。长期睡眠质量一般可能影响免疫系统的功能,增加患病的风险。再不引起重视的话,会发展到更严重的地步");
+                resultJson.put("总分因子解释", "匹兹堡睡眠质量指数(Pittsburghsleepqualityindex,PSQI)是美国匹兹堡大学精神科医生Buysse博士等人于1989年编制的。该量表适用于睡眠障碍患者、精神障碍患者评价睡眠质量,同时也适用于一般人睡眠质量的评估。得分越高,睡眠质量越差。");
+                resultJson.put("总分建议", "舒缓的心情就可以让患者早日睡眠,还有就是患者要积极锻炼,在肌体劳累之时就可以很快入眠。适度的规律运动对睡眠有益,但应避免在临睡前进行剧烈运动。避免使用手机、电脑等发出蓝光的屏幕,可以选择阅读、听音乐等有助于放松的活动。睡眠质量的评估是一个相对主观的过程,因为每个人的需求和反应都有所不同。如果你对自己的睡眠质量有疑虑,建议咨询医生或专业睡眠机构,以获取更准确的评估和建议。");
             } else if (score >= 41 && score <= 54) {
-                newResultDtos.add(new NewResultDto("总分", String.valueOf(score), "睡眠质量很差", "睡眠质量已经到了令您非常头痛的地步,长期的睡眠不足,精神状态较差,难以入睡,导致健康状况的严重恶化,应付工作力不从心,情绪不稳定。", "无",
-                        "无", "无", "建议您及时就医了,必要时采用药物治疗。", "是"));
+                newResultDtos.add(new NewResultDto("总分", String.valueOf(score), "睡眠质量很差",
+                        "你经常失眠,难以入睡或无法持续睡眠,经常在夜间醒来并难以重新入睡。夜间频繁醒来,导致睡眠不连续,无法获得充足的休息。频繁的梦呓、噩梦或恶梦可能会打扰睡眠,导致醒来时感到紧张或不安。早晨醒来时间过早,未能满足正常的睡眠需求。白天感到极度的疲劳和精力不足,无法保持清醒状态。白天容易打盹,无法集中注意力,甚至可能在工作或学习中打瞌睡。可能引发身体不适,如头痛、肌肉酸痛、胃部不适等。你的睡眠质量已经到了令您非常头痛的地步,长期的睡眠不足,精神状态较差,难以入睡,导致健康状况的严重恶化,应付工作力不从心,情绪也极不稳定。",
+                        "无",
+                        "无",
+                        "匹兹堡睡眠质量指数(Pittsburghsleepqualityindex,PSQI)是美国匹兹堡大学精神科医生Buysse博士等人于1989年编制的。该量表适用于睡眠障碍患者、精神障碍患者评价睡眠质量,同时也适用于一般人睡眠质量的评估。得分越高,睡眠质量越差。",
+                        "尽量保持每天相似的起床和就寝时间,帮助身体建立规律的生物钟。确保卧室安静、黑暗、凉爽、舒适,可以考虑使用眼罩和耳塞等辅助工具。可以尝试进行放松的活动,如瑜伽、深呼吸练习、冥想或温水浴,有助于缓解压力和焦虑。过于严重建议咨询医生或专业的睡眠专家,以获取进一步的评估和帮助。他们可以根据你的情况提供针对性的建议和治疗方案。",
+                        "是"));
                 resultMap0.put("总分症状", "睡眠质量很差");
-                resultMap0.put("总分指导语", "睡眠质量已经到了令您非常头痛的地步,长期的睡眠不足,精神状态较差,难以入睡,导致健康状况的严重恶化,应付工作力不从心,情绪不稳定。");
-                resultMap0.put("总分因子解释", "无");
-                resultMap0.put("总分建议", "建议您及时就医了,必要时采用药物治疗。");
+                resultMap0.put("总分指导语", "你经常失眠,难以入睡或无法持续睡眠,经常在夜间醒来并难以重新入睡。夜间频繁醒来,导致睡眠不连续,无法获得充足的休息。频繁的梦呓、噩梦或恶梦可能会打扰睡眠,导致醒来时感到紧张或不安。早晨醒来时间过早,未能满足正常的睡眠需求。白天感到极度的疲劳和精力不足,无法保持清醒状态。白天容易打盹,无法集中注意力,甚至可能在工作或学习中打瞌睡。可能引发身体不适,如头痛、肌肉酸痛、胃部不适等。你的睡眠质量已经到了令您非常头痛的地步,长期的睡眠不足,精神状态较差,难以入睡,导致健康状况的严重恶化,应付工作力不从心,情绪也极不稳定。");
+                resultMap0.put("总分因子解释", "匹兹堡睡眠质量指数(Pittsburghsleepqualityindex,PSQI)是美国匹兹堡大学精神科医生Buysse博士等人于1989年编制的。该量表适用于睡眠障碍患者、精神障碍患者评价睡眠质量,同时也适用于一般人睡眠质量的评估。得分越高,睡眠质量越差。");
+                resultMap0.put("总分建议", "尽量保持每天相似的起床和就寝时间,帮助身体建立规律的生物钟。确保卧室安静、黑暗、凉爽、舒适,可以考虑使用眼罩和耳塞等辅助工具。可以尝试进行放松的活动,如瑜伽、深呼吸练习、冥想或温水浴,有助于缓解压力和焦虑。过于严重建议咨询医生或专业的睡眠专家,以获取进一步的评估和帮助。他们可以根据你的情况提供针对性的建议和治疗方案。");
                 resultJson.put("总分症状", "睡眠质量很差");
-                resultJson.put("总分指导语", "睡眠质量已经到了令您非常头痛的地步,长期的睡眠不足,精神状态较差,难以入睡,导致健康状况的严重恶化,应付工作力不从心,情绪不稳定。");
-                resultJson.put("总分因子解释", "");
-                resultJson.put("总分建议", "建议您及时就医了,必要时采用药物治疗。");
+                resultJson.put("总分指导语", "你经常失眠,难以入睡或无法持续睡眠,经常在夜间醒来并难以重新入睡。夜间频繁醒来,导致睡眠不连续,无法获得充足的休息。频繁的梦呓、噩梦或恶梦可能会打扰睡眠,导致醒来时感到紧张或不安。早晨醒来时间过早,未能满足正常的睡眠需求。白天感到极度的疲劳和精力不足,无法保持清醒状态。白天容易打盹,无法集中注意力,甚至可能在工作或学习中打瞌睡。可能引发身体不适,如头痛、肌肉酸痛、胃部不适等。你的睡眠质量已经到了令您非常头痛的地步,长期的睡眠不足,精神状态较差,难以入睡,导致健康状况的严重恶化,应付工作力不从心,情绪也极不稳定。");
+                resultJson.put("总分因子解释", "匹兹堡睡眠质量指数(Pittsburghsleepqualityindex,PSQI)是美国匹兹堡大学精神科医生Buysse博士等人于1989年编制的。该量表适用于睡眠障碍患者、精神障碍患者评价睡眠质量,同时也适用于一般人睡眠质量的评估。得分越高,睡眠质量越差。");
+                resultJson.put("总分建议", "尽量保持每天相似的起床和就寝时间,帮助身体建立规律的生物钟。确保卧室安静、黑暗、凉爽、舒适,可以考虑使用眼罩和耳塞等辅助工具。可以尝试进行放松的活动,如瑜伽、深呼吸练习、冥想或温水浴,有助于缓解压力和焦虑。过于严重建议咨询医生或专业的睡眠专家,以获取进一步的评估和帮助。他们可以根据你的情况提供针对性的建议和治疗方案。");
             }
 
             resultMapList.add(resultMap0);

+ 11 - 8
src/main/java/com/rf/kjb/scale/scaleResult/SCL90ScaleNEW.java

@@ -172,7 +172,7 @@ public class SCL90ScaleNEW extends BaseScale {
             //循环遍历判断得分在哪个区间
             for (ScaleMarksEntity scaleMarksEntity : scaleMarksEntities1) {
                 if (resultScore <= Double.parseDouble(df.format(Double.parseDouble(scaleMarksEntity.getScoreEnd()))) && resultScore >= Double.parseDouble(df.format(Double.parseDouble(scaleMarksEntity.getScoreStart())))) {
-                    putDimResult(resultMap0, resultJson, dimensionEntity, newResultDto1, scaleMarksEntity);
+                    putDimResult(resultMap0, resultJson, dimensionEntity.getName(), newResultDto1, scaleMarksEntity);
                     //需要进行图表展示的维度放入map
                     if ("1".equals(dimensionEntity.getIsIconFlag())) {
                         indicatorMap.put("text", dimensionEntity.getName());
@@ -206,13 +206,16 @@ public class SCL90ScaleNEW extends BaseScale {
         return returnJson;
     }
 
-    private static void putDimResult(Map<String, String> resultMap0, JSONObject oldResult, DimensionEntity dimensionEntity, NewResultDto newResultDto1, ScaleMarksEntity scaleMarksEntity) {
-        resultMap0.put(dimensionEntity.getName() + "常模参考值", scaleMarksEntity.getReference());
-        resultMap0.put(dimensionEntity.getName() + "症状", scaleMarksEntity.getSymptom());
-        oldResult.put(dimensionEntity.getName() + "症状", scaleMarksEntity.getSymptom());
-        resultMap0.put(dimensionEntity.getName() + "因子解释", scaleMarksEntity.getNameExplain());
-        resultMap0.put(dimensionEntity.getName() + "指导语", scaleMarksEntity.getImprovementSuggestions());
-        resultMap0.put(dimensionEntity.getName() + "建议", scaleMarksEntity.getSuggestion());
+    private static void putDimResult(Map<String, String> resultMap0, JSONObject resultJson, String dimensionName, NewResultDto newResultDto1, ScaleMarksEntity scaleMarksEntity) {
+        //resultMap0.put(dimensionName + "常模参考值", scaleMarksEntity.getReference());
+        resultMap0.put(dimensionName + "症状", scaleMarksEntity.getSymptom());
+        resultJson.put(dimensionName + "结论", scaleMarksEntity.getSymptom());
+        resultMap0.put(dimensionName + "因子解释", scaleMarksEntity.getNameExplain());
+        resultJson.put(dimensionName + "因子解释", scaleMarksEntity.getNameExplain());
+        resultMap0.put(dimensionName + "指导语", scaleMarksEntity.getImprovementSuggestions());
+        resultJson.put(dimensionName + "指导语", scaleMarksEntity.getImprovementSuggestions());
+        resultMap0.put(dimensionName + "建议", scaleMarksEntity.getSuggestion());
+        resultJson.put(dimensionName + "建议", scaleMarksEntity.getSuggestion());
         BeanUtils.copyProperties(scaleMarksEntity, newResultDto1);
     }
 }

+ 147 - 0
src/main/java/com/rf/kjb/utils/FileUtil.java

@@ -0,0 +1,147 @@
+package com.rf.kjb.utils;
+
+import com.ruiyun.jvppeteer.core.Puppeteer;
+import com.ruiyun.jvppeteer.core.browser.Browser;
+import com.ruiyun.jvppeteer.core.browser.BrowserFetcher;
+import com.ruiyun.jvppeteer.core.page.Page;
+import com.ruiyun.jvppeteer.options.LaunchOptions;
+import com.ruiyun.jvppeteer.options.LaunchOptionsBuilder;
+import com.ruiyun.jvppeteer.options.PDFOptions;
+import com.ruiyun.jvppeteer.options.PageNavigateOptions;
+import com.ruiyun.jvppeteer.protocol.DOM.Margin;
+import lombok.extern.slf4j.Slf4j;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+
+/**
+ * @Author:zzf
+ * @Date:2022/6/18:11:40
+ * @Description: 文件工具类
+ */
+@Slf4j
+public class FileUtil {
+
+
+    /**
+     * html转pdf
+     * @param htmlFilePathList html文件路径
+     * @throws IOException
+     * @throws ExecutionException
+     * @throws InterruptedException
+     */
+    public static void html2pdf(List<String> htmlFilePathList) throws IOException, ExecutionException, InterruptedException {
+
+        //自动下载,第一次下载后不会再下载
+        BrowserFetcher.downloadIfNotExist(null);
+        ArrayList<String> arrayList = new ArrayList<>();
+        //生成pdf必须在无厘头模式下才能生效
+        LaunchOptions options = new LaunchOptionsBuilder().withArgs(arrayList).withHeadless(true).build();
+        if(OSUtil.isLinux()){
+            options.setExecutablePath(".local-browser/linux-722234/chrome-linux/chrome");
+        }else{
+            options.setExecutablePath(".local-browser/win64-722234/chrome-win/chrome.exe");
+        }
+
+        PageNavigateOptions pageNavigateOptions = new PageNavigateOptions();
+        pageNavigateOptions.setWaitUntil(Collections.singletonList("networkidle2"));
+        PDFOptions pdfOptions = new PDFOptions();
+        arrayList.add("--no-sandbox");
+        arrayList.add("--disable-setuid-sandbox");
+        Browser browser = Puppeteer.launch(options);
+        Page page = browser.newPage();
+        htmlFilePathList.forEach(item -> {
+            File h = new File(item);
+            if(!h.exists()){
+                return;
+            }else{
+                try{
+                    System.out.println("item------------"+item);
+                    System.out.println("h.getName()--"+h.getName());
+                    page.goTo("file:///"+h.getAbsolutePath(),pageNavigateOptions);
+                    pdfOptions.setPath("./h2p/export_pdf/PDFReport/"+h.getName().replace("html","pdf"));
+                    pdfOptions.setFormat("A4");
+                    pdfOptions.setPrintBackground(true);
+                    Margin margin = new Margin();
+                    margin.setTop("70");
+                    margin.setBottom("70");
+                    margin.setLeft("0");
+                    margin.setRight("0");
+                    pdfOptions.setMargin(margin);
+                    page.pdf(pdfOptions);
+                }catch (Exception e){
+                    log.error("转换出错:"+e.getMessage());
+                    e.printStackTrace();
+                }finally {
+                    //删除html文件
+                    FileUtil.deleteFile(h);
+                }
+            }
+        });
+        page.close();
+        browser.close();
+    }
+
+    /**
+     * 删除文件
+     * @param file
+     */
+    private static void deleteFile(File file)   {
+        if(file.exists())  file.delete();
+    }
+
+    /**
+     * 文件下载
+     * @param file 下载文件信息
+     * @param responseFileName 下载文件名称
+     * @param deleteFile 是否删除源文件
+     */
+    public static void downloadFile(HttpServletResponse response,File file,String responseFileName,boolean deleteFile) throws UnsupportedEncodingException {
+        response.reset();
+        response.setContentType("application/octet-stream");
+        response.setCharacterEncoding("utf-8");
+        response.setContentLength((int) file.length());
+        String fileName = URLEncoder.encode((responseFileName == null || responseFileName.equals(""))?file.getName():responseFileName,"utf-8");
+        response.setHeader("Content-Disposition", "attachment;filename="+ fileName);
+        byte[] buffer = new byte[1024];
+        FileInputStream fis = null;
+        BufferedInputStream bis = null;
+        try {
+            fis = new FileInputStream(file);
+            bis = new BufferedInputStream(fis);
+            OutputStream os = response.getOutputStream();
+            int i = bis.read(buffer);
+            while (i != -1) {
+                os.write(buffer, 0, i);
+                i = bis.read(buffer);
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        } finally {
+
+            if (bis != null) {
+                try {
+                    bis.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (fis != null) {
+                try {
+                    fis.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if(deleteFile) deleteFile(file);
+
+        }
+    }
+
+
+}