CS2-43: Added 'Last Data' tables saving to Db

This commit is contained in:
KharchenkoVV 2021-08-02 18:35:36 +05:00
parent 4cb797e9c8
commit 543272ce7b
13 changed files with 120 additions and 50 deletions

View File

@ -0,0 +1,28 @@
namespace AsbCloudApp.Data
{
public class MudDiagramDataDto
{
public double ProbeNumber { get; set; }
public double ProbeExtractionDepth { get; set; }
public double Sandstone { get; set; }
public double Siltstone { get; set; }
public double Argillit { get; set; }
public double BrokenArgillit { get; set; }
public double Coal { get; set; }
public double Sand { get; set; }
public double Clay { get; set; }
public double Camstone { get; set; }
public double Cement { get; set; }
public string Summary { get; set; }
public double DrillingMud { get; set; }
public double Sludge { get; set; }
public double MaxSum { get; set; }
public double Methane { get; set; }
public double Ethan { get; set; }
public double Propane { get; set; }
public double Butane { get; set; }
public double Pentane { get; set; }
public double MechanicalSpeed { get; set; }
public string PreliminaryConclusion { get; set; }
}
}

View File

@ -0,0 +1,23 @@
namespace AsbCloudApp.Data
{
public class NnbDataDto
{
public double Depth { get; set; }
public double ZenithAngle { get; set; }
public double TrueAzimuth { get; set; }
public double ConditionalViscosity { get; set; }
public double DirectAzimuth { get; set; }
public double VerticalDepth { get; set; }
public double AbsoluteMark { get; set; }
public double LocalNorthOffset { get; set; }
public double LocalEastOffset { get; set; }
public double OutFallOffset { get; set; }
public double OffsetAzimuth { get; set; }
public double AreaIntensity { get; set; }
public double OffsetStopAngle { get; set; }
public double ZenithIntensity { get; set; }
public double Comment { get; set; }
public double DepthPlanFactDifference { get; set; }
public double DistancePlanFactDifference { get; set; }
}
}

View File

@ -3,6 +3,6 @@
public interface ILastDataService<Tdto>
{
Tdto Get(int idWell, int idCategory);
int Upsert(int idWell, int idCategory, Tdto value);
void Upsert(int idWell, int idCategory, Tdto value);
}
}

View File

@ -215,18 +215,18 @@ namespace AsbCloudDb.Model
modelBuilder.Entity<FileCategory>(entity =>
{
entity.HasData(new List<FileCategory> {
new FileCategory {Id = 1, Name = "Растворный сервис"},
new FileCategory {Id = 2, Name = "Цементирование"},
new FileCategory {Id = 3, Name = "ННБ"},
new FileCategory {Id = 4, Name = "ГТИ"},
new FileCategory {Id = 5, Name = "Документы по скважине"},
new FileCategory {Id = 6, Name = "Супервайзер"},
new FileCategory {Id = 7, Name = "Мастер"},
new FileCategory {Id = 8, Name = "Последние данные"},
new FileCategory {Id = 9, Name = "Последний замер бурового раствора"},
new FileCategory {Id = 10, Name = "Шламограмма"},
new FileCategory {Id = 11, Name = "Последние данные ННБ"},
new FileCategory {Id = 12, Name = "Рапорт"}
new FileCategory {Id = 1, Name = "Растворный сервис", ShortName = "fluidService"},
new FileCategory {Id = 2, Name = "Цементирование", ShortName = "cement"},
new FileCategory {Id = 3, Name = "ННБ", ShortName = "nnb"},
new FileCategory {Id = 4, Name = "ГТИ", ShortName = "gti"},
new FileCategory {Id = 5, Name = "Документы по скважине", ShortName = "wellDocuments"},
new FileCategory {Id = 6, Name = "Супервайзер", ShortName = "supervisor"},
new FileCategory {Id = 7, Name = "Мастер", ShortName = "master"},
new FileCategory {Id = 8, Name = "Последний замер бурового раствора ПЛАН", ShortName = "fluidPlanLastData"},
new FileCategory {Id = 9, Name = "Последний замер бурового раствора ФАКТ", ShortName = "fluidFactLastData"},
new FileCategory {Id = 10, Name = "Последние данные Шламограммы", ShortName = "mudLastData"},
new FileCategory {Id = 11, Name = "Последние данные ННБ", ShortName = "nnbLastData"},
new FileCategory {Id = 12, Name = "Рапорт", ShortName = "report"}
});
});
}

View File

@ -13,5 +13,8 @@ namespace AsbCloudDb.Model
[Column("name"), Comment("Название категории")]
public string Name { get; set; }
[Column("short_name"), Comment("Короткое название категории")]
public string ShortName { get; set; }
}
}

View File

