Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
2024-10-03 18:47:49 +02:00
27 changed files with 1181 additions and 151 deletions

View File

@@ -0,0 +1,16 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Tomcat 9 (RistoCash)" type="Remote">
<module name="ems-engine" />
<option name="USE_SOCKET_TRANSPORT" value="true" />
<option name="SERVER_MODE" value="false" />
<option name="SHMEM_ADDRESS" />
<option name="HOST" value="127.0.0.1" />
<option name="PORT" value="8001" />
<option name="AUTO_RESTART" value="false" />
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value="8001" />
<option name="LOCAL" value="false" />
</RunnerSettings>
<method v="2" />
</configuration>
</component>

View File

@@ -3,6 +3,7 @@ package it.integry.ems.dto;
import com.fasterxml.jackson.annotation.JsonValue;
import it.integry.ems.report.dto.JasperDTO;
import it.integry.ems_model.base.EntityBase;
import it.integry.ems_model.entity.DtbDocPdf;
import it.integry.ems_model.entity.MtbAartLink;
import it.integry.ems_model.entity.MtbUntMis;
import it.integry.ems_model.entity.StbActivityFile;
@@ -18,6 +19,8 @@ public class CreateZipDTO {
private List<MtbAartLink> listMtbAartLink;
private List<DtbDocPdf> listDtbDocPdf;
private String fileName;
private SaveMode saveMode = SaveMode.STB_FILES_ATTACHED;
@@ -51,6 +54,15 @@ public class CreateZipDTO {
return this;
}
public List<DtbDocPdf> getListDtbDocPdf() {
return listDtbDocPdf;
}
public CreateZipDTO setListDtbDocPdf(List<DtbDocPdf> listDtbDocPdf) {
this.listDtbDocPdf = listDtbDocPdf;
return this;
}
public String getFileName() {
return fileName;
}

View File

@@ -103,7 +103,7 @@ public class EntityDevelopmentService {
javaClass.addAndGetAnnotation(JsonTypeName.class)
.addPair("value", new FieldAccessExpr(new NameExpr(javaClassName), "ENTITY"));
final FieldDeclaration entityField = javaClass.addFieldWithInitializer(String.class, "ENTITY", new StringLiteralExpr(databaseTable.getTableName()), PRIVATE, FINAL, STATIC);
final FieldDeclaration entityField = javaClass.addFieldWithInitializer(String.class, "ENTITY", new StringLiteralExpr(databaseTable.getTableName()), PUBLIC, FINAL, STATIC);
final FieldDeclaration serialVersionUIDField = javaClass.addFieldWithInitializer(Long.class, "serialVersionUID", new LongLiteralExpr("1L"), PRIVATE, FINAL, STATIC);
final FieldDeclaration loggerField = javaClass.addFieldWithInitializer(Logger.class, "logger", new MethodCallExpr("LogManager.getLogger"), PRIVATE, FINAL, STATIC);

View File

@@ -0,0 +1,452 @@
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.IntegryCustomerDB;
import it.integry.ems.migration._base.MigrationModelInterface;
import it.integry.ems_model.entity.*;
import it.integry.ems_model.types.OperationType;
public class Migration_20240930110848 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB() || !isCustomer(IntegryCustomer.Tosca))
return;
updateSetupValue("w_dordi_rc", "CREA_COMMESSA", "AUTO_GENERATE","N");
if (isCustomerDb(IntegryCustomerDB.Tosca_Cloud)) {
executeStatement("SET IDENTITY_INSERT tosca_cloud.dbo.stb_publications ON;");
executeStatement("INSERT INTO stb_publications (id, publication_description) VALUES (10, N'Sincronizzazione Anagrafiche');");
executeStatement("INSERT INTO stb_publications (id, publication_description) VALUES (11, N'Sincronizzazione impegnato (Triggiano)');");
executeStatement("INSERT INTO stb_publications (id, publication_description) VALUES (12, N'Sincronizzazione impegnato (Caserta)');");
executeStatement("INSERT INTO stb_publications (id, publication_description) VALUES (13, N'Sincronizzazione impegnato (Catanzaro)');");
executeStatement("INSERT INTO stb_publications (id, publication_description) VALUES (14, N'Sincronizzazione impegnato (Forlì-Cesena)');");
executeStatement("INSERT INTO stb_publications (id, publication_description) VALUES (15, N'Sincronizzazione impegnato (Milano)');");
executeStatement("INSERT INTO stb_publications (id, publication_description) VALUES (16, N'Sincronizzazione impegnato (Ragusa)');");
executeStatement("INSERT INTO stb_publications (id, publication_description) VALUES (17, N'Sincronizzazione impegnato (Roma)');");
executeStatement("INSERT INTO stb_publications (id, publication_description) VALUES (18, N'Sincronizzazione impegnato (Verona)');");
executeStatement("SET IDENTITY_INSERT tosca_cloud.dbo.stb_publications OFF;");
//<editor-fold desc="Pubblicazione anagrafiche">
StbPublications anagPublication = new StbPublications();
anagPublication
.setId(10L)
.setPublicationDescription("Sincronizzazione Anagrafiche");
anagPublication.setOperation(OperationType.NO_OP);
StbPublicationsDetail detailGtbAnag = new StbPublicationsDetail();
detailGtbAnag
.setActive(true)
.setStbPublicationId(10L)
.setReadyToTransmit(true)
.setEntityName(GtbAnag.ENTITY)
.setExportHistory(false)
.setOperation(OperationType.INSERT);
anagPublication.getStbPublicationsDetails().add(detailGtbAnag);
StbPublicationsDetail detailVtbDest = new StbPublicationsDetail();
detailVtbDest.setActive(true)
.setStbPublicationId(10L)
.setReadyToTransmit(true)
.setEntityName(VtbDest.ENTITY)
.setExportHistory(false)
.setOperation(OperationType.INSERT);
anagPublication.getStbPublicationsDetails().add(detailVtbDest);
StbPublicationsDetail detailMtbDepo = new StbPublicationsDetail();
detailMtbDepo.setActive(true)
.setStbPublicationId(10L)
.setReadyToTransmit(true)
.setEntityName(MtbDepo.ENTITY)
.setExportHistory(false)
.setOperation(OperationType.INSERT);
anagPublication.getStbPublicationsDetails().add(detailMtbDepo);
StbPublicationsDetail detailVtbClie = new StbPublicationsDetail();
detailVtbClie
.setActive(true)
.setStbPublicationId(10L)
.setReadyToTransmit(true)
.setEntityName(VtbClie.ENTITY)
.setExportHistory(false)
.setOperation(OperationType.INSERT);
anagPublication.getStbPublicationsDetails().add(detailVtbClie);
StbPublicationsDetail detailAtbForn = new StbPublicationsDetail();
detailAtbForn
.setActive(true)
.setStbPublicationId(10L)
.setEntityName(AtbForn.ENTITY)
.setReadyToTransmit(true)
.setExportHistory(false)
.setOperation(OperationType.INSERT);
anagPublication.getStbPublicationsDetails().add(detailAtbForn);
anagPublication.manageWithParentConnection(advancedDataSource.getConnection(),droolsDataCompleting);
//</editor-fold>
//<editor-fold desc="Pubblicazione impegnato (Triggiano)">
StbPublications impegnatoTriggiano = new StbPublications();
impegnatoTriggiano.setId(11L).setPublicationDescription("Sincronizzazione impegnato (Triggiano)");
impegnatoTriggiano.setOperation(OperationType.NO_OP);
StbPublicationsDetail detailDtbOrdtBA = new StbPublicationsDetail();
detailDtbOrdtBA
.setStbPublicationId(11L)
.setReadyToTransmit(true)
.setEntityName(DtbOrdt.ENTITY)
.setWhereCondField("gestione = 'V' AND codMdep = 'BA'")
.setActive(true)
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoTriggiano.getStbPublicationsDetails().add(detailDtbOrdtBA);
StbPublicationsDetail detailDtbOrdrBA = new StbPublicationsDetail();
detailDtbOrdrBA
.setStbPublicationId(11L)
.setReadyToTransmit(true)
.setEntityName(DtbOrdr.ENTITY)
.setActive(true)
.setWhereCondField("gestione = 'V' AND codMdep = 'BA'")
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoTriggiano.getStbPublicationsDetails().add(detailDtbOrdrBA);
impegnatoTriggiano.manageWithParentConnection(advancedDataSource.getConnection());
//</editor-fold>
//<editor-fold desc="Pubblicazione impegnato (Caserta)">
StbPublications impegnatoCaserta = new StbPublications();
impegnatoCaserta.setId(12L).setPublicationDescription("Sincronizzazione impegnato (Caserta)");
impegnatoCaserta.setOperation(OperationType.NO_OP);
StbPublicationsDetail detailDtbOrdtCE = new StbPublicationsDetail();
detailDtbOrdtCE
.setStbPublicationId(12L)
.setEntityName(DtbOrdt.ENTITY)
.setReadyToTransmit(true)
.setWhereCondField("gestione = 'V' AND codMdep = 'CE'")
.setActive(true)
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoCaserta.getStbPublicationsDetails().add(detailDtbOrdtCE);
StbPublicationsDetail detailDtbOrdrCE = new StbPublicationsDetail();
detailDtbOrdrCE
.setStbPublicationId(12L)
.setEntityName(DtbOrdr.ENTITY)
.setReadyToTransmit(true)
.setActive(true)
.setWhereCondField("gestione = 'V' AND codMdep = 'CE'")
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoCaserta.getStbPublicationsDetails().add(detailDtbOrdrCE);
impegnatoCaserta.manageWithParentConnection(advancedDataSource.getConnection());
//</editor-fold>
//<editor-fold desc="Pubblicazione impegnato (Catanzaro)">
StbPublications impegnatoCatanzaro = new StbPublications();
impegnatoCatanzaro.setId(13L).setPublicationDescription("Sincronizzazione impegnato (Catanzaro)");
impegnatoCatanzaro.setOperation(OperationType.NO_OP);
StbPublicationsDetail detailDtbOrdtCZ = new StbPublicationsDetail();
detailDtbOrdtCZ
.setStbPublicationId(13L)
.setReadyToTransmit(true)
.setEntityName(DtbOrdt.ENTITY)
.setWhereCondField("gestione = 'V' AND codMdep = 'CZ'")
.setActive(true)
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoCatanzaro.getStbPublicationsDetails().add(detailDtbOrdtCZ);
StbPublicationsDetail detailDtbOrdrCZ = new StbPublicationsDetail();
detailDtbOrdrCZ
.setStbPublicationId(13L)
.setReadyToTransmit(true)
.setEntityName(DtbOrdr.ENTITY)
.setActive(true)
.setWhereCondField("gestione = 'V' AND codMdep = 'CZ'")
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoCatanzaro.getStbPublicationsDetails().add(detailDtbOrdrCZ);
impegnatoCatanzaro.manageWithParentConnection(advancedDataSource.getConnection());
//</editor-fold>
//<editor-fold desc="Pubblicazione impegnato (Forlì-Cesena)">
StbPublications impegnatoFC = new StbPublications();
impegnatoFC.setId(14L).setPublicationDescription("Sincronizzazione impegnato (Forlì-Cesena)");
impegnatoFC.setOperation(OperationType.NO_OP);
StbPublicationsDetail detailDtbOrdtFC = new StbPublicationsDetail();
detailDtbOrdtFC
.setStbPublicationId(14L)
.setReadyToTransmit(true)
.setEntityName(DtbOrdt.ENTITY)
.setWhereCondField("gestione = 'V' AND codMdep = 'FC'")
.setActive(true)
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoFC.getStbPublicationsDetails().add(detailDtbOrdtFC);
StbPublicationsDetail detailDtbOrdrFC = new StbPublicationsDetail();
detailDtbOrdrFC
.setStbPublicationId(14L)
.setReadyToTransmit(true)
.setEntityName(DtbOrdr.ENTITY)
.setActive(true)
.setWhereCondField("gestione = 'V' AND codMdep = 'FC'")
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoFC.getStbPublicationsDetails().add(detailDtbOrdrFC);
impegnatoFC.manageWithParentConnection(advancedDataSource.getConnection());
//</editor-fold>
//<editor-fold desc="Pubblicazione impegnato (Milano)">
StbPublications impegnatoMI = new StbPublications();
impegnatoMI.setId(15L).setPublicationDescription("Sincronizzazione impegnato (Milano)");
impegnatoMI.setOperation(OperationType.NO_OP);
StbPublicationsDetail detailDtbOrdtMI = new StbPublicationsDetail();
detailDtbOrdtMI
.setStbPublicationId(15L)
.setReadyToTransmit(true)
.setEntityName(DtbOrdt.ENTITY)
.setWhereCondField("gestione = 'V' AND codMdep = 'MI'")
.setActive(true)
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoMI.getStbPublicationsDetails().add(detailDtbOrdtMI);
StbPublicationsDetail detailDtbOrdrMI = new StbPublicationsDetail();
detailDtbOrdrMI
.setStbPublicationId(15L)
.setReadyToTransmit(true)
.setEntityName(DtbOrdr.ENTITY)
.setActive(true)
.setWhereCondField("gestione = 'V' AND codMdep = 'MI'")
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoMI.getStbPublicationsDetails().add(detailDtbOrdrMI);
impegnatoMI.manageWithParentConnection(advancedDataSource.getConnection());
//</editor-fold>
//<editor-fold desc="Pubblicazione impegnato (Ragusa)">
StbPublications impegnatoRG = new StbPublications();
impegnatoRG.setId(16L).setPublicationDescription("Sincronizzazione impegnato (Ragusa)");
impegnatoRG.setOperation(OperationType.NO_OP);
StbPublicationsDetail detailDtbOrdtRG = new StbPublicationsDetail();
detailDtbOrdtRG
.setStbPublicationId(16L)
.setReadyToTransmit(true)
.setEntityName(DtbOrdt.ENTITY)
.setWhereCondField("gestione = 'V' AND codMdep = 'RG'")
.setActive(true)
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoRG.getStbPublicationsDetails().add(detailDtbOrdtRG);
StbPublicationsDetail detailDtbOrdrRG = new StbPublicationsDetail();
detailDtbOrdrRG
.setStbPublicationId(16L)
.setReadyToTransmit(true)
.setEntityName(DtbOrdr.ENTITY)
.setActive(true)
.setWhereCondField("gestione = 'V' AND codMdep = 'RG'")
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoRG.getStbPublicationsDetails().add(detailDtbOrdrRG);
impegnatoRG.manageWithParentConnection(advancedDataSource.getConnection());
//</editor-fold>
//<editor-fold desc="Pubblicazione impegnato (Roma)">
StbPublications impegnatoRoma = new StbPublications();
impegnatoRoma.setId(17L).setPublicationDescription("Sincronizzazione impegnato (Roma)");
impegnatoRoma.setOperation(OperationType.NO_OP);
StbPublicationsDetail detailDtbOrdtRM = new StbPublicationsDetail();
detailDtbOrdtRM
.setStbPublicationId(17L)
.setReadyToTransmit(true)
.setEntityName(DtbOrdt.ENTITY)
.setWhereCondField("gestione = 'V' AND codMdep = 'RM'")
.setActive(true)
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoRoma.getStbPublicationsDetails().add(detailDtbOrdtRM);
StbPublicationsDetail detailDtbOrdrRM = new StbPublicationsDetail();
detailDtbOrdrRM
.setStbPublicationId(17L)
.setReadyToTransmit(true)
.setEntityName(DtbOrdr.ENTITY)
.setActive(true)
.setWhereCondField("gestione = 'V' AND codMdep = 'RM'")
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoRoma.getStbPublicationsDetails().add(detailDtbOrdrRM);
impegnatoRoma.manageWithParentConnection(advancedDataSource.getConnection());
//</editor-fold>
//<editor-fold desc="Pubblicazione impegnato (Verona)">
StbPublications impegnatoVR = new StbPublications();
impegnatoVR.setId(18L).setPublicationDescription("Sincronizzazione impegnato (Verona)");
impegnatoVR.setOperation(OperationType.NO_OP);
StbPublicationsDetail detailDtbOrdtVR = new StbPublicationsDetail();
detailDtbOrdtVR
.setStbPublicationId(18L)
.setReadyToTransmit(true)
.setEntityName(DtbOrdt.ENTITY)
.setWhereCondField("gestione = 'V' AND codMdep = 'VR'")
.setActive(true)
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoVR.getStbPublicationsDetails().add(detailDtbOrdtVR);
StbPublicationsDetail detailDtbOrdrVR = new StbPublicationsDetail();
detailDtbOrdrVR
.setStbPublicationId(18L)
.setReadyToTransmit(true)
.setEntityName(DtbOrdr.ENTITY)
.setActive(true)
.setWhereCondField("gestione = 'V' AND codMdep = 'VR'")
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoVR.getStbPublicationsDetails().add(detailDtbOrdrVR);
impegnatoVR.manageWithParentConnection(advancedDataSource.getConnection());
//</editor-fold>
} else {
//<editor-fold desc="sottoscrizione anagrafiche">
StbRemoteSubscription anagSubscription = new StbRemoteSubscription();
anagSubscription
.setActive(true)
.setPublicationId(10L)
.setPublicationDescription("Sincronizzazione anagrafiche clienti/fornitori")
.setEndpointProtocol("HTTP")
.setEndpointHost("4.232.161.31")
.setEndpointPort(8080)
.setUsernameField("dba")
.setPassword("sql")
.setProfileDb("TOSCA_CLOUD")
.setOperation(OperationType.INSERT);
anagSubscription.manageWithParentConnection(advancedDataSource.getConnection());
;
//</editor-fold>
if (isCustomerDb(IntegryCustomerDB.Tosca_Ba)) {
StbRemoteSubscription syncImpegnatoBa = new StbRemoteSubscription();
syncImpegnatoBa.setActive(true)
.setPublicationId(11L)
.setProfileDb("TOSCA_CLOUD")
.setPublicationDescription("Sincronizzazione impengato (Ba)")
.setEndpointProtocol("HTTP")
.setEndpointHost("4.232.161.31")
.setEndpointPort(8080)
.setUsernameField("dba")
.setPassword("sql")
.setOperation(OperationType.INSERT);
syncImpegnatoBa.manageWithParentConnection(advancedDataSource.getConnection());
} else if (isCustomerDb(IntegryCustomerDB.Tosca_Ce)) {
StbRemoteSubscription syncImpegnatoCe = new StbRemoteSubscription();
syncImpegnatoCe.setActive(true)
.setPublicationId(12L)
.setProfileDb("TOSCA_CLOUD")
.setPublicationDescription("Sincronizzazione impengato (Caserta)")
.setEndpointProtocol("HTTP")
.setEndpointHost("4.232.161.31")
.setEndpointPort(8080)
.setUsernameField("dba")
.setPassword("sql")
.setOperation(OperationType.INSERT);
syncImpegnatoCe.manageWithParentConnection(advancedDataSource.getConnection());
} else if (isCustomerDb(IntegryCustomerDB.Tosca_Cz)) {
StbRemoteSubscription syncImpegnatoCz = new StbRemoteSubscription();
syncImpegnatoCz.setActive(true)
.setPublicationId(13L)
.setProfileDb("TOSCA_CLOUD")
.setPublicationDescription("Sincronizzazione impengato (Catanzaro)")
.setEndpointProtocol("HTTP")
.setEndpointHost("4.232.161.31")
.setEndpointPort(8080)
.setUsernameField("dba")
.setPassword("sql")
.setOperation(OperationType.INSERT);
syncImpegnatoCz.manageWithParentConnection(advancedDataSource.getConnection());
} else if (isCustomerDb(IntegryCustomerDB.Tosca_Fc)) {
StbRemoteSubscription syncImpegnatoFc = new StbRemoteSubscription();
syncImpegnatoFc.setActive(true)
.setPublicationId(14L)
.setProfileDb("TOSCA_CLOUD")
.setPublicationDescription("Sincronizzazione impengato (Forlì-Cesena)")
.setEndpointProtocol("HTTP")
.setEndpointHost("4.232.161.31")
.setEndpointPort(8080)
.setUsernameField("dba")
.setPassword("sql")
.setOperation(OperationType.INSERT);
syncImpegnatoFc.manageWithParentConnection(advancedDataSource.getConnection());
} else if (isCustomerDb(IntegryCustomerDB.Tosca_Mi)) {
StbRemoteSubscription syncImpegnatoMi = new StbRemoteSubscription();
syncImpegnatoMi.setActive(true)
.setPublicationId(15L)
.setProfileDb("TOSCA_CLOUD")
.setPublicationDescription("Sincronizzazione impengato (Milano)")
.setEndpointProtocol("HTTP")
.setEndpointHost("4.232.161.31")
.setEndpointPort(8080)
.setUsernameField("dba")
.setPassword("sql")
.setOperation(OperationType.INSERT);
syncImpegnatoMi.manageWithParentConnection(advancedDataSource.getConnection());
} else if (isCustomerDb(IntegryCustomerDB.Tosca_Rg)) {
StbRemoteSubscription syncImpegnatoRg = new StbRemoteSubscription();
syncImpegnatoRg.setActive(true)
.setPublicationId(16L)
.setProfileDb("TOSCA_CLOUD")
.setPublicationDescription("Sincronizzazione impengato (Ragusa)")
.setEndpointProtocol("HTTP")
.setEndpointHost("4.232.161.31")
.setEndpointPort(8080)
.setUsernameField("dba")
.setPassword("sql")
.setOperation(OperationType.INSERT);
syncImpegnatoRg.manageWithParentConnection(advancedDataSource.getConnection());
} else if (isCustomerDb(IntegryCustomerDB.Tosca_Rm)) {
StbRemoteSubscription syncImpegnatoRm = new StbRemoteSubscription();
syncImpegnatoRm.setActive(true)
.setPublicationId(17L)
.setProfileDb("TOSCA_CLOUD")
.setPublicationDescription("Sincronizzazione impengato (Roma)")
.setEndpointProtocol("HTTP")
.setEndpointHost("4.232.161.31")
.setEndpointPort(8080)
.setUsernameField("dba")
.setPassword("sql")
.setOperation(OperationType.INSERT);
syncImpegnatoRm.manageWithParentConnection(advancedDataSource.getConnection());
} else if (isCustomerDb(IntegryCustomerDB.Tosca_Vr)) {
StbRemoteSubscription syncImpegnatoVr = new StbRemoteSubscription();
syncImpegnatoVr.setActive(true)
.setPublicationId(18L)
.setProfileDb("TOSCA_CLOUD")
.setPublicationDescription("Sincronizzazione impengato (Verona)")
.setEndpointProtocol("HTTP")
.setEndpointHost("4.232.161.31")
.setEndpointPort(8080)
.setUsernameField("dba")
.setPassword("sql")
.setOperation(OperationType.INSERT);
syncImpegnatoVr.manageWithParentConnection(advancedDataSource.getConnection());
}
}
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,42 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
import it.integry.ems_model.utility.dto.IndexTableDTO;
import java.util.Arrays;
public class Migration_20240930172801 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
executeStatement("create table ctb_movr_intercode(\n" +
" id bigint not null identity,\n" +
" num_cmov int not null,\n" +
" id_riga int not null,\n" +
" intercode varchar(40),\n" +
" num_doc_orig varchar(40))",
" alter table ctb_movr_intercode add constraint pk_ctb_movr_intercode primary key (id)");
IndexTableDTO indexTableDTO = new IndexTableDTO()
.setIndexName("IX_ctb_movr_intercode_unique")
.setTableName("ctb_movr_intercode")
.setUnique(true)
.setColumnsIndex(Arrays.asList(
new IndexTableDTO.ColumnIndex("num_cmov"),
new IndexTableDTO.ColumnIndex("id_riga")
));
createIndex(indexTableDTO);
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,25 @@
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_20241001133030 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
if (isCustomer(IntegryCustomer.Tosca))
updateSetupValue("PICKING","SPEDIZIONE","FLAG_CAN_ADD_EXTRA_ITEMS","S");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,35 @@
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_20241003123326 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createSetup("W_VARTVENDCLI_DISP", "DATAWINDOW", "D_VARTVENDCLI_CANALE_REP", null,
null, false, null, false, false,
false, false, false, null, false, null);
createSetup("W_VARTVENDCLI_DISP", "DATAWINDOW", "D_VARTVENDCLI_NODEST_REP", null,
null, false, null, false, false,
false, false, false, null, false, null);
if(isCustomer(IntegryCustomer.Gramm)) {
updateSetupValue("W_VARTVENDCLI_DISP", "DATAWINDOW", "D_VARTVENDCLI_REP", "D_VARTVENDCLI_GRAMM_REP");
updateSetupValue("W_VARTVENDCLI_DISP", "DATAWINDOW", "D_VARTVENDCLI_CANALE_REP", "D_VARTVENDCLI_CANALE_GRAMM_REP");
updateSetupValue("W_VARTVENDCLI_DISP", "DATAWINDOW", "D_VARTVENDCLI_NODEST_REP", "D_VARTVENDCLI_NODEST_GRAMM_REP");
}
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,137 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20241003172732 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createOrUpdateFunction("f_int2lettere", "CREATE FUNCTION dbo.f_int2lettere (@Numero INT)\n" +
"RETURNS NVARCHAR(4000)\n" +
"AS\n" +
"BEGIN\n" +
" DECLARE @Risultato NVARCHAR(4000) = ''\n" +
" DECLARE @Unita NVARCHAR(11)\n" +
" DECLARE @Decine NVARCHAR(11)\n" +
" DECLARE @Centinaia NVARCHAR(11)\n" +
" DECLARE @Migliaia NVARCHAR(11)\n" +
" DECLARE @Milioni NVARCHAR(11)\n" +
"\n" +
" IF @Numero = 0\n" +
" RETURN 'zero'\n" +
"\n" +
" IF @Numero < 0\n" +
" RETURN 'meno ' + dbo.f_numeroInLettere(-@Numero)\n" +
"\n" +
" -- Milioni\n" +
" IF @Numero >= 1000000\n" +
" BEGIN\n" +
" SET @Milioni = dbo.f_numeroInLettere(@Numero / 1000000)\n" +
" SET @Risultato = @Milioni + 'milione' + CASE WHEN @Numero / 1000000 > 1 THEN 'i' ELSE '' END\n" +
" SET @Numero = @Numero % 1000000\n" +
" /*IF @Numero > 0\n" +
" SET @Risultato = @Risultato + ' '*/\n" +
" END\n" +
"\n" +
" -- Migliaia\n" +
" IF @Numero >= 1000\n" +
" BEGIN\n" +
" SET @Migliaia = dbo.f_numeroInLettere(@Numero / 1000)\n" +
" IF @Numero / 1000 = 1\n" +
" SET @Risultato = @Risultato + 'mille'\n" +
" ELSE\n" +
" SET @Risultato = @Risultato + @Migliaia + 'mila'\n" +
" SET @Numero = @Numero % 1000\n" +
" /* IF @Numero > 0\n" +
" SET @Risultato = @Risultato + ' '*/\n" +
" END\n" +
"\n" +
" -- Centinaia\n" +
" IF @Numero >= 100\n" +
" BEGIN\n" +
" SET @Centinaia = CASE\n" +
" WHEN @Numero / 100 = 1 THEN 'cento'\n" +
" WHEN @Numero / 100 = 2 THEN 'duecento'\n" +
" WHEN @Numero / 100 = 3 THEN 'trecento'\n" +
" WHEN @Numero / 100 = 4 THEN 'quattrocento'\n" +
" WHEN @Numero / 100 = 5 THEN 'cinquecento'\n" +
" WHEN @Numero / 100 = 6 THEN 'seicento'\n" +
" WHEN @Numero / 100 = 7 THEN 'settecento'\n" +
" WHEN @Numero / 100 = 8 THEN 'ottocento'\n" +
" ELSE 'novecento'\n" +
" END\n" +
" SET @Risultato = @Risultato + @Centinaia\n" +
" SET @Numero = @Numero % 100\n" +
" /*IF @Numero > 0\n" +
" SET @Risultato = @Risultato + ' '*/\n" +
" END\n" +
"\n" +
" -- Decine e unità\n" +
" IF @Numero >= 20\n" +
" BEGIN\n" +
" SET @Decine = CASE\n" +
" WHEN @Numero / 10 = 2 THEN 'venti'\n" +
" WHEN @Numero / 10 = 3 THEN 'trenta'\n" +
" WHEN @Numero / 10 = 4 THEN 'quaranta'\n" +
" WHEN @Numero / 10 = 5 THEN 'cinquanta'\n" +
" WHEN @Numero / 10 = 6 THEN 'sessanta'\n" +
" WHEN @Numero / 10 = 7 THEN 'settanta'\n" +
" WHEN @Numero / 10 = 8 THEN 'ottanta'\n" +
" ELSE 'novanta'\n" +
" END\n" +
" SET @Risultato = @Risultato + @Decine\n" +
" SET @Numero = @Numero % 10\n" +
" /* IF @Numero > 0\n" +
" SET @Risultato = @Risultato + ' '*/\n" +
" END\n" +
"\n" +
" IF @Numero > 0\n" +
" BEGIN\n" +
" SET @Unita = CASE\n" +
" WHEN @Numero = 1 THEN 'uno'\n" +
" WHEN @Numero = 2 THEN 'due'\n" +
" WHEN @Numero = 3 THEN 'tre'\n" +
" WHEN @Numero = 4 THEN 'quattro'\n" +
" WHEN @Numero = 5 THEN 'cinque'\n" +
" WHEN @Numero = 6 THEN 'sei'\n" +
" WHEN @Numero = 7 THEN 'sette'\n" +
" WHEN @Numero = 8 THEN 'otto'\n" +
" ELSE 'nove'\n" +
" END\n" +
" SET @Risultato = @Risultato + @Unita\n" +
" END\n" +
"\n" +
" RETURN @Risultato\n" +
"END");
createOrUpdateFunction("f_dec2lettere", "CREATE FUNCTION dbo.f_dec2Lettere (@Numero numeric(20,5))\n" +
"RETURNS NVARCHAR(4000)\n" +
"AS\n" +
"BEGIN\n" +
" DECLARE @Risultato NVARCHAR(4000) = ''\n" +
" DECLARE @Decimali NVARCHAR(11) = ''\n" +
" \n" +
" if @Numero <> cast(@Numero as int) \n" +
" begin\n" +
" set @Decimali = '/'+ cast(cast((@Numero - cast(@Numero as int))*100 as int)as varchar) \n" +
" end\n" +
" set @Numero = CAST(@Numero as int) \n" +
"\n" +
" select @Risultato = dbo.f_int2Lettere(@Numero) + @Decimali\n" +
"\n" +
" \n" +
" \n" +
" RETURN @Risultato\n" +
"END");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -685,6 +685,22 @@ public class EmsServices {
}
}
if (!UtilityList.isNullOrEmpty(createZipDTO.getListDtbDocPdf())){
List<DtbDocPdf> listDtbDocPdf = createZipDTO.getListDtbDocPdf().stream()
.peek(dtbDocPdf -> dtbDocPdf.setOperation(OperationType.SELECT_OBJECT))
.collect(Collectors.toList());
List<EntityBase> entityBases = Collections.unmodifiableList(entityProcessor.processEntityList(listDtbDocPdf, true));
UtilityEntity.throwEntitiesException(entityBases);
listDtbDocPdf = UtilityEntity.toCustomEntity(entityBases);
for (DtbDocPdf dtbDocPdf : listDtbDocPdf) {
UtilityZip.addFileToArchive(zos, dtbDocPdf.getFilename(), Base64.decodeBase64(dtbDocPdf.getFilecontentByteArr(false)));
}
}
if (baos.size() > 0) {
zos.close();

View File

@@ -13,9 +13,7 @@ import it.integry.ems_model.base.EntityBase;
import it.integry.ems_model.entity.StbPublicationsDetail;
import it.integry.ems_model.entity.StbTransactionLog;
import it.integry.ems_model.types.OperationType;
import it.integry.ems_model.utility.UtilityDB;
import it.integry.ems_model.utility.UtilityLocalDate;
import it.integry.ems_model.utility.UtilityString;
import it.integry.ems_model.utility.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.josql.Query;
@@ -101,35 +99,37 @@ public class AsyncManager {
return 0;
String tableName = entityBase.getTableName().toUpperCase();
StbPublicationsDetail activePublication = cachedSetup.get(dbName).stream()
List<StbPublicationsDetail> activePublications = cachedSetup.get(dbName).stream()
.filter(x -> x.getEntityName().equalsIgnoreCase(tableName))
.findFirst()
.orElse(null);
.collect(Collectors.toList());
if (activePublication == null)
if (UtilityList.isNullOrEmpty(activePublications))
return 0;
//logger.debug("SYNC OFFLINE ABILITATA SU " + tableName);
List<EntityBase> myObjs = new ArrayList<>();
myObjs.add(entityBase);
for (StbPublicationsDetail activePublication : activePublications){
List<EntityBase> myObjs = new ArrayList<>();
myObjs.add(entityBase);
String selectSql = "SELECT * FROM " + entityBase.getClass().getCanonicalName();
if (!UtilityString.isNullOrEmpty(activePublication.getWhereCondField())) {
selectSql = selectSql + " WHERE " + activePublication.getWhereCondField();
String selectSql = "SELECT * FROM " + entityBase.getClass().getCanonicalName();
if (!UtilityString.isNullOrEmpty(activePublication.getWhereCondField())) {
selectSql = selectSql + " WHERE " + activePublication.getWhereCondField();
}
// Create a new Query.
Query q = new Query();
q.parse(selectSql);
QueryResults qr = q.execute(myObjs);
List<?> res = qr.getResults();
if (res == null || res.isEmpty())
continue;
return activePublication.getStbPublicationId();
}
// Create a new Query.
Query q = new Query();
q.parse(selectSql);
QueryResults qr = q.execute(myObjs);
List<?> res = qr.getResults();
if (res == null || res.isEmpty())
return 0;
return activePublication.getStbPublicationId();
return 0;
}
@@ -166,7 +166,7 @@ public class AsyncManager {
Long tmpTransactionGroupId = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(
connection, "SELECT MAX(group_id) AS max_id FROM " + StbTransactionLog.ENTITY);
tmpTransactionGroupId = tmpTransactionGroupId != 0 ? tmpTransactionGroupId : 0L;
tmpTransactionGroupId = UtilityLong.isNull(tmpTransactionGroupId,0L);
transactionGroupId = Math.max(maxToBeProcessed, tmpTransactionGroupId);
} else {

View File

@@ -943,8 +943,10 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
for (EntityBase entityChild : (List<EntityBase>) entityChildRef) {
entityChild.setOnlyPkMaster(false);
}
} else
((EntityBase) entityChildRef).setOnlyPkMaster(false);
} else {
if (entityChildRef != null)
((EntityBase) entityChildRef).setOnlyPkMaster(false);
}
}
transactionGroupId = AsyncManager.saveNewTransaction(connection, dbName, clonedEntity, publicationId, transactionGroupId);

