create viste per report tracciabilità Rossogargano
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250903120642 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateView("vw_tracciabUDCVend", "CREATE VIEW vw_tracciabUDCVend AS\n" +
|
||||
"select mtb_colt.cod_anag, gtb_anag.rag_soc, isNull(vtb_dest.destinatario,'') as destinazione,\n" +
|
||||
" ISNULL(vtb_dest.citta, gtb_anag.citta) as citta,\n" +
|
||||
" ISNULL(vtb_dest.prov, gtb_anag.prov) as provincia,\n" +
|
||||
" ISNULL(vtb_dest.nazione, gtb_anag.nazione) as nazione,\n" +
|
||||
" mtb_colt.cod_dtip, mtb_colt.data_doc, mtb_colt.ser_doc, mtb_colt.num_doc,\n" +
|
||||
" mtb_colr.cod_mart, mtb_aart.descrizione_estesa, Isnull(mtb_partita_mag.partita_mag_prod, mtb_colr.partita_mag) as lotto, \n" +
|
||||
" mtb_partita_mag.data_prod as data_lotto,\n" +
|
||||
" IIF(dtb_tipi.segno_qta_scar = -1, mtb_colr.barcode_ul_in, mtb_colr.barcode_ul_out) as UDCVenduta,\n" +
|
||||
" UDC.data_vers as dataOraProd,\n" +
|
||||
" UDC.cod_jfas as LineaProd,\n" +
|
||||
" UDC.num_ord as numOrdProd,\n" +
|
||||
" UDC.data_ord as DataOrdProd,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" sum(mtb_colr.qta_col) as qta_venduta,\n" +
|
||||
" SUM(mtb_colr.num_collo) as colli_venduti\n" +
|
||||
"from\n" +
|
||||
" mtb_colt inner join mtb_colr on mtb_colt.gestione = mtb_colr.gestione and\n" +
|
||||
" mtb_colt.data_collo = mtb_colr.data_collo and\n" +
|
||||
" mtb_colt.ser_collo = mtb_colr.ser_collo and\n" +
|
||||
" mtb_colt.num_collo = mtb_colr.num_collo\n" +
|
||||
" inner join dtb_tipi on mtb_colt.cod_dtip = dtb_tipi.cod_dtip\n" +
|
||||
" inner join gtb_anag on mtb_colt.cod_anag = gtb_anag.cod_anag\n" +
|
||||
" left outer join vtb_dest on mtb_colt.cod_anag = vtb_dest.cod_anag and\n" +
|
||||
" mtb_colt.cod_vdes = vtb_dest.cod_vdes\n" +
|
||||
" inner join mtb_aart on mtb_colr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" inner join mtb_partita_mag on mtb_colr.cod_mart = mtb_partita_mag.cod_mart and mtb_colr.partita_mag = mtb_partita_mag.partita_mag\n" +
|
||||
" inner join mtb_colt UDC on IIF(dtb_tipi.segno_qta_scar = -1, mtb_colr.barcode_ul_in, mtb_colr.barcode_ul_out) = UDC.barcode_ul\n" +
|
||||
"where mtb_colt.gestione = 'V' and dtb_tipi.tipo_emissione = 'DIRETTA'\n" +
|
||||
"group by mtb_colt.cod_anag, gtb_anag.rag_soc, isNull(vtb_dest.destinatario,''),\n" +
|
||||
" ISNULL(vtb_dest.citta, gtb_anag.citta),\n" +
|
||||
" ISNULL(vtb_dest.prov, gtb_anag.prov),\n" +
|
||||
" ISNULL(vtb_dest.nazione, gtb_anag.nazione),\n" +
|
||||
" mtb_colt.cod_dtip, mtb_colt.data_doc, mtb_colt.ser_doc, mtb_colt.num_doc,\n" +
|
||||
" mtb_colr.cod_mart, mtb_aart.descrizione_estesa, \n" +
|
||||
" Isnull(mtb_partita_mag.partita_mag_prod, mtb_colr.partita_mag), \n" +
|
||||
" mtb_partita_mag.data_prod,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" IIF(dtb_tipi.segno_qta_scar = -1, mtb_colr.barcode_ul_in, mtb_colr.barcode_ul_out),\n" +
|
||||
" UDC.data_vers,\n" +
|
||||
" UDC.cod_jfas,\n" +
|
||||
" UDC.data_ord,\n" +
|
||||
" UDC.num_ord");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250903120821 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateView("vw_tracciabUDCProd", "CREATE VIEW vw_tracciabUDCProd AS\n" +
|
||||
"select mtb_colr.data_ord as DataOrdProd,\n" +
|
||||
" mtb_colr.num_ord as numOrdProd,\n" +
|
||||
" mtb_colt.cod_anag,\n" +
|
||||
" gtb_anag.rag_soc as Produttore,\n" +
|
||||
" mtb_colt.cod_jfas as linea,\n" +
|
||||
" mtb_colr.datetime_row as dataOraProd,\n" +
|
||||
" mtb_colt.cod_dtip,\n" +
|
||||
" mtb_colt.data_doc,\n" +
|
||||
" mtb_colt.ser_doc,\n" +
|
||||
" mtb_colt.num_doc,\n" +
|
||||
" IIF(mtb_colt.segno = 1, mtb_colr.cod_mart, '') as codProd, \n" +
|
||||
" IIF(mtb_colt.segno = 1, mtb_aart.descrizione_estesa,'') as DescrizioneProd,\n" +
|
||||
" IIF(mtb_colt.segno = 1, mtb_colr.partita_mag,'') as lottoProd,\n" +
|
||||
" IIF(mtb_colt.segno = 1, mtb_colr.barcode_ul_in,'') as UDCProd,\n" +
|
||||
" IIF(mtb_colt.segno = 1, mtb_colr.qta_col, 0) as qtaProd,\n" +
|
||||
" IIF(mtb_colt.segno = -1, mtb_colr.cod_mart, '') as codMP, \n" +
|
||||
" IIF(mtb_colt.segno = -1, mtb_aart.descrizione_estesa,'') as DescrizioneMP,\n" +
|
||||
" IIF(mtb_colt.segno = -1, mtb_colr.partita_mag,'') as lottoMP,\n" +
|
||||
" IIF(mtb_colt.segno = -1, mtb_colr.barcode_ul_in,'') as UDCMP,\n" +
|
||||
" IIF(mtb_colt.segno = -1, mtb_colr.qta_col, 0) as qtaScar\n" +
|
||||
"\n" +
|
||||
"from\n" +
|
||||
" mtb_colt inner join mtb_colr on mtb_colt.gestione = mtb_colr.gestione and\n" +
|
||||
" mtb_colt.data_collo = mtb_colr.data_collo and\n" +
|
||||
" mtb_colt.ser_collo = mtb_colr.ser_collo and\n" +
|
||||
" mtb_colt.num_collo = mtb_colr.num_collo\n" +
|
||||
" inner join mtb_aart on mtb_colr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" inner join gtb_anag on mtb_colt.cod_anag = gtb_anag.cod_anag\n" +
|
||||
"Where mtb_colt.gestione = 'L' and mtb_colr.data_ord is not null");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250903121033 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateView("vw_tracciabUDCACQ", "CREATE VIEW vw_tracciabUDCACQ AS\n" +
|
||||
"Select doct.cod_anag, gtb_anag.rag_soc,\n" +
|
||||
" doct.data_doc, doct.ser_doc, doct.num_doc, doct.cod_dtip,\n" +
|
||||
" doct.num_doc_forn,\n" +
|
||||
" mtb_grup.tipo_mgrp,\n" +
|
||||
" docr.cod_mart, docr.descrizione, docr.partita_mag, docr.unt_doc, docr.qta_doc,\n" +
|
||||
" UDCAcq.UDC, UDCAcq.qtaUDC\n" +
|
||||
" from dtb_doct doct inner join dtb_docr docr on doct.cod_anag = docr.cod_anag and \n" +
|
||||
" doct.cod_dtip = docr.cod_dtip and\n" +
|
||||
" doct.data_doc = docr.data_doc and \n" +
|
||||
" doct.ser_doc = docr.ser_doc and\n" +
|
||||
" doct.num_doc = docr.num_doc\n" +
|
||||
" inner join dtb_tipi on doct.cod_dtip = dtb_tipi.cod_Dtip\n" +
|
||||
" inner join gtb_anag on doct.cod_anag = gtb_anag.cod_anag\n" +
|
||||
" inner join mtb_aart on docr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" inner join mtb_grup on mtb_aart.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" left outer join\n" +
|
||||
" (select mtb_colt.barcode_ul as UDC, mtb_colt.cod_anag, mtb_colt.cod_dtip, mtb_colt.data_doc, mtb_colt.ser_doc, mtb_colt.num_doc,\n" +
|
||||
" mtb_colr.cod_mart, mtb_colr.partita_mag, mtb_colr.qta_col as qtaUDC\n" +
|
||||
" from\n" +
|
||||
" mtb_colt inner join mtb_colr on mtb_colt.gestione = mtb_colr.gestione and\n" +
|
||||
" mtb_colt.data_collo = mtb_colr.data_collo and\n" +
|
||||
" mtb_colt.ser_collo = mtb_colr.ser_collo and\n" +
|
||||
" mtb_colt.num_collo = mtb_colr.num_collo\n" +
|
||||
" Where mtb_colt.gestione = 'A' and mtb_colt.segno = 1\n" +
|
||||
" )UDCAcq on doct.cod_anag = UDCAcq.cod_anag and \n" +
|
||||
" doct.cod_dtip = UDCAcq.cod_dtip and \n" +
|
||||
" doct.data_doc = UDCAcq.data_doc and \n" +
|
||||
" doct.ser_doc = UDCAcq.ser_doc and \n" +
|
||||
" doct.num_doc = UDCAcq.num_doc and\n" +
|
||||
" docr.cod_mart = UDCAcq.cod_mart and\n" +
|
||||
" docr.partita_mag = UDCAcq.partita_mag\n" +
|
||||
" Where doct.gestione = 'A' and dtb_tipi.segno_qta_car = 1 and docr.partita_mag is not null");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user