This commit is contained in:
Vinjor 2025-02-07 18:17:05 +08:00
parent 8a11a4767a
commit 8d2ac0c412
20 changed files with 147 additions and 36 deletions

View File

@ -31,8 +31,8 @@ public class DriveSchoolAddressController {
**/ **/
@GetMapping("/getList") @GetMapping("/getList")
@Operation(summary = "查满足条件的所有地址") @Operation(summary = "查满足条件的所有地址")
public CommonResult<?> getList(Integer type) { public CommonResult<?> getList(Integer type,String subject) {
return success(addressService.getList(type)); return success(addressService.getList(type,subject));
} }

View File

@ -36,6 +36,10 @@ public class DriveSchoolAddress extends TenantBaseDO {
* 详细地址 * 详细地址
*/ */
private String address; private String address;
/**
* 适用科目多选1,2,3,4多个英文逗号隔开
*/
private String subjects;
/** /**
* 排序 * 排序
*/ */

View File

@ -54,7 +54,7 @@ public interface DlDriveSchoolStudentService extends IService<DlDriveSchoolStude
* @param userId 用户ID * @param userId 用户ID
* @return cn.iocoder.yudao.module.base.entity.DlDriveSchoolStudent * @return cn.iocoder.yudao.module.base.entity.DlDriveSchoolStudent
**/ **/
DlDriveSchoolStudent getStudentByUserId(Integer userId); DlDriveSchoolStudent getStudentByUserId(Long userId);
/** /**
* 分页查询学生列表 * 分页查询学生列表

View File

@ -19,5 +19,5 @@ public interface DriveSchoolAddressService extends IService<DriveSchoolAddress>
* @param type 地点类型0-训练|1-考试 * @param type 地点类型0-训练|1-考试
* @return java.util.List<cn.iocoder.yudao.module.base.entity.DriveSchoolAddress> * @return java.util.List<cn.iocoder.yudao.module.base.entity.DriveSchoolAddress>
**/ **/
List<DriveSchoolAddress> getList(Integer type); List<DriveSchoolAddress> getList(Integer type,String subject);
} }

View File

