Merge branch 'master' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good

This commit is contained in:
2025-01-23 09:46:33 +01:00
4 changed files with 209 additions and 14 deletions

View File

@@ -0,0 +1,47 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250122192402 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createOrUpdateFunction("f_suggestEAN13","CREATE FUNCTION [dbo].[f_suggestEAN13](@precode VARCHAR(12))\n" +
" RETURNS VARCHAR(13)\n" +
"AS\n" +
"BEGIN\n" +
"\n" +
" DECLARE @ean13 VARCHAR(13);\n" +
"\n" +
" IF LEN(@precode) = 12\n" +
" BEGIN\n" +
" SELECT @ean13 = CONCAT(@precode, dbo.getCheckDigitEan13(@precode))\n" +
" END;\n" +
" ELSE\n" +
" BEGIN\n" +
" WITH ean AS (SELECT MAX(CAST(RIGHT(cod_barre, LEN(cod_barre) - LEN(@precode)) as numeric)) AS maxValue\n" +
"\n" +
" FROM mvw_barcode\n" +
" WHERE cod_barre LIKE @precode + '%'\n" +
" AND ISNUMERIC(RIGHT(cod_barre, LEN(cod_barre) - LEN(@precode))) = 1\n" +
" )\n" +
" SELECT @ean13 = CONCAT(@precode, RIGHT(FORMAT(ISNULL(maxValue,1), REPLICATE('0', 12)), 12 - LEN(@precode)))\n" +
" FROM ean;\n" +
"\n" +
" SELECT @ean13 = CONCAT(@ean13, dbo.getCheckDigitEan13(@ean13))\n" +
"\n" +
"\n" +
" END\n" +
" RETURN @ean13;\n" +
"END\n");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,127 @@
package it.integry.ems.document.dto;
import it.integry.ems_model.annotation.SqlField;
import java.math.BigDecimal;
import java.time.LocalDate;
public class UlVenditaDTO {
@SqlField("data_collo")
private LocalDate dataCollo;
@SqlField("ser_collo")
private String serCollo;
@SqlField("gestione")
private String gestione;
@SqlField("num_collo")
private Integer numCollo;
@SqlField("cod_mdep")
private String codMdep;
@SqlField("cod_mart")
private String codMart;
@SqlField("partita_mag")
private String partitaMag;
@SqlField("qta_col")
private BigDecimal qtaCol;
@SqlField("num_cnf")
private BigDecimal numCnf;
@SqlField("cod_tcol")
private String codTcol;
public ArticoloPartitaDTO getArticoloPartita() {
ArticoloPartitaDTO dto = new ArticoloPartitaDTO();
dto.setCodMart(codMart)
.setPartitaMag(partitaMag);
return dto;
}
public LocalDate getDataCollo() {
return dataCollo;
}
public UlVenditaDTO setDataCollo(LocalDate dataCollo) {
this.dataCollo = dataCollo;
return this;
}
public String getSerCollo() {
return serCollo;
}
public UlVenditaDTO setSerCollo(String serCollo) {
this.serCollo = serCollo;
return this;
}
public String getGestione() {
return gestione;
}
public UlVenditaDTO setGestione(String gestione) {
this.gestione = gestione;
return this;
}
public Integer getNumCollo() {
return numCollo;
}
public UlVenditaDTO setNumCollo(Integer numCollo) {
this.numCollo = numCollo;
return this;
}
public String getCodMdep() {
return codMdep;
}
public UlVenditaDTO setCodMdep(String codMdep) {
this.codMdep = codMdep;
return this;
}
public String getCodMart() {
return codMart;
}
public UlVenditaDTO setCodMart(String codMart) {
this.codMart = codMart;
return this;
}
public String getPartitaMag() {
return partitaMag;
}
public UlVenditaDTO setPartitaMag(String partitaMag) {
this.partitaMag = partitaMag;
return this;
}
public BigDecimal getQtaCol() {
return qtaCol;
}
public UlVenditaDTO setQtaCol(BigDecimal qtaCol) {
this.qtaCol = qtaCol;
return this;
}
public BigDecimal getNumCnf() {
return numCnf;
}
public UlVenditaDTO setNumCnf(BigDecimal numCnf) {
this.numCnf = numCnf;
return this;
}
public String getCodTcol() {
return codTcol;
}
public UlVenditaDTO setCodTcol(String codTcol) {
this.codTcol = codTcol;
return this;
}
}

