|
|
@@ -1,11 +1,18 @@
|
|
|
package com.example.cinema.bl;
|
|
|
|
|
|
import com.example.cinema.data.ScheduleMapper;
|
|
|
-import com.example.cinema.vo.ResponseVO;
|
|
|
-import com.example.cinema.vo.ScheduleForm;
|
|
|
+import com.example.cinema.vo.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.concurrent.CopyOnWriteArrayList;
|
|
|
+
|
|
|
/**
|
|
|
* @author fjj
|
|
|
* @date 2019/4/11 4:14 PM
|
|
|
@@ -27,4 +34,44 @@ public class ScheduleServiceImpl implements ScheduleService {
|
|
|
return ResponseVO.buildFailure("失败");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseVO searchScheduleSevenDays(ScheduleSearchForm scheduleSearchForm) {
|
|
|
+ try {
|
|
|
+ // 处理查询表单的起止时间
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Date startDate = simpleDateFormat.parse(simpleDateFormat.format(scheduleSearchForm.getStartDate()));
|
|
|
+ scheduleSearchForm.setStartDate(startDate);
|
|
|
+
|
|
|
+ Calendar calendarStartDate = Calendar.getInstance();
|
|
|
+ calendarStartDate.setTime(startDate);
|
|
|
+ calendarStartDate.add(Calendar.DAY_OF_YEAR, 7);
|
|
|
+ scheduleSearchForm.setEndDate(calendarStartDate.getTime());
|
|
|
+
|
|
|
+ // 按照日期整理ScheduleItem
|
|
|
+ List<ScheduleItem> scheduleItemList = scheduleMapper.selectSchedule(scheduleSearchForm);
|
|
|
+ List<ScheduleVO> scheduleVOList = new ArrayList<>();
|
|
|
+
|
|
|
+ for(int i = 0; i < 7; i++){
|
|
|
+ calendarStartDate.setTime(startDate);
|
|
|
+ calendarStartDate.add(Calendar.DAY_OF_YEAR, i);
|
|
|
+ Date date = calendarStartDate.getTime();
|
|
|
+ ScheduleVO scheduleVO = new ScheduleVO();
|
|
|
+ scheduleVO.setDate(date);
|
|
|
+ List<ScheduleItem> scheduleItems = new ArrayList<>();
|
|
|
+ for(ScheduleItem scheduleItem : scheduleItemList){
|
|
|
+ Date startTime = simpleDateFormat.parse(simpleDateFormat.format(scheduleItem.getStartTime()));
|
|
|
+ if(date.equals(startTime)){
|
|
|
+ scheduleItems.add(scheduleItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ scheduleVO.setScheduleItemList(scheduleItems);
|
|
|
+ scheduleVOList.add(scheduleVO);
|
|
|
+ }
|
|
|
+ return ResponseVO.buildSuccess(scheduleVOList);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return ResponseVO.buildFailure("失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|