forked from ddrilling/AsbCloudServer
Рефактор
This commit is contained in:
parent
f8496a5034
commit
08b6f7d209
@ -111,30 +111,31 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
||||
|
||||
private static IEnumerable<SubsystemOperationTime> TrimOperation(IEnumerable<SubsystemOperationTime> data, DateTimeOffset? gtDate, DateTimeOffset? ltDate)
|
||||
{
|
||||
if (!ltDate.HasValue && !gtDate.HasValue) return data;
|
||||
if (!ltDate.HasValue && !gtDate.HasValue)
|
||||
return data.Select(d => d.Adapt<SubsystemOperationTime>());
|
||||
|
||||
var items = data.Select((item) =>
|
||||
{
|
||||
var dateDiff = (ltDate!.Value - gtDate!.Value).TotalSeconds;
|
||||
var depthDiff = (item.DepthEnd ?? 0) - (item.DepthStart ?? 0);
|
||||
var a = depthDiff / (float)dateDiff;
|
||||
var x = (float)(item.DateStart - gtDate.Value).TotalSeconds;
|
||||
var b = item.DepthStart;
|
||||
var cutDepth = a * x + b;
|
||||
|
||||
var operationTime = item.Adapt<SubsystemOperationTime>();
|
||||
if (!(item.DepthStart.HasValue && item.DepthEnd.HasValue))
|
||||
return operationTime;
|
||||
|
||||
var dateDiff = (item.DateEnd - item.DateStart).TotalSeconds;
|
||||
var depthDiff = item.DepthEnd.Value - item.DepthStart.Value;
|
||||
var a = depthDiff / dateDiff;
|
||||
var b = item.DepthStart.Value;
|
||||
|
||||
if (gtDate.HasValue && item.DateStart < gtDate.Value)
|
||||
{
|
||||
operationTime.DateStart = gtDate.Value;
|
||||
operationTime.DepthStart = cutDepth;
|
||||
var x = (gtDate.Value - item.DateStart).TotalSeconds;
|
||||
operationTime.DepthStart = (float)(a * x + b);
|
||||
}
|
||||
if (ltDate.HasValue && item.DateEnd > ltDate.Value)
|
||||
{
|
||||
operationTime.DateEnd = ltDate.Value;
|
||||
operationTime.DepthEnd = cutDepth;
|
||||
|
||||
var test = data;
|
||||
var x = (ltDate.Value - item.DateStart).TotalSeconds;
|
||||
operationTime.DepthEnd = (float)(a * x + b);
|
||||
}
|
||||
return operationTime;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user