Browse Source

修复报告管理useTime和userInfo接口

4228306 5 years ago
parent
commit
2f312fe2ff

+ 1 - 2
src/main/docker/Dockerfile → Dockerfile

@@ -1,6 +1,5 @@
 FROM frolvlad/alpine-java
-VOLUME /tmp
 ADD diagnosis.jar app.jar
 ENV PARAMS=""
-ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar","--spring.profiles.active=docker","${PARAMS}"]
+ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","--spring.profiles.active=docker","${PARAMS}","app.jar"]
 EXPOSE 8080

+ 1 - 1
pom.xml

@@ -176,7 +176,7 @@
                     <imageName>${project.artifactId}</imageName>
                     <imageTags>${project.version}</imageTags>
                     <dockerHost>${docker.host}</dockerHost>
-                    <dockerDirectory>src/main/docker</dockerDirectory>
+                    <dockerDirectory>.</dockerDirectory>
                     <resources>
                         <resource>
                             <targetPath>/</targetPath>

+ 5 - 0
src/main/java/edu/math/diagnosis/config/Constants.java

@@ -85,4 +85,9 @@ public class Constants {
     public static final String MATTER_EMOTION = "学习情绪问题";
     public static final String MATTER_STUDY = "学科能力问题";
 
+    public static final String ABILITY = "ability";
+    public static final String SUBJECT = "subject";
+    public static final String DEFAULT_SCORE_LEVEL = "一级";
+    public static final String DEFAULT_SCORE_LEVEL_EVALUATE = "您的%s处于有待开发的阶段。对%s进行专项训练可以帮助您快速提高%s成绩。";
+    public static final String DEFAULT_SCORE_LEVEL_PARAMS = "[\"ability\",\"ability\",\"subject\"]";
 }

+ 10 - 0
src/main/java/edu/math/diagnosis/dao/ScoreSegmentRepo.java

@@ -0,0 +1,10 @@
+package edu.math.diagnosis.dao;
+
+import edu.math.diagnosis.entity.ScoreSegment;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import java.util.List;
+
+public interface ScoreSegmentRepo extends JpaRepository<ScoreSegment, Long> {
+    List<ScoreSegment> findBySubjectId(Long subjectId);
+}

+ 64 - 3
src/main/java/edu/math/diagnosis/entity/PaperResult.java

