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

This commit is contained in:
2024-09-13 18:17:01 +02:00
18 changed files with 451 additions and 28 deletions

View File

@@ -11,6 +11,7 @@ import it.integry.ems.utility.UtilityDebug;
import it.integry.ems_model.entity.Azienda;
import it.integry.ems_model.entity.StbGestSetup;
import it.integry.ems_model.entity.StbGestSetupQuery;
import it.integry.ems_model.entity.StbGestSync;
import it.integry.ems_model.exception.DataConverterNotFoundException;
import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
import it.integry.ems_model.types.ApplicationName;
@@ -454,4 +455,28 @@ public abstract class BaseMigration implements MigrationModelInterface {
Azienda currentAzienda = Azienda.getDefaultAzienda(advancedDataSource.getConnection());
return currentAzienda.getApplicationNameEnum() == ApplicationName.DMS;
}
protected void enableSaveToRest(String gestName) throws Exception {
boolean existRow =
UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
Query.format("SELECT cast(count(*) as bit) FROM stb_gest_sync WHERE gest_name = %s", gestName));
StbGestSync gestSync =
new StbGestSync()
.setGestName(gestName)
.setSyncronize("R");
if (existRow) {
gestSync.setOperation(OperationType.UPDATE);
} else{
String entityName =
UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
Query.format("SELECT entity_name FROM stb_menu_opz WHERE gest_name = %s", gestName));
gestSync.setEntityName(entityName);
gestSync.setOperation(OperationType.INSERT);
}
gestSync.manageWithParentConnection(advancedDataSource.getConnection());
}
}

View File

