Пример #1
0
        public void SaveRepairHistory(RepairFaults repairFaults, MasterJobTable jobInfo, PalletInfo palletInfo, string empId)
        {
            REWORK_REPORTINGEntities entities = new REWORK_REPORTINGEntities();
            EmployeeDatabase dbEmp = new EmployeeDatabase();
            var emp = dbEmp.GetEmployeeInfo(int.Parse(empId));

            var history = new RepairHistory
            {
                ArriveDtm = DateTime.Now,
                CompletedDtm = DateTime.Now,
                PalletId = palletInfo.PalletNbr,
                EmployeeId = int.Parse(emp.EmployeeId),
                EmployeeName = emp.Name.Trim(),
                JobId = jobInfo.Job_ID,
                RepairFaultXrefRepairHistories = GetRepairFaultXrefRepairHistories(repairFaults),
                RepairTestRequirements = GetRepairTestRequirements(repairFaults)
            };

            entities.RepairHistories.Add(history);

            try
            {
                entities.SaveChanges();
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Console.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                    }
                }
                throw dbEx;
            }
        }
Пример #2
0
        //public void GetRepairInfo(int jobId)
        //{
        //    RepairReportingDataContext db = new RepairReportingDataContext();
        //    var repairHeader = db.RPT_GetRepairInfoHeader(jobId).ToList();
            
        //    foreach(var header in repairHeader)
        //    {
        //        dynamic Repair = new
        //        {
        //            HeaderInfo = header,
        //            RepairHistory = new
        //            {

        //            }
        //        };
        //    }


        //}

        public PalletHistoryInfo GetPalletInfoByJobId(long jobId)
        {
            ReworkFactory reworkFactory = new ReworkFactory();
            RepairFaults faults = new RepairFaults();
            DispositionDataContext db = new DispositionDataContext();
            REWORK_REPORTINGEntities reworkEntities = new REWORK_REPORTINGEntities();
            MesDataContext dbMes = new MesDataContext();
            ItemDetailsModel itemDetailModel = new ItemDetailsModel();

            var jobInfo = (from j in dbMes.MasterJobTables
                           where j.Job_ID == jobId
                           select j).FirstOrDefault();

            if (jobInfo == null)
                return null;

            var palletInfo = GetPalletInfo(jobInfo);
            return palletInfo;
        }
