Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
邬吉朋
practical_train
Commits
913d157a
Commit
913d157a
authored
Aug 03, 2026
by
wujipeng
Browse files
学生端-我的课程-日历-详情
parent
38adeb62
Changes
10
Hide whitespace changes
Inline
Side-by-side
practical-api/practical-business-api/src/main/java/com/platform/business/model/dto/ClassSubjectDTO.java
View file @
913d157a
...
@@ -8,11 +8,15 @@ import java.util.List;
...
@@ -8,11 +8,15 @@ import java.util.List;
@Data
@Data
public
class
ClassSubjectDTO
{
public
class
ClassSubjectDTO
{
private
i
nt
classId
;
private
I
nt
eger
classId
;
private
String
date
;
private
String
date
;
private
String
teacherId
;
private
String
teacherId
;
private
List
<
ClassSubjectEntity
>
classSubjectList
;
private
List
<
ClassSubjectEntity
>
classSubjectList
;
private
String
userId
;
private
List
<
Integer
>
classIds
;
}
}
practical-api/practical-business-api/src/main/java/com/platform/business/model/entity/ClassSubjectEntity.java
View file @
913d157a
...
@@ -35,4 +35,7 @@ public class ClassSubjectEntity {
...
@@ -35,4 +35,7 @@ public class ClassSubjectEntity {
@ApiModelProperty
(
value
=
"课程地点"
)
@ApiModelProperty
(
value
=
"课程地点"
)
private
String
location
;
private
String
location
;
@ApiModelProperty
(
value
=
"课程类型:理论/实操"
)
private
String
type
;
}
}
practical-api/practical-business-api/src/main/java/com/platform/business/model/vo/ClassSubjectVO.java
View file @
913d157a
package
com.platform.business.model.vo
;
package
com.platform.business.model.vo
;
import
com.platform.business.model.entity.ClassSubjectEntity
;
import
com.platform.business.model.entity.ClassSubjectEntity
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.EqualsAndHashCode
;
import
java.util.List
;
@Data
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
public
class
ClassSubjectVO
extends
ClassSubjectEntity
{
public
class
ClassSubjectVO
extends
ClassSubjectEntity
{
...
@@ -13,4 +16,11 @@ public class ClassSubjectVO extends ClassSubjectEntity {
...
@@ -13,4 +16,11 @@ public class ClassSubjectVO extends ClassSubjectEntity {
private
int
classNum
;
private
int
classNum
;
private
String
className
;
private
String
className
;
private
String
status
;
private
List
<
ClassSubjectVO
>
data
;
@ApiModelProperty
(
value
=
"课程数"
)
private
int
subjectNum
;
}
}
practical-business/src/main/java/com/platform/business/controller/ClassController.java
View file @
913d157a
...
@@ -2,7 +2,9 @@ package com.platform.business.controller;
...
@@ -2,7 +2,9 @@ package com.platform.business.controller;
import
com.platform.business.model.dto.CalendarDTO
;
import
com.platform.business.model.dto.CalendarDTO
;
import
com.platform.business.model.dto.ClassDTO
;
import
com.platform.business.model.dto.ClassDTO
;
import
com.platform.business.model.dto.ClassSubjectDTO
;
import
com.platform.business.model.vo.CalendarVO
;
import
com.platform.business.model.vo.CalendarVO
;
import
com.platform.business.model.vo.ClassSubjectVO
;
import
com.platform.business.model.vo.ClassVO
;
import
com.platform.business.model.vo.ClassVO
;
import
com.platform.business.service.ClassService
;
import
com.platform.business.service.ClassService
;
import
com.platform.controller.BaseController
;
import
com.platform.controller.BaseController
;
...
@@ -44,12 +46,18 @@ public class ClassController extends BaseController {
...
@@ -44,12 +46,18 @@ public class ClassController extends BaseController {
return
toAjax
(
classService
.
deleteStu
(
studentId
));
return
toAjax
(
classService
.
deleteStu
(
studentId
));
}
}
@ApiOperation
(
"
课程安排表
"
)
@ApiOperation
(
"
学生端-我的课程-日历
"
)
@PostMapping
(
"/schedule"
)
@PostMapping
(
"/schedule"
)
public
Result
<
List
<
ClassVO
>>
schedule
(
@RequestBody
ClassDTO
classDTO
)
{
public
Result
<
List
<
ClassVO
>>
schedule
(
@RequestBody
ClassDTO
classDTO
)
{
return
Result
.
data
(
classService
.
schedule
(
classDTO
));
return
Result
.
data
(
classService
.
schedule
(
classDTO
));
}
}
@ApiOperation
(
"学生端-我的课程-日历-详情"
)
@PostMapping
(
"/schedule/detail"
)
public
Result
<
ClassSubjectVO
>
scheduleDetail
(
@RequestBody
ClassSubjectDTO
classSubjectDTO
)
{
return
Result
.
data
(
classService
.
scheduleDetail
(
classSubjectDTO
));
}
@ApiOperation
(
"课程安排表-教师端"
)
@ApiOperation
(
"课程安排表-教师端"
)
@PostMapping
(
"/schedule/teacher"
)
@PostMapping
(
"/schedule/teacher"
)
public
Result
<
List
<
ClassVO
>>
scheduleTeacher
(
@RequestBody
ClassDTO
classDTO
)
{
public
Result
<
List
<
ClassVO
>>
scheduleTeacher
(
@RequestBody
ClassDTO
classDTO
)
{
...
...
practical-business/src/main/java/com/platform/business/mapper/ClassSubjectMapper.java
View file @
913d157a
...
@@ -27,4 +27,7 @@ public interface ClassSubjectMapper extends BaseMapper<ClassSubjectEntity> {
...
@@ -27,4 +27,7 @@ public interface ClassSubjectMapper extends BaseMapper<ClassSubjectEntity> {
List
<
ClassSubjectVO
>
queryByTeacherId
(
String
id
);
List
<
ClassSubjectVO
>
queryByTeacherId
(
String
id
);
List
<
CalendarVO
>
todayCourse
(
@Param
(
"classIds"
)
List
<
Integer
>
classIds
);
List
<
CalendarVO
>
todayCourse
(
@Param
(
"classIds"
)
List
<
Integer
>
classIds
);
List
<
ClassSubjectVO
>
queryListByUserIdAndDate
(
ClassSubjectDTO
classSubjectDTO
);
}
}
practical-business/src/main/java/com/platform/business/service/ClassService.java
View file @
913d157a
...
@@ -3,8 +3,10 @@ package com.platform.business.service;
...
@@ -3,8 +3,10 @@ package com.platform.business.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.platform.business.model.dto.CalendarDTO
;
import
com.platform.business.model.dto.CalendarDTO
;
import
com.platform.business.model.dto.ClassDTO
;
import
com.platform.business.model.dto.ClassDTO
;
import
com.platform.business.model.dto.ClassSubjectDTO
;
import
com.platform.business.model.entity.ClassEntity
;
import
com.platform.business.model.entity.ClassEntity
;
import
com.platform.business.model.vo.CalendarVO
;
import
com.platform.business.model.vo.CalendarVO
;
import
com.platform.business.model.vo.ClassSubjectVO
;
import
com.platform.business.model.vo.ClassVO
;
import
com.platform.business.model.vo.ClassVO
;
import
java.util.List
;
import
java.util.List
;
...
@@ -21,6 +23,8 @@ public interface ClassService extends IService<ClassEntity> {
...
@@ -21,6 +23,8 @@ public interface ClassService extends IService<ClassEntity> {
List
<
ClassVO
>
schedule
(
ClassDTO
classDTO
);
List
<
ClassVO
>
schedule
(
ClassDTO
classDTO
);
ClassSubjectVO
scheduleDetail
(
ClassSubjectDTO
classSubjectDTO
);
List
<
ClassVO
>
scheduleTeacher
(
ClassDTO
classDTO
);
List
<
ClassVO
>
scheduleTeacher
(
ClassDTO
classDTO
);
List
<
CalendarVO
>
todayCourse
(
String
userId
);
List
<
CalendarVO
>
todayCourse
(
String
userId
);
...
...
practical-business/src/main/java/com/platform/business/service/ClassSubjectService.java
View file @
913d157a
...
@@ -33,5 +33,6 @@ public interface ClassSubjectService extends IService<ClassSubjectEntity> {
...
@@ -33,5 +33,6 @@ public interface ClassSubjectService extends IService<ClassSubjectEntity> {
List
<
CalendarVO
>
todayCourse
(
List
<
Integer
>
classIds
);
List
<
CalendarVO
>
todayCourse
(
List
<
Integer
>
classIds
);
List
<
ClassSubjectVO
>
queryListByUserIdAndDate
(
ClassSubjectDTO
classSubjectDTO
);
}
}
practical-business/src/main/java/com/platform/business/service/impl/ClassServiceImpl.java
View file @
913d157a
...
@@ -6,6 +6,7 @@ import com.google.common.collect.Lists;
...
@@ -6,6 +6,7 @@ import com.google.common.collect.Lists;
import
com.platform.business.mapper.ClassMapper
;
import
com.platform.business.mapper.ClassMapper
;
import
com.platform.business.model.dto.CalendarDTO
;
import
com.platform.business.model.dto.CalendarDTO
;
import
com.platform.business.model.dto.ClassDTO
;
import
com.platform.business.model.dto.ClassDTO
;
import
com.platform.business.model.dto.ClassSubjectDTO
;
import
com.platform.business.model.entity.ClassEntity
;
import
com.platform.business.model.entity.ClassEntity
;
import
com.platform.business.model.entity.ClassStudentEntity
;
import
com.platform.business.model.entity.ClassStudentEntity
;
import
com.platform.business.model.entity.ClassSubjectAttendanceEntity
;
import
com.platform.business.model.entity.ClassSubjectAttendanceEntity
;
...
@@ -83,12 +84,17 @@ public class ClassServiceImpl extends ServiceImpl<ClassMapper, ClassEntity> impl
...
@@ -83,12 +84,17 @@ public class ClassServiceImpl extends ServiceImpl<ClassMapper, ClassEntity> impl
@Override
@Override
public
List
<
ClassVO
>
schedule
(
ClassDTO
classDTO
)
{
public
List
<
ClassVO
>
schedule
(
ClassDTO
classDTO
)
{
Date
now
=
new
Date
();
//查询考试信息
//查询考试信息
List
<
ExamStudentVO
>
examStudentList
=
examStudentService
.
queryOneself
(
classDTO
.
getUserId
());
List
<
ExamStudentVO
>
examStudentList
=
examStudentService
.
queryOneself
(
classDTO
.
getUserId
());
//获取班级id
//获取班级id
List
<
Integer
>
classIds
=
classStudentService
.
queryClassIdByUserId
(
classDTO
.
getUserId
());
List
<
Integer
>
classIds
=
classStudentService
.
queryClassIdByUserId
(
classDTO
.
getUserId
());
//查询课程信息
//查询课程信息
List
<
ClassSubjectVO
>
classSubjectList
=
classSubjectService
.
queryOneself
(
classIds
,
classDTO
.
getStartDate
(),
classDTO
.
getEndDate
());
List
<
ClassSubjectVO
>
classSubjectList
=
classSubjectService
.
queryOneself
(
classIds
,
classDTO
.
getStartDate
(),
classDTO
.
getEndDate
());
//查询签到数据
List
<
ClassSubjectAttendanceEntity
>
classSubjectAttendanceList
=
classSubjectAttendanceService
.
queryOneself
(
classDTO
);
HashMap
<
Integer
,
ClassSubjectAttendanceEntity
>
classSubjectAttendanceMap
=
new
HashMap
<>();
classSubjectAttendanceList
.
forEach
(
classSubjectAttendanceEntity
->
classSubjectAttendanceMap
.
put
(
classSubjectAttendanceEntity
.
getSubjectId
(),
classSubjectAttendanceEntity
));
List
<
ClassVO
>
result
=
Lists
.
newArrayList
();
List
<
ClassVO
>
result
=
Lists
.
newArrayList
();
List
<
Date
>
dateList
=
getDatesBetweenTwoDate
(
classDTO
.
getStartDate
(),
classDTO
.
getEndDate
());
List
<
Date
>
dateList
=
getDatesBetweenTwoDate
(
classDTO
.
getStartDate
(),
classDTO
.
getEndDate
());
for
(
Date
date
:
dateList
)
{
for
(
Date
date
:
dateList
)
{
...
@@ -96,6 +102,16 @@ public class ClassServiceImpl extends ServiceImpl<ClassMapper, ClassEntity> impl
...
@@ -96,6 +102,16 @@ public class ClassServiceImpl extends ServiceImpl<ClassMapper, ClassEntity> impl
List
<
ClassSubjectVO
>
classSubjectChildList
=
Lists
.
newArrayList
();
List
<
ClassSubjectVO
>
classSubjectChildList
=
Lists
.
newArrayList
();
for
(
ClassSubjectVO
classSubjectVO
:
classSubjectList
)
{
for
(
ClassSubjectVO
classSubjectVO
:
classSubjectList
)
{
if
(
classSubjectVO
.
getDate
().
equals
(
date
))
{
if
(
classSubjectVO
.
getDate
().
equals
(
date
))
{
//判断状态
if
(
isBeforeMinTime
(
now
,
classSubjectVO
.
getDate
(),
classSubjectVO
.
getTimeFrame
()))
{
classSubjectVO
.
setStatus
(
classSubjectVO
.
getType
());
}
else
{
if
(
classSubjectAttendanceMap
.
containsKey
(
classSubjectVO
.
getId
()))
{
classSubjectVO
.
setStatus
(
"已签到"
);
}
else
{
classSubjectVO
.
setStatus
(
"缺勤"
);
}
}
classSubjectChildList
.
add
(
classSubjectVO
);
classSubjectChildList
.
add
(
classSubjectVO
);
}
}
}
}
...
@@ -113,6 +129,98 @@ public class ClassServiceImpl extends ServiceImpl<ClassMapper, ClassEntity> impl
...
@@ -113,6 +129,98 @@ public class ClassServiceImpl extends ServiceImpl<ClassMapper, ClassEntity> impl
return
result
;
return
result
;
}
}
@Override
public
ClassSubjectVO
scheduleDetail
(
ClassSubjectDTO
classSubjectDTO
)
{
Date
now
=
new
Date
();
ClassSubjectVO
result
=
new
ClassSubjectVO
();
List
<
Integer
>
classIds
=
classStudentService
.
queryClassIdByUserId
(
classSubjectDTO
.
getUserId
());
classSubjectDTO
.
setClassIds
(
classIds
);
List
<
ClassSubjectVO
>
data
=
classSubjectService
.
queryListByUserIdAndDate
(
classSubjectDTO
);
//查询签到数据
List
<
ClassSubjectAttendanceEntity
>
classSubjectAttendanceList
=
classSubjectAttendanceService
.
list
(
new
LambdaQueryWrapper
<>(
ClassSubjectAttendanceEntity
.
class
)
.
eq
(
ClassSubjectAttendanceEntity:
:
getUserId
,
classSubjectDTO
.
getUserId
()));
HashMap
<
Integer
,
ClassSubjectAttendanceEntity
>
classSubjectAttendanceMap
=
new
HashMap
<>();
classSubjectAttendanceList
.
forEach
(
classSubjectAttendanceEntity
->
classSubjectAttendanceMap
.
put
(
classSubjectAttendanceEntity
.
getSubjectId
(),
classSubjectAttendanceEntity
));
//设置状态
for
(
ClassSubjectVO
classSubjectVO
:
data
)
{
//判断状态
if
(
isBeforeMinTime
(
now
,
classSubjectVO
.
getDate
(),
classSubjectVO
.
getTimeFrame
()))
{
classSubjectVO
.
setStatus
(
classSubjectVO
.
getType
());
}
else
{
if
(
classSubjectAttendanceMap
.
containsKey
(
classSubjectVO
.
getId
()))
{
classSubjectVO
.
setStatus
(
"已签到"
);
}
else
{
classSubjectVO
.
setStatus
(
"缺勤"
);
}
}
}
result
.
setData
(
data
);
result
.
setSubjectNum
(
data
.
size
());
return
result
;
}
/**
* 判断指定日期是否在时间段中最小的开始时间之前
*
* @param date 要判断的日期时间
* @param baseDate 基准日期(用于组合时间段中的时分秒)
* @param timeFrame 时间段字符串,格式如 "05:00-09:00,10:20-11:20"
* @return true表示date在最小开始时间之前,false表示之后或等于
*/
public
static
boolean
isBeforeMinTime
(
Date
date
,
Date
baseDate
,
String
timeFrame
)
{
// 用于解析时间格式
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"HH:mm"
);
List
<
Date
>
startTimes
=
new
ArrayList
<>();
// 按逗号拆分时间段
String
[]
timeFrames
=
timeFrame
.
split
(
","
);
for
(
String
tf
:
timeFrames
)
{
// 按横杠拆分开始和结束时间
String
[]
times
=
tf
.
split
(
"-"
);
if
(
times
.
length
==
2
)
{
try
{
// 解析开始时间的时分
Date
timePart
=
sdf
.
parse
(
times
[
0
]);
// 使用Calendar将时分与基准日期组合
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
baseDate
);
Calendar
timeCal
=
Calendar
.
getInstance
();
timeCal
.
setTime
(
timePart
);
// 设置时分秒
cal
.
set
(
Calendar
.
HOUR_OF_DAY
,
timeCal
.
get
(
Calendar
.
HOUR_OF_DAY
));
cal
.
set
(
Calendar
.
MINUTE
,
timeCal
.
get
(
Calendar
.
MINUTE
));
cal
.
set
(
Calendar
.
SECOND
,
0
);
cal
.
set
(
Calendar
.
MILLISECOND
,
0
);
startTimes
.
add
(
cal
.
getTime
());
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
// 如果解析失败,跳过这个时间段
continue
;
}
}
}
// 如果没有有效的时间段,返回false
if
(
startTimes
.
isEmpty
())
{
return
false
;
}
// 找到最小的开始时间
Date
minStartTime
=
startTimes
.
get
(
0
);
for
(
Date
st
:
startTimes
)
{
if
(
st
.
before
(
minStartTime
))
{
minStartTime
=
st
;
}
}
// 判断传入的date是否在最小开始时间之前
return
date
.
before
(
minStartTime
);
}
@Override
@Override
public
List
<
ClassVO
>
scheduleTeacher
(
ClassDTO
classDTO
)
{
public
List
<
ClassVO
>
scheduleTeacher
(
ClassDTO
classDTO
)
{
//查询考试信息
//查询考试信息
...
...
practical-business/src/main/java/com/platform/business/service/impl/ClassSubjectServiceImpl.java
View file @
913d157a
...
@@ -212,9 +212,7 @@ public class ClassSubjectServiceImpl extends ServiceImpl<ClassSubjectMapper, Cla
...
@@ -212,9 +212,7 @@ public class ClassSubjectServiceImpl extends ServiceImpl<ClassSubjectMapper, Cla
UserVO
userVO
=
userService
.
queryByUserName
(
userName
);
UserVO
userVO
=
userService
.
queryByUserName
(
userName
);
String
teacherId
=
userVO
.
getId
();
String
teacherId
=
userVO
.
getId
();
Integer
count1
=
0
;
//记录当月剩余课时
Integer
count1
=
0
;
//记录当月剩余课时
int
count2
=
0
;
//记录待评分试卷
Integer
count2
=
0
;
//记录待评分试卷
// 获取当前日期和时间
// 获取当前日期和时间
LocalDateTime
now
=
LocalDateTime
.
now
();
LocalDateTime
now
=
LocalDateTime
.
now
();
// 获取当前年份和月份
// 获取当前年份和月份
...
@@ -269,4 +267,9 @@ public class ClassSubjectServiceImpl extends ServiceImpl<ClassSubjectMapper, Cla
...
@@ -269,4 +267,9 @@ public class ClassSubjectServiceImpl extends ServiceImpl<ClassSubjectMapper, Cla
public
List
<
CalendarVO
>
todayCourse
(
List
<
Integer
>
classIds
)
{
public
List
<
CalendarVO
>
todayCourse
(
List
<
Integer
>
classIds
)
{
return
baseMapper
.
todayCourse
(
classIds
);
return
baseMapper
.
todayCourse
(
classIds
);
}
}
@Override
public
List
<
ClassSubjectVO
>
queryListByUserIdAndDate
(
ClassSubjectDTO
classSubjectDTO
)
{
return
baseMapper
.
queryListByUserIdAndDate
(
classSubjectDTO
);
}
}
}
practical-business/src/main/resources/com/platform/business/mapper/ClassSubjectMapper.xml
View file @
913d157a
...
@@ -74,6 +74,8 @@
...
@@ -74,6 +74,8 @@
cs.subject_name,
cs.subject_name,
cs.teacher_id,
cs.teacher_id,
cs.remark,
cs.remark,
cs.location,
cs.type,
c.name as className
c.name as className
from
from
class_subject cs
class_subject cs
...
@@ -101,6 +103,8 @@
...
@@ -101,6 +103,8 @@
cs.subject_name,
cs.subject_name,
cs.teacher_id,
cs.teacher_id,
cs.remark,
cs.remark,
cs.location,
cs.type,
c.name as className
c.name as className
from
from
class_subject cs
class_subject cs
...
@@ -132,5 +136,23 @@
...
@@ -132,5 +136,23 @@
#{item}
#{item}
</foreach>
</foreach>
</select>
</select>
<select
id=
"queryListByUserIdAndDate"
resultType=
"com.platform.business.model.vo.ClassSubjectVO"
>
select
cs.time_frame,
cs.subject_name,
u.nick_name,
cs.type
from
class_subject cs
left join
user u
on
cs.teacher_id = u.id
where date = #{date}
and cs.class_id in
<foreach
item=
"item"
index=
"index"
collection=
"classIds"
open=
"("
separator=
","
close=
")"
>
#{item}
</foreach>
</select>
</mapper>
</mapper>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment