public override void ScanForIssues(BatchReport report)
 {
     CheckWeighTimeOfMaterials(report);
     RemoveIssuesWithTimeLossLessThanThreshold(report);
     CheckIfPefumeWeighIssueNeedsRemoving(report);
     SetIssueScannedFor(report);
 }
Пример #2
0
        public static Material GetSingleMaterialFromVessel(BatchReport report, VesselTypes vesselType, string materialName)
        {
            Vessel tempVessel;

            try
            {
                tempVessel = report.AllVessels.Find((x) => x.VesselType == vesselType);
            }
            catch
            {
                return(null);
            }

            try
            {
                foreach (var material in tempVessel.Materials)
                {
                    if (material.Name == materialName)
                    {
                        return(material);
                    }
                }
            }
            catch
            {
                Console.WriteLine();
            }

            return(null);
        }
Пример #3
0
        public override void ScanForIssues(BatchReport report)
        {
            var tempSensitiveMaterials = _materialDetailsRepository.GetAllMaterialDetails()
                                         .Where(x => x.MinRawTemp > 0 || x.MaxRawTemp > 0)
                                         .ToList();

            foreach (var material in tempSensitiveMaterials)
            {
                var materialFromBatch = BatchHelperMethods.GetSingleMaterialFromVessel(report, material.Name);
                if (materialFromBatch != null)
                {
                    bool overTemp  = materialFromBatch.RawMatTemp > material.MaxRawTemp;
                    bool underTemp = materialFromBatch.RawMatTemp < material.MinRawTemp;

                    if (overTemp || underTemp)
                    {
                        report.BatchIssues.Add(new BatchIssue
                        {
                            FaultType         = overTemp ? BatchIssue.FaultTypes.TemperatureHigh : BatchIssue.FaultTypes.TemperatureLow,
                            Message           = $"{material.Name} temperature in storage was {UnderOverText(overTemp)} of {GetMaxMinTemp(overTemp, material)}C",
                            MaterialName      = material.Name,
                            MaterialShortName = material.ShortName,
                            TimeLost          = 0,
                            ActualReading     = materialFromBatch.RawMatTemp,
                            IssueCreatedBy    = IssueDescriptor
                        });
                    }
                }
            }

            SetIssueScannedFor(report);
        }
        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);
        }
        public Material FindReworkInBatch(BatchReport report)
        {
            Vessel   vessel = report.AllVessels.Where(x => x.VesselType == VesselTypes.MainMixer).First();
            Material output = vessel.Materials.Where(x => x.Name == "Material 94" || x.Name == "Material 3").FirstOrDefault();

            return(output);
        }
 private void GetMaterialDataDump(List <string> lineInfo, Vessel vessel, BatchReport report)
 {
     try
     {
         Material material = new Material()
         {
             Name          = lineInfo[0] + " " + lineInfo[1],
             TargetWeight  = Convert.ToDouble(lineInfo[2]),
             ActualWeight  = Convert.ToDouble(lineInfo[3]),
             StartTime     = HelperMethods.AdjustDateIfTimePassesIntoNextDay(report.StartTime.ToShortDateString(), lineInfo[4], report.StartTime),
             WaitTime      = -1,
             WeighTime     = -1,
             VesselBefore  = -1,
             WeightAfter   = -1,
             VesselTemp    = -1,
             AgitatorSpeed = -1,
             RawMatTemp    = -1
         };
         vessel.Materials.Add(material);
         _materialsFound.AddNewMaterial(material.Name);
     }
     catch (Exception ex)
     {
         string message = "Dump data for " + lineInfo[0] + " " + lineInfo[1] + " could not be converted due to incorrect format.";
         RecordFault(report, message, ex.Message);
     }
 }