View File

@@ -118,6 +118,9 @@ public class CtbMovr extends EntityBase {
@EntityChild
private List<CtbMovrCoan> ctbMovrCoan = new ArrayList<>();
@EntityChild
private List<CtbMovrIntercode> ctbMovrIntercode = new ArrayList<>();
@EntityChild
private List<CtbParr> ctbParr = new ArrayList<>();
@@ -406,6 +409,21 @@ public class CtbMovr extends EntityBase {
return this;
}
public List<CtbMovrIntercode> getCtbMovrIntercode() {
return ctbMovrIntercode;
}
public CtbMovr setCtbMovrIntercode(List<CtbMovrIntercode> ctbMovrIntercode) {
this.ctbMovrIntercode = ctbMovrIntercode;
return this;
}
public CtbMovr addCtbMovrIntercode(CtbMovrIntercode ctbMovrIntercode) {
if (this.getCtbMovrIntercode() == null ) this.setCtbMovrIntercode(new ArrayList<>());
this.getCtbMovrIntercode().add(ctbMovrIntercode);
return this;
}
public List<CtbParr> getCtbParr() {
return ctbParr;
}
@@ -451,6 +469,11 @@ public class CtbMovr extends EntityBase {
ctbScad.setIdRigaMov(getIdRiga());
}
}
if (getCtbMovrIntercode() != null) {
for (CtbMovrIntercode ctbMovrIntercode : getCtbMovrIntercode()) {
ctbMovrIntercode.setIdRiga(getIdRiga());
}
}
}
@Override
@@ -468,6 +491,10 @@ public class CtbMovr extends EntityBase {
ctbParr.manageWithParentConnection(connection, ctbParr.getOperation(), dataCompleting, entityHolder);
}
}
for (CtbMovrIntercode ctbMovrIntercode : getCtbMovrIntercode()) {
ctbMovrIntercode.manageWithParentConnection(connection, ctbMovrIntercode.getOperation(), dataCompleting, entityHolder);
}
}
@Override
@@ -493,5 +520,7 @@ public class CtbMovr extends EntityBase {
}
CtbParr ctbParr = new CtbParr();
ctbParr.deleteAllEntities(connection, whereCond);
CtbMovrIntercode ctbMovrIntercode = new CtbMovrIntercode();
ctbMovrIntercode.deleteAllEntities(connection, whereCond);
}
}

