1092 lines
47 KiB
C#
1092 lines
47 KiB
C#
|
|
using Antlr.Runtime.Tree;
|
|||
|
|
using Face.Domain.Application;
|
|||
|
|
using Face.Domain.Entities;
|
|||
|
|
using Face.Services.Cache;
|
|||
|
|
using Face.Services.DBUtility.Custom;
|
|||
|
|
using Face.Web.Areas.App.Models;
|
|||
|
|
using MySql.Data.MySqlClient;
|
|||
|
|
using PagedList;
|
|||
|
|
using SqlSugar;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Drawing.Printing;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Net.Http.Headers;
|
|||
|
|
using System.Web;
|
|||
|
|
using System.Web.Mvc;
|
|||
|
|
using static Face.Web.Areas.App.Controllers.InterfaceController;
|
|||
|
|
using static Face.Web.Areas.App.Models.Roominfo;
|
|||
|
|
|
|||
|
|
namespace Face.Web.Areas.App.Controllers
|
|||
|
|
{
|
|||
|
|
public class HistoryStatusSearchCondition
|
|||
|
|
{
|
|||
|
|
public int page { set; get; }
|
|||
|
|
public string sn { get; set; }
|
|||
|
|
public int[] arrReason { get; set; }
|
|||
|
|
public string st { get; set; }
|
|||
|
|
public string ed { get; set; }
|
|||
|
|
|
|||
|
|
//true; show count
|
|||
|
|
/*
|
|||
|
|
* SELECT SN, COUNT(*) as cnt, '链路重新OnOpen, onError,onClose触发' as reason FROM `devicestatushistory`
|
|||
|
|
WHERE CreateTime > '2023-08-09 00:00:00' AND CreateTime < '2023-08-10 00:00:00' AND (Reason = '链路重新OnOpen触发' OR Reason = '链路重新OnOpen触发' OR Reason = '链路OnError触发')
|
|||
|
|
GROUP BY SN
|
|||
|
|
HAVING cnt > 2
|
|||
|
|
ORDER BY cnt desc
|
|||
|
|
*/
|
|||
|
|
//false; show original data
|
|||
|
|
/*
|
|||
|
|
* SELECT * FROM `devicestatushistory`
|
|||
|
|
WHERE CreateTime > '2023-08-09 00:00:00' AND CreateTime < '2023-08-10 00:00:00' AND (Reason = '链路重新OnOpen触发' OR Reason = '链路重新OnOpen触发' OR Reason = '链路OnError触发')
|
|||
|
|
ORDER BY CreateTime DESC
|
|||
|
|
*/
|
|||
|
|
//public bool isShowCount { get; set; }
|
|||
|
|
}
|
|||
|
|
public class countstatushistory
|
|||
|
|
{
|
|||
|
|
public string SN { get; set; }
|
|||
|
|
public string Factory { get; set; }
|
|||
|
|
public int cnt { get; set; }
|
|||
|
|
public string reason { get; set; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
public class combineddeviceinfo
|
|||
|
|
{
|
|||
|
|
public string SerialNo { get; set; }
|
|||
|
|
public string DeviceStatus { get; set; }
|
|||
|
|
public string HotelName { get; set; }
|
|||
|
|
public string RoomNumber { get; set; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public class expendcountstatushistory : countstatushistory
|
|||
|
|
{
|
|||
|
|
public string hotel { get; set; }
|
|||
|
|
public string room { get; set; }
|
|||
|
|
public string currentstatus { get; set; }
|
|||
|
|
public string onlinetime { get; set; }
|
|||
|
|
public string offlinetime { get; set; }
|
|||
|
|
public string offrateperc { get; set; }
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public class snaggritem
|
|||
|
|
{
|
|||
|
|
public string SN { get; set; }
|
|||
|
|
public string Factory { get; set; }
|
|||
|
|
public int cnt { get; set; }
|
|||
|
|
public Dictionary<string, int> dicReason { get; set; }
|
|||
|
|
public List<Face.Domain.Application.FaceAll.devicestatushistory> evtlist { get; set; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public class HistoryStatusRange
|
|||
|
|
{
|
|||
|
|
public DateTime breakPoint { get; set; }
|
|||
|
|
public int status { get; set; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
public class errohandling
|
|||
|
|
{
|
|||
|
|
public int HotelID { get; set; }
|
|||
|
|
/// <summary>
|
|||
|
|
/// 页数据最大
|
|||
|
|
/// </summary>
|
|||
|
|
public int dataMax { get; set; }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 页数据最小
|
|||
|
|
/// </summary>
|
|||
|
|
public int dataMin { get; set; }
|
|||
|
|
/// <summary>
|
|||
|
|
/// 页
|
|||
|
|
/// </summary>
|
|||
|
|
public int Pages { get; set; }
|
|||
|
|
/// <summary>
|
|||
|
|
/// 时间
|
|||
|
|
/// </summary>
|
|||
|
|
public DateTime RoomMinDate { get; set; }
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 时间
|
|||
|
|
/// </summary>
|
|||
|
|
public DateTime RoomMaxDate { get; set; }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 错误信息
|
|||
|
|
/// </summary>
|
|||
|
|
public string FaceName { get; set; }
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public class LogController : BaseController
|
|||
|
|
{
|
|||
|
|
List<FaceBinding> li = new List<FaceBinding>();
|
|||
|
|
// GET: App/Log
|
|||
|
|
public ActionResult FacebindingMessage(int? page)//人脸机绑定/解绑
|
|||
|
|
{
|
|||
|
|
List<int> lit = (List<int>)Session["list"];
|
|||
|
|
using (SqlSugarClient db = SqlSugarBase.GesmartDb())
|
|||
|
|
{
|
|||
|
|
var userList = db.Queryable<FaceBinding>().ToList();
|
|||
|
|
int pageNumber = page ?? 1;
|
|||
|
|
|
|||
|
|
//每页显示多少条
|
|||
|
|
int pageSize = 8;
|
|||
|
|
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.OrderByDescending(x => x.bindingDate).ToList();
|
|||
|
|
}
|
|||
|
|
IPagedList<FaceBinding> userPagedList = li.ToPagedList(pageNumber, pageSize);
|
|||
|
|
//将分页处理后的列表传给View
|
|||
|
|
return View(userPagedList);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
public ActionResult PmsMessage(int? page, string date = null, string state = null, string roomname = null)//pms数据记录
|
|||
|
|
{
|
|||
|
|
List<int> lit = (List<int>)Session["list"];
|
|||
|
|
List<TBL_ROOM_BASIC_INFO> ZongRoominfo = (List<TBL_ROOM_BASIC_INFO>)Session["ZongRoominfo"];
|
|||
|
|
List<pmsInterface> li = new List<pmsInterface>();
|
|||
|
|
using (SqlSugarClient db = SqlSugarBase.GesmartDb())
|
|||
|
|
{
|
|||
|
|
var userList = db.Queryable<pmsInterface>().ToList();
|
|||
|
|
ViewData["pmsLog"] = db.Queryable<pmsLog>().ToList();
|
|||
|
|
for (int i = 0; i < lit.Count; i++)
|
|||
|
|
{
|
|||
|
|
var id = Convert.ToInt32(lit[i]);
|
|||
|
|
li.AddRange(userList.Where(x => x.hotelid == id).ToList());
|
|||
|
|
}
|
|||
|
|
li.AddRange(userList.Where(x => x.hotelid == null).ToList());
|
|||
|
|
int pageNumber = page ?? 1;
|
|||
|
|
var message = db.Queryable<FaceIssue>().ToList();
|
|||
|
|
ViewData["facemessage"] = message;
|
|||
|
|
//每页显示多少条
|
|||
|
|
int pageSize = 11;
|
|||
|
|
li = li.OrderByDescending(x => x.pmsId).ToList();
|
|||
|
|
if (state != null && state != "3")
|
|||
|
|
{
|
|||
|
|
ViewData["pmsstate"] = state;
|
|||
|
|
li = li.Where(x => x.pmstype == int.Parse(state)).ToList();
|
|||
|
|
}
|
|||
|
|
if (date != null)
|
|||
|
|
{
|
|||
|
|
ViewData["pmsdate"] = date;
|
|||
|
|
li = li.Where(x => x.DateTime.ToString("yyyy/MM/dd").Contains(date)).ToList();
|
|||
|
|
}
|
|||
|
|
if (roomname != null)
|
|||
|
|
{
|
|||
|
|
ViewData["pmsroomname"] = roomname;
|
|||
|
|
var ser = ZongRoominfo.Where(s => s.ROOM_NUMBER == roomname).ToList();
|
|||
|
|
List<pmsInterface> list = new List<pmsInterface>();
|
|||
|
|
foreach (var item in ser)
|
|||
|
|
{
|
|||
|
|
list.AddRange(li.Where(x => x.room == item.ROOM_OLD_ID));
|
|||
|
|
}
|
|||
|
|
li = list;
|
|||
|
|
}
|
|||
|
|
IPagedList<pmsInterface> userPagedList = li.ToPagedList(pageNumber, pageSize);
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
var hotelsList = SqlSugarBase.authoriydb.Queryable<Hotels>().ToList();
|
|||
|
|
ViewData["hotelsS"] = hotelsList;
|
|||
|
|
return View(userPagedList);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
public ActionResult PmsMessageLog()
|
|||
|
|
{
|
|||
|
|
return View();
|
|||
|
|
}
|
|||
|
|
public ActionResult InquirePmsMessageLog(Condition data)
|
|||
|
|
{
|
|||
|
|
List<TBL_ROOM_BASIC_INFO> ZongRoominfo = (List<TBL_ROOM_BASIC_INFO>)Session["ZongRoominfo"];
|
|||
|
|
List<int> lit = (List<int>)Session["list"];
|
|||
|
|
string strSql = "";
|
|||
|
|
string strFinalSql = "";
|
|||
|
|
string strNumberSql = "";
|
|||
|
|
string strSqlHeader = "select * from pmsInterface where 0=0 and ";
|
|||
|
|
string sqlnumberHeader = "select * from pmsInterface where 0=0 and ";
|
|||
|
|
//根据酒店id查询
|
|||
|
|
if (data.HotelID != 0)
|
|||
|
|
{
|
|||
|
|
strSql += (" hotelid=" + data.HotelID + " ");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
strSql += " (";
|
|||
|
|
for (int i = 0; i < lit.Count; i++)
|
|||
|
|
{
|
|||
|
|
strSql += (" hotelid=" + lit[i] + " or");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
strSql = strSql.Substring(0, strSql.Length - 2);
|
|||
|
|
strSql += ")";
|
|||
|
|
}
|
|||
|
|
//根据房间状态查询
|
|||
|
|
if (data.RoomStatus != 3)
|
|||
|
|
{
|
|||
|
|
strSql += " and pmstype=" + data.RoomStatus;
|
|||
|
|
}
|
|||
|
|
//根据房间编号查询
|
|||
|
|
if (data.RoomName != "" && data.RoomName != null)
|
|||
|
|
{
|
|||
|
|
IEnumerable<string> roomArr = data.RoomName.Split(';').Where(x => !String.IsNullOrWhiteSpace(x));
|
|||
|
|
List<TBL_ROOM_BASIC_INFO> ser = new List<TBL_ROOM_BASIC_INFO>();
|
|||
|
|
List<String> roomInnerIDList = new List<string>();
|
|||
|
|
if (data.HotelID != 0)
|
|||
|
|
{
|
|||
|
|
Func<TBL_ROOM_BASIC_INFO, bool> lamCondition0 = (s) =>
|
|||
|
|
{
|
|||
|
|
if (s.HOTEL_OLD_ID == data.HotelID && roomArr.Contains(s.ROOM_NUMBER))
|
|||
|
|
return true;
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
};
|
|||
|
|
ser = ZongRoominfo.Where(lamCondition0).ToList();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Func<TBL_ROOM_BASIC_INFO, bool> lamCondition = (s) =>
|
|||
|
|
{
|
|||
|
|
if (roomArr.Contains(s.ROOM_NUMBER) && lit.Contains(s.HOTEL_OLD_ID))
|
|||
|
|
return true;
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
};
|
|||
|
|
ser = ZongRoominfo.Where(lamCondition).ToList();
|
|||
|
|
}
|
|||
|
|
strSql += " and ( 0=0 ";
|
|||
|
|
/*for (int j = 0; j < ser.Count; j++)
|
|||
|
|
{
|
|||
|
|
strSql += (" or room=" + ser[j].ROOM_OLD_ID);
|
|||
|
|
}*/
|
|||
|
|
if (ser.Count > 0)
|
|||
|
|
{
|
|||
|
|
List<String> ids = new List<string>();
|
|||
|
|
for (int j = 0; j < ser.Count; j++)
|
|||
|
|
{
|
|||
|
|
ids.Add(ser[j].ROOM_OLD_ID.ToString());
|
|||
|
|
}
|
|||
|
|
strSql += "and room in (" + String.Join(",", ids.ToArray()) + ") ";
|
|||
|
|
}
|
|||
|
|
strSql += ")";
|
|||
|
|
}
|
|||
|
|
//根据时间查询
|
|||
|
|
if (
|
|||
|
|
(data.RoomMinDate != null && data.RoomMinDate.ToString() != "0001/1/1 0:00:00")
|
|||
|
|
&& (data.RoomMaxDate != null && data.RoomMinDate.ToString() != "0001/1/1 0:00:00")
|
|||
|
|
)
|
|||
|
|
{
|
|||
|
|
strSql += " and DateTime>='"
|
|||
|
|
+ data.RoomMinDate.ToString("yyyy/MM/dd")
|
|||
|
|
+ " 00:00:00' and DateTime<'"
|
|||
|
|
+ data.RoomMaxDate.ToString("yyyy/MM/dd") + " 23:59:59'";
|
|||
|
|
}
|
|||
|
|
//根据步骤查询
|
|||
|
|
if (data.showS8 != 1)
|
|||
|
|
{
|
|||
|
|
//strSql += " and ( pmsId not in(SELECT pmsid FROM `pmslog` WHERE ( step = 10 or step = 9 or step = 11) ) ) ";
|
|||
|
|
strSql += " and ( pmsId not in(SELECT pmsid FROM `pmslog` WHERE ( step = 291 or step = 297 or step = 299 or step = 304 or step = 309 or step = 314 or step = 303 or step = 315 or step = 318 ) ) ) ";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//展示的16条数据
|
|||
|
|
strFinalSql = strSqlHeader + strSql + " ORDER BY `pmsId` DESC LIMIT " + (data.dataMin) + ",16;";
|
|||
|
|
var countNum = new DALHelperCustom<Face.Domain.Entities.pmsInterface>("pmsInterface").SqlQueryGetList(strFinalSql.ToString());
|
|||
|
|
//总数
|
|||
|
|
strNumberSql = sqlnumberHeader + strSql + " ORDER BY `pmsId` DESC";
|
|||
|
|
var countNumCount = new DALHelperCustom<pmsInterface>("pmsInterface").SqlQueryGetList(strNumberSql.ToString());
|
|||
|
|
|
|||
|
|
//每个开房记录的通信发送流程步骤
|
|||
|
|
List<int> listint = new List<int>();
|
|||
|
|
if (countNum != null)
|
|||
|
|
{
|
|||
|
|
string strAmountSql = "SELECT * FROM pmslog ";
|
|||
|
|
strAmountSql += "WHERE ";
|
|||
|
|
foreach (var item in countNum)
|
|||
|
|
{
|
|||
|
|
strAmountSql += "pmsid=" + item.pmsId + " OR ";
|
|||
|
|
}
|
|||
|
|
strAmountSql = strAmountSql.Substring(0, strAmountSql.Length - 3);
|
|||
|
|
var retNum = new DALHelperCustom<Face.Domain.Entities.pmsLog>("pmslog").SqlQueryGetList(strAmountSql.ToString());
|
|||
|
|
ViewData["pmsLog"] = retNum;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//计算分页
|
|||
|
|
if (countNumCount != null && countNumCount.Count > 0)
|
|||
|
|
{
|
|||
|
|
ViewBag.count = countNumCount.Count;
|
|||
|
|
ViewBag.allpage = (countNumCount.Count + 16 - 1) / 16;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
countNum = null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
return PartialView("InquirePmsMessageLog", countNum);
|
|||
|
|
}
|
|||
|
|
public ActionResult InquirePmsMessageLoginfo(Condition data)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
List<int> lit = (List<int>)Session["list"];
|
|||
|
|
List<TBL_ROOM_BASIC_INFO> ZongRoominfo = (List<TBL_ROOM_BASIC_INFO>)Session["ZongRoominfo"];
|
|||
|
|
//查询登录用户权限下的所有酒店
|
|||
|
|
//List<Face.Domain.Entities.pmsInterface> Hotellist = SqlSugarBase.Db.Queryable<pmsInterface>().Where(x => lit.Contains(x.hotelid)).ToList();//所有酒店
|
|||
|
|
List<Face.Domain.Entities.Hotels> Hotellist = new List<Hotels>();
|
|||
|
|
List<faceerrormsg> facesgsd = new List<faceerrormsg>(); /* SqlSugarBase.Db.Queryable<faceerrormsg>().Where(x => lit.Contains(int.Parse(x.hotelid))).ToList();//错误信息*/
|
|||
|
|
if ((data.RoomMinDate != null && data.RoomMinDate.ToString() != "0001/1/1 0:00:00") && (data.RoomMaxDate != null && data.RoomMaxDate.ToString() != "0001/1/1 0:00:00"))
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
string RoomMinDate = data.RoomMinDate.ToString("yyyy/MM/dd") + " 00:00:00";
|
|||
|
|
// and DateTime<'"
|
|||
|
|
string RoomMaxDate = data.RoomMaxDate.ToString("yyyy/MM/dd") + " 23:59:59";
|
|||
|
|
DateTime RoomMin = DateTime.Parse(RoomMinDate);
|
|||
|
|
DateTime RoomMax = DateTime.Parse(RoomMaxDate);
|
|||
|
|
facesgsd = SqlSugarBase.Db.Queryable<faceerrormsg>().Where(x => lit.Contains(int.Parse(x.hotelid)) && x.creationtime > RoomMin && x.creationtime < RoomMax).ToList();//错误信息
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
facesgsd = SqlSugarBase.Db.Queryable<faceerrormsg>().Where(x => lit.Contains(int.Parse(x.hotelid)) && x.creationtime > DateTime.Now.AddDays(-3)).ToList();//错误信息
|
|||
|
|
}
|
|||
|
|
List<int> hid = new List<int>();
|
|||
|
|
//Dictionary<int, int> pairs = new Dictionary<int, int>();
|
|||
|
|
if (facesgsd.Count() > 0)
|
|||
|
|
{
|
|||
|
|
string facesgsd0 = facesgsd[0].hotelid;
|
|||
|
|
hid.Add(int.Parse(facesgsd0));
|
|||
|
|
foreach (var item in facesgsd)
|
|||
|
|
{
|
|||
|
|
if (item.hotelid != facesgsd0)
|
|||
|
|
{
|
|||
|
|
hid.Add(int.Parse(item.hotelid));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (data.HotelID == 0)
|
|||
|
|
{
|
|||
|
|
//data.HotelID = 1;
|
|||
|
|
Hotellist = SqlSugarBase.authoriydb.Queryable<Hotels>().Where(x => hid.Contains(x.Id)).ToList();//所有酒店
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Hotellist = SqlSugarBase.authoriydb.Queryable<Hotels>().Where(x => x.Id == data.HotelID).ToList();//所有酒店
|
|||
|
|
}
|
|||
|
|
List<Hotelnameinfo> infolist = new List<Hotelnameinfo>();
|
|||
|
|
foreach (var item in Hotellist)
|
|||
|
|
{
|
|||
|
|
Hotelnameinfo hotelnameinfo = new Hotelnameinfo();
|
|||
|
|
//在线数量
|
|||
|
|
int onlinenumber = 0;
|
|||
|
|
//总数量
|
|||
|
|
int totalnumber = 0;
|
|||
|
|
//离线数量
|
|||
|
|
int offnumber = 0;
|
|||
|
|
//出现问题的设备数量
|
|||
|
|
int probemnumber = 0;
|
|||
|
|
#region
|
|||
|
|
//List<faceerrormsg> faceerrormsg = new List<faceerrormsg>();
|
|||
|
|
//if ((data.RoomMinDate != null && data.RoomMinDate.ToString() != "0001/1/1 0:00:00") && (data.RoomMaxDate != null && data.RoomMaxDate.ToString() != "0001/1/1 0:00:00"))
|
|||
|
|
//{
|
|||
|
|
|
|||
|
|
// string RoomMinDate = data.RoomMinDate.ToString("yyyy/MM/dd") + " 00:00:00";
|
|||
|
|
// // and DateTime<'"
|
|||
|
|
// string RoomMaxDate = data.RoomMaxDate.ToString("yyyy/MM/dd") + " 23:59:59";
|
|||
|
|
// DateTime RoomMin = DateTime.Parse(RoomMinDate);
|
|||
|
|
// DateTime RoomMax = DateTime.Parse(RoomMaxDate);
|
|||
|
|
// faceerrormsg = SqlSugarBase.Db.Queryable<faceerrormsg>().Where(x => x.hotelid == item.Id.ToString() && x.creationtime > RoomMin && x.creationtime< RoomMax).ToList();//错误信息
|
|||
|
|
//}
|
|||
|
|
//else
|
|||
|
|
//{
|
|||
|
|
// faceerrormsg = SqlSugarBase.Db.Queryable<faceerrormsg>().Where(x => x.hotelid == item.Id.ToString() && x.creationtime > DateTime.Now.AddDays(-3)).ToList();//错误信息
|
|||
|
|
//}
|
|||
|
|
//if (faceerrormsg.Count() > 0)
|
|||
|
|
//{
|
|||
|
|
#endregion
|
|||
|
|
List<Face.Domain.Entities.DeviceManage> devices = SqlSugarBase.Db.Queryable<DeviceManage>().Where(X => X.HotelCode == item.Id.ToString()).ToList();
|
|||
|
|
hotelnameinfo.Roomanddevname = new List<Roomanddevname>();
|
|||
|
|
foreach (var itemF in devices)
|
|||
|
|
{
|
|||
|
|
totalnumber++;
|
|||
|
|
if (itemF.Status)
|
|||
|
|
{
|
|||
|
|
onlinenumber++;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
offnumber++;
|
|||
|
|
}
|
|||
|
|
TBL_ROOM_BASIC_INFO list = ZongRoominfo.FirstOrDefault(s => s.ROOM_OLD_ID == itemF.RoomId);
|
|||
|
|
if (list != null)
|
|||
|
|
{
|
|||
|
|
Roomanddevname RD = new Roomanddevname();
|
|||
|
|
RD.roomNmae = list.ROOM_NUMBER;
|
|||
|
|
RD.LabelName = itemF.Factory;
|
|||
|
|
RD.VersionNumber = itemF.APKVersion;
|
|||
|
|
RD.pmsidinfo = new List<tableinfo>();
|
|||
|
|
List<faceerrormsg> msg = new List<faceerrormsg>();
|
|||
|
|
if ((data.RoomMinDate != null && data.RoomMinDate.ToString() != "0001/1/1 0:00:00") && (data.RoomMaxDate != null && data.RoomMaxDate.ToString() != "0001/1/1 0:00:00"))
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
string RoomMinDate = data.RoomMinDate.ToString("yyyy/MM/dd") + " 00:00:00";
|
|||
|
|
// and DateTime<'"
|
|||
|
|
string RoomMaxDate = data.RoomMaxDate.ToString("yyyy/MM/dd") + " 23:59:59";
|
|||
|
|
DateTime RoomMin = DateTime.Parse(RoomMinDate);
|
|||
|
|
DateTime RoomMax = DateTime.Parse(RoomMaxDate);
|
|||
|
|
msg = SqlSugarBase.Db.Queryable<faceerrormsg>().Where(x => x.Roomid == itemF.RoomId.ToString() && x.creationtime > RoomMin && x.creationtime < RoomMax).ToList();//错误信息
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
msg = SqlSugarBase.Db.Queryable<faceerrormsg>().Where(x => x.Roomid == itemF.RoomId.ToString() && x.creationtime > DateTime.Now.AddDays(-3)).ToList();//错误信息
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//List<faceerrormsg> msg = SqlSugarBase.Db.Queryable<faceerrormsg>(x => x.Roomid == itemF.RoomId.ToString()).Where().ToList();//错误信息
|
|||
|
|
|
|||
|
|
foreach (var items in msg)
|
|||
|
|
{
|
|||
|
|
tableinfo rid = new tableinfo();
|
|||
|
|
rid.pmsid = items.pmsid;
|
|||
|
|
rid.type = items.cmd;
|
|||
|
|
RD.SN = items.sn;
|
|||
|
|
rid.datainfo = items.errormsg;
|
|||
|
|
rid.GetDateTime = (DateTime)items.creationtime;
|
|||
|
|
rid.Rremary = items.remary;
|
|||
|
|
rid.errorcode = items.errorcode;
|
|||
|
|
probemnumber++;
|
|||
|
|
RD.pmsidinfo.Add(rid);
|
|||
|
|
}
|
|||
|
|
hotelnameinfo.Roomanddevname.Add(RD);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
hotelnameinfo.onlinenumber = onlinenumber;
|
|||
|
|
hotelnameinfo.totalnumber = totalnumber;
|
|||
|
|
hotelnameinfo.offnumber = offnumber;
|
|||
|
|
hotelnameinfo.HotelName = item.Name;
|
|||
|
|
hotelnameinfo.hotelids = item.Id;
|
|||
|
|
hotelnameinfo.probemnumber = probemnumber;
|
|||
|
|
infolist.Add(hotelnameinfo);
|
|||
|
|
//}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#region
|
|||
|
|
|
|||
|
|
//foreach (var item in faceerrormsg)
|
|||
|
|
//{
|
|||
|
|
// Face.Domain.Entities.Hotels Hotellist = SqlSugarBase.authoriydb.Queryable<Hotels>().First(x => x.Id== int.Parse(item.hotelid));
|
|||
|
|
// //在线数量
|
|||
|
|
// int onlinenumber = 0;
|
|||
|
|
// //总数量
|
|||
|
|
// int totalnumber = 0;
|
|||
|
|
// //离线数量
|
|||
|
|
// int offnumber = 0;
|
|||
|
|
// //出现问题的设备数量
|
|||
|
|
// int probemnumber = 0;
|
|||
|
|
// List<Face.Domain.Entities.DeviceManage> devices = SqlSugarBase.Db.Queryable<DeviceManage>().Where(X => X.HotelCode == Hotellist.Id.ToString()).ToList();
|
|||
|
|
// foreach (var itemF in devices)
|
|||
|
|
// {
|
|||
|
|
// totalnumber++;
|
|||
|
|
// if (itemF.Status)
|
|||
|
|
// {
|
|||
|
|
// onlinenumber++;
|
|||
|
|
// }
|
|||
|
|
// else
|
|||
|
|
// {
|
|||
|
|
// offnumber++;
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// TBL_ROOM_BASIC_INFO list = ZongRoominfo.FirstOrDefault(s => s.ROOM_OLD_ID ==int.Parse(item.Roomid));
|
|||
|
|
//}
|
|||
|
|
//////查询登录用户下酒店对应的所有设备
|
|||
|
|
//foreach (var item in Hotellist)
|
|||
|
|
//{
|
|||
|
|
|
|||
|
|
// Hotelnameinfo hotelnameinfo = new Hotelnameinfo();
|
|||
|
|
|
|||
|
|
// //在线数量
|
|||
|
|
// int onlinenumber = 0;
|
|||
|
|
// //总数量
|
|||
|
|
// int totalnumber = 0;
|
|||
|
|
// //离线数量
|
|||
|
|
// int offnumber = 0;
|
|||
|
|
// //出现问题的设备数量
|
|||
|
|
// int probemnumber = 0;
|
|||
|
|
// //List<string> arr = new List<string>();
|
|||
|
|
// List<Face.Domain.Entities.DeviceManage> devices = SqlSugarBase.Db.Queryable<DeviceManage>().Where(X => X.HotelCode == item.Id.ToString()).ToList();
|
|||
|
|
// if (devices.Count() != 0)
|
|||
|
|
// {
|
|||
|
|
// hotelnameinfo.Roomanddevname = new List<Roomanddevname>();
|
|||
|
|
|
|||
|
|
// foreach (var itemF in devices)
|
|||
|
|
// {
|
|||
|
|
// Roomanddevname RD = new Roomanddevname();
|
|||
|
|
// totalnumber++;
|
|||
|
|
// if (itemF.Status)
|
|||
|
|
// {
|
|||
|
|
// onlinenumber++;
|
|||
|
|
// }
|
|||
|
|
// else
|
|||
|
|
// {
|
|||
|
|
// offnumber++;
|
|||
|
|
// }
|
|||
|
|
// RD.SN = itemF.SerialNo;
|
|||
|
|
// //TBL_ROOM_BASIC_INFO list = ZongRoominfo.FirstOrDefault(s => s.ROOM_OLD_ID == itemF.RoomId);
|
|||
|
|
// //if (list != null)
|
|||
|
|
// //{
|
|||
|
|
// // RD.roomNmae = list.ROOM_NUMBER;
|
|||
|
|
// // RD.LabelName = itemF.Factory;
|
|||
|
|
// // RD.VersionNumber = itemF.APKVersion;
|
|||
|
|
// // RD.pmsidinfo = new List<tableinfo>();
|
|||
|
|
// // //查询酒店房间里面产生的所有pmsid
|
|||
|
|
// // List<pmsInterface> asd = SqlSugarBase.Db.Queryable<pmsInterface>().Where(X => X.hotelid == item.Id && X.room == itemF.RoomId && X.DateTime >= DateTime.Now.AddDays(-3)).ToList();
|
|||
|
|
|
|||
|
|
// // if (asd.Count() > 0)
|
|||
|
|
// // {
|
|||
|
|
// // foreach (var itemsfsa in asd)
|
|||
|
|
// // {
|
|||
|
|
// // pmsLog pms = SqlSugarBase.Db.Queryable<pmsLog>().First(X => X.pmsid == itemsfsa.pmsId && X.step == 7);
|
|||
|
|
// // if (pms != null)
|
|||
|
|
// // {
|
|||
|
|
// // pmsLog pmssdd = SqlSugarBase.Db.Queryable<pmsLog>().First(X => X.pmsid == pms.pmsid && X.step == 5);
|
|||
|
|
// // if (pmssdd!=null)
|
|||
|
|
// // {
|
|||
|
|
// // tableinfo rid = new tableinfo();
|
|||
|
|
// // rid.pmsid = pms.pmsid;
|
|||
|
|
// // rid.type = (int)itemsfsa.pmstype;
|
|||
|
|
|
|||
|
|
// // rid.datainfo = pmssdd.Data;
|
|||
|
|
// // rid.GetDateTime = (DateTime)pmssdd.Creationtime;
|
|||
|
|
// // probemnumber++;
|
|||
|
|
// // RD.pmsidinfo.Add(rid);
|
|||
|
|
// // }
|
|||
|
|
|
|||
|
|
// // }
|
|||
|
|
|
|||
|
|
|
|||
|
|
// // }
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
// // hotelnameinfo.Roomanddevname.Add(RD);
|
|||
|
|
|
|||
|
|
// // }
|
|||
|
|
|
|||
|
|
// //}
|
|||
|
|
|
|||
|
|
// }
|
|||
|
|
// hotelnameinfo.onlinenumber = onlinenumber;
|
|||
|
|
// hotelnameinfo.totalnumber = totalnumber;
|
|||
|
|
// hotelnameinfo.offnumber = offnumber;
|
|||
|
|
// hotelnameinfo.HotelName = item.Name;
|
|||
|
|
// hotelnameinfo.hotelids = item.Id;
|
|||
|
|
// hotelnameinfo.probemnumber = probemnumber;
|
|||
|
|
// infolist.Add(hotelnameinfo);
|
|||
|
|
|
|||
|
|
// }
|
|||
|
|
//}
|
|||
|
|
#endregion
|
|||
|
|
ViewBag.info = infolist;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
Console.WriteLine(ex);
|
|||
|
|
}
|
|||
|
|
return PartialView("InquirePmsMessageLoginfo");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
public ActionResult operationLog(int? page)//人脸机操作
|
|||
|
|
{
|
|||
|
|
List<int> lit = (List<int>)Session["list"];
|
|||
|
|
List<TBL_ROOM_BASIC_INFO> ZongRoominfo = (List<TBL_ROOM_BASIC_INFO>)Session["ZongRoominfo"];
|
|||
|
|
List<ULog> uLogs = new List<ULog>();
|
|||
|
|
using (SqlSugarClient db = SqlSugarBase.GesmartDb())
|
|||
|
|
{
|
|||
|
|
var userList = db.Queryable<ULog>().ToList();
|
|||
|
|
int pageNumber = page ?? 1;
|
|||
|
|
//每页显示多少条
|
|||
|
|
int pageSize = 8;
|
|||
|
|
for (int i = 0; i < lit.Count; i++)
|
|||
|
|
{
|
|||
|
|
var id = Convert.ToInt32(lit[i]);
|
|||
|
|
uLogs.AddRange(userList.Where(x => x.hotelcode == id).ToList());
|
|||
|
|
}
|
|||
|
|
uLogs = uLogs.OrderByDescending(x => x.id).ToList();
|
|||
|
|
//userList = userList.OrderByDescending(x => x.Creationtime);
|
|||
|
|
IPagedList<ULog> userPagedList = uLogs.ToPagedList(pageNumber, pageSize);
|
|||
|
|
return View(userPagedList);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public ActionResult errormessagehandling()
|
|||
|
|
{
|
|||
|
|
//List<errormessagehandling> pmsinfo = SqlSugarBase.Db.Queryable<errormessagehandling>().ToList();
|
|||
|
|
int totalCount = 0;
|
|||
|
|
var pmsinfos = SqlSugarBase.Db.Queryable<errormessagehandling>().ToPageList(1, 10, ref totalCount).ToList();
|
|||
|
|
|
|||
|
|
ViewBag.errorinfos = pmsinfos;
|
|||
|
|
//计算分页
|
|||
|
|
if (totalCount > 0)
|
|||
|
|
{
|
|||
|
|
ViewBag.count = totalCount;
|
|||
|
|
ViewBag.allpages = (totalCount + 10 - 1) / 10;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
pmsinfos = null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return View();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//[HttpPost]
|
|||
|
|
public ActionResult geterrorinfo(errohandling dara)
|
|||
|
|
{
|
|||
|
|
int totalCount = 0;
|
|||
|
|
List<errormessagehandling> pmsinfos = SqlSugarBase.Db.Queryable<errormessagehandling>().OrderByDescending(x => x.creationdata).ToList();
|
|||
|
|
//.ToPageList(dara.Pages, 10, ref totalCount)
|
|||
|
|
//时间范围
|
|||
|
|
if (
|
|||
|
|
(dara.RoomMinDate != null && dara.RoomMinDate.ToString() != "0001/1/1 0:00:00")
|
|||
|
|
&& (dara.RoomMaxDate != null && dara.RoomMinDate.ToString() != "0001/1/1 0:00:00")
|
|||
|
|
)
|
|||
|
|
{
|
|||
|
|
pmsinfos = pmsinfos.Where(x => x.creationdata >= dara.RoomMinDate && x.creationdata < dara.RoomMaxDate).OrderByDescending(x => x.creationdata).ToList();
|
|||
|
|
//.ToPageList(dara.Pages, 10, ref totalCount)
|
|||
|
|
}
|
|||
|
|
if (dara.HotelID != -1)
|
|||
|
|
{
|
|||
|
|
pmsinfos = pmsinfos.Where(x => x.isVerify == dara.HotelID).OrderByDescending(x => x.creationdata).ToList();
|
|||
|
|
//.ToPageList(dara.Pages, 10, ref totalCount)
|
|||
|
|
}
|
|||
|
|
if (!string.IsNullOrEmpty(dara.FaceName))
|
|||
|
|
{
|
|||
|
|
pmsinfos = pmsinfos.Where(x => x.ErrorNmae.Contains(dara.FaceName)).OrderByDescending(x => x.creationdata).ToList();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
List<errormessagehandling> data = (pmsinfos.Skip((dara.Pages - 1) * 10).Take(10)).ToList();
|
|||
|
|
ViewBag.errorinfos = data;
|
|||
|
|
//计算分页
|
|||
|
|
if (pmsinfos.Count() > 0)
|
|||
|
|
{
|
|||
|
|
ViewBag.count = pmsinfos.Count();//总数
|
|||
|
|
int ad = (pmsinfos.Count() + 10 - 1) / 10;
|
|||
|
|
ViewBag.allpages = (pmsinfos.Count() + 10 - 1) / 10;//分页数
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
pmsinfos = null;
|
|||
|
|
}
|
|||
|
|
return PartialView("geterrorinfo");
|
|||
|
|
}
|
|||
|
|
[HttpPost]
|
|||
|
|
public ActionResult updateerrorinfo(int id)
|
|||
|
|
{
|
|||
|
|
errormessagehandling pmsinfo = SqlSugarBase.Db.Queryable<errormessagehandling>().Where(x => x.id == id).First();
|
|||
|
|
pmsinfo.isVerify = 1;
|
|||
|
|
int count = SqlSugarBase.Db.Updateable(pmsinfo).Where(x => x.id == id).ExecuteCommand();
|
|||
|
|
return Json(count);
|
|||
|
|
}
|
|||
|
|
public ActionResult everydayLog(int? page)//日常操作日志
|
|||
|
|
{
|
|||
|
|
List<int> lit = (List<int>)Session["list"];
|
|||
|
|
List<TBL_ROOM_BASIC_INFO> ZongRoominfo = (List<TBL_ROOM_BASIC_INFO>)Session["ZongRoominfo"];
|
|||
|
|
List<Dailyoperation> dn = new List<Dailyoperation>();
|
|||
|
|
using (SqlSugarClient db = SqlSugarBase.GesmartDb())
|
|||
|
|
{
|
|||
|
|
var userList = db.Queryable<Dailyoperation>().ToList();
|
|||
|
|
int pageNumber = page ?? 1;
|
|||
|
|
|
|||
|
|
//每页显示多少条
|
|||
|
|
int pageSize = 8;
|
|||
|
|
for (int i = 0; i < lit.Count; i++)
|
|||
|
|
{
|
|||
|
|
var id = Convert.ToInt32(lit[i]);
|
|||
|
|
dn.AddRange(userList.Where(x => x.hotelCode == id).ToList());
|
|||
|
|
}
|
|||
|
|
//userList = userList.OrderByDescending(x => x.Creationtime);
|
|||
|
|
IPagedList<Dailyoperation> userPagedList = dn.ToPagedList(pageNumber, pageSize);
|
|||
|
|
return View(userPagedList);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 返回一个json格式的数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public ActionResult FaceStatusHistoryLogGetData(HistoryStatusSearchCondition searchObj)
|
|||
|
|
{
|
|||
|
|
List<expendcountstatushistory> expcntlist = new List<expendcountstatushistory>();
|
|||
|
|
|
|||
|
|
Dictionary<int, string> dicReason = new Dictionary<int, string>();
|
|||
|
|
dicReason.Add(0, "链路第一次OnOpen触发");
|
|||
|
|
dicReason.Add(1, "链路OnError触发");
|
|||
|
|
dicReason.Add(2, "链路OnClose触发");
|
|||
|
|
dicReason.Add(3, "链路重新OnOpen触发");
|
|||
|
|
dicReason.Add(4, "Ping周期采样状态反转触发");
|
|||
|
|
|
|||
|
|
List<Face.Domain.Application.FaceAll.devicestatushistory> cntlist = new List<Face.Domain.Application.FaceAll.devicestatushistory>();
|
|||
|
|
|
|||
|
|
|
|||
|
|
List<IConditionalModel> listCol = new List<IConditionalModel>();
|
|||
|
|
if (!String.IsNullOrWhiteSpace(searchObj.sn))
|
|||
|
|
{
|
|||
|
|
listCol.Add(new ConditionalModel() { FieldName = "SN", ConditionalType = ConditionalType.Equal, FieldValue = searchObj.sn });
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!String.IsNullOrWhiteSpace(searchObj.st) && !String.IsNullOrWhiteSpace(searchObj.ed))
|
|||
|
|
{
|
|||
|
|
listCol.Add(new ConditionalModel() { FieldName = "CreateTime", ConditionalType = ConditionalType.GreaterThan, FieldValue = (searchObj.st + " 00:00:00") });
|
|||
|
|
listCol.Add(new ConditionalModel() { FieldName = "CreateTime", ConditionalType = ConditionalType.LessThan, FieldValue = (searchObj.ed + " 23:59:59") });
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string strResultCombineReson = "";
|
|||
|
|
string curReason = "";
|
|||
|
|
searchObj.arrReason = new int[] { 0, 1, 2, 3, 4 };
|
|||
|
|
strResultCombineReson = "链路";
|
|||
|
|
ConditionalCollections tmpOrList = new ConditionalCollections();
|
|||
|
|
tmpOrList.ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>();
|
|||
|
|
for (int i = 0; i < searchObj.arrReason.Length; i++)
|
|||
|
|
{
|
|||
|
|
curReason = dicReason[searchObj.arrReason[i]];
|
|||
|
|
if (searchObj.arrReason[i] == 0)
|
|||
|
|
strResultCombineReson += "第一次OnOpen" + ",";
|
|||
|
|
else if (searchObj.arrReason[i] == 1)
|
|||
|
|
strResultCombineReson += "OnError" + ",";
|
|||
|
|
else if (searchObj.arrReason[i] == 2)
|
|||
|
|
strResultCombineReson += "OnClose" + ",";
|
|||
|
|
else if (searchObj.arrReason[i] == 3)
|
|||
|
|
strResultCombineReson += "重新OnOpen" + ",";
|
|||
|
|
else if (searchObj.arrReason[i] == 4)
|
|||
|
|
strResultCombineReson += "Ping周期采样状态反转" + ",";
|
|||
|
|
var tmpCn = new KeyValuePair<WhereType, ConditionalModel>(i == 0 ? WhereType.And : WhereType.Or,
|
|||
|
|
new ConditionalModel() { FieldName = "Reason", ConditionalType = ConditionalType.Equal, FieldValue = curReason });
|
|||
|
|
tmpOrList.ConditionalList.Add(tmpCn);
|
|||
|
|
}
|
|||
|
|
listCol.Add(tmpOrList);
|
|||
|
|
strResultCombineReson = strResultCombineReson.Substring(0, strResultCombineReson.Length - 1);
|
|||
|
|
strResultCombineReson += "触发";
|
|||
|
|
|
|||
|
|
cntlist = SqlSugarBase.Db.Queryable<Face.Domain.Application.FaceAll.devicestatushistory>()
|
|||
|
|
.Where(listCol)
|
|||
|
|
.OrderBy(it => it.CreateTime)
|
|||
|
|
.ToList();
|
|||
|
|
|
|||
|
|
//I can group by myself
|
|||
|
|
//snaggritem
|
|||
|
|
Dictionary<string, snaggritem> tmpDic = new Dictionary<string, snaggritem>();
|
|||
|
|
foreach (var p in cntlist)
|
|||
|
|
{
|
|||
|
|
string curSn = p.SN;
|
|||
|
|
if (tmpDic.ContainsKey(curSn))
|
|||
|
|
{
|
|||
|
|
var curItem = tmpDic[curSn];
|
|||
|
|
curItem.cnt++;
|
|||
|
|
if (curItem.dicReason.ContainsKey(p.Reason))
|
|||
|
|
{
|
|||
|
|
curItem.dicReason[p.Reason]++;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
curItem.dicReason.Add(p.Reason, 1);
|
|||
|
|
}
|
|||
|
|
tmpDic[curSn].evtlist.Add(p);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Dictionary<string, int> reasonDic = new Dictionary<string, int>();
|
|||
|
|
reasonDic.Add(p.Reason, 1);
|
|||
|
|
tmpDic.Add(curSn, new snaggritem
|
|||
|
|
{
|
|||
|
|
SN = curSn,
|
|||
|
|
Factory = p.Factory,
|
|||
|
|
cnt = 1,
|
|||
|
|
dicReason = reasonDic,
|
|||
|
|
evtlist = new List<Domain.Application.FaceAll.devicestatushistory> { p }
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
List<snaggritem> aggrList = tmpDic.Values.ToList();
|
|||
|
|
aggrList.Sort((a, b) =>
|
|||
|
|
{
|
|||
|
|
//return a.cnt - b.cnt;
|
|||
|
|
return b.cnt - a.cnt; //降序排序
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
List<string> snList = new List<string>();
|
|||
|
|
foreach (var p in aggrList)
|
|||
|
|
{
|
|||
|
|
snList.Add(p.SN);
|
|||
|
|
}
|
|||
|
|
var combineList = SqlSugarBase.Db.Queryable<Face.Domain.Application.FaceAll.DeviceManage>().AS("face.devicemanage")
|
|||
|
|
.LeftJoin<Hotels>((d, h) => d.HotelCode == h.Id.ToString()).AS<Hotels>("authoritydb.hotels")
|
|||
|
|
.LeftJoin<TBL_ROOM_BASIC_INFO>((d, h, r) => d.RoomId == r.ROOM_OLD_ID).AS<TBL_ROOM_BASIC_INFO>("blv_rcu_db.tbl_room_basic_info")
|
|||
|
|
.Where((d, h, r) => snList.Contains(d.SerialNo))
|
|||
|
|
.Select((d, h, r) => new combineddeviceinfo
|
|||
|
|
{
|
|||
|
|
SerialNo = d.SerialNo,
|
|||
|
|
HotelName = h.Name,
|
|||
|
|
RoomNumber = r.ROOM_NUMBER,
|
|||
|
|
DeviceStatus = (d.Status == true ? "在线" : "离线")
|
|||
|
|
})
|
|||
|
|
.ToList();
|
|||
|
|
Dictionary<string, combineddeviceinfo> dicTmp = new Dictionary<string, combineddeviceinfo>();
|
|||
|
|
foreach (var it in combineList)
|
|||
|
|
{
|
|||
|
|
dicTmp.Add(it.SerialNo, it);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
foreach (var p in aggrList)
|
|||
|
|
{
|
|||
|
|
//查找每一个sn指定时间范围内的区间列表
|
|||
|
|
//每一个区间开始有跳变原因,跳变后状态,跳变时间,持续时间
|
|||
|
|
//所有跳变后状态为1的区间,其持续时间求和就是在线时间
|
|||
|
|
//所有跳变后状态为0的区间,其持续时间求和就是离线时间
|
|||
|
|
//off/(off+on) 就是总的 offrate
|
|||
|
|
|
|||
|
|
List<HistoryStatusRange> rangeList = new List<HistoryStatusRange>();
|
|||
|
|
if (!String.IsNullOrWhiteSpace(searchObj.st))
|
|||
|
|
{
|
|||
|
|
rangeList.Add(new HistoryStatusRange
|
|||
|
|
{
|
|||
|
|
breakPoint = DateTime.Parse(searchObj.st + " 00:00:00"),
|
|||
|
|
status = 1 //不知道,应该根据下一个节点反推。
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
foreach (var it in p.evtlist)
|
|||
|
|
{
|
|||
|
|
rangeList.Add(new HistoryStatusRange
|
|||
|
|
{
|
|||
|
|
breakPoint = it.CreateTime,
|
|||
|
|
status = it.Status
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
if (!String.IsNullOrWhiteSpace(searchObj.ed))
|
|||
|
|
{
|
|||
|
|
rangeList.Add(new HistoryStatusRange
|
|||
|
|
{
|
|||
|
|
breakPoint = DateTime.Parse(searchObj.ed + " 23:59:59"),
|
|||
|
|
status = 1 //不知道,应该根据上一个节点反推。
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
HistoryStatusRange[] tmpArr = rangeList.ToArray();
|
|||
|
|
|
|||
|
|
TimeSpan onSumTp = new TimeSpan(0);
|
|||
|
|
TimeSpan offSumTp = new TimeSpan(0);
|
|||
|
|
for (int i = 1; i < tmpArr.Length; i++)
|
|||
|
|
{
|
|||
|
|
if (i == 1)//第一个区间认为是第二个区间反转
|
|||
|
|
{
|
|||
|
|
if (tmpArr[i].status == 0)
|
|||
|
|
{
|
|||
|
|
onSumTp += (tmpArr[i].breakPoint - tmpArr[i - 1].breakPoint);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
offSumTp += (tmpArr[i].breakPoint - tmpArr[i - 1].breakPoint);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else//计算当前点前一个区间
|
|||
|
|
{
|
|||
|
|
if (tmpArr[i - 1].status == 1)
|
|||
|
|
{
|
|||
|
|
onSumTp += (tmpArr[i].breakPoint - tmpArr[i - 1].breakPoint);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
offSumTp += (tmpArr[i].breakPoint - tmpArr[i - 1].breakPoint);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string strReasons = "";
|
|||
|
|
if (p.dicReason.Count > 0)
|
|||
|
|
{
|
|||
|
|
string[] tmpReasonArr = p.dicReason.Keys.ToArray();
|
|||
|
|
strReasons = String.Join(",", tmpReasonArr);
|
|||
|
|
}
|
|||
|
|
string percVal = "";
|
|||
|
|
double rate = offSumTp.TotalSeconds / (onSumTp.TotalSeconds + offSumTp.TotalSeconds);
|
|||
|
|
percVal = Convert.ToDouble(rate).ToString("P");
|
|||
|
|
expcntlist.Add(new expendcountstatushistory
|
|||
|
|
{
|
|||
|
|
SN = p.SN,
|
|||
|
|
Factory = p.Factory,
|
|||
|
|
cnt = p.cnt,
|
|||
|
|
reason = strReasons,
|
|||
|
|
hotel = dicTmp[p.SN].HotelName,
|
|||
|
|
room = dicTmp[p.SN].RoomNumber,
|
|||
|
|
currentstatus = dicTmp[p.SN].DeviceStatus,
|
|||
|
|
onlinetime = onSumTp.ToString(),
|
|||
|
|
offlinetime = offSumTp.ToString(),
|
|||
|
|
offrateperc = percVal
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//return Json(cntlist, JsonRequestBehavior.AllowGet);
|
|||
|
|
return Json(expcntlist, JsonRequestBehavior.AllowGet);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 返回一个json格式的数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public ActionResult FaceStatusHistoryLogGetDataSingle(HistoryStatusSearchCondition searchObj)
|
|||
|
|
{
|
|||
|
|
Dictionary<int, string> dicReason = new Dictionary<int, string>();
|
|||
|
|
dicReason.Add(0, "链路第一次OnOpen触发");
|
|||
|
|
dicReason.Add(1, "链路OnError触发");
|
|||
|
|
dicReason.Add(2, "链路OnClose触发");
|
|||
|
|
dicReason.Add(3, "链路重新OnOpen触发");
|
|||
|
|
dicReason.Add(4, "Ping周期采样状态反转触发");
|
|||
|
|
|
|||
|
|
List<Face.Domain.Application.FaceAll.devicestatushistory> cntlist = new List<Face.Domain.Application.FaceAll.devicestatushistory>();
|
|||
|
|
|
|||
|
|
|
|||
|
|
List<IConditionalModel> listCol = new List<IConditionalModel>();
|
|||
|
|
if (!String.IsNullOrWhiteSpace(searchObj.sn))
|
|||
|
|
{
|
|||
|
|
listCol.Add(new ConditionalModel() { FieldName = "SN", ConditionalType = ConditionalType.Equal, FieldValue = searchObj.sn });
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!String.IsNullOrWhiteSpace(searchObj.st) && !String.IsNullOrWhiteSpace(searchObj.ed))
|
|||
|
|
{
|
|||
|
|
searchObj.st += " 00:00:00";
|
|||
|
|
searchObj.ed += " 23:59:59";
|
|||
|
|
listCol.Add(new ConditionalModel() { FieldName = "CreateTime", ConditionalType = ConditionalType.GreaterThan, FieldValue = searchObj.st });
|
|||
|
|
listCol.Add(new ConditionalModel() { FieldName = "CreateTime", ConditionalType = ConditionalType.LessThan, FieldValue = searchObj.ed });
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string strResultCombineReson = "";
|
|||
|
|
string curReason = "";
|
|||
|
|
if (searchObj.arrReason != null && searchObj.arrReason.Length > 0)
|
|||
|
|
{
|
|||
|
|
strResultCombineReson = "链路";
|
|||
|
|
ConditionalCollections tmpOrList = new ConditionalCollections();
|
|||
|
|
tmpOrList.ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>();
|
|||
|
|
for (int i = 0; i < searchObj.arrReason.Length; i++)
|
|||
|
|
{
|
|||
|
|
curReason = dicReason[searchObj.arrReason[i]];
|
|||
|
|
if (searchObj.arrReason[i] == 0)
|
|||
|
|
strResultCombineReson += "第一次OnOpen" + ",";
|
|||
|
|
else if (searchObj.arrReason[i] == 1)
|
|||
|
|
strResultCombineReson += "OnError" + ",";
|
|||
|
|
else if (searchObj.arrReason[i] == 2)
|
|||
|
|
strResultCombineReson += "OnClose" + ",";
|
|||
|
|
else if (searchObj.arrReason[i] == 3)
|
|||
|
|
strResultCombineReson += "重新OnOpen" + ",";
|
|||
|
|
else if (searchObj.arrReason[i] == 4)
|
|||
|
|
strResultCombineReson += "Ping周期采样状态反转" + ",";
|
|||
|
|
var tmpCn = new KeyValuePair<WhereType, ConditionalModel>(i == 0 ? WhereType.And : WhereType.Or,
|
|||
|
|
new ConditionalModel() { FieldName = "Reason", ConditionalType = ConditionalType.Equal, FieldValue = curReason });
|
|||
|
|
tmpOrList.ConditionalList.Add(tmpCn);
|
|||
|
|
}
|
|||
|
|
listCol.Add(tmpOrList);
|
|||
|
|
strResultCombineReson = strResultCombineReson.Substring(0, strResultCombineReson.Length - 1);
|
|||
|
|
strResultCombineReson += "触发";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
cntlist = SqlSugarBase.Db.Queryable<Face.Domain.Application.FaceAll.devicestatushistory>()
|
|||
|
|
.Where(listCol) //普通过滤
|
|||
|
|
.OrderBy(x => x.CreateTime)
|
|||
|
|
.ToList();
|
|||
|
|
|
|||
|
|
|
|||
|
|
return Json(cntlist, JsonRequestBehavior.AllowGet);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public ActionResult FaceStatusHistoryLog()
|
|||
|
|
{
|
|||
|
|
return View();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
public class Hotelnameinfo
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
public int onlinenumber { get; set; }
|
|||
|
|
|
|||
|
|
public int totalnumber { get; set; }
|
|||
|
|
public int offnumber { get; set; }
|
|||
|
|
public int probemnumber { get; set; }
|
|||
|
|
public string HotelName { get; set; }
|
|||
|
|
public List<Roomanddevname> Roomanddevname { get; set; }
|
|||
|
|
public int hotelids { get; set; }
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
public class Roomanddevname
|
|||
|
|
{
|
|||
|
|
public string roomNmae { get; set; }
|
|||
|
|
public string SN { get; set; }
|
|||
|
|
public string LabelName { get; set; }
|
|||
|
|
public string VersionNumber { get; set; }
|
|||
|
|
public List<tableinfo> pmsidinfo { get; set; }
|
|||
|
|
//public int Roomids { get; set; }
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
public class tableinfo
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
public int pmsid { get; set; }
|
|||
|
|
public string type { get; set; }
|
|||
|
|
public string datainfo { get; set; }
|
|||
|
|
public DateTime GetDateTime { get; set; }
|
|||
|
|
public string Rremary { get; set; }
|
|||
|
|
|
|||
|
|
public int errorcode { get; set; }
|
|||
|
|
public string errormsg { get; set; }
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
public class faceerrormsg
|
|||
|
|
{
|
|||
|
|
public int Id { get; set; }
|
|||
|
|
public string hotelid { get; set; }
|
|||
|
|
public string Roomid { get; set; }
|
|||
|
|
public string brandinfo { get; set; }
|
|||
|
|
public string sn { get; set; }
|
|||
|
|
public int pmsid { get; set; }
|
|||
|
|
public int step { get; set; }
|
|||
|
|
public int errorcode { get; set; }
|
|||
|
|
|
|||
|
|
public string errormsg { get; set; }
|
|||
|
|
public string remary { get; set; }
|
|||
|
|
|
|||
|
|
public string APKVersion { get; set; }
|
|||
|
|
|
|||
|
|
public string cmd { get; set; }
|
|||
|
|
|
|||
|
|
public DateTime creationtime { get; set; }
|
|||
|
|
}
|