master
xjl 3 months ago
parent 900d7646a1
commit f8487ef2cd

@ -721,41 +721,41 @@ public class CloudClientMgr
/// </summary> /// </summary>
private static void TaskStaHourAmountVal() private static void TaskStaHourAmountVal()
{ {
if ((DateTime.Now - _dateTime2).TotalSeconds <= 30) //if ((DateTime.Now - _dateTime2).TotalSeconds <= 30)
{ //{
return; // return;
} //}
_dateTime2 = DateTime.Now; //_dateTime2 = DateTime.Now;
var emeterEnergy = emeterDayEnergyService.QueryListByClause(u => u.Type == 1, 7, i => i.Time, //var emeterEnergy = emeterDayEnergyService.QueryListByClause(u => u.Type == 1, 7, i => i.Time,
OrderByType.Desc); // OrderByType.Desc);
float hc = emeterEnergy.Sum(e => e.Value); //float hc = emeterEnergy.Sum(e => e.Value);
ElecPriceModelVersionDetailServices elecPriceModelVersionDetailServices = AppInfo.Container.Resolve<ElecPriceModelVersionDetailServices>(); //ElecPriceModelVersionDetailServices elecPriceModelVersionDetailServices = AppInfo.Container.Resolve<ElecPriceModelVersionDetailServices>();
var elecPriceModelVersionDetail= elecPriceModelVersionDetailServices.QueryListByClause(u=>u.Version==1); //var elecPriceModelVersionDetail= elecPriceModelVersionDetailServices.QueryListByClause(u=>u.Version==1);
var timeList = elecPriceModelVersionDetail.Select(u => u.StartHour).ToList(); //var timeList = elecPriceModelVersionDetail.Select(u => u.StartHour).ToList();
int targetTime = DateTime.Now.Hour; //int targetTime = DateTime.Now.Hour;
int index1 = timeList.FindIndex(time => time > targetTime)-1; //int index1 = timeList.FindIndex(time => time > targetTime)-1;
index1 = index1<0? timeList.Count-1: index1; //index1 = index1<0? timeList.Count-1: index1;
int index2 = timeList.FindIndex(time => time == targetTime); //int index2 = timeList.FindIndex(time => time == targetTime);
int index3 = index2 == -1 ? index1 : index2; //int index3 = index2 == -1 ? index1 : index2;
var price = elecPriceModelVersionDetail[index3].Price; //var price = elecPriceModelVersionDetail[index3].Price;
StaHourAmountVal staHourAmountVal = new() //StaHourAmountVal staHourAmountVal = new()
{ //{
sn = StaticStationInfo.StationNo, // sn = StaticStationInfo.StationNo,
ht = Convert.ToSingle(hc * price), // ht = Convert.ToSingle(hc * price),
hc = Convert.ToSingle(hc * price), // hc = Convert.ToSingle(hc * price),
hs = 0, // hs = 0,
ho = 0, // ho = 0,
//st = DateTime.Now.AddHours(-1), // //st = DateTime.Now.AddHours(-1),
//et = DateTime.Now, // //et = DateTime.Now,
st = Convert.ToDateTime(emeterEnergy?.First().Time), // st = Convert.ToDateTime(emeterEnergy?.First().Time),
et = Convert.ToDateTime(emeterEnergy?.First().Time).AddHours(1), // et = Convert.ToDateTime(emeterEnergy?.First().Time).AddHours(1),
}; //};
CloudApi.SendStaHourAmountVal(staHourAmountVal); //CloudApi.SendStaHourAmountVal(staHourAmountVal);
} }

Loading…
Cancel
Save