예제 #1
0
        public IEnumerable<SequencingStation> GetSequencingStationsByType(string type)
        {
            PartSequencingDataContext dbSeq = new PartSequencingDataContext();
            PlasticSeqDatabase dbPlasticSeq = new PlasticSeqDatabase();

            if (type.ToUpper().Equals("FRONT"))
            {
                return (from s in SequencingSettingsCacheManager.SequencingStationSettings.Where(s => s.LineId == 1 && s.Obsolete == false)
                        where s.Obsolete == false
                        select new SequencingStation
                        {
                            Description = s.Description,
                            ScheduleAvailable = false,
                            ItemsWaiting = 0,
                            ItemsWaitingPercentage = 0,
                            Id = s.Id,
                            SequencingLocation = dbSeq.SequencingLocations.Where(x => x.Id == s.SequencingLocationId).Single(),
                            Line = dbSeq.Lines.Where(x => x.Id == s.LineId).Single(),
                            Station = dbPlasticSeq.GetStation((int)s.StationId),
                            StationOrder = (int)s.StationOrder,
                            BoxPerSchedule = (int)s.BoxPerSchedule,
                            BoxQty = (int)s.BoxQty,
                            MessageFormat = s.MessageFormat,
                            Obsolete = (bool)s.Obsolete,
                            PartsPerBox = (int)s.PartsPerBox,
                            SeatOptions = (int)s.SeatOptions,
                            SeatOptions2Check = (int)s.SeatOptions2Check,
                            BaseStation = SequencingSettingsCacheManager.SequencingStationSettings.Where(i => i.Id == SequencingSettingsCacheManager.BaseSequencingStationOffsets.Where(x => x.LineId == s.LineId).Single().SequencingStationSettingsId).Single(),
                            Offset = (int)s.Offset,
                        }).ToList();
            }
            else if (type.ToUpper().Equals("REAR"))
            {
                return (from s in SequencingSettingsCacheManager.SequencingStationSettings.Where(s => (s.LineId == 2 || s.LineId == 3) && s.Obsolete == false)
                        where s.Obsolete == false
                        select new SequencingStation
                        {
                            Description = s.Description,
                            ScheduleAvailable = false,
                            ItemsWaiting = 0,
                            ItemsWaitingPercentage = 0,
                            Id = s.Id,
                            SequencingLocation = dbSeq.SequencingLocations.Where(x => x.Id == s.SequencingLocationId).Single(),
                            Line = dbSeq.Lines.Where(x => x.Id == s.LineId).Single(),
                            Station = dbPlasticSeq.GetStation((int)s.StationId),
                            StationOrder = (int)s.StationOrder,
                            BoxPerSchedule = (int)s.BoxPerSchedule,
                            BoxQty = (int)s.BoxQty,
                            MessageFormat = s.MessageFormat,
                            Obsolete = (bool)s.Obsolete,
                            PartsPerBox = (int)s.PartsPerBox,
                            SeatOptions = (int)s.SeatOptions,
                            SeatOptions2Check = (int)s.SeatOptions2Check,
                            BaseStation = SequencingSettingsCacheManager.SequencingStationSettings.Where(i => i.Id == SequencingSettingsCacheManager.BaseSequencingStationOffsets.Where(x => x.LineId == s.LineId).Single().SequencingStationSettingsId).Single(),
                            Offset = (int)s.Offset,
                        }).ToList();
            }

            return null;
        }
예제 #2
0
        public IEnumerable<PlasticSeqSchedule> GetPlasticScheduleHistoryDetailByLocationId(int locationId, int scheduleNum)
        {
            SequencingScheduleFactory factory = new SequencingScheduleFactory();
            PlasticSeqDatabase db = new PlasticSeqDatabase();

            List<PlasticSeqSchedule> listPlasticHistory = new List<PlasticSeqSchedule>();

            var seqStations = db.GetSequencingStationsBySequencingLocationId(locationId);

            foreach (var station in seqStations)
            {
                var schedule = factory.GetPlasticScheduleHistoryDetail(station, scheduleNum);
                listPlasticHistory.Add(schedule);
            }

            return listPlasticHistory;
        }
