This commit is contained in:
PQZ 2025-02-19 16:18:22 +08:00
commit fc74639e3c
17 changed files with 371 additions and 7 deletions

View File

@ -11,6 +11,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 数据查询统一方法")
@ -35,4 +37,24 @@ public class DataViewController {
return success(dataViewService.selectStudentInfo(id,coachId));
}
/**
* 首页数据统计查询接口 --
* @author vinjor-M
* @date 14:12 2025/2/14
* @param type 查询类型coach-教练查询|admin-管理员查询
* @param timeType 时间查询类型all-全部|day-当日|month-当月|more-自定义
* @param coachId 教练id
* @param startTime 查询时间范围--开始
* @param endTime 查询时间范围--结束
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
**/
@GetMapping("/indexData")
@Operation(summary = "首页数据统计查询接口")
public CommonResult<?> selectIndexInfo(@RequestParam(value = "type") String type,
@RequestParam(value = "timeType") String timeType,
@RequestParam(value = "coachId",required = false) Long coachId,
@RequestParam(value = "startTime",required = false) String startTime,
@RequestParam(value = "endTime",required = false) String endTime) {
return success(dataViewService.selectIndexInfo(type,timeType,coachId,startTime,endTime));
}
}

View File

@ -126,5 +126,19 @@ public class DlDriveSchoolCoachController {
return success(dlDriveSchoolCoachService.getCoachById(id));
}
/**
*
* @author vinjor-M
* @date 15:41 2025/2/18
* @param userId userId
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
**/
@GetMapping("/getCoachByUserId")
@Operation(summary = "根据userId获得驾校教练信息")
@Parameter(name = "userId", description = "用户id", required = true, example = "1024")
public CommonResult<?> getCoachByUserId(@RequestParam("userId") Long userId) {
return success(dlDriveSchoolCoachService.getDlDriveSchoolCoachByUserId(userId));
}
}

View File

@ -57,4 +57,24 @@ public interface DlDriveSchoolStudentMapper extends BaseMapper<DlDriveSchoolStud
* @return com.baomidou.mybatisplus.core.metadata.IPage<cn.iocoder.yudao.module.base.vo.DlDriveSchoolStudentVO>
**/
IPage<DlDriveSchoolStudentVO> selectByCoachId(@Param("entity") DlDriveSchoolStudentVO pageReqVO, Page<DlDriveSchoolStudentVO> page);
/**
* 查学生列表---驾校层面查询
* @author vinjor-M
* @date 15:13 2025/2/14
* @param coachId 教练ID
* @param startTime 开始时间
* @param endTime 结束时间
* @return java.util.List<cn.iocoder.yudao.module.base.vo.DlDriveSchoolStudentVO>
**/
List<DlDriveSchoolStudentVO> selectStudentList(@Param("coachId")Long coachId, @Param("startTime") String startTime, @Param("endTime")String endTime);
/**
* 教练层面查询自己的学生列表
* @author vinjor-M
* @date 15:24 2025/2/17
**/
List<DlDriveSchoolStudentVO> selectStudentListCoach(@Param("coachId")Long coachId, @Param("startTime") String startTime, @Param("endTime")String endTime);
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.base.service;
import cn.iocoder.yudao.module.base.vo.IndexDataVO;
import cn.iocoder.yudao.module.base.vo.StudentInfoVO;
/**
@ -16,5 +17,15 @@ public interface DataViewService {
* @return cn.iocoder.yudao.module.base.vo.StudentInfoVO
**/
StudentInfoVO selectStudentInfo(Long id,Long coachId);
/**
* 首页数据统计查询接口 --
* @author vinjor-M
* @date 14:12 2025/2/14
* @param type 查询类型coach-教练查询|admin-管理员查询
* @param timeType 时间查询类型all-全部|day-当日|month-当月|more-自定义
* @param coachId 教练id
* @param startTime 查询时间范围--开始
* @param endTime 查询时间范围--结束
**/
IndexDataVO selectIndexInfo(String type, String timeType, Long coachId, String startTime, String endTime);
}

View File

