Aggiornata scrittura di pers_orario
This commit is contained in:
parent
99a70b4917
commit
4b6cd01797
|
@ -183,7 +183,11 @@ public class EPASPersonWorkingTimeService {
|
||||||
List<EPASPersonWorkingTimeDTO> pwtDTOList=new LinkedList<>();
|
List<EPASPersonWorkingTimeDTO> pwtDTOList=new LinkedList<>();
|
||||||
for(EPASPersons epasPerson:epasPersons) {
|
for(EPASPersons epasPerson:epasPersons) {
|
||||||
EPASPersonWorkingTimeDTO pwtDTO=getByPersonId(epasPerson.getId());
|
EPASPersonWorkingTimeDTO pwtDTO=getByPersonId(epasPerson.getId());
|
||||||
|
if(pwtDTO!=null) {
|
||||||
pwtDTOList.add(pwtDTO);
|
pwtDTOList.add(pwtDTO);
|
||||||
|
} else {
|
||||||
|
logger.error("Not exists Working Time for Person id: {}", epasPerson.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return pwtDTOList;
|
return pwtDTOList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
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.SIPersOrario;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class SIPersOrarioRepository {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(SIPersOrarioRepository.class);
|
||||||
|
|
||||||
|
private JdbcTemplate jdbcTemplate;
|
||||||
|
|
||||||
|
//
|
||||||
|
public SIPersOrarioRepository(final @Qualifier("sistemaInformativoDataSource") DataSource dataSource) {
|
||||||
|
super();
|
||||||
|
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeNewFlux(Long fluxId, SIPersOrario siPersOrario) {
|
||||||
|
jdbcTemplate.update(
|
||||||
|
"INSERT INTO epas_pers_orario (id,idpersona,cf,dal,al,descrizione,"
|
||||||
|
+ "lun,mar,mer,gio,ven,sab,percentuale,turno,ore_turno,festivo,notturno,"
|
||||||
|
+ "data_mod,flag_del,id_flusso)" + " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
||||||
|
siPersOrario.getId(), siPersOrario.getIdpersona(), siPersOrario.getCf(), siPersOrario.getDal(),
|
||||||
|
siPersOrario.getAl(), siPersOrario.getDescrizione(), siPersOrario.getLun(), siPersOrario.getMar(),
|
||||||
|
siPersOrario.getMer(), siPersOrario.getGio(), siPersOrario.getVen(), siPersOrario.getSab(),
|
||||||
|
siPersOrario.getPercentuale(), siPersOrario.getTurno(), siPersOrario.getOre_turno(),
|
||||||
|
siPersOrario.getFestivo(), siPersOrario.getNotturno(), siPersOrario.getData_mod(),
|
||||||
|
siPersOrario.getFlag_del(), fluxId);
|
||||||
|
logger.debug("Writed SIPersOrario: {}", siPersOrario);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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.SIPersOrario;
|
||||||
|
import it.cnr.isti.epasmed.sistemainformativo.repository.SIPersOrarioRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service class for managing PersOrario.
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Transactional("sistemaInformativoTransactionManager")
|
||||||
|
public class SIPersOrarioService {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(SIPersOrarioService.class);
|
||||||
|
|
||||||
|
private final SIPersOrarioRepository siPersOrarioRepository;
|
||||||
|
|
||||||
|
public SIPersOrarioService(SIPersOrarioRepository siPersOrarioRepository) {
|
||||||
|
super();
|
||||||
|
this.siPersOrarioRepository = siPersOrarioRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeNewFlux(Long fluxId, SIPersOrario siPersOrario) {
|
||||||
|
log.debug("Write SIPersOrario Flux = {}", fluxId);
|
||||||
|
siPersOrarioRepository.writeNewFlux(fluxId, siPersOrario);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -29,6 +29,7 @@ import it.cnr.isti.epasmed.domain.TabsSI;
|
||||||
import it.cnr.isti.epasmed.domain.TimeCardsReporting;
|
import it.cnr.isti.epasmed.domain.TimeCardsReporting;
|
||||||
import it.cnr.isti.epasmed.epas.dto.EPASAffiliationsDTO;
|
import it.cnr.isti.epasmed.epas.dto.EPASAffiliationsDTO;
|
||||||
import it.cnr.isti.epasmed.epas.dto.EPASGroupsDTO;
|
import it.cnr.isti.epasmed.epas.dto.EPASGroupsDTO;
|
||||||
|
import it.cnr.isti.epasmed.epas.dto.EPASPersonWorkingTimeDTO;
|
||||||
import it.cnr.isti.epasmed.epas.dto.EPASPersonsDTO;
|
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;
|
||||||
|
@ -50,6 +51,7 @@ 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.EPASLeavesService;
|
||||||
import it.cnr.isti.epasmed.epas.service.EPASOffSiteWorksService;
|
import it.cnr.isti.epasmed.epas.service.EPASOffSiteWorksService;
|
||||||
|
import it.cnr.isti.epasmed.epas.service.EPASPersonWorkingTimeService;
|
||||||
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;
|
||||||
import it.cnr.isti.epasmed.epas.service.EPASValidatesService;
|
import it.cnr.isti.epasmed.epas.service.EPASValidatesService;
|
||||||
|
@ -65,6 +67,7 @@ import it.cnr.isti.epasmed.sistemainformativo.model.SIGruppi;
|
||||||
import it.cnr.isti.epasmed.sistemainformativo.model.SIGruppiPers;
|
import it.cnr.isti.epasmed.sistemainformativo.model.SIGruppiPers;
|
||||||
import it.cnr.isti.epasmed.sistemainformativo.model.SILavoroFuoriSede;
|
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.SIPersOrario;
|
||||||
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.SIAspettativeService;
|
||||||
|
@ -76,6 +79,7 @@ import it.cnr.isti.epasmed.sistemainformativo.service.SIGruppiService;
|
||||||
import it.cnr.isti.epasmed.sistemainformativo.service.SILavoroFuoriSedeService;
|
import it.cnr.isti.epasmed.sistemainformativo.service.SILavoroFuoriSedeService;
|
||||||
import it.cnr.isti.epasmed.sistemainformativo.service.SIMasterLogService;
|
import it.cnr.isti.epasmed.sistemainformativo.service.SIMasterLogService;
|
||||||
import it.cnr.isti.epasmed.sistemainformativo.service.SIOrarioService;
|
import it.cnr.isti.epasmed.sistemainformativo.service.SIOrarioService;
|
||||||
|
import it.cnr.isti.epasmed.sistemainformativo.service.SIPersOrarioService;
|
||||||
import it.cnr.isti.epasmed.sistemainformativo.service.SITelefoniService;
|
import it.cnr.isti.epasmed.sistemainformativo.service.SITelefoniService;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -124,6 +128,8 @@ public class SyncService {
|
||||||
SILavoroFuoriSedeService siLavoroFuoriSedeService;
|
SILavoroFuoriSedeService siLavoroFuoriSedeService;
|
||||||
@Autowired
|
@Autowired
|
||||||
SIAspettativeService siAspettativeService;
|
SIAspettativeService siAspettativeService;
|
||||||
|
@Autowired
|
||||||
|
SIPersOrarioService siPersOrarioService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
EPASPersonsService epasPersonsService;
|
EPASPersonsService epasPersonsService;
|
||||||
|
@ -145,6 +151,8 @@ public class SyncService {
|
||||||
EPASAbsenceTypesService epasAbsenceTypeService;
|
EPASAbsenceTypesService epasAbsenceTypeService;
|
||||||
@Autowired
|
@Autowired
|
||||||
EPASLeavesService epasLeavesService;
|
EPASLeavesService epasLeavesService;
|
||||||
|
@Autowired
|
||||||
|
EPASPersonWorkingTimeService epasPersonWorkingTimeService;
|
||||||
|
|
||||||
private boolean banagrafico;
|
private boolean banagrafico;
|
||||||
private boolean bemail;
|
private boolean bemail;
|
||||||
|
@ -221,7 +229,7 @@ public class SyncService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void executeWriteOffSiteWorks(String year, String month) throws Exception {
|
public void executeWritesOffSiteWorks(String year, String month) throws Exception {
|
||||||
setBWriteTables();
|
setBWriteTables();
|
||||||
List<TabsSI> tabsSI = tabsSIService.getAllTabsSI();
|
List<TabsSI> tabsSI = tabsSIService.getAllTabsSI();
|
||||||
Long fluxId = siMasterLogService.startFluxWrites();
|
Long fluxId = siMasterLogService.startFluxWrites();
|
||||||
|
@ -230,7 +238,7 @@ public class SyncService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void executeWriteLeaves(String year, String month) throws Exception {
|
public void executeWritesLeaves(String year, String month) throws Exception {
|
||||||
setBWriteTables();
|
setBWriteTables();
|
||||||
List<TabsSI> tabsSI = tabsSIService.getAllTabsSI();
|
List<TabsSI> tabsSI = tabsSIService.getAllTabsSI();
|
||||||
Long fluxId = siMasterLogService.startFluxWrites();
|
Long fluxId = siMasterLogService.startFluxWrites();
|
||||||
|
@ -239,6 +247,15 @@ public class SyncService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void executeWritesPersonWorkingTime(String year, String month) throws Exception {
|
||||||
|
setBWriteTables();
|
||||||
|
List<TabsSI> tabsSI = tabsSIService.getAllTabsSI();
|
||||||
|
Long fluxId = siMasterLogService.startFluxWrites();
|
||||||
|
writePersonWorkingTimeData(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;
|
||||||
|
@ -1015,6 +1032,31 @@ public class SyncService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void writePersonWorkingTimeData(Long fluxId, List<TabsSI> tabsSI, String year, String month)
|
||||||
|
throws Exception {
|
||||||
|
logger.info("Report {}-{}", year, month);
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
|
||||||
|
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 "pers_orario":
|
||||||
|
syncPersOrario(fluxId, tab, year, month, now);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void syncOrario(Long fluxId, TabsSI tab) {
|
private void syncOrario(Long fluxId, TabsSI tab) {
|
||||||
if (tab.getIdFlusso() == null || tab.getIdFlusso().longValue() == 0) {
|
if (tab.getIdFlusso() == null || tab.getIdFlusso().longValue() == 0) {
|
||||||
logger.error("Invalid Id Flusso for tab: {}", tab);
|
logger.error("Invalid Id Flusso for tab: {}", tab);
|
||||||
|
@ -1093,7 +1135,7 @@ public class SyncService {
|
||||||
logger.error("Invalid FiscalCode: {}", offSiteWorks.getPerson().getFiscalCode());
|
logger.error("Invalid FiscalCode: {}", offSiteWorks.getPerson().getFiscalCode());
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
logger.info("FiscalCode: {}", offSiteWorks.getPerson().getFiscalCode());
|
logger.debug("FiscalCode: {}", offSiteWorks.getPerson().getFiscalCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer idPersona = 0;
|
Integer idPersona = 0;
|
||||||
|
@ -1104,7 +1146,7 @@ public class SyncService {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Date: {}", offSiteWorks.getDate());
|
logger.debug("Date: {}", offSiteWorks.getDate());
|
||||||
|
|
||||||
java.sql.Date date = null;
|
java.sql.Date date = null;
|
||||||
try {
|
try {
|
||||||
|
@ -1181,21 +1223,21 @@ public class SyncService {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nextYear = nextYear + 1;
|
nextYear = nextYear + 1;
|
||||||
logger.info("Next Year: {}", nextYear.toString());
|
logger.debug("Next Year: {}", nextYear.toString());
|
||||||
|
|
||||||
List<EPASLeaves> epasLeavesList = epasLeavesService.getLeavesByOfficeId(ISTI_OFFICE_ID, year, "true");
|
List<EPASLeaves> epasLeavesList = epasLeavesService.getLeavesByOfficeId(ISTI_OFFICE_ID, year, "true");
|
||||||
logger.info("Current Year Leaves: {}", epasLeavesList);
|
logger.debug("Current Year Leaves: {}", epasLeavesList);
|
||||||
List<EPASLeaves> epasLeavesNextList = epasLeavesService.getLeavesByOfficeId(ISTI_OFFICE_ID, nextYear.toString(),
|
List<EPASLeaves> epasLeavesNextList = epasLeavesService.getLeavesByOfficeId(ISTI_OFFICE_ID, nextYear.toString(),
|
||||||
"true");
|
"true");
|
||||||
logger.info("Next Year Leaves: {}", epasLeavesNextList);
|
logger.debug("Next Year Leaves: {}", epasLeavesNextList);
|
||||||
|
|
||||||
if (epasLeavesList == null || epasLeavesList.isEmpty()) {
|
if (epasLeavesList == null || epasLeavesList.isEmpty()) {
|
||||||
logger.info("Leaves not found for: {}", year);
|
logger.debug("Leaves not found for: {}", year);
|
||||||
epasLeavesList = new LinkedList<>();
|
epasLeavesList = new LinkedList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (epasLeavesNextList == null || epasLeavesNextList.isEmpty()) {
|
if (epasLeavesNextList == null || epasLeavesNextList.isEmpty()) {
|
||||||
logger.info("Leaves not found for: {}", nextYear);
|
logger.debug("Leaves not found for: {}", nextYear);
|
||||||
epasLeavesNextList = new LinkedList<>();
|
epasLeavesNextList = new LinkedList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1228,7 +1270,7 @@ public class SyncService {
|
||||||
LinkedHashMap<String, EPASAbsenceTypes> epasAbsenceTypeMap) {
|
LinkedHashMap<String, EPASAbsenceTypes> epasAbsenceTypeMap) {
|
||||||
// SI
|
// SI
|
||||||
for (EPASLeaves leave : epasLeavesList) {
|
for (EPASLeaves leave : epasLeavesList) {
|
||||||
logger.info("Writing Leave: {}", leave);
|
logger.debug("Writing Leave: {}", leave);
|
||||||
if (leave == null || leave.getPerson() == null) {
|
if (leave == null || leave.getPerson() == null) {
|
||||||
logger.error("Invalid Leave: {}", leave);
|
logger.error("Invalid Leave: {}", leave);
|
||||||
continue;
|
continue;
|
||||||
|
@ -1238,7 +1280,7 @@ public class SyncService {
|
||||||
logger.error("Invalid FiscalCode: {}", leave.getPerson().getFiscalCode());
|
logger.error("Invalid FiscalCode: {}", leave.getPerson().getFiscalCode());
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
logger.info("FiscalCode: {}", leave.getPerson().getFiscalCode());
|
logger.debug("FiscalCode: {}", leave.getPerson().getFiscalCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer idPersona = 0;
|
Integer idPersona = 0;
|
||||||
|
@ -1268,7 +1310,7 @@ public class SyncService {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Start Date: {}", leave.getStart());
|
logger.debug("Start Date: {}", leave.getStart());
|
||||||
java.sql.Date startDate = null;
|
java.sql.Date startDate = null;
|
||||||
if (leave.getStart() == null || leave.getStart().isEmpty()) {
|
if (leave.getStart() == null || leave.getStart().isEmpty()) {
|
||||||
logger.error("Invalid start date: {}", leave.getStart());
|
logger.error("Invalid start date: {}", leave.getStart());
|
||||||
|
@ -1282,7 +1324,7 @@ public class SyncService {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("End Date: {}", leave.getEnd());
|
logger.debug("End Date: {}", leave.getEnd());
|
||||||
java.sql.Date endDate = null;
|
java.sql.Date endDate = null;
|
||||||
if (leave.getEnd() != null && !leave.getEnd().isEmpty()) {
|
if (leave.getEnd() != null && !leave.getEnd().isEmpty()) {
|
||||||
try {
|
try {
|
||||||
|
@ -1310,7 +1352,6 @@ public class SyncService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SIAspettative siAspettative = new SIAspettative(leave.getPerson().getFiscalCode(),
|
SIAspettative siAspettative = new SIAspettative(leave.getPerson().getFiscalCode(),
|
||||||
epasAbsenceType.getDescription(), startDate, endDate, dataMod, SI_FLAG_DEL_FALSE, fluxId, id,
|
epasAbsenceType.getDescription(), startDate, endDate, dataMod, SI_FLAG_DEL_FALSE, fluxId, id,
|
||||||
idPersona, absenceId, epasAbsenceType.getCode(), durata);
|
idPersona, absenceId, epasAbsenceType.getCode(), durata);
|
||||||
|
@ -1320,6 +1361,111 @@ public class SyncService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void syncPersOrario(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);
|
||||||
|
|
||||||
|
List<EPASPersonWorkingTimeDTO> epasPersonWorkingTimeDTOList = epasPersonWorkingTimeService
|
||||||
|
.getList(ISTI_OFFICE_ID);
|
||||||
|
|
||||||
|
if (epasPersonWorkingTimeDTOList == null || epasPersonWorkingTimeDTOList.isEmpty()) {
|
||||||
|
logger.error("PersonWorkingTimeDTOList not found");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
logger.info("PersonWorkingTimeDTOList size: {}",epasPersonWorkingTimeDTOList.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
// SI
|
||||||
|
for (EPASPersonWorkingTimeDTO pwtDTO : epasPersonWorkingTimeDTOList) {
|
||||||
|
logger.info("Writing Person Working Time: {}", pwtDTO);
|
||||||
|
if (pwtDTO == null) {
|
||||||
|
logger.error("Invalid Person Working Time: {}", pwtDTO);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer id = 0;
|
||||||
|
if (pwtDTO.getId() == null || pwtDTO.getId().isEmpty()) {
|
||||||
|
logger.error("Invalid Id: {}", pwtDTO.getId());
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
logger.debug("Id: {}", pwtDTO.getId());
|
||||||
|
try {
|
||||||
|
id = Integer.parseInt(pwtDTO.getId());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
logger.error("Invalid Id: {}", pwtDTO.getId());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer idPersona = 0;
|
||||||
|
if (pwtDTO.getIdPersona() == null || pwtDTO.getIdPersona().isEmpty()) {
|
||||||
|
logger.error("Invalid Id Persona: {}", pwtDTO.getIdPersona());
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
logger.debug("Id Persona: {}", pwtDTO.getIdPersona());
|
||||||
|
try {
|
||||||
|
idPersona = Integer.parseInt(pwtDTO.getIdPersona());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
logger.error("Invalid Id Persona: {}", pwtDTO.getIdPersona());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pwtDTO.getCf() == null || pwtDTO.getCf().isEmpty()) {
|
||||||
|
logger.error("Invalid FiscalCode: {}", pwtDTO.getCf());
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
logger.debug("FiscalCode: {}", pwtDTO.getCf());
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug("Dal: {}", pwtDTO.getDal());
|
||||||
|
if (pwtDTO.getDal() == null || pwtDTO.getDal().isEmpty()) {
|
||||||
|
logger.error("Invalid dal date: {}", pwtDTO.getDal());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
java.sql.Date startDate = null;
|
||||||
|
try {
|
||||||
|
startDate = java.sql.Date.valueOf(pwtDTO.getDal());
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Invalid dal date format: {}", pwtDTO.getDal());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug("Al: {}", pwtDTO.getAl());
|
||||||
|
java.sql.Date endDate = null;
|
||||||
|
if (pwtDTO.getAl() != null && !pwtDTO.getAl().isEmpty()) {
|
||||||
|
try {
|
||||||
|
endDate = java.sql.Date.valueOf(pwtDTO.getAl());
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Invalid al date format: {}", pwtDTO.getAl());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timestamp dataMod = Timestamp.valueOf(now);
|
||||||
|
|
||||||
|
SIPersOrario siPersOrario = new SIPersOrario(id, idPersona, pwtDTO.getCf(), startDate, endDate,
|
||||||
|
pwtDTO.getDescrizione(), pwtDTO.getLun(), pwtDTO.getMar(), pwtDTO.getMer(), pwtDTO.getGio(),
|
||||||
|
pwtDTO.getVen(), pwtDTO.getSab(), pwtDTO.getPercentuale(), pwtDTO.getTurno(), pwtDTO.getOre_turno(),
|
||||||
|
pwtDTO.getFestivo(), pwtDTO.getNotturno(), dataMod, SI_FLAG_DEL_FALSE, fluxId);
|
||||||
|
logger.info("Write SIPersOrario: {}", siPersOrario);
|
||||||
|
siPersOrarioService.writeNewFlux(fluxId, siPersOrario);
|
||||||
|
|
||||||
|
}
|
||||||
|
logger.info("SIPersOrario Updated");
|
||||||
|
|
||||||
|
bpers_orario = true;
|
||||||
|
tab.setIdFlusso(fluxId);
|
||||||
|
tab.setLastUpdate(now);
|
||||||
|
tabsSIService.updateTabsSI(tab);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
|
|
@ -213,7 +213,7 @@ public class SyncResource {
|
||||||
@RequestParam("month") String month) throws Exception {
|
@RequestParam("month") String month) throws Exception {
|
||||||
logger.info("REST request syncWritesOffSiteWorks)");
|
logger.info("REST request syncWritesOffSiteWorks)");
|
||||||
ResponseEntity<Void> res;
|
ResponseEntity<Void> res;
|
||||||
syncService.executeWriteOffSiteWorks(year, month);
|
syncService.executeWritesOffSiteWorks(year, month);
|
||||||
String msg = "Rendicontazione del lavoro fuori sede eseguita correttamente.";
|
String msg = "Rendicontazione del lavoro fuori sede eseguita correttamente.";
|
||||||
logger.info(msg);
|
logger.info(msg);
|
||||||
res = ResponseEntity.noContent().headers(HeaderUtil.createAlert(applicationName, msg, "")).build();
|
res = ResponseEntity.noContent().headers(HeaderUtil.createAlert(applicationName, msg, "")).build();
|
||||||
|
@ -240,7 +240,7 @@ public class SyncResource {
|
||||||
@RequestParam("month") String month) throws Exception {
|
@RequestParam("month") String month) throws Exception {
|
||||||
logger.info("REST request syncWritesLeaves)");
|
logger.info("REST request syncWritesLeaves)");
|
||||||
ResponseEntity<Void> res;
|
ResponseEntity<Void> res;
|
||||||
syncService.executeWriteLeaves(year, month);
|
syncService.executeWritesLeaves(year, month);
|
||||||
String msg = "Rendicontazione delle Aspettative eseguita correttamente.";
|
String msg = "Rendicontazione delle Aspettative eseguita correttamente.";
|
||||||
logger.info(msg);
|
logger.info(msg);
|
||||||
res = ResponseEntity.noContent().headers(HeaderUtil.createAlert(applicationName, msg, "")).build();
|
res = ResponseEntity.noContent().headers(HeaderUtil.createAlert(applicationName, msg, "")).build();
|
||||||
|
@ -248,4 +248,31 @@ public class SyncResource {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code GET /sync/writesPersonWorkingTime} : Reports Person Working Time 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/writesPersonWorkingTime")
|
||||||
|
@PreAuthorize("hasAuthority(\"" + AuthoritiesConstants.ADMIN + "\")")
|
||||||
|
public ResponseEntity<Void> syncWritesPersonWorkingTime(@RequestParam("year") String year,
|
||||||
|
@RequestParam("month") String month) throws Exception {
|
||||||
|
logger.info("REST request syncWritesPersonWorkingTime)");
|
||||||
|
ResponseEntity<Void> res;
|
||||||
|
syncService.executeWritesPersonWorkingTime(year, month);
|
||||||
|
String msg = "Rendicontazione di Pers_Orario eseguita correttamente.";
|
||||||
|
logger.info(msg);
|
||||||
|
res = ResponseEntity.noContent().headers(HeaderUtil.createAlert(applicationName, msg, "")).build();
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ import it.cnr.isti.epasmed.web.rest.TestUtil;
|
||||||
@AutoConfigureMockMvc
|
@AutoConfigureMockMvc
|
||||||
@WithMockUser(authorities = AuthoritiesConstants.ADMIN)
|
@WithMockUser(authorities = AuthoritiesConstants.ADMIN)
|
||||||
@SpringBootTest(classes = EpasmedApp.class)
|
@SpringBootTest(classes = EpasmedApp.class)
|
||||||
@EnabledIf("true")
|
@EnabledIf("false")
|
||||||
public class EPASContractsResourceIT {
|
public class EPASContractsResourceIT {
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||||
|
|
|
@ -3,6 +3,13 @@ package it.cnr.isti.epasmed.web.rest.sync;
|
||||||
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.sql.Timestamp;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.time.format.DateTimeFormatterBuilder;
|
||||||
|
import java.time.format.DateTimeParseException;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
|
|
||||||
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;
|
||||||
|
@ -27,6 +34,9 @@ import it.cnr.isti.epasmed.security.AuthoritiesConstants;
|
||||||
@EnabledIf("false")
|
@EnabledIf("false")
|
||||||
public class SyncResourceIT {
|
public class SyncResourceIT {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(SyncResourceIT.class);
|
||||||
|
|
||||||
|
|
||||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
private static final String YEAR = "2022";
|
private static final String YEAR = "2022";
|
||||||
private static final String MONTH = "9";
|
private static final String MONTH = "9";
|
||||||
|
@ -90,4 +100,33 @@ public class SyncResourceIT {
|
||||||
restSyncMockMvc.perform(get("/api/sync/writesLeaves?year=" + YEAR + "&month=" + MONTH));
|
restSyncMockMvc.perform(get("/api/sync/writesLeaves?year=" + YEAR + "&month=" + MONTH));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void syncWritesPersonWorkingTime() throws Exception {
|
||||||
|
restSyncMockMvc.perform(get("/api/sync/writesPersonWorkingTime?year=" + YEAR + "&month=" + MONTH));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDataMod() throws Exception {
|
||||||
|
// "2021-02-03T09:49:05.231072"
|
||||||
|
DateTimeFormatter formatter = new DateTimeFormatterBuilder().parseCaseInsensitive()
|
||||||
|
.append(DateTimeFormatter.ISO_LOCAL_DATE_TIME).optionalStart().appendPattern(".SSSSSS").optionalEnd()
|
||||||
|
.optionalStart().appendZoneOrOffsetId().optionalEnd().toFormatter();
|
||||||
|
//DateTimeFormatter formatterDataMod = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
|
Timestamp dataMod;
|
||||||
|
try {
|
||||||
|
LocalDateTime dMod = LocalDateTime.parse("2021-02-03T19:49:05.231072", formatter);
|
||||||
|
dMod=dMod.truncatedTo(ChronoUnit.SECONDS);
|
||||||
|
//dMod= LocalDateTime.parse(dMod.format(formatterDataMod));
|
||||||
|
//dataMod = Timestamp.valueOf(dMod.format(formatterDataMod));
|
||||||
|
dataMod = Timestamp.valueOf(dMod);
|
||||||
|
|
||||||
|
} catch (IllegalArgumentException | DateTimeParseException e) {
|
||||||
|
logger.error("Invalid stamping data format: {}", e.getLocalizedMessage(), e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info("Result: {}",dataMod);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue