Aggiunto controllo su esistenza lotto nella generazione degli ordini per il planning di produzione

This commit is contained in:
2024-09-12 12:20:50 +02:00
parent 9e38f3da92
commit b1f28f9462
4 changed files with 69 additions and 7 deletions

View File

@@ -31,6 +31,8 @@ import java.util.Date;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import static it.integry.ems.rules.completing.QueryRules.getSingleValue;
public class GeneraOrdLav {
private static final Logger logger = LogManager.getLogger();
@@ -730,6 +732,7 @@ public class GeneraOrdLav {
boolean generaLottoProdAutomatico = ordProdSetupDTO.isGeneraLottoAut(codMdep);
boolean partitaMagRequired = ordProdSetupDTO.isPartitaMagRequired();
boolean checkExistLotto = ordProdSetupDTO.isCheckExistLotto(codMdep);
// Se il prodotto è presente tra quelli da escludere dall'assegnazione automatica allora non viene generato il lotto
String whereCondEscludiProd = ordProdSetupDTO.getWhereCondEscludiProd(codMdep);
@@ -761,7 +764,20 @@ public class GeneraOrdLav {
sql = " select dbo.f_suggestCodePartitaMag(" + UtilityDB.valueToString(parameter) + ", 0) ";
partitaMag = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
if (partitaMag != null && partitaMag.length() != 0) {
Integer existLotto = 0;
if (checkExistLotto){
sql = "select COUNT(*)" +
" from dtb_ordt inner join mtb_partita_mag on dtb_ordt.cod_prod = mtb_partita_mag.cod_mart and " +
" dtb_ordt.partita_mag = mtb_partita_mag.partita_mag " +
" where dtb_ordt.gestione = 'L' and" +
" dtb_ordt.data_ord >= dateadd(month, -2, GETDATE()) and dtb_ordt.cod_mdep = " +UtilityDB.valueToString(codMdep) + " and " +
" dtb_ordt.cod_prod = " + UtilityDB.valueToString(codMart) + " and " +
" dtb_ordt.partita_mag = " + UtilityDB.valueToString(partitaMag);
existLotto = (Integer) getSingleValue(conn, sql);
}
if (partitaMag != null && partitaMag.length() != 0 && existLotto == 0) {
// Definizione data scadenza partita di magazzino
parameter = codMart + ';' +
formato.format(dataCons) + ';' +
@@ -784,6 +800,10 @@ public class GeneraOrdLav {
} else {
if (partitaMagRequired && partitaMag == null) {
throw new Exception("Partita di magazzino obbligatoria, impossibile procedere alla generazione");
} else {
if (existLotto != 0){
dtbOrdr.setPartitaMag(partitaMag);
}
}
}
} else {
@@ -823,7 +843,6 @@ public class GeneraOrdLav {
String codJfasDist = UtilityHashMap.getValueIfExists(datiProd, "cod_jfas");
BigDecimal rapporto = qtaProd.divide(qtaProdDist, EmsRestConstants.cifreDecMax, RoundingMode.HALF_UP);
List<ExplodeDistDTO> artDist = new ArrayList<>();
List<JtbDistMate> jtbDistMates;
String sql;

View File

@@ -37,6 +37,8 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.*;
import static it.integry.ems.rules.completing.QueryRules.getSingleValue;
public class ProductionBusinessLogic {
public static void getNextCodJcom(Connection conn, CommessaDTO datiComm, HashMap<String, String> setup) throws Exception {
// Acquisizione configurazioni commessa
@@ -350,6 +352,8 @@ public class ProductionBusinessLogic {
boolean partitaMagRequired = UtilityString.equalsIgnoreCase(setupLottoProd.get("PARTITA_MAG_REQUIRED"), "S");
boolean checkExistLotto = UtilityString.equalsIgnoreCase(new SetupGest().getSetupDepo(conn, classNameOrdProd, "SETUP", "CHECK_EXIST_LOTTO", codMdep), "S");
// Se il prodotto è presente tra quelli da escludere dall'assegnazione automatica allora non viene generato il lotto
String whereCondEscludiProd = new SetupGest().getSetupDepo(conn, classNameOrdProd, "GENERA_LOTTO_PROD", "GENERA_LOTTO_AUT_WHERECOND_ESCLUDI", codMdep);
if (!UtilityString.isNullOrEmpty(whereCondEscludiProd)) {
@@ -380,12 +384,20 @@ public class ProductionBusinessLogic {
sql = " select dbo.f_suggestCodePartitaMag(" + UtilityDB.valueToString(parameter) + ", 0) ";
partitaMag = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
/* PLANNING
if ()
dtbOrdr.setPartitaMag(partitaMag);
*/
Integer existLotto = 0;
if (checkExistLotto){
sql = "select COUNT(*)" +
" from dtb_ordt inner join mtb_partita_mag on dtb_ordt.cod_prod = mtb_partita_mag.cod_mart and " +
" dtb_ordt.partita_mag = mtb_partita_mag.partita_mag " +
" where dtb_ordt.gestione = 'L' and" +
" dtb_ordt.data_ord >= dateadd(month, -2, GETDATE()) and dtb_ordt.cod_mdep = " +UtilityDB.valueToString(codMdep) + " and " +
" dtb_ordt.cod_prod = " + UtilityDB.valueToString(codMart) + " and " +
" dtb_ordt.partita_mag = " + UtilityDB.valueToString(partitaMag);
if (partitaMag != null && partitaMag.length() != 0) {
existLotto = (Integer) getSingleValue(conn, sql);
}
if (partitaMag != null && partitaMag.length() != 0 && existLotto == 0) {
// Definizione data scadenza partita di magazzino
parameter = codMart + ';' +
formato.format(dataCons) + ';' +
@@ -408,6 +420,10 @@ public class ProductionBusinessLogic {
} else {
if (partitaMagRequired && partitaMag == null) {
throw new Exception("Partita di magazzino obbligatoria, impossibile procedere alla generazione");
} else {
if (existLotto != 0){
dtbOrdr.setPartitaMag(partitaMag);
}
}
}
} else {

View File

@@ -75,6 +75,17 @@ public class UtilityProduction {
ordProdSetupDTO.setSetupDepoGeneraLottoAuto(setupGeneraLotto);
List<HashMap<String, Object>> setupSetup = getSetupDepo(conn, classNameOrdProd, "SETUP");
Map<String, Boolean> setupCheckLotto = setupSetup.stream()
.filter(x -> UtilityString.equalsIgnoreCase((String) x.get("key_section"), "CHECK_EXIST_LOTTO"))
.collect(Collectors.toMap(
x -> (String) x.get("cod_mdep"),
x -> UtilityString.equalsIgnoreCase((String) x.get("value"), "S")
));
ordProdSetupDTO.setSetupDepoCheckExistLotto(setupCheckLotto);
return ordProdSetupDTO;
}

View File

@@ -41,6 +41,8 @@ public class OrdProdSetupDTO {
private Map<String, Boolean> setupDepoGeneraLottoAuto;
private Map<String, String> setupDepowhereCondEscludiProd;
private Map<String, Boolean> setupDepoCheckExistLotto;
private boolean generaLottoAut;
private String whereCondEscludiProd;
@@ -48,6 +50,8 @@ public class OrdProdSetupDTO {
return checkLockProd;
}
private boolean checkExistLotto;
public OrdProdSetupDTO setCheckLockProd(boolean checkLockProd) {
this.checkLockProd = checkLockProd;
return this;
@@ -269,4 +273,16 @@ public class OrdProdSetupDTO {
return setupDepowhereCondEscludiProd.get(codMdep);
}
public boolean isCheckExistLotto(String codMdep) {
return setupDepoCheckExistLotto.get(codMdep)==null?false:setupDepoCheckExistLotto.get(codMdep);
}
public Map<String, Boolean> getSetupDepoCheckExistLotto() {
return setupDepoCheckExistLotto;
}
public OrdProdSetupDTO setSetupDepoCheckExistLotto(Map<String, Boolean> setupDepoCheckExistLotto) {
this.setupDepoCheckExistLotto = setupDepoCheckExistLotto;
return this;
}
}