feat(esppOrderLoader): доделал логику синхронизации
This commit is contained in:
2648
PARR.DAL/Migrations/20231024002524_TblOrdersAndAgentHistory.Designer.cs
generated
Normal file
2648
PARR.DAL/Migrations/20231024002524_TblOrdersAndAgentHistory.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PARR.DAL.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class TblOrdersAndAgentHistory : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<DateTimeOffset>(
|
||||
name: "DateModified",
|
||||
table: "Orders",
|
||||
type: "timestamp with time zone",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ShortName",
|
||||
table: "Orders",
|
||||
type: "text",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "OrderId",
|
||||
table: "AgentHistories",
|
||||
type: "uuid",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AgentHistories_OrderId",
|
||||
table: "AgentHistories",
|
||||
column: "OrderId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_AgentHistories_Orders_OrderId",
|
||||
table: "AgentHistories",
|
||||
column: "OrderId",
|
||||
principalTable: "Orders",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_AgentHistories_Orders_OrderId",
|
||||
table: "AgentHistories");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_AgentHistories_OrderId",
|
||||
table: "AgentHistories");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DateModified",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ShortName",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "OrderId",
|
||||
table: "AgentHistories");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -384,6 +384,9 @@ namespace PARR.DAL.Migrations
|
||||
b.Property<string>("Message")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid?>("OrderId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("TemplateId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
@@ -391,6 +394,8 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasIndex("HistoryLevelId");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
|
||||
b.HasIndex("TemplateId");
|
||||
|
||||
b.ToTable("AgentHistories");
|
||||
@@ -1556,6 +1561,9 @@ namespace PARR.DAL.Migrations
|
||||
b.Property<DateTimeOffset>("DateCreated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTimeOffset?>("DateModified")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Number")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
@@ -1563,6 +1571,10 @@ namespace PARR.DAL.Migrations
|
||||
b.Property<int>("OrderStatusCode")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("ShortName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid?>("TemplateId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
@@ -2226,6 +2238,10 @@ namespace PARR.DAL.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PARR.DAL.Models.Order", "Order")
|
||||
.WithMany("AgentHistories")
|
||||
.HasForeignKey("OrderId");
|
||||
|
||||
b.HasOne("PARR.DAL.Models.Template", "Template")
|
||||
.WithMany("AgentHistories")
|
||||
.HasForeignKey("TemplateId")
|
||||
@@ -2234,6 +2250,8 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.Navigation("AgentHistoryLevel");
|
||||
|
||||
b.Navigation("Order");
|
||||
|
||||
b.Navigation("Template");
|
||||
});
|
||||
|
||||
@@ -2551,6 +2569,11 @@ namespace PARR.DAL.Migrations
|
||||
b.Navigation("Templates");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Order", b =>
|
||||
{
|
||||
b.Navigation("AgentHistories");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.OrderStatus", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
|
||||
@@ -24,10 +24,14 @@ namespace PARR.DAL.Models
|
||||
|
||||
public Guid TemplateId { get; set; }
|
||||
|
||||
public Guid? OrderId { get; set; }
|
||||
|
||||
[ForeignKey(nameof(TemplateId))]
|
||||
public Template? Template { get; set; }
|
||||
|
||||
[ForeignKey(nameof(HistoryLevelId))]
|
||||
public AgentHistoryLevel? AgentHistoryLevel { get; set; }
|
||||
|
||||
public Order? Order { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,12 @@ namespace PARR.DAL.Models
|
||||
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public DateTimeOffset? DateModified { get; set; }
|
||||
|
||||
public required string Number { get; set; }
|
||||
|
||||
public required string ShortName { get; set; }
|
||||
|
||||
public string? WorkGroup { get; set; }
|
||||
|
||||
public Guid? TemplateId { get; set; }
|
||||
@@ -31,5 +32,7 @@ namespace PARR.DAL.Models
|
||||
|
||||
[ForeignKey(nameof(OrderStatusCode))]
|
||||
public OrderStatus? OrderStatus { get; set; }
|
||||
|
||||
public ICollection<AgentHistory> AgentHistories { get; set; } = new HashSet<AgentHistory>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using PARR.DAL.Context;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.DAL.Context;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
|
||||
@@ -7,15 +9,38 @@ namespace PARR.DAL.Services.Implementations
|
||||
internal class OrderStatusService : IOrderStatusService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<OrderStatusService> logger;
|
||||
|
||||
public OrderStatusService(DataContext dataContext)
|
||||
public OrderStatusService(DataContext dataContext, ILogger<OrderStatusService> logger)
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
public IQueryable<OrderStatus> Get()
|
||||
{
|
||||
return dataContext.OrderStatuses;
|
||||
}
|
||||
|
||||
|
||||
public OrderStatusEnum GetOrderStatusByName(string statusName)
|
||||
{
|
||||
switch (statusName.ToLower().Trim())
|
||||
{
|
||||
case "1-Направлен в группу":
|
||||
return OrderStatusEnum.New;
|
||||
case "2-В работе":
|
||||
return OrderStatusEnum.InWork;
|
||||
case "3-Приостановлен":
|
||||
return OrderStatusEnum.Stop;
|
||||
case "4-Выполнен":
|
||||
return OrderStatusEnum.Complete;
|
||||
case "5-Закрыт":
|
||||
return OrderStatusEnum.Closed;
|
||||
default:
|
||||
logger.LogWarning($"Не смог распознать статус наряда, вернул значение по умполчанию: {OrderStatusEnum.New.ToString()}, входящее значение: {statusName}");
|
||||
return OrderStatusEnum.New;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.Models;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
public interface IOrderStatusService
|
||||
{
|
||||
IQueryable<OrderStatus> Get();
|
||||
OrderStatusEnum GetOrderStatusByName(string statusName);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user