Пример #3
0
        private PalletHistoryInfo GetPalletInfo(MasterJobTable jobInfo)
        {
            ReworkFactory reworkFactory = new ReworkFactory();
            RepairFaults faults = new RepairFaults();
            DispositionDataContext db = new DispositionDataContext();
            REWORK_REPORTINGEntities reworkEntities = new REWORK_REPORTINGEntities();
            MesDataContext dbMes = new MesDataContext();
            ItemDetailsModel itemDetailModel = new ItemDetailsModel();

            var item = itemDetailModel.GetItemInfo(jobInfo.SKU);

            var convertSkuInfo = reworkFactory.GetSkuInfo(item).OrderBy(x => x.PartIndex).ToList();
            var lineInfos = reworkFactory.GetLineInfo(jobInfo);

            //RepairTorqueDetails = Count = 0

            reworkEntities.Configuration.ProxyCreationEnabled = false;
            reworkEntities.Configuration.LazyLoadingEnabled = false;
            var repairHistory = reworkEntities.RepairHistories
                .Include("RepairFaultXrefRepairHistories")
                .Include("RepairFaultXrefRepairHistories.RepairFault")
                .Include("RepairFaultXrefRepairHistories.RepairFault.FaultType")
                .Include("RepairFaultXrefRepairHistories.RepairFault.RepairFaultDetails")
                .Include("RepairFaultXrefRepairHistories.RepairFault.RepairDispositionDetails")
                .Include("RepairFaultXrefRepairHistories.RepairFault.RepairRecipes")
                //.Include("RepairFaultXrefRepairHistories.RepairFault.RepairRecipes.RepairBarcodeDetails")
                //.Include("RepairFaultXrefRepairHistories.RepairFault.RepairRecipes.RepairTorqueDetails")
                .Include("RepairTestRequirements")
                .Include("RepairTestRequirements.RepairTestRequirementDetails")
                .Where(r => r.JobId == jobInfo.Job_ID)
                .Select(i => new
                {
                    i.ArriveDtm,
                    i.CompletedDtm,
                    i.EmployeeId,
                    i.EmployeeName,
                    i.JobId,
                    i.PalletId,
                    RepairFaultXrefRepairHistories = i.RepairFaultXrefRepairHistories.Select(j => new
                    {
                        RepairFault = new
                        {
                            FaultType = j.RepairFault.FaultType,
                            RepairDispositionDetails = j.RepairFault.RepairDispositionDetails,
                            RepairFaultDetails = j.RepairFault.RepairFaultDetails,
                            RepairRecipes = j.RepairFault.RepairRecipes
                        }
                    }).ToList(),
                    RepairTestRequirements = i.RepairTestRequirements.Select(k => new
                    {
                        k.TestId,
                        k.TestName,
                        k.TestResult,
                        k.TestStatus,
                        k.Buildcode,
                        RepairTestRequirementDetails = k.RepairTestRequirementDetails
                    }).ToList(),
                }).ToList();

            dynamic extract = new List<dynamic>();
            foreach (var j in repairHistory)
            {
                dynamic onejob = new
                {
                    PalletId = j.PalletId,
                    JobId = j.JobId,
                    CompletedDtm = j.CompletedDtm,
                    EmployeeName = j.EmployeeName,
                    RepairTestRequirements = (from t in j.RepairTestRequirements
                                             select new {
                                                 TestId = t.TestId,
                                                 TestName = t.TestName,
                                                 TestResult = t.TestResult,
                                                 TestStatus = t.TestStatus,
                                                 Buildcode = t.Buildcode,
                                                 RepairTestRequirementDetails = (from d in t.RepairTestRequirementDetails
                                                                                select new
                                                                                {
                                                                                    BitNo = d.BitNo,
                                                                                    Description = d.Description,
                                                                                    Result = d.Result
                                                                                }).ToList(),
                                             }).ToList(),
                    RepairFaultXrefRepairHistories = from s in j.RepairFaultXrefRepairHistories
                                                     select new
                                                     {
                                                         RepairFault = new {
                                                             FaultType = new {
                                                                 Id = s.RepairFault.FaultType.Id,
                                                                 Description = s.RepairFault.FaultType.Description,
                                                             },
                                                             RepairRecipes = from r in s.RepairFault.RepairRecipes
                                                                             select new {
                                                                                 Description = r.Description,
                                                                                 RepairBarcodeDetails = (from b in r.RepairBarcodeDetails
                                                                                                        select new
                                                                                                        {
                                                                                                            Description = b.Description,
                                                                                                            OriginalBarcode = b.OriginalBarcode,
                                                                                                            ReplaceBarcode = b.ReplaceBarcode
                                                                                                        }).ToList(),
                                                                                 RepairTorqueDetails = (from t in r.RepairTorqueDetails
                                                                                                        select new
                                                                                                        {
                                                                                                            Angle = t.Angle,
                                                                                                            AngleStatus = t.AngleStatus,
                                                                                                            CompletedDTM = t.CompletedDTM,
                                                                                                            ControllerName = t.ControllerName,
                                                                                                            Pset = t.Pset,
                                                                                                            TighteningID = t.TighteningID,
                                                                                                            TighteningStatus = t.TighteningStatus,
                                                                                                            Torque = t.Torque,
                                                                                                            TorqueStatus = t.TorqueStatus
                                                                                                        }).ToList(),
                                                                             },
                                                             RepairFaultDetails = (from d in s.RepairFault.RepairFaultDetails
                                                                                  select new
                                                                                  {
                                                                                      Station = d.Station,
                                                                                      Description = d.Description
                                                                                  }).ToList(),
                                                             RepairDispositionDetails = (from disp in s.RepairFault.RepairDispositionDetails
                                                                                        select new
                                                                                        {
                                                                                            Type = disp.Type,
                                                                                            Side = disp.Side,
                                                                                            SeatPortion = disp.SeatPortion,
                                                                                            Commodity = disp.Commodity,
                                                                                            Defect = disp.Defect,
                                                                                            DefectDetail = disp.DefectDetail,
                                                                                            Responsibility = disp.Responsibility
                                                                                        }).ToList()
                                                         }
                                                     }
                };
                extract.Add(onejob);
            }

            PalletHistoryInfo palletInfo = new PalletHistoryInfo
            {
                OrderNumber = jobInfo.Order_Nbr,
                FinishDTM = (DateTime)jobInfo.FinishBld_DTTM,
                JobId = jobInfo.Job_ID,
                Sku = jobInfo.SKU,
                PalletId = (int)jobInfo.Ship_Pallet,
                SkuInfo = convertSkuInfo,
                LineInfo = lineInfos,
                RepairHistory = extract
            };

            return palletInfo;
        }