@@ -2,6 +2,8 @@ package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
import it.integry.ems.utility.UtilityDebug;
import it.integry.ems_model.utility.UtilityDB;
public class Migration_20240906164323 extends BaseMigration implements MigrationModelInterface {
@@ -9,7 +11,7 @@ public class Migration_20240906164323 extends BaseMigration implements Migration
public void up() throws Exception {
if (isHistoryDB())
return;
if (UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer()) return;
executeStatement("update stb_menu set flag_attivo = 'N' where cod_opz in ('vg107', 'ag030','ag031','lg081','lg082', 'vg106', 'ag032')" );
}

View File

@@ -0,0 +1,27 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20240913112628 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
executeStatement("CREATE TABLE dtb_note_doc (id bigint identity not null,note varchar(8000) not null, \n" +
" CONSTRAINT PK_dtb_note_doc PRIMARY KEY (id));\n" +
"\n" +
"CREATE TABLE drl_tipi_note_doc (cod_dtip varchar(5) not null, id_note bigint not null, id_riga integer not null, \n" +
" CONSTRAINT PK_drl_tipi_note_doc PRIMARY KEY (cod_dtip, id_note),\n" +
" CONSTRAINT FK_drl_tipi_note_doc_cod FOREIGN KEY (cod_dtip) REFERENCES dtb_tipi(cod_dtip),\n" +
" CONSTRAINT FK_drl_tipi_note_doc_id FOREIGN KEY (id_note) REFERENCES dtb_note_doc(id));");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,24 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20240913135928 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
executeStatement("alter table ctb_cont add data_ins datetime",
"alter table ctb_cont add data_mod datetime");
}
@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.MigrationModelInterface;
public class Migration_20240913141508 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
executeStatement(
"update ctb_cont set data_ins = IsNull(c.data_cmov, '2000/01/01'), data_mod = Isnull(c.data_cmov, '2000/01/01') " +
"FROM ctb_cont cross apply (select MIN(data_cmov) as data_cmov from ctb_movt ) c",
"alter table ctb_cont alter column data_ins datetime not null",
"alter table ctb_cont alter column data_mod datetime not null");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,27 @@
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_20240913144135 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
if (isCustomer(IntegryCustomer.RossoGargano))
executeStatement("update ctb_cont set ctb_cont.data_ins = convert(datetime, cast( CL_DATA_INSERIMENTO as varchar),112),\n" +
"ctb_cont.data_mod = convert(datetime, cast( CL_DATA_MODIFICA as varchar),112)\n" +
"from ctb_cont \n" +
"inner join RossoGarganoExchange.dbo.ANAG on ctb_cont.diacod = ANAG.CL_CODICE\n" +
"\n");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,39 @@
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_20240913153037 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
if ( !isCustomer(IntegryCustomer.Biolevante)) return;
executeStatement("insert into dtb_note_doc \n" +
"values ('Eventuali variazioni di IBAN sono da considerarsi valide solo se confermate direttamente dal personale della OLIO LEVANTE SRL a mezzo telefono'),\n" +
"('Any changes of IBAN are to be considered valid only if confirmed directly by the staff of OLIO LEVANTE SRL by phone')",
"insert into drl_tipi_note_doc\n" +
"select cod_dtip, 1, 1\n" +
"from dtb_tipi \n" +
"where mod_stamp in ('MOD7', 'BOLAC','FAT','MOD10','MOD8','MOD6')\n" +
"and gestione = 'v' ",
"insert into drl_tipi_note_doc\n" +
"select cod_dtip,2, 1\n" +
"from dtb_tipi \n" +
"where mod_stamp in ('MOD4','FATAC','MOD1','MOD5','MOD2','MOD3')\n" +
"and gestione = 'v'\n" +
"\n"
);
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,21 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20240913154727 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
enableSaveToRest("ccont");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,44 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20240913171829 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createSetup("IMPORT_ANAGRAFICHE ARTICOLI", "FOTO", "ATTIVO", "N",
"Inserire S/N per attivare/disattivare il tipo di importazione", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_ANAGRAFICHE ARTICOLI", "FOTO", "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("IMPORT_ANAGRAFICHE ARTICOLI", "FOTO", "FILE_FILTER", null,
"Inserire il criterio di filtro dei file o il nome del file specifio (seguire la sintassi di java)", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_ANAGRAFICHE ARTICOLI", "FOTO", "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("IMPORT_ANAGRAFICHE ARTICOLI", "FOTO", "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("IMPORT_ANAGRAFICHE ARTICOLI", "FOTO", "LISTENING", "N",
"Se LISTENIG = 'N' la procedura di importazione non si potrà mai mettere in ascolto sulla directory perchè nella procedura vengono prese in considerazione più file.", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_ANAGRAFICHE ARTICOLI", "FOTO", "PATH_FILE", null,
"Directory contente i file da importare.", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_ANAGRAFICHE ARTICOLI", "FOTO", "PATH_FILE_IMPORTED", null,
"Directory dove vengono spostati i file dopo l'importazione.", false, null, false, false,
false, false, false, null, false, null);
}
@Override
public void down() throws Exception {
}
}

View File

@@ -1,16 +1,19 @@
package it.integry.ems_model.entity;
import com.fasterxml.jackson.annotation.JsonTypeName;
import it.integry.common.var.CommonConstants;
import it.integry.ems_model.annotation.Master;
import it.integry.ems_model.annotation.PK;
import it.integry.ems_model.annotation.SqlField;
import it.integry.ems_model.annotation.Table;
import it.integry.ems_model.base.EntityBase;
import it.integry.ems_model.config.EmsRestConstants;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.kie.api.definition.type.PropertyReactive;
import java.math.BigDecimal;
import java.util.Date;
@Master
@PropertyReactive
@@ -64,6 +67,12 @@ public class CtbCont extends EntityBase {
@SqlField(value = "diacod", maxLength = 40)
private String diacod;
@SqlField(value = "data_ins", defaultObjectValue = CommonConstants.TIMESTAMP)
private Date dataIns;
@SqlField(value = "data_mod", defaultObjectValue = CommonConstants.TIMESTAMP)
private Date dataMod;
public CtbCont() {
super(logger);
}
@@ -172,4 +181,22 @@ public class CtbCont extends EntityBase {
this.diacod = diacod;
return this;
}
public Date getDataIns() {
return dataIns;
}
public CtbCont setDataIns(Date dataIns) {
this.dataIns = dataIns;
return this;
}
public Date getDataMod() {
return dataMod;
}
public CtbCont setDataMod(Date dataMod) {
this.dataMod = dataMod;
return this;
}
}

