From 679a0e0f935c92e5e6edfc66a77d52fd82073996 Mon Sep 17 00:00:00 2001
From: xiaoCJ <406612557@qq.com>
Date: Wed, 15 Nov 2023 17:57:56 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=83=A8=E5=88=86?=
 =?UTF-8?q?=E8=A1=A8=E5=AD=97=E6=AE=B5=EF=BC=8C=E6=96=B0=E5=BB=BAflow?=
 =?UTF-8?q?=E4=B8=AD=E9=97=B4=E8=A1=A8=E5=85=B3=E8=81=94user=20ID=E5=92=8C?=
 =?UTF-8?q?=E6=B5=81=E7=A8=8BID?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../fund_investment/config/Constant.java      |   4 +-
 .../controller/TopicController.java           |  84 ++++++++++++++
 .../controller/topicController.java           |  48 --------
 .../entity/PerformanceScore.java              |  35 ++++++
 .../entity/PerformanceScoreExample.java       |  60 ++++++++++
 .../fund_investment/entity/TopicRecord.java   |  11 ++
 .../entity/TopicRecordExample.java            |  70 ++++++++++++
 .../service/PerformanceScoreService.java      |   9 ++
 .../fund_investment/service/TopicService.java |  15 +++
 ...ervice.java => TrainingReportService.java} |   2 +-
 .../PerformanceScoreServiceImpl.java          |  35 ++++++
 .../service/serviceImpl/TopicServiceImpl.java | 105 ++++++++++++++++++
 ...ervice.java => TrainingReportService.java} |   2 +-
 src/main/resources/generatorConfig.xml        |  26 ++---
 .../resources/mappers/TopicRecordMapper.xml   |  27 ++++-
 15 files changed, 464 insertions(+), 69 deletions(-)
 create mode 100644 src/main/java/com/sztzjy/fund_investment/controller/TopicController.java
 delete mode 100644 src/main/java/com/sztzjy/fund_investment/controller/topicController.java
 create mode 100644 src/main/java/com/sztzjy/fund_investment/service/PerformanceScoreService.java
 create mode 100644 src/main/java/com/sztzjy/fund_investment/service/TopicService.java
 rename src/main/java/com/sztzjy/fund_investment/service/{trainingReportService.java => TrainingReportService.java} (68%)
 create mode 100644 src/main/java/com/sztzjy/fund_investment/service/serviceImpl/PerformanceScoreServiceImpl.java
 create mode 100644 src/main/java/com/sztzjy/fund_investment/service/serviceImpl/TopicServiceImpl.java
 rename src/main/java/com/sztzjy/fund_investment/service/serviceImpl/{trainingReportService.java => TrainingReportService.java} (81%)

diff --git a/src/main/java/com/sztzjy/fund_investment/config/Constant.java b/src/main/java/com/sztzjy/fund_investment/config/Constant.java
index 7559f80..60aea77 100644
--- a/src/main/java/com/sztzjy/fund_investment/config/Constant.java
+++ b/src/main/java/com/sztzjy/fund_investment/config/Constant.java
@@ -16,6 +16,8 @@ public class Constant {
      */
     public static final String BASIC = "Basic";
 
-
+    public static final String TOFQUESTIONS = "判断题";
+    public static final String SINGLECHOICE = "单选题";
+    public static final String MULTIPLECHOICE = "多选题";
 
 }
