sistemato servizio per aggiornare ordini di slim
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
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_20251117142928 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetupQuery("SI_NO", "SI_NO", "SELECT 'S' UNION ALL SELECT 'N'");
|
||||
createSetup("W_jriep_presenze_dip_disp", "SETUP", "SET_DATA_FINE", "N",
|
||||
"imposta data fine = fine mese", false, "SI_NO", false, false,
|
||||
false, false, false, null, false, "SELECT 'S' UNION ALL SELECT 'N'");
|
||||
|
||||
if (isCustomer(IntegryCustomer.Integry))
|
||||
updateSetupValue("W_jriep_presenze_dip_disp", "SETUP", "SET_DATA_FINE", "S");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,12 +34,10 @@ public class OrdiniVSlim2kService {
|
||||
public List<EntityBase> modificaQtaCnf(MultiDBTransactionManager multiDBTransactionManager, List<DtbOrdr> ordini) throws Exception {
|
||||
List<EntityBase> entities = new ArrayList<>();
|
||||
Map<DtbOrdt, List<DtbOrdr>> groupOrdini = ordini.stream()
|
||||
.collect(Collectors.groupingBy(x -> {
|
||||
return new DtbOrdt()
|
||||
.setGestione(x.getGestione())
|
||||
.setDataOrd(x.getDataOrd())
|
||||
.setNumOrd(x.getNumOrd());
|
||||
}
|
||||
.collect(Collectors.groupingBy(x -> new DtbOrdt()
|
||||
.setGestione(x.getGestione())
|
||||
.setDataOrd(x.getDataOrd())
|
||||
.setNumOrd(x.getNumOrd())
|
||||
));
|
||||
|
||||
List<HashMap<String, Object>> articoli = new ArrayList<>();
|
||||
@@ -47,12 +45,17 @@ public class OrdiniVSlim2kService {
|
||||
|
||||
for(DtbOrdt ord : groupOrdini.keySet()) {
|
||||
for (DtbOrdr dtbOrdr : groupOrdini.get(ord)) {
|
||||
String sql =
|
||||
Query.format("SELECT * FROM dtb_ordt WHERE gestione = %s AND data_ord = %s AND num_ord = %s",
|
||||
ord.getGestione(), ord.getDataOrd(), ord.getNumOrd());
|
||||
|
||||
ord = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, DtbOrdt.class);
|
||||
BigDecimal qtaCnf;
|
||||
Optional<HashMap<String, Object>> articolo = articoli.stream().filter(x -> ((String) x.get("cod_mart")).equalsIgnoreCase(dtbOrdr.getCodMart())).findFirst();
|
||||
if (articolo.isPresent()) {
|
||||
qtaCnf = (BigDecimal) articolo.get().get("qta_cnf");
|
||||
} else {
|
||||
String sql = Query.format("SELECT cod_mart, qta_cnf FROM mtb_aart WHERE cod_mart = %s", dtbOrdr.getCodMart());
|
||||
sql = Query.format("SELECT cod_mart, qta_cnf FROM mtb_aart WHERE cod_mart = %s", dtbOrdr.getCodMart());
|
||||
HashMap<String, Object> datiArt = UtilityDB.executeSimpleQueryOnlyFirstRow(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
articoli.add(datiArt);
|
||||
qtaCnf = (BigDecimal) datiArt.get("qta_cnf");
|
||||
@@ -64,13 +67,16 @@ public class OrdiniVSlim2kService {
|
||||
} else {
|
||||
dtbOrdr.setQtaOrd(dtbOrdr.getNumCnf().multiply(qtaCnf));
|
||||
}
|
||||
|
||||
dtbOrdr.setOperation(OperationType.UPDATE);
|
||||
ord.getDtbOrdr().add(dtbOrdr);
|
||||
}
|
||||
|
||||
entityProcessor.processEntity(ord, multiDBTransactionManager);
|
||||
entityProcessor.processEntity(ord, multiDBTransactionManager, false);
|
||||
|
||||
Optional<HashMap<String, Object>> exportOpt = export.stream().filter(x -> ((String) x.get("cod_anag")).equalsIgnoreCase(ord.getCodAnag())).findFirst();
|
||||
DtbOrdt finalOrd = ord;
|
||||
Optional<HashMap<String, Object>> exportOpt = export.stream()
|
||||
.filter(x -> ((String) x.get("cod_anag")).equalsIgnoreCase(finalOrd.getCodAnag())).findFirst();
|
||||
HashMap<String, Object> datiExport;
|
||||
if ( exportOpt.isPresent() ) {
|
||||
datiExport = exportOpt.get();
|
||||
|
||||
Reference in New Issue
Block a user