| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.course.entity.CancelledClasses; |
| | | import com.dsh.course.entity.CourseCounsum; |
| | | import com.dsh.course.entity.CoursePackageStudent; |
| | | import com.dsh.course.entity.TCoursePackage; |
| | | import com.dsh.course.feignclient.model.GetStudentCourse; |
| | | import com.dsh.course.service.CancelledClassesService; |
| | | import com.dsh.course.service.CourseCounsumService; |
| | | import com.dsh.course.service.CoursePackageStudentService; |
| | | import com.dsh.course.service.TCoursePackageService; |
| | | import com.dsh.course.util.ToolUtil; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Api |
| | |
| | | private CancelledClassesService caccService; |
| | | |
| | | |
| | | |
| | | @PostMapping("/base/courseRecord/queryDeduClassHours") |
| | | public Integer getDeductionClassHour(@RequestParam("courseId") Integer courseId,@RequestParam("stuId") Integer stuId,@RequestParam("appUserId") Integer appUserId){ |
| | | public Integer getDeductionClassHour(@RequestBody GetStudentCourse course) { |
| | | Integer sult = 0; |
| | | TCoursePackage coursePackage = tcpService.getById(courseId); |
| | | if (null != coursePackage && coursePackage.getStatus() == 3){ |
| | | List<CoursePackageStudent> coursePackageStudents = cosService.queryStuDeduClassHourNums(courseId, stuId, appUserId); |
| | | if (coursePackageStudents.size() > 0){ |
| | | TCoursePackage coursePackage = tcpService.getById(course.getCourseId()); |
| | | if (null != coursePackage && coursePackage.getStatus() == 3) { |
| | | List<CoursePackageStudent> coursePackageStudents = cosService.list(new QueryWrapper<CoursePackageStudent>() |
| | | .eq("coursePackageId", course.getCourseId()) |
| | | .eq("studentId", course.getStuId()) |
| | | .eq("appUserId", course.getAppUserId()) |
| | | .eq("signInOrNot", 1)); |
| | | if (coursePackageStudents.size() > 0) { |
| | | List<CancelledClasses> list = caccService.list(new QueryWrapper<CancelledClasses>() |
| | | .eq("coursePackageId",courseId )); |
| | | if (list.size() > 0){ |
| | | .eq("coursePackageId", course.getCourseId())); |
| | | if (list.size() > 0) { |
| | | for (CancelledClasses cancelledClasses : list) { |
| | | sult = sult + cancelledClasses.getCancelledClassesNumber(); |
| | | } |
| | |
| | | } |
| | | return sult; |
| | | } |
| | | @Autowired |
| | | private CourseCounsumService courseCounsumService; |
| | | |
| | | @PostMapping("/base/courseRecord/save") |
| | | public void save(@RequestBody CourseCounsum courseCounsum) { |
| | | courseCounsumService.save(courseCounsum); |
| | | } |
| | | |
| | | @PostMapping("/base/courseRecord/cancelCourseData") |
| | | public Integer cancelCourseRecordClass(@RequestBody Integer courseRecordId) { |
| | | int sult = 0; |
| | | CoursePackageStudent packageStudent = cosService.getById(courseRecordId); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd"); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm"); |
| | | String tis = simpleDateFormat.format(new Date()); |
| | | if (ToolUtil.isNotEmpty(packageStudent)) { |
| | | TCoursePackage coursePackage = tcpService.getById(packageStudent.getCoursePackageId()); |
| | | String startTime = tis + " " + coursePackage.getClassStartTime(); |
| | | Date parse = null; |
| | | try { |
| | | parse = format.parse(startTime); |
| | | } catch (ParseException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | LocalDateTime localDateTime = parse.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); |
| | | // 计算时间间隔 |
| | | long hours = ChronoUnit.HOURS.between(LocalDateTime.now(), localDateTime); |
| | | // 判断是否在前三小时内 |
| | | if (hours <= 3 && hours >= 0) { |
| | | sult = 1; |
| | | } else { |
| | | sult = 2; |
| | | } |
| | | } |
| | | return sult; |
| | | } |
| | | |
| | | } |