Joburgess 5 лет назад
Родитель
Сommit
759be0f16f

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java

@@ -22,7 +22,8 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
      * @param courseID
      * @return
      */
-    TeacherAttendanceDto getCurrentCourseDetail(@Param("courseID") Long courseID);
+    TeacherAttendanceDto getCurrentCourseDetail(@Param("courseID") Long courseID,
+                                                @Param("teacherId") Integer teacherId);
 
     /**
      * @param startTime:

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -92,7 +92,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		if(Objects.isNull(courseID)){
 			throw new BizException("参数错误!");
 		}
-		TeacherAttendanceDto currentCourseDetail = courseScheduleDao.getCurrentCourseDetail(courseID);
+		TeacherAttendanceDto currentCourseDetail = courseScheduleDao.getCurrentCourseDetail(courseID,user.getId());
 		if(Objects.isNull(currentCourseDetail)){
 		    throw new BizException("课程不存在");
         }

+ 10 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentAttendanceServiceImpl.java

@@ -199,7 +199,10 @@ public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentA
 			throw new BizException("开课2个小时之前才可以请假");
 		}
 		
-		StudentAttendance studentAttendance  = new StudentAttendance();
+		StudentAttendance studentAttendance  = studentAttendanceDao.findByStatusAndCourseScheduleId(userId,courseScheduleId.intValue());
+		if(Objects.isNull(studentAttendance)){
+			studentAttendance=new StudentAttendance();
+		}
 		studentAttendance.setClassGroupId(courseSchedule.getClassGroupId());
 		studentAttendance.setCourseScheduleId(courseScheduleId);
 		studentAttendance.setCreateTime(date);
@@ -207,8 +210,12 @@ public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentA
 		studentAttendance.setRemark(remark);
 		studentAttendance.setStatus(StudentAttendanceStatusEnum.LEAVE);
 		studentAttendance.setUserId(userId);
-		
-		studentAttendanceDao.insert(studentAttendance);
+
+		if(Objects.nonNull(studentAttendance.getId())){
+			studentAttendanceDao.update(studentAttendance);
+		}else{
+			studentAttendanceDao.insert(studentAttendance);
+		}
 		
 		ClassGroupStudentMapper classGroupStudentMapper = classGroupStudentMapperDao.query(courseSchedule.getClassGroupId(), userId);
 		if(Objects.isNull(classGroupStudentMapper)){

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TeacherAttendanceServiceImpl.java

@@ -85,7 +85,7 @@ public class TeacherAttendanceServiceImpl extends BaseServiceImpl<Long, TeacherA
 			isAttendance=true;
 		}
 
-		TeacherAttendanceDto currentCourseDetail = courseScheduleDao.getCurrentCourseDetail(teacherSignOutDto.getTeacherAttendanceInfo().getCourseScheduleId());
+		TeacherAttendanceDto currentCourseDetail = courseScheduleDao.getCurrentCourseDetail(teacherSignOutDto.getTeacherAttendanceInfo().getCourseScheduleId(),user.getId());
 		if(Objects.isNull(currentCourseDetail)){
 			throw new BizException("课程不存在");
 		}

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -248,7 +248,7 @@
         LEFT JOIN school s ON mg.school_id_=s.id_
         LEFT JOIN sys_user su ON cs.actual_teacher_id_=su.id_
         LEFT JOIN teacher_attendance ta ON cs.id_=ta.course_schedule_id_
-        WHERE cs.id_= #{courseID}
+        WHERE cs.id_= #{courseID} AND ta.teacher_id_=#{teacherId}
     </select>
 
     <select id="getTeacherCourseByDateSpeed"