Beispiel #1
0
        public void CozguIsEmriEkle(vCozguIsEmri hesaplar)
        {
            vCozgu cozgusu = db.GetGeneric <vCozgu>(c => c.TipId == _CozguIsEmriTipId).FirstOrDefault();

            if ((CozguIsEmirleri.Count > 0 ? CozguIsEmirleri.FindAll(f => f.Cozgu == "Hav").Sum(s => s.DokumaMetre) : 0) + hesaplar.DokumaMetre > (cozgusu == null ? 0 : cozgusu.Miktar))
            {
                throw new Exception("Toplam iş emri çözgü metresinden fazla olamaz..!");
            }

            hesaplar.Islem = Convert.ToInt64(DateTime.Now.ToString("yyMMddhhmmssfff"));

            List <tblMakinalar> tezgahlar = new Makina().MakinalariGetir(1);
            vKumas        kumas           = vKumas.TipGetir(_CozguIsEmriTipId);
            tblMalzemeler havIplik        = db.GetGeneric <tblMalzemeler>(c => c.Id == kumas.Hav1).FirstOrDefault();
            tblMalzemeler zeminIplik      = db.GetGeneric <tblMalzemeler>(c => c.Id == kumas.Zemin1).FirstOrDefault();

            CozguIsEmirleri.Add(new vCozguIsEmri()
            {
                Cozgu         = "Hav",
                DokumaMetre   = hesaplar.DokumaMetre,
                Metre         = hesaplar.HavMetre,
                Id            = 0,
                PersonelId    = hesaplar.PersonelId,
                Tarih         = DateTime.Now,
                Tezgahlar     = tezgahlar,
                TipId         = hesaplar.TipId,
                TipNo         = hesaplar.TipNo,
                IplikId       = havIplik == null ? 0 : havIplik.Id,
                IplikKodu     = havIplik == null ? null : havIplik.Kodu,
                IplikAdi      = havIplik == null ? null : havIplik.Adi,
                IplikTelAdedi = kumas == null ? null : kumas.HavCozguTel,
                Islem         = hesaplar.Islem
            });

            CozguIsEmirleri.Add(new vCozguIsEmri()
            {
                Cozgu         = "Alt Zemin",
                DokumaMetre   = hesaplar.DokumaMetre,
                Metre         = hesaplar.AltZeminMetre,
                Id            = 0,
                PersonelId    = hesaplar.PersonelId,
                Tarih         = DateTime.Now,
                Tezgahlar     = tezgahlar,
                TipId         = hesaplar.TipId,
                TipNo         = hesaplar.TipNo,
                IplikId       = zeminIplik == null ? 0 : zeminIplik.Id,
                IplikKodu     = zeminIplik == null ? null : zeminIplik.Kodu,
                IplikAdi      = zeminIplik == null ? null : zeminIplik.Adi,
                IplikTelAdedi = kumas == null ? null : kumas.HavCozguTel,
                Islem         = hesaplar.Islem
            });

            CozguIsEmirleri.Add(new vCozguIsEmri()
            {
                Cozgu         = "Üst Zemin",
                DokumaMetre   = hesaplar.DokumaMetre,
                Metre         = hesaplar.UstZeminMetre,
                Id            = 0,
                PersonelId    = hesaplar.PersonelId,
                Tarih         = DateTime.Now,
                Tezgahlar     = tezgahlar,
                TipId         = hesaplar.TipId,
                TipNo         = hesaplar.TipNo,
                IplikId       = zeminIplik == null ? 0 : zeminIplik.Id,
                IplikKodu     = zeminIplik == null ? null : zeminIplik.Kodu,
                IplikAdi      = zeminIplik == null ? null : zeminIplik.Adi,
                IplikTelAdedi = kumas == null ? null : kumas.HavCozguTel,
                Islem         = hesaplar.Islem
            });
        }
Beispiel #2
0
        public int TezgahPlanOtele()
        {
            DateTime           atkiSonTarih = Makina.TezgahAtkiSonGirisTarihiGetir();
            List <tblPlanlama> planlar      = db.GetGeneric <tblPlanlama>(c => c.Tarih == atkiSonTarih);

            foreach (var plan in planlar)
            {
                tblKumas tip = db.GetGeneric <tblKumas>(c => c.Id == plan.TipId).FirstOrDefault();
                List <tblTezgahAtkiGiris> atkiGirisleri = db.GetGeneric <tblTezgahAtkiGiris>(c => c.Tarih == plan.Tarih && c.TezgahId == plan.TezgahId && c.TipId == plan.TipId);


                double?dokMetre = null;
                int    fark     = atkiGirisleri == null ? 0 : atkiGirisleri.Sum(c => c.AtkiBitis - c.AtkiBaslangic);
                if (tip.AtkiSiklik.HasValue)
                {
                    dokMetre = fark * 1000 * 2 / (tip.AtkiSiklik.Value * 100);
                }

                if (dokMetre.HasValue == false)
                {
                    return(0);
                }
                double?kontMetre = (plan.Miktar / 2) + (plan.Miktar * 0.2);
                kontMetre = Math.Round(kontMetre.Value, 2);

                if (dokMetre < kontMetre)
                {
                    plan.OtelemeKontrol = false;
                    plan.EksikDokuma    = kontMetre - dokMetre;

                    if (atkiGirisleri != null && atkiGirisleri.Count != 0)//&& snc == 1)
                    {
                        atkiGirisleri.ForEach(f => f.PlanOteledi = true);
                        db.UpdateGeneric <tblTezgahAtkiGiris>(atkiGirisleri);
                    }
                }
            }

            if (db.UpdateGeneric <tblPlanlama>(planlar))
            {
                planlar = db.GetGeneric <tblPlanlama>(c => c.OtelemeKontrol == false);

                var otelemeList = planlar.GroupBy(g => new { g.SiparisId, g.TezgahId, g.TipId, g.Miktar }).Select(s => new
                {
                    ToplamEksik = s.Sum(f => f.EksikDokuma),
                    TezgahId    = s.Key.TezgahId,
                    PlanMiktar  = s.Key.Miktar,
                    Tarih       = s.FirstOrDefault().Tarih
                });

                _OtelenenSiparisler = new List <int>();
                foreach (var item in otelemeList)
                {
                    if (((item.PlanMiktar / 2) + (item.PlanMiktar * 0.2)) <= item.ToplamEksik)
                    {
                        this.TezgahPlanOtele(item.TezgahId, item.Tarih, 1, true);
                    }
                }

                if (_OtelenenSiparisler != null && _OtelenenSiparisler.Count != 0)
                {
                    string idStr = "";
                    foreach (var item in _OtelenenSiparisler)
                    {
                        idStr += item.ToString() + ",";
                    }
                    idStr = idStr.TrimEnd(',');
                    //ötelenen tezgahların üzerlerindeki diğer siparişlerde ötelenmiş olduğundan bu siparişler de 1 er gün ötelendi olarak update edilmeli.
                    db.GetGenericWithSQLQuery <string>("update tblPlanlama set AtkiOtelemesi = ISNULL(AtkiOtelemesi, 0) + 1 where SiparisId in (" + idStr + ")", new object[0]);
                }
            }

            return(0);
        }