Compare commits
1 Commits
feature/Fe
...
feature/Co
| Author | SHA1 | Date | |
|---|---|---|---|
| 9e4d509698 |
@@ -154,7 +154,7 @@ public class CommonRules extends QueryRules {
|
||||
String sql = "SELECT full_name FROM stb_user WHERE user_name = '" + username + "'";
|
||||
String value = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(value)) return value;
|
||||
if (!UtilityString.isNullOrEmpty(value)) return value;
|
||||
|
||||
return username;
|
||||
}
|
||||
@@ -177,7 +177,7 @@ public class CommonRules extends QueryRules {
|
||||
finalList = new ArrayList<>();
|
||||
field.setAccessible(true);
|
||||
Object object = field.get(testata);
|
||||
if (object != null && field.getType().isAssignableFrom(List.class) && ( field.getAnnotation(ReloadRow.class) != null || testata.getOperation() == OperationType.SUBSTITUTE)) {
|
||||
if (object != null && field.getType().isAssignableFrom(List.class) && (field.getAnnotation(ReloadRow.class) != null || testata.getOperation() == OperationType.SUBSTITUTE)) {
|
||||
List<? extends EntityBase> rows = (ArrayList<EntityBase>) object;
|
||||
List<? extends EntityBase> list = null;
|
||||
if (testata.getOperation() != OperationType.DELETE_THEN_INSERT &&
|
||||
@@ -312,7 +312,7 @@ public class CommonRules extends QueryRules {
|
||||
}
|
||||
|
||||
for (EntityBase row : rows) {
|
||||
if (rigaField.get(row) == null || testata.getOperation() == OperationType.INSERT ) {
|
||||
if (rigaField.get(row) == null || testata.getOperation() == OperationType.INSERT) {
|
||||
startRiga++;
|
||||
rigaField.set(row, startRiga);
|
||||
}
|
||||
@@ -354,9 +354,9 @@ public class CommonRules extends QueryRules {
|
||||
|
||||
}
|
||||
|
||||
public static void completePosRigaEntity(Connection conn, DtbOrdt testata) throws Exception {
|
||||
public static void completePosRigaEntity(Connection conn, DtbOrdt testata) throws Exception {
|
||||
List<DtbOrdr> rows = Stream.of(testata.getDtbOrdr()).filter(x -> x.getOperation() != OperationType.DELETE).toList();
|
||||
if (rows.size() > 0) {
|
||||
if (!rows.isEmpty()) {
|
||||
if (testata.getExecuteRecalc()) {
|
||||
ComparatorCompat<DtbOrdr> c =
|
||||
new ComparatorCompat<DtbOrdr>(Comparator.comparingInt(a -> UtilityInteger.isNull(a.getPosRiga(), Integer.MAX_VALUE)))
|
||||
@@ -366,7 +366,7 @@ public class CommonRules extends QueryRules {
|
||||
} else {
|
||||
Integer posRigaLista =
|
||||
Stream.of(rows)
|
||||
.filter(x -> x.getPosRiga() != null).max(Comparator.comparingInt(DtbOrdr::getPosRiga)).map(x->x.getPosRiga()).orElse(1);
|
||||
.filter(x -> x.getPosRiga() != null).max(Comparator.comparingInt(DtbOrdr::getPosRiga)).map(x -> x.getPosRiga()).orElse(1);
|
||||
String sql =
|
||||
"SELECT ISNULL(max(pos_riga), 0) as pos_riga " +
|
||||
" FROM dtb_ordr ";
|
||||
@@ -379,11 +379,11 @@ public class CommonRules extends QueryRules {
|
||||
posRigaLista = posRigaDb;
|
||||
}
|
||||
AtomicReference<Integer> i = new AtomicReference<>(posRigaLista);
|
||||
Stream.of(rows).filter(x->x.getPosRiga() == null).forEach(x->x.setPosRiga(i.getAndSet(i.get() + 1)));
|
||||
Stream.of(rows).filter(x -> x.getPosRiga() == null).forEach(x -> x.setPosRiga(i.getAndSet(i.get() + 1)));
|
||||
}
|
||||
|
||||
Integer rigaPrec = 0;
|
||||
for (DtbOrdr row: rows) {
|
||||
for (DtbOrdr row : rows) {
|
||||
if (row.getPosRiga() == null || rigaPrec.equals(row.getPosRiga())) {
|
||||
rigaPrec++;
|
||||
row.setPosRiga(rigaPrec);
|
||||
@@ -395,6 +395,82 @@ public class CommonRules extends QueryRules {
|
||||
}
|
||||
}
|
||||
|
||||
public static void completePosRigaPersEntity(Connection conn, DtbOrdt testata) throws Exception {
|
||||
List<DtbOrdr> rows = Stream.of(testata.getDtbOrdr()).filter(x -> x.getOperation() != OperationType.DELETE).toList();
|
||||
|
||||
if (!testata.getGestione().equalsIgnoreCase("A") || !UtilityString.equalsIgnoreCase(testata.getGestioneRif(), testata.getGestione()) || rows.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String tipoRaggruppamento = setupGest.getSetup(conn, "PVM", "CONTO_ECONOMICO_PRODOTTO", "TIPO_RAGGRUPPAMENTO");
|
||||
|
||||
if (tipoRaggruppamento == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Comparator<DtbOrdr> comparator = null;
|
||||
|
||||
switch (tipoRaggruppamento) {
|
||||
// Tipo merceologico
|
||||
case "T":
|
||||
comparator = Comparator.comparing(DtbOrdr::getCodMtip, Comparator.nullsFirst(Comparator.naturalOrder()))
|
||||
.thenComparing(DtbOrdr::getCodMstp, Comparator.nullsFirst(Comparator.naturalOrder()));
|
||||
|
||||
break;
|
||||
// Gruppo merceologico
|
||||
case "M":
|
||||
comparator = Comparator.comparing(DtbOrdr::getCodMgrp, Comparator.nullsFirst(Comparator.naturalOrder()))
|
||||
.thenComparing(DtbOrdr::getCodMsgr, Comparator.nullsFirst(Comparator.naturalOrder()))
|
||||
.thenComparing(DtbOrdr::getCodMsfa, Comparator.nullsFirst(Comparator.naturalOrder()));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
String sql = String.format(
|
||||
"SELECT ma.cod_mart,\n" +
|
||||
" ma.cod_mtip,\n" +
|
||||
" ma.cod_mstp,\n" +
|
||||
" ma.cod_mgrp,\n" +
|
||||
" ma.cod_msgr,\n" +
|
||||
" ma.cod_msfa\n" +
|
||||
"FROM mtb_aart ma\n" +
|
||||
"WHERE ma.cod_mart IN (%s)",
|
||||
UtilityQuery.concatStringFieldsWithSeparator(Stream.of(rows).map(DtbOrdr::getCodMart).toList(), ",")
|
||||
);
|
||||
|
||||
List<MtbAart> artData = UtilityDB.executeSimpleQueryDTO(conn, sql, MtbAart.class);
|
||||
|
||||
if (artData == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Stream.of(rows).forEach(row -> {
|
||||
MtbAart art = Stream.of(artData)
|
||||
.filter(rowOrder ->
|
||||
rowOrder.getCodMart().equalsIgnoreCase(row.getCodMart()))
|
||||
.findFirstOrElse(null);
|
||||
|
||||
if (art != null) {
|
||||
row
|
||||
.setCodMtip(art.getCodMtip())
|
||||
.setCodMstp(art.getCodMstp())
|
||||
.setCodMgrp(art.getCodMgrp())
|
||||
.setCodMsgr(art.getCodMsgr())
|
||||
.setCodMsfa(art.getCodMsfa());
|
||||
}
|
||||
});
|
||||
|
||||
Stream.of(rows)
|
||||
.sorted(comparator)
|
||||
.forEachIndexed((i, row) -> {
|
||||
if (row.getOperation() == null) {
|
||||
row.setOperation(OperationType.UPDATE);
|
||||
}
|
||||
|
||||
row.setPosRiga(i + 1);
|
||||
});
|
||||
}
|
||||
|
||||
public static void completeRigaCtbMovr(EntityBase testata) {
|
||||
//questo campo definisce anche l'ordinemanto delle righe quindi viene sempre riassegnato.
|
||||
Integer startRiga = 0;
|
||||
@@ -778,31 +854,32 @@ public class CommonRules extends QueryRules {
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static BigDecimal completeQtaCnfOffA(Connection connection, AtbOffr atbOffr) throws Exception {
|
||||
AtbOfft atbOfft = (AtbOfft) atbOffr.getParent();
|
||||
String sql= null;
|
||||
String sql = null;
|
||||
BigDecimal qtaCnf = null;
|
||||
if (atbOfft.getCodAlis() != null) {
|
||||
sql =
|
||||
Query.format(
|
||||
"SELECT qta_cnf\n" +
|
||||
" FROM dbo.getListinoAcquisto(%s,%s,%s,%s, 'N', null) lisa\n" +
|
||||
" WHERE IsNull(lisa.tipo_variazione, 'I') <> 'D' AND\n" +
|
||||
"lisa.flag_attivo = 'S' ",
|
||||
atbOfft.getDataIniz(),
|
||||
atbOfft.getCodAlis(),
|
||||
atbOffr.getCodArtForn(),
|
||||
atbOffr.getCodMart());
|
||||
Query.format(
|
||||
"SELECT qta_cnf\n" +
|
||||
" FROM dbo.getListinoAcquisto(%s,%s,%s,%s, 'N', null) lisa\n" +
|
||||
" WHERE IsNull(lisa.tipo_variazione, 'I') <> 'D' AND\n" +
|
||||
"lisa.flag_attivo = 'S' ",
|
||||
atbOfft.getDataIniz(),
|
||||
atbOfft.getCodAlis(),
|
||||
atbOffr.getCodArtForn(),
|
||||
atbOffr.getCodMart());
|
||||
qtaCnf = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
}
|
||||
|
||||
if (UtilityBigDecimal.isNullOrZero(qtaCnf)) {
|
||||
sql =
|
||||
Query.format("SELECT qta_cnf FROM mtb_aart WHERE cod_mart = %s", atbOffr.getCodMart());
|
||||
Query.format("SELECT qta_cnf FROM mtb_aart WHERE cod_mart = %s", atbOffr.getCodMart());
|
||||
qtaCnf = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
}
|
||||
|
||||
if (!UtilityBigDecimal.isNullOrZero(atbOffr.getRapConv()) && atbOffr.getRapConv().compareTo(BigDecimal.ONE) != 0 ) {
|
||||
if (!UtilityBigDecimal.isNullOrZero(atbOffr.getRapConv()) && atbOffr.getRapConv().compareTo(BigDecimal.ONE) != 0) {
|
||||
qtaCnf = qtaCnf.divide(atbOffr.getRapConv(), RoundingMode.HALF_UP);
|
||||
}
|
||||
return qtaCnf;
|
||||
@@ -932,9 +1009,9 @@ public class CommonRules extends QueryRules {
|
||||
+ UtilityDB.valueDateToString(dataValidita, CommonConstants.DATE_FORMAT_YMD) + ","
|
||||
+ UtilityDB.valueToString(codMdep) + ") as costo_dist";
|
||||
BigDecimal valUnt = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
if ( valUnt == null)
|
||||
if (valUnt == null)
|
||||
return BigDecimal.ZERO;
|
||||
else
|
||||
else
|
||||
return valUnt;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -56,6 +56,7 @@ then
|
||||
ProductionBusinessLogic.GeneraOrdTraf(conn, $testata);
|
||||
}
|
||||
CommonRules.completePosRigaEntity(conn, $testata);
|
||||
CommonRules.completePosRigaPersEntity(conn, $testata);
|
||||
OrdWebRules.completeIdArtOrd(conn, $testata);
|
||||
if ($testata.getExecuteRecalc() ) {
|
||||
DocOrdCalTotaliRules.calcTotali(conn, $testata);
|
||||
|
||||
Reference in New Issue
Block a user