From 49c471369d080bae2a00d43edaa6a8629aebc283 Mon Sep 17 00:00:00 2001
From: xjl <2595686544@qq.com>
Date: Mon, 22 Jul 2024 09:52:25 +0800
Subject: [PATCH] =?UTF-8?q?=E4=B8=8E=E5=B9=B3=E5=8F=B0=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Entity/Ammeter/EmeterEnergy.cs | 2 +-
.../EquipAlarmProcessRecordRepository.cs | 2 +-
Service/Ammeter/EmeterEnergyChangeService.cs | 2 +
Service/Ammeter/EmeterHourEnergyService.cs | 4 +-
Service/Cloud/Client/CloudClient.cs | 43 +-
Service/Cloud/Client/CloudClientMgr.cs | 580 +++++++++++++++++-
.../Cloud/Msg/Host/Req/MeterDayEnergyVal.cs | 26 +-
Service/Cloud/Msg/Host/Req/MeterEnergyKwh.cs | 27 +-
Service/Cloud/Msg/Host/Req/PowerTotal.cs | 15 +-
.../Cloud/Msg/Host/Req/StaChargingTotal.cs | 20 +-
Service/Cloud/Msg/Host/Req/StaDayEnergyVal.cs | 8 +-
.../Cloud/Msg/Host/Req/StationChnRunStatus.cs | 2 +-
Service/Execute/Api/CloudApi.cs | 158 ++++-
Service/MyJob/CountDayOrderJob.cs | 10 +-
14 files changed, 818 insertions(+), 81 deletions(-)
diff --git a/Entity/Ammeter/EmeterEnergy.cs b/Entity/Ammeter/EmeterEnergy.cs
index 7a787e0..4b0d92d 100644
--- a/Entity/Ammeter/EmeterEnergy.cs
+++ b/Entity/Ammeter/EmeterEnergy.cs
@@ -33,7 +33,7 @@ public class EmeterEnergy
/// 上报标识:0未上传 1上传
///
[SugarColumn(ColumnName = "upload_flag")]
- public virtual string UploadFlag { get; set; }
+ public virtual int UploadFlag { get; set; }
///
/// 统计sql小时接收
diff --git a/Repository/Station/EquipAlarmProcessRecordRepository.cs b/Repository/Station/EquipAlarmProcessRecordRepository.cs
index 999c0eb..7e698dd 100644
--- a/Repository/Station/EquipAlarmProcessRecordRepository.cs
+++ b/Repository/Station/EquipAlarmProcessRecordRepository.cs
@@ -4,7 +4,7 @@ using SqlSugar;
namespace Repository.Station;
-[Scope]
+[Scope("SingleInstance")]
public class EquipAlarmProcessRecordRepository : BaseRepository
{
public EquipAlarmProcessRecordRepository(ISqlSugarClient sqlSugar) : base(sqlSugar)
diff --git a/Service/Ammeter/EmeterEnergyChangeService.cs b/Service/Ammeter/EmeterEnergyChangeService.cs
index 707873b..ea433f3 100644
--- a/Service/Ammeter/EmeterEnergyChangeService.cs
+++ b/Service/Ammeter/EmeterEnergyChangeService.cs
@@ -1,5 +1,6 @@
using Entity.Ammeter;
using HybirdFrameworkCore.Autofac.Attribute;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using Repository.Ammeter;
using SqlSugar;
@@ -13,6 +14,7 @@ public class EmeterEnergyChangeService : BaseServices
public EmeterEnergyChangeService(EmeterEnergyChangeRepository emeterEnergyChangeRep)
{
_emeterEnergyChangeRep = emeterEnergyChangeRep;
+ BaseDal = emeterEnergyChangeRep;
}
///
diff --git a/Service/Ammeter/EmeterHourEnergyService.cs b/Service/Ammeter/EmeterHourEnergyService.cs
index 86dd2a3..4c2022c 100644
--- a/Service/Ammeter/EmeterHourEnergyService.cs
+++ b/Service/Ammeter/EmeterHourEnergyService.cs
@@ -14,8 +14,10 @@ namespace Service.Ammeter
[Scope("SingleInstance")]
public class EmeterHourEnergyService: BaseServices
{
+ EmeterHourEnergyRepository _emeterHourEnergyRepository;
public EmeterHourEnergyService(EmeterHourEnergyRepository service)
- {
+ {
+ _emeterHourEnergyRepository = service;
this.BaseDal = service;
}
diff --git a/Service/Cloud/Client/CloudClient.cs b/Service/Cloud/Client/CloudClient.cs
index c24b09a..927cd08 100644
--- a/Service/Cloud/Client/CloudClient.cs
+++ b/Service/Cloud/Client/CloudClient.cs
@@ -512,7 +512,13 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
this.Publish(eqmStateStartLogInfo);
return StartLog.GetResp(timeSpan);
}
- public EvmDataInfoRes? SendTemperatureHumidityData(EvmDataInfo evmDataInfo,
+ ///
+ /// 温湿度
+ ///
+ ///
+ ///
+ ///
+ public EvmDataInfoRes? SendEvmDataInfo(EvmDataInfo evmDataInfo,
TimeSpan timeSpan)
{
this.TemperatureHumidity.Req = evmDataInfo;
@@ -538,7 +544,12 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
this.Publish(cardataReport);
return VehicleData.GetResp(timeSpan);
}
-
+ ///
+ /// 充电订单
+ ///
+ ///
+ ///
+ ///
public ChargeRecordUploadRes? SendChargeRecordUpLoad(ChargeRecordUpLoad req, TimeSpan? timeSpan = null)
{
this.ChargeRecordUpLoad.Req = req;
@@ -566,7 +577,12 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
this.Publish(req);
return ChargingTotalDis.GetResp(timeSpan);
}
-
+ ///
+ /// 电表累计值
+ ///
+ ///
+ ///
+ ///
public PowerTotalRes? SendPowerTotal(PowerTotal req, TimeSpan? timeSpan = null)
{
this.PowerTotal.Req = req;
@@ -574,13 +590,24 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
return PowerTotal.GetResp(timeSpan);
}
+ ///
+ /// 电表变化值
+ ///
+ ///
+ ///
+ ///
public StaChargingTotalRes? SendStaChargingTotal(StaChargingTotal req, TimeSpan? timeSpan = null)
{
this.StaChargingTotal.Req = req;
this.Publish(req);
return StaChargingTotal.GetResp(timeSpan);
}
-
+ ///
+ /// 电表小时值
+ ///
+ ///
+ ///
+ ///
public MeterEnergyKwhRes? SendMeterEnergyKwh(MeterEnergyKwh req, TimeSpan? timeSpan = null)
{
this.MeterEnergyKwh.Req = req;
@@ -588,6 +615,12 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
return MeterEnergyKwh.GetResp(timeSpan);
}
+ ///
+ /// 电表天
+ ///
+ ///
+ ///
+ ///
public MeterDayEnergyValRes? SendMeterDayEnergyVal(MeterDayEnergyVal req, TimeSpan? timeSpan = null)
{
this.MeterDayEnergyVal.Req = req;
@@ -648,7 +681,7 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
#region business func
///
- ///
+ ///充电订单
///
///
/// 1: 自动; 2: 人工手动
diff --git a/Service/Cloud/Client/CloudClientMgr.cs b/Service/Cloud/Client/CloudClientMgr.cs
index 68201e1..217847e 100644
--- a/Service/Cloud/Client/CloudClientMgr.cs
+++ b/Service/Cloud/Client/CloudClientMgr.cs
@@ -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();
+ static EmeterHourEnergyService emeterHourEnergyService = AppInfo.Container.Resolve();
+
+
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;//天
+
+
+
+ private const int TimeSpan = 5;
+
- public static void Init()
+ public static async void Init()
{
CloudClient = AppInfo.Container.Resolve();
@@ -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();
@@ -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;
+ ///
+ /// 上传换电站状态 10s
+ ///
+ private static void TaskHostStatusReported()
+ {
+
+ if (os != StaticStationInfo.StationStatus)
+ {
+ if ((DateTime.Now - _dateTime2).TotalSeconds <= 30)
+ {
+ return;
+ }
+
+ _dateTime2 = DateTime.Now;
+ EquipAlarmRecordRepository equipAlarmRecordRepository = AppInfo.Container.Resolve();
+ 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;
+ }
+
+ ///
+ /// 空调数据上报 10s
+ ///
+ 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);
+
+
+ }
+
+ ///
+ /// 温湿度 10s
+ ///
+ 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);
+
+
+ }
+
+ ///
+ /// 电能表累计值信息 15m
+ ///
+ private static void TaskPowerTotal()//Desc记得改回来
+ {
+ if ((DateTime.Now - _dateTime5).TotalMinutes <= 15)
+ {
+ return;
+ }
+ _dateTime5 = DateTime.Now;
+
+ EmeterEnergyService emeterEnergyService = AppInfo.Container.Resolve();
+ EmeterEnergyChangeService emeterEnergyChangeService = AppInfo.Container.Resolve();
+
+ List 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();
+ 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);
+
+
+ }
+
+ ///
+ /// 电能表变化值信息 15m
+ ///
+ private static void TaskStaChargingTota()
+ {
+ if ((DateTime.Now - _dateTime6).TotalMinutes <= 15)
+ {
+ return;
+ }
+
+ _dateTime6 = DateTime.Now;
+
+ EmeterEnergyService emeterEnergyService = AppInfo.Container.Resolve();
+ EmeterEnergyChangeService emeterEnergyChangeService = AppInfo.Container.Resolve();
+
+ List 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();
+ 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);
+
+ }
+
+ ///
+ /// 电能表小时能耗值信息 1h
+ ///
+ 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();
+ 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);
+ }
+
+ ///
+ /// 电能表天能耗值信息 1d
+ ///
+ private static void TaskMeterDayEnergyVal()
+ {
+ if ((DateTime.Now - _dateTime8).TotalDays < 1)
+ {
+ return;
+ }
+ _dateTime8 = DateTime.Now;
+
+ EmeterDayEnergyService emeterDayEnergyService = AppInfo.Container.Resolve();
+
+ 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();
+ 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);
+ }
+
+ ///
+ /// 换电站分时用电统计信息 1h
+ ///
+ 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);
+
+ }
+
+
+ ///
+ /// 换电站每天用电统计信息 1d
+ ///
+ 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);
+
+ }
+
+
+ ///
+ /// 换电站日运行统计结果 1d
+ ///
+ private static void TaskStaDayOpeEnergyVal()
+ {
+ if ((DateTime.Now - _dateTime11).TotalDays < 1)
+ {
+ return;
+ }
+ _dateTime11 = DateTime.Now;
+
+ ExStationDayRunResultService exStationDayRunResultService = AppInfo.Container.Resolve();
+
+ 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);
+
+ }
+
+ ///
+ /// 换电站分时用电统计信息
+ ///
+ 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();
+
+ 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);
+
}
}
diff --git a/Service/Cloud/Msg/Host/Req/MeterDayEnergyVal.cs b/Service/Cloud/Msg/Host/Req/MeterDayEnergyVal.cs
index c613cad..530188e 100644
--- a/Service/Cloud/Msg/Host/Req/MeterDayEnergyVal.cs
+++ b/Service/Cloud/Msg/Host/Req/MeterDayEnergyVal.cs
@@ -11,30 +11,8 @@ public class MeterDayEnergyVal : ICmd
/// 换电站编码
///
public string sn { get; set; }
- ///
- /// 电表编码
- ///
- public string mn { get; set; }
- ///
- /// 安装位置编号
- ///
- public int addr { get; set; }
- ///
- /// 位置描述
- ///
- public string desc { get; set; }
- ///
- /// 天变化值 单位:kWh,保留两位小 数
- ///
- public float dv { get; set; }
- ///
- /// 开始时间 精确到天。格式” yyyy-MM-dd ”
- ///
- public DateTime st { get; set; }
- ///
- /// 结束时间 精确到天。格式” yyyy-MM-dd ”
- ///
- public DateTime et { get; set; }
+ public List meter { get; set; }
+
public string GetCmd()
{
return CloudConst.meterDayEnergyVal;
diff --git a/Service/Cloud/Msg/Host/Req/MeterEnergyKwh.cs b/Service/Cloud/Msg/Host/Req/MeterEnergyKwh.cs
index 1698500..bbc47bc 100644
--- a/Service/Cloud/Msg/Host/Req/MeterEnergyKwh.cs
+++ b/Service/Cloud/Msg/Host/Req/MeterEnergyKwh.cs
@@ -11,30 +11,9 @@ public class MeterEnergyKwh : ICmd
/// 换电站编码
///
public string sn { get; set; }
- ///
- /// 电表编码
- ///
- public string ms { get; set; }
- ///
- /// 安装位置编号
- ///
- public int addr { get; set; }
- ///
- /// 位置描述
- ///
- public string desc { get; set; }
- ///
- /// 变化值 单位:kWh,保留两 位小数
- ///
- public float mc { get; set; }
- ///
- /// 开始时间 格式” yyyy-MM-dd HH:mm:ss ”
- ///
- public DateTime st { get; set; }
- ///
- /// 结束时间 格式” yyyy-MM-dd HH:mm:ss ”
- ///
- public DateTime et { get; set; }
+
+ public List meter { get; set; }
+
public string GetCmd()
{
return CloudConst.meterEnergyKwh;
diff --git a/Service/Cloud/Msg/Host/Req/PowerTotal.cs b/Service/Cloud/Msg/Host/Req/PowerTotal.cs
index 16620ea..e7f086b 100644
--- a/Service/Cloud/Msg/Host/Req/PowerTotal.cs
+++ b/Service/Cloud/Msg/Host/Req/PowerTotal.cs
@@ -11,6 +11,17 @@ public class PowerTotal : ICmd
/// 换电站编码
///
public string sn { get; set; }
+
+ public List meter { get; set; }
+
+ public string GetCmd()
+ {
+ return CloudConst.powerTotal;
+ }
+}
+
+public class meter
+{
///
/// 安装位置编号
///
@@ -27,8 +38,4 @@ public class PowerTotal : ICmd
/// 累积值 单位:kWh,保留两位 小数
///
public float mk { get; set; }
- public string GetCmd()
- {
- return CloudConst.powerTotal;
- }
}
\ No newline at end of file
diff --git a/Service/Cloud/Msg/Host/Req/StaChargingTotal.cs b/Service/Cloud/Msg/Host/Req/StaChargingTotal.cs
index b8cc7f8..4a54d38 100644
--- a/Service/Cloud/Msg/Host/Req/StaChargingTotal.cs
+++ b/Service/Cloud/Msg/Host/Req/StaChargingTotal.cs
@@ -11,6 +11,20 @@ public class StaChargingTotal : ICmd
/// 换电站编码
///
public string sn { get; set; }
+
+ public List meter { get; set; }
+
+ public string GetCmd()
+ {
+ return CloudConst.staChargingTotal;
+ }
+}
+
+///
+/// 电表信息
+///
+public class meter2
+{
///
/// 电表编码
///
@@ -26,7 +40,7 @@ public class StaChargingTotal : ICmd
///
/// 变化值 单位:kWh,保留两 位小数
///
- public float mc { get; set; }
+ public float mk { get; set; }
///
/// 开始时间 格式” yyyy-MM-dd HH:mm:ss ”
///
@@ -35,8 +49,4 @@ public class StaChargingTotal : ICmd
/// 结束时间 格式” yyyy-MM-dd HH:mm:ss ”
///
public DateTime et { get; set; }
- public string GetCmd()
- {
- return CloudConst.staChargingTotal;
- }
}
\ No newline at end of file
diff --git a/Service/Cloud/Msg/Host/Req/StaDayEnergyVal.cs b/Service/Cloud/Msg/Host/Req/StaDayEnergyVal.cs
index 907856f..7aec3b8 100644
--- a/Service/Cloud/Msg/Host/Req/StaDayEnergyVal.cs
+++ b/Service/Cloud/Msg/Host/Req/StaDayEnergyVal.cs
@@ -14,19 +14,19 @@ public class StaDayEnergyVal : ICmd
///
/// 天计算总量能耗值 单位:kWh,保留两位小 数
///
- public float dt { get; set; }
+ public float ht { get; set; }//原dt改ht,和小时字段一致,云平台说的,下面几个字段一样
///
/// 天计算充电能耗值 单位:kWh,保留两位小 数
///
- public float dc { get; set; }
+ public float hc { get; set; }
///
/// 天计算换电能耗值 单位:kWh,保留两位小 数
///
- public float ds { get; set; }
+ public float hs { get; set; }
///
/// 天计算其它能耗值 单位:kWh,保留两位小 数
///
- public float dv { get; set; }
+ public float ho { get; set; }
///
/// 开始时间 精确到天。格式”yyyy-MM-dd”(如2020-11-20 )
///
diff --git a/Service/Cloud/Msg/Host/Req/StationChnRunStatus.cs b/Service/Cloud/Msg/Host/Req/StationChnRunStatus.cs
index ae224db..6c472d5 100644
--- a/Service/Cloud/Msg/Host/Req/StationChnRunStatus.cs
+++ b/Service/Cloud/Msg/Host/Req/StationChnRunStatus.cs
@@ -52,7 +52,7 @@ namespace Service.Cloud.Msg.Host.Req
/// 更新时间
/// 格式”yyyy-MM-dd HH:mm:ss”
///
- public int ut { get; set; }
+ public DateTime ut { get; set; }
public string GetCmd()
{
diff --git a/Service/Execute/Api/CloudApi.cs b/Service/Execute/Api/CloudApi.cs
index 1952b2b..5774f8b 100644
--- a/Service/Execute/Api/CloudApi.cs
+++ b/Service/Execute/Api/CloudApi.cs
@@ -107,19 +107,60 @@ public abstract class CloudApi
return sendUploadPowerChangeOrder.re;
}
+
+ public static InfoEnum.BusinessSwappingForCloudState BusinessSwappingForCloudState =
+ InfoEnum.BusinessSwappingForCloudState.Idle;
///
/// 上报换电步序到云端
///
- ///
///
- public static void SendStateLog(SwapOrder swapOrder, InfoEnum.BusinessSwappingForCloudState state)
+ /// 是否空闲
+ public static void SendStateLog( int state)
{
- StationChnRunStatus stationChnRunStatus = new()
+ if (BusinessSwappingForCloudState!= StationSoftMgr.SwappingStateMachine.BusinessSwappingForCloudState)
{
- };
+ StationChnRunStatus stationChnRunStatus = null;
- CloudClientMgr.CloudClient?.SendChannelStatusReporting(stationChnRunStatus,
- global::System.TimeSpan.FromSeconds(TimeSpan));
+ if (state == 1)
+ {
+ stationChnRunStatus = new()
+ {
+ ec = 0,
+ ws = StationSoftMgr.SwappingStateMachine.SwapStatus == 0 ? 2 : 3,
+ cs = (int)StationSoftMgr.SwappingStateMachine.BusinessSwappingForCloudState,
+ iv = StationSoftMgr.SwappingStateMachine.RadarInFlag == true ? 1 : 2,
+ ls = StationSoftMgr.SwappingStateMachine.VelUnlockFlag == true ? 2 : 1,
+ fl = 0,
+ ut = DateTime.Now,
+
+ };
+ }
+ else
+ {
+
+ stationChnRunStatus = new()
+ {
+ ec = 0,
+ ws = 1,
+ cs = 1,
+ iv = 2,
+ ls = 0,
+ fl = 0,
+ ut = DateTime.Now,
+
+ };
+ }
+
+ CloudClientMgr.CloudClient?.SendChannelStatusReporting(stationChnRunStatus,
+ global::System.TimeSpan.FromSeconds(TimeSpan));
+
+ for (int i = 0; i < 3; i++)
+ {
+
+ }
+
+ }
+ BusinessSwappingForCloudState = StationSoftMgr.SwappingStateMachine.BusinessSwappingForCloudState;
return;
}
@@ -184,4 +225,109 @@ public abstract class CloudApi
CloudClientMgr.CloudClient?.SendPileRealtime(req,
global::System.TimeSpan.FromSeconds(TimeSpan));
}
+
+ ///
+ /// 换电站状态上报
+ ///
+ ///
+ public static void SendHostStatusReported(StationRunStatus req)
+ {
+ CloudClientMgr.CloudClient?.SendHostStatusReported(req,
+ global::System.TimeSpan.FromSeconds(TimeSpan));
+ }
+
+ ///
+ /// 空调信息
+ ///
+ ///
+ public static void SendAirConditioningData(AcDataInfo req)
+ {
+
+ CloudClientMgr.CloudClient?.SendAirConditioningData(req,
+ global::System.TimeSpan.FromSeconds(TimeSpan));
+ }
+ ///
+ /// 换电站温湿度数据信息
+ ///
+ ///
+ public static void SendEvmDataInfo(EvmDataInfo req)
+ {
+
+ CloudClientMgr.CloudClient?.SendEvmDataInfo(req,
+ global::System.TimeSpan.FromSeconds(TimeSpan));
+ }
+ ///
+ /// 电能表累计值信息
+ ///
+ ///
+ public static void SendPowerTotal(PowerTotal req)
+ {
+
+ CloudClientMgr.CloudClient?.SendPowerTotal(req,
+ global::System.TimeSpan.FromSeconds(TimeSpan));
+ }
+ ///
+ /// 换电站电能表变化值信息
+ ///
+ ///
+ public static void SendStaChargingTotal(StaChargingTotal req)
+ {
+
+ CloudClientMgr.CloudClient?.SendStaChargingTotal(req,
+ global::System.TimeSpan.FromSeconds(TimeSpan));
+ }
+ ///
+ /// 换电站分时用电统计信息
+ ///
+ ///
+ public static void SendStaHourEnergyVal(StaHourEnergyVal req)
+ {
+ CloudClientMgr.CloudClient?.SendStaHourEnergyVal(req,
+ global::System.TimeSpan.FromSeconds(TimeSpan));
+ }
+ ///
+ /// 电能表小时能耗值信息
+ ///
+ ///
+ public static void SendMeterEnergyKwh(MeterEnergyKwh req)
+ {
+ CloudClientMgr.CloudClient?.SendMeterEnergyKwh(req,
+ global::System.TimeSpan.FromSeconds(TimeSpan));
+ }
+ ///
+ /// 电能表每天能耗值信息
+ ///
+ ///
+ public static void SendMeterDayEnergyVal(MeterDayEnergyVal req)
+ {
+ CloudClientMgr.CloudClient?.SendMeterDayEnergyVal(req,
+ global::System.TimeSpan.FromSeconds(TimeSpan));
+ }
+ ///
+ /// 换电站每天用电统计信息
+ ///
+ ///
+ public static void SendStaDayEnergyVal(StaDayEnergyVal req)
+ {
+ CloudClientMgr.CloudClient?.SendStaDayEnergyVal(req,
+ global::System.TimeSpan.FromSeconds(TimeSpan));
+ }
+ ///
+ /// 换电站日运行统计结果信息
+ ///
+ ///
+ public static void SendStaDayOpeEnergyVal(StaDayOpeEnergyVal req)
+ {
+ CloudClientMgr.CloudClient?.SendStaDayOpeEnergyVal(req,
+ global::System.TimeSpan.FromSeconds(TimeSpan));
+ }
+ ///
+ /// 换电站分时用电计费信息
+ ///
+ ///
+ public static void SendStaHourAmountVal(StaHourAmountVal req)
+ {
+ CloudClientMgr.CloudClient?.SendStaHourAmountVal(req,
+ global::System.TimeSpan.FromSeconds(TimeSpan));
+ }
}
\ No newline at end of file
diff --git a/Service/MyJob/CountDayOrderJob.cs b/Service/MyJob/CountDayOrderJob.cs
index 2905a29..af00082 100644
--- a/Service/MyJob/CountDayOrderJob.cs
+++ b/Service/MyJob/CountDayOrderJob.cs
@@ -78,9 +78,13 @@ public class CountDayOrderJob : AbstractCronJob
dayCount.AvgChgTime = avgMinutes.ToString("F2");
dayCount.AvgRepTime = avgRepTime.ToString("F2");
dayCount.SwapDate = DateTime.Now.AddDays(-1).ToString();
-
-
- dayCount.FristSwapTime = firstSwapOrder?.SwapBeginTime?.ToString() ?? null;
+
+ dayCount.RunStartTime = DateTime.Now.AddDays(-1).ToString();
+ dayCount.RunEndTime = DateTime.Now.ToString();
+
+ dayCount.ToltalTimeCount = 24 * 60;
+
+ dayCount.FristSwapTime = firstSwapOrder?.SwapBeginTime?.ToString() ?? null;
dayCount.StopTime = lastSwapOrder?.SwapEndTime?.ToString() ?? null;
dayCount.ChgCount = chgCount;
dayCount.ToltalSwapCount = totalSwapCount;