wucl před 2 roky
rodič
revize
868009cc3b
33 změnil soubory, kde provedl 672 přidání a 154 odebrání
  1. 37 76
      .idea/workspace.xml
  2. 9 6
      src/main/java/com/dayou/controller/DocumentController.java
  3. 8 0
      src/main/java/com/dayou/controller/QuestionAnalysisController.java
  4. 23 5
      src/main/java/com/dayou/controller/QuestionController.java
  5. 2 1
      src/main/java/com/dayou/dao/DocumentMapper.java
  6. 4 0
      src/main/java/com/dayou/dao/QuestionAnalysisMapper.java
  7. 4 0
      src/main/java/com/dayou/dao/QuestionMapper.java
  8. 0 3
      src/main/java/com/dayou/dto/DocumentDTO.java
  9. 1 3
      src/main/java/com/dayou/entity/Document.java
  10. 17 1
      src/main/java/com/dayou/entity/Question.java
  11. 1 3
      src/main/java/com/dayou/service/IDocumentService.java
  12. 4 0
      src/main/java/com/dayou/service/IQuestionAnalysisService.java
  13. 4 0
      src/main/java/com/dayou/service/IQuestionService.java
  14. 41 18
      src/main/java/com/dayou/service/impl/DocumentServiceImpl.java
  15. 4 3
      src/main/java/com/dayou/service/impl/ProfessorResultServiceImpl.java
  16. 95 1
      src/main/java/com/dayou/service/impl/QuestionAnalysisServiceImpl.java
  17. 35 0
      src/main/java/com/dayou/service/impl/QuestionServiceImpl.java
  18. 18 0
      src/main/java/com/dayou/utils/Tree.java
  19. 126 0
      src/main/java/com/dayou/utils/TreeUtil.java
  20. 39 1
      src/main/java/com/dayou/vo/AnalysisResultVO.java
  21. 18 0
      src/main/java/com/dayou/vo/ChildrenParentName.java
  22. 1 1
      src/main/java/com/dayou/vo/CycleVO.java
  23. 6 1
      src/main/java/com/dayou/vo/DocumentCycleVO.java
  24. 2 0
      src/main/java/com/dayou/vo/DocumentVO.java
  25. 24 0
      src/main/java/com/dayou/vo/MergeTableVO.java
  26. 24 0
      src/main/java/com/dayou/vo/MergeVO.java
  27. 1 0
      src/main/java/com/dayou/vo/ProfessorResultVO.java
  28. 51 0
      src/main/java/com/dayou/vo/QuestionTreeVO.java
  29. 36 6
      src/main/resources/mapper/AnalysisResultMapper.xml
  30. 12 10
      src/main/resources/mapper/CycleMapper.xml
  31. 10 9
      src/main/resources/mapper/DocumentMapper.xml
  32. 7 6
      src/main/resources/mapper/ProfessorResultMapper.xml
  33. 8 0
      src/main/resources/mapper/QuestionMapper.xml

+ 37 - 76
.idea/workspace.xml

@@ -5,81 +5,38 @@
   </component>
   <component name="ChangeListManager">
     <list default="true" id="298c0123-5a38-45f2-a872-7d3a74d33353" name="Changes" comment="">
-      <change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/BaseApplication.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/configuration/BaseEntity.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/configuration/BusinessException.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/configuration/CacheConfig.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/configuration/DefaultPageIntecptor.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/configuration/ErrorCode.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/configuration/GlobalExceptionHandler.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/configuration/JwtConstants.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/configuration/MybatisPlusConfig.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/configuration/RestResponse.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/configuration/SpringContextHolder.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/configuration/WebConfig.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/configuration/annotation/IgnoreAuth.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/controller/CycleController.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/controller/DocumentController.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/controller/ProfessorResultController.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/controller/QuestionAnalysisController.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/controller/QuestionController.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/controller/UserController.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/dao/CycleMapper.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/dao/DocumentMapper.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/dao/DocumentQuestionMapper.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/dao/ProfessorResultMapper.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/dao/QuestionAnalysisMapper.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/dao/QuestionMapper.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/dao/UserMapper.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/dto/CommitDTO.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/dto/DocumentDTO.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/dto/LoginDTO.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/dto/UserDTO.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/entity/Cycle.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/entity/Document.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/entity/DocumentQuestion.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/entity/ProfessorResult.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/entity/Question.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/entity/QuestionAnalysis.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/entity/User.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/interceptor/LoginInterceptor.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/ICycleService.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/IDocumentQuestionService.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/IDocumentService.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/IProfessorResultService.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/IQuestionAnalysisService.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/IQuestionService.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/IUserService.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/CycleServiceImpl.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/DocumentQuestionServiceImpl.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/DocumentServiceImpl.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/ProfessorResultServiceImpl.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/QuestionAnalysisServiceImpl.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/QuestionServiceImpl.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/UserServiceImpl.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/websocket/WebSocketConfig.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/websocket/WebSocketServer.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/utils/ConvertUtil.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/utils/Convertor.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/utils/JwtTokenUtil.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/utils/LoginContext.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/AnalysisResultVO.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/CycleVO.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/DocumentCycleVO.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/DocumentVO.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/LabelKeyVO.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/ProfessorResultVO.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/QuestionVO.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/resources/application-local.yml" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/resources/application-prod.yml" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/resources/application-test.yml" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/resources/application.yml" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/resources/mapper/AnalysisResultMapper.xml" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/resources/mapper/CycleMapper.xml" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/resources/mapper/DocumentMapper.xml" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/resources/mapper/ProfessorResultMapper.xml" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/utils/Tree.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/utils/TreeUtil.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/ChildrenParentName.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/MergeTableVO.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/MergeVO.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/QuestionTreeVO.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/resources/mapper/QuestionMapper.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/controller/DocumentController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/controller/DocumentController.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/controller/QuestionAnalysisController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/controller/QuestionAnalysisController.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/controller/QuestionController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/controller/QuestionController.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/dao/DocumentMapper.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/dao/DocumentMapper.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/dao/QuestionAnalysisMapper.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/dao/QuestionAnalysisMapper.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/dao/QuestionMapper.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/dao/QuestionMapper.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/dto/DocumentDTO.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/dto/DocumentDTO.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/entity/Document.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/entity/Document.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/entity/Question.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/entity/Question.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/service/IDocumentService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/IDocumentService.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/service/IQuestionAnalysisService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/IQuestionAnalysisService.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/service/IQuestionService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/IQuestionService.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/DocumentServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/DocumentServiceImpl.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/ProfessorResultServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/ProfessorResultServiceImpl.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/QuestionAnalysisServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/QuestionAnalysisServiceImpl.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/QuestionServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/service/impl/QuestionServiceImpl.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/vo/AnalysisResultVO.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/AnalysisResultVO.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/vo/CycleVO.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/CycleVO.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/vo/DocumentCycleVO.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/DocumentCycleVO.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/vo/DocumentVO.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/DocumentVO.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/dayou/vo/ProfessorResultVO.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dayou/vo/ProfessorResultVO.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/resources/mapper/AnalysisResultMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/mapper/AnalysisResultMapper.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/resources/mapper/CycleMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/mapper/CycleMapper.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/resources/mapper/DocumentMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/mapper/DocumentMapper.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/resources/mapper/ProfessorResultMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/mapper/ProfessorResultMapper.xml" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -187,7 +144,11 @@
       <workItem from="1689727659647" duration="15945000" />
       <workItem from="1689814541193" duration="21345000" />
       <workItem from="1689900018717" duration="15499000" />
