This commit is contained in:
ai.astrakhantsev 2022-12-07 08:47:41 +05:00
parent 4f100e6bc4
commit 398a6d443e
11 changed files with 13135 additions and 46 deletions

View File

@ -21,6 +21,11 @@ namespace AsbCloudApp.Data
/// </summary>
public int IdWell { get; set; }
/// <summary>
/// Id пользователя
/// </summary>
public int IdUser { get; set; }
/// <summary>
/// Тип секции
/// </summary>
@ -44,27 +49,27 @@ namespace AsbCloudApp.Data
/// <summary>
/// Нагрузка
/// </summary>
public PlanFactDto? AxialLoad { get; set; }
public PlanFactDto AxialLoad { get; set; } = null!;
/// <summary>
/// Перепад давления
/// </summary>
public PlanFactDto? Pressure { get; set; }
public PlanFactDto Pressure { get; set; } = null!;
/// <summary>
/// Момент на ВСП
/// </summary>
public PlanFactDto? TopDriveTorque { get; set; }
public PlanFactDto TopDriveTorque { get; set; } = null!;
/// <summary>
/// Обороты на ВСП
/// </summary>
public PlanFactDto? TopDriveSpeed { get; set; }
public PlanFactDto TopDriveSpeed { get; set; } = null!;
/// <summary>
/// Расход
/// </summary>
public PlanFactDto? Flow { get; set; }
public PlanFactDto Flow { get; set; } = null!;
/// <summary>
/// Плановая механическая скорость, м/ч

View File

@ -9,7 +9,7 @@ namespace AsbCloudApp.Services
/// <summary>
/// ÐÒÊ
/// </summary>
public interface IDrillFlowChartRepository : IRepositoryWellRelated<ProcessMapDto>
public interface IProcessMapRepository : IRepositoryWellRelated<ProcessMapDto>
{
/// <summary>
/// Ïîëó÷èòü ïàðàìåòðû áóðåíèÿ íà÷èíàÿ ñ äàòû.
@ -19,6 +19,6 @@ namespace AsbCloudApp.Services
/// <param name="token"></param>
/// <returns></returns>
Task<IEnumerable<ProcessMapDto>> GetAllAsync(int idWell,
DateTime updateFrom, CancellationToken token = default);
DateTime? updateFrom, CancellationToken token = default);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,48 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class UpdateTable_t_process_map_add_user_id : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "id_user",
table: "t_process_map",
type: "integer",
nullable: false,
defaultValue: 0,
comment: "Id пользователя");
migrationBuilder.CreateIndex(
name: "IX_t_process_map_id_user",
table: "t_process_map",
column: "id_user");
migrationBuilder.AddForeignKey(
name: "FK_t_process_map_t_user_id_user",
table: "t_process_map",
column: "id_user",
principalTable: "t_user",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_t_process_map_t_user_id_user",
table: "t_process_map");
migrationBuilder.DropIndex(
name: "IX_t_process_map_id_user",
table: "t_process_map");
migrationBuilder.DropColumn(
name: "id_user",
table: "t_process_map");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,36 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class UpdateTable_t_process_map_delete_fk : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_t_process_map_t_user_id_user",
table: "t_process_map");
migrationBuilder.DropIndex(
name: "IX_t_process_map_id_user",
table: "t_process_map");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_t_process_map_id_user",
table: "t_process_map",
column: "id_user");
migrationBuilder.AddForeignKey(
name: "FK_t_process_map_t_user_id_user",
table: "t_process_map",
column: "id_user",
principalTable: "t_user",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@ -1801,6 +1801,11 @@ namespace AsbCloudDb.Migrations
.HasColumnName("flow_plan")
.HasComment("Расход, план");
b.Property<int>("IdUser")
.HasColumnType("integer")
.HasColumnName("id_user")
.HasComment("Id пользователя");
b.Property<int>("IdWell")
.HasColumnType("integer")
.HasColumnName("well_id")

View File

@ -17,6 +17,9 @@ namespace AsbCloudDb.Model
[Column("well_id"), Comment("Id скважины")]
public int IdWell { get; set; }
[Column("id_user"), Comment("Id пользователя")]
public int IdUser { get; set; }
[Column("id_wellsection_type"), Comment("Тип секции")]
public int IdWellSectionType { get; set; }
@ -64,11 +67,11 @@ namespace AsbCloudDb.Model
[JsonIgnore]
[ForeignKey(nameof(IdWell))]
public virtual Well? Well { get; set; }
public virtual Well? Well { get; set; } = null!;
[JsonIgnore]
[ForeignKey(nameof(IdWellSectionType))]
public virtual WellSectionType? WellSectionType { get; set; }
public virtual WellSectionType? WellSectionType { get; set; } = null!;
}
#nullable disable
}

View File

@ -109,7 +109,7 @@ namespace AsbCloudInfrastructure
services.AddTransient<IAuthService, AuthService>();
services.AddTransient<IClusterService, ClusterService>();
services.AddTransient<IDrillFlowChartRepository, ProcessMapRepository>();
services.AddTransient<IProcessMapRepository, ProcessMapRepository>();
services.AddTransient<IDrillingProgramService, DrillingProgramService>();
services.AddTransient<IEventService, EventService>();
services.AddTransient<FileService>();

