migration per disattivare setup attivata erroneamente

This commit is contained in:
2024-09-17 17:33:47 +02:00
parent 3ea63962a2
commit 9df7e2ad73
4 changed files with 185 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.IntegryCustomer;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20240917172212 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
if (isCustomer(IntegryCustomer.Carelli)) return;
updateSetupValue("IMPORT_RAPPORTINI FG", "MMPOS", "ATTIVO", "N");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,63 @@
package it.integry.ems.contabil.Import;
import it.integry.ems.Import.base.BaseEntityImporter;
import it.integry.ems.Import.base.IEntityImporter;
import it.integry.ems.contabil.Import.service.ContabilImportService;
import it.integry.ems_model.base.EntityBase;
import java.util.List;
public class ContabilImporter extends BaseEntityImporter<List<EntityBase>> implements IEntityImporter<List<EntityBase>> {
@Override
public List<EntityBase> doImport() throws Exception {
Format enumFormat = Format.fromString(super.format);
List<EntityBase> entities;
ContabilImportService contabilImportService = getContextBean(ContabilImportService.class);
if (enumFormat != null) {
switch (enumFormat) {
case INFRAGRUPPO:
entities = contabilImportService.importMovIngragruppo(type, format, requestDto.getWhereCond());
break;
case PAGHE_TEAMSYSTEM:
entities = contabilImportService.importMovPagheTeams(type, format, requestDto.getRawContent(), anomalie);
break;
case SINFOONESCADENZE:
entities = contabilImportService.importPartiteScadSinfoOne(type, format, requestDto, anomalie);
break;
default:
throw new Exception("Tipo " + format + " non supportato");
}
} else {
throw new Exception("Tipo " + format + " non definito");
}
return entities;
}
public enum Format {
INFRAGRUPPO("INFRAGRUPPO"),
PAGHE_TEAMSYSTEM("PAGHE_TEAMSYSTEM"),
SINFOONESCADENZE("SINFO_ONE_SCADENZE");
private String text;
Format(String text) {
this.text = text;
}
public static Format fromString(String text) {
for (Format b : Format.values()) {
if (b.text.equalsIgnoreCase(text)) return b;
}
return null;
}
public String getText() {
return this.text;
}
}
}

View File

@@ -0,0 +1,26 @@
package it.integry.ems.contabil.context;
import it.integry.annotations.PostContextConstruct;
import it.integry.ems.Import.base.EntityImporterUtility;
import it.integry.ems.Import.enums.EntityImportType;
import it.integry.ems.contabil.Import.ContabilImporter;
import it.integry.ems.contabil.export.ContabilExporter;
import it.integry.ems.export.base.EntityExporterUtility;
import it.integry.ems.export.enums.EntityExportType;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Component;
@Component
public class EmsContabilContext {
private final Logger logger = LogManager.getLogger();
@PostContextConstruct
public void init() {
logger.debug("Init");
EntityExporterUtility.addTypeBinding(EntityExportType.MOVIMENTI_CONTABILI, ContabilExporter.class);
EntityImporterUtility.addTypeBinding(EntityImportType.MOVIMENTI_CONTABILI, ContabilImporter.class);
}
}

View File

@@ -0,0 +1,72 @@
package it.integry.ems.contabil.export;
import com.fasterxml.jackson.databind.ObjectMapper;
import it.integry.ems.contabil.export.services.MovimentiContabiliExporterService;
import it.integry.ems.contabil.fatture.base.enums.InvoiceType;
import it.integry.ems.contabil.fatture.rest.ExportFattureRequest;
import it.integry.ems.contabil.fatture.services.InvoiceService;
import it.integry.ems.export.base.BaseEntityExporter;
import it.integry.ems.export.base.EntityExportResponse;
import it.integry.ems.export.base.IEntityExporter;
import org.springframework.web.context.ContextLoader;
public class ContabilExporter extends BaseEntityExporter implements IEntityExporter {
@Override
public EntityExportResponse doExport() throws Exception {
ContabilExportFormat format = ContabilExportFormat.fromString(super.format);
EntityExportResponse entityExportResponse = null;
ExportFattureRequest exportFattureRequest;
ObjectMapper mapper = new ObjectMapper();
InvoiceService invoiceService = ContextLoader.getCurrentWebApplicationContext().getBean(InvoiceService.class);
MovimentiContabiliExporterService movimentiContabiliService = ContextLoader.getCurrentWebApplicationContext().getBean(MovimentiContabiliExporterService.class);
if (format != null) {
switch (format) {
case SP_FATTURE:
exportFattureRequest = mapper.treeToValue(super.jsonBody, ExportFattureRequest.class);
entityExportResponse = invoiceService.exportFattureXml(super.setupGest, exportFattureRequest, InvoiceType.FATTURE_VENDITA);
break;
case SP_PRIMA_NOTA:
exportFattureRequest = mapper.treeToValue(super.jsonBody, ExportFattureRequest.class);
entityExportResponse = invoiceService.exportFattureXml(super.setupGest, exportFattureRequest, InvoiceType.PRIMA_NOTA);
break;
case MAGIX:
entityExportResponse = movimentiContabiliService.exportMagix(super.setupGest, type, super.format, whereCond);
break;
case ZUCCHETTI:
entityExportResponse = movimentiContabiliService.exportZucchetti(super.setupGest, super.type, super.format, super.whereCond);
break;
}
}
return entityExportResponse;
}
public enum ContabilExportFormat {
SP_FATTURE("SP_FATTURE"),
SP_PRIMA_NOTA("SP_PRIMA_NOTA"),
MAGIX("MAGIX"),
ZUCCHETTI("ZUCCHETTI");
private String text;
ContabilExportFormat(String text) {
this.text = text;
}
public static ContabilExportFormat fromString(String text) {
for (ContabilExportFormat b : ContabilExportFormat.values()) {
if (b.text.equalsIgnoreCase(text)) return b;
}
return null;
}
public String getText() {
return this.text;
}
}
}