Updated Sync Service
This commit is contained in:
parent
c128f13eb7
commit
45f4a2c28d
src
main/java/it/cnr/isti/epasmed
epas
sync
web/rest/epas
test/java/it/cnr/isti/epasmed/web/rest/epas
|
@ -43,6 +43,35 @@ public class EPASTimeCardsClient {
|
|||
return epasTimeCard;
|
||||
}
|
||||
|
||||
public EPASTimeCards getByPersonFiscalCode(String fc, String year, String month) {
|
||||
log.info("Retrieving EPASTimeCard by person fiscalcode: {}", fc);
|
||||
Map<String, String> uriVariables = new HashMap<>();
|
||||
uriVariables.put("fc", fc);
|
||||
uriVariables.put("year", year);
|
||||
uriVariables.put("month", month);
|
||||
|
||||
EPASTimeCards epasTimeCard = rt.getForObject(
|
||||
appProps.getDatasourceEpasRest().getRestUrl() + "/v3/persondays/getMonthSituationByPerson?fiscalCode={fc}&year={year}&month={month}",
|
||||
EPASTimeCards.class,uriVariables);
|
||||
log.info("Retrieved EPASTimeCard: {}", epasTimeCard);
|
||||
return epasTimeCard;
|
||||
}
|
||||
|
||||
|
||||
public EPASTimeCards getByPersonEmail(String email, String year, String month) {
|
||||
log.info("Retrieving EPASTimeCard by person email: {}", email);
|
||||
Map<String, String> uriVariables = new HashMap<>();
|
||||
uriVariables.put("email", email);
|
||||
uriVariables.put("year", year);
|
||||
uriVariables.put("month", month);
|
||||
|
||||
EPASTimeCards epasTimeCard = rt.getForObject(
|
||||
appProps.getDatasourceEpasRest().getRestUrl() + "/v3/persondays/getMonthSituationByPerson?email={email}&year={year}&month={month}",
|
||||
EPASTimeCards.class,uriVariables);
|
||||
log.info("Retrieved EPASTimeCard: {}", epasTimeCard);
|
||||
return epasTimeCard;
|
||||
}
|
||||
|
||||
|
||||
public List<EPASTimeCards> getByOfficeCodeId(String id, String year, String month) {
|
||||
Map<String, String> uriVariables = new HashMap<>();
|
||||
|
@ -61,4 +90,7 @@ public class EPASTimeCardsClient {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class EPASValidatesClient {
|
|||
ApplicationProperties appProps;
|
||||
|
||||
public String isByPersonEmail(String email, String year, String month) {
|
||||
log.info("Retrieving EPASValidates status for person email: {}", email);
|
||||
log.info("Retrieving EPASValidates status by person email: {}", email);
|
||||
Map<String, String> uriVariables = new HashMap<>();
|
||||
uriVariables.put("email", email);
|
||||
uriVariables.put("year", year);
|
||||
|
|
|
@ -18,6 +18,14 @@ public class EPASTimeCardsService {
|
|||
return epasTimeCardsClient.getByPersonId(id, year, month);
|
||||
}
|
||||
|
||||
public EPASTimeCards getTimeCardByPersonFiscalCode(String fc, String year, String month) {
|
||||
return epasTimeCardsClient.getByPersonFiscalCode(fc, year, month);
|
||||
}
|
||||
|
||||
public EPASTimeCards getTimeCardByPersonEmail(String email, String year, String month) {
|
||||
return epasTimeCardsClient.getByPersonEmail(email, year, month);
|
||||
}
|
||||
|
||||
public List<EPASTimeCards> getTimeCardByOfficeCodeId(String id, String year, String month) {
|
||||
return epasTimeCardsClient.getByOfficeCodeId(id, year, month);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package it.cnr.isti.epasmed.sync;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
@ -12,8 +13,11 @@ import it.cnr.isti.epasmed.domain.TabsSI;
|
|||
import it.cnr.isti.epasmed.epas.dto.EPASPersonsDTO;
|
||||
import it.cnr.isti.epasmed.epas.mapper.EPASPersonsMapper;
|
||||
import it.cnr.isti.epasmed.epas.model.EPASPersons;
|
||||
import it.cnr.isti.epasmed.epas.model.EPASTimeCards;
|
||||
import it.cnr.isti.epasmed.epas.model.EPASValidates;
|
||||
import it.cnr.isti.epasmed.epas.service.EPASPersonsService;
|
||||
import it.cnr.isti.epasmed.epas.service.EPASTimeCardsService;
|
||||
import it.cnr.isti.epasmed.epas.service.EPASValidatesService;
|
||||
import it.cnr.isti.epasmed.service.TabsSIService;
|
||||
import it.cnr.isti.epasmed.sistemainformativo.model.SIAnagrafico;
|
||||
import it.cnr.isti.epasmed.sistemainformativo.model.SIEmail;
|
||||
|
@ -26,6 +30,8 @@ import it.cnr.isti.epasmed.sistemainformativo.service.SITelefoniService;
|
|||
@Service
|
||||
public class SyncService {
|
||||
private static final String ISTI_OFFICE_ID = "1";
|
||||
private static final String ISTI_OFFICE_CODEID = "225200";
|
||||
|
||||
private static final String SI_FLAG_DEL_TRUE = "1";
|
||||
private static final String SI_RECAPITO_TELEFONICO_UFFICIO = "Ufficio";
|
||||
@SuppressWarnings("unused")
|
||||
|
@ -51,9 +57,10 @@ public class SyncService {
|
|||
@Autowired
|
||||
EPASPersonsMapper epasPersonsMapper;
|
||||
@Autowired
|
||||
|
||||
EPASTimeCardsService epasTimeCardsService;
|
||||
|
||||
|
||||
@Autowired
|
||||
EPASValidatesService epasValidatesService;
|
||||
|
||||
private boolean banagrafico;
|
||||
private boolean bemail;
|
||||
|
@ -421,7 +428,7 @@ public class SyncService {
|
|||
TabsSI cartelliniTab = null;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
for (TabsSI tab : tabsSI) {
|
||||
log.info("TabSI: {}", tab);
|
||||
if (tab.getOperazioni() != null && !tab.getOperazioni().isEmpty()
|
||||
|
@ -431,31 +438,62 @@ public class SyncService {
|
|||
}
|
||||
|
||||
switch (tab.getNome()) {
|
||||
case "orario":
|
||||
syncOrario(idFlux,tab);
|
||||
break;
|
||||
case "pers_orario":
|
||||
syncPersOrario(idFlux,tab);
|
||||
break;
|
||||
//case "orario":
|
||||
// syncOrario(idFlux,tab);
|
||||
// break;
|
||||
//case "pers_orario":
|
||||
// syncPersOrario(idFlux,tab);
|
||||
// break;
|
||||
case "cartellini":
|
||||
break;
|
||||
case "cartellini_rendicontazioni":
|
||||
syncCartelliniRendicontazioni(idFlux,tab);
|
||||
break;
|
||||
|
||||
case "lavoro_fuori_sede":
|
||||
syncLavoroFuoriSede(idFlux,tab);
|
||||
break;
|
||||
case "aspettative":
|
||||
syncAspettative(idFlux,tab);
|
||||
break;
|
||||
//case "lavoro_fuori_sede":
|
||||
// syncLavoroFuoriSede(idFlux,tab);
|
||||
// break;
|
||||
//case "aspettative":
|
||||
// syncAspettative(idFlux,tab);
|
||||
// break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
private void syncCartelliniRendicontazioni(Long idFlux, TabsSI tab) {
|
||||
if (tab.getIdFlusso() == null || tab.getIdFlusso().longValue() == 0) {
|
||||
log.info("Invalid Id Flusso for tab: {}", tab);
|
||||
return;
|
||||
}
|
||||
long maxIdFlusso = 0;
|
||||
|
||||
GregorianCalendar lastMonthSent=new GregorianCalendar(2021,11,1);
|
||||
GregorianCalendar nextMonthToSent=new GregorianCalendar();
|
||||
nextMonthToSent.setTime(lastMonthSent.getTime());
|
||||
nextMonthToSent.add(GregorianCalendar.MONTH, 1);
|
||||
String y=String.valueOf(nextMonthToSent.get(GregorianCalendar.YEAR));
|
||||
String m=String.valueOf(nextMonthToSent.get(GregorianCalendar.YEAR));
|
||||
EPASValidates epasValidates=epasValidatesService.getValidatesByOfficeCodeId(ISTI_OFFICE_CODEID, y,
|
||||
m);
|
||||
|
||||
if(!epasValidates.getAllCertificationsValidated()) {
|
||||
log.info("No new month closed on EPAS: [year={}, month={}]", y,m);
|
||||
return;
|
||||
}
|
||||
|
||||
//TODO
|
||||
log.info("Certifications Validated: [year={}, month={}]",y,m);
|
||||
for(EPASPersons person:epasValidates.getValidatedPersons()) {
|
||||
log.info("Writing TimeCard for Person: {}",person);
|
||||
EPASTimeCards epasTimeCards=epasTimeCardsService.getTimeCardByPersonEmail(person.getEmail(), y, m);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import io.github.jhipster.web.util.HeaderUtil;
|
||||
import io.github.jhipster.web.util.ResponseUtil;
|
||||
import it.cnr.isti.epasmed.epas.model.EPASCertifications;
|
||||
import it.cnr.isti.epasmed.epas.model.EPASTimeCards;
|
||||
import it.cnr.isti.epasmed.epas.service.EPASTimeCardsService;
|
||||
|
||||
|
@ -33,27 +35,51 @@ public class EPASTimeCardsResource {
|
|||
}
|
||||
|
||||
/**
|
||||
* {@code GET /timecards/show} : get time card by personId, year and month.
|
||||
* {@code GET /timecards/byPerson} : get time card by person, year and month
|
||||
*
|
||||
* @param personId the id of the persons.
|
||||
* @param year the year
|
||||
* @param month the month
|
||||
* @param id the id of the person.
|
||||
* @param fiscalCode the fiscal code of the person.
|
||||
* @param email the email of the person.
|
||||
* @param year the year.
|
||||
* @param month the month.
|
||||
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body
|
||||
* the EPAS Time Card, or with status {@code 404 (Not Found)}.
|
||||
* the EPAS TimeCards, or with status {@code 404 (Not Found)}.
|
||||
*/
|
||||
@GetMapping("/timecards/show")
|
||||
public ResponseEntity<EPASTimeCards> getEPASTimeCardByPersonId(@RequestParam("personId") String id,
|
||||
@RequestParam("year") String year, @RequestParam("month") String month) {
|
||||
log.info("REST request to get ePAS TimeCard by Person Id: personId={}, year={}, month={}", id,year,month);
|
||||
EPASTimeCards epasTimeCard = epasTimeCardsService.getTimeCardByPersonId(id, year, month);
|
||||
log.info("Retrieved TimeCard: {}", epasTimeCard);
|
||||
return ResponseUtil.wrapOrNotFound(Optional.of(epasTimeCard));
|
||||
@GetMapping("/timecards/byPerson")
|
||||
public ResponseEntity<EPASTimeCards> getEPASCertificationByPerson(@RequestParam("id") Optional<String> id,
|
||||
@RequestParam("fiscalCode") Optional<String> fiscalCode,
|
||||
@RequestParam("email") Optional<String> email,
|
||||
@RequestParam("year") String year,@RequestParam("month") String month) {
|
||||
|
||||
|
||||
EPASTimeCards epasTimeCards = null;
|
||||
if (id.isPresent()) {
|
||||
log.info("REST request to get ePAS TimeCards by Person id: {}", id.get());
|
||||
epasTimeCards = epasTimeCardsService.getTimeCardByPersonId(id.get(), year, month);
|
||||
} else {
|
||||
if (fiscalCode.isPresent()) {
|
||||
log.info("REST request to get ePAS TimeCards by Person fiscalcode: {}", fiscalCode.get());
|
||||
epasTimeCards = epasTimeCardsService.getTimeCardByPersonFiscalCode(fiscalCode.get(), year, month);
|
||||
} else {
|
||||
if (email.isPresent()) {
|
||||
log.info("REST request to get ePAS TimeCards by Person email: {}", email.get());
|
||||
epasTimeCards = epasTimeCardsService.getTimeCardByPersonEmail(email.get(), year, month);
|
||||
} else {
|
||||
return ResponseUtil.wrapOrNotFound(Optional.of(epasTimeCards), HeaderUtil.createFailureAlert(applicationName,false,
|
||||
"","","Invalid parameter in call"));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
log.info("Retrieved Certification: {}", epasTimeCards);
|
||||
return ResponseUtil.wrapOrNotFound(Optional.of(epasTimeCards));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* {@code GET /timecards} : get the time cards list.
|
||||
* {@code GET /timecards/byOffice} : get the time cards list.
|
||||
*
|
||||
* @param officeCodeId the id of the office.
|
||||
* @param year the year
|
||||
|
@ -61,8 +87,8 @@ public class EPASTimeCardsResource {
|
|||
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body
|
||||
* the EPAS Time Card, or with status {@code 404 (Not Found)}.
|
||||
*/
|
||||
@GetMapping("/timecards")
|
||||
public ResponseEntity<List<EPASTimeCards>> getEPASTimeCardByOfficeCodeId(@RequestParam("officeCodeId") String id,
|
||||
@GetMapping("/timecards/byOffice")
|
||||
public ResponseEntity<List<EPASTimeCards>> getEPASTimeCardByOffice(@RequestParam("codeId") String id,
|
||||
@RequestParam("year") String year, @RequestParam("month") String month) {
|
||||
log.info("REST request to get ePAS TimeCard list: officeCodeId={}, year={}, month={}", id,year,month);
|
||||
List<EPASTimeCards> epasTimeCardsList = epasTimeCardsService.getTimeCardByOfficeCodeId(id, year, month);
|
||||
|
|
|
@ -24,7 +24,7 @@ import it.cnr.isti.epasmed.security.AuthoritiesConstants;
|
|||
@AutoConfigureMockMvc
|
||||
@WithMockUser(authorities = AuthoritiesConstants.ADMIN)
|
||||
@SpringBootTest(classes = EpasmedApp.class)
|
||||
@EnabledIf("false")
|
||||
@EnabledIf("true")
|
||||
public class EPASCertificationsResourceIT {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
@ -59,7 +59,7 @@ public class EPASCertificationsResourceIT {
|
|||
|
||||
@Test
|
||||
public void getEPASCertificationsByPersonId() throws Exception {
|
||||
restEPASCertificationsMockMvc.perform(get("/api/epas/certifications/getMonthSituation?id=" + PERSON_DEFAULT_ID + "&year=2021&month=10"))
|
||||
restEPASCertificationsMockMvc.perform(get("/api/epas/certifications/getMonthSituation?id=" + PERSON_DEFAULT_ID + "&year=2021&month=11"))
|
||||
.andExpect(status().isOk());
|
||||
}
|
||||
|
||||
|
@ -67,14 +67,14 @@ public class EPASCertificationsResourceIT {
|
|||
public void getEPASCertificationsByPersonFiscalcode() throws Exception {
|
||||
restEPASCertificationsMockMvc
|
||||
.perform(
|
||||
get("/api/epas/certifications/getMonthSituation?fiscalCode=" + PERSON_DEFAULT_FISCAL_CODE + "&year=2021&month=10"))
|
||||
get("/api/epas/certifications/getMonthSituation?fiscalCode=" + PERSON_DEFAULT_FISCAL_CODE + "&year=2021&month=11"))
|
||||
.andExpect(status().isOk());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getEPASCertificationsByPersonEmail() throws Exception {
|
||||
restEPASCertificationsMockMvc
|
||||
.perform(get("/api/epas/certifications/getMonthSituation?email=" + PERSON_DEFAULT_EMAIL + "&year=2021&month=10"))
|
||||
.perform(get("/api/epas/certifications/getMonthSituation?email=" + PERSON_DEFAULT_EMAIL + "&year=2021&month=11"))
|
||||
.andExpect(status().isOk());
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import it.cnr.isti.epasmed.security.AuthoritiesConstants;
|
|||
@AutoConfigureMockMvc
|
||||
@WithMockUser(authorities = AuthoritiesConstants.ADMIN)
|
||||
@SpringBootTest(classes = EpasmedApp.class)
|
||||
@EnabledIf("false")
|
||||
@EnabledIf("true")
|
||||
public class EPASLeavesResourceIT {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
|
|
@ -46,7 +46,7 @@ import it.cnr.isti.epasmed.web.rest.TestUtil;
|
|||
@AutoConfigureMockMvc
|
||||
@WithMockUser(authorities = AuthoritiesConstants.ADMIN)
|
||||
@SpringBootTest(classes = EpasmedApp.class)
|
||||
@EnabledIf("false")
|
||||
@EnabledIf("true")
|
||||
public class EPASPersonsResourceIT {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
|
|
@ -24,7 +24,7 @@ import it.cnr.isti.epasmed.security.AuthoritiesConstants;
|
|||
@AutoConfigureMockMvc
|
||||
@WithMockUser(authorities = AuthoritiesConstants.ADMIN)
|
||||
@SpringBootTest(classes = EpasmedApp.class)
|
||||
@EnabledIf("false")
|
||||
@EnabledIf("true")
|
||||
public class EPASTimeCardsResourceIT {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
@ -34,6 +34,12 @@ public class EPASTimeCardsResourceIT {
|
|||
//private static final String OFFICE_DEFAULT_CODE = "074000";
|
||||
private static final String OFFICE_DEFAULT_CODEID = "225200";
|
||||
|
||||
private static final String PERSON_DEFAULT_ID = "113";
|
||||
//private static final String PERSON_DEFAULT_NAME = "Giuseppe";
|
||||
//private static final String PERSON_DEFAULT_SURNAME = "Amato";
|
||||
private static final String PERSON_DEFAULT_FISCAL_CODE = "MTAGPP68D15D976W";
|
||||
private static final String PERSON_DEFAULT_EMAIL = "giuseppe.amato@cnr.it";
|
||||
//private static final String PERSON_DEFAULT_QUALIFICATION = "2";
|
||||
|
||||
@Autowired
|
||||
private MockMvc restEPASTimeCardsMockMvc;
|
||||
|
@ -51,12 +57,22 @@ public class EPASTimeCardsResourceIT {
|
|||
|
||||
@Test
|
||||
public void getTimeCardByPersonId() throws Exception {
|
||||
restEPASTimeCardsMockMvc.perform(get("/api/epas/timecards/show?personId=113&year=2021&month=11")).andExpect(status().isOk());
|
||||
restEPASTimeCardsMockMvc.perform(get("/api/epas/timecards/byPerson?id="+PERSON_DEFAULT_ID+"&year=2021&month=11")).andExpect(status().isOk());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTimeCardByPersonFiscalCode() throws Exception {
|
||||
restEPASTimeCardsMockMvc.perform(get("/api/epas/timecards/byPerson?fiscalCode="+PERSON_DEFAULT_FISCAL_CODE+"&year=2021&month=11")).andExpect(status().isOk());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTimeCardByPersonEmail() throws Exception {
|
||||
restEPASTimeCardsMockMvc.perform(get("/api/epas/timecards/byPerson?email="+PERSON_DEFAULT_EMAIL+"&year=2021&month=11")).andExpect(status().isOk());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTimeCardByOfficeCodeId() throws Exception {
|
||||
restEPASTimeCardsMockMvc.perform(get("/api/epas/timecards?officeCodeId="+OFFICE_DEFAULT_CODEID+"&year=2021&month=11")).andExpect(status().isOk());
|
||||
restEPASTimeCardsMockMvc.perform(get("/api/epas/timecards/byOffice?codeId="+OFFICE_DEFAULT_CODEID+"&year=2021&month=11")).andExpect(status().isOk());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import it.cnr.isti.epasmed.security.AuthoritiesConstants;
|
|||
@AutoConfigureMockMvc
|
||||
@WithMockUser(authorities = AuthoritiesConstants.ADMIN)
|
||||
@SpringBootTest(classes = EpasmedApp.class)
|
||||
@EnabledIf("false")
|
||||
@EnabledIf("true")
|
||||
public class EPASValidatesResourceIT {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
@ -67,7 +67,7 @@ public class EPASValidatesResourceIT {
|
|||
@Test
|
||||
public void getEPASValidatesByOfficeCodeId() throws Exception {
|
||||
MvcResult result = restEPASValidatesMockMvc.perform(get("/api/epas/validates?officeCodeId="+OFFICE_DEFAULT_CODEID+"&"
|
||||
+ "year=2021&month=10")).andExpect(status().isOk()).andReturn();
|
||||
+ "year=2021&month=11")).andExpect(status().isOk()).andReturn();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
EPASValidates validates = mapper.readValue(result.getResponse().getContentAsString(),
|
||||
new TypeReference<EPASValidates>() {
|
||||
|
|
Loading…
Reference in New Issue