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/Station")]
|
[ApiDescriptionSettings("LargeScreen", Name = "Demo(泵站)", Order = 666)]
|
public class DemoStation_Controller : IDynamicApiController, ITransient
|
{
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
/// <summary>
|
///
|
/// </summary>
|
public DemoStation_Controller(IHttpContextAccessor httpContextAccessor)
|
{
|
_httpContextAccessor = httpContextAccessor;
|
}
|
|
/// <summary>
|
/// 获取泵站主页汇总信息(左上部分)
|
/// </summary>
|
/// <param name="StationID">泵站ID</param>
|
[Route("GetLeftTopInfo")]
|
[HttpGet]
|
public DemoStationLeftTopInfoDto GetLeftTopInfo(long StationID)
|
{
|
DemoStationLeftTopInfoDto info_list = new DemoStationLeftTopInfoDto();
|
var r = new Random();
|
info_list.StationName = "松花江泵站";
|
info_list.RecordInfos = new List<DemoStationRecordInfoDto>();
|
info_list.RecordInfos.Add(new DemoStationRecordInfoDto() { ID = 1, Name = "出口压力", Value = (r.Next(10, 30) / 200.0 + 0.341).ToString(), Unit = "MPa" });
|
info_list.RecordInfos.Add(new DemoStationRecordInfoDto() { ID = 2, Name = "出口流量", Value = (r.Next(510, 530) + 2).ToString(), Unit = "m³/h" });
|
info_list.RecordInfos.Add(new DemoStationRecordInfoDto() { ID = 3, Name = "总功率", Value = (r.Next(210, 230) + 1.2).ToString(), Unit = "kW" });
|
info_list.RecordInfos.Add(new DemoStationRecordInfoDto() { ID = 4, Name = "单位能耗", Value = (r.Next(10, 30) + 73.2).ToString(), Unit = "kW/千吨水" });
|
|
|
info_list.RunInfos = new List<DemoStationRunInfoDto>();
|
info_list.RunInfos.Add(new DemoStationRunInfoDto() { ID = 1, Name = "一号泵", OpenStatus = 1 });
|
info_list.RunInfos.Add(new DemoStationRunInfoDto() { ID = 2, Name = "二号泵", OpenStatus = 0 });
|
info_list.RunInfos.Add(new DemoStationRunInfoDto() { ID = 3, Name = "三号泵", OpenStatus = 0 });
|
info_list.RunInfos.Add(new DemoStationRunInfoDto() { ID = 4, Name = "四号泵", OpenStatus = 1 });
|
info_list.RunInfos.Add(new DemoStationRunInfoDto() { ID = 5, Name = "五号泵", OpenStatus = -1 });
|
info_list.RunInfos.Add(new DemoStationRunInfoDto() { ID = 6, Name = "六号泵", OpenStatus = 1 });
|
|
|
|
return info_list;
|
}
|
|
/// <summary>
|
/// 获取泵站数据分析汇总信息(左中部分)
|
/// </summary>
|
/// <param name="StationID">泵站ID</param>
|
/// <param name="StaticType">汇总类型(1按日 2 按周 3 按月 4 按年)</param>
|
/// <returns></returns>
|
[Route("GetLeftMiddleInfo")]
|
[HttpGet]
|
public List<DemoStationLeftMiddleItemInfoDto> GetLeftMiddleInfo(long StationID, int StaticType)
|
{
|
var r = new Random();
|
List<DemoStationLeftMiddleItemInfoDto> info_list = new List<DemoStationLeftMiddleItemInfoDto>();
|
if (StaticType == 1 || StaticType <= 0)
|
{
|
for (DateTime day = DateTime.Today.AddMonths(-1); day < DateTime.Today; day = day.AddDays(1))
|
{
|
DemoStationLeftMiddleItemInfoDto item = new DemoStationLeftMiddleItemInfoDto();
|
item.Label = day.ToString("yyyy-MM-dd");
|
item.SupplyWater = r.Next(260, 280);
|
item.EnergyConsumption = r.Next(280, 295);
|
info_list.Add(item);
|
}
|
}
|
else if (StaticType == 3 || StaticType == 2)
|
{//2 按周 3 按月
|
for (int month = 1; month < DateTime.Today.Month; month = month + 1)
|
{
|
DemoStationLeftMiddleItemInfoDto item = new DemoStationLeftMiddleItemInfoDto();
|
item.Label = month.ToString();
|
item.SupplyWater = r.Next(260, 280) * 30;
|
item.EnergyConsumption = r.Next(220, 235) * 30;
|
info_list.Add(item);
|
}
|
}
|
else
|
{//4 按年
|
for (int year = 1; year < 4; year = year + 1)
|
{
|
DemoStationLeftMiddleItemInfoDto item = new DemoStationLeftMiddleItemInfoDto();
|
item.Label = (DateTime.Today.Year - 3 + year).ToString();
|
item.SupplyWater = r.Next(260, 280) * 270;
|
item.EnergyConsumption = r.Next(260, 275) * 270;
|
info_list.Add(item);
|
}
|
}
|
return info_list;
|
}
|
|
/// <summary>
|
/// 获取泵站数据分析明细信息(左下部分)
|
/// </summary>
|
/// <param name="StationID">泵站ID</param>
|
/// <param name="StaticType">汇总类型(1按日 2 按周 3 按月 4 按年)</param>
|
/// <returns></returns>
|
[Route("GetLeftBottomInfo")]
|
[HttpGet]
|
public List<DemoStationLeftBottomItemInfoDto> GetLeftBottomInfo(long StationID, int StaticType)
|
{
|
var r = new Random();
|
List<DemoStationLeftBottomItemInfoDto> info_list = new List<DemoStationLeftBottomItemInfoDto>();
|
|
int ratio = 1;
|
if (StaticType == 2)
|
ratio = 7;
|
if (StaticType == 3)
|
ratio = 30;
|
if (StaticType == 4)
|
ratio = 350;
|
|
var product_name_list = new List<string>() { "一号泵", "二号泵", "三号泵", "四号泵", "五号泵", "六号泵" };
|
|
int ID = 1;
|
foreach (var name in product_name_list)
|
{
|
DemoStationLeftBottomItemInfoDto item = new DemoStationLeftBottomItemInfoDto();
|
item.ID = ID;
|
item.Name = name;
|
item.SupplyWater = r.Next(260, 270) * ratio;
|
item.EnergyConsumption = r.Next(260, 275) * ratio;
|
item.UnitEnergyConsumption = r.Next(183, 195) / 10.0;
|
info_list.Add(item);
|
|
ID++;
|
}
|
|
return info_list;
|
}
|
|
/// <summary>
|
/// 获取首页报警和信息公告(中间底部)
|
/// </summary>
|
/// <param name="StationID">泵站ID</param>
|
/// <param name="InfoType">信息类型(1公告信息 2报警信息)</param>
|
[Route("GetCenterBottomInfo")]
|
[HttpGet]
|
public List<DemoStationCenterBottomItemInfoDto> GetCenterBottomInfo(long StationID, int InfoType)
|
{
|
var r = new Random();
|
List<DemoStationCenterBottomItemInfoDto> info_list = new List<DemoStationCenterBottomItemInfoDto>();
|
|
if (InfoType == 1)
|
{
|
DemoStationCenterBottomItemInfoDto item1 = new DemoStationCenterBottomItemInfoDto();
|
item1.Title = "一号泵";
|
item1.UserName = "管理员";
|
item1.Content = "2020年8月26日,控江路管道维修抢修完成。";
|
info_list.Add(item1);
|
|
DemoStationCenterBottomItemInfoDto item2 = new DemoStationCenterBottomItemInfoDto();
|
item2.Title = "二号泵";
|
item2.UserName = "管理员";
|
item2.Content = "2020年9月11日,二号泵电机振动过大,进行大修。";
|
info_list.Add(item2);
|
|
|
DemoStationCenterBottomItemInfoDto item3 = new DemoStationCenterBottomItemInfoDto();
|
item3.Title = "二号泵";
|
item3.UserName = "管理员";
|
item3.Content = "2020年9月22日,巡检员张坤成在人民广场附件发现曝管。";
|
info_list.Add(item2);
|
}
|
else
|
{
|
DemoStationCenterBottomItemInfoDto item1 = new DemoStationCenterBottomItemInfoDto();
|
item1.Title = "二号泵";
|
item1.UserName = "李三林";
|
item1.Content = "2020年9月20日 12时30分,一号机漏水严重。";
|
info_list.Add(item1);
|
|
DemoStationCenterBottomItemInfoDto item2 = new DemoStationCenterBottomItemInfoDto();
|
item2.Title = "二号泵";
|
item2.UserName = "李三林";
|
item2.Content = "2020年9月21日 12时30分,一号机漏水严重。";
|
info_list.Add(item2);
|
|
|
DemoStationCenterBottomItemInfoDto item3 = new DemoStationCenterBottomItemInfoDto();
|
item3.Title = "二号泵";
|
item3.UserName = "管理员";
|
item3.Content = "2020年9月25日 12时30分,二号电机电流超标。";
|
info_list.Add(item2);
|
}
|
|
return info_list;
|
}
|
|
/// <summary>
|
/// 获取表单状态统计占比(右部上)
|
/// </summary>
|
/// <param name="StationID">泵站ID</param>
|
/// <param name="StaticType">统计类型(1按日 2 按周 3 按月 4 按年) </param>
|
[Route("GetRightTopInfo")]
|
[HttpGet]
|
public DemoStationRightTopInfoDto GetRightTopInfo(long StationID, int StaticType)
|
{
|
var r = new Random();
|
int ratio = 1;
|
if (StaticType == 2)
|
ratio = 5;
|
if (StaticType == 3)
|
ratio = 20;
|
if (StaticType == 4)
|
ratio = 250;
|
|
DemoStationRightTopInfoDto item1 = new DemoStationRightTopInfoDto();
|
|
item1.ProcessedForm = r.Next(1, 2) * ratio;
|
item1.ProcessingForm = r.Next(1, 3) * ratio;
|
item1.UnProcessingForm = r.Next(0, 1) * ratio;
|
item1.TotalForm = item1.ProcessedForm + item1.ProcessingForm + item1.UnProcessingForm;
|
|
return item1;
|
}
|
|
/// <summary>
|
/// 获取表单类型统计占比(右部中)
|
/// </summary>
|
/// <param name="StationID">泵站ID</param>
|
/// <param name="StaticType">统计类型(1按日 2 按周 3 按月 4 按年)</param>
|
[Route("GetRightCenterInfo")]
|
[HttpGet]
|
public List<DemoStationRightCenterInfoDto> GetRightCenterInfo(long StationID, int StaticType)
|
{
|
var r = new Random();
|
List<DemoStationRightCenterInfoDto> info_list = new List<DemoStationRightCenterInfoDto>();
|
int ratio = 1;
|
if (StaticType == 2)
|
ratio = 7;
|
if (StaticType == 3)
|
ratio = 30;
|
if (StaticType == 4)
|
ratio = 350;
|
|
|
DemoStationRightCenterInfoDto item1 = new DemoStationRightCenterInfoDto();
|
item1.Label = "机组故障";
|
item1.Number = r.Next(1, 3) * ratio;
|
info_list.Add(item1);
|
|
|
DemoStationRightCenterInfoDto item2 = new DemoStationRightCenterInfoDto();
|
item2.Label = "管道维修";
|
item2.Number = r.Next(0, 3) * ratio;
|
info_list.Add(item2);
|
|
|
DemoStationRightCenterInfoDto item3 = new DemoStationRightCenterInfoDto();
|
item3.Label = "阀门维修";
|
item3.Number = r.Next(0, 3) * ratio;
|
info_list.Add(item3);
|
|
DemoStationRightCenterInfoDto item4 = new DemoStationRightCenterInfoDto();
|
item4.Label = "仪表";
|
item4.Number = r.Next(0, 4) * ratio;
|
info_list.Add(item4);
|
|
DemoStationRightCenterInfoDto item5 = new DemoStationRightCenterInfoDto();
|
item5.Label = "其他";
|
item5.Number = r.Next(0, 5) * ratio;
|
info_list.Add(item5);
|
return info_list;
|
}
|
|
/// <summary>
|
/// 通过 ID 获取详细
|
/// </summary>
|
[Route("GetDetailByID")]
|
[HttpGet]
|
public DemoStationDetailDto GetDetailByID([FromQuery][Required] IDUnderCorpInput input)
|
{
|
var model = new Service.Station().GetByID(input.CorpID, input.ID);
|
return model == null ? null : new DemoStationDetailDto(model);
|
}
|
|
}
|
}
|