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 60aea77..1b0f7a5 100644 --- a/src/main/java/com/sztzjy/fund_investment/config/Constant.java +++ b/src/main/java/com/sztzjy/fund_investment/config/Constant.java @@ -16,8 +16,17 @@ public class Constant { */ public static final String BASIC = "Basic"; - public static final String TOFQUESTIONS = "判断题"; - public static final String SINGLECHOICE = "单选题"; public static final String MULTIPLECHOICE = "多选题"; + public static final String ZSCETK = "知识测评题库"; + public static final String XMJDTK = "项目尽调题库"; + public static final String XMGZTK = "项目估值题库"; + public static final String IPOBK = "IPO上市板块题目"; + public static final String IPOTJ = "IPO上市条件题目"; + + + + + + } diff --git a/src/main/java/com/sztzjy/fund_investment/controller/TopicController.java b/src/main/java/com/sztzjy/fund_investment/controller/TopicController.java index d4d3f95..fdb907c 100644 --- a/src/main/java/com/sztzjy/fund_investment/controller/TopicController.java +++ b/src/main/java/com/sztzjy/fund_investment/controller/TopicController.java @@ -1,10 +1,15 @@ package com.sztzjy.fund_investment.controller; +import cn.hutool.core.util.IdUtil; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import com.sztzjy.fund_investment.annotation.AnonymousAccess; -import com.sztzjy.fund_investment.entity.TopicRecord; +import com.sztzjy.fund_investment.entity.PerformanceScore; +import com.sztzjy.fund_investment.entity.PerformanceScoreExample; 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.entity.dto.TopicRecordDto; +import com.sztzjy.fund_investment.entity.dto.TopicsDto; +import com.sztzjy.fund_investment.mapper.PerformanceScoreMapper; import com.sztzjy.fund_investment.mapper.TopicsMapper; import com.sztzjy.fund_investment.service.TopicService; import com.sztzjy.fund_investment.util.ResultEntity; @@ -14,8 +19,8 @@ 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.math.BigDecimal; +import java.util.Arrays; import java.util.List; /** @@ -24,61 +29,124 @@ import java.util.List; */ @RestController @RequestMapping("/topics") -@Api(tags = "学生端--知识测评答题") +@Api(tags = "学生端--答题视频相关接口") public class TopicController { @Autowired private TopicsMapper topicsMapper; @Autowired private TopicService topicService; @Autowired - private TopicRecordMapper topicRecordMapper; + private PerformanceScoreMapper performanceScoreMapper; - /* + /* 选项格式 A.xx,B.xx 1.对,2.错 * @author xcj * @Date 2023/11/14 */ @GetMapping("getRandomTopic") - @ApiOperation("知识测评、项目估值、项目尽调,答题页面返回随机6条数据") + @ApiOperation("知识测评,项目估值,项目尽调,答题页面返回随机6条数据") @AnonymousAccess - public ResultEntity> getRandomTopic(@ApiParam("题目来源模块") @RequestParam String module) { - TopicsExample topicsExample = new TopicsExample(); - topicsExample.createCriteria().andModuleEqualTo(module); - List topics = topicsMapper.selectByExampleWithBLOBs(topicsExample); - //随机取6道题目 - Collections.shuffle(topics); - int size = Math.min(6, topics.size()); - List randomTopics = topics.subList(0, size); - for (Topics randomTopic : randomTopics) { - randomTopic.setAnswer(null); - } - return new ResultEntity<>(randomTopics); + public ResultEntity> getRandomTopic(@ApiParam("题目来源模块") @RequestParam String module) { + return new ResultEntity>(topicService.getRandomTopic(module)); } + + /* + * @author xcj + * @Date 2023/11/21 + */ + @GetMapping("getIPOTopicTwo") + @ApiOperation("IPO页面弹窗2使用返回随机6条数据") + @AnonymousAccess + public ResultEntity> getIPOTopicTwo() { + return new ResultEntity>(topicService.getIPOTopicTwo()); + } + + /* * @author xcj * @Date 2023/11/15 */ - @PostMapping("getRightScore") - @ApiOperation("知识测评、项目估值、项目尽调,判断答案对错并返回得分") + @PostMapping("getRightScore/{flowId}") + @ApiOperation("知识测评,项目估值,项目尽调,IPO申请,判断答案对错算分") @AnonymousAccess - public ResultEntity> getRightScore(@ApiParam("需要ID和用户填写的答案") @RequestBody List topics, @RequestParam String flowId) { + public ResultEntity> getRightScore(@ApiParam("需要ID和用户填写的答案") @PathVariable ("flowId") String flowId, + @RequestBody List topics) { return topicService.getRightScore(topics, flowId); } + /* * @author xcj * @Date 2023/11/15 */ @PostMapping("getTopicRecord") - @ApiOperation("知识测评、项目估值、项目尽调,回显答题记录") + @ApiOperation("知识测评、项目估值、项目尽调,IPO申请,回显答题记录") @AnonymousAccess - public ResultEntity > getTopicRecord(@ApiParam("getRightScore返回的ID集合")@RequestParam List ids) { - Listlist= new ArrayList<>(); - for (String id : ids) { - TopicRecord topicRecord = topicRecordMapper.selectByPrimaryKey(id); - list.add(topicRecord); + public ResultEntity> getTopicRecord(@ApiParam("getRightScore返回的ID集合") @RequestBody List ids) { + return new ResultEntity>(topicService.getTopicRecord(ids)); + } + + /* + * @author xcj + * @Date 2023/11/21 + */ + @GetMapping("getAllScore") + @ApiOperation("页面回显得分通用接口") + @AnonymousAccess + public ResultEntity getAllScore(@RequestParam String flowId) { + PerformanceScoreExample performanceScoreExample = new PerformanceScoreExample(); + performanceScoreExample.createCriteria().andFlowIdEqualTo(flowId); + List performanceScores = performanceScoreMapper.selectByExample(performanceScoreExample); + return new ResultEntity<>(performanceScores.get(0)); + } + + + @GetMapping("getIPOTopicOne") + @ApiOperation("IPO弹窗1") + @AnonymousAccess + public ResultEntity getIPOTopicOne() { + Topics topics = topicsMapper.selectByPrimaryKey("999"); + return new ResultEntity(topics); + } + + + @AnonymousAccess + @PutMapping("/getVideoScore") + @ApiOperation("实务认知计算视频得分接口") + public ResultEntity getVideoScore(@ApiParam("观看视频时间,单位秒") @RequestParam Integer time, + @RequestParam String flowId, + @RequestParam String schoolId) { + + //系统的第一个流程,新增一个得分对象 + PerformanceScore performanceScore = new PerformanceScore(); + + //观看2分钟以上得满分5分,否则不得分 + BigDecimal score = BigDecimal.ZERO; + if (time >= 120) { + score = BigDecimal.valueOf(5); + performanceScore.setPracticalCognitionScore(score); + } else { + performanceScore.setPracticalCognitionScore(BigDecimal.ZERO); } - return new ResultEntity<>(list); + performanceScore.setId(IdUtil.simpleUUID()); + performanceScore.setSchoolid(schoolId); + performanceScore.setFlowId(flowId); + performanceScore.setKnowledgeAssessmentScore(BigDecimal.ZERO); + performanceScore.setFundraisingScore(BigDecimal.ZERO); + performanceScore.setProjectSearchScore(BigDecimal.ZERO); + performanceScore.setProjectDueDiligenceScore(BigDecimal.ZERO); + performanceScore.setProjectValuationScore(BigDecimal.ZERO); + performanceScore.setInvestmentSigningScore(BigDecimal.ZERO); + performanceScore.setIpoApplicationScore(BigDecimal.ZERO); + performanceScore.setPricingIssuanceScore(BigDecimal.ZERO); + performanceScore.setProfitManagementScore(BigDecimal.ZERO); + performanceScore.setProfitDistributionScore(BigDecimal.ZERO); + performanceScore.setInvestmentReportScore(BigDecimal.ZERO); + performanceScore.setTotalScore(BigDecimal.ZERO); + performanceScoreMapper.insert(performanceScore); + return new ResultEntity<>(score); } + + } 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 e74acde..731ab46 100644 --- a/src/main/java/com/sztzjy/fund_investment/entity/TopicRecord.java +++ b/src/main/java/com/sztzjy/fund_investment/entity/TopicRecord.java @@ -15,15 +15,18 @@ public class TopicRecord { @ApiModelProperty("流程ID") private String flowId; + @ApiModelProperty("题干") + private String topicContent; + + @ApiModelProperty("选项") + private String choices; + @ApiModelProperty("用户提交答案") private String userAnswer; @ApiModelProperty("正确答案") private String answer; - @ApiModelProperty("题干") - private String topicContent; - public String getId() { return id; } @@ -48,6 +51,22 @@ public class TopicRecord { this.flowId = flowId == null ? null : flowId.trim(); } + public String getTopicContent() { + return topicContent; + } + + public void setTopicContent(String topicContent) { + this.topicContent = topicContent == null ? null : topicContent.trim(); + } + + public String getChoices() { + return choices; + } + + public void setChoices(String choices) { + this.choices = choices == null ? null : choices.trim(); + } + public String getUserAnswer() { return userAnswer; } @@ -63,12 +82,4 @@ 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 9f2f7ad..6fcbc0e 100644 --- a/src/main/java/com/sztzjy/fund_investment/entity/TopicRecordExample.java +++ b/src/main/java/com/sztzjy/fund_investment/entity/TopicRecordExample.java @@ -314,6 +314,146 @@ public class TopicRecordExample { 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 values) { + addCriterion("topic_content in", values, "topicContent"); + return (Criteria) this; + } + + public Criteria andTopicContentNotIn(List 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 Criteria andChoicesIsNull() { + addCriterion("choices is null"); + return (Criteria) this; + } + + public Criteria andChoicesIsNotNull() { + addCriterion("choices is not null"); + return (Criteria) this; + } + + public Criteria andChoicesEqualTo(String value) { + addCriterion("choices =", value, "choices"); + return (Criteria) this; + } + + public Criteria andChoicesNotEqualTo(String value) { + addCriterion("choices <>", value, "choices"); + return (Criteria) this; + } + + public Criteria andChoicesGreaterThan(String value) { + addCriterion("choices >", value, "choices"); + return (Criteria) this; + } + + public Criteria andChoicesGreaterThanOrEqualTo(String value) { + addCriterion("choices >=", value, "choices"); + return (Criteria) this; + } + + public Criteria andChoicesLessThan(String value) { + addCriterion("choices <", value, "choices"); + return (Criteria) this; + } + + public Criteria andChoicesLessThanOrEqualTo(String value) { + addCriterion("choices <=", value, "choices"); + return (Criteria) this; + } + + public Criteria andChoicesLike(String value) { + addCriterion("choices like", value, "choices"); + return (Criteria) this; + } + + public Criteria andChoicesNotLike(String value) { + addCriterion("choices not like", value, "choices"); + return (Criteria) this; + } + + public Criteria andChoicesIn(List values) { + addCriterion("choices in", values, "choices"); + return (Criteria) this; + } + + public Criteria andChoicesNotIn(List values) { + addCriterion("choices not in", values, "choices"); + return (Criteria) this; + } + + public Criteria andChoicesBetween(String value1, String value2) { + addCriterion("choices between", value1, value2, "choices"); + return (Criteria) this; + } + + public Criteria andChoicesNotBetween(String value1, String value2) { + addCriterion("choices not between", value1, value2, "choices"); + return (Criteria) this; + } + public Criteria andUserAnswerIsNull() { addCriterion("user_answer is null"); return (Criteria) this; @@ -453,76 +593,6 @@ 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 values) { - addCriterion("topic_content in", values, "topicContent"); - return (Criteria) this; - } - - public Criteria andTopicContentNotIn(List 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/entity/Topics.java b/src/main/java/com/sztzjy/fund_investment/entity/Topics.java index cd03099..b7e9a91 100644 --- a/src/main/java/com/sztzjy/fund_investment/entity/Topics.java +++ b/src/main/java/com/sztzjy/fund_investment/entity/Topics.java @@ -9,6 +9,9 @@ import io.swagger.annotations.ApiModelProperty; public class Topics { private String topicId; + @ApiModelProperty("选项") + private String choices; + @ApiModelProperty("题型") private String topicType; @@ -35,6 +38,14 @@ public class Topics { this.topicId = topicId == null ? null : topicId.trim(); } + public String getChoices() { + return choices; + } + + public void setChoices(String choices) { + this.choices = choices == null ? null : choices.trim(); + } + public String getTopicType() { return topicType; } diff --git a/src/main/java/com/sztzjy/fund_investment/entity/TopicsExample.java b/src/main/java/com/sztzjy/fund_investment/entity/TopicsExample.java index b1cec58..165c976 100644 --- a/src/main/java/com/sztzjy/fund_investment/entity/TopicsExample.java +++ b/src/main/java/com/sztzjy/fund_investment/entity/TopicsExample.java @@ -174,6 +174,76 @@ public class TopicsExample { return (Criteria) this; } + public Criteria andChoicesIsNull() { + addCriterion("choices is null"); + return (Criteria) this; + } + + public Criteria andChoicesIsNotNull() { + addCriterion("choices is not null"); + return (Criteria) this; + } + + public Criteria andChoicesEqualTo(String value) { + addCriterion("choices =", value, "choices"); + return (Criteria) this; + } + + public Criteria andChoicesNotEqualTo(String value) { + addCriterion("choices <>", value, "choices"); + return (Criteria) this; + } + + public Criteria andChoicesGreaterThan(String value) { + addCriterion("choices >", value, "choices"); + return (Criteria) this; + } + + public Criteria andChoicesGreaterThanOrEqualTo(String value) { + addCriterion("choices >=", value, "choices"); + return (Criteria) this; + } + + public Criteria andChoicesLessThan(String value) { + addCriterion("choices <", value, "choices"); + return (Criteria) this; + } + + public Criteria andChoicesLessThanOrEqualTo(String value) { + addCriterion("choices <=", value, "choices"); + return (Criteria) this; + } + + public Criteria andChoicesLike(String value) { + addCriterion("choices like", value, "choices"); + return (Criteria) this; + } + + public Criteria andChoicesNotLike(String value) { + addCriterion("choices not like", value, "choices"); + return (Criteria) this; + } + + public Criteria andChoicesIn(List values) { + addCriterion("choices in", values, "choices"); + return (Criteria) this; + } + + public Criteria andChoicesNotIn(List values) { + addCriterion("choices not in", values, "choices"); + return (Criteria) this; + } + + public Criteria andChoicesBetween(String value1, String value2) { + addCriterion("choices between", value1, value2, "choices"); + return (Criteria) this; + } + + public Criteria andChoicesNotBetween(String value1, String value2) { + addCriterion("choices not between", value1, value2, "choices"); + return (Criteria) this; + } + public Criteria andTopicTypeIsNull() { addCriterion("topic_type is null"); return (Criteria) this; diff --git a/src/main/java/com/sztzjy/fund_investment/entity/dto/TopicRecordDto.java b/src/main/java/com/sztzjy/fund_investment/entity/dto/TopicRecordDto.java new file mode 100644 index 0000000..c48c034 --- /dev/null +++ b/src/main/java/com/sztzjy/fund_investment/entity/dto/TopicRecordDto.java @@ -0,0 +1,34 @@ +package com.sztzjy.fund_investment.entity.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Map; + +/** + * + * @author xcj + * topic_record + */ +@Data +public class TopicRecordDto { + private String id; + + @ApiModelProperty("题目ID") + private String topicId; + + @ApiModelProperty("流程ID") + private String flowId; + + @ApiModelProperty("题干") + private String topicContent; + + @ApiModelProperty("选项") + private Map choices; + + @ApiModelProperty("用户提交答案") + private String userAnswer; + + @ApiModelProperty("正确答案") + private String answer; +} \ No newline at end of file diff --git a/src/main/java/com/sztzjy/fund_investment/entity/dto/TopicsDto.java b/src/main/java/com/sztzjy/fund_investment/entity/dto/TopicsDto.java new file mode 100644 index 0000000..347f130 --- /dev/null +++ b/src/main/java/com/sztzjy/fund_investment/entity/dto/TopicsDto.java @@ -0,0 +1,38 @@ +package com.sztzjy.fund_investment.entity.dto; + +import io.swagger.annotations.ApiModelProperty; +import io.swagger.annotations.License; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +/** + * @Author xcj + * @Date 2023/11/21 + */ +@Data +public class TopicsDto { + private String topicId; + + @ApiModelProperty("选项") + private Map choices; + + @ApiModelProperty("题型") + private String topicType; + + @ApiModelProperty("来源(内置/自增)") + private String source; + + @ApiModelProperty("题库类型") + private String module; + + @ApiModelProperty("答案") + private String answer; + + @ApiModelProperty("学校ID") + private String schoolId; + + @ApiModelProperty("题干") + private String topicContent; +} diff --git a/src/main/java/com/sztzjy/fund_investment/mapper/TopicsMapper.java b/src/main/java/com/sztzjy/fund_investment/mapper/TopicsMapper.java index bac4c63..ac2653f 100644 --- a/src/main/java/com/sztzjy/fund_investment/mapper/TopicsMapper.java +++ b/src/main/java/com/sztzjy/fund_investment/mapper/TopicsMapper.java @@ -2,11 +2,11 @@ package com.sztzjy.fund_investment.mapper; import com.sztzjy.fund_investment.entity.Topics; import com.sztzjy.fund_investment.entity.TopicsExample; +import java.util.List; + import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; -import java.util.List; - @Mapper public interface TopicsMapper { long countByExample(TopicsExample example); diff --git a/src/main/java/com/sztzjy/fund_investment/service/TopicService.java b/src/main/java/com/sztzjy/fund_investment/service/TopicService.java index c6e23bd..181d192 100644 --- a/src/main/java/com/sztzjy/fund_investment/service/TopicService.java +++ b/src/main/java/com/sztzjy/fund_investment/service/TopicService.java @@ -1,6 +1,8 @@ package com.sztzjy.fund_investment.service; import com.sztzjy.fund_investment.entity.Topics; +import com.sztzjy.fund_investment.entity.dto.TopicRecordDto; +import com.sztzjy.fund_investment.entity.dto.TopicsDto; import com.sztzjy.fund_investment.util.ResultEntity; import java.util.List; @@ -12,4 +14,9 @@ import java.util.List; public interface TopicService { ResultEntity> getRightScore(List topics,String flowId); + List getIPOTopicTwo(); + + List getRandomTopic(String module); + + List getTopicRecord(List ids); } 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 index 0d317b7..844383b 100644 --- a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/PerformanceScoreServiceImpl.java +++ b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/PerformanceScoreServiceImpl.java @@ -7,6 +7,7 @@ import com.sztzjy.fund_investment.service.PerformanceScoreService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.util.List; /** @@ -29,7 +30,10 @@ public class PerformanceScoreServiceImpl implements PerformanceScoreService { performanceScoreExample.createCriteria().andFlowIdEqualTo(flowId); List performanceScores = performanceScoreMapper.selectByExample(performanceScoreExample); PerformanceScore performanceScore = performanceScores.get(0); - performanceScore.set(methodName,score); + + BigDecimal scoreOld =(BigDecimal) performanceScore.get(methodName); + BigDecimal addScore = scoreOld.add(BigDecimal.valueOf(score)); + performanceScore.set(methodName,addScore); 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 index c556e7f..f9cf2c7 100644 --- a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/TopicServiceImpl.java +++ b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/TopicServiceImpl.java @@ -1,22 +1,24 @@ package com.sztzjy.fund_investment.service.serviceImpl; import cn.hutool.core.util.IdUtil; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; 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.entity.TopicsExample; +import com.sztzjy.fund_investment.entity.dto.TopicRecordDto; +import com.sztzjy.fund_investment.entity.dto.TopicsDto; 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.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.List; +import java.util.*; /** * @Author xcj @@ -31,13 +33,21 @@ public class TopicServiceImpl implements TopicService { @Autowired private TopicRecordMapper topicRecordMapper; + + + /* 知识测评,项目估值,项目尽调,IPO申请,判断答案对错算分 + * @author xcj + * @Date 2023/11/21 + */ @Override public ResultEntity> getRightScore(List topics, String flowId) { int score = 0; - Listlist =new ArrayList<>(); + List list = new ArrayList<>(); + String module = ""; for (Topics topic : topics) { String userAnswer = topic.getAnswer(); String topicId = topic.getTopicId(); + module = topic.getModule(); Topics topicsData = topicsMapper.selectByPrimaryKey(topicId); String rightAnswer = topicsData.getAnswer(); String topicType = topicsData.getTopicType(); @@ -60,7 +70,9 @@ public class TopicServiceImpl implements TopicService { break; } } - if (isCorrect) { + if (isCorrect && topicId.equals("999")) { + score = 4; + } else if (isCorrect) { // 答案正确 score = score + 1; // 设置得分为1或其他适当的值 } @@ -69,9 +81,8 @@ public class TopicServiceImpl implements TopicService { score = score + 1; } } - //添加到答题记录表 - TopicRecord topicRecord =new TopicRecord(); + TopicRecord topicRecord = new TopicRecord(); String recordId = IdUtil.simpleUUID(); topicRecord.setId(recordId); topicRecord.setTopicId(topicId); @@ -79,21 +90,35 @@ public class TopicServiceImpl implements TopicService { topicRecord.setAnswer(rightAnswer); topicRecord.setFlowId(flowId); topicRecord.setTopicContent(topic.getTopicContent()); + topicRecord.setChoices(topicsData.getChoices()); topicRecordMapper.insert(topicRecord); list.add(recordId); } - //六道题总分最多五分 - if (score >= 5) { + //IPO模块总分十分,其余5分 + if (!(module.equals(Constant.IPOBK) || module.equals(Constant.IPOTJ)) && score >= 5) { score = 5; } // 调用计分方法 - performanceScoreService.calculateScoreByModule("knowledgeAssessmentScore", score, flowId); - String strScore = String.valueOf(score); - list.add(strScore); + if (module.equals(Constant.ZSCETK)) { + performanceScoreService.calculateScoreByModule("knowledgeAssessmentScore", score, flowId); + } + if (module.equals(Constant.XMJDTK)) { + performanceScoreService.calculateScoreByModule("projectDueDiligenceScore", score, flowId); + } + if (module.equals(Constant.XMGZTK)) { + performanceScoreService.calculateScoreByModule("projectValuationScore", score, flowId); + } + if (module.equals(Constant.IPOBK) || module.equals(Constant.IPOTJ)) { + performanceScoreService.calculateScoreByModule("ipoApplicationScore", score, flowId); + } return new ResultEntity<>(list); } - // 检查字符数组是否包含指定字符 + + /* 检查字符数组是否包含指定字符 + * @author xcj + * @Date 2023/11/21 + */ private boolean containsChar(char[] array, char c) { for (char element : array) { if (element == c) { @@ -102,4 +127,137 @@ public class TopicServiceImpl implements TopicService { } return false; } + + + /* + * @author xcj + * @Date 2023/11/21 + */ + @Override + public List getRandomTopic(String module) { + TopicsExample topicsExample = new TopicsExample(); + topicsExample.createCriteria().andModuleEqualTo(module); + List topics = topicsMapper.selectByExampleWithBLOBs(topicsExample); + //随机取6道题目 + Collections.shuffle(topics); + int size = Math.min(6, topics.size()); + List randomTopics = topics.subList(0, size); + List list = new ArrayList<>(); + for (Topics randomTopic : randomTopics) { + randomTopic.setAnswer(null); + TopicsDto topicsDto = new TopicsDto(); + BeanUtils.copyProperties(randomTopic, topicsDto); + String choices = randomTopic.getChoices(); //选项 + Map map = getStringToMap(choices); + topicsDto.setChoices(map); + list.add(topicsDto); + } + return list; + } + + /* 知识测评,项目估值,项目尽调,IPO申请,判断答案对错算分 + * @author xcj + * @Date 2023/11/21 + */ + @Override + public List getTopicRecord(List ids) { + List list = new ArrayList<>(); + for (String id : ids) { + TopicRecord topicRecord = topicRecordMapper.selectByPrimaryKey(id); + Map stringToMap = getStringToMap(topicRecord.getChoices()); + TopicRecordDto topicRecordDto = new TopicRecordDto(); + BeanUtils.copyProperties(topicRecord, topicRecordDto); + topicRecordDto.setChoices(stringToMap); + list.add(topicRecordDto); + } + return list; + } + + + /* IPO页面弹窗2使用返回随机6条数据 + * @author xcj + * @Date 2023/11/21 + */ + @Override + public List getIPOTopicTwo() { + int topicCountPerModule = 3; + List topics = getRandomTopicsByModule(Constant.IPOBK, topicCountPerModule); + List topics1 = getRandomTopicsByModule(Constant.IPOTJ, topicCountPerModule); + + List list = toTopicsDtoList(topics); + list.addAll(toTopicsDtoList(topics1)); + + return list; + } + + + /* IPO两个模块分别取三题 + * @author xcj + * @Date 2023/11/21 + */ + private List getRandomTopicsByModule(String module, int count) { + TopicsExample topicsExample = new TopicsExample(); + topicsExample.createCriteria().andModuleEqualTo(module); + List topics = topicsMapper.selectByExampleWithBLOBs(topicsExample); + Collections.shuffle(topics); + int size = Math.min(count, topics.size()); + return topics.subList(0, size); + } + + + /* 选项转Map,对象转Dto返回 + * @author xcj + * @Date 2023/11/21 + */ + private List toTopicsDtoList(List topics) { + List list = new ArrayList<>(); + for (Topics topic : topics) { + topic.setAnswer(null); + TopicsDto topicsDto = new TopicsDto(); + BeanUtils.copyProperties(topic, topicsDto); + String choices = topic.getChoices(); + Map map = getStringToMap(choices); + topicsDto.setChoices(map); + list.add(topicsDto); + } + return list; + } + + + /* 字符串转map + * @author xcj + * @Date 2023/11/21 + */ + private Map getStringToMap(String choices) { + String[] split = choices.split(","); + Map map = new HashMap<>(); + for (String pair : split) { + String[] keyValue = pair.split("\\."); + if (keyValue.length == 2) { + String key = keyValue[0]; + String value = keyValue[1]; + map.put(key, value); + } + } + return map; + } + + + + public static void main(String[] args) throws Exception { + //字符串切割转list + String listString = "A:111,B:2222,C:333"; + listString = listString.replace(",", ""); + String[] stringArray = listString.split(","); + List stringList = Arrays.asList(stringArray); + System.out.println(stringList); + + //json转list + String json = "[\"apple\", \"banana\", \"orange\"]"; + ObjectMapper mapper = new ObjectMapper(); + List list = mapper.readValue(json, new TypeReference>() { + }); + + System.out.println(list); + } } diff --git a/src/main/resources/mappers/TopicRecordMapper.xml b/src/main/resources/mappers/TopicRecordMapper.xml index 57ad196..fe71ef8 100644 --- a/src/main/resources/mappers/TopicRecordMapper.xml +++ b/src/main/resources/mappers/TopicRecordMapper.xml @@ -5,9 +5,10 @@ + + - @@ -68,7 +69,7 @@ - id, topic_id, flow_id, user_answer, answer, topic_content + id, topic_id, flow_id, topic_content, choices, user_answer, answer @@ -169,15 +176,18 @@ flow_id = #{record.flowId,jdbcType=VARCHAR}, + + topic_content = #{record.topicContent,jdbcType=VARCHAR}, + + + choices = #{record.choices,jdbcType=VARCHAR}, + user_answer = #{record.userAnswer,jdbcType=VARCHAR}, answer = #{record.answer,jdbcType=VARCHAR}, - - topic_content = #{record.topicContent,jdbcType=VARCHAR}, - @@ -188,9 +198,10 @@ set id = #{record.id,jdbcType=VARCHAR}, topic_id = #{record.topicId,jdbcType=VARCHAR}, flow_id = #{record.flowId,jdbcType=VARCHAR}, + topic_content = #{record.topicContent,jdbcType=VARCHAR}, + choices = #{record.choices,jdbcType=VARCHAR}, user_answer = #{record.userAnswer,jdbcType=VARCHAR}, - answer = #{record.answer,jdbcType=VARCHAR}, - topic_content = #{record.topicContent,jdbcType=VARCHAR} + answer = #{record.answer,jdbcType=VARCHAR} @@ -204,15 +215,18 @@ flow_id = #{flowId,jdbcType=VARCHAR}, + + topic_content = #{topicContent,jdbcType=VARCHAR}, + + + choices = #{choices,jdbcType=VARCHAR}, + user_answer = #{userAnswer,jdbcType=VARCHAR}, answer = #{answer,jdbcType=VARCHAR}, - - topic_content = #{topicContent,jdbcType=VARCHAR}, - where id = #{id,jdbcType=VARCHAR} @@ -220,9 +234,10 @@ update topic_record set topic_id = #{topicId,jdbcType=VARCHAR}, flow_id = #{flowId,jdbcType=VARCHAR}, + topic_content = #{topicContent,jdbcType=VARCHAR}, + choices = #{choices,jdbcType=VARCHAR}, user_answer = #{userAnswer,jdbcType=VARCHAR}, - answer = #{answer,jdbcType=VARCHAR}, - topic_content = #{topicContent,jdbcType=VARCHAR} + answer = #{answer,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file