@ -1,22 +1,31 @@
package cn.iocoder.yudao.module.base.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.iocoder.yudao.module.base.entity.DlDriveSchoolStudent;
import cn.iocoder.yudao.module.base.mapper.DlDriveSchoolStudentMapper;
import cn.iocoder.yudao.module.base.service.DataViewService;
import cn.iocoder.yudao.module.base.service.DlDriveSchoolCoachService;
import cn.iocoder.yudao.module.base.service.DlDriveSchoolStudentService;
import cn.iocoder.yudao.module.base.vo.DlDriveSchoolCoachRespVO;
import cn.iocoder.yudao.module.base.vo.DlDriveSchoolStudentVO;
import cn.iocoder.yudao.module.base.vo.IndexDataVO;
import cn.iocoder.yudao.module.base.vo.StudentInfoVO;
import cn.iocoder.yudao.module.course.entity.Process;
import cn.iocoder.yudao.module.course.service.ProcessService;
import cn.iocoder.yudao.module.exam.mapper.ExamBatchItemMapper;
import cn.iocoder.yudao.module.exam.service.ExamBatchItemService;
import cn.iocoder.yudao.module.exam.vo.ExamBatchItemVO;
import cn.iocoder.yudao.module.train.entity.Train;
import cn.iocoder.yudao.module.train.mapper.TrainMapper;
import cn.iocoder.yudao.module.train.service.TrainService;
import cn.iocoder.yudao.module.train.vo.TrainVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.List;
import java.text.DecimalFormat;
import java.util.*;
@Service
@Validated
@ -24,13 +33,19 @@ public class DataViewServiceImpl implements DataViewService {
@Autowired
private DlDriveSchoolStudentService studentService;
@Autowired
private DlDriveSchoolStudentMapper studentMapper;
@Autowired
private DlDriveSchoolCoachService coachService;
@Autowired
private ProcessService processService;
@Autowired
private TrainService trainService;
@Autowired
private TrainMapper trainMapper;
@Autowired
private ExamBatchItemService examBatchItemService;
@Autowired
private ExamBatchItemMapper examBatchItemMapper;
/**
* 查询学员详情
@ -68,4 +83,167 @@ public class DataViewServiceImpl implements DataViewService {
studentInfoVO.setExamList(examList);
return studentInfoVO;
}
/**
* 首页数据统计查询接口 --
*
* @param type 查询类型coach-教练查询|admin-管理员查询
* @param timeType 时间查询类型all-全部|day-当日|month-当月|more-自定义
* @param coachId 教练id
* @param startTime 查询时间范围--开始
* @param endTime 查询时间范围--结束
* @author vinjor-M
* @date 14:12 2025/2/14
**/
@Override
public IndexDataVO selectIndexInfo(String type, String timeType, Long coachId, String startTime, String endTime) {
IndexDataVO rtnObj = new IndexDataVO();
DecimalFormat df = new DecimalFormat("#.00");
//默认查全部数据
String startTimeStr = "";
String endTimeStr = "";
if("more".equals(timeType)){
if(StringUtils.isNotEmpty(startTime)){
startTimeStr = startTime+" 00:00:01";
}
if(StringUtils.isNotEmpty(endTime)) {
endTimeStr = endTime + " 23:59:59";
}
}else if("month".equals(timeType)){
//当月
startTimeStr = DateUtil.format(DateUtil.beginOfMonth(DateUtil.date()),"yyyy-MM-dd")+" 00:00:01";
endTimeStr = DateUtil.format(DateUtil.endOfMonth(DateUtil.date()),"yyyy-MM-dd")+" 23:59:59";
}else if("day".equals(timeType)){
//当天
startTimeStr = DateUtil.formatDate(DateUtil.date())+" 00:00:01";
endTimeStr = DateUtil.formatDate(DateUtil.date())+" 23:59:59";
}
if("admin".equals(type)){
//管理员查询
/*1.招生情况*/
List<DlDriveSchoolStudentVO> studentList = studentMapper.selectStudentList(coachId, startTimeStr, endTimeStr);
Map<String,Object> studentInfoMap = new HashMap<>();
int coachNum=0;
double coachAmount=0;
int schoolNum=0;
double schoolAmount=0;
for (DlDriveSchoolStudentVO item:studentList){
if("02".equals(item.getSource())){
//教练自招
coachNum++;
coachAmount = coachAmount+item.getPriceAmount();
}else{
//驾校统招
schoolNum++;
schoolAmount = schoolAmount+item.getPriceAmount();
}
}
int allNum = coachNum+schoolNum;
double coachRate=0;
double schoolRate=0;
if(allNum>0){
if(coachNum>0){
coachRate = coachNum / allNum;
}
if(schoolNum>0){
schoolRate = schoolNum / allNum;
}
}
studentInfoMap.put("coachNum",coachNum);
studentInfoMap.put("coachAmount",coachAmount);
studentInfoMap.put("coachRate",0!=coachRate?(Double.parseDouble(df.format(coachRate))*100):0);
studentInfoMap.put("schoolNum",schoolNum);
studentInfoMap.put("schoolAmount",schoolAmount);
studentInfoMap.put("schoolRate",0!=schoolRate?(Double.parseDouble(df.format(schoolRate))*100):0);
rtnObj.setStudentInfo(studentInfoMap);
/*4.财务情况--TODO*/
Map<String,Object> moneyInfoMap = new HashMap<>();
moneyInfoMap.put("inAmount",0);
moneyInfoMap.put("outAmount",0);
rtnObj.setMoneyInfo(moneyInfoMap);
}else if("coach".equals(type)){
//教练查询
/*1.学员情况*/
List<DlDriveSchoolStudentVO> studentVOList = studentMapper.selectStudentListCoach(coachId,startTimeStr,endTimeStr);
int overNum = (int) studentVOList.stream().filter(item -> null != item.getGradTime()).count();
int noOverNum = studentVOList.size()-overNum;
Map<String,Object> studentInfoMap = new HashMap<>();
studentInfoMap.put("allNum",studentVOList.size());
studentInfoMap.put("overNum",overNum);
studentInfoMap.put("noOverNum",noOverNum);
rtnObj.setStudentInfo(studentInfoMap);
/*4.财务情况-查教练自己应得的提成-TODO*/
Map<String,Object> moneyInfoMap = new HashMap<>();
moneyInfoMap.put("money",0);
rtnObj.setMoneyInfo(moneyInfoMap);
}
/*2.训练情况*/
List<TrainVO> allTrainList = trainMapper.selectTrainByCondition(coachId,startTimeStr,endTimeStr);
//所有车辆set目的是去重
Set<String> allCarSet = new HashSet<>();
Set<String> subject2CarSet = new HashSet<>();
Set<String> subject3CarSet = new HashSet<>();
Set<Long> allUserSet = new HashSet<>();
Set<Long> subject2UserSet = new HashSet<>();
Set<Long> subject3UserSet = new HashSet<>();
for (TrainVO trainVO:allTrainList){
if(2==trainVO.getSubject()){
subject2CarSet.add(trainVO.getCarNo());
allCarSet.add(trainVO.getCarNo());
subject2UserSet.add(trainVO.getUserId());
allUserSet.add(trainVO.getUserId());
}else if(3==trainVO.getSubject()){
subject3CarSet.add(trainVO.getCarNo());
allCarSet.add(trainVO.getCarNo());
subject3UserSet.add(trainVO.getUserId());
allUserSet.add(trainVO.getUserId());
}
}
Map<String,Object> trainInfoMap = new HashMap<>();
trainInfoMap.put("allCarNum",allCarSet.size());
trainInfoMap.put("subject2CarNum",subject2CarSet.size());
trainInfoMap.put("subject3CarNum",subject3CarSet.size());
trainInfoMap.put("allUserNum",allUserSet.size());
trainInfoMap.put("subject2UserNum",subject2UserSet.size());
trainInfoMap.put("subject3UserNum",subject3UserSet.size());
rtnObj.setTrainInfo(trainInfoMap);
/*3.考试情况*/
List<ExamBatchItemVO> examBatchItemVOList = examBatchItemMapper.selectByCoachId(coachId,startTimeStr,endTimeStr);
Double subject2Num = 0.0;
Double subject3Num = 0.0;
Double subject2PassNum = 0.0;
Double subject3PassNum = 0.0;
for (ExamBatchItemVO exam:examBatchItemVOList){
if(2==exam.getSubject()){
subject2Num++;
if(null!=exam.getIfPass() && exam.getIfPass()){
//考试通过
subject2PassNum++;
}
}else if(3==exam.getSubject()){
subject3Num++;
if(null!=exam.getIfPass() && exam.getIfPass()){
//考试通过
subject3PassNum++;
}
}
}
double subject2Rate=0;
double subject3Rate=0;
if(0!=subject2Num && 0!=subject2PassNum){
subject2Rate = subject2PassNum / subject2Num;
}
if(0!=subject3Num && 0!=subject3PassNum){
subject3Rate = subject3PassNum / subject3Num;
}
Map<String,Object> examInfoMap = new HashMap<>();
examInfoMap.put("subject2All",subject2Num);
examInfoMap.put("subject2Pass",subject2PassNum);
examInfoMap.put("subject2Rate",0!=subject2Rate?(Double.parseDouble(df.format(subject2Rate))*100):0);
examInfoMap.put("subject3All",subject3Num);
examInfoMap.put("subject3Pass",subject3PassNum);
examInfoMap.put("subject3Rate",0!=subject3Rate?(Double.parseDouble(df.format(subject3Rate))*100):0);
rtnObj.setExamInfo(examInfoMap);
return rtnObj;
}
}

