forked from ddrilling/AsbCloudServer
Запись пользователя, изменившего / создавшего опреацию в БД + запись даты изменения / создания
This commit is contained in:
parent
6f51048ae7
commit
be0d171973
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace AsbCloudApp.Data.DailyReport
|
namespace AsbCloudApp.Data
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// хранение дополнительной информации о записи
|
/// хранение дополнительной информации о записи
|
@ -6,7 +6,7 @@ namespace AsbCloudApp.Data
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Операции на скважине (заведенные пользователем)
|
/// Операции на скважине (заведенные пользователем)
|
||||||
/// </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;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
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")
|
.HasColumnName("id_type")
|
||||||
.HasComment("0 = План или 1 = Факт");
|
.HasComment("0 = План или 1 = Факт");
|
||||||
|
|
||||||
|
b.Property<int?>("IdUser")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<int>("IdWell")
|
b.Property<int>("IdWell")
|
||||||
.HasColumnType("integer")
|
.HasColumnType("integer")
|
||||||
.HasColumnName("id_well")
|
.HasColumnName("id_well")
|
||||||
@ -5057,6 +5060,9 @@ namespace AsbCloudDb.Migrations
|
|||||||
.HasColumnName("id_well_section_type")
|
.HasColumnName("id_well_section_type")
|
||||||
.HasComment("Id тип секции скважины");
|
.HasComment("Id тип секции скважины");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("LastUpdateDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("DateStart");
|
b.HasIndex("DateStart");
|
||||||
|
@ -7,7 +7,7 @@ using System.Text.Json.Serialization;
|
|||||||
namespace AsbCloudDb.Model
|
namespace AsbCloudDb.Model
|
||||||
{
|
{
|
||||||
[Table("t_well_operation"), Comment("Данные по операциям на скважине")]
|
[Table("t_well_operation"), Comment("Данные по операциям на скважине")]
|
||||||
public class WellOperation : IId
|
public class WellOperation : ItemInfo, IId
|
||||||
{
|
{
|
||||||
public const int IdOperationTypePlan = 0;
|
public const int IdOperationTypePlan = 0;
|
||||||
public const int IdOperationTypeFact = 1;
|
public const int IdOperationTypeFact = 1;
|
||||||
|
@ -373,7 +373,9 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
.Where(subOp => subOp.IdType == o.IdType)
|
.Where(subOp => subOp.IdType == o.IdType)
|
||||||
.Where(subOp => subOp.DateStart <= o.DateStart)
|
.Where(subOp => subOp.DateStart <= o.DateStart)
|
||||||
.Min(subOp => subOp.DateStart))
|
.Min(subOp => subOp.DateStart))
|
||||||
.TotalDays
|
.TotalDays,
|
||||||
|
IdUser = o.IdUser,
|
||||||
|
LastUpdateDate = o.LastUpdateDate.ToOffset(TimeSpan.FromHours(timezone.Hours))
|
||||||
});
|
});
|
||||||
|
|
||||||
if (request.SortFields?.Any() == true)
|
if (request.SortFields?.Any() == true)
|
||||||
|
@ -186,18 +186,24 @@ namespace AsbCloudInfrastructure.Services.DailyReport
|
|||||||
var dto = entity.Info.Adapt<DailyReportDto>();
|
var dto = entity.Info.Adapt<DailyReportDto>();
|
||||||
dto.StartDate = entity.StartDate;
|
dto.StartDate = entity.StartDate;
|
||||||
|
|
||||||
var dailyFactOperation = factOperationsForDtos
|
var dailyFactOperations = factOperationsForDtos
|
||||||
.Where(o => DateOnly.FromDateTime(o.DateStart) == dto.StartDate)
|
.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)
|
.GroupBy(o => o.IdParentCategory!.Value)
|
||||||
.ToDictionary(g => g.Key, g => g.Sum(o => o.DurationHours));
|
.ToDictionary(g => g.Key, g => g.Sum(o => o.DurationHours));
|
||||||
|
|
||||||
dto.TimeBalance.OperationsStat = dailyFactOperation;
|
|
||||||
|
|
||||||
var blocks = new ItemInfoDto[] {
|
var blocks = new ItemInfoDto[] {
|
||||||
dto.Head,
|
dto.Head,
|
||||||
dto.Bha,
|
dto.Bha,
|
||||||
dto.NoDrilling,
|
dto.NoDrilling,
|
||||||
|
dto.TimeBalance,
|
||||||
dto.Saub,
|
dto.Saub,
|
||||||
dto.Sign
|
dto.Sign
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AsbCloudApp.Data.DailyReport;
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Data.DailyReport;
|
||||||
using AsbCloudApp.Exceptions;
|
using AsbCloudApp.Exceptions;
|
||||||
using AsbCloudApp.Repositories;
|
using AsbCloudApp.Repositories;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
|
@ -209,7 +209,11 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
foreach (var value in values)
|
foreach (var value in values)
|
||||||
|
{
|
||||||
value.IdWell = idWell;
|
value.IdWell = idWell;
|
||||||
|
value.LastUpdateDate = DateTimeOffset.UtcNow;
|
||||||
|
value.IdUser = User.GetUserId();
|
||||||
|
}
|
||||||
|
|
||||||
var result = await operationRepository.InsertRangeAsync(values, token)
|
var result = await operationRepository.InsertRangeAsync(values, token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
@ -236,6 +240,8 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
|
|
||||||
value.IdWell = idWell;
|
value.IdWell = idWell;
|
||||||
value.Id = idOperation;
|
value.Id = idOperation;
|
||||||
|
value.LastUpdateDate = DateTimeOffset.UtcNow;
|
||||||
|
value.IdUser = User.GetUserId();
|
||||||
|
|
||||||
var result = await operationRepository.UpdateAsync(value, token)
|
var result = await operationRepository.UpdateAsync(value, token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user