public bool AddProfessor(List <CursoProfessor> _ListaCursoProfessor, CursoProfessor _cursoProfessor, Dictionary <long?, PrevisaoSKU> _listaPrevisaoSKU, ProfessorEmec _prof, string _indNaoEnade = null) { var qtdCursos = _ListaCursoProfessor.Where( x => x.Professores.Where( c => c.cpfProfessor == _prof.cpfProfessor).Count() > 0).Count(); var notaAnt = CalculaNota(_cursoProfessor, _listaPrevisaoSKU, _prof.Regime, _prof.Titulacao); var notaNova = CalculaNota(_cursoProfessor, _listaPrevisaoSKU, _prof.Regime, _prof.Titulacao, 1); var qtdProf = _cursoProfessor.Professores.Count(); if (notaNova >= notaAnt) { return(true); } else { return(false); } }
private List <CursoProfessor> MontaCursoProfessor20P([FromQuery] List <ProfessorCursoEmec> _profs, List <CursoEnquadramento> _CursoArea) { List <CursoProfessor> cursoProfessor = new List <CursoProfessor>(); var query = _profs; var CursoArea = _CursoArea.ToDictionary(x => x.CodEmec); foreach (var res in query) { // Filtra parâmtetro indGraduacao if (!(res.Titulacao == null || res.Titulacao == "GRADUADO")) //res.Titulacao != "GRADUADO" || ParametrosFiltro.indGraduado { if (cursoProfessor.Where(c => c.CodEmec == res.CodEmec).Count() > 0) { CursoProfessor prof = cursoProfessor.Find(x => x.CodEmec == res.CodEmec); prof.CodArea = (CursoArea.ContainsKey(Convert.ToInt32((prof.CodEmec)))) ? CursoArea[(Int32)prof.CodEmec].CodEmec : 9999; if (prof.Professores.Where(x => x.cpfProfessor == res.CpfProfessor).Count() == 0) { ProfessorEmec pr = new ProfessorEmec { cpfProfessor = res.CpfProfessor, Ativo = res.IndAtivo, Regime = res.Regime, Titulacao = res.Titulacao }; //prof.Professores = new Dictionary<long, ProfessorEmec>(); prof.Professores.Add(pr); } } else { CursoProfessor prof = new CursoProfessor(); prof.CodEmec = res.CodEmec; prof.Professores = new List <ProfessorEmec>(); ProfessorEmec pr = new ProfessorEmec { cpfProfessor = res.CpfProfessor, Ativo = res.IndAtivo, Regime = res.Regime, Titulacao = res.Titulacao }; prof.Professores.Add(pr); cursoProfessor.Add(prof); } } } return(cursoProfessor); }
public bool RemoveProfessor30Perc(List <CursoProfessor> _ListaCursoProfessor, CursoProfessor _cursoProfessor, Dictionary <long?, PrevisaoSKU> _listaPrevisaoSKU, ProfessorEmec _prof, double _meta, int _qtd_anterior) { var notaAnt = CalculaNota(_cursoProfessor, _listaPrevisaoSKU, _prof.Regime, _prof.Titulacao); var notaNova = CalculaNota(_cursoProfessor, _listaPrevisaoSKU, _prof.Regime, _prof.Titulacao, -1); var qtdProf = _cursoProfessor.Professores.Count(); if (notaNova > notaAnt && (_meta > _qtd_anterior - qtdProf)) { return(true); } else { return(false); } }
public void AddProfessor20p(List <CursoProfessor> _cursoProfessor, List <ProfessorCursoEmec20p> _listaProfessor20p, Dictionary <long?, PrevisaoSKU> _dicPrevisao, ParametrosCenso _param, List <string> _listaEnade) { // Controle de Uso Dictionary <long, int> listaUsoProfessor = new Dictionary <long, int>(); // Adiciona os professores 20% nos cursos Dictionary <string, string> dicEnade = new Dictionary <string, string>(); dicEnade = _listaEnade.ToDictionary(x => x); foreach (var emec in _listaProfessor20p) { try { if (dicEnade.ContainsKey(emec.CodEmec.ToString())) { var codEmec = emec.CodEmec; var qtd = (_cursoProfessor.Find(x => x.CodEmec == codEmec) != null) ? _cursoProfessor .Find(x => x.CodEmec == codEmec) .Professores .Where(x => x.cpfProfessor == emec.CpfProfessor).Count() : 0 ; if (qtd < 1) { var curso = _cursoProfessor.Find(x => x.CodEmec == emec.CodEmec); if (curso != null) { var _prof = new ProfessorEmec { Ativo = emec.IndAtivo, cpfProfessor = emec.CpfProfessor, Regime = emec.Regime, Titulacao = emec.Titulacao }; if (curso.Professores.Where(x => x.cpfProfessor == emec.CpfProfessor).Count() < 1 & AddProfessor(_cursoProfessor, curso, _dicPrevisao, _prof) & (listaUsoProfessor.TryGetValue(emec.CpfProfessor, out int dic) ? dic : 0) < _param.usoProfessor) { curso.Professores.Add(_prof); // Adciona controle de adição de professores if (listaUsoProfessor.ContainsKey(emec.CpfProfessor)) { listaUsoProfessor[emec.CpfProfessor] += 1; } else { listaUsoProfessor.Add(emec.CpfProfessor, 1); } } } } } } catch (System.Exception ex) { } } }
public bool RemoveProfessorExcluido(List <CursoProfessor> _ListaCursoProfessor, CursoProfessor _cursoProfessor, Dictionary <long?, PrevisaoSKU> _listaPrevisaoSKU, ProfessorEmec _prof) { var qtdCursos = _ListaCursoProfessor.Where( x => x.Professores.Where( c => c.cpfProfessor == _prof.cpfProfessor).Count() > 0).Count(); var notaAnt = CalculaNota(_cursoProfessor, _listaPrevisaoSKU, _prof.Regime, _prof.Titulacao); var notaNova = CalculaNota(_cursoProfessor, _listaPrevisaoSKU, _prof.Regime, _prof.Titulacao, -1); var qtdProf = _cursoProfessor.Professores.Count(); if (notaNova > notaAnt) { return(true); } else { return(false); } }
// ########## Monta a lista de cursos por professores ########## // ################# Monta Cursos dos Professores ###################### public List <CursoProfessor> MontaCursoProfessor([FromQuery] List <ProfessorCursoEmec> _profs, List <CursoEnquadramento> _CursoArea) { List <CursoProfessor> cursoProfessor = new List <CursoProfessor>(); // ProfessorCursoComparer pcc = new ProfessorCursoComparer(); // HashSet<CursoProfessor> hsCursoProfessor = new HashSet<CursoProfessor>(pcc); var query = _profs; var CursoArea = _CursoArea.ToDictionary(x => x.codEmec); try { foreach (var res in query) { // Filtra parâmtetro indGraduacao if (!(res.Titulacao == null || res.Titulacao == "GRADUADO")) //res.Titulacao != "GRADUADO" || ParametrosFiltro.indGraduado { if (res.CodEmec == 4959) { var a = 1; } if (cursoProfessor.Where(c => c.CodEmec == res.CodEmec).Count() > 0) { CursoProfessor prof = cursoProfessor.Find(x => x.CodEmec == res.CodEmec); prof.CodArea = (CursoArea.ContainsKey(Convert.ToInt32((prof.CodEmec)))) ? CursoArea[(Int32)prof.CodEmec].codArea : 9999; if (prof.Professores.Where(x => x.cpfProfessor == res.CpfProfessor).Count() == 0) { ProfessorEmec pr = new ProfessorEmec { cpfProfessor = res.CpfProfessor, Ativo = res.IndAtivo, Regime = res.Regime, Titulacao = res.Titulacao }; //prof.Professores = new Dictionary<long, ProfessorEmec>(); prof.Professores.Add(pr); } } else { CursoProfessor prof = new CursoProfessor(); prof.CodArea = (CursoArea.ContainsKey(Convert.ToInt32((res.CodEmec)))) ? CursoArea[(Int32)res.CodEmec].codArea : 9999; prof.CodEmec = res.CodEmec; prof.Professores = new List <ProfessorEmec>(); ProfessorEmec pr = new ProfessorEmec { cpfProfessor = res.CpfProfessor, Ativo = res.IndAtivo, Regime = res.Regime, Titulacao = res.Titulacao }; prof.Professores.Add(pr); cursoProfessor.Add(prof); } } } return(cursoProfessor); } catch (System.Exception ex) { return(null); } }
public bool RemoveProfessorBlackList(List <CursoProfessor> _ListaCursoProfessor, CursoProfessor _cursoProfessor, Dictionary <long?, PrevisaoSKU> _listaPrevisaoSKU, ProfessorEmec _prof) { var dic = ProfessorBlaklist.GetBlackList(this.Configuration); if (dic.ContainsKey(_prof.cpfProfessor.ToString())) { if (dic[_prof.cpfProfessor.ToString()].ListaCodEmec.Contains(_cursoProfessor.CodEmec)) { return(true); } } return(false); }
public List <Resultado> OtimizaCurso(Dictionary <long?, PrevisaoSKU> _dicPrevisao, List <ProfessorCursoEmec> _ListaProfessorEmec, List <CursoProfessor> _listaProfessor, List <CursoEnquadramento> _listaCursoEnquadramento, ParametrosCenso _parametros) { var cargaDS = this.CargaContext.CargaDS .ToDictionary(x => x.CpfProfessor); var cargaFS = this.CargaContext.CargaFS .ToDictionary(x => x.CpfProfessor); ListaprofessorCurso = new List <ProfessorCurso>(); var TaskEnade = Task.Run(() => { return(this.Context.CursoCenso.ToList()); }); var ListaProfessorAdd = this.ProfessorAddContext.Professor.ToList(); // ############## Alavanca Curso não Enade ############ // #################################################### Task.WaitAll(TaskEnade); var CursoEnade = TaskEnade.Result; var CursoNaoEnade = CursoEnade.Where(x => x.IndEnade.Contains('N')).Select(c => c.CodEmec.ToString()).Distinct().ToList(); var CursoSimEnade = CursoEnade.Where(x => x.IndEnade.Contains('S')).Select(c => c.CodEmec.ToString()).Distinct().ToList(); foreach (var item in _listaProfessor) { item.Professores.RemoveAll(pe => RemoveProfessor(_listaProfessor, item, _dicPrevisao, pe, "S") && _listaProfessor.Where(cp => cp.Professores .Where(p => p.cpfProfessor == pe.cpfProfessor).Count() > 0) .Select(cp => cp.CodEmec) .ToList() .Exists(x => CursoNaoEnade.Contains(x.ToString()) && CursoSimEnade.Contains(item.CodEmec.ToString())) ); } ; // ######################## Alavanca Colaborador ######################## // foreach (var item in _listaProfessor) { item.Professores.RemoveAll(pe => (RemoveProfessor(_listaProfessor, item, _dicPrevisao, pe) && pe.Regime == "HORISTA" && ((cargaDS.TryGetValue(pe.cpfProfessor.ToString(), out var ds) ? ds.QtdHoras : 0) + (cargaFS.TryGetValue(pe.cpfProfessor.ToString(), out var fs) ? fs.QtdHoras : 0)) < 8 )); } ; // ######################## Alavanca Excluído Ofensor ######################## // foreach (var item in _listaProfessor) { item.Professores.RemoveAll(pe => (RemoveProfessorExcluido(_listaProfessor, item, _dicPrevisao, pe) && pe.Ativo == "NÃO" )); } ; // ######################## Limpeza força bruta ######################## // foreach (var item in _listaProfessor) { item.Professores.RemoveAll(pe => (RemoveProfessor(_listaProfessor, item, _dicPrevisao, pe, "N") && (CalculaNota(item, _dicPrevisao, pe.Regime, pe.Titulacao) ?? 0) < 1.945 )); } ; // ##################### Black List ############################### // // ProfessorBlaklist // foreach(var item in _listaProfessor) // { // item.Professores.RemoveAll(pe => // (RemoveProfessorBlackList(_listaProfessor, item, _dicPrevisao, pe) // )); // }; // ##################### Alavancas ########################## // // Remove professor Cenário 2 - Hoper /* * * HashSet<long> CursoExcluir = new HashSet<long>() * { * * * }; * * foreach (var item in _listaProfessor) * { * * if (CursoExcluir.Contains(item.CodEmec)) * { * int removido= 0; * double meta = Math.Floor(item.Professores.Count() * 0.3); * int qtdAnterior = item.Professores.Count(); * * * // item.Professores.RemoveAll(pe => * * // RemoveProfessor30Perc(_listaProfessor, item, _dicPrevisao, pe, meta, qtdAnterior) * // ); * * * foreach (var pe in item.Professores) * { * if (RemoveProfessor30Perc(_listaProfessor, item, _dicPrevisao, pe, meta, qtdAnterior) && * meta > removido) * { * pe.ind_remover = "S"; * removido++; * } * } * * item.Professores.RemoveAll(pe => pe.ind_remover == "S"); * * } * * } */ // ##################### Professor Adicionado ############################### // try { ProfessorEmec professorEmec; foreach (var item in ListaProfessorAdd) { CursoProfessor curso; if (_listaProfessor.Where(x => x.CodEmec == item.CodEmec).Count() < 1) { CursoProfessor Cr = new CursoProfessor(); Cr.CodEmec = item.CodEmec; Cr.CodArea = 9999; curso = Cr; curso.Professores = new List <ProfessorEmec>(); _listaProfessor.Add(curso); } curso = _listaProfessor.First(x => x.CodEmec == item.CodEmec); var prof = _ListaProfessorEmec.Where(x => x.CpfProfessor == item.CpfProfessor); if (prof.Count() != 0) { var profi = prof.First(); professorEmec = new ProfessorEmec(); professorEmec.cpfProfessor = profi.CpfProfessor; professorEmec.Regime = profi.Regime; professorEmec.Titulacao = profi.Titulacao; professorEmec.Ativo = profi.IndAtivo; curso.Professores.Add(professorEmec); } else { // Criando professor que não está na curso professor professorEmec = new ProfessorEmec(); professorEmec.cpfProfessor = item.CpfProfessor; professorEmec.Regime = "TEMPO INTEGRAL"; professorEmec.Titulacao = "DOUTOR"; professorEmec.Ativo = "SIM"; curso.Professores.Add(professorEmec); } prof = null; curso = null; } ; } catch (System.Exception ex) { } var final = CalculaNotaCursos(_dicPrevisao, _listaProfessor, CursoSimEnade); return(final); }