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

This commit is contained in:
2024-05-30 15:51:47 +02:00
15 changed files with 274 additions and 47 deletions

View File

@@ -0,0 +1,36 @@
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;
public class Migration_20240529103245 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
if (!isCustomerDb(IntegryCustomerDB.Suit_Puglia)){
return;
}
createSetup("FARMMES", "SETUP", "CICLO_PROD_INVENTARIO", "INGRASSO|SVEZZAMENTO", null, false, null, false, false, false, false, false, null, false, null);
createSetup("FARMMES", "SETUP", "CIFRE_DEC_PESO_MEDIO", "5", "Indica il numero di cifre di arrotondamento del calcolo del peso medio passato ai filtri dei WS", false, null, false, false, false, false, false, null, false, null);
createSetup("FARMMES", "SETUP", "COD_PROD_VEN_INGRASSO_03", "0704010", "DESCRIZIONE PRODOTTO PER VENDITA DA INGRASSO", false, null, false, false, false, false, false, null, false, null);
createSetup("FARMMES", "SETUP", "COD_PROD_VEN_INGRASSO_04", "0704011", "DESCRIZIONE PRODOTTO PER VENDITA DA INGRASSO", false, null, false, false, false, false, false, null, false, null);
createSetupQuery("SI_NO", "SI_NO", "SELECT 'S' UNION ALL SELECT 'N'", false);
createSetup("FARMMES", "SETUP", "SCAR_MANGIMI_NEW", "S", "Se impostato a S viene gestito lo scarico dei mangimi con la nuova logica che permette lo scarico di tutti i mangimi e non per fase del ciclo produttivo", false, "SI_NO", false, false, false, false, false, null, false, "SELECT 'S' UNION ALL SELECT 'N'");
createSetup("FARMMES", "SETUP", "SUISAN_COD_DTIP_TRASF", "DDTLX", null, false, null, false, false, false, false, false, null, false, null);
createSetup("FARMMES", "SETUP", "SUISAN_COD_MDEP_TRASF", "SUISA", null, false, null, false, false, false, false, false, null, false, null);
createSetup("FARMMES", "SETUP", "SUISAN_PREF_PARTITA_MAG_TRASF", "SS", null, false, null, false, false, false, false, false, null, false, null);
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,20 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20240529130027 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
executeStatement("EXEC sp_addextendedproperty 'MS_Description', 'Valori possibili: null -> righe documento, 1 -> Riepilogo totali INTRA', 'SCHEMA', 'dbo', 'TABLE', 'dtb_docr', 'COLUMN', 'flag_sezione'");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,22 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20240529154500 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createSetup("w_adocu_oneri_new_rc", "GEST_ONERI", "GESTISCI_TARA_IN_PESO", "S", "Se impostato a N nel calcolo del peso non viene presa l'eventuale tara presente in anagrafica", false, null, false, false, false, false, false, null, false, 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_20240529183729 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
if (!isCustomer(IntegryCustomer.Gramm)){
return;
}
createSetup("IMPORT_ORDINI", "EURITMO", "SET_DATA_DECOR_DATA_CONS_C1047", "S", null, false, null, false, false, false, false, false, null, false, null);
createSetup("IMPORT_ORDINI", "EURITMO", "SET_DATA_DECOR_DATA_CONS_C0731", "S", null, false, null, false, false, false, false, false, null, false, null);
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,26 @@
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_20240529183817 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
if (!isCustomer(IntegryCustomer.Gramm)){
return;
}
createSetup("IMPORT_ORDINI", "GS", "SET_DATA_DECOR_DATA_CONS_C0326", "S", null, false, null, false, false, false, false, false, null, false, null);
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,26 @@
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_20240530093711 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
if (!isCustomer(IntegryCustomer.Gramm)){
return;
}
createSetup("w_adocu_oneri_new_rc", "GEST_ONERI", "GESTISCI_TARA_IN_PESO", "N", "Se impostato a N nel calcolo del peso non viene presa l'eventuale tara presente in anagrafica", false, null, false, false, false, false, false, null, false, null);
}
@Override
public void down() throws Exception {
}
}