View File

@@ -0,0 +1,89 @@
package it.integry.ems_model.entity;
import it.integry.ems_model.annotation.*;
import org.apache.logging.log4j.LogManager;
import it.integry.ems_model.base.EntityBase;
import org.kie.api.definition.type.PropertyReactive;
import com.fasterxml.jackson.annotation.JsonTypeName;
import org.apache.logging.log4j.Logger;
@Master()
@PropertyReactive()
@Table(value = CtbMovrIntercode.ENTITY)
@JsonTypeName(value = CtbMovrIntercode.ENTITY)
public class CtbMovrIntercode extends EntityBase {
public final static String ENTITY = "ctb_movr_intercode";
private final static Long serialVersionUID = 1L;
private final static Logger logger = LogManager.getLogger();
public CtbMovrIntercode() {
super(logger);
}
@PK()
@Identity()
@SqlField(value = "id", nullable = false)
private Long id;
@ImportFromParent
@SqlField(value = "num_cmov", nullable = false)
private Integer numCmov;
@ImportFromParent
@SqlField(value = "id_riga", nullable = false)
private Integer idRiga;
@SqlField(value = "intercode", maxLength = 40, nullable = true)
private String intercode;
@SqlField(value = "num_doc_orig", maxLength = 40, nullable = true)
private String numDocOrig;
public Long getId() {
return id;
}
public CtbMovrIntercode setId(Long id) {
this.id = id;
return this;
}
public Integer getNumCmov() {
return numCmov;
}
public CtbMovrIntercode setNumCmov(Integer numCmov) {
this.numCmov = numCmov;
return this;
}
public Integer getIdRiga() {
return idRiga;
}
public CtbMovrIntercode setIdRiga(Integer idRiga) {
this.idRiga = idRiga;
return this;
}
public String getIntercode() {
return intercode;
}
public CtbMovrIntercode setIntercode(String intercode) {
this.intercode = intercode;
return this;
}
public String getNumDocOrig() {
return numDocOrig;
}
public CtbMovrIntercode setNumDocOrig(String numDocOrig) {
this.numDocOrig = numDocOrig;
return this;
}
}

