forked from ddrilling/AsbCloudServer
корректировка сервиса (изменение моделей)
This commit is contained in:
parent
0f27809489
commit
61e2056eea
@ -1,4 +1,5 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using AsbCloudDb.Model.DailyReportDB;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -5,8 +5,8 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||
namespace AsbCloudDb.Model.DailyReportDB
|
||||
{
|
||||
#nullable disable
|
||||
[Table("t_daily_report"), Comment("Ежедневные отчёты")]
|
||||
public class DailyReportDb
|
||||
[Table("t_daily_report_mod"), Comment("Ежедневные отчёты")]
|
||||
public class DailyReport
|
||||
{
|
||||
[Column("id_well"), Comment("ID скважины")]
|
||||
public int IdWell { get; set; }
|
||||
@ -15,11 +15,14 @@ namespace AsbCloudDb.Model.DailyReportDB
|
||||
public DateTimeOffset StartDate { get; set; }
|
||||
|
||||
[Column("blockHead", TypeName = "jsonb"), Comment("1 блок параметров для отчёта")]
|
||||
public DailyReportInfo BlockHead { get; set; }
|
||||
public DailyReportHead BlockHead { get; set; }
|
||||
|
||||
[Column("blockBha", TypeName = "jsonb"), Comment("2 блок параметров для отчёта")]
|
||||
public DailyReportBha BlockBha { get; set; }
|
||||
|
||||
[Column("blockTimeBalance", TypeName = "jsonb"), Comment("2 блок параметров для отчёта")]
|
||||
public DailyReportTimeBalance BlockTimeBalance { get; set; }
|
||||
|
||||
[Column("blockDimensionless", TypeName = "jsonb"), Comment("4 блок параметров для отчёта")]
|
||||
public DailyReportDimensionless BlockDimensionless { get; set; }
|
||||
|
||||
@ -37,7 +40,7 @@ namespace AsbCloudDb.Model.DailyReportDB
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
18
AsbCloudDb/Model/DailyReportDB/DailyReportInfo.cs
Normal file
18
AsbCloudDb/Model/DailyReportDB/DailyReportInfo.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AsbCloudDb.Model.DailyReportDB;
|
||||
|
||||
namespace AsbCloudDb.Model
|
||||
{
|
||||
#nullable disable
|
||||
public class DailyReportInfo
|
||||
{
|
||||
public DailyReportHead HeadInfo { get; set; }
|
||||
public DailyReportBha BhaDto { get; set; }
|
||||
public DailyReportDimensionless DimensionlessInfo { get; set; }
|
||||
public DailyReportTimeBalance TimeBalanceInfo { get; set; }
|
||||
public DailyReportSaub SaubInfo { get; set; }
|
||||
public DailyReportSign SignInfo { get; set; }
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using AsbCloudDb.Model.WITS;
|
||||
using AsbCloudDb.Model.DailyReportDB;
|
||||
using AsbCloudDb.Model.WITS;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using System;
|
||||
|
@ -9,7 +9,7 @@ using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudDb.Model;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using AsbCloudDb.Model.DailyReportDB;
|
||||
using AsbCloudApp.Data.DailyReport;
|
||||
|
||||
namespace AsbCloudInfrastructure.Services.DailyReport
|
||||
@ -64,11 +64,17 @@ namespace AsbCloudInfrastructure.Services.DailyReport
|
||||
var offsetHours = wellService.GetTimezone(idWell).Hours;
|
||||
var reportDateOffset = dto.HeadDto.ReportDate.ToUtcDateTimeOffset(offsetHours);
|
||||
var info = Convert(dto, offsetHours);
|
||||
var entity = new AsbCloudDb.Model.DailyReport
|
||||
var entity = new AsbCloudDb.Model.DailyReportDB.DailyReport
|
||||
{
|
||||
IdWell = idWell,
|
||||
StartDate = reportDateOffset,
|
||||
Info = info,
|
||||
BlockHead = info.HeadInfo,
|
||||
BlockBha = info.BhaDto,
|
||||
BlockDimensionless = info.DimensionlessInfo,
|
||||
BlockTimeBalance = info.TimeBalanceInfo,
|
||||
BlockSaub = info.SaubInfo,
|
||||
BlockSign = info.SignInfo
|
||||
|
||||
};
|
||||
db.DailyReports.Add(entity);
|
||||
var result = await db.SaveChangesAsync(token);
|
||||
@ -88,7 +94,8 @@ namespace AsbCloudInfrastructure.Services.DailyReport
|
||||
if (entity is null)
|
||||
return 0;
|
||||
|
||||
entity.Info = Convert(dto, offsetHours);
|
||||
var convertEntity = Convert(dto, offsetHours);
|
||||
entity.BlockHead = convertEntity.HeadInfo;
|
||||
db.DailyReports.Update(entity);
|
||||
|
||||
var result = await db.SaveChangesAsync(token);
|
||||
@ -141,9 +148,18 @@ namespace AsbCloudInfrastructure.Services.DailyReport
|
||||
return result;
|
||||
}
|
||||
|
||||
private static DailyReportDto Convert(AsbCloudDb.Model.DailyReport entity, double offsetHours)
|
||||
private static DailyReportDto Convert(AsbCloudDb.Model.DailyReportDB.DailyReport entity, double offsetHours)
|
||||
{
|
||||
var dto = entity.Info.Adapt<DailyReportDto>();
|
||||
var dto = new DailyReportDto()
|
||||
{
|
||||
BhaDto = entity.BlockBha.Adapt<DailyReportBhaDto>(),
|
||||
HeadDto = entity.BlockHead.Adapt<DailyReportHeadDto>(),
|
||||
TimeBalanceDto = entity.BlockTimeBalance.Adapt<DailyReportTimeBalanceDto>(),
|
||||
DimensionlessDto = entity.BlockDimensionless.Adapt<DailyReportDimensionlessDto>(),
|
||||
SaubDto = entity.BlockSaub.Adapt<DailyReportSaubDto>(),
|
||||
SignDto = entity.BlockSign.Adapt<DailyReportSignDto>()
|
||||
};
|
||||
|
||||
dto.HeadDto.ReportDate = entity.StartDate
|
||||
.ToRemoteDateTime(offsetHours);
|
||||
return dto;
|
||||
|
Loading…
Reference in New Issue
Block a user