public async Task <IEnumerable <ConselhoDeClasseGrupoMatrizDto> > ObterListagemDeSinteses(long conselhoClasseId, long fechamentoTurmaId, string alunoCodigo, string codigoTurma, int bimestre) { var retorno = new List <ConselhoDeClasseGrupoMatrizDto>(); var fechamentoTurma = await consultasFechamentoTurma.ObterCompletoPorIdAsync(fechamentoTurmaId); var turma = fechamentoTurma?.Turma; if (fechamentoTurma == null) { turma = await repositorioTurma.ObterPorCodigo(codigoTurma); if (turma == null) { throw new NegocioException("Turma não encontrada"); } if (turma.AnoLetivo == DateTime.Today.Year) { throw new NegocioException("Não existe fechamento para a turma"); } } if (turma.AnoLetivo != 2020 && turma.AnoLetivo == DateTime.Now.Year && bimestre == 0 && !await ExisteConselhoClasseUltimoBimestreAsync(turma, alunoCodigo)) { throw new NegocioException("Aluno não possui conselho de classe do último bimestre"); } var usuario = await servicoUsuario.ObterUsuarioLogado(); var disciplinas = await servicoEOL.ObterDisciplinasPorCodigoTurma(turma.CodigoTurma); if (disciplinas == null || !disciplinas.Any()) { return(null); } var gruposMatrizes = disciplinas.Where(x => !x.LancaNota && x.GrupoMatriz != null) .GroupBy(c => new { Id = c.GrupoMatriz?.Id, Nome = c.GrupoMatriz?.Nome }); var frequenciaAluno = await repositorioFrequenciaAlunoDisciplinaPeriodo.ObterFrequenciaBimestresAsync(alunoCodigo, bimestre, turma.CodigoTurma); foreach (var grupoDisiplinasMatriz in gruposMatrizes.OrderBy(k => k.Key.Nome)) { var grupoMatriz = new ConselhoDeClasseGrupoMatrizDto() { Id = grupoDisiplinasMatriz.Key.Id ?? 0, Titulo = grupoDisiplinasMatriz.Key.Nome ?? "", ComponenteSinteses = new List <ConselhoDeClasseComponenteSinteseDto>() }; foreach (var componenteCurricular in grupoDisiplinasMatriz.Where(x => x.LancaNota)) { var componenteCurricularDto = await MapearDto(frequenciaAluno, componenteCurricular, bimestre); grupoMatriz.ComponenteSinteses.Add(componenteCurricularDto); } retorno.Add(grupoMatriz); } return(retorno); }
public async Task <ConsultasConselhoClasseRecomendacaoConsultaDto> ObterRecomendacoesAlunoFamilia(long conselhoClasseId, long fechamentoTurmaId, string alunoCodigo, string codigoTurma, int?bimestre) { var fechamentoTurma = await consultasFechamentoTurma.ObterCompletoPorIdAsync(fechamentoTurmaId); var turma = fechamentoTurma?.Turma; var periodoEscolar = fechamentoTurma?.PeriodoEscolar; var emFechamento = true; if (fechamentoTurma == null) { turma = await consultasTurma.ObterPorCodigo(codigoTurma); if (turma == null) { throw new NegocioException("Turma não encontrada"); } var tipoCalendario = await repositorioTipoCalendario.BuscarPorAnoLetivoEModalidade(turma.AnoLetivo, turma.ModalidadeTipoCalendario, turma.Semestre); if (tipoCalendario == null) { throw new NegocioException("Tipo calendário não encontrado"); } periodoEscolar = await consultasPeriodoEscolar.ObterPeriodoEscolarPorTipoCalendarioBimestre(tipoCalendario.Id, bimestre.Value); } if (!bimestre.HasValue) { if (fechamentoTurma.Turma.AnoLetivo != 2020) { var validacaoConselhoFinal = await consultasConselhoClasse.ValidaConselhoClasseUltimoBimestre(turma); if (!validacaoConselhoFinal.Item2) { throw new NegocioException($"Para acessar este aba você precisa registrar o conselho de classe do {validacaoConselhoFinal.Item1}º bimestre"); } } emFechamento = await consultasPeriodoFechamento.TurmaEmPeriodoDeFechamento(turma.CodigoTurma, DateTime.Today); } else { emFechamento = await consultasPeriodoFechamento.TurmaEmPeriodoDeFechamento(turma.CodigoTurma, DateTime.Today, bimestre.Value); } var anotacoesDoAluno = await consultasFechamentoAluno.ObterAnotacaoAlunoParaConselhoAsync(alunoCodigo, fechamentoTurmaId); if (anotacoesDoAluno == null) { anotacoesDoAluno = new List <FechamentoAlunoAnotacaoConselhoDto>(); } var conselhoClasseAluno = fechamentoTurma != null ? await repositorioConselhoClasseAluno.ObterPorFechamentoAsync(fechamentoTurma.Id, alunoCodigo): null; if (conselhoClasseAluno == null || string.IsNullOrEmpty(conselhoClasseAluno.RecomendacoesAluno) || string.IsNullOrEmpty(conselhoClasseAluno.RecomendacoesFamilia)) { return(await ObterRecomendacoesIniciais(conselhoClasseAluno, anotacoesDoAluno, emFechamento)); } return(TransformaEntidadeEmConsultaDto(conselhoClasseAluno, anotacoesDoAluno, emFechamento)); }