-      <workItem from="1690160956840" duration="4572000" />
+      <workItem from="1690160956840" duration="6388000" />
+      <workItem from="1690246915477" duration="13083000" />
+      <workItem from="1690331871855" duration="13059000" />
+      <workItem from="1690420437727" duration="9737000" />
+      <workItem from="1690504907314" duration="14387000" />
     </task>
     <servers />
   </component>

+ 9 - 6
src/main/java/com/dayou/controller/DocumentController.java

@@ -1,7 +1,10 @@
 package com.dayou.controller;
 
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.dayou.configuration.BaseEntity;
 import com.dayou.configuration.RestResponse;
 import com.dayou.configuration.annotation.IgnoreAuth;
 import com.dayou.dto.CommitDTO;
@@ -59,24 +62,24 @@ public class DocumentController {
 
     /**
      * 问卷列表
-     * @param documentVO
+     * @param document
      * @param page
      * @return
      */
     @GetMapping("")
-    public RestResponse<IPage<DocumentVO>> gePage(Page page, DocumentVO documentVO ){
-        IPage<DocumentVO> result = documentService.getPage(documentVO,page);
+    public RestResponse<IPage<DocumentVO>> getPage(Page page, Document document ){
+        IPage<DocumentVO> result = documentService.getPage(page,document);
         return RestResponse.data(result);
     }
 
     /**
      * 新增问卷
-     * @param documentDTO
+     * @param document
      * @return
      */
     @PostMapping("")
-    public RestResponse<Boolean> saveDocument(@RequestBody DocumentDTO documentDTO){
-        Boolean result = documentService.saveDocument(documentDTO);
+    public RestResponse<Boolean> saveDocument(@RequestBody Document document){
+        Boolean result = documentService.saveOrUpdate(document);
         return RestResponse.data(result);
     }
 }

+ 8 - 0
src/main/java/com/dayou/controller/QuestionAnalysisController.java

@@ -4,6 +4,8 @@ import com.dayou.configuration.RestResponse;
 import com.dayou.configuration.annotation.IgnoreAuth;
 import com.dayou.service.IQuestionAnalysisService;
 import com.dayou.vo.AnalysisResultVO;
+import com.dayou.vo.MergeTableVO;
+import com.dayou.vo.MergeVO;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -40,4 +42,10 @@ public class QuestionAnalysisController {
         List<AnalysisResultVO> list = questionAnalysisService.getAnalysisListByCycleId(id);
         return RestResponse.data(list);
     }
+
+    @GetMapping("/merge")
+    public RestResponse<MergeVO> getMergeData(){
+        MergeVO mergeVO = questionAnalysisService.getMergeData();
+        return RestResponse.data(mergeVO);
+    }
 }

+ 23 - 5
src/main/java/com/dayou/controller/QuestionController.java

@@ -10,6 +10,7 @@ import com.dayou.entity.Question;
 import com.dayou.service.IQuestionService;
 import com.dayou.utils.ConvertUtil;
 import com.dayou.vo.LabelKeyVO;
+import com.dayou.vo.QuestionTreeVO;
 import com.dayou.vo.QuestionVO;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -36,23 +37,40 @@ public class QuestionController {
     @GetMapping("")
     public RestResponse<IPage<QuestionVO>> getQuestion(Question question, Page page){
         Page xPage = questionService.page(page, new LambdaQueryWrapper<Question>()
-                .like(StrUtil.isNotBlank(question.getName()), Question::getName, question.getName()));
+                .like(StrUtil.isNotBlank(question.getLabel()), Question::getLabel, question.getLabel()));
         return RestResponse.data(xPage);
     }
 
     @PostMapping("")
-    public RestResponse<Boolean> saveQuestion(@RequestBody @Valid Question question){
-        return RestResponse.data(questionService.save(question));
+    public RestResponse<Long> saveQuestion(@RequestBody @Valid Question question){
+        boolean b = questionService.saveOrUpdate(question);
+        return RestResponse.data(question.getId());
     }
 
     @GetMapping("/simpleAll")
     public RestResponse<List<LabelKeyVO>> getList(){
-        List<Question> list = questionService.list(new LambdaQueryWrapper<Question>().select(BaseEntity::getId, Question::getName));
+        List<Question> list = questionService.list(new LambdaQueryWrapper<Question>().select(BaseEntity::getId, Question::getLabel).isNull(Question::getParentId));
         List<LabelKeyVO> labelKeyVOS = ConvertUtil.copyList(list, LabelKeyVO.class);
         labelKeyVOS.stream().forEach(x->{
             x.setKey(x.getId());
-            x.setLabel(x.getName());
+            x.setLabel(x.getLabel());
         });
         return RestResponse.data(labelKeyVOS);
     }
+
+    /**
+     * 题目树
+     * @param question
+     * @return
+     */
+    @GetMapping("/tree")
+    public RestResponse<List<QuestionTreeVO>> getQuestionTree(Question question){
+        List<QuestionTreeVO> tree = questionService.getQuestionTree(question);
+        return RestResponse.data(tree);
+    }
+
+    @DeleteMapping("/{id}")
+    public RestResponse<Boolean> remove(@PathVariable("id") Long id){
+        return RestResponse.data(questionService.removeById(id));
+    }
 }

+ 2 - 1
src/main/java/com/dayou/dao/DocumentMapper.java

@@ -7,6 +7,7 @@ import com.dayou.entity.Document;
 import com.dayou.vo.DocumentCycleVO;
 import com.dayou.vo.DocumentVO;
 import org.apache.ibatis.annotations.Param;
+import org.springframework.web.bind.annotation.PostMapping;
 
 /**
  * 类说明:
@@ -18,5 +19,5 @@ import org.apache.ibatis.annotations.Param;
 public interface DocumentMapper extends BaseMapper<Document> {
     DocumentCycleVO getDocumentCycleVO();
 
-    IPage<DocumentVO> getPage(Page page, @Param("document") DocumentVO documentVO);
+    IPage<DocumentVO> getPage(Page page, @Param("document") Document document);
 }

+ 4 - 0
src/main/java/com/dayou/dao/QuestionAnalysisMapper.java

@@ -3,9 +3,11 @@ package com.dayou.dao;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.dayou.entity.QuestionAnalysis;
 import com.dayou.vo.AnalysisResultVO;
+import com.dayou.vo.ChildrenParentName;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 类说明:
@@ -18,4 +20,6 @@ public interface QuestionAnalysisMapper extends BaseMapper<QuestionAnalysis> {
     List<AnalysisResultVO> getAnalysisList();
 
     List<AnalysisResultVO> getAnalysisListByCycleId(@Param("id") Long id);
+
+    List<ChildrenParentName> getParentLabel();
 }

+ 4 - 0
src/main/java/com/dayou/dao/QuestionMapper.java

@@ -2,6 +2,9 @@ package com.dayou.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.dayou.entity.Question;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 类说明:
@@ -11,4 +14,5 @@ import com.dayou.entity.Question;
  * created with IntelliJ IDEA.
  */
 public interface QuestionMapper extends BaseMapper<Question> {
+    List<Question> findChildren(@Param("rootId") Long rootId);
 }

+ 0 - 3
src/main/java/com/dayou/dto/DocumentDTO.java

@@ -17,9 +17,6 @@ public class DocumentDTO {
 
     private String itemName;
 
-    private String scope;
-
     private String type;
 
-    private List<Long> questions;
 }

+ 1 - 3
src/main/java/com/dayou/entity/Document.java

@@ -16,8 +16,6 @@ public class Document extends BaseEntity {
 
     private String itemName;
 
-    private String type;
-
-    private String scope;
+    private Long typeId;
 
 }

+ 17 - 1
src/main/java/com/dayou/entity/Question.java

@@ -1,11 +1,14 @@
 package com.dayou.entity;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.dayou.configuration.BaseEntity;
 import com.github.liangbaika.validate.annations.AbcValidate;
 import com.github.liangbaika.validate.enums.Check;
 import lombok.Builder;
 import lombok.Data;
 
+import java.math.BigDecimal;
+
 /**
  * 类说明:
  *
@@ -17,6 +20,19 @@ import lombok.Data;
 public class Question extends BaseEntity {
 
     @AbcValidate(required = true,message = "题目名称不能为空" ,fun = Check.NotEmpty)
-    private String name;
+    private String label;
+
+    private Long parentId;
+
+    private String scope;
+
+    private BigDecimal minScore;
+
+    private BigDecimal maxScore;
+
+    @TableField(exist = false)
+    private String parentLabel;
 
+    @TableField(exist = false)
+    private BigDecimal score;
 }

+ 1 - 3
src/main/java/com/dayou/service/IDocumentService.java

@@ -18,7 +18,5 @@ import com.dayou.vo.DocumentVO;
 public interface IDocumentService extends IService<Document> {
     DocumentCycleVO getDocumentCycleVO();
 
-    IPage<DocumentVO> getPage(DocumentVO documentVO, Page page);
-
-    Boolean saveDocument(DocumentDTO documentDTO);
+    IPage<DocumentVO> getPage(Page page, Document document);
 }

+ 4 - 0
src/main/java/com/dayou/service/IQuestionAnalysisService.java

@@ -3,6 +3,8 @@ package com.dayou.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.dayou.entity.QuestionAnalysis;
 import com.dayou.vo.AnalysisResultVO;
+import com.dayou.vo.MergeTableVO;
+import com.dayou.vo.MergeVO;
 
 import java.util.List;
 
@@ -17,4 +19,6 @@ public interface IQuestionAnalysisService extends IService<QuestionAnalysis> {
     List<AnalysisResultVO> getAnalysisList();
 
     List<AnalysisResultVO> getAnalysisListByCycleId(Long id);
+
+    MergeVO getMergeData();
 }

+ 4 - 0
src/main/java/com/dayou/service/IQuestionService.java

@@ -2,6 +2,9 @@ package com.dayou.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.dayou.entity.Question;
+import com.dayou.vo.QuestionTreeVO;
+
+import java.util.List;
 
 /**
  * 类说明:
@@ -11,4 +14,5 @@ import com.dayou.entity.Question;
  * created with IntelliJ IDEA.
  */
 public interface IQuestionService extends IService<Question> {
+    List<QuestionTreeVO> getQuestionTree(Question question);
 }

+ 41 - 18
src/main/java/com/dayou/service/impl/DocumentServiceImpl.java

@@ -1,22 +1,35 @@
 package com.dayou.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.dayou.configuration.BaseEntity;
 import com.dayou.dao.DocumentMapper;
+import com.dayou.dao.QuestionMapper;
 import com.dayou.dto.DocumentDTO;
 import com.dayou.entity.Document;
 import com.dayou.entity.DocumentQuestion;
+import com.dayou.entity.Question;
 import com.dayou.service.IDocumentQuestionService;
 import com.dayou.service.IDocumentService;
+import com.dayou.service.IQuestionService;
+import com.dayou.utils.ConvertUtil;
+import com.dayou.utils.TreeUtil;
 import com.dayou.vo.DocumentCycleVO;
 import com.dayou.vo.DocumentVO;
+import com.dayou.vo.QuestionTreeVO;
+import com.google.common.collect.Lists;
+import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
@@ -33,32 +46,42 @@ public class DocumentServiceImpl extends ServiceImpl<DocumentMapper, Document> i
     private DocumentMapper documentMapper;
 
     @Autowired
-    private IDocumentQuestionService documentQuestionService;
+    private IQuestionService questionService;
+
+    @Autowired
+    private QuestionMapper questionMapper;
+
     @Override
     public DocumentCycleVO getDocumentCycleVO() {
         DocumentCycleVO documentCycleVO = documentMapper.getDocumentCycleVO();
+        List<List<Question>> results = new ArrayList<>();
+        Long typeId = documentCycleVO.getTypeId();
+        List<Question> children = Lists.newArrayList();
+        children = findChildren(typeId, children);
+        Map<Long, List<Question>> collect = children.stream().collect(Collectors.groupingBy(Question::getParentId));
+        for(Map.Entry<Long,List<Question>> map :collect.entrySet()){
+            results.add(map.getValue());
+        }
+        documentCycleVO.setQuestions(results);
         return documentCycleVO;
     }
 
     @Override
-    public IPage<DocumentVO> getPage(DocumentVO documentVO, Page page) {
-        IPage<DocumentVO> xPage = documentMapper.getPage(page,documentVO);
-        return xPage;
+    public IPage<DocumentVO> getPage(Page page, Document document) {
+        IPage<DocumentVO> result = documentMapper.getPage(page,document);
+        return result;
     }
 
-    @Transactional
-    @Override
-    public Boolean saveDocument(DocumentDTO documentDTO) {
-        Document document = BeanUtil.copyProperties(documentDTO, Document.class);
-        this.save(document);
-        List<Long> questions = documentDTO.getQuestions();
-        Long documentId = document.getId();
-        List<DocumentQuestion> collect = questions.stream().map(x -> {
-            DocumentQuestion dq = new DocumentQuestion();
-            dq.setDocumentId(documentId);
-            dq.setQuestionId(x);
-            return dq;
-        }).collect(Collectors.toList());
-        return documentQuestionService.saveBatch(collect);
+    private List<Question> findChildren(Long rootId,List<Question> children){
+        List<Question> list = questionMapper.findChildren(rootId);
+        if (CollectionUtils.isNotEmpty(list)){
+            children.addAll(list);
+        }else {
+            return children;
+        }
+        for (Question question : list){
+            findChildren(question.getId(),children);
+        }
+        return children;
     }
 }

+ 4 - 3
src/main/java/com/dayou/service/impl/ProfessorResultServiceImpl.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.dayou.configuration.BaseEntity;
 import com.dayou.dao.ProfessorResultMapper;
 import com.dayou.entity.ProfessorResult;
+import com.dayou.entity.Question;
 import com.dayou.entity.QuestionAnalysis;
 import com.dayou.service.IProfessorResultService;
 import com.dayou.service.IQuestionAnalysisService;
@@ -42,7 +43,7 @@ public class ProfessorResultServiceImpl extends ServiceImpl<ProfessorResultMappe
     @Transactional
     @Override
     public synchronized Boolean commitDocument(DocumentCycleVO documentCycleVO) {
-        List<QuestionVO> questions = documentCycleVO.getQuestions();
+        List<Question> questions = documentCycleVO.getResult();
         String professorNo = documentCycleVO.getProfessorNo();
         Long cycleId = documentCycleVO.getId();
 
@@ -60,7 +61,7 @@ public class ProfessorResultServiceImpl extends ServiceImpl<ProfessorResultMappe
             this.saveBatch(collect);
         }
         else {
-            for (QuestionVO questionVO : questions){
+            for (Question questionVO : questions){
                 for (ProfessorResult professorResult :list){
                     if (professorResult.getQuestionId().equals(questionVO.getId())){
                         professorResult.setScore(questionVO.getScore());
@@ -70,7 +71,7 @@ public class ProfessorResultServiceImpl extends ServiceImpl<ProfessorResultMappe
             this.updateBatchById(list);
         }
 
-        List<Long> questionIds = questions.stream().map(QuestionVO::getId).collect(Collectors.toList());
+        List<Long> questionIds = questions.stream().map(Question::getId).collect(Collectors.toList());
         analysisScore(cycleId,questionIds);
         webSocketServer.sendSocket("data");
         return Boolean.TRUE;

+ 95 - 1
src/main/java/com/dayou/service/impl/QuestionAnalysisServiceImpl.java

@@ -4,11 +4,21 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.dayou.dao.QuestionAnalysisMapper;
 import com.dayou.entity.QuestionAnalysis;
 import com.dayou.service.IQuestionAnalysisService;
+import com.dayou.utils.Tree;
+import com.dayou.utils.TreeUtil;
 import com.dayou.vo.AnalysisResultVO;
+import com.dayou.vo.ChildrenParentName;
+import com.dayou.vo.MergeTableVO;
+import com.dayou.vo.MergeVO;
+import com.google.common.collect.Lists;
+import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 类说明:
@@ -25,11 +35,95 @@ public class QuestionAnalysisServiceImpl extends ServiceImpl<QuestionAnalysisMap
 
     @Override
     public List<AnalysisResultVO> getAnalysisList() {
-        return questionAnalysisMapper.getAnalysisList();
+        List<AnalysisResultVO> analysisList = questionAnalysisMapper.getAnalysisList();
+        analysisList = (List<AnalysisResultVO>) TreeUtil.buildTree(analysisList,analysisList.get(0).getTypeId());
+        return analysisList;
     }
 
     @Override
     public List<AnalysisResultVO> getAnalysisListByCycleId(Long id) {
         return questionAnalysisMapper.getAnalysisListByCycleId(id);
     }
+
+    @Override
+    public MergeVO getMergeData() {
+        MergeVO merge = new MergeVO();
+        List<ChildrenParentName> parentLabel = questionAnalysisMapper.getParentLabel();
+        Map<String, String> childrenParentMap = parentLabel.stream().collect(Collectors.toMap(ChildrenParentName::getLabel, ChildrenParentName::getParentLabel));
+        List<AnalysisResultVO> analysisList = questionAnalysisMapper.getAnalysisList();
+        merge.setItemName(analysisList.get(0).getItemName());
+        merge.setCycleName(analysisList.get(0).getCycleName());
+        merge.setTypeName(analysisList.get(0).getTypeName());
+        if (analysisList.get(0).getQuestionId()==null){
+            return merge;
+        }
+        Map<String, BigDecimal> labelScore = analysisList.stream().collect(Collectors.toMap(AnalysisResultVO::getQuestionName, AnalysisResultVO::getAvgScore));
+        analysisList = (List<AnalysisResultVO>) TreeUtil.buildTree(analysisList,analysisList.get(0).getTypeId());
+        List<AnalysisResultVO> allChildren = Lists.newArrayList();
+        for (AnalysisResultVO analysisResultVO : analysisList){
+                allChildren = getChildrenIsNull(analysisResultVO, allChildren);
+        }
+        List<MergeTableVO> result = Lists.newArrayList();
+        for (AnalysisResultVO analysisResultVO : allChildren){
+            if (analysisResultVO.getScope().equals("名称")){
+                MergeTableVO mergeVO = MergeTableVO.builder()
+                        .name(analysisResultVO.getQuestionName()
+                                +"-"+ labelScore.get(analysisResultVO.getQuestionName())).build();
+                result.add(mergeVO);
+            }
+            if (analysisResultVO.getScope().equals("定级因素")){
+                MergeTableVO mergeVO = MergeTableVO.builder().element(analysisResultVO.getQuestionName()
+                                +"-"+ labelScore.get(analysisResultVO.getQuestionName()) )
+                        .name(childrenParentMap.get(analysisResultVO.getQuestionName())
+                                +"-"+ labelScore.get(childrenParentMap.get(analysisResultVO.getQuestionName()))).build();
+                result.add(mergeVO);
+            }
+            if (analysisResultVO.getScope().equals("一级因子")){
+                MergeTableVO mergeVO = MergeTableVO.builder().element1(analysisResultVO.getQuestionName()
+                                +"-"+ labelScore.get(analysisResultVO.getQuestionName()))
+                        .element(childrenParentMap.get(analysisResultVO.getQuestionName())
+                                +"-"+ labelScore.get(childrenParentMap.get(analysisResultVO.getQuestionName())))
+                        .name(childrenParentMap.get(childrenParentMap.get(analysisResultVO.getQuestionName()))
+                                +"-"+ labelScore.get(childrenParentMap.get(childrenParentMap.get(analysisResultVO.getQuestionName())))).build();
+                result.add(mergeVO);
+            }
+            if (analysisResultVO.getScope().equals("二级因子")){
+                MergeTableVO mergeVO = MergeTableVO.builder().element2(analysisResultVO.getQuestionName()
+                                +"-"+ labelScore.get(analysisResultVO.getQuestionName()))
+                        .element1(childrenParentMap.get(analysisResultVO.getQuestionName())
+                                +"-"+ labelScore.get(childrenParentMap.get(analysisResultVO.getQuestionName())))
+                        .element(childrenParentMap.get(childrenParentMap.get(analysisResultVO.getQuestionName()))
+                                +"-"+ labelScore.get(childrenParentMap.get(childrenParentMap.get(analysisResultVO.getQuestionName()))))
+                        .name(childrenParentMap.get(childrenParentMap.get(childrenParentMap.get(analysisResultVO.getQuestionName())))
+                                +"-"+ labelScore.get(childrenParentMap.get(childrenParentMap.get(childrenParentMap.get(analysisResultVO.getQuestionName()))))).build();
+                result.add(mergeVO);
+            }
+        }
+        merge.setAnalysisData(result);
+        return merge;
+    }
+
+    private List<AnalysisResultVO> getChildrenAll(AnalysisResultVO analysisResultVO,List<AnalysisResultVO> allChildren){
+        List<AnalysisResultVO> children = analysisResultVO.getChildren();
+        if (CollectionUtils.isEmpty(children)){
+            return allChildren;
+        }
+        allChildren.addAll(children);
+        for (AnalysisResultVO analysis : children){
+            getChildrenAll(analysis,allChildren);
+        }
+        return null;
+    }
+
+    private List<AnalysisResultVO> getChildrenIsNull(AnalysisResultVO analysisResultVO,List<AnalysisResultVO> childrenNull){
+        List<AnalysisResultVO> children = analysisResultVO.getChildren();
+        if (CollectionUtils.isEmpty(children)){
+            childrenNull.add(analysisResultVO);
+        }else {
+            for (AnalysisResultVO analysis : children){
+                getChildrenIsNull(analysis,childrenNull);
+            }
+        }
+        return childrenNull;
+    }
 }

+ 35 - 0
src/main/java/com/dayou/service/impl/QuestionServiceImpl.java

@@ -1,11 +1,22 @@
 package com.dayou.service.impl;
 
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.dayou.configuration.BaseEntity;
 import com.dayou.dao.QuestionMapper;
 import com.dayou.entity.Question;
 import com.dayou.service.IQuestionService;
+import com.dayou.utils.ConvertUtil;
+import com.dayou.utils.TreeUtil;
+import com.dayou.vo.QuestionTreeVO;
+import org.apache.commons.collections.CollectionUtils;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
 /**
  * 类说明:
  *
@@ -15,4 +26,28 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> implements IQuestionService {
+    @Override
+    public List<QuestionTreeVO> getQuestionTree(Question question) {
+        List<QuestionTreeVO> results = null;
+        List<Question> questions = this.list(new LambdaQueryWrapper<Question>()
+                .eq(question.getId()!=null,BaseEntity::getId,question.getId())
+                .like(StrUtil.isNotBlank(question.getLabel()), Question::getLabel, question.getLabel())
+                .eq(StrUtil.isNotBlank(question.getScope()), Question::getScope, question.getScope()));
+        Map<Long, String> idLabels = questions.stream().collect(Collectors.toMap(BaseEntity::getId, Question::getLabel));
+        if (CollectionUtils.isNotEmpty(questions)){
+            List<QuestionTreeVO> result = ConvertUtil.copyList(questions, q -> {
+                QuestionTreeVO questionTreeVO = new QuestionTreeVO();
+                questionTreeVO.setId(q.getId());
+                questionTreeVO.setLabel(q.getLabel());
+                questionTreeVO.setParentId(q.getParentId());
+                questionTreeVO.setParentLabel(idLabels.get(q.getParentId()));
+                questionTreeVO.setMinScore(q.getMinScore());
+                questionTreeVO.setMaxScore(q.getMaxScore());
+                questionTreeVO.setScope(q.getScope());
+                return questionTreeVO;
+            });
+            results = (List<QuestionTreeVO>) TreeUtil.buildTree(result,null);
+        }
+        return results;
+    }
 }

+ 18 - 0
src/main/java/com/dayou/utils/Tree.java

@@ -0,0 +1,18 @@
+package com.dayou.utils;
+
+import java.util.List;
+
+public interface Tree<K,V> {
+
+    K getId();
+
+    V getName();
+
+    K getParentId();
+
+    int order();
+
+    List<? extends Tree<K,V>> getChildren();
+
+    void setChildren(List<? extends Tree<K,V>> children);
+}

+ 126 - 0
src/main/java/com/dayou/utils/TreeUtil.java

@@ -0,0 +1,126 @@
+package com.dayou.utils;
+
+import org.apache.commons.collections.CollectionUtils;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class TreeUtil {
+
+    /**
+     * 根据平铺列表构建树
+     * @param list
+     * @param <K>
+     * @param <V>
+     * @return
+     */
+    public static<K,V> List<? extends Tree<K,V>> buildTree(Collection<? extends Tree<K,V>> list,Long rootId){
+        List<Tree<K, V>> trees = new LinkedList<>();
+
+        if(CollectionUtils.isEmpty(list)){
+            return trees;
+        }
+        //找出所有根节点
+        List<? extends Tree<K,V>>  root = null;
+        if (rootId!=null){
+            root =  list.stream().filter(t->(t.getParentId().equals(rootId))).collect(Collectors.toList());
+        }else {
+            root = list.stream().filter(t->(t.getParentId()==null||t.getParentId().equals(0L))).collect(Collectors.toList());
+        }
+
+        if(CollectionUtils.isNotEmpty(root)){
+            Collections.sort(root,(o1, o2) -> o1.order() - o2.order());
+            //为每个节点找出它的children
+            for (Tree<K,V> leaf:root){
+                findChildren(leaf,list);
+                trees.add(leaf);
+            }
+        }
+
+        return trees;
+    }
+
+    /**
+     * 将树转换为平铺列表
+     * @param trees
+     * @param <K>
+     * @param <V>
+     * @return
+     */
+    public static<K,V> Collection<? extends Tree<K,V>> treeTile(Collection<? extends Tree<K,V>> trees){
+        Collection<Tree<K, V>> list = new LinkedList<>();
+
+        if(CollectionUtils.isEmpty(trees)){
+            return Collections.EMPTY_LIST;
+        }
+
+        for(Tree<K,V> node:trees){
+//            Tree<K, V> tiledNode = new Tree<K, V>() {
+//                @Override
+//                public K getId() {
+//                    return node.getId();
+//                }
+//
+//                @Override
+//                public V getName() {
+//                    return node.getName();
+//                }
+//
+//                @Override
+//                public K getParentId() {
+//                    return node.getParentId();
+//                }
+//
+//                @Override
+//                public List<? extends Tree<K, V>> getChildren() {
+//                    return null;
+//                }
+//
+//                @Override
+//                public void setChildren(List<? extends Tree<K, V>> children) {
+//
+//                }
+//            };
+            list.add(node);
+            Collection<? extends Tree<K,V>> children=node.getChildren();
+            if(CollectionUtils.isNotEmpty(children)){
+                Collection<? extends Tree<K,V>> subList=treeTile(children);
+                list.addAll(subList);
+            }
+            node.setChildren(null);
+        }
+
+        return list;
+
+    }
+
+    private static<K,V> void findChildren(Tree<K,V> leaf, Collection<? extends Tree<K,V>> list) {
+        K id=leaf.getId();
+        List<? extends Tree<K,V>> children = list.stream().filter(t->id.equals(t.getParentId())).collect(Collectors.toList());
+        if(CollectionUtils.isNotEmpty(children)){
+            Collections.sort(children,(o1, o2) -> o1.order() - o2.order());
+            leaf.setChildren(children);
+        }
+        list = list.stream().filter(t->!id.equals(t.getId())).collect(Collectors.toList());
+        if(CollectionUtils.isNotEmpty(children)){
+            for(Tree<K,V> subLeaf:children){
+                findChildren(subLeaf, list);
+            }
+        }
+    }
+
+    /**
+     * 检测树中是否包含环
+     * todo
+     * @param list
+     * @param <K>
+     * @param <V>
+     * @return
+     */
+    public static<K,V> boolean checkIfExistRecycle(Collection<? extends Tree<K,V>> list){
+        return false;
+    }
+}

+ 39 - 1
src/main/java/com/dayou/vo/AnalysisResultVO.java

@@ -1,8 +1,11 @@
 package com.dayou.vo;
 
+import com.dayou.utils.Tree;
 import lombok.Data;
+import org.checkerframework.checker.units.qual.K;
 
 import java.math.BigDecimal;
+import java.util.List;
 
 /**
  * 类说明:
@@ -12,7 +15,7 @@ import java.math.BigDecimal;
  * created with IntelliJ IDEA.
  */
 @Data
-public class AnalysisResultVO {
+public class AnalysisResultVO implements Tree<Long,String>  {
 
     private Long documentId;
 
@@ -29,4 +32,39 @@ public class AnalysisResultVO {
     private String questionName;
 
     private BigDecimal avgScore;
+
+    private List<AnalysisResultVO> children;
+
+    private Long id;
+
+    private Long parentId;
+
+    private Long typeId;
+
+    private String typeName;
+
+    @Override
+    public Long getId() {
+        return id;
+    }
+
+    @Override
+    public String getName() {
+        return questionName;
+    }
+
+    @Override
+    public Long getParentId() {
+        return parentId;
+    }
+
+    @Override
+    public int order() {
+        return 0;
+    }
+
+    @Override
+    public void setChildren(List<? extends Tree<Long, String>> children) {
+        this.children =(List<AnalysisResultVO>) children;
+    }
 }

+ 18 - 0
src/main/java/com/dayou/vo/ChildrenParentName.java

@@ -0,0 +1,18 @@
+package com.dayou.vo;
+
+import lombok.Data;
+
+/**
+ * 类说明:
+ *
+ * @author: wucl
+ * @since: 2023/7/28
+ * created with IntelliJ IDEA.
+ */
+@Data
+public class ChildrenParentName {
+
+    private String label;
+
+    private String parentLabel;
+}

+ 1 - 1
src/main/java/com/dayou/vo/CycleVO.java

@@ -24,7 +24,7 @@ public class CycleVO {
 
     private String type;
 
-    private String scope;
+    private Long typeId;
 
     private LocalDateTime created;
 }

+ 6 - 1
src/main/java/com/dayou/vo/DocumentCycleVO.java

@@ -1,5 +1,6 @@
 package com.dayou.vo;
 
+import com.dayou.entity.Question;
 import com.github.liangbaika.validate.annations.AbcValidate;
 import com.github.liangbaika.validate.enums.Check;
 import lombok.Data;
@@ -26,11 +27,15 @@ public class DocumentCycleVO {
 
     private String itemName;
 
+    private Long typeId;
+
     private String type;
 
     private String scope;
 
-    private List<QuestionVO> questions;
+    private List<List<Question>> questions;
+
+    private List<Question> result;
 
     private LocalDateTime created;
 

+ 2 - 0
src/main/java/com/dayou/vo/DocumentVO.java

@@ -24,6 +24,8 @@ public class DocumentVO {
 
     private String type;
 
+    private Long typeId;
+
     private List<QuestionVO> questions;
 
     private LocalDateTime created;

+ 24 - 0
src/main/java/com/dayou/vo/MergeTableVO.java

@@ -0,0 +1,24 @@
+package com.dayou.vo;
+
+import lombok.Builder;
+import lombok.Data;
+
+/**
+ * 类说明:
+ *
+ * @author: wucl
+ * @since: 2023/7/28
+ * created with IntelliJ IDEA.
+ */
+@Data
+@Builder
+public class MergeTableVO {
+
+    private String name;
+
+    private String element;
+
+    private String element1;
+
+    private String element2;
+}

+ 24 - 0
src/main/java/com/dayou/vo/MergeVO.java

@@ -0,0 +1,24 @@
+package com.dayou.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * 类说明:
+ *
+ * @author: wucl
+ * @since: 2023/7/28
+ * created with IntelliJ IDEA.
+ */
+@Data
+public class MergeVO {
+
+    private String itemName;
+
+    private String cycleName;
+
+    private String typeName;
+
+    private List<MergeTableVO> analysisData;
+}

+ 1 - 0
src/main/java/com/dayou/vo/ProfessorResultVO.java

@@ -1,5 +1,6 @@
 package com.dayou.vo;
 
+import com.dayou.utils.Tree;
 import lombok.Data;
 
 import java.math.BigDecimal;

+ 51 - 0
src/main/java/com/dayou/vo/QuestionTreeVO.java

@@ -0,0 +1,51 @@
+package com.dayou.vo;
+
+import com.dayou.utils.Tree;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 类说明:
+ *
+ * @author: wucl
+ * @since: 2023/7/25
+ * created with IntelliJ IDEA.
+ */
+@Data
+public class QuestionTreeVO implements Tree<Long,String> {
+
+    private Long id;
+    private String label;
+
+    private Long parentId;
+
+    private String parentLabel;
+
+    private String scope;
+
+    private List<QuestionTreeVO> children = new ArrayList<>();
+
+    private BigDecimal minScore;
+
+    private BigDecimal maxScore;
+
+
+
+    @Override
+    public String getName() {
+        return label;
+    }
+
+    @Override
+    public int order() {
+        return 0;
+    }
+
+    @Override
+    public void setChildren(List<? extends Tree<Long, String>> children) {
+        this.children = (List<QuestionTreeVO>) children;
+    }
+}

+ 36 - 6
src/main/resources/mapper/AnalysisResultMapper.xml

@@ -7,16 +7,21 @@
             t.id AS cycle_id,
             qa.question_id,
             t.cycle_name,
-            q.NAME AS questionName,
+            q.label AS questionName,
             d.item_name,
-            d.scope,
             qa.avg_score,
-            t.document_id
+            t.document_id,
+            t.type_id,
+            q.parent_id,
+            q.id,
+            q.scope,
+            qq.label as typeName
         FROM
             question_analysis qa
-                RIGHT JOIN ( SELECT id, document_id, cycle_name FROM cycle ORDER BY created DESC LIMIT 1 ) t ON t.id = qa.cycle_id
+                RIGHT JOIN ( SELECT c.id, c.document_id, c.cycle_name,d.type_id FROM cycle c left join document d on d.id = c.document_id ORDER BY c.created DESC LIMIT 1  ) t ON t.id = qa.cycle_id
                 LEFT JOIN question q ON q.id = qa.question_id
                 LEFT JOIN document d ON d.id = t.document_id
+                left join question qq on qq.id = d.type_id
         ORDER BY
             q.created
     </select>
@@ -26,9 +31,8 @@
             t.id AS cycle_id,
             qa.question_id,
             t.cycle_name,
-            q.NAME AS questionName,
+            q.label AS questionName,
             d.item_name,
-            d.scope,
             qa.avg_score,
             t.document_id
         FROM
@@ -39,4 +43,30 @@
         ORDER BY
             q.created
     </select>
+
+    <select id="getParentLabel" resultType="com.dayou.vo.ChildrenParentName">
+        SELECT
+            q.label AS label,
+            qq.label AS parentLabel
+        FROM
+            question_analysis qa
+                RIGHT JOIN (
+                SELECT
+                    c.id,
+                    c.document_id,
+                    c.cycle_name,
+                    d.type_id
+                FROM
+                    cycle c
+                        LEFT JOIN document d ON d.id = c.document_id
+                ORDER BY
+                    c.created DESC
+                    LIMIT 1
+            ) t ON t.id = qa.cycle_id
+                LEFT JOIN question q ON q.id = qa.question_id
+                LEFT JOIN question qq ON q.parent_id = qq.id
+        WHERE
+            q.deleted = 0
+          AND qq.deleted = 0
+    </select>
 </mapper>

+ 12 - 10
src/main/resources/mapper/CycleMapper.xml

@@ -4,17 +4,16 @@
 
     <select id="getPage" parameterType="com.dayou.vo.CycleVO" resultType="com.dayou.vo.CycleVO">
         SELECT
-            c.id,
-            d.id as documentId,
-            d.item_name,
-            d.scope,
-            d.type,
-            c.cycle_name,
-            c.created
+        c.id,
+        d.id as documentId,
+        d.item_name,
+        q.label as type,
+        c.cycle_name,
+        c.created
         FROM
-            cycle c
-                LEFT JOIN document d ON d.id = c.document_id
-            <where>
+        cycle c
+        LEFT JOIN document d ON d.id = c.document_id left join question q on d.type_id= q.id
+        <where>
                 c.deleted = 0 and d.deleted = 0
                 <if test="cycle!=null and cycle.itemName!=null and cycle.itemName!='' ">
                     and d.item_name like concat('%',#{cycle.itemName},'%')
@@ -22,6 +21,9 @@
                 <if test="cycle!=null and cycle.cycleName!=null and cycle.cycleName!='' ">
                     and c.cycle_name like concat('%',#{cycle.cycleName},'%')
                 </if>
+                <if test="cycle!=null and cycle.typeId!=null">
+                    and d.type_id = #{cycle.typeId}
+                </if>
             </where>
         order by c.created DESC
     </select>

+ 10 - 9
src/main/resources/mapper/DocumentMapper.xml

@@ -7,17 +7,16 @@
         <result column="id" property="id" />
         <result column="document_id" property="documentId" />
         <result column="cycle_name" property="cycleName" />
-        <result column="scope" property="scope" />
         <result column="type" property="type" />
+        <result column="type_id" property="typeId" />
         <result column="item_name" property="itemName" />
         <result column="created" property="created" />
-        <collection property="questions"  ofType="com.dayou.vo.QuestionVO" select="selectQuestion" column="document_id"/>
+<!--        <collection property="questions"  ofType="com.dayou.vo.QuestionVO" select="selectQuestion" column="document_id"/>-->
     </resultMap>
 
     <resultMap id="documentMap" type="com.dayou.vo.DocumentVO">
         <result column="id" property="id" />
         <result column="item_name" property="itemName" />
-        <result column="scope" property="scope" />
         <result column="type" property="type" />
         <result column="created" property="created" />
         <collection property="questions"  ofType="com.dayou.vo.QuestionVO" select="selectQuestion" column="id"/>
@@ -27,8 +26,8 @@
     <select id="getDocumentCycleVO" resultMap="documentCycleMap">
         SELECT
             d.item_name,
-            d.scope,
-            d.type,
+            d.type_id,
+            qq.label as type,
             t.cycle_name,
             d.id AS document_id,
             t.id,
@@ -36,6 +35,7 @@
         FROM
             document d
                 RIGHT JOIN ( SELECT id, document_id, cycle_name, created FROM cycle WHERE deleted = 0 ORDER BY created DESC LIMIT 1 ) t ON t.document_id = d.id
+                left join question qq on qq.id=d.type_id
         WHERE
             d.deleted = 0
     </select>
@@ -44,11 +44,12 @@
         select q.id,q.name,q.created from document_question dq left join question q on q.id = dq.question_id where dq.document_id = #{id} and dq.deleted = 0 and q.deleted = 0
     </select>
 
-    <select id="getPage" parameterType="com.dayou.vo.DocumentVO" resultMap="documentMap">
-        select id,item_name,type,scope,created from document where  deleted = 0
+    <select id="getPage" parameterType="com.dayou.entity.Document" resultType="com.dayou.vo.DocumentVO">
+        select d.*,q.label as type from document d left join question q on d.type_id = q.id
+        where d.deleted =0 and q.deleted = 0
         <if test="document!=null and document.itemName!=null and document.itemName!='' ">
-            and item_name like concat ('%',#{document.itemName},'%')
+            and d.item_name like concat ('%',#{document.itemName},'%')
         </if>
-        order by created DESC
+        order by d.id DESC
     </select>
 </mapper>

+ 7 - 6
src/main/resources/mapper/ProfessorResultMapper.xml

@@ -25,10 +25,10 @@
             t.id AS cycle_id,
             pr.question_id,
             t.cycle_name,
-            q.NAME AS questionName,
+            q.label AS questionName,
             d.item_name,
-            d.scope,
-            d.type,
+            q.scope,
+            qq.label as type,
             pr.created,
             t.document_id
         FROM
@@ -36,6 +36,7 @@
                 RIGHT JOIN ( SELECT id, document_id, cycle_name FROM cycle ORDER BY created DESC LIMIT 1 ) t ON t.id = pr.cycle_id
                 LEFT JOIN question q ON q.id = pr.question_id
                 LEFT JOIN document d ON d.id = t.document_id
+                left join question qq on qq.id = d.type_id
         where pr.deleted = 0
         order by pr.created DESC
     </select>
@@ -48,14 +49,14 @@
             t.id AS cycle_id,
             pr.question_id,
             t.cycle_name,
-            q.NAME AS questionName,
+            q.label AS questionName,
             d.item_name,
-            d.scope,
+            q.scope,
             pr.created,
             t.document_id
         FROM
             professor_result pr
-                RIGHT JOIN ( SELECT id, document_id, cycle_name FROM cycle where id = #{id} ) t ON t.id = pr.cycle_id
+                RIGHT JOIN ( SELECT id, document_id, cycle_name FROM cycle where id = 5 ) t ON t.id = pr.cycle_id
                 LEFT JOIN question q ON q.id = pr.question_id
                 LEFT JOIN document d ON d.id = t.document_id
         where pr.deleted = 0

+ 8 - 0
src/main/resources/mapper/QuestionMapper.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.dayou.dao.QuestionMapper">
+
+   <select id="findChildren" parameterType="java.lang.Long" resultType="com.dayou.entity.Question">
+       select q.id,q.label,q.parent_id,q.scope,q.min_score,q.max_score,qq.label AS parentLabel from question q left join question qq on q.parent_id = qq.id where q.deleted = 0 and q.parent_id = #{rootId}
+   </select>
+</mapper>