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, diff --git a/AsbCloudWebApi/Controllers/ClusterController.cs b/AsbCloudWebApi/Controllers/ClusterController.cs index 09c5a5d6..528a55f2 100644 --- a/AsbCloudWebApi/Controllers/ClusterController.cs +++ b/AsbCloudWebApi/Controllers/ClusterController.cs @@ -62,7 +62,7 @@ namespace AsbCloudWebApi.Controllers /// /// [HttpGet("{idCluster}/Stat")] - [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] + [ProducesResponseType(typeof(ClusterStatDto), (int)System.Net.HttpStatusCode.OK)] public IActionResult GetStat(int idCluster) { int? idCompany = User.GetCompanyId();