Пример #4
0
        public PalletHistoryInfo GetPalletInfoByPalletId(int palletId)
        {
            ReworkFactory reworkFactory = new ReworkFactory();
            RepairFaults faults = new RepairFaults();
            DispositionDataContext db = new DispositionDataContext();
            REWORK_REPORTINGEntities reworkEntities = new REWORK_REPORTINGEntities();
            MesDataContext dbMes = new MesDataContext();
            ItemDetailsModel itemDetailModel = new ItemDetailsModel();

            var palletHdr = (from p in dbMes.PalletInfos
                             where p.PalletNbr == palletId && (p.Pallet_Type == "S1" || p.Pallet_Type == "S2")
                             select p).FirstOrDefault();

            if (palletHdr == null)
                return null;

            var jobInfo = (from j in dbMes.MasterJobTables
                           where j.Job_ID == palletHdr.Job_ID
                           select j).FirstOrDefault();

            if (jobInfo == null)
                return null;

            var palletInfo = GetPalletInfo(jobInfo);
            return palletInfo;
        }
Пример #5
0
 public List<RepairTestRequirement> GetRepairTestRequirements(RepairFaults repairFaults)
 {
     var tests = (from t in repairFaults.TestRepairs
                  select new RepairTestRequirement
                  {
                      Buildcode = t.BuildCode,
                      TestId = t.TestId,
                      TestName = t.TestName,
                      TestResult = t.TestResult == null ? 0 : t.TestResult.TestResult,
                      TestStatus = t.TestResult == null ? 0 : t.TestResult.TestStatus,
                      RepairTestRequirementDetails = (from d in GetTestResultDetails(t.TestResult)
                                                      select new RepairTestRequirementDetail
                                                      {
                                                          BitNo = d.BitNo,
                                                          Description = d.Description,
                                                          Result = d.Status
                                                      }).ToList(),
                  }).ToList();
     return tests;
 }