View File

@@ -0,0 +1,65 @@
package it.integry.ems_model.entity;
import com.fasterxml.jackson.annotation.JsonTypeName;
import it.integry.ems_model.annotation.*;
import it.integry.ems_model.base.EntityBase;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.kie.api.definition.type.PropertyReactive;
@Master()
@PropertyReactive()
@Table(value = DrlTipiNoteDoc.ENTITY)
@JsonTypeName(value = DrlTipiNoteDoc.ENTITY)
public class DrlTipiNoteDoc extends EntityBase {
public final static String ENTITY = "drl_tipi_note_doc";
private final static Long serialVersionUID = 1L;
private final static Logger logger = LogManager.getLogger();
public DrlTipiNoteDoc() {
super(logger);
}
@PK()
@SqlField(value = "cod_dtip", maxLength = 5, nullable = false)
@FK(tableName = DtbTipi.ENTITY, columnName = "cod_dtip")
private String codDtip;
@PK()
@SqlField(value = "id_note", nullable = false)
@FK(tableName = DtbNoteDoc.ENTITY, columnName = "id")
private Long idNote;
@SqlField(value = "id_riga", nullable = false)
private Integer idRiga;
public String getCodDtip() {
return codDtip;
}
public DrlTipiNoteDoc setCodDtip(String codDtip) {
this.codDtip = codDtip;
return this;
}
public Long getIdNote() {
return idNote;
}
public DrlTipiNoteDoc setIdNote(Long idNote) {
this.idNote = idNote;
return this;
}
public Integer getIdRiga() {
return idRiga;
}
public DrlTipiNoteDoc setIdRiga(Integer idRiga) {
this.idRiga = idRiga;
return this;
}
}

View File

@@ -0,0 +1,53 @@
package it.integry.ems_model.entity;
import com.fasterxml.jackson.annotation.JsonTypeName;
import it.integry.ems_model.annotation.*;
import it.integry.ems_model.base.EntityBase;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.kie.api.definition.type.PropertyReactive;
@Master()
@PropertyReactive()
@Table(value = DtbNoteDoc.ENTITY)
@JsonTypeName(value = DtbNoteDoc.ENTITY)
public class DtbNoteDoc extends EntityBase {
public final static String ENTITY = "dtb_note_doc";
private final static Long serialVersionUID = 1L;
private final static Logger logger = LogManager.getLogger();
public DtbNoteDoc() {
super(logger);
}
@PK()
@Identity()
@SqlField(value = "id", nullable = false)
private Long id;
@SqlField(value = "note", maxLength = 8000, nullable = false)
private String note;
public Long getId() {
return id;
}
public DtbNoteDoc setId(Long id) {
this.id = id;
return this;
}
public String getNote() {
return note;
}
public DtbNoteDoc setNote(String note) {
this.note = note;
return this;
}
}

View File

