Finish Hotfix-43
This commit is contained in:
@@ -8,6 +8,7 @@ import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.db.ResultSetMapper;
|
||||
import it.integry.ems_model.entity.CarelliGiacenzaProg;
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
import it.integry.ems_model.entity.MtbInvenr;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
@@ -86,13 +87,12 @@ public class GiacenzaService {
|
||||
"WHERE carelli_giacenza_prog.cod_mdep = %s", codMdep);
|
||||
|
||||
List<String> articoliSalvati = UtilityDB.executeSimpleQueryOnlyFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
nuoviInserimenti(codMdep, queryArt);
|
||||
logger.debug(String.format(GiacenzaService.class.getSimpleName() + " - Deposito %s - Popolamento da griglia: Timing " + ((new Date().getTime() - startDate.getTime()) / 1000) + " secs", codMdep));
|
||||
popolaQtaCarInventario(codMdep, queryArt, articoliSalvati, codDtipRett);
|
||||
logger.debug(String.format(GiacenzaService.class.getSimpleName() + " - Deposito %s - Popolamento da inventario: Timing " + ((new Date().getTime() - startDate.getTime()) / 1000) + " secs", codMdep));
|
||||
popolaQtaMovimenti(codMdep, queryArt, articoliSalvati);
|
||||
logger.debug(String.format(GiacenzaService.class.getSimpleName() + " - Deposito %s - Popolamento da movimenti: Timing " + ((new Date().getTime() - startDate.getTime()) / 1000) + " secs", codMdep));
|
||||
nuoviInserimenti(codMdep, queryArt);
|
||||
logger.debug(String.format(GiacenzaService.class.getSimpleName() + " - Deposito %s - Popolamento da griglia: Timing " + ((new Date().getTime() - startDate.getTime()) / 1000) + " secs", codMdep));
|
||||
}
|
||||
|
||||
private void nuoviInserimenti(String codMdep, String queryArt) throws Exception {
|
||||
@@ -174,8 +174,7 @@ public class GiacenzaService {
|
||||
" IsNull(giac.qta_iniz, 0) as qta_iniz,\n" +
|
||||
" isNull(SUM(movimenti.qta_car * art.qta_std) , 0) + IsNull(giac.qta_iniz, 0) as qta_car,\n" +
|
||||
" isNull(SUM(movimenti.qta_scar * art.qta_std), 0) as qta_scar,\n" +
|
||||
" getdate() as data_ins,\n" +
|
||||
" max(movimenti.tipo_car) as tipo_car\n" +
|
||||
" getdate() as data_ins\n" +
|
||||
"FROM movimenti\n" +
|
||||
" INNER JOIN art ON movimenti.cod_mart = art.cod_mart\n" +
|
||||
" LEFT OUTER JOIN carelli_giacenza_prog giac ON giac.cod_mdep = movimenti.cod_mdep AND giac.cod_mart = art.cod_mart_mov\n" +
|
||||
@@ -204,19 +203,17 @@ public class GiacenzaService {
|
||||
|
||||
private void popolaQtaCarInventario(String codMdep, String queryArt, List<String> articoliSalvati, String codDtipRett) throws Exception {
|
||||
String sql =
|
||||
Query.format("SELECT min(data_reg) from carelli_giacenza_prog WHERE cod_mdep = %s and id_inventario is not null", codMdep);
|
||||
Query.format("SELECT min(id_inventario) from carelli_giacenza_prog WHERE cod_mdep = %s and id_inventario is not null", codMdep);
|
||||
|
||||
Date dataIniz = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
Integer maxIdInv = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
if (dataIniz == null) {
|
||||
String dataParm = setupGest.getSetupDepo(multiDBTransactionManager.getPrimaryConnection(), "DATI_AZIENDA", "GIACENZA_DA_INV", "DATA_INIZ", codMdep);
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(dataParm))
|
||||
dataIniz = UtilityString.parseDate(dataParm);
|
||||
else
|
||||
throw new Exception(String.format("Data inizio popolamento non valorizzata per il depostio %s", codMdep));
|
||||
|
||||
}
|
||||
String dataParm = setupGest.getSetupDepo(multiDBTransactionManager.getPrimaryConnection(), "DATI_AZIENDA", "GIACENZA_DA_INV", "DATA_INIZ", codMdep);
|
||||
Date dataIniz ;
|
||||
if (!UtilityString.isNullOrEmpty(dataParm))
|
||||
dataIniz = UtilityString.parseDate(dataParm);
|
||||
else
|
||||
throw new Exception(String.format("Data inizio popolamento non valorizzata per il depostio %s", codMdep));
|
||||
|
||||
sql =
|
||||
Query.format(
|
||||
@@ -227,7 +224,9 @@ public class GiacenzaService {
|
||||
"FROM mtb_invent\n " +
|
||||
"WHERE cod_mdep = %s AND \n" +
|
||||
"data_inventario >= %s AND\n " +
|
||||
(maxIdInv!=null?"id_inventario>"+maxIdInv + " AND \n":"") +
|
||||
"flag_stato <> 2 \n " +
|
||||
"AND EXISTS(SELECT * FROM mtb_invenr WHERE mtb_invent.id_inventario = mtb_invenr.id_inventario and mtb_invent.cod_mdep = mtb_invenr.cod_mdep ) " +
|
||||
"AND NOT EXISTS(SELECT * FROM carelli_giacenza_prog WHERE mtb_invent.id_inventario = carelli_giacenza_prog.id_inventario AND mtb_invent.cod_mdep = carelli_giacenza_prog.cod_mdep )",
|
||||
codMdep, dataIniz);
|
||||
|
||||
@@ -335,6 +334,7 @@ public class GiacenzaService {
|
||||
" INNER JOIN (" + queryArt + ") art on mtb_colr.cod_mart = art.cod_mart\n" +
|
||||
"WHERE mtb_colt.cod_dtip_provv = %s\n" +
|
||||
" AND mtb_colt.data_collo > %s\n" +
|
||||
" AND mtb_colt.cod_dtip is null \n" +
|
||||
" AND mtb_colt.cod_mdep = %s\n" +
|
||||
"GROUP BY art.cod_mart_mov, mtb_colt.data_collo",
|
||||
codDtipRett, dataIniz, codMdep);
|
||||
@@ -344,9 +344,10 @@ public class GiacenzaService {
|
||||
List<CarelliGiacenzaProg> carelliGiacenzaProgs = new ArrayList<>();
|
||||
for (HashMap<String, Object> doc : datiDoc) {
|
||||
BigDecimal qtaCol = UtilityHashMap.getValueIfExists(doc, "qta_col");
|
||||
String codMart = UtilityHashMap.getValueIfExists(doc, "cod_mart");
|
||||
CarelliGiacenzaProg c = new CarelliGiacenzaProg()
|
||||
.setCodMart(codMdep)
|
||||
.setCodMart(UtilityHashMap.getValueIfExists(doc, "cod_mart"))
|
||||
.setCodMdep(codMdep)
|
||||
.setCodMart(codMart)
|
||||
.setQtaCar(qtaCol)
|
||||
.setQtaIniz(qtaCol)
|
||||
.setQtaScar(BigDecimal.ZERO)
|
||||
@@ -354,13 +355,34 @@ public class GiacenzaService {
|
||||
.setTipoCar("C")
|
||||
.setDataIns(new Date());
|
||||
|
||||
c.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
if (articoliSalvati.contains(codMart))
|
||||
c.setOperation(OperationType.UPDATE);
|
||||
else {
|
||||
c.setOperation(OperationType.INSERT);
|
||||
articoliSalvati.add(codMart);
|
||||
}
|
||||
carelliGiacenzaProgs.add(c);
|
||||
}
|
||||
saveEntity(carelliGiacenzaProgs);
|
||||
|
||||
sql =
|
||||
Query.format(
|
||||
"SELECT gestione, data_collo, ser_collo, num_collo FROM mtb_colt " +
|
||||
"WHERE mtb_colt.cod_dtip_provv = %s\n" +
|
||||
" AND mtb_colt.data_collo > %s\n" +
|
||||
" AND mtb_colt.cod_mdep = %s\n" +
|
||||
" AND mtb_colt.cod_dtip is null \n",
|
||||
codDtipRett, dataIniz, codMdep);
|
||||
|
||||
List<MtbColt> mtbColts = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, MtbColt.class);
|
||||
if (mtbColts != null){
|
||||
for (MtbColt collo : mtbColts) {
|
||||
collo.setCodDtip(codDtipRett);
|
||||
collo.setOperation(OperationType.UPDATE);
|
||||
entityProcessor.processEntity(collo, false, true, "", multiDBTransactionManager, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void saveEntity(List<? extends EntityBase> entityBases) throws SQLException, IOException {
|
||||
|
||||
Reference in New Issue
Block a user