using Microsoft.AspNetCore.Mvc;
|
using System.Net;
|
using System.Net.Http.Headers;
|
using Microsoft.Extensions.Hosting.Internal;
|
using Microsoft.AspNetCore.Http.Extensions;
|
using IStation.Untity;
|
using Furion.DynamicApiController;
|
using System.ComponentModel.DataAnnotations;
|
using Mapster;
|
using Microsoft.AspNetCore.Http;
|
using Furion.DependencyInjection;
|
using Microsoft.AspNetCore.Authorization;
|
using Furion.DataEncryption;
|
using Furion.FriendlyException;
|
|
namespace IStation.Application
|
{
|
/// <summary>
|
/// 主页
|
/// </summary>
|
[AllowAnonymous]
|
[Route("LargeScreen/Demo/Home")]
|
[ApiDescriptionSettings("LargeScreen", Name = "Demo(主页)", Order = 666)]
|
public class DemoHome_Controller : IDynamicApiController, ITransient
|
{
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
/// <summary>
|
///
|
/// </summary>
|
public DemoHome_Controller(IHttpContextAccessor httpContextAccessor)
|
{
|
_httpContextAccessor = httpContextAccessor;
|
}
|
|
/// <summary>
|
/// 获取泵站主页汇总信息(左上部分)
|
/// </summary>
|
/// <returns></returns>
|
[Route("GetLeftTopInfo")]
|
[HttpGet]
|
public DemoHomeLeftTopInfoDto GetLeftTopInfo()
|
{
|
DemoHomeLeftTopInfoDto info_list = new DemoHomeLeftTopInfoDto();
|
var r = new Random();
|
info_list.StationNumber = 10;
|
info_list.PumpNumber = r.Next(35, 42).ToString() + "/50";
|
info_list.TotalSupplyWater = r.Next(4535, 4642);
|
info_list.TotalEnergyConsumption = r.Next(12535, 12642);
|
|
info_list.YesterdayUnitEnergyConsumption = r.Next(883, 915) / 10.0;
|
info_list.YesterdayEnergyConsumption = r.Next(2860, 2965);
|
info_list.YesterdaySupplyWater = r.Next(2600, 2800);
|
return info_list;
|
}
|
|
/// <summary>
|
/// 获取泵站数据分析汇总信息(左中部分)
|
/// </summary>
|
/// <param name="StaticType">汇总类型(1按日 2 按周 3 按月 4 按年)</param>
|
[Route("GetLeftMiddleInfo")]
|
[HttpGet]
|
public List<DemoHomeLeftMiddleItemInfoDto> GetLeftMiddleInfo(int StaticType)
|
{
|
var r = new Random();
|
List<DemoHomeLeftMiddleItemInfoDto> info_list = new List<DemoHomeLeftMiddleItemInfoDto>();
|
if (StaticType == 1 || StaticType <= 0)
|
{
|
for (DateTime day = DateTime.Today.AddMonths(-1); day < DateTime.Today; day = day.AddDays(1))
|
{
|
DemoHomeLeftMiddleItemInfoDto item = new DemoHomeLeftMiddleItemInfoDto();
|
item.Label = day.ToString("yyyy-MM-dd");
|
item.SupplyWater = r.Next(2600, 2800);
|
item.EnergyConsumption = r.Next(2860, 2965);
|
info_list.Add(item);
|
}
|
}
|
else if (StaticType == 3 || StaticType == 2)
|
{//2按月
|
for (int month = 1; month < DateTime.Today.Month; month = month + 1)
|
{
|
DemoHomeLeftMiddleItemInfoDto item = new DemoHomeLeftMiddleItemInfoDto();
|
item.Label = month.ToString();
|
item.SupplyWater = r.Next(2600, 2800) * 30;
|
item.EnergyConsumption = r.Next(2860, 2965) * 30;
|
info_list.Add(item);
|
}
|
}
|
else
|
{//4 按年
|
for (int year = 1; year < 4; year = year + 1)
|
{
|
DemoHomeLeftMiddleItemInfoDto item = new DemoHomeLeftMiddleItemInfoDto();
|
item.Label = (DateTime.Today.Year - 3 + year).ToString();
|
item.SupplyWater = r.Next(2600, 2800) * 300;
|
item.EnergyConsumption = r.Next(2860, 2965) * 300;
|
info_list.Add(item);
|
}
|
}
|
return info_list;
|
}
|
|
/// <summary>
|
/// 获取泵站数据分析明细信息(左下部分)
|
/// </summary>
|
/// <param name="StaticType">汇总类型(1按日 2 按周 3 按月 4 按年)</param>
|
[Route("GetLeftBottomInfo")]
|
[HttpGet]
|
public List<DemoHomeLeftBottomItemInfoDto> GetLeftBottomInfo(int StaticType)
|
{
|
var r = new Random();
|
List<DemoHomeLeftBottomItemInfoDto> info_list = new List<DemoHomeLeftBottomItemInfoDto>();
|
|
int ratio = 1;
|
if (StaticType == 2)
|
ratio = 7;
|
if (StaticType == 3)
|
ratio = 30;
|
if (StaticType == 4)
|
ratio = 350;
|
List<string> station_name_list = new List<string>() { "松花江泵站", "市南泵站", "市北泵站", "鸭绿江泵站", "南大泵站" };
|
int ID = 1;
|
foreach (var name in station_name_list)
|
{
|
DemoHomeLeftBottomItemInfoDto item = new DemoHomeLeftBottomItemInfoDto();
|
item.ID = ID;
|
item.Name = name;
|
item.SupplyWater = r.Next(2600, 2800) * ratio;
|
item.EnergyConsumption = r.Next(2860, 2965) * ratio;
|
item.UnitEnergyConsumption = r.Next(883, 915) / 10.0;
|
info_list.Add(item);
|
|
ID++;
|
}
|
|
return info_list;
|
}
|
|
/// <summary>
|
/// 获取首页报警和信息公告(中间底部)
|
/// </summary>
|
/// <param name="InfoType">信息类型(1信息 2报警)</param>
|
[Route("GetCenterBottomInfo")]
|
[HttpGet]
|
public List<DemoHomeCenterBottomItemInfoDto> GetCenterBottomInfo(int InfoType)
|
{
|
var r = new Random();
|
List<DemoHomeCenterBottomItemInfoDto> info_list = new List<DemoHomeCenterBottomItemInfoDto>();
|
|
if (InfoType == 1)
|
{
|
DemoHomeCenterBottomItemInfoDto item1 = new DemoHomeCenterBottomItemInfoDto();
|
item1.Title = "松花江";
|
item1.UserName = "管理员";
|
item1.Content = "2020年8月26日,控江路管道维修抢修完成。";
|
info_list.Add(item1);
|
|
DemoHomeCenterBottomItemInfoDto item2 = new DemoHomeCenterBottomItemInfoDto();
|
item2.Title = "市南泵站";
|
item2.UserName = "管理员";
|
item2.Content = "2020年9月11日,二号泵电机振动过大,进行大修。";
|
info_list.Add(item2);
|
|
|
DemoHomeCenterBottomItemInfoDto item3 = new DemoHomeCenterBottomItemInfoDto();
|
item3.Title = "管网";
|
item3.UserName = "管理员";
|
item3.Content = "2020年9月22日,巡检员张坤成在人民广场附件发现曝管。";
|
info_list.Add(item2);
|
}
|
else
|
{
|
DemoHomeCenterBottomItemInfoDto item1 = new DemoHomeCenterBottomItemInfoDto();
|
item1.Title = "松花江";
|
item1.UserName = "李三林";
|
item1.Content = "2020年9月20日 12时30分,一号机漏水严重。";
|
info_list.Add(item1);
|
|
DemoHomeCenterBottomItemInfoDto item2 = new DemoHomeCenterBottomItemInfoDto();
|
item2.Title = "松花江";
|
item2.UserName = "李三林";
|
item2.Content = "2020年9月21日 12时30分,一号机漏水严重。";
|
info_list.Add(item2);
|
|
|
DemoHomeCenterBottomItemInfoDto item3 = new DemoHomeCenterBottomItemInfoDto();
|
item3.Title = "市南泵站";
|
item3.UserName = "管理员";
|
item3.Content = "2020年9月25日 12时30分,二号电机电流超标。";
|
info_list.Add(item2);
|
}
|
|
|
return info_list;
|
}
|
|
/// <summary>
|
/// 获取表单状态统计占比(右部上)
|
/// </summary>
|
/// <param name="StaticType">统计类型(1按日 2 按周 3 按月 4 按年) </param>
|
[Route("GetRightTopInfo")]
|
[HttpGet]
|
public DemoHomeRightTopInfoDto GetRightTopInfo(int StaticType)
|
{
|
var r = new Random();
|
int ratio = 1;
|
if (StaticType == 2)
|
ratio = 5;
|
if (StaticType == 3)
|
ratio = 20;
|
if (StaticType == 4)
|
ratio = 250;
|
|
DemoHomeRightTopInfoDto item1 = new DemoHomeRightTopInfoDto();
|
|
item1.ProcessedForm = r.Next(6, 10) * ratio;
|
item1.ProcessingForm = r.Next(4, 8) * ratio;
|
item1.UnProcessingForm = r.Next(3, 7) * ratio;
|
item1.TotalForm = item1.ProcessedForm + item1.ProcessingForm + item1.UnProcessingForm;
|
|
return item1;
|
}
|
|
|
/// <summary>
|
/// 获取表单类型统计占比(右部中)
|
/// </summary>
|
/// <param name="StaticType">统计类型(1按日 2 按周 3 按月 4 按年)</param>
|
[Route("GetRightCenterInfo")]
|
[HttpGet]
|
public List<DemoHomeRightCenterInfoDto> GetRightCenterInfo(int StaticType)
|
{
|
var r = new Random();
|
List<DemoHomeRightCenterInfoDto> info_list = new List<DemoHomeRightCenterInfoDto>();
|
int ratio = 1;
|
if (StaticType == 2)
|
ratio = 7;
|
if (StaticType == 3)
|
ratio = 30;
|
if (StaticType == 4)
|
ratio = 350;
|
|
|
DemoHomeRightCenterInfoDto item1 = new DemoHomeRightCenterInfoDto();
|
item1.Label = "机组故障";
|
item1.Number = r.Next(8, 11) * ratio;
|
info_list.Add(item1);
|
|
|
DemoHomeRightCenterInfoDto item2 = new DemoHomeRightCenterInfoDto();
|
item2.Label = "管道维修";
|
item2.Number = r.Next(2, 5) * ratio;
|
info_list.Add(item2);
|
|
|
DemoHomeRightCenterInfoDto item3 = new DemoHomeRightCenterInfoDto();
|
item3.Label = "阀门维修";
|
item3.Number = r.Next(1, 3) * ratio;
|
info_list.Add(item3);
|
|
DemoHomeRightCenterInfoDto item4 = new DemoHomeRightCenterInfoDto();
|
item4.Label = "仪表";
|
item4.Number = r.Next(2, 4) * ratio;
|
info_list.Add(item4);
|
|
DemoHomeRightCenterInfoDto item5 = new DemoHomeRightCenterInfoDto();
|
item5.Label = "其他";
|
item5.Number = r.Next(5, 12) * ratio;
|
info_list.Add(item5);
|
return info_list;
|
}
|
|
}
|
}
|