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