@ -2,6 +2,8 @@ package com.project.task.domain.service.impl;
import cn.hutool.core.collection.CollUtil ;
import cn.hutool.core.collection.CollUtil ;
import cn.hutool.core.date.DateUtil ;
import cn.hutool.core.date.DateUtil ;
import cn.hutool.core.util.BooleanUtil ;
import cn.hutool.core.util.EnumUtil ;
import cn.hutool.core.util.ObjectUtil ;
import cn.hutool.core.util.ObjectUtil ;
import cn.hutool.core.util.StrUtil ;
import cn.hutool.core.util.StrUtil ;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
@ -9,19 +11,27 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.base.domain.result.PageResult ;
import com.project.base.domain.result.PageResult ;
import com.project.base.domain.result.Result ;
import com.project.base.domain.result.Result ;
import com.project.base.domain.utils.PageConverter ;
import com.project.base.domain.utils.PageConverter ;
import com.project.classicpaper.domain.entity.ClassicCategoryEntity ;
import com.project.classicpaper.domain.entity.ClassicPaperSetEntity ;
import com.project.classicpaper.domain.service.ClassicCategoryBaseService ;
import com.project.classicpaper.domain.service.ClassicPaperSetBaseService ;
import com.project.ding.utils.SecurityUtils ;
import com.project.ding.utils.SecurityUtils ;
import com.project.exam.domain.entity.ExamRecordEntity ;
import com.project.exam.domain.entity.ExamRecordEntity ;
import com.project.exam.mapper.ExamRecordMapper ;
import com.project.exam.mapper.ExamRecordMapper ;
import com.project.information.domain.entity.ProductLineEntity ;
import com.project.information.domain.service.ProductLineBaseService ;
import com.project.task.domain.dto.TaskDTO ;
import com.project.task.domain.dto.TaskDTO ;
import com.project.task.domain.entity.TaskEntity ;
import com.project.task.domain.entity.TaskEntity ;
import com.project.task.domain.entity.TaskUserEntity ;
import com.project.task.domain.entity.TaskUserEntity ;
import com.project.task.domain.enums.CandidateExamResultEnum ;
import com.project.task.domain.enums.CandidateExamResultEnum ;
import com.project.task.domain.enums.CandidateTaskStatusEnum ;
import com.project.task.domain.enums.CandidateTaskStatusEnum ;
import com.project.task.domain.enums.ExamModeEnum ;
import com.project.task.domain.enums.TaskUserStatusEnum ;
import com.project.task.domain.enums.TaskUserStatusEnum ;
import com.project.task.domain.param.TaskParam ;
import com.project.task.domain.param.TaskParam ;
import com.project.task.domain.service.CandidateSearchTaskDomainService ;
import com.project.task.domain.service.CandidateSearchTaskDomainService ;
import com.project.task.mapper.TaskMapper ;
import com.project.task.mapper.TaskMapper ;
import com.project.task.mapper.TaskUserMapper ;
import com.project.task.mapper.TaskUserMapper ;
import io.vavr.control.Try ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.stereotype.Service ;
import org.springframework.stereotype.Service ;
@ -44,6 +54,15 @@ public class CandidateSearchTaskDomainServiceImpl implements CandidateSearchTask
@Autowired
@Autowired
private ExamRecordMapper examRecordMapper ;
private ExamRecordMapper examRecordMapper ;
@Autowired
private ProductLineBaseService productLineBaseService ;
@Autowired
private ClassicPaperSetBaseService classicPaperSetBaseService ;
@Autowired
private ClassicCategoryBaseService classicCategoryBaseService ;
@Override
@Override
public Result < PageResult < TaskDTO > > candidateSearch ( TaskParam param ) throws Exception {
public Result < PageResult < TaskDTO > > candidateSearch ( TaskParam param ) throws Exception {
@ -74,6 +93,11 @@ public class CandidateSearchTaskDomainServiceImpl implements CandidateSearchTask
if ( StrUtil . equals ( param . getCandidateTaskStatus ( ) , CandidateTaskStatusEnum . End . name ( ) ) ) {
if ( StrUtil . equals ( param . getCandidateTaskStatus ( ) , CandidateTaskStatusEnum . End . name ( ) ) ) {
queryWrapper . lt ( TaskEntity : : getEndTime , beginOfToday ) ;
queryWrapper . lt ( TaskEntity : : getEndTime , beginOfToday ) ;
}
}
if ( BooleanUtil . isTrue ( param . getExcludeEnd ( ) ) ) {
// 强制要求:结束时间必须 >= 今天 00:00:00
// 这样,截止时间是今天的任务会被【保留】,只有昨天及以前截止的任务会被【排除】
queryWrapper . ge ( TaskEntity : : getEndTime , beginOfToday ) ;
}
// 未考试:在有效期内,且用户状态为未参加考试
// 未考试:在有效期内,且用户状态为未参加考试
if ( StrUtil . equals ( param . getCandidateTaskStatus ( ) , CandidateTaskStatusEnum . Not_Exam . name ( ) ) ) {
if ( StrUtil . equals ( param . getCandidateTaskStatus ( ) , CandidateTaskStatusEnum . Not_Exam . name ( ) ) ) {
queryWrapper . le ( TaskEntity : : getStartTime , endOfToday ) ;
queryWrapper . le ( TaskEntity : : getStartTime , endOfToday ) ;
@ -81,7 +105,7 @@ public class CandidateSearchTaskDomainServiceImpl implements CandidateSearchTask
queryWrapper . inSql ( TaskEntity : : getId ,
queryWrapper . inSql ( TaskEntity : : getId ,
String . format ( "SELECT task_id FROM evaluator_task_user WHERE user_id = '%s' AND status = %s and deleted = 0 " , SecurityUtils . getUserId ( ) , TaskUserStatusEnum . Not_Start . getValue ( ) ) ) ;
String . format ( "SELECT task_id FROM evaluator_task_user WHERE user_id = '%s' AND status = %s and deleted = 0 " , SecurityUtils . getUserId ( ) , TaskUserStatusEnum . Not_Start . getValue ( ) ) ) ;
}
}
// 已考试:在有效期内,用户状态为已通过或未通过
// 已考试:在有效期内,用户状态为已通过或未通过(不含评分中)
if ( StrUtil . equals ( param . getCandidateTaskStatus ( ) , CandidateTaskStatusEnum . Has_Exam . name ( ) ) ) {
if ( StrUtil . equals ( param . getCandidateTaskStatus ( ) , CandidateTaskStatusEnum . Has_Exam . name ( ) ) ) {
queryWrapper . le ( TaskEntity : : getStartTime , endOfToday ) ;
queryWrapper . le ( TaskEntity : : getStartTime , endOfToday ) ;
queryWrapper . ge ( TaskEntity : : getEndTime , beginOfToday ) ;
queryWrapper . ge ( TaskEntity : : getEndTime , beginOfToday ) ;
@ -90,6 +114,14 @@ public class CandidateSearchTaskDomainServiceImpl implements CandidateSearchTask
SecurityUtils . getUserId ( ) , CollUtil . join ( List . of ( TaskUserStatusEnum . Fail . getValue ( ) , TaskUserStatusEnum . Pass . getValue ( ) )
SecurityUtils . getUserId ( ) , CollUtil . join ( List . of ( TaskUserStatusEnum . Fail . getValue ( ) , TaskUserStatusEnum . Pass . getValue ( ) )
, "," ) ) ) ;
, "," ) ) ) ;
}
}
// 评分中:在有效期内,用户状态为评分中
if ( StrUtil . equals ( param . getCandidateTaskStatus ( ) , CandidateTaskStatusEnum . Scoring . name ( ) ) ) {
queryWrapper . le ( TaskEntity : : getStartTime , endOfToday ) ;
queryWrapper . ge ( TaskEntity : : getEndTime , beginOfToday ) ;
queryWrapper . inSql ( TaskEntity : : getId ,
String . format ( "SELECT task_id FROM evaluator_task_user WHERE user_id = '%s' AND status = %s and deleted = 0 " ,
SecurityUtils . getUserId ( ) , TaskUserStatusEnum . Scoring . getValue ( ) ) ) ;
}
// 排序
// 排序
if ( Objects . nonNull ( param . getSortType ( ) ) ) {
if ( Objects . nonNull ( param . getSortType ( ) ) ) {
switch ( param . getSortType ( ) ) {
switch ( param . getSortType ( ) ) {
@ -149,6 +181,11 @@ public class CandidateSearchTaskDomainServiceImpl implements CandidateSearchTask
dto . setCandidateTaskStatus ( CandidateTaskStatusEnum . Has_Exam . name ( ) ) ;
dto . setCandidateTaskStatus ( CandidateTaskStatusEnum . Has_Exam . name ( ) ) ;
dto . setCandidateTaskStatusText ( CandidateTaskStatusEnum . Has_Exam . getValue ( ) ) ;
dto . setCandidateTaskStatusText ( CandidateTaskStatusEnum . Has_Exam . getValue ( ) ) ;
}
}
if ( TaskUserStatusEnum . Scoring . getValue ( ) . equals ( taskUserEntity . getStatus ( ) ) ) {
dto . setCandidateTaskStatus ( CandidateTaskStatusEnum . Scoring . name ( ) ) ;
dto . setCandidateTaskStatusText ( CandidateTaskStatusEnum . Scoring . getValue ( ) ) ;
}
}
}
if ( TaskUserStatusEnum . Pass . getValue ( ) . equals ( taskUserEntity . getStatus ( ) ) ) {
if ( TaskUserStatusEnum . Pass . getValue ( ) . equals ( taskUserEntity . getStatus ( ) ) ) {
dto . setExamResult ( CandidateExamResultEnum . Pass . name ( ) ) ;
dto . setExamResult ( CandidateExamResultEnum . Pass . name ( ) ) ;
@ -158,6 +195,10 @@ public class CandidateSearchTaskDomainServiceImpl implements CandidateSearchTask
dto . setExamResult ( CandidateExamResultEnum . Fail . name ( ) ) ;
dto . setExamResult ( CandidateExamResultEnum . Fail . name ( ) ) ;
dto . setExamResultText ( CandidateExamResultEnum . Fail . getValue ( ) ) ;
dto . setExamResultText ( CandidateExamResultEnum . Fail . getValue ( ) ) ;
}
}
if ( TaskUserStatusEnum . Scoring . getValue ( ) . equals ( taskUserEntity . getStatus ( ) ) ) {
dto . setExamResult ( "Scoring" ) ;
dto . setExamResultText ( "评分中" ) ;
}
dto . setTaskUserStatus ( TaskUserStatusEnum . getNameByValue ( taskUserEntity . getStatus ( ) ) ) ;
dto . setTaskUserStatus ( TaskUserStatusEnum . getNameByValue ( taskUserEntity . getStatus ( ) ) ) ;
dto . setLastRecordId ( taskUserEntity . getLastRecordId ( ) ) ;
dto . setLastRecordId ( taskUserEntity . getLastRecordId ( ) ) ;
if ( Objects . nonNull ( taskUserEntity . getLastRecordId ( ) ) ) {
if ( Objects . nonNull ( taskUserEntity . getLastRecordId ( ) ) ) {
@ -168,6 +209,23 @@ public class CandidateSearchTaskDomainServiceImpl implements CandidateSearchTask
dto . setLastRecordScoreStr ( lastRecordScoreStr ) ;
dto . setLastRecordScoreStr ( lastRecordScoreStr ) ;
}
}
dto . setTotalScore ( ( int ) Math . floor ( entity . getTotalScore ( ) ) ) ;
dto . setTotalScore ( ( int ) Math . floor ( entity . getTotalScore ( ) ) ) ;
// 题目类型
dto . setExamModeTag ( Try . of ( ( ) - > EnumUtil . getBy ( ExamModeEnum : : getValue , dto . getExamMode ( ) ) )
. getOrElse ( ExamModeEnum . GENERATIVE )
. getDesc ( ) ) ;
if ( ExamModeEnum . GENERATIVE . getValue ( ) . equals ( dto . getExamMode ( ) ) ) {
// 生成式
ProductLineEntity byId = productLineBaseService . getById ( dto . getSubLineId ( ) ) ;
dto . setClassificationTag ( String . format ( "%s - %s" , byId . getParentName ( ) , byId . getName ( ) ) ) ;
} else {
// 经典
ClassicPaperSetEntity byId = classicPaperSetBaseService . getById ( dto . getClassicPaperSetId ( ) ) ;
ClassicCategoryEntity classicCategoryBaseServiceById = classicCategoryBaseService . getById ( byId . getClassicCategoryId ( ) ) ;
ClassicCategoryEntity classicCategoryBaseServiceByParentId = classicCategoryBaseService . getById ( classicCategoryBaseServiceById . getParentId ( ) ) ;
dto . setClassificationTag ( String . format ( "%s - %s" , classicCategoryBaseServiceByParentId . getName ( ) , byId . getName ( ) ) ) ;
}
return dto ;
return dto ;
}
}
}
}