diff --git a/src/main/java/it/cnr/isti/epasmed/config/SyncConfiguration.java b/src/main/java/it/cnr/isti/epasmed/config/SyncConfiguration.java index c45574e..ba4b1c8 100755 --- a/src/main/java/it/cnr/isti/epasmed/config/SyncConfiguration.java +++ b/src/main/java/it/cnr/isti/epasmed/config/SyncConfiguration.java @@ -24,10 +24,10 @@ public class SyncConfiguration { } @Scheduled(cron = "0 50 7 * * ?") - public void cronJobSch() { + public void cronJobSyncRead() { LocalDateTime start = LocalDateTime.now(); - logger.info("Scheduled Sync Start : {}", start); + logger.info("Scheduled Sync Read Start : {}", start); try { syncService.executeReads(); @@ -36,7 +36,28 @@ public class SyncConfiguration { } LocalDateTime end = LocalDateTime.now(); - logger.info("Scheduled Sync End : {}", end); + logger.info("Scheduled Sync Read End : {}", end); } + + @Scheduled(cron = "0 0 3 * * ?") + public void cronJobSyncWrite() { + + LocalDateTime start = LocalDateTime.now(); + logger.info("Scheduled Sync Write Start : {}", start); + String year=String.valueOf(start.getYear()); + String month=String.valueOf(start.getMonthValue()); + + + try { + syncService.executeWritesScheduled(year, month); + } catch (Exception e) { + logger.error(e.getLocalizedMessage(), e); + } + + LocalDateTime end = LocalDateTime.now(); + logger.info("Scheduled Sync Write End : {}", end); + + } + } diff --git a/src/main/java/it/cnr/isti/epasmed/sync/SyncService.java b/src/main/java/it/cnr/isti/epasmed/sync/SyncService.java index e64cda2..58da0c9 100755 --- a/src/main/java/it/cnr/isti/epasmed/sync/SyncService.java +++ b/src/main/java/it/cnr/isti/epasmed/sync/SyncService.java @@ -216,6 +216,15 @@ public class SyncService { siMasterLogService.closeFluxWrites(fluxId, writeTabs()); } + public void executeWritesScheduled(String year, String month) throws Exception { + setBWriteTables(); + List<TabsSI> tabsSI = tabsSIService.getAllTabsSI(); + Long fluxId = siMasterLogService.startFluxWrites(); + writeScheduledData(fluxId, tabsSI, year, month); + siMasterLogService.closeFluxWrites(fluxId, writeTabs()); + } + + public void executeWritesOrario() throws Exception { setBWriteTables(); List<TabsSI> tabsSI = tabsSIService.getAllTabsSI(); @@ -870,6 +879,38 @@ public class SyncService { return writeTabs; } + private void writeScheduledData(Long fluxId, List<TabsSI> tabsSI, String year, String month) throws Exception { + logger.info("Report {}-{}", year, month); + LocalDateTime now = LocalDateTime.now(); + // checkValidMonthToSend(year, month); + + for (TabsSI tab : tabsSI) { + logger.info("TabSI: {}", tab); + if (tab.getOperazioni() != null && !tab.getOperazioni().isEmpty() + && tab.getOperazioni().compareTo("W") == 0) { + if (tab.getNome() == null || tab.getNome().isEmpty()) { + continue; + } + + switch (tab.getNome()) { + case "aspettative": + syncAspettative(fluxId, tab, year, month, now); + break; + case "orario": + syncOrario(fluxId, tab); + break; + case "pers_orario": + syncPersOrario(fluxId, tab, year, month, now); + break; + default: + break; + } + + } + } + } + + private void writeOrarioData(Long fluxId, List<TabsSI> tabsSI) { for (TabsSI tab : tabsSI) { logger.info("TabSI: {}", tab); @@ -1513,7 +1554,7 @@ public class SyncService { } - logger.info("Peronale Orario scritto su SI: {}",count); + logger.info("Personale Orario scritto su SI: {}",count); logger.info("SIPersOrario Updated"); bpers_orario = true; diff --git a/src/main/java/it/cnr/isti/epasmed/web/rest/sync/SyncResource.java b/src/main/java/it/cnr/isti/epasmed/web/rest/sync/SyncResource.java index 8432d27..1826d62 100755 --- a/src/main/java/it/cnr/isti/epasmed/web/rest/sync/SyncResource.java +++ b/src/main/java/it/cnr/isti/epasmed/web/rest/sync/SyncResource.java @@ -72,7 +72,7 @@ public class SyncResource { * */ @GetMapping("/sync/writes") - @PreAuthorize("hasAuthority(\"" + AuthoritiesConstants.ADMIN + "\")") + @PreAuthorize("hasAuthority(\"" + AuthoritiesConstants.ADMIN + "\",\""+AuthoritiesConstants.USER+"\")") public ResponseEntity<Void> syncWrites(@RequestParam("year") String year, @RequestParam("month") String month) throws Exception { logger.info("REST request syncWrites"); @@ -85,6 +85,35 @@ public class SyncResource { return res; } + + /** + * {@code GET /sync/writesscheduled} : Report from ePAS and update SistemaInformativo scheduled info. + * + * @param year the year. + * @param month the month. + * @return the {@link ResponseEntity} with status {@code 201 (Executed)} or with + * status {@code 400 (Bad Request)} if there is a error. + * @throws Exception + * + * + */ + @GetMapping("/sync/writesscheduled") + @PreAuthorize("hasAuthority(\"" + AuthoritiesConstants.ADMIN + "\",\""+AuthoritiesConstants.USER+"\")") + public ResponseEntity<Void> syncWritesScheduled(@RequestParam("year") String year, @RequestParam("month") String month) + throws Exception { + logger.info("REST request syncWritesScheduled"); + + ResponseEntity<Void> res; + syncService.executeWritesScheduled(year, month); + String msg = "Sincronizzazione delle scritture schedulate eseguita correttamente."; + logger.info(msg); + res = ResponseEntity.noContent().headers(HeaderUtil.createAlert(applicationName, msg, "")).build(); + + return res; + } + + + /** * {@code GET /sync/test} : Test api. @@ -181,7 +210,7 @@ public class SyncResource { * */ @GetMapping("/sync/writesSingleTimeCards") - @PreAuthorize("hasAuthority(\"" + AuthoritiesConstants.ADMIN + "\")") + @PreAuthorize("hasAuthority(\"" + AuthoritiesConstants.ADMIN + "\",\""+AuthoritiesConstants.USER+"\")") public ResponseEntity<Void> syncSingleWritesTimeCards(@RequestParam("year") String year, @RequestParam("month") String month, @RequestParam("fiscalCode") String fc) throws Exception { logger.info("REST request syncSingleWritesTimeCards)"); diff --git a/src/main/webapp/app/entities/entity.module.ts b/src/main/webapp/app/entities/entity.module.ts index 831cb2c..0bf603e 100755 --- a/src/main/webapp/app/entities/entity.module.ts +++ b/src/main/webapp/app/entities/entity.module.ts @@ -26,6 +26,13 @@ import { RouterModule } from '@angular/router'; pageTitle: 'Leaves', }, }, + { + path: 'persorario', + loadChildren: () => import('./persorario/persorario.module').then(m => m.PersOrarioModule), + data: { + pageTitle: 'Pers Orario', + }, + }, ]), ], }) diff --git a/src/main/webapp/app/entities/persorario/persorario-delete-dialog.component.html b/src/main/webapp/app/entities/persorario/persorario-delete-dialog.component.html new file mode 100755 index 0000000..6834a13 --- /dev/null +++ b/src/main/webapp/app/entities/persorario/persorario-delete-dialog.component.html @@ -0,0 +1,23 @@ +<form *ngIf="persOrario" name="deleteForm" (ngSubmit)="confirmDelete(persOrario?.id!)"> + <div class="modal-header"> + <h4 class="modal-title">Confirm delete operation</h4> + + <button type="button" class="close" data-dismiss="modal" aria-hidden="true" (click)="cancel()">×</button> + </div> + + <div class="modal-body"> + <jhi-alert-error></jhi-alert-error> + + <p>Are you sure you want to delete this Personale Orario?</p> + </div> + + <div class="modal-footer"> + <button type="button" class="btn btn-secondary" data-dismiss="modal" (click)="cancel()"> + <fa-icon icon="ban"></fa-icon> <span>Cancel</span> + </button> + + <button type="submit" class="btn btn-danger"> + <fa-icon icon="times"></fa-icon> <span>Delete</span> + </button> + </div> +</form> diff --git a/src/main/webapp/app/entities/persorario/persorario-delete-dialog.component.ts b/src/main/webapp/app/entities/persorario/persorario-delete-dialog.component.ts new file mode 100755 index 0000000..6431a76 --- /dev/null +++ b/src/main/webapp/app/entities/persorario/persorario-delete-dialog.component.ts @@ -0,0 +1,27 @@ +import { Component } from '@angular/core'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { PersOrario } from './persorario.model'; +import { PersOrarioService } from './persorario.service'; + +@Component({ + selector: 'jhi-persorario-delete-dialog', + templateUrl: './persorario-delete-dialog.component.html', +}) +export class PersOrarioDeleteDialogComponent { + persOrario?: PersOrario; + + constructor(private persOrarioService: PersOrarioService, public activeModal: NgbActiveModal, private eventManager: JhiEventManager) {} + + cancel(): void { + this.activeModal.dismiss(); + } + + confirmDelete(id: string): void { + this.persOrarioService.delete(id).subscribe(() => { + this.eventManager.broadcast('persOrarioListModification'); + this.activeModal.close(); + }); + } +} diff --git a/src/main/webapp/app/entities/persorario/persorario-detail.component.html b/src/main/webapp/app/entities/persorario/persorario-detail.component.html new file mode 100755 index 0000000..45f6fbf --- /dev/null +++ b/src/main/webapp/app/entities/persorario/persorario-detail.component.html @@ -0,0 +1,69 @@ +<div class="row justify-content-center"> + <div class="col-8"> + <div *ngIf="persOrario"> + <h2> + <span>Personale Orario</span> [<b>{{ persOrario.id }}</b>] + </h2> + <dl class="row-md jh-entity-details"> + <dt><span>Id</span></dt> + <dd>{{ persOrario.id }}</dd> + + <dt><span>Id Persona</span></dt> + <dd>{{ persOrario.idPersona }}</dd> + + <dt><span>Codice Fiscale</span></dt> + <dd>{{ persOrario.cf }}</dd> + + <dt><span>Dal</span></dt> + <dd>{{ persOrario.dal }}</dd> + + <dt><span>Al</span></dt> + <dd>{{ persOrario.al }}</dd> + + <dt><span>Descrizione</span></dt> + <dd>{{ persOrario.descrizione }}</dd> + + <dt><span>Lun</span></dt> + <dd>{{ persOrario.lun }}</dd> + + <dt><span>Mar</span></dt> + <dd>{{ persOrario.mar }}</dd> + + <dt><span>Mer</span></dt> + <dd>{{ persOrario.mer }}</dd> + + <dt><span>Gio</span></dt> + <dd>{{ persOrario.gio }}</dd> + + <dt><span>Ven</span></dt> + <dd>{{ persOrario.ven }}</dd> + + <dt><span>Sab</span></dt> + <dd>{{ persOrario.sab }}</dd> + + <dt><span>Percentuale</span></dt> + <dd>{{ persOrario.percentuale }}</dd> + + <dt><span>Turno</span></dt> + <dd>{{ persOrario.turno }}</dd> + + <dt><span>Ore Turno</span></dt> + <dd>{{ persOrario.oreTurno }}</dd> + + <dt><span>Festivo</span></dt> + <dd>{{ persOrario.festivo }}</dd> + + <dt><span>Notturno</span></dt> + <dd>{{ persOrario.notturno }}</dd> + + <dt><span>Data Mod</span></dt> + <dd>{{ persOrario.dataMod }}</dd> + + </dl> + + <button type="submit" routerLink="../../" class="btn btn-info"> + <fa-icon icon="arrow-left"></fa-icon> <span>Back</span> + </button> + </div> + </div> +</div> diff --git a/src/main/webapp/app/entities/persorario/persorario-detail.component.ts b/src/main/webapp/app/entities/persorario/persorario-detail.component.ts new file mode 100755 index 0000000..b87f676 --- /dev/null +++ b/src/main/webapp/app/entities/persorario/persorario-detail.component.ts @@ -0,0 +1,18 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { PersOrario } from './persorario.model'; + +@Component({ + selector: 'jhi-persorario-detail', + templateUrl: './persorario-detail.component.html', +}) +export class PersOrarioDetailComponent implements OnInit { + persOrario: PersOrario | null = null; + + constructor(private route: ActivatedRoute) {} + + ngOnInit(): void { + this.route.data.subscribe(({ persOrario }) => (this.persOrario = persOrario)); + } +} diff --git a/src/main/webapp/app/entities/persorario/persorario-update.component.html b/src/main/webapp/app/entities/persorario/persorario-update.component.html new file mode 100755 index 0000000..6af0a62 --- /dev/null +++ b/src/main/webapp/app/entities/persorario/persorario-update.component.html @@ -0,0 +1,247 @@ +<div class="row justify-content-center"> + <div class="col-8"> + <form name="editForm" role="form" novalidate (ngSubmit)="save()" + [formGroup]="editForm"> + <h2 id="myPersOrarioLabel">Create or edit Personale Orario</h2> + + <div *ngIf="persOrario"> + <jhi-alert-error></jhi-alert-error> + + <div class="form-group" [hidden]="!persOrario.id"> + <label>Id</label> <input type="text" class="form-control" name="id" + formControlName="id" readonly> + </div> + + + <div class="form-group"> + <label class="form-control-label">Id Persona</label> <input + type="text" class="form-control" name="idPersona" + formControlName="idPersona"> + + <div + *ngIf="editForm.get('idPersona')!.invalid && (editForm.get('idPersona')!.dirty || editForm.get('idPersona')!.touched)"> + <small class="form-text text-danger" + *ngIf="editForm.get('idPersona')?.errors?.required"> This + field is required. </small> + </div> + </div> + + <div class="form-group"> + <label class="form-control-label">Codice Fiscale</label> <input + type="text" class="form-control" name="cf" formControlName="cf"> + + <div + *ngIf="editForm.get('cf')!.invalid && (editForm.get('cf')!.dirty || editForm.get('cf')!.touched)"> + <small class="form-text text-danger" + *ngIf="editForm.get('cf')?.errors?.required"> This field + is required. </small> + </div> + </div> + + <div class="form-group"> + <label class="form-control-label">Dal</label> <input + type="text" class="form-control" name="dal" + formControlName="dal"> + + <div + *ngIf="editForm.get('dal')!.invalid && (editForm.get('dal')!.dirty || editForm.get('dal')!.touched)"> + <small class="form-text text-danger" + *ngIf="editForm.get('dal')?.errors?.required"> + This field is required. </small> + </div> + </div> + + <div class="form-group"> + <label class="form-control-label">Al</label> <input + type="text" class="form-control" name="al" + formControlName="al"> + + <div + *ngIf="editForm.get('al')!.invalid && (editForm.get('al')!.dirty || editForm.get('al')!.touched)"> + <small class="form-text text-danger" + *ngIf="editForm.get('al')?.errors?.required"> This + field is required. </small> + </div> + </div> + + + <div class="form-group"> + <label class="form-control-label">Descrizione</label> + <input type="text" class="form-control" + name="descrizione" + formControlName="descrizione"> + + <div + *ngIf="editForm.get('descrizione')!.invalid && (editForm.get('descrizione')!.dirty || editForm.get('descrizione')!.touched)"> + <small class="form-text text-danger" + *ngIf="editForm.get('descrizione')?.errors?.required"> + This field is required. </small> + </div> + </div> + + <div class="form-group"> + <label class="form-control-label">Lun</label> <input + type="text" class="form-control" name="lun" + formControlName="lun"> + + <div + *ngIf="editForm.get('lun')!.invalid && (editForm.get('lun')!.dirty || editForm.get('lun')!.touched)"> + <small class="form-text text-danger" + *ngIf="editForm.get('lun')?.errors?.required"> + This field is required. </small> + </div> + </div> + + <div class="form-group"> + <label class="form-control-label">Mar</label> <input + type="text" class="form-control" name="mar" + formControlName="mar"> + + <div + *ngIf="editForm.get('mar')!.invalid && (editForm.get('mar')!.dirty || editForm.get('mar')!.touched)"> + <small class="form-text text-danger" + *ngIf="editForm.get('mar')?.errors?.required"> + This field is required. </small> + </div> + </div> + + <div class="form-group"> + <label class="form-control-label">Mer</label> <input + type="text" class="form-control" name="mer" + formControlName="mer"> + + <div + *ngIf="editForm.get('mer')!.invalid && (editForm.get('mer')!.dirty || editForm.get('mer')!.touched)"> + <small class="form-text text-danger" + *ngIf="editForm.get('mer')?.errors?.required"> + This field is required. </small> + </div> + </div> + <div class="form-group"> + <label class="form-control-label">Gio</label> <input + type="text" class="form-control" name="gio" + formControlName="gio"> + + <div + *ngIf="editForm.get('gio')!.invalid && (editForm.get('gio')!.dirty || editForm.get('gio')!.touched)"> + <small class="form-text text-danger" + *ngIf="editForm.get('gio')?.errors?.required"> + This field is required. </small> + </div> + </div> + <div class="form-group"> + <label class="form-control-label">Ven</label> <input + type="text" class="form-control" name="ven" + formControlName="ven"> + + <div + *ngIf="editForm.get('ven')!.invalid && (editForm.get('ven')!.dirty || editForm.get('ven')!.touched)"> + <small class="form-text text-danger" + *ngIf="editForm.get('ven')?.errors?.required"> + This field is required. </small> + </div> + </div> + <div class="form-group"> + <label class="form-control-label">Sab</label> <input + type="text" class="form-control" name="sab" + formControlName="sab"> + + <div + *ngIf="editForm.get('sab')!.invalid && (editForm.get('sab')!.dirty || editForm.get('sab')!.touched)"> + <small class="form-text text-danger" + *ngIf="editForm.get('sab')?.errors?.required"> + This field is required. </small> + </div> + </div> + <div class="form-group"> + <label class="form-control-label">Percentuale</label> <input + type="text" class="form-control" name="percentuale" + formControlName="percentuale"> + + <div + *ngIf="editForm.get('percentuale')!.invalid && (editForm.get('percentuale')!.dirty || editForm.get('percentuale')!.touched)"> + <small class="form-text text-danger" + *ngIf="editForm.get('percentuale')?.errors?.required"> + This field is required. </small> + </div> + </div> + + <div class="form-group"> + <label class="form-control-label">Turno</label> <input + type="text" class="form-control" name="turno" + formControlName="turno"> + + <div + *ngIf="editForm.get('turno')!.invalid && (editForm.get('turno')!.dirty || editForm.get('turno')!.touched)"> + <small class="form-text text-danger" + *ngIf="editForm.get('turno')?.errors?.required"> + This field is required. </small> + </div> + </div> + + <div class="form-group"> + <label class="form-control-label">Ore Turno</label> <input type="text" + class="form-control" name="oreTurno" formControlName="oreTurno"> + + <div + *ngIf="editForm.get('oreTurno')!.invalid && (editForm.get('oreTurno')!.dirty || editForm.get('oreTurno')!.touched)"> + <small class="form-text text-danger" + *ngIf="editForm.get('oreTurno')?.errors?.required"> This + field is required. </small> + </div> + </div> + + <div class="form-group"> + <label class="form-control-label">Festivo</label> <input type="text" + class="form-control" name="festivo" formControlName="festivo"> + + <div + *ngIf="editForm.get('festivo')!.invalid && (editForm.get('festivo')!.dirty || editForm.get('festivo')!.touched)"> + <small class="form-text text-danger" + *ngIf="editForm.get('festivo')?.errors?.required"> This + field is required. </small> + </div> + </div> + + <div class="form-group"> + <label class="form-control-label">Notturno</label> <input type="text" + class="form-control" name="notturno" formControlName="notturno"> + + <div + *ngIf="editForm.get('notturno')!.invalid && (editForm.get('notturno')!.dirty || editForm.get('notturno')!.touched)"> + <small class="form-text text-danger" + *ngIf="editForm.get('notturno')?.errors?.required"> This + field is required. </small> + </div> + </div> + + <div class="form-group"> + <label class="form-control-label">Data Mod</label> <input + type="text" class="form-control" name="dataMod" + formControlName="dataMod"> + + <div + *ngIf="editForm.get('dataMod')!.invalid && (editForm.get('dataMod')!.dirty || editForm.get('dataMod')!.touched)"> + <small class="form-text text-danger" + *ngIf="editForm.get('dataMod')?.errors?.required"> This + field is required. </small> + </div> + </div> + </div> + + <div *ngIf="persOrario"> + <button type="button" class="btn btn-secondary" + (click)="previousState()"> + <fa-icon icon="ban"></fa-icon> + <span>Cancel</span> + </button> + + <button type="submit" [disabled]="editForm.invalid || isSaving" + class="btn btn-primary"> + <fa-icon icon="save"></fa-icon> + <span>Save</span> + </button> + </div> + </form> + </div> +</div> diff --git a/src/main/webapp/app/entities/persorario/persorario-update.component.ts b/src/main/webapp/app/entities/persorario/persorario-update.component.ts new file mode 100755 index 0000000..8abda32 --- /dev/null +++ b/src/main/webapp/app/entities/persorario/persorario-update.component.ts @@ -0,0 +1,119 @@ +import { Component, OnInit } from '@angular/core'; +import { FormBuilder, Validators } from '@angular/forms'; +import { ActivatedRoute } from '@angular/router'; + +import { PersOrario } from './persorario.model'; +import { PersOrarioService } from './persorario.service'; + +@Component({ + selector: 'jhi-persorario-update', + templateUrl: './persorario-update.component.html', +}) +export class PersOrarioUpdateComponent implements OnInit { + persOrario!: PersOrario; + isSaving = false; + + editForm = this.fb.group({ + id: [], + idPersona: ['', [Validators.required]], + cf: ['', [Validators.required]], + dal: ['', [Validators.required]], + al: [''], + descrizione: ['', [Validators.required]], + lun: [''], + mar: [''], + mer: [''], + gio: [''], + ven: [''], + sab: [''], + percentuale: [''], + turno: [''], + oreTurno: [''], + festivo: [''], + notturno: [''], + dataMod: ['', [Validators.required]], + }); + + constructor(private persOrarioService: PersOrarioService, private route: ActivatedRoute, private fb: FormBuilder) {} + + ngOnInit(): void { + this.route.data.subscribe(({ persOrario }) => { + if (persOrario) { + this.persOrario = persOrario; + this.updateForm(persOrario); + } + }); + } + + previousState(): void { + window.history.back(); + } + + save(): void { + this.isSaving = true; + this.updatePersOrario(this.persOrario); + if (this.persOrario.id !== undefined) { + this.persOrarioService.update(this.persOrario).subscribe( + () => this.onSaveSuccess(), + () => this.onSaveError() + ); + } else { + this.persOrarioService.create(this.persOrario).subscribe( + () => this.onSaveSuccess(), + () => this.onSaveError() + ); + } + } + + private updateForm(persOrario: PersOrario): void { + this.editForm.patchValue({ + id: persOrario.id, + idPersona: persOrario.idPersona, + cf: persOrario.cf, + dal: persOrario.dal, + al: persOrario.al, + descrizione: persOrario.descrizione, + lun: persOrario.lun, + mar: persOrario.mar, + mer: persOrario.mer, + gio: persOrario.gio, + ven: persOrario.ven, + sab: persOrario.sab, + percentuale: persOrario.percentuale, + turno: persOrario.turno, + oreTurno: persOrario.oreTurno, + festivo: persOrario.festivo, + notturno: persOrario.notturno, + dataMod: persOrario.dataMod, + }); + } + + private updatePersOrario(persOrario: PersOrario): void { + persOrario.idPersona = this.editForm.get(['idPersona'])!.value; + persOrario.cf = this.editForm.get(['cf'])!.value; + persOrario.dal = this.editForm.get(['dal'])!.value; + persOrario.al = this.editForm.get(['al'])!.value; + persOrario.descrizione = this.editForm.get(['descrizione'])!.value; + persOrario.lun = this.editForm.get(['lun'])!.value; + persOrario.mar = this.editForm.get(['mar'])!.value; + persOrario.mer = this.editForm.get(['mer'])!.value; + persOrario.gio = this.editForm.get(['gio'])!.value; + persOrario.ven = this.editForm.get(['ven'])!.value; + persOrario.sab = this.editForm.get(['sab'])!.value; + persOrario.percentuale = this.editForm.get(['percentuale'])!.value; + persOrario.turno = this.editForm.get(['turno'])!.value; + persOrario.oreTurno = this.editForm.get(['oreTurno'])!.value; + persOrario.festivo = this.editForm.get(['festivo'])!.value; + persOrario.notturno = this.editForm.get(['notturno'])!.value; + persOrario.dataMod = this.editForm.get(['dataMod'])!.value; + } + + private onSaveSuccess(): void { + this.isSaving = false; + this.previousState(); + } + + private onSaveError(): void { + this.isSaving = false; + } +} diff --git a/src/main/webapp/app/entities/persorario/persorario.component.html b/src/main/webapp/app/entities/persorario/persorario.component.html new file mode 100755 index 0000000..d0dd45b --- /dev/null +++ b/src/main/webapp/app/entities/persorario/persorario.component.html @@ -0,0 +1,79 @@ +<div> + <h2> + <span id="persorario-page-heading">Personale Orario</span> + + <button class="btn btn-primary float-right jh-create-entity" + [routerLink]="['./new']"> + <fa-icon icon="plus"></fa-icon> + <span>Create a new Personale Orario</span> + </button> + </h2> + + <jhi-alert-error></jhi-alert-error> + + <jhi-alert></jhi-alert> + + <div class="table-responsive" *ngIf="persOrarioArray"> + <table class="table table-striped" + aria-describedby="user-management-page-heading"> + <thead> + <tr jhiSort [(predicate)]="predicate" [(ascending)]="ascending" + [callback]="transition.bind(this)"> + <th scope="col" jhiSortBy="id"><span>Id</span> <fa-icon + icon="sort"></fa-icon></th> + <th scope="col"><span>Id Persona</span></th> + <th scope="col"><span>Codice Fiscale</span></th> + <th scope="col"><span>Dal</span></th> + <th scope="col"><span>Al</span></th> + <th scope="col"><span>Descrizione</span></th> + <th scope="col"><span>Data Mod</span></th> + <th scope="col"></th> + </tr> + </thead> + <tbody *ngIf="persOrarioArray"> + <tr *ngFor="let persOrario of persOrarioArray; trackBy: trackIdentity"> + <td><a [routerLink]="['./', persOrario.id, 'view']">{{ persOrario.id }}</a></td> + <td>{{ persOrario.idPersona }}</td> + <td>{{ persOrario.cf }}</td> + <td>{{ persOrario.dal }}</td> + <td>{{ persOrario.al }}</td> + <td>{{ persOrario.descrizione }}</td> + <td>{{ persOrario.dataMod }}</td> + <td class="text-right"> + <div class="btn-group"> + <button type="submit" [routerLink]="['./', persOrario.id, 'view']" + class="btn btn-info btn-sm"> + <fa-icon icon="eye"></fa-icon> + <span class="d-none d-md-inline">View</span> + </button> + <button type="submit" [routerLink]="['./', persOrario.id, 'edit']" + queryParamsHandling="merge" class="btn btn-primary btn-sm"> + <fa-icon icon="pencil-alt"></fa-icon> + <span class="d-none d-md-inline">Edit</span> + </button> + <button type="button" (click)="deletePersOrario(persOrario)" + class="btn btn-danger btn-sm"> + <fa-icon icon="times"></fa-icon> + <span class="d-none d-md-inline">Delete</span> + </button> + </div> + </td> + + </tr> + </tbody> + </table> + </div> + + <div *ngIf="persOrarioArray"> + <div class="row justify-content-center"> + <jhi-item-count [page]="page" [total]="totalItems" + [itemsPerPage]="itemsPerPage"></jhi-item-count> + </div> + + <div class="row justify-content-center"> + <ngb-pagination [collectionSize]="totalItems" [(page)]="page" + [pageSize]="itemsPerPage" [maxSize]="5" [rotate]="true" + [boundaryLinks]="true" (pageChange)="transition()"></ngb-pagination> + </div> + </div> +</div> diff --git a/src/main/webapp/app/entities/persorario/persorario.component.ts b/src/main/webapp/app/entities/persorario/persorario.component.ts new file mode 100755 index 0000000..9076b19 --- /dev/null +++ b/src/main/webapp/app/entities/persorario/persorario.component.ts @@ -0,0 +1,97 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpResponse, HttpHeaders } from '@angular/common/http'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; +import { Subscription, combineLatest } from 'rxjs'; +import { ActivatedRoute, ParamMap, Router, Data } from '@angular/router'; +import { JhiEventManager } from 'ng-jhipster'; + +import { ITEMS_PER_PAGE } from 'app/shared/constants/pagination.constants'; +import { PersOrarioService } from './persorario.service'; +import { PersOrario } from './persorario.model'; +import { PersOrarioDeleteDialogComponent } from './persorario-delete-dialog.component'; + +@Component({ + selector: 'jhi-persorario', + templateUrl: './persorario.component.html', +}) +export class PersOrarioComponent implements OnInit, OnDestroy { + persOrarioArray: PersOrario[] | null = null; + persOrarioListSubscription?: Subscription; + totalItems = 0; + itemsPerPage = ITEMS_PER_PAGE; + page!: number; + predicate!: string; + ascending!: boolean; + + constructor( + private persOrarioService: PersOrarioService, + private activatedRoute: ActivatedRoute, + private router: Router, + private eventManager: JhiEventManager, + private modalService: NgbModal + ) {} + + ngOnInit(): void { + this.persOrarioListSubscription = this.eventManager.subscribe('persOrarioListModification', () => this.loadAll()); + this.handleNavigation(); + } + + ngOnDestroy(): void { + if (this.persOrarioListSubscription) { + this.eventManager.destroy(this.persOrarioListSubscription); + } + } + + trackIdentity(index: number, item: PersOrario): any { + return item.id; + } + + deletePersOrario(persOrario: PersOrario): void { + const modalRef = this.modalService.open(PersOrarioDeleteDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.componentInstance.persOrario = persOrario; + } + + transition(): void { + this.router.navigate(['./'], { + relativeTo: this.activatedRoute.parent, + queryParams: { + page: this.page, + sort: this.predicate + ',' + (this.ascending ? 'asc' : 'desc'), + }, + }); + } + + private handleNavigation(): void { + combineLatest(this.activatedRoute.data, this.activatedRoute.queryParamMap, (data: Data, params: ParamMap) => { + const page = params.get('page'); + this.page = page !== null ? +page : 1; + const sort = (params.get('sort') ?? data['defaultSort']).split(','); + this.predicate = sort[0]; + this.ascending = sort[1] === 'asc'; + this.loadAll(); + }).subscribe(); + } + + private loadAll(): void { + this.persOrarioService + .query({ + page: this.page - 1, + size: this.itemsPerPage, + sort: this.sort(), + }) + .subscribe((res: HttpResponse<PersOrario[]>) => this.onSuccess(res.body, res.headers)); + } + + private sort(): string[] { + const result = [this.predicate + ',' + (this.ascending ? 'asc' : 'desc')]; + if (this.predicate !== 'id') { + result.push('id'); + } + return result; + } + + private onSuccess(persOrarioArray: PersOrario[] | null, headers: HttpHeaders): void { + this.totalItems = Number(headers.get('X-Total-Count')); + this.persOrarioArray = persOrarioArray; + } +} diff --git a/src/main/webapp/app/entities/persorario/persorario.model.ts b/src/main/webapp/app/entities/persorario/persorario.model.ts new file mode 100755 index 0000000..37d66f8 --- /dev/null +++ b/src/main/webapp/app/entities/persorario/persorario.model.ts @@ -0,0 +1,43 @@ +export interface IPersOrario { + id?: any; + idPersona?: any; + cf?: string; + dal?: any; + al?: any; + descrizione?: string; + lun?: any; + mar?: any; + mer?: any; + gio?: any; + ven?: any; + sab?: any; + percentuale?: any; + turno?: string; + oreTurno?: any; + festivo?: string; + notturno?: string; + dataMod?: any; +} + +export class PersOrario implements IPersOrario { + constructor( + public id?: any, + public idPersona?: any, + public cf?: string, + public dal?: any, + public al?: any, + public descrizione?: string, + public lun?: any, + public mar?: any, + public mer?: any, + public gio?: any, + public ven?: any, + public sab?: any, + public percentuale?: any, + public turno?: string, + public oreTurno?: any, + public festivo?: string, + public notturno?: string, + public dataMod?: any + ) {} +} diff --git a/src/main/webapp/app/entities/persorario/persorario.module.ts b/src/main/webapp/app/entities/persorario/persorario.module.ts new file mode 100755 index 0000000..2bd51c2 --- /dev/null +++ b/src/main/webapp/app/entities/persorario/persorario.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { EpasmedSharedModule } from 'app/shared/shared.module'; +import { PersOrarioComponent } from './persorario.component'; +import { PersOrarioDetailComponent } from './persorario-detail.component'; +import { PersOrarioUpdateComponent } from './persorario-update.component'; +import { PersOrarioDeleteDialogComponent } from './persorario-delete-dialog.component'; +import { persOrarioRoute } from './persorario.route'; + +@NgModule({ + imports: [EpasmedSharedModule, RouterModule.forChild(persOrarioRoute)], + declarations: [PersOrarioComponent, PersOrarioDetailComponent, PersOrarioUpdateComponent, PersOrarioDeleteDialogComponent], + entryComponents: [PersOrarioComponent], +}) +export class PersOrarioModule {} diff --git a/src/main/webapp/app/entities/persorario/persorario.route.ts b/src/main/webapp/app/entities/persorario/persorario.route.ts new file mode 100755 index 0000000..69bf922 --- /dev/null +++ b/src/main/webapp/app/entities/persorario/persorario.route.ts @@ -0,0 +1,53 @@ +import { Injectable } from '@angular/core'; +import { Resolve, ActivatedRouteSnapshot, Routes } from '@angular/router'; +import { Observable, of } from 'rxjs'; + +import { PersOrario, IPersOrario } from './persorario.model'; +import { PersOrarioService } from './persorario.service'; +import { PersOrarioComponent } from './persorario.component'; +import { PersOrarioDetailComponent } from './persorario-detail.component'; +import { PersOrarioUpdateComponent } from './persorario-update.component'; + +@Injectable({ providedIn: 'root' }) +export class PersOrarioResolve implements Resolve<IPersOrario> { + constructor(private service: PersOrarioService) {} + + resolve(route: ActivatedRouteSnapshot): Observable<IPersOrario> { + const id = route.params['id']; + if (id) { + return this.service.find(id); + } + return of(new PersOrario()); + } +} + +export const persOrarioRoute: Routes = [ + { + path: '', + component: PersOrarioComponent, + data: { + defaultSort: 'id,asc', + }, + }, + { + path: ':id/view', + component: PersOrarioDetailComponent, + resolve: { + persOrario: PersOrarioResolve, + }, + }, + { + path: 'new', + component: PersOrarioUpdateComponent, + resolve: { + persOrario: PersOrarioResolve, + }, + }, + { + path: ':id/edit', + component: PersOrarioUpdateComponent, + resolve: { + persOrario: PersOrarioResolve, + }, + }, +]; diff --git a/src/main/webapp/app/entities/persorario/persorario.service.ts b/src/main/webapp/app/entities/persorario/persorario.service.ts new file mode 100755 index 0000000..de8a27f --- /dev/null +++ b/src/main/webapp/app/entities/persorario/persorario.service.ts @@ -0,0 +1,35 @@ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; + +import { SERVER_API_URL } from 'app/app.constants'; +import { createRequestOption, Pagination } from 'app/shared/util/request-util'; +import { IPersOrario } from './persorario.model'; + +@Injectable({ providedIn: 'root' }) +export class PersOrarioService { + public resourceUrl = SERVER_API_URL + 'api/persorario'; + + constructor(private http: HttpClient) {} + + query(req?: Pagination): Observable<HttpResponse<IPersOrario[]>> { + const options = createRequestOption(req); + return this.http.get<IPersOrario[]>(this.resourceUrl, { params: options, observe: 'response' }); + } + + create(persOrario: IPersOrario): Observable<IPersOrario> { + return this.http.post<IPersOrario>(this.resourceUrl, persOrario); + } + + update(persOrario: IPersOrario): Observable<IPersOrario> { + return this.http.put<IPersOrario>(this.resourceUrl, persOrario); + } + + find(id: string): Observable<IPersOrario> { + return this.http.get<IPersOrario>(`${this.resourceUrl}/${id}`); + } + + delete(id: string): Observable<{}> { + return this.http.delete(`${this.resourceUrl}/${id}`); + } +} diff --git a/src/main/webapp/app/layouts/navbar/navbar.component.html b/src/main/webapp/app/layouts/navbar/navbar.component.html index 5a40f5d..886caad 100755 --- a/src/main/webapp/app/layouts/navbar/navbar.component.html +++ b/src/main/webapp/app/layouts/navbar/navbar.component.html @@ -33,16 +33,25 @@ <fa-icon icon="user" [fixedWidth]="true"></fa-icon> <span>Tabs SI</span> </a> + </li> + <li> <a class="dropdown-item" routerLink="entities/timecardsreporting" routerLinkActive="active" (click)="collapseNavbar()"> <fa-icon icon="user" [fixedWidth]="true"></fa-icon> - <span>TimeCards Reporting</span> + <span>Cartellini Rendicontazioni</span> </a> + </li> + <li> <a class="dropdown-item" routerLink="entities/leaves" routerLinkActive="active" (click)="collapseNavbar()"> <fa-icon icon="user" [fixedWidth]="true"></fa-icon> - <span>Leaves</span> + <span>Aspettative</span> + </a> + </li> + <li> + <a class="dropdown-item" routerLink="entities/persorario" routerLinkActive="active" (click)="collapseNavbar()"> + <fa-icon icon="user" [fixedWidth]="true"></fa-icon> + <span>Pers Orario</span> </a> </li> - </ul> </li> <li *ngSwitchCase="true" ngbDropdown class="nav-item dropdown pointer" display="dynamic" routerLinkActive="active" [routerLinkActiveOptions]="{ exact: true }"> @@ -65,7 +74,7 @@ <span>Rendicontazione Singolo Cart.</span> </a> </li> - <li> + <li *jhiHasAnyAuthority="'ROLE_ADMIN'"> <a class="dropdown-item" routerLink="operations/sync" routerLinkActive="active" (click)="collapseNavbar()"> <fa-icon icon="cloud" [fixedWidth]="true"></fa-icon> <span>Sync</span> diff --git a/src/test/java/it/cnr/isti/epasmed/web/rest/sync/SyncResourceIT.java b/src/test/java/it/cnr/isti/epasmed/web/rest/sync/SyncResourceIT.java index 013efad..8fb143d 100755 --- a/src/test/java/it/cnr/isti/epasmed/web/rest/sync/SyncResourceIT.java +++ b/src/test/java/it/cnr/isti/epasmed/web/rest/sync/SyncResourceIT.java @@ -36,7 +36,6 @@ public class SyncResourceIT { private static final Logger logger = LoggerFactory.getLogger(SyncResourceIT.class); - private final Logger log = LoggerFactory.getLogger(getClass()); private static final String YEAR = "2022"; private static final String MONTH = "9"; @@ -111,24 +110,37 @@ public class SyncResourceIT { DateTimeFormatter formatter = new DateTimeFormatterBuilder().parseCaseInsensitive() .append(DateTimeFormatter.ISO_LOCAL_DATE_TIME).optionalStart().appendPattern(".SSSSSS").optionalEnd() .optionalStart().appendZoneOrOffsetId().optionalEnd().toFormatter(); - //DateTimeFormatter formatterDataMod = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - - Timestamp dataMod; + // DateTimeFormatter formatterDataMod = DateTimeFormatter.ofPattern("yyyy-MM-dd + // HH:mm:ss"); + + Timestamp dataMod; try { LocalDateTime dMod = LocalDateTime.parse("2021-02-03T19:49:05.231072", formatter); - dMod=dMod.truncatedTo(ChronoUnit.SECONDS); - //dMod= LocalDateTime.parse(dMod.format(formatterDataMod)); - //dataMod = Timestamp.valueOf(dMod.format(formatterDataMod)); + dMod = dMod.truncatedTo(ChronoUnit.SECONDS); + // dMod= LocalDateTime.parse(dMod.format(formatterDataMod)); + // dataMod = Timestamp.valueOf(dMod.format(formatterDataMod)); dataMod = Timestamp.valueOf(dMod); - - - + } catch (IllegalArgumentException | DateTimeParseException e) { logger.error("Invalid stamping data format: {}", e.getLocalizedMessage(), e); return; } + + logger.info("Result: {}", dataMod); + } + + @Test + public void testLocalData() throws Exception { + + LocalDateTime data = LocalDateTime.now(); + + logger.info("Data: {}", data); + logger.info("Year: {}", data.getYear()); + logger.info("Month: {}", data.getMonth()); + logger.info("Month Value: {}", data.getMonthValue()); + + - logger.info("Result: {}",dataMod); } }