|
|
|
@ -1,14 +1,27 @@
|
|
|
|
|
using Autofac;
|
|
|
|
|
using Entity.Ammeter;
|
|
|
|
|
using Entity.Constant;
|
|
|
|
|
using Entity.DbModel.Station;
|
|
|
|
|
using HybirdFrameworkCore.Autofac;
|
|
|
|
|
using HybirdFrameworkCore.Autofac.Attribute;
|
|
|
|
|
using HybirdFrameworkCore.Redis;
|
|
|
|
|
using log4net;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
|
|
|
|
|
using Repository.Station;
|
|
|
|
|
using Service.Ammeter;
|
|
|
|
|
using Service.Cloud.Msg;
|
|
|
|
|
using Service.Cloud.Msg.Cloud.Resp;
|
|
|
|
|
using Service.Cloud.Msg.Host.Req;
|
|
|
|
|
using Service.Execute.Api;
|
|
|
|
|
using Service.FireControl.Client;
|
|
|
|
|
using Service.Init;
|
|
|
|
|
using Service.Station;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Service.Cloud.Client;
|
|
|
|
|
|
|
|
|
@ -18,9 +31,28 @@ public class CloudClientMgr
|
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(CloudClientMgr));
|
|
|
|
|
public static CloudClient? CloudClient { get; set; }
|
|
|
|
|
|
|
|
|
|
static EmeterDayEnergyService emeterDayEnergyService = AppInfo.Container.Resolve<EmeterDayEnergyService>();
|
|
|
|
|
static EmeterHourEnergyService emeterHourEnergyService = AppInfo.Container.Resolve<EmeterHourEnergyService>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static DateTime _dateTime = DateTime.Now.AddSeconds(-30);
|
|
|
|
|
private static DateTime _dateTime2 = DateTime.Now.AddSeconds(-10);
|
|
|
|
|
private static DateTime _dateTime3 = DateTime.Now.AddSeconds(-10);
|
|
|
|
|
private static DateTime _dateTime4 = DateTime.Now.AddSeconds(-10);
|
|
|
|
|
private static DateTime _dateTime5 = DateTime.Now.AddMinutes(-15);//15分钟
|
|
|
|
|
private static DateTime _dateTime6 = DateTime.Now.AddMinutes(-15);//15分钟
|
|
|
|
|
private static DateTime _dateTime7 = DateTime.Today.AddHours(DateTime.Now.Hour-1);//小时
|
|
|
|
|
private static DateTime _dateTime8 = DateTime.Now.AddDays(-1).Date;//天
|
|
|
|
|
private static DateTime _dateTime9 = DateTime.Today.AddHours(DateTime.Now.Hour - 1);//小时
|
|
|
|
|
private static DateTime _dateTime10 = DateTime.Now.AddDays(-1).Date;//天
|
|
|
|
|
private static DateTime _dateTime11 = DateTime.Now.AddDays(-1).Date;//天
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void Init()
|
|
|
|
|
private const int TimeSpan = 5;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static async void Init()
|
|
|
|
|
{
|
|
|
|
|
CloudClient = AppInfo.Container.Resolve<CloudClient>();
|
|
|
|
|
|
|
|
|
@ -37,7 +69,7 @@ public class CloudClientMgr
|
|
|
|
|
CloudClient.AutoReConnect = true;
|
|
|
|
|
|
|
|
|
|
CloudClient.InitHandler();
|
|
|
|
|
|
|
|
|
|
var ddddd = CloudClient.Connected;
|
|
|
|
|
Task.Run(() => CloudClient.Connect());
|
|
|
|
|
|
|
|
|
|
RedisHelper? redisHelper = AppInfo.Container.Resolve<RedisHelper>();
|
|
|
|
@ -121,5 +153,549 @@ public class CloudClientMgr
|
|
|
|
|
Log.Info("error", e);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StartAsyncLoop();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static async Task StartAsyncLoop()
|
|
|
|
|
{
|
|
|
|
|
await Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
while (CloudClient!=null)
|
|
|
|
|
{
|
|
|
|
|
if (CloudClient.Connected)
|
|
|
|
|
{
|
|
|
|
|
//Log.Info("测试111111111111111111111111111111111111111111111111111111111111111111111111111111");
|
|
|
|
|
CloudApi.SendStateLog(0);
|
|
|
|
|
|
|
|
|
|
TaskHostStatusReported();
|
|
|
|
|
|
|
|
|
|
TaskAirConditioningData();
|
|
|
|
|
|
|
|
|
|
TaskTemperatureHumidityData();
|
|
|
|
|
|
|
|
|
|
TaskPowerTotal();
|
|
|
|
|
|
|
|
|
|
TaskStaChargingTota();
|
|
|
|
|
|
|
|
|
|
TaskMeterEnergyKwh();
|
|
|
|
|
|
|
|
|
|
TaskMeterDayEnergyVal();
|
|
|
|
|
|
|
|
|
|
TaskStaHourEnergyVal();
|
|
|
|
|
|
|
|
|
|
TaskStaDayEnergyVal();
|
|
|
|
|
|
|
|
|
|
TaskStaDayOpeEnergyVal();
|
|
|
|
|
|
|
|
|
|
TaskStaHourAmountVal();
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(ex);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int os = 0;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 上传换电站状态 10s
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static void TaskHostStatusReported()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (os != StaticStationInfo.StationStatus)
|
|
|
|
|
{
|
|
|
|
|
if ((DateTime.Now - _dateTime2).TotalSeconds <= 30)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dateTime2 = DateTime.Now;
|
|
|
|
|
EquipAlarmRecordRepository equipAlarmRecordRepository = AppInfo.Container.Resolve<EquipAlarmRecordRepository>();
|
|
|
|
|
var EquipAlarm = equipAlarmRecordRepository.Query();
|
|
|
|
|
var ErrorLevel = Convert.ToInt32(EquipAlarm.Min(x => x.ErrorLevel));
|
|
|
|
|
StationRunStatus stationRunStatus = new()
|
|
|
|
|
{
|
|
|
|
|
rs = StaticStationInfo.StationStatus == 1 ? 1 : 2,
|
|
|
|
|
os = StaticStationInfo.StationStatus,
|
|
|
|
|
fl = ErrorLevel,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CloudApi.SendHostStatusReported(stationRunStatus);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
os = StaticStationInfo.StationStatus;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 空调数据上报 10s
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static void TaskAirConditioningData()
|
|
|
|
|
{
|
|
|
|
|
if ((DateTime.Now - _dateTime3).TotalSeconds <= 60)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dateTime3 = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
AcDataInfo airConditioningData = new()
|
|
|
|
|
{
|
|
|
|
|
sn = StaticStationInfo.StationNo,
|
|
|
|
|
ad = "",
|
|
|
|
|
an = "",
|
|
|
|
|
au = 0,
|
|
|
|
|
am = 3,
|
|
|
|
|
ap = 0,
|
|
|
|
|
bt = DateTime.Now,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
CloudApi.SendAirConditioningData(airConditioningData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 温湿度 10s
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static void TaskTemperatureHumidityData()
|
|
|
|
|
{
|
|
|
|
|
if ((DateTime.Now - _dateTime4).TotalSeconds <= 10)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dateTime4 = DateTime.Now;
|
|
|
|
|
EvmDataInfo evmDataInfo = new()
|
|
|
|
|
{
|
|
|
|
|
sn = StaticStationInfo.StationNo,
|
|
|
|
|
ea = "电池仓",
|
|
|
|
|
et = FireControlMgr.Temperature,
|
|
|
|
|
eh = FireControlMgr.Humidity,
|
|
|
|
|
bt = DateTime.Now,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CloudApi.SendEvmDataInfo(evmDataInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 电能表累计值信息 15m
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static void TaskPowerTotal()//Desc记得改回来
|
|
|
|
|
{
|
|
|
|
|
if ((DateTime.Now - _dateTime5).TotalMinutes <= 15)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_dateTime5 = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
EmeterEnergyService emeterEnergyService = AppInfo.Container.Resolve<EmeterEnergyService>();
|
|
|
|
|
EmeterEnergyChangeService emeterEnergyChangeService = AppInfo.Container.Resolve<EmeterEnergyChangeService>();
|
|
|
|
|
|
|
|
|
|
List<EmeterEnergy> emeterEnergy = emeterEnergyService.QueryListByClause(u=>u.UploadFlag==0, 7,i => i.UploadTime,
|
|
|
|
|
OrderByType.Asc);
|
|
|
|
|
emeterEnergy = emeterEnergy.OrderBy(p => p.Code).ToList();
|
|
|
|
|
|
|
|
|
|
var emeterEnergyChange = emeterEnergyChangeService.QueryListByClause(u => u.UploadFlag == 0, 7, i => i.UploadTime,
|
|
|
|
|
OrderByType.Asc);
|
|
|
|
|
emeterEnergyChange = emeterEnergyChange.OrderBy(p => p.Code).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PowerTotal powerTotal = new()
|
|
|
|
|
{
|
|
|
|
|
sn = StaticStationInfo.StationNo,
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
powerTotal.meter = new List<meter>();
|
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
|
{
|
|
|
|
|
meter meter = new()
|
|
|
|
|
{
|
|
|
|
|
addr = i + 1,
|
|
|
|
|
desc = (i + 2).ToString() + "号仓直流表",
|
|
|
|
|
ms = emeterEnergy[i].Code,
|
|
|
|
|
mk = emeterEnergy[i].Value,
|
|
|
|
|
};
|
|
|
|
|
powerTotal.meter.Add(meter);
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0;i < 7; i++)
|
|
|
|
|
{
|
|
|
|
|
meter meter = new()
|
|
|
|
|
{
|
|
|
|
|
addr = i + 1,
|
|
|
|
|
desc = (i + 2).ToString() + "号仓交流表",
|
|
|
|
|
ms = emeterEnergyChange[i].Code,
|
|
|
|
|
mk = emeterEnergyChange[i].Value,
|
|
|
|
|
};
|
|
|
|
|
powerTotal.meter.Add(meter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CloudApi.SendPowerTotal(powerTotal);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 电能表变化值信息 15m
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static void TaskStaChargingTota()
|
|
|
|
|
{
|
|
|
|
|
if ((DateTime.Now - _dateTime6).TotalMinutes <= 15)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dateTime6 = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
EmeterEnergyService emeterEnergyService = AppInfo.Container.Resolve<EmeterEnergyService>();
|
|
|
|
|
EmeterEnergyChangeService emeterEnergyChangeService = AppInfo.Container.Resolve<EmeterEnergyChangeService>();
|
|
|
|
|
|
|
|
|
|
List<EmeterEnergy> emeterEnergy = emeterEnergyService.QueryListByClause(u => u.UploadFlag == 0, 7, i => i.UploadTime,
|
|
|
|
|
OrderByType.Asc);
|
|
|
|
|
emeterEnergy = emeterEnergy.OrderBy(p => p.Code).ToList();
|
|
|
|
|
|
|
|
|
|
var emeterEnergyChange = emeterEnergyChangeService.QueryListByClause(u => u.UploadFlag == 0, 7, i => i.UploadTime,
|
|
|
|
|
OrderByType.Asc);
|
|
|
|
|
emeterEnergyChange = emeterEnergyChange.OrderBy(p => p.Code).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StaChargingTotal staChargingTotal = new()
|
|
|
|
|
{
|
|
|
|
|
sn = StaticStationInfo.StationNo,
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
staChargingTotal.meter = new List<meter2>();
|
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
|
{
|
|
|
|
|
meter2 meter = new()
|
|
|
|
|
{
|
|
|
|
|
addr = i + 1,
|
|
|
|
|
desc = (i + 2).ToString() + "号仓直流表",
|
|
|
|
|
ms = emeterEnergy[i].Code,
|
|
|
|
|
mk = emeterEnergy[i].Value,
|
|
|
|
|
st = DateTime.Now.AddMinutes(-15),
|
|
|
|
|
et = DateTime.Now,
|
|
|
|
|
};
|
|
|
|
|
staChargingTotal.meter.Add(meter);
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
|
{
|
|
|
|
|
meter2 meter = new()
|
|
|
|
|
{
|
|
|
|
|
addr = i + 1,
|
|
|
|
|
desc = (i + 2).ToString() + "号仓交流表",
|
|
|
|
|
ms = emeterEnergyChange[i].Code,
|
|
|
|
|
mk = emeterEnergyChange[i].Value,
|
|
|
|
|
st = DateTime.Now.AddMinutes(-15),
|
|
|
|
|
et = DateTime.Now,
|
|
|
|
|
};
|
|
|
|
|
staChargingTotal.meter.Add(meter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CloudApi.SendStaChargingTotal(staChargingTotal);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 电能表小时能耗值信息 1h
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static void TaskMeterEnergyKwh()
|
|
|
|
|
{
|
|
|
|
|
if ((DateTime.Now - _dateTime7).TotalHours <= 1)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dateTime7 = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
var emeterEnergy = emeterHourEnergyService.QueryListByClause(u => u.UploadFlag == 0, 14, i => i.Time,
|
|
|
|
|
OrderByType.Asc);
|
|
|
|
|
emeterEnergy = emeterEnergy.OrderBy(p => p.Code).ToList();
|
|
|
|
|
|
|
|
|
|
var emeterEnergy1= emeterEnergy.Where(p => p.Type==1).ToList();
|
|
|
|
|
var emeterEnergy2= emeterEnergy.Where(p => p.Type==2).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MeterEnergyKwh meterEnergyKwh = new()
|
|
|
|
|
{
|
|
|
|
|
sn = StaticStationInfo.StationNo,
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
meterEnergyKwh.meter = new List<meter2>();
|
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
|
{
|
|
|
|
|
meter2 meter = new()
|
|
|
|
|
{
|
|
|
|
|
addr = i + 1,
|
|
|
|
|
desc = (i + 2).ToString() + "号仓直流表",
|
|
|
|
|
ms = emeterEnergy1[i].Code,
|
|
|
|
|
mk = emeterEnergy1[i].Value,
|
|
|
|
|
//st = DateTime.Now.AddMinutes(-60),
|
|
|
|
|
//et = DateTime.Now,
|
|
|
|
|
st = Convert.ToDateTime(emeterEnergy1[i].Time),
|
|
|
|
|
et = Convert.ToDateTime(emeterEnergy1[i].Time).AddHours(1),
|
|
|
|
|
};
|
|
|
|
|
meterEnergyKwh.meter.Add(meter);
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
|
{
|
|
|
|
|
meter2 meter = new()
|
|
|
|
|
{
|
|
|
|
|
addr = i + 1,
|
|
|
|
|
desc = (i + 2).ToString() + "号仓交流表",
|
|
|
|
|
ms = emeterEnergy2[i].Code,
|
|
|
|
|
mk = emeterEnergy2[i].Value,
|
|
|
|
|
//st = DateTime.Now.AddMinutes(-15),
|
|
|
|
|
//et = DateTime.Now,
|
|
|
|
|
st = Convert.ToDateTime(emeterEnergy1[i].Time),
|
|
|
|
|
et = Convert.ToDateTime(emeterEnergy1[i].Time).AddHours(1),
|
|
|
|
|
};
|
|
|
|
|
meterEnergyKwh.meter.Add(meter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CloudApi.SendMeterEnergyKwh(meterEnergyKwh);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < emeterEnergy.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
emeterEnergy[i].UploadFlag = 1;
|
|
|
|
|
}
|
|
|
|
|
emeterHourEnergyService.Update(emeterEnergy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 电能表天能耗值信息 1d
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static void TaskMeterDayEnergyVal()
|
|
|
|
|
{
|
|
|
|
|
if ((DateTime.Now - _dateTime8).TotalDays < 1)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_dateTime8 = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
EmeterDayEnergyService emeterDayEnergyService = AppInfo.Container.Resolve<EmeterDayEnergyService>();
|
|
|
|
|
|
|
|
|
|
var emeterEnergy = emeterDayEnergyService.QueryListByClause(u => u.UploadFlag == 0, 14, i => i.Time,
|
|
|
|
|
OrderByType.Asc);
|
|
|
|
|
emeterEnergy = emeterEnergy.OrderBy(p => p.Code).ToList();
|
|
|
|
|
|
|
|
|
|
var emeterEnergy1 = emeterEnergy.Where(p => p.Type == 1).ToList();
|
|
|
|
|
var emeterEnergy2 = emeterEnergy.Where(p => p.Type == 2).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MeterDayEnergyVal meterEnergyKwh = new()
|
|
|
|
|
{
|
|
|
|
|
sn = StaticStationInfo.StationNo,
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
meterEnergyKwh.meter = new List<meter2>();
|
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
|
{
|
|
|
|
|
meter2 meter = new()
|
|
|
|
|
{
|
|
|
|
|
addr = i + 1,
|
|
|
|
|
desc = (i + 2).ToString() + "号仓直流表",
|
|
|
|
|
ms = emeterEnergy1[i].Code,
|
|
|
|
|
mk = emeterEnergy1[i].Value,
|
|
|
|
|
//st = DateTime.Now.AddDays(-1),
|
|
|
|
|
//et = DateTime.Now,
|
|
|
|
|
st = Convert.ToDateTime(emeterEnergy1[i].Time).AddDays(-1),
|
|
|
|
|
et = Convert.ToDateTime(emeterEnergy1[i].Time),
|
|
|
|
|
};
|
|
|
|
|
meterEnergyKwh.meter.Add(meter);
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
|
{
|
|
|
|
|
meter2 meter = new()
|
|
|
|
|
{
|
|
|
|
|
addr = i + 1,
|
|
|
|
|
desc = (i + 2).ToString() + "号仓交流表",
|
|
|
|
|
ms = emeterEnergy2[i].Code,
|
|
|
|
|
mk = emeterEnergy2[i].Value,
|
|
|
|
|
//st = DateTime.Now.AddDays(-1),
|
|
|
|
|
//et = DateTime.Now,
|
|
|
|
|
st = Convert.ToDateTime(emeterEnergy1[i].Time).AddDays(-1),
|
|
|
|
|
et = Convert.ToDateTime(emeterEnergy1[i].Time),
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
meterEnergyKwh.meter.Add(meter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CloudApi.SendMeterDayEnergyVal(meterEnergyKwh);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < emeterEnergy.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
emeterEnergy[i].UploadFlag = 1;
|
|
|
|
|
}
|
|
|
|
|
emeterDayEnergyService.Update(emeterEnergy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 换电站分时用电统计信息 1h
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static void TaskStaHourEnergyVal()
|
|
|
|
|
{
|
|
|
|
|
if ((DateTime.Now - _dateTime9).TotalHours <= 1)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_dateTime9 = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
var emeterEnergy = emeterHourEnergyService.QueryListByClause(u => u.Type == 1, 7, i => i.Time,
|
|
|
|
|
OrderByType.Asc);
|
|
|
|
|
float hc = emeterEnergy.Sum(e => e.Value);
|
|
|
|
|
StaHourEnergyVal meterEnergyKwh = new()
|
|
|
|
|
{
|
|
|
|
|
sn = StaticStationInfo.StationNo,
|
|
|
|
|
ht= hc,
|
|
|
|
|
hc = hc,
|
|
|
|
|
hs =0,
|
|
|
|
|
ho=0,
|
|
|
|
|
//st = DateTime.Now.AddHours(-1),
|
|
|
|
|
//et = DateTime.Now,
|
|
|
|
|
st = Convert.ToDateTime(emeterEnergy?.First().Time),
|
|
|
|
|
et = Convert.ToDateTime(emeterEnergy?.First().Time).AddHours(1),
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
CloudApi.SendStaHourEnergyVal(meterEnergyKwh);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 换电站每天用电统计信息 1d
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static void TaskStaDayEnergyVal()
|
|
|
|
|
{
|
|
|
|
|
if ((DateTime.Now - _dateTime10).TotalDays < 1)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_dateTime10 = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
var emeterEnergy = emeterDayEnergyService.QueryListByClause(u => u.Type == 1, 7, i => i.Time,
|
|
|
|
|
OrderByType.Asc);
|
|
|
|
|
|
|
|
|
|
float dc = emeterEnergy.Sum(e => e.Value);
|
|
|
|
|
|
|
|
|
|
StaDayEnergyVal staDayEnergyVal = new()
|
|
|
|
|
{
|
|
|
|
|
sn = StaticStationInfo.StationNo,
|
|
|
|
|
ht = dc,
|
|
|
|
|
hc = dc,
|
|
|
|
|
hs = 0,
|
|
|
|
|
ho = 0,
|
|
|
|
|
//st = DateTime.Now.AddDays(-1),
|
|
|
|
|
//et = DateTime.Now,
|
|
|
|
|
st = Convert.ToDateTime(emeterEnergy?.First().Time).AddDays(-1),
|
|
|
|
|
et = Convert.ToDateTime(emeterEnergy?.First().Time),
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
CloudApi.SendStaDayEnergyVal(staDayEnergyVal);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 换电站日运行统计结果 1d
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static void TaskStaDayOpeEnergyVal()
|
|
|
|
|
{
|
|
|
|
|
if ((DateTime.Now - _dateTime11).TotalDays < 1)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_dateTime11 = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
ExStationDayRunResultService exStationDayRunResultService = AppInfo.Container.Resolve<ExStationDayRunResultService>();
|
|
|
|
|
|
|
|
|
|
var exStationDayRunResult = exStationDayRunResultService.QueryByClause(u => u.Id !=0, i => i.CreatedTime,
|
|
|
|
|
OrderByType.Asc);
|
|
|
|
|
|
|
|
|
|
StaDayOpeEnergyVal staDayOpeEnergyVal = new()
|
|
|
|
|
{
|
|
|
|
|
sn = StaticStationInfo.StationNo,
|
|
|
|
|
sm = StaticStationInfo.StationName,
|
|
|
|
|
st = Convert.ToDateTime(exStationDayRunResult?.RunStartTime),
|
|
|
|
|
et = Convert.ToDateTime(exStationDayRunResult?.RunEndTime),
|
|
|
|
|
tt = Convert.ToInt32(exStationDayRunResult?.ToltalTimeCount),
|
|
|
|
|
//tt = 24 * 60,
|
|
|
|
|
ft = Convert.ToDateTime(exStationDayRunResult?.FristSwapTime),
|
|
|
|
|
sp = Convert.ToDateTime(exStationDayRunResult?.StopTime),
|
|
|
|
|
ts = Convert.ToSingle(exStationDayRunResult?.ToltalSwapAllTime * 60),
|
|
|
|
|
tc = exStationDayRunResult.ToltalSwapCount,
|
|
|
|
|
cc = exStationDayRunResult.ChgCount,
|
|
|
|
|
os = Convert.ToByte(exStationDayRunResult.State),
|
|
|
|
|
at = Convert.ToSingle(exStationDayRunResult?.AvgRepTime),
|
|
|
|
|
ct = Convert.ToSingle(exStationDayRunResult?.AvgChgTime),
|
|
|
|
|
dt = Convert.ToDateTime(exStationDayRunResult?.SwapDate),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
CloudApi.SendStaDayOpeEnergyVal(staDayOpeEnergyVal);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 换电站分时用电统计信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static void TaskStaHourAmountVal()
|
|
|
|
|
{
|
|
|
|
|
if ((DateTime.Now - _dateTime2).TotalSeconds <= 30)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_dateTime2 = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
var emeterEnergy = emeterDayEnergyService.QueryListByClause(u => u.Type == 1, 7, i => i.Time,
|
|
|
|
|
OrderByType.Asc);
|
|
|
|
|
float hc = emeterEnergy.Sum(e => e.Value);
|
|
|
|
|
|
|
|
|
|
ElecPriceModelVersionDetailServices elecPriceModelVersionDetailServices = AppInfo.Container.Resolve<ElecPriceModelVersionDetailServices>();
|
|
|
|
|
|
|
|
|
|
var elecPriceModelVersionDetail= elecPriceModelVersionDetailServices.QueryListByClause(u=>u.Version==1);
|
|
|
|
|
var timeList = elecPriceModelVersionDetail.Select(u => u.StartHour).ToList();
|
|
|
|
|
int targetTime = DateTime.Now.Hour;
|
|
|
|
|
int index1 = timeList.FindIndex(time => time > targetTime)-1;
|
|
|
|
|
index1 = index1<0? timeList.Count-1: index1;
|
|
|
|
|
int index2 = timeList.FindIndex(time => time == targetTime);
|
|
|
|
|
int index3 = index2 == -1 ? index1 : index2;
|
|
|
|
|
|
|
|
|
|
var price = elecPriceModelVersionDetail[index3].Price;
|
|
|
|
|
StaHourAmountVal staHourAmountVal = new()
|
|
|
|
|
{
|
|
|
|
|
sn = StaticStationInfo.StationNo,
|
|
|
|
|
ht = Convert.ToSingle(hc * price),
|
|
|
|
|
hc = Convert.ToSingle(hc * price),
|
|
|
|
|
hs = 0,
|
|
|
|
|
ho = 0,
|
|
|
|
|
//st = DateTime.Now.AddHours(-1),
|
|
|
|
|
//et = DateTime.Now,
|
|
|
|
|
st = Convert.ToDateTime(emeterEnergy?.First().Time),
|
|
|
|
|
et = Convert.ToDateTime(emeterEnergy?.First().Time).AddHours(1),
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
CloudApi.SendStaHourAmountVal(staHourAmountVal);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|