package cn.sdut.controller.admin;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import cn.sdut.service.AccountService;
import cn.sdut.util.FaceCompare;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import cn.sdut.entity.BookOrder;
import cn.sdut.entity.RoomType;
import cn.sdut.entity.admin.Checkin;
import cn.sdut.entity.admin.Room;
import cn.sdut.page.admin.Page;
import cn.sdut.service.BookOrderService;
import cn.sdut.service.RoomTypeService;
import cn.sdut.service.admin.CheckinService;
import cn.sdut.service.admin.RoomService;
/**
* 入住管理后台控制器
*
*/
@RequestMapping("/admin/checkin")
@Controller
public class CheckinController {
@Autowired
private RoomService roomService;
@Autowired
private RoomTypeService roomTypeService;
@Autowired
private BookOrderService bookOrderService;
@Autowired
private CheckinService checkinService;
@Autowired
private AccountService accountService;
/**
* 入住管理列表页面
* @param model
* @return
*/
@RequestMapping(value="/list",method=RequestMethod.GET)
public ModelAndView list(ModelAndView model){
model.addObject("roomTypeList", roomTypeService.findAll());
model.addObject("roomList", roomService.findAll());
model.addObject("accountList", accountService.findAll());
model.setViewName("checkin/list");
return model;
}
@RequestMapping(value = "/comparePhoto", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> comparePhoto(@RequestParam String photo1, @RequestParam String photo2){
Map<String, String> ret = new HashMap<>();
try {
double result = FaceCompare.compare_image(photo1, photo2);
ret.put("type", "success");
ret.put("result", String.valueOf(result));
if (result >= 0.4){
ret.put("msg", "人脸匹配!");
}else{
ret.put("msg", "人脸不匹配!");
}
} catch (Exception e){
ret.put("type", "error");
ret.put("msg", "发生错误");
e.printStackTrace();
}
return ret;
}
/**
* 入住信息添加操作
* @param checkin
* @return
*/
@RequestMapping(value="/add",method=RequestMethod.POST)
@ResponseBody
public Map<String, String> add(Checkin checkin,
@RequestParam(name="bookOrderId",required=false) Long bookOrderId
){
Map<String, String> ret = new HashMap<>();
if(checkin == null){
ret.put("type", "error");
ret.put("msg", "请填写正确的入住信息!");
return ret;
}
if(checkin.getRoomId() == null){
ret.put("type", "error");
ret.put("msg", "房间不能为空!");
return ret;
}
if(checkin.getRoomTypeId() == null){
ret.put("type", "error");
ret.put("msg", "房型不能为空!");
return ret;
}
if(StringUtils.isEmpty(checkin.getName())){
ret.put("type", "error");
ret.put("msg", "入住联系人名称不能为空!");
return ret;
}
if(StringUtils.isEmpty(checkin.getMobile())){
ret.put("type", "error");
ret.put("msg", "入住联系人手机号不能为空!");
return ret;
}
if(StringUtils.isEmpty(checkin.getIdCard())){
ret.put("type", "error");
ret.put("msg", "联系人身份证号不能为空!");
return ret;
}
if(StringUtils.isEmpty(checkin.getArriveDate())){
ret.put("type", "error");
ret.put("msg", "到达时间不能为空!");
return ret;
}
if(StringUtils.isEmpty(checkin.getLeaveDate())){
ret.put("type", "error");
ret.put("msg", "离店时间不能为空!");
return ret;
}
checkin.setCreateTime(new Date());
if(checkinService.add(checkin) <= 0){
ret.put("type", "error");
ret.put("msg", "添加失败,请联系管理员!");
return ret;
}
RoomType roomType = roomTypeService.find(checkin.getRoomTypeId());
if(bookOrderId != null){
//从预订来的入住单(入住既可以是直接入住也可以是已经预订的人来入住)
BookOrder bookOrder = bookOrderService.find(bookOrderId);
bookOrder.setStatus(1);
bookOrderService.edit(bookOrder);
//roomType.setBookNum(roomType.getBookNum() - 1);//预订数减1
}else{
roomType.setAvailableNum(roomType.getAvailableNum() - 1);
}
//入住成功后去修改该房型的预订数
if(roomType != null){
roomType.setLivedNum(roomType.getLivedNum() + 1);//入住数加1
roomTypeService.updateNum(roomType);
//如果可用的房间数为0,则设置该房型状态已满
if(roomType.getAvailableNum() == 0){
roomType.setStatus(0);
roomTypeService.edit(roomType);
}
}
Room room = roomService.find(checkin.getRoomId());
if(room != null){
//要把房间状态设置为已入住
room.setStatus(1);
roomService.edit(room);
}
ret.put("type", "success");
ret.put("msg", "入住成功!");
return ret;
}
/**
* 入住信息编辑操作
* @return
*/
@RequestMapping(value="/edit",method=RequestMethod.POST)
@ResponseBody
public Map<String, String> edit(Checkin checkin,@RequestParam(name="bookOrderId",required=false) Long bookOrderId){
Map<String, String> ret = new HashMap<String, String>();
if(checkin == null){
ret.put("type", "error");
ret.put("msg", "请填写正确的入住信息!");
return ret;
}
if(checkin.getRoomId() == null){
ret.put("type", "error");
ret.put("msg", "房间不能为空!");
return ret;
}
if(checkin.getRoomTypeId() == null){
ret.put("type", "error");
ret.put("msg", "房型不能为空!");
return ret;
}
if(StringUtils.isEmpty(checkin.getName())){
ret.put("type", "error");
ret.put("msg", "入住联系人名称不能为空!");
return ret;
}
if(StringUtils.isEmpty(checkin.getMobile())){
ret.put("type", "error");
ret.put("msg", "入住联系人手机号不能为空!");
return ret;
}
if(StringUtils.isEmpty(checkin.getIdCard())){
ret.put("type", "error");
ret.put("msg", "联系人身份证号不能为空!");
return ret;
}
if(StringUtils.isEmpty(checkin.getArriveDate())){
ret.put("type", "error");
ret.put("msg", "到达时间不能为空!");
return ret;
}
if(StringUtils.isEmpty(checkin.getLeaveDate())){
ret.put("type", "error");
ret.put("msg", "离店时间不能为空!");
return ret;
}
Checkin existCheckin = checkinService.find(checkin.getId());
if(existCheckin == null){
ret.put("type", "error");
ret.put("msg", "请选择正确的入住信息进行编辑!");
return ret;
}
if(checkinService.edit(checkin) <= 0){
ret.put("type", "error");
ret.put("msg", "编辑失败,请联系管理员!");
return ret;
}
//编辑成功之后:1:判断房型是否发生变化,2:判断房间是否发生变化,3:判断是否是从预订订单来的信息
//首先判断是否是从预订来的入住信息
RoomType oldRoomType = roomTypeService.find(existCheckin.getRoomTypeId());
RoomType newRoomType = roomTypeService.find(checkin.getRoomTypeId());
//房型入住数不收预订订单的影响
if(oldRoomType.getId().longValue() != newRoomType.getId().longValue()){
//说明房型发生了变化,原来的房型入住数恢复,新的房型入住数增加
oldRoomType.setLivedNum(oldRoomType.getLivedNum() - 1);
newRoomType.setLivedNum(newRoomType.getLivedNum() + 1);
if(bookOrderId == null){
oldRoomType.setAvailableNum(oldRoomType.getAvailableNum() + 1);
newRoomType.setAvailableNum(newRoomType.getAvailableNum() - 1);
}
}
roomTypeService.updateNum(newRoomType);
roomTypeService.updateNum(oldRoomType);
//判断房间是否发生变化
if(checkin.getRoomId().longValue() != existCheckin.getRoomId().longValue()){
//表示房间发生了变化
Room oldRoom = roomService.find(existCheckin.getRoomId());
Room newRoom = roomService.find(checkin.getRoomId());
oldRoom.setStatus(0);//原来的房间可入住
newRoom.setStatus(1);//现在的房间已入住
roomService.edit(newRoom);
roomService.edit(oldRoom);
}
ret.put("type", "success");
ret.put("msg", "修改成功!");
return ret;
}
/**
* 分页查询入住信息
* @param name
* @param page
* @re
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【资源说明】 毕业设计 基于SSM+OpenCV的酒店客房预订系统的设计与实现+全部资料齐全+部署文档 优秀项目.zip毕业设计 基于SSM+OpenCV的酒店客房预订系统的设计与实现+全部资料齐全+部署文档 优秀项目.zip 【备注】 1、该项目是高分毕业设计项目源码,已获导师指导认可通过,答辩评审分达到95分 2、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 3、本项目适合计算机相关专业(如软件工程、计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载使用,也可作为毕业设计、课程设计、作业、项目初期立项演示等,当然也适合小白学习进阶。 4、如果基础还行,可以在此代码基础上进行修改,以实现其他功能,也可直接用于毕设、课设、作业等。 欢迎下载,沟通交流,互相学习,共同进步!
资源推荐
资源详情
资源评论
收起资源包目录
毕业设计 基于SSM+OpenCV的酒店客房预订系统的设计与实现+全部资料齐全+部署文档 优秀项目.zip (2000个子文件)
icon.css 132KB
easyui.css 46KB
easyui.css 46KB
easyui.css 45KB
easyui.css 45KB
easyui.css 43KB
jquery-ui.min.css 25KB
index.css 20KB
tabs.css 8KB
tabs.css 8KB
tabs.css 8KB
tabs.css 8KB
reservation.css 6KB
tabs.css 6KB
login.css 5KB
datagrid.css 5KB
datagrid.css 5KB
datagrid.css 5KB
datagrid.css 5KB
datagrid.css 4KB
linkbutton.css 4KB
linkbutton.css 4KB
linkbutton.css 4KB
style.css 4KB
calendar.css 4KB
calendar.css 4KB
calendar.css 4KB
calendar.css 4KB
calendar.css 4KB
tree.css 3KB
tree.css 3KB
tree.css 3KB
tree.css 3KB
tree.css 3KB
panel.css 3KB
panel.css 3KB
panel.css 3KB
linkbutton.css 3KB
linkbutton.css 3KB
panel.css 3KB
order.css 2KB
panel.css 2KB
menu.css 2KB
menu.css 2KB
menu.css 2KB
menu.css 2KB
menu.css 2KB
window.css 2KB
window.css 2KB
window.css 2KB
window.css 2KB
tooltip.css 2KB
tooltip.css 2KB
tooltip.css 2KB
tooltip.css 2KB
tooltip.css 2KB
layout.css 2KB
layout.css 2KB
layout.css 2KB
layout.css 2KB
layout.css 2KB
slider.css 2KB
slider.css 2KB
slider.css 2KB
slider.css 2KB
slider.css 2KB
icon.css 2KB
window.css 2KB
searchbox.css 1KB
searchbox.css 1KB
searchbox.css 1KB
searchbox.css 1KB
searchbox.css 1KB
wu.css 1KB
reset.css 1KB
pagination.css 1KB
pagination.css 1KB
pagination.css 1KB
pagination.css 1KB
pagination.css 1KB
register.css 1KB
spinner.css 1KB
spinner.css 1KB
spinner.css 1KB
spinner.css 1KB
spinner.css 1KB
combo.css 1017B
combo.css 1017B
combo.css 1017B
combo.css 1008B
combo.css 1005B
splitbutton.css 981B
splitbutton.css 978B
splitbutton.css 975B
splitbutton.css 975B
splitbutton.css 972B
accordion.css 838B
accordion.css 835B
accordion.css 835B
accordion.css 829B
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
不走小道
- 粉丝: 3224
- 资源: 5113
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功