@ -68,7 +68,7 @@ public class DlDriveSchoolStudentServiceImpl extends ServiceImpl<DlDriveSchoolSt
* @date 22:17 2025/1/20 * @date 22:17 2025/1/20
**/ **/
@Override @Override
public DlDriveSchoolStudent getStudentByUserId(Integer userId) { public DlDriveSchoolStudent getStudentByUserId(Long userId) {
LambdaQueryWrapper<DlDriveSchoolStudent> queryWrapper = new LambdaQueryWrapper<DlDriveSchoolStudent>() LambdaQueryWrapper<DlDriveSchoolStudent> queryWrapper = new LambdaQueryWrapper<DlDriveSchoolStudent>()
.eq(DlDriveSchoolStudent::getUserId,userId) .eq(DlDriveSchoolStudent::getUserId,userId)
.orderByDesc(BaseDO::getCreateTime); .orderByDesc(BaseDO::getCreateTime);

View File

@ -27,11 +27,14 @@ public class DriveSchoolAddressServiceImpl extends ServiceImpl<DriveSchoolAddres
* @date 18:39 2025/2/6 * @date 18:39 2025/2/6
**/ **/
@Override @Override
public List<DriveSchoolAddress> getList(Integer type) { public List<DriveSchoolAddress> getList(Integer type,String subject) {
LambdaQueryWrapper<DriveSchoolAddress> queryWrapper = new LambdaQueryWrapper<DriveSchoolAddress>(); LambdaQueryWrapper<DriveSchoolAddress> queryWrapper = new LambdaQueryWrapper<DriveSchoolAddress>();
if(null!=type){ if(null!=type){
queryWrapper.eq(DriveSchoolAddress::getType,type); queryWrapper.eq(DriveSchoolAddress::getType,type);
} }
if(null!=subject){
queryWrapper.like(DriveSchoolAddress::getSubjects,subject);
}
queryWrapper.orderByAsc(DriveSchoolAddress::getSort); queryWrapper.orderByAsc(DriveSchoolAddress::getSort);
return this.list(queryWrapper); return this.list(queryWrapper);
} }

View File

@ -40,5 +40,5 @@ public interface ProcessService extends IService<Process> {
* @param coachId 教练id * @param coachId 教练id
* @return cn.iocoder.yudao.module.course.entity.Process * @return cn.iocoder.yudao.module.course.entity.Process
**/ **/
Process getByStudentAndCourse(Integer userId,String courseId,Integer subject,Long coachId); Process getByStudentAndCourse(Long userId,String courseId,Integer subject,Long coachId,String examStatus);
} }

View File

@ -84,14 +84,17 @@ public class ProcessServiceImpl extends ServiceImpl<ProcessMapper, Process> impl
* @date 18:39 2025/1/16 * @date 18:39 2025/1/16
**/ **/
@Override @Override
public Process getByStudentAndCourse(Integer userId, String courseId, Integer subject, Long coachId) { public Process getByStudentAndCourse(Long userId, String courseId, Integer subject, Long coachId,String examStatus) {
LambdaQueryWrapper<Process> queryWrapper = new LambdaQueryWrapper<Process>() LambdaQueryWrapper<Process> queryWrapper = new LambdaQueryWrapper<Process>()
.eq(Process::getUserId,userId) .eq(Process::getUserId,userId)
.eq(Process::getCoachId,coachId) .eq(Process::getCoachId,coachId)
.eq(Process::getCourseId,courseId) .eq(Process::getCourseId,courseId)
.eq(Process::getSubject,subject) .eq(Process::getSubject,subject)
.eq(Process::getStatus,"1") .eq(Process::getStatus,"1");
.orderByDesc(BaseDO::getCreateTime); if(null!=examStatus){
queryWrapper.eq(Process::getExamStatus,examStatus);
}
queryWrapper.orderByDesc(BaseDO::getCreateTime);
List<Process> processList = this.list(queryWrapper); List<Process> processList = this.list(queryWrapper);
return processList.isEmpty()?null:processList.get(0); return processList.isEmpty()?null:processList.get(0);
} }

View File

@ -67,18 +67,6 @@ public class ExamBatch extends TenantBaseDO {
*/ */
private String addr; private String addr;
/**
* 用户学员ID
*/
private Long userId;
/**
* 用户学员姓名
*/
private String userName;
/**
* 学员手机号
*/
private String userMobile;
/** /**
* 通过率 * 通过率
*/ */

View File

@ -40,6 +40,10 @@ public class ExamBatchItem extends TenantBaseDO {
* 考试分数 * 考试分数
*/ */
private Double fraction; private Double fraction;
/**
* 是否通过
*/
private Boolean ifPass;
/** /**
* 图片多个英文逗号隔开 * 图片多个英文逗号隔开
*/ */

View File

@ -1,20 +1,30 @@
package cn.iocoder.yudao.module.exam.service.impl; package cn.iocoder.yudao.module.exam.service.impl;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.course.entity.Process;
import cn.iocoder.yudao.module.course.mapper.ProcessMapper; import cn.iocoder.yudao.module.course.mapper.ProcessMapper;
import cn.iocoder.yudao.module.course.service.ProcessService;
import cn.iocoder.yudao.module.exam.entity.ExamBatch;
import cn.iocoder.yudao.module.exam.entity.ExamBatchItem; import cn.iocoder.yudao.module.exam.entity.ExamBatchItem;
import cn.iocoder.yudao.module.exam.mapper.ExamBatchItemMapper; import cn.iocoder.yudao.module.exam.mapper.ExamBatchItemMapper;
import cn.iocoder.yudao.module.exam.service.ExamBatchItemService; import cn.iocoder.yudao.module.exam.service.ExamBatchItemService;
import cn.iocoder.yudao.module.exam.service.ExamBatchService;
import cn.iocoder.yudao.module.exam.vo.ExamBatchItemVO; import cn.iocoder.yudao.module.exam.vo.ExamBatchItemVO;
import cn.iocoder.yudao.module.exam.vo.ExamBatchVO; import cn.iocoder.yudao.module.exam.vo.ExamBatchVO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils; import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 考试批次明细表 Service 实现类 * 考试批次明细表 Service 实现类
@ -27,6 +37,11 @@ public class ExamBatchItemServiceImpl extends ServiceImpl<ExamBatchItemMapper, E
private ExamBatchItemMapper examBatchItemMapper; private ExamBatchItemMapper examBatchItemMapper;
@Autowired @Autowired
private ProcessMapper processMapper; private ProcessMapper processMapper;
@Autowired
private ProcessService processService;
@Lazy
@Autowired
private ExamBatchService examBatchService;
/** /**
* 分页查询 * 分页查询
@ -38,6 +53,9 @@ public class ExamBatchItemServiceImpl extends ServiceImpl<ExamBatchItemMapper, E
**/ **/
@Override @Override
public IPage<ExamBatchItemVO> queryListPage(ExamBatchVO pageReqVO, Page<ExamBatchItemVO> page) { public IPage<ExamBatchItemVO> queryListPage(ExamBatchVO pageReqVO, Page<ExamBatchItemVO> page) {
//教练ID
Long userId = SecurityFrameworkUtils.getLoginUserId();
pageReqVO.setCoachId(userId);
IPage<ExamBatchItemVO> rtnList = examBatchItemMapper.queryListPage(pageReqVO, page); IPage<ExamBatchItemVO> rtnList = examBatchItemMapper.queryListPage(pageReqVO, page);
return rtnList; return rtnList;
} }
@ -62,15 +80,88 @@ public class ExamBatchItemServiceImpl extends ServiceImpl<ExamBatchItemMapper, E
* @author vinjor-M * @author vinjor-M
* @date 13:48 2025/1/21 * @date 13:48 2025/1/21
*/ */
@SneakyThrows
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void updateObj(ExamBatchItemVO examBatchVO) { public void updateObj(ExamBatchItemVO examBatchVO) {
//教练ID //教练ID
Long userId = SecurityFrameworkUtils.getLoginUserId(); Long userId = SecurityFrameworkUtils.getLoginUserId();
ExamBatchItem updateItem = new ExamBatchItem(); ExamBatchItem updateItem = this.getById(examBatchVO.getId());
BeanUtils.copyProperties(examBatchVO,updateItem); updateItem.setFraction(examBatchVO.getFraction());
updateItem.setImages(examBatchVO.getImages());
updateItem.setIfPass(examBatchVO.getIfPass());
//更新子表考试结果 //更新子表考试结果
this.updateById(updateItem); this.updateById(updateItem);
//更新学习进度表的考试状态和结果将学员下一个科目的状态置为进行中 ExamBatch examBatch = examBatchService.getById(updateItem.getBatchId());
Process process = processService.getByStudentAndCourse(updateItem.getUserId(),examBatch.getCourseId(),examBatch.getSubject(),examBatch.getCoachId(),"9");
if(null==process){
throw new Exception("未找到该学生学习进度信息,请联系管理员");
}
//考试分数
process.setExamScore(examBatchVO.getFraction());
process.setImages(examBatchVO.getImages());
process.setExamTime(examBatch.getStartTime());
//已完成
process.setStatus("2");
process.setExamStatus(examBatchVO.getIfPass()?"1":"0");
processService.updateById(process);
//更新考试批次的通过率
this.updateBatchPassRate(examBatch.getId());
if(examBatchVO.getIfPass()){
//考试通过
if(process.getSubject()<3){
//科目一二插入一条下一个科目的学习进度
Process nextProcess = new Process();
nextProcess.setCourseId(process.getCourseId());
nextProcess.setCourseName(process.getCourseName());
nextProcess.setUserId(process.getUserId());
nextProcess.setUserName(process.getUserName());
nextProcess.setUserMobile(process.getUserMobile());
nextProcess.setCoachId(process.getCoachId());
nextProcess.setCoachName(process.getCoachName());
nextProcess.setSubject(process.getSubject()+1);
nextProcess.setExamNum(process.getExamNum()+1);
nextProcess.setStatus("1");
nextProcess.setTrainTime((double) 0);
processService.save(nextProcess);
}
}else{
//考试不通过,重新插入一条本科目的学习记录
Process thisProcess = new Process();
thisProcess.setCourseId(process.getCourseId());
thisProcess.setCourseName(process.getCourseName());
thisProcess.setUserId(process.getUserId());
thisProcess.setUserName(process.getUserName());
thisProcess.setUserMobile(process.getUserMobile());
thisProcess.setCoachId(process.getCoachId());
thisProcess.setCoachName(process.getCoachName());
thisProcess.setSubject(process.getSubject());
thisProcess.setExamNum(process.getExamNum()+1);
thisProcess.setStatus("1");
thisProcess.setTrainTime(process.getTrainTime());
processService.save(thisProcess);
}
} }
/**
* 更新考试批次通过率
* @author vinjor-M
* @date 17:39 2025/2/7
* @param id 批次ID
**/
public void updateBatchPassRate(String id){
ExamBatch examBatch = examBatchService.getById(id);
LambdaQueryWrapper<ExamBatchItem> queryWrapper = new LambdaQueryWrapper<ExamBatchItem>()
.eq(ExamBatchItem::getBatchId,id);
List<ExamBatchItem> allList = this.list(queryWrapper);
if(!allList.isEmpty()){
List<ExamBatchItem> passList = allList.stream().filter(item->null!=item.getIfPass() && item.getIfPass()).collect(Collectors.toList());
if(!passList.isEmpty()){
BigDecimal result = new BigDecimal(passList.size()).divide(new BigDecimal(allList.size()), 2, RoundingMode.HALF_UP);
examBatch.setPassRate(result.doubleValue());
examBatchService.updateById(examBatch);
}
}
}
} }

View File

@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
@ -33,6 +34,7 @@ public class ExamBatchServiceImpl extends ServiceImpl<ExamBatchMapper, ExamBatch
@Autowired @Autowired
private ProcessMapper processMapper; private ProcessMapper processMapper;
@Autowired @Autowired
@Lazy
private ExamBatchItemService examBatchItemService; private ExamBatchItemService examBatchItemService;
/** /**
@ -66,8 +68,8 @@ public class ExamBatchServiceImpl extends ServiceImpl<ExamBatchMapper, ExamBatch
List<ExamBatchItem> itemList = new ArrayList<>(); List<ExamBatchItem> itemList = new ArrayList<>();
examBatchVO.getItemList().forEach(item->{ examBatchVO.getItemList().forEach(item->{
ExamBatchItem batchItem = new ExamBatchItem(); ExamBatchItem batchItem = new ExamBatchItem();
batchItem.setBatchId(examBatchVO.getId());
BeanUtils.copyProperties(item,batchItem); BeanUtils.copyProperties(item,batchItem);
batchItem.setBatchId(examBatchVO.getId());
itemList.add(batchItem); itemList.add(batchItem);
}); });
//存子表数据 //存子表数据

View File

@ -21,4 +21,12 @@ public class ExamBatchItemVO extends ExamBatchItem {
* 学生电话 * 学生电话
*/ */
private String userMobile; private String userMobile;
/**
* 考试批次编号
*/
private String batchName;
/**
* 本科目累计训练时长
*/
private Double trainTime;
} }

