初始化
This commit is contained in:
208
Face.Web/Controllers/HomeController.cs
Normal file
208
Face.Web/Controllers/HomeController.cs
Normal file
@@ -0,0 +1,208 @@
|
||||
using Face.Domain.Application;
|
||||
using Face.Domain.Entities;
|
||||
using Face.Domain.ViewModels;
|
||||
using Face.Services.Cache;
|
||||
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.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.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
Areas.App.Models.Root judgedate = new Areas.App.Models.Root();
|
||||
List<AuthItem> authItems = new List<AuthItem>();
|
||||
ReturnResult result = new ReturnResult();
|
||||
DateTime lastUpdated = DateTime.Now;
|
||||
public ActionResult Index(string Token = null)
|
||||
{
|
||||
string username = "";
|
||||
if (Token == null)
|
||||
{
|
||||
return Redirect("/App/Login/Index");
|
||||
}
|
||||
try
|
||||
{
|
||||
int sum = 0;
|
||||
|
||||
var HotelList = SqlSugarBase.authoriydb.Queryable<Hotels>().ToList();
|
||||
//var roomlist = horomm.Database.SqlQuery<Hosts>(@"select Id ,RoomStatusID,HotelID,[RoomNumber],[Status] = convert(int,[Status]),[Desc] =[remark],[CreateTime]=[registerdate] from BLW.CRICS.[dbo].tb_Hosts ").ToList();
|
||||
Session["HotelList"] = HotelList;
|
||||
//Session["roomlist"] = roomlist;
|
||||
//permissionStatic.lit.Clear();
|
||||
if (Token != null && Token != "")
|
||||
{
|
||||
string ip = Services.Tool.IPHelper.GetIP();
|
||||
var UserAgent = HttpContext.Request.UserAgent;
|
||||
judgedate = jumpDenglv(Token, ip, UserAgent);
|
||||
List<Areas.App.Models.Root> listSession = new List<Areas.App.Models.Root>();
|
||||
List<int> lit = new List<int>();
|
||||
List<TBL_ROOM_BASIC_INFO> ZongRoominfo = new List<TBL_ROOM_BASIC_INFO>();
|
||||
if (judgedate.Status == 200)
|
||||
{
|
||||
|
||||
|
||||
Session["judeg"] = judgedate.Data.Userinfo.HeadImg;
|
||||
Session["username"] = judgedate.Data.Userinfo.Uid;
|
||||
username = judgedate.Data.Userinfo.Uid;
|
||||
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());
|
||||
lit.Add(s);//添加酒店权限id
|
||||
foreach (var ite in iten.Auth)
|
||||
{
|
||||
authItems.Add(ite);//添加操作权限
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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>();//获取总数
|
||||
|
||||
|
||||
|
||||
|
||||
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["ZongRoominfo"] = ZongRoominfo;//总房间数
|
||||
result.Message = "/APP/Home/Index";
|
||||
result.Status = 200;
|
||||
return Redirect("/App/Home/Index");
|
||||
}
|
||||
else
|
||||
{
|
||||
return Redirect("/App/Login/Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelp.WriteExceptionLog(ex);
|
||||
throw;
|
||||
}
|
||||
return Redirect("/App/Login/Index");
|
||||
}
|
||||
/// <summary>
|
||||
/// API访问登录
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public Areas.App.Models.Root jumpDenglv(string token,string ip,string requesthead=null, bool isdata=true)
|
||||
{
|
||||
|
||||
string url = "http://auth.blv-oa.com/OTApi/MoreLogin";
|
||||
string postData = string.Format("Token={0}&appid=2&Ip={1}&UserAgent={2}&IsData={3}", token, ip, requesthead, isdata);
|
||||
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();
|
||||
Areas.App.Models.Root info = JsonConvert.DeserializeObject<Areas.App.Models.Root>(Show);//josn转换实体类
|
||||
sw.Dispose();
|
||||
sw.Close();
|
||||
sr.Dispose();
|
||||
sr.Close();
|
||||
s.Dispose();
|
||||
s.Close();
|
||||
return info;
|
||||
}
|
||||
public ActionResult Error()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user