Updated the synchronization support
This commit is contained in:
parent
82589c8dc0
commit
3ef43f206f
|
|
@ -1,6 +1,8 @@
|
|||
package it.cnr.isti.epasmed.sync;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -10,20 +12,32 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import it.cnr.isti.epasmed.domain.TabsSI;
|
||||
import it.cnr.isti.epasmed.epas.dto.EPASAffiliationsDTO;
|
||||
import it.cnr.isti.epasmed.epas.dto.EPASGroupsDTO;
|
||||
import it.cnr.isti.epasmed.epas.dto.EPASPersonsDTO;
|
||||
import it.cnr.isti.epasmed.epas.mapper.EPASAffiliationsMapper;
|
||||
import it.cnr.isti.epasmed.epas.mapper.EPASGroupsMapper;
|
||||
import it.cnr.isti.epasmed.epas.mapper.EPASPersonsMapper;
|
||||
import it.cnr.isti.epasmed.epas.model.EPASAffiliations;
|
||||
import it.cnr.isti.epasmed.epas.model.EPASGroups;
|
||||
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.EPASAffiliationsService;
|
||||
import it.cnr.isti.epasmed.epas.service.EPASGroupsService;
|
||||
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;
|
||||
import it.cnr.isti.epasmed.sistemainformativo.model.SIGruppi;
|
||||
import it.cnr.isti.epasmed.sistemainformativo.model.SIGruppiPers;
|
||||
import it.cnr.isti.epasmed.sistemainformativo.model.SITelefoni;
|
||||
import it.cnr.isti.epasmed.sistemainformativo.service.SIAnagraficoService;
|
||||
import it.cnr.isti.epasmed.sistemainformativo.service.SIEmailService;
|
||||
import it.cnr.isti.epasmed.sistemainformativo.service.SIGruppiPersService;
|
||||
import it.cnr.isti.epasmed.sistemainformativo.service.SIGruppiService;
|
||||
import it.cnr.isti.epasmed.sistemainformativo.service.SIMasterLogService;
|
||||
import it.cnr.isti.epasmed.sistemainformativo.service.SITelefoniService;
|
||||
|
||||
|
|
@ -39,7 +53,7 @@ public class SyncService {
|
|||
private static final String SI_TIPO_EMAIL_CNR = "C.N.R.";
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(SyncService.class);
|
||||
|
||||
private final SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");
|
||||
@Autowired
|
||||
TabsSIService tabsSIService;
|
||||
|
||||
|
|
@ -51,12 +65,19 @@ public class SyncService {
|
|||
SITelefoniService siTelefoniService;
|
||||
@Autowired
|
||||
SIEmailService siEmailService;
|
||||
@Autowired
|
||||
SIGruppiService siGruppiService;
|
||||
@Autowired
|
||||
SIGruppiPersService siGruppiPersService;
|
||||
|
||||
@Autowired
|
||||
EPASPersonsService epasPersonsService;
|
||||
@Autowired
|
||||
EPASPersonsMapper epasPersonsMapper;
|
||||
@Autowired
|
||||
EPASGroupsService epasGroupsService;
|
||||
@Autowired
|
||||
EPASAffiliationsService epasAffiliationsService;
|
||||
|
||||
EPASTimeCardsService epasTimeCardsService;
|
||||
@Autowired
|
||||
|
|
@ -301,18 +322,220 @@ public class SyncService {
|
|||
}
|
||||
|
||||
private void syncGruppi(TabsSI tab) {
|
||||
// TODO Auto-generated method stub
|
||||
if (tab.getIdFlusso() == null || tab.getIdFlusso().longValue() == 0) {
|
||||
log.info("Invalid Id Flusso for tab: {}", tab);
|
||||
return;
|
||||
}
|
||||
long maxIdFlusso = 0;
|
||||
|
||||
List<SIGruppi> sigList = siGruppiService.readNewFlux(tab.getIdFlusso());
|
||||
for (SIGruppi sig : sigList) {
|
||||
if (sig.getId_flusso() != null && sig.getId_flusso().longValue() > maxIdFlusso) {
|
||||
maxIdFlusso = sig.getId_flusso();
|
||||
}
|
||||
if (sig.getId() != null && sig.getId() != 0) {
|
||||
if (sig.getFlag_del() != null && !sig.getFlag_del().isEmpty()) {
|
||||
if (sig.getFlag_del().compareTo(SI_FLAG_DEL_TRUE) != 0) {
|
||||
List<EPASGroups> epasGroups = epasGroupsService.getList(ISTI_OFFICE_ID);
|
||||
if (epasGroups != null) {
|
||||
EPASGroups groupPresent = null;
|
||||
for (EPASGroups g : epasGroups) {
|
||||
if (Integer.valueOf(g.getExternalId()).compareTo(sig.getId()) == 0) {
|
||||
groupPresent = g;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (groupPresent == null) {
|
||||
EPASGroupsDTO epasGroupsDTO = new EPASGroupsDTO(sig.getDescrizione(), null,
|
||||
String.valueOf(sig.getId()), null, null, sig.getSigla(), ISTI_OFFICE_ID);
|
||||
EPASGroups epasGroup = epasGroupsService.create(epasGroupsDTO);
|
||||
log.info("EPAS Created Group: {}", epasGroup);
|
||||
} else {
|
||||
EPASGroupsMapper epasGroupsMapper = new EPASGroupsMapper();
|
||||
EPASGroupsDTO epasGroupsDTO = epasGroupsMapper.epasGroupsToEPASGroupsDTO(groupPresent);
|
||||
epasGroupsDTO.setDescription(sig.getDescrizione());
|
||||
epasGroupsDTO.setName(sig.getSigla());
|
||||
epasGroupsService.updateById(groupPresent.getId(), epasGroupsDTO);
|
||||
log.info("EPAS Updated Group: {}", epasGroupsDTO);
|
||||
}
|
||||
} else {
|
||||
EPASGroupsDTO epasGroupsDTO = new EPASGroupsDTO(sig.getDescrizione(), null,
|
||||
String.valueOf(sig.getId()), null, null, sig.getSigla(), ISTI_OFFICE_ID);
|
||||
EPASGroups epasGroup = epasGroupsService.create(epasGroupsDTO);
|
||||
log.info("EPAS Created Group: {}", epasGroup);
|
||||
}
|
||||
} else {
|
||||
List<EPASGroups> epasGroups = epasGroupsService.getList(ISTI_OFFICE_ID);
|
||||
if (epasGroups != null) {
|
||||
EPASGroups groupPresent = null;
|
||||
for (EPASGroups g : epasGroups) {
|
||||
if (Integer.valueOf(g.getExternalId()).compareTo(sig.getId()) == 0) {
|
||||
groupPresent = g;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (groupPresent != null) {
|
||||
Date endDate = new Date();
|
||||
if (sig.getData_mod() != null) {
|
||||
endDate.setTime(sig.getData_mod().getTime());
|
||||
groupPresent.setEndDate(sdfDate.format(endDate));
|
||||
EPASGroupsMapper epasGroupsMapper = new EPASGroupsMapper();
|
||||
EPASGroupsDTO epasGroupsDTO = epasGroupsMapper
|
||||
.epasGroupsToEPASGroupsDTO(groupPresent);
|
||||
epasGroupsService.updateById(groupPresent.getId(), epasGroupsDTO);
|
||||
log.info("EPAS Delete Group: {}", epasGroupsDTO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (maxIdFlusso > 0) {
|
||||
bgruppi = true;
|
||||
tab.setIdFlusso(maxIdFlusso);
|
||||
tab.setLastUpdate(LocalDateTime.now());
|
||||
tabsSIService.updateTabsSI(tab);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void syncGruppoPers(TabsSI tab) {
|
||||
// TODO Auto-generated method stub
|
||||
if (tab.getIdFlusso() == null || tab.getIdFlusso().longValue() == 0) {
|
||||
log.info("Invalid Id Flusso for tab: {}", tab);
|
||||
return;
|
||||
}
|
||||
long maxIdFlusso = 0;
|
||||
|
||||
List<SIGruppiPers> sigList = siGruppiPersService.readNewFlux(tab.getIdFlusso());
|
||||
for (SIGruppiPers sigp : sigList) {
|
||||
if (sigp.getId_flusso() != null && sigp.getId_flusso().longValue() > maxIdFlusso) {
|
||||
maxIdFlusso = sigp.getId_flusso();
|
||||
}
|
||||
if (sigp.getId() != null && sigp.getId() != 0) {
|
||||
if (sigp.getFlag_del() != null && !sigp.getFlag_del().isEmpty()) {
|
||||
if (sigp.getFlag_del().compareTo(SI_FLAG_DEL_TRUE) != 0) {
|
||||
List<EPASAffiliations> epasAffiliations = epasAffiliationsService
|
||||
.getByPersonFiscalcode(sigp.getCf());
|
||||
if (epasAffiliations != null) {
|
||||
EPASAffiliations affPresent = null;
|
||||
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 = epasPersonsService.getByFiscalCode(sigp.getCf());
|
||||
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);
|
||||
log.info("EPAS Updated Affilation: {}", epasAffiliationsDTO);
|
||||
|
||||
}
|
||||
|
||||
//private void syncPosizioniAndProroghe(TabsSI posizioniTab, TabsSI prorogheTab) {
|
||||
//
|
||||
//}
|
||||
}
|
||||
}
|
||||
} 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 = epasPersonsService.getByFiscalCode(sigp.getCf());
|
||||
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);
|
||||
log.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 = epasPersonsService.getByFiscalCode(sigp.getCf());
|
||||
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);
|
||||
log.info("EPAS Created Affilation: {}", epasAffiliationNew);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<EPASAffiliations> epasAffiliations = epasAffiliationsService
|
||||
.getByPersonFiscalcode(sigp.getCf());
|
||||
if (epasAffiliations != null) {
|
||||
EPASAffiliations affPresent = null;
|
||||
for (EPASAffiliations aff : epasAffiliations) {
|
||||
if (Integer.valueOf(aff.getExternalId()).compareTo(sigp.getId()) == 0) {
|
||||
affPresent = aff;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (affPresent != null) {
|
||||
EPASAffiliationsMapper epasAffiliationsMapper=new EPASAffiliationsMapper();
|
||||
EPASAffiliationsDTO epasAffiliationsDTO=epasAffiliationsMapper.epasAffiliationsToEPASAffiliationsDTO(affPresent);
|
||||
epasAffiliationsDTO.setEndDate(sdfDate.format(sigp.getAl()));
|
||||
epasAffiliationsService.updateById(affPresent.getId(), epasAffiliationsDTO);
|
||||
log.info("EPAS Delete Affilation: {}", epasAffiliationsDTO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (maxIdFlusso > 0) {
|
||||
bgruppo_pers = true;
|
||||
tab.setIdFlusso(maxIdFlusso);
|
||||
tab.setLastUpdate(LocalDateTime.now());
|
||||
tabsSIService.updateTabsSI(tab);
|
||||
}
|
||||
}
|
||||
|
||||
private String readTabs() {
|
||||
String readTabs = "";
|
||||
|
|
@ -354,21 +577,15 @@ public class SyncService {
|
|||
}
|
||||
}
|
||||
|
||||
/*if (bposizioni) {
|
||||
if (tabelle_lette == null || tabelle_lette.isEmpty()) {
|
||||
tabelle_lette = "posizioni";
|
||||
} else {
|
||||
tabelle_lette = tabelle_lette + ",posizioni";
|
||||
}
|
||||
}
|
||||
|
||||
if (bproroghe) {
|
||||
if (tabelle_lette == null || tabelle_lette.isEmpty()) {
|
||||
tabelle_lette = "proroghe";
|
||||
} else {
|
||||
tabelle_lette = tabelle_lette + ",proroghe";
|
||||
}
|
||||
}*/
|
||||
/*
|
||||
* if (bposizioni) { if (tabelle_lette == null || tabelle_lette.isEmpty()) {
|
||||
* tabelle_lette = "posizioni"; } else { tabelle_lette = tabelle_lette +
|
||||
* ",posizioni"; } }
|
||||
*
|
||||
* if (bproroghe) { if (tabelle_lette == null || tabelle_lette.isEmpty()) {
|
||||
* tabelle_lette = "proroghe"; } else { tabelle_lette = tabelle_lette +
|
||||
* ",proroghe"; } }
|
||||
*/
|
||||
|
||||
return readTabs;
|
||||
}
|
||||
|
|
@ -421,13 +638,9 @@ public class SyncService {
|
|||
return writeTabs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void writeData(Long idFlux, List<TabsSI> tabsSI) {
|
||||
TabsSI caretelliniRendicontazioniTab = null;
|
||||
TabsSI cartelliniTab = null;
|
||||
|
||||
|
||||
//TabsSI caretelliniRendicontazioniTab = null;
|
||||
//TabsSI cartelliniTab = null;
|
||||
|
||||
for (TabsSI tab : tabsSI) {
|
||||
log.info("TabSI: {}", tab);
|
||||
|
|
@ -476,8 +689,7 @@ public class SyncService {
|
|||
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);
|
||||
EPASValidates epasValidates = epasValidatesService.getValidatesByOfficeCodeId(ISTI_OFFICE_CODEID, y, m);
|
||||
|
||||
if (!epasValidates.getAllCertificationsValidated()) {
|
||||
log.info("No new month closed on EPAS: [year={}, month={}]", y, m);
|
||||
|
|
@ -492,8 +704,6 @@ public class SyncService {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue