|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* IPO页面弹窗2使用返回随机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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 选项转Map,对象转Dto返回
|
|
|
|
|
* @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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|