forked from ddrilling/AsbCloudServer
fix WellService controller
This commit is contained in:
parent
e447473a71
commit
9c5c1fc9c5
@ -3,7 +3,7 @@
|
|||||||
public class ClusterDto : IMapPoint
|
public class ClusterDto : IMapPoint
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string Name { get; set; }
|
public string Caption { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public double? Latitude { get; set; }
|
public double? Latitude { get; set; }
|
||||||
public double? Longitude { get; set; }
|
public double? Longitude { get; set; }
|
||||||
|
13
AsbCloudApp/Data/ClusterStatDto.cs
Normal file
13
AsbCloudApp/Data/ClusterStatDto.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AsbCloudApp.Data
|
||||||
|
{
|
||||||
|
public class ClusterStatDto: ClusterDto
|
||||||
|
{
|
||||||
|
public IEnumerable<WellStatDto> WellsStat { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace AsbCloudApp.Data
|
namespace AsbCloudApp.Data
|
||||||
{
|
{
|
||||||
public class WellDrillingStatDto : WellDto
|
public class WellStatDto : WellDto
|
||||||
{
|
{
|
||||||
public DateTime? PlanStart { get; set; }
|
public DateTime? PlanStart { get; set; }
|
||||||
public DateTime? PlanEnd { get; set; }
|
public DateTime? PlanEnd { get; set; }
|
@ -9,6 +9,6 @@ namespace AsbCloudApp.Services
|
|||||||
IEnumerable<ClusterDto> GetClusters(int idCompany, int depositId);
|
IEnumerable<ClusterDto> GetClusters(int idCompany, int depositId);
|
||||||
IEnumerable<ClusterDto> GetClusters(int idCompany);
|
IEnumerable<ClusterDto> GetClusters(int idCompany);
|
||||||
IEnumerable<WellDto> GetWells(int idCompany, int clusterId);
|
IEnumerable<WellDto> GetWells(int idCompany, int clusterId);
|
||||||
IEnumerable<WellDrillingStatDto> GetStat(int idCompany, int clusterId);
|
ClusterStatDto GetStat(int idCompany, int clusterId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,13 +12,13 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
{
|
{
|
||||||
private readonly IAsbCloudDbContext db;
|
private readonly IAsbCloudDbContext db;
|
||||||
private readonly ITelemetryTracker telemetryTracker;
|
private readonly ITelemetryTracker telemetryTracker;
|
||||||
private readonly CacheTable<Well> cacheWells;
|
private readonly CacheTable<RelationCompanyWell> cacheRelationCompaniesWells;
|
||||||
|
|
||||||
public WellService(IAsbCloudDbContext db, ITelemetryTracker telemetryTracker, CacheDb cacheDb)
|
public WellService(IAsbCloudDbContext db, ITelemetryTracker telemetryTracker, CacheDb cacheDb)
|
||||||
{
|
{
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.telemetryTracker = telemetryTracker;
|
this.telemetryTracker = telemetryTracker;
|
||||||
cacheWells = cacheDb.GetCachedTable<Well>((AsbCloudDbContext)db);
|
cacheRelationCompaniesWells = cacheDb.GetCachedTable<RelationCompanyWell>((AsbCloudDbContext)db);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<WellDto> GetTransmittingWells(int idCompany)
|
public IEnumerable<WellDto> GetTransmittingWells(int idCompany)
|
||||||
@ -40,10 +40,9 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
return wells.Select(w => From(w));
|
return wells.Select(w => From(w));
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CheckWellOwnership(int idCompany, int wellId)
|
public bool CheckWellOwnership(int idCompany, int idWell)
|
||||||
=> cacheWells.Contains(w => w.Id == wellId && w.RelationCompaniesWells.Any(r => r.IdCompany == idCompany));
|
=> cacheRelationCompaniesWells.Contains(r => r.IdWell == idWell && r.IdCompany == idCompany);
|
||||||
|
|
||||||
|
|
||||||
private static WellDto From(Well well)
|
private static WellDto From(Well well)
|
||||||
{
|
{
|
||||||
var wellDto = new WellDto
|
var wellDto = new WellDto
|
||||||
|
@ -44,7 +44,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
var dtos = entities.Select(e => new ClusterDto
|
var dtos = entities.Select(e => new ClusterDto
|
||||||
{
|
{
|
||||||
Id = e.Id,
|
Id = e.Id,
|
||||||
Name = e.Caption,
|
Caption = e.Caption,
|
||||||
Latitude = e.Latitude,
|
Latitude = e.Latitude,
|
||||||
Longitude = e.Longitude,
|
Longitude = e.Longitude,
|
||||||
});
|
});
|
||||||
@ -63,7 +63,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
var dtos = entities.Select(e => new ClusterDto
|
var dtos = entities.Select(e => new ClusterDto
|
||||||
{
|
{
|
||||||
Id = e.Id,
|
Id = e.Id,
|
||||||
Name = e.Caption,
|
Caption = e.Caption,
|
||||||
Latitude = e.Latitude,
|
Latitude = e.Latitude,
|
||||||
Longitude = e.Longitude,
|
Longitude = e.Longitude,
|
||||||
});
|
});
|
||||||
@ -90,13 +90,13 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
return dtos;
|
return dtos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<WellDrillingStatDto> GetStat(int idCompany, int idCluster)
|
public ClusterStatDto GetStat(int idCompany, int idCluster)
|
||||||
{
|
{
|
||||||
var entities = from w in db.Wells
|
var wellEntities = from w in db.Wells
|
||||||
where w.IdCluster == idCluster && w.RelationCompaniesWells.Any(c => c.IdCompany == idCompany)
|
where w.IdCluster == idCluster && w.RelationCompaniesWells.Any(c => c.IdCompany == idCompany)
|
||||||
select w;
|
select w;
|
||||||
|
|
||||||
var dtos = entities.Select(e => new WellDrillingStatDto
|
var wellStatDtos = wellEntities.Select(e => new WellStatDto
|
||||||
{
|
{
|
||||||
Id = e.Id,
|
Id = e.Id,
|
||||||
Caption = e.Caption,
|
Caption = e.Caption,
|
||||||
@ -139,9 +139,21 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
CompanyType = c.Company.CompanyType.Caption,
|
CompanyType = c.Company.CompanyType.Caption,
|
||||||
}),
|
}),
|
||||||
WellType = e.WellType.Caption,
|
WellType = e.WellType.Caption,
|
||||||
});
|
}).ToList();
|
||||||
|
|
||||||
return dtos;
|
if (!wellStatDtos.Any())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var clusterById = db.Clusters.FirstOrDefault(c => c.Id == idCluster);
|
||||||
|
|
||||||
|
return new ClusterStatDto {
|
||||||
|
Id = clusterById.Id,
|
||||||
|
Description = "",
|
||||||
|
Caption = clusterById.Caption,
|
||||||
|
Latitude = clusterById.Latitude,
|
||||||
|
Longitude = clusterById.Longitude,
|
||||||
|
WellsStat = wellStatDtos,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// <param name="idCluster"></param>
|
/// <param name="idCluster"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("{idCluster}/Stat")]
|
[HttpGet("{idCluster}/Stat")]
|
||||||
[ProducesResponseType(typeof(IEnumerable<WellDrillingStatDto>), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(IEnumerable<WellStatDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public IActionResult GetStat(int idCluster)
|
public IActionResult GetStat(int idCluster)
|
||||||
{
|
{
|
||||||
int? idCompany = User.GetCompanyId();
|
int? idCompany = User.GetCompanyId();
|
||||||
|
@ -14,7 +14,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[Authorize]
|
[Authorize]
|
||||||
public class DepositController : ControllerBase
|
public class DepositController : ControllerBase
|
||||||
{
|
{
|
||||||
IClusterService clusterService;
|
private readonly IClusterService clusterService;
|
||||||
|
|
||||||
public DepositController(IClusterService clusterService)
|
public DepositController(IClusterService clusterService)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user