feat(esppScheduleSync, esppTemplateSync): в шаблонах синхронизируется поле Исполнитель. В расписаниях исправлена логика поиска связанного шаблона. Добавлен атрибут SkipComparision - исключить поля для сравнения
This commit is contained in:
126
PARR.EsppScheduleSync/Domain/EsppObjectSchedule.cs
Normal file
126
PARR.EsppScheduleSync/Domain/EsppObjectSchedule.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.EsppSync;
|
||||
using PARR.EsppSync.Attributes;
|
||||
|
||||
namespace PARR.EsppScheduleSync.Domain
|
||||
{
|
||||
internal class EsppObjectSchedule : IEsppObject
|
||||
{
|
||||
//Все поля описаны в документации по роботам: http://gitlab.dvgd.oao.rzd/devptk/parr/parr_api/-/wikis/EsppRobots
|
||||
|
||||
public RobotsEnum Robot => RobotsEnum.ScheduleOrder;
|
||||
|
||||
public required string TemplateName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ИД расписания
|
||||
/// Не сраваниваем ЕСПП ИД, потому что У НАС РЕАЛЬНЫЙ ЕСПП ИД И ЕСПП ИД В БД МОГУ РАСХОДИТЬСЯ!!! УЖАССС!!!
|
||||
/// </summary>
|
||||
[SkipComparison]
|
||||
public string Code { get; set; } = string.Empty;
|
||||
|
||||
[SkipComparison]
|
||||
public string ScheduleName { get; set; } = string.Empty;
|
||||
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
[SkipComparison]
|
||||
public string ResponseArea { get; set; } = string.Empty;
|
||||
|
||||
[SkipComparison]
|
||||
public string WorkGroup { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Тип повторения: Регулярно, Ежегодно...
|
||||
/// </summary>
|
||||
public EsppSchTypeScheduleEnum TypeSchedule { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Интервал времени: Ежедневно, 1 00:00:00
|
||||
/// </summary>
|
||||
public string Interval { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Еженедельно: Каждый понедельник
|
||||
/// </summary>
|
||||
public string Dayofweek { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Ежемесячно: Каждое 23
|
||||
/// </summary>
|
||||
public string Dayofmonth { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Ежемесячно-2: Каждый Первый
|
||||
/// </summary>
|
||||
public string Md1 { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Ежемесячно-2: Каждый Понедельник
|
||||
/// </summary>
|
||||
public string Md2 { get; set; } = string.Empty;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Ежегодно: Каждый Январь
|
||||
/// </summary>
|
||||
public string Annualm { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Ежегодно: Каждый 12
|
||||
/// </summary>
|
||||
public string Annualday { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Ежегодно-2: Каждый Первый
|
||||
/// </summary>
|
||||
public string An1 { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Ежегодно-2: Каждый Понедельник
|
||||
/// </summary>
|
||||
public string An2 { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Ежегодно-2: Каждый Января
|
||||
/// </summary>
|
||||
public string An3 { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Тип исключения: Нет исключений
|
||||
/// </summary>
|
||||
public string TypeV60calendar { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Следующее срабатывание: 16/10/23 17:00:00
|
||||
/// </summary>
|
||||
public required string Scheduled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// В каком часовом поясе: Greenwich/Universal
|
||||
/// </summary>
|
||||
public required string Timezone { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Тип прекращения, Отсутствует дата завершения: Выбран radio button forever
|
||||
/// </summary>
|
||||
public required string TerminationType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Завершение после: 0
|
||||
/// </summary>
|
||||
[SkipComparison]
|
||||
public string CompleteAfter { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Рабочий график
|
||||
/// </summary>
|
||||
public string V60calendar { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Время создания наряда (чч:мм:сс)
|
||||
/// </summary>
|
||||
public string BasisTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using PARR.BLL;
|
||||
using PARR.DAL;
|
||||
using PARR.EsppScheduleSync.Domain;
|
||||
using PARR.EsppScheduleSync.Settings;
|
||||
using PARR.EsppSync;
|
||||
using PARR.EsppSync.Domain;
|
||||
|
||||
namespace PARR.EsppScheduleSync
|
||||
{
|
||||
|
||||
@@ -10,9 +10,9 @@ using PARR.DAL.Models;
|
||||
using PARR.DAL.NextRunServices;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.DAL.Services.Interfaces.Schedule;
|
||||
using PARR.EsppScheduleSync.Domain;
|
||||
using PARR.EsppScheduleSync.Settings;
|
||||
using PARR.EsppSync;
|
||||
using PARR.EsppSync.Domain;
|
||||
using PARR.EsppSync.Helpers;
|
||||
|
||||
namespace PARR.EsppScheduleSync
|
||||
@@ -125,10 +125,24 @@ namespace PARR.EsppScheduleSync
|
||||
using var scope = serviceProvider.CreateScope();
|
||||
var templateService = scope.ServiceProvider.GetRequiredService<ITemplateService>();
|
||||
|
||||
var candidates = await templateService.Get()
|
||||
.Include(t => t.RobotConfigurations)
|
||||
.Where(t => t.Name == esppTemplateName || t.ScheduleEsppId == esppScheduleId)
|
||||
.ToListAsync();
|
||||
// это не очень, так как esppScheduleId может быть null или empty, а в БД таких значений может быть много
|
||||
//var candidates = await templateService.Get()
|
||||
// .Include(t => t.RobotConfigurations)
|
||||
// .Where(t => t.Name == esppTemplateName || t.ScheduleEsppId == esppScheduleId)
|
||||
// .ToListAsync();
|
||||
|
||||
IQueryable<Template> query = templateService.Get().Include(t => t.RobotConfigurations);
|
||||
if (string.IsNullOrEmpty(esppScheduleId))
|
||||
{
|
||||
query = query.Where(t => t.Name == esppTemplateName);
|
||||
}
|
||||
else
|
||||
{
|
||||
//ScheduleEsppId не нулл и не пустой, поизем по нему тоже
|
||||
query = query.Where(t => t.Name == esppTemplateName || t.ScheduleEsppId == esppScheduleId);
|
||||
}
|
||||
|
||||
var candidates = await query.ToListAsync();
|
||||
|
||||
var templateByName = candidates.FirstOrDefault(t => t.Name == esppTemplateName);
|
||||
var templateByScheduleId = candidates.FirstOrDefault(t => t.ScheduleEsppId == esppScheduleId);
|
||||
@@ -592,11 +606,14 @@ namespace PARR.EsppScheduleSync
|
||||
/// <returns></returns>
|
||||
private EsppObjectSchedule ClearOptionalFields(EsppObjectSchedule esppObject)
|
||||
{
|
||||
esppObject.Code = string.Empty;
|
||||
esppObject.ScheduleName = string.Empty;
|
||||
esppObject.ResponseArea = string.Empty;
|
||||
esppObject.WorkGroup = string.Empty;
|
||||
esppObject.CompleteAfter = string.Empty;
|
||||
#region Отключение синхронизации не нужных полей настраивается через атрибут SkipComparison в моделе
|
||||
// Обнуляем ЕСПП ИД, потому что У НАС РЕАЛЬНЫЙ ЕСПП ИД И ЕСПП ИД В БД МОГУ РАСХОДИТЬСЯ!!! УЖАССС!!!
|
||||
//esppObject.Code = string.Empty;
|
||||
//esppObject.ScheduleName = string.Empty;
|
||||
//esppObject.ResponseArea = string.Empty;
|
||||
//esppObject.WorkGroup = string.Empty;
|
||||
//esppObject.CompleteAfter = string.Empty;
|
||||
#endregion
|
||||
|
||||
if (esppObject.TypeV60calendar == noneExcludeCalendarEsppValue)
|
||||
esppObject.V60calendar = string.Empty;
|
||||
|
||||
Reference in New Issue
Block a user