Пример #1
0
        private void TratarFinalizacaoLotecef(LotecefPronto lotecefPronto, int qtdeDesejada)
        {
            //// movendo excessos para novo dia
            if (lotecefPronto.QtdeTotal - qtdeDesejada > 0)
            {
                LoteCef lotecefAberto    = null;
                var     listagemJaAberto = this.loteCefRepositorio.ObterAbertos();
                if (listagemJaAberto.Count > 0)
                {
                    lotecefAberto = listagemJaAberto.Where(x => x.Id != lotecefPronto.LotecefId).OrderBy(x => x.Id).FirstOrDefault();
                }

                if (lotecefAberto == null)
                {
                    lotecefAberto = LoteCef.Novo();
                    this.loteCefRepositorio.Salvar(lotecefAberto);
                }

                var contador = 0;
                var lotes    = this.loteRepositorio.ObterPorLoteCefId(lotecefPronto.LotecefId).OrderByDescending(x => x.Id);
                foreach (var lote in lotes.Where(x => x.Status == LoteStatus.Faturamento && x.ResultadoQualidadeCef == null && x.QualidadeM2sys == 0))
                {
                    this.loteRepositorio.AtualizarLotecef(lote.Id, lotecefAberto.Id);
                    contador++;
                    if (contador >= lotecefPronto.QtdeTotal - qtdeDesejada)
                    {
                        break;
                    }
                }
            }

            this.loteCefRepositorio.Finalizar(lotecefPronto.LotecefId, qtdeDesejada);
        }
Пример #2
0
        public void Executar(ConfiguracaoDeLoteCef configuracaoDeLoteCef)
        {
            Contexto.LotesCef.Clear();
            var lotesCef = this.loteCefRepositorio.ObterAbertos(configuracaoDeLoteCef);

            while (lotesCef.Count < 1)
            {
                var novoLote = LoteCef.Novo();
                this.loteCefRepositorio.Salvar(novoLote);

                lotesCef.Add(novoLote);
            }

            foreach (var loteCef in lotesCef)
            {
                this.AdicionaNoContexto(loteCef.Id, loteCef.QuantidadeDeLotes);
            }
        }