Skip to content
Snippets Groups Projects
Commit 0a3551c1 authored by ROBERTO JÚNIOR's avatar ROBERTO JÚNIOR
Browse files

Voltando as alterações do commit

88047377. Para atender a issue 613
parent 312c1451
Branches
No related tags found
2 merge requests!43Atualizado a página de publicações no simcaq,!8Rs
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { map } from 'rxjs/operators';
import * as _ from 'lodash';
import { Functionality } from '../../../../shared/entities/functionality/functionality';
......@@ -8,10 +8,12 @@ import { HttpService } from '../../../../shared/services/http/http.service';
import { UtilitiesService } from '../../../../shared/services/utilities/utilities.service';
import { CollaborationScheme } from '../entities/collaboration-scheme';
import { CollaborationSchemesByStage } from '../entities/collaboration-schemes-by-stage';
import { SelectLocation } from '../../../select-location/entities/select-location';
import { SessionService } from '../../../../shared/services/session/session.service';
import { AdmDependency } from '../../../../shared/entities/enums/adm-dependency.enum';
import { EnrollmentProjection } from '../../enrollment-projection/entities/enrollment-projection';
import { EnrollmentProjectionByLocation } from '../../enrollment-projection/entities/enrollment-projection-by-location';
import { ViewEnrollmentByStageSeries } from '../../view-enrollment-by-stage-series/entities/view-enrollment-by-stage-series';
import { CurrentYearService } from '../../../shared/services/current-year/current-year.service';
import { NavigableComponentService } from '../../../shared/entities/base/navigable-component-service';
import { SourceInformationEnum } from './../../../../shared/entities/enums/source-information.enum';
......@@ -33,8 +35,6 @@ export class CollaborationSchemeService implements NavigableComponentService {
collaborationScheme.totalCurrentPublicEnrollment = 0;
collaborationScheme.totalProposalPublicEnrollment = 0;
return this.getEnrollmentT4().pipe(
switchMap(enrollmentT4 => {
return this.utilitiesService.getStages().pipe(
map(stages => {
collaborationSchemesByStage = stages.map(stage => new CollaborationSchemesByStage({
......@@ -47,27 +47,26 @@ export class CollaborationSchemeService implements NavigableComponentService {
municipalPercentage: 0
}));
const resultForEnrollmentProjection: EnrollmentProjection = this.sessionService.getItem<EnrollmentProjection>(Functionality.enrollmentProjection.key);
const enrollmentOfferYear: number = this.currentYearService.getEnrollmentCurrentYear();
collaborationScheme.yearCurrentPublicEnrollment = enrollmentOfferYear;
collaborationScheme.yearProposalPublicEnrollment = enrollmentOfferYear + 1;
const resultForEnrollmentProjection: EnrollmentProjection = this.sessionService.getItem<EnrollmentProjection>(Functionality.enrollmentProjection.key);
const resultForViewEnrollmentProjection: ViewEnrollmentByStageSeries =
this.sessionService.getItem<ViewEnrollmentByStageSeries>(Functionality.viewEnrollmentByStageAndSeries.key);
const resultForSelectLocation: SelectLocation = this.sessionService.getItem<SelectLocation>(Functionality.selectLocation.key);
for (const stage of stages) {
const collaboration: CollaborationSchemesByStage = _.find(collaborationSchemesByStage, c => c.id === stage.id);
const stagesAdmDependencyLocationEnrollments = _.filter(enrollmentT4, s => s.education_level_short_id === stage.id);
const enrollmentsByAdmDependencyFederal = _.find(stagesAdmDependencyLocationEnrollments, t => t.adm_dependency_id === AdmDependency.Federal);
const enrollmentsByAdmDependencyState = _.find(stagesAdmDependencyLocationEnrollments, t => t.adm_dependency_id === AdmDependency.State);
const enrollmentsByAdmDependencyMunicipal = _.find(stagesAdmDependencyLocationEnrollments, t => t.adm_dependency_id === AdmDependency.Municipal);
const totalEnrollmentsByAdmDependencyFederal = enrollmentsByAdmDependencyFederal ? enrollmentsByAdmDependencyFederal.total : 0;
const totalEnrollmentsByAdmDependencyState = enrollmentsByAdmDependencyState ? enrollmentsByAdmDependencyState.total : 0;
const totalEnrollmentsByAdmDependencyMunicipal = enrollmentsByAdmDependencyMunicipal ? enrollmentsByAdmDependencyMunicipal.total : 0;
const stagesAdmDependencyLocationEnrollments = _.find(resultForViewEnrollmentProjection.stagesAdmDependencyLocationEnrollments, s => s.id === stage.id);
const totalCurrentPublicEnrollment =
(totalEnrollmentsByAdmDependencyFederal + totalEnrollmentsByAdmDependencyState + totalEnrollmentsByAdmDependencyMunicipal);
const totalEnrollmentsByAdmDependencyFederal = _.find(stagesAdmDependencyLocationEnrollments.totalEnrollmentsByAdmDependency, t => t.id === AdmDependency.Federal);
const totalEnrollmentsByAdmDependencyState = _.find(stagesAdmDependencyLocationEnrollments.totalEnrollmentsByAdmDependency, t => t.id === AdmDependency.State);
const totalEnrollmentsByAdmDependencyMunicipal = _.find(stagesAdmDependencyLocationEnrollments.totalEnrollmentsByAdmDependency, t => t.id === AdmDependency.Municipal);
const totalCurrentPublicEnrollment = (totalEnrollmentsByAdmDependencyFederal.quantity + totalEnrollmentsByAdmDependencyState.quantity + totalEnrollmentsByAdmDependencyMunicipal.quantity);
if (collaboration) {
const enrollmentProjectionByLocation: EnrollmentProjectionByLocation = _.head(resultForEnrollmentProjection.enrollmentsProjectionsByLocations);
......@@ -75,15 +74,15 @@ export class CollaborationSchemeService implements NavigableComponentService {
const stageEnrollment = _.find(enrollmentProjectionByLocation.stagesEnrollments, r => r.id === stage.id);
if (stageEnrollment) {
collaboration.numberCurrentPublicEnrollment = totalCurrentPublicEnrollment;
collaboration.numberCurrentPublicEnrollment = stageEnrollment.totalCurrentOffers;
const stagesEnrollmentsProposal = _.find(enrollmentProjectionByLocation.stagesEnrollments, r => r.id === stage.id);
collaboration.numberProposalPublicEnrollment =
_.find(stagesEnrollmentsProposal.totalEnrollments, s => s.year === collaborationScheme.yearProposalPublicEnrollment).quantity;
collaboration.federalPercentage = ((totalEnrollmentsByAdmDependencyFederal / totalCurrentPublicEnrollment) * 100);
collaboration.statePercentage = ((totalEnrollmentsByAdmDependencyState / totalCurrentPublicEnrollment) * 100);
collaboration.municipalPercentage = ((totalEnrollmentsByAdmDependencyMunicipal / totalCurrentPublicEnrollment) * 100);
collaboration.federalPercentage = ((totalEnrollmentsByAdmDependencyFederal.quantity / totalCurrentPublicEnrollment) * 100);
collaboration.statePercentage = ((totalEnrollmentsByAdmDependencyState.quantity / totalCurrentPublicEnrollment) * 100);
collaboration.municipalPercentage = ((totalEnrollmentsByAdmDependencyMunicipal.quantity / totalCurrentPublicEnrollment) * 100);
}
}
......@@ -96,7 +95,6 @@ export class CollaborationSchemeService implements NavigableComponentService {
return collaborationScheme;
}));
}));
}
getSourceInformations(): Array<Footnote> {
......@@ -113,29 +111,4 @@ export class CollaborationSchemeService implements NavigableComponentService {
}));
return footNotes;
}
getEnrollmentT4(): Observable<any> {
let filtersLocation: Array<string> = new Array<string>();
const enrollmentCurrentYear: number = this.currentYearService.getEnrollmentCurrentYear();
filtersLocation = this.utilitiesService.getSelectLocationFilter();
let filters: Array<string> = new Array<string>(
`min_year:"${enrollmentCurrentYear}"`,
`max_year:"${enrollmentCurrentYear}"`,
`adm_dependency:["1","2","3"]`
);
filters = filters.concat(filtersLocation);
const options: any = this.httpService.getRequestOptionsWithSearchParams(new Map<string, string>([['filter', filters.join(',')]]));
return this.httpService.getApiEndpoint().pipe(
switchMap(apiEndpoint => {
return this.httpService.get<Array<any>>(`${apiEndpoint}/enrollment?dims=education_level_short,adm_dependency`, options).pipe(
map(diagnosticT4 => diagnosticT4));
}));
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment