feat(all): преметры espp Api принимают дату utc. В подробном описании шаблона возвращается префикс.

This commit is contained in:
Mikhail Trubnikov
2023-10-24 15:40:52 +10:00
parent 59db8fa312
commit fbeabeb165
12 changed files with 98 additions and 68 deletions

View File

@@ -20,18 +20,23 @@ namespace PARR.EsppApi
public async Task<EsppResultBase<IEnumerable<EsppOrder>>> FindOrdersAsync(FindOrdersQuery query)
{
DateTime? generateDateStartWOTimeZone = query.GenerateDateStart.HasValue ? query.GenerateDateStart.Value.AddHours(esppOrderSettings.EsppUserTimeZone) : null;
DateTime? generateDateEndWOTimeZone = query.GenerateDateEnd.HasValue ? query.GenerateDateEnd.Value.AddHours(esppOrderSettings.EsppUserTimeZone) : null;
var conditions = new List<string>();
if (!string.IsNullOrEmpty(query.DescriptionContains))
conditions.Add($"description like \"*{query.DescriptionContains}*\"");
//if (!string.IsNullOrEmpty(query.TemplateNameContains))
// conditions.Add($"templateName like \"*{query.TemplateNameContains}*\"");
if (query.GenerateDateStart.HasValue)
conditions.Add($"open.time>='{query.GenerateDateStart.Value.Day}/{query.GenerateDateStart.Value.Month}/{query.GenerateDateStart.Value.Year}" +
$" {query.GenerateDateStart.Value.Hour}:{query.GenerateDateStart.Value.Minute}:{query.GenerateDateStart.Value.Second}'");
if (query.GenerateDateEnd.HasValue)
conditions.Add($"open.time<='{query.GenerateDateEnd.Value.Day}/{query.GenerateDateEnd.Value.Month}/{query.GenerateDateEnd.Value.Year}" +
$" {query.GenerateDateEnd.Value.Hour}:{query.GenerateDateEnd.Value.Minute}:{query.GenerateDateEnd.Value.Second}'");
if (generateDateStartWOTimeZone.HasValue)
conditions.Add($"open.time>='{generateDateStartWOTimeZone.Value.Day}/{generateDateStartWOTimeZone.Value.Month}/{generateDateStartWOTimeZone.Value.Year}" +
$" {generateDateStartWOTimeZone.Value.Hour}:{generateDateStartWOTimeZone.Value.Minute}:{generateDateStartWOTimeZone.Value.Second}'");
if (generateDateEndWOTimeZone.HasValue)
conditions.Add($"open.time<='{generateDateEndWOTimeZone.Value.Day}/{generateDateEndWOTimeZone.Value.Month}/{generateDateEndWOTimeZone.Value.Year}" +
$" {generateDateEndWOTimeZone.Value.Hour}:{generateDateEndWOTimeZone.Value.Minute}:{generateDateEndWOTimeZone.Value.Second}'");
if (conditions.Count < 1)
{

View File

@@ -5,20 +5,22 @@
/// </summary>
public class FindOrdersQuery
{
//todo: тут поля для запроса списка нарядов из еспп
/// <summary>
/// Подробное описание, содержит значение
/// </summary>
public string? DescriptionContains { get; set; }
private DateTime? _generateDateStart;
/// <summary>
/// Дата сначала которой выбирать созданные наряды
/// Дата сначала которой выбирать созданные наряды, UTC
/// </summary>
public DateTime? GenerateDateStart { get; set; }
/// <summary>
/// Дата конца периода до которого создавались наряды
/// Дата конца периода до которого создавались наряды, UTC
/// </summary>
public DateTime? GenerateDateEnd { get; set; }
}

View File

@@ -1,4 +1,6 @@
namespace PARR.EsppApi.Settings
using System.Security;
namespace PARR.EsppApi.Settings
{
internal class EsppOrderSettings
{
@@ -6,5 +8,9 @@
public string UserName { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
/// <summary>
/// Часовая зона пользователя в ЕСПП относительно UTC
/// </summary>
public int EsppUserTimeZone { get; set; }
}
}