@ -3,65 +3,34 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace AsbCloudDb.Model
{
[Table("t_fluid_data")]
public class FluidData
{
[Key]
[Column("id")]
public int Id { get; set; }
[Column("temperature")]
public double Temperature { get; set; }
[Column("density")]
public double Density { get; set; }
[Column("conditionalViscosity")]
public double ConditionalViscosity { get; set; }
[Column("r300")]
public double R300 { get; set; }
[Column("r600")]
public double R600 { get; set; }
[Column("r3r6")]
public double R3r6 { get; set; }
[Column("dnsDpa")]
public double DnsDpa { get; set; }
[Column("plasticViscocity")]
public double PlasticViscocity { get; set; }
[Column("snsDpa")]
public double SnsDpa { get; set; }
[Column("r3r649С")]
public double R3r649С { get; set; }
[Column("dns49Cdpa")]
public double Dns49Cdpa { get; set; }
[Column("plasticViscocity49c")]
public double PlasticViscocity49c { get; set; }
[Column("sns49Cdpa")]
public double Sns49Cdpa { get; set; }
[Column("mbt")]
public double Mbt { get; set; }
[Column("sand")]
public double Sand { get; set; }
[Column("filtering")]
public double Filtering { get; set; }
[Column("crust")]
public double Crust { get; set; }
[Column("ktk")]
public double Ktk { get; set; }
[Column("ph")]
public double Ph { get; set; }
[Column("hardness")]
public double Hardness { get; set; }
[Column("chlorides")]
public double Chlorides { get; set; }
[Column("pf")]
public double Pf { get; set; }
[Column("mf")]
public double Mf { get; set; }
[Column("pm")]
public double Pm { get; set; }
[Column("fluidSolidPhase")]
public double FluidSolidPhase { get; set; }
[Column("grease")]
public double Grease { get; set; }
[Column("calciumCarbonate")]
public double CalciumCarbonate { get; set; }
}
}

View File

@ -2,6 +2,7 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
namespace AsbCloudDb.Model
{
@ -23,5 +24,13 @@ namespace AsbCloudDb.Model
[Column("data", TypeName = "jsonb"), Comment("Данные таблицы последних данных")]
public object Data { get; set; }
[JsonIgnore]
[ForeignKey(nameof(IdWell))]
public virtual Well Well { get; set; }
[JsonIgnore]
[ForeignKey(nameof(IdCategory))]
public virtual FileCategory FileCategory { get; set; }
}
}

View File

@ -39,6 +39,8 @@ namespace AsbCloudInfrastructure
services.AddTransient<ILastDataService<FluidDataDto>, LastDataService<FluidDataDto, FluidData>>();
services.AddTransient<ILastDataService<MudDiagramDataDto>, LastDataService<MudDiagramDataDto, MudDiagramData>>();
services.AddTransient<ILastDataService<NnbDataDto>, LastDataService<NnbDataDto, NnbData>>();
return services;

View File

@ -27,7 +27,7 @@ namespace AsbCloudInfrastructure.Services
return dto;
}
public int Upsert(int idWell, int idCategory, Tdto value)
public void Upsert(int idWell, int idCategory, Tdto value)
{
var model = value.Adapt<TModel>();
@ -44,13 +44,15 @@ namespace AsbCloudInfrastructure.Services
{
var newLastData = new LastData
{
IdWell = idWell,
IdCategory = idCategory,
LastUpdateDate = DateTime.Now,
Data = model
};
db.LastData.Add(newLastData);
}
return db.SaveChanges();
db.SaveChanges();
}
}

View File

@ -5,10 +5,10 @@ using AsbCloudApp.Services;
namespace AsbCloudWebApi.Controllers
{
[Route("api/lastData/{idWell}")]
[Route("api/fluidLastData/{idWell}")]
[ApiController]
[Authorize]
public class FluidController : CrudController<FluidDataDto>
public class FluidController : LastDataController<FluidDataDto>
{
public FluidController(ILastDataService<FluidDataDto> lastDataService,
IWellService wellService) : base(lastDataService, wellService)

View File

@ -30,7 +30,7 @@ namespace AsbCloudWebApi.Controllers
}
[HttpPost]
public IActionResult Put([FromRoute] int idWell, [FromQuery] int idCategory, [FromForm] T data)
public IActionResult Put([FromRoute] int idWell, [FromQuery] int idCategory, T data)
{
int? idCompany = User.GetCompanyId();

View File

@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using AsbCloudApp.Data;
using AsbCloudApp.Services;
namespace AsbCloudWebApi.Controllers
{
[Route("api/mudLastData/{idWell}")]
[ApiController]
[Authorize]
public class MudDiagramController : LastDataController<MudDiagramDataDto>
{
public MudDiagramController(ILastDataService<MudDiagramDataDto> lastDataService,
IWellService wellService) : base(lastDataService, wellService)
{ }
}
}

View File

@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using AsbCloudApp.Data;
using AsbCloudApp.Services;
namespace AsbCloudWebApi.Controllers
{
[Route("api/nnbLastData/{idWell}")]
[ApiController]
[Authorize]
public class NnbDataController : LastDataController<NnbDataDto>
{
public NnbDataController(ILastDataService<NnbDataDto> lastDataService,
IWellService wellService) : base(lastDataService, wellService)
{ }
}
}