初始化

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,264 @@
using Face.Domain.Application;
using Face.Domain.Entities;
using Face.Domain.ViewModels;
using Face.Services.Cache;
using Face.Services.DBUtility.Common;
using Face.Services.Enums;
using Face.Services.Extensions;
using Face.Services.Manager;
using Face.Web.Areas.App.Models;
using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.ServiceModel.Channels;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using static Face.Web.Areas.App.Models.Roominfo;
namespace Face.Web.Areas.App.Controllers
{
public class LoginController : Controller
{
[HttpPost]
public ActionResult test(string data = "")
{
string z = data[115].ToString();
portinfo ci = JsonConvert.DeserializeObject<portinfo>(data);
return View();
}
public ActionResult Index()
{
return View();
}
/// <summary>
/// 计算密码 Hash值
/// </summary>
/// <param name="password"></param>
/// <param name="entity"></param>
/// <returns></returns>
private string ComputePasswordHash(string password, Accountentity ay)
{
return StringExtensions.ToMD5(ay.Uid.ToUpper() + password + ay.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"));
}
/// <summary>
/// 登录
/// </summary>
/// <param name="username">用户名</param>
/// <param name="password">密码</param>
/// <returns></returns>
[HttpPost]
public ActionResult Login(string username, string password)
{
//记录数量
Session["ullist"] = 0;
Session["dp"] = 0;
Session["fbcount"] = 0;
Session["lodgeinfo"] = 0;
Session["sum"] = 0;
Session["li"] = 0;
Session["quantity"] = 0;
Session["pmslist"] = 0;
Session["lasttimehotelID"] = "";
int sum = 0;
List<TBL_ROOM_BASIC_INFO> ZongRoominfo=new List<TBL_ROOM_BASIC_INFO>();
using (SqlSugarClient rcu = SqlSugarBase.Gesmartblv_rcu_db())
{
ZongRoominfo = rcu.Queryable<TBL_ROOM_BASIC_INFO>().ToList();
}
string ip = Services.Tool.IPHelper.GetIP();
var result = new ReturnResult();
try
{
if (string.IsNullOrEmpty(username) | string.IsNullOrEmpty(password))
throw new CustomException("用户名或密码不能为空");
Models.Root judgedate = Denglv(username, password,ip);
List<AuthItem> authItems=new List<AuthItem>();
List<HotelsItem> Hotelslist =new List<HotelsItem>();
List<int> lit = new List<int>();
if (judgedate.Status == 200)
{
Session["judeg"] = judgedate.Data.Userinfo.HeadImg;
Session["username"] = username;
Session["id"] = judgedate.Data.Userinfo.Uid;
foreach (var item in judgedate.Data.HotelData)
{
foreach (var iten in item.Hotels)
{
int s = int.Parse(iten.HotelId.ToString());
Hotelslist.Add(iten);
lit.Add(s);//添加酒店权限id
foreach (var ite in iten.Auth)
{
authItems.Add(ite);//添加操作权限
}
}
}
var HotelList = SqlSugarBase.authoriydb.Queryable<Hotels>().ToList();
Session["HotelList"] = HotelList;
Session["authItems"] = authItems;
Task.Run(() =>
{
List<CheckInInfo> li = new List<CheckInInfo>();//获取在店住客总数
List<DeviceManage> dm = new List<DeviceManage>();//获取人脸机总数
List<Lodger> lr = new List<Lodger>();//获取住客总数
List<FaceBinding> fb = new List<FaceBinding>();//获取绑定人脸机总数
List<CheckInInfo> storage = new List<CheckInInfo>();
List<Dailyoperation> dp = new List<Dailyoperation>();//获取住客总数
List<pmsInterface> pms = new List<pmsInterface>();//获取住客总数
List<ULog> ul = new List<ULog>();//获取总数
SqlSugarBase.Db.Queryable<FaceBinding>().ToList();
using (SqlSugarClient db = SqlSugarBase.GesmartDb())
{
var dmlist = db.Queryable<DeviceManage>().ToList();//查询所有
var userList = db.Queryable<CheckInInfo>().ToList();//查询所有
var Loderlist = db.Queryable<Lodger>().ToList();//查询所有
var facelog =db.Queryable<FaceBinding>().ToList();//查询所有
var pmslist = db.Queryable<pmsInterface>().ToList();//查询所有
var dplist = db.Queryable<Dailyoperation>().ToList();//查询所有
var ullist = db.Queryable<ULog>().ToList();//查询所有
var hotellist = lit;
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;
for (int i = 0; i < storage.Count; i++)
{
var id = storage[i].IdNumber;
var lodge = db.Queryable<Lodger>().Where(s => s.IDNumber == id).ToList();
lr.AddRange(lodge);
}
for (int i = 0; i < lit.Count; i++)
{
var id = Convert.ToInt32(lit[i]);
dm.AddRange(dmlist.Where(x => x.HotelCode == id.ToString()).ToList());
li.AddRange(userList.Where(x => x.HotelCode == id).ToList());
fb.AddRange(facelog.Where(x => x.HotelCode == id).ToList());
dp.AddRange(dplist.Where(x => x.hotelCode == id).ToList());
ul.AddRange(ullist.Where(x => x.hotelcode == id).ToList());
pms.AddRange(pmslist.Where(x => x.hotelid == id).ToList());
}
li = li.Where(x => x.checkOutTime.Value.ToString("yyyy-MM-dd") == "2000-01-01").ToList();
for (int i = 0; i < authItems.Count; i++)
{
if (authItems[i].AuthotypeId == 5)
{
CacheHelp.Geiface(username + "pmslist", pms.Count());
}
if (authItems[i].AuthorityId == 3)
{
sum = 1;
}
}
if (sum == 1)
{
dm.AddRange(dmlist.Where(x => x.HotelCode == null || x.HotelCode == "").ToList());
}
}
CacheHelp.Geiface(username + "ullist", ul.Count());
CacheHelp.Geiface(username + "dp", dp.Count());
CacheHelp.Geiface(username + "fbcount", fb.Count());
CacheHelp.Geiface(username + "lodgeinfo", lr.Count());
CacheHelp.Geiface(username+"face", dm.Count());
CacheHelp.Geiface(username + "li", li.Count());
CacheHelp.Geiface(username + "quantity", lit.Count());
});
Session["list"] = lit;
Session["qxHotels"] = Hotelslist;
string strlhID = "";
int lastHotelID = 0;
if (Request.Cookies["lastHotelId"] != null)
{
strlhID = Request.Cookies["lastHotelId"].Value;
if (String.IsNullOrWhiteSpace(strlhID))
lastHotelID = 0;
else
lastHotelID = Convert.ToInt32(strlhID);
if (!lit.Contains(lastHotelID))
lastHotelID = 0;
}
Session["defaultHotelId"] = lit.Count > 0 ? (lastHotelID!=0 ? lastHotelID : lit[0]) : 0;
Session["ZongRoominfo"] = ZongRoominfo;//总房间数
result.Message = "/APP/Home/Index";
result.Status = 200;
}
else
{
throw new CustomException("用户名或密码错误");
}
}
catch (CustomException ex)
{
result.Message = ex.Message;
}
catch (Exception ex)
{
var s = ex.Message;
result.Message = "网络系统繁忙,请稍候再试!";
LogHelp.WriteExceptionLog(ex, this.GetType().Name);
//Logs.WriteErrorLog(HttpContext.Request.Url.ToString(), ex);
}
return Json(result, JsonRequestBehavior.AllowGet);
}
/// <summary>
/// API访问登录
/// </summary>
/// <param name="name"></param>
/// <param name="pwd"></param>
/// <returns></returns>
public Models.Root Denglv(string name, string pwd,string ip)
{
string url = "http://auth.blv-oa.com/OTApi/Login";
string postData = string.Format("Uid={0}&Pwd={1}&appid=2", name, pwd);
WebRequest request = WebRequest.Create(url);
request.Method = "Post";
request.ContentType = "application/x-www-form-urlencoded";
StreamWriter sw = new StreamWriter(request.GetRequestStream());
sw.Write(postData);
sw.Flush();
WebResponse response = request.GetResponse();
Stream s = response.GetResponseStream();
StreamReader sr = new StreamReader(s, Encoding.GetEncoding("UTF-8"));
string Show = sr.ReadToEnd();
Models.Root info = JsonConvert.DeserializeObject<Models.Root>(Show);//josn转换实体类
sw.Dispose();
sw.Close();
sr.Dispose();
sr.Close();
s.Dispose();
s.Close();
return info;
}
/// <summary>
/// 刷新会话超时时间
/// </summary>
/// <returns></returns>
public ActionResult RefreshSessionTimeout()
{
// 设置会话超时时间为120分钟2小时
Session.Timeout = 120;
return Json(new { Session.Timeout });
}
}
}