@@ -45,31 +45,35 @@ public class StbGestSync extends EntityBase {
return gestName;
}
public void setGestName(String gestName) {
public StbGestSync setGestName(String gestName) {
this.gestName = gestName;
return this;
}
public String getEntityName() {
return entityName;
}
public void setEntityName(String entityName) {
public StbGestSync setEntityName(String entityName) {
this.entityName = entityName;
return this;
}
public String getSaveLog() {
return saveLog;
}
public void setSaveLog(String saveLog) {
public StbGestSync setSaveLog(String saveLog) {
this.saveLog = saveLog;
return this;
}
public String getSyncronize() {
return syncronize;
}
public void setSyncronize(String syncronize) {
public StbGestSync setSyncronize(String syncronize) {
this.syncronize = syncronize;
return this;
}
}

File diff suppressed because one or more lines are too long

View File

@@ -48,6 +48,15 @@ then
}
end
rule "completeDataModGtbAnag"
no-loop
when
eval(completeRulesEnabled)
$entity : GtbAnag(operation != OperationType.DELETE)
then
modify ( $entity ) { setDataMod(new Date()) }
end
rule "completeDataUltAggPersRif"
when
eval(completeRulesEnabled)

View File

@@ -20,6 +20,18 @@ global Boolean postRulesEnabled
global Boolean checkRulesEnabled
global Boolean completeRulesEnabled
//ctb_cont
rule "completeDataModCtbCont"
no-loop
when
eval(completeRulesEnabled)
$entity : CtbCont(operation != OperationType.DELETE)
then
modify ( $entity ) { setDataMod(new Date()) }
end
//MOVIMENTI
//TESTATE
@@ -35,6 +47,8 @@ then
end
rule "completeTipoAnagMov"
no-loop
when

View File

@@ -747,7 +747,12 @@ public class RossoGarganoSyncService {
" UNION\n" +
" SELECT diacod\n" +
" FROM " + multiDBTransactionManager.getPrimaryDatasource().getDbName() + ".dbo.gtb_anag\n" +
" WHERE diacod IS NOT NULL))\n" +
" WHERE diacod IS NOT NULL)\n" +
" union\n" +
" select cl_codice from ANAG \n" +
" where convert(datetime, cast( CL_DATA_MODIFICA as varchar),112) >= DateAdd(week,-1, getDate()) \n" +
" AND cl_codice NOT LIKE '9%'\n" +
" AND cl_codice NOT LIKE '1%')\n" +
" , conti_new AS (SELECT SUBSTRING(cl_codice, 2, 4) AS cod_cmas,\n" +
" SUBSTRING(cl_codice, 2, 2) AS cod_cgrp,\n" +
" cl_ragione_soc AS descrizione,\n" +
@@ -755,23 +760,24 @@ public class RossoGarganoSyncService {
" 'N' AS flag_cont_att,\n" +
" 'N' AS flag_risconto,\n" +
" 0 AS perc_ded,\n" +
" cl_codice AS diacod\n" +
" cl_codice AS diacod,\n" +
" convert(datetime, cast( CL_DATA_INSERIMENTO as varchar),112) AS data_ins,\n" +
" convert(datetime, cast( CL_DATA_MODIFICA as varchar),112) AS data_mod\n" +
" FROM anag\n" +
" WHERE cl_codice IN (SELECT pn_cod_anag FROM conti)\n" +
" WHERE cl_codice IN (SELECT pn_cod_anag FROM conti) \n" +
" AND cl_codice NOT LIKE '9%'\n" +
" AND cl_codice NOT LIKE '1%')\n" +
"\n" +
"\n" +
"SELECT distinct FORMAT(CAST(conti_rg.max_id AS INT) +\n" +
"SELECT distinct isNull(ctb_cont.cod_ccon, FORMAT(CAST(conti_rg.max_id AS INT) +\n" +
" ROW_NUMBER() OVER (PARTITION BY conti_new.cod_cgrp, conti_new.cod_cmas ORDER BY conti_new.diacod),\n" +
" '000000') AS cod_ccon,\n" +
" '000000')) AS cod_ccon,\n" +
" conti_new.*\n" +
"FROM conti_new\n" +
" INNER JOIN (SELECT cod_cgrp, cod_cmas, MAX(cod_ccon) AS max_id\n" +
" FROM rossogargano.dbo.ctb_cont\n" +
" GROUP BY cod_cgrp, cod_cmas) conti_rg\n" +
" ON conti_new.cod_cgrp = conti_rg.cod_cgrp AND conti_new.cod_cmas = conti_rg.cod_cmas";
List<CtbCont> ctbConts = new ResultSetMapper().mapQuerySetToList(sourceData, sql, CtbCont.class, OperationType.INSERT);
" ON conti_new.cod_cgrp = conti_rg.cod_cgrp AND conti_new.cod_cmas = conti_rg.cod_cmas\n" +
" LEFT OUTER JOIN " + multiDBTransactionManager.getPrimaryDatasource().getDbName() + ".dbo.ctb_cont ON conti_new.diacod = ctb_cont.diacod ";
List<CtbCont> ctbConts = new ResultSetMapper().mapQuerySetToList(sourceData, sql, CtbCont.class, OperationType.INSERT_OR_UPDATE);
UtilityEntity.throwEntitiesException(entityProcessor.processEntityList(ctbConts, true));
}

View File

@@ -23,7 +23,9 @@ import it.integry.ems_model.service.SetupGest;
import it.integry.ems_model.types.OperationType;
import it.integry.ems_model.types.TypeDbObject;
import it.integry.ems_model.utility.*;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -34,6 +36,7 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.FileInputStream;
import java.math.BigDecimal;
import java.sql.*;
import java.text.SimpleDateFormat;
@@ -1023,7 +1026,7 @@ public class ProductServices {
if (filePath == null) {
mtbAartList.add(
prepareEntityForImportFoto(requestDto.getFileName())
prepareEntityForImportFoto(requestDto.getFileName(), requestDto.getRawContentB64())
);
} else {
File directory = new File(filePath);
@@ -1034,10 +1037,9 @@ public class ProductServices {
if (files != null) {
for (File file : files) {
if (file.isFile()) {
mtbAartList.add(
prepareEntityForImportFoto(file.getName())
);
MtbAart aart = prepareEntityForImportFoto(file);
if (aart != null)
mtbAartList.add(aart);
}
}
} else {
@@ -1050,10 +1052,18 @@ public class ProductServices {
throw new Exception("Nessuna immagine salvata");
}
return entityProcessor.processEntityList(mtbAartList, multiDBTransactionManager, true);
return entityProcessor.processEntityList(mtbAartList, multiDBTransactionManager, false);
}
private MtbAart prepareEntityForImportFoto(String fileName) throws Exception {
private MtbAart prepareEntityForImportFoto(File file) throws Exception {
String fileName = file.getName().toLowerCase();
byte[] content = FileUtils.readFileToByteArray(file);
String b64File = Base64.encodeBase64String(content);
return prepareEntityForImportFoto(fileName, b64File);
}
private MtbAart prepareEntityForImportFoto(String fileName, String b64File) throws Exception {
List<String> validExtensions = Arrays.asList(".jpg", ".jpeg", ".png", ".gif");
int extensionIndex = fileName.lastIndexOf(".");
String codMart;
@@ -1067,21 +1077,22 @@ public class ProductServices {
String[] arg = codMart.split("-");
if (arg.length > 0) codMart = arg[0];
MtbAartLink searchArtLink = new MtbAartLink();
searchArtLink.setCodMart(codMart);
searchArtLink.setPathLink(fileName);
searchArtLink.setOperation(OperationType.SELECT);
List<EntityBase> artLinkResult = entityProcessor.processEntity(searchArtLink, multiDBTransactionManager);
Integer idRiga =
UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(),
it.integry.ems_model.utility.Query.format("SELECT id_riga from mtb_aart_link where cod_mart = %s and path_link = %s",
codMart, fileName));
MtbAartLink mtbAartLink = new MtbAartLink();
mtbAartLink.setCodMart(codMart);
mtbAartLink.setPathLink(fileName);
mtbAartLink.setB64Content(b64File);
mtbAartLink.setDescrizioneLink("Immagine prodotto " + codMart);
if (artLinkResult == null || artLinkResult.isEmpty()) {
if (idRiga ==null) {
mtbAartLink.setOperation(OperationType.INSERT);
} else {
mtbAartLink.setIdRiga(idRiga);
mtbAartLink.setOperation(OperationType.UPDATE);
}