View File

@ -16,4 +16,6 @@ public class DlDriveSchoolStudentVO extends DlDriveSchoolStudent {
private String courseId;
/**学习进度*/
private Process process;
/**总金额*/
private Double priceAmount;
}

View File

@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.base.vo;
import lombok.Data;
import java.util.Map;
/**
* app首页数据统计实体
* @author vinjor-M
* @date 14:15 2025/2/14
**/
@Data
public class IndexDataVO {
/**招生情况*/
private Map<String,Object> studentInfo;
/**训练情况*/
private Map<String,Object> trainInfo;
/**考试情况*/
private Map<String,Object> examInfo;
/**财务情况*/
private Map<String,Object> moneyInfo;
}

View File

@ -24,4 +24,6 @@ public interface ExamBatchItemMapper extends BaseMapper<ExamBatchItem> {
List<ExamBatchItemVO> selectByBatchId(@Param("batchId")String batchId);
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);
}

View File

@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 练车记录 Mapper
*
@ -18,6 +20,6 @@ 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);
}

View File

@ -13,4 +13,8 @@ public class TrainVO extends Train {
* 学习课程进度表ID
*/
private String processId;
/**
* 车牌号
*/
private String carNo;
}

View File

@ -80,4 +80,46 @@
GROUP BY
temp.user_id
</select>
<select id="selectStudentList" resultType="cn.iocoder.yudao.module.base.vo.DlDriveSchoolStudentVO">
SELECT
dss.* ,SUM(dsco.reserve_money+dsco.rest_money)AS priceAmount
FROM
drive_school_student dss
LEFT JOIN drive_school_course_order dsco ON dss.user_id=dsco.user_id AND dsco.deleted=0
WHERE
dss.deleted=0
AND dsco.id IS NOT NULL
<if test="startTime!=null and startTime!=''">
AND dss.create_time &gt;= #{startTime}
</if>
<if test="endTime!=null and endTime!=''">
AND dss.create_time &lt;= #{endTime}
</if>
<if test="coachId!=null and coachId!=''">
AND dss.source_user_id=#{coachId}
</if>
GROUP BY dss.id
</select>
<select id="selectStudentListCoach" resultType="cn.iocoder.yudao.module.base.vo.DlDriveSchoolStudentVO">
SELECT
dss.*
FROM
drive_school_process dsp
LEFT JOIN drive_school_student dss ON dsp.user_id = dss.user_id
AND dss.deleted = 0
WHERE
dsp.deleted = 0
AND dss.id IS NOT NULL
<if test="coachId != null and coachId != ''">
AND dsp.coach_id = #{coachId}
</if>
<if test="startTime!=null and startTime!=''">
AND dss.create_time &gt;= #{startTime}
</if>
<if test="endTime!=null and endTime!=''">
AND dss.create_time &lt;= #{endTime}
</if>
GROUP BY
dss.id
</select>
</mapper>