Пример #6
0
        public List<RepairFaultXrefRepairHistory> GetRepairFaultXrefRepairHistories(RepairFaults repairFaults)
        {
            List<RepairFaultXrefRepairHistory> xrefList = new List<RepairFaultXrefRepairHistory>();

            var defects = (from d in repairFaults.DefectFaults
                           select new RepairFault
                           {
                               FaultTypeId = 1,
                               RepairDispositionDetails = (from g in d.Disposition
                                                           select new RepairDispositionDetail
                                                           {
                                                               Commodity = g.SeatCommodity.Description.Trim(),
                                                               CommodityID = g.SeatCommodity.CommodityID,
                                                               Defect = g.SeatDefect.Description.Trim(),
                                                               DefectID = g.SeatDefect.DefectID,
                                                               DefectDetail = g.SeatDefectDetail.Description.Trim(),
                                                               DefectDetailID = g.SeatDefectDetail.DefectDetailID,
                                                               Responsibility = g.SeatResponsibility.Description.Trim(),
                                                               ResponsibilityID = g.SeatResponsibility.ResponsibilityID,
                                                               SeatPortion = g.SeatPortion.Description.Trim(),
                                                               SeatPortionID = g.SeatPortion.SeatPortionID,
                                                               Side = g.SeatSide.Description.Trim(),
                                                               SideID = g.SeatSide.SideID,
                                                               Type = g.SeatType.Description.Trim(),
                                                               TypeID = g.SeatType.TypeID
                                                           }).ToList(),
                               RepairRecipes = GetRepairRecipes(d.RepairDetails),
                               RepairFaultDetails = GetDefectRepairFaultDetail(d)
                           }).ToList();

            var defectsXref = (from x in defects
                               select new RepairFaultXrefRepairHistory
                               {
                                   RepairFault = x,
                               }).ToList();

            xrefList.AddRange(defectsXref);

            var other = (from o in repairFaults.OtherFaults
                         select new RepairFault
                         {
                             FaultTypeId = 2,
                             RepairDispositionDetails = (from g in o.Disposition
                                                         select new RepairDispositionDetail
                                                         {
                                                             Commodity = g.SeatCommodity.Description.Trim(),
                                                             CommodityID = g.SeatCommodity.CommodityID,
                                                             Defect = g.SeatDefect.Description.Trim(),
                                                             DefectID = g.SeatDefect.DefectID,
                                                             DefectDetail = g.SeatDefectDetail.Description.Trim(),
                                                             DefectDetailID = g.SeatDefectDetail.DefectDetailID,
                                                             Responsibility = g.SeatResponsibility.Description.Trim(),
                                                             ResponsibilityID = g.SeatResponsibility.ResponsibilityID,
                                                             SeatPortion = g.SeatPortion.Description.Trim(),
                                                             SeatPortionID = g.SeatPortion.SeatPortionID,
                                                             Side = g.SeatSide.Description.Trim(),
                                                             SideID = g.SeatSide.SideID,
                                                             Type = g.SeatType.Description.Trim(),
                                                             TypeID = g.SeatType.TypeID
                                                         }).ToList(),
                             RepairRecipes = GetRepairRecipes(o.RepairDetails),
                             RepairFaultDetails = GetOtherRepairFaultDetail(o),

                         }).ToList();

            var otherxref = (from x in other
                             select new RepairFaultXrefRepairHistory
                             {
                                 RepairFault = x,
                             }).ToList();

            xrefList.AddRange(otherxref);

            var bcs = (from b in repairFaults.BarcodeFaults
                       select new RepairFault
                       {
                           FaultTypeId = 4,
                           RepairDispositionDetails = (from g in b.Disposition
                                                       select new RepairDispositionDetail
                                                       {
                                                           Commodity = g.SeatCommodity.Description.Trim(),
                                                           CommodityID = g.SeatCommodity.CommodityID,
                                                           Defect = g.SeatDefect.Description.Trim(),
                                                           DefectID = g.SeatDefect.DefectID,
                                                           DefectDetail = g.SeatDefectDetail.Description.Trim(),
                                                           DefectDetailID = g.SeatDefectDetail.DefectDetailID,
                                                           Responsibility = g.SeatResponsibility.Description.Trim(),
                                                           ResponsibilityID = g.SeatResponsibility.ResponsibilityID,
                                                           SeatPortion = g.SeatPortion.Description.Trim(),
                                                           SeatPortionID = g.SeatPortion.SeatPortionID,
                                                           Side = g.SeatSide.Description.Trim(),
                                                           SideID = g.SeatSide.SideID,
                                                           Type = g.SeatType.Description.Trim(),
                                                           TypeID = g.SeatType.TypeID
                                                       }).ToList(),
                           RepairRecipes = GetRepairRecipes(b.RepairDetails),
                           RepairFaultDetails = GeBarcodeRepairFaultDetail(b),
                       }).ToList();

            var bcsxref = (from x in bcs
                            select new RepairFaultXrefRepairHistory
                            {
                                RepairFault = x,
                            }).ToList();

            xrefList.AddRange(bcsxref);

            var trqs = (from t in repairFaults.TorqueFaults
                       select new RepairFault
                       {
                           FaultTypeId = 5,
                           RepairDispositionDetails = (from g in t.Disposition
                                                       select new RepairDispositionDetail
                                                       {
                                                           Commodity = g.SeatCommodity.Description.Trim(),
                                                           CommodityID = g.SeatCommodity.CommodityID,
                                                           Defect = g.SeatDefect.Description.Trim(),
                                                           DefectID = g.SeatDefect.DefectID,
                                                           DefectDetail = g.SeatDefectDetail.Description.Trim(),
                                                           DefectDetailID = g.SeatDefectDetail.DefectDetailID,
                                                           Responsibility = g.SeatResponsibility.Description.Trim(),
                                                           ResponsibilityID = g.SeatResponsibility.ResponsibilityID,
                                                           SeatPortion = g.SeatPortion.Description.Trim(),
                                                           SeatPortionID = g.SeatPortion.SeatPortionID,
                                                           Side = g.SeatSide.Description.Trim(),
                                                           SideID = g.SeatSide.SideID,
                                                           Type = g.SeatType.Description.Trim(),
                                                           TypeID = g.SeatType.TypeID
                                                       }).ToList(),
                           RepairRecipes = GetRepairRecipes(t.RepairDetails),
                           RepairFaultDetails = GetTorqueRepairFaultDetail(t),
                       }).ToList();

            var trqsxref = (from x in trqs
                           select new RepairFaultXrefRepairHistory
                           {
                               RepairFault = x,
                           }).ToList();

            xrefList.AddRange(trqsxref);

            var combines = (from c in repairFaults.CombineFaults
                            select new RepairFault
                            {
                                FaultTypeId = 3,
                                RepairDispositionDetails = (from g in c.Disposition
                                                            select new RepairDispositionDetail
                                                            {
                                                                Commodity = g.SeatCommodity.Description.Trim(),
                                                                CommodityID = g.SeatCommodity.CommodityID,
                                                                Defect = g.SeatDefect.Description.Trim(),
                                                                DefectID = g.SeatDefect.DefectID,
                                                                DefectDetail = g.SeatDefectDetail.Description.Trim(),
                                                                DefectDetailID = g.SeatDefectDetail.DefectDetailID,
                                                                Responsibility = g.SeatResponsibility.Description.Trim(),
                                                                ResponsibilityID = g.SeatResponsibility.ResponsibilityID,
                                                                SeatPortion = g.SeatPortion.Description.Trim(),
                                                                SeatPortionID = g.SeatPortion.SeatPortionID,
                                                                Side = "LH/RH",
                                                                SideID = 1,
                                                                Type = g.SeatType.Description.Trim(),
                                                                TypeID = g.SeatType.TypeID
                                                            }).ToList(),
                                RepairRecipes = GetRepairRecipes(c.RepairDetails),
                                RepairFaultDetails = GetCombineRepairFaultDetails(c)
                            }).ToList();

            var combineXref = (from x in combines
                               select new RepairFaultXrefRepairHistory
                               {
                                   RepairFault = x,
                               }).ToList();

            xrefList.AddRange(combineXref);
            return xrefList;
        }
