package com.example.cinema.blImpl.management.schedule;
import java.util.Date;
import com.example.cinema.bl.management.ScheduleService;
import com.example.cinema.blImpl.management.hall.HallServiceForBl;
import com.example.cinema.data.management.ScheduleMapper;
import com.example.cinema.po.Movie;
import com.example.cinema.po.ScheduleItem;
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.*;
/**
* @author fjj
* @date 2019/4/11 4:14 PM
*/
@Service
public class ScheduleServiceImpl implements ScheduleService, ScheduleServiceForBl {
private static final String TIME_CONFLICT_ERROR_MESSAGE = "时间段冲突";
private static final String CROSS_DAYS_ERROR_MESSAGE = "起止时间不能跨天";
private static final String DATE_INTERVAL_LESS_THAN_LENGTH_ERROR_MESSAGE = "起止时间段不能少于电影时长或结束时间不能早于开始时间";
private static final String BEFORE_NOW_TIME_ERROR_MESSAGE = "排片日期不能早于当前时间";
private static final String BEFORE_START_DATE_ERROR_MESSAGE = "排片时间不能早于电影上映时间";
private static final String MOVIE_NOT_EXIST_ERROR_MESSAGE = "电影不存在";
private static final String HALL_NOT_EXIST_ERROR_MESSAGE = "影厅不存在";
private static final String VIEW_COUNT_ERROR_MESSAGE = "排片可见限制数错误";
private static final String ID_LIST_NULL_ERROR_MESSAGE = "id列表不可为空";
private static final String VIEW_CONFLICT_ERROR_MESSAGE = "有排片信息已对观众可见,无法删除或修改";
@Autowired
private ScheduleMapper scheduleMapper;
@Autowired
private MovieServiceForBl movieServiceForBl;
@Autowired
private HallServiceForBl hallServiceForBl;
@Override
public ResponseVO addSchedule(ScheduleForm scheduleForm) {
try {
ResponseVO responseVO = preCheck(scheduleForm);
if(!responseVO.getSuccess()){
return responseVO;
}
scheduleMapper.insertOneSchedule(scheduleForm);
return ResponseVO.buildSuccess();
} catch (Exception e) {
e.printStackTrace();
return ResponseVO.buildFailure("失败");
}
}
@Override
public ResponseVO updateSchedule(ScheduleForm scheduleForm) {
try {
ResponseVO responseVO = preCheck(scheduleForm);
if(!responseVO.getSuccess()){
return responseVO;
}
//在修改时要检查想要修改的排片信息是否已被观众可见,若可见则无法修改
if(isAudienceCanView(Arrays.asList(scheduleForm.getId()))){
return ResponseVO.buildFailure(VIEW_CONFLICT_ERROR_MESSAGE);
}
scheduleMapper.updateScheduleById(scheduleForm);
return ResponseVO.buildSuccess();
} catch (Exception e) {
e.printStackTrace();
return ResponseVO.buildFailure("失败");
}
}
@Override
public ResponseVO getScheduleById(int id) {
try {
ScheduleItem scheduleItem = scheduleMapper.selectScheduleById(id);
if(scheduleItem != null){
return ResponseVO.buildSuccess(new ScheduleItemVO(scheduleItem));
}else{
return ResponseVO.buildSuccess(null);
}
}catch (Exception e){
e.printStackTrace();
return ResponseVO.buildFailure("失败");
}
}
@Override
public ResponseVO getScheduleView() {
try {
return ResponseVO.buildSuccess(scheduleMapper.selectView());
}catch (Exception e){
e.printStackTrace();
return ResponseVO.buildFailure("失败");
}
}
@Override
public ResponseVO searchAudienceSchedule(int movieId) {
try{
//根据view中设置的排片可见限制
int days = scheduleMapper.selectView();
List<ScheduleItem> scheduleItems = scheduleMapper.selectScheduleByMovieId(movieId);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date today = simpleDateFormat.parse(simpleDateFormat.format(new Date()));
Date endDate = getNumDayAfterDate(today, days);
List<ScheduleItem> result = new ArrayList<>();
for(ScheduleItem s : scheduleItems){
if(s.getStartTime().before(endDate) && s.getStartTime().after(new Date())){
result.add(s);
}
}
int interval = 1;
if(result.size() > 0){
interval = (int)((result.get(result.size() - 1).getStartTime().getTime() - today.getTime()) / (1000 * 3600 * 24)) + 1;
}
return ResponseVO.buildSuccess(getScheduleVOList(interval, today, result));
}catch (Exception e){
e.printStackTrace();
return ResponseVO.buildFailure("失败");
}
}
@Override
public List<ScheduleItem> getScheduleByMovieIdList(List<Integer> movieIdList) {
try {
return scheduleMapper.selectScheduleByMovieIdList(movieIdList);
}catch (Exception e){
e.printStackTrace();
return null;
}
}
@Override
public ScheduleItem getScheduleItemById(int id) {
try {
return scheduleMapper.selectScheduleById(id);
}catch (Exception e){
e.printStackTrace();
return null;
}
}
@Override
public ResponseVO searchScheduleSevenDays(int hallId, Date startDate) {
try {
// 处理查询表单的起止时间
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
startDate = simpleDateFormat.parse(simpleDateFormat.format(startDate));
Date endDate = getNumDayAfterDate(startDate, 7);
// 按照日期整理ScheduleItem
List<ScheduleItem> scheduleItemList = scheduleMapper.selectSchedule(hallId, startDate, endDate);
return ResponseVO.buildSuccess(getScheduleVOList(7, startDate, scheduleItemList));
} catch (ParseException e) {
e.printStackTrace();
return ResponseVO.buildFailure("失败");
}
}
@Override
public ResponseVO setScheduleView(ScheduleViewForm scheduleViewForm) {
try{
if(scheduleViewForm.getDay() < 0){
return ResponseVO.buildFailure(VIEW_COUNT_ERROR_MESSAGE);
}
int num = scheduleMapper.selectViewCount();
if(num == 0){
scheduleMapper.insertOneView(scheduleViewForm);
}
else if(num == 1){
scheduleMapper.updateOneView(scheduleViewForm);
}
else {
return ResponseVO.buildFailure(VIEW_COUNT_ERROR_MESSAGE);
}
return ResponseVO.buildSuccess();
}catch (Exception e){
e.printStackTrace();
return ResponseVO.buildFailure("失败");
}
}
@Override
public ResponseVO deleteBatchOfSchedule(ScheduleBatchDeleteForm scheduleBatchDeleteForm) {
try{
List<Integer> scheduleIdList = scheduleBatchDeleteForm.getScheduleIdList();
if(scheduleIdList.size() == 0){
return ResponseVO.buildFailure(ID_LIST_NULL_ERROR_MESSAGE);
}
if(isAudienceCanView(scheduleIdList)){
return ResponseVO.buildFailure(VIEW_CONFLICT_ERROR_MESSAGE);
}
scheduleMapper.deleteScheduleBatch(scheduleIdList);
return ResponseVO.buildSuccess();
}catch (Exception e){
e.printStackTrace();
return ResponseVO.buildFailure("失败");
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Java项目:电影售票系统设计和实现(java+Springboot+ssm+mysql+jsp+maven)

共385个文件
java:97个
class:97个
js:46个

1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 123 浏览量
2022-03-15
08:49:43
上传
评论 1
收藏 1.75MB RAR 举报
温馨提示
一、项目简述 Java电影院系统功能: 登陆注册模块 : 普通用户可以直接访问影院主界面进行电影浏览、查询等 功能,但是当用户操作需要读取用户信息时就要求用户进 行登录了。普通用户可以直接访问登录页面或者通过页面 的登录选项进行登录,当用户不拥有账号时,即可通过注 册链接进行账号注册,注册完毕后自动返回登录页面,方 便用户登录。 电影查询浏览模块 : 电影浏览查询模块作为本系统最重要的模块之一,面向普 通用户。其意指通过不同方式向用户展示电影并提供电影 详情链接,其主要包括以下子模块:(1) 电影类型查询:用 户可以根据个人类型喜好对影片进行筛选。(2) 电影放映 厅类型查询:用户可以根据个人 二项目运行 、 环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持) 项目技术: JSP +Springboot+ SpringMVC + MyBatis + ThymeLeaf + HTML+ JavaScript + JQuery + Ajax + maven等等
资源推荐
资源详情
资源评论




















收起资源包目录





































































































共 385 条
- 1
- 2
- 3
- 4
资源评论


OldWinePot
- 粉丝: 9250
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 电子商务-网路经营模式可分成那几大类(1).pptx
- 对学校财务管理信息化的现实思考(1).docx
- Excel日历控件教程详细(1).docx
- PetHomie宠物移动电子商务平台_计划书(1).pdf
- 生物软件汇总(1).pdf
- 秋季学期教育信息化管理的工作计划(1).docx
- 编译原理第三章PPT(1).ppt
- 2022年智慧楼宇信息化解决方案(1).pptx
- 化工装置电气自动化研究(1).doc
- 施工总承包特级资质企业提供信息化解决方案-北京速恒 (1)(1).doc
- 光伏电池建模及仿真:PV曲线、IV曲线与温度光照影响因素解析
- 软件测试通过及BUG分级标准(1).docx
- 智慧商业街大数据建设综合解决方案(20200526222625)(1).pdf
- 斑马物联网e仓储—国际电商的得力新宠(1).ppt
- 完整word版单片机原理习题及答案(1).doc
- 人工智能在医疗领域的应用(1).docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
