完成测试页面相关所有接口,实务认知页面接口

master
xiaoCJ 1 year ago
parent c637e14afe
commit cf21c69fc9

@ -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上市条件题目";
}

@ -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<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);
public ResultEntity<List<TopicsDto>> getRandomTopic(@ApiParam("题目来源模块") @RequestParam String module) {
return new ResultEntity<List<TopicsDto>>(topicService.getRandomTopic(module));
}
/*
* @author xcj
* @Date 2023/11/21
*/
@GetMapping("getIPOTopicTwo")
@ApiOperation("IPO页面弹窗2使用返回随机6条数据")
@AnonymousAccess
public ResultEntity<List<TopicsDto>> getIPOTopicTwo() {
return new ResultEntity<List<TopicsDto>>(topicService.getIPOTopicTwo());
}
/*
* @author xcj
* @Date 2023/11/15
*/
@PostMapping("getRightScore")
@ApiOperation("知识测评、项目估值、项目尽调,判断答案对错并返回得分")
@PostMapping("getRightScore/{flowId}")
@ApiOperation("知识测评,项目估值,项目尽调,IPO申请,判断答案对错算分")
@AnonymousAccess
public ResultEntity<List<String>> getRightScore(@ApiParam("需要ID和用户填写的答案") @RequestBody List<Topics> topics, @RequestParam String flowId) {
public ResultEntity<List<String>> getRightScore(@ApiParam("需要ID和用户填写的答案") @PathVariable ("flowId") String flowId,
@RequestBody List<Topics> topics) {
return topicService.getRightScore(topics, flowId);
}
/*
* @author xcj
* @Date 2023/11/15
*/
@PostMapping("getTopicRecord")
@ApiOperation("知识测评、项目估值、项目尽调,回显答题记录")
@ApiOperation("知识测评、项目估值、项目尽调,IPO申请,回显答题记录")
@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);
public ResultEntity<List<TopicRecordDto>> getTopicRecord(@ApiParam("getRightScore返回的ID集合") @RequestBody List<String> ids) {
return new ResultEntity<List<TopicRecordDto>>(topicService.getTopicRecord(ids));
}
/*
* @author xcj
* @Date 2023/11/21
*/
@GetMapping("getAllScore")
@ApiOperation("页面回显得分通用接口")
@AnonymousAccess
public ResultEntity<PerformanceScore> getAllScore(@RequestParam String flowId) {
PerformanceScoreExample performanceScoreExample = new PerformanceScoreExample();
performanceScoreExample.createCriteria().andFlowIdEqualTo(flowId);
List<PerformanceScore> performanceScores = performanceScoreMapper.selectByExample(performanceScoreExample);
return new ResultEntity<>(performanceScores.get(0));
}
@GetMapping("getIPOTopicOne")
@ApiOperation("IPO弹窗1")
@AnonymousAccess
public ResultEntity<Topics> getIPOTopicOne() {
Topics topics = topicsMapper.selectByPrimaryKey("999");
return new ResultEntity<Topics>(topics);
}
@AnonymousAccess
@PutMapping("/getVideoScore")
@ApiOperation("实务认知计算视频得分接口")
public ResultEntity<BigDecimal> 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);
}
}

@ -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();
}
}

@ -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<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 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<String> values) {
addCriterion("choices in", values, "choices");
return (Criteria) this;
}
public Criteria andChoicesNotIn(List<String> 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<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 {

@ -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;
}

@ -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<String> values) {
addCriterion("choices in", values, "choices");
return (Criteria) this;
}
public Criteria andChoicesNotIn(List<String> 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;

@ -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<String,String> choices;
@ApiModelProperty("用户提交答案")
private String userAnswer;
@ApiModelProperty("正确答案")
private String answer;
}

@ -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<String,String> 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;
}

@ -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);

@ -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<List<String>> getRightScore(List<Topics> topics,String flowId);
List<TopicsDto> getIPOTopicTwo();
List<TopicsDto> getRandomTopic(String module);
List<TopicRecordDto> getTopicRecord(List<String> ids);
}

@ -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<PerformanceScore> 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);
}
}

