aggiornata f_getSSCC

This commit is contained in:
2025-06-13 12:55:52 +02:00
parent 376a1a0afa
commit 145194efec

View File

@@ -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_20250613105615 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createOrUpdateFunction("[f_getSSCC]", "CREATE FUNCTION [dbo].[f_getSSCC](@gestione varchar(1), @dataCollo datetime, @sercollo varchar(3), @numcollo int )\n" +
"RETURNS varchar(18)\n" +
"AS\n" +
"BEGIN\n" +
" -- Declare the return variable here\n" +
" DECLARE @sscc varchar(18) \n" +
"\n" +
" -- Se c'è barcode_ul in testata collo torna quello altrimenti lo calcola\n" +
" select @sscc= barcode_ul from mtb_colt where mtb_colt.gestione = @gestione and\n" +
" mtb_colt.data_collo = @dataCollo and\n" +
" mtb_colt.ser_collo = @sercollo and\n" +
" mtb_colt.num_collo = @numcollo;\n" +
" IF @sscc is null \n" +
" begin\n" +
" select @sscc = '0' + azienda.prefisso_ean + \n" +
" Cast(cast(mtb_colt.num_collo/100000 as int) as varchar) +\n" +
" CASE mtb_colt.gestione \n" +
" WHEN 'A' THEN '1' \n" +
" WHEN 'L' THEN '2'\n" +
" WHEN 'V' THEN '3' END +\n" +
" Right(Cast(DatePart(year, mtb_colt.data_collo) as varchar), 2) +\n" +
" RIGHT(Format(mtb_colt.num_collo, '00000'), 5) \n" +
" FROM mtb_colt, azienda\n" +
" where mtb_colt.gestione = @gestione and\n" +
" mtb_colt.data_collo = @dataCollo and\n" +
" mtb_colt.ser_collo = @sercollo and\n" +
" mtb_colt.num_collo = @numcollo;\n" +
"\n" +
" SELECT @sscc = @sscc + Cast([dbo].[getCheckDigitSSCC] (@sscc) as varchar)\n" +
" end\n" +
" -- Return the result of the function\n" +
" RETURN @sscc\n" +
"END");
}
@Override
public void down() throws Exception {
}
}