forked from ddrilling/AsbCloudServer
АПД разбивается на ротор и слайд
This commit is contained in:
parent
23fd77eb9d
commit
e28ec2cd0a
@ -24,6 +24,8 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
||||
private const int idSubsytemTorqueMaster = 65537;
|
||||
private const int idSubsytemSpinMaster = 65536;
|
||||
private const int idSubsytemAkb = 1;
|
||||
private const int idSubsytemAkbRototor = 11;
|
||||
private const int idSubsytemAkbSlide = 12;
|
||||
private const int idSubsytemMse = 2;
|
||||
|
||||
public static WorkPeriodic MakeWork()
|
||||
@ -101,11 +103,20 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
||||
|
||||
private static async Task<IEnumerable<SubsystemOperationTime>> OperationTimeSaubAsync(int idTelemetry, DateTimeOffset begin, IAsbCloudDbContext db, CancellationToken token)
|
||||
{
|
||||
static bool isSubsytemAkb(short? mode)
|
||||
static bool isSubsytemAkbRotor(short? mode)
|
||||
{
|
||||
if (mode is null)
|
||||
return false;
|
||||
if (mode == 1 | mode == 3)
|
||||
if (mode == 1)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool isSubsytemAkbSlide(short? mode)
|
||||
{
|
||||
if (mode is null)
|
||||
return false;
|
||||
if (mode == 3)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@ -139,7 +150,8 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
||||
|
||||
var subsystemsOperationTimes = new List<SubsystemOperationTime>();
|
||||
|
||||
(bool isEnable, DateTimeOffset date, float depth) akbPre = default;
|
||||
(bool isEnable, DateTimeOffset date, float depth) akbPreRotor = default;
|
||||
(bool isEnable, DateTimeOffset date, float depth) akbPreSlide = default;
|
||||
(bool isEnable, DateTimeOffset date, float depth) msePre = default;
|
||||
|
||||
while (result.Read())
|
||||
@ -147,29 +159,50 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
||||
var mode = result.GetFieldValue<short?>(1);
|
||||
var state = result.GetFieldValue<short?>(3);
|
||||
|
||||
var isAkbEnable = isSubsytemAkb(mode);
|
||||
var isAkbRotorEnable = isSubsytemAkbRotor(mode);
|
||||
var isAkbSlideEnable = isSubsytemAkbSlide(mode);
|
||||
var isMseEnable = IsSubsystemMse(state);
|
||||
var date = result.GetFieldValue<DateTimeOffset>(0);
|
||||
var depth = result.GetFieldValue<float>(2);
|
||||
|
||||
if (!akbPre.isEnable && isAkbEnable)
|
||||
if (!akbPreRotor.isEnable && isAkbRotorEnable)
|
||||
{
|
||||
akbPre = (true, date, depth);
|
||||
akbPreRotor = (true, date, depth);
|
||||
}
|
||||
else if (akbPre.isEnable && !isAkbEnable)
|
||||
else if (akbPreRotor.isEnable && !isAkbRotorEnable)
|
||||
{
|
||||
var subsystemOperationTime = new SubsystemOperationTime
|
||||
{
|
||||
IdTelemetry = idTelemetry,
|
||||
IdSubsystem = idSubsytemAkb,
|
||||
DateStart = akbPre.date,
|
||||
IdSubsystem = idSubsytemAkbRototor,
|
||||
DateStart = akbPreRotor.date,
|
||||
DateEnd = date,
|
||||
DepthStart = akbPre.depth,
|
||||
DepthStart = akbPreRotor.depth,
|
||||
DepthEnd = depth,
|
||||
};
|
||||
if (IsValid(subsystemOperationTime))
|
||||
subsystemsOperationTimes.Add(subsystemOperationTime);
|
||||
akbPre.isEnable = false;
|
||||
akbPreRotor.isEnable = false;
|
||||
}
|
||||
|
||||
if (!akbPreSlide.isEnable && isAkbSlideEnable)
|
||||
{
|
||||
akbPreSlide = (true, date, depth);
|
||||
}
|
||||
else if (akbPreSlide.isEnable && !isAkbSlideEnable)
|
||||
{
|
||||
var subsystemOperationTime = new SubsystemOperationTime
|
||||
{
|
||||
IdTelemetry = idTelemetry,
|
||||
IdSubsystem = idSubsytemAkbSlide,
|
||||
DateStart = akbPreSlide.date,
|
||||
DateEnd = date,
|
||||
DepthStart = akbPreSlide.depth,
|
||||
DepthEnd = depth,
|
||||
};
|
||||
if (IsValid(subsystemOperationTime))
|
||||
subsystemsOperationTimes.Add(subsystemOperationTime);
|
||||
akbPreSlide.isEnable = false;
|
||||
}
|
||||
|
||||
if (!msePre.isEnable && isMseEnable)
|
||||
@ -182,9 +215,9 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
||||
{
|
||||
IdTelemetry = idTelemetry,
|
||||
IdSubsystem = idSubsytemMse,
|
||||
DateStart = akbPre.date,
|
||||
DateStart = akbPreRotor.date < akbPreSlide.date ? akbPreRotor.date : akbPreSlide.date,
|
||||
DateEnd = date,
|
||||
DepthStart = akbPre.depth,
|
||||
DepthStart = akbPreRotor.depth < akbPreSlide.depth ? akbPreRotor.depth : akbPreSlide.depth,
|
||||
DepthEnd = depth,
|
||||
};
|
||||
if (IsValid(subsystemOperationTime))
|
||||
@ -197,6 +230,7 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
||||
return subsystemsOperationTimes;
|
||||
}
|
||||
|
||||
|
||||
private static async Task<IEnumerable<SubsystemOperationTime>> OperationTimeSpinAsync(int idTelemetry, DateTimeOffset begin, IAsbCloudDbContext db, CancellationToken token)
|
||||
{
|
||||
static int? GetSubsytemId(short? mode, int? state)
|
||||
|
@ -146,6 +146,7 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
||||
private IEnumerable<SubsystemStatDto> CalcStat(IEnumerable<SubsystemOperationTimeDto> dtos, (double depthIntervalRotor, double depthIntervalSlide) depthInterval)
|
||||
{
|
||||
var groupedDataSubsystems = dtos
|
||||
.OrderBy(o => o.Id)
|
||||
.GroupBy(o => o.IdSubsystem);
|
||||
var periodGroupTotal = dtos.Sum(o => (o.DateEnd - o.DateStart).TotalHours);
|
||||
|
||||
@ -168,6 +169,21 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
||||
return subsystemStat;
|
||||
});
|
||||
|
||||
var apdParts = result.Where(x => x.IdSubsystem == 11 || x.IdSubsystem == 12);
|
||||
if (apdParts.Any())
|
||||
{
|
||||
var apdSum = new SubsystemStatDto()
|
||||
{
|
||||
IdSubsystem = 1,
|
||||
SubsystemName = "АПД",
|
||||
UsedTimeHours = apdParts.Sum(part => part.UsedTimeHours),
|
||||
KUsage = apdParts.Sum(part => part.KUsage) / apdParts.Count(),
|
||||
SumDepthInterval = apdParts.Sum(part => part.SumDepthInterval),
|
||||
OperationCount = apdParts.Sum(part => part.OperationCount),
|
||||
};
|
||||
result = result.Append(apdSum).OrderBy(m => m.IdSubsystem);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
private static (double depthIntervalRotor, double depthIntervalSlide) GetDepthInterval (IEnumerable<DetectedOperationDto> detectedOperations)
|
||||
@ -348,8 +364,8 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
||||
|
||||
if (request?.Take > 0)
|
||||
query = query.Take((int)request.Take);
|
||||
else
|
||||
query = query.Take(3000);
|
||||
//else
|
||||
//query = query.Take(3000);
|
||||
|
||||
return query;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user