Merge branch 'develop' into feature/RefactoringGestioneColli
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250430154023 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetup("TASK", "SETUP", "DEFAULT_ACTIVITY_TYPE", null,
|
||||
"Tipo attività di default proposto in inserimento ore", false, null, false, false,
|
||||
true, false, false, null, false, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250502095239 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetupQuery("SI_NO", "SI_NO", "SELECT 'S' UNION ALL SELECT 'N'");
|
||||
createSetup("TASK", "AGENDA", "SEND_EMAIL", "N",
|
||||
"Se abilitata invia una mail all'amministrazione quando vengono inserite o modificate delle assenze.", false, "SI_NO", false, false,
|
||||
false, false, false, null, false, "SELECT 'S' UNION ALL SELECT 'N'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250502115240 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetupQuery("SI_NO", "SI_NO", "SELECT 'S' UNION ALL SELECT 'N'");
|
||||
createSetup("TASK", "SETUP", "MANAGE_ACTIVITIES", "S",
|
||||
"Permette di scegliere se gestire o meno le attività. Se non abilitata permetterà la sola visualizzazione del calendario e gestione assenze.", false, "SI_NO", false, false,
|
||||
false, false, false, null, false, "SELECT 'S' UNION ALL SELECT 'N'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250502120455 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetupQuery("SI_NO", "SI_NO", "SELECT 'S' UNION ALL SELECT 'N'");
|
||||
createSetup("TASK", "AGENDA", "EXCLUDE_WEEKEND", "N",
|
||||
"Permette di scegliere se considerare o meno il weekend nel calendario.", false, "SI_NO", false, false,
|
||||
false, false, false, null, false, "SELECT 'S' UNION ALL SELECT 'N'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250502164926 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("ALTER TABLE jtb_giustifica ADD flag_permesso bit");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -146,6 +146,7 @@ public class UserCacheService {
|
||||
(application == IntegryApplicationEnum.PVM && x.isWeb()) ||
|
||||
(application == IntegryApplicationEnum.CONSEGNA && x.isWeb()) ||
|
||||
(application == IntegryApplicationEnum.WMS && x.isWeb()) ||
|
||||
(application == IntegryApplicationEnum.TASK && x.isWeb()) ||
|
||||
(application == IntegryApplicationEnum.GESTIONALE_BASE && x.isInternal())))
|
||||
.findFirst();
|
||||
|
||||
@@ -171,6 +172,7 @@ public class UserCacheService {
|
||||
(application == IntegryApplicationEnum.PVM && x.isWeb()) ||
|
||||
(application == IntegryApplicationEnum.CONSEGNA && x.isWeb()) ||
|
||||
(application == IntegryApplicationEnum.WMS && x.isWeb()) ||
|
||||
(application == IntegryApplicationEnum.TASK && x.isWeb()) ||
|
||||
(application == IntegryApplicationEnum.GESTIONALE_BASE && x.isInternal())))
|
||||
.findFirst();
|
||||
|
||||
|
||||
@@ -41,6 +41,9 @@ public class JtbGiustifica extends EntityBase {
|
||||
@SqlField(value = "cod_intercode", maxLength = 5)
|
||||
private String codIntercode;
|
||||
|
||||
@SqlField(value = "flag_permesso", defaultObjectValue = "0")
|
||||
private Boolean flagPermesso;
|
||||
|
||||
@EntityChild
|
||||
private List<JtbGiustificaRow> jtbGiustificaRow = new ArrayList<>();
|
||||
|
||||
@@ -104,6 +107,15 @@ public class JtbGiustifica extends EntityBase {
|
||||
this.jtbGiustificaRow = jtbGiustificaRow;
|
||||
}
|
||||
|
||||
public Boolean getFlagPermesso() {
|
||||
return flagPermesso;
|
||||
}
|
||||
|
||||
public JtbGiustifica setFlagPermesso(Boolean flagPermesso) {
|
||||
this.flagPermesso = flagPermesso;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void insertChilds() throws Exception {
|
||||
for (JtbGiustificaRow jtbGiustificaRow : getJtbGiustificaRow()) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import it.integry.ems.response.FileItem;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.zip.*;
|
||||
|
||||
@@ -131,4 +132,26 @@ public class UtilityZip {
|
||||
|
||||
return outputStream.toByteArray();
|
||||
}
|
||||
|
||||
public static List<byte[]> extractZipFile(byte[] zipFile) throws Exception {
|
||||
List<byte[]> extractedFiles = new ArrayList<>();
|
||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(zipFile);
|
||||
ZipInputStream zipInputStream = new ZipInputStream(inputStream);
|
||||
|
||||
while (zipInputStream.getNextEntry() != null) {
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int len;
|
||||
while ((len = zipInputStream.read(buffer)) > 0) {
|
||||
outputStream.write(buffer, 0, len);
|
||||
}
|
||||
extractedFiles.add(outputStream.toByteArray());
|
||||
zipInputStream.closeEntry();
|
||||
outputStream.close();
|
||||
}
|
||||
|
||||
zipInputStream.close();
|
||||
inputStream.close();
|
||||
return extractedFiles;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -22,52 +22,43 @@ import java.util.List;
|
||||
@Scope(value = "request")
|
||||
public class UserAbsenceController {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private UserAbsenceService userAbsenceService;
|
||||
|
||||
@Autowired
|
||||
private RequestDataDTO requestDataDTO;
|
||||
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = "/retrieve", method = RequestMethod.GET)
|
||||
public ServiceRestResponse retrieveAssenze(HttpServletRequest request,
|
||||
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate startDate,
|
||||
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate endDate) throws Exception {
|
||||
public ServiceRestResponse retrieveAssenze(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate startDate,
|
||||
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate endDate) throws Exception {
|
||||
return ServiceRestResponse.createPositiveResponse(userAbsenceService.retrieveAssenze(startDate, endDate));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/available-justifications", method = RequestMethod.GET)
|
||||
public ServiceRestResponse retrieve(HttpServletRequest request) throws Exception {
|
||||
public ServiceRestResponse retrieve(@RequestParam(CommonConstants.PROFILE_DB) String config) throws Exception {
|
||||
return ServiceRestResponse.createPositiveResponse(userAbsenceService.getGiustificativo());
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = "/register", method = RequestMethod.POST)
|
||||
public ServiceRestResponse registerAbsence(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestBody List<UserAbsenceRequestDTO> userAbsences) throws Exception {
|
||||
userAbsenceService.registerAbsence(userAbsences, requestDataDTO.getUsername());
|
||||
public ServiceRestResponse registerAbsence(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestBody List<UserAbsenceRequestDTO> absenceRequest) throws Exception {
|
||||
userAbsenceService.registerAbsence(absenceRequest);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = "/modify", method = RequestMethod.POST)
|
||||
public ServiceRestResponse modifyAbsence(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestBody UserAbsenceRequestDTO absence) throws Exception {
|
||||
userAbsenceService.modifyAbsence(absence, requestDataDTO.getUsername());
|
||||
public ServiceRestResponse modifyAbsence(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestBody UserAbsenceRequestDTO absenceRequest) throws Exception {
|
||||
userAbsenceService.modifyAbsence(absenceRequest);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
public ServiceRestResponse deleteAbsence(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestBody UserAbsenceRequestDTO absence) throws Exception {
|
||||
userAbsenceService.deleteAbsence(absence, requestDataDTO.getUsername());
|
||||
public ServiceRestResponse deleteAbsence(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestBody UserAbsenceRequestDTO absenceRequest) throws Exception {
|
||||
userAbsenceService.deleteAbsence(absenceRequest);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package it.integry.ems.activity.dto;
|
||||
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
public class AssenzaDTO {
|
||||
@@ -18,6 +19,12 @@ public class AssenzaDTO {
|
||||
@SqlField("note")
|
||||
private String note;
|
||||
|
||||
@SqlField("ore_assenza")
|
||||
private BigDecimal oreAssenza;
|
||||
|
||||
@SqlField("cod_jflav")
|
||||
private String codJflav;
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
@@ -53,4 +60,22 @@ public class AssenzaDTO {
|
||||
this.note = note;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getOreAssenza() {
|
||||
return oreAssenza;
|
||||
}
|
||||
|
||||
public AssenzaDTO setOreAssenza(BigDecimal oreAssenza) {
|
||||
this.oreAssenza = oreAssenza;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodJflav() {
|
||||
return codJflav;
|
||||
}
|
||||
|
||||
public AssenzaDTO setCodJflav(String codJflav) {
|
||||
this.codJflav = codJflav;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
package it.integry.ems.activity.dto;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class UserAbsenceRequestDTO {
|
||||
|
||||
private String username;
|
||||
private String codJflav;
|
||||
private LocalDate dataInizio;
|
||||
private LocalDate dataFine;
|
||||
private String giustificativo;
|
||||
private String note;
|
||||
private String fullname;
|
||||
private BigDecimal oreAssenza;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
public String getCodJflav() {
|
||||
return codJflav;
|
||||
}
|
||||
|
||||
public UserAbsenceRequestDTO setUsername(String username) {
|
||||
this.username = username;
|
||||
public UserAbsenceRequestDTO setCodJflav(String codJflav) {
|
||||
this.codJflav = codJflav;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -54,4 +57,22 @@ public class UserAbsenceRequestDTO {
|
||||
this.note = note;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFullname() {
|
||||
return fullname;
|
||||
}
|
||||
|
||||
public UserAbsenceRequestDTO setFullname(String fullname) {
|
||||
this.fullname = fullname;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getOreAssenza() {
|
||||
return oreAssenza;
|
||||
}
|
||||
|
||||
public UserAbsenceRequestDTO setOreAssenza(BigDecimal oreAssenza) {
|
||||
this.oreAssenza = oreAssenza;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,14 @@ import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.service.MailService;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.user.service.UserService;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems_model.entity.JtbGiustifica;
|
||||
import it.integry.ems_model.entity.JtbRLavt;
|
||||
import it.integry.ems_model.exception.DataConverterNotFoundException;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
@@ -24,6 +27,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -41,52 +45,72 @@ public class UserAbsenceService {
|
||||
@Autowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
|
||||
@Autowired
|
||||
private SetupGest setupGest;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private RequestDataDTO requestDataDTO;
|
||||
|
||||
public List<AssenzaDTO> retrieveAssenze(LocalDate startDate, LocalDate endDate) throws SQLException, IOException, PrimaryDatabaseNotPresentException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||
String sql = "SELECT jrl_flav_users.user_name,\n" +
|
||||
" data_lav,\n" +
|
||||
" jtb_rlavt.giustificativo,\n" +
|
||||
" jtb_rlavt.note\n" +
|
||||
"FROM jtb_rlavt\n" +
|
||||
" INNER JOIN jrl_flav_users ON jrl_flav_users.cod_jflav = jtb_rlavt.cod_jflav\n" +
|
||||
"WHERE giustificativo IS NOT NULL\n" +
|
||||
" AND jtb_rlavt.data_lav BETWEEN " + UtilityDB.valueToString(startDate) + " AND " + UtilityDB.valueToString(endDate) + "\n" +
|
||||
" AND jrl_flav_users.flag_jflav_default = 'S'";
|
||||
public List<AssenzaDTO> retrieveAssenze(LocalDate startDate, LocalDate endDate) throws Exception {
|
||||
String sql = Query.format(
|
||||
"SELECT jrl_flav_users.user_name,\n" +
|
||||
" data_lav,\n" +
|
||||
" jtb_rlavt.giustificativo,\n" +
|
||||
" jtb_rlavt.note,\n" +
|
||||
" jtb_rlavt.ore_assenza,\n" +
|
||||
" jtb_rlavt.cod_jflav\n" +
|
||||
"FROM jtb_rlavt\n" +
|
||||
" LEFT OUTER JOIN jrl_flav_users\n" +
|
||||
" ON jrl_flav_users.cod_jflav = jtb_rlavt.cod_jflav AND jrl_flav_users.flag_jflav_default = 'S'\n" +
|
||||
"WHERE giustificativo IS NOT NULL\n" +
|
||||
" AND jtb_rlavt.data_lav BETWEEN %s AND %s",
|
||||
startDate, endDate
|
||||
);
|
||||
|
||||
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, AssenzaDTO.class);
|
||||
}
|
||||
|
||||
public List<JtbGiustifica> getGiustificativo() throws Exception {
|
||||
String sql = "SELECT giustificativo\n" +
|
||||
String sql = "SELECT giustificativo, flag_permesso\n" +
|
||||
"FROM jtb_giustifica\n" +
|
||||
"WHERE flag_attivo = 'S'";
|
||||
|
||||
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, JtbGiustifica.class);
|
||||
}
|
||||
|
||||
public void registerAbsence(List<UserAbsenceRequestDTO> assenzeList, String username) throws Exception {
|
||||
String codJflav = userService.retrieveCodJflav(username);
|
||||
String fullname = requestDataDTO.getUser().getFullname();
|
||||
|
||||
public void registerAbsence(List<UserAbsenceRequestDTO> assenzeList) throws Exception {
|
||||
boolean sendEmail = sendEmail();
|
||||
List<JtbRLavt> jtbRLavtList = new ArrayList<>();
|
||||
|
||||
for (UserAbsenceRequestDTO assenzaItem : assenzeList) {
|
||||
|
||||
if (assenzaItem.getDataInizio() == null) throw new Exception("Errore nella data inizio");
|
||||
if (assenzaItem.getDataFine() == null) throw new Exception("Errore nella data fine");
|
||||
if (assenzaItem.getDataInizio() == null) throw new Exception("Data inizio mancante");
|
||||
if (assenzaItem.getDataFine() == null) throw new Exception("Data fine mancante");
|
||||
|
||||
String codJflav;
|
||||
String fullname;
|
||||
if (UtilityString.isNullOrEmpty(assenzaItem.getCodJflav())) {
|
||||
codJflav = userService.retrieveCodJflav(requestDataDTO.getUsername());
|
||||
fullname = requestDataDTO.getUser().getFullname();
|
||||
} else {
|
||||
codJflav = assenzaItem.getCodJflav();
|
||||
fullname = assenzaItem.getFullname();
|
||||
}
|
||||
|
||||
for (LocalDate currentDate = assenzaItem.getDataInizio();
|
||||
currentDate.isBefore(assenzaItem.getDataFine()) || currentDate.isEqual(assenzaItem.getDataFine());
|
||||
currentDate = currentDate.plusDays(1)) {
|
||||
|
||||
if (!isGiornoLavorativo(currentDate)) continue;
|
||||
|
||||
JtbRLavt jtbRLavt = new JtbRLavt()
|
||||
.setGiustificativo(assenzaItem.getGiustificativo())
|
||||
.setDataLav(UtilityLocalDate.localDateToDate(currentDate))
|
||||
.setCodJflav(codJflav)
|
||||
.setCodJflav(codJflav).
|
||||
setOreAssenza(assenzaItem.getOreAssenza())
|
||||
.setNote(assenzaItem.getNote());
|
||||
jtbRLavt
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
@@ -94,98 +118,111 @@ public class UserAbsenceService {
|
||||
jtbRLavtList.add(jtbRLavt);
|
||||
}
|
||||
|
||||
|
||||
String startDate = CommonConstants.DATE_DMY_SLASHED_FORMATTER.format(assenzaItem.getDataInizio());
|
||||
String endDate = CommonConstants.DATE_DMY_SLASHED_FORMATTER.format(assenzaItem.getDataFine());
|
||||
|
||||
String giustificativo = WordUtils.capitalize(assenzaItem.getGiustificativo().toLowerCase());
|
||||
String note = assenzaItem.getNote();
|
||||
if (jtbRLavtList.isEmpty()) return;
|
||||
|
||||
UtilityEntity.throwEntitiesException(entityProcessor.processEntityList(jtbRLavtList, multiDBTransactionManager, true));
|
||||
|
||||
String subject = String.format("%s di %s", giustificativo, fullname);
|
||||
String message = String.format("%s di %s per il periodo dal: %s al: %s.", giustificativo, fullname, startDate, endDate);
|
||||
if (sendEmail) {
|
||||
String startDate = CommonConstants.DATE_DMY_SLASHED_FORMATTER.format(assenzaItem.getDataInizio());
|
||||
String endDate = CommonConstants.DATE_DMY_SLASHED_FORMATTER.format(assenzaItem.getDataFine());
|
||||
|
||||
String giustificativo = WordUtils.capitalize(assenzaItem.getGiustificativo().toLowerCase());
|
||||
String note = assenzaItem.getNote();
|
||||
|
||||
String subject = String.format("%s di %s", giustificativo, fullname);
|
||||
String message = String.format("%s di %s per il periodo dal: %s al: %s.", giustificativo, fullname, startDate, endDate);
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(note)) {
|
||||
message = message.concat(String.format("\nNote: %s", note));
|
||||
}
|
||||
|
||||
mailService.sendMail("amministrazione@integry.it", "m.morelli@integry.it", subject, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void modifyAbsence(UserAbsenceRequestDTO assenza) throws Exception {
|
||||
boolean sendEmail = sendEmail();
|
||||
if (assenza.getDataInizio() == null) throw new Exception("Data inizio mancante");
|
||||
|
||||
String giustificativo = WordUtils.capitalize(assenza.getGiustificativo().toLowerCase());
|
||||
String note = assenza.getNote();
|
||||
|
||||
processAbsence(assenza, OperationType.UPDATE);
|
||||
|
||||
String fullname = "";
|
||||
if (UtilityString.isNullOrEmpty(assenza.getCodJflav())) {
|
||||
fullname = requestDataDTO.getUser().getFullname();
|
||||
}
|
||||
|
||||
if (sendEmail) {
|
||||
String subject = String.format("Modifica %s di %s", giustificativo, fullname);
|
||||
String message = String.format("%s di %s per il giorno: %s.", giustificativo, fullname, assenza.getDataInizio());
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(note)) {
|
||||
message = message.concat(String.format("\nNote: %s", note));
|
||||
}
|
||||
|
||||
mailService.sendMail("amministrazione@integry.it", "m.morelli@integry.it", subject, message);
|
||||
mailService.sendMail("amministrazione@integry.it", null, subject, message);
|
||||
}
|
||||
}
|
||||
|
||||
public void modifyAbsence(UserAbsenceRequestDTO assenza, String username) throws Exception {
|
||||
String codJflav;
|
||||
String fullname;
|
||||
|
||||
if (UtilityString.isNullOrEmpty(assenza.getUsername())) {
|
||||
codJflav = userService.retrieveCodJflav(username);
|
||||
fullname = requestDataDTO.getUser().getFullname();
|
||||
} else {
|
||||
codJflav = userService.retrieveCodJflav(assenza.getUsername());
|
||||
fullname = userService.retrieveFullName(assenza.getUsername());
|
||||
}
|
||||
|
||||
if (assenza.getDataInizio() == null) throw new Exception("Errore nella data inizio");
|
||||
|
||||
JtbRLavt jtbRLavt = new JtbRLavt();
|
||||
|
||||
jtbRLavt.setGiustificativo(assenza.getGiustificativo())
|
||||
.setDataLav(UtilityLocalDate.localDateToDate(assenza.getDataInizio()))
|
||||
.setCodJflav(codJflav)
|
||||
.setNote(assenza.getNote())
|
||||
.setOperation(OperationType.UPDATE);
|
||||
public void deleteAbsence(UserAbsenceRequestDTO assenza) throws Exception {
|
||||
boolean sendEmail = sendEmail();
|
||||
if (assenza.getDataInizio() == null) throw new Exception("Data inizio mancante");
|
||||
|
||||
String giustificativo = WordUtils.capitalize(assenza.getGiustificativo().toLowerCase());
|
||||
String note = assenza.getNote();
|
||||
|
||||
UtilityEntity.throwEntitiesException(entityProcessor.processEntity(jtbRLavt, multiDBTransactionManager));
|
||||
processAbsence(assenza, OperationType.DELETE);
|
||||
|
||||
String subject = String.format("Modifica %s di %s", giustificativo, fullname);
|
||||
String message = String.format("%s di %s per il giorno: %s.", giustificativo, fullname, assenza.getDataInizio());
|
||||
if (sendEmail) {
|
||||
String subject = String.format("Eliminazione %s di %s", giustificativo, assenza.getFullname());
|
||||
String message = String.format("%s di %s per il giorno: %s.", giustificativo, assenza.getFullname(), assenza.getDataInizio());
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(note)) {
|
||||
message = message.concat(String.format("\nNote: %s", note));
|
||||
if (!UtilityString.isNullOrEmpty(note)) {
|
||||
message = message.concat(String.format("\nNote: %s", note));
|
||||
}
|
||||
|
||||
mailService.sendMail("amministrazione@integry.it", null, subject, message);
|
||||
}
|
||||
|
||||
mailService.sendMail("amministrazione@integry.it", null, subject, message);
|
||||
}
|
||||
|
||||
public void deleteAbsence(UserAbsenceRequestDTO assenza, String username) throws Exception {
|
||||
private void processAbsence(UserAbsenceRequestDTO assenza, OperationType op) throws Exception {
|
||||
String codJflav;
|
||||
String fullname;
|
||||
|
||||
if (UtilityString.isNullOrEmpty(assenza.getUsername())) {
|
||||
codJflav = userService.retrieveCodJflav(username);
|
||||
fullname = requestDataDTO.getUser().getFullname();
|
||||
if (UtilityString.isNullOrEmpty(assenza.getCodJflav())) {
|
||||
codJflav = userService.retrieveCodJflav(requestDataDTO.getUsername());
|
||||
} else {
|
||||
codJflav = userService.retrieveCodJflav(assenza.getUsername());
|
||||
fullname = userService.retrieveFullName(assenza.getUsername());
|
||||
codJflav = assenza.getCodJflav();
|
||||
}
|
||||
|
||||
if (assenza.getDataInizio() == null) throw new Exception("Errore nella data inizio");
|
||||
|
||||
JtbRLavt jtbRLavt = new JtbRLavt();
|
||||
|
||||
jtbRLavt.setGiustificativo(assenza.getGiustificativo())
|
||||
JtbRLavt jtbRLavt = new JtbRLavt()
|
||||
.setGiustificativo(assenza.getGiustificativo())
|
||||
.setDataLav(UtilityLocalDate.localDateToDate(assenza.getDataInizio()))
|
||||
.setCodJflav(codJflav)
|
||||
.setNote(assenza.getNote())
|
||||
.setOperation(OperationType.DELETE);
|
||||
|
||||
String giustificativo = WordUtils.capitalize(assenza.getGiustificativo().toLowerCase());
|
||||
String note = assenza.getNote();
|
||||
.setNote(assenza.getNote());
|
||||
jtbRLavt.setOperation(op);
|
||||
|
||||
UtilityEntity.throwEntitiesException(entityProcessor.processEntity(jtbRLavt, multiDBTransactionManager));
|
||||
|
||||
String subject = String.format("Eliminazione %s di %s", giustificativo, fullname);
|
||||
String message = String.format("%s di %s per il giorno: %s.", giustificativo, fullname, assenza.getDataInizio());
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(note)) {
|
||||
message = message.concat(String.format("\nNote: %s", note));
|
||||
}
|
||||
|
||||
mailService.sendMail("amministrazione@integry.it", null, subject, message);
|
||||
}
|
||||
|
||||
}
|
||||
private boolean sendEmail() throws Exception {
|
||||
if (UtilityDebug.isDebugExecution()) return false;
|
||||
|
||||
return setupGest.getSetupBoolean(multiDBTransactionManager.getPrimaryConnection(), "TASK", "AGENDA", "SEND_EMAIL");
|
||||
}
|
||||
|
||||
public boolean isGiornoLavorativo(LocalDate data) throws Exception {
|
||||
String sql = Query.format(
|
||||
"SELECT CAST(COUNT(*) AS BIT)\n" +
|
||||
"FROM jtb_ricorrenze\n" +
|
||||
"WHERE data = %s",
|
||||
UtilityLocalDate.formatDate(data, CommonConstants.DATE_FORMAT_YMD)
|
||||
);
|
||||
boolean isFestivo = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
DayOfWeek giornoDellaSettimana = data.getDayOfWeek();
|
||||
|
||||
return giornoDellaSettimana != DayOfWeek.SATURDAY &&
|
||||
giornoDellaSettimana != DayOfWeek.SUNDAY && !isFestivo;
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class DocumentiExporter extends BaseEntityExporter implements IEntityExpo
|
||||
break;
|
||||
case INTESA:
|
||||
DocumentiIntesaExportService intesaExportService = context.getBean(DocumentiIntesaExportService.class);
|
||||
entityExportResponse = intesaExportService.export(whereCond, type, format, anomalie);
|
||||
entityExportResponse = intesaExportService.export(whereCond, type, format);
|
||||
break;
|
||||
case EXCEL:
|
||||
case CSV:
|
||||
|
||||
@@ -40,11 +40,9 @@ public class DocumentiIntesaExportService {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
public EntityExportResponse<List<FileItem>> export(String whereCond, String type, String format, List<AnomalieDTO> anomalie) throws Exception {
|
||||
public EntityExportResponse<List<FileItem>> export(String whereCond, String type, String format) throws Exception {
|
||||
Connection conn = multiDBTransactionManager.getPrimaryConnection();
|
||||
|
||||
EntityExportResponse<List<FileItem>> entityExportResponse = new EntityExportResponse<>();
|
||||
entityExportResponse.setAnomalie(anomalie);
|
||||
|
||||
char charSeparator = ';';
|
||||
String fileName = "index";
|
||||
@@ -88,7 +86,8 @@ public class DocumentiIntesaExportService {
|
||||
" NULL AS agente,\n" +
|
||||
" IIF(doc.cod_vdes IS NOT NULL, vtb_dest.indirizzo, gtb_anag.indirizzo) AS destinazione,\n" +
|
||||
" doc.cod_vvet AS consegnatario,\n" +
|
||||
" NULL AS tipo_documento\n" +
|
||||
" NULL AS tipo_documento,\n" +
|
||||
" doc.ser_doc AS serie\n" +
|
||||
"FROM dtb_doct doc\n" +
|
||||
" INNER JOIN dtb_tipi ON doc.cod_dtip = dtb_tipi.cod_dtip\n" +
|
||||
" INNER JOIN gtb_anag ON doc.cod_anag = gtb_anag.cod_anag\n" +
|
||||
@@ -166,12 +165,7 @@ public class DocumentiIntesaExportService {
|
||||
|
||||
entityProcessor.processEntityList(dtbDocPdfList, true);
|
||||
|
||||
if (logger.isInfoEnabled() && dtbDocPdfList.isEmpty()) {
|
||||
String anomalia = "Nessun file firmato inviato";
|
||||
logger.error(anomalia);
|
||||
anomalie.add(AnomalieDTO.warning(anomalia));
|
||||
return entityExportResponse;
|
||||
}
|
||||
if (logger.isInfoEnabled() && dtbDocPdfList.isEmpty()) throw new Exception("Nessun file firmato inviato");
|
||||
|
||||
List<FileItem> listFileToZip = new ArrayList<>();
|
||||
listFileToZip.add(indexFile);
|
||||
|
||||
@@ -354,6 +354,13 @@ public class SystemController {
|
||||
return ServiceRestResponse.createPositiveResponse(systemService.getGestSetupList(stbGestSetupList, requestDataDTO.getUsername(), codMdep));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "updateGestSetup", method = RequestMethod.POST)
|
||||
public ServiceRestResponse updateGestSetup(@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestParam(required = false) String username,
|
||||
@RequestBody StbGestSetup stbGestSetup) throws Exception {
|
||||
return ServiceRestResponse.createPositiveResponse(systemService.updateGestSetup(stbGestSetup, username));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@RequestMapping(value = EmsRestConstants.PATH_SEND_MAIL, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
@@ -554,16 +561,16 @@ public class SystemController {
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_USERS, method = RequestMethod.GET)
|
||||
public ServiceRestResponse getUsers(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
public ServiceRestResponse getUsers(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam(value = "username", required = false) String userName) throws Exception {
|
||||
|
||||
try {
|
||||
return ServiceRestResponse.createPositiveResponse(systemService.getUsers(userName));
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
return ServiceRestResponse.createNegativeResponse(e);
|
||||
}
|
||||
return ServiceRestResponse.createPositiveResponse(systemService.getUsers(userName));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "getForzaLavoro", method = RequestMethod.GET)
|
||||
public ServiceRestResponse getForzaLavoro(@RequestParam(CommonConstants.PROFILE_DB) String config) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(systemService.getForzaLavoro());
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_ATTACH_FILE_ACTIVITY, method = RequestMethod.POST)
|
||||
|
||||
@@ -456,7 +456,6 @@ public class SystemService {
|
||||
}
|
||||
|
||||
public List<UserDTO> getUsers(String userName) throws Exception {
|
||||
|
||||
String sql = "SELECT DISTINCT jrl_flav_users.user_name, stb_user.full_name, stb_user.e_mail, stb_user.key_group\n" +
|
||||
"FROM jrl_flav_users\n" +
|
||||
" INNER JOIN stb_user ON stb_user.user_name = jrl_flav_users.user_name\n" +
|
||||
@@ -467,6 +466,13 @@ public class SystemService {
|
||||
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, UserDTO.class);
|
||||
}
|
||||
|
||||
public List<JtbFlav> getForzaLavoro() throws Exception {
|
||||
String sql = "SELECT *\n" +
|
||||
"FROM jtb_flav\n" +
|
||||
"WHERE data_fine_lavoro IS NULL";
|
||||
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, JtbFlav.class);
|
||||
}
|
||||
|
||||
public ServiceRestResponse getActivityProcessTree(String activityParent, String codJcom, String userName, String dataInizio, String dataFine) throws Exception {
|
||||
String whereCond = "";
|
||||
|
||||
@@ -669,6 +675,22 @@ public class SystemService {
|
||||
return setupList;
|
||||
}
|
||||
|
||||
public EntityBase updateGestSetup(StbGestSetup stbGestSetup, String username) throws Exception {
|
||||
if (username != null){
|
||||
WtbGestSetupUser wtbGestSetupUser = new WtbGestSetupUser();
|
||||
wtbGestSetupUser.setGestName(stbGestSetup.getGestName());
|
||||
wtbGestSetupUser.setKeySection(stbGestSetup.getKeySection());
|
||||
wtbGestSetupUser.setSection(stbGestSetup.getSection());
|
||||
wtbGestSetupUser.setValue(stbGestSetup.getValue());
|
||||
wtbGestSetupUser.setUserName(username);
|
||||
wtbGestSetupUser.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
return entityProcessor.processEntity(wtbGestSetupUser, multiDBTransactionManager);
|
||||
}
|
||||
|
||||
stbGestSetup.setOperation(OperationType.UPDATE);
|
||||
return entityProcessor.processEntity(stbGestSetup, multiDBTransactionManager);
|
||||
}
|
||||
|
||||
public void migrateStbFilesAttachedContentsToObjectStorage() throws Exception {
|
||||
int cores = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
Reference in New Issue
Block a user