Пример #7
0
 private void SortMaterialsByStartTimes(BatchReport report)
 {
     foreach (var vessel in report.AllVessels)
     {
         vessel.Materials = vessel.Materials.OrderBy(m => m.StartTime).ToList();
     }
 }
        private void GetEmptyVxxxIncreaseInfo(BatchReport report, Vessel tempVessel, List <string> lineInfo)
        {
            try
            {
                Material material = new Material()
                {
                    Name          = lineInfo[0] + " " + lineInfo[1],
                    ActualWeight  = Convert.ToDouble(lineInfo[4]),
                    WaitTime      = Convert.ToDouble(lineInfo[5]),
                    WeighTime     = Convert.ToDouble(lineInfo[6]),
                    VesselTemp    = Convert.ToDouble(lineInfo[7]),
                    AgitatorSpeed = Convert.ToDouble(lineInfo[8]),
                };

                Material temp = tempVessel.getSingleMaterialFromList(tempVessel.Materials.Count - 1);
                material.StartTime = temp.StartTime.AddMinutes(5);
                tempVessel.Materials.Add(material);
                //BatchReport.CheckIfCurrentMaterialIsNew(material.Name);
            }
            catch (Exception ex)
            {
                string message = "An error occured when converting " + lineInfo[0] + " " + lineInfo[1] + ".";
                RecordFault(report, message, ex.Message);
            }
        }
Пример #9
0
        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 GetMillingTimeInfo(BatchReport report, Vessel tempVessel, List <string> lineInfo)
        {
            string date = report.StartTime.ToShortDateString();
            string time = lineInfo[3];

            if (time.EndsWith("."))
            {
                time = time.Substring(0, time.Length - 1);
            }

            try
            {
                Material material = new Material()
                {
                    Name = lineInfo[0],
                    MillingFinishTime = HelperMethods.AdjustDateIfTimePassesIntoNextDay(date, time, report.StartTime),
                    StartTime         = HelperMethods.AdjustDateIfTimePassesIntoNextDay(date, time, report.StartTime),
                    MillingRunTime    = Convert.ToDouble(lineInfo[6]),
                };
                tempVessel.Materials.Add(material);
            }
            catch (Exception ex)
            {
                string message = "An error occured when trying to convert " + lineInfo[0] + " time.";
                RecordFault(report, message, ex.Message);
            }
        }
