This commit is contained in:
许允枞 2025-04-07 16:45:10 +08:00
parent edf7003f37
commit b6ea15e44b
20 changed files with 519 additions and 110 deletions

View File

@ -1,16 +1,16 @@
package cn.iocoder.yudao.module.course.controller.app;
package cn.iocoder.yudao.module.base.controller.app;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.base.entity.SchoolFeedBack;
import cn.iocoder.yudao.module.base.service.SchoolFeedbackService;
import cn.iocoder.yudao.module.course.vo.SchoolFeedBackVO;
import cn.iocoder.yudao.module.base.vo.SchoolFeedBackVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
* @Description: 评价
@ -40,7 +40,25 @@ public class AppSchoolFeedBackController {
if (request.getTenantId() == null) {
throw new RuntimeException("租户id不能为空");
}
request.setUserId(SecurityFrameworkUtils.getLoginUserId());
schoolFeedbackService.add(request);
return CommonResult.success(true);
}
/**
* 分页查询评价
*
* @param request 请求
* @param pageNo 页码
* @param pageSize 每页大小
* @return CommonResult<?>
*/
@GetMapping("/page")
@TenantIgnore
public CommonResult<?> page(SchoolFeedBackVO request,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
Page<SchoolFeedBack> page = new Page<>(pageNo, pageSize);
return CommonResult.success(schoolFeedbackService.queryPage(page, request));
}
}

View File

@ -85,8 +85,6 @@ public class SchoolCourseOrderSmallProgramController {
@GetMapping("/getCourseByLoginUser")
@PermitAll
public CommonResult<?> getCourseByLoginUser() {
// SecurityFrameworkUtils.getLoginUserId()
// TODO 写死了
//获取当前登陆人
return success(schoolCourseOrderService.getCourseByLoginUser(SecurityFrameworkUtils.getLoginUserId()));
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.base.entity;
import cn.iocoder.yudao.annotation.Excel;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import cn.iocoder.yudao.module.jx.core.page.TenantBaDO;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@ -13,7 +14,7 @@ import lombok.Data;
*/
@TableName("drive_school_feedback")
@Data
public class SchoolFeedBack extends TenantBaDO {
public class SchoolFeedBack extends TenantBaseDO {
/** 主键 */
private Long id;
/**

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.course.mapper;
package cn.iocoder.yudao.module.base.mapper;
import cn.iocoder.yudao.module.base.entity.SchoolFeedBack;
import cn.iocoder.yudao.module.base.vo.SchoolFeedBackVO;
import cn.iocoder.yudao.module.jx.domain.DriveSchoolFeedback;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -17,7 +18,7 @@ import java.util.List;
* @date 2024-04-27
*/
@Mapper
public interface SchoolFeedbackMapper extends BaseMapper<SchoolFeedBack>
public interface SchoolFeedBackMapper extends BaseMapper<SchoolFeedBack>
{
/**
* 查询反馈
@ -33,7 +34,7 @@ public interface SchoolFeedbackMapper extends BaseMapper<SchoolFeedBack>
* @param driveSchoolFeedback 反馈
* @return 反馈集合
*/
public IPage<DriveSchoolFeedback> selectDriveSchoolFeedbackList(@Param("entity") DriveSchoolFeedback driveSchoolFeedback, Page<DriveSchoolFeedback> page);
public IPage<SchoolFeedBackVO> selectDriveSchoolFeedbackList(@Param("entity") SchoolFeedBackVO driveSchoolFeedback, Page<SchoolFeedBack> page);
public List<DriveSchoolFeedback> selectDriveSchoolFeedbackListAll(@Param("entity") DriveSchoolFeedback driveSchoolFeedback);
public Integer likeOne(DriveSchoolFeedback driveSchoolFeedback);
public Integer likeTwo(DriveSchoolFeedback driveSchoolFeedback);

View File

@ -2,15 +2,11 @@ package cn.iocoder.yudao.module.base.service;
import cn.iocoder.yudao.module.base.entity.SchoolFeedBack;
import cn.iocoder.yudao.module.course.vo.SchoolFeedBackVO;
import cn.iocoder.yudao.module.jx.domain.DriveSchoolFeedback;
import cn.iocoder.yudao.module.base.vo.SchoolFeedBackVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
import java.util.Map;
/**
* 反馈Service接口
*
@ -25,4 +21,13 @@ public interface SchoolFeedbackService extends IService<SchoolFeedBack> {
* @param request 请求
*/
void add(SchoolFeedBackVO request);
/**
* 分页查询评价
*
* @param page 分页
* @param request 请求
* @return IPage
*/
IPage<SchoolFeedBackVO> queryPage(Page<SchoolFeedBack> page, SchoolFeedBackVO request);
}

View File

@ -0,0 +1,28 @@
package cn.iocoder.yudao.module.base.vo;
import cn.iocoder.yudao.module.base.entity.SchoolFeedBack;
import lombok.Data;
/**
* @Description: 评价vo
* @Author: 86187
* @Date: 2025/04/03 14:28
* @Version: 1.0
*/
@Data
public class SchoolFeedBackVO extends SchoolFeedBack {
/**
* 业务名称
*/
private String busiName;
/**
* 课程类型
*/
private String courseType;
/**
* 教练名称
*/
private String coachName;
}

View File

@ -318,7 +318,7 @@ public class ProcessServiceImpl extends ServiceImpl<ProcessMapper, Process> impl
// 修改订单信息中的是否分配教练状态
schoolCourseOrderService.update(Wrappers.lambdaUpdate(SchoolCourseOrder.class)
.eq(SchoolCourseOrder::getId, request.getOrderId())
.set(SchoolCourseOrder::getIfAssignmentCoach, SchoolBaseConstants.SCHOOL_COURSE_ORDER_IS_NOT_ASSIGN_COACH));
.set(SchoolCourseOrder::getIfAssignmentCoach, SchoolBaseConstants.SCHOOL_COURSE_ORDER_IS_ASSIGN_COACH));
}

View File

@ -169,8 +169,7 @@ public class SchoolCourseOrderServiceImpl extends ServiceImpl<SchoolCourseOrderM
List<SchoolCourseOrder> list = list(Wrappers.lambdaQuery(SchoolCourseOrder.class)
.eq(SchoolCourseOrder::getUserId, loginUserId)
.eq(SchoolCourseOrder::getIfEnd, SchoolBaseConstants.COMMON_NO)
.eq(SchoolCourseOrder::getIfAssignmentCoach, SchoolBaseConstants.SCHOOL_COURSE_ORDER_IS_ASSIGN_COACH)
.eq(SchoolCourseOrder::getDeleted, SchoolBaseConstants.COMMON_NO));
.eq(SchoolCourseOrder::getIfAssignmentCoach, SchoolBaseConstants.SCHOOL_COURSE_ORDER_IS_ASSIGN_COACH));
return BeanUtil.copyToList(list, SchoolCourseOrderVO.class);
}