Пример #7
0
        public RepairPalletInfo GetPalletInfo(int palletId, int mode, int entryMode)
        {
            RepairFaults faults = new RepairFaults();
            DispositionDataContext db = new DispositionDataContext();
            DispositionDatabase dbDisposition = new DispositionDatabase();
            MesDataContext dbMes = new MesDataContext();
            
            ItemDetailsModel itemDetailModel = new ItemDetailsModel();

            var palletHdr = (from p in dbMes.PalletInfos
                             where p.PalletNbr == palletId && (p.Pallet_Type == "S1" || p.Pallet_Type == "S2")
                             select p).FirstOrDefault();

            if (palletHdr == null) //Check by job id when in manual mode and no ship pallet exists
            {
                if (entryMode == 2)
                {
                    var jobInfo = (from j in dbMes.MasterJobTables
                                   where j.Job_ID == palletId
                                   select j).FirstOrDefault();

                    if (jobInfo == null)
                        return null;

                    var itemMaster = dbMes.ItemMasterTables.Where(c => c.Item_Nbr == jobInfo.SKU).FirstOrDefault();
                    var item = itemDetailModel.GetItemInfo(jobInfo.SKU);

                    var carline = (itemMaster == null) ? "UNKNOWN" : itemMaster.Carline;

                    var convertSkuInfo = GetSkuInfo(item);
                    var lineInfos = GetLineInfo(jobInfo);

                    return new RepairPalletInfo
                    {
                        RULabelVerification = (carline == "RU") ? GetRULabelVerification(jobInfo.Job_ID, item.LineId) : null,
                        Carline = carline,
                        PalletId = 0,
                        JobId = jobInfo.Job_ID,
                        LineInfos = lineInfos,
                        OrderNumber = jobInfo.Order_Nbr.Trim(),
                        SkuInfo = convertSkuInfo,
                        FinalQuestions = new List<FinalQuestionResult>(),
                        RepairFaults = GetEmptyRepairFaults(jobInfo, item, convertSkuInfo, lineInfos, 0, mode),
                        PalletDescription = new PalletDescription(convertSkuInfo, 0, jobInfo.Job_ID, jobInfo.Create_DTTM.ToString("yyyy-mm-dd h:mm:ss tt"), DateTime.Now.ToString("yyyy-mm-dd h:mm:ss tt")),
                    };
                }

                return null;
            }
            else
            {
                var jobInfo = (from j in dbMes.MasterJobTables
                               where j.Job_ID == palletHdr.Job_ID
                               select j).FirstOrDefault();

                if (jobInfo == null)
                    return null;

                var itemMaster = dbMes.ItemMasterTables.Where(c => c.Item_Nbr == jobInfo.SKU).FirstOrDefault();
                var item = itemDetailModel.GetItemInfo(jobInfo.SKU);

                if (item == null)
                {
                    throw new HttpResponseException(
                        HttpErrorResponse.GetHttpErrorResponse(
                        HttpStatusCode.NotFound, "SKU Error", string.Format("SKU = {0} is setup incorrectly", jobInfo.SKU)));
                }

                var carline = (itemMaster == null) ? "UNKNOWN" : itemMaster.Carline;

                var convertSkuInfo = GetSkuInfo(item);
                var lineInfos = GetLineInfo(jobInfo);

                return new RepairPalletInfo
                {
                    RULabelVerification = (carline == "RU") ? GetRULabelVerification(jobInfo.Job_ID, item.LineId) : null,
                    Carline = carline,
                    PalletId = palletId,
                    JobId = jobInfo.Job_ID,
                    LineInfos = lineInfos,
                    OrderNumber = jobInfo.Order_Nbr.Trim(),
                    SkuInfo = convertSkuInfo,
                    FinalQuestions = dbDisposition.GetFinalQuestionsResult(jobInfo.Group),
                    RepairFaults = GetRepairFaults(jobInfo, item, convertSkuInfo, lineInfos, palletId, mode, carline),
                    PalletDescription = new PalletDescription(convertSkuInfo, palletHdr.PalletNbr, jobInfo.Job_ID, jobInfo.Create_DTTM.ToString("yyyy-mm-dd h:mm:ss tt"), palletHdr.Assigned_DTTM.Value.ToString("yyy-mm-dd h:mm:ss tt")),
                };
            }
        }