Пример #11
0
        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 double GetTimeLost(BatchReport report, Material material, double avgWeighTime)
        {
            int currentMaterialGroup = GetCurrentMaterialWeighGroup(material.Name);

            if (report.Campaign == 737)
            {
                Console.WriteLine();
            }
            if (currentMaterialGroup != 0)
            {
                Material lastMaterialInGroup = GetLastMaterialFromGroupInBatch(report, currentMaterialGroup);
                if (lastMaterialInGroup.Name == material.Name)
                {
                    return(material.WeighTime - avgWeighTime);
                }


                if (material.StartTime.AddMinutes(material.WeighTime) > lastMaterialInGroup.StartTime)
                {
                    TimeSpan span = material.StartTime.AddMinutes(material.WeighTime).Subtract(lastMaterialInGroup.StartTime);
                    return(Math.Round(span.TotalMinutes, 2));
                }
                else
                {
                    return(0);
                }
            }
            return(Math.Round(material.WeighTime - avgWeighTime, 2));
        }
        public void ScanForIssues(BatchReport report)
        {
            foreach (var scanner in issueScanners)
            {
                if (report.BatchIssues.Exists(x => x.IssueCreatedBy == scanner.Descriptor()))
                {
                    continue;
                }
                switch (scanner.GetScanType())
                {
                case IssueScannerBase.ScanTypes.Quality:

                case IssueScannerBase.ScanTypes.Adjustment:

                case IssueScannerBase.ScanTypes.MatVar:
                    scanner.ScanForIssues(report);
                    break;

                case IssueScannerBase.ScanTypes.Issue:
                    if (report.MakingTime > 65 && report.NewMakeTime > 65)
                    {
                        if (!report.IssuesScannedFor.Exists((x) => x.IssueClassName == scanner.GetType().Name))
                        {
                            scanner.ScanForIssues(report);
                            SetNewMakeTime(report);
                        }
                    }
                    break;
                }
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("BatchReportId,OriginalReport,StreamName,Recipe,Campaign,BatchNo,WeekNo,StartTime,MakingTime,QATime,PreQaTemp,Visco,Ph,SG,Appearance,VisualColour,MeasuredColour,Odour,OverallQAStatus,StockTankAllocationTime,AllocatedTo,DropTime,TotalRecipeWeight,TotalActualWeight,VesselWeightIncrease,RecipeType,NewMakeTime")] BatchReport batchReport)
        {
            if (id != batchReport.BatchReportId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(batchReport);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BatchReportExists(batchReport.BatchReportId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(batchReport));
        }
Пример #15
0
 public BatchReport AddBatchToDb(BatchReport report)
 {
     //bool batchExists = await _batchRepository.BatchExists(report.Campaign, report.BatchNo, report.StartTime);
     _batchRepository.Add(report);
     _batchRepository.SaveChanges();
     //int id = report.BatchReportId;
     return(report);
 }
 internal void SetIssueScannedFor(BatchReport report)
 {
     report.IssuesScannedFor.Add(new IssuesScannedFor()
     {
         IssueName      = IssueDescriptor,
         IssueClassName = this.GetType().Name
     });
 }
Пример #17
0
        private void AdjustPerfumeStartTime(BatchReport report)
        {
            // The Perfume start time is wrong, the start time is actually the time it finished
            // This function alters the start times to make them correct

            Material perfume = GetSingleMaterialFromVessel(report, VesselTypes.PerfumePreWeigher, 0);

            perfume.StartTime = perfume.StartTime.AddMinutes(-perfume.WeighTime);
        }
Пример #18
0
 private List <Batch> ProcessSelectedBatchReportFile(string path)
 {
     if (File.Exists(path))
     {
         var batchReportContents = new BatchReport(path);
         return(batchReportContents.Scan());
     }
     MessageBox.Show("Whoops! We can't find a file located at '" + path + "'");
     return(new List <Batch>());
 }
        public async Task <IActionResult> Create([Bind("BatchReportId,OriginalReport,StreamName,Recipe,Campaign,BatchNo,WeekNo,StartTime,MakingTime,QATime,PreQaTemp,Visco,Ph,SG,Appearance,VisualColour,MeasuredColour,Odour,OverallQAStatus,StockTankAllocationTime,AllocatedTo,DropTime,TotalRecipeWeight,TotalActualWeight,VesselWeightIncrease,RecipeType,NewMakeTime")] BatchReport batchReport)
        {
            if (ModelState.IsValid)
            {
                _context.Add(batchReport);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(batchReport));
        }
Пример #20
0
        private List <Material> GetAllMaterialsUsedInBatch(BatchReport report)
        {
            List <Material> allMaterials = new List <Material>();

            foreach (var vessel in report.AllVessels)
            {
                allMaterials.AddRange(vessel.Materials);
            }

            return(allMaterials);
        }
Пример #21
0
        private void AdjustWaterStartTimes(BatchReport report)
        {
            // COLD & HOT Water start times are wrong, the start time is actually the time it finished
            // This function alters the start times to make them correct

            Material hotWater  = GetSingleMaterialFromVessel(report, VesselTypes.MainMixer, "HOT WTR");
            Material coldWater = GetSingleMaterialFromVessel(report, VesselTypes.MainMixer, "COLD WTR");

            hotWater.StartTime  = hotWater.StartTime.AddMinutes(-hotWater.WeighTime);
            coldWater.StartTime = coldWater.StartTime.AddMinutes(-coldWater.WeighTime);
        }
 private void RemoveIssuesWithTimeLossLessThanThreshold(BatchReport report)
 {
     foreach (var issue in report.BatchIssues)
     {
         if (issue.IssueCreatedBy == IssueDescriptor && issue.TimeLost < WeighTimeLossThreshold)
         {
             issue.RemoveIssue    = true;
             issue.ReasonRemoved  = $"Time lost weighing {issue.MaterialName} is below the threshold of " + WeighTimeLossThreshold + " Minutes";
             issue.IssueRemovedBy = IssueDescriptor;
         }
     }
 }
Пример #23
0
        private void batchReportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form c in this.MdiChildren)
            {
                c.Close();
            }
            BatchReport brt = new BatchReport();

            brt.MdiParent = this;
            brt.Show();
            groupBox1.Hide();
        }
 public override void ScanForIssues(BatchReport report)
 {
     report.BatchIssues.Add(new BatchIssue
     {
         FaultType      = BatchIssue.FaultTypes.Quality,
         Message        = "Test Fault",
         MaterialName   = "Puresse",
         TimeLost       = 0,
         IssueCreatedBy = IssueDescriptor
     });
     SetIssueScannedFor(report);
 }
 private void GetDumpToVxxxInfo(BatchReport report, Vessel tempVessel, List <string> lineInfo)
 {
     try
     {
         tempVessel.DumpTime = Convert.ToDouble(lineInfo[7]);
         tempVessel.Decrease = Convert.ToDouble(lineInfo[4]);
     }
     catch (Exception ex)
     {
         string message = "An error occured when trying to convert vessel " + tempVessel.VesselName + " dump time.";
         RecordFault(report, message, ex.Message);
     }
 }
 private void AddBatchAdjustment(BatchReport report, string message)
 {
     report.IsBatchAdjusted = true;
     report.BatchIssues.Add(new BatchIssue
     {
         FaultType         = BatchIssue.FaultTypes.BatchAdjusted,
         Message           = message,
         TimeLost          = 0,
         WeightDiffference = 0,
         IssueCreatedBy    = "BatchDataFileManager - Function CreateWaterIfMissing",
         MaterialName      = "WaterMissing",
     });
 }
