From e5a3e30183a890e1fd25f981663fde1823d30b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Thu, 22 Jul 2021 14:23:47 +0500 Subject: [PATCH] =?UTF-8?q?CS2-36=20=D0=92=20=D0=BA=D0=BE=D0=BD=D1=82?= =?UTF-8?q?=D1=80=D0=BE=D0=BB=D0=BB=D0=B5=D1=80=20Deposit=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=B1=D0=B0=D0=B2=D0=B8=D1=82=D1=8C=20=D0=BC=D0=B5=D1=82=D0=BE?= =?UTF-8?q?=D0=B4=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=20"=D0=B4=D0=B5=D1=80=D0=B5=D0=B2=D0=B0"=20=D0=B4=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D1=83=D0=BF=D0=BD=D1=8B=D1=85=20=D0=BF=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8E=20=D0=BC=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D0=BE=D1=80=D0=BE=D0=B6=D0=B4=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B9->=D0=BA=D1=83=D1=81=D1=82=D0=BE=D0=B2->=D1=81=D0=BA?= =?UTF-8?q?=D0=B2=D0=B0=D0=B6=D0=B8=D0=BD=20=D0=B4=D0=BB=D1=8F=20=D0=BF?= =?UTF-8?q?=D0=B0=D0=BD=D0=B5=D0=BB=D0=B8=20=D0=BD=D0=B0=D0=B2=D0=B8=D0=B3?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D0=B8=20=D1=84=D1=80=D0=BE=D0=BD=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudApp/Data/ClusterDto.cs | 6 ++- AsbCloudApp/Data/DepositDto.cs | 8 ++-- AsbCloudApp/Data/WellDto.cs | 1 - AsbCloudDb/Model/AsbCloudDbContext.cs | 2 +- .../Services/СlusterService.cs | 43 ++++++++++++++----- 5 files changed, 43 insertions(+), 17 deletions(-) diff --git a/AsbCloudApp/Data/ClusterDto.cs b/AsbCloudApp/Data/ClusterDto.cs index 10d92106..2f5c0ee9 100644 --- a/AsbCloudApp/Data/ClusterDto.cs +++ b/AsbCloudApp/Data/ClusterDto.cs @@ -1,4 +1,6 @@ -namespace AsbCloudApp.Data +using System.Collections.Generic; + +namespace AsbCloudApp.Data { public class ClusterDto : IMapPoint { @@ -8,6 +10,6 @@ public double? Latitude { get; set; } public double? Longitude { get; set; } - //public IEnumerable Wells { get; set; } + public IEnumerable Wells { get; set; } } } diff --git a/AsbCloudApp/Data/DepositDto.cs b/AsbCloudApp/Data/DepositDto.cs index 61801a01..108160e5 100644 --- a/AsbCloudApp/Data/DepositDto.cs +++ b/AsbCloudApp/Data/DepositDto.cs @@ -1,13 +1,15 @@ -namespace AsbCloudApp.Data +using System.Collections.Generic; + +namespace AsbCloudApp.Data { public class DepositDto : IMapPoint { public int Id { get; set; } - public string Name { get; set; } + public string Caption { get; set; } public string Description { get; set; } public double? Latitude { get; set; } public double? Longitude { get; set; } - //public IEnumerable Clusters { get; set; } + public IEnumerable Clusters { get; set; } } } diff --git a/AsbCloudApp/Data/WellDto.cs b/AsbCloudApp/Data/WellDto.cs index 1a8621b9..e84f7979 100644 --- a/AsbCloudApp/Data/WellDto.cs +++ b/AsbCloudApp/Data/WellDto.cs @@ -4,7 +4,6 @@ public class WellDto : WellInfoDto, IMapPoint { public int Id { get; set; } - public object LastData { get; set; }//DataSaubBaseDto public double? Latitude { get; set; } public double? Longitude { get; set; } public string WellType { get; set; } diff --git a/AsbCloudDb/Model/AsbCloudDbContext.cs b/AsbCloudDb/Model/AsbCloudDbContext.cs index e8c5e104..f662c054 100644 --- a/AsbCloudDb/Model/AsbCloudDbContext.cs +++ b/AsbCloudDb/Model/AsbCloudDbContext.cs @@ -183,7 +183,7 @@ namespace AsbCloudDb.Model modelBuilder.Entity(entity => { entity.HasData(new List{ - new Company{ Id = 1, Caption = "\"ООО\" АСБ", IdCompanyType = 3}, + new Company{ Id = 1, Caption = "ООО \"АСБ\"", IdCompanyType = 3}, }); }); diff --git a/AsbCloudInfrastructure/Services/СlusterService.cs b/AsbCloudInfrastructure/Services/СlusterService.cs index 81a5f498..2b655865 100644 --- a/AsbCloudInfrastructure/Services/СlusterService.cs +++ b/AsbCloudInfrastructure/Services/СlusterService.cs @@ -18,17 +18,41 @@ namespace AsbCloudInfrastructure.Services public IEnumerable GetDeposits(int idCompany) { - var entities = db.GetWellsForCompany(idCompany) - .Select(e => e.Cluster.Deposit) - .Distinct() - .ToList(); + var wellEntities = (from well in db.Wells + .Include(w => w.RelationCompaniesWells) + .Include(w => w.WellType) + .Include(w=>w.Cluster) + .ThenInclude(c => c.Deposit) + where well.RelationCompaniesWells.Any(r => r.IdCompany == idCompany) + select well).ToList(); - var dtos = entities.Select(e => new DepositDto + var gDepositEntities = wellEntities + .GroupBy(w => w.Cluster) + .GroupBy(c => c.Key.Deposit); + + var dtos = gDepositEntities.Select(gDeposit => new DepositDto { - Id = e.Id, - Name = e.Caption, - Latitude = e.Latitude, - Longitude = e.Longitude, + Id = gDeposit.Key.Id, + Caption = gDeposit.Key.Caption, + Latitude = gDeposit.Key.Latitude, + Longitude = gDeposit.Key.Longitude, + Description = "", + Clusters = gDeposit.Select(gCluster=>new ClusterDto { + Id = gCluster.Key.Id, + Caption = gCluster.Key.Caption, + Latitude = gCluster.Key.Latitude, + Longitude = gCluster.Key.Longitude, + Description = "", + Wells = gCluster.Select(well => new WellDto { + Id = well.Id, + Caption = well.Caption, + Latitude = well.Latitude, + Longitude = well.Longitude, + WellType = well.WellType?.Caption, + Cluster = gCluster.Key.Caption, + Deposit = gDeposit.Key.Caption, + }), + }), }); return dtos; @@ -106,7 +130,6 @@ namespace AsbCloudInfrastructure.Services Longitude = e.Longitude, FactEnd = e.FactEnd, FactStart = e.FactStart, - LastData = null, PlanEnd = e.PlanEnd, PlanStart = e.PlanStart, RateOfPenetrationFact = e.RateOfPenetrationFact,