初始化

This commit is contained in:
2025-11-25 17:41:24 +08:00
commit 4cdf0f0f85
3383 changed files with 1050962 additions and 0 deletions

View File

@@ -0,0 +1,226 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Face.Domain.Entities;
using Face.Services.Cache;
using Face.Web.Areas.App.Models;
using Face.Services.DBUtility.Custom;
using Face.Domain.Application;
using PagedList;
using SqlSugar;
using Face.Domain.ViewModels;
using Face.Services.DBUtility.Common;
using Face.Services.Manager;
using static Face.Web.Areas.App.Controllers.FaceController;
using static Face.Web.Areas.App.Controllers.InterfaceController;
using static Face.Web.Areas.App.Models.Roominfo;
namespace Face.Web.Areas.App.Controllers
{
public class RoomController : Controller
{
public ActionResult TestRoomall(string Sn)
{
return View();
}
[HttpPost]
public ActionResult InquireRoomall(Condition data)
{
List<int> lit = (List<int>)Session["list"];
List<AuthItem> authItem = (List<AuthItem>)Session["authItems"];
string strSql = "";
string strCntSql = "";
//string selectSql = "select r.ROOM_ID as InnerRoomId, h.Id as HotelId, h.Name as HotelName, h.Code as ExternalHotelCode, r.ROOM_NUMBER as RoomNumberd.* ";//d.bindingStatus, d.SerialNo, d.Status, d.maintainStatus ";
string selectSql = "select r.ROOM_OLD_ID as InnerRoomId, h.Id as HotelId, h.Name as HotelName, h.Code as ExternalHotelCode, r.ROOM_NUMBER as RoomNumber, r.RoomStatusID as RoomCheckInStatus, ";
selectSql += "d.Facelid, d.SerialNo, d.CreatedDate, d.HotelCode, d.RoomId, d.Factory, d.Status, d.bindingDate, d.bindingStatus, d.faceIp, d.faceAddress, d.maintainStatus ";
string fromSql = "";
string orderSql = "";
string limitSql = "";
string cond1Sql = "";
string cond2Sql = "";
string cond3Sql = "";
string tbl1Sql = "";
for (int i = 0; i < lit.Count; i++)
{
cond1Sql += (" Id=" + lit[i] + " or");
}
cond1Sql = cond1Sql.Substring(0, cond1Sql.Length - 2);
if (authItem[0].AuthorityId == 3)
{
cond1Sql += " or Id=0 or Id is null ";
}
//酒店id判断
Session["defaultHotelId"] = data.HotelID;
HttpCookie aCookie = new HttpCookie("lastHotelId");
aCookie.Value = Convert.ToString(data.HotelID);
aCookie.Expires = DateTime.Now.AddDays(7);
Response.Cookies.Add(aCookie);
if (data.HotelID == -1)
{
cond2Sql += " and (Id=0 or Id is null) ";
}
else if (data.HotelID != 0)
{
cond2Sql += " and Id=" + data.HotelID;
}
tbl1Sql = "(select * from authoritydb.hotels where 0=0 and (" + cond1Sql + ") " + cond2Sql + " ) h ";
fromSql = "from " + tbl1Sql + "join blv_rcu_db.tbl_room_basic_info r on h.Id = r.HOTEL_OLD_ID ";
fromSql += "left join face.devicemanage d on r.ROOM_OLD_ID=d.RoomId ";
//-1代表全部房间
if (data.Notbing != -1)
{
if(data.Notbing == 0)
cond3Sql += "where d.bindingStatus=" + data.Notbing + " or d.bindingStatus is null "; //0 or null both means no binding
else
cond3Sql += "where d.bindingStatus=" + data.Notbing + " ";
}
if (data.FaceName != "" && data.FaceName != null)
{
if (cond3Sql.IndexOf("where") < 0)
cond3Sql += "where ";
else
cond3Sql += "and ";
cond3Sql += "d.SerialNo like '%" + data.FaceName + "%' ";
}
orderSql = "order by h.Name, r.ROOM_NUMBER ";
limitSql = "LIMIT " + (data.dataMin) + ",8; ";
strSql = selectSql + fromSql + cond3Sql + orderSql + limitSql;
List<InfoRoomall> allRooms = new DALHelperCustom<InfoRoomall>("DeviceManage").SqlQueryGetList(strSql);
strCntSql = "select COUNT(*) " + fromSql + cond3Sql + orderSql;
DataSet dsCnt = Fasce.Services.DBUtility.Custom.DbHelperMySqlCustom.Query(strCntSql);
int cnt = 0;
int cntmode = 0;
if (dsCnt != null && dsCnt.Tables.Count > 0)
{
DataRow dr = dsCnt.Tables[0].Rows[0];
cnt = Convert.ToInt32(dr[0]);
cntmode = cnt % 8;
}
if (allRooms != null && cnt != 0)
{
ViewBag.count = cnt;
ViewBag.modcount = cntmode;
ViewBag.curpagenum = data.Pages;
ViewBag.allpage = cnt / 8 + (cntmode == 0 ? 0 : 1);
}
else
{
allRooms = null;
}
DateTime dt = Convert.ToDateTime("2000-01-01");
var stillcheckin = SqlSugarBase.GesmartDb().Queryable<CheckInInfo>().Where(s => s.checkOutTime == dt).ToList();
ViewData["sungo"] = stillcheckin;
return PartialView("InquireRoomall", allRooms);
}
[HttpPost]
public ActionResult BindFaceDeviceToRoom(obje obje)//房间绑定人脸机操作
{
ReturnResult result = new ReturnResult();
try
{
if (SqlOperationsData.reviseRommFace(obje.hotel, obje.romm, obje.faceNo) != 0)
{
FaceBinding binding = new FaceBinding
{
bindingDate = DateTime.Now,
HotelCode = int.Parse(obje.hotel),
OperatorType = true,
RoomId = obje.romm,
SerialNo = obje.faceNo,
Operator = Session["username"].ToString()
};
if (SqlOperationsData.bindingState(binding) != 0)
{
result.Status = 200;
result.Message = "为房间添加人脸机成功";
}
}
else
{
result.Status = 500;
}
}
catch (Exception ex)
{
LogHelp.WriteExceptionLog(ex, Session["username"].ToString());
result.Status = 100;
}
return Json(result);
}
[HttpPost]
public ActionResult RemoveFaceDeviceFromRoom(obje hotelno)
{
ReturnResult result = new ReturnResult();
try
{
if (SqlOperationsData.unbundleoperateRoom(hotelno.faceNo) != 0)
{
FaceBinding binding = new FaceBinding
{
bindingDate = DateTime.Now,
HotelCode = int.Parse(hotelno.hotel),
OperatorType = false,
RoomId = hotelno.romm,
SerialNo = hotelno.faceNo,
Operator = Session["username"].ToString()
};
if (SqlOperationsData.bindingState(binding) != 0)
result.Status = 200;
}
else
{
result.Status = 500;
}
}
catch (Exception ex)
{
LogHelp.WriteExceptionLog(ex, Session["username"].ToString());
result.Status = 100;
}
return Json(result);
}
public class TwoRetDevList
{
public List<DeviceManage> allFreeOfHotel = new List<DeviceManage>();
public List<DeviceManage> allFree = new List<DeviceManage>();
}
[HttpGet]
public JsonResult GetFaceDeviceOfHotel(int hotelId)//根据酒店id有人脸机的房间下拉框
{
TwoRetDevList retObj = new TwoRetDevList();
using (SqlSugarClient db = SqlSugarBase.GesmartDb())
{
var allfree = db.Queryable<DeviceManage>().Where(x => x.bindingStatus == false).Select(x => x).ToList();
var allfreeofhotel = allfree.Where(y => Convert.ToInt32(y.HotelCode) == hotelId).ToList();
retObj.allFree = allfree;
retObj.allFreeOfHotel = allfreeofhotel;
}
return Json(retObj, JsonRequestBehavior.AllowGet);
}
}
}