This commit is contained in:
KharchenkoVV 2021-07-22 15:22:50 +05:00
commit 2d2a7d744e
6 changed files with 44 additions and 18 deletions

View File

@ -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<WellDto> Wells { get; set; }
public IEnumerable<WellDto> Wells { get; set; }
}
}

View File

@ -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<ClusterDto> Clusters { get; set; }
public IEnumerable<ClusterDto> Clusters { get; set; }
}
}

View File

@ -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; }

View File

@ -183,7 +183,7 @@ namespace AsbCloudDb.Model
modelBuilder.Entity<Company>(entity =>
{
entity.HasData(new List<Company>{
new Company{ Id = 1, Caption = "\"ООО\" АСБ", IdCompanyType = 3},
new Company{ Id = 1, Caption = "ООО \"АСБ\"", IdCompanyType = 3},
});
});

View File

@ -18,17 +18,41 @@ namespace AsbCloudInfrastructure.Services
public IEnumerable<DepositDto> 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,

View File

@ -62,7 +62,7 @@ namespace AsbCloudWebApi.Controllers
/// <param name="idCluster"></param>
/// <returns></returns>
[HttpGet("{idCluster}/Stat")]
[ProducesResponseType(typeof(IEnumerable<WellStatDto>), (int)System.Net.HttpStatusCode.OK)]
[ProducesResponseType(typeof(ClusterStatDto), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetStat(int idCluster)
{
int? idCompany = User.GetCompanyId();