Пример #27
0
        public ActionResult <BatchReport> AddBatchToDatabase([FromBody] BatchReport batch)
        {
            var request = Request;
            var headers = request.Headers;

            var isSync = Convert.ToBoolean(headers["Sync"]);

            if (batch == null)
            {
                return(NotFound());
            }

            if (headers.ContainsKey("Authorization"))
            {
                // The authorization key will be the computers MAC address when software goes live
                // it was set to this for testing purposes

                if (headers["Authorization"] == "Auth 123456")
                {
                    if (batch.IsValidBatch)
                    {
                        issueScannerManager.ScanForIssues(batch);
                        var batchReport = _apiBatchRepository.AddBatchToDb(batch);

                        if (!isSync)
                        {
                            var batchJson = JsonConvert.SerializeObject(batchReport);
                            batchJson = AddAdditionalInfoToJson(batchJson, batch, isSync);
                            var batchesMadeJson = JsonConvert.SerializeObject(BatchesMadePerWeekByCategory());
                            _hubContext.Clients.All.SendAsync("LastBatch", batchJson);
                            _hubContext.Clients.All.SendAsync("BatchesMadeByCategory", batchesMadeJson);
                        }
                    }
                    else
                    {
                        return(BadRequest());
                    }
                }
                else
                {
                    return(Unauthorized());
                }
            }
            else
            {
                return(Unauthorized());
            }


            return(Ok());
        }
 private void FinishCurrentTempVessel(BatchReport report, Vessel tempVessel, List <string> lineInfo)
 {
     try
     {
         tempVessel.TimeCompleted = DateTime.ParseExact(lineInfo[5] + " " + lineInfo[3], "dd-MMM-yy HH:mm:ss", null);
         report.AllVessels.Add(tempVessel);
         //tempVessel = new Vessel();
     }
     catch (Exception ex)
     {
         string message = "Could not finish vessel " + tempVessel.VesselName + ".";
         RecordFault(report, message, ex.Message);
     }
 }
        private void SetNewMakeTime(BatchReport report)
        {
            double timeLost = 0;

            foreach (var issue in report.BatchIssues)
            {
                if (!issue.RemoveIssue)
                {
                    timeLost += issue.TimeLost;
                }
            }

            report.NewMakeTime = Math.Round(report.MakingTime - timeLost, 2);
        }
        private Material GetLastMaterialFromGroupInBatch(BatchReport report, int currentMaterialGroup)
        {
            List <string> materialsInGroup = GetListOfMaterialsInGroup(currentMaterialGroup);
            Vessel        mainMixer        = report.AllVessels.Where(x => x.VesselType == Vessel.VesselTypes.MainMixer).FirstOrDefault();

            for (int i = materialsInGroup.Count - 1; i > 0; i--)
            {
                if (mainMixer.Materials.Any(x => x.Name == materialsInGroup[i]))
                {
                    return(mainMixer.Materials.Where(x => x.Name == materialsInGroup[i]).First());
                }
            }
            return(null);
        }