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
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/e908d3f559a440a89ffab26bc7ee7a71_weixin_38343072.jpg!1)
马coder
- 粉丝: 1215
- 资源: 6602
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- 上市公司澄清公告数据集.xlsx
- 基于Matlab实现的基于车辆运动学,实现低速度下的MPC轨迹跟踪(高分项目)
- 安卓Android社团管理App+源代码+文档说明+数据库(高分项目).zip
- 基于安卓Android的社团管理App+sql数据库(高分毕设项目).zip
- 通用性I2C接口的应用之驱动SHT20(N32G45XVL-STB)
- 基于Python+BERT+词典开发的医药知识图谱自动问答系统实现+源代码+文档说明+使用教程+数据.zip
- 基于yolov8对6种水果数据集的目标检测实现【数据+代码+训练好的权重】
- ѧ�����˿α�_23252202222.xls
- UVa12227/LA4618 Wormholes
- WIN10及WIN11系统PL2303USB 串口驱动问题解决方法,亲测好用
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)