forked from ddrilling/AsbCloudServer
Merge pull request 'Запись пользователя, изменившего / создавшего опреацию в БД + запись даты изменения / создания' (#42) from feature/set-user-editor-to-operation into dev
Reviewed-on: http://test.digitaldrilling.ru:8080/DDrilling/AsbCloudServer/pulls/42
This commit is contained in:
commit
ab30bc9158
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace AsbCloudApp.Data.DailyReport
|
||||
namespace AsbCloudApp.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// хранение дополнительной информации о записи
|
@ -6,7 +6,7 @@ namespace AsbCloudApp.Data
|
||||
/// <summary>
|
||||
/// Операции на скважине (заведенные пользователем)
|
||||
/// </summary>
|
||||
public class WellOperationDto : IId, IWellRelated
|
||||
public class WellOperationDto : ItemInfoDto, IId, IWellRelated
|
||||
{
|
||||
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using AsbCloudApp.Data.DailyReport;
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Data.DailyReport;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@ -31,7 +32,7 @@ namespace AsbCloudApp.Services
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> AddAsync(int idWell, DateOnly startDate, int idUser, CancellationToken token);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Сформировать файл рапорта
|
||||
/// </summary>
|
||||
|
7824
AsbCloudDb/Migrations/20230404045901_Add_UserEditor_To_WellOperation_Table.Designer.cs
generated
Normal file
7824
AsbCloudDb/Migrations/20230404045901_Add_UserEditor_To_WellOperation_Table.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
public partial class Add_UserEditor_To_WellOperation_Table : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "IdUser",
|
||||
table: "t_well_operation",
|
||||
type: "integer",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<DateTimeOffset>(
|
||||
name: "LastUpdateDate",
|
||||
table: "t_well_operation",
|
||||
type: "timestamp with time zone",
|
||||
nullable: false,
|
||||
defaultValue: new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)));
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IdUser",
|
||||
table: "t_well_operation");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "LastUpdateDate",
|
||||
table: "t_well_operation");
|
||||
}
|
||||
}
|
||||
}
|
@ -5047,6 +5047,9 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("id_type")
|
||||
.HasComment("0 = План или 1 = Факт");
|
||||
|
||||
b.Property<int?>("IdUser")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("IdWell")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_well")
|
||||
@ -5057,6 +5060,9 @@ namespace AsbCloudDb.Migrations
|
||||
.HasColumnName("id_well_section_type")
|
||||
.HasComment("Id тип секции скважины");
|
||||
|
||||
b.Property<DateTimeOffset>("LastUpdateDate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DateStart");
|
||||
|
@ -7,7 +7,7 @@ using System.Text.Json.Serialization;
|
||||
namespace AsbCloudDb.Model
|
||||
{
|
||||
[Table("t_well_operation"), Comment("Данные по операциям на скважине")]
|
||||
public class WellOperation : IId
|
||||
public class WellOperation : ItemInfo, IId
|
||||
{
|
||||
public const int IdOperationTypePlan = 0;
|
||||
public const int IdOperationTypeFact = 1;
|
||||
|
@ -373,7 +373,9 @@ namespace AsbCloudInfrastructure.Repository
|
||||
.Where(subOp => subOp.IdType == o.IdType)
|
||||
.Where(subOp => subOp.DateStart <= o.DateStart)
|
||||
.Min(subOp => subOp.DateStart))
|
||||
.TotalDays
|
||||
.TotalDays,
|
||||
IdUser = o.IdUser,
|
||||
LastUpdateDate = o.LastUpdateDate.ToOffset(TimeSpan.FromHours(timezone.Hours))
|
||||
});
|
||||
|
||||
if (request.SortFields?.Any() == true)
|
||||
|
@ -186,18 +186,24 @@ namespace AsbCloudInfrastructure.Services.DailyReport
|
||||
var dto = entity.Info.Adapt<DailyReportDto>();
|
||||
dto.StartDate = entity.StartDate;
|
||||
|
||||
var dailyFactOperation = factOperationsForDtos
|
||||
var dailyFactOperations = factOperationsForDtos
|
||||
.Where(o => DateOnly.FromDateTime(o.DateStart) == dto.StartDate)
|
||||
.Where(o => o.IdParentCategory is not null)
|
||||
.Where(o => o.IdParentCategory is not null);
|
||||
|
||||
var lastDailyFactOperation = dailyFactOperations
|
||||
.OrderByDescending(o => o.LastUpdateDate)
|
||||
.FirstOrDefault();
|
||||
dto.TimeBalance.IdUser = lastDailyFactOperation?.IdUser;
|
||||
dto.TimeBalance.LastUpdateDate = lastDailyFactOperation?.LastUpdateDate;
|
||||
dto.TimeBalance.OperationsStat = dailyFactOperations
|
||||
.GroupBy(o => o.IdParentCategory!.Value)
|
||||
.ToDictionary(g => g.Key, g => g.Sum(o => o.DurationHours));
|
||||
|
||||
dto.TimeBalance.OperationsStat = dailyFactOperation;
|
||||
|
||||
var blocks = new ItemInfoDto[] {
|
||||
dto.Head,
|
||||
dto.Bha,
|
||||
dto.NoDrilling,
|
||||
dto.TimeBalance,
|
||||
dto.Saub,
|
||||
dto.Sign
|
||||
};
|
||||
|
@ -1,4 +1,5 @@
|
||||
using AsbCloudApp.Data.DailyReport;
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Data.DailyReport;
|
||||
using AsbCloudApp.Exceptions;
|
||||
using AsbCloudApp.Repositories;
|
||||
using AsbCloudApp.Services;
|
||||
|
@ -209,7 +209,11 @@ namespace AsbCloudWebApi.Controllers
|
||||
return Forbid();
|
||||
|
||||
foreach (var value in values)
|
||||
{
|
||||
value.IdWell = idWell;
|
||||
value.LastUpdateDate = DateTimeOffset.UtcNow;
|
||||
value.IdUser = User.GetUserId();
|
||||
}
|
||||
|
||||
var result = await operationRepository.InsertRangeAsync(values, token)
|
||||
.ConfigureAwait(false);
|
||||
@ -236,6 +240,8 @@ namespace AsbCloudWebApi.Controllers
|
||||
|
||||
value.IdWell = idWell;
|
||||
value.Id = idOperation;
|
||||
value.LastUpdateDate = DateTimeOffset.UtcNow;
|
||||
value.IdUser = User.GetUserId();
|
||||
|
||||
var result = await operationRepository.UpdateAsync(value, token)
|
||||
.ConfigureAwait(false);
|
||||
|
Loading…
Reference in New Issue
Block a user