forked from ddrilling/AsbCloudServer
Merge branch 'dev' into feature/well_report
This commit is contained in:
commit
44068b771a
@ -58,7 +58,12 @@ public class TelemetryInfoDto
|
|||||||
public string? SpinPlcVersion { get; set; }
|
public string? SpinPlcVersion { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// комментарий
|
/// версия ПО ПЛК Памп мастер
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? Comment { get; set; }
|
public string? PumpPlcVersion { get; set; }
|
||||||
}
|
|
||||||
|
/// <summary>
|
||||||
|
/// комментарий
|
||||||
|
/// </summary>
|
||||||
|
public string? Comment { get; set; }
|
||||||
|
}
|
54
AsbCloudApp/Data/SAUB/VersionDto.cs
Normal file
54
AsbCloudApp/Data/SAUB/VersionDto.cs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace AsbCloudApp.Data.SAUB;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Версия ПО
|
||||||
|
/// </summary>
|
||||||
|
public class VersionDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Идентификатор скважины
|
||||||
|
/// </summary>
|
||||||
|
public int IdWell { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// название скважины
|
||||||
|
/// </summary>
|
||||||
|
public string Well { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// название куста
|
||||||
|
/// </summary>
|
||||||
|
public string Cluster { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// название месторождения
|
||||||
|
/// </summary>
|
||||||
|
public string Deposit { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// название заказчика
|
||||||
|
/// </summary>
|
||||||
|
public string? Customer { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// версия ПО панели оператора
|
||||||
|
/// </summary>
|
||||||
|
public string? HmiVersion { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// версия ПО ПЛК САУБ
|
||||||
|
/// </summary>
|
||||||
|
public string? SaubPlcVersion { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// версия ПО ПЛК Спин мастер
|
||||||
|
/// </summary>
|
||||||
|
public string? SpinPlcVersion { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// версия ПО ПЛК Памп мастер
|
||||||
|
/// </summary>
|
||||||
|
public string? PumpPlcVersion { get; set; }
|
||||||
|
}
|
61
AsbCloudApp/Requests/VersionRequest.cs
Normal file
61
AsbCloudApp/Requests/VersionRequest.cs
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace AsbCloudApp.Requests;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Запрос получения версий ПО
|
||||||
|
/// </summary>
|
||||||
|
public class VersionRequestBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор по умолчанию
|
||||||
|
/// </summary>
|
||||||
|
public VersionRequestBase()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Копирующий конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
public VersionRequestBase(VersionRequestBase request)
|
||||||
|
{
|
||||||
|
IdWellState = request.IdWellState;
|
||||||
|
IdsWell = request.IdsWell;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Необязательный параметр. Определяет состояние скважины
|
||||||
|
/// null - возвращаются все записи
|
||||||
|
/// 0 - неизвестно,
|
||||||
|
/// 1 - в работе,
|
||||||
|
/// 2 - завершена
|
||||||
|
/// </summary>
|
||||||
|
public int? IdWellState { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Идентификаторы скважин
|
||||||
|
/// </summary>
|
||||||
|
public IEnumerable<int>? IdsWell { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Запрос получения версий ПО
|
||||||
|
/// </summary>
|
||||||
|
public class VersionRequest : VersionRequestBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
public VersionRequest(int idCompany,
|
||||||
|
VersionRequestBase request)
|
||||||
|
: base(request)
|
||||||
|
{
|
||||||
|
IdCompany = idCompany;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Идентификатор компании
|
||||||
|
/// </summary>
|
||||||
|
public int IdCompany { get; set; }
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Data.SAUB;
|
using AsbCloudApp.Data.SAUB;
|
||||||
|
using AsbCloudApp.Requests;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -62,6 +63,14 @@ public interface ITelemetryService
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task UpdateInfoAsync(string uid, TelemetryInfoDto info, CancellationToken token);
|
Task UpdateInfoAsync(string uid, TelemetryInfoDto info, CancellationToken token);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить версии ПО
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IEnumerable<VersionDto>> GetVersionsAsync(VersionRequest request, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Слить данные телеметрии в одну
|
/// Слить данные телеметрии в одну
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
12377
AsbCloudDb/Migrations/20240821094214_Add_New_Permission.Designer.cs
generated
Normal file
12377
AsbCloudDb/Migrations/20240821094214_Add_New_Permission.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
38
AsbCloudDb/Migrations/20240821094214_Add_New_Permission.cs
Normal file
38
AsbCloudDb/Migrations/20240821094214_Add_New_Permission.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace AsbCloudDb.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Add_New_Permission : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.InsertData(
|
||||||
|
table: "t_permission",
|
||||||
|
columns: new[] { "id", "description", "name" },
|
||||||
|
values: new object[] { 532, "Разрешение просматривать информацию о телеметрии", "TelemetryInfo.get" });
|
||||||
|
|
||||||
|
migrationBuilder.InsertData(
|
||||||
|
table: "t_relation_user_role_permission",
|
||||||
|
columns: new[] { "id_permission", "id_user_role" },
|
||||||
|
values: new object[] { 532, 1 });
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DeleteData(
|
||||||
|
table: "t_relation_user_role_permission",
|
||||||
|
keyColumns: new[] { "id_permission", "id_user_role" },
|
||||||
|
keyValues: new object[] { 532, 1 });
|
||||||
|
|
||||||
|
migrationBuilder.DeleteData(
|
||||||
|
table: "t_permission",
|
||||||
|
keyColumn: "id",
|
||||||
|
keyValue: 532);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2626,6 +2626,12 @@ namespace AsbCloudDb.Migrations
|
|||||||
Id = 531,
|
Id = 531,
|
||||||
Description = "Разрешение на удаление плановой конструкции скважины",
|
Description = "Разрешение на удаление плановой конструкции скважины",
|
||||||
Name = "WellSectionPlan.delete"
|
Name = "WellSectionPlan.delete"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 532,
|
||||||
|
Description = "Разрешение просматривать информацию о телеметрии",
|
||||||
|
Name = "TelemetryInfo.get"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -6366,6 +6372,11 @@ namespace AsbCloudDb.Migrations
|
|||||||
{
|
{
|
||||||
IdUserRole = 1,
|
IdUserRole = 1,
|
||||||
IdPermission = 531
|
IdPermission = 531
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
IdUserRole = 1,
|
||||||
|
IdPermission = 532
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -163,7 +163,9 @@ namespace AsbCloudDb.Model.DefaultData
|
|||||||
new() { Id = 528, Name = "WellContact.delete", Description = "Разрешение на удаление контакта" },
|
new() { Id = 528, Name = "WellContact.delete", Description = "Разрешение на удаление контакта" },
|
||||||
|
|
||||||
new() { Id = 530, Name = "WellSectionPlan.edit", Description = "Разрешение на редактирование плановой конструкции скважины"},
|
new() { Id = 530, Name = "WellSectionPlan.edit", Description = "Разрешение на редактирование плановой конструкции скважины"},
|
||||||
new() { Id = 531, Name = "WellSectionPlan.delete", Description = "Разрешение на удаление плановой конструкции скважины"}
|
new() { Id = 531, Name = "WellSectionPlan.delete", Description = "Разрешение на удаление плановой конструкции скважины"},
|
||||||
|
|
||||||
|
new() { Id = 532, Name = "TelemetryInfo.get", Description = "Разрешение просматривать информацию о телеметрии"}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ namespace AsbCloudDb.Model
|
|||||||
public string? HmiVersion { get; set; }
|
public string? HmiVersion { get; set; }
|
||||||
public string? SaubPlcVersion { get; set; }
|
public string? SaubPlcVersion { get; set; }
|
||||||
public string? SpinPlcVersion { get; set; }
|
public string? SpinPlcVersion { get; set; }
|
||||||
|
public string? PumpPlcVersion { get; set; }
|
||||||
public string? Comment { get; set; }
|
public string? Comment { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ using AsbCloudDb.Model;
|
|||||||
using AsbCloudDb.Model.GTR;
|
using AsbCloudDb.Model.GTR;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -106,6 +107,7 @@ public class GtrWitsRepository : IGtrRepository
|
|||||||
Min = group.Min(e => e.DateTime),
|
Min = group.Min(e => e.DateTime),
|
||||||
Max = group.Max(e => e.DateTime)
|
Max = group.Max(e => e.DateTime)
|
||||||
});
|
});
|
||||||
|
db.Database.SetCommandTimeout(5*60);
|
||||||
var range = await groupedQuery.FirstOrDefaultAsync(token);
|
var range = await groupedQuery.FirstOrDefaultAsync(token);
|
||||||
|
|
||||||
if (range is null)
|
if (range is null)
|
||||||
|
@ -14,6 +14,7 @@ using System.Linq;
|
|||||||
using System.Text.Csv;
|
using System.Text.Csv;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using AsbCloudApp.Requests;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services.SAUB;
|
namespace AsbCloudInfrastructure.Services.SAUB;
|
||||||
|
|
||||||
@ -24,7 +25,6 @@ public class TelemetryService : ITelemetryService
|
|||||||
//TODO: методы использующие ITelemetryDataCache, скорее всего, тут не нужны
|
//TODO: методы использующие ITelemetryDataCache, скорее всего, тут не нужны
|
||||||
private readonly ITelemetryDataCache<TelemetryDataSaubDto> dataSaubCache;
|
private readonly ITelemetryDataCache<TelemetryDataSaubDto> dataSaubCache;
|
||||||
private readonly ITimezoneService timezoneService;
|
private readonly ITimezoneService timezoneService;
|
||||||
|
|
||||||
public ITimezoneService TimeZoneService => timezoneService;
|
public ITimezoneService TimeZoneService => timezoneService;
|
||||||
|
|
||||||
public TelemetryService(
|
public TelemetryService(
|
||||||
@ -78,6 +78,53 @@ public class TelemetryService : ITelemetryService
|
|||||||
DropTelemetryCache();
|
DropTelemetryCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<VersionDto>> GetVersionsAsync(VersionRequest request, CancellationToken token)
|
||||||
|
{
|
||||||
|
var query = db.Set<Well>()
|
||||||
|
.Include(x => x.RelationCompaniesWells)
|
||||||
|
.ThenInclude(x => x.Company)
|
||||||
|
.Include(x => x.Cluster)
|
||||||
|
.ThenInclude(c => c.Deposit)
|
||||||
|
.Where(x => x.RelationCompaniesWells.Any(y => y.IdCompany == request.IdCompany));
|
||||||
|
|
||||||
|
if (request.IdWellState.HasValue)
|
||||||
|
query = query.Where(x => x.IdState == request.IdWellState);
|
||||||
|
|
||||||
|
if (request.IdsWell?.Any() == true)
|
||||||
|
query = query.Where(x => request.IdsWell.Contains(x.Id));
|
||||||
|
|
||||||
|
var wells = await query.Where(x => x.IdTelemetry.HasValue)
|
||||||
|
.ToDictionaryAsync(x => x.Id, x => x, token);
|
||||||
|
|
||||||
|
var idTelemetries = wells.Select(x => x.Value.IdTelemetry!.Value);
|
||||||
|
|
||||||
|
var telemetries = GetTelemetryCache()
|
||||||
|
.Where(x => idTelemetries.Contains(x.Id))
|
||||||
|
.OrderBy(x => x.Info.DrillingStartDate);
|
||||||
|
|
||||||
|
var dtos = telemetries.Select(x =>
|
||||||
|
{
|
||||||
|
var well = wells[x.Well!.Id];
|
||||||
|
|
||||||
|
var dto = new VersionDto
|
||||||
|
{
|
||||||
|
IdWell = well.Id,
|
||||||
|
Well = well.Caption,
|
||||||
|
Cluster = well.Cluster.Caption,
|
||||||
|
Deposit = well.Cluster.Deposit.Caption,
|
||||||
|
Customer = well.RelationCompaniesWells.Select(r => r.Company).FirstOrDefault(c => c.IdCompanyType == 1)?.Caption,
|
||||||
|
HmiVersion = x.Info.HmiVersion,
|
||||||
|
SaubPlcVersion = x.Info.SaubPlcVersion,
|
||||||
|
SpinPlcVersion = x.Info.SpinPlcVersion,
|
||||||
|
};
|
||||||
|
|
||||||
|
return dto;
|
||||||
|
});
|
||||||
|
|
||||||
|
return dtos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[Obsolete("This method will be private. Use TelemetryDto.TimeZone prop.")]
|
[Obsolete("This method will be private. Use TelemetryDto.TimeZone prop.")]
|
||||||
public SimpleTimezoneDto GetTimezone(int idTelemetry)
|
public SimpleTimezoneDto GetTimezone(int idTelemetry)
|
||||||
{
|
{
|
||||||
|
50
AsbCloudWebApi/Controllers/VersionController.cs
Normal file
50
AsbCloudWebApi/Controllers/VersionController.cs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using AsbCloudApp.Data.SAUB;
|
||||||
|
using AsbCloudApp.Requests;
|
||||||
|
using AsbCloudApp.Services;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace AsbCloudWebApi.Controllers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Версии ПО
|
||||||
|
/// </summary>
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
[Authorize]
|
||||||
|
public class VersionController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ITelemetryService telemetryService;
|
||||||
|
|
||||||
|
public VersionController(ITelemetryService telemetryService)
|
||||||
|
{
|
||||||
|
this.telemetryService = telemetryService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить список версий ПО
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
[Permission]
|
||||||
|
[ProducesResponseType(typeof(IEnumerable<VersionDto>), StatusCodes.Status200OK)]
|
||||||
|
public async Task<IActionResult> GetAsync([FromQuery] VersionRequestBase request, CancellationToken token)
|
||||||
|
{
|
||||||
|
var idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
|
if (!idCompany.HasValue)
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
|
var requestToService = new VersionRequest(idCompany.Value, request);
|
||||||
|
|
||||||
|
var version = await telemetryService.GetVersionsAsync(requestToService, token);
|
||||||
|
|
||||||
|
return Ok(version);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user