Aggiornata gestione delle Aspettative

This commit is contained in:
Giancarlo Panichi 2022-10-14 15:59:33 +02:00
parent 1f1d15f15a
commit 99a70b4917
19 changed files with 579 additions and 146 deletions

View File

@ -29,14 +29,16 @@ public class EPASLeavesClient {
@Autowired @Autowired
ApplicationProperties appProps; ApplicationProperties appProps;
public List<EPASLeaves> getByPersonId(String id, String year) { public List<EPASLeaves> getByPersonId(String id, String year, String includeDetails) {
log.info("Retrieving EPASLeaves by person id: {}", id); log.info("Retrieving EPASLeaves by person id: {}", id);
Map<String, String> uriVariables = new HashMap<>(); Map<String, String> uriVariables = new HashMap<>();
uriVariables.put("id", id); uriVariables.put("id", id);
uriVariables.put("year", year); uriVariables.put("year", year);
uriVariables.put("includeDetails", includeDetails);
ResponseEntity<List<EPASLeaves>> responseEntity = rt.exchange( ResponseEntity<List<EPASLeaves>> responseEntity = rt.exchange(
appProps.getDatasourceEpasRest().getRestUrl() + "/v2/leaves/byPersonAndYear?id={id}&year={year}", appProps.getDatasourceEpasRest().getRestUrl()
+ "/v2/leaves/byPersonAndYear?id={id}&year={year}&includeDetails={includeDetails}",
HttpMethod.GET, null, new ParameterizedTypeReference<List<EPASLeaves>>() { HttpMethod.GET, null, new ParameterizedTypeReference<List<EPASLeaves>>() {
}, uriVariables); }, uriVariables);
List<EPASLeaves> listEPASLeaves = responseEntity.getBody(); List<EPASLeaves> listEPASLeaves = responseEntity.getBody();
@ -44,15 +46,16 @@ public class EPASLeavesClient {
return listEPASLeaves; return listEPASLeaves;
} }
public List<EPASLeaves> getByFiscalcode(String fc, String year) { public List<EPASLeaves> getByFiscalcode(String fc, String year, String includeDetails) {
log.info("Retrieving EPASLeaves by person fiscalcode: {}", fc); log.info("Retrieving EPASLeaves by person fiscalcode: {}", fc);
Map<String, String> uriVariables = new HashMap<>(); Map<String, String> uriVariables = new HashMap<>();
uriVariables.put("fc", fc); uriVariables.put("fc", fc);
uriVariables.put("year", year); uriVariables.put("year", year);
uriVariables.put("includeDetails", includeDetails);
ResponseEntity<List<EPASLeaves>> responseEntity = rt.exchange( ResponseEntity<List<EPASLeaves>> responseEntity = rt.exchange(
appProps.getDatasourceEpasRest().getRestUrl() appProps.getDatasourceEpasRest().getRestUrl()
+ "/v2/leaves/byPersonAndYear?fiscalCode={fc}&year={year}&includeDetails=true", + "/v2/leaves/byPersonAndYear?fiscalCode={fc}&year={year}&includeDetails={includeDetails}",
HttpMethod.GET, null, new ParameterizedTypeReference<List<EPASLeaves>>() { HttpMethod.GET, null, new ParameterizedTypeReference<List<EPASLeaves>>() {
}, uriVariables); }, uriVariables);
List<EPASLeaves> listEPASLeaves = responseEntity.getBody(); List<EPASLeaves> listEPASLeaves = responseEntity.getBody();
@ -61,14 +64,16 @@ public class EPASLeavesClient {
} }
public List<EPASLeaves> getByPersonEmail(String email, String year) { public List<EPASLeaves> getByPersonEmail(String email, String year, String includeDetails) {
log.info("Retrieving EPASLeaves by person email: {}", email); log.info("Retrieving EPASLeaves by person email: {}", email);
Map<String, String> uriVariables = new HashMap<>(); Map<String, String> uriVariables = new HashMap<>();
uriVariables.put("email", email); uriVariables.put("email", email);
uriVariables.put("year", year); uriVariables.put("year", year);
uriVariables.put("includeDetails", includeDetails);
ResponseEntity<List<EPASLeaves>> responseEntity = rt.exchange( ResponseEntity<List<EPASLeaves>> responseEntity = rt.exchange(
appProps.getDatasourceEpasRest().getRestUrl() + "/v2/leaves/byPersonAndYear?email={email}&year={year}", appProps.getDatasourceEpasRest().getRestUrl()
+ "/v2/leaves/byPersonAndYear?email={email}&year={year}&includeDetails={includeDetails}",
HttpMethod.GET, null, new ParameterizedTypeReference<List<EPASLeaves>>() { HttpMethod.GET, null, new ParameterizedTypeReference<List<EPASLeaves>>() {
}, uriVariables); }, uriVariables);
List<EPASLeaves> listEPASLeaves = responseEntity.getBody(); List<EPASLeaves> listEPASLeaves = responseEntity.getBody();
@ -76,14 +81,16 @@ public class EPASLeavesClient {
return listEPASLeaves; return listEPASLeaves;
} }
public List<EPASLeaves> getByOfficeCodeId(String officeCodeId, String year) { public List<EPASLeaves> getByOfficeId(String officeId, String year, String includeDetails) {
log.info("Retrieving EPASLeaves by office codeId: {}", officeCodeId); log.info("Retrieving EPASLeaves by office codeId: {}", officeId);
Map<String, String> uriVariables = new HashMap<>(); Map<String, String> uriVariables = new HashMap<>();
uriVariables.put("id", officeCodeId); uriVariables.put("id", officeId);
uriVariables.put("year", year); uriVariables.put("year", year);
uriVariables.put("includeDetails", includeDetails);
ResponseEntity<List<EPASLeaves>> responseEntity = rt.exchange( ResponseEntity<List<EPASLeaves>> responseEntity = rt.exchange(
appProps.getDatasourceEpasRest().getRestUrl() + "/v2/leaves/byOfficeAndYear?sedeId={id}&year={year}", appProps.getDatasourceEpasRest().getRestUrl()
+ "/v2/leaves/byOfficeAndYear?id={id}&year={year}&includeDetails={includeDetails}",
HttpMethod.GET, null, new ParameterizedTypeReference<List<EPASLeaves>>() { HttpMethod.GET, null, new ParameterizedTypeReference<List<EPASLeaves>>() {
}, uriVariables); }, uriVariables);
List<EPASLeaves> listEPASLeaves = responseEntity.getBody(); List<EPASLeaves> listEPASLeaves = responseEntity.getBody();

View File

@ -19,15 +19,15 @@ public class EPASPersonWorkingTimeDTO implements Serializable {
private String dal; private String dal;
private String al; private String al;
private String descrizione; private String descrizione;
private int lun; private Integer lun;
private int mar; private Integer mar;
private int mer; private Integer mer;
private int gio; private Integer gio;
private int ven; private Integer ven;
private int sab; private Integer sab;
private int percentuale; private Integer percentuale;
private String turno; private String turno;
private int ore_turno; private Integer ore_turno;
private String festivo; private String festivo;
private String notturno; private String notturno;

View File

@ -18,4 +18,5 @@ public class EPASLeaves implements Serializable {
private String code; private String code;
private String start; private String start;
private String end; private String end;
private EPASAbsences[] absences;
} }

View File

@ -2,6 +2,7 @@ package it.cnr.isti.epasmed.epas.service;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -32,4 +33,16 @@ public class EPASAbsenceTypesService {
return epasAbsenceTypeMap; return epasAbsenceTypeMap;
} }
public LinkedHashMap<String,EPASAbsenceTypes> getAbsenceTypesMapFull() {
List<EPASAbsenceTypes> epasAbsenceTypeList=epasAbsenceTypesClient.getAbsenceTypes();
LinkedHashMap<String,EPASAbsenceTypes> epasAbsenceTypeMap=new LinkedHashMap<>();
if(epasAbsenceTypeList!=null && !epasAbsenceTypeList.isEmpty()) {
epasAbsenceTypeMap=epasAbsenceTypeList.stream().collect(
Collectors.toMap(EPASAbsenceTypes::getCode, Function.identity(),
(oldValue, newValue) -> newValue, LinkedHashMap::new));
}
return epasAbsenceTypeMap;
}
} }

View File

@ -14,20 +14,20 @@ public class EPASLeavesService {
@Autowired @Autowired
EPASLeavesClient epasLeavesClient; EPASLeavesClient epasLeavesClient;
public List<EPASLeaves> getLeavesByPersonId(String id, String year) { public List<EPASLeaves> getLeavesByPersonId(String id, String year, String includeDetails) {
return epasLeavesClient.getByPersonId(id, year); return epasLeavesClient.getByPersonId(id, year, includeDetails);
} }
public List<EPASLeaves> getLeavesByPersonFiscalcode(String fc, String year) { public List<EPASLeaves> getLeavesByPersonFiscalcode(String fc, String year, String includeDetails) {
return epasLeavesClient.getByFiscalcode(fc, year); return epasLeavesClient.getByFiscalcode(fc, year, includeDetails);
} }
public List<EPASLeaves> getLeavesByPersonEmail(String email, String year) { public List<EPASLeaves> getLeavesByPersonEmail(String email, String year, String includeDetails) {
return epasLeavesClient.getByPersonEmail(email, year); return epasLeavesClient.getByPersonEmail(email, year, includeDetails);
} }
public List<EPASLeaves> getLeavesByOfficeCodeId(String officeCodeId, String year) { public List<EPASLeaves> getLeavesByOfficeId(String officeId, String year, String includeDetails) {
return epasLeavesClient.getByOfficeCodeId(officeCodeId, year); return epasLeavesClient.getByOfficeId(officeId, year, includeDetails);
} }
} }

View File

@ -4,6 +4,7 @@ import java.time.DayOfWeek;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -34,23 +35,42 @@ public class EPASPersonWorkingTimeService {
EPASContractsService epasContranctsService; EPASContractsService epasContranctsService;
public EPASPersonWorkingTimeDTO getByPersonId(String personId) { public EPASPersonWorkingTimeDTO getByPersonId(String personId) {
List<EPASContracts> listContracts = epasContranctsService.getByPersonId(personId);
List<EPASContracts> listContracts = null;
try {
listContracts = epasContranctsService.getByPersonId(personId);
} catch (Exception e) {
logger.error("Error retrieving contracts for person id: {}", personId);
logger.error(e.getLocalizedMessage(), e);
return null;
}
if (listContracts == null || listContracts.isEmpty()) { if (listContracts == null || listContracts.isEmpty()) {
logger.error("There is no contract for this person Id: {}", personId); logger.error("There is no contract for this person Id: {}", personId);
return null; return null;
} }
EPASPersonWorkingTimeDTO pwtDTO = getPersonWorkingTimeDTO(personId, listContracts); EPASPersonWorkingTimeDTO pwtDTO = getPersonWorkingTimeDTO(personId, listContracts);
return pwtDTO; return pwtDTO;
} }
public EPASPersonWorkingTimeDTO getByPersonFiscalCode(String fc) { public EPASPersonWorkingTimeDTO getByPersonFiscalCode(String fc) {
EPASPersons epasPerson=epasPersonService.getByFiscalCode(fc); EPASPersons epasPerson = epasPersonService.getByFiscalCode(fc);
if(epasPerson==null||epasPerson.getId()==null||epasPerson.getId().isEmpty()) { if (epasPerson == null || epasPerson.getId() == null || epasPerson.getId().isEmpty()) {
logger.error("There is no Person for fiscal code: {}", fc); logger.error("There is no Person for fiscal code: {}", fc);
return null; return null;
} }
logger.debug("EPASPerson: {}",epasPerson); logger.debug("EPASPerson: {}", epasPerson);
List<EPASContracts> listContracts = epasContranctsService.getByPersonFiscalcode(fc);
List<EPASContracts> listContracts = null;
try {
listContracts = epasContranctsService.getByPersonFiscalcode(fc);
} catch (Exception e) {
logger.error("Error retrieving contracts for fiscal code: {}", fc);
logger.error(e.getLocalizedMessage(), e);
return null;
}
if (listContracts == null || listContracts.isEmpty()) { if (listContracts == null || listContracts.isEmpty()) {
logger.error("There is no contract for this person Id: {}", epasPerson.getId()); logger.error("There is no contract for this person Id: {}", epasPerson.getId());
return null; return null;
@ -59,8 +79,6 @@ public class EPASPersonWorkingTimeService {
return pwtDTO; return pwtDTO;
} }
private EPASPersonWorkingTimeDTO getPersonWorkingTimeDTO(String personId, List<EPASContracts> listContracts) { private EPASPersonWorkingTimeDTO getPersonWorkingTimeDTO(String personId, List<EPASContracts> listContracts) {
String lastContractId = null; String lastContractId = null;
LocalDate lastContractDate = null; LocalDate lastContractDate = null;
@ -74,7 +92,7 @@ public class EPASPersonWorkingTimeService {
} }
if (lastContractId == null || lastContractId.isEmpty()) { if (lastContractId == null || lastContractId.isEmpty()) {
logger.error("There is no last contract for this person id: {}",personId); logger.error("There is no last contract for this person id: {}", personId);
return null; return null;
} }
logger.debug("Found Last Contract Id: {}", lastContractId); logger.debug("Found Last Contract Id: {}", lastContractId);
@ -123,7 +141,7 @@ public class EPASPersonWorkingTimeService {
} }
LinkedHashMap<Integer, Integer> workingTimeByDays = new LinkedHashMap<Integer, Integer>(); LinkedHashMap<Integer, Integer> workingTimeByDays = new LinkedHashMap<Integer, Integer>();
int percentuale = 0;
for (EPASWorkingTimeTypeDays wtd : wtt.getWorkingTimeTypeDays()) { for (EPASWorkingTimeTypeDays wtd : wtt.getWorkingTimeTypeDays()) {
boolean isHoliday = Boolean.parseBoolean(wtd.getHoliday()); boolean isHoliday = Boolean.parseBoolean(wtd.getHoliday());
try { try {
@ -134,23 +152,40 @@ public class EPASPersonWorkingTimeService {
} else { } else {
int workingTime = Integer.parseInt(wtd.getWorkingTime()); int workingTime = Integer.parseInt(wtd.getWorkingTime());
workingTimeByDays.put(dayOfWeek, workingTime); workingTimeByDays.put(dayOfWeek, workingTime);
percentuale += workingTime;
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
logger.error("Invalid working time by days: "+e.getLocalizedMessage(),e); logger.error("Invalid working time by days: " + e.getLocalizedMessage(), e);
} }
} }
//TODO percentuale = (100 * percentuale) / 2160;
// Recuperare la percentuale, turno e le ore turno. // TODO
// turno e le ore turno.
EPASPersonWorkingTimeDTO pwtDTO = new EPASPersonWorkingTimeDTO(lastContractId, personId, EPASPersonWorkingTimeDTO pwtDTO = new EPASPersonWorkingTimeDTO(lastContractId, personId,
lastContract.getPerson().getFiscalCode(), lastWTPBeginDateS, lastWTPEndDate, wtt.getDescription(), lastContract.getPerson().getFiscalCode(), lastWTPBeginDateS, lastWTPEndDate, wtt.getDescription(),
workingTimeByDays.get(DayOfWeek.MONDAY.getValue()), workingTimeByDays.get(DayOfWeek.TUESDAY.getValue()), workingTimeByDays.get(DayOfWeek.MONDAY.getValue()), workingTimeByDays.get(DayOfWeek.TUESDAY.getValue()),
workingTimeByDays.get(DayOfWeek.WEDNESDAY.getValue()), workingTimeByDays.get(DayOfWeek.WEDNESDAY.getValue()),
workingTimeByDays.get(DayOfWeek.THURSDAY.getValue()), workingTimeByDays.get(DayOfWeek.THURSDAY.getValue()),
workingTimeByDays.get(DayOfWeek.FRIDAY.getValue()), workingTimeByDays.get(DayOfWeek.FRIDAY.getValue()),
workingTimeByDays.get(DayOfWeek.SATURDAY.getValue()), workingTimeByDays.get(DayOfWeek.SATURDAY.getValue()), percentuale, "NO", 0, "SI", "NO");
100, "NO", 0, "SI", "NO");
return pwtDTO; return pwtDTO;
} }
public List<EPASPersonWorkingTimeDTO> getList(String officeId) {
List<EPASPersons> epasPersons=epasPersonService.getList(officeId);
if(epasPersons==null||epasPersons.isEmpty()) {
logger.error("No persons found for office id: {}",officeId);
return null;
}
List<EPASPersonWorkingTimeDTO> pwtDTOList=new LinkedList<>();
for(EPASPersons epasPerson:epasPersons) {
EPASPersonWorkingTimeDTO pwtDTO=getByPersonId(epasPerson.getId());
pwtDTOList.add(pwtDTO);
}
return pwtDTOList;
}
} }

View File

@ -0,0 +1,31 @@
package it.cnr.isti.epasmed.sistemainformativo.model;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SIAspettative implements Serializable {
private static final long serialVersionUID = 1L;
private String cf;
private String codice_assenza_descrizione;
private Date data_inizio;
private Date data_fine;
private Timestamp data_mod;
private String flag_del;
private Long id_flusso;
private Integer id;
private Integer idpersona;
private Integer codice_assenza_codice;
private String codice_assenza_cnr;
private Integer durata;
}

View File

@ -0,0 +1,39 @@
package it.cnr.isti.epasmed.sistemainformativo.model;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SIPersOrario implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
private Integer idpersona;
private String cf;
private Date dal;
private Date al;
private String descrizione;
private Integer lun;
private Integer mar;
private Integer mer;
private Integer gio;
private Integer ven;
private Integer sab;
private Integer percentuale;
private String turno;
private Integer ore_turno;
private String festivo;
private String notturno;
private Timestamp data_mod;
private String flag_del;
private Long id_flusso;
}

View File

@ -0,0 +1,43 @@
package it.cnr.isti.epasmed.sistemainformativo.repository;
import javax.sql.DataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import it.cnr.isti.epasmed.sistemainformativo.model.SIAspettative;
@Repository
public class SIAspettativeRepository {
private static final Logger logger = LoggerFactory.getLogger(SIAspettativeRepository.class);
private JdbcTemplate jdbcTemplate;
//
public SIAspettativeRepository(
final @Qualifier("sistemaInformativoDataSource") DataSource dataSource) {
super();
this.jdbcTemplate = new JdbcTemplate(dataSource);
}
public void writeNewFlux(Long fluxId, SIAspettative siAspettative) {
jdbcTemplate.update(
"INSERT INTO epas_aspettative (cf,codice_assenza_descrizione,"
+ "data_inizio,data_fine,data_mod,flag_del,id_flusso,"
+ "id,idpersona,"
+ "codice_assenza_codice,codice_assenza_cnr,durata)"
+ " VALUES (?,?,?,?,?,?,?,?,?,?,?,?)",
siAspettative.getCf(), siAspettative.getCodice_assenza_descrizione(),
siAspettative.getData_inizio(), siAspettative.getData_fine(),
siAspettative.getData_mod(),siAspettative.getFlag_del(), fluxId,
siAspettative.getId(), siAspettative.getIdpersona(),
siAspettative.getCodice_assenza_codice(), siAspettative.getCodice_assenza_cnr(),
siAspettative.getDurata());
logger.debug("Writed SIAspettative: {}", siAspettative);
}
}

View File

@ -77,7 +77,7 @@ public class SIMasterLogRepository {
jdbcTemplate.update("INSERT INTO master_log (codice_flusso, tabelle, operazione, data_inizio_oper)" jdbcTemplate.update("INSERT INTO master_log (codice_flusso, tabelle, operazione, data_inizio_oper)"
+ " VALUES ('epas','epas_cartellini, epas_cartellini_rendicontazioni," + " VALUES ('epas','epas_cartellini, epas_cartellini_rendicontazioni,"
+ " epas_orario," + " epas_orario,"
+ " epas_lavoro_fuori_sede'," + " epas_lavoro_fuori_sede, epas_aspettative, epas_pers_orario',"
+ " 'S',current_timestamp)"); + " 'S',current_timestamp)");
logger.info("Flusso in scrittura aperto"); logger.info("Flusso in scrittura aperto");

View File

@ -0,0 +1,35 @@
package it.cnr.isti.epasmed.sistemainformativo.service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import it.cnr.isti.epasmed.sistemainformativo.model.SIAspettative;
import it.cnr.isti.epasmed.sistemainformativo.repository.SIAspettativeRepository;
/**
* Service class for managing Aspettative.
*/
@Service
@Transactional("sistemaInformativoTransactionManager")
public class SIAspettativeService {
private static final Logger logger = LoggerFactory.getLogger(SIAspettativeService.class);
private final SIAspettativeRepository siAspettativeRepository;
public SIAspettativeService(SIAspettativeRepository siAspettativeRepository) {
super();
this.siAspettativeRepository = siAspettativeRepository;
}
public void writeNewFlux(Long fluxId, SIAspettative siAspettative) {
logger.debug("Write SIAspettative Flux = {}",fluxId);
siAspettativeRepository.writeNewFlux(fluxId,siAspettative);
}
}

View File

@ -2,14 +2,17 @@ package it.cnr.isti.epasmed.sync;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.YearMonth; import java.time.YearMonth;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder; import java.time.format.DateTimeFormatterBuilder;
import java.time.format.DateTimeParseException; import java.time.format.DateTimeParseException;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -30,9 +33,11 @@ import it.cnr.isti.epasmed.epas.dto.EPASPersonsDTO;
import it.cnr.isti.epasmed.epas.mapper.EPASAffiliationsMapper; import it.cnr.isti.epasmed.epas.mapper.EPASAffiliationsMapper;
import it.cnr.isti.epasmed.epas.mapper.EPASGroupsMapper; import it.cnr.isti.epasmed.epas.mapper.EPASGroupsMapper;
import it.cnr.isti.epasmed.epas.mapper.EPASPersonsMapper; import it.cnr.isti.epasmed.epas.mapper.EPASPersonsMapper;
import it.cnr.isti.epasmed.epas.model.EPASAbsenceTypes;
import it.cnr.isti.epasmed.epas.model.EPASAbsences; import it.cnr.isti.epasmed.epas.model.EPASAbsences;
import it.cnr.isti.epasmed.epas.model.EPASAffiliations; import it.cnr.isti.epasmed.epas.model.EPASAffiliations;
import it.cnr.isti.epasmed.epas.model.EPASGroups; import it.cnr.isti.epasmed.epas.model.EPASGroups;
import it.cnr.isti.epasmed.epas.model.EPASLeaves;
import it.cnr.isti.epasmed.epas.model.EPASOffSiteWorks; import it.cnr.isti.epasmed.epas.model.EPASOffSiteWorks;
import it.cnr.isti.epasmed.epas.model.EPASPersonDays; import it.cnr.isti.epasmed.epas.model.EPASPersonDays;
import it.cnr.isti.epasmed.epas.model.EPASPersons; import it.cnr.isti.epasmed.epas.model.EPASPersons;
@ -43,6 +48,7 @@ import it.cnr.isti.epasmed.epas.model.EPASWorkingTimeTypes;
import it.cnr.isti.epasmed.epas.service.EPASAbsenceTypesService; import it.cnr.isti.epasmed.epas.service.EPASAbsenceTypesService;
import it.cnr.isti.epasmed.epas.service.EPASAffiliationsService; import it.cnr.isti.epasmed.epas.service.EPASAffiliationsService;
import it.cnr.isti.epasmed.epas.service.EPASGroupsService; import it.cnr.isti.epasmed.epas.service.EPASGroupsService;
import it.cnr.isti.epasmed.epas.service.EPASLeavesService;
import it.cnr.isti.epasmed.epas.service.EPASOffSiteWorksService; import it.cnr.isti.epasmed.epas.service.EPASOffSiteWorksService;
import it.cnr.isti.epasmed.epas.service.EPASPersonsService; import it.cnr.isti.epasmed.epas.service.EPASPersonsService;
import it.cnr.isti.epasmed.epas.service.EPASTimeCardsService; import it.cnr.isti.epasmed.epas.service.EPASTimeCardsService;
@ -51,6 +57,7 @@ import it.cnr.isti.epasmed.epas.service.EPASWorkingTimeTypesService;
import it.cnr.isti.epasmed.service.TabsSIService; import it.cnr.isti.epasmed.service.TabsSIService;
import it.cnr.isti.epasmed.service.TimeCardsReportingService; import it.cnr.isti.epasmed.service.TimeCardsReportingService;
import it.cnr.isti.epasmed.sistemainformativo.model.SIAnagrafico; import it.cnr.isti.epasmed.sistemainformativo.model.SIAnagrafico;
import it.cnr.isti.epasmed.sistemainformativo.model.SIAspettative;
import it.cnr.isti.epasmed.sistemainformativo.model.SICartellini; import it.cnr.isti.epasmed.sistemainformativo.model.SICartellini;
import it.cnr.isti.epasmed.sistemainformativo.model.SICartelliniRendicontazioni; import it.cnr.isti.epasmed.sistemainformativo.model.SICartelliniRendicontazioni;
import it.cnr.isti.epasmed.sistemainformativo.model.SIEmail; import it.cnr.isti.epasmed.sistemainformativo.model.SIEmail;
@ -60,6 +67,7 @@ import it.cnr.isti.epasmed.sistemainformativo.model.SILavoroFuoriSede;
import it.cnr.isti.epasmed.sistemainformativo.model.SIOrario; import it.cnr.isti.epasmed.sistemainformativo.model.SIOrario;
import it.cnr.isti.epasmed.sistemainformativo.model.SITelefoni; import it.cnr.isti.epasmed.sistemainformativo.model.SITelefoni;
import it.cnr.isti.epasmed.sistemainformativo.service.SIAnagraficoService; import it.cnr.isti.epasmed.sistemainformativo.service.SIAnagraficoService;
import it.cnr.isti.epasmed.sistemainformativo.service.SIAspettativeService;
import it.cnr.isti.epasmed.sistemainformativo.service.SICartelliniRendicontazioniService; import it.cnr.isti.epasmed.sistemainformativo.service.SICartelliniRendicontazioniService;
import it.cnr.isti.epasmed.sistemainformativo.service.SICartelliniService; import it.cnr.isti.epasmed.sistemainformativo.service.SICartelliniService;
import it.cnr.isti.epasmed.sistemainformativo.service.SIEmailService; import it.cnr.isti.epasmed.sistemainformativo.service.SIEmailService;
@ -114,6 +122,8 @@ public class SyncService {
SIOrarioService siOrarioService; SIOrarioService siOrarioService;
@Autowired @Autowired
SILavoroFuoriSedeService siLavoroFuoriSedeService; SILavoroFuoriSedeService siLavoroFuoriSedeService;
@Autowired
SIAspettativeService siAspettativeService;
@Autowired @Autowired
EPASPersonsService epasPersonsService; EPASPersonsService epasPersonsService;
@ -133,6 +143,8 @@ public class SyncService {
EPASOffSiteWorksService epasOffSiteWorksService; EPASOffSiteWorksService epasOffSiteWorksService;
@Autowired @Autowired
EPASAbsenceTypesService epasAbsenceTypeService; EPASAbsenceTypesService epasAbsenceTypeService;
@Autowired
EPASLeavesService epasLeavesService;
private boolean banagrafico; private boolean banagrafico;
private boolean bemail; private boolean bemail;
@ -218,6 +230,15 @@ public class SyncService {
} }
public void executeWriteLeaves(String year, String month) throws Exception {
setBWriteTables();
List<TabsSI> tabsSI = tabsSIService.getAllTabsSI();
Long fluxId = siMasterLogService.startFluxWrites();
writeLeavesData(fluxId, tabsSI, year, month);
siMasterLogService.closeFluxWrites(fluxId, writeTabs());
}
private void readData(List<TabsSI> tabsSI) { private void readData(List<TabsSI> tabsSI) {
// TabsSI posizioniTab = null; // TabsSI posizioniTab = null;
// TabsSI prorogheTab = null; // TabsSI prorogheTab = null;
@ -831,20 +852,6 @@ public class SyncService {
case "orario": case "orario":
syncOrario(fluxId, tab); syncOrario(fluxId, tab);
break; break;
// case "pers_orario":
// syncPersOrario(fluxId,tab);
// break;
// case "cartellini":
// break;
// case "cartellini_rendicontazioni":
// syncCartelliniRendicontazioni(fluxId, tab);
// break;
// case "lavoro_fuori_sede":
// syncLavoroFuoriSede(fluxId,tab);
// break;
// case "aspettative":
// syncAspettative(fluxId,tab);
// break;
default: default:
break; break;
} }
@ -937,9 +944,6 @@ public class SyncService {
logger.info("Report {}-{}", year, month); logger.info("Report {}-{}", year, month);
logger.info("FiscalCode: {}", fc); logger.info("FiscalCode: {}", fc);
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
// checkValidMonthToSend(year, month);
// TimeCardsReporting timeCardsReporting = createTimeCardReporting(fluxId, year,
// month, now);
for (TabsSI tab : tabsSI) { for (TabsSI tab : tabsSI) {
logger.info("TabSI: {}", tab); logger.info("TabSI: {}", tab);
@ -950,25 +954,9 @@ public class SyncService {
} }
switch (tab.getNome()) { switch (tab.getNome()) {
// case "orario":
// syncOrario(fluxId, tab);
// break;
// case "pers_orario":
// syncPersOrario(fluxId,tab);
// break;
case "cartellini": case "cartellini":
syncSingleCartellino(fluxId, tab, year, month, now, fc); syncSingleCartellino(fluxId, tab, year, month, now, fc);
break; break;
// case "cartellini_rendicontazioni":
// syncCartelliniRendicontazioni(fluxId, tab, year, month, now,
// timeCardsReporting);
// break;
// case "lavoro_fuori_sede":
// syncLavoroFuoriSede(fluxId,tab);
// break;
// case "aspettative":
// syncAspettative(fluxId,tab);
// break;
default: default:
break; break;
} }
@ -980,7 +968,7 @@ public class SyncService {
private void writeOffSiteWorksData(Long fluxId, List<TabsSI> tabsSI, String year, String month) throws Exception { private void writeOffSiteWorksData(Long fluxId, List<TabsSI> tabsSI, String year, String month) throws Exception {
logger.info("Report {}-{}", year, month); logger.info("Report {}-{}", year, month);
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
checkValidMonthToSend(year, month); // checkValidMonthToSend(year, month);
for (TabsSI tab : tabsSI) { for (TabsSI tab : tabsSI) {
logger.info("TabSI: {}", tab); logger.info("TabSI: {}", tab);
@ -991,23 +979,34 @@ public class SyncService {
} }
switch (tab.getNome()) { switch (tab.getNome()) {
// case "orario":
// syncOrario(fluxId, tab);
// break;
// case "pers_orario":
// syncPersOrario(fluxId,tab);
// break;
// case "cartellini":
// break;
// case "cartellini_rendicontazioni":
// syncCartelliniRendicontazioni(fluxId, tab);
// break;
case "lavoro_fuori_sede": case "lavoro_fuori_sede":
syncLavoroFuoriSede(fluxId, tab, year, month, now); syncLavoroFuoriSede(fluxId, tab, year, month, now);
break; break;
// case "aspettative": default:
// syncAspettative(fluxId,tab); break;
// break; }
}
}
}
private void writeLeavesData(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;
default: default:
break; break;
} }
@ -1164,6 +1163,163 @@ public class SyncService {
} }
private void syncAspettative(Long fluxId, TabsSI tab, String year, String month, LocalDateTime now)
throws Exception {
if (tab.getIdFlusso() == null || tab.getIdFlusso().longValue() == 0) {
logger.error("Invalid Id Flusso for tab: {}", tab);
return;
}
logger.info("Reference: {}-{}", year, month);
Integer nextYear = 0;
try {
nextYear = Integer.parseInt(year);
} catch (Exception e) {
logger.error("Invalid year parameter: {}", year);
return;
}
nextYear = nextYear + 1;
logger.info("Next Year: {}", nextYear.toString());
List<EPASLeaves> epasLeavesList = epasLeavesService.getLeavesByOfficeId(ISTI_OFFICE_ID, year, "true");
logger.info("Current Year Leaves: {}", epasLeavesList);
List<EPASLeaves> epasLeavesNextList = epasLeavesService.getLeavesByOfficeId(ISTI_OFFICE_ID, nextYear.toString(),
"true");
logger.info("Next Year Leaves: {}", epasLeavesNextList);
if (epasLeavesList == null || epasLeavesList.isEmpty()) {
logger.info("Leaves not found for: {}", year);
epasLeavesList = new LinkedList<>();
}
if (epasLeavesNextList == null || epasLeavesNextList.isEmpty()) {
logger.info("Leaves not found for: {}", nextYear);
epasLeavesNextList = new LinkedList<>();
}
epasLeavesList.addAll(epasLeavesNextList);
if (epasLeavesList.isEmpty()) {
logger.info("Leaves not found");
return;
}
LinkedHashMap<String, EPASAbsenceTypes> epasAbsenceTypeMap = epasAbsenceTypeService.getAbsenceTypesMapFull();
if (epasAbsenceTypeMap == null || epasAbsenceTypeMap.isEmpty()) {
logger.error("Absence Type Map not found");
return;
}
writeAspettativeOnSI(fluxId, now, epasLeavesList, epasAbsenceTypeMap);
logger.info("SIAspettative Updated");
baspettative = true;
tab.setIdFlusso(fluxId);
tab.setLastUpdate(now);
tabsSIService.updateTabsSI(tab);
}
private void writeAspettativeOnSI(Long fluxId, LocalDateTime now, List<EPASLeaves> epasLeavesList,
LinkedHashMap<String, EPASAbsenceTypes> epasAbsenceTypeMap) {
// SI
for (EPASLeaves leave : epasLeavesList) {
logger.info("Writing Leave: {}", leave);
if (leave == null || leave.getPerson() == null) {
logger.error("Invalid Leave: {}", leave);
continue;
}
if (leave.getPerson().getFiscalCode() == null || leave.getPerson().getFiscalCode().isEmpty()) {
logger.error("Invalid FiscalCode: {}", leave.getPerson().getFiscalCode());
continue;
} else {
logger.info("FiscalCode: {}", leave.getPerson().getFiscalCode());
}
Integer idPersona = 0;
try {
idPersona = Integer.valueOf(leave.getPerson().getId());
} catch (NumberFormatException e) {
logger.error("Invalid Person Id: {}", leave.getPerson().getId());
continue;
}
if (leave.getCode() == null || leave.getCode().isEmpty()) {
logger.error("Invalid absence code: {}", leave.getCode());
continue;
}
EPASAbsenceTypes epasAbsenceType = epasAbsenceTypeMap.get(leave.getCode());
if (epasAbsenceType == null) {
logger.error("Not found absence type: {}", leave.getCode());
continue;
}
Integer absenceId = 0;
try {
absenceId = Integer.parseInt(epasAbsenceType.getId());
} catch (NumberFormatException e) {
logger.error("Not found absence id for absence: {}", leave.getCode());
continue;
}
logger.info("Start Date: {}", leave.getStart());
java.sql.Date startDate = null;
if (leave.getStart() == null || leave.getStart().isEmpty()) {
logger.error("Invalid start date: {}", leave.getStart());
continue;
}
try {
startDate = java.sql.Date.valueOf(leave.getStart());
} catch (Exception e) {
logger.error("Invalid start date format: {}", leave.getStart());
continue;
}
logger.info("End Date: {}", leave.getEnd());
java.sql.Date endDate = null;
if (leave.getEnd() != null && !leave.getEnd().isEmpty()) {
try {
endDate = java.sql.Date.valueOf(leave.getEnd());
} catch (Exception e) {
logger.error("Invalid end date format: {}", leave.getEnd());
}
}
Timestamp dataMod = Timestamp.valueOf(now);
Integer durata = 0;
if (startDate != null && endDate != null) {
LocalDate startD = LocalDate.parse(leave.getStart());
LocalDate endD = LocalDate.parse(leave.getEnd());
durata = new Long(ChronoUnit.DAYS.between(startD, endD) + 1).intValue();
}
int id = 0;
if (leave.getAbsences() != null && leave.getAbsences().length > 0) {
EPASAbsences firstAbsence = leave.getAbsences()[0];
try {
id = Integer.parseInt(firstAbsence.getId());
} catch (NumberFormatException e) {
logger.error("Invalid id for first absence: {}",firstAbsence);
}
}
SIAspettative siAspettative = new SIAspettative(leave.getPerson().getFiscalCode(),
epasAbsenceType.getDescription(), startDate, endDate, dataMod, SI_FLAG_DEL_FALSE, fluxId, id,
idPersona, absenceId, epasAbsenceType.getCode(), durata);
logger.info("Write SIAspettativa: {}", siAspettative);
siAspettativeService.writeNewFlux(fluxId, siAspettative);
}
}
private void syncCartelliniRendicontazioni(Long fluxId, TabsSI tab, String year, String month, LocalDateTime now, private void syncCartelliniRendicontazioni(Long fluxId, TabsSI tab, String year, String month, LocalDateTime now,
TimeCardsReporting timeCardsReporting) throws Exception { TimeCardsReporting timeCardsReporting) throws Exception {
if (tab.getIdFlusso() == null || tab.getIdFlusso().longValue() == 0) { if (tab.getIdFlusso() == null || tab.getIdFlusso().longValue() == 0) {

View File

@ -39,29 +39,30 @@ public class EPASLeavesResource {
* @param id the id of the person. * @param id the id of the person.
* @param fiscalCode the fiscal code of the person. * @param fiscalCode the fiscal code of the person.
* @param email the email of the person. * @param email the email of the person.
* @param includeDetails a true or false flag that specifies whether or not to
* include absence details.
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body
* the EPAS Leaves, or with status {@code 404 (Not Found)}. * the EPAS Leaves, or with status {@code 404 (Not Found)}.
*/ */
@GetMapping("/leaves/byPersonAndYear") @GetMapping("/leaves/byPersonAndYear")
public ResponseEntity<List<EPASLeaves>> getEPASContractsByPerson(@RequestParam("id") Optional<String> id, public ResponseEntity<List<EPASLeaves>> getEPASContractsByPerson(@RequestParam("id") Optional<String> id,
@RequestParam("fiscalCode") Optional<String> fiscalCode, @RequestParam("fiscalCode") Optional<String> fiscalCode, @RequestParam("email") Optional<String> email,
@RequestParam("email") Optional<String> email, @RequestParam("year") String year, @RequestParam("includeDetails") String includeDetails) {
@RequestParam("year") String year) {
List<EPASLeaves> epasLeavesList = null; List<EPASLeaves> epasLeavesList = null;
if (id.isPresent()) { if (id.isPresent()) {
logger.info("REST request to get ePAS Leaves by Person: {}", id.get()); logger.info("REST request to get ePAS Leaves by Person: {}", id.get());
epasLeavesList = epasLeavesService.getLeavesByPersonId(id.get(),year); epasLeavesList = epasLeavesService.getLeavesByPersonId(id.get(), year, includeDetails);
} else { } else {
if (fiscalCode.isPresent()) { if (fiscalCode.isPresent()) {
logger.info("REST request to get ePAS Leaves by Person fiscal code: {}", fiscalCode.get()); logger.info("REST request to get ePAS Leaves by Person fiscal code: {}", fiscalCode.get());
epasLeavesList = epasLeavesService.getLeavesByPersonFiscalcode(fiscalCode.get(), year); epasLeavesList = epasLeavesService.getLeavesByPersonFiscalcode(fiscalCode.get(), year, includeDetails);
} else { } else {
if (email.isPresent()) { if (email.isPresent()) {
logger.info("REST request to get ePAS Leaves by Person email: {}", email.get()); logger.info("REST request to get ePAS Leaves by Person email: {}", email.get());
epasLeavesList = epasLeavesService.getLeavesByPersonEmail(email.get(), year); epasLeavesList = epasLeavesService.getLeavesByPersonEmail(email.get(), year, includeDetails);
} else { } else {
return ResponseUtil.wrapOrNotFound(Optional.of(epasLeavesList), HeaderUtil.createFailureAlert(applicationName,false, return ResponseUtil.wrapOrNotFound(Optional.of(epasLeavesList),
"","","Invalid parameter in call")); HeaderUtil.createFailureAlert(applicationName, false, "", "", "Invalid parameter in call"));
} }
} }
@ -70,23 +71,23 @@ public class EPASLeavesResource {
return ResponseUtil.wrapOrNotFound(Optional.of(epasLeavesList)); return ResponseUtil.wrapOrNotFound(Optional.of(epasLeavesList));
} }
/** /**
* {@code GET /leaves/byOfficeAndYear} : get leaves by office and year. * {@code GET /leaves/byOfficeAndYear} : get leaves by office and year.
* *
* @param officeCodeId the office codeId. * @param officeId the office Id.
* @param year the year. * @param year the year.
* @param includeDetails a true or false flag that specifies whether or not to
* include absence details.
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body
* the list of EPAS Leaves, or with status {@code 404 (Not Found)}. * the list of EPAS Leaves, or with status {@code 404 (Not Found)}.
*/ */
@GetMapping("/leaves/byOfficeAndYear") @GetMapping("/leaves/byOfficeAndYear")
public ResponseEntity<List<EPASLeaves>> getEPASLeavesByOfficeCodeId(@RequestParam("officeCodeId") String officeCodeId, public ResponseEntity<List<EPASLeaves>> getEPASLeavesByOfficeCodeId(@RequestParam("officeId") String officeId,
@RequestParam("year") String year) { @RequestParam("year") String year, @RequestParam("includeDetails") String includeDetails) {
logger.info("REST request to get ePAS Leaves by office: codeId={}, year={}", officeCodeId, year); logger.info("REST request to get ePAS Leaves by office: codeId={}, year={}", officeId, year);
List<EPASLeaves> epasLeavesList = epasLeavesService.getLeavesByOfficeCodeId(officeCodeId, year); List<EPASLeaves> epasLeavesList = epasLeavesService.getLeavesByOfficeId(officeId, year, includeDetails);
return ResponseUtil.wrapOrNotFound(Optional.of(epasLeavesList)); return ResponseUtil.wrapOrNotFound(Optional.of(epasLeavesList));
} }
} }

View File

@ -1,5 +1,6 @@
package it.cnr.isti.epasmed.web.rest.epas; package it.cnr.isti.epasmed.web.rest.epas;
import java.util.List;
import java.util.Optional; import java.util.Optional;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -61,4 +62,22 @@ public class EPASPersonWorkingTimeResource {
return ResponseUtil.wrapOrNotFound(Optional.of(epasPersonWorkingTime)); return ResponseUtil.wrapOrNotFound(Optional.of(epasPersonWorkingTime));
} }
/**
* {@code GET /personworkingtime/list} : get personwokingtime by office id.
*
* @param officeId the office Id.
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body
* the list of EPAS Person Working Time, or with status
* {@code 404 (Not Found)}.
*/
@GetMapping("/personworkingtime/list")
public ResponseEntity<List<EPASPersonWorkingTimeDTO>> getEPASPersonWorkingTimeOfficeId(
@RequestParam("officeId") String officeId) {
logger.info("REST request to get ePAS Person Working Time by office Id={}", officeId);
List<EPASPersonWorkingTimeDTO> epasPersonWorkingTimeList = epasPersonWorkingTimeService.getList(officeId);
return ResponseUtil.wrapOrNotFound(Optional.of(epasPersonWorkingTimeList));
}
} }

View File

@ -221,4 +221,31 @@ public class SyncResource {
return res; return res;
} }
/**
* {@code GET /sync/writesLeaves} : Reports Leaves from ePAS in
* SistemaInformativo.
*
* @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/writesLeaves")
@PreAuthorize("hasAuthority(\"" + AuthoritiesConstants.ADMIN + "\")")
public ResponseEntity<Void> syncWritesLeaves(@RequestParam("year") String year,
@RequestParam("month") String month) throws Exception {
logger.info("REST request syncWritesLeaves)");
ResponseEntity<Void> res;
syncService.executeWriteLeaves(year, month);
String msg = "Rendicontazione delle Aspettative eseguita correttamente.";
logger.info(msg);
res = ResponseEntity.noContent().headers(HeaderUtil.createAlert(applicationName, msg, "")).build();
return res;
}
} }

View File

@ -36,7 +36,7 @@ import it.cnr.isti.epasmed.security.AuthoritiesConstants;
@EnabledIf("false") @EnabledIf("false")
public class EPASAbsenceTypesResourceIT { public class EPASAbsenceTypesResourceIT {
private final Logger log = LoggerFactory.getLogger(getClass()); private final Logger logger = LoggerFactory.getLogger(getClass());
// private static final String OFFICE_DEFAULT_ID = "1"; // private static final String OFFICE_DEFAULT_ID = "1";
// private static final String OFFICE_DEFAULT_NAME = "ISTI - Pisa"; // private static final String OFFICE_DEFAULT_NAME = "ISTI - Pisa";
@ -52,7 +52,7 @@ public class EPASAbsenceTypesResourceIT {
@BeforeEach @BeforeEach
public void initTest() { public void initTest() {
for (String profileName : environment.getActiveProfiles()) { for (String profileName : environment.getActiveProfiles()) {
log.info("Currently active profile - " + profileName); logger.info("Currently active profile - " + profileName);
} }
} }
@ -70,14 +70,14 @@ public class EPASAbsenceTypesResourceIT {
}); });
} catch (Exception e) { } catch (Exception e) {
log.error(e.getLocalizedMessage(), e); logger.error(e.getLocalizedMessage(), e);
return; return;
} }
if (epasAbsenceTypes != null) { if (epasAbsenceTypes != null) {
log.info("EPAS Absence Types size: {}", epasAbsenceTypes.size()); logger.info("EPAS Absence Types size: {}", epasAbsenceTypes.size());
for (EPASAbsenceTypes type : epasAbsenceTypes) { for (EPASAbsenceTypes type : epasAbsenceTypes) {
log.info("{}", type); logger.info("{}", type);
} }
} }
@ -97,14 +97,14 @@ public class EPASAbsenceTypesResourceIT {
}); });
} catch (Exception e) { } catch (Exception e) {
log.error(e.getLocalizedMessage(), e); logger.error(e.getLocalizedMessage(), e);
return; return;
} }
if (epasAbsenceTypesMap != null) { if (epasAbsenceTypesMap != null) {
log.info("EPAS Absence Types Map size: {}", epasAbsenceTypesMap.size()); logger.info("EPAS Absence Types Map size: {}", epasAbsenceTypesMap.size());
for (Map.Entry<String, String> m : epasAbsenceTypesMap.entrySet()) { for (Map.Entry<String, String> m : epasAbsenceTypesMap.entrySet()) {
log.info(m.getKey() + "-" + m.getValue()); logger.info(m.getKey() + "-" + m.getValue());
} }
} }

View File

@ -29,27 +29,26 @@ public class EPASLeavesResourceIT {
private final Logger log = LoggerFactory.getLogger(getClass()); private final Logger log = LoggerFactory.getLogger(getClass());
// private static final String OFFICE_DEFAULT_ID = "1"; private static final String OFFICE_DEFAULT_ID = "1";
// private static final String OFFICE_DEFAULT_NAME = "ISTI - Pisa"; // private static final String OFFICE_DEFAULT_NAME = "ISTI - Pisa";
// private static final String OFFICE_DEFAULT_CODE = "074000"; // private static final String OFFICE_DEFAULT_CODE = "074000";
private static final String OFFICE_DEFAULT_CODEID = "225200"; // private static final String OFFICE_DEFAULT_CODEID = "225200";
private static final String YEAR_DEFAULT="2022"; private static final String YEAR_DEFAULT = "2022";
private static final String INCLUDEDETAILS_DEFAULT = "false";
private static final String PERSON_DEFAULT_ID = "xxx"; private static final String PERSON_DEFAULT_ID = "1";
//private static final String PERSON_DEFAULT_NAME = "Giulio"; // private static final String PERSON_DEFAULT_NAME = "Giulio";
//private static final String PERSON_DEFAULT_SURNAME = "Mori"; // private static final String PERSON_DEFAULT_SURNAME = "Mori";
private static final String PERSON_DEFAULT_FISCAL_CODE = "MROGLI68H29E625F"; private static final String PERSON_DEFAULT_FISCAL_CODE = "MROGLI68H29E625F";
private static final String PERSON_DEFAULT_EMAIL = "giulio.mori@cnr.it"; private static final String PERSON_DEFAULT_EMAIL = "giulio.mori@cnr.it";
@Autowired @Autowired
private MockMvc restEPASLeavesMockMvc; private MockMvc restEPASLeavesMockMvc;
@Autowired @Autowired
private Environment environment; private Environment environment;
//private EPASLeaves epasLeaves; // private EPASLeaves epasLeaves;
@BeforeEach @BeforeEach
public void initTest() { public void initTest() {
@ -60,30 +59,26 @@ public class EPASLeavesResourceIT {
@Test @Test
public void getEPASLeavesByPersonId() throws Exception { public void getEPASLeavesByPersonId() throws Exception {
restEPASLeavesMockMvc.perform(get("/api/epas/leaves/byPersonAndYear?id=" + PERSON_DEFAULT_ID + "&year="+YEAR_DEFAULT)) restEPASLeavesMockMvc.perform(get("/api/epas/leaves/byPersonAndYear?id=" + PERSON_DEFAULT_ID + "&year="
.andExpect(status().isOk()); + YEAR_DEFAULT + "&includeDetails=" + INCLUDEDETAILS_DEFAULT)).andExpect(status().isOk());
} }
@Test @Test
public void getEPASLeaveByPersonFiscalcode() throws Exception { public void getEPASLeaveByPersonFiscalcode() throws Exception {
restEPASLeavesMockMvc restEPASLeavesMockMvc.perform(get("/api/epas/leaves/byPersonAndYear?fiscalCode=" + PERSON_DEFAULT_FISCAL_CODE
.perform( + "&year=" + YEAR_DEFAULT + "&includeDetails=" + INCLUDEDETAILS_DEFAULT)).andExpect(status().isOk());
get("/api/epas/leaves/byPersonAndYear?fiscalCode=" + PERSON_DEFAULT_FISCAL_CODE + "&year="+YEAR_DEFAULT))
.andExpect(status().isOk());
} }
@Test @Test
public void getEPASLeavesByPersonEmail() throws Exception { public void getEPASLeavesByPersonEmail() throws Exception {
restEPASLeavesMockMvc restEPASLeavesMockMvc.perform(get("/api/epas/leaves/byPersonAndYear?email=" + PERSON_DEFAULT_EMAIL + "&year="
.perform(get("/api/epas/leaves/byPersonAndYear?email=" + PERSON_DEFAULT_EMAIL + "&year="+YEAR_DEFAULT)) + YEAR_DEFAULT + "&includeDetails=" + INCLUDEDETAILS_DEFAULT)).andExpect(status().isOk());
.andExpect(status().isOk());
} }
@Test @Test
public void getEPASLeavesByOfficeCodeId() throws Exception { public void getEPASLeavesByOfficeId() throws Exception {
restEPASLeavesMockMvc restEPASLeavesMockMvc.perform(get("/api/epas/leaves/byOfficeAndYear?officeId=" + OFFICE_DEFAULT_ID + "&year="
.perform(get("/api/epas/leaves/byOfficeAndYear?officeCodeId=" + OFFICE_DEFAULT_CODEID + "&year="+YEAR_DEFAULT)) + YEAR_DEFAULT + "&includeDetails=" + INCLUDEDETAILS_DEFAULT)).andExpect(status().isOk());
.andExpect(status().isOk());
} }
} }

View File

@ -3,6 +3,8 @@ 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.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.util.List;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -35,7 +37,7 @@ public class EPASPersonWorkingTimeIT {
private static final Logger logger = LoggerFactory.getLogger(EPASPersonWorkingTimeIT.class); private static final Logger logger = LoggerFactory.getLogger(EPASPersonWorkingTimeIT.class);
// private static final String OFFICE_DEFAULT_ID = "1"; private static final String OFFICE_DEFAULT_ID = "1";
// private static final String OFFICE_DEFAULT_NAME = "ISTI - Pisa"; // private static final String OFFICE_DEFAULT_NAME = "ISTI - Pisa";
// private static final String OFFICE_DEFAULT_CODE = "074000"; // private static final String OFFICE_DEFAULT_CODE = "074000";
// private static final String OFFICE_DEFAULT_CODEID = "225200"; // private static final String OFFICE_DEFAULT_CODEID = "225200";
@ -43,7 +45,10 @@ public class EPASPersonWorkingTimeIT {
private static final String PERSON_DEFAULT_ID = "78"; private static final String PERSON_DEFAULT_ID = "78";
//private static final String PERSON_DEFAULT_FISCAL_CODE = "MROGLI68H29E625F"; //private static final String PERSON_DEFAULT_FISCAL_CODE = "MROGLI68H29E625F";
private static final String PERSON_DEFAULT_FISCAL_CODE = "PNCGCR75S04L103G"; private static final String PERSON_DEFAULT_FISCAL_CODE = "PNCGCR75S04L103G";
//private static final String PERSON_DEFAULT_FISCAL_CODE = "MLSDNL59T56E281S";
//private static final String PERSON_DEFAULT_FISCAL_CODE = "PCCMRA63M50G702W";
//private static final String PERSON_DEFAULT_FISCAL_CODE = "LMBGNN59T09G702K";
//private static final String PERSON_DEFAULT_FISCAL_CODE = "MNGPLA70T22D612X";
@Autowired @Autowired
@ -85,4 +90,20 @@ public class EPASPersonWorkingTimeIT {
} }
@Test
public void getPersonWorkingTimeList() throws Exception {
MvcResult result = restEPASPersonWorkingTimeMockMvc
.perform(get("/api/epas/personworkingtime/list?officeId=" + OFFICE_DEFAULT_ID)).andExpect(status().isOk())
.andReturn();
ObjectMapper mapper = new ObjectMapper();
List<EPASPersonWorkingTimeDTO> epasWTTList = mapper.readValue(result.getResponse().getContentAsString(),
new TypeReference<List<EPASPersonWorkingTimeDTO>>() {
});
logger.info("EPASPersonWorkingTime List: {}", epasWTTList);
}
} }

View File

@ -80,4 +80,14 @@ public class SyncResourceIT {
+ PERSON_DEFAULT_FISCAL_CODE)); + PERSON_DEFAULT_FISCAL_CODE));
} }
@Test
public void syncWritesOffSiteWorks() throws Exception {
restSyncMockMvc.perform(get("/api/sync/writesOffSiteWorks?year=" + YEAR + "&month=" + MONTH));
}
@Test
public void syncWritesLeaves() throws Exception {
restSyncMockMvc.perform(get("/api/sync/writesLeaves?year=" + YEAR + "&month=" + MONTH));
}
} }