feat(dal, aihitSyncer, aihitLoader): добавлена ЗО для РГ. Обновлён список ЗО. Обновлена синхронизация из АИХИТ.
This commit is contained in:
@@ -87,7 +87,7 @@ namespace PARR.AIHITLoader
|
||||
{
|
||||
//var vrt = aihitData.Where(ek => ek.EKFindCode!.StartsWith("ВРТ", true, CultureInfo.GetCultureInfo("ru-RU"))).ToList();
|
||||
|
||||
var vrt = aihitData.Where(ek =>
|
||||
var vrt = aihitData.Where(ek =>
|
||||
ek.EKFindCode!.StartsWith("ВРТ", true, CultureInfo.GetCultureInfo("ru-RU"))
|
||||
|| ek.EKFindCode!.StartsWith("ХСТ", true, CultureInfo.GetCultureInfo("ru-RU"))
|
||||
).ToList();
|
||||
@@ -123,8 +123,11 @@ namespace PARR.AIHITLoader
|
||||
SM = ek.MonitoringServerType,
|
||||
OS = ek.OSType,
|
||||
WorkGroup = ek.WorkGroup,
|
||||
Status = (ek.Status == "00-ГВЦ") ? "99-ГВЦ" : ek.Status!,
|
||||
ResponseArea = ek.ResponseArea!
|
||||
//Status = (ek.Status == "00-ГВЦ") ? "99-ГВЦ" : ek.Status!,
|
||||
//ResponseArea = ek.ResponseArea!
|
||||
Status = ek.Status!,
|
||||
ResponseArea = (ek.ResponseArea == "00-ГВЦ") ? "99-ГВЦ" : ek.ResponseArea!,
|
||||
WorkGroupResponseArea = (ek.WorkGroupResponseArea == "00-ГВЦ") ? "99-ГВЦ" : ek.WorkGroupResponseArea!
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,5 +96,7 @@ namespace PARR.AIHITLoader.Models
|
||||
public string? MonitoringServerType { get; set; }
|
||||
[Column("ОС")]
|
||||
public string? OSType { get; set; }
|
||||
[Column("ЗО_РГ")]
|
||||
public string? WorkGroupResponseArea { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +84,9 @@ namespace PARR.AIHITSyncer.Services
|
||||
{
|
||||
var id = Guid.NewGuid();
|
||||
|
||||
int responseAreaCode = GetResponseAreaCodeFromStr(objFromQuery.ResponseArea) ?? 0;
|
||||
if (responseAreaCode == 0)
|
||||
return null;
|
||||
|
||||
var host = new Host
|
||||
{
|
||||
@@ -92,8 +95,9 @@ namespace PARR.AIHITSyncer.Services
|
||||
IP = objFromQuery.IP,
|
||||
EkStatusCode = ResolveCode(objFromQuery.Status),
|
||||
//WorkGroup = objFromQuery.WorkGroup,
|
||||
WorkGroup = await CreateWorkGroupIfNotExistAsync(objFromQuery.WorkGroup),
|
||||
ResponseAreaCode = ((ResolveCode(objFromQuery.ResponseArea) == 0) ? 99 : ResolveCode(objFromQuery.ResponseArea))
|
||||
WorkGroup = await CreateWorkGroupIfNotExistAsync(objFromQuery.WorkGroup, objFromQuery.WorkGroupResponseArea),
|
||||
// ResponseAreaCode = ((ResolveCode(objFromQuery.ResponseArea) == 0) ? 99 : ResolveCode(objFromQuery.ResponseArea))
|
||||
ResponseAreaCode = responseAreaCode
|
||||
};
|
||||
|
||||
if (!await hostService.CreateAsync(host) || !await hostService.CommitAsync())
|
||||
@@ -106,18 +110,41 @@ namespace PARR.AIHITSyncer.Services
|
||||
return await hostService.GetHostWithAppsByEkAsync(host.Ek);
|
||||
}
|
||||
|
||||
private async Task<WorkGroup?> CreateWorkGroupIfNotExistAsync(string? workGroupName)
|
||||
private async Task<WorkGroup?> CreateWorkGroupIfNotExistAsync(string? workGroupName, string wgResponseArea)
|
||||
{
|
||||
if (string.IsNullOrEmpty(workGroupName) || string.IsNullOrWhiteSpace(workGroupName)) return null;
|
||||
if (string.IsNullOrEmpty(workGroupName) || string.IsNullOrWhiteSpace(workGroupName))
|
||||
return null;
|
||||
|
||||
if (string.IsNullOrEmpty(wgResponseArea) || string.IsNullOrWhiteSpace(wgResponseArea))
|
||||
return null;
|
||||
|
||||
int wgCode = GetResponseAreaCodeFromStr(wgResponseArea) ?? 0;
|
||||
if (wgCode == 0)
|
||||
return null;
|
||||
|
||||
var existWorkGroup = await workGroupService.GetByNameAsync(workGroupName);
|
||||
if (existWorkGroup != null)
|
||||
{
|
||||
//проверяем, соответствует ли рабочая группа
|
||||
if (existWorkGroup.ResponseAreaCode != wgCode)
|
||||
{
|
||||
logger.LogDebug($"У рабочей группы {existWorkGroup.Name} не совпадают ЗО, обновляем, текущее значение: {existWorkGroup.ResponseAreaCode}, новое: {wgCode}");
|
||||
existWorkGroup.ResponseAreaCode = wgCode;
|
||||
if (!await workGroupService.CommitAsync())
|
||||
{
|
||||
logger.LogError($"Ошибка при обновлении ЗО рабочей группы {existWorkGroup.Name}");
|
||||
}
|
||||
}
|
||||
|
||||
return existWorkGroup;
|
||||
}
|
||||
|
||||
|
||||
var workGroup = new WorkGroup
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Name = workGroupName.Trim(),
|
||||
ResponseAreaCode = wgCode
|
||||
};
|
||||
|
||||
if (!await workGroupService.CreateAsync(workGroup) || !await workGroupService.CommitAsync())
|
||||
@@ -151,14 +178,21 @@ namespace PARR.AIHITSyncer.Services
|
||||
|
||||
if (objFromQuery.WorkGroup != null && (host.WorkGroup == null || !host.WorkGroup!.Name.Equals(objFromQuery.WorkGroup)))
|
||||
{
|
||||
host.WorkGroup = await CreateWorkGroupIfNotExistAsync(objFromQuery.WorkGroup);
|
||||
host.WorkGroup = await CreateWorkGroupIfNotExistAsync(objFromQuery.WorkGroup, objFromQuery.WorkGroupResponseArea);
|
||||
isChanged = true;
|
||||
}
|
||||
|
||||
int responseAreaCode = GetResponseAreaCodeFromStr(objFromQuery.ResponseArea) ?? 0;
|
||||
if (responseAreaCode == 0) {
|
||||
logger.LogWarning($"Ошибка при получении ЗО хоста: {objFromQuery.EK}, ЗО: {objFromQuery.ResponseArea}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (host.ResponseAreaCode != ((ResolveCode(objFromQuery.ResponseArea) == 0) ? 99 : ResolveCode(objFromQuery.ResponseArea)))
|
||||
//if (host.ResponseAreaCode != ((ResolveCode(objFromQuery.ResponseArea) == 0) ? 99 : ResolveCode(objFromQuery.ResponseArea)))
|
||||
if (host.ResponseAreaCode != responseAreaCode)
|
||||
{//TODO Возможно проще выгружать с помощью INCLUDE зону ответственности и сравнивать string
|
||||
host.ResponseAreaCode = ((ResolveCode(objFromQuery.ResponseArea) == 0) ? 99 : ResolveCode(objFromQuery.ResponseArea));
|
||||
//host.ResponseAreaCode = ((ResolveCode(objFromQuery.ResponseArea) == 0) ? 99 : ResolveCode(objFromQuery.ResponseArea));
|
||||
host.ResponseAreaCode = responseAreaCode;
|
||||
isChanged = true;
|
||||
}
|
||||
if (isChanged)
|
||||
@@ -389,6 +423,23 @@ namespace PARR.AIHITSyncer.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private int? GetResponseAreaCodeFromStr(string responseAreaStr)
|
||||
{
|
||||
if (string.IsNullOrEmpty(responseAreaStr) || string.IsNullOrWhiteSpace(responseAreaStr))
|
||||
return null;
|
||||
|
||||
if (responseAreaStr.ToUpper().Trim() == "ОБЩЕЕ")
|
||||
return (int)ResponseAreaEnum.general;
|
||||
|
||||
if (responseAreaStr.ToUpper().Trim() == "00-ГВЦ")
|
||||
return (int)ResponseAreaEnum.gvc;
|
||||
|
||||
return ResolveCode(responseAreaStr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private async Task GetAppTypesAsync()
|
||||
{
|
||||
if (AppTypes == null || AppTypes.Count == 0)
|
||||
|
||||
@@ -17,5 +17,6 @@
|
||||
public string? WorkGroup { get; set; }
|
||||
public required string Status { get; set; }
|
||||
public required string ResponseArea { get; set; }
|
||||
public required string WorkGroupResponseArea { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,10 @@ namespace PARR.DAL.Context
|
||||
new { Code = (int)ResponseAreaEnum.msk, Name = "17-МСК" },
|
||||
new { Code = (int)ResponseAreaEnum.klgd, Name = "10-КЛГ" },
|
||||
new { Code = (int)ResponseAreaEnum.orw, Name = "01-ОКТ" },
|
||||
new { Code = (int)ResponseAreaEnum.gvc, Name = "00-ГВЦ" }
|
||||
new { Code = (int)ResponseAreaEnum.gvc, Name = "00-ГВЦ" },
|
||||
new { Code = (int)ResponseAreaEnum.general, Name = "ОБЩЕЕ" },
|
||||
new { Code = (int)ResponseAreaEnum.vp, Name = "ВП" },
|
||||
new { Code = (int)ResponseAreaEnum.osk, Name = "ОСК" }
|
||||
);
|
||||
});
|
||||
#endregion
|
||||
|
||||
@@ -90,5 +90,20 @@
|
||||
/// ГВЦ
|
||||
/// </summary>
|
||||
gvc = 99,
|
||||
|
||||
/// <summary>
|
||||
/// ОБЩЕЕ
|
||||
/// </summary>
|
||||
general = 100,
|
||||
|
||||
/// <summary>
|
||||
/// ВП
|
||||
/// </summary>
|
||||
vp = 110,
|
||||
|
||||
/// <summary>
|
||||
/// ОСК
|
||||
/// </summary>
|
||||
osk = 111,
|
||||
}
|
||||
}
|
||||
|
||||
2752
PARR.DAL/Migrations/20240618012342_tblWorkGroupsAddRelToResponseArea.Designer.cs
generated
Normal file
2752
PARR.DAL/Migrations/20240618012342_tblWorkGroupsAddRelToResponseArea.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,58 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PARR.DAL.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class tblWorkGroupsAddRelToResponseArea : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ResponseAreaCode",
|
||||
table: "WorkGroups",
|
||||
type: "integer",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "ResponseAreas",
|
||||
columns: new[] { "Code", "Name" },
|
||||
values: new object[] { 100, "ОБЩЕЕ" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_WorkGroups_ResponseAreaCode",
|
||||
table: "WorkGroups",
|
||||
column: "ResponseAreaCode");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_WorkGroups_ResponseAreas_ResponseAreaCode",
|
||||
table: "WorkGroups",
|
||||
column: "ResponseAreaCode",
|
||||
principalTable: "ResponseAreas",
|
||||
principalColumn: "Code");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_WorkGroups_ResponseAreas_ResponseAreaCode",
|
||||
table: "WorkGroups");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_WorkGroups_ResponseAreaCode",
|
||||
table: "WorkGroups");
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "ResponseAreas",
|
||||
keyColumn: "Code",
|
||||
keyValue: 100);
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ResponseAreaCode",
|
||||
table: "WorkGroups");
|
||||
}
|
||||
}
|
||||
}
|
||||
2762
PARR.DAL/Migrations/20240618042349_tblResponseAreaAddVP_OSK.Designer.cs
generated
Normal file
2762
PARR.DAL/Migrations/20240618042349_tblResponseAreaAddVP_OSK.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,39 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
|
||||
|
||||
namespace PARR.DAL.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class tblResponseAreaAddVP_OSK : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.InsertData(
|
||||
table: "ResponseAreas",
|
||||
columns: new[] { "Code", "Name" },
|
||||
values: new object[,]
|
||||
{
|
||||
{ 110, "ВП" },
|
||||
{ 111, "ОСК" }
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DeleteData(
|
||||
table: "ResponseAreas",
|
||||
keyColumn: "Code",
|
||||
keyValue: 110);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "ResponseAreas",
|
||||
keyColumn: "Code",
|
||||
keyValue: 111);
|
||||
}
|
||||
}
|
||||
}
|
||||
2764
PARR.DAL/Migrations/20240618042610_tblWorkGroupRespAreaCodeRequired.Designer.cs
generated
Normal file
2764
PARR.DAL/Migrations/20240618042610_tblWorkGroupRespAreaCodeRequired.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,59 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PARR.DAL.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class tblWorkGroupRespAreaCodeRequired : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_WorkGroups_ResponseAreas_ResponseAreaCode",
|
||||
table: "WorkGroups");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "ResponseAreaCode",
|
||||
table: "WorkGroups",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
defaultValue: 0,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "integer",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_WorkGroups_ResponseAreas_ResponseAreaCode",
|
||||
table: "WorkGroups",
|
||||
column: "ResponseAreaCode",
|
||||
principalTable: "ResponseAreas",
|
||||
principalColumn: "Code",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_WorkGroups_ResponseAreas_ResponseAreaCode",
|
||||
table: "WorkGroups");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "ResponseAreaCode",
|
||||
table: "WorkGroups",
|
||||
type: "integer",
|
||||
nullable: true,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "integer");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_WorkGroups_ResponseAreas_ResponseAreaCode",
|
||||
table: "WorkGroups",
|
||||
column: "ResponseAreaCode",
|
||||
principalTable: "ResponseAreas",
|
||||
principalColumn: "Code");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1666,6 +1666,21 @@ namespace PARR.DAL.Migrations
|
||||
{
|
||||
Code = 99,
|
||||
Name = "00-ГВЦ"
|
||||
},
|
||||
new
|
||||
{
|
||||
Code = 100,
|
||||
Name = "ОБЩЕЕ"
|
||||
},
|
||||
new
|
||||
{
|
||||
Code = 110,
|
||||
Name = "ВП"
|
||||
},
|
||||
new
|
||||
{
|
||||
Code = 111,
|
||||
Name = "ОСК"
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2237,8 +2252,13 @@ namespace PARR.DAL.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("ResponseAreaCode")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ResponseAreaCode");
|
||||
|
||||
b.ToTable("WorkGroups");
|
||||
});
|
||||
|
||||
@@ -2573,6 +2593,17 @@ namespace PARR.DAL.Migrations
|
||||
b.Navigation("Tnk");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.WorkGroup", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.ResponseArea", "ResponseArea")
|
||||
.WithMany("WorkGroups")
|
||||
.HasForeignKey("ResponseAreaCode")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ResponseArea");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.AgentHistoryLevel", b =>
|
||||
{
|
||||
b.Navigation("AgentHistories");
|
||||
@@ -2653,6 +2684,8 @@ namespace PARR.DAL.Migrations
|
||||
modelBuilder.Entity("PARR.DAL.Models.ResponseArea", b =>
|
||||
{
|
||||
b.Navigation("Hosts");
|
||||
|
||||
b.Navigation("WorkGroups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Robot", b =>
|
||||
|
||||
@@ -13,5 +13,7 @@ namespace PARR.DAL.Models
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public ICollection<Host> Hosts { get; set; } = new HashSet<Host>();
|
||||
|
||||
public ICollection<WorkGroup> WorkGroups { get; set; } = new HashSet<WorkGroup>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,16 @@ namespace PARR.DAL.Models
|
||||
|
||||
[NotMapped]
|
||||
public DateTimeOffset? DateModified { get; set; }
|
||||
|
||||
public required string Name { get; set; }
|
||||
|
||||
public int ResponseAreaCode { get; set; }
|
||||
|
||||
public ICollection<Host> Hosts { get; set; } = new HashSet<Host>();
|
||||
|
||||
public ICollection<AppInWorkInWorkGroup> AppInWorks { get; set; } = new HashSet<AppInWorkInWorkGroup>();
|
||||
|
||||
[ForeignKey(nameof(ResponseAreaCode))]
|
||||
public ResponseArea? ResponseArea { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user