Aggiunta metodo pareto durata (da validare)
This commit is contained in:
@@ -261,32 +261,34 @@ namespace MP.MONO.Data.Controllers
|
||||
/// <summary>
|
||||
/// Recupero lista sommatoria durata eventi allarme per analisi, ordinati in logica di pareto (Max-min)
|
||||
/// </summary>
|
||||
/// <param name="MachineId">Id Macchina</param>
|
||||
/// <param name="machineId">Id Macchina</param>
|
||||
/// <param name="dtFrom">inizio analisi (evento deve iniziare/finire entro periodo)</param>
|
||||
/// <param name="dtTo">fine analisi (evento deve iniziare/finire entro periodo)</param>
|
||||
/// <param name="minDur">durata minima evento per venire considerato, -1 = tutti</param>
|
||||
/// <param name="maxDur">durata massima evento per venire considerato, -1 = tutti</param>
|
||||
/// <returns></returns>
|
||||
public List<AlarmDurationDTO> AlarmRecGetParetoDur(int MachineId, DateTime dtFrom, DateTime dtTo, int minDur = -1, int maxDur = -1)
|
||||
public List<AlarmDurationDTO> AlarmRecGetParetoDur(int machineId, DateTime dtFrom, DateTime dtTo, int minDur = -1, int maxDur = -1)
|
||||
{
|
||||
List<AlarmDurationDTO> dbResult = new List<AlarmDurationDTO>();
|
||||
using (MapoMonoContext localDbCtx = new MapoMonoContext())
|
||||
{
|
||||
try
|
||||
{
|
||||
//dbResult = localDbCtx
|
||||
// .DbSetAlarmRec
|
||||
// .Where(x => x.MachineId == MachineId)
|
||||
// .Include(m => m.MachineNav)
|
||||
// .Include(m => m.AlarmListNav)
|
||||
// .OrderByDescending(x => x.DtStart)
|
||||
// .Skip(skipRec)
|
||||
// .Take(numRec)
|
||||
// .ToList();
|
||||
dbResult = localDbCtx
|
||||
.DbSetAlarmRec
|
||||
.Where(x => x.MachineId == machineId
|
||||
&& (x.DtStart >= dtFrom && x.DtStart <= dtTo)
|
||||
&& (x.Duration >= minDur || minDur < 0)
|
||||
&& (x.Duration <= maxDur || maxDur < 0))
|
||||
.GroupBy(g => g.AlarmId)
|
||||
.Select(g => new AlarmDurationDTO() { MachineId = machineId, AlarmId = g.Key, Duration = g.Sum(x => x.Duration) })
|
||||
.Include(m => m.MachineNav)
|
||||
.Include(m => m.AlarmListNav)
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante AlarmRecGetParetoFreq{Environment.NewLine}{exc}");
|
||||
Log.Error($"Eccezione durante AlarmRecGetParetoDur{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
|
||||
Reference in New Issue
Block a user