Fissato problema nei contratti per previousContract

This commit is contained in:
Giancarlo Panichi 2022-12-01 18:36:28 +01:00
parent 3c01bf39b8
commit 953dc7a23b
5 changed files with 164 additions and 156 deletions

View File

@ -21,6 +21,5 @@ public class EPASContractsDTO implements Serializable {
private String id; private String id;
private boolean onCertificate; private boolean onCertificate;
private String personId; private String personId;
private String previousContract;
} }

View File

@ -38,7 +38,6 @@ public class EPASContractsMapper {
if (epasContracts.getPerson() != null) { if (epasContracts.getPerson() != null) {
epasContractsDTO.setPersonId(epasContracts.getPerson().getId()); epasContractsDTO.setPersonId(epasContracts.getPerson().getId());
} }
epasContractsDTO.setPreviousContract(epasContracts.getPreviousContract());
return epasContractsDTO; return epasContractsDTO;
} }
} }

View File

@ -20,7 +20,6 @@ public class EPASContracts implements Serializable {
private String id; private String id;
private boolean onCertificate; private boolean onCertificate;
private EPASPersons person; private EPASPersons person;
private String previousContract;
private EPASWorkingTimeForPerson[] workingTimeTypes; private EPASWorkingTimeForPerson[] workingTimeTypes;
private String updatedAt; private String updatedAt;

View File

@ -224,7 +224,6 @@ public class SyncService {
siMasterLogService.closeFluxWrites(fluxId, writeTabs()); siMasterLogService.closeFluxWrites(fluxId, writeTabs());
} }
public void executeWritesOrario() throws Exception { public void executeWritesOrario() throws Exception {
setBWriteTables(); setBWriteTables();
List<TabsSI> tabsSI = tabsSIService.getAllTabsSI(); List<TabsSI> tabsSI = tabsSIService.getAllTabsSI();
@ -635,111 +634,28 @@ public class SyncService {
} }
if (epasAffiliations != null) { if (epasAffiliations != null) {
EPASAffiliations affPresent = null; gestisciDipendenteGiaAffiliato(sigp, epasAffiliations);
for (EPASAffiliations aff : epasAffiliations) {
if (Integer.valueOf(aff.getExternalId()).compareTo(sigp.getId()) == 0) {
affPresent = aff;
break;
}
}
if (affPresent != null) {
List<EPASGroups> epasGroups = epasGroupsService.getList(ISTI_OFFICE_ID);
EPASGroups groupPresent = null;
if (epasGroups != null) {
for (EPASGroups g : epasGroups) {
if (Integer.valueOf(g.getExternalId()).compareTo(sigp.getId()) == 0) {
groupPresent = g;
break;
}
}
if (groupPresent != null) {
EPASPersons epasPerson = null;
try {
epasPerson = epasPersonsService.getByFiscalCode(sigp.getCf());
} catch (Exception e) {
logger.error("Error retrieving person by fiscal code: {}", sigp.getCf());
logger.error(e.getLocalizedMessage(), e);
}
if (epasPerson != null) {
EPASAffiliationsDTO epasAffiliationsDTO = new EPASAffiliationsDTO(
sdfDate.format(sigp.getDal()), sdfDate.format(sigp.getAl()),
groupPresent.getId(), null, String.valueOf(sigp.getPercentuale()),
epasPerson.getId(), String.valueOf(sigp.getId()));
epasAffiliationsService.updateById(affPresent.getId(), epasAffiliationsDTO);
logger.info("EPAS Updated Affilation: {}", epasAffiliationsDTO);
}
}
}
} else { } else {
List<EPASGroups> epasGroups = epasGroupsService.getList(ISTI_OFFICE_ID); gestisciDipendenteNonAffiliato(sigp);
EPASGroups groupPresent = null;
if (epasGroups != null) {
for (EPASGroups g : epasGroups) {
if (Integer.valueOf(g.getExternalId()).compareTo(sigp.getId()) == 0) {
groupPresent = g;
break;
}
}
if (groupPresent != null) {
EPASPersons epasPerson = null;
try {
epasPerson = epasPersonsService.getByFiscalCode(sigp.getCf());
} catch (Exception e) {
logger.error("Error retrieving person by fiscal code: {}", sigp.getCf());
logger.error(e.getLocalizedMessage(), e);
}
if (epasPerson != null) {
EPASAffiliationsDTO epasAffiliationsDTO = new EPASAffiliationsDTO(
sdfDate.format(sigp.getDal()), sdfDate.format(sigp.getAl()),
groupPresent.getId(), null, String.valueOf(sigp.getPercentuale()),
epasPerson.getId(), String.valueOf(sigp.getId()));
EPASAffiliations epasAffiliationNew = epasAffiliationsService
.create(epasAffiliationsDTO);
logger.info("EPAS Created Affilation: {}", epasAffiliationNew);
}
}
}
}
} else {
List<EPASGroups> epasGroups = epasGroupsService.getList(ISTI_OFFICE_ID);
EPASGroups groupPresent = null;
if (epasGroups != null) {
for (EPASGroups g : epasGroups) {
if (Integer.valueOf(g.getExternalId()).compareTo(sigp.getId()) == 0) {
groupPresent = g;
break;
}
}
if (groupPresent != null) {
EPASPersons epasPerson = null;
try {
epasPerson = epasPersonsService.getByFiscalCode(sigp.getCf());
} catch (Exception e) {
logger.error("Error retrieving person by fiscal code: {}", sigp.getCf());
logger.error(e.getLocalizedMessage(), e);
}
if (epasPerson != null) {
EPASAffiliationsDTO epasAffiliationsDTO = new EPASAffiliationsDTO(
sdfDate.format(sigp.getDal()), sdfDate.format(sigp.getAl()),
groupPresent.getId(), null, String.valueOf(sigp.getPercentuale()),
epasPerson.getId(), String.valueOf(sigp.getId()));
EPASAffiliations epasAffiliationNew = epasAffiliationsService
.create(epasAffiliationsDTO);
logger.info("EPAS Created Affilation: {}", epasAffiliationNew);
}
}
}
} }
} else { } else {
rimuoviAffiliazione(sigp);
}
}
}
}
if (maxIdFlusso > 0) {
bgruppo_pers = true;
tab.setIdFlusso(maxIdFlusso);
tab.setLastUpdate(LocalDateTime.now());
tabsSIService.updateTabsSI(tab);
}
}
private void rimuoviAffiliazione(SIGruppiPers sigp) {
logger.debug("Rimuovi Affiliazione");
List<EPASAffiliations> epasAffiliations = null; List<EPASAffiliations> epasAffiliations = null;
try { try {
epasAffiliations = epasAffiliationsService.getByPersonFiscalcode(sigp.getCf()); epasAffiliations = epasAffiliationsService.getByPersonFiscalcode(sigp.getCf());
@ -751,11 +667,20 @@ public class SyncService {
if (epasAffiliations != null) { if (epasAffiliations != null) {
EPASAffiliations affPresent = null; EPASAffiliations affPresent = null;
for (EPASAffiliations aff : epasAffiliations) { for (EPASAffiliations aff : epasAffiliations) {
if (Integer.valueOf(aff.getExternalId()).compareTo(sigp.getId()) == 0) { if (aff.getExternalId() != null && !aff.getExternalId().isEmpty()) {
Integer affId = 0;
try {
affId = Integer.valueOf(aff.getExternalId());
} catch (NumberFormatException e) {
logger.error("Invalid aff external id: {} ", aff.getExternalId());
}
if (affId.compareTo(sigp.getId()) == 0) {
affPresent = aff; affPresent = aff;
break; break;
} }
} }
}
if (affPresent != null) { if (affPresent != null) {
EPASAffiliationsMapper epasAffiliationsMapper = new EPASAffiliationsMapper(); EPASAffiliationsMapper epasAffiliationsMapper = new EPASAffiliationsMapper();
EPASAffiliationsDTO epasAffiliationsDTO = epasAffiliationsMapper EPASAffiliationsDTO epasAffiliationsDTO = epasAffiliationsMapper
@ -766,15 +691,107 @@ public class SyncService {
} }
} }
} }
private void gestisciDipendenteNonAffiliato(SIGruppiPers sigp) {
logger.debug("Aggiungi dipendente non affiliato");
List<EPASGroups> epasGroups = epasGroupsService.getList(ISTI_OFFICE_ID);
EPASGroups groupPresent = null;
if (epasGroups != null) {
for (EPASGroups g : epasGroups) {
if (g.getExternalId() != null && !g.getExternalId().isEmpty()) {
Integer gId = 0;
try {
gId = Integer.valueOf(g.getExternalId());
} catch (NumberFormatException e) {
logger.error("Invalid external id: {} ", g.getExternalId());
}
if (gId.compareTo(sigp.getId()) == 0) {
groupPresent = g;
break;
}
}
}
if (groupPresent != null) {
EPASPersons epasPerson = null;
try {
epasPerson = epasPersonsService.getByFiscalCode(sigp.getCf());
} catch (Exception e) {
logger.error("Error retrieving person by fiscal code: {}", sigp.getCf());
logger.error(e.getLocalizedMessage(), e);
}
if (epasPerson != null) {
EPASAffiliationsDTO epasAffiliationsDTO = new EPASAffiliationsDTO(sdfDate.format(sigp.getDal()),
sdfDate.format(sigp.getAl()), groupPresent.getId(), null,
String.valueOf(sigp.getPercentuale()), epasPerson.getId(), String.valueOf(sigp.getId()));
EPASAffiliations epasAffiliationNew = epasAffiliationsService.create(epasAffiliationsDTO);
logger.info("EPAS Created Affilation: {}", epasAffiliationNew);
}
} }
} }
} }
if (maxIdFlusso > 0) { private void gestisciDipendenteGiaAffiliato(SIGruppiPers sigp, List<EPASAffiliations> epasAffiliations) {
bgruppo_pers = true; logger.debug("Aggiungi dipendente già affiliato");
tab.setIdFlusso(maxIdFlusso); EPASAffiliations affPresent = null;
tab.setLastUpdate(LocalDateTime.now()); for (EPASAffiliations aff : epasAffiliations) {
tabsSIService.updateTabsSI(tab); if (aff.getExternalId() != null && !aff.getExternalId().isEmpty()) {
Integer affId = 0;
try {
affId = Integer.valueOf(aff.getExternalId());
} catch (NumberFormatException e) {
logger.error("Invalid aff external id: {} ", aff.getExternalId());
}
if (affId.compareTo(sigp.getId()) == 0) {
affPresent = aff;
break;
}
}
}
if (affPresent != null) {
List<EPASGroups> epasGroups = epasGroupsService.getList(ISTI_OFFICE_ID);
EPASGroups groupPresent = null;
if (epasGroups != null) {
for (EPASGroups g : epasGroups) {
if (g.getExternalId() != null && !g.getExternalId().isEmpty()) {
Integer gId = 0;
try {
gId = Integer.valueOf(g.getExternalId());
} catch (NumberFormatException e) {
logger.error("Invalid external id: {} ", g.getExternalId());
}
if (gId.compareTo(sigp.getId()) == 0) {
groupPresent = g;
break;
}
}
}
if (groupPresent != null) {
EPASPersons epasPerson = null;
try {
epasPerson = epasPersonsService.getByFiscalCode(sigp.getCf());
} catch (Exception e) {
logger.error("Error retrieving person by fiscal code: {}", sigp.getCf());
logger.error(e.getLocalizedMessage(), e);
}
if (epasPerson != null) {
EPASAffiliationsDTO epasAffiliationsDTO = new EPASAffiliationsDTO(sdfDate.format(sigp.getDal()),
sdfDate.format(sigp.getAl()), groupPresent.getId(), null,
String.valueOf(sigp.getPercentuale()), epasPerson.getId(),
String.valueOf(sigp.getId()));
epasAffiliationsService.updateById(affPresent.getId(), epasAffiliationsDTO);
logger.info("EPAS Updated Affilation: {}", epasAffiliationsDTO);
}
}
}
} else {
gestisciDipendenteNonAffiliato(sigp);
} }
} }
@ -910,7 +927,6 @@ public class SyncService {
} }
} }
private void writeOrarioData(Long fluxId, List<TabsSI> tabsSI) { private void writeOrarioData(Long fluxId, List<TabsSI> tabsSI) {
for (TabsSI tab : tabsSI) { for (TabsSI tab : tabsSI) {
logger.info("TabSI: {}", tab); logger.info("TabSI: {}", tab);
@ -1540,7 +1556,6 @@ public class SyncService {
LocalDateTime dMod = now.truncatedTo(ChronoUnit.SECONDS); LocalDateTime dMod = now.truncatedTo(ChronoUnit.SECONDS);
Timestamp dataMod = Timestamp.valueOf(dMod); Timestamp dataMod = Timestamp.valueOf(dMod);
SIPersOrario siPersOrario = new SIPersOrario(id, idPersona, pwtDTO.getCf(), startDate, endDate, SIPersOrario siPersOrario = new SIPersOrario(id, idPersona, pwtDTO.getCf(), startDate, endDate,
pwtDTO.getDescrizione(), pwtDTO.getLun(), pwtDTO.getMar(), pwtDTO.getMer(), pwtDTO.getGio(), pwtDTO.getDescrizione(), pwtDTO.getLun(), pwtDTO.getMar(), pwtDTO.getMer(), pwtDTO.getGio(),
pwtDTO.getVen(), pwtDTO.getSab(), pwtDTO.getPercentuale(), pwtDTO.getTurno(), pwtDTO.getOre_turno(), pwtDTO.getVen(), pwtDTO.getSab(), pwtDTO.getPercentuale(), pwtDTO.getTurno(), pwtDTO.getOre_turno(),
@ -1552,7 +1567,6 @@ public class SyncService {
siPersOrarioService.writeNewFlux(fluxId, siPersOrario); siPersOrarioService.writeNewFlux(fluxId, siPersOrario);
} }
} }
logger.info("Personale Orario scritto su SI: {}", count); logger.info("Personale Orario scritto su SI: {}", count);
@ -1591,8 +1605,6 @@ public class SyncService {
} }
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

@ -72,7 +72,7 @@ public class EPASContractsResourceIT {
private static final String CONTRACT_DEFAUL_ENDDATE = null; private static final String CONTRACT_DEFAUL_ENDDATE = null;
private static final String CONTRACT_DEFAULT_ENDCONTRACT = null; private static final String CONTRACT_DEFAULT_ENDCONTRACT = null;
private static final boolean CONTRACT_DEFAULT_ONCERTIFICATE = true; private static final boolean CONTRACT_DEFAULT_ONCERTIFICATE = true;
private static final String CONTRACT_DEFAULT_PREVIOUSCONTRACT = null; //private static final String CONTRACT_DEFAULT_PREVIOUSCONTRACT = null;
private static final String CONTRACT_DEFAULT_EXTERNALID = "2496"; private static final String CONTRACT_DEFAULT_EXTERNALID = "2496";
private static final String CONTRACT_UPDATE_ENDATE = "2021-12-31"; private static final String CONTRACT_UPDATE_ENDATE = "2021-12-31";
@ -102,7 +102,6 @@ public class EPASContractsResourceIT {
epasContracts.setEndContract(CONTRACT_DEFAULT_ENDCONTRACT); epasContracts.setEndContract(CONTRACT_DEFAULT_ENDCONTRACT);
epasContracts.setOnCertificate(CONTRACT_DEFAULT_ONCERTIFICATE); epasContracts.setOnCertificate(CONTRACT_DEFAULT_ONCERTIFICATE);
epasContracts.setPerson(createEPASPerson()); epasContracts.setPerson(createEPASPerson());
epasContracts.setPreviousContract(CONTRACT_DEFAULT_PREVIOUSCONTRACT);
epasContracts.setExternalId(CONTRACT_DEFAULT_EXTERNALID); epasContracts.setExternalId(CONTRACT_DEFAULT_EXTERNALID);
return epasContracts; return epasContracts;
} }