View File

@ -52,4 +52,24 @@
</if>
ORDER BY dseb.create_time DESC
</select>
<select id="selectByCoachId" resultType="cn.iocoder.yudao.module.exam.vo.ExamBatchItemVO">
SELECT
dsebi.*,
dseb.`subject`
FROM
drive_school_exam_batch_item dsebi
LEFT JOIN drive_school_exam_batch dseb ON dsebi.batch_id = dseb.id
WHERE
dsebi.deleted = 0
AND dseb.deleted = 0
<if test="coachId != null and coachId != ''">
AND dseb.coach_id= #{coachId}
</if>
<if test="startTime!=null and startTime!=''">
AND dseb.start_time &gt;= #{startTime}
</if>
<if test="endTime!=null and endTime!=''">
AND dseb.start_time &lt;= #{endTime}
</if>
</select>
</mapper>

View File

@ -2,7 +2,7 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.train.mapper.ReservationCourseMapper">
<mapper namespace="cn.iocoder.yudao.module.train.mapper.TrainMapper">
<select id="queryListPage" resultType="cn.iocoder.yudao.module.train.vo.TrainVO">
SELECT
@ -31,4 +31,23 @@
</if>
order by dsrc.create_time desc
</select>
<select id="selectTrainByCondition" resultType="cn.iocoder.yudao.module.train.vo.TrainVO">
SELECT
dst.*,
dsc.car_id
FROM
drive_school_train dst
LEFT JOIN drive_school_coach dsc ON dst.coach_id = dsc.user_id
WHERE
dst.deleted = 0
<if test="coachId != null and coachId != ''">
AND dst.coach_id = #{coachId}
</if>
<if test="startTime!=null and startTime!=''">
AND dst.create_time &gt;= #{startTime}
</if>
<if test="endTime!=null and endTime!=''">
AND dst.create_time &lt;= #{endTime}
</if>
</select>
</mapper>

