| | |
| | | |
| | | 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 |
| | |
| | | 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; |
| | | } |
| | | |
| | | } |