private BatchIssue CheckWeighTimeAgainstLastMaterialInParallelWeighGroup(BatchReport report, Material material, MaterialDetails materialInfo) { BatchIssue issue = null; Material lastMaterialInGroup = GetSingleMaterialFromVessel(report, GetLastMaterialNameFromGroup(materialInfo.ParallelWeighGroup)); double timeLost = GetTimeLost(report, material, materialInfo.AvgWeighTime); if (timeLost > WeighTimeLossThreshold && lastMaterialInGroup != null) { issue = new BatchIssue() { FaultType = BatchIssue.FaultTypes.WeighTime, MaterialName = material.Name, MaterialShortName = _materialDetailsRepository.GetSingleMaterial(material.Name).ShortName ?? material.Name, TimeLost = timeLost, WeightDiffference = 0, Message = $"{material.Name} took {material.WeighTime} minutes to weigh. " + $"However it weighs in parallel with other materials. The last material " + $"to weigh in the group is {lastMaterialInGroup.Name} which did not weigh " + $"until {lastMaterialInGroup.StartTime.ToShortTimeString()} meaning the time lost was {timeLost} minutes.", IssueCreatedBy = IssueDescriptor }; } return(issue); }
private void ScanForGapsInMaterials(BatchReport report) { Vessel mainMixer = report.AllVessels.Where(x => x.VesselType == Vessel.VesselTypes.MainMixer).FirstOrDefault(); if (mainMixer != null) { List <Material> materials = mainMixer.Materials.OrderBy(x => x.StartTime).ToList(); for (int i = 1; i < materials.Count; i++) { double timeDifference = GetDifferenceInTime(materials[i], materials[i - 1]); if (timeDifference != 0 && timeDifference > GapInMaterialTimeThreshold) { if (!CheckIfWaitIssueAlreadyExists(report, materials[i - 1].Name, materials[i].Name)) { BatchIssue issue = new BatchIssue() { FaultType = BatchIssue.FaultTypes.WeighTime, MaterialName = materials[i].Name + " & " + materials[i - 1].Name, IssueCreatedBy = IssueDescriptor, TimeLost = Math.Round(timeDifference, 2), Message = GetMessageForIssue(materials[i - 1].Name, materials[i].Name) + " Time lost : " + timeDifference + " minutes." }; report.BatchIssues.Add(issue); } } } } }
private void CheckTargetVsActualWeights(BatchReport report) { foreach (Material material in GetAllMaterialsUsedInBatch(report)) { if (MaterialNamesIncludedInMatVar.Contains(material.Name)) { double difference = Math.Round(material.TargetWeight - material.ActualWeight, 2); double percentage = Math.Round(100 - ((material.ActualWeight / material.TargetWeight) * 100), 2); if (Math.Abs(percentage) >= 5) { BatchIssue issue = new BatchIssue() { MaterialName = material.Name, MaterialShortName = _MaterialDetailsrepository.GetSingleMaterial(material.Name).ShortName ?? material.Name, FaultType = BatchIssue.FaultTypes.Overweigh, TimeLost = 0, PercentOut = percentage, WeightDiffference = difference, Message = $"{material.Name} {GetUnderOverMessage(difference)} by {difference} kg", IssueCreatedBy = IssueDescriptor }; report.BatchIssues.Add(issue); } } } }
private void CheckMainMixerWeighTimes(BatchReport report, Material material) { var materialInfo = materialDetails.Find(x => x.Name.ToLower().Replace(" ", "") == material.Name.ToLower().Replace(" ", "")); BatchIssue weighIssue = null; if (materialInfo != null) { if (materialInfo.ParallelWeighGroup >= 1) { weighIssue = CheckWeighTimeAgainstLastMaterialInParallelWeighGroup(report, material, materialInfo); } else { weighIssue = CheckWeighTimeAgainstAverageTime(report, material, materialInfo); } } if (weighIssue != null) { report.BatchIssues.Add(weighIssue); } }
private void CheckIfPefumeWeighIssueNeedsRemoving(BatchReport report) { Material perfume = GetSingleMaterialFromVessel(report, Vessel.VesselTypes.PerfumePreWeigher, 0); BatchIssue perfumeIssue = report.BatchIssues .Where(x => x.MaterialName == perfume.Name && x.FaultType == BatchIssue.FaultTypes.WeighTime) .FirstOrDefault(); if (perfumeIssue != null) { DateTime batchReadyForPerfumeTime = GetTimeBatchWasReadyForPreweigher(report, Vessel.VesselTypes.PerfumePreWeigher); if (perfume.StartTime.AddMinutes(perfume.WeighTime) < batchReadyForPerfumeTime) { perfumeIssue.RemoveIssue = true; perfumeIssue.IssueRemovedBy = IssueDescriptor; perfumeIssue.ReasonRemoved = $"Although {perfume.Name} took {perfume.WeighTime} minutes" + $"to weigh the batch did require the perfume until after that. " + $"So no time was lost."; } } }
private void CheckActivePrewigherWeighTimes(BatchReport report, Material material) { Material activeMaterial = GetSingleMaterialFromVessel(report, Vessel.VesselTypes.ActivePreWeigher, material.Name); DateTime batchReadyForPerfumeTime = GetTimeBatchWasReadyForPreweigher(report, Vessel.VesselTypes.ActivePreWeigher); if (activeMaterial.StartTime.AddMinutes(activeMaterial.WeighTime) > batchReadyForPerfumeTime) { double timeLost = activeMaterial.StartTime.AddMinutes(activeMaterial.WeighTime).Subtract(batchReadyForPerfumeTime).TotalMinutes; BatchIssue issue = new BatchIssue() { MaterialName = activeMaterial.Name, MaterialShortName = _materialDetailsRepository.GetSingleMaterial(material.Name).ShortName ?? material.Name, IssueCreatedBy = IssueDescriptor, FaultType = BatchIssue.FaultTypes.WeighTime, Message = $"{activeMaterial.Name} took {activeMaterial.WeighTime} minute to weigh but the mixer " + $"did not need it until {batchReadyForPerfumeTime.ToShortTimeString() } so only {timeLost} " + $"minutes where lost.", TimeLost = timeLost }; } }
private BatchIssue CheckWeighTimeAgainstAverageTime(BatchReport report, Material material, MaterialDetails materialInfo) { BatchIssue issue = null; if (material.WeighTime > materialInfo.AvgWeighTime) { double timeLost = GetTimeLost(report, material, materialInfo.AvgWeighTime); issue = new BatchIssue() { FaultType = BatchIssue.FaultTypes.WeighTime, MaterialShortName = _materialDetailsRepository.GetSingleMaterial(material.Name).ShortName ?? material.Name, MaterialName = material.Name, TimeLost = timeLost, WeightDiffference = 0, Message = $"{material.Name} took {material.WeighTime} minutes to weigh. " + $"The average weigh time is {materialInfo.AvgWeighTime} minutes giving " + $"a loss of {timeLost} minutes", IssueCreatedBy = IssueDescriptor }; } return(issue); }
private void CheckWaitTimes(BatchReport report) { foreach (var vessel in report.AllVessels) { foreach (var material in vessel.Materials) { if (material.WaitTime > waitTimeLimit) { BatchIssue issue = new BatchIssue { FaultType = BatchIssue.FaultTypes.WaitTime, MaterialName = material.Name, MaterialShortName = _materialDetailsRepository.GetSingleMaterial(material.Name).ShortName ?? material.Name, TimeLost = Math.Round(material.WaitTime, 2), WeightDiffference = 0, Message = $"The batch had to wait { material.WaitTime } minutes for { material.Name }. " + $"This is usually because it is being used by another stream.", IssueCreatedBy = IssueDescriptor }; report.BatchIssues.Add(issue); } } } }