You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.6 KiB

using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
6 months ago
using HybirdFrameworkCore.AutoTask;
using log4net;
using Repository.Station;
namespace Service.Cloud.Client.MyTask;
6 months ago
[Scope]
public class ChargeOrderUploadTask : ITask
{
private static readonly ILog Log = LogManager.GetLogger(typeof(ChargeOrderUploadTask));
6 months ago
private volatile bool _stop;
6 months ago
public ChargeOrderRepository _chargeOrderRepository { get; set; }
5 months ago
public SwapOrderRepository _swapOrder { get; set; }
6 months ago
public int Interval()
{
return 1000 * 10;
}
6 months ago
public void Handle()
{
6 months ago
try
{
6 months ago
List<ChargeOrder>? chargeOrders =
5 months ago
_chargeOrderRepository.QueryListByClause(it => Convert.ToInt32(it.CloudReportStatus) == 0 && Convert.ToInt32(it.CanUpload) == 1);
6 months ago
Log.Info($"there are {chargeOrders?.Count ?? 0} to upload");
if (chargeOrders is { Count: > 0 })
{
5 months ago
Dictionary<string,List<ChargeOrder>> dictionary = chargeOrders.GroupBy(it => it.CloudChargeOrder).ToDictionary(i => i.Key, i=> i.ToList());
foreach (var (k, v) in dictionary)
6 months ago
{
5 months ago
CloudClientMgr.CloudClient?.PublishChargeOrder(v, 1);
6 months ago
}
}
}
6 months ago
catch (Exception e)
{
Log.Error(e);
}
}
6 months ago
public string Name()
{
return "ChargeOrderUploadTask";
}
6 months ago
public bool Stoped()
{
return _stop;
}
public void Stop()
{
_stop = true;
}
public void ResetStop()
{
_stop = false;
}
}