Пример #8
0
        public void CompleteRepair(RepairFaults repairFaults, int palletId, string userId)
        {
            MesDataContext dbMes = new MesDataContext();
            ReportingDatabase dbReporting = new ReportingDatabase();

            var palletHdr = (from p in dbMes.PalletInfos
                             where p.PalletNbr == palletId && (p.Pallet_Type == "S1" || p.Pallet_Type == "S2")
                             select p).FirstOrDefault();

            if (palletHdr == null)
            {
                var jobInfo = (from j in dbMes.MasterJobTables
                               where j.Job_ID == palletId
                               select j).FirstOrDefault();

                if (jobInfo != null)
                {
                    palletHdr = new PalletInfo
                    {
                        PalletNbr = 0,
                    };
                    //save repair history
                    dbReporting.SaveRepairHistory(repairFaults, jobInfo, palletHdr, userId);

                    dbMes.IWS_SP_CompleteRepairByJobId(jobInfo.Job_ID, userId);
                }

            } else {

                var jobInfo = (from j in dbMes.MasterJobTables
                               where j.Job_ID == palletHdr.Job_ID
                               select j).FirstOrDefault();

                if (jobInfo != null)
                {
                    //update swap barcodes
                    //repairFaults.DefectFaults.First().RepairDetails.

                    //save repair history
                    dbReporting.SaveRepairHistory(repairFaults, jobInfo, palletHdr, userId);

                    //update eds status to pass wanding
                    dbMes.IWS_SP_CompleteRepairByJobId(jobInfo.Job_ID, userId);
                }
            }


        }
