| | |
| | | import com.dsh.course.entity.*; |
| | | import com.dsh.course.feignclient.account.StudentClient; |
| | | import com.dsh.course.feignclient.account.model.Student; |
| | | import com.dsh.course.feignclient.account.model.TStudent; |
| | | import com.dsh.course.mapper.CoursePackageSchedulingMapper; |
| | | import com.dsh.course.mapper.CoursePackageStudentMapper; |
| | | import com.dsh.course.model.QueryCoursePackageSchedulingList; |
| | |
| | | import javax.annotation.Resource; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | |
| | | @Resource |
| | | private StudentClient studentClient; |
| | | |
| | | @Autowired |
| | | private CourseCounsumService courseCounsumService; |
| | | |
| | | |
| | | /** |
| | |
| | | coursePackageSchedulingMapper.updateById(coursePackageScheduling); |
| | | |
| | | TCoursePackage coursePackage = coursePackageService.getById(coursePackageScheduling.getCoursePackageId()); |
| | | if (coursePackage.getStatus() == 1) { |
| | | if (null != coursePackage && coursePackage.getStatus() == 1) { |
| | | coursePackage.setStatus(2); |
| | | coursePackageService.updateById(coursePackage); |
| | | } |
| | |
| | | .gt("useTime", "now()") |
| | | .gt("laveClassHours", 0) |
| | | ); |
| | | |
| | | List<CoursePackageOrder> list1 = coursePackageOrderService.list(new QueryWrapper<CoursePackageOrder>() |
| | | .eq("payStatus", 2) |
| | | .eq("status", 1) |
| | | .eq("state", 1) |
| | | .gt("laveClassHours", 0) |
| | | .orderByAsc("insertTime") |
| | | ); |
| | | |
| | | for (CoursePackageOrderStudent coursePackageOrderStudent : list) { |
| | | CoursePackageScheduling coursePackageScheduling = this.getOne(new QueryWrapper<CoursePackageScheduling>() |
| | | .eq("appUserId", coursePackageOrderStudent.getAppUserId()) |
| | |
| | | .eq("status", 1) |
| | | .eq("type", 1) |
| | | ); |
| | | laveClassHours -= count; |
| | | |
| | | Integer codeTime = coursePackage.getCodeTime(); |
| | | laveClassHours -= count; |
| | | //剩余数量不足以排课 |
| | | if (laveClassHours.compareTo(codeTime) < 0) { |
| | | break; |
| | | } |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | //生成一周的排课数据 |
| | | for (int i = 0; i < num; i++) { |
| | |
| | | } |
| | | |
| | | }else{ |
| | | Date classDate = coursePackageScheduling.getClassDate(); |
| | | Date classDate = new Date(); |
| | | |
| | | if (coursePackageScheduling!=null){ |
| | | classDate = coursePackageScheduling.getClassDate(); |
| | | } |
| | | |
| | | int count = this.count(new QueryWrapper<CoursePackageScheduling>() |
| | | .eq("appUserId", coursePackageOrderStudent.getAppUserId()) |
| | | .eq("studentId", coursePackageOrderStudent.getStudentId()) |
| | |
| | | ); |
| | | |
| | | Integer number = laveClassHours - count; |
| | | if(codeTime.compareTo(number) > 0 && calendar.getTimeInMillis() > classDate.getTime()){ |
| | | if((number.compareTo(codeTime) > 0 && calendar.getTimeInMillis() > classDate.getTime())||coursePackageScheduling==null){ |
| | | //从第二天开始 |
| | | Calendar startTime = Calendar.getInstance(); |
| | | startTime.setTime(coursePackageScheduling.getClassDate()); |
| | | // startTime.setTime(coursePackageScheduling.getClassDate()); |
| | | startTime.setTime(classDate); |
| | | startTime.set(Calendar.DAY_OF_YEAR, startTime.get(Calendar.DAY_OF_YEAR) + 1); |
| | | startTime.set(Calendar.HOUR_OF_DAY, 0); |
| | | startTime.set(Calendar.MINUTE, 0); |
| | |
| | | //判断最后一天是否所有时段都已排完 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String format = sdf.format(coursePackageScheduling.getClassDate()); |
| | | String time = format.substring(format.indexOf(" ") + 1); |
| | | String format = sdf.format(classDate); |
| | | String time = format.substring(0,format.indexOf(" ") + 1); |
| | | String classStartTime = coursePackage.getClassStartTime(); |
| | | String classEndTime = coursePackage.getClassEndTime(); |
| | | String[] split = classStartTime.split(","); |
| | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 过时清零排课记录及剩余课时数据 |
| | | */ |
| | | @Override |
| | | public void taskOverdueClearing() { |
| | | List<TStudent> tStudents = studentClient.queryExpiredList(); |
| | | for (TStudent tStudent : tStudents) { |
| | | List<CoursePackageScheduling> list1 = this.list(new QueryWrapper<CoursePackageScheduling>() |
| | | .eq("type", 1) |
| | | .eq("studentId", tStudent.getId()) |
| | | .eq("status", 1) |
| | | ); |
| | | if(list1.size() > 0){ |
| | | List<Long> collect = list1.stream().map(CoursePackageScheduling::getId).collect(Collectors.toList()); |
| | | this.removeByIds(collect); |
| | | coursePackageStudentMapper.delete(new QueryWrapper<CoursePackageStudent>() |
| | | .in("coursePackageSchedulingId", collect) |
| | | ); |
| | | } |
| | | |
| | | List<CoursePackageOrderStudent> list = coursePackageOrderStudentService.list(new QueryWrapper<CoursePackageOrderStudent>() |
| | | .eq("studentId", tStudent.getId()) |
| | | .eq("status", 1) |
| | | .eq("state", 1) |
| | | ); |
| | | for (CoursePackageOrderStudent coursePackageOrderStudent : list) { |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setChangeType(0); |
| | | courseCounsum.setNum(coursePackageOrderStudent.getLaveClassHours()); |
| | | courseCounsum.setReason("有效期结束清楚剩余课时"); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setAppUserId(coursePackageOrderStudent.getAppUserId()); |
| | | courseCounsumService.save(courseCounsum); |
| | | coursePackageOrderStudent.setLaveClassHours(0); |
| | | } |
| | | if(list.size() > 0){ |
| | | coursePackageOrderStudentService.updateBatchById(list); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |