338 lines
12 KiB
C#
338 lines
12 KiB
C#
|
|
using Face.Domain.Application;
|
|||
|
|
using Face.Domain.Entities;
|
|||
|
|
using Face.Domain.ViewModels;
|
|||
|
|
using Face.Services.Cache;
|
|||
|
|
using Face.Services.DBUtility.Common;
|
|||
|
|
using Face.Services.Manager;
|
|||
|
|
using Face.Web.Areas.App.Models;
|
|||
|
|
using PagedList;
|
|||
|
|
using SqlSugar;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Drawing;
|
|||
|
|
using System.IO;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using System.Web;
|
|||
|
|
using System.Web.Hosting;
|
|||
|
|
using System.Web.Mvc;
|
|||
|
|
using System.Xml.Serialization;
|
|||
|
|
using static Face.Web.Areas.App.Models.Roominfo;
|
|||
|
|
|
|||
|
|
namespace Face.Web.Areas.App.Controllers
|
|||
|
|
{
|
|||
|
|
public class LodgerController : BaseController
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
// GET: App/Lodger
|
|||
|
|
|
|||
|
|
public List<Hosts> GetRoomChecks//开房入住信息缓存
|
|||
|
|
{
|
|||
|
|
get { return CacheHelp.GetRoomCheck(); }
|
|||
|
|
}
|
|||
|
|
public List<Hosts> GetRoom//房间缓存
|
|||
|
|
{
|
|||
|
|
get { return CacheHelp.GetRoomGroup(); }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public ActionResult LodgerInfo(int? page, string TiaoJian = null, string band = null)//住客信息
|
|||
|
|
{
|
|||
|
|
List<int> lit = (List<int>)Session["list"];
|
|||
|
|
List<TBL_ROOM_BASIC_INFO> ZongRoominfo = (List<TBL_ROOM_BASIC_INFO>)Session["ZongRoominfo"];
|
|||
|
|
|
|||
|
|
var hotellist = lit;
|
|||
|
|
IPagedList<Lodger> userPagedList = null;
|
|||
|
|
List<Lodger> lodgers = new List<Lodger>();
|
|||
|
|
|
|||
|
|
List<CheckInInfo> storage = new List<CheckInInfo>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (SqlSugarClient db = SqlSugarBase.GesmartDb())
|
|||
|
|
{
|
|||
|
|
List<CheckInInfo> checkInInfos = new List<CheckInInfo>();
|
|||
|
|
var infoin =db.Queryable<CheckInInfo>().ToList();
|
|||
|
|
for (int i = 0; i < hotellist.Count; i++)
|
|||
|
|
{
|
|||
|
|
var id = hotellist[i];
|
|||
|
|
checkInInfos.AddRange(infoin.Where(x => x.HotelCode == id));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ViewBag.inall = checkInInfos;
|
|||
|
|
var checkInInfo = db.Queryable<CheckInInfo>()
|
|||
|
|
.Where(it => hotellist.Contains(it.HotelCode.Value)).ToList()
|
|||
|
|
.GroupBy(x => x.IdNumber).ToList();
|
|||
|
|
for (var item = 0; item < checkInInfo.Count; item++)
|
|||
|
|
{
|
|||
|
|
storage.Add(checkInInfo[item].ToList()[0]);
|
|||
|
|
}
|
|||
|
|
ViewData["storage"] = storage;
|
|||
|
|
|
|||
|
|
|
|||
|
|
var lodge = db.Queryable<Lodger>().ToList();
|
|||
|
|
|
|||
|
|
for (int i = 0; i < storage.Count; i++)
|
|||
|
|
{
|
|||
|
|
List<Lodger> list = new List<Lodger>();
|
|||
|
|
var id = storage[i].IdNumber;
|
|||
|
|
list = lodge.Where(s => s.IDNumber == id).ToList();
|
|||
|
|
lodgers.AddRange(list);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
ViewData["storage"] = storage;
|
|||
|
|
//第几页
|
|||
|
|
int pageNumber = page ?? 1;
|
|||
|
|
|
|||
|
|
// //每页显示多少条
|
|||
|
|
int pageSize = 10;
|
|||
|
|
//根据ID升序排序
|
|||
|
|
lodgers = lodgers.OrderByDescending(x => x.LodgerId).ToList();
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (TiaoJian != "" && TiaoJian != null)
|
|||
|
|
{
|
|||
|
|
ViewData["infose"] = TiaoJian;
|
|||
|
|
lodgers = lodgers.Where(x => x.LodgerNmae.Contains(TiaoJian)).ToList();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// //通过ToPagedList扩展方法进行分页
|
|||
|
|
userPagedList = lodgers.ToPagedList(pageNumber, pageSize);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
LogHelp.WriteExceptionLog(ex, Session["username"].ToString());
|
|||
|
|
throw;
|
|||
|
|
}
|
|||
|
|
// //将分页处理后的列表传给View
|
|||
|
|
return View(userPagedList);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public ActionResult Openhouse(int? page, string TiaoJian = null)//开房信息
|
|||
|
|
{
|
|||
|
|
List<int> lit = (List<int>)Session["list"];
|
|||
|
|
List<TBL_ROOM_BASIC_INFO> ZongRoominfo = (List<TBL_ROOM_BASIC_INFO>)Session["ZongRoominfo"];
|
|||
|
|
|
|||
|
|
List<CheckInInfo> li = new List<CheckInInfo>();
|
|||
|
|
using (SqlSugarClient db = SqlSugarBase.GesmartDb())
|
|||
|
|
{
|
|||
|
|
var userList = db.Queryable<CheckInInfo>().ToList();
|
|||
|
|
//第几页
|
|||
|
|
int pageNumber = page ?? 1;
|
|||
|
|
|
|||
|
|
//每页显示多少条
|
|||
|
|
int pageSize = 10;
|
|||
|
|
for (int i = 0; i < lit.Count; i++)
|
|||
|
|
{
|
|||
|
|
var id = Convert.ToInt32(lit[i]);
|
|||
|
|
li.AddRange(userList.Where(x => x.HotelCode == id).ToList());
|
|||
|
|
}
|
|||
|
|
li = li.Where(x => x.checkOutTime.Value.ToString("yyyy-MM-dd") == "2000-01-01").ToList();
|
|||
|
|
//根据ID升序排序
|
|||
|
|
li = li.OrderByDescending(x => x.id).ToList();
|
|||
|
|
|
|||
|
|
if (TiaoJian != "" && TiaoJian != null)
|
|||
|
|
{
|
|||
|
|
ViewData["infose2"] = TiaoJian;
|
|||
|
|
li = li.Where(x => x.Name.Contains(TiaoJian)).ToList();
|
|||
|
|
}
|
|||
|
|
//通过ToPagedList扩展方法进行分页
|
|||
|
|
IPagedList<CheckInInfo> userPagedList = li.ToPagedList(pageNumber, pageSize);
|
|||
|
|
|
|||
|
|
//CheckInfo r = DESerializer<CheckInfo>();
|
|||
|
|
|
|||
|
|
//将分页处理后的列表传给View
|
|||
|
|
return View(userPagedList);
|
|||
|
|
//反序列化
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
//public ActionResult Addedpersonnel()//添加人员信息
|
|||
|
|
//{
|
|||
|
|
// return View();
|
|||
|
|
//}
|
|||
|
|
public ActionResult AddCheckinfo()//添加入住人员信息
|
|||
|
|
{
|
|||
|
|
return View();
|
|||
|
|
}
|
|||
|
|
public ActionResult Addpeople(Lodger lr)//添加客户信息操作
|
|||
|
|
{
|
|||
|
|
ReturnResult result = new ReturnResult();
|
|||
|
|
if (string.IsNullOrEmpty(lr.IDNumber) | string.IsNullOrEmpty(lr.LodgerNmae) | string.IsNullOrEmpty(lr.phonenumber) | string.IsNullOrEmpty(lr.Sex.ToString()))
|
|||
|
|
{
|
|||
|
|
result.Status = 100;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
lr.Sourcedian = 0;
|
|||
|
|
lr.CheckInDate = DateTime.Now;
|
|||
|
|
// if (SqlOperationsData.addClient(lr) != 0)
|
|||
|
|
// {
|
|||
|
|
// result.Status = 200;
|
|||
|
|
// }
|
|||
|
|
// else
|
|||
|
|
// {
|
|||
|
|
// result.Status = 500;
|
|||
|
|
// }
|
|||
|
|
//}
|
|||
|
|
}
|
|||
|
|
return Json(result);
|
|||
|
|
}
|
|||
|
|
public ActionResult addcheckin(TestUser co)//添加入住信息操作
|
|||
|
|
{
|
|||
|
|
ReturnResult result = new ReturnResult();
|
|||
|
|
using (SqlSugarClient db = SqlSugarBase.GesmartDb())
|
|||
|
|
{
|
|||
|
|
TestUser test= db.Queryable<TestUser>().First(it => it.phone == co.phone);
|
|||
|
|
if (test!=null)
|
|||
|
|
{
|
|||
|
|
result.Status = 700;
|
|||
|
|
return Json(result);
|
|||
|
|
}
|
|||
|
|
TestUser tests = db.Queryable<TestUser>().First(it => it.idNumber == co.idNumber);
|
|||
|
|
if (tests != null)
|
|||
|
|
{
|
|||
|
|
result.Status = 800;
|
|||
|
|
return Json(result);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (string.IsNullOrEmpty(co.picture))
|
|||
|
|
{
|
|||
|
|
result.Status = 300;
|
|||
|
|
}
|
|||
|
|
else if (string.IsNullOrEmpty(co.idNumber) | string.IsNullOrEmpty(co.name))
|
|||
|
|
{
|
|||
|
|
result.Status = 100;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
co.establish = Session["id"].ToString();
|
|||
|
|
co.creationTime = DateTime.Now;
|
|||
|
|
co.state = 1;
|
|||
|
|
using (SqlSugarClient db = SqlSugarBase.GesmartDb())
|
|||
|
|
{
|
|||
|
|
db.Insertable(co).ExecuteCommand();
|
|||
|
|
}
|
|||
|
|
result.Status = 200;
|
|||
|
|
}
|
|||
|
|
catch (Exception e)
|
|||
|
|
{
|
|||
|
|
result.Status = 100;
|
|||
|
|
LogHelp.WriteExceptionLog(e, Session["username"].ToString());
|
|||
|
|
throw;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
return Json(result);
|
|||
|
|
}
|
|||
|
|
public ActionResult officialRoom(int hotelId)//房间下拉框
|
|||
|
|
{
|
|||
|
|
var geiRoomShow = GetRoom.Where(o => o.HotelID == hotelId).ToList();
|
|||
|
|
return Json(geiRoomShow);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 图像水平翻转
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="bmp">原来图像</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
//public bool HorizontalFlip(string orgimgsrc, string newimgsrc)
|
|||
|
|
//{
|
|||
|
|
// try
|
|||
|
|
// {
|
|||
|
|
|
|||
|
|
// using (Image originalImage = Image.FromFile(orgimgsrc))
|
|||
|
|
// {
|
|||
|
|
// using (Bitmap bitmap = new Bitmap(originalImage))
|
|||
|
|
// {
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
// var width = bitmap.Width;
|
|||
|
|
// var height = bitmap.Height;
|
|||
|
|
// Graphics g = Graphics.FromImage(bitmap);
|
|||
|
|
// Dictionary<string,Color> colorlist = new Dictionary<string, Color>();
|
|||
|
|
// for (int i = 0; i < width; i++)
|
|||
|
|
// {
|
|||
|
|
// for (int j = 0; j < height; j++)
|
|||
|
|
// {
|
|||
|
|
// colorlist.Add("_"+i+"_"+j,bitmap.GetPixel(i,j));
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// for (int i = 0; i < width; i++)
|
|||
|
|
// {
|
|||
|
|
// for (int j = 0; j < height; j++)
|
|||
|
|
// {
|
|||
|
|
// bitmap.SetPixel(i,j, colorlist["_" +(width-1- i) + "_" + (j)]);
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// //Rectangle rect = new Rectangle(0, 0, width, height);
|
|||
|
|
// //bitmap.RotateFlip(RotateFlipType.Rotate180FlipXY);
|
|||
|
|
// //g.DrawImage(bitmap, rect);
|
|||
|
|
// //if (System.IO.File.Exists(name))
|
|||
|
|
// //{
|
|||
|
|
// // System.IO.File.Delete(name);
|
|||
|
|
// //}
|
|||
|
|
// bitmap.Save(newimgsrc);
|
|||
|
|
// bitmap.Dispose();
|
|||
|
|
// return true;
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
|
|||
|
|
// }
|
|||
|
|
// catch (Exception ex)
|
|||
|
|
// {
|
|||
|
|
// return false;
|
|||
|
|
// }
|
|||
|
|
|
|||
|
|
//}
|
|||
|
|
//public string Base64StringToImage()
|
|||
|
|
//{
|
|||
|
|
// try
|
|||
|
|
// {
|
|||
|
|
// string TimePath = HostingEnvironment.MapPath("~/Upload/Image/");//保存路径
|
|||
|
|
// TimePath += DateTime.Now.ToString("yyyy-MM-dd");
|
|||
|
|
// TimePath += "\\";
|
|||
|
|
// var oFile = Request.Files[0];//获得上传的文件
|
|||
|
|
// //获取后缀名
|
|||
|
|
// string ext = Path.GetExtension(Request.Files[0].FileName);
|
|||
|
|
// //string fullPath = Guid.NewGuid().ToString() + ext;
|
|||
|
|
// string fullPath = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss fff") + ext;
|
|||
|
|
// if (!Directory.Exists(TimePath))//判断文件夹是否存在
|
|||
|
|
// {
|
|||
|
|
// Directory.CreateDirectory(TimePath);//不存在则创建文件夹
|
|||
|
|
// }
|
|||
|
|
// oFile.SaveAs(TimePath + fullPath);
|
|||
|
|
// if(HorizontalFlip(TimePath + fullPath, TimePath + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss fff") + ext))
|
|||
|
|
// {
|
|||
|
|
// return TimePath + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss fff") + ext;
|
|||
|
|
|
|||
|
|
// }
|
|||
|
|
// else
|
|||
|
|
// {
|
|||
|
|
// return "";
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// catch (Exception ex)
|
|||
|
|
// {
|
|||
|
|
// return "";
|
|||
|
|
// }
|
|||
|
|
|
|||
|
|
//}
|
|||
|
|
//public string ConvertImageToBase64(Image file)
|
|||
|
|
//{
|
|||
|
|
// using (MemoryStream memoryStream = new MemoryStream())
|
|||
|
|
// {
|
|||
|
|
// file.Save(memoryStream, file.RawFormat);
|
|||
|
|
// byte[] imageBytes = memoryStream.ToArray();
|
|||
|
|
// return Convert.ToBase64String(imageBytes);
|
|||
|
|
// }
|
|||
|
|
//}
|
|||
|
|
}
|
|||
|
|
}
|