Пример #9
0
        public RepairFaults GetRepairFaults(MasterJobTable jobInfo, Item item, List<SkuInfo> skuInfo, List<LineInfo> lineInfos, int palletId, int testerMode, string carline)
        {
            MesDataContext db = new MesDataContext();
            RepairFaults repairFaults = new RepairFaults();

            var palletValidationReqs = GetAllValidationRequirements(skuInfo);

            REWORK_REPORTINGEntities reworkEntities = new REWORK_REPORTINGEntities();
            var history = reworkEntities.RepairHistories.Where(j => j.JobId == jobInfo.Job_ID).FirstOrDefault();


            #region Missing Barcodes
            if (history == null)
            {
                if (palletValidationReqs.BarcodeRequirementInfos != null && history == null)
                {
                    foreach (var line in lineInfos)
                    {
                        var bcfaults = (from _bcrq in palletValidationReqs.BarcodeRequirementInfos.Where(s => s.LineId == line.LineId).ToList()
                                        join _bcactual in line.Serials
                                        on new { KEY1 = _bcrq.CSType } equals new { KEY1 = _bcactual.CSType } into _bcgroup
                                        where !_bcgroup.Any()
                                        select new BarcodeFault
                                        {
                                            LineId = line.LineId,
                                            CSType = _bcrq.CSType,
                                            Description = _bcrq.Description,
                                            Repaired = false
                                        }).ToList();

                        repairFaults.BarcodeFaults.AddRange(bcfaults);
                    }
                }
            }
            #endregion

            #region Missing Torques
            if (history == null && !carline.Equals("RU"))
            {
                var trqfaults = (from t in db.IWS_SP_GetMissingTorquesByJobId(jobInfo.Job_ID)
                                 select new TorqueFault
                                 {
                                     LineId = (int)t.LineId,
                                     Repaired = false,
                                     StationId = t.StationId,
                                     PsetNum = (int)t.PsetNum,
                                     TorquesRequired = (int)t.TorqueRequired,
                                     TorquesMissing = (int)t.TorqueCount,
                                     Description = (t.Description == null) ? "UNKNOWN" : t.Description.Trim(),
                                     RepairControllerName = (t.RepairControllerName == null) ? "UNKNOWN" : t.RepairControllerName.Trim(),
                                     RepairPsetNum = (t.RepairPsetNum == null) ? 0 : (int)t.RepairPsetNum,
                                     RepairDetails = new List<RepairDetail>(),
                                     Disposition = new List<IntegramREST.Models.Disposition.Disposition>()
                                 }).ToList();

                repairFaults.TorqueFaults.AddRange(trqfaults);
            }
            #endregion

            #region Failed Tests
            //foreach (var line in lineInfos)
            //{
            //    var testfaults = (from t in line.Tests.Where(c => c.TestStatus != "1").ToList()
            //                      select new TestFault
            //                      {
            //                          LineId = line.LineId,
            //                          TestName = t.TestFunction,
            //                          TestValue = t.TestValue,
            //                          TestDTM = (DateTime)t.StartDTM,
            //                          StationId = t.StationId,
            //                          Repaired = false
            //                      }).ToList();

            //    repairFaults.TestFaults.AddRange(testfaults);
            //}
            #endregion

            #region Test Requirements
            List<TestRepairRequirement> repairTestReqs = null;
            if (jobInfo.Group == "FRONT")
                repairTestReqs = GetFrontRepairTestRequirements(item, jobInfo.Job_ID, palletId, testerMode);
            else
                repairTestReqs = GetRearRepairTestRequirements(item, jobInfo.Job_ID, palletId, testerMode);

            repairFaults.TestRepairs = repairTestReqs;
            #endregion

            #region Defects
            var defectFaults = (from d in db.IWS_SP_GetUnresolvedDefectsByJobId(jobInfo.Job_ID).OrderBy(x => x.Log_DTTM)
                        group d by new {
                            d.DefectId,
                            d.DefectDescription,
                            d.StationId,
                            d.DT_Description
                        }  into g
                        select new DefectFault
                        {
                            Defect = new Defect
                            {
                                DefectID = 0,
                                Description = g.Key.DefectDescription.Trim(),
                                Obsolete = 0
                            },
                            Repaired = false,
                            StationNum = g.Key.DT_Description.Trim(),
                            RepairDetails = new List<RepairDetail>()
                        }).ToList();
            repairFaults.DefectFaults = defectFaults;
            #endregion

            #region ASRS Return
            //if (jobInfo.Curr_Inv_Loc.Trim() == "ASRS")
            //{
            //    defectFaults.Add(new DefectFault
            //    {
            //        Defect = new Defect
            //        {
            //            DefectID = 0,
            //            Description = "ASRS Return. Require Retest.",
            //            Obsolete = 0
            //        },
            //        Repaired = false,
            //        StationNum = (jobInfo.Group == "FRONT") ? "OP1450X" : "OP5200X",
            //        RepairDetails = new List<RepairDetail>()
            //    });
            //}
            #endregion
            
            return repairFaults;
        }
Пример #10
0
        public RepairFaults GetEmptyRepairFaults(MasterJobTable jobInfo, Item item, List<SkuInfo> skuInfo, List<LineInfo> lineInfos, int palletId, int testerMode)
        {
            RepairFaults repairFaults = new RepairFaults
            {
                BarcodeFaults = new List<BarcodeFault>(),
                CombineFaults = new List<CombineFault>(),
                DefectFaults = new List<DefectFault>(),
                LineFaults = new List<LineFault>(),
                OtherFaults = new List<OtherFault>(),
                TestFaults = new List<TestFault>(),
                TorqueFaults = new List<TorqueFault>(),
            };

            #region Test Requirements
            List<TestRepairRequirement> repairTestReqs = null;
            if (jobInfo.Group == "FRONT")
                repairTestReqs = GetFrontRepairTestRequirements(item, jobInfo.Job_ID, palletId, testerMode);
            else
                repairTestReqs = GetRearRepairTestRequirements(item, jobInfo.Job_ID, palletId, testerMode);

            repairFaults.TestRepairs = repairTestReqs;
            #endregion

            return repairFaults;
        }
Пример #11
0
 public RepairPalletInfo()
 {
     RepairFaults = new RepairFaults();
 }