View File

@ -11,4 +11,8 @@ public class ExamBatchVO extends ExamBatch {
* 明细子表数据 * 明细子表数据
*/ */
private List<ExamBatchItemVO> itemList; private List<ExamBatchItemVO> itemList;
/**
* 学员姓名
*/
private String userName;
} }

View File

@ -80,7 +80,7 @@ public class ReservationCourseController {
@GetMapping("/getUserInfoAndReservation") @GetMapping("/getUserInfoAndReservation")
@Operation(summary = "根据学生userId查询学生信息及当天的预约记录") @Operation(summary = "根据学生userId查询学生信息及当天的预约记录")
@Parameter(name = "id", description = "学生userId", required = true, example = "1024") @Parameter(name = "id", description = "学生userId", required = true, example = "1024")
public CommonResult<?> getReservationCourse(@RequestParam("userId") Integer userId, public CommonResult<?> getReservationCourse(@RequestParam("userId") Long userId,
@RequestParam("courseId") String courseId, @RequestParam("courseId") String courseId,
@RequestParam("type") String type, @RequestParam("type") String type,
@RequestParam("subject") Integer subject) { @RequestParam("subject") Integer subject) {

View File

@ -32,6 +32,6 @@ public interface ReservationCourseService extends IService<ReservationCourse> {
* @param userId * @param userId
* @return java.util.Map<java.lang.String,java.lang.Object> * @return java.util.Map<java.lang.String,java.lang.Object>
**/ **/
Map<String,Object> getUserInfoAndReservation(Integer userId,String courseId,Integer subject,String type); Map<String,Object> getUserInfoAndReservation(Long userId,String courseId,Integer subject,String type);
} }

View File

@ -48,5 +48,5 @@ public interface TrainService extends IService<Train> {
* @param dayStr 日期 * @param dayStr 日期
* @return cn.iocoder.yudao.module.train.entity.Train * @return cn.iocoder.yudao.module.train.entity.Train
**/ **/
Train getUserTrainData(Integer userId,String courseId,Integer subject,String dayStr); Train getUserTrainData(Long userId,String courseId,Integer subject,String dayStr);
} }

View File

@ -66,7 +66,7 @@ public class ReservationCourseServiceImpl extends ServiceImpl<ReservationCourseM
**/ **/
@SneakyThrows @SneakyThrows
@Override @Override
public Map<String, Object> getUserInfoAndReservation(Integer userId,String courseId,Integer subject,String type) { public Map<String, Object> getUserInfoAndReservation(Long userId,String courseId,Integer subject,String type) {
Map<String, Object> rtnMap = new HashMap<>(); Map<String, Object> rtnMap = new HashMap<>();
//当前教练ID //当前教练ID
Long coachId = SecurityFrameworkUtils.getLoginUserId(); Long coachId = SecurityFrameworkUtils.getLoginUserId();
@ -86,7 +86,7 @@ public class ReservationCourseServiceImpl extends ServiceImpl<ReservationCourseM
rtnMap.put("reservation",list.get(0)); rtnMap.put("reservation",list.get(0));
} }
//查该学员该科目进度 //查该学员该科目进度
Process process = processService.getByStudentAndCourse(userId,courseId,subject,coachId); Process process = processService.getByStudentAndCourse(userId,courseId,subject,coachId,null);
if(null==process){ if(null==process){
throw new Exception("该学员未报名你的课程,请向管理员核实"); throw new Exception("该学员未报名你的课程,请向管理员核实");
} }

View File

@ -91,7 +91,7 @@ public class TrainServiceImpl extends ServiceImpl<TrainMapper, Train> implements
* @date 10:21 2025/1/17 * @date 10:21 2025/1/17
**/ **/
@Override @Override
public Train getUserTrainData(Integer userId, String courseId, Integer subject, String dayStr) { public Train getUserTrainData(Long userId, String courseId, Integer subject, String dayStr) {
LambdaQueryWrapper<Train> queryWrapper = new LambdaQueryWrapper<Train>() LambdaQueryWrapper<Train> queryWrapper = new LambdaQueryWrapper<Train>()
.eq(Train::getUserId,userId) .eq(Train::getUserId,userId)
.eq(Train::getCourseId,courseId) .eq(Train::getCourseId,courseId)

View File

@ -6,17 +6,21 @@
<select id="queryListPage" resultType="cn.iocoder.yudao.module.exam.vo.ExamBatchItemVO"> <select id="queryListPage" resultType="cn.iocoder.yudao.module.exam.vo.ExamBatchItemVO">
SELECT SELECT
dsebi.*,dseb.course_id,dseb.course_name,dss.phone AS userMobile dsebi.*,dseb.course_id,dseb.course_name,dseb.subject,dsp.user_mobile AS userMobile,dseb.batch_name AS batchName,dsp.train_time AS trainTime
FROM FROM
drive_school_exam_batch_item dsebi drive_school_exam_batch_item dsebi
LEFT JOIN drive_school_exam_batch dseb ON dsebi.batch_id = dseb.id LEFT JOIN drive_school_exam_batch dseb ON dsebi.batch_id = dseb.id
LEFT JOIN drive_school_student dss ON dsebi.user_id = dss.user_id LEFT JOIN drive_school_process dsp ON dsebi.user_id = dsp.user_id
AND dss.deleted = 0 AND dseb.course_id = dsp.course_id AND dseb.coach_id = dsp.coach_id
AND dseb.subject = dsp.subject AND dsp.deleted = 0 AND dsp.exam_status = '9'
WHERE WHERE
dseb.deleted = 0 dseb.deleted = 0
AND dseb.course_id = #{entity.courseId} AND dseb.course_id = #{entity.courseId}
AND dseb.coach_id = #{entity.coachId} AND dseb.coach_id = #{entity.coachId}
AND dseb.`subject` = #{entity.subject} AND dseb.`subject` = #{entity.subject}
<if test="entity.userName != null and entity.userName != ''">
AND dsebi.user_name LIKE CONCAT('%',#{entity.userName},'%')
</if>
AND dsebi.fraction IS NULL AND dsebi.fraction IS NULL
</select> </select>
<select id="selectByBatchId" resultType="cn.iocoder.yudao.module.exam.vo.ExamBatchItemVO"> <select id="selectByBatchId" resultType="cn.iocoder.yudao.module.exam.vo.ExamBatchItemVO">