elimiazione trigger e varie modifiche su ordini di produzione
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240809145906 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateFunction("getMaterialiDistinta", "CREATE FUNCTION [dbo].[getMaterialiDistinta](@codProd VARCHAR(15), @explodeSemilavorati bit)\n" +
|
||||
" RETURNS TABLE\n" +
|
||||
" AS\n" +
|
||||
" RETURN\n" +
|
||||
" ( \n" +
|
||||
" -- Add the SELECT statement with parameter references here\n" +
|
||||
" WITH distinta AS (SELECT cod_prod,\n" +
|
||||
" CONVERT(VARCHAR(15), NULL) AS cod_parent,\n" +
|
||||
" cod_prod AS cod_mart,\n" +
|
||||
" jtb_cicl.descrizione_prod AS descrizione,\n" +
|
||||
" jtb_cicl.descrizione_estesa,\n" +
|
||||
" CONVERT(VARCHAR(3), unt_mis_prod) AS unt_mis_prod,\n" +
|
||||
" CONVERT(NUMERIC(20, 5), rap_conv_prod) AS rap_conv_prod,\n" +
|
||||
" CONVERT(NUMERIC(20, 5), jtb_cicl.qta_prod * jtb_cicl.rap_conv_prod) AS qta_prod,\n" +
|
||||
" CONVERT(NUMERIC(20, 5), jtb_cicl.qta_prod ) AS qta_dist,\n" +
|
||||
" 1 AS livello,\n" +
|
||||
" FORMAT(ROW_NUMBER() OVER ( ORDER BY cod_prod), '00000') AS item_id,\n" +
|
||||
" CONVERT(VARCHAR(15), cod_prod) AS cod_prod_pri,\n" +
|
||||
" CAST(0 AS BIT) AS ricorsione,\n" +
|
||||
" CONVERT(numeric(5,2), 0) as perc_sfrido,\n" +
|
||||
" convert(int, null ) as num_fase,\n" +
|
||||
" convert(varchar(1), null ) as flag_pri, \n" +
|
||||
" convert(varchar(1024), null ) as note,\n" +
|
||||
" cast(1 as bit) as is_root,\n" +
|
||||
" cast(0 as bit) as is_foglia\n" +
|
||||
" FROM jtb_cicl\n" +
|
||||
" WHERE (@codProd IS NULL OR cod_prod = @codProd)\n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT distinta.cod_prod,\n" +
|
||||
" CONVERT(VARCHAR(15), jtb_dist_mate.cod_prod) AS cod_parent,\n" +
|
||||
" jtb_dist_mate.cod_mart,\n" +
|
||||
" jtb_dist_mate.descrizione,\n" +
|
||||
" jtb_dist_mate.descrizione_estesa,\n" +
|
||||
" CONVERT(VARCHAR(3), jtb_dist_mate.unt_mis_dist) as unt_mis_prod,\n" +
|
||||
" CONVERT(NUMERIC(20, 5), jtb_dist_mate.rap_conv_dist) as rap_conv_prod,\n" +
|
||||
" CONVERT(NUMERIC(20, 5), ((jtb_dist_mate.qta_std * ( 1 + jtb_dist_mate.perc_sfrido/100)) / ( jtb_cicl.qta_prod * jtb_cicl.rap_conv_prod )) * distinta.qta_prod ) as qta_prod,\n" +
|
||||
" CONVERT(NUMERIC(20, 5), null),\n" +
|
||||
" distinta.livello + 1,\n" +
|
||||
" distinta.item_id + '_' +\n" +
|
||||
" FORMAT(ROW_NUMBER() OVER ( ORDER BY jtb_dist_mate.flag_pri desc, jtb_dist_mate.num_fase, id_riga ), '00000') AS item_id,\n" +
|
||||
" CONVERT(VARCHAR(15), distinta.cod_mart) AS cod_prod_pri,\n" +
|
||||
" CAST(CASE\n" +
|
||||
" WHEN jtb_dist_mate.cod_mart = jtb_dist_mate.cod_prod THEN 1\n" +
|
||||
" ELSE 0 END AS BIT) AS ricorsione,\n" +
|
||||
" jtb_dist_mate.perc_sfrido,\n" +
|
||||
" jtb_dist_mate.num_fase, \n" +
|
||||
" jtb_dist_mate.flag_pri, \n" +
|
||||
" jtb_dist_mate.note,\n" +
|
||||
" cast(0 as bit) as is_root,\n" +
|
||||
" cast(IIF(jtb_dist_mate.flag_pri = 's',0,1) as bit) as is_foglia\n" +
|
||||
" FROM jtb_dist_mate\n" +
|
||||
" INNER JOIN distinta ON jtb_dist_mate.cod_prod = distinta.cod_mart\n" +
|
||||
" INNER JOIN jtb_cicl ON jtb_dist_mate.cod_prod = jtb_cicl.cod_mart\n" +
|
||||
" INNER JOIN mtb_aart ON mtb_aart.cod_mart = jtb_dist_mate.cod_mart \n" +
|
||||
" WHERE distinta.ricorsione = 0 and (distinta.is_root = 1 or distinta.flag_pri = 'S' or @explodeSemilavorati = 1))\n" +
|
||||
"\n" +
|
||||
" SELECT cod_prod,\n" +
|
||||
" cod_parent,\n" +
|
||||
" cod_mart,\n" +
|
||||
" descrizione,\n" +
|
||||
" descrizione_estesa,\n" +
|
||||
" unt_mis_prod,\n" +
|
||||
" rap_conv_prod,\n" +
|
||||
" IsNull(qta_dist,qta_prod) as qta_prod,\n" +
|
||||
" livello,\n" +
|
||||
" item_id,\n" +
|
||||
" cod_prod_pri,\n" +
|
||||
" perc_sfrido,\n" +
|
||||
" num_fase, \n" +
|
||||
" dense_rank() over ( partition by cod_prod order by cod_prod_pri ) - 1 + num_fase as num_fase_calc,\n" +
|
||||
" flag_pri,\n" +
|
||||
" note,\n" +
|
||||
" is_root,\n" +
|
||||
" is_foglia\n" +
|
||||
" FROM distinta\n" +
|
||||
" )");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -931,7 +931,7 @@ public class GeneraOrdLav {
|
||||
artDist.stream().noneMatch(x->x.getCodProd().equalsIgnoreCase(codProd))
|
||||
) {
|
||||
artDist.add(new ExplodeDistDTO().setCodProd(codProd).setRoot(true).setNumFase(numFase)
|
||||
.setQtaProd(qtaProdDist)
|
||||
.setQtaProd(qtaProd)
|
||||
.setUntMis(untMisProd)
|
||||
.setCodJfasRow(codJfasDist)
|
||||
.setRapConv(rapConvDist)
|
||||
|
||||
@@ -52,7 +52,7 @@ when
|
||||
eval(postRulesEnabled)
|
||||
$testata: DtbOrdt(gestione != null)
|
||||
then
|
||||
if ($testata.getGestione().equalsIgnoreCase("A") && $testata.getOrdTrasf() && $testata.getDtbOrdr().size() > 0) {
|
||||
if ($testata.getGestione().equalsIgnoreCase("A") && $testata.getOrdTrasf() != null && $testata.getOrdTrasf() && $testata.getDtbOrdr().size() > 0) {
|
||||
ProductionBusinessLogic.GeneraOrdTraf(conn, $testata);
|
||||
}
|
||||
CommonRules.completePosRigaEntity(conn, $testata);
|
||||
|
||||
Reference in New Issue
Block a user