Merge branch 'refs/heads/develop' into feature/RefactoringGestioneColli
This commit is contained in:
@@ -549,10 +549,32 @@ public class EmsController {
|
||||
@RequestBody(required = false) JsonNode body) throws Exception {
|
||||
|
||||
EntityExportResponse<?> entityExportResponse = emsServices.export(typeExport, formatExport, body, headless);
|
||||
List<MessageDTO> messages = new ArrayList<>();
|
||||
|
||||
if (entityExportResponse.getAnomalie() != null && !entityExportResponse.getAnomalie().isEmpty()) {
|
||||
messages = entityExportResponse.getAnomalie().stream()
|
||||
.filter(x -> x.getTipo() != null)
|
||||
.map(x -> {
|
||||
switch (x.getTipo()) {
|
||||
case ERROR:
|
||||
return MessageDTO.error(x.getMessage());
|
||||
case WARNING:
|
||||
default:
|
||||
return MessageDTO.warning(x.getMessage());
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
ServiceRestResponse sr;
|
||||
if (!messages.isEmpty() && messages.stream().anyMatch(x->x.getLevel()==(MessageDTO.Level.ERROR))) {
|
||||
sr = ServiceRestResponse.createNegativeResponse();
|
||||
} else {
|
||||
sr = ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
sr.setMessages(messages);
|
||||
|
||||
ServiceRestResponse sr = ServiceRestResponse.createPositiveResponse();
|
||||
if (entityExportResponse != null) {
|
||||
|
||||
if (binaryDownload) {
|
||||
List<DownloadFileDto> downloadableFileList = new ArrayList<>();
|
||||
for (EntityExportedFile exportedFile : (List<EntityExportedFile>) entityExportResponse.getResponse()) {
|
||||
|
||||
@@ -19,7 +19,8 @@ public enum EntityExportType {
|
||||
LISTINI_ACQUISTO("LISTINI ACQUISTO"),
|
||||
LISTINI_VENDITA("LISTINI VENDITA"),
|
||||
COLLI("COLLI"),
|
||||
SCADENZE("SCADENZE");
|
||||
SCADENZE("SCADENZE"),
|
||||
SCONTRINI("SCONTRINI");
|
||||
|
||||
private String text;
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ public class CsvMapper<T> {
|
||||
List<Field> declaredFields = Arrays.asList(dtoList.get(0).getClass().getDeclaredFields());
|
||||
|
||||
List<Field> sortedFields = Stream.of(declaredFields)
|
||||
.filter(x -> x.getAnnotation(DtoField.class) != null && x.getAnnotation(DtoField.class).startPosition() >= 0)
|
||||
.filter(x -> x.getAnnotation(DtoField.class) != null &&
|
||||
x.getAnnotation(DtoField.class).startPosition() >= 0)
|
||||
.sortBy(x -> x.getAnnotation(DtoField.class).startPosition())
|
||||
.toList();
|
||||
|
||||
@@ -39,7 +40,7 @@ public class CsvMapper<T> {
|
||||
String header = StringUtils.join(Stream
|
||||
.of(sortedFields).map(
|
||||
x -> x.getName()
|
||||
).toList(), CommonConstants.TAB);
|
||||
).toList(), splitChar);
|
||||
|
||||
return serialize(dtoList, splitChar, header, hasHeader);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class LicenseController {
|
||||
|
||||
@RequestMapping(value = "", method = RequestMethod.GET)
|
||||
public @ResponseBody ServiceRestResponse retrieve(@RequestParam(CommonConstants.PROFILE_DB) String profile) {
|
||||
LicenseStatusDTO licenseStatusDTO = licenseComponent.getLicenseStatus(profile);
|
||||
LicenseStatusDTO licenseStatusDTO = licenseComponent.getLicenseStatus(profile.toUpperCase());
|
||||
|
||||
if(licenseStatusDTO == null) return ServiceRestResponse.createPositiveResponse();
|
||||
return ServiceRestResponse.createPositiveResponse(licenseStatusDTO);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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_20250404145055 extends BaseMigration implements MigrationModelInterface {
|
||||
@@ -10,6 +11,9 @@ public class Migration_20250404145055 extends BaseMigration implements Migration
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if(isCustomer(IntegryCustomer.DMS))
|
||||
return;
|
||||
|
||||
createOrUpdateView(
|
||||
"olvw_fabbisogni_sfusi",
|
||||
"CREATE VIEW dbo.olvw_fabbisogni_sfusi AS\n" +
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250407083930 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetup("EXPORT_SCONTRINI", "ZUCCHETTI", "ATTIVO", "N",
|
||||
"Inserire S/N per attivare/disattivare il tipo di importazione", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("EXPORT_SCONTRINI", "ZUCCHETTI", "EMAIL_FOR_LOG", null,
|
||||
"Inserire il file l'indirizzo email per inviare il log dell'importazione", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("EXPORT_SCONTRINI", "ZUCCHETTI", "GG_CANC_FILE", null,
|
||||
"Giorni per la cancellazione dei file dalla cartella di appoggio", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("EXPORT_SCONTRINI", "ZUCCHETTI", "IMPORT_REST", "S",
|
||||
"Inserire S/N per attivare/disattivare il salvataggio con i servizi REST", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("EXPORT_SCONTRINI", "ZUCCHETTI", "PATH_FILE", null,
|
||||
"Directory dove vengono salvati i file temporanei, se non è configurata i file saranno salvati in c:\\mlSetupWS\\TEMP_EXPORT", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("EXPORT_SCONTRINI", "ZUCCHETTI", "INTERCODE_REPARTO", null,
|
||||
"codice identificativo del reparto", true, null, true, false,
|
||||
false, false, false, "mtb_grup", false, null);
|
||||
createSetup("EXPORT_SCONTRINI", "ZUCCHETTI", "INTERCODE_AZIENDA", null,
|
||||
"codice identificativo dell'azienda", false, null, true, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("EXPORT_SCONTRINI", "ZUCCHETTI", "INTERCODE_PV", null,
|
||||
"codice identificativo del punto vendita", true, null, true, true,
|
||||
false, false, false, null, false, null);
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Carelli_GestFood) || isCustomerDb(IntegryCustomerDB.Carelli_Carelli)){
|
||||
updateSetupValue("EXPORT_SCONTRINI", "ZUCCHETTI", "ATTIVO", "S");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250407084809 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createSetup("EXPORT_SCONTRINI", "ZUCCHETTI", "ATTRIBUTO_FATTURATO", null,
|
||||
"codice identificativo del reparto", true, null, true, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("EXPORT_SCONTRINI", "ZUCCHETTI", "ATTRIBUTO_SCONTRINI", null,
|
||||
"codice identificativo dell'azienda", false, null, true, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("EXPORT_SCONTRINI", "ZUCCHETTI", "ATTRIBUTO_BATTUTE", null,
|
||||
"codice identificativo del punto vendita", true, null, true, false,
|
||||
false, false, false, null, false, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250407154810 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createOrUpdateTrigger("t_UpdProgPart", "CREATE TRIGGER [dbo].[t_UpdProgPart] ON [dbo].[ctb_parr] AFTER INSERT,UPDATE, DELETE\n" +
|
||||
"AS \n" +
|
||||
"BEGIN\t\n" +
|
||||
"\tIF EXISTS (SELECT * FROM deleted)\n" +
|
||||
"\tBEGIN\n" +
|
||||
"\t\t--storno progressivi\n" +
|
||||
"\t\tupdate ctb_part\n" +
|
||||
"\t\t set ctb_part.dare_part = ctb_part.dare_part - tmp.dare_part,\n" +
|
||||
"\t\t\t ctb_part.avere_part = ctb_part.avere_part - tmp.avere_part\n" +
|
||||
"\t\t from ctb_part,\n" +
|
||||
"\t\t\t ( select deleted.tipo_anag, \n" +
|
||||
"\t\t\t\t\t\tdeleted.cod_anag, \n" +
|
||||
"\t\t\t\t\t\tdeleted.anno_part, \n" +
|
||||
"\t\t\t\t\t\tdeleted.ser_doc, \n" +
|
||||
"\t\t\t\t\t\tdeleted.num_doc,\n" +
|
||||
"\t\t\t\t\t\t(round(SUM((deleted.imp_dare/deleted.cambio_divi_cont) * ctb_part.cambio_divi_cont),gtb_divi.cifre_dec)) as dare_part,\n" +
|
||||
"\t\t\t\t\t\t(round(SUM((deleted.imp_avere/deleted.cambio_divi_cont) * ctb_part.cambio_divi_cont),gtb_divi.cifre_dec)) as avere_part\n" +
|
||||
"\t\t\t\t FROM deleted, ctb_part, gtb_divi\n" +
|
||||
"\t\t\t\t where ctb_part.tipo_anag = deleted.tipo_anag AND\n" +
|
||||
"\t\t\t\t\t\tctb_part.cod_anag = deleted.cod_anag AND\n" +
|
||||
"\t\t\t\t\t\tctb_part.anno_part = deleted.anno_part AND\n" +
|
||||
"\t\t\t\t\t\tctb_part.ser_doc = deleted.ser_doc AND\n" +
|
||||
"\t\t\t\t\t\tctb_part.num_doc = deleted.num_doc and\n" +
|
||||
"\t\t\t\t\t\tctb_part.cod_divi_cont = gtb_divi.cod_divi\n" +
|
||||
"\t\t\t\tGROUP BY deleted.tipo_anag, \n" +
|
||||
"\t\t\t\t\t\tdeleted.cod_anag, \n" +
|
||||
"\t\t\t\t\t\tdeleted.anno_part, \n" +
|
||||
"\t\t\t\t\t\tdeleted.ser_doc, \n" +
|
||||
"\t\t\t\t\t\tdeleted.num_doc,\n" +
|
||||
"\t\t\t\t\t\tgtb_divi.cifre_dec) tmp\n" +
|
||||
"\t where ctb_part.tipo_anag = tmp.tipo_anag AND\n" +
|
||||
"\t\t\t ctb_part.cod_anag = tmp.cod_anag AND\n" +
|
||||
"\t\t\t ctb_part.anno_part = tmp.anno_part AND\n" +
|
||||
"\t\t\t ctb_part.ser_doc = tmp.ser_doc AND\n" +
|
||||
"\t\t\t ctb_part.num_doc = tmp.num_doc \n" +
|
||||
"\tEND\n" +
|
||||
"\t\t\n" +
|
||||
"\tIF EXISTS (SELECT * FROM inserted)\n" +
|
||||
"\tBEGIN\t\t\n" +
|
||||
"\t\tupdate ctb_part\n" +
|
||||
"\t\t set ctb_part.dare_part = ctb_part.dare_part + tmp.dare_part,\n" +
|
||||
"\t\t\t ctb_part.avere_part = ctb_part.avere_part + tmp.avere_part\n" +
|
||||
"\t\t from ctb_part,\n" +
|
||||
"\t\t\t ( select inserted.tipo_anag, \n" +
|
||||
"\t\t\t\t\t\tinserted.cod_anag, \n" +
|
||||
"\t\t\t\t\t\tinserted.anno_part, \n" +
|
||||
"\t\t\t\t\t\tinserted.ser_doc, \n" +
|
||||
"\t\t\t\t\t\tinserted.num_doc,\n" +
|
||||
"\t\t\t\t\t\t(round(SUM((inserted.imp_dare/inserted.cambio_divi_cont) * ctb_part.cambio_divi_cont),gtb_divi.cifre_dec)) as dare_part,\n" +
|
||||
"\t\t\t\t\t\t(round(SUM((inserted.imp_avere/inserted.cambio_divi_cont) * ctb_part.cambio_divi_cont),gtb_divi.cifre_dec)) as avere_part\n" +
|
||||
"\t\t\t\t FROM inserted, ctb_part, gtb_divi\n" +
|
||||
"\t\t\t\t where ctb_part.tipo_anag = inserted.tipo_anag AND\n" +
|
||||
"\t\t\t\t\t\tctb_part.cod_anag = inserted.cod_anag AND\n" +
|
||||
"\t\t\t\t\t\tctb_part.anno_part = inserted.anno_part AND\n" +
|
||||
"\t\t\t\t\t\tctb_part.ser_doc = inserted.ser_doc AND\n" +
|
||||
"\t\t\t\t\t\tctb_part.num_doc = inserted.num_doc and\n" +
|
||||
"\t\t\t\t\t\tctb_part.cod_divi_cont = gtb_divi.cod_divi\n" +
|
||||
"\t\t\t\t\tGROUP BY inserted.tipo_anag, \n" +
|
||||
"\t\t\t\t\t\tinserted.cod_anag, \n" +
|
||||
"\t\t\t\t\t\tinserted.anno_part, \n" +
|
||||
"\t\t\t\t\t\tinserted.ser_doc, \n" +
|
||||
"\t\t\t\t\t\tinserted.num_doc,\n" +
|
||||
"\t\t\t\t\t\tgtb_divi.cifre_dec) tmp\n" +
|
||||
"\t where ctb_part.tipo_anag = tmp.tipo_anag AND\n" +
|
||||
"\t\t\t ctb_part.cod_anag = tmp.cod_anag AND\n" +
|
||||
"\t\t\t ctb_part.anno_part = tmp.anno_part AND\n" +
|
||||
"\t\t\t ctb_part.ser_doc = tmp.ser_doc AND\n" +
|
||||
"\t\t\t ctb_part.num_doc = tmp.num_doc \n" +
|
||||
"\n" +
|
||||
"\tEND\t\n" +
|
||||
"END");
|
||||
createOrUpdateTrigger("t_UpdProgScad", "CREATE TRIGGER [dbo].[t_UpdProgScad] ON [dbo].[ctb_scad] AFTER INSERT,UPDATE, DELETE\n" +
|
||||
"AS \n" +
|
||||
"\tBEGIN\n" +
|
||||
"\n" +
|
||||
"\t\t--AGGIORNA SALDO SCADENZE\n" +
|
||||
"\t\tupdate ctb_part\n" +
|
||||
"\t\t set ctb_part.dare_scad = scadenze.imp_dare,\n" +
|
||||
"\t\t\t ctb_part.avere_scad = scadenze.imp_avere\n" +
|
||||
"\t\t from ctb_part, \n" +
|
||||
"\t\t\t (select tmp.tipo_anag, \n" +
|
||||
"\t\t\t\t\t tmp.cod_anag, \n" +
|
||||
"\t\t\t\t\t tmp.anno_part, \n" +
|
||||
"\t\t\t\t\t tmp.ser_doc, \n" +
|
||||
"\t\t\t\t\t tmp.num_doc ,\n" +
|
||||
"\t\t\t\t\t sum(ctb_scad.imp_dare) as imp_dare, \n" +
|
||||
"\t\t\t\t\t sum(ctb_scad.imp_avere)\tas imp_avere \n" +
|
||||
"\t\t\t\t from ctb_scad, \n" +
|
||||
"\t\t\t\t\t ( SELECT tipo_anag,\n" +
|
||||
"\t\t\t\t\t\t\t cod_anag,\n" +
|
||||
"\t\t\t\t\t\t\t anno_part,\n" +
|
||||
"\t\t\t\t\t\t\t ser_doc,\n" +
|
||||
"\t\t\t\t\t\t\t num_doc\n" +
|
||||
"\t\t\t\t\t\tfrom inserted \n" +
|
||||
"\t\t\t\t\t\tunion \n" +
|
||||
"\t\t\t\t\t\tSELECT tipo_anag,\n" +
|
||||
"\t\t\t\t\t\t\t cod_anag,\n" +
|
||||
"\t\t\t\t\t\t\t anno_part,\n" +
|
||||
"\t\t\t\t\t\t\t ser_doc,\n" +
|
||||
"\t\t\t\t\t\t\t num_doc\n" +
|
||||
"\t\t\t\t\t\tfrom deleted ) tmp\n" +
|
||||
"\t where ctb_scad.tipo_anag = tmp.tipo_anag AND\n" +
|
||||
"\t\t\t ctb_scad.cod_anag = tmp.cod_anag AND\n" +
|
||||
"\t\t\t ctb_scad.anno_part = tmp.anno_part AND\n" +
|
||||
"\t\t\t ctb_scad.ser_doc = tmp.ser_doc AND\n" +
|
||||
"\t\t\t ctb_scad.num_doc = tmp.num_doc \n" +
|
||||
"\t group by tmp.tipo_anag, \n" +
|
||||
"\t\t\t\t\t tmp.cod_anag, \n" +
|
||||
"\t\t\t\t\t tmp.anno_part, \n" +
|
||||
"\t\t\t\t\t tmp.ser_doc, \n" +
|
||||
"\t\t\t\t\t tmp.num_doc ) scadenze\n" +
|
||||
"\t where ctb_part.tipo_anag = scadenze.tipo_anag AND\n" +
|
||||
"\t\t\t ctb_part.cod_anag = scadenze.cod_anag AND\n" +
|
||||
"\t\t\t ctb_part.anno_part = scadenze.anno_part AND\n" +
|
||||
"\t\t\t ctb_part.ser_doc = scadenze.ser_doc AND\n" +
|
||||
"\t\t\t ctb_part.num_doc = scadenze.num_doc ;\t\t\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"\t\tIF EXISTS (SELECT * FROM deleted)\n" +
|
||||
"\t\tBEGIN\n" +
|
||||
"\t\tupdate ctb_titoli\n" +
|
||||
"\t\t set ctb_titoli.importo_evaso = ctb_titoli.importo_evaso - tmp.importo\n" +
|
||||
"\t\t from ctb_titoli,\t\t\t \n" +
|
||||
"\t\t\t ( select deleted.cod_anag, \n" +
|
||||
"\t\t\t\t\t\tdeleted.id_titolo,\n" +
|
||||
"\t\t\t\t\t\tSUM(case ctb_part.tipo_partita when 1 then deleted.imp_dare when 0 then-deleted.imp_avere end) as importo\n" +
|
||||
"\t\t\t\t FROM deleted, ctb_part\n" +
|
||||
"\t\t\t\t WHERE deleted.id_titolo is not null and\n" +
|
||||
"\t\t\t\t\t\tctb_part.tipo_anag = deleted.tipo_anag and \n" +
|
||||
"\t\t\t\t\t\tctb_part.cod_anag = deleted.cod_anag and \n" +
|
||||
"\t\t\t\t\t\tctb_part.anno_part = deleted.anno_part and \n" +
|
||||
"\t\t\t\t\t\tctb_part.ser_doc = deleted.ser_doc and \n" +
|
||||
"\t\t\t\t\t\tctb_part.num_doc = deleted.num_doc\n" +
|
||||
"\t\t\t group by deleted.cod_anag, \n" +
|
||||
"\t\t\t\t\t\tdeleted.id_titolo ) tmp\t\t\n" +
|
||||
"\t where ctb_titoli.cod_anag = tmp.cod_anag AND\n" +
|
||||
"\t\t\t ctb_titoli.id_titolo = tmp.id_titolo\n" +
|
||||
"\tEND\n" +
|
||||
"\t\t\n" +
|
||||
"\tIF EXISTS (SELECT * FROM inserted)\n" +
|
||||
"\tBEGIN\n" +
|
||||
"\t\tupdate ctb_titoli\n" +
|
||||
"\t\t set ctb_titoli.importo_evaso = ctb_titoli.importo_evaso + tmp.importo\n" +
|
||||
"\t\t from ctb_titoli,\t\t\t \n" +
|
||||
"\t\t\t ( select inserted.cod_anag, \n" +
|
||||
"\t\t\t\t\t\tinserted.id_titolo,\n" +
|
||||
"\t\t\t\t\t\tSUM(case ctb_part.tipo_partita when 1 then inserted.imp_dare when 0 then-inserted.imp_avere end) as importo\n" +
|
||||
"\t\t\t\t FROM inserted, ctb_part\n" +
|
||||
"\t\t\t\t WHERE inserted.id_titolo is not null and\n" +
|
||||
"\t\t\t\t\t\tctb_part.tipo_anag = inserted.tipo_anag and \n" +
|
||||
"\t\t\t\t\t\tctb_part.cod_anag = inserted.cod_anag and \n" +
|
||||
"\t\t\t\t\t\tctb_part.anno_part = inserted.anno_part and \n" +
|
||||
"\t\t\t\t\t\tctb_part.ser_doc = inserted.ser_doc and \n" +
|
||||
"\t\t\t\t\t\tctb_part.num_doc = inserted.num_doc\n" +
|
||||
"\t\t\t group by inserted.cod_anag, \n" +
|
||||
"\t\t\t\t\t\tinserted.id_titolo ) tmp\t\t\n" +
|
||||
"\t where ctb_titoli.cod_anag = tmp.cod_anag AND\n" +
|
||||
"\t\t\t ctb_titoli.id_titolo = tmp.id_titolo\n" +
|
||||
"\tEND\n" +
|
||||
"END");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import it.integry.ems.export.base.EntityExporterUtility;
|
||||
import it.integry.ems.export.enums.EntityExportType;
|
||||
import it.integry.ems.retail.Import.RapportiniFgImporter;
|
||||
import it.integry.ems.retail.Import.ScontriniImporter;
|
||||
import it.integry.ems.retail.export.ScontriniExporter;
|
||||
import it.integry.ems.retail.export.VariazioniExporter;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -23,6 +24,7 @@ public class EmsRetailContext {
|
||||
logger.debug("Init");
|
||||
|
||||
EntityExporterUtility.addTypeBinding(EntityExportType.VARIAZIONE_PV, VariazioniExporter.class);
|
||||
EntityExporterUtility.addTypeBinding(EntityExportType.SCONTRINI, ScontriniExporter.class);
|
||||
|
||||
EntityImporterUtility.addTypeBinding(EntityImportType.RAPPORTINI_FG, RapportiniFgImporter.class);
|
||||
EntityImporterUtility.addTypeBinding(EntityImportType.SCONTRINI, ScontriniImporter.class);
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
package it.integry.ems.retail.dto;
|
||||
|
||||
import it.integry.ems_model.annotation.DtoField;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class ZucchettiHrDTO {
|
||||
|
||||
@DtoField(maxLength = 3, startPosition = 1)
|
||||
private String tipoRecord = "F01";
|
||||
@DtoField(maxLength = 1, startPosition = 4)
|
||||
private String modalitaOperativa = "C";
|
||||
@DtoField(maxLength = 30, startPosition = 5)
|
||||
private String tabellaRiferimento = "DATI_EFFETTIVI";
|
||||
@DtoField(maxLength = 6, startPosition = 35)
|
||||
private String codiceAzienda;
|
||||
@DtoField(maxLength = 6, startPosition = 41)
|
||||
private String codiceReparto = "000000"; // 6 caratteri
|
||||
@DtoField(maxLength = 10, startPosition = 47)
|
||||
private String codiceFiliale;
|
||||
@DtoField(maxLength = 15, startPosition = 57)
|
||||
private String centroCosto = "000000000000000"; // 15 caratteri
|
||||
@DtoField(maxLength = 5, startPosition = 58)
|
||||
private String businessUnit = "00000"; // 5 caratteri
|
||||
@DtoField(maxLength = 6, startPosition = 64 )
|
||||
private String codiceUnitaLocale = "000000"; // 6 caratteri
|
||||
@DtoField(maxLength = 15, startPosition = 70)
|
||||
private String codiceInternalOrder = "000000000000000"; // 15 caratteri
|
||||
@DtoField(maxLength = 10, startPosition = 85)
|
||||
private String data;
|
||||
@DtoField(showFloatPoint = true, separator = ".", scale = 2, maxLength = 5, startPosition = 95)
|
||||
private BigDecimal orarioInizio;
|
||||
@DtoField(showFloatPoint = true, separator = ".", scale = 2, maxLength = 5, startPosition = 100)
|
||||
private BigDecimal orarioFine;
|
||||
@DtoField(maxLength = 10, startPosition = 105)
|
||||
private String codiceAttributo;
|
||||
@DtoField(showFloatPoint = true, separator = ".", scale = 2, maxLength = 16, startPosition = 115)
|
||||
private BigDecimal valore;
|
||||
|
||||
public String getTipoRecord() {
|
||||
return tipoRecord;
|
||||
}
|
||||
|
||||
public String getModalitaOperativa() {
|
||||
return modalitaOperativa;
|
||||
}
|
||||
|
||||
public String getTabellaRiferimento() {
|
||||
return tabellaRiferimento;
|
||||
}
|
||||
|
||||
public String getCodiceAzienda() {
|
||||
return codiceAzienda;
|
||||
}
|
||||
|
||||
public ZucchettiHrDTO setCodiceAzienda(String codiceAzienda) {
|
||||
this.codiceAzienda = codiceAzienda;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodiceReparto() {
|
||||
return codiceReparto;
|
||||
}
|
||||
|
||||
public ZucchettiHrDTO setCodiceReparto(String codiceReparto) {
|
||||
this.codiceReparto = codiceReparto;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodiceFiliale() {
|
||||
return codiceFiliale;
|
||||
}
|
||||
|
||||
public ZucchettiHrDTO setCodiceFiliale(String codiceFiliale) {
|
||||
this.codiceFiliale = codiceFiliale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCentroCosto() {
|
||||
return centroCosto;
|
||||
}
|
||||
|
||||
public ZucchettiHrDTO setCentroCosto(String centroCosto) {
|
||||
this.centroCosto = centroCosto;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBusinessUnit() {
|
||||
return businessUnit;
|
||||
}
|
||||
|
||||
public ZucchettiHrDTO setBusinessUnit(String businessUnit) {
|
||||
this.businessUnit = businessUnit;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodiceUnitaLocale() {
|
||||
return codiceUnitaLocale;
|
||||
}
|
||||
|
||||
public ZucchettiHrDTO setCodiceUnitaLocale(String codiceUnitaLocale) {
|
||||
this.codiceUnitaLocale = codiceUnitaLocale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodiceInternalOrder() {
|
||||
return codiceInternalOrder;
|
||||
}
|
||||
|
||||
public ZucchettiHrDTO setCodiceInternalOrder(String codiceInternalOrder) {
|
||||
this.codiceInternalOrder = codiceInternalOrder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public ZucchettiHrDTO setData(String data) {
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getOrarioInizio() {
|
||||
return orarioInizio;
|
||||
}
|
||||
|
||||
public ZucchettiHrDTO setOrarioInizio(BigDecimal orarioInizio) {
|
||||
this.orarioInizio = orarioInizio;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getOrarioFine() {
|
||||
return orarioFine;
|
||||
}
|
||||
|
||||
public ZucchettiHrDTO setOrarioFine(BigDecimal orarioFine) {
|
||||
this.orarioFine = orarioFine;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodiceAttributo() {
|
||||
return codiceAttributo;
|
||||
}
|
||||
|
||||
public ZucchettiHrDTO setCodiceAttributo(String codiceAttributo) {
|
||||
this.codiceAttributo = codiceAttributo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getValore() {
|
||||
return valore;
|
||||
}
|
||||
|
||||
public ZucchettiHrDTO setValore(BigDecimal valore) {
|
||||
this.valore = valore;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package it.integry.ems.retail.export;
|
||||
|
||||
import it.integry.ems.export.base.BaseEntityExporter;
|
||||
import it.integry.ems.export.base.EntityExportResponse;
|
||||
import it.integry.ems.export.base.IEntityExporter;
|
||||
import it.integry.ems.retail.export.service.ScontriniZucchettiExportServices;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
|
||||
public class ScontriniExporter extends BaseEntityExporter implements IEntityExporter {
|
||||
@Override
|
||||
public EntityExportResponse doExport() throws Exception {
|
||||
ScontriniExporter.Format currentFormatEnum = ScontriniExporter.Format.fromString(super.format);
|
||||
|
||||
EntityExportResponse entityExportResponse = null;
|
||||
|
||||
if (currentFormatEnum != null) {
|
||||
|
||||
switch (currentFormatEnum) {
|
||||
case ZUCCHETTI:
|
||||
ScontriniZucchettiExportServices scontriniExportServices = ContextLoader.getCurrentWebApplicationContext().getBean(ScontriniZucchettiExportServices.class);
|
||||
entityExportResponse = scontriniExportServices.exportZucchetti(type, format, whereCond, anomalie);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return entityExportResponse;
|
||||
|
||||
}
|
||||
|
||||
public enum Format {
|
||||
ZUCCHETTI("ZUCCHETTI");
|
||||
|
||||
private String text;
|
||||
|
||||
Format(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public static ScontriniExporter.Format fromString(String text) {
|
||||
for (ScontriniExporter.Format b : ScontriniExporter.Format.values()) {
|
||||
if (b.text.equalsIgnoreCase(text)) return b;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.text;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
package it.integry.ems.retail.export.service;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.Import.dto.AnomalieDTO;
|
||||
import it.integry.ems.export.base.EntityExportResponse;
|
||||
import it.integry.ems.file_formatter.csv.CsvMapper;
|
||||
import it.integry.ems.retail.dto.ZucchettiHrDTO;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Scope("request")
|
||||
public class ScontriniZucchettiExportServices {
|
||||
@Autowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
@Autowired
|
||||
private SetupGest setupGest;
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
public EntityExportResponse exportZucchetti(String type, String format, String whereCond, List<AnomalieDTO> anomalie) throws Exception {
|
||||
EntityExportResponse<List<File>> entityExportResponse = new EntityExportResponse<>();
|
||||
entityExportResponse.setResponse(new ArrayList<>());
|
||||
Map<String, String> exportSetupSection = setupGest.getExportSetupSection(multiDBTransactionManager.getPrimaryConnection(), type, format);
|
||||
|
||||
String intercodeAzienda = getSetupValue(type, format, exportSetupSection, "INTERCODE_AZIENDA");
|
||||
String attributoFatturato = getSetupValue(type, format, exportSetupSection, "ATTRIBUTO_FATTURATO");
|
||||
String attributoBattute = getSetupValue(type, format, exportSetupSection, "ATTRIBUTO_BATTUTE");
|
||||
String attributoScontrini = getSetupValue(type, format, exportSetupSection, "ATTRIBUTO_SCONTRINI");
|
||||
|
||||
String sql =
|
||||
Query.format(
|
||||
"SELECT cod_mdep,\n" +
|
||||
" value AS intercode\n" +
|
||||
"FROM stb_gest_setup_depo\n" +
|
||||
"WHERE gest_name = %s\n" +
|
||||
" AND section = %s\n" +
|
||||
" AND key_section = 'INTERCODE_PV'",
|
||||
"EXPORT_" + type, format);
|
||||
List<HashMap<String, Object>> setupDepo = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
sql = Query.format(
|
||||
"SELECT val_col_rif as cod_mgrp,\n" +
|
||||
" value AS intercode\n" +
|
||||
"FROM stb_gest_setup_det\n" +
|
||||
"WHERE gest_name = %s\n" +
|
||||
" AND section = %s\n" +
|
||||
" AND key_section = 'INTERCODE_REPARTO'\n" +
|
||||
" AND tipo_setup = 'mtb_grup' ",
|
||||
"EXPORT_" + type, format);
|
||||
List<HashMap<String, Object>> setupReparti = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
if (UtilityString.isNullOrEmpty(whereCond)) {
|
||||
whereCond = "ntb_doct.date_only_doc = " + UtilityDB.valueDateToString(new Date(), CommonConstants.DATE_FORMAT_YMD);
|
||||
}
|
||||
|
||||
sql =
|
||||
"SELECT ntb_doct.cod_mdep,\n" +
|
||||
" ntb_doct.date_only_doc AS data,\n" +
|
||||
" CONVERT(VARCHAR(5), MIN(ntb_doct.data_doc), 108) AS ora_iniz,\n" +
|
||||
" CONVERT(VARCHAR(5), MAX(ntb_doct.data_doc), 108) AS ora_fine,\n" +
|
||||
" mtb_aart.cod_mgrp,\n" +
|
||||
" CAST(\n" +
|
||||
" CAST(DATEDIFF(MINUTE, ntb_doct.date_only_doc, ntb_doct.data_doc) AS FLOAT) / 30 AS INT) AS gruppo_ore,\n" +
|
||||
" SUM(ntb_docr.qta_doc) AS qta,\n" +
|
||||
" SUM((ntb_docr.qta_doc * ntb_docr.prz_unt_iva) - ntb_docr.val_sco) AS valore,\n" +
|
||||
" COUNT(DISTINCT ntb_doct.id_scontr) AS count_scontrini,\n" +
|
||||
" COUNT(*) AS count_battute\n" +
|
||||
"FROM ntb_doct\n" +
|
||||
" INNER JOIN ntb_docr ON ntb_doct.cod_mdep = ntb_docr.cod_mdep\n" +
|
||||
" AND ntb_doct.cod_cassa = ntb_docr.cod_cassa\n" +
|
||||
" AND ntb_doct.data_doc = ntb_docr.data_doc\n" +
|
||||
" INNER JOIN mtb_aart ON ntb_docr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
"GROUP BY ntb_doct.cod_mdep, ntb_doct.date_only_doc,\n" +
|
||||
" CAST(\n" +
|
||||
" CAST(DATEDIFF(MINUTE, ntb_doct.date_only_doc, ntb_doct.data_doc) AS FLOAT) / 30 AS INT),\n" +
|
||||
" mtb_aart.cod_mgrp\n" +
|
||||
"ORDER BY ntb_doct.cod_mdep, ntb_doct.date_only_doc, 3";
|
||||
|
||||
sql = UtilityDB.addwhereCond(sql, whereCond, false );
|
||||
List<HashMap<String, Object>> scontrini = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
if ( scontrini == null || scontrini.isEmpty()) {
|
||||
logger.info("Nessun scontrino trovato ");
|
||||
}
|
||||
|
||||
//Verifica intercode depositi
|
||||
List<String> depositi = scontrini.stream().map(x -> ((String) x.get("cod_mdep"))).distinct().collect(Collectors.toList());
|
||||
|
||||
for (String codMdep : depositi) {
|
||||
getIntercodePV(setupDepo, codMdep, anomalie);
|
||||
}
|
||||
|
||||
//verifica intercode reparti
|
||||
List<String> reparti = scontrini.stream().map(x -> ((String) x.get("cod_mgrp"))).distinct().collect(Collectors.toList());
|
||||
for (String codMgrp : reparti) {
|
||||
getIntecodeReparti(setupReparti, codMgrp, anomalie);
|
||||
}
|
||||
|
||||
if ( !anomalie.isEmpty() && anomalie.stream().anyMatch(x->x.isError())) {
|
||||
return entityExportResponse;
|
||||
}
|
||||
List<ZucchettiHrDTO> dati = new ArrayList<>();
|
||||
for(HashMap<String, Object> row : scontrini) {
|
||||
String intercodePv = getIntercodePV(setupDepo, (String) row.get("cod_mdep"), anomalie);
|
||||
String intercodeReparto = getIntecodeReparti(setupReparti, (String) row.get("cod_mgrp"), anomalie);
|
||||
|
||||
BigDecimal oraInizio = new BigDecimal(row.get("ora_iniz").toString().replace(":", "."));
|
||||
BigDecimal oraFine = new BigDecimal(row.get("ora_fine").toString().replace(":", "."));
|
||||
for ( int i=1; i < 4; i++) {
|
||||
String attributo;
|
||||
BigDecimal valore;
|
||||
if ( i == 1) {
|
||||
attributo = attributoFatturato + intercodeReparto;
|
||||
valore = (BigDecimal) row.get("valore");
|
||||
} else if (i == 2) {
|
||||
attributo = attributoScontrini + intercodeReparto;
|
||||
valore = new BigDecimal((Integer) row.get("count_scontrini"));
|
||||
} else {
|
||||
attributo = attributoBattute + intercodeReparto;
|
||||
valore = new BigDecimal((Integer) row.get("count_scontrini"));
|
||||
}
|
||||
|
||||
ZucchettiHrDTO zucchettiHrDTO = new ZucchettiHrDTO()
|
||||
.setCodiceAzienda(intercodeAzienda)
|
||||
.setCodiceReparto(intercodeReparto)
|
||||
.setCodiceFiliale(intercodePv)
|
||||
.setData(new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY).format(row.get("data")))
|
||||
.setOrarioInizio(oraInizio)
|
||||
.setOrarioFine(oraFine)
|
||||
.setCodiceAttributo(attributo)
|
||||
.setValore(valore);
|
||||
dati.add(zucchettiHrDTO);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( !dati.isEmpty()) {
|
||||
String fileName = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".csv";
|
||||
File file = new File(fileName);
|
||||
|
||||
CsvMapper<ZucchettiHrDTO> mapper = new CsvMapper<>();
|
||||
String csv = mapper.serialize(dati, ";", false);
|
||||
FileUtils.writeStringToFile(file, csv);
|
||||
entityExportResponse.getResponse().add(file);
|
||||
}
|
||||
|
||||
return entityExportResponse;
|
||||
|
||||
}
|
||||
|
||||
private String getSetupValue(String type, String format, Map<String, String> exportSetupSection, String keySection) throws Exception {
|
||||
if (UtilityString.isNullOrEmpty(exportSetupSection.get(keySection))) {
|
||||
throw new Exception(String.format("Setup non configurata %S->%S->%S", type, format, keySection));
|
||||
} else {
|
||||
return exportSetupSection.get(keySection);
|
||||
}
|
||||
}
|
||||
|
||||
private String getIntercodePV(List<HashMap<String, Object>> setupDepo, String codMdep, List<AnomalieDTO> anomalie) throws Exception {
|
||||
String intercodePv = setupDepo.stream()
|
||||
.filter(x->((String) x.get("cod_mdep")).equalsIgnoreCase(codMdep)).findFirst().map(x->(String)x.get("intercode")).orElse(null);
|
||||
if ( intercodePv == null) {
|
||||
String errore = String.format("Intercode non trovato per il deposito %s", codMdep);
|
||||
logger.error(errore);
|
||||
anomalie.add(AnomalieDTO.error(errore));
|
||||
}
|
||||
return intercodePv;
|
||||
|
||||
}
|
||||
|
||||
private String getIntecodeReparti(List<HashMap<String, Object>> setupReparti, String codMgrp, List<AnomalieDTO> anomalie) throws Exception {
|
||||
String intercodeReparto = setupReparti.stream()
|
||||
.filter(x->((String) x.get("cod_mgrp")).equalsIgnoreCase(codMgrp)).findFirst().map(x->(String)x.get("intercode")).orElse(null);
|
||||
if ( intercodeReparto == null) {
|
||||
String errore = String.format("Intercode non trovato per il reparto %s", codMgrp);
|
||||
logger.error(errore);
|
||||
anomalie.add(AnomalieDTO.error(errore));
|
||||
}
|
||||
return intercodeReparto;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user