예제 #3
0
 public IEnumerable<SequencingStation> SequencingStationSettingsBySequencingLocationId(int id)
 {
     PlasticSeqDatabase dbPlastic = new PlasticSeqDatabase();
     return dbPlastic.GetSequencingStationSettingssBySequencingLocationId(id);
 }
예제 #4
0
 public HttpResponseMessage SequencingStationSettingsById([FromBody]SequencingStation settings)
 {
     PlasticSeqDatabase dbPlastic = new PlasticSeqDatabase();
     dbPlastic.UpdateSequencingStationSettingsById(settings);
     return new HttpResponseMessage(HttpStatusCode.OK);
 }
예제 #5
0
 public SequencingStation SequencingStationSettingsById(int id) 
 {
     PlasticSeqDatabase dbPlastic = new PlasticSeqDatabase();
     return dbPlastic.GetSequencingStationSettingsById(id);
 }
        public void CompleteSequencingByAisleId(int id, int employeeId)
        {
            PartSequencingDataContext dbSeq = new PartSequencingDataContext();
            EmployeeDatabase dbEmp = new EmployeeDatabase();
            PlasticSeqDatabase db = new PlasticSeqDatabase();
            var seqStations = db.GetSequencingStationsBySequencingLocationId(id);

            int scheduleNum = 0;
            if (seqStations.Count() > 0)
            {
                var first = seqStations.FirstOrDefault();
                if (first != null)
                {
                    scheduleNum = first.NextBox.ScheduleNum;
                }
            }

            foreach (var station in seqStations)
                CompleteSequencingStation(station.Id);

            var employee = dbEmp.GetEmployeeInfo(employeeId);

            var scheduleHist = new SequencingStationScheduleHistory
            {
                EmployeeId = employeeId,
                EmployeeName = employee == null ? "Unknown Employee" : employee.Name.Trim(),
                ScheduleNum = scheduleNum,
                SequencingLocationId = id,
                DateCompleted = DateTime.Now,
            };

            dbSeq.SequencingStationScheduleHistories.InsertOnSubmit(scheduleHist);
            dbSeq.SubmitChanges();
        }
        public SequencingStation UpdateNextBoxBySequencingId(int id)
        {
            PartSequencingDataContext dbSeq = new PartSequencingDataContext();
            MesDataContext dbMes = new MesDataContext();
            PlasticSeqDatabase dbPlasticSeq = new PlasticSeqDatabase();

            SequencingTrackingItem lastItem = null;
            SequencingTrackingItem firstItem = null;

            var station = (from s in SequencingSettingsCacheManager.SequencingStationSettings
                           where s.Obsolete == false && s.Id == id
                           select new SequencingStation
                           {
                               Description = s.Description,
                               ScheduleAvailable = false,
                               ItemsWaiting = 0,
                               ItemsWaitingPercentage = 0,
                               Id = s.Id,
                               SequencingLocation = dbSeq.SequencingLocations.Where(x => x.Id == s.SequencingLocationId).Single(),
                               Line = dbSeq.Lines.Where(x => x.Id == s.LineId).Single(),
                               Station = dbPlasticSeq.GetStation((int)s.StationId),
                               StationOrder = (int)s.StationOrder,
                               BoxPerSchedule = (int)s.BoxPerSchedule,
                               BoxQty = (int)s.BoxQty,
                               MessageFormat = s.MessageFormat,
                               Obsolete = (bool)s.Obsolete,
                               PartsPerBox = (int)s.PartsPerBox,
                               SeatOptions = (int)s.SeatOptions,
                               SeatOptions2Check = (int)s.SeatOptions2Check,
                               BaseStation = SequencingSettingsCacheManager.SequencingStationSettings.Where(i=>i.Id == SequencingSettingsCacheManager.BaseSequencingStationOffsets.Where(x=>x.LineId == s.LineId).Single().SequencingStationSettingsId).Single(),
                               Offset = (int)s.Offset,
                           }).Single();

            var tracking = GetSequencingHistory(station);
            var lineBuffer = GetSequencingBuffer(station);

            var minBuffer = lineBuffer.OrderBy(j => j.OrderId).FirstOrDefault();

            var scheduleStatus = dbSeq.SequencingStationLookups.Where(s => s.SequenceStationSettingsId == station.Id).FirstOrDefault();

            if (tracking.Any())
            {
                lastItem = tracking.OrderByDescending(j => j.OrderId).First();
                firstItem = tracking.OrderBy(j => j.OrderId).First();
            }

            station.NextBox = new SequenceBox();

            if (scheduleStatus == null)
            {
                int nextOrderId = Int16.MinValue;

                if (lineBuffer.Count() > 0)
                    nextOrderId = lineBuffer.First().OrderId;


                if (lastItem != null)
                {
                    if (lastItem.OrderId > nextOrderId) {
                        nextOrderId = lastItem.OrderId + 1;
                    }
                }

                scheduleStatus = new SequencingStationLookup
                {
                    SequenceStationSettingsId = station.Id,
                    NextBoxNum = 1,
                    NextScheduleNum = 1,
                    NextOrderId = nextOrderId
                };

                station.NextBox.BoxNum = scheduleStatus.NextBoxNum;
                station.NextBox.OrderId = scheduleStatus.NextOrderId;
                station.NextBox.ScheduleNum = scheduleStatus.NextScheduleNum;
                SetScheduleAvailable(station, lineBuffer.Count());

                dbSeq.SequencingStationLookups.InsertOnSubmit(scheduleStatus);
                dbSeq.SubmitChanges();
            }
            else
            {
                if (lastItem != null)
                {
                    if (lastItem.Type == 2)
                    {
                        var lastRealJob = tracking.Where(o => o.OrderId < lastItem.OrderId).OrderByDescending(f => f.OrderId).Where(x => x.ScheduleNum > 0).FirstOrDefault();
                        if (lastRealJob != null)
                        {
                            station.NextBox.ScheduleNum = lastRealJob.ScheduleNum + 1;
                            station.NextBox.BoxNum = lastRealJob.BoxNum + 1;
                            station.NextBox.OrderId = lastItem.OrderId + 1;
                        }
                        else
                        {
                            station.NextBox.ScheduleNum = scheduleStatus.NextScheduleNum;
                            station.NextBox.BoxNum = scheduleStatus.NextBoxNum;
                            station.NextBox.OrderId = lastItem.OrderId + 1;
                        }
                    }
                    else
                    {
                        if ((lastItem.BoxNum + station.BoxPerSchedule) > station.BoxQty)
                            station.NextBox.BoxNum = 1;
                        else
                            station.NextBox.BoxNum = (lastItem.BoxNum + 1);

                        station.NextBox.ScheduleNum = lastItem.ScheduleNum + 1;
                        station.NextBox.OrderId = lastItem.OrderId + 1;
                    }
                    

                }
                else
                {
                    if (minBuffer != null)
                    {
                        station.NextBox.OrderId = minBuffer.OrderId;
                        station.NextBox.BoxNum = 1;
                        station.NextBox.ScheduleNum = 1;
                    }
                    else
                    {
                        station.NextBox.OrderId = scheduleStatus.NextOrderId;
                        station.NextBox.BoxNum = scheduleStatus.NextBoxNum;
                        station.NextBox.ScheduleNum = scheduleStatus.NextScheduleNum;
                    }

                }

                scheduleStatus.NextBoxNum = station.NextBox.BoxNum;
                scheduleStatus.NextScheduleNum = station.NextBox.ScheduleNum;
                scheduleStatus.NextOrderId = station.NextBox.OrderId;

                dbSeq.SubmitChanges();

                var validBuffer = (from l in lineBuffer
                                   where l.OrderId >= station.NextBox.OrderId
                                   select l).ToList();

                SetScheduleAvailable(station, validBuffer.Count());

            }


            return station;

        }