shanji 2 years ago
parent
commit
e85e5079db
  1. 35
      BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs
  2. 3
      BBWY.Server.Business/TaskSchedulerManager.cs

35
BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs

@ -11,6 +11,8 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Yitter.IdGenerator;
namespace BBWY.Server.Business
@ -21,10 +23,16 @@ namespace BBWY.Server.Business
private IIdGenerator idGenerator;
public EvaluationAssistantBusiness(RestApiService restApiService, IOptions<GlobalConfig> options, YunDingBusiness yunDingBusiness, IFreeSql fsql, IIdGenerator idGenerator) : base(restApiService, options, yunDingBusiness)
private TaskSchedulerManager taskSchedulerManager;
private VenderBusiness venderBusiness;
public EvaluationAssistantBusiness(RestApiService restApiService, IOptions<GlobalConfig> options, YunDingBusiness yunDingBusiness, IFreeSql fsql, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager, VenderBusiness venderBusiness) : base(restApiService, options, yunDingBusiness)
{
this.fsql = fsql;
this.idGenerator = idGenerator;
this.taskSchedulerManager = taskSchedulerManager;
this.venderBusiness = venderBusiness;
}
#region 赠品模板
@ -475,5 +483,30 @@ namespace BBWY.Server.Business
fsql.Update<PromotionTask>(request.Id).Set(pt => pt.Status, Enums.PromitionTaskStatus.).ExecuteAffrows();
}
#endregion
public void StartMonitor(long? shopId)
{
var shopList = venderBusiness.GetShopList(shopId, Enums.Platform.);
foreach (var shop in shopList)
{
Task.Factory.StartNew(() => MonitorTaskCore(shop), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.JDPromotionMonitorTaskScheduler);
}
}
#region 自动任务
private void MonitorTaskCore(ShopResponse shop)
{
var shopId = long.Parse(shop.ShopId);
#region 查询正在进行的任务
var runningTaskList = fsql.Select<PromotionTask>().Where(pt => pt.ShopId == shopId && pt.Status == Enums.PromitionTaskStatus.).ToList();
if (runningTaskList == null || runningTaskList.Count() == 0)
return;
#endregion
}
#endregion
}
}

3
BBWY.Server.Business/TaskSchedulerManager.cs

@ -24,6 +24,8 @@ namespace BBWY.Server.Business
public LimitedConcurrencyLevelTaskScheduler JDPromotionDelayTaskScheduler { get; private set; }
public LimitedConcurrencyLevelTaskScheduler JDPromotionMonitorTaskScheduler { get; private set; }
public TaskSchedulerManager()
{
SyncOrderTaskScheduler = new LimitedConcurrencyLevelTaskScheduler(10);
@ -39,6 +41,7 @@ namespace BBWY.Server.Business
GOIWarningTaskScheduler = new LimitedConcurrencyLevelTaskScheduler(10);
JDPromotionDelayTaskScheduler = new LimitedConcurrencyLevelTaskScheduler(10);
JDPromotionMonitorTaskScheduler = new LimitedConcurrencyLevelTaskScheduler(10);
}
}
}

Loading…
Cancel
Save