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-11-20 17:31:57 +01:00
2 changed files with 62 additions and 41 deletions

View File

@@ -49,47 +49,6 @@ public class Migration_20251120123843 extends BaseMigration implements Migration
" RETURN @val;\n" +
" END;");
if (isCustomerDb(IntegryCustomerDB.CapelliMonelli_CapelliMonelli)) {
createOrUpdateFunction("f_suggestCodeCodAnag","\n" +
"CREATE FUNCTION [dbo].[f_suggestCodeCodAnag](@partialCode varchar(5))\n" +
" \n" +
"RETURNS varchar(20) \n" +
"WITH INLINE = OFF\n" +
"AS\n" +
"BEGIN\n" +
"\tDECLARE @ls_codAnag VARCHAR(5), @codLen int, @condPartialCode varchar(10), @recuperaCodici varchar(1);\n" +
"\n" +
"\tSELECT @condPartialCode= ISNULL(@partialCode, '') + '[0-9]'\n" +
"\n" +
"\tSELECT @partialCode = ISNULL(@partialCode, '')\n" +
"\n" +
"\tSET @codLen = 5\n" +
"\t\n" +
"\tSELECT @recuperaCodici = dbo.getGestSetup('GTB_ANAG','SETUP','RECUPERA_CODICI')\n" +
"\n" +
"\tIF @recuperaCodici = 'S'\n" +
"\t\tBEGIN\n" +
"\t\t\tSELECT @ls_codAnag = (\n" +
"\t\t\tSELECT top 1 @partialCode + REPLICATE('0', 5 - len(@partialCode) - len(row_id)) + cast(row_id as varchar)\n" +
"\t\t\tfrom (\n" +
"\t\t\tselect cast(SUBSTRING(cod_anag, len(@partialCode) + 1, len(cod_anag) - len(@partialCode) + 1) as int) as num_code, \n" +
"\t\t\tROW_NUMBER() over (order by cast(SUBSTRING(cod_anag, len(@partialCode) + 1, len(cod_anag) - len(@partialCode) + 1) as int)) as row_id\n" +
"\t\t\tfrom gtb_anag\n" +
"\t\t\twhere cod_anag like @condPartialCode+'%') tmp \n" +
"\t\t\twhere tmp.num_code > tmp.row_id and tmp.num_code <> 0)\n" +
"\t\tEND\n" +
"\n" +
"\tif @ls_codAnag is null \n" +
"\t\tbegin\t\t\t\t\n" +
"\t\t\tSELECT @ls_codAnag = @partialCode + REPLICATE('0', @codLen - len(@partialCode) - len(dbo.IntToBase36(max_code.partial_code))) + Cast(dbo.IntToBase36(max_code.partial_code) as varchar)\n" +
"\t\t\tfrom ( \n" +
"\t\t\tSELECT cast(IsNull(max(try_cast(substring(cod_anag, len(@partialCode)+1, len(cod_anag) - len(@partialCode)) as numeric)), 0) + 1 as varchar) as partial_code\n" +
"\t\t\tFROM gtb_anag\n" +
"\t\t\tWHERE cod_anag like @partialCode + '%' ) max_code;\n" +
"\t\tend \n" +
"\tRETURN @ls_codAnag;\n" +
"END \n");
}
}

View File

@@ -0,0 +1,62 @@
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_20251120172527 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
if(!isCustomer(IntegryCustomer.CapelliMonelli)) return;
createOrUpdateFunction("[f_suggestCodeCodAnag]", "CREATE FUNCTION [dbo].[f_suggestCodeCodAnag](@partialCode varchar(5))\n" +
" \n" +
"RETURNS varchar(20) \n" +
"WITH INLINE = OFF\n" +
"AS\n" +
"BEGIN\n" +
" DECLARE @ls_codAnag VARCHAR(5), @codLen int, @condPartialCode varchar(10), @recuperaCodici varchar(1);\n" +
"\n" +
" SELECT @condPartialCode= ISNULL(@partialCode, '') + '[0-9]'\n" +
"\n" +
" SELECT @partialCode = ISNULL(@partialCode, '')\n" +
"\n" +
" SET @codLen = 5\n" +
" \n" +
" SELECT @recuperaCodici = dbo.getGestSetup('GTB_ANAG','SETUP','RECUPERA_CODICI')\n" +
"\n" +
" IF @recuperaCodici = 'S'\n" +
" BEGIN\n" +
" SELECT @ls_codAnag = (\n" +
" SELECT top 1 @partialCode + REPLICATE('0', 5 - len(@partialCode) - len(row_id)) + cast(row_id as varchar)\n" +
" from (\n" +
" select cast(SUBSTRING(cod_anag, len(@partialCode) + 1, len(cod_anag) - len(@partialCode) + 1) as int) as num_code, \n" +
" ROW_NUMBER() over (order by cast(SUBSTRING(cod_anag, len(@partialCode) + 1, len(cod_anag) - len(@partialCode) + 1) as int)) as row_id\n" +
" from gtb_anag\n" +
" where cod_anag like @condPartialCode+'%') tmp \n" +
" where tmp.num_code > tmp.row_id and tmp.num_code <> 0)\n" +
" END\n" +
"\n" +
" if @ls_codAnag is null \n" +
" begin \n" +
" SELECT @ls_codAnag = @partialCode + REPLICATE('0', @codLen - len(@partialCode) - len(dbo.IntToBase36(max_code.partial_code))) + Cast(dbo.IntToBase36(max_code.partial_code) as varchar)\n" +
" from ( \n" +
" SELECT cast(IsNull(max(try_cast(substring(cod_anag, len(@partialCode)+1, len(cod_anag) - len(@partialCode)) as numeric)), 0) + 1 as varchar) as partial_code\n" +
" FROM gtb_anag\n" +
" WHERE cod_anag like @partialCode + '%' ) max_code;\n" +
" end \n" +
" RETURN @ls_codAnag;\n" +
"END");
}
@Override
public void down() throws Exception {
}
}