@@ -111,7 +111,7 @@ public class PaperResult {
     /**
      * 模块作答详情
      * {
-     * "0":{
+     * "1":{
      * "collectInfo":"43/50",
      * "useTime":"30:00/30:00",
      * "score":35
@@ -122,8 +122,45 @@ public class PaperResult {
     @ApiModelProperty("模块作答详情 \"模块一\":{\"collectInfo\":\"43/50\",\"useTime\":\"30:00/30:00\",\"score\":30}}")
     private String sectionInfo;
 
-//    @Transient
-//    private List<AbilityScore> scores;
+    /**
+     * 每章节能力掌握情况
+     * {
+     *     "第一章":[{
+     *         "chapter":1,
+     *         "knowledgeContent":"1.10 因数和倍数"
+     *         "knowledgeCode":"A1",
+     *         "keep":1,
+     *         "abilityCodes": "A1A2"
+     *     }]
+     * }
+     */
+    @Lob
+    @ApiModelProperty("每章节能力掌握情况 {\"第一章\":[{\"chapter\":1,\"knowledgeContent\":\"1.10 因数和倍数\",\"knowledgeCode\":\"A1\",\"keep\":1,\"abilityCodes\": \"A1A2\"}")
+    private String chapterAbility;
+
+    /**
+     * 各能力评价
+     * {
+     *     "计算能力":{
+     *         "abilityCode":"A1",
+     *         "score":4.5,
+     *         "evaluate":"您的成绩...",
+     *         "keep":[1,0,1,2,0,1,0],
+     *         "explain":"这是示例与解释"
+     *     }
+     * }
+     */
+    @Lob
+    @ApiModelProperty("{\"计算能力\":{\"score\":4.5,\"evaluate\":\"您的成绩...\",\"keep\":[1,0,1,2,0,1,0],\"explain\":\"这是示例与解释\"}}")
+    private String abilityEvaluate;
+
+    /**
+     * 题目问题
+     *
+     */
+    @Lob
+    @ApiModelProperty("题目问题")
+    private String questionMatter;
 
     public PaperResult() {
     }
@@ -263,4 +300,28 @@ public class PaperResult {
     public void setSectionInfo(String sectionInfo) {
         this.sectionInfo = sectionInfo;
     }
+
+    public String getChapterAbility() {
+        return chapterAbility;
+    }
+
+    public void setChapterAbility(String chapterAbility) {
+        this.chapterAbility = chapterAbility;
+    }
+
+    public String getAbilityEvaluate() {
+        return abilityEvaluate;
+    }
+
+    public void setAbilityEvaluate(String abilityEvaluate) {
+        this.abilityEvaluate = abilityEvaluate;
+    }
+
+    public String getQuestionMatter() {
+        return questionMatter;
+    }
+
+    public void setQuestionMatter(String questionMatter) {
+        this.questionMatter = questionMatter;
+    }
 }

+ 101 - 0
src/main/java/edu/math/diagnosis/entity/ScoreSegment.java

@@ -1,4 +1,105 @@
 package edu.math.diagnosis.entity;
 
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.persistence.*;
+
+@Entity
+@ApiModel("分数段")
 public class ScoreSegment {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Long id;
+    @ApiModelProperty("低分数 左闭右开")
+    private Double lowerScore;
+    @ApiModelProperty("高分数 左闭右开")
+    private Double highScore;
+    @ApiModelProperty("对内等级")
+    private String level;
+    @ApiModelProperty("对外名称")
+    private String name;
+    @ApiModelProperty("评价")
+    private String evaluate;
+    @Lob
+    @ApiModelProperty("示例与解释")
+    private String explanation;
+    private Long subjectId;
+    /**
+     * ["ability","subject"]
+     */
+    private String params;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Double getLowerScore() {
+        return lowerScore;
+    }
+
+    public void setLowerScore(Double lowerScore) {
+        this.lowerScore = lowerScore;
+    }
+
+    public Double getHighScore() {
+        return highScore;
+    }
+
+    public void setHighScore(Double highScore) {
+        this.highScore = highScore;
+    }
+
+    public String getLevel() {
+        return level;
+    }
+
+    public void setLevel(String level) {
+        this.level = level;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getEvaluate() {
+        return evaluate;
+    }
+
+    public void setEvaluate(String evaluate) {
+        this.evaluate = evaluate;
+    }
+
+    public String getExplanation() {
+        return explanation;
+    }
+
+    public void setExplanation(String explanation) {
+        this.explanation = explanation;
+    }
+
+    public Long getSubjectId() {
+        return subjectId;
+    }
+
+    public void setSubjectId(Long subjectId) {
+        this.subjectId = subjectId;
+    }
+
+    public String getParams() {
+        return params;
+    }
+
+    public void setParams(String params) {
+        this.params = params;
+    }
 }

+ 4 - 3
src/main/java/edu/math/diagnosis/entity/SubjectKnowledge.java

@@ -1,6 +1,7 @@
 package edu.math.diagnosis.entity;
 
 import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
@@ -20,11 +21,11 @@ public class SubjectKnowledge {
     private String grade;
 
     private String chapter;
-
+    @ApiModelProperty("知识点编号")
     private String code;
-
+    @ApiModelProperty("知识点内容")
     private String content;
-
+    @ApiModelProperty("知识点包含的能力")
     private String abilityCodes;
 
     public SubjectKnowledge() {

+ 49 - 0
src/main/java/edu/math/diagnosis/model/AbilityEvaluateVo.java

@@ -0,0 +1,49 @@
+package edu.math.diagnosis.model;
+
+public class AbilityEvaluateVo {
+    private Double score;
+    private String abilityCode;
+    private String evaluate;
+    private String keep;
+    private String explain;
+
+    public Double getScore() {
+        return score;
+    }
+
+    public void setScore(Double score) {
+        this.score = score;
+    }
+
+    public String getAbilityCode() {
+        return abilityCode;
+    }
+
+    public void setAbilityCode(String abilityCode) {
+        this.abilityCode = abilityCode;
+    }
+
+    public String getEvaluate() {
+        return evaluate;
+    }
+
+    public void setEvaluate(String evaluate) {
+        this.evaluate = evaluate;
+    }
+
+    public String getKeep() {
+        return keep;
+    }
+
+    public void setKeep(String keep) {
+        this.keep = keep;
+    }
+
+    public String getExplain() {
+        return explain;
+    }
+
+    public void setExplain(String explain) {
+        this.explain = explain;
+    }
+}

+ 50 - 0
src/main/java/edu/math/diagnosis/model/ChapterAbilityVo.java

@@ -0,0 +1,50 @@
+package edu.math.diagnosis.model;
+
+
+public class ChapterAbilityVo {
+    private String chapter;
+    private String knowledgeCode;
+    private String knowledgeContent;
+    private Integer keep;
+    private String abilityCodes;
+
+    public String getChapter() {
+        return chapter;
+    }
+
+    public void setChapter(String chapter) {
+        this.chapter = chapter;
+    }
+
+    public String getKnowledgeCode() {
+        return knowledgeCode;
+    }
+
+    public void setKnowledgeCode(String knowledgeCode) {
+        this.knowledgeCode = knowledgeCode;
+    }
+
+    public String getKnowledgeContent() {
+        return knowledgeContent;
+    }
+
+    public void setKnowledgeContent(String knowledgeContent) {
+        this.knowledgeContent = knowledgeContent;
+    }
+
+    public Integer getKeep() {
+        return keep;
+    }
+
+    public void setKeep(Integer keep) {
+        this.keep = keep;
+    }
+
+    public String getAbilityCodes() {
+        return abilityCodes;
+    }
+
+    public void setAbilityCodes(String abilityCodes) {
+        this.abilityCodes = abilityCodes;
+    }
+}

+ 43 - 5
src/main/java/edu/math/diagnosis/service/PaperResultService.java

@@ -5,10 +5,7 @@ import edu.math.diagnosis.config.Constants;
 import edu.math.diagnosis.dao.PaperCommitRepo;
 import edu.math.diagnosis.dao.PaperResultRepo;
 import edu.math.diagnosis.entity.*;
-import edu.math.diagnosis.model.Answer;
-import edu.math.diagnosis.model.KnowledgeKeepVo;
-import edu.math.diagnosis.model.Result;
-import edu.math.diagnosis.model.SectionInfoVo;
+import edu.math.diagnosis.model.*;
 import edu.math.diagnosis.util.NumberUtil;
 import edu.math.diagnosis.util.ObjectUtil;
 import org.apache.commons.lang3.StringUtils;
@@ -141,7 +138,14 @@ public class PaperResultService {
         r.setChapterRate(chapterRate(r, paper));
         r.setKnowledgeKeepStatus(ObjectUtil.object2Json(knowledgeKeepStatus(r, paper)));
         r.setUseTime(useTime(paper, commit));
+        //TODO 还没做的
         r.setSectionInfo(sectionInfo(r, paper));
+
+        //第二部分 学科能力
+        r.setChapterAbility(chapterAbility(r, paper));
+        r.setAbilityEvaluate(abilityEvaluate(r, paper));
+        r.setQuestionMatter(questionMatter(r, paper));
+
 //        paperResultRepo.save(r);
     }
 
@@ -415,7 +419,41 @@ public class PaperResultService {
         return ObjectUtil.object2Json(list);
     }
 
-    private List<Answer> convertAnswer(String json){
+    public String chapterAbility(PaperResult result, Paper paper) {
+        List<SubjectKnowledge> knowledge = knowledgeService.list(paper.getSubjectId(), paper.getGrade());
+        //根据章节分组 Map<chapter,List<SubjectKnowledge>>
+//        Map<String, List<SubjectKnowledge>> group = knowledge.stream().collect(Collectors.groupingBy(SubjectKnowledge::getChapter));
+
+        List<Integer> collects = convertCollectQuestion(result.getCollectQuestion());
+        //Map<tag,Set<number>> 知识点与题目对应
+        Map<String, Set<Integer>> tagNumbers = tagNumbers(paper);
+        //Map<tag,keep> 每个知识点的掌握情况
+        Map<String, Integer> tagKeep = tagKeep(collects, tagNumbers);
+
+        List<ChapterAbilityVo> vos = new ArrayList<>();
+        knowledge.forEach(k -> {
+            ChapterAbilityVo vo = new ChapterAbilityVo();
+            vo.setChapter(k.getChapter());
+            vo.setKnowledgeCode(k.getCode());
+            vo.setKnowledgeContent(k.getContent());
+            // 设置该知识点掌握程度
+            vo.setKeep(tagKeep.getOrDefault(k.getCode(), 0));
+            vo.setAbilityCodes(k.getAbilityCodes());
+            vos.add(vo);
+        });
+        Map<String, List<ChapterAbilityVo>> group = vos.stream().collect(Collectors.groupingBy(ChapterAbilityVo::getChapter));
+        return ObjectUtil.object2Json(group);
+    }
+
+    public String abilityEvaluate(PaperResult result, Paper paper) {
+        return "{}";
+    }
+
+    public String questionMatter(PaperResult result, Paper paper) {
+        return "{}";
+    }
+
+    private List<Answer> convertAnswer(String json) {
         return ObjectUtil.getGson().fromJson(json, new TypeToken<List<Answer>>() {
         }.getType());
     }

+ 35 - 0
src/main/java/edu/math/diagnosis/service/ScoreSegmentService.java

@@ -0,0 +1,35 @@
+package edu.math.diagnosis.service;
+
+import edu.math.diagnosis.config.Constants;
+import edu.math.diagnosis.dao.ScoreSegmentRepo;
+import edu.math.diagnosis.entity.ScoreSegment;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Service
+public class ScoreSegmentService {
+
+    @Resource
+    private ScoreSegmentRepo scoreSegmentRepo;
+
+    private List<ScoreSegment> findBySubjectId(Long subjectId) {
+        return scoreSegmentRepo.findBySubjectId(subjectId);
+    }
+
+    public ScoreSegment getLevel(Double score, List<ScoreSegment> segment, String ability,String subject) {
+        ScoreSegment scoreSegment = new ScoreSegment();
+        scoreSegment.setLevel(Constants.DEFAULT_SCORE_LEVEL);
+        scoreSegment.setEvaluate(String.format(Constants.DEFAULT_SCORE_LEVEL_EVALUATE, ability, ability,subject));
+        for (ScoreSegment s : segment) {
+            if (s.getLowerScore() <= score && score < s.getHighScore()) {
+                String params = s.getParams();
+                String[] p = params.split(",");
+                s.setEvaluate(String.format(s.getEvaluate(),p));
+                return s;
+            }
+        }
+        return scoreSegment;
+    }
+}

+ 8 - 0
src/test/java/edu/math/diagnosis/service/StringTest.java

@@ -21,4 +21,12 @@ public class StringTest {
         System.out.println(a.length);
         System.out.println(Arrays.asList(a));
     }
+
+    @Test
+    public void testString2(){
+        String text = "ability,ability,subject";
+        String[] a = text.split(",");
+        String t = "您的%s处于有待开发的阶段。对%s进行专项训练可以帮助您快速提高%s成绩。";
+        System.out.println(String.format(t, a));
+    }
 }