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/Szjt/Bzgl")]
|
[ApiDescriptionSettings("LargeScreen", Name = "苏州金庭(泵站管理)", Order = 999)]
|
public class SzjtBzgl_Controller : IDynamicApiController, ITransient
|
{
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
/// <summary>
|
///
|
/// </summary>
|
public SzjtBzgl_Controller(IHttpContextAccessor httpContextAccessor)
|
{
|
_httpContextAccessor = httpContextAccessor;
|
}
|
|
#region const
|
|
private const long _corpid = 3;//客户标识
|
|
private const long _stationId = 23;//泵站标识
|
|
private const long _tlpointid_23 = 1688;//累积流量
|
private const long _tlsignalid_23 = 2388;//累积流量信号
|
|
private const long _lpointid_23 = 1687;//瞬时流量
|
private const long _lsignalid_23 = 2387;//瞬时流量信号
|
|
private const long _zdpointId_23 = 1692;//浊度
|
private const long _zdsignalid_23 = 2392;//浊度信号
|
|
private const long _ylpointid_23 = 1693;//余氯
|
private const long _ylsignalid_23 = 2393;//余氯信号
|
|
private const long _ckylpointid_23 = 1690;//出口压力
|
private const long _ckylsignalid_23 = 2390;//出口压力信号
|
|
|
#endregion
|
|
/// <summary>
|
/// 制水生产 (左上部分)
|
/// </summary>
|
/// <returns></returns>
|
[Route("GetLeftTopInfo")]
|
[HttpGet]
|
public SzjtBzglLeftTopInfoDto GetLeftTopInfo()
|
{
|
|
SzjtBzglLeftTopInfoDto info_list = new SzjtBzglLeftTopInfoDto();
|
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;
|
|
// LeftTopInfo info_list = new LeftTopInfo();
|
//var service_station = new Service.StationBase();
|
//var service_product = new Service.ProductBase();
|
//var servive_record = new Service.GeneralRecord();
|
//var service_stationRun = new Service.StationRun();
|
//var service_pumpRun = new Service.PumpRun();
|
|
////泵站数量
|
//var allStations = service_station.GetByCorpID(CorpID);
|
//if (allStations != null)
|
// info_list.StationNumber = allStations.Count();
|
|
////开机数/总数
|
//int pumpsCount=0, pumpRunCount = 0;
|
//var pumps = service_product.GetMachine机泵ByCorpID(CorpID);
|
//if (pumps != null && pumps.Count > 0)
|
//{
|
// pumpsCount = pumps.Count;
|
// var allPumpRealStatus = service_pumpRun.GetRunRealStatus(pumps.Select(x=>x.ID));
|
// if (allPumpRealStatus != null && allPumpRealStatus.Count > 0)
|
// {
|
// pumpRunCount = allPumpRealStatus.Where(x => x.RunStatus == Model.eRunStatus.开机).Count();
|
// }
|
//}
|
//info_list.PumpNumber = string.Format("{0}/{1}",pumpRunCount,pumpsCount);
|
|
////总供水量
|
//var tq_record = servive_record.GetLastRecordValue(_tlpointid_13);
|
//info_list.TotalSupplyWater =NumberHelper.Round( tq_record,2);
|
|
////总能耗
|
//info_list.TotalEnergyConsumption =NumberHelper.Round( servive_record.GetLastRecordValue(_dpointId_13),2);
|
|
////昨日总能耗
|
//var d_yes_firstValue = servive_record.GetFirstRecordInDayByPointID(_dpointId_13, DateTime.Now.AddDays(-1));
|
//var d_yes_lastVlaue = servive_record.GetLastRecordInDayByPointID(_dpointId_13, DateTime.Now.AddDays(-1));
|
//if (d_yes_firstValue != null && d_yes_lastVlaue != null)
|
// info_list.YesterdayEnergyConsumption = NumberHelper.Round(d_yes_lastVlaue.DataValue - d_yes_firstValue.DataValue, 2);
|
|
////昨日累积供水量
|
//var tl_yes_firstValue = servive_record.GetFirstRecordInDayByPointID(_tlpointid_13, DateTime.Now.AddDays(-1));
|
//var tl_yes_lastVlaue = servive_record.GetLastRecordInDayByPointID(_tlpointid_13, DateTime.Now.AddDays(-1));
|
//if (tl_yes_firstValue != null && tl_yes_lastVlaue != null)
|
// info_list.YesterdaySupplyWater = NumberHelper.Round(tl_yes_lastVlaue.DataValue - tl_yes_firstValue.DataValue, 2);
|
|
////昨日单耗
|
//if (info_list.YesterdayEnergyConsumption != null)
|
//{
|
// if (info_list.YesterdaySupplyWater != null&&info_list.YesterdaySupplyWater!=0)
|
// {
|
// info_list.YesterdayUnitEnergyConsumption = NumberHelper.Round(info_list.YesterdayEnergyConsumption.Value / info_list.YesterdaySupplyWater.Value * 1000, 2);
|
// }
|
//}
|
|
|
|
}
|
|
/// <summary>
|
/// 泵站分析 (左中部分)
|
/// </summary>
|
/// <param name="StaticType">汇总类型(1按日 2 按周 3 按月 4 按年)</param>
|
[Route("GetLeftMiddleInfo")]
|
[HttpGet]
|
public List<SzjtBzglLeftMiddleItemInfoDto> GetLeftMiddleInfo(int StaticType)
|
{
|
var r = new Random();
|
List<SzjtBzglLeftMiddleItemInfoDto> info_list = new List<SzjtBzglLeftMiddleItemInfoDto>();
|
if (StaticType == 1 || StaticType <= 0)
|
{
|
for (DateTime day = DateTime.Today.AddMonths(-1); day < DateTime.Today; day = day.AddDays(1))
|
{
|
SzjtBzglLeftMiddleItemInfoDto item = new SzjtBzglLeftMiddleItemInfoDto();
|
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)
|
{
|
SzjtBzglLeftMiddleItemInfoDto item = new SzjtBzglLeftMiddleItemInfoDto();
|
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)
|
{
|
SzjtBzglLeftMiddleItemInfoDto item = new SzjtBzglLeftMiddleItemInfoDto();
|
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<SzjtBzglLeftBottomItemInfoDto> GetLeftBottomInfo(int StaticType)
|
{
|
var info_list = new List<SzjtBzglLeftBottomItemInfoDto>();
|
var service_station = new Service.Station();
|
var service_record = new Service.MonitorRealRecord();
|
|
var station_list = service_station.GetByCorpID(_corpid);
|
|
foreach (var station in station_list)
|
{
|
var item = new SzjtBzglLeftBottomItemInfoDto();
|
item.ID = station.ID;
|
item.Name = station.Name;
|
if (station.ID == _stationId)
|
{
|
item.Flow = NumberHelper.RoundString(double.Parse(service_record.GetLastRecord(_corpid, _lpointid_23, _lsignalid_23).DataValue), 2);
|
item.Press = NumberHelper.RoundString(double.Parse(service_record.GetLastRecord(_corpid, _ckylpointid_23, _ckylsignalid_23).DataValue), 2);
|
item.ResidualChlorine = NumberHelper.RoundString(double.Parse(service_record.GetLastRecord(_corpid, _ylpointid_23, _ylsignalid_23).DataValue), 3);
|
item.Turbidity = NumberHelper.RoundString(double.Parse(service_record.GetLastRecord(_corpid, _zdpointId_23, _zdsignalid_23).DataValue), 3);
|
}
|
info_list.Add(item);
|
}
|
|
//var r = new Random();
|
//List<LeftBottomItemInfo> info_list = new List<LeftBottomItemInfo>();
|
|
//var all_station = new Service.StationBase().GetByCorpID(1);
|
|
//foreach (var station in all_station)
|
//{
|
// LeftBottomItemInfo item = new LeftBottomItemInfo();
|
// item.ID = station.ID;
|
// item.Name = station.Name;
|
// item.Flow = r.Next(2600, 2800) / 100.0;
|
// item.Press = r.Next(211, 225) / 1000.0;
|
// item.WaterQuality = r.Next(210, 225) / 100.0;
|
|
// info_list.Add(item);
|
|
//}
|
return info_list;
|
}
|
|
/// <summary>
|
/// 获取首页报警和信息公告(中间底部)
|
/// </summary>
|
/// <param name="InfoType">信息类型(1信息 2报警)</param>
|
[Route("GetCenterBottomInfo")]
|
[HttpGet]
|
public List<SzjtBzglCenterBottomItemInfoDto> GetCenterBottomInfo(int InfoType)
|
{
|
var r = new Random();
|
List<SzjtBzglCenterBottomItemInfoDto> info_list = new List<SzjtBzglCenterBottomItemInfoDto>();
|
|
|
if (InfoType == 1)
|
{
|
var service = new Service.RepairRequestForm();
|
var forms = service.GetLastByCorpID(_corpid, 8);
|
foreach (var f in forms)
|
{
|
var station_list = new Service.Station().GetByCorpID(_corpid);
|
var product_list = new Service.Product().GetByCorpID(_corpid);
|
var user_list = new Service.User().GetByCorpID(_corpid);
|
if (f.BelongType == ObjectType.Station)
|
{
|
var item1 = new SzjtBzglCenterBottomItemInfoDto();
|
item1.ID = f.ID;
|
item1.Title = station_list?.Find(t => t.ID == f.BelongID)?.Name;
|
item1.UserName = user_list?.Find(t => t.ID == f.CreateUserID)?.RealName;
|
item1.Content = string.Format("{0} {1}发生:{2}", f.CreateTime.ToString("MM月dd日,HH时"), product_list?.Find(t => t.ID == f.ProductID)?.Name, f.Question);
|
info_list.Add(item1);
|
}
|
}
|
}
|
else
|
{
|
SzjtBzglCenterBottomItemInfoDto item1 = new SzjtBzglCenterBottomItemInfoDto();
|
item1.Title = "金庭镇第一水厂";
|
item1.UserName = "李三林";
|
item1.Content = "2020年11月20日 12时30分,一号机漏水严重。";
|
info_list.Add(item1);
|
|
SzjtBzglCenterBottomItemInfoDto item2 = new SzjtBzglCenterBottomItemInfoDto();
|
item2.Title = "金庭镇第一水厂";
|
item2.UserName = "李三林";
|
item2.Content = "2020年11月21日 12时30分,一号机漏水严重。";
|
info_list.Add(item2);
|
|
|
SzjtBzglCenterBottomItemInfoDto item3 = new SzjtBzglCenterBottomItemInfoDto();
|
item3.Title = "涵村待诏坞";
|
item3.UserName = "管理员";
|
item3.Content = "2020年10月25日 12时30分,巡检员张坤成在东蔡村附件发现曝管。";
|
info_list.Add(item2);
|
}
|
|
|
return info_list;
|
}
|
|
/// <summary>
|
/// 工单数量 (右部上 )
|
/// </summary>
|
/// <returns></returns>
|
[Route("GetRightTopInfo")]
|
[HttpGet]
|
public SzjtBzglRightTopInfoDto GetRightTopInfo()
|
{
|
var start = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
|
var taskFormList = new Service.RepairTaskForm().GetFluzzyList(_corpid, null, null, null, null, null, null, null, start, null);
|
var taskFormCount = new Service.RepairTaskForm().GetCountByCorpID(_corpid);
|
var requestPendingCount = new Service.RepairRequestForm().GetPendingCountByCorpID(_corpid);
|
|
var vm = new SzjtBzglRightTopInfoDto();
|
vm.UnProcessingForm = requestPendingCount;
|
if (taskFormList == null || taskFormList.Count < 1)
|
{
|
vm.HistoryTotalForm = taskFormCount;
|
}
|
else
|
{
|
vm.TotalForm = taskFormList.Count;
|
vm.HistoryTotalForm = taskFormCount - vm.TotalForm;
|
vm.ProcessedForm = taskFormList.Where(x => x.Item1.FormStatus == Model.Repair.eTaskStatus.Accepted).Count();
|
vm.ProcessingForm = taskFormList.Where(x => x.Item1.FormStatus > Model.Repair.eTaskStatus.Accepted && x.Item1.FormStatus < Model.Repair.eTaskStatus.Succeed).Count();
|
vm.CheckedForm = taskFormList.Where(x => x.Item1.FormStatus >= Model.Repair.eTaskStatus.Succeed).Count();
|
}
|
|
return vm;
|
|
}
|
|
/// <summary>
|
/// 获取表单类型统计占比(右部中)
|
/// </summary>
|
/// <param name="StaticType">统计类型(1按日 2 按周 3 按月 4 按年)</param>
|
[Route("GetRightCenterInfo")]
|
[HttpGet]
|
public List<SzjtBzglRightCenterInfoDto> GetRightCenterInfo(int StaticType)
|
{
|
DateTime today = DateTime.Today;
|
DateTime start = new DateTime(today.Year, today.Month, 1);
|
if (today.Day < 5)
|
{
|
start = new DateTime(today.Year, today.Month, 1).AddMonths(-1);
|
}
|
DateTime end = today.AddDays(1);
|
|
IStation.Service.Product productService = new Service.Product();
|
var allProduct = productService.GetByCorpID(_corpid);
|
|
|
IStation.Service.RepairTaskForm service = new Service.RepairTaskForm();
|
var form_list = service.GetFluzzyList(_corpid,null,null,null,null,null,null,null, start, end);
|
|
int yb = 0;
|
int jb = 0;
|
int f = 0;
|
int other = 0;
|
foreach (var form in form_list)
|
{
|
var product = (from x in allProduct where form.Item1.ProductID == x.ID select x).FirstOrDefault();
|
if (product == null)
|
continue;
|
|
|
if (product.Catalog == IStation.Product.Catalog_JiBeng)
|
{
|
jb++;
|
}
|
else if (product.Catalog == IStation.Product.Catalog_Beng)
|
{
|
jb++;
|
}
|
else if (product.Catalog == IStation.Product.Catalog_DianJi)
|
{
|
jb++;
|
}
|
else if (product.Catalog == IStation.Product.Catalog_Fa)
|
{
|
f++;
|
}
|
else if (product.Catalog == IStation.Product.Catalog_ShuiBiao)
|
{
|
yb++;
|
}
|
else if (product.Catalog == IStation.Product.Catalog_LiuLiangJi)
|
{
|
yb++;
|
}
|
else if (product.Catalog == IStation.Product.Catalog_YaLiJi)
|
{
|
yb++;
|
}
|
else if (product.Catalog == IStation.Product.Catalog_ShuiZhiYi)
|
{
|
yb++;
|
}
|
else
|
{
|
other++;
|
}
|
}
|
|
List<SzjtBzglRightCenterInfoDto> info_list = new List<SzjtBzglRightCenterInfoDto>();
|
|
SzjtBzglRightCenterInfoDto item1 = new SzjtBzglRightCenterInfoDto();
|
item1.Label = "机组故障";
|
item1.Number = jb;
|
info_list.Add(item1);
|
|
|
SzjtBzglRightCenterInfoDto item2 = new SzjtBzglRightCenterInfoDto();
|
item2.Label = "管道维修";
|
item2.Number = 0;
|
info_list.Add(item2);
|
|
|
SzjtBzglRightCenterInfoDto item3 = new SzjtBzglRightCenterInfoDto();
|
item3.Label = "阀门维修";
|
item3.Number = f;
|
info_list.Add(item3);
|
|
SzjtBzglRightCenterInfoDto item4 = new SzjtBzglRightCenterInfoDto();
|
item4.Label = "仪表";
|
item4.Number = yb;
|
info_list.Add(item4);
|
|
SzjtBzglRightCenterInfoDto item5 = new SzjtBzglRightCenterInfoDto();
|
item5.Label = "其他";
|
item5.Number = other;
|
info_list.Add(item5);
|
return info_list;
|
}
|
|
|
}
|
}
|