Added Rendicontazione Singolo Cartellino

This commit is contained in:
Giancarlo Panichi 2022-10-04 18:18:19 +02:00
parent 3caea5bd36
commit 94f33cf0ba
14 changed files with 335 additions and 7 deletions

View File

@ -1,6 +1,8 @@
package it.cnr.isti.epasmed.epas.service;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -18,4 +20,16 @@ public class EPASAbsenceTypesService {
return epasAbsenceTypesClient.getAbsenceTypes();
}
public LinkedHashMap<String,String> getAbsenceTypesMap() {
List<EPASAbsenceTypes> epasAbsenceTypeList=epasAbsenceTypesClient.getAbsenceTypes();
LinkedHashMap<String,String> epasAbsenceTypeMap=new LinkedHashMap<>();
if(epasAbsenceTypeList!=null && !epasAbsenceTypeList.isEmpty()) {
epasAbsenceTypeMap=epasAbsenceTypeList.stream().collect(
Collectors.toMap(EPASAbsenceTypes::getCode, EPASAbsenceTypes::getDescription,
(oldValue, newValue) -> newValue, LinkedHashMap::new));
}
return epasAbsenceTypeMap;
}
}

View File

@ -9,6 +9,7 @@ import java.time.format.DateTimeFormatterBuilder;
import java.time.format.DateTimeParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@ -39,6 +40,7 @@ import it.cnr.isti.epasmed.epas.model.EPASStampings;
import it.cnr.isti.epasmed.epas.model.EPASTimeCards;
import it.cnr.isti.epasmed.epas.model.EPASValidates;
import it.cnr.isti.epasmed.epas.model.EPASWorkingTimeTypes;
import it.cnr.isti.epasmed.epas.service.EPASAbsenceTypesService;
import it.cnr.isti.epasmed.epas.service.EPASAffiliationsService;
import it.cnr.isti.epasmed.epas.service.EPASGroupsService;
import it.cnr.isti.epasmed.epas.service.EPASOffSiteWorksService;
@ -127,6 +129,8 @@ public class SyncService {
EPASValidatesService epasValidatesService;
@Autowired
EPASOffSiteWorksService epasOffSiteWorksService;
@Autowired
EPASAbsenceTypesService epasAbsenceTypeService;
private boolean banagrafico;
private boolean bemail;
@ -198,7 +202,7 @@ public class SyncService {
setBWriteTables();
List<TabsSI> tabsSI = tabsSIService.getAllTabsSI();
Long fluxId = siMasterLogService.startFluxWrites();
writeSingleTimeCardsData(fluxId, tabsSI, year, month,fc);
writeSingleTimeCardsData(fluxId, tabsSI, year, month, fc);
siMasterLogService.closeFluxWrites(fluxId, writeTabs());
}
@ -1192,6 +1196,8 @@ public class SyncService {
EPASTimeCards epasTimeCards = epasTimeCardsService.getTimeCardByPersonFiscalCode(person.getFiscalCode(),
year, month);
LinkedHashMap<String, String> epasAbsenceTypeMap = epasAbsenceTypeService.getAbsenceTypesMap();
EPASPersons epasPerson = epasTimeCards.getPerson();
Integer personId = Integer.valueOf(epasPerson.getId());
@ -1199,7 +1205,7 @@ public class SyncService {
Long id = Long.valueOf(epasPersonDay.getId());
StringBuilder motivo = new StringBuilder();
extractMotivoInfo(epasPersonDay, motivo);
extractMotivoInfo(epasPersonDay, epasAbsenceTypeMap, motivo);
java.sql.Date date = null;
try {
@ -1265,6 +1271,7 @@ public class SyncService {
EPASTimeCards epasTimeCards = epasTimeCardsService.getTimeCardByPersonFiscalCode(person.getFiscalCode(), year,
month);
LinkedHashMap<String, String> epasAbsenceTypeMap = epasAbsenceTypeService.getAbsenceTypesMap();
EPASPersons epasPerson = epasTimeCards.getPerson();
Integer personId = Integer.valueOf(epasPerson.getId());
@ -1272,7 +1279,7 @@ public class SyncService {
Long id = Long.valueOf(epasPersonDay.getId());
StringBuilder motivo = new StringBuilder();
extractMotivoInfo(epasPersonDay, motivo);
extractMotivoInfo(epasPersonDay, epasAbsenceTypeMap, motivo);
java.sql.Date date = null;
try {
@ -1293,7 +1300,7 @@ public class SyncService {
tab.setIdFlusso(fluxId);
tab.setLastUpdate(now);
tabsSIService.updateTabsSI(tab);
}
private TimeCardsReporting createTimeCardReporting(Long fluxId, String year, String month, LocalDateTime now) {
@ -1366,7 +1373,9 @@ public class SyncService {
}
private void extractMotivoInfo(EPASPersonDays epasPersonDay, StringBuilder motivo) {
private void extractMotivoInfo(EPASPersonDays epasPersonDay,
LinkedHashMap<String, String> epasAbsenceTypeMap,
StringBuilder motivo) {
if (epasPersonDay.getIsHoliday()) {
motivo.append("[Festivo]");
}
@ -1403,6 +1412,12 @@ public class SyncService {
// motivo.append(epasAbsences.getJustifiedType());
// motivo.append("-");
motivo.append(epasAbsences.getCode());
String description=epasAbsenceTypeMap.get(epasAbsences.getCode());
if(description!=null && !description.isEmpty()) {
motivo.append("-");
motivo.append(description);
}
if (epasAbsences.getNote() != null && !epasAbsences.getNote().isEmpty()) {
motivo.append("-");
motivo.append(epasAbsences.getNote());

View File

@ -1,5 +1,6 @@
package it.cnr.isti.epasmed.web.rest.epas;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Optional;
@ -44,9 +45,25 @@ public class EPASAbsenceTypesResource {
List<EPASAbsenceTypes> epasAbsenceTypesList = null;
epasAbsenceTypesList = epasAbsenceTypesService.getAbsenceTypes();
return ResponseUtil.wrapOrNotFound(Optional.of(epasAbsenceTypesList));
}
/**
* {@code GET /absenceTypesMap} : get the absence types map.
*
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body
* the map of EPAS Absence Types Code and EPAS Absence Types
* Description, or with status {@code 404 (Not Found)}.
*/
@GetMapping("/absenceTypesMap")
public ResponseEntity<LinkedHashMap<String, String>> getEPASAbsencesTypesMap() {
log.debug("REST request GET EPAS Absences Types Map");
LinkedHashMap<String, String> epasAbsenceTypesMap = null;
epasAbsenceTypesMap = epasAbsenceTypesService.getAbsenceTypesMap();
return ResponseUtil.wrapOrNotFound(Optional.of(epasAbsenceTypesMap));
}
}

View File

@ -6,3 +6,4 @@ export const VERSION = process.env.VERSION;
export const DEBUG_INFO_ENABLED = Boolean(process.env.DEBUG_INFO_ENABLED);
export const SERVER_API_URL = process.env.SERVER_API_URL;
export const BUILD_TIMESTAMP = process.env.BUILD_TIMESTAMP;
export const OFFICE_DEFAULT_ID = '1';

View File

@ -55,6 +55,12 @@
<span>Rendicontazione</span>
</a>
</li>
<li>
<a class="dropdown-item" routerLink="operations/rendicontazionesingolo" routerLinkActive="active" (click)="collapseNavbar()">
<fa-icon icon="cloud" [fixedWidth]="true"></fa-icon>
<span>Rendicontazione Singolo Cart.</span>
</a>
</li>
<li>
<a class="dropdown-item" routerLink="operations/sync" routerLinkActive="active" (click)="collapseNavbar()">
<fa-icon icon="cloud" [fixedWidth]="true"></fa-icon>

View File

@ -12,6 +12,13 @@ import { RouterModule } from '@angular/router';
pageTitle: 'Rendicontazione',
},
},
{
path: 'rendicontazionesingolo',
loadChildren: () => import('./rendicontazionesingolo/rendicontazionesingolo.module').then(m => m.RendicontazioneSingoloModule),
data: {
pageTitle: 'Rendicontazione Singolo Cart.',
},
},
{
path: 'sync',
loadChildren: () => import('./sync/sync.module').then(m => m.SyncModule),

View File

@ -0,0 +1,68 @@
<div class="table-responsive">
<h2 id="logs-page-heading">Rendicontazione Singolo Cartellino</h2>
<jhi-alert-error></jhi-alert-error>
<jhi-alert></jhi-alert>
<p>Rendiconta Singolo Cartellino da ePAS a Sistema Informativo.</p>
<div class="page-min-height">
<form>
<div class="form-group">
<label for="annoRendicontazione">Anno</label> <input type="number"
class="form-control" id="annoRendicontazione"
name="annoRendicontazione" min="2000" max="3000" [(ngModel)]="year"
required>
<!-- -->
</div>
<div class="form-group">
<label for="meseRendicontazione">Mese</label> <select
id="meseRendicontazione" name="meseRendicontazione"
class="form-select form-control" aria-label="Mese"
[(ngModel)]="month" required>
<option value="1">Gennaio</option>
<option value="2">Febbraio</option>
<option value="3">Marzo</option>
<option value="4">Aprile</option>
<option value="5">Maggio</option>
<option value="6">Giugno</option>
<option value="7">Luglio</option>
<option value="8">Agosto</option>
<option value="9">Settembre</option>
<option value="10">Ottobre</option>
<option value="10">Novembre</option>
<option value="12">Dicembre</option>
</select>
</div>
<div class="form-group">
<label for="dipendente">Dipendente</label> <select id="dipendente" name="dipendente"
class="form-select form-control" aria-label="Dipendente"
[(ngModel)]="fiscalCode" required>
<option *ngFor="let dip of dipendenti" value="{{dip.fiscalCode}}">{{dip.fullname}}</option>
</select>
<!--
<input id="dipendente"
type="text" class="form-control" [(ngModel)]="dipendente"
[ngModelOptions]="{standalone: true}"
[ngbTypeahead]="search" [inputFormatter]="formatter"
[resultFormatter]="formatter" [editable]='false' required /> -->
</div>
<button class="btn btn-primary" type="button" [disabled]="isLoading"
(click)="rendicontaSingolo()">Rendiconta Singolo</button>
</form>
<div *ngIf="isLoading" class="d-flex justify-content-center">
<div class="spinner-border text-dark" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,96 @@
import { Component, OnInit } from '@angular/core';
import { EPASPerson } from './rendicontazionesingolo.model';
import { RendicontazioneSingoloService } from './rendicontazionesingolo.service';
import { HttpErrorResponse } from '@angular/common/http';
// import { Observable, OperatorFunction } from 'rxjs';
// import { debounceTime, distinctUntilChanged, map, filter } from 'rxjs/operators';
@Component({
selector: 'jhi-rendicontazionesingolo',
templateUrl: './rendicontazionesingolo.component.html',
styleUrls: ['rendicontazionesingolo.scss'],
})
export class RendicontazioneSingoloComponent implements OnInit {
year: number;
month: number;
fiscalCode: string;
dipendenti: EPASPerson[];
isLoading = false; // hidden by default
constructor(private rendicontazioneSingoloService: RendicontazioneSingoloService) {
const date: Date = new Date();
this.year = date.getFullYear();
this.month = date.getMonth() + 1;
this.fiscalCode = '';
this.dipendenti = [];
}
ngOnInit(): void {
this.rendicontazioneSingoloService.getPersonList().subscribe(
(result: EPASPerson[]) => {
this.dipendenti = result;
this.dipendenti.forEach(dip =>
// eslint-disable-next-line no-console
console.log(dip)
);
},
error =>
// eslint-disable-next-line no-console
console.log(error)
);
}
// formatter = (dipendente: EPASPerson) => dipendente.fullname;
// search: OperatorFunction<string, readonly EPASPerson[]> = (text$: Observable<string>) => text$.pipe(
// debounceTime(200),
// distinctUntilChanged(),
// filter(term => term.length >= 2),
// map(term => this.dipendenti.filter(dipendente => new RegExp(term, 'mi').test(dipendente.fullname.toLocaleLowerCase())).slice(0, 10))
// );
rendicontaSingolo(): void {
this.isLoading = true;
if (this.year == null || this.year <= 0) {
// eslint-disable-next-line no-console
console.log('Select the year');
this.isLoading = false;
return;
}
if (this.month == null || this.month <= 0) {
// eslint-disable-next-line no-console
console.log('Select the month');
this.isLoading = false;
return;
}
if (!this.fiscalCode) {
// eslint-disable-next-line no-console
console.log('Select the employee');
this.isLoading = false;
return;
}
// eslint-disable-next-line no-console
console.log(this.fiscalCode);
this.rendicontazioneSingoloService.rendicontaSingolo(this.year, this.month, this.fiscalCode).subscribe(
() => this.onSuccess(),
error => this.onError(error)
);
}
private onSuccess(): void {
this.isLoading = false;
// eslint-disable-next-line no-console
console.log('Success');
}
private onError(error: HttpErrorResponse): void {
this.isLoading = false;
// eslint-disable-next-line no-console
console.log('Error');
// eslint-disable-next-line no-console
console.log(error);
}
}

View File

@ -0,0 +1,3 @@
export class EPASPerson {
constructor(public id: string, public fullname: string, public fiscalCode: string) {}
}

View File

@ -0,0 +1,13 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { EpasmedSharedModule } from 'app/shared/shared.module';
import { RendicontazioneSingoloComponent } from './rendicontazionesingolo.component';
import { rendicontazioneSingoloRoute } from './rendicontazionesingolo.route';
@NgModule({
imports: [EpasmedSharedModule, RouterModule.forChild(rendicontazioneSingoloRoute)],
declarations: [RendicontazioneSingoloComponent],
entryComponents: [RendicontazioneSingoloComponent],
})
export class RendicontazioneSingoloModule {}

View File

@ -0,0 +1,13 @@
import { Routes } from '@angular/router';
import { RendicontazioneSingoloComponent } from './rendicontazionesingolo.component';
export const rendicontazioneSingoloRoute: Routes = [
{
path: '',
component: RendicontazioneSingoloComponent,
data: {
pageTitle: 'Rendicontazione Singolo Cart.',
},
},
];

View File

@ -0,0 +1,21 @@
@import '~bootstrap/scss/functions';
@import '~bootstrap/scss/variables';
button.btn.btn-outline-secondary.calendar,
button.btn.btn-outline-secondary.calendar:active {
width: 2.75rem;
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACIAAAAcCAYAAAAEN20fAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAEUSURBVEiJ7ZQxToVAEIY/YCHGxN6XGOIpnpaEsBSeQC9ArZbm9TZ6ADyBNzAhQGGl8Riv4BLAWAgmkpBYkH1b8FWT2WK/zJ8ZJ4qiI6XUI3ANnGKWBnht2/ZBDRK3hgVGNsCd7/ui+JkEIrKtqurLpEWaphd933+IyI3LEIdpCYCiKD6HcuOa/nwOa0ScJEnk0BJg0UTUWJRl6RxCYEzEmomsIlPU3IPW+grIAbquy+q6fluy/28RIBeRMwDXdXMgXLj/B2uimRXpui4D9sBeRLKl+1N+L+t6RwbWrZliTTTr1oxYtzVWiTQAcRxvTX+eJMnlUDaO1vpZRO5NS0x48sIwfPc87xg4B04MCzQi8hIEwe4bl1DnFMCN2zsAAAAASUVORK5CYII=') !important;
background-repeat: no-repeat;
background-size: 23px;
background-position: center;
}
.page-min-height {
min-height: 500px;
}
.ngb-typeahead-scrollable {
max-height: 200px;
overflow-y: auto;
overflow-x: hidden;
}

View File

@ -0,0 +1,24 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { HttpClient, HttpParams } from '@angular/common/http';
import { SERVER_API_URL, OFFICE_DEFAULT_ID } from 'app/app.constants';
import { EPASPerson } from './rendicontazionesingolo.model';
@Injectable({ providedIn: 'root' })
export class RendicontazioneSingoloService {
constructor(private http: HttpClient) {}
rendicontaSingolo(year: number, month: number, fiscalCode: string): Observable<{}> {
let queryParams = new HttpParams();
queryParams = queryParams.append('year', year + '');
queryParams = queryParams.append('month', month + '');
queryParams = queryParams.append('fiscalCode', fiscalCode);
return this.http.get(SERVER_API_URL + 'api/sync/writesSingleTimeCards', { params: queryParams });
}
getPersonList(): Observable<EPASPerson[]> {
let queryParams = new HttpParams();
queryParams = queryParams.append('officeId', OFFICE_DEFAULT_ID);
return this.http.get<EPASPerson[]>(SERVER_API_URL + 'api/epas/persons', { params: queryParams });
}
}

View File

@ -3,7 +3,9 @@ package it.cnr.isti.epasmed.web.rest.epas;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -81,4 +83,32 @@ public class EPASAbsenceTypesResourceIT {
}
@Test
public void getAbsenceTypesMap() throws Exception {
LinkedHashMap<String, String> epasAbsenceTypesMap = null;
try {
MvcResult result = restEPASAbsenceTypesMockMvc.perform(get("/api/epas/absenceTypesMap"))
.andExpect(status().isOk()).andReturn();
ObjectMapper mapper = new ObjectMapper();
epasAbsenceTypesMap = mapper.readValue(result.getResponse().getContentAsString(),
new TypeReference<LinkedHashMap<String, String>>() {
});
} catch (Exception e) {
log.error(e.getLocalizedMessage(), e);
return;
}
if (epasAbsenceTypesMap != null) {
log.info("EPAS Absence Types Map size: {}", epasAbsenceTypesMap.size());
for (Map.Entry<String, String> m : epasAbsenceTypesMap.entrySet()) {
log.info(m.getKey() + "-" + m.getValue());
}
}
}
}