diff --git a/src/main/java/com/sztzjy/fund_investment/controller/TopicController.java b/src/main/java/com/sztzjy/fund_investment/controller/TopicController.java
new file mode 100644
index 0000000..d4d3f95
--- /dev/null
+++ b/src/main/java/com/sztzjy/fund_investment/controller/TopicController.java
@@ -0,0 +1,84 @@
+package com.sztzjy.fund_investment.controller;
+
+import com.sztzjy.fund_investment.annotation.AnonymousAccess;
+import com.sztzjy.fund_investment.entity.TopicRecord;
+import com.sztzjy.fund_investment.entity.Topics;
+import com.sztzjy.fund_investment.entity.TopicsExample;
+import com.sztzjy.fund_investment.mapper.TopicRecordMapper;
+import com.sztzjy.fund_investment.mapper.TopicsMapper;
+import com.sztzjy.fund_investment.service.TopicService;
+import com.sztzjy.fund_investment.util.ResultEntity;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @Author xcj
+ * @Date 2023/11/14
+ */
+@RestController
+@RequestMapping("/topics")
+@Api(tags = "学生端--知识测评答题")
+public class TopicController {
+    @Autowired
+    private TopicsMapper topicsMapper;
+    @Autowired
+    private TopicService topicService;
+    @Autowired
+    private TopicRecordMapper topicRecordMapper;
+
+
+    /*
+     * @author xcj
+     * @Date 2023/11/14
+     */
+    @GetMapping("getRandomTopic")
+    @ApiOperation("知识测评、项目估值、项目尽调,答题页面返回随机6条数据")
+    @AnonymousAccess
+    public ResultEntity<List<Topics>> getRandomTopic(@ApiParam("题目来源模块") @RequestParam String module) {
+        TopicsExample topicsExample = new TopicsExample();
+        topicsExample.createCriteria().andModuleEqualTo(module);
+        List<Topics> topics = topicsMapper.selectByExampleWithBLOBs(topicsExample);
+        //随机取6道题目
+        Collections.shuffle(topics);
+        int size = Math.min(6, topics.size());
+        List<Topics> randomTopics = topics.subList(0, size);
+        for (Topics randomTopic : randomTopics) {
+            randomTopic.setAnswer(null);
+        }
+        return new ResultEntity<>(randomTopics);
+    }
+
+    /*
+     * @author xcj
+     * @Date 2023/11/15
+     */
+    @PostMapping("getRightScore")
+    @ApiOperation("知识测评、项目估值、项目尽调,判断答案对错并返回得分")
+    @AnonymousAccess
+    public ResultEntity<List<String>> getRightScore(@ApiParam("需要ID和用户填写的答案") @RequestBody List<Topics> topics, @RequestParam String flowId) {
+        return topicService.getRightScore(topics, flowId);
+    }
+
+    /*
+     * @author xcj
+     * @Date 2023/11/15
+     */
+    @PostMapping("getTopicRecord")
+    @ApiOperation("知识测评、项目估值、项目尽调,回显答题记录")
+    @AnonymousAccess
+    public ResultEntity <List<TopicRecord>> getTopicRecord(@ApiParam("getRightScore返回的ID集合")@RequestParam List<String> ids) {
+        List<TopicRecord>list= new ArrayList<>();
+        for (String id : ids) {
+            TopicRecord topicRecord = topicRecordMapper.selectByPrimaryKey(id);
+            list.add(topicRecord);
+        }
+        return new ResultEntity<>(list);
+    }
+}
diff --git a/src/main/java/com/sztzjy/fund_investment/controller/topicController.java b/src/main/java/com/sztzjy/fund_investment/controller/topicController.java
deleted file mode 100644
index 8da48b0..0000000
--- a/src/main/java/com/sztzjy/fund_investment/controller/topicController.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.sztzjy.fund_investment.controller;
-
-import com.sztzjy.fund_investment.annotation.AnonymousAccess;
-import com.sztzjy.fund_investment.entity.Topics;
-import com.sztzjy.fund_investment.entity.TopicsExample;
-import com.sztzjy.fund_investment.mapper.TopicsMapper;
-import com.sztzjy.fund_investment.util.ResultEntity;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import org.springframework.beans.factory.annotation.Autowired;
-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 java.util.Collections;
-import java.util.List;
-
-/**
- * @Author xcj
- * @Date 2023/11/14
- */
-@RestController
-@RequestMapping("/topics")
-@Api(tags = "学生端--知识测评答题")
-public class topicController {
-    @Autowired
-    private TopicsMapper topicsMapper;
-
-    /* 知识测评答题
-     * @author xcj
-     * @Date 2023/11/14
-     */
-    @GetMapping("getRandomTopic")
-    @ApiOperation("知识测评答题页面返回随机6条数据")
-    @AnonymousAccess
-    public ResultEntity<List<Topics>> getRandomTopic(@ApiParam("题目来源模块") @RequestParam String module) {
-        TopicsExample topicsExample =new TopicsExample();
-        topicsExample.createCriteria().andModuleEqualTo(module);
-        List<Topics> topics = topicsMapper.selectByExampleWithBLOBs(topicsExample);
-        //随机取6道题目
-        Collections.shuffle(topics);
-        int size = Math.min(6, topics.size());
-        List<Topics> randomTopics = topics.subList(0, size);
-        return new ResultEntity<>(randomTopics);
-    }
-}
diff --git a/src/main/java/com/sztzjy/fund_investment/entity/PerformanceScore.java b/src/main/java/com/sztzjy/fund_investment/entity/PerformanceScore.java
index b6f4e1d..1a7bc9a 100644
--- a/src/main/java/com/sztzjy/fund_investment/entity/PerformanceScore.java
+++ b/src/main/java/com/sztzjy/fund_investment/entity/PerformanceScore.java
@@ -1,5 +1,6 @@
 package com.sztzjy.fund_investment.entity;
 
+import java.lang.reflect.Method;
 import java.math.BigDecimal;
 
 import io.swagger.annotations.ApiModelProperty;
@@ -54,6 +55,32 @@ public class PerformanceScore {
     @ApiModelProperty("投资报告得分")
     private BigDecimal investmentReportScore;
 
+    @ApiModelProperty("总成绩")
+    private BigDecimal totalScore;
+
+
+    public void set(String methodName, Object value) {
+        try {
+            Method method = getClass().getMethod("set" + Character.toUpperCase(methodName.charAt(0)) + methodName.substring(1),value.getClass());
+            method.invoke(this, value);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public Object get(String methodName) {
+        Object result = null;
+        try {
+            Method method = getClass().getMethod("get" + Character.toUpperCase(methodName.charAt(0)) + methodName.substring(1));
+            result = method.invoke(this);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return result;
+    }
+
+
+
     public String getId() {
         return id;
     }
@@ -173,4 +200,12 @@ public class PerformanceScore {
     public void setInvestmentReportScore(BigDecimal investmentReportScore) {
         this.investmentReportScore = investmentReportScore;
     }
+
+    public BigDecimal getTotalScore() {
+        return totalScore;
+    }
+
+    public void setTotalScore(BigDecimal totalScore) {
+        this.totalScore = totalScore;
+    }
 }
\ No newline at end of file
diff --git a/src/main/java/com/sztzjy/fund_investment/entity/PerformanceScoreExample.java b/src/main/java/com/sztzjy/fund_investment/entity/PerformanceScoreExample.java
index b617737..bedadfa 100644
--- a/src/main/java/com/sztzjy/fund_investment/entity/PerformanceScoreExample.java
+++ b/src/main/java/com/sztzjy/fund_investment/entity/PerformanceScoreExample.java
@@ -1034,6 +1034,66 @@ public class PerformanceScoreExample {
             addCriterion("investment_report_score not between", value1, value2, "investmentReportScore");
             return (Criteria) this;
         }
+
+        public Criteria andTotalScoreIsNull() {
+            addCriterion("total_score is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andTotalScoreIsNotNull() {
+            addCriterion("total_score is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andTotalScoreEqualTo(BigDecimal value) {
+            addCriterion("total_score =", value, "totalScore");
+            return (Criteria) this;
+        }
+
+        public Criteria andTotalScoreNotEqualTo(BigDecimal value) {
+            addCriterion("total_score <>", value, "totalScore");
+            return (Criteria) this;
+        }
+
+        public Criteria andTotalScoreGreaterThan(BigDecimal value) {
+            addCriterion("total_score >", value, "totalScore");
+            return (Criteria) this;
+        }
+
+        public Criteria andTotalScoreGreaterThanOrEqualTo(BigDecimal value) {
+            addCriterion("total_score >=", value, "totalScore");
+            return (Criteria) this;
+        }
+
+        public Criteria andTotalScoreLessThan(BigDecimal value) {
+            addCriterion("total_score <", value, "totalScore");
+            return (Criteria) this;
+        }
+
+        public Criteria andTotalScoreLessThanOrEqualTo(BigDecimal value) {
+            addCriterion("total_score <=", value, "totalScore");
+            return (Criteria) this;
+        }
+
+        public Criteria andTotalScoreIn(List<BigDecimal> values) {
+            addCriterion("total_score in", values, "totalScore");
+            return (Criteria) this;
+        }
+
+        public Criteria andTotalScoreNotIn(List<BigDecimal> values) {
+            addCriterion("total_score not in", values, "totalScore");
+            return (Criteria) this;
+        }
+
+        public Criteria andTotalScoreBetween(BigDecimal value1, BigDecimal value2) {
+            addCriterion("total_score between", value1, value2, "totalScore");
+            return (Criteria) this;
+        }
+
+        public Criteria andTotalScoreNotBetween(BigDecimal value1, BigDecimal value2) {
+            addCriterion("total_score not between", value1, value2, "totalScore");
+            return (Criteria) this;
+        }
     }
 
     public static class Criteria extends GeneratedCriteria {
diff --git a/src/main/java/com/sztzjy/fund_investment/entity/TopicRecord.java b/src/main/java/com/sztzjy/fund_investment/entity/TopicRecord.java
index ade78bc..e74acde 100644
--- a/src/main/java/com/sztzjy/fund_investment/entity/TopicRecord.java
+++ b/src/main/java/com/sztzjy/fund_investment/entity/TopicRecord.java
@@ -21,6 +21,9 @@ public class TopicRecord {
     @ApiModelProperty("正确答案")
     private String answer;
 
+    @ApiModelProperty("题干")
+    private String topicContent;
+
     public String getId() {
         return id;
     }
@@ -60,4 +63,12 @@ public class TopicRecord {
     public void setAnswer(String answer) {
         this.answer = answer == null ? null : answer.trim();
     }
+
+    public String getTopicContent() {
+        return topicContent;
+    }
+
+    public void setTopicContent(String topicContent) {
+        this.topicContent = topicContent == null ? null : topicContent.trim();
+    }
 }
\ No newline at end of file
diff --git a/src/main/java/com/sztzjy/fund_investment/entity/TopicRecordExample.java b/src/main/java/com/sztzjy/fund_investment/entity/TopicRecordExample.java
index 483f7c4..9f2f7ad 100644
--- a/src/main/java/com/sztzjy/fund_investment/entity/TopicRecordExample.java
+++ b/src/main/java/com/sztzjy/fund_investment/entity/TopicRecordExample.java
@@ -453,6 +453,76 @@ public class TopicRecordExample {
             addCriterion("answer not between", value1, value2, "answer");
             return (Criteria) this;
         }
+
+        public Criteria andTopicContentIsNull() {
+            addCriterion("topic_content is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andTopicContentIsNotNull() {
+            addCriterion("topic_content is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andTopicContentEqualTo(String value) {
+            addCriterion("topic_content =", value, "topicContent");
+            return (Criteria) this;
+        }
+
+        public Criteria andTopicContentNotEqualTo(String value) {
+            addCriterion("topic_content <>", value, "topicContent");
+            return (Criteria) this;
+        }
+
+        public Criteria andTopicContentGreaterThan(String value) {
+            addCriterion("topic_content >", value, "topicContent");
+            return (Criteria) this;
+        }
+
+        public Criteria andTopicContentGreaterThanOrEqualTo(String value) {
+            addCriterion("topic_content >=", value, "topicContent");
+            return (Criteria) this;
+        }
+
+        public Criteria andTopicContentLessThan(String value) {
+            addCriterion("topic_content <", value, "topicContent");
+            return (Criteria) this;
+        }
+
+        public Criteria andTopicContentLessThanOrEqualTo(String value) {
+            addCriterion("topic_content <=", value, "topicContent");
+            return (Criteria) this;
+        }
+
+        public Criteria andTopicContentLike(String value) {
+            addCriterion("topic_content like", value, "topicContent");
+            return (Criteria) this;
+        }
+
+        public Criteria andTopicContentNotLike(String value) {
+            addCriterion("topic_content not like", value, "topicContent");
+            return (Criteria) this;
+        }
+
+        public Criteria andTopicContentIn(List<String> values) {
+            addCriterion("topic_content in", values, "topicContent");
+            return (Criteria) this;
+        }
+
+        public Criteria andTopicContentNotIn(List<String> values) {
+            addCriterion("topic_content not in", values, "topicContent");
+            return (Criteria) this;
+        }
+
+        public Criteria andTopicContentBetween(String value1, String value2) {
+            addCriterion("topic_content between", value1, value2, "topicContent");
+            return (Criteria) this;
+        }
+
+        public Criteria andTopicContentNotBetween(String value1, String value2) {
+            addCriterion("topic_content not between", value1, value2, "topicContent");
+            return (Criteria) this;
+        }
     }
 
     public static class Criteria extends GeneratedCriteria {
diff --git a/src/main/java/com/sztzjy/fund_investment/service/PerformanceScoreService.java b/src/main/java/com/sztzjy/fund_investment/service/PerformanceScoreService.java
new file mode 100644
index 0000000..dd13ed4
--- /dev/null
+++ b/src/main/java/com/sztzjy/fund_investment/service/PerformanceScoreService.java
@@ -0,0 +1,9 @@
+package com.sztzjy.fund_investment.service;
+
+/**
+ * @Author xcj
+ * @Date 2023/11/15
+ */
+public interface PerformanceScoreService {
+    void calculateScoreByModule(String methodName, Integer score, String flowId);
+}
diff --git a/src/main/java/com/sztzjy/fund_investment/service/TopicService.java b/src/main/java/com/sztzjy/fund_investment/service/TopicService.java
new file mode 100644
index 0000000..c6e23bd
--- /dev/null
+++ b/src/main/java/com/sztzjy/fund_investment/service/TopicService.java
@@ -0,0 +1,15 @@
+package com.sztzjy.fund_investment.service;
+
+import com.sztzjy.fund_investment.entity.Topics;
+import com.sztzjy.fund_investment.util.ResultEntity;
+
+import java.util.List;
+
+/**
+ * @Author xcj
+ * @Date 2023/11/15
+ */
+public interface TopicService {
+    ResultEntity<List<String>> getRightScore(List<Topics> topics,String flowId);
+
+}
diff --git a/src/main/java/com/sztzjy/fund_investment/service/trainingReportService.java b/src/main/java/com/sztzjy/fund_investment/service/TrainingReportService.java
similarity index 68%
rename from src/main/java/com/sztzjy/fund_investment/service/trainingReportService.java
rename to src/main/java/com/sztzjy/fund_investment/service/TrainingReportService.java
index b382975..3737181 100644
--- a/src/main/java/com/sztzjy/fund_investment/service/trainingReportService.java
+++ b/src/main/java/com/sztzjy/fund_investment/service/TrainingReportService.java
@@ -4,5 +4,5 @@ package com.sztzjy.fund_investment.service;
  * @Author xcj
  * @Date 2023/11/14
  */
-public interface trainingReportService {
+public interface TrainingReportService {
 }
diff --git a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/PerformanceScoreServiceImpl.java b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/PerformanceScoreServiceImpl.java
new file mode 100644
index 0000000..0d317b7
--- /dev/null
+++ b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/PerformanceScoreServiceImpl.java
@@ -0,0 +1,35 @@
+package com.sztzjy.fund_investment.service.serviceImpl;
+
+import com.sztzjy.fund_investment.entity.PerformanceScore;
+import com.sztzjy.fund_investment.entity.PerformanceScoreExample;
+import com.sztzjy.fund_investment.mapper.PerformanceScoreMapper;
+import com.sztzjy.fund_investment.service.PerformanceScoreService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @Author xcj
+ * @Date 2023/11/15
+ */
+@Service
+public class PerformanceScoreServiceImpl implements PerformanceScoreService {
+    @Autowired
+    private PerformanceScoreMapper performanceScoreMapper;
+
+
+    /* 计分方法
+     * @author xcj
+     * @Date 2023/11/15
+     */
+    @Override     //                          实体类字段名          分数           流程ID
+    public void calculateScoreByModule(String methodName, Integer score, String flowId) {
+        PerformanceScoreExample performanceScoreExample = new PerformanceScoreExample();
+        performanceScoreExample.createCriteria().andFlowIdEqualTo(flowId);
+        List<PerformanceScore> performanceScores = performanceScoreMapper.selectByExample(performanceScoreExample);
+        PerformanceScore performanceScore = performanceScores.get(0);
+        performanceScore.set(methodName,score);
+        performanceScoreMapper.updateByPrimaryKey(performanceScore);
+    }
+}
diff --git a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/TopicServiceImpl.java b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/TopicServiceImpl.java
new file mode 100644
index 0000000..c556e7f
--- /dev/null
+++ b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/TopicServiceImpl.java
@@ -0,0 +1,105 @@
+package com.sztzjy.fund_investment.service.serviceImpl;
+
+import cn.hutool.core.util.IdUtil;
+import com.sztzjy.fund_investment.config.Constant;
+import com.sztzjy.fund_investment.entity.PerformanceScore;
+import com.sztzjy.fund_investment.entity.PerformanceScoreExample;
+import com.sztzjy.fund_investment.entity.TopicRecord;
+import com.sztzjy.fund_investment.entity.Topics;
+import com.sztzjy.fund_investment.mapper.PerformanceScoreMapper;
+import com.sztzjy.fund_investment.mapper.TopicRecordMapper;
+import com.sztzjy.fund_investment.mapper.TopicsMapper;
+import com.sztzjy.fund_investment.service.PerformanceScoreService;
+import com.sztzjy.fund_investment.service.TopicService;
+import com.sztzjy.fund_investment.util.ResultEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Author xcj
+ * @Date 2023/11/15
+ */
+@Service
+public class TopicServiceImpl implements TopicService {
+    @Autowired
+    private TopicsMapper topicsMapper;
+    @Autowired
+    private PerformanceScoreService performanceScoreService;
+    @Autowired
+    private TopicRecordMapper topicRecordMapper;
+
+    @Override
+    public ResultEntity<List<String>> getRightScore(List<Topics> topics, String flowId) {
+        int score = 0;
+        List<String>list =new ArrayList<>();
+        for (Topics topic : topics) {
+            String userAnswer = topic.getAnswer();
+            String topicId = topic.getTopicId();
+            Topics topicsData = topicsMapper.selectByPrimaryKey(topicId);
+            String rightAnswer = topicsData.getAnswer();
+            String topicType = topicsData.getTopicType();
+            if (topicType.equals(Constant.MULTIPLECHOICE)) {
+                // 将用户选择的答案和正确答案转换为字符数组或集合
+                char[] userAnswerArray = userAnswer.toCharArray();
+                char[] rightAnswerArray = rightAnswer.toCharArray();
+
+                // 检查答案长度是否相等
+                if (userAnswerArray.length != rightAnswerArray.length) {
+                    // 答案长度不相等,答案错误跳过循环
+                    continue;
+                }
+
+                // 检查每个选项是否同时存在于用户答案和正确答案中
+                boolean isCorrect = true;
+                for (char c : rightAnswerArray) {
+                    if (!containsChar(userAnswerArray, c)) {
+                        isCorrect = false;
+                        break;
+                    }
+                }
+                if (isCorrect) {
+                    // 答案正确
+                    score = score + 1; // 设置得分为1或其他适当的值
+                }
+            } else {
+                if (userAnswer.equals(rightAnswer)) {
+                    score = score + 1;
+                }
+            }
+
+            //添加到答题记录表
+            TopicRecord topicRecord =new TopicRecord();
+            String recordId = IdUtil.simpleUUID();
+            topicRecord.setId(recordId);
+            topicRecord.setTopicId(topicId);
+            topicRecord.setUserAnswer(userAnswer);
+            topicRecord.setAnswer(rightAnswer);
+            topicRecord.setFlowId(flowId);
+            topicRecord.setTopicContent(topic.getTopicContent());
+            topicRecordMapper.insert(topicRecord);
+            list.add(recordId);
+        }
+        //六道题总分最多五分
+        if (score >= 5) {
+            score = 5;
+        }
+//      调用计分方法
+        performanceScoreService.calculateScoreByModule("knowledgeAssessmentScore", score, flowId);
+        String strScore = String.valueOf(score);
+        list.add(strScore);
+        return new ResultEntity<>(list);
+    }
+
+    // 检查字符数组是否包含指定字符
+    private boolean containsChar(char[] array, char c) {
+        for (char element : array) {
+            if (element == c) {
+                return true;
+            }
+        }
+        return false;
+    }
+}
diff --git a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/trainingReportService.java b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/TrainingReportService.java
similarity index 81%
rename from src/main/java/com/sztzjy/fund_investment/service/serviceImpl/trainingReportService.java
rename to src/main/java/com/sztzjy/fund_investment/service/serviceImpl/TrainingReportService.java
index a9f880a..dfbe344 100644
--- a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/trainingReportService.java
+++ b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/TrainingReportService.java
@@ -7,6 +7,6 @@ import org.springframework.stereotype.Service;
  * @Date 2023/11/14
  */
 @Service
-public class trainingReportService {
+public class TrainingReportService {
 
 }
diff --git a/src/main/resources/generatorConfig.xml b/src/main/resources/generatorConfig.xml
index 5bb82aa..76e9959 100644
--- a/src/main/resources/generatorConfig.xml
+++ b/src/main/resources/generatorConfig.xml
@@ -37,20 +37,20 @@
         </javaClientGenerator>
 
         <!-- 需要生成的表 -->
-        <table tableName="allotment_object" domainObjectName="AllotmentObject" />
-        <table tableName="flow" domainObjectName="Flow" />
-        <table tableName="fundraising" domainObjectName="Fundraising" />
-        <table tableName="inquiry_participation" domainObjectName="InquiryParticipation" />
-        <table tableName="issuance_info" domainObjectName="IssuanceInfo" />
-        <table tableName="issuance_parameter_input" domainObjectName="IssuanceParameterInput" />
-        <table tableName="performance_score" domainObjectName="PerformanceScore" />
-        <table tableName="profit_distribution" domainObjectName="ProfitDistribution" />
-        <table tableName="profit_management" domainObjectName="ProfitManagement" />
-        <table tableName="question_answer" domainObjectName="QuestionAnswer" />
-        <table tableName="sys_topics" domainObjectName="Topics" />
+<!--        <table tableName="allotment_object" domainObjectName="AllotmentObject" />-->
+<!--        <table tableName="flow" domainObjectName="Flow" />-->
+<!--        <table tableName="fundraising" domainObjectName="Fundraising" />-->
+<!--        <table tableName="inquiry_participation" domainObjectName="InquiryParticipation" />-->
+<!--        <table tableName="issuance_info" domainObjectName="IssuanceInfo" />-->
+<!--        <table tableName="issuance_parameter_input" domainObjectName="IssuanceParameterInput" />-->
+<!--        <table tableName="performance_score" domainObjectName="PerformanceScore" />-->
+<!--        <table tableName="profit_distribution" domainObjectName="ProfitDistribution" />-->
+<!--        <table tableName="profit_management" domainObjectName="ProfitManagement" />-->
+<!--        <table tableName="question_answer" domainObjectName="QuestionAnswer" />-->
+<!--        <table tableName="sys_topics" domainObjectName="Topics" />-->
         <table tableName="topic_record" domainObjectName="TopicRecord" />
-        <table tableName="training_report" domainObjectName="TrainingReport" />
-        <table tableName="user_table" domainObjectName="UserTable" />
+<!--        <table tableName="training_report" domainObjectName="TrainingReport" />-->
+<!--        <table tableName="user_table" domainObjectName="UserTable" />-->
     </context>
 
 
diff --git a/src/main/resources/mappers/TopicRecordMapper.xml b/src/main/resources/mappers/TopicRecordMapper.xml
index 608319d..57ad196 100644
--- a/src/main/resources/mappers/TopicRecordMapper.xml
+++ b/src/main/resources/mappers/TopicRecordMapper.xml
@@ -7,6 +7,7 @@
     <result column="flow_id" jdbcType="VARCHAR" property="flowId" />
     <result column="user_answer" jdbcType="VARCHAR" property="userAnswer" />
     <result column="answer" jdbcType="VARCHAR" property="answer" />
+    <result column="topic_content" jdbcType="VARCHAR" property="topicContent" />
   </resultMap>
   <sql id="Example_Where_Clause">
     <where>
@@ -67,7 +68,7 @@
     </where>
   </sql>
   <sql id="Base_Column_List">
-    id, topic_id, flow_id, user_answer, answer
+    id, topic_id, flow_id, user_answer, answer, topic_content
   </sql>
   <select id="selectByExample" parameterType="com.sztzjy.fund_investment.entity.TopicRecordExample" resultMap="BaseResultMap">
     select
@@ -101,9 +102,11 @@
   </delete>
   <insert id="insert" parameterType="com.sztzjy.fund_investment.entity.TopicRecord">
     insert into topic_record (id, topic_id, flow_id, 
-      user_answer, answer)
+      user_answer, answer, topic_content
+      )
     values (#{id,jdbcType=VARCHAR}, #{topicId,jdbcType=VARCHAR}, #{flowId,jdbcType=VARCHAR}, 
-      #{userAnswer,jdbcType=VARCHAR}, #{answer,jdbcType=VARCHAR})
+      #{userAnswer,jdbcType=VARCHAR}, #{answer,jdbcType=VARCHAR}, #{topicContent,jdbcType=VARCHAR}
+      )
   </insert>
   <insert id="insertSelective" parameterType="com.sztzjy.fund_investment.entity.TopicRecord">
     insert into topic_record
@@ -123,6 +126,9 @@
       <if test="answer != null">
         answer,
       </if>
+      <if test="topicContent != null">
+        topic_content,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="id != null">
@@ -140,6 +146,9 @@
       <if test="answer != null">
         #{answer,jdbcType=VARCHAR},
       </if>
+      <if test="topicContent != null">
+        #{topicContent,jdbcType=VARCHAR},
+      </if>
     </trim>
   </insert>
   <select id="countByExample" parameterType="com.sztzjy.fund_investment.entity.TopicRecordExample" resultType="java.lang.Long">
@@ -166,6 +175,9 @@
       <if test="record.answer != null">
         answer = #{record.answer,jdbcType=VARCHAR},
       </if>
+      <if test="record.topicContent != null">
+        topic_content = #{record.topicContent,jdbcType=VARCHAR},
+      </if>
     </set>
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
@@ -177,7 +189,8 @@
       topic_id = #{record.topicId,jdbcType=VARCHAR},
       flow_id = #{record.flowId,jdbcType=VARCHAR},
       user_answer = #{record.userAnswer,jdbcType=VARCHAR},
-      answer = #{record.answer,jdbcType=VARCHAR}
+      answer = #{record.answer,jdbcType=VARCHAR},
+      topic_content = #{record.topicContent,jdbcType=VARCHAR}
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
     </if>
@@ -197,6 +210,9 @@
       <if test="answer != null">
         answer = #{answer,jdbcType=VARCHAR},
       </if>
+      <if test="topicContent != null">
+        topic_content = #{topicContent,jdbcType=VARCHAR},
+      </if>
     </set>
     where id = #{id,jdbcType=VARCHAR}
   </update>
@@ -205,7 +221,8 @@
     set topic_id = #{topicId,jdbcType=VARCHAR},
       flow_id = #{flowId,jdbcType=VARCHAR},
       user_answer = #{userAnswer,jdbcType=VARCHAR},
-      answer = #{answer,jdbcType=VARCHAR}
+      answer = #{answer,jdbcType=VARCHAR},
+      topic_content = #{topicContent,jdbcType=VARCHAR}
     where id = #{id,jdbcType=VARCHAR}
   </update>
 </mapper>
\ No newline at end of file

From bb0e41af647c1c78a583ed36e5a736e3b2d3b0e8 Mon Sep 17 00:00:00 2001
From: xiaoCJ <406612557@qq.com>
Date: Wed, 15 Nov 2023 17:58:33 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=83=A8=E5=88=86?=
 =?UTF-8?q?=E8=A1=A8=E5=AD=97=E6=AE=B5=EF=BC=8C=E6=96=B0=E5=BB=BAflow?=
 =?UTF-8?q?=E4=B8=AD=E9=97=B4=E8=A1=A8=E5=85=B3=E8=81=94user=20ID=E5=92=8C?=
 =?UTF-8?q?=E6=B5=81=E7=A8=8BID=20=E6=96=B0=E5=A2=9E=E7=9F=A5=E8=AF=86?=
 =?UTF-8?q?=E8=AF=84=E6=B5=8B=E9=A2=98=E7=9B=AE=E8=B0=83=E7=94=A8=20?=
 =?UTF-8?q?=E5=88=A4=E6=96=AD=E5=AF=B9=E9=94=99=20=E5=9B=9E=E6=98=BE?=
 =?UTF-8?q?=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../mappers/PerformanceScoreMapper.xml        | 25 +++++++++++++++----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/main/resources/mappers/PerformanceScoreMapper.xml b/src/main/resources/mappers/PerformanceScoreMapper.xml
index 3e56708..f70131b 100644
--- a/src/main/resources/mappers/PerformanceScoreMapper.xml
+++ b/src/main/resources/mappers/PerformanceScoreMapper.xml
@@ -17,6 +17,7 @@
     <result column="profit_management_score" jdbcType="DECIMAL" property="profitManagementScore" />
     <result column="profit_distribution_score" jdbcType="DECIMAL" property="profitDistributionScore" />
     <result column="investment_report_score" jdbcType="DECIMAL" property="investmentReportScore" />
+    <result column="total_score" jdbcType="DECIMAL" property="totalScore" />
   </resultMap>
   <sql id="Example_Where_Clause">
     <where>
@@ -80,7 +81,7 @@
     id, flow_id, schoolId, practical_cognition_score, knowledge_assessment_score, fundraising_score, 
     project_search_score, project_due_diligence_score, project_valuation_score, investment_signing_score, 
     IPO_application_score, pricing_issuance_score, profit_management_score, profit_distribution_score, 
-    investment_report_score
+    investment_report_score, total_score
   </sql>
   <select id="selectByExample" parameterType="com.sztzjy.fund_investment.entity.PerformanceScoreExample" resultMap="BaseResultMap">
     select
@@ -119,14 +120,14 @@
       project_valuation_score, investment_signing_score, 
       IPO_application_score, pricing_issuance_score, 
       profit_management_score, profit_distribution_score, 
-      investment_report_score)
+      investment_report_score, total_score)
     values (#{id,jdbcType=VARCHAR}, #{flowId,jdbcType=VARCHAR}, #{schoolid,jdbcType=VARCHAR}, 
       #{practicalCognitionScore,jdbcType=DECIMAL}, #{knowledgeAssessmentScore,jdbcType=DECIMAL}, 
       #{fundraisingScore,jdbcType=DECIMAL}, #{projectSearchScore,jdbcType=DECIMAL}, #{projectDueDiligenceScore,jdbcType=DECIMAL}, 
       #{projectValuationScore,jdbcType=DECIMAL}, #{investmentSigningScore,jdbcType=DECIMAL}, 
       #{ipoApplicationScore,jdbcType=DECIMAL}, #{pricingIssuanceScore,jdbcType=DECIMAL}, 
       #{profitManagementScore,jdbcType=DECIMAL}, #{profitDistributionScore,jdbcType=DECIMAL}, 
-      #{investmentReportScore,jdbcType=DECIMAL})
+      #{investmentReportScore,jdbcType=DECIMAL}, #{totalScore,jdbcType=DECIMAL})
   </insert>
   <insert id="insertSelective" parameterType="com.sztzjy.fund_investment.entity.PerformanceScore">
     insert into performance_score
@@ -176,6 +177,9 @@
       <if test="investmentReportScore != null">
         investment_report_score,
       </if>
+      <if test="totalScore != null">
+        total_score,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="id != null">
@@ -223,6 +227,9 @@
       <if test="investmentReportScore != null">
         #{investmentReportScore,jdbcType=DECIMAL},
       </if>
+      <if test="totalScore != null">
+        #{totalScore,jdbcType=DECIMAL},
+      </if>
     </trim>
   </insert>
   <select id="countByExample" parameterType="com.sztzjy.fund_investment.entity.PerformanceScoreExample" resultType="java.lang.Long">
@@ -279,6 +286,9 @@
       <if test="record.investmentReportScore != null">
         investment_report_score = #{record.investmentReportScore,jdbcType=DECIMAL},
       </if>
+      <if test="record.totalScore != null">
+        total_score = #{record.totalScore,jdbcType=DECIMAL},
+      </if>
     </set>
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
@@ -300,7 +310,8 @@
       pricing_issuance_score = #{record.pricingIssuanceScore,jdbcType=DECIMAL},
       profit_management_score = #{record.profitManagementScore,jdbcType=DECIMAL},
       profit_distribution_score = #{record.profitDistributionScore,jdbcType=DECIMAL},
-      investment_report_score = #{record.investmentReportScore,jdbcType=DECIMAL}
+      investment_report_score = #{record.investmentReportScore,jdbcType=DECIMAL},
+      total_score = #{record.totalScore,jdbcType=DECIMAL}
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
     </if>
@@ -350,6 +361,9 @@
       <if test="investmentReportScore != null">
         investment_report_score = #{investmentReportScore,jdbcType=DECIMAL},
       </if>
+      <if test="totalScore != null">
+        total_score = #{totalScore,jdbcType=DECIMAL},
+      </if>
     </set>
     where id = #{id,jdbcType=VARCHAR}
   </update>
@@ -368,7 +382,8 @@
       pricing_issuance_score = #{pricingIssuanceScore,jdbcType=DECIMAL},
       profit_management_score = #{profitManagementScore,jdbcType=DECIMAL},
       profit_distribution_score = #{profitDistributionScore,jdbcType=DECIMAL},
-      investment_report_score = #{investmentReportScore,jdbcType=DECIMAL}
+      investment_report_score = #{investmentReportScore,jdbcType=DECIMAL},
+      total_score = #{totalScore,jdbcType=DECIMAL}
     where id = #{id,jdbcType=VARCHAR}
   </update>
 </mapper>
\ No newline at end of file