Merge branch 'develop' into feature/JDK11
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good

This commit is contained in:
jenkins
2025-02-27 16:53:44 +01:00

View File

@@ -0,0 +1,79 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.IntegryCustomer;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250227154029 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
if (!isCustomer(IntegryCustomer.RossoGargano)) return;
createOrUpdateFunction("f_suggestBarcodeUl", "CREATE FUNCTION [dbo].[f_suggestBarcodeUl](@gestione VARCHAR,\n" +
" @dataCollo DATE,\n" +
" @serCollo VARCHAR(2),\n" +
" @codJfas VARCHAR(5),\n" +
" @numCollo INT,\n" +
" @customPrefissoEan VARCHAR(9),\n" +
" @idCollo BIGINT\n" +
")\n" +
" RETURNS VARCHAR(20)\n" +
"AS\n" +
"BEGIN\n" +
"\n" +
" DECLARE @barcode VARCHAR(20);\n" +
"\n" +
" IF @codJfas IS NULL\n" +
" BEGIN\n" +
" SELECT @barcode = CONCAT(prefisso_ean,\n" +
" RIGHT(FORMAT(@idCollo, REPLICATE('0', 17)), (17 - LEN(prefisso_ean))))\n" +
" FROM azienda\n" +
"\n" +
" SELECT @barcode = CONCAT(@barcode, dbo.getCheckDigitSSCC(@barcode))\n" +
"\n" +
" RETURN @barcode;\n" +
"\n" +
" END;\n" +
" ELSE\n" +
" BEGIN\n" +
" WITH dati AS (SELECT ISNULL(@customPrefissoEan, azienda.prefisso_ean) AS prefisso_ean,\n" +
" Isnull(jtb_fasi.id_jfas, 0) AS id_variabile,\n" +
" ISNULL(@idCollo, @numCollo) AS idCollo\n" +
"\n" +
" FROM jtb_fasi\n" +
" , azienda\n" +
" WHERE jtb_fasi.cod_jfas = @codJfas)\n" +
"\n" +
" SELECT @barcode =\n" +
" CASE\n" +
" WHEN @codJfas = 'RACC' THEN CONCAT(FORMAT(@dataCollo, 'yy'),\n" +
" RIGHT(FORMAT(@idCollo, REPLICATE('0', 6)), 6))\n" +
" ELSE\n" +
" CONCAT(prefisso_ean,\n" +
" id_variabile,\n" +
" RIGHT(FORMAT(idCollo, REPLICATE('0', 17)),\n" +
" (17 - LEN(prefisso_ean) - LEN(id_variabile)))) END\n" +
" FROM dati\n" +
"\n" +
" IF @codJFas <> 'RACC'\n" +
" SELECT @barcode = CONCAT(@barcode, dbo.getCheckDigitSSCC(@barcode))\n" +
"\n" +
"\n" +
" RETURN @barcode;\n" +
" END\n" +
" RETURN @barcode\n" +
"END");
}
@Override
public void down() throws Exception {
}
}