Aggiunto controllo su esistenza lotto nella generazione degli ordini per il planning di produzione
This commit is contained in:
@@ -31,6 +31,8 @@ import java.util.Date;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import static it.integry.ems.rules.completing.QueryRules.getSingleValue;
|
||||||
|
|
||||||
public class GeneraOrdLav {
|
public class GeneraOrdLav {
|
||||||
|
|
||||||
private static final Logger logger = LogManager.getLogger();
|
private static final Logger logger = LogManager.getLogger();
|
||||||
@@ -730,6 +732,7 @@ public class GeneraOrdLav {
|
|||||||
|
|
||||||
boolean generaLottoProdAutomatico = ordProdSetupDTO.isGeneraLottoAut(codMdep);
|
boolean generaLottoProdAutomatico = ordProdSetupDTO.isGeneraLottoAut(codMdep);
|
||||||
boolean partitaMagRequired = ordProdSetupDTO.isPartitaMagRequired();
|
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
|
// Se il prodotto è presente tra quelli da escludere dall'assegnazione automatica allora non viene generato il lotto
|
||||||
String whereCondEscludiProd = ordProdSetupDTO.getWhereCondEscludiProd(codMdep);
|
String whereCondEscludiProd = ordProdSetupDTO.getWhereCondEscludiProd(codMdep);
|
||||||
@@ -761,7 +764,20 @@ public class GeneraOrdLav {
|
|||||||
sql = " select dbo.f_suggestCodePartitaMag(" + UtilityDB.valueToString(parameter) + ", 0) ";
|
sql = " select dbo.f_suggestCodePartitaMag(" + UtilityDB.valueToString(parameter) + ", 0) ";
|
||||||
partitaMag = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
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
|
// Definizione data scadenza partita di magazzino
|
||||||
parameter = codMart + ';' +
|
parameter = codMart + ';' +
|
||||||
formato.format(dataCons) + ';' +
|
formato.format(dataCons) + ';' +
|
||||||
@@ -784,6 +800,10 @@ public class GeneraOrdLav {
|
|||||||
} else {
|
} else {
|
||||||
if (partitaMagRequired && partitaMag == null) {
|
if (partitaMagRequired && partitaMag == null) {
|
||||||
throw new Exception("Partita di magazzino obbligatoria, impossibile procedere alla generazione");
|
throw new Exception("Partita di magazzino obbligatoria, impossibile procedere alla generazione");
|
||||||
|
} else {
|
||||||
|
if (existLotto != 0){
|
||||||
|
dtbOrdr.setPartitaMag(partitaMag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -823,7 +843,6 @@ public class GeneraOrdLav {
|
|||||||
String codJfasDist = UtilityHashMap.getValueIfExists(datiProd, "cod_jfas");
|
String codJfasDist = UtilityHashMap.getValueIfExists(datiProd, "cod_jfas");
|
||||||
BigDecimal rapporto = qtaProd.divide(qtaProdDist, EmsRestConstants.cifreDecMax, RoundingMode.HALF_UP);
|
BigDecimal rapporto = qtaProd.divide(qtaProdDist, EmsRestConstants.cifreDecMax, RoundingMode.HALF_UP);
|
||||||
|
|
||||||
|
|
||||||
List<ExplodeDistDTO> artDist = new ArrayList<>();
|
List<ExplodeDistDTO> artDist = new ArrayList<>();
|
||||||
List<JtbDistMate> jtbDistMates;
|
List<JtbDistMate> jtbDistMates;
|
||||||
String sql;
|
String sql;
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import static it.integry.ems.rules.completing.QueryRules.getSingleValue;
|
||||||
|
|
||||||
public class ProductionBusinessLogic {
|
public class ProductionBusinessLogic {
|
||||||
public static void getNextCodJcom(Connection conn, CommessaDTO datiComm, HashMap<String, String> setup) throws Exception {
|
public static void getNextCodJcom(Connection conn, CommessaDTO datiComm, HashMap<String, String> setup) throws Exception {
|
||||||
// Acquisizione configurazioni commessa
|
// Acquisizione configurazioni commessa
|
||||||
@@ -350,6 +352,8 @@ public class ProductionBusinessLogic {
|
|||||||
|
|
||||||
boolean partitaMagRequired = UtilityString.equalsIgnoreCase(setupLottoProd.get("PARTITA_MAG_REQUIRED"), "S");
|
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
|
// 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);
|
String whereCondEscludiProd = new SetupGest().getSetupDepo(conn, classNameOrdProd, "GENERA_LOTTO_PROD", "GENERA_LOTTO_AUT_WHERECOND_ESCLUDI", codMdep);
|
||||||
if (!UtilityString.isNullOrEmpty(whereCondEscludiProd)) {
|
if (!UtilityString.isNullOrEmpty(whereCondEscludiProd)) {
|
||||||
@@ -380,12 +384,20 @@ public class ProductionBusinessLogic {
|
|||||||
sql = " select dbo.f_suggestCodePartitaMag(" + UtilityDB.valueToString(parameter) + ", 0) ";
|
sql = " select dbo.f_suggestCodePartitaMag(" + UtilityDB.valueToString(parameter) + ", 0) ";
|
||||||
partitaMag = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
partitaMag = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||||
|
|
||||||
/* PLANNING
|
Integer existLotto = 0;
|
||||||
if ()
|
if (checkExistLotto){
|
||||||
dtbOrdr.setPartitaMag(partitaMag);
|
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
|
// Definizione data scadenza partita di magazzino
|
||||||
parameter = codMart + ';' +
|
parameter = codMart + ';' +
|
||||||
formato.format(dataCons) + ';' +
|
formato.format(dataCons) + ';' +
|
||||||
@@ -408,6 +420,10 @@ public class ProductionBusinessLogic {
|
|||||||
} else {
|
} else {
|
||||||
if (partitaMagRequired && partitaMag == null) {
|
if (partitaMagRequired && partitaMag == null) {
|
||||||
throw new Exception("Partita di magazzino obbligatoria, impossibile procedere alla generazione");
|
throw new Exception("Partita di magazzino obbligatoria, impossibile procedere alla generazione");
|
||||||
|
} else {
|
||||||
|
if (existLotto != 0){
|
||||||
|
dtbOrdr.setPartitaMag(partitaMag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -75,6 +75,17 @@ public class UtilityProduction {
|
|||||||
|
|
||||||
ordProdSetupDTO.setSetupDepoGeneraLottoAuto(setupGeneraLotto);
|
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;
|
return ordProdSetupDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ public class OrdProdSetupDTO {
|
|||||||
private Map<String, Boolean> setupDepoGeneraLottoAuto;
|
private Map<String, Boolean> setupDepoGeneraLottoAuto;
|
||||||
private Map<String, String> setupDepowhereCondEscludiProd;
|
private Map<String, String> setupDepowhereCondEscludiProd;
|
||||||
|
|
||||||
|
private Map<String, Boolean> setupDepoCheckExistLotto;
|
||||||
|
|
||||||
private boolean generaLottoAut;
|
private boolean generaLottoAut;
|
||||||
private String whereCondEscludiProd;
|
private String whereCondEscludiProd;
|
||||||
|
|
||||||
@@ -48,6 +50,8 @@ public class OrdProdSetupDTO {
|
|||||||
return checkLockProd;
|
return checkLockProd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean checkExistLotto;
|
||||||
|
|
||||||
public OrdProdSetupDTO setCheckLockProd(boolean checkLockProd) {
|
public OrdProdSetupDTO setCheckLockProd(boolean checkLockProd) {
|
||||||
this.checkLockProd = checkLockProd;
|
this.checkLockProd = checkLockProd;
|
||||||
return this;
|
return this;
|
||||||
@@ -269,4 +273,16 @@ public class OrdProdSetupDTO {
|
|||||||
return setupDepowhereCondEscludiProd.get(codMdep);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user