View File

@@ -7,7 +7,6 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@Deprecated
public class FileItem {
private String fileName;

View File

@@ -8,6 +8,9 @@ import org.apache.commons.lang3.StringUtils;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
@@ -192,4 +195,16 @@ public class UtilityQuery {
" VALUES " + StringUtils.join(values, ",") + "\n" +
") AS " + tableName + "(" + StringUtils.join(columns, ",") + ")";
}
public static String mapQueryToCSV(Connection connection, String query, char separatorChar, Boolean useHeader, Boolean titleUpperCase) throws Exception {
PreparedStatement psRow = connection.prepareStatement(query);
ResultSet rsRow = psRow.executeQuery();
String returnString = UtilityResultSet.mapResultSetToCSV(rsRow, separatorChar, useHeader, titleUpperCase);
rsRow.close();
psRow.close();
return returnString;
}
}

View File

@@ -785,8 +785,8 @@ public class ActivityService {
" WHEN estimated_date >= CAST(GETDATE() AS DATE) THEN estimated_date\n" +
" ELSE NULL END) AS next_activity_date,\n" +
" MAX(CASE\n" +
" WHEN (estimated_date BETWEEN dbo.f_getfirstdayofweek(GETDATE()) AND dbo.f_getlastdayofweek(GETDATE()) OR\n" +
" estimated_date IS NULL) \n" +
" WHEN ((estimated_date BETWEEN dbo.f_getfirstdayofweek(GETDATE()) AND dbo.f_getlastdayofweek(GETDATE()) OR\n" +
" estimated_date IS NULL) and effective_date is null) \n" +
" THEN stb_activity.activity_description\n" +
" ELSE NULL END) AS activity_description,\n" +
" MAX(CASE\n" +

View File

@@ -690,7 +690,7 @@ public class SteUPService {
}else if(activityTypeId.equalsIgnoreCase(tipoAttivitaRotturaStock)){
List<HashMap<String, Object>> pluRepo = getGrigliaPluRepo(codMdep,codJfas,activityTypeId,null);
if(repartiFreschi.contains(codJfas)){
if(repartiFreschi != null && repartiFreschi.contains(codJfas)){
List<String> finalBarcodes = barcodes;
barcodes = pluRepo.stream().filter(a-> !finalBarcodes.contains(((String) a.get("barcode")))).map(a->(String) a.get("barcode")).collect(Collectors.toList());
}else{

View File

@@ -8,18 +8,14 @@ import it.integry.ems_model.entity.WtbUsersInfo;
import it.integry.ems_model.service.SetupGest;
import it.integry.ems_model.types.OperationType;
import it.integry.ems_model.utility.Query;
import it.integry.ems_model.utility.UtilityDB;
import it.integry.ems_model.utility.UtilityResultSet;
import it.integry.ems_model.utility.UtilityQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@Service
@@ -35,7 +31,7 @@ public class DocumentiToscaExportService {
@Autowired
SetupGest setupGest;
public EntityExportResponse export(String userName, String type, String format) throws Exception {
public EntityExportResponse<List<FileItem>> export(String userName, String type, String format) throws Exception {
EntityExportResponse<List<FileItem>> entityExportResponse = new EntityExportResponse<>();
WtbUsersInfo wtbUsersInfo =
@@ -57,7 +53,7 @@ public class DocumentiToscaExportService {
" INNER JOIN azienda ON azienda.part_iva = gtb_anag.part_iva\n" +
" INNER JOIN atb_forn ON gtb_anag.cod_anag = atb_forn.cod_anag) AS 'LOCATION_1',\n" +
" mtb_movi.cod_anag AS 'LOCATION_2',\n" +
" mtb_movi.data_reg AS 'DATE',\n" +
" FORMAT(mtb_movi.data_reg, 'dd/MM/yyyy') AS 'DATE',\n" +
" IIF(mtb_movi.qta_car > 0, 'IN', 'OUT') AS 'DIRECTION',\n" +
" mtb_movi.num_doc AS 'REFERENCE',\n" +
" mtb_movi.cod_mart AS 'ITEM',\n" +
@@ -65,23 +61,17 @@ public class DocumentiToscaExportService {
"FROM mtb_movi\n" +
" INNER JOIN mtb_tcol\n" +
" ON mtb_tcol.cod_mart = mtb_movi.cod_mart\n" +
" INNER JOIN wtb_forn\n" +
" ON wtb_forn.cod_anag = mtb_movi.cod_anag\n" +
"WHERE mtb_movi.data_doc = %s\n" +
" AND mtb_tcol.circuito = 'TOSCA'",
new Date()
" AND mtb_tcol.circuito = %s\n" +
" AND wtb_forn.user_name = %s",
new Date(),
format,
userName
);
PreparedStatement stm = multiDBTransactionManager
.getPrimaryConnection()
.prepareStatement(sql,
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = stm.executeQuery();
byte[] csvContent = UtilityResultSet.mapResultSetToCSV(rs, charSeparator, true, false).getBytes();
rs.close();
stm.close();
byte[] csvContent = UtilityQuery.mapQueryToCSV(multiDBTransactionManager.getPrimaryConnection(), sql, charSeparator, true, false).getBytes();
fileName += new SimpleDateFormat("yyyyMMdd").format(new Date()) + "." + ext;
FileItem file = new FileItem(fileName, csvContent, ext);

View File

@@ -48,10 +48,10 @@ public class OrdiniExporter extends BaseEntityExporter implements IEntityExporte
entityExportResponse = ordiniAcquistoExportServices.exportOrdiniPazienza(type, format, whereCond);
break;
case SLIM2K:
if (type.equalsIgnoreCase("ORDINI VENDITA")){
if (type.equalsIgnoreCase("ORDINI VENDITA")) {
ordiniVenditaExportServices = ContextLoader.getCurrentWebApplicationContext().getBean(OrdiniVenditaExportServices.class);
ordiniVenditaExportServices.exportOrdiniVenditaSlim2K(type, format, whereCond);
}else{
} else {
ordiniAcquistoExportServices = ContextLoader.getCurrentWebApplicationContext().getBean(OrdiniAcquistoExportServices.class);
ordiniAcquistoExportServices.exportOrdiniSlim2K(type, format);
}
@@ -75,7 +75,11 @@ public class OrdiniExporter extends BaseEntityExporter implements IEntityExporte
break;
case EXCEL_IMMAGINI:
ordiniVenditaExportServices = ContextLoader.getCurrentWebApplicationContext().getBean(OrdiniVenditaExportServices.class);
entityExportResponse = ordiniVenditaExportServices.exportOrdiniVenditaTextilesConImmagini(username,type, format, whereCond);
entityExportResponse = ordiniVenditaExportServices.exportOrdiniVenditaTextilesConImmagini(username, type, format, whereCond);
break;
case GIOIELLA:
ordiniAcquistoExportServices = ContextLoader.getCurrentWebApplicationContext().getBean(OrdiniAcquistoExportServices.class);
entityExportResponse = ordiniAcquistoExportServices.exportOrdiniGioiella(type, format, whereCond, username);
break;
}
@@ -90,23 +94,23 @@ public class OrdiniExporter extends BaseEntityExporter implements IEntityExporte
if (currentFormatEnum.equals(Format.CSV) || currentFormatEnum.equals(Format.EXCEL))
return;
if (!UtilityString.isNullOrEmpty(whereCond) ) {
if (!UtilityString.isNullOrEmpty(whereCond)) {
String noteExport = String.format("Formato: %s", format);
String condGestione = "";
if (!type.equalsIgnoreCase("ORDINI")) {
condGestione = String.format(
"dtb_ordt.gestione = '%s'",
(type.equalsIgnoreCase("ORDINI ACQUISTO")?"A":
type.equalsIgnoreCase("ORDINI VENDITA")?"V":"L")
condGestione = String.format(
"dtb_ordt.gestione = '%s'",
(type.equalsIgnoreCase("ORDINI ACQUISTO") ? "A" :
type.equalsIgnoreCase("ORDINI VENDITA") ? "V" : "L")
);
}
String sql =
"SELECT dtb_ordt.gestione,\n" +
" dtb_ordt.data_ord,\n" +
" dtb_ordt.num_ord\n" +
"FROM dtb_ordt\n";
"SELECT dtb_ordt.gestione,\n" +
" dtb_ordt.data_ord,\n" +
" dtb_ordt.num_ord\n" +
"FROM dtb_ordt\n";
sql = UtilityDB.addwhereCond(sql, condGestione, false);
sql = UtilityDB.addwhereCond(sql, whereCond, false);
@@ -114,7 +118,7 @@ public class OrdiniExporter extends BaseEntityExporter implements IEntityExporte
List<DtbOrdt> dtbOrdt = new ResultSetMapper().mapQuerySetToList(conn, sql, DtbOrdt.class, OperationType.UPDATE);
Stream.of(dtbOrdt)
.forEach(x->x
.forEach(x -> x
.setDataEsportazione(new Date())
.setNoteExport(noteExport));
@@ -138,7 +142,7 @@ public class OrdiniExporter extends BaseEntityExporter implements IEntityExporte
if (setDataRicezione) {
Date finalDataRicezione = dataRicezione;
Stream.of(dtbOrdt)
.forEach(x->x
.forEach(x -> x
.setDataRicezione(finalDataRicezione));
}
@@ -161,7 +165,8 @@ public class OrdiniExporter extends BaseEntityExporter implements IEntityExporte
EXCEL("EXCEL"),
EURITMO("EURITMO"),
CSV("CSV"),
EXCEL_IMMAGINI("EXCEL_IMMAGINI");
EXCEL_IMMAGINI("EXCEL_IMMAGINI"),
GIOIELLA("GIOIELLA");
private String text;

View File

@@ -4,15 +4,16 @@ import com.google.common.io.Files;
import it.integry.common.var.CommonConstants;
import it.integry.ems.datasource.DataSource;
import it.integry.ems.export.base.EntityExportResponse;
import it.integry.ems.response.FileItem;
import it.integry.ems.service.EntityProcessor;
import it.integry.ems.service.HttpRestWrapper;
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
import it.integry.ems.utility.UtilityDirs;
import it.integry.ems.utility.UtilityFile;
import it.integry.ems_model.entity.WtbUsersInfo;
import it.integry.ems_model.service.SetupGest;
import it.integry.ems_model.utility.IntegerUtility;
import it.integry.ems_model.utility.UtilityDB;
import it.integry.ems_model.utility.UtilityHashMap;
import it.integry.ems_model.utility.UtilityString;
import it.integry.ems_model.types.OperationType;
import it.integry.ems_model.utility.*;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
@@ -38,6 +39,9 @@ public class OrdiniAcquistoExportServices {
@Autowired
private SetupGest setupGest;
@Autowired
private EntityProcessor entityProcessor;
public EntityExportResponse exportOrdiniAIA(String type, String format, String whereCond, String fileName) throws Exception {
String pathFile = "", ls_codMdep = "", ls_intercode = null, ls_codArtForn, ls_untOrd, ls_data_esportazione = null,
ls_fileName, ls_fileNameCustom, ls_stringFile = "", ls_descrizione, ls_qtaOrd;
@@ -624,6 +628,58 @@ public class OrdiniAcquistoExportServices {
return entityExportResponse;
}
public EntityExportResponse<List<FileItem>> exportOrdiniGioiella(String type, String format, String whereCond, String userName) throws Exception {
EntityExportResponse<List<FileItem>> entityExportResponse = new EntityExportResponse<>();
WtbUsersInfo wtbUsersInfo =
new WtbUsersInfo()
.setUserName(userName)
.setExportType(type)
.setFormatFile(format);
wtbUsersInfo.setOperation(OperationType.SELECT_OBJECT);
entityProcessor.processEntity(wtbUsersInfo, multiDBTransactionManager);
char separatorChar = ';';
String ext = "csv";
String sql = "SELECT FORMAT(MAX(dtb_ordr.data_cons), 'yyyyMMdd') AS 'data_cons',\n" +
" dtb_ordt.num_ord,\n" +
" FORMAT(MAX(dtb_ordt.data_ord), 'yyyyMMdd') AS 'data_ord',\n" +
" mtb_depo_intercode.intercode AS 'codice_destinazione',\n" +
" dtb_ordt.note AS 'note'\n" +
"FROM dtb_ordt\n" +
" INNER JOIN mtb_depo_intercode ON dtb_ordt.cod_mdep = mtb_depo_intercode.cod_mdep AND\n" +
" dtb_ordt.cod_anag = mtb_depo_intercode.cod_forn AND\n" +
" ISNULL(dtb_ordt.cod_vdes, '') = ISNULL(mtb_depo_intercode.cod_vdes, '')\n" +
" INNER JOIN dtb_ordr ON dtb_ordr.num_ord = dtb_ordt.num_ord AND\n" +
" dtb_ordr.gestione = dtb_ordt.gestione AND\n" +
" dtb_ordr.data_ord = dtb_ordt.data_ord\n" +
"GROUP BY dtb_ordt.num_ord, dtb_ordt.data_ord, mtb_depo_intercode.intercode, dtb_ordt.note";
sql = UtilityDB.addwhereCond(sql, whereCond, false);
String testata = UtilityQuery.mapQueryToCSV(multiDBTransactionManager.getPrimaryConnection(), sql, separatorChar, false, false);
sql = "SELECT dtb_ordr.cod_mart, dtb_ordr.qta_cnf\n" +
"FROM dtb_ordt\n" +
" INNER JOIN dtb_ordr ON dtb_ordr.num_ord = dtb_ordt.num_ord AND\n" +
" dtb_ordr.gestione = dtb_ordt.gestione AND\n" +
" dtb_ordr.data_ord = dtb_ordt.data_ord";
sql = UtilityDB.addwhereCond(sql, whereCond, false);
String corpo = UtilityQuery.mapQueryToCSV(multiDBTransactionManager.getPrimaryConnection(), sql, separatorChar, false, false);
String csvContent = (testata + corpo);
String fileName = wtbUsersInfo.getFileName() + UtilityDate.formatDate(new Date(), "yyyyMMddHHmmss") + "." + ext;
FileItem file = new FileItem(fileName, csvContent, ext);
entityExportResponse
.setResponse(new ArrayList<>())
.getResponse()
.add(file);
return entityExportResponse;
}
}

View File

@@ -88,7 +88,7 @@ public class OrdiniVenditaExportServices {
Date dataOrd = UtilityHashMap.getValueIfExists(datiOrdine, "data_ord");
Integer numOrd = UtilityHashMap.getValueIfExists(datiOrdine,"num_ord");
String codMdep = UtilityHashMap.getValueIfExists(datiOrdine,"cod_mdep");
String listCode = UtilityHashMap.getValueIfExists(datiOrdine,"listcode");
String listCode = UtilityHashMap.getValueIfExists(datiOrdine,"listCode");
sql =
"DELETE FROM slim2k.dbo.shippingplan_import " +

View File

@@ -351,6 +351,11 @@ public class OrdiniEDIimportService {
}
}
boolean flagDataDecor = UtilityHashMap.getValueIfExists(setup, "SET_DATA_DECOR_DATA_CONS_" + codAnag, "N").equalsIgnoreCase("S");
if (flagDataDecor){
dtbOrdt.setDataRifScad(dataConsClie);
}
dtbOrdt.setDataInizTrasp(DateUtils.truncate(dataInizTrasp, Calendar.DAY_OF_MONTH));
return dtbOrdt;