feat(api): метод сброса ошибок синхронизации шаблонов
This commit is contained in:
@@ -30,18 +30,21 @@ namespace PARR.API.Controllers.V1
|
||||
private readonly ITemplateService templateService;
|
||||
private readonly IRobotConfigurationService robotConfigurationService;
|
||||
private readonly IClientService clientService;
|
||||
private readonly ILogger<TemplateController> logger;
|
||||
|
||||
public TemplateController(
|
||||
IMapper mapper,
|
||||
ITemplateService templateService,
|
||||
IRobotConfigurationService robotConfigurationService,
|
||||
IClientService clientService
|
||||
IClientService clientService,
|
||||
ILogger<TemplateController> logger
|
||||
)
|
||||
{
|
||||
this.mapper = mapper;
|
||||
this.templateService = templateService;
|
||||
this.robotConfigurationService = robotConfigurationService;
|
||||
this.clientService = clientService;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
|
||||
@@ -175,87 +178,5 @@ namespace PARR.API.Controllers.V1
|
||||
return Ok(new Response<TemplateResponse>(response, true));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получить один шаблон по заданному статусу
|
||||
/// </summary>
|
||||
/// <param name="statusCode"></param>
|
||||
/// <returns></returns>
|
||||
//[HttpGet(ApiRoutes.Template.GetByStatusCode)]
|
||||
//public async Task<IActionResult> GetByStatus([FromRoute] int statusCode, [FromQuery] RobinQuery query)
|
||||
//{
|
||||
// Template? template = null;
|
||||
|
||||
// //1.Ищем `RobotStatusCode` = 22 и `RobotLastStatusUpdated` истекло и `RobotAttemptsNumber` >= допустимого значения из настроек,
|
||||
// //ставим всем этим записям `RobotStatusCode`= 33
|
||||
// //2.Поиск шаблонов со `StatusCode` 10 или 20 и `RobotStatusCode` = 11.Находим, **выбрали эту запись, конец**.
|
||||
// //3.Поиск шаблонов со `StatusCode` 10 или 20 и `RobotStatusCode` = 22.
|
||||
// //Далее проверяется `RobotLastStatusUpdated`, что время последнего смены статуса не превышает допустимого(берется из настроек, поле `RobotWaitTime`)
|
||||
// //и что текущая попытка не больше разрешенной(берется из настроек, поле `RobotAttemptsNumber`) - если это так, берется эта запись.
|
||||
|
||||
// //1.
|
||||
// await templateService.CheckAndSetErrorRobotStatusAsync(settingsFromDb.RobotAttemptsNumber, settingsFromDb.RobotWaitTime);
|
||||
|
||||
|
||||
// //2.
|
||||
// template = await templateService.GetWithIncludes()
|
||||
// .AsSplitQuery()
|
||||
// .FirstOrDefaultAsync(t => t.StatusCode == statusCode && t.RobotStatusCode == (int)RobotStatusEnum.Wait);
|
||||
|
||||
// //3.
|
||||
// if (template == null)
|
||||
// {
|
||||
// var endDate = DateTimeOffset.UtcNow.Add(-settingsFromDb.RobotWaitTime);
|
||||
// template = await templateService.GetWithIncludes()
|
||||
// .AsSplitQuery()
|
||||
// .FirstOrDefaultAsync(t =>
|
||||
// t.StatusCode == statusCode
|
||||
// && t.RobotStatusCode == (int)RobotStatusEnum.InProgress
|
||||
// && t.RobotAttemptsNumber < settingsFromDb.RobotAttemptsNumber
|
||||
// && t.RobotLastStatusUpdated < endDate
|
||||
// );
|
||||
// }
|
||||
|
||||
|
||||
// if (template == null)
|
||||
// return NotFound();
|
||||
|
||||
// var response = mapper.Map<TemplateResponse>(template);
|
||||
|
||||
// if (query.Robin == true)
|
||||
// {
|
||||
// var stringResponse = mapper.Map<TemplateStringResponse>(response);
|
||||
// return Ok(stringResponse);
|
||||
// }
|
||||
|
||||
// return Ok(new Response<TemplateResponse>(response, true));
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Установить статус ОК для шаблона с id
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
//[HttpPut(ApiRoutes.Template.SetOkStatus)]
|
||||
//public async Task<IActionResult> SetOkStatus([FromRoute] Guid id)
|
||||
//{
|
||||
// var template = await templateService.GetWithIncludes()
|
||||
// .AsSplitQuery()
|
||||
// .FirstOrDefaultAsync(t => t.Id == id);
|
||||
|
||||
// if (template == null)
|
||||
// return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = $"Не найден шаблон с id: {id}" } }));
|
||||
|
||||
// template.StatusCode = (int)TaskStatusEnum.Ok;
|
||||
|
||||
// if (!await templateService.CommitAsync())
|
||||
// return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = $"Ошибка при изменении статуса у шаблона с id: {id}" } }));
|
||||
|
||||
// var response = mapper.Map<TemplateResponse>(template);
|
||||
|
||||
// return Ok(new Response<TemplateResponse>(response, true));
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user