【修改】 1、考点服务器同步试题,插入数据库BUG修改;2、代码优化
This commit is contained in:
@@ -43,9 +43,8 @@ import static pc.exam.pp.module.system.enums.ErrorCodeConstants.*;
|
|||||||
* @date 2025-03-13
|
* @date 2025-03-13
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class ExamQuestionServiceImpl implements IExamQuestionService
|
public class ExamQuestionServiceImpl implements IExamQuestionService {
|
||||||
{
|
// @Autowired
|
||||||
// @Autowired
|
|
||||||
// private ExamBankMapper examBankMapper;
|
// private ExamBankMapper examBankMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ExamQuestionMapper examQuestionMapper;
|
private ExamQuestionMapper examQuestionMapper;
|
||||||
@@ -73,6 +72,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
private IExamQuestionService examQuestionService;
|
private IExamQuestionService examQuestionService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ConfigApi configApi;
|
private ConfigApi configApi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询试题(hyc)
|
* 查询试题(hyc)
|
||||||
*
|
*
|
||||||
@@ -80,37 +80,36 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
* @return 试题(hyc)
|
* @return 试题(hyc)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ExamQuestion selectExamQuestionByQuId(String quId)
|
public ExamQuestion selectExamQuestionByQuId(String quId) {
|
||||||
{
|
|
||||||
//查找试题答案
|
//查找试题答案
|
||||||
List<ExamQuestionAnswer> examQuestionAnswers = examQuestionAnswerMapper.selectExamQuestionAnswerByQuId(quId);
|
List<ExamQuestionAnswer> examQuestionAnswers = examQuestionAnswerMapper.selectExamQuestionAnswerByQuId(quId);
|
||||||
//查找试题文件
|
//查找试题文件
|
||||||
List<SysFileUpload> sysFileUploads =sysFileMapper.selectSysFileByQuid(quId);
|
List<SysFileUpload> sysFileUploads = sysFileMapper.selectSysFileByQuid(quId);
|
||||||
//查找试题判分
|
//查找试题判分
|
||||||
ExamQuestionScore examQuestionScore =examQuestionScoreMapper.selectExamQuestionScoreByQuId(quId);
|
ExamQuestionScore examQuestionScore = examQuestionScoreMapper.selectExamQuestionScoreByQuId(quId);
|
||||||
//获取试题关键字
|
//获取试题关键字
|
||||||
List<ExamQuestionKeyword> examQuestionKeywords = examQuestionKeywordMapper.selectExamQuestionKeywordByQuId(quId);
|
List<ExamQuestionKeyword> examQuestionKeywords = examQuestionKeywordMapper.selectExamQuestionKeywordByQuId(quId);
|
||||||
|
|
||||||
ExamQuestion examQuestion = examQuestionMapper.selectExamQuestionByQuId(quId);
|
ExamQuestion examQuestion = examQuestionMapper.selectExamQuestionByQuId(quId);
|
||||||
if (examQuestion!=null){
|
if (examQuestion != null) {
|
||||||
if (examQuestionAnswers!=null&&examQuestionAnswers.size()>0){
|
if (examQuestionAnswers != null && examQuestionAnswers.size() > 0) {
|
||||||
examQuestion.setAnswerList(examQuestionAnswers);
|
examQuestion.setAnswerList(examQuestionAnswers);
|
||||||
}
|
}
|
||||||
if (sysFileUploads!=null&&sysFileUploads.size()>0){
|
if (sysFileUploads != null && sysFileUploads.size() > 0) {
|
||||||
examQuestion.setFileUploads(sysFileUploads);
|
examQuestion.setFileUploads(sysFileUploads);
|
||||||
}
|
}
|
||||||
if (examQuestionScore!=null){
|
if (examQuestionScore != null) {
|
||||||
examQuestion.setQuestionScores(examQuestionScore);
|
examQuestion.setQuestionScores(examQuestionScore);
|
||||||
}
|
}
|
||||||
if (examQuestionKeywords!=null&&examQuestionKeywords.size()>0){
|
if (examQuestionKeywords != null && examQuestionKeywords.size() > 0) {
|
||||||
examQuestion.setQuestionKeywords(examQuestionKeywords);
|
examQuestion.setQuestionKeywords(examQuestionKeywords);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String chapteridDictText = examQuestion.getChapteridDictText();
|
String chapteridDictText = examQuestion.getChapteridDictText();
|
||||||
String pointNames = examQuestion.getPointNames();
|
String pointNames = examQuestion.getPointNames();
|
||||||
String point= knowledgePointsMapper.selectKnowledgeNameBySpId(pointNames);
|
String point = knowledgePointsMapper.selectKnowledgeNameBySpId(pointNames);
|
||||||
String chapterText= knowledgePointsMapper.selectKnowledgeNameBySpId(chapteridDictText);
|
String chapterText = knowledgePointsMapper.selectKnowledgeNameBySpId(chapteridDictText);
|
||||||
examQuestion.setPointNamesVo(point);
|
examQuestion.setPointNamesVo(point);
|
||||||
examQuestion.setChapteridDictTextVo(chapterText);
|
examQuestion.setChapteridDictTextVo(chapterText);
|
||||||
return examQuestion;
|
return examQuestion;
|
||||||
@@ -131,8 +130,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertExamQuestion(ExamQuestion examQuestion)
|
public int insertExamQuestion(ExamQuestion examQuestion) {
|
||||||
{
|
|
||||||
//更新题库的试题数
|
//更新题库的试题数
|
||||||
// if (examQuestion.getQuBankId()!=null){
|
// if (examQuestion.getQuBankId()!=null){
|
||||||
// UpdateQuCountNow(examQuestion.getQuBankId());
|
// UpdateQuCountNow(examQuestion.getQuBankId());
|
||||||
@@ -146,7 +144,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
List<SysFileUpload> fileUploads = examQuestion.getFileUploads();
|
List<SysFileUpload> fileUploads = examQuestion.getFileUploads();
|
||||||
ExamQuestionScore questionScore = examQuestion.getQuestionScores();
|
ExamQuestionScore questionScore = examQuestion.getQuestionScores();
|
||||||
List<ExamQuestionKeyword> examQuestionKeywords = examQuestion.getQuestionKeywords();
|
List<ExamQuestionKeyword> examQuestionKeywords = examQuestion.getQuestionKeywords();
|
||||||
if (answerList!=null&&answerList.size()>0){
|
if (answerList != null && answerList.size() > 0) {
|
||||||
answerList.replaceAll(answer -> {
|
answerList.replaceAll(answer -> {
|
||||||
answer.setAnswerId(IdUtils.simpleUUID());
|
answer.setAnswerId(IdUtils.simpleUUID());
|
||||||
answer.setQuId(uuid);
|
answer.setQuId(uuid);
|
||||||
@@ -156,7 +154,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
examQuestionAnswerMapper.insertExamQuestionAnswerList(answerList);
|
examQuestionAnswerMapper.insertExamQuestionAnswerList(answerList);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileUploads!=null&&fileUploads.size()>0){
|
if (fileUploads != null && fileUploads.size() > 0) {
|
||||||
fileUploads.replaceAll(fileUpload -> {
|
fileUploads.replaceAll(fileUpload -> {
|
||||||
// 设置文件名(如果文件名为空)
|
// 设置文件名(如果文件名为空)
|
||||||
if (fileUpload.getFileName() == null || fileUpload.getFileName().isEmpty()) {
|
if (fileUpload.getFileName() == null || fileUpload.getFileName().isEmpty()) {
|
||||||
@@ -186,12 +184,12 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (questionScore!=null){
|
if (questionScore != null) {
|
||||||
questionScore.setScoreId(IdUtils.simpleUUID());
|
questionScore.setScoreId(IdUtils.simpleUUID());
|
||||||
questionScore.setQuId(uuid);
|
questionScore.setQuId(uuid);
|
||||||
examQuestionScoreMapper.insertExamQuestionScore(questionScore);
|
examQuestionScoreMapper.insertExamQuestionScore(questionScore);
|
||||||
}
|
}
|
||||||
if (examQuestionKeywords!=null&&examQuestionKeywords.size()>0){
|
if (examQuestionKeywords != null && examQuestionKeywords.size() > 0) {
|
||||||
examQuestionKeywords.replaceAll(examQuestionKeyword -> {
|
examQuestionKeywords.replaceAll(examQuestionKeyword -> {
|
||||||
examQuestionKeyword.setKeywordId(IdUtils.simpleUUID());
|
examQuestionKeyword.setKeywordId(IdUtils.simpleUUID());
|
||||||
examQuestionKeyword.setQuId(uuid);
|
examQuestionKeyword.setQuId(uuid);
|
||||||
@@ -201,12 +199,12 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
}
|
}
|
||||||
// return examQuestionMapper.insert(examQuestion);
|
// return examQuestionMapper.insert(examQuestion);
|
||||||
Long loginTenantId = SecurityFrameworkUtils.getLoginTenantId();
|
Long loginTenantId = SecurityFrameworkUtils.getLoginTenantId();
|
||||||
int count= examQuestionMapper.selectCountQu();
|
int count = examQuestionMapper.selectCountQu();
|
||||||
// 读取系统创建试题位数设置
|
// 读取系统创建试题位数设置
|
||||||
String number = configApi.getConfigValueByKey("qu_number");
|
String number = configApi.getConfigValueByKey("qu_number");
|
||||||
// 格式化为8位,不足前面补0
|
// 格式化为8位,不足前面补0
|
||||||
String formattedNumber = String.format("%0" + number + "d", ++count);
|
String formattedNumber = String.format("%0" + number + "d", ++count);
|
||||||
String quNum =loginTenantId +"-"+formattedNumber;
|
String quNum = loginTenantId + "-" + formattedNumber;
|
||||||
examQuestion.setQuNum(quNum);
|
examQuestion.setQuNum(quNum);
|
||||||
return examQuestionMapper.insertExamQuestion(examQuestion);
|
return examQuestionMapper.insertExamQuestion(examQuestion);
|
||||||
}
|
}
|
||||||
@@ -219,8 +217,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class) // 所有异常都回滚
|
@Transactional(rollbackFor = Exception.class) // 所有异常都回滚
|
||||||
public int updateExamQuestion(ExamQuestion examQuestion)
|
public int updateExamQuestion(ExamQuestion examQuestion) {
|
||||||
{
|
|
||||||
|
|
||||||
List<ExamQuestionAnswer> answerList = examQuestion.getAnswerList();
|
List<ExamQuestionAnswer> answerList = examQuestion.getAnswerList();
|
||||||
List<SysFileUpload> fileUploads = examQuestion.getFileUploads();
|
List<SysFileUpload> fileUploads = examQuestion.getFileUploads();
|
||||||
@@ -231,7 +228,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
if (!excludedSubjects.contains(examQuestion.getSubjectName())) {
|
if (!excludedSubjects.contains(examQuestion.getSubjectName())) {
|
||||||
//先删除试题的答案
|
//先删除试题的答案
|
||||||
examQuestionAnswerMapper.deleteExamQuestionAnswerByQuesId(examQuestion.getQuId());
|
examQuestionAnswerMapper.deleteExamQuestionAnswerByQuesId(examQuestion.getQuId());
|
||||||
if (answerList!=null&&answerList.size()>0){
|
if (answerList != null && answerList.size() > 0) {
|
||||||
//赋值
|
//赋值
|
||||||
answerList.replaceAll(answer -> {
|
answerList.replaceAll(answer -> {
|
||||||
answer.setAnswerId(IdUtils.simpleUUID());
|
answer.setAnswerId(IdUtils.simpleUUID());
|
||||||
@@ -245,7 +242,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
}
|
}
|
||||||
//先删除试题的文件
|
//先删除试题的文件
|
||||||
sysFileMapper.deleteSysFileByQuesId(examQuestion.getQuId());
|
sysFileMapper.deleteSysFileByQuesId(examQuestion.getQuId());
|
||||||
if (fileUploads!=null&&fileUploads.size()>0){
|
if (fileUploads != null && fileUploads.size() > 0) {
|
||||||
|
|
||||||
//赋值
|
//赋值
|
||||||
fileUploads.replaceAll(fileUpload -> {
|
fileUploads.replaceAll(fileUpload -> {
|
||||||
@@ -276,7 +273,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
sysFileMapper.insertSysFileList(fileUploads);
|
sysFileMapper.insertSysFileList(fileUploads);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (questionScore!=null){
|
if (questionScore != null) {
|
||||||
//先删除试题的判分
|
//先删除试题的判分
|
||||||
examQuestionScoreMapper.deleteExamQuestionScoreByQuesId(examQuestion.getQuId());
|
examQuestionScoreMapper.deleteExamQuestionScoreByQuesId(examQuestion.getQuId());
|
||||||
//赋值
|
//赋值
|
||||||
@@ -286,7 +283,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
}
|
}
|
||||||
//先删除试题的判分
|
//先删除试题的判分
|
||||||
examQuestionKeywordMapper.deleteExamQuestionScoreByQuesId(examQuestion.getQuId());
|
examQuestionKeywordMapper.deleteExamQuestionScoreByQuesId(examQuestion.getQuId());
|
||||||
if (examQuestionKeywords!=null&&examQuestionKeywords.size()>0){
|
if (examQuestionKeywords != null && examQuestionKeywords.size() > 0) {
|
||||||
//赋值
|
//赋值
|
||||||
examQuestionKeywords.replaceAll(examQuestionKeyword -> {
|
examQuestionKeywords.replaceAll(examQuestionKeyword -> {
|
||||||
examQuestionKeyword.setKeywordId(IdUtils.simpleUUID());
|
examQuestionKeyword.setKeywordId(IdUtils.simpleUUID());
|
||||||
@@ -338,9 +335,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
Set<String> usedIdSet = new HashSet<>(usedIds);
|
Set<String> usedIdSet = new HashSet<>(usedIds);
|
||||||
|
|
||||||
// 找出未被使用的题目ID
|
// 找出未被使用的题目ID
|
||||||
List<String> canDeleteIds = Arrays.stream(ids)
|
List<String> canDeleteIds = Arrays.stream(ids).filter(id -> !usedIdSet.contains(id)).collect(Collectors.toList());
|
||||||
.filter(id -> !usedIdSet.contains(id))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
if (canDeleteIds.isEmpty()) {
|
if (canDeleteIds.isEmpty()) {
|
||||||
// 全部试题都已被引用,不能删除
|
// 全部试题都已被引用,不能删除
|
||||||
return ("全部试题都已被引用,不能删除!");
|
return ("全部试题都已被引用,不能删除!");
|
||||||
@@ -363,10 +358,8 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
examQuestionMapper.deleteExamQuestionByQuIds(deleteIds);
|
examQuestionMapper.deleteExamQuestionByQuIds(deleteIds);
|
||||||
if (!allCanBeDeleted) {
|
if (!allCanBeDeleted) {
|
||||||
// 找出不能删除的ID
|
// 找出不能删除的ID
|
||||||
List<String> cannotDeleteIds = Arrays.stream(ids)
|
List<String> cannotDeleteIds = Arrays.stream(ids).filter(usedIdSet::contains).collect(Collectors.toList());
|
||||||
.filter(usedIdSet::contains)
|
List<String> quNumList = examQuestionMapper.selectQuNumBuIds(cannotDeleteIds);
|
||||||
.collect(Collectors.toList());
|
|
||||||
List<String> quNumList=examQuestionMapper.selectQuNumBuIds(cannotDeleteIds);
|
|
||||||
return ("部分试题已参与组卷无法删除: " + quNumList);
|
return ("部分试题已参与组卷无法删除: " + quNumList);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -381,21 +374,18 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteExamQuestionByQuId(String quId)
|
public int deleteExamQuestionByQuId(String quId) {
|
||||||
{
|
|
||||||
return examQuestionMapper.deleteExamQuestionByQuId(quId);
|
return examQuestionMapper.deleteExamQuestionByQuId(quId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<ExamQuestion> selectExamQuestionList(QuestionVo questionVo) {
|
public PageResult<ExamQuestion> selectExamQuestionList(QuestionVo questionVo) {
|
||||||
PageResult<ExamQuestion> examQuestionPageResult = examQuestionMapper.selectExamQuestionList(questionVo);
|
PageResult<ExamQuestion> examQuestionPageResult = examQuestionMapper.selectExamQuestionList(questionVo);
|
||||||
List<ExamQuestion> list = examQuestionPageResult.getList();
|
List<ExamQuestion> list = examQuestionPageResult.getList();
|
||||||
List<ExamKnowledgePoints> examKnowledgePoints = knowledgePointsMapper.selectKnowledgePoints();
|
List<ExamKnowledgePoints> examKnowledgePoints = knowledgePointsMapper.selectKnowledgePoints();
|
||||||
// 构造 ID → 名称映射
|
// 构造 ID → 名称映射
|
||||||
Map<Long, String> idNameMap = examKnowledgePoints.stream()
|
Map<Long, String> idNameMap = examKnowledgePoints.stream().collect(Collectors.toMap(ExamKnowledgePoints::getSpId, ExamKnowledgePoints::getSpName));
|
||||||
.collect(Collectors.toMap(ExamKnowledgePoints::getSpId, ExamKnowledgePoints::getSpName));
|
|
||||||
for (ExamQuestion examQuestion : list) {
|
for (ExamQuestion examQuestion : list) {
|
||||||
String pointIdStr = examQuestion.getPointNames();
|
String pointIdStr = examQuestion.getPointNames();
|
||||||
String chapterIdStr = examQuestion.getChapteridDictText();
|
String chapterIdStr = examQuestion.getChapteridDictText();
|
||||||
@@ -424,6 +414,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传试题至Rabbitmq
|
* 上传试题至Rabbitmq
|
||||||
|
*
|
||||||
* @param rabbitMQSendInfoVO 试题内容
|
* @param rabbitMQSendInfoVO 试题内容
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -432,7 +423,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
// 1、判断上传题目数量
|
// 1、判断上传题目数量
|
||||||
int quCount = rabbitMQSendInfoVO.getQuIds().size();
|
int quCount = rabbitMQSendInfoVO.getQuIds().size();
|
||||||
List<String> quIds = rabbitMQSendInfoVO.getQuIds();
|
List<String> quIds = rabbitMQSendInfoVO.getQuIds();
|
||||||
if (quIds!=null&&quIds.size()>0){
|
if (quIds != null && quIds.size() > 0) {
|
||||||
examQuestionMapper.setQuestionAuditByids(quIds);
|
examQuestionMapper.setQuestionAuditByids(quIds);
|
||||||
for (String quId : quIds) {
|
for (String quId : quIds) {
|
||||||
// 2、根据试题ID查找试题详情
|
// 2、根据试题ID查找试题详情
|
||||||
@@ -451,6 +442,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 拉取数据Rabbitmq
|
* 拉取数据Rabbitmq
|
||||||
|
*
|
||||||
* @param queueName 客户端ID
|
* @param queueName 客户端ID
|
||||||
* @return 试题内容
|
* @return 试题内容
|
||||||
*/
|
*/
|
||||||
@@ -465,11 +457,11 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(examQuestions!=null&&examQuestions.size()>0){
|
if (examQuestions != null && examQuestions.size() > 0) {
|
||||||
// 2、保存至数据库
|
// 2、保存至数据库
|
||||||
List<QuestionExamineDO> questionExamineDOS=new ArrayList<>();
|
List<QuestionExamineDO> questionExamineDOS = new ArrayList<>();
|
||||||
for (ExamQuestion examQuestion : examQuestions) {
|
for (ExamQuestion examQuestion : examQuestions) {
|
||||||
QuestionExamineDO questionExamineDO=new QuestionExamineDO();
|
QuestionExamineDO questionExamineDO = new QuestionExamineDO();
|
||||||
questionExamineDO.setQuId(examQuestion.getQuId());
|
questionExamineDO.setQuId(examQuestion.getQuId());
|
||||||
questionExamineDO.setSource(examQuestion.getSource());
|
questionExamineDO.setSource(examQuestion.getSource());
|
||||||
questionExamineDO.setCreateTeacher(examQuestion.getCreateTeacher());
|
questionExamineDO.setCreateTeacher(examQuestion.getCreateTeacher());
|
||||||
@@ -505,19 +497,18 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
public PageResult<ExamQuestion> selectExamQuestionListNoAudit(QuestionExaminePageReqVO questionVo) {
|
public PageResult<ExamQuestion> selectExamQuestionListNoAudit(QuestionExaminePageReqVO questionVo) {
|
||||||
PageResult<QuestionExamineDO> questionExamineDOPageResult = questionExamineMapper.selectPage(questionVo);
|
PageResult<QuestionExamineDO> questionExamineDOPageResult = questionExamineMapper.selectPage(questionVo);
|
||||||
List<QuestionExamineDO> list = questionExamineDOPageResult.getList();
|
List<QuestionExamineDO> list = questionExamineDOPageResult.getList();
|
||||||
List<ExamQuestion> examQuestionList=new ArrayList<>();
|
List<ExamQuestion> examQuestionList = new ArrayList<>();
|
||||||
|
|
||||||
List<ExamKnowledgePoints> examKnowledgePoints = knowledgePointsMapper.selectKnowledgePoints();
|
List<ExamKnowledgePoints> examKnowledgePoints = knowledgePointsMapper.selectKnowledgePoints();
|
||||||
// 构造 ID → 名称映射
|
// 构造 ID → 名称映射
|
||||||
Map<Long, String> idNameMap = examKnowledgePoints.stream()
|
Map<Long, String> idNameMap = examKnowledgePoints.stream().collect(Collectors.toMap(ExamKnowledgePoints::getSpId, ExamKnowledgePoints::getSpName));
|
||||||
.collect(Collectors.toMap(ExamKnowledgePoints::getSpId, ExamKnowledgePoints::getSpName));
|
if (list != null && list.size() > 0) {
|
||||||
if (list!=null&&list.size()>0){
|
|
||||||
for (QuestionExamineDO questionExamineDO : list) {
|
for (QuestionExamineDO questionExamineDO : list) {
|
||||||
String schoolName =questionExamineMapper.selectSchoolName(questionExamineDO.getSource());
|
String schoolName = questionExamineMapper.selectSchoolName(questionExamineDO.getSource());
|
||||||
ExamQuestion examQuestion = examQuestionMapper.selectExamQuestionByQuId(questionExamineDO.getQuId());
|
ExamQuestion examQuestion = examQuestionMapper.selectExamQuestionByQuId(questionExamineDO.getQuId());
|
||||||
String pointIdStr = examQuestion.getPointNames();
|
String pointIdStr = examQuestion.getPointNames();
|
||||||
String chapterIdStr = examQuestion.getChapteridDictText();
|
String chapterIdStr = examQuestion.getChapteridDictText();
|
||||||
if (examQuestion!=null){
|
if (examQuestion != null) {
|
||||||
try {
|
try {
|
||||||
if (pointIdStr != null) {
|
if (pointIdStr != null) {
|
||||||
Long pointId = Long.valueOf(pointIdStr);
|
Long pointId = Long.valueOf(pointIdStr);
|
||||||
@@ -547,7 +538,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PageResult<ExamQuestion> examQuestionPageResult=new PageResult<>();
|
PageResult<ExamQuestion> examQuestionPageResult = new PageResult<>();
|
||||||
examQuestionPageResult.setList(examQuestionList);
|
examQuestionPageResult.setList(examQuestionList);
|
||||||
examQuestionPageResult.setTotal((long) examQuestionList.size());
|
examQuestionPageResult.setTotal((long) examQuestionList.size());
|
||||||
|
|
||||||
@@ -560,7 +551,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
tenantDto.setOffset(tenantDto.getOffset());
|
tenantDto.setOffset(tenantDto.getOffset());
|
||||||
List<TenantVo> schoolName = examQuestionMapper.getSchoolName(tenantDto);
|
List<TenantVo> schoolName = examQuestionMapper.getSchoolName(tenantDto);
|
||||||
long total = examQuestionMapper.getSchoolNameTotal(tenantDto);
|
long total = examQuestionMapper.getSchoolNameTotal(tenantDto);
|
||||||
PageResult<TenantVo> pageResult=new PageResult<>();
|
PageResult<TenantVo> pageResult = new PageResult<>();
|
||||||
pageResult.setList(schoolName);
|
pageResult.setList(schoolName);
|
||||||
pageResult.setTotal(total);
|
pageResult.setTotal(total);
|
||||||
return pageResult;
|
return pageResult;
|
||||||
@@ -569,8 +560,8 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
@Override
|
@Override
|
||||||
public int auditQueByIds(List<String> quIds) {
|
public int auditQueByIds(List<String> quIds) {
|
||||||
|
|
||||||
examQuestionMapper.updateExamQuestionByIds(SecurityFrameworkUtils.getLoginUserNickname(),quIds);
|
examQuestionMapper.updateExamQuestionByIds(SecurityFrameworkUtils.getLoginUserNickname(), quIds);
|
||||||
return examQuestionMapper.auditQueByIds(quIds,SecurityFrameworkUtils.getLoginUserNickname());
|
return examQuestionMapper.auditQueByIds(quIds, SecurityFrameworkUtils.getLoginUserNickname());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -584,7 +575,6 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean getExamQuestionToRabbitMQInsertData(String queueName) {
|
public boolean getExamQuestionToRabbitMQInsertData(String queueName) {
|
||||||
// 最先判断类型
|
// 最先判断类型
|
||||||
// TODO 1、拉取数据,保存至数据库 2、回调服务器是否拉取成功(中心服务器)
|
// TODO 1、拉取数据,保存至数据库 2、回调服务器是否拉取成功(中心服务器)
|
||||||
@@ -595,19 +585,21 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(examQuestions!=null&&examQuestions.size()>0){
|
if (examQuestions != null && examQuestions.size() > 0) {
|
||||||
for (ExamQuestion examQuestion : examQuestions) {
|
for (ExamQuestion examQuestion : examQuestions) {
|
||||||
|
|
||||||
ExamQuestion question= examQuestionMapper.selectExamQuestionCountByQuId(examQuestion.getQuBankId());
|
ExamQuestion question = examQuestionMapper.selectExamQuestionCountByQuId(examQuestion.getQuBankId());
|
||||||
if (question==null){
|
if (question == null) {
|
||||||
//如果没有,就是新增
|
//如果没有,就是新增
|
||||||
String quId = IdUtils.simpleUUID();
|
String quId = IdUtils.simpleUUID();
|
||||||
examQuestion.setQuId(quId);
|
examQuestion.setQuId(quId);
|
||||||
Long loginTenantId = SecurityFrameworkUtils.getLoginTenantId();
|
Long loginTenantId = SecurityFrameworkUtils.getLoginTenantId();
|
||||||
int count= examQuestionMapper.selectCountQu();
|
int count = examQuestionMapper.selectCountQu();
|
||||||
|
// 读取系统创建试题位数设置
|
||||||
|
String number = configApi.getConfigValueByKey("qu_number");
|
||||||
// 格式化为8位,不足前面补0
|
// 格式化为8位,不足前面补0
|
||||||
String formattedNumber = String.format("%08d", ++count);
|
String formattedNumber = String.format("%0" + number + "d", ++count);
|
||||||
String quNum =loginTenantId +"-"+formattedNumber;
|
String quNum = loginTenantId + "-" + formattedNumber;
|
||||||
examQuestion.setQuNum(quNum);
|
examQuestion.setQuNum(quNum);
|
||||||
|
|
||||||
//新增
|
//新增
|
||||||
@@ -616,7 +608,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
ExamQuestionScore questionScores = examQuestion.getQuestionScores();
|
ExamQuestionScore questionScores = examQuestion.getQuestionScores();
|
||||||
List<ExamQuestionKeyword> questionKeywords = examQuestion.getQuestionKeywords();
|
List<ExamQuestionKeyword> questionKeywords = examQuestion.getQuestionKeywords();
|
||||||
|
|
||||||
if (answerList!=null&&answerList.size()>0){
|
if (answerList != null && answerList.size() > 0) {
|
||||||
answerList.replaceAll(answer -> {
|
answerList.replaceAll(answer -> {
|
||||||
answer.setAnswerId(IdUtils.simpleUUID());
|
answer.setAnswerId(IdUtils.simpleUUID());
|
||||||
answer.setQuId(quId);
|
answer.setQuId(quId);
|
||||||
@@ -626,7 +618,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
examQuestionAnswerMapper.insertExamQuestionAnswerList(answerList);
|
examQuestionAnswerMapper.insertExamQuestionAnswerList(answerList);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileUploads!=null&&fileUploads.size()>0){
|
if (fileUploads != null && fileUploads.size() > 0) {
|
||||||
fileUploads.replaceAll(fileUpload -> {
|
fileUploads.replaceAll(fileUpload -> {
|
||||||
// 设置 fileId 和 quId
|
// 设置 fileId 和 quId
|
||||||
fileUpload.setFileId(IdUtils.simpleUUID());
|
fileUpload.setFileId(IdUtils.simpleUUID());
|
||||||
@@ -638,12 +630,12 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (questionScores!=null){
|
if (questionScores != null) {
|
||||||
questionScores.setScoreId(IdUtils.simpleUUID());
|
questionScores.setScoreId(IdUtils.simpleUUID());
|
||||||
questionScores.setQuId(quId);
|
questionScores.setQuId(quId);
|
||||||
examQuestionScoreMapper.insertExamQuestionScore(questionScores);
|
examQuestionScoreMapper.insertExamQuestionScore(questionScores);
|
||||||
}
|
}
|
||||||
if (questionKeywords!=null&&questionKeywords.size()>0){
|
if (questionKeywords != null && questionKeywords.size() > 0) {
|
||||||
questionKeywords.replaceAll(examQuestionKeyword -> {
|
questionKeywords.replaceAll(examQuestionKeyword -> {
|
||||||
examQuestionKeyword.setKeywordId(IdUtils.simpleUUID());
|
examQuestionKeyword.setKeywordId(IdUtils.simpleUUID());
|
||||||
examQuestionKeyword.setQuId(quId);
|
examQuestionKeyword.setQuId(quId);
|
||||||
@@ -654,7 +646,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
|
|
||||||
}
|
}
|
||||||
//有就是覆盖
|
//有就是覆盖
|
||||||
else{
|
else {
|
||||||
examQuestion.setQuId(question.getQuId());
|
examQuestion.setQuId(question.getQuId());
|
||||||
examQuestion.setQuNum(question.getQuNum());
|
examQuestion.setQuNum(question.getQuNum());
|
||||||
String quId = question.getQuId();
|
String quId = question.getQuId();
|
||||||
@@ -670,7 +662,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
ExamQuestionScore questionScores = examQuestion.getQuestionScores();
|
ExamQuestionScore questionScores = examQuestion.getQuestionScores();
|
||||||
List<ExamQuestionKeyword> questionKeywords = examQuestion.getQuestionKeywords();
|
List<ExamQuestionKeyword> questionKeywords = examQuestion.getQuestionKeywords();
|
||||||
|
|
||||||
if (answerList!=null&&answerList.size()>0){
|
if (answerList != null && answerList.size() > 0) {
|
||||||
answerList.replaceAll(answer -> {
|
answerList.replaceAll(answer -> {
|
||||||
answer.setAnswerId(IdUtils.simpleUUID());
|
answer.setAnswerId(IdUtils.simpleUUID());
|
||||||
answer.setQuId(quId);
|
answer.setQuId(quId);
|
||||||
@@ -680,7 +672,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
examQuestionAnswerMapper.insertExamQuestionAnswerList(answerList);
|
examQuestionAnswerMapper.insertExamQuestionAnswerList(answerList);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileUploads!=null&&fileUploads.size()>0){
|
if (fileUploads != null && fileUploads.size() > 0) {
|
||||||
fileUploads.replaceAll(fileUpload -> {
|
fileUploads.replaceAll(fileUpload -> {
|
||||||
// 设置 fileId 和 quId
|
// 设置 fileId 和 quId
|
||||||
fileUpload.setFileId(IdUtils.simpleUUID());
|
fileUpload.setFileId(IdUtils.simpleUUID());
|
||||||
@@ -692,12 +684,12 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (questionScores!=null){
|
if (questionScores != null) {
|
||||||
questionScores.setScoreId(IdUtils.simpleUUID());
|
questionScores.setScoreId(IdUtils.simpleUUID());
|
||||||
questionScores.setQuId(quId);
|
questionScores.setQuId(quId);
|
||||||
examQuestionScoreMapper.insertExamQuestionScore(questionScores);
|
examQuestionScoreMapper.insertExamQuestionScore(questionScores);
|
||||||
}
|
}
|
||||||
if (questionKeywords!=null&&questionKeywords.size()>0){
|
if (questionKeywords != null && questionKeywords.size() > 0) {
|
||||||
questionKeywords.replaceAll(examQuestionKeyword -> {
|
questionKeywords.replaceAll(examQuestionKeyword -> {
|
||||||
examQuestionKeyword.setKeywordId(IdUtils.simpleUUID());
|
examQuestionKeyword.setKeywordId(IdUtils.simpleUUID());
|
||||||
examQuestionKeyword.setQuId(quId);
|
examQuestionKeyword.setQuId(quId);
|
||||||
@@ -720,7 +712,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
// 1、判断上传题目数量
|
// 1、判断上传题目数量
|
||||||
int quCount = rabbitMQSendInfoVO.getQuIds().size();
|
int quCount = rabbitMQSendInfoVO.getQuIds().size();
|
||||||
List<String> quIds = rabbitMQSendInfoVO.getQuIds();
|
List<String> quIds = rabbitMQSendInfoVO.getQuIds();
|
||||||
if (quIds!=null&&quIds.size()>0){
|
if (quIds != null && quIds.size() > 0) {
|
||||||
for (String quId : quIds) {
|
for (String quId : quIds) {
|
||||||
QuestionExamineDO questionExamineDO = questionExamineMapper.selectById(quId);
|
QuestionExamineDO questionExamineDO = questionExamineMapper.selectById(quId);
|
||||||
|
|
||||||
@@ -730,24 +722,24 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
//查找试题答案
|
//查找试题答案
|
||||||
List<ExamQuestionAnswer> examQuestionAnswers = examQuestionAnswerMapper.selectExamQuestionAnswerByQuId(quId);
|
List<ExamQuestionAnswer> examQuestionAnswers = examQuestionAnswerMapper.selectExamQuestionAnswerByQuId(quId);
|
||||||
//查找试题文件
|
//查找试题文件
|
||||||
List<SysFileUpload> sysFileUploads =sysFileMapper.selectSysFileByQuid(quId);
|
List<SysFileUpload> sysFileUploads = sysFileMapper.selectSysFileByQuid(quId);
|
||||||
//查找试题判分
|
//查找试题判分
|
||||||
ExamQuestionScore examQuestionScore =examQuestionScoreMapper.selectExamQuestionScoreByQuId(quId);
|
ExamQuestionScore examQuestionScore = examQuestionScoreMapper.selectExamQuestionScoreByQuId(quId);
|
||||||
//获取试题关键字
|
//获取试题关键字
|
||||||
List<ExamQuestionKeyword> examQuestionKeywords = examQuestionKeywordMapper.selectExamQuestionKeywordByQuId(quId);
|
List<ExamQuestionKeyword> examQuestionKeywords = examQuestionKeywordMapper.selectExamQuestionKeywordByQuId(quId);
|
||||||
|
|
||||||
|
|
||||||
if (examQuestion_obj!=null){
|
if (examQuestion_obj != null) {
|
||||||
if (examQuestionAnswers!=null&&examQuestionAnswers.size()>0){
|
if (examQuestionAnswers != null && examQuestionAnswers.size() > 0) {
|
||||||
examQuestion_obj.setAnswerList(examQuestionAnswers);
|
examQuestion_obj.setAnswerList(examQuestionAnswers);
|
||||||
}
|
}
|
||||||
if (sysFileUploads!=null&&sysFileUploads.size()>0){
|
if (sysFileUploads != null && sysFileUploads.size() > 0) {
|
||||||
examQuestion_obj.setFileUploads(sysFileUploads);
|
examQuestion_obj.setFileUploads(sysFileUploads);
|
||||||
}
|
}
|
||||||
if (examQuestionScore!=null){
|
if (examQuestionScore != null) {
|
||||||
examQuestion_obj.setQuestionScores(examQuestionScore);
|
examQuestion_obj.setQuestionScores(examQuestionScore);
|
||||||
}
|
}
|
||||||
if (examQuestionKeywords!=null&&examQuestionKeywords.size()>0){
|
if (examQuestionKeywords != null && examQuestionKeywords.size() > 0) {
|
||||||
examQuestion_obj.setQuestionKeywords(examQuestionKeywords);
|
examQuestion_obj.setQuestionKeywords(examQuestionKeywords);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -772,8 +764,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 2. 遍历,逐个创建 or 更新
|
// 2. 遍历,逐个创建 or 更新
|
||||||
QueImportRespVO respVO = QueImportRespVO.builder().createUsernames(new ArrayList<>())
|
QueImportRespVO respVO = QueImportRespVO.builder().createUsernames(new ArrayList<>()).updateUsernames(new ArrayList<>()).failureUsernames(new LinkedHashMap<>()).build();
|
||||||
.updateUsernames(new ArrayList<>()).failureUsernames(new LinkedHashMap<>()).build();
|
|
||||||
|
|
||||||
|
|
||||||
list.forEach(importUser -> {
|
list.forEach(importUser -> {
|
||||||
@@ -781,11 +772,11 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
// 校验,判断是否有不符合的原因
|
// 校验,判断是否有不符合的原因
|
||||||
try {
|
try {
|
||||||
//校验 是否有 专业课程题型
|
//校验 是否有 专业课程题型
|
||||||
validateQueForCreateOrUpdate(importUser.getSpecialtyName(), importUser.getCourseName(),importUser.getSubjectName());
|
validateQueForCreateOrUpdate(importUser.getSpecialtyName(), importUser.getCourseName(), importUser.getSubjectName());
|
||||||
//检验是否有章节 知识点
|
//检验是否有章节 知识点
|
||||||
validatePointsForCreateOrUpdate(importUser.getSpecialtyName(),importUser.getChapteridDictText(),importUser.getPointNames(),importUser);
|
validatePointsForCreateOrUpdate(importUser.getSpecialtyName(), importUser.getChapteridDictText(), importUser.getPointNames(), importUser);
|
||||||
//校验 选项
|
//校验 选项
|
||||||
validateChoice(importUser.getA(),importUser.getB(),importUser.getC(),importUser.getD(),importUser.getAnswer());
|
validateChoice(importUser.getA(), importUser.getB(), importUser.getC(), importUser.getD(), importUser.getAnswer());
|
||||||
|
|
||||||
|
|
||||||
} catch (ServiceException ex) {
|
} catch (ServiceException ex) {
|
||||||
@@ -793,18 +784,20 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 2.2.1 判断如果不存在,在进行插入
|
// 2.2.1 判断如果不存在,在进行插入
|
||||||
ExamQuestion examQuestionSelect = examQuestionMapper.selectByTypes(importUser.getSpecialtyName(),importUser.getCourseName(),importUser.getSubjectName(),importUser.getContent());
|
ExamQuestion examQuestionSelect = examQuestionMapper.selectByTypes(importUser.getSpecialtyName(), importUser.getCourseName(), importUser.getSubjectName(), importUser.getContent());
|
||||||
if (examQuestionSelect==null){
|
if (examQuestionSelect == null) {
|
||||||
if ("选择题".equals(importUser.getSubjectName())){
|
if ("选择题".equals(importUser.getSubjectName())) {
|
||||||
String quId = IdUtils.simpleUUID();
|
String quId = IdUtils.simpleUUID();
|
||||||
ExamQuestion examQuestion = new ExamQuestion();
|
ExamQuestion examQuestion = new ExamQuestion();
|
||||||
|
|
||||||
Long loginTenantId = SecurityFrameworkUtils.getLoginTenantId();
|
Long loginTenantId = SecurityFrameworkUtils.getLoginTenantId();
|
||||||
int count= examQuestionMapper.selectCountQu();
|
int count = examQuestionMapper.selectCountQu();
|
||||||
|
|
||||||
|
// 读取系统创建试题位数设置
|
||||||
|
String number = configApi.getConfigValueByKey("qu_number");
|
||||||
// 格式化为8位,不足前面补0
|
// 格式化为8位,不足前面补0
|
||||||
String formattedNumber = String.format("%08d", ++count);
|
String formattedNumber = String.format("%0" + number + "d", ++count);
|
||||||
String quNum =loginTenantId +"-"+formattedNumber;
|
String quNum = loginTenantId + "-" + formattedNumber;
|
||||||
examQuestion.setQuNum(quNum);
|
examQuestion.setQuNum(quNum);
|
||||||
|
|
||||||
examQuestion.setChapteridDictText(importUser.getChapteridDictText());
|
examQuestion.setChapteridDictText(importUser.getChapteridDictText());
|
||||||
@@ -831,8 +824,8 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
if (!StringUtils.isBlank(importUser.getD())) {
|
if (!StringUtils.isBlank(importUser.getD())) {
|
||||||
validAnswerMap.put("D", importUser.getD());
|
validAnswerMap.put("D", importUser.getD());
|
||||||
}
|
}
|
||||||
List<ExamQuestionAnswer> examQuestionAnswerList=new ArrayList<>();
|
List<ExamQuestionAnswer> examQuestionAnswerList = new ArrayList<>();
|
||||||
int i=1;
|
int i = 1;
|
||||||
for (Map.Entry<String, String> entry : validAnswerMap.entrySet()) {
|
for (Map.Entry<String, String> entry : validAnswerMap.entrySet()) {
|
||||||
String option = entry.getKey(); // A, B, C, D
|
String option = entry.getKey(); // A, B, C, D
|
||||||
String content = entry.getValue(); // 实际内容
|
String content = entry.getValue(); // 实际内容
|
||||||
@@ -861,11 +854,10 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
respVO.getCreateUsernames().add(importUser.getContent());
|
respVO.getCreateUsernames().add(importUser.getContent());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if ("选择题".equals(importUser.getSubjectName())){
|
if ("选择题".equals(importUser.getSubjectName())) {
|
||||||
|
|
||||||
String quId=examQuestionSelect.getQuId();
|
String quId = examQuestionSelect.getQuId();
|
||||||
ExamQuestion examQuestion = new ExamQuestion();
|
ExamQuestion examQuestion = new ExamQuestion();
|
||||||
examQuestion.setChapteridDictText(importUser.getChapteridDictText());
|
examQuestion.setChapteridDictText(importUser.getChapteridDictText());
|
||||||
examQuestion.setSpecialtyName(importUser.getSpecialtyName());
|
examQuestion.setSpecialtyName(importUser.getSpecialtyName());
|
||||||
@@ -890,8 +882,8 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
if (!StringUtils.isBlank(importUser.getD())) {
|
if (!StringUtils.isBlank(importUser.getD())) {
|
||||||
validAnswerMap.put("D", importUser.getD());
|
validAnswerMap.put("D", importUser.getD());
|
||||||
}
|
}
|
||||||
List<ExamQuestionAnswer> examQuestionAnswerList=new ArrayList<>();
|
List<ExamQuestionAnswer> examQuestionAnswerList = new ArrayList<>();
|
||||||
int i=1;
|
int i = 1;
|
||||||
for (Map.Entry<String, String> entry : validAnswerMap.entrySet()) {
|
for (Map.Entry<String, String> entry : validAnswerMap.entrySet()) {
|
||||||
String option = entry.getKey(); // A, B, C, D
|
String option = entry.getKey(); // A, B, C, D
|
||||||
String content = entry.getValue(); // 实际内容
|
String content = entry.getValue(); // 实际内容
|
||||||
@@ -922,13 +914,12 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return respVO;
|
return respVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean changeStatus(String quId, String status) {
|
public boolean changeStatus(String quId, String status) {
|
||||||
return examQuestionMapper.changeStatus(quId,status);
|
return examQuestionMapper.changeStatus(quId, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -937,8 +928,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
List<ExamQuestion> list = examQuestionPageResult.getList();
|
List<ExamQuestion> list = examQuestionPageResult.getList();
|
||||||
List<ExamKnowledgePoints> examKnowledgePoints = knowledgePointsMapper.selectKnowledgePoints();
|
List<ExamKnowledgePoints> examKnowledgePoints = knowledgePointsMapper.selectKnowledgePoints();
|
||||||
// 构造 ID → 名称映射
|
// 构造 ID → 名称映射
|
||||||
Map<Long, String> idNameMap = examKnowledgePoints.stream()
|
Map<Long, String> idNameMap = examKnowledgePoints.stream().collect(Collectors.toMap(ExamKnowledgePoints::getSpId, ExamKnowledgePoints::getSpName));
|
||||||
.collect(Collectors.toMap(ExamKnowledgePoints::getSpId, ExamKnowledgePoints::getSpName));
|
|
||||||
|
|
||||||
if (list != null && !list.isEmpty()) {
|
if (list != null && !list.isEmpty()) {
|
||||||
for (ExamQuestion examQuestion : list) {
|
for (ExamQuestion examQuestion : list) {
|
||||||
@@ -961,7 +951,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
examQuestion.setChapteridDictTextVo(idNameMap.get(chapterId));
|
examQuestion.setChapteridDictTextVo(idNameMap.get(chapterId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
// 日志记录或跳过处理
|
// 日志记录或跳过处理
|
||||||
System.err.println("ID格式错误:" + e.getMessage());
|
System.err.println("ID格式错误:" + e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -984,9 +974,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
if (!CollectionUtils.isEmpty(examQuestionAnswers)) {
|
if (!CollectionUtils.isEmpty(examQuestionAnswers)) {
|
||||||
for (ExamQuestionAnswer examQuestionAnswer : examQuestionAnswers) {
|
for (ExamQuestionAnswer examQuestionAnswer : examQuestionAnswers) {
|
||||||
String answerId = examQuestionAnswer.getAnswerId();
|
String answerId = examQuestionAnswer.getAnswerId();
|
||||||
List<ExamMysqlKeyword> newKeywordList = mysqlKeywordMapper.selectList(
|
List<ExamMysqlKeyword> newKeywordList = mysqlKeywordMapper.selectList(new QueryWrapper<ExamMysqlKeyword>().eq("answer_id", answerId));
|
||||||
new QueryWrapper<ExamMysqlKeyword>().eq("answer_id", answerId)
|
|
||||||
);
|
|
||||||
examQuestionAnswer.setExamMysqlKeywordList(newKeywordList);
|
examQuestionAnswer.setExamMysqlKeywordList(newKeywordList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1015,22 +1003,22 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
|
|
||||||
private void validateQueForCreateOrUpdate(String specialtyName, String courseName, String subjectName) {
|
private void validateQueForCreateOrUpdate(String specialtyName, String courseName, String subjectName) {
|
||||||
// 校验专业课程题型
|
// 校验专业课程题型
|
||||||
validateSpecCourseSub(specialtyName, courseName,subjectName);
|
validateSpecCourseSub(specialtyName, courseName, subjectName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void validatePointsForCreateOrUpdate(String specialtyName,String chapteridDictText, String pointNames,QuemportExcelVO quemportExcelVO) {
|
private void validatePointsForCreateOrUpdate(String specialtyName, String chapteridDictText, String pointNames, QuemportExcelVO quemportExcelVO) {
|
||||||
validateSpecPointsSub(specialtyName,chapteridDictText,pointNames,quemportExcelVO);
|
validateSpecPointsSub(specialtyName, chapteridDictText, pointNames, quemportExcelVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void validateSpecPointsSub(String specialtyName,String chapteridDictText, String pointNames,QuemportExcelVO quemportExcelVO) {
|
void validateSpecPointsSub(String specialtyName, String chapteridDictText, String pointNames, QuemportExcelVO quemportExcelVO) {
|
||||||
|
|
||||||
ExamKnowledgePoints examKnowledgePoints= examSpecialtyMapper.selectByPointsSub(specialtyName,chapteridDictText,pointNames);
|
ExamKnowledgePoints examKnowledgePoints = examSpecialtyMapper.selectByPointsSub(specialtyName, chapteridDictText, pointNames);
|
||||||
if (examKnowledgePoints==null){
|
if (examKnowledgePoints == null) {
|
||||||
throw exception(QESESTION_TYPE_POINTS_ERROR);
|
throw exception(QESESTION_TYPE_POINTS_ERROR);
|
||||||
}else {
|
} else {
|
||||||
quemportExcelVO.setPointNames(String.valueOf(examKnowledgePoints.getSpId()));
|
quemportExcelVO.setPointNames(String.valueOf(examKnowledgePoints.getSpId()));
|
||||||
quemportExcelVO.setChapteridDictText(String.valueOf(examKnowledgePoints.getParentId()));
|
quemportExcelVO.setChapteridDictText(String.valueOf(examKnowledgePoints.getParentId()));
|
||||||
}
|
}
|
||||||
@@ -1039,8 +1027,8 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void validateSpecCourseSub(String specialtyName, String courseName, String subjectName) {
|
void validateSpecCourseSub(String specialtyName, String courseName, String subjectName) {
|
||||||
|
|
||||||
ExamSpecialty examSpecialty= examSpecialtyMapper.selectBySpecCourseSub(specialtyName,courseName,subjectName);
|
ExamSpecialty examSpecialty = examSpecialtyMapper.selectBySpecCourseSub(specialtyName, courseName, subjectName);
|
||||||
if (examSpecialty==null){
|
if (examSpecialty == null) {
|
||||||
throw exception(QESESTION_TYPE_ERROR);
|
throw exception(QESESTION_TYPE_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -202,16 +202,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="insertOrUpdateList">
|
<insert id="insertOrUpdateList">
|
||||||
|
INSERT INTO exam_question (qu_id, qu_bank_id,tname, qu_num,chapterId_dict_text, subject_name,specialty_name,
|
||||||
INSERT INTO exam_question (qu_id, qu_bank_id,tname, qu_num,chapterId_dict_text, subject_name,specialty_name, course_name, qu_level, content, audit, status, content_text, analysis, point_names, keywords, manual)
|
course_name, qu_level, content, audit, status, content_text, analysis, point_names, keywords, manual)
|
||||||
VALUES
|
VALUES
|
||||||
<foreach collection="collection" item="item" separator=",">
|
<foreach collection="collection" item="item" separator=",">
|
||||||
(#{item.quId}, #{item.quBankId},#{item.tname},#{item.quNum}, #{item.chapteridDictText}, #{item.subjectName},
|
(#{item.quId}, #{item.quBankId},#{item.tname},#{item.quNum}, #{item.chapteridDictText}, #{item.subjectName},
|
||||||
#{item.specialtyName}, #{item.courseName}, #{item.quLevel}, #{item.content}, #{item.audit}
|
#{item.specialtyName}, #{item.courseName}, #{item.quLevel}, #{item.content}, #{item.audit}
|
||||||
, #{item.status}, #{item.contentText}, #{item.analysis}, #{item.pointNames}, #{item.keywords}, #{item.manual})
|
, #{item.status}, #{item.contentText}, #{item.analysis}, #{item.pointNames}, #{item.keywords},
|
||||||
|
#{item.manual})
|
||||||
</foreach>
|
</foreach>
|
||||||
ON DUPLICATE KEY UPDATE
|
ON DUPLICATE KEY UPDATE
|
||||||
tname== VALUES(tname),
|
tname = VALUES(tname),
|
||||||
chapterId_dict_text = VALUES(chapterId_dict_text),
|
chapterId_dict_text = VALUES(chapterId_dict_text),
|
||||||
subject_name = VALUES(subject_name),
|
subject_name = VALUES(subject_name),
|
||||||
specialty_name = VALUES(specialty_name),
|
specialty_name = VALUES(specialty_name),
|
||||||
|
Reference in New Issue
Block a user