Commit c518440e by wyc

重复任务关闭,科室分组

parent 9021d490
...@@ -43,7 +43,7 @@ public void Execute() ...@@ -43,7 +43,7 @@ public void Execute()
{ {
using (var scope = _serviceScopeFactory.CreateScope()) using (var scope = _serviceScopeFactory.CreateScope())
{ {
var service = scope.ServiceProvider.GetService<TaskService>(); var service = scope.ServiceProvider.GetService<TaskService>();
var tasks = service.GetTasks(); var tasks = service.GetTasks();
if (tasks == null || tasks.Count == 0) if (tasks == null || tasks.Count == 0)
...@@ -374,26 +374,34 @@ private void Timeout(TaskService service, List<bg_task> tasks) ...@@ -374,26 +374,34 @@ private void Timeout(TaskService service, List<bg_task> tasks)
} }
} }
/// <summary> /// <summary>
/// 重复任务仅执行最后异常 /// 重复任务仅执行最后一次(存在执行只的任务,就将后加的任务停止)
/// </summary> /// </summary>
/// <param name="service"></param> /// <param name="service"></param>
/// <param name="tasks"></param> /// <param name="tasks"></param>
private void Repeat(TaskService service, List<bg_task> tasks) private void Repeat(TaskService service, List<bg_task> tasks)
{ {
var gps = tasks var waitingTasks = tasks.Where(w => w.Status == (int)Background.Status.等待).ToList();
.Where(w => w.Status == (int)Background.Status.等待)
.GroupBy(w => new { w.JobType, w.Argument });
foreach (var item in gps) var groupedTasks = waitingTasks
.GroupBy(w => new { w.JobType, w.Argument })
.ToList();
foreach (var group in groupedTasks)
{ {
foreach (var task in item) var maxId = group.Max(w => w.ID);
var isExist = tasks.Any(w => w.JobType == group.Key.JobType && w.Argument == group.Key.Argument && w.Status == (int)Background.Status.执行中);
foreach (var task in group)
{ {
if (task.Status == (int)Background.Status.等待 && task.ID != item.Max(w => w.ID)) if ((task.Status == (int)Background.Status.等待 && task.ID != maxId) || isExist)
{
service.Update(task.ID, Background.Status.无效, "任务重复"); service.Update(task.ID, Background.Status.无效, "任务重复");
}
} }
} }
} }
private class BackgroundSetting private class BackgroundSetting
{ {
public Background.JobType JobType { get; internal set; } public Background.JobType JobType { get; internal set; }
......
...@@ -3334,7 +3334,7 @@ ...@@ -3334,7 +3334,7 @@
</member> </member>
<member name="M:Performance.Api.BackgroundJob.Repeat(Performance.Services.TaskService,System.Collections.Generic.List{Performance.EntityModels.bg_task})"> <member name="M:Performance.Api.BackgroundJob.Repeat(Performance.Services.TaskService,System.Collections.Generic.List{Performance.EntityModels.bg_task})">
<summary> <summary>
重复任务仅执行最后异常 重复任务仅执行最后一次(存在执行只的任务,就将后加的任务停止)
</summary> </summary>
<param name="service"></param> <param name="service"></param>
<param name="tasks"></param> <param name="tasks"></param>
......
...@@ -530,8 +530,17 @@ public List<cof_accounting> GetAccountingList(AccoungingRequest request) ...@@ -530,8 +530,17 @@ public List<cof_accounting> GetAccountingList(AccoungingRequest request)
} }
if (request.Type == (int)AccountTypeEnum.AccountingUnit && !string.IsNullOrEmpty(request.UnitType)) if (request.Type == (int)AccountTypeEnum.AccountingUnit && !string.IsNullOrEmpty(request.UnitType))
exp = exp.And(t => t.UnitType.Replace("行政后勤", "行政工勤") == request.UnitType.Replace("行政后勤", "行政工勤")); {
string processedRequestUnitType = request.UnitType
.Replace("行政后勤", "行政工勤")
.Replace("行政中层", "行政工勤")
.Replace("行政高层", "行政工勤");
exp = exp.And(t => t.UnitType
.Replace("行政后勤", "行政工勤")
.Replace("行政中层", "行政工勤")
.Replace("行政高层", "行政工勤") == processedRequestUnitType);
}
return _cofaccountingRepository.GetEntities(exp)?.OrderBy(t => t.IsVerify).ThenBy(t => ConvertHelper.To<int>(t.Code)).ToList() ?? new List<cof_accounting>(); return _cofaccountingRepository.GetEntities(exp)?.OrderBy(t => t.IsVerify).ThenBy(t => ConvertHelper.To<int>(t.Code)).ToList() ?? new List<cof_accounting>();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment