From 538414c7339b452338d386d286a3ee8c9d347ff6 Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Sun, 5 Feb 2023 15:14:41 +0800 Subject: [PATCH] 1 --- .../EvaluationAssistantBusiness.cs | 50 +++++++++++++++---- BBWY.Server.Business/TaskSchedulerManager.cs | 3 ++ 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs b/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs index fafc5d48..7a6993de 100644 --- a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs +++ b/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs @@ -316,24 +316,36 @@ namespace BBWY.Server.Business if (prpt.Status != Enums.PromitionTaskStatus.等待 && prpt.Status != Enums.PromitionTaskStatus.进行中) throw new BusinessException("前置任务状态必须为等待或进行中"); + var nextPromotionTaskList = fsql.Select().Where(pt1 => pt1.PreTaskId == request.PreTaskId).ToList(); + if (nextPromotionTaskList.Count() > 0) + { + CheckSkuRepeat(pt, nextPromotionTaskList); + } + + fsql.Update(request.TaskId).Set(pt1 => pt1.PreTaskId, request.PreTaskId).ExecuteAffrows(); + } + + private void CheckSkuRepeat(PromotionTask pt, IList waitCheckList) + { var ptSkuList = new List(); - var prptSkuList = new List(); + var waitptSkuList = new List(); if (!string.IsNullOrEmpty(pt.MainProductSku)) ptSkuList.AddRange(pt.MainProductSku.Split(spliter, StringSplitOptions.RemoveEmptyEntries)); if (!string.IsNullOrEmpty(pt.CustomMotherSku)) ptSkuList.AddRange(pt.CustomMotherSku.Split(spliter, StringSplitOptions.RemoveEmptyEntries)); - if (!string.IsNullOrEmpty(prpt.MainProductSku)) - prptSkuList.AddRange(prpt.MainProductSku.Split(spliter, StringSplitOptions.RemoveEmptyEntries)); - if (!string.IsNullOrEmpty(prpt.CustomMotherSku)) - prptSkuList.AddRange(prpt.CustomMotherSku.Split(spliter, StringSplitOptions.RemoveEmptyEntries)); - - var intersectSkuList = ptSkuList.Intersect(prptSkuList).ToList(); - if (intersectSkuList != null && intersectSkuList.Count() > 0) - throw new BusinessException($"{string.Join(",", intersectSkuList)}存在重复"); - - fsql.Update(request.TaskId).Set(pt1 => pt1.PreTaskId, request.PreTaskId).ExecuteAffrows(); + foreach (var waitPt in waitCheckList) + { + if (!string.IsNullOrEmpty(waitPt.MainProductSku)) + waitptSkuList.AddRange(waitPt.MainProductSku.Split(spliter, StringSplitOptions.RemoveEmptyEntries)); + if (!string.IsNullOrEmpty(waitPt.CustomMotherSku)) + waitptSkuList.AddRange(waitPt.CustomMotherSku.Split(spliter, StringSplitOptions.RemoveEmptyEntries)); + + var intersectSkuList = ptSkuList.Intersect(waitptSkuList).ToList(); + if (intersectSkuList != null && intersectSkuList.Count() > 0) + throw new BusinessException($"任务1[{pt.ActivityName}]与任务2[{waitPt.ActivityName}]之间存在sku重复,{string.Join(",", intersectSkuList)}"); + } } /// @@ -842,11 +854,27 @@ namespace BBWY.Server.Business #region 开始后续任务 if (jobDoneTaskIdList.Count() > 0) { + //var nextPromotionTaskList = fsql.Select().Where(pt => pt.ShopId == shopId && + // pt.Status == Enums.PromitionTaskStatus.等待 && + // jobDoneTaskIdList.Contains(pt.PreTaskId.Value)).ToList(); + //if (nextPromotionTaskList.Count() > 0) + //{ + // foreach (var task in nextPromotionTaskList) + // { + + // } + //} } #endregion } + private void AutoStart(long taskId, string appKey, string appSecret, string appToken) + { + + } + + private void LogMonitorError(ShopResponse shop, string loggerName, string step, string error) { nLogManager.GetLogger(loggerName).Error($"{step},{error}"); diff --git a/BBWY.Server.Business/TaskSchedulerManager.cs b/BBWY.Server.Business/TaskSchedulerManager.cs index 2b5c2370..b416c3d1 100644 --- a/BBWY.Server.Business/TaskSchedulerManager.cs +++ b/BBWY.Server.Business/TaskSchedulerManager.cs @@ -26,6 +26,8 @@ namespace BBWY.Server.Business public LimitedConcurrencyLevelTaskScheduler JDPromotionMonitorTaskScheduler { get; private set; } + public LimitedConcurrencyLevelTaskScheduler JDPromotionAutoStartTaskScheduler { get; private set; } + public TaskSchedulerManager() { SyncOrderTaskScheduler = new LimitedConcurrencyLevelTaskScheduler(10); @@ -42,6 +44,7 @@ namespace BBWY.Server.Business JDPromotionDelayTaskScheduler = new LimitedConcurrencyLevelTaskScheduler(10); JDPromotionMonitorTaskScheduler = new LimitedConcurrencyLevelTaskScheduler(10); + JDPromotionAutoStartTaskScheduler = new LimitedConcurrencyLevelTaskScheduler(10); } } }