370 lines
15 KiB
C#
370 lines
15 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using BLL;
|
|
using FineUIPro.Web.ZHGL.DataSync;
|
|
using Model;
|
|
using Newtonsoft.Json;
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ListView;
|
|
|
|
namespace FineUIPro.Web.common
|
|
{
|
|
public partial class mainMenu_ZJ : PageBase
|
|
{
|
|
public Model.HSSEData_HSSE hSSEData_HSSE;
|
|
public List<Model.HSSEDataHiddenDangerDetailItem> hiddenDangerDetailList;
|
|
public List<Base_Project> projectList;
|
|
public string zgl1;
|
|
public string zgl2;
|
|
|
|
public string dataYHQ;
|
|
public string dataYHZ;
|
|
public string xArrYH;
|
|
public string projectData;
|
|
public string notice;
|
|
|
|
protected string VideoURL
|
|
{
|
|
get
|
|
{
|
|
string video_Url = string.Empty;
|
|
var sysSet16 = (from x in Funs.DB.Sys_Set where x.SetName == "视频监控地址" select x).ToList().FirstOrDefault();
|
|
if (sysSet16 != null)
|
|
{
|
|
video_Url = sysSet16.SetValue;
|
|
}
|
|
var sysSet17 = (from x in Funs.DB.Sys_Set where x.SetName == "视频监控密码" select x).ToList().FirstOrDefault();
|
|
if (sysSet17 != null)
|
|
{
|
|
return video_Url + "#/screen?username=admin&password=" + Funs.EncryptionPassword(sysSet17.SetValue);
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
protected string VideoHost
|
|
{
|
|
get
|
|
{
|
|
string video_Url = string.Empty;
|
|
var sysSet16 = (from x in Funs.DB.Sys_Set where x.SetName == "视频监控地址" select x).ToList().FirstOrDefault();
|
|
if (sysSet16 != null)
|
|
{
|
|
video_Url = sysSet16.SetValue;
|
|
}
|
|
|
|
return video_Url;
|
|
|
|
}
|
|
}
|
|
protected string VideoPassWord
|
|
{
|
|
get
|
|
{
|
|
var sysSet17 = (from x in Funs.DB.Sys_Set where x.SetName == "视频监控密码" select x).ToList().FirstOrDefault();
|
|
return Funs.EncryptionPassword(sysSet17.SetValue);
|
|
}
|
|
}
|
|
protected string VideoUserName
|
|
{
|
|
get
|
|
{
|
|
return "zhongji";
|
|
}
|
|
}
|
|
protected async void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
|
|
MainSevice mainSevice = new MainSevice(this.CurrUser.UserId);
|
|
try
|
|
{
|
|
hSSEData_HSSE = await mainSevice.GetHsseDataAsync().ConfigureAwait(false);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
throw;
|
|
}
|
|
|
|
hiddenDangerDetailList = mainSevice.GetDataHiddenDangerDetailItems();
|
|
int unitType = CommonService.GetUnitTypeByUserId(this.CurrUser.UserId);
|
|
if (unitType == 0)
|
|
{
|
|
|
|
projectList = Funs.DB.Base_Project.Where(x => x.MapCoordinates != null && (x.IsDelete == null || x.IsDelete == false)).ToList();
|
|
}
|
|
else if (unitType == 1)
|
|
{
|
|
|
|
projectList = Funs.DB.Base_Project.Where(x => x.UnitId == this.CurrUser.UnitId && x.MapCoordinates != null && (x.IsDelete == null || x.IsDelete == false)).ToList();
|
|
}
|
|
else if (unitType == 2)
|
|
{
|
|
hSSEData_HSSE = new Model.HSSEData_HSSE();
|
|
hiddenDangerDetailList = new List<HSSEDataHiddenDangerDetailItem>();
|
|
projectList = new List<Base_Project>();
|
|
}
|
|
zgl1 = "0";
|
|
zgl2 = "0";
|
|
if (hSSEData_HSSE.GeneralClosedNum.HasValue && hSSEData_HSSE.GeneralNotClosedNum.HasValue)
|
|
{
|
|
zgl1 = String.Format("{0:N2}", 100.0 * hSSEData_HSSE.GeneralClosedNum.Value / (hSSEData_HSSE.GeneralClosedNum.Value + hSSEData_HSSE.GeneralNotClosedNum.Value));
|
|
}
|
|
else
|
|
{
|
|
zgl1 = "0";
|
|
}
|
|
if (hSSEData_HSSE.MajorClosedNum.HasValue && hSSEData_HSSE.MajorNotClosedNum.HasValue)
|
|
{
|
|
zgl2 = String.Format("{0:N2}", 100.0 * hSSEData_HSSE.MajorClosedNum.Value / (hSSEData_HSSE.MajorClosedNum.Value + hSSEData_HSSE.MajorNotClosedNum.Value));
|
|
}
|
|
else
|
|
{
|
|
zgl2 = "0";
|
|
}
|
|
if (hSSEData_HSSE.GeneralClosedNum.HasValue && hSSEData_HSSE.GeneralNotClosedNum.HasValue)
|
|
{
|
|
zgl1 = String.Format("{0:N2}", 100.0 * hSSEData_HSSE.GeneralClosedNum.Value / (hSSEData_HSSE.GeneralClosedNum.Value + hSSEData_HSSE.GeneralNotClosedNum.Value));
|
|
}
|
|
else
|
|
{
|
|
zgl1 = "0";
|
|
}
|
|
|
|
/*var reportDate = Funs.DB.HSSEData_HiddenDangerDetail.Max(x => x.ReportDate);
|
|
if (reportDate.HasValue)
|
|
{
|
|
var details = Funs.DB.HSSEData_HiddenDangerDetail.Where(x => x.ReportDate == reportDate.Value).ToList();
|
|
|
|
if (details != null && details.Count > 0)
|
|
{
|
|
foreach (var d in details)
|
|
{
|
|
dataYHQ += d.TotalNum + ",";
|
|
dataYHZ += d.NeedRectifyNum + ",";
|
|
xArrYH += "'" + d.TypeName + "',";
|
|
}
|
|
dataYHQ = dataYHQ.TrimEnd(',');
|
|
dataYHZ = dataYHZ.TrimEnd(',');
|
|
xArrYH = xArrYH.TrimEnd('\'').TrimEnd(',');
|
|
}
|
|
}*/
|
|
if (hiddenDangerDetailList.Count > 0)
|
|
{
|
|
foreach (var d in hiddenDangerDetailList)
|
|
{
|
|
dataYHQ += d.TotalNum + ",";
|
|
dataYHZ += d.NeedRectifyNum + ",";
|
|
xArrYH += "'" + d.TypeName + "',";
|
|
}
|
|
dataYHQ = dataYHQ.TrimEnd(',');
|
|
dataYHZ = dataYHZ.TrimEnd(',');
|
|
xArrYH = xArrYH.TrimEnd('\'').TrimEnd(',');
|
|
}
|
|
|
|
|
|
if (projectList != null && projectList.Count > 0)
|
|
{
|
|
foreach (var p in projectList)
|
|
{
|
|
string unit_yz = ProjectService.getProjectUnitNameByUnitType(p.ProjectId, Const.ProjectUnitType_4);
|
|
string unit_JL = ProjectService.getProjectUnitNameByUnitType(p.ProjectId, Const.ProjectUnitType_3);
|
|
string unit_FB = ProjectService.getProjectUnitNameByUnitType(p.ProjectId, Const.ProjectUnitType_2);
|
|
projectData += "{name:'" + p.ShortName + "',value:['" + p.MapCoordinates + "'],address:'" + p.ProjectAddress + "',id:'" + p.ProjectId + "',ownUnit:'" + unit_yz + "',jLUnit:'" + unit_JL + "',SGUnit:'" + unit_FB + "',ProjectMoney:'" + p.ProjectMoney.ToString() + "'},";
|
|
}
|
|
projectData = projectData.TrimEnd(',');
|
|
}
|
|
|
|
getAlarmData();
|
|
getNotice();
|
|
}
|
|
}
|
|
|
|
|
|
public void getVideo()
|
|
{
|
|
var sysSet16 = (from x in Funs.DB.Sys_Set where x.SetName == "视频监控地址" select x).ToList().FirstOrDefault();
|
|
var sysSet17 = (from x in Funs.DB.Sys_Set where x.SetName == "视频监控密码" select x).ToList().FirstOrDefault();
|
|
if (sysSet16 == null)
|
|
{
|
|
return;
|
|
}
|
|
if (sysSet17 == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
string url = sysSet16.SetValue;
|
|
string username = "admin";
|
|
string password = sysSet17.SetValue;
|
|
String res = BLL.CommonService.CreateGetHttpResponse(url + "api/v1/login?username=" + username + "&password=" + Funs.EncryptionPassword(password));
|
|
Dictionary<string, string> dicres = JsonConvert.DeserializeObject<Dictionary<string, string>>(res);
|
|
string URLToken = dicres["URLToken"];
|
|
DataTable dt = new DataTable();
|
|
dt.Columns.Add("id");
|
|
dt.Columns.Add("name");
|
|
dt.Columns.Add("serial");
|
|
dt.Columns.Add("deviceName");
|
|
List<string> urls = new List<string>();
|
|
res = APIGetHttpService.Http(url + "api/v1/device/channeltree?token=" + URLToken);
|
|
List<Dictionary<string, string>> jsonNvr = JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(res);
|
|
foreach (Dictionary<string, string> nvr in jsonNvr)
|
|
{
|
|
string jsonCameras = APIGetHttpService.Http(url + "api/v1/device/channeltree?token=" + URLToken + "&serial=" + nvr["serial"]);
|
|
List<Dictionary<string, string>> jsonDiv = JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(jsonCameras);
|
|
foreach (Dictionary<string, string> div in jsonDiv)
|
|
{
|
|
var rowDiv = dt.NewRow();
|
|
rowDiv["id"] = div["id"];
|
|
rowDiv["deviceName"] = nvr["customName"];
|
|
if (!string.IsNullOrEmpty(div["customName"]))
|
|
{
|
|
rowDiv["name"] = div["customName"];
|
|
}
|
|
else
|
|
{
|
|
rowDiv["name"] = div["name"];
|
|
}
|
|
rowDiv["serial"] = div["code"];
|
|
|
|
dt.Rows.Add(rowDiv);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public string showData(int? value, string format)
|
|
{
|
|
if (value.HasValue)
|
|
{
|
|
return value.Value.ToString();
|
|
}
|
|
else
|
|
{
|
|
return format;
|
|
}
|
|
}
|
|
|
|
public string showDecimalData(decimal? value, string format)
|
|
{
|
|
if (value.HasValue)
|
|
{
|
|
return value.Value.ToString();
|
|
}
|
|
else
|
|
{
|
|
return format;
|
|
}
|
|
}
|
|
|
|
#region 预警警报
|
|
private void getAlarmData()
|
|
{
|
|
//#region 当日水电消耗
|
|
//var energyData_Electricit = (from x in Funs.DB.ZJ_Energy
|
|
// group x by new { x.ProjectId } into g
|
|
// select new
|
|
// {
|
|
// ProjectId = g.Key,
|
|
// TotalElectricityUse = 120 * (g.Max(e => e.ElectricityUse) - g.Min(e => e.ElectricityUse))
|
|
// }).ToList();
|
|
//var energyData_Water = (from x in Funs.DB.ZJ_Energy
|
|
// group x by new { x.ProjectId } into g
|
|
// select new
|
|
// {
|
|
// ProjectId = g.Key,
|
|
// TotalWaterUse = g.Max(x => x.WaterUse) - g.Min(x => x.WaterUse),
|
|
// }).ToList();
|
|
//divenergyData.InnerHtml = "";
|
|
//string strenergyData_Electricit = "";
|
|
//string strenergyData_Water = "";
|
|
//if (energyData_Electricit.Count > 0)
|
|
//{
|
|
// strenergyData_Electricit = energyData_Electricit.Sum(x => x.TotalElectricityUse).ToString();
|
|
//}
|
|
//if (energyData_Water.Count > 0)
|
|
//{
|
|
// strenergyData_Water = energyData_Water.Sum(x => x.TotalWaterUse).ToString();
|
|
//}
|
|
|
|
|
|
//divenergyData.InnerHtml = strenergyData_Water + "吨|" + strenergyData_Electricit + "Kwh";
|
|
//#endregion
|
|
|
|
|
|
#region 累计水电消耗
|
|
var energyData_Electricit = (from x in Funs.DB.ZJ_Energy
|
|
group x by new { x.ProjectId } into g
|
|
select new
|
|
{
|
|
ProjectId = g.Key,
|
|
ElectricityUse = g.Max(x => x.ElectricityUse),
|
|
}).ToList();
|
|
var energyData_Water = (from x in Funs.DB.ZJ_Energy
|
|
group x by new { x.ProjectId } into g
|
|
select new
|
|
{
|
|
ProjectId = g.Key,
|
|
WaterUse = g.Max(x => x.WaterUse),
|
|
}).ToList();
|
|
divenergyData.InnerHtml = "";
|
|
string strenergyData_Electricit = "";
|
|
string strenergyData_Water = "";
|
|
if (energyData_Electricit.Count > 0)
|
|
{
|
|
strenergyData_Electricit = (energyData_Electricit.Sum(x => x.ElectricityUse) * 120).ToString();
|
|
}
|
|
if (energyData_Water.Count > 0)
|
|
{
|
|
strenergyData_Water = energyData_Water.Sum(x => x.WaterUse).ToString();
|
|
}
|
|
divenergyData.InnerHtml = strenergyData_Water + "吨|" + strenergyData_Electricit + "Kwh";
|
|
#endregion
|
|
|
|
var carWashCheckData = (from x in Funs.DB.ZJ_CarWashCheck
|
|
where x.CapTime > DateTime.Now.Date
|
|
orderby x.CapTime descending
|
|
select x).ToList();
|
|
var deepPitCheckData = (from x in Funs.DB.ZJ_DeepPitCheck
|
|
where x.Time > DateTime.Now.Date
|
|
orderby x.Time descending
|
|
select x).ToList();
|
|
var towerCraneWarningData = (from x in Funs.DB.ZJ_TowerCraneWarning
|
|
where x.Time > DateTime.Now.Date
|
|
orderby x.Time descending
|
|
select x).ToList();
|
|
|
|
divtowerCraneWarningData.InnerHtml = towerCraneWarningData.Count.ToString();
|
|
divdeepPitCheckData.InnerHtml = deepPitCheckData.Count.ToString();
|
|
divcarWashCheckData.InnerHtml = carWashCheckData.Count.ToString();
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
private void getNotice()
|
|
{
|
|
var noticeList = (from x in Funs.DB.InformationProject_Notice orderby x.CompileDate descending select x).ToList();
|
|
foreach (var item in noticeList)
|
|
{
|
|
string tr = string.Format(
|
|
"<div class=\"tr\" title=\" {0}\" >\r\n <span class=\"time\">\r\n {1}\r\n </span>\r\n <span class=\"content\">\r\n {2}\r\n </span>\r\n\t\t\t\t\t\t\r\n </div>",
|
|
item.NoticeTitle, string.Format("{0:yyyy-MM-dd}", item.CompileDate), item.NoticeTitle);
|
|
notice += tr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
} |