View File

@ -20,6 +20,9 @@ public class NotifyMessageMyPageReqVO extends PageParam {
@Schema(description = "是否已读", example = "true")
private Boolean readStatus;
@Schema(description = "系统标识", example = "true")
private String systemCode;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;

View File

@ -80,5 +80,4 @@ public class ApiNotifyMessageController {
public CommonResult<Long> getUnreadNotifyMessageCount() {
return success(notifyMessageService.getWXUnreadNotifyMessageCount(getLoginUserId()));
}
}

View File

@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.system.dal.dataobject.notify;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
@ -11,7 +10,6 @@ import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.*;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.Map;
/**
@ -97,5 +95,9 @@ public class NotifyMessageDO extends BaseDO {
* 阅读时间
*/
private LocalDateTime readTime;
/**
* 系统标识
*/
private String systemCode;
}

View File

@ -29,6 +29,7 @@ public interface NotifyMessageMapper extends BaseMapperX<NotifyMessageDO> {
default PageResult<NotifyMessageDO> selectPage(NotifyMessageMyPageReqVO reqVO, Long userId, Integer userType) {
return selectPage(reqVO, new LambdaQueryWrapperX<NotifyMessageDO>()
.eqIfPresent(NotifyMessageDO::getReadStatus, reqVO.getReadStatus())
.eqIfPresent(NotifyMessageDO::getSystemCode, reqVO.getSystemCode())
.betweenIfPresent(NotifyMessageDO::getCreateTime, reqVO.getCreateTime())
.eq(NotifyMessageDO::getUserId, userId)
.eq(NotifyMessageDO::getUserType, userType)
@ -38,6 +39,7 @@ public interface NotifyMessageMapper extends BaseMapperX<NotifyMessageDO> {
default PageResult<NotifyMessageDO> selectWxPage(NotifyMessageMyPageReqVO reqVO, Long userId) {
return selectPage(reqVO, new LambdaQueryWrapperX<NotifyMessageDO>()
.eqIfPresent(NotifyMessageDO::getReadStatus, reqVO.getReadStatus())
.eqIfPresent(NotifyMessageDO::getSystemCode, reqVO.getSystemCode())
.betweenIfPresent(NotifyMessageDO::getCreateTime, reqVO.getCreateTime())
.eq(NotifyMessageDO::getUserId, userId)
.eq(NotifyMessageDO::getUserType, 1)