View File

@ -1,39 +1,32 @@
package cn.iocoder.yudao.module.course.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.base.constant.SchoolBaseConstants;
import cn.iocoder.yudao.module.base.entity.SchoolFeedBack;
import cn.iocoder.yudao.module.base.service.SchoolFeedbackService;
import cn.iocoder.yudao.module.course.mapper.SchoolFeedbackMapper;
import cn.iocoder.yudao.module.course.vo.SchoolFeedBackVO;
import cn.iocoder.yudao.module.base.mapper.SchoolFeedBackMapper;
import cn.iocoder.yudao.module.base.vo.SchoolFeedBackVO;
import cn.iocoder.yudao.module.exam.entity.ExamBatchItem;
import cn.iocoder.yudao.module.exam.service.ExamBatchItemService;
import cn.iocoder.yudao.module.jx.domain.DriveSchoolFeedback;
import cn.iocoder.yudao.module.jx.domain.DriveSchoolInfo;
import cn.iocoder.yudao.module.jx.mapper.DriveSchoolFeedbackMapper;
import cn.iocoder.yudao.module.jx.mapper.DriveSchoolInfoMapper;
import cn.iocoder.yudao.module.jx.payment.entity.DriveSchoolPay;
import cn.iocoder.yudao.module.jx.payment.service.DriveSchoolPayService;
import cn.iocoder.yudao.module.jx.service.IDriveSchoolFeedbackService;
import cn.iocoder.yudao.module.jx.vo.DriveSchoolInfoVO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import cn.iocoder.yudao.module.exam.vo.ExamBatchItemVO;
import cn.iocoder.yudao.module.train.entity.Train;
import cn.iocoder.yudao.module.train.service.TrainService;
import cn.iocoder.yudao.module.train.vo.TrainVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* 反馈Service业务层处理
@ -43,11 +36,11 @@ import java.util.Map;
*/
@Service
@RequiredArgsConstructor
public class SchoolFeedbackServiceImpl extends ServiceImpl<SchoolFeedbackMapper, SchoolFeedBack> implements SchoolFeedbackService
{
public class SchoolFeedbackServiceImpl extends ServiceImpl<SchoolFeedBackMapper, SchoolFeedBack> implements SchoolFeedbackService {
private final TrainService trainService;
private final ExamBatchItemService examBatchItemService;
/**
* 新增评论
*
@ -72,4 +65,86 @@ public class SchoolFeedbackServiceImpl extends ServiceImpl<SchoolFeedbackMapper,
.set(ExamBatchItem::getEvaluateId, request.getId()));
}
}
/**
* 分页查询评价
*
* @param page 分页
* @param request 请求
* @return IPage
*/
@Override
public IPage<SchoolFeedBackVO> queryPage(Page<SchoolFeedBack> page, SchoolFeedBackVO request) {
// 1. 分页查询原始数据
IPage<SchoolFeedBack> pageList = this.page(page, Wrappers.lambdaQuery(SchoolFeedBack.class)
.eq(ObjectUtil.isNotEmpty(request.getUserId()), SchoolFeedBack::getUserId, request.getUserId()));
// 2. 提取训练和考试的ID集合
List<String> trainIds = pageList.getRecords().stream()
.filter(item -> SchoolBaseConstants.EVALUATE_TYPE_TRAIN.equals(item.getEvaluateType()))
.map(SchoolFeedBack::getBusiId)
.collect(Collectors.toList());
List<String> examIds = pageList.getRecords().stream()
.filter(item -> SchoolBaseConstants.EVALUATE_TYPE_EXAM.equals(item.getEvaluateType()))
.map(SchoolFeedBack::getBusiId)
.collect(Collectors.toList());
// 3. 批量查询关联数据
Map<String, TrainVO> trainMap = Optional.ofNullable(trainService.listJoinBatchByIds(trainIds))
.orElse(Collections.emptyList()) // 如果为 null返回空列表
.stream()
.collect(Collectors.toMap(
TrainVO::getId,
train -> train
));
Map<String, ExamBatchItemVO> examMap = Optional.ofNullable(examBatchItemService.listJoinBatchByIds(examIds))
.orElse(Collections.emptyList()) // 如果返回 null替换成空列表
.stream()
.collect(Collectors.toMap(
ExamBatchItemVO::getId,
exam -> exam
));
// 4. 转换为VO列表
List<SchoolFeedBackVO> voList = pageList.getRecords().stream().map(item -> {
SchoolFeedBackVO vo = BeanUtil.copyProperties(item, SchoolFeedBackVO.class);
if (SchoolBaseConstants.EVALUATE_TYPE_TRAIN.equals(item.getEvaluateType())) {
vo.setBusiName(getSubjectStr(trainMap.get(item.getBusiId()).getSubject()) + "训练");
vo.setCourseType(trainMap.get(item.getBusiId()).getCourseType());
vo.setCoachName(trainMap.get(item.getBusiId()).getCoachName());
} else if (SchoolBaseConstants.EVALUATE_TYPE_EXAM.equals(item.getEvaluateType())) {
vo.setBusiName(getSubjectStr(examMap.get(item.getBusiId()).getSubject()) + "考试");
vo.setCourseType(examMap.get(item.getBusiId()).getCourseType());
vo.setCoachName(examMap.get(item.getBusiId()).getCoachName());
}
return vo;
}).collect(Collectors.toList());
// 5. 构建返回的IPage对象
IPage<SchoolFeedBackVO> resultPage = new Page<>();
BeanUtil.copyProperties(pageList, resultPage); // 复制分页信息
resultPage.setRecords(voList); // 设置VO数据
return resultPage;
}
public String getSubjectStr(Integer subject) {
if (subject == null) {
return "";
}
switch (subject) {
case 1:
return "科目一";
case 2:
return "科目二";
case 3:
return "科目三";
case 4:
return "科目四";
default:
return "";
}
}
}

View File

@ -1,12 +0,0 @@
package cn.iocoder.yudao.module.course.vo;
import cn.iocoder.yudao.module.base.entity.SchoolFeedBack;
/**
* @Description: 评价vo
* @Author: 86187
* @Date: 2025/04/03 14:28
* @Version: 1.0
*/
public class SchoolFeedBackVO extends SchoolFeedBack {
}

View File

@ -23,11 +23,13 @@ public interface ExamBatchItemMapper extends BaseMapper<ExamBatchItem> {
IPage<ExamBatchItemVO> queryListPage(@Param("entity") ExamBatchVO pageReqVO, Page<ExamBatchItemVO> page);
List<ExamBatchItemVO> selectByBatchId(@Param("batchId")String batchId);
List<ExamBatchItemVO> selectByBatchId(@Param("batchId") String batchId);
List<ExamBatchItemVO> selectByUserIdAndCoachId(@Param("userId")Long userId,@Param("coachId")Long coachId);
List<ExamBatchItemVO> selectByUserIdAndCoachId(@Param("userId") Long userId, @Param("coachId") Long coachId);
List<ExamBatchItemVO> selectByCoachId(@Param("coachId")Long coachId,@Param("startTime")String startTime,@Param("endTime")String endTime);
List<ExamBatchItemVO> selectByCoachId(@Param("coachId") Long coachId, @Param("startTime") String startTime, @Param("endTime") String endTime);
List<ExamVO> selectExamByUserIdAndCoachId(@Param("userId")Long userId, @Param("coachId")Long coachId);
List<ExamVO> selectExamByUserIdAndCoachId(@Param("userId") Long userId, @Param("coachId") Long coachId);
List<ExamBatchItemVO> listJoinBatchByIds(@Param("examIds") List<String> examIds);
}

View File

@ -20,54 +20,68 @@ public interface ExamBatchItemService extends IService<ExamBatchItem> {
/**
* 分页查询
*
* @param pageReqVO TODO
* @param page TODO
* @author vinjor-M
* @date 15:05 2025/1/14
* @param pageReqVO TODO
* @param page TODO
**/
IPage<ExamBatchItemVO> queryListPage(ExamBatchVO pageReqVO, Page<ExamBatchItemVO> page);
/**
* 根据批次ID查所有子表记录
* @author vinjor-M
* @date 13:40 2025/1/21
*
* @param batchId 批次ID
* @return java.util.List<cn.iocoder.yudao.module.exam.vo.ExamBatchItemVO>
**/
* @author vinjor-M
* @date 13:40 2025/1/21
**/
List<ExamBatchItemVO> selectListByBatchId(String batchId);
/**
* 录入学生考试成绩
*
* @author vinjor-M
* @date 13:48 2025/1/21
**/
**/
void updateObj(ExamBatchItemVO examBatchVO);
/**
* 根据学生id和教练ID查询考试记录
* @author vinjor-M
* @date 16:38 2025/2/10
* @param userId 学生ID
*
* @param userId 学生ID
* @param coachId 教练ID可能为空
* @return java.util.List<cn.iocoder.yudao.module.exam.vo.ExamBatchItemVO>
**/
List<ExamBatchItemVO> selectByUserIdAndCoachId(Long userId,Long coachId);
* @author vinjor-M
* @date 16:38 2025/2/10
**/
List<ExamBatchItemVO> selectByUserIdAndCoachId(Long userId, Long coachId);
/**
* 根据学生id和教练ID查询考试记录
* @author vinjor-M
* @date 16:38 2025/2/10
* @param userId 学生ID
*
* @param userId 学生ID
* @param coachId 教练ID可能为空
* @return java.util.List<cn.iocoder.yudao.module.exam.vo.ExamBatchItemVO>
* @author vinjor-M
* @date 16:38 2025/2/10
**/
List<ExamVO> selectExamByUserIdAndCoachId(Long userId, Long coachId);
/**
* 录入学生考试成绩
*
* @author vinjor-M
* @date 13:48 2025/1/21
**/
void updateObjNew(ExamBatchItemVO examBatchVO);
/**
* 通过批次详情id集合查询
*
* @param examIds
* @return
*/
List<ExamBatchItemVO> listJoinBatchByIds(List<String> examIds);
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.exam.service.impl;
import cn.hutool.core.collection.CollUtil;
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;
@ -95,8 +96,8 @@ public class ExamBatchItemServiceImpl extends ServiceImpl<ExamBatchItemMapper, E
//更新子表考试结果
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){
Process process = processService.getByStudentAndCourse(updateItem.getUserId(), examBatch.getCourseId(), examBatch.getSubject(), examBatch.getCoachId(), "9");
if (null == process) {
throw new Exception("未找到该学生学习进度信息,请联系管理员");
}
//考试分数
@ -105,22 +106,22 @@ public class ExamBatchItemServiceImpl extends ServiceImpl<ExamBatchItemMapper, E
process.setExamTime(examBatch.getStartTime());
//已完成
process.setStatus("2");
process.setExamStatus(examBatchVO.getIfPass()?"1":"0");
process.setExamStatus(examBatchVO.getIfPass() ? "1" : "0");
processService.updateById(process);
//更新考试批次的通过率
this.updateBatchPassRate(examBatch.getId());
if(examBatchVO.getIfPass()){
if (examBatchVO.getIfPass()) {
//考试通过
if(process.getSubject()<3){
if (process.getSubject() < 3) {
//科目一二插入一条需要查出下一个的学习进度如果不存在手动插入一个
Integer nextSubject = process.getSubject()+1;
Integer nextSubject = process.getSubject() + 1;
LambdaQueryWrapper<Process> queryWrapper = new LambdaQueryWrapper<Process>()
.eq(Process::getCourseId,process.getCourseId())
.eq(Process::getUserId,process.getUserId())
.eq(Process::getSubject,nextSubject)
.eq(Process::getStatus,"0");
.eq(Process::getCourseId, process.getCourseId())
.eq(Process::getUserId, process.getUserId())
.eq(Process::getSubject, nextSubject)
.eq(Process::getStatus, "0");
List<Process> list = processService.list(queryWrapper);
if(list.isEmpty()){
if (list.isEmpty()) {
//插入
Process nextProcess = new Process();
nextProcess.setCourseId(process.getCourseId());
@ -129,19 +130,19 @@ public class ExamBatchItemServiceImpl extends ServiceImpl<ExamBatchItemMapper, E
nextProcess.setUserName(process.getUserName());
nextProcess.setUserMobile(process.getUserMobile());
nextProcess.setCoachName(process.getCoachName());
nextProcess.setSubject(process.getSubject()+1);
nextProcess.setExamNum(process.getExamNum()+1);
nextProcess.setSubject(process.getSubject() + 1);
nextProcess.setExamNum(process.getExamNum() + 1);
nextProcess.setStatus("1");
nextProcess.setTrainTime((double) 0);
processService.save(nextProcess);
}else{
} else {
//更新状态为进行中
Process nextProcess = list.get(0);
nextProcess.setStatus("1");
processService.updateById(nextProcess);
}
}
}else{
} else {
//考试不通过,重新插入一条本科目的学习记录-并改为进行中
Process thisProcess = new Process();
thisProcess.setCourseId(process.getCourseId());
@ -152,7 +153,7 @@ public class ExamBatchItemServiceImpl extends ServiceImpl<ExamBatchItemMapper, E
thisProcess.setCoachId(process.getCoachId());
thisProcess.setCoachName(process.getCoachName());
thisProcess.setSubject(process.getSubject());
thisProcess.setExamNum(process.getExamNum()+1);
thisProcess.setExamNum(process.getExamNum() + 1);
thisProcess.setStatus("1");
thisProcess.setTrainTime(process.getTrainTime());
processService.save(thisProcess);
@ -162,18 +163,19 @@ public class ExamBatchItemServiceImpl extends ServiceImpl<ExamBatchItemMapper, E
/**
* 更新考试批次通过率
*
* @param id 批次ID
* @author vinjor-M
* @date 17:39 2025/2/7
* @param id 批次ID
**/
public void updateBatchPassRate(String id){
**/
public void updateBatchPassRate(String id) {
ExamBatch examBatch = examBatchService.getById(id);
LambdaQueryWrapper<ExamBatchItem> queryWrapper = new LambdaQueryWrapper<ExamBatchItem>()
.eq(ExamBatchItem::getBatchId,id);
.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()){
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);
@ -229,8 +231,8 @@ public class ExamBatchItemServiceImpl extends ServiceImpl<ExamBatchItemMapper, E
//更新子表考试结果
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){
Process process = processService.getByStudentAndCourse(updateItem.getUserId(), examBatch.getCourseId(), examBatch.getSubject(), examBatch.getCoachId(), "9");
if (null == process) {
throw new Exception("未找到该学生学习进度信息,请联系管理员");
}
//考试分数
@ -240,23 +242,23 @@ public class ExamBatchItemServiceImpl extends ServiceImpl<ExamBatchItemMapper, E
process.setRemark(examBatch.getRemark());
//已完成
process.setStatus("2");
process.setExamStatus(examBatchVO.getIfPass()?"1":"0");
process.setExamStatus(examBatchVO.getIfPass() ? "1" : "0");
processService.updateById(process);
//更新考试批次的通过率
this.updateBatchPassRate(examBatch.getId());
if(examBatchVO.getIfPass()){
if (examBatchVO.getIfPass()) {
//考试通过
if(process.getSubject()<3){
if (process.getSubject() < 3) {
//科目一二插入一条需要查出下一个的学习进度如果不存在手动插入一个
Integer nextSubject = process.getSubject()+1;
Integer nextSubject = process.getSubject() + 1;
LambdaQueryWrapper<Process> queryWrapper = new LambdaQueryWrapper<Process>()
.eq(Process::getCourseId,process.getCourseId())
.eq(Process::getUserId,process.getUserId())
.eq(Process::getCoachId,process.getCoachId())
.eq(Process::getSubject,nextSubject)
.eq(Process::getStatus,"0");
.eq(Process::getCourseId, process.getCourseId())
.eq(Process::getUserId, process.getUserId())
.eq(Process::getCoachId, process.getCoachId())
.eq(Process::getSubject, nextSubject)
.eq(Process::getStatus, "0");
List<Process> list = processService.list(queryWrapper);
if(list.isEmpty()){
if (list.isEmpty()) {
//插入
Process nextProcess = new Process();
nextProcess.setCourseId(process.getCourseId());
@ -266,19 +268,19 @@ public class ExamBatchItemServiceImpl extends ServiceImpl<ExamBatchItemMapper, E
nextProcess.setUserMobile(process.getUserMobile());
nextProcess.setCoachId(process.getCoachId());
nextProcess.setCoachName(process.getCoachName());
nextProcess.setSubject(process.getSubject()+1);
nextProcess.setExamNum(process.getExamNum()+1);
nextProcess.setSubject(process.getSubject() + 1);
nextProcess.setExamNum(process.getExamNum() + 1);
nextProcess.setStatus("1");
nextProcess.setTrainTime((double) 0);
processService.save(nextProcess);
}else{
} else {
//更新状态为进行中
Process nextProcess = list.get(0);
nextProcess.setStatus("1");
processService.updateById(nextProcess);
}
}
}else{
} else {
//考试不通过,重新插入一条本科目的学习记录-并改为进行中
Process thisProcess = new Process();
thisProcess.setCourseId(process.getCourseId());
@ -289,11 +291,23 @@ public class ExamBatchItemServiceImpl extends ServiceImpl<ExamBatchItemMapper, E
thisProcess.setCoachId(process.getCoachId());
thisProcess.setCoachName(process.getCoachName());
thisProcess.setSubject(process.getSubject());
thisProcess.setExamNum(process.getExamNum()+1);
thisProcess.setExamNum(process.getExamNum() + 1);
thisProcess.setStatus("1");
thisProcess.setTrainTime(process.getTrainTime());
processService.save(thisProcess);
}
}
/**
* 通过批次详情id集合查询
*
* @param examIds
* @return
*/
@Override
public List<ExamBatchItemVO> listJoinBatchByIds(List<String> examIds) {
if (CollUtil.isEmpty(examIds)) return null;
return baseMapper.listJoinBatchByIds(examIds);
}
}

View File

@ -55,5 +55,15 @@ public class ExamBatchItemVO extends ExamBatchItem {
@TableField(exist = false)
private Boolean showMore;
/**
* 考试类型
*/
private String courseType;
/**
* 教练名称
*/
private String coachName;
}

View File

@ -20,7 +20,9 @@ public interface TrainMapper extends BaseMapper<Train> {
IPage<TrainVO> queryListPage(@Param("entity") TrainVO entity, Page<TrainVO> page);
List<TrainVO> selectTrainByCondition(@Param("coachId")Long coachId,@Param("startTime")String startTime,@Param("endTime")String endTime);
List<TrainVO> selectTrainByCondition(@Param("coachId") Long coachId, @Param("startTime") String startTime, @Param("endTime") String endTime);
IPage<TrainVO> queryTrainListPage(@Param("entity") TrainVO pageReqVO,@Param("page") Page<TrainVO> page);
IPage<TrainVO> queryTrainListPage(@Param("entity") TrainVO pageReqVO, @Param("page") Page<TrainVO> page);
List<TrainVO> listJoinBatchByIds(@Param("trainIds") List<String> trainIds);
}

View File

@ -76,4 +76,12 @@ public interface TrainService extends IService<Train> {
* @date 16:26 2025/2/10
**/
List<Train> selectByUserIdAndCoachId(Long userId, Long coachId);
/**
* 批量查询
*
* @param trainIds 训练id集合
* @return
*/
List<TrainVO> listJoinBatchByIds(List<String> trainIds);
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.train.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.course.entity.Process;
@ -135,4 +136,16 @@ public class TrainServiceImpl extends ServiceImpl<TrainMapper, Train> implements
queryWrapper.orderByDesc(BaseDO::getCreateTime);
return this.list(queryWrapper);
}
/**
* 批量查询
*
* @param trainIds 训练id集合
* @return
*/
@Override
public List<TrainVO> listJoinBatchByIds(List<String> trainIds) {
if (CollUtil.isEmpty(trainIds)) return null;
return trainMapper.listJoinBatchByIds(trainIds);
}
}

View File

@ -0,0 +1,201 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.base.mapper.SchoolFeedBackMapper">
<resultMap type="cn.iocoder.yudao.module.jx.domain.DriveSchoolFeedback" id="DriveSchoolFeedbackResult">
<result property="id" column="id" />
<result property="userId" column="userId" />
<result property="content" column="content" />
<result property="jlContent" column="jlContent" />
<result property="jlId" column="jlId" />
<result property="jlName" column="jlName" />
<result property="jxId" column="jxId" />
<result property="jxName" column="jxName" />
<result property="createTime" column="create_time" />
<result property="creator" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updater" column="update_by" />
<result property="evaluateType" column="evaluateType" />
<result property="userName" column="userName" />
<result property="likes" column="likes" />
</resultMap>
<sql id="selectDriveSchoolFeedbackVo">
select * from drive_school_feedback
</sql>
<select id="selectDriveSchoolFeedbackList" resultType="cn.iocoder.yudao.module.base.vo.SchoolFeedBackVO">
SELECT
dsf.*,
<choose>
<!-- 当 evaluate_type 为 1考试-->
<when test="dsf.evaluateType == '1'">
CASE
WHEN dseb.subject = '1' THEN '科目一考试'
WHEN dseb.subject = '2' THEN '科目二考试'
WHEN dseb.subject = '3' THEN '科目三考试'
WHEN dseb.subject = '4' THEN '科目四考试'
ELSE ''
END AS busiName,
dseb.batch_name AS busiName
</when>
<!-- 当 evaluate_type 为 0训练-->
<when test="dsf.evaluateType == '0'">
CASE
WHEN exam.subject = 1 THEN '科目一训练'
WHEN exam.subject = 2 THEN '科目二训练'
WHEN exam.subject = 3 THEN '科目三训练'
WHEN exam.subject = 4 THEN '科目四训练'
ELSE ''
END AS busiName
</when>
<!-- 默认的 busiName -->
<otherwise>
'' AS busiName
</otherwise>
</choose>
FROM drive_school_feedback dsf
<!-- 动态的连接逻辑 -->
<choose>
<!-- 如果 evaluate_type 为 1考试连接考试表 -->
<when test="dsf.evaluateType == '1'">
LEFT JOIN drive_school_exam_batch_item train ON dsf.busi_id = train.id
LEFT JOIN drive_school_exam_batch dseb ON train.batch_id = dseb.id
</when>
<!-- 如果 evaluate_type 为 0训练连接训练表 -->
<when test="dsf.evaluateType == '0'">
LEFT JOIN drive_school_train exam ON dsf.busi_id = exam.id
</when>
</choose>
<where>
dsf.deleted = 0
<if test="dsf.userId != null">
AND dsf.user_id = #{dsf.userId}
</if>
<!-- 确保通过 evaluate_type 进行筛选 -->
<if test="dsf.evaluateType != null">
AND dsf.evaluate_type = #{dsf.evaluateType}
</if>
</where>
ORDER BY dsf.create_time DESC
</select>
<select id="selectDriveSchoolFeedbackListAll" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolFeedback" resultMap="DriveSchoolFeedbackResult">
<include refid="selectDriveSchoolFeedbackVo"/>
<where>
deleted = 0
<if test="entity.userId != null "> and userId = #{entity.userId}</if>
<if test="entity.jxName != null and entity.jxName != ''"> and jxName like concat('%',#{entity.jxName},'%') </if>
<if test="entity.jlName != null and entity.jlName != ''"> and jlName like concat('%',#{entity.jlName},'%')</if>
<if test="entity.evaluateType != null "> and evaluateType = #{entity.evaluateType}</if>
</where>
order by create_time desc
</select>
<select id="likeOne" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolFeedback" resultType="Integer">
select count(1) total from drive_school_feedback
<where>
deleted = 0 and
likes = '1'
<if test="jxId != null "> and jxId = #{jxId}</if>
</where>
order by create_time desc
</select>
<select id="likeTwo" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolFeedback" resultType="Integer">
select count(1) total from drive_school_feedback
<where>
deleted = 0 and
likes = '2'
<if test="jxId != null "> and jxId = #{jxId}</if>
</where>
</select>
<select id="likeThree" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolFeedback" resultType="Integer">
<include refid="selectDriveSchoolFeedbackVo"/>
select count(1) total from drive_school_feedback
<where>
deleted = 0 and
likes = '3'
<if test="jxId != null "> and jxId = #{jxId}</if>
</where>
</select>
<select id="selectDriveSchoolFeedbackById" parameterType="Long" resultMap="DriveSchoolFeedbackResult">
<include refid="selectDriveSchoolFeedbackVo"/>
where id = #{id}
</select>
<insert id="insertDriveSchoolFeedback" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolFeedback">
insert into drive_school_feedback
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="userId != null">userId,</if>
<if test="content != null">content,</if>
<if test="jlContent != null">jlContent,</if>
<if test="jlId != null">jlId,</if>
<if test="jlName != null">jlName,</if>
<if test="jxId != null">jxId,</if>
<if test="jxName != null">jxName,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="evaluateType != null">evaluateType,</if>
<if test="userName != null">userName,</if>
<if test="likes!= null">likes,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="userId != null">#{userId},</if>
<if test="content != null">#{content},</if>
<if test="jlContent != null">#{jlContent},</if>
<if test="jlId != null">#{jlId},</if>
<if test="jlName != null">#{jlName},</if>
<if test="jxId != null">#{jxId},</if>
<if test="jxName != null">#{jxName},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="evaluateType != null">#{evaluateType},</if>
<if test="userName != null">#{userName},</if>
<if test="likes != null">#{likes},</if>
</trim>
</insert>
<insert id="insertData">
insert into drive_school_feedback (userId, content, create_time) values (#{userId}, #{content}, now())
</insert>
<update id="updateDriveSchoolFeedback" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolFeedback">
update drive_school_feedback
<trim prefix="SET" suffixOverrides=",">
<if test="userId != null">userId = #{userId},</if>
<if test="content != null">content = #{content},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="evaluateType != null">evaluateType = #{evaluateType},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDriveSchoolFeedbackById" parameterType="Long">
delete from drive_school_feedback where id = #{id}
</delete>
<delete id="deleteDriveSchoolFeedbackByIds" parameterType="String">
delete from drive_school_feedback where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -134,4 +134,23 @@
</if>
ORDER BY dseb.create_time DESC-->
</select>
<select id="listJoinBatchByIds" resultType="cn.iocoder.yudao.module.exam.vo.ExamBatchItemVO">
SELECT
dsebi.*,
dseb.batch_name,
dseb.start_time,
dseb.end_time,
dseb.`subject`,
dseb.addr,
dseb.trans_way,
dseb.coach_id
FROM
drive_school_exam_batch_item dsebi
LEFT JOIN drive_school_exam_batch dseb ON dsebi.batch_id = dseb.id
WHERE
dsebi.id IN
<foreach collection="examIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
</mapper>

View File

@ -68,4 +68,17 @@
and dst.course_id =#{entity.courseId}
</if>
</select>
<select id="listJoinBatchByIds" resultType="cn.iocoder.yudao.module.train.vo.TrainVO">
SELECT
dst.*, dsc.type as courseType
FROM
drive_school_train dst
LEFT JOIN drive_school_course dsc ON dst.course_id = dsc.id
where
dst.deleted = 0
and dst.id in
<foreach collection="trainIds" item="trainId" open="(" separator="," close=")">
#{trainId}
</foreach>
</select>
</mapper>