View File

@@ -0,0 +1,17 @@
package it.integry.ems_model.utility;
public class UtilityLong {
public static Long isNull(Long valOrig, Long valDef) {
return valOrig==null?valDef:valOrig;
}
public static boolean isNullOrZero(Long numCollo) {
return numCollo == null || numCollo == 0;
}
public static Long stringToLong(String str) {
if (!UtilityString.isNullOrEmpty(str)) { return Long.parseLong(str); }
return null;
}
}

View File

@@ -7,19 +7,24 @@ import it.integry.ems.Import.dto.ImportRequestDTO;
import it.integry.ems.product.export.services.ProdottiLaranciaService;
import it.integry.ems.service.EntityProcessor;
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
import it.integry.ems.utility.UtilityDirs;
import it.integry.ems.utility.UtilityFile;
import it.integry.ems_model.base.EntityBase;
import it.integry.ems_model.entity.CtbPart;
import it.integry.ems_model.entity.CtbScad;
import it.integry.ems_model.service.SetupGest;
import it.integry.ems_model.types.OperationType;
import it.integry.ems_model.utility.*;
import org.apache.commons.lang3.StringUtils;
import org.codehaus.stax2.ri.typed.StringBase64Decoder;
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.sql.Connection;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -44,6 +49,7 @@ public class ScadenzeImportService {
throw new Exception("Nessun file da importare");
List<CtbPart> ctbParts = new ArrayList<>();
List<String> datiFile = new ArrayList<>();
List<String> lines = UtilityString.splitStringToMultipleLine(requestDTO.getRawContent());
if (!lines.isEmpty()) {
for (String line : lines) {
@@ -97,16 +103,17 @@ public class ScadenzeImportService {
ctbParts.remove(ctbPart);
}
if (ctbPart == null && numFromIntercode != null) {
if (ctbPart == null && ( numFromIntercode != null || !UtilityString.isNullOrEmpty(intercodeSubstring))) {
sql = Query.format(
"SELECT *\n" +
"FROM ctb_part\n" +
"WHERE cod_anag = %s\n" +
" AND anno_part = %s\n" +
" AND num_doc = %s\n" +
" AND ( num_doc = %s OR num_doc_forn = %s) \n" +
" AND ((tipo_partita = %s\n"+
" AND dare_part - avere_part <> 0) OR (tipo_partita <> %s AND dare_part - avere_part = %s))"
, codAnag, anno, numFromIntercode, tipoPartita, tipoPartita, segno + importo
, codAnag, anno, numFromIntercode, intercodeSubstring,
tipoPartita, tipoPartita, segno + importo
);
List<CtbPart> ctbPartList = UtilityDB.executeSimpleQueryDTO(conn, sql, CtbPart.class);
@@ -120,7 +127,26 @@ public class ScadenzeImportService {
}
}
if (ctbPart == null && (anno != null && anno < 2021 || dataDoc.before(UtilityDate.StringToDate("2021/07/01", "yyyy/MM/dd")))) {
boolean forceIn2021 = false;
List<String> diacodToCheckList = new ArrayList<>();
List<String> intercodeToCheckList = new ArrayList<>();
diacodToCheckList.add("10216200");
diacodToCheckList.add("10407300");
diacodToCheckList.add("90254600");
intercodeToCheckList.add("21001276019001");
intercodeToCheckList.add("21004001");
intercodeToCheckList.add("21241137001001");
for (int i = 0; i < diacodToCheckList.size(); i++) {
if (diacodToCheckList.get(i).equals(diacod) && intercodeToCheckList.get(i).equals(intercode)) {
forceIn2021 = true;
break;
}
}
if (forceIn2021 || (ctbPart == null && (anno != null && (anno < 2021 || dataDoc.before(UtilityDate.StringToDate("2021/07/01", "yyyy/MM/dd")))))) {
sql = Query.format(
"SELECT *\n" +
"FROM ctb_part\n" +
@@ -133,6 +159,7 @@ public class ScadenzeImportService {
}
if (ctbPart == null) {
datiFile.add(codAnag + ";" + diacod + ";" + intercode + ";" + segno + importo);
listAnomalie.add(
AnomalieDTO.warning(
String.format(
@@ -158,7 +185,15 @@ public class ScadenzeImportService {
}
}
//entityList = entityProcessor.processEntityList(ctbParts, false);
if (!datiFile.isEmpty()) {
String fileName = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".csv";
fileName = UtilityDirs.getDirectoryImport(multiDBTransactionManager.getPrimaryDatasource().getDbName(),
type, format) + File.separator + fileName;
File file = new File(fileName);
UtilityFile.writeStringToFile(StringUtils.join(datiFile, CommonConstants.A_CAPO), file);
}
entityList = entityProcessor.processEntityList(ctbParts, false);
return entityList;
}

View File

@@ -217,8 +217,9 @@ public class ContabilController {
@RequestMapping(value = "/checkPartitaIva", method = RequestMethod.POST)
public @ResponseBody
ServiceRestResponse checkPartitaIva(HttpServletResponse response, HttpServletRequest request, @RequestBody CheckVat json) throws Exception {
CheckVatRestResponse checkVatRestResponse = contabilService.checkVat(json.getCountryCode(), json.getVatNumber());
ServiceRestResponse checkPartitaIva(@RequestParam(required = false, defaultValue = "true") boolean enableLocationCheck,
@RequestBody CheckVat json) throws Exception {
CheckVatRestResponse checkVatRestResponse = contabilService.checkVat(json.getCountryCode(), json.getVatNumber(), enableLocationCheck);
return ServiceRestResponse.createPositiveResponse(checkVatRestResponse);
}

View File

@@ -24,55 +24,57 @@ public class ScadenzeExporterService {
EntityExportResponse<List<FileItem>> entityExportResponse = new EntityExportResponse<>();
entityExportResponse.setResponse(new ArrayList<>());
String sql = "SELECT ISNULL(gtb_tipi_paga_intercode.intercode, ctb_scad.cod_paga) /*leggere da tabella di trascodifica*/ AS 'tipo_pagamento'\n" +
" , REPLACE(CAST(\n" +
String sql = "SELECT ISNULL(gtb_tipi_paga_intercode.intercode, ctb_scad.cod_paga) /*leggere da tabella di trascodifica*/ AS 'tipo_pagamento',\n" +
" REPLACE(\n" +
" CAST(\n" +
" FORMAT(\n" +
" (ctb_scad.imp_dare + ctb_scad.imp_avere),\n" +
" IIF(ctb_part.tipo_partita = 0, '-', '+') + '00000000000.000'\n" +
" ) AS VARCHAR), '.',\n" +
" ',') AS 'importo'\n" +
" , gtb_divi.cod_divi AS 'divisa_scadenza'\n" +
" , REPLACE(CAST(FORMAT(ctb_part.cambio, '00000.000') AS VARCHAR), '.',\n" +
" ',') AS 'cambio'\n" +
" , REPLACE(CAST(\n" +
" ) AS VARCHAR), '.', ',') AS 'importo',\n" +
" gtb_divi.cod_divi AS 'divisa_scadenza',\n" +
" REPLACE(\n" +
" CAST(\n" +
" FORMAT(ctb_part.cambio, '00000.000') AS VARCHAR), '.', ',') AS 'cambio',\n" +
" REPLACE(\n" +
" CAST(\n" +
" FORMAT(\n" +
" ((ctb_scad.imp_dare + ctb_scad.imp_avere) / ctb_part.cambio),\n" +
" IIF(ctb_part.tipo_partita = 0, '-', '+') + '00000000000.000'\n" +
" ) AS VARCHAR), '.',\n" +
" ',') AS 'controvalore'\n" +
" , '00001' AS 'type'\n" +
" , 'N' AS 'raiting'\n" +
" , REPLACE(CONVERT(VARCHAR(10), ctb_scad.data_scad, 103), '/', '') AS 'data_scadenza'\n" +
" , REPLACE(CONVERT(VARCHAR(10), ctb_scad.data_scad, 103), '/', '') AS 'data_valuta'\n" +
" , LEFT(gtb_banc_azi_intercode.intercode, 8) AS 'banca'\n" +
" , RIGHT(gtb_banc_azi_intercode.intercode, 4) AS 'rbn'\n" +
" , 'N' AS 'bloccata'\n" +
" , IIF(ctb_part.tipo_anag = 'F', '0201', '0101') AS 'voce'\n" +
" , IIF(diacod > 0, diacod, ctb_anag.cod_ccon + gtb_anag.cod_anag) AS 'piano_dei_conti'\n" +
" , gtb_anag.rag_soc AS 'descrizione'\n" +
" , ctb_part.cod_abi AS 'ABI'\n" +
" , ctb_part.cod_cab AS 'CAB'\n" +
" , '' AS 'blank'\n" +
" , 'CO' AS 'provenienza'\n" +
" , '' AS 'sezione'\n" +
" , '' AS 'cambio_della_gestione'\n" +
" , CAST(ctb_part.num_doc AS VARCHAR) AS 'numero_doc_origine'\n" +
" , ISNULL(CTB_SCAD.INTERCODE,\n" +
" ',') AS 'controvalore',\n" +
" '00001' AS 'type',\n" +
" 'N' AS 'raiting',\n" +
" REPLACE(CONVERT(VARCHAR(10), ctb_scad.data_scad, 103), '/', '') AS 'data_scadenza',\n" +
" REPLACE(CONVERT(VARCHAR(10), ctb_scad.data_scad, 103), '/', '') AS 'data_valuta',\n" +
" LEFT(gtb_banc_azi_intercode.intercode, 8) AS 'banca',\n" +
" RIGHT(gtb_banc_azi_intercode.intercode, 4) AS 'rbn',\n" +
" 'N' AS 'bloccata',\n" +
" IIF(ctb_part.tipo_anag = 'F', '0201', '0101') AS 'voce',\n" +
" gtb_anag.diacod AS 'piano_dei_conti',\n" +
" gtb_anag.rag_soc AS 'descrizione',\n" +
" ctb_part.cod_abi AS 'ABI',\n" +
" ctb_part.cod_cab AS 'CAB',\n" +
" '' AS 'blank',\n" +
" 'CO' AS 'provenienza',\n" +
" '' AS 'sezione',\n" +
" '' AS 'cambio_della_gestione',\n" +
" CAST(ctb_part.num_doc AS VARCHAR) AS 'numero_doc_origine',\n" +
" ISNULL(CTB_SCAD.INTERCODE,\n" +
" RIGHT(CAST(ctb_part.anno_part AS VARCHAR), 2) +\n" +
" IIF(ctb_part.tipo_anag = 'c', FORMAT(ctb_part.num_doc, REPLICATE('0', 5)),\n" +
" CAST(ctb_part.num_doc AS VARCHAR) + SPACE(5 - LEN(CAST(ctb_part.num_doc AS VARCHAR)))) +\n" +
" FORMAT(ctb_scad.id_riga, '000') +\n" +
" FORMAT(DENSE_RANK() OVER (PARTITION BY ctb_part.cod_anag, ctb_part.num_doc ORDER BY ctb_scad.data_doc),\n" +
" '000')) AS 'chiave_coge'\n" +
" , 'ROSSOGARGA' AS 'azienda'\n" +
" , Right(ctb_part.iban,12) AS 'numero_cc'\n" +
" , SUBSTRING(ctb_part.iban, 5, 1) AS 'cin'\n" +
" , LEFT(ctb_part.iban, 2) AS 'paese'\n" +
" , SUBSTRING(ctb_part.iban, 3, 2) AS 'chk_paese'\n" +
" , REPLACE(CONVERT(VARCHAR(10), ctb_part.data_doc, 103), '/', '') AS 'data_documento'\n" +
" , ctb_parr.des_agg AS 'note'\n" +
" , IIF(vtb_clie.cod_anag IS NULL, atb_forn.cod_bic, vtb_clie.cod_bic) AS 'cod_bic'\n" +
" , ctb_part.iban\n" +
" '000')) AS 'chiave_coge',\n" +
" 'ROSSOGARGA' AS 'azienda',\n" +
" Right(ctb_part.iban,12) AS 'numero_cc',\n" +
" SUBSTRING(ctb_part.iban, 5, 1) AS 'cin',\n" +
" LEFT(ctb_part.iban, 2) AS 'paese',\n" +
" SUBSTRING(ctb_part.iban, 3, 2) AS 'chk_paese',\n" +
" REPLACE(CONVERT(VARCHAR(10), ctb_part.data_doc, 103), '/', '') AS 'data_documento',\n" +
" ctb_parr.des_agg AS 'note',\n" +
" IIF(vtb_clie.cod_anag IS NULL, atb_forn.cod_bic, vtb_clie.cod_bic) AS 'cod_bic',\n" +
" ctb_part.iban\n" +
"FROM ctb_part\n" +
" INNER JOIN ctb_scad ON ctb_part.tipo_anag = ctb_scad.tipo_anag AND ctb_part.cod_anag = ctb_scad.cod_anag AND\n" +
" ctb_part.anno_part = ctb_scad.anno_part AND ctb_part.ser_doc = ctb_scad.ser_doc AND\n" +
@@ -97,7 +99,69 @@ public class ScadenzeExporterService {
" AND ctb_part.ser_doc = ctb_parr.ser_doc\n" +
" AND ctb_part.num_doc = ctb_parr.num_doc\n" +
" ORDER BY ctb_parr.data_cmov) ctb_parr\n" +
"WHERE ctb_scad.data_pag IS NULL";
"WHERE ctb_scad.data_pag IS NULL\n" +
"UNION ALL\n" +
"SELECT 'RD' /*leggere da tabella di trascodifica*/ AS 'tipo_pagamento',\n" +
" REPLACE(\n" +
" CAST(\n" +
" FORMAT(\n" +
" (ctb_movr.imp_dare - ctb_movr.imp_avere),\n" +
" IIF(ctb_movr.imp_dare - ctb_movr.imp_avere > 0, '+', '') + '00000000000.000'\n" +
" ) AS VARCHAR\n" +
" ), '.', ','\n" +
" ) AS 'importo',\n" +
" ctb_movt.cod_divi_cont AS 'divisa_scadenza',\n" +
" REPLACE(\n" +
" CAST(\n" +
" FORMAT(ctb_movt.cambio_divi_cont, '00000.000') AS VARCHAR\n" +
" ), '.', ','\n" +
" ) AS 'cambio',\n" +
" REPLACE(\n" +
" CAST(\n" +
" FORMAT(\n" +
" (ctb_movr.imp_dare - ctb_movr.imp_avere),\n" +
" IIF((ctb_movr.imp_dare - ctb_movr.imp_avere) > 0, '+', '') + '00000000000.000'\n" +
" ) AS VARCHAR\n" +
" ), '.', ','\n" +
" ) AS 'controlvalore',\n" +
" '01' AS 'type',\n" +
" 'N' AS 'raiting',\n" +
" REPLACE(CONVERT(VARCHAR(10), ctb_movt.data_cmov, 103), '/', '') AS 'data_scadenza',\n" +
" REPLACE(CONVERT(VARCHAR(10), ctb_movt.data_cmov, 103), '/', '') AS 'data_valuta',\n" +
" '' AS 'banca',\n" +
" '' AS 'rbn',\n" +
" 'N' AS 'bloccata',\n" +
" IIF(ctb_movr.tipo_anag = 'F', '0201', '0101') AS 'voce',\n" +
" IIF(diacod > 0, diacod, ctb_movr.cod_ccon + ctb_movr.cod_anag) AS 'piano_dei_conti',\n" +
" gtb_anag.rag_soc AS 'descrizione',\n" +
" '' AS 'ABI',\n" +
" '' AS 'CAB',\n" +
" '' AS 'blank',\n" +
" 'CO' AS 'provenienza',\n" +
" '' AS 'sezione',\n" +
" '' AS 'cambio_della_gestione',\n" +
" ISNULL(ctb_movr_intercode.num_doc_orig, '') AS 'numero_doc_origine',\n" +
" IIF(ctb_movr_intercode.intercode IS NOT NULL, ctb_movr_intercode.intercode + FORMAT(\n" +
" DENSE_RANK() OVER (PARTITION BY ctb_movr.cod_anag, ctb_movt.num_doc ORDER BY ctb_movt.data_cmov), '000'),\n" +
" RIGHT(ctb_movr.num_cmov, LEN(ctb_movr.num_cmov) - 2) + FORMAT(ctb_movr.id_riga, '000') +\n" +
" '001') AS chiave_coge,\n" +
" 'ROSSOGARGA' AS 'azienda',\n" +
" '' AS 'numero_cc',\n" +
" '' AS cin,\n" +
" '' AS paese,\n" +
" '' AS chk_paese,\n" +
" REPLACE(CONVERT(VARCHAR(10), ctb_movt.data_cmov, 103), '/', '') AS 'data_documento',\n" +
" ctb_movr.des_agg AS 'note',\n" +
" '' AS 'cod_bic',\n" +
" '' AS 'iban'\n" +
"FROM ctb_movr\n" +
" INNER JOIN ctb_movt\n" +
" ON ctb_movr.num_cmov = ctb_movt.num_cmov\n" +
" INNER JOIN gtb_anag ON ctb_movr.cod_anag = gtb_anag.cod_anag\n" +
" INNER JOIN ctb_caus ON ctb_movt.cod_ccau = ctb_caus.cod_ccau AND ctb_caus.flag_ap_ch = 'N'\n" +
" LEFT OUTER JOIN ctb_movr_intercode ON ctb_movr.num_cmov = ctb_movr_intercode.num_cmov AND\n" +
" ctb_movr.id_riga = ctb_movr_intercode.id_riga\n" +
"WHERE anno_part IS NULL";
List<ScadenzeDocFinanceDTO> scadenzeDocFinance = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ScadenzeDocFinanceDTO.class);
TxtMapper<ScadenzeDocFinanceDTO> txtMapper = new TxtMapper<ScadenzeDocFinanceDTO>()

View File

@@ -509,7 +509,7 @@ public class ContabilService {
return null;
}
public CheckVatRestResponse checkVat(String countryCode, String vatNumber) throws Exception {
public CheckVatRestResponse checkVat(String countryCode, String vatNumber, boolean enableLocationCheck) throws Exception {
String sql =
"SELECT IsNull(cod_nazi_alpha_2, gtb_nazi.nazione) as nazione , gtb_nazi.chk_part_iva " +
" FROM gtb_nazi INNER JOIN gtb_nazi_iso ON gtb_nazi.cod_nazione_iso = gtb_nazi_iso.cod_nazione_iso " +
@@ -522,12 +522,12 @@ public class ContabilService {
Boolean chkPartIva = (Boolean) datiNazione.get("chk_part_iva");
if (chkPartIva) {
return checkVatNazioneIso(isoCountry, vatNumber);
return checkVatNazioneIso(isoCountry, vatNumber, enableLocationCheck);
} else {
return null;
}
}
private CheckVatRestResponse checkVatNazioneIso(String countryCode, String vatNumber) throws Exception {
private CheckVatRestResponse checkVatNazioneIso(String countryCode, String vatNumber, boolean enableLocationCheck) throws Exception {
SupportedStates state = SupportedStates.fromString(countryCode);
if (state == null) {
@@ -569,33 +569,35 @@ public class ContabilService {
response.setValid(valid.value);
if (response.isValid()) {
response.setCountryCode(code.value);
response.setVatNumber(pIva.value);
response.setRequestDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(date.value.toGregorianCalendar().getTimeInMillis())));
if (enableLocationCheck) {
response.setCountryCode(code.value);
response.setVatNumber(pIva.value);
response.setRequestDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(date.value.toGregorianCalendar().getTimeInMillis())));
response.setName(name.value);
response.setAddress(address.value);
response.setRagSoc(name.value);// alias di 'name'
response.setName(name.value);
response.setAddress(address.value);
response.setRagSoc(name.value);// alias di 'name'
String indirizzo = null, cap = null, citta = null, prov = null;
if (address.value != null) {
IndirizzoDTO indirizzoDTO = null;
try {
indirizzoDTO = mapService.geocode(address.value);
} catch (Exception e) {
logger.error("checkVat", e);
}
if (indirizzoDTO != null) {
indirizzo = indirizzoDTO.getIndirizzo();
cap = indirizzoDTO.getCap();
citta = indirizzoDTO.getCitta();
prov = indirizzoDTO.getProv();
String indirizzo = null, cap = null, citta = null, prov = null;
if (address.value != null) {
IndirizzoDTO indirizzoDTO = null;
try {
indirizzoDTO = mapService.geocode(address.value);
} catch (Exception e) {
logger.error("checkVat", e);
}
if (indirizzoDTO != null) {
indirizzo = indirizzoDTO.getIndirizzo();
cap = indirizzoDTO.getCap();
citta = indirizzoDTO.getCitta();
prov = indirizzoDTO.getProv();
}
}
response.setIndirizzo(indirizzo);
response.setCap(cap);
response.setCitta(citta);
response.setProv(prov);
}
response.setIndirizzo(indirizzo);
response.setCap(cap);
response.setCitta(citta);
response.setProv(prov);
} else {
throw new CheckVatException(String.format("Partita IVA %s [Stato: %s] non registrata al VIES", partitaIVA, countryCode));

View File

@@ -114,6 +114,8 @@ public class RossoGarganoSyncService {
e, new Date());
}
throw e;
} finally {
rgExchange.forceClose();
}
}
@@ -351,9 +353,6 @@ public class RossoGarganoSyncService {
}
}
getCtbPart(sourceData, ctbMovt, c);
} else {
numDoc = UtilityHashMap.<BigDecimal>getValueIfExists(c, "PN_NRO_DOCUMENTO").intValue();
ctbMovt.setNumDoc(numDoc);
}
if (pnCausaleMovimento.equalsIgnoreCase("998")) {
@@ -433,6 +432,16 @@ public class RossoGarganoSyncService {
}
}
}
if ( !UtilityString.isNullOrEmpty(ctbMovr.getCodAnag()) && ctbMovr.getNumDoc() == null){
String intercode =
UtilityString.fillString(UtilityHashMap.getValueIfExists(c, "PN_PARTITA").toString(), ' ', 8, UtilityString.H_POSITION.RIGHT) +
UtilityString.BigDecimalToString(UtilityHashMap.getValueIfExists(c, "PN_NRO_RIGA_REG"), "000");
CtbMovrIntercode ctbMovrIntercode = new CtbMovrIntercode()
.setIntercode(intercode)
.setNumDocOrig(UtilityHashMap.getValueIfExists(c, "PN_NRO_DOCUMENTO").toString());
ctbMovr.addCtbMovrIntercode(ctbMovrIntercode);
}
ctbMovt.getCtbMovr().add(ctbMovr);
if (ctbMovrIva != null) {
@@ -815,7 +824,10 @@ public class RossoGarganoSyncService {
" convert(datetime, cast( CL_DATA_MODIFICA as varchar),112) AS data_mod\n" +
"FROM anag\n" +
" LEFT OUTER JOIN " + multiDBTransactionManager.getPrimaryDatasource().getDbName() + ".dbo.ctb_cont ON cl_conto_acquisti = ctb_cont.diacod\n" +
"WHERE cl_data_inserimento >= 20240901 \n" +
"WHERE cl_codice IN (SELECT LTRIM(pn_cod_anag) \n" +
" FROM pnota\n" +
" WHERE pn_cod_anag LIKE '9%'\n" +
" AND pn_data_competenza >= 20180101) \n" +
" AND cl_rif_bilancio NOT IN ('24', '28', '32')\n" +
" AND cl_codice LIKE '9%' \n" +
" AND cl_codice NOT IN (SELECT diacod FROM " + multiDBTransactionManager.getPrimaryDatasource().getDbName() + ".dbo.gtb_anag WHERE diacod IS NOT NULL)";

View File

@@ -36,19 +36,11 @@ public class ToscaSalesService {
private EntityProcessor entityProcessor;
public void importOrdiniLavorazione() {
}
public void importOrdiniVendita(MultipartFile file) throws Exception {
InputStream inputStream = file.getInputStream();
List<ToscaOrdineVenditaDTO> ordiniDaImportare = parseFile(inputStream);
List<Date> invalidDates = ordiniDaImportare.stream().map(ToscaOrdineVenditaDTO::getDateTransaction).distinct().filter(d -> d.before(UtilityDate.getStartOfDay(new Date()))).collect(Collectors.toList());
if (!UtilityList.isNullOrEmpty(invalidDates))
throw new Exception("Caricare l'impegnato per giorni passati non è consentito");
importAnagrafiche(ordiniDaImportare);
Map<String, List<ToscaOrdineVenditaDTO>> ordini = ordiniDaImportare.stream().collect(Collectors.groupingBy(ToscaOrdineVenditaDTO::getTransactionNumber));

View File

@@ -67,7 +67,7 @@ public class ImportListiniAcquistoApuliaCarrefourService {
}
if (UtilityDebug.isDebugExecution() && !UtilityDebug.isIntegryServer()){
pathFile = "\\\\serverdb\\BulkFile\\Apulia\\carelli";
pathFile = "\\\\serverdb\\BulkFile\\Apulia\\" + multiDBTransactionManager.getPrimaryDatasource().getProfile();
}
//INSERIMENTO DATI DA FILE
@@ -312,17 +312,15 @@ public class ImportListiniAcquistoApuliaCarrefourService {
" CASE WHEN data_iniz < '2020/01/01' THEN '2020/01/01' ELSE data_iniz END AS data_iniz,\n" +
" tipo_variazione\n" +
" FROM dbo.getlistinoacquisto([DATA_IMPORT], NULL, NULL, NULL, 'N', NULL) lisa\n" +
" LEFT OUTER JOIN (SELECT value_string AS cod_alis\n" +
" WHERE lisa.cod_alis LIKE 'AP%'\n" +
" AND lisa.tipo_variazione <> 'D'\n" +
" AND lisa.tipo_variazione IS NOT NULL\n" +
" AND NOT EXISTS (SELECT value_string AS cod_alis\n" +
" FROM dbo.parsestringintoarray(\n" +
" (SELECT dbo.getgestsetup('IMPORT_[TYPE]',\n" +
" '[FORMAT]',\n" +
" 'LISTINI_DA_ESCLUDERE')),\n" +
" '|')) listini_esclusi\n" +
" ON lisa.cod_alis = listini_esclusi.cod_alis\n" +
" WHERE lisa.cod_alis LIKE 'AP%'\n" +
" AND lisa.tipo_variazione <> 'D'\n" +
" AND lisa.tipo_variazione IS NOT NULL\n" +
" AND listini_esclusi.cod_alis IS NULL) lisa\n" +
" '|') listini_esclusi WHERE lisa.cod_alis = listini_esclusi.value_string)) lisa\n" +
" ON apulia.cod_alis = lisa.cod_alis AND apulia.cod_art_for = lisa.cod_art_for\n" +
" LEFT OUTER JOIN mtb_lisa ON apulia.cod_alis = mtb_lisa.cod_alis AND apulia.cod_art_for = mtb_lisa.cod_art_for\n" +
" LEFT OUTER JOIN mtb_aart ON mtb_lisa.cod_mart = mtb_aart.cod_mart\n" +

View File

@@ -496,7 +496,8 @@ public class ProductionOrderDataHandlerService {
" jtb_cicl.unt_mis_prod, " +
" mtb_tcol.descrizione," +
" mtb_aart.flag_tracciabilita," +
" setupCaricoImmediato.flag_carico_scarico_immediato " +
" setupCaricoImmediato.flag_carico_scarico_immediato, " +
" dtb_ordt.data_cons_prod_max" +
" ORDER BY dtb_ordr.data_ord, dtb_ordr.num_ord, dtb_ordr.pos_riga, dtb_ordt.num_ord";
}

View File

@@ -1661,13 +1661,16 @@ public class SystemController {
return ServiceRestResponse.createPositiveResponse();
}
@RequestMapping(value = "/system/test", method = RequestMethod.POST)
@RequestMapping(value = "/system/test", method = RequestMethod.GET)
public @ResponseBody
ServiceRestResponse systemTest() throws Exception {
mailService.sendErrorMail(multiDBTransactionManager, "g.scorrano@integry.it", "Test",
"Test email", null, null, null,
Collections.singletonList(new NotValidLicenseException()));
Thread.sleep(10 * 60 * 1000);
// mailService.sendErrorMail(multiDBTransactionManager, "g.scorrano@integry.it", "Test",
// "Test email", null, null, null,
// Collections.singletonList(new NotValidLicenseException()));
return ServiceRestResponse.createPositiveResponse();

View File

@@ -30,13 +30,28 @@ public class ExchangeDocumentImportController {
@RequestMapping(value = "importLavorazione", method = RequestMethod.GET)
public @ResponseBody
ServiceRestResponse importDocumentiLavorazione(HttpServletRequest request,
ServiceRestResponse importLavorazione(HttpServletRequest request,
@RequestParam(CommonConstants.PROFILE_DB) String profileDb,
@RequestParam() String profileDbExchange) throws Exception {
try (MultiDBTransactionManager internalDb = new MultiDBTransactionManager(profileDb);
MultiDBTransactionManager exchangeDb = new MultiDBTransactionManager(profileDbExchange)) {
exchangeDocumentImportService.importTestateDocumentiLavorazione(internalDb, exchangeDb, requestDataDTO);
exchangeDocumentImportService.importLavorazione(internalDb, exchangeDb, requestDataDTO);
}
return ServiceRestResponse.createPositiveResponse();
}
@RequestMapping(value = "importVendita", method = RequestMethod.GET)
public @ResponseBody
ServiceRestResponse importVendita(HttpServletRequest request,
@RequestParam(CommonConstants.PROFILE_DB) String profileDb,
@RequestParam() String profileDbExchange) throws Exception {
try (MultiDBTransactionManager internalDb = new MultiDBTransactionManager(profileDb);
MultiDBTransactionManager exchangeDb = new MultiDBTransactionManager(profileDbExchange)) {
exchangeDocumentImportService.importVendita(internalDb, exchangeDb, requestDataDTO);
}
return ServiceRestResponse.createPositiveResponse();
}

View File

@@ -43,16 +43,39 @@ public class ExchangeDocumentImportService {
private final Logger logger = LogManager.getLogger();
public void importTestateDocumentiLavorazione(MultiDBTransactionManager internalMultiDb, MultiDBTransactionManager exchangeMultiDb, RequestDataDTO requestDataDTO) throws Exception {
public void importLavorazione(MultiDBTransactionManager internalMultiDb, MultiDBTransactionManager exchangeMultiDb, RequestDataDTO requestDataDTO) throws Exception {
this.internalImport(internalMultiDb, exchangeMultiDb, requestDataDTO, ExchangeImportSchemaManagerService.SchemaType.DocumentiLavorazione);
}
public void importVendita(MultiDBTransactionManager internalMultiDb, MultiDBTransactionManager exchangeMultiDb, RequestDataDTO requestDataDTO) throws Exception {
this.internalImport(internalMultiDb, exchangeMultiDb, requestDataDTO, ExchangeImportSchemaManagerService.SchemaType.DocumentiVendita);
}
private void internalImport(MultiDBTransactionManager internalMultiDb, MultiDBTransactionManager exchangeMultiDb, RequestDataDTO requestDataDTO, ExchangeImportSchemaManagerService.SchemaType schemaType) throws Exception {
boolean useTempTable = true;
ExchangeImportSchemaManagerService.SchemaType schemaType = ExchangeImportSchemaManagerService.SchemaType.DocumentiLavorazione;
try {
exchangeImportSchemaManagerService.syncSchema(exchangeMultiDb.getPrimaryConnection(), schemaType, useTempTable);
exchangeImportDataManagerService.prepareData(exchangeMultiDb.getPrimaryConnection(), useTempTable,
exchangeImportSchemaManagerService.getTablesBySchemaType(schemaType));
String testataTableName;
String righeTableName;
if (schemaType == ExchangeImportSchemaManagerService.SchemaType.DocumentiLavorazione) {
testataTableName = "dtb_doct_lav";
righeTableName = "dtb_docr_lav";
} else if (schemaType == ExchangeImportSchemaManagerService.SchemaType.DocumentiVendita) {
testataTableName = "dtb_doct_vend";
righeTableName = "dtb_docr_vend";
} else {
righeTableName = null;
testataTableName = null;
}
AtomicInteger dataCount = new AtomicInteger(0);
AtomicInteger importedCounter = new AtomicInteger(0);
@@ -66,30 +89,30 @@ public class ExchangeDocumentImportService {
startDate = startDate.plusDays(1);
final List<DtbDoct> exchangeImportedTestateData = importTestateDocumentiLavorazione(
final List<DtbDoct> exchangeImportedTestateData = importTestateDocumenti(
exchangeMultiDb.getPrimaryConnection(),
tempStartDate,
tempEndDate,
true, false);
true, false, testataTableName);
final List<DtbDoct> exchangeUpdatedTestateData = importTestateDocumentiLavorazione(
final List<DtbDoct> exchangeUpdatedTestateData = importTestateDocumenti(
exchangeMultiDb.getPrimaryConnection(),
tempStartDate,
tempEndDate,
false, useTempTable);
false, useTempTable, testataTableName);
final List<DtbDocr> exchangeImportedRigheData = importRigheDocumentiLavorazione(
final List<DtbDocr> exchangeImportedRigheData = importRigheDocumenti(
exchangeMultiDb.getPrimaryConnection(),
tempStartDate,
tempEndDate,
true, false);
true, false, righeTableName);
final List<DtbDocr> exchangeUpdatedRigheData = importRigheDocumentiLavorazione(
final List<DtbDocr> exchangeUpdatedRigheData = importRigheDocumenti(
exchangeMultiDb.getPrimaryConnection(),
tempStartDate,
tempEndDate,
false, useTempTable);
false, useTempTable, righeTableName);
List<EquatableEntityInterface> allTestateData = exchangeImportDataManagerService
.runSync(DtbDoct.class, exchangeImportedTestateData, exchangeUpdatedTestateData);
@@ -101,6 +124,12 @@ public class ExchangeDocumentImportService {
((DtbDoct) x).setUpdProgMaga(false);
});
allRigheData.parallelStream()
.filter(x -> x.getOperation() == OperationType.INSERT)
.forEach(x -> {
x.setOperation(OperationType.INSERT_OR_UPDATE);
});
allRigheData.stream()
.map(x -> (DtbDocr) x)
.filter(x -> allTestateData.stream()
@@ -160,7 +189,7 @@ public class ExchangeDocumentImportService {
//ignore error if is DELETE
if (document.getOperation() != OperationType.DELETE) throw mergeEntityDBToObjectException;
}
singleUpdateImported(exchangeMultiDb.getPrimaryConnection(), (DtbDoct) dataToSave, useTempTable);
singleUpdateImported(exchangeMultiDb.getPrimaryConnection(), (DtbDoct) dataToSave, useTempTable, testataTableName);
if (!document.getDtbDocr().isEmpty()) {
@@ -169,7 +198,7 @@ public class ExchangeDocumentImportService {
entityProcessor.processEntity(document, true, true, ROSSOGARGANO_EXCHANGE_USER, internalMultiDb, requestDataDTO);
}
singleUpdateImported(exchangeMultiDb.getPrimaryConnection(), document.getDtbDocr(), useTempTable);
singleUpdateImported(exchangeMultiDb.getPrimaryConnection(), document.getDtbDocr(), useTempTable, righeTableName);
}
internalMultiDb.commitAll();
@@ -202,16 +231,15 @@ public class ExchangeDocumentImportService {
}
private List<DtbDoct> importTestateDocumentiLavorazione(Connection connection,
LocalDate minDate, LocalDate maxDate, boolean retrieveAlreadyImported, boolean useTempTable) throws Exception {
private List<DtbDoct> importTestateDocumenti(Connection connection, LocalDate minDate, LocalDate maxDate,
boolean retrieveAlreadyImported, boolean useTempTable, String tableName) throws Exception {
String dtbDoctLavOriginalName = "dtb_doct_lav";
String dtbDoctLavOriginalName = tableName;
String dtbDoctLavTableName = dtbDoctLavOriginalName + (useTempTable ? "_tmp" : "");
final List<DtbDoct> dtbDoctLav = exchangeImportDataManagerService.retrieveDataFromExchange(connection, DtbDoct.class,
dtbDoctLavTableName, Query.format("data_doc BETWEEN {} AND {}", minDate, maxDate), retrieveAlreadyImported);
dtbDoctLav
.forEach(x -> {
x.setUserName(ROSSOGARGANO_EXCHANGE_USER);
@@ -222,10 +250,10 @@ public class ExchangeDocumentImportService {
}
private List<DtbDocr> importRigheDocumentiLavorazione(Connection connection,
LocalDate minDate, LocalDate maxDate, boolean retrieveAlreadyImported, boolean useTempTable) throws Exception {
private List<DtbDocr> importRigheDocumenti(Connection connection, LocalDate minDate, LocalDate maxDate,
boolean retrieveAlreadyImported, boolean useTempTable, String tableName) throws Exception {
String dtbDocrLavOriginalName = "dtb_docr_lav";
String dtbDocrLavOriginalName = tableName;
String dtbDocrLavTableName = dtbDocrLavOriginalName + (useTempTable ? "_tmp" : "");
@@ -234,7 +262,7 @@ public class ExchangeDocumentImportService {
}
private void singleUpdateImported(Connection connection, DtbDoct importedDtbDoct, boolean useTempTable) throws Exception {
private void singleUpdateImported(Connection connection, DtbDoct importedDtbDoct, boolean useTempTable, String tableName) throws Exception {
final HashMap<String, Object> importedKey = new HashMap<String, Object>() {{
put("data_doc", importedDtbDoct.getDataDoc());
put("ser_doc", importedDtbDoct.getSerDoc());
@@ -243,10 +271,10 @@ public class ExchangeDocumentImportService {
put("cod_dtip", importedDtbDoct.getCodDtip());
}};
exchangeImportDataManagerService.updateImportedStatus(connection, "dtb_doct_lav", importedKey, useTempTable);
exchangeImportDataManagerService.updateImportedStatus(connection, tableName, importedKey, useTempTable);
}
private void singleUpdateImported(Connection connection, List<DtbDocr> importedDtbDocr, boolean useTempTable) throws Exception {
private void singleUpdateImported(Connection connection, List<DtbDocr> importedDtbDocr, boolean useTempTable, String tableName) throws Exception {
final List<HashMap<String, Object>> importedRowKeys = importedDtbDocr.stream()
.map(x -> new HashMap<String, Object>() {{
put("data_doc", x.getDataDoc());
@@ -256,7 +284,7 @@ public class ExchangeDocumentImportService {
put("cod_dtip", x.getCodDtip());
put("id_riga", x.getIdRiga());
}}).collect(Collectors.toList());
exchangeImportDataManagerService.updateImportedStatus(connection, "dtb_docr_lav", importedRowKeys, useTempTable);
exchangeImportDataManagerService.updateImportedStatus(connection, tableName, importedRowKeys, useTempTable);
}
}

View File

@@ -26,7 +26,8 @@ public class ExchangeImportSchemaManagerService {
VersamentoGrezzo(6),
CampiRaccolta(7),
BancheAziendali(8),
ValorizzazioneCertificati(9);
ValorizzazioneCertificati(9),
DocumentiVendita(10),;
private final int value;
@@ -65,6 +66,7 @@ public class ExchangeImportSchemaManagerService {
put(SchemaType.ColliLavorazione, Arrays.asList("mtb_colt_lav", "mtb_colr_lav"));
put(SchemaType.OrdiniLavorazione, Arrays.asList("dtb_ordt_lav", "dtb_ordr_lav"));
put(SchemaType.DocumentiLavorazione, Arrays.asList("dtb_doct_lav", "dtb_docr_lav"));
put(SchemaType.DocumentiVendita, Arrays.asList("dtb_doct_vend", "dtb_docr_vend"));
put(SchemaType.Articoli, Arrays.asList("mtb_aart", "mtb_grup", "mtb_sgrp", "mtb_sfam", "mtb_tipi", "mtb_aart_marchio"));
put(SchemaType.PartiteMagazzinoLavorazione, Arrays.asList("mtb_partita_mag_lav"));
put(SchemaType.VersamentoGrezzo, Arrays.asList("mtb_colt_versamento_grezzo", "mtb_colr_versamento_grezzo"));

View File

@@ -118,7 +118,12 @@ public class ExchangeSystemManagerService {
case DocumentiLavorazione:
final ExchangeDocumentImportService beanDocumentiLavorazione = ContextLoader.getCurrentWebApplicationContext().getBean(ExchangeDocumentImportService.class);
beanDocumentiLavorazione.importTestateDocumentiLavorazione(internalDb, exchangeDb, requestDataDTO);
beanDocumentiLavorazione.importLavorazione(internalDb, exchangeDb, requestDataDTO);
break;
case DocumentiVendita:
final ExchangeDocumentImportService beanDocumentiVendita = ContextLoader.getCurrentWebApplicationContext().getBean(ExchangeDocumentImportService.class);
beanDocumentiVendita.importVendita(internalDb, exchangeDb, requestDataDTO);
break;
case Articoli: