aggiornata f_getSSCC
This commit is contained in:
@@ -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 {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user