@ -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<List<String>> getRightScore(List<Topics> topics, String flowId) {
int score = 0;
List<String>list =new ArrayList<>();
List<String> 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<TopicsDto> getRandomTopic(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);
List<TopicsDto> list = new ArrayList<>();
for (Topics randomTopic : randomTopics) {
randomTopic.setAnswer(null);
TopicsDto topicsDto = new TopicsDto();
BeanUtils.copyProperties(randomTopic, topicsDto);
String choices = randomTopic.getChoices(); //选项
Map<String, String> map = getStringToMap(choices);
topicsDto.setChoices(map);
list.add(topicsDto);
}
return list;
}
/* ,,,IPO,
* @author xcj
* @Date 2023/11/21
*/
@Override
public List<TopicRecordDto> getTopicRecord(List<String> ids) {
List<TopicRecordDto> list = new ArrayList<>();
for (String id : ids) {
TopicRecord topicRecord = topicRecordMapper.selectByPrimaryKey(id);
Map<String, String> stringToMap = getStringToMap(topicRecord.getChoices());
TopicRecordDto topicRecordDto = new TopicRecordDto();
BeanUtils.copyProperties(topicRecord, topicRecordDto);
topicRecordDto.setChoices(stringToMap);
list.add(topicRecordDto);
}
return list;
}
/* IPO2使6
* @author xcj
* @Date 2023/11/21
*/
@Override
public List<TopicsDto> getIPOTopicTwo() {
int topicCountPerModule = 3;
List<Topics> topics = getRandomTopicsByModule(Constant.IPOBK, topicCountPerModule);
List<Topics> topics1 = getRandomTopicsByModule(Constant.IPOTJ, topicCountPerModule);
List<TopicsDto> list = toTopicsDtoList(topics);
list.addAll(toTopicsDtoList(topics1));
return list;
}
/* IPO
* @author xcj
* @Date 2023/11/21
*/
private List<Topics> getRandomTopicsByModule(String module, int count) {
TopicsExample topicsExample = new TopicsExample();
topicsExample.createCriteria().andModuleEqualTo(module);
List<Topics> topics = topicsMapper.selectByExampleWithBLOBs(topicsExample);
Collections.shuffle(topics);
int size = Math.min(count, topics.size());
return topics.subList(0, size);
}
/* MapDto
* @author xcj
* @Date 2023/11/21
*/
private List<TopicsDto> toTopicsDtoList(List<Topics> topics) {
List<TopicsDto> list = new ArrayList<>();
for (Topics topic : topics) {
topic.setAnswer(null);
TopicsDto topicsDto = new TopicsDto();
BeanUtils.copyProperties(topic, topicsDto);
String choices = topic.getChoices();
Map<String, String> map = getStringToMap(choices);
topicsDto.setChoices(map);
list.add(topicsDto);
}
return list;
}
/* map
* @author xcj
* @Date 2023/11/21
*/
private Map<String, String> getStringToMap(String choices) {
String[] split = choices.split(",");
Map<String, String> 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<String> stringList = Arrays.asList(stringArray);
System.out.println(stringList);
//json转list
String json = "[\"apple\", \"banana\", \"orange\"]";
ObjectMapper mapper = new ObjectMapper();
List<String> list = mapper.readValue(json, new TypeReference<List<String>>() {
});
System.out.println(list);
}
}

@ -5,9 +5,10 @@
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="topic_id" jdbcType="VARCHAR" property="topicId" />
<result column="flow_id" jdbcType="VARCHAR" property="flowId" />
<result column="topic_content" jdbcType="VARCHAR" property="topicContent" />
<result column="choices" jdbcType="VARCHAR" property="choices" />
<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>
@ -68,7 +69,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, topic_id, flow_id, user_answer, answer, topic_content
id, topic_id, flow_id, topic_content, choices, user_answer, answer
</sql>
<select id="selectByExample" parameterType="com.sztzjy.fund_investment.entity.TopicRecordExample" resultMap="BaseResultMap">
select
@ -102,11 +103,11 @@
</delete>
<insert id="insert" parameterType="com.sztzjy.fund_investment.entity.TopicRecord">
insert into topic_record (id, topic_id, flow_id,
user_answer, answer, topic_content
)
topic_content, choices, user_answer,
answer)
values (#{id,jdbcType=VARCHAR}, #{topicId,jdbcType=VARCHAR}, #{flowId,jdbcType=VARCHAR},
#{userAnswer,jdbcType=VARCHAR}, #{answer,jdbcType=VARCHAR}, #{topicContent,jdbcType=VARCHAR}
)
#{topicContent,jdbcType=VARCHAR}, #{choices,jdbcType=VARCHAR}, #{userAnswer,jdbcType=VARCHAR},
#{answer,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.sztzjy.fund_investment.entity.TopicRecord">
insert into topic_record
@ -120,15 +121,18 @@
<if test="flowId != null">
flow_id,
</if>
<if test="topicContent != null">
topic_content,
</if>
<if test="choices != null">
choices,
</if>
<if test="userAnswer != null">
user_answer,
</if>
<if test="answer != null">
answer,
</if>
<if test="topicContent != null">
topic_content,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -140,15 +144,18 @@
<if test="flowId != null">
#{flowId,jdbcType=VARCHAR},
</if>
<if test="topicContent != null">
#{topicContent,jdbcType=VARCHAR},
</if>
<if test="choices != null">
#{choices,jdbcType=VARCHAR},
</if>
<if test="userAnswer != null">
#{userAnswer,jdbcType=VARCHAR},
</if>
<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">
@ -169,15 +176,18 @@
<if test="record.flowId != null">
flow_id = #{record.flowId,jdbcType=VARCHAR},
</if>
<if test="record.topicContent != null">
topic_content = #{record.topicContent,jdbcType=VARCHAR},
</if>
<if test="record.choices != null">
choices = #{record.choices,jdbcType=VARCHAR},
</if>
<if test="record.userAnswer != null">
user_answer = #{record.userAnswer,jdbcType=VARCHAR},
</if>
<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" />
@ -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}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -204,15 +215,18 @@
<if test="flowId != null">
flow_id = #{flowId,jdbcType=VARCHAR},
</if>
<if test="topicContent != null">
topic_content = #{topicContent,jdbcType=VARCHAR},
</if>
<if test="choices != null">
choices = #{choices,jdbcType=VARCHAR},
</if>
<if test="userAnswer != null">
user_answer = #{userAnswer,jdbcType=VARCHAR},
</if>
<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>
@ -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}
</update>
</mapper>
Loading…
Cancel
Save