View File

@@ -2,8 +2,8 @@ package it.integry.ems.document.service;
import it.integry.common.var.CommonConstants;
import it.integry.ems.document.dto.ArticoloPartitaDTO;
import it.integry.ems.document.dto.UlVenditaDTO;
import it.integry.ems.javabeans.RequestDataDTO;
import it.integry.ems.retail.wms.generic.dto.MvwSitArtUdcDetInventarioDTO;
import it.integry.ems.rules.businessLogic.enums.TipoEmissione;
import it.integry.ems.rules.completing.ConfigActivityRules;
import it.integry.ems.service.EntityProcessor;
@@ -127,7 +127,7 @@ public class DocumentiDirettiService {
throw new RuntimeException(e);
}
}).collect(Collectors.toList()), " OR ");
List<MvwSitArtUdcDetInventarioDTO> artsToTransfer = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), Query.format("WITH uds AS (SELECT *\n" +
List<UlVenditaDTO> artsToTransfer = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), Query.format("WITH uds AS (SELECT *\n" +
" FROM mtb_colt\n" +
" WHERE cod_mdep <> {}\n" +
" AND (" + whereCondColli + "))\n" +
@@ -139,13 +139,14 @@ public class DocumentiDirettiService {
" cod_mdep,\n" +
" cod_mart,\n" +
" partita_mag,\n" +
" mtb_colt.cod_tcol,\n" +
" SUM(qta_col) AS qta_col,\n" +
" SUM(num_cnf) AS num_cnf\n" +
"FROM uds mtb_colt\n" +
" INNER JOIN mtb_colr ON mtb_colt.gestione = mtb_colr.gestione AND mtb_colt.data_collo = mtb_colr.data_collo AND\n" +
" mtb_colt.ser_collo = mtb_colr.ser_collo AND mtb_colt.num_collo = mtb_colr.num_collo\n" +
"GROUP BY mtb_colt.data_collo, mtb_colt.ser_collo, mtb_colt.gestione, mtb_colt.num_collo, cod_mdep, partita_mag,cod_mart\n", dtbDoct.getCodMdep(), whereCondColli)
, MvwSitArtUdcDetInventarioDTO.class);
, UlVenditaDTO.class);
//controllo che ci sia qualcosa da trasferire
@@ -190,7 +191,7 @@ public class DocumentiDirettiService {
dtbDoct.setActivityId(activityId);
}
//</editor-fold>
List<String> depositiPartenza = artsToTransfer.stream().map(MvwSitArtUdcDetInventarioDTO::getCodMdep).distinct().collect(Collectors.toList());
List<String> depositiPartenza = artsToTransfer.stream().map(UlVenditaDTO::getCodMdep).distinct().collect(Collectors.toList());
for (String codMdep : depositiPartenza) {
//<editor-fold desc="Controllo se esiste già un documento di trasferimento">
DtbDoct docTrasf = null;
@@ -219,9 +220,9 @@ public class DocumentiDirettiService {
}
//</editor-fold>
//<editor-fold desc="Raggruppo le quantità da trasferire per deposito/articolo/partita">
Map<ArticoloPartitaDTO, List<MvwSitArtUdcDetInventarioDTO>> ulToTransf = artsToTransfer.stream()
Map<ArticoloPartitaDTO, List<UlVenditaDTO>> ulToTransf = artsToTransfer.stream()
.filter(ul -> ul.getCodMdep().equalsIgnoreCase(codMdep))
.collect(groupingBy(MvwSitArtUdcDetInventarioDTO::getArticoloPartita));
.collect(groupingBy(UlVenditaDTO::getArticoloPartita));
//</editor-fold>
//<editor-fold desc="per ogni coppia di articolo / partita sommo le quantità e aggiungo al documento">
@@ -238,10 +239,30 @@ public class DocumentiDirettiService {
}
row
.setQtaDoc(ulToTransf.get(articoloPartitaDTO).stream().map(MvwSitArtUdcDetInventarioDTO::getQtaCol).reduce(BigDecimal.ZERO, BigDecimal::add))
.setNumCnf(ulToTransf.get(articoloPartitaDTO).stream().map(MvwSitArtUdcDetInventarioDTO::getNumCnf).reduce(BigDecimal.ZERO, BigDecimal::add));
.setQtaDoc(ulToTransf.get(articoloPartitaDTO).stream().map(UlVenditaDTO::getQtaCol).reduce(BigDecimal.ZERO, BigDecimal::add))
.setNumCnf(ulToTransf.get(articoloPartitaDTO).stream().map(UlVenditaDTO::getNumCnf).reduce(BigDecimal.ZERO, BigDecimal::add));
}
//<editor-fold desc="Aggiungo pedane da trasferire al documento">
Map<String, List<UlVenditaDTO>> ulForCodTcol = artsToTransfer.stream().filter(x -> !UtilityString.isNullOrEmpty(x.getCodTcol())).collect(groupingBy(UlVenditaDTO::getCodTcol));
for (String codTcol : ulForCodTcol.keySet()) {
MtbAart mtbAart = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), Query.format("SELECT * from mtb_tcol where cod_tcol = {}", codTcol), MtbAart.class);
if (mtbAart == null || UtilityString.isNullOrEmpty(mtbAart.getCodMart()))
continue;
DtbDocr row = docTrasf.getDtbDocr().stream().filter(docR -> docR.getCodMart().equalsIgnoreCase(mtbAart.getCodMart())).findFirst().orElse(null);
if (row == null) {
row = new DtbDocr();
row.setCodMart(mtbAart.getCodMart())
.setQtaDoc(BigDecimal.ZERO)
.setQtaCnf(mtbAart.getQtaCnf())
.setOperation(OperationType.INSERT);
docTrasf.getDtbDocr().add(row);
}
row.setQtaDoc(BigDecimal.valueOf(ulForCodTcol.get(codTcol).size()));
}
//</editor-fold>
//</editor-fold>
//<editor-fold desc="Se qualche riga del documento resta con qta = 0 vuol dire che è una coppia di articolo/partita non più necessaria e se le righe sono tutte a 0 elimino il documento">
@@ -257,7 +278,7 @@ public class DocumentiDirettiService {
}
return null;
return dtbDoct;
}
private HashMap<String, Object> getOldPkDoc(DtbDoct dtbDoct) throws IOException {
@@ -396,7 +417,7 @@ public class DocumentiDirettiService {
final String keySectionTipoDocResi = "TIPO_DOC_RESI";
String codDtipPedResi = setupSection.get(keySectionTipoDocResi);
String codDtipPedResi = setupSection.get(keySectionTipoDocResi);
if (UtilityString.isNullOrEmpty(codDtipPedResi))
throw new Exception(String.format("Tipo Documento per la creazione delle di reso delle pedane non configurato %s -> %s -> %s", gestName, section, keySectionTipoDocResi));
@@ -488,7 +509,7 @@ public class DocumentiDirettiService {
}
}
if ( dtbDoctPed == null) {
if (dtbDoctPed == null) {
sql = Query.format(
"SELECT cod_anag, cod_dtip, data_doc, ser_doc, num_doc\n" +
"FROM dtb_doct\n" +
@@ -502,7 +523,7 @@ public class DocumentiDirettiService {
dtbDoctPed = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, DtbDoct.class);
}
if ( dtbDoctPed == null) {
if (dtbDoctPed == null) {
dtbDoctPed =
new DtbDoct()
.setCodDtip(codDtipPed)
@@ -578,7 +599,7 @@ public class DocumentiDirettiService {
if (!UtilityString.isNullOrEmpty(activityId)) {
List<DtbDoct> docAgganciati = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), Query.format("SELECT * from dtb_doct where activity_id = {} AND NOT(" + dtbDoct.getPkWhereCond() + ")", activityId), DtbDoct.class);
if (!UtilityList.isNullOrEmpty(docAgganciati)) {
docAgganciati = docAgganciati.stream().peek(ul->ul.setOperation(OperationType.DELETE)).collect(Collectors.toList());
docAgganciati = docAgganciati.stream().peek(ul -> ul.setOperation(OperationType.DELETE)).collect(Collectors.toList());
UtilityEntity.throwEntitiesException(entityProcessor.processEntityList(docAgganciati, multiDBTransactionManager, true));
}
}

View File

@@ -205,7 +205,7 @@ public class ProductionOrderDataHandlerService {
try {
ggMassimiOrd = Integer.parseInt(setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "MES", "SETUP", "GG_MASSIMI_ORD"));
} catch (Exception e) {
logger.error("Setup giorni massimi non configurata!", e);
logger.debug("Setup giorni massimi non configurata!", e);
ggMassimiOrd = 14;
}