View File

@ -12,24 +12,27 @@ using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Repository
{
public class ProcessMapRepository : CrudWellRelatedServiceBase<ProcessMapDto, ProcessMap>,
IDrillFlowChartRepository
IProcessMapRepository
{
private readonly IWellService wellService;
public ProcessMapRepository(IAsbCloudDbContext context, IWellService wellService)
: base(context)
: base(context, dbSet =>
dbSet.Include(x => x.Well)
.Include(x => x.WellSectionType)
)
{
this.wellService = wellService;
}
public async Task<IEnumerable<ProcessMapDto>> GetAllAsync(int idWell,
DateTime updateFrom, CancellationToken token = default)
DateTime? updateFrom, CancellationToken token = default)
{
var timezone = wellService.GetTimezone(idWell);
var updateFromUtc = updateFrom.ToUtcDateTimeOffset(timezone.Hours);
var updateFromUtc = updateFrom?.ToUtcDateTimeOffset(timezone.Hours);
var entities = await GetQuery()
.Where(e => e.IdWell == idWell)
.Where(e => e.LastUpdate == updateFromUtc)
.Where(e => e.LastUpdate >= updateFromUtc)
.OrderBy(e => e.DepthStart)
.ThenBy(e => e.Id)
.ToListAsync(token)
@ -62,35 +65,34 @@ namespace AsbCloudInfrastructure.Repository
protected override ProcessMapDto Convert(ProcessMap entity)
{
return new ProcessMapDto {
Id = entity.Id,
IdWell = entity.IdWell,
LastUpdate = entity.LastUpdate,
IdWellSectionType = entity.IdWellSectionType,
DepthEnd = entity.DepthEnd,
DepthStart = entity.DepthStart,
AxialLoad = new PlanFactDto {
Fact = entity.AxialLoadFact,
Plan = entity.AxialLoadPlan
},
Flow = new PlanFactDto {
Fact = entity.FlowFact,
Plan = entity.FlowPlan
},
Pressure = new PlanFactDto {
Fact = entity.FlowFact,
Plan = entity.FlowPlan
},
TopDriveSpeed = new PlanFactDto {
Fact = entity.TopDriveSpeedFact,
Plan = entity.TopDriveSpeedPlan
},
TopDriveTorque = new PlanFactDto {
Fact= entity.TopDriveTorqueFact,
Plan = entity.TopDriveTorquePlan
},
RopPlan = entity.RopPlan
var dto = entity.Adapt<ProcessMapDto>();
dto.LastUpdate = entity.LastUpdate.ToRemoteDateTime(entity.Well.Timezone.Hours);
dto.AxialLoad = new PlanFactDto
{
Fact = entity.AxialLoadFact,
Plan = entity.AxialLoadPlan
};
dto.Flow = new PlanFactDto
{
Fact = entity.FlowFact,
Plan = entity.FlowPlan
};
dto.Pressure = new PlanFactDto
{
Fact = entity.FlowFact,
Plan = entity.FlowPlan
};
dto.TopDriveSpeed = new PlanFactDto
{
Fact = entity.TopDriveSpeedFact,
Plan = entity.TopDriveSpeedPlan
};
dto.TopDriveTorque = new PlanFactDto
{
Fact = entity.TopDriveTorqueFact,
Plan = entity.TopDriveTorquePlan
};
return dto;
}
}
}

View File

@ -15,11 +15,11 @@ namespace AsbCloudWebApi.Controllers
[ApiController]
[Route("api/[controller]")]
[Authorize]
public class ProcessMapController : CrudWellRelatedController<ProcessMapDto, IDrillFlowChartRepository>
public class ProcessMapController : CrudWellRelatedController<ProcessMapDto, IProcessMapRepository>
{
private readonly ITelemetryService telemetryService;
public ProcessMapController(IWellService wellService, IDrillFlowChartRepository service,
public ProcessMapController(IWellService wellService, IProcessMapRepository service,
ITelemetryService telemetryService)
: base(wellService, service)
{
@ -57,9 +57,35 @@ namespace AsbCloudWebApi.Controllers
/// <exception cref="NotImplementedException"></exception>
[HttpGet]
[Route("{wellId}")]
public IActionResult GetExtendedRTCAsync(int wellId)
public IActionResult GetReportFileAsync(int wellId)
{
throw new NotImplementedException();
}
/// <summary>
/// Добавить запись
/// </summary>
/// <param name="value"></param>
/// <param name="token"></param>
/// <returns></returns>
[HttpPost]
public override async Task<ActionResult<int>> InsertAsync([FromBody] ProcessMapDto value, CancellationToken token)
{
value.IdUser = User.GetUserId() ?? -1;
return await base.InsertAsync(value, token);
}
// <summary>
/// Редактировать запись по id
/// </summary>
/// <param name="value">запись</param>
/// <param name="token"></param>
/// <returns>1 - успешно отредактировано, 0 - нет</returns>
[HttpPut]
public override async Task<ActionResult<int>> UpdateAsync([FromBody] ProcessMapDto value, CancellationToken token)
{
value.IdUser = User.GetUserId() ?? -1;
return await base.InsertAsync(value, token);
}
}
}