Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
@@ -7,6 +7,10 @@
|
||||
<option name="HOST" value="serverdev" />
|
||||
<option name="PORT" value="8001" />
|
||||
<option name="AUTO_RESTART" value="false" />
|
||||
<RunnerSettings RunnerId="Debug">
|
||||
<option name="DEBUG_PORT" value="8001" />
|
||||
<option name="LOCAL" value="false" />
|
||||
</RunnerSettings>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
@@ -385,6 +385,27 @@ public class SQLServerDBSchemaManager {
|
||||
}
|
||||
|
||||
|
||||
public List<String> generateAlterTableToDisableAnsiPadding() throws SQLException {
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstColumn(this.mConnection, "SELECT 'ALTER TABLE ' + OBJECT_SCHEMA_NAME(sys.objects.object_id) + '.' + \n" +
|
||||
" sys.objects.name + ' ALTER COLUMN [' + sys.columns.name + '] ' + \n" +
|
||||
" sys.types.name + CASE WHEN sys.types.name IN ('text','ntext') THEN ''\n" +
|
||||
" WHEN sys.types.name IN ('char','varchar') \n" +
|
||||
" THEN '('+IIF(sys.columns.max_length = -1, 'MAX', CAST(sys.columns.max_length AS varchar(10)))+')'\n" +
|
||||
" WHEN sys.types.name IN ('nchar','nvarchar') \n" +
|
||||
" THEN '('+CAST(sys.columns.max_length/2 AS varchar(10))+')' END +\n" +
|
||||
" ' ' + CASE WHEN sys.columns.is_nullable = 0 \n" +
|
||||
" THEN 'NOT NULL' ELSE 'NULL' END\n" +
|
||||
"FROM sys.columns\n" +
|
||||
"JOIN sys.types\n" +
|
||||
" ON sys.columns.user_type_id = sys.types.user_type_id\n" +
|
||||
"JOIN sys.objects\n" +
|
||||
" ON sys.columns.object_id = sys.objects.object_id\n" +
|
||||
"WHERE is_ansi_padded = 0\n" +
|
||||
" AND sys.types.name in ('char','varchar')\n" +
|
||||
" AND sys.objects.type = 'U'");
|
||||
}
|
||||
|
||||
|
||||
private String generateAddColumnSyntax(DatabaseTableColumn tableColumn) {
|
||||
String columnSize = null;
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bouncycastle.its.operator.ITSContentSigner;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -177,8 +178,11 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
||||
executeStatement(dropSql);
|
||||
}
|
||||
|
||||
|
||||
protected void createSetupQuery(String codQuery, String name, String query, boolean override) throws SQLException, IOException {
|
||||
if (UtilityString.isNullOrEmpty(codQuery)) {
|
||||
executeStatement(Query.format("EXEC sp_insertQuerySetup %s", query));
|
||||
return;
|
||||
}
|
||||
boolean existQuery = false;
|
||||
if(override) {
|
||||
String sql = Query.format("SELECT cast(count(*) as bit) FROM stb_gest_setup_query WHERE cod_query = %s", codQuery);
|
||||
@@ -261,12 +265,26 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
||||
ps.executeUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
protected void createSetup(String gestName, String section, String keySection, String value, String description, boolean flagSync,
|
||||
String codQuery, boolean flagUserView, boolean flagSetupDepo, boolean flagSetupUserWeb,
|
||||
boolean flagTipoJson, boolean flagTipoColore, String tipoSetup, boolean flagMultiValue ) throws Exception {
|
||||
createSetup(gestName, section,keySection, value, description, flagSync, codQuery, flagUserView, flagSetupDepo,
|
||||
flagSetupUserWeb, flagTipoJson, flagTipoColore, tipoSetup, flagMultiValue, null);
|
||||
}
|
||||
|
||||
protected void createSetup(String gestName, String section, String keySection, String value, String description, boolean flagSync,
|
||||
String codQuery, boolean flagUserView, boolean flagSetupDepo, boolean flagSetupUserWeb,
|
||||
boolean flagTipoJson, boolean flagTipoColore, String tipoSetup, boolean flagMultiValue,
|
||||
String query) throws Exception {
|
||||
if (existsSetup(gestName, section, keySection))
|
||||
return;
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(query) && UtilityString.isNullOrEmpty(codQuery)) {
|
||||
codQuery = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
|
||||
Query.format("SELECT cod_query FROM stb_gest_setup_query WHERE cod_query = %s", query));
|
||||
}
|
||||
|
||||
String insertSql = "INSERT INTO " + StbGestSetup.ENTITY +
|
||||
" (gest_name, section, key_section, value, description, flag_sync, query_default,\n" +
|
||||
"flag_user_view, flag_setup_depo, flag_setup_user_web,\n" +
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.entity_logger.db_schema_manager.component.SQLServerDBSchemaManager;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240408151802 extends BaseMigration implements MigrationModelInterface {
|
||||
import java.util.List;
|
||||
|
||||
public class Migration_20240408151803 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomer(IntegryCustomer.Tosca,
|
||||
if (isCustomer(
|
||||
IntegryCustomer.Tosca,
|
||||
IntegryCustomer.Biolevante,
|
||||
IntegryCustomer.Cosmapack,
|
||||
IntegryCustomer.Dulciar,
|
||||
@@ -23,11 +27,16 @@ public class Migration_20240408151802 extends BaseMigration implements Migration
|
||||
IntegryCustomer.ResinaColor,
|
||||
IntegryCustomer.Ivr,
|
||||
IntegryCustomer.Sardinya,
|
||||
IntegryCustomer.Didonna))
|
||||
{
|
||||
IntegryCustomer.Didonna,
|
||||
IntegryCustomer.Smetar)) {
|
||||
updateSetupValue("DATI_AZIENDA", "SETUP", "DELIMITED_IDENTIFIER", "1");
|
||||
updateSetupValue("DATI_AZIENDA", "SETUP", "FLAG_ANSI_PADDING", "S");
|
||||
updateSetupValue("DATI_AZIENDA", "SETUP", "FLAG_CONCAT_NULL_YIELDS_NULL", "S");
|
||||
|
||||
SQLServerDBSchemaManager schemaManager = new SQLServerDBSchemaManager(this.advancedDataSource.getConnection());
|
||||
final List<String> queries = schemaManager.generateAlterTableToDisableAnsiPadding();
|
||||
|
||||
//executeStatement(queries.toArray(new String[0]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240409131537 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateView("cvw_saldiAnagAnno", "CREATE view cvw_saldiAnagAnno as \n" +
|
||||
"select cod_anag, cod_ccon, anno_comp, sum(saldo_iniz) as saldo_iniz, sum(dare) as dare, sum(avere) as avere from (\n" +
|
||||
"SELECT ctb_movr.cod_anag,\n" +
|
||||
" ctb_movr.cod_ccon,\n" +
|
||||
" ctb_movt.anno_comp,\n" +
|
||||
" 0 AS saldo_iniz,\n" +
|
||||
" SUM(imp_dare) AS dare,\n" +
|
||||
" SUM(imp_avere) AS avere\n" +
|
||||
"FROM ctb_anag,\n" +
|
||||
" ctb_caus,\n" +
|
||||
" ctb_movr,\n" +
|
||||
" ctb_movt\n" +
|
||||
"WHERE (ctb_caus.cod_ccau = ctb_movr.cod_ccau)\n" +
|
||||
" AND (ctb_anag.cod_anag = ctb_movr.cod_anag)\n" +
|
||||
" AND (ctb_anag.cod_ccon = ctb_movr.cod_ccon)\n" +
|
||||
" AND (ctb_movt.num_cmov = ctb_movr.num_cmov)\n" +
|
||||
" AND ((ctb_caus.flag_ap_ch <> 'A' AND ctb_caus.flag_ap_ch <> 'F'))\n" +
|
||||
"GROUP BY ctb_movr.cod_anag, ctb_movr.cod_ccon, ctb_movt.anno_comp\n" +
|
||||
"UNION\n" +
|
||||
"SELECT ctb_movr.cod_anag,\n" +
|
||||
" ctb_movr.cod_ccon,\n" +
|
||||
" ctb_movt.anno_comp,\n" +
|
||||
" SUM(imp_dare - imp_avere) AS saldo_iniz,\n" +
|
||||
" 0 AS dare,\n" +
|
||||
" 0 AS avere\n" +
|
||||
"FROM ctb_anag,\n" +
|
||||
" ctb_caus,\n" +
|
||||
" ctb_movr,\n" +
|
||||
" ctb_movt\n" +
|
||||
"WHERE (ctb_caus.cod_ccau = ctb_movr.cod_ccau)\n" +
|
||||
" AND (ctb_anag.cod_anag = ctb_movr.cod_anag)\n" +
|
||||
" AND (ctb_anag.cod_ccon = ctb_movr.cod_ccon)\n" +
|
||||
" AND (ctb_movt.num_cmov = ctb_movr.num_cmov)\n" +
|
||||
" AND ((ctb_caus.flag_ap_ch = 'A'))\n" +
|
||||
"GROUP BY ctb_movr.cod_anag, ctb_movr.cod_ccon, ctb_movt.anno_comp\n" +
|
||||
") t \n" +
|
||||
"group by cod_anag, cod_ccon, anno_comp");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240409155144 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createOrUpdateFunction("f_getEAN128UL", "CREATE FUNCTION [dbo].[f_getEAN128UL](@gestione VARCHAR(1), @dataCollo DATETIME, @serCollo VARCHAR(2), @numCollo int, @customPrefissoEan VARCHAR(7))\n" +
|
||||
" RETURNS TABLE AS\n" +
|
||||
" RETURN\n" +
|
||||
"\n" +
|
||||
"-- DECLARE @gestione AS VARCHAR(1) = 'L'\n" +
|
||||
"-- DECLARE @serCollo AS VARCHAR(10) = '/'\n" +
|
||||
"-- DECLARE @numCollo AS INT = 4427\n" +
|
||||
"-- DECLARE @dataCollo AS DATETIME = '2024-02-05';\n" +
|
||||
"-- DECLARE @customPrefissoEan AS VARCHAR(7);-- = '8017596';\n" +
|
||||
"\n" +
|
||||
"WITH barcodes AS (\n" +
|
||||
" SELECT CONCAT(CASE WHEN @customPrefissoEan IS NULL THEN azienda.prefisso_ean ELSE @customPrefissoEan END,\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, REPLICATE('0', 5)), 5)) AS AI_00,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_aart.cod_barre_imb IS NOT NULL AND LEN(mtb_aart.cod_barre_imb) < 14 THEN\n" +
|
||||
" FORMAT(CONVERT(NUMERIC, ISNULL(NULLIF(mtb_aart.cod_barre_imb, ''), '0')), REPLICATE('0', 14))\n" +
|
||||
" ELSE mtb_aart.cod_barre_imb\n" +
|
||||
" END AS AI_01,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_aart.bar_code IS NOT NULL AND LEN(mtb_aart.bar_code) < 14\n" +
|
||||
" THEN\n" +
|
||||
" FORMAT(CONVERT(BIGINT, mtb_aart.bar_code), REPLICATE('0', 14))\n" +
|
||||
" ELSE mtb_aart.bar_code\n" +
|
||||
" END AS AI_02,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_colr.partita_mag IS NOT NULL THEN\n" +
|
||||
" mtb_colr.partita_mag + CHAR(29)\n" +
|
||||
" END AS AI_10,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_partita_mag.data_scad IS NOT NULL THEN\n" +
|
||||
" REPLACE(CONVERT(varchar(10), mtb_partita_mag.data_scad, 2), '.', '')\n" +
|
||||
" END AS AI_15,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 6 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '000000'), '.', '')\n" +
|
||||
" END AS AI_3100,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 5 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '00000.0'), '.', '')\n" +
|
||||
" END AS AI_3101,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 4 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '0000.00'), '.', '')\n" +
|
||||
" END AS AI_3102,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 3 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '000.000'), '.', '')\n" +
|
||||
" END AS AI_3103,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 2 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '00.0000'), '.', '')\n" +
|
||||
" END AS AI_3104,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 1 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '0.00000'), '.', '')\n" +
|
||||
" END AS AI_3105,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 6 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_colt.peso_kg, '000000'), '.', '')\n" +
|
||||
" END AS AI_3300,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 5 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_colt.peso_kg, '00000.0'), '.', '')\n" +
|
||||
" END AS AI_3301,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 4 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_colt.peso_kg, '0000.00'), '.', '')\n" +
|
||||
" END AS AI_3302,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 3 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_colt.peso_kg, '000.000'), '.', '')\n" +
|
||||
" END AS AI_3303,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 2 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_colt.peso_kg, '00.0000'), '.', '')\n" +
|
||||
" END AS AI_3304,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 1 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_colt.peso_kg, '0.00000'), '.', '')\n" +
|
||||
" END AS AI_3305,\n" +
|
||||
" CONVERT(varchar, CONVERT(integer, SUM(mtb_colr.qta_col / mtb_colr.qta_cnf))) AS AI_37\n" +
|
||||
" FROM mtb_colt\n" +
|
||||
" INNER JOIN mtb_colr\n" +
|
||||
" ON mtb_colt.gestione = mtb_colr.gestione and mtb_colt.data_collo = mtb_colr.data_collo and\n" +
|
||||
" mtb_colt.ser_collo = mtb_colr.ser_collo and mtb_colt.num_collo = mtb_colr.num_collo\n" +
|
||||
" INNER JOIN mtb_aart ON mtb_colr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" LEFT outer JOIN mtb_partita_mag ON mtb_colr.cod_mart = mtb_partita_mag.cod_mart AND\n" +
|
||||
" mtb_colr.partita_mag = mtb_partita_mag.partita_mag,\n" +
|
||||
" azienda\n" +
|
||||
" WHERE mtb_colt.gestione = @gestione\n" +
|
||||
" AND mtb_colt.data_collo = @dataCollo\n" +
|
||||
" AND mtb_colt.ser_collo = @serCollo\n" +
|
||||
" AND mtb_colt.num_collo = @numCollo\n" +
|
||||
" GROUP BY mtb_colr.qta_col,\n" +
|
||||
" mtb_colr.qta_cnf,\n" +
|
||||
" mtb_colt.data_vers,\n" +
|
||||
" nome_ditta,\n" +
|
||||
" azienda.indirizzo,\n" +
|
||||
" azienda.cap,\n" +
|
||||
" azienda.citta,\n" +
|
||||
" azienda.prov,\n" +
|
||||
" prefisso_ean,\n" +
|
||||
" mtb_colt.data_collo,\n" +
|
||||
" mtb_colt.num_collo,\n" +
|
||||
" mtb_aart.cod_barre_imb,\n" +
|
||||
" mtb_aart.bar_code,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" mtb_colr.partita_mag,\n" +
|
||||
" mtb_partita_mag.data_scad,\n" +
|
||||
" mtb_colt.peso_netto_kg,\n" +
|
||||
" mtb_colr.cod_mart, \n" +
|
||||
"\t\t\t mtb_colt.gestione,\n" +
|
||||
"\t\t\t mtb_colt.peso_kg,\n" +
|
||||
"\t\t\t mtb_aart.peso_kg\n" +
|
||||
"),\n" +
|
||||
" appoggio AS (\n" +
|
||||
" SELECT CONCAT(\n" +
|
||||
" REPLICATE('0', 17 - LEN(AI_00)),\n" +
|
||||
" AI_00) AS AI_00,\n" +
|
||||
" CASE WHEN AI_01 IS NOT NULL AND LEN(AI_01) = 13 THEN CONCAT(AI_01, dbo.getCheckDigitITF14(AI_01)) ELSE AI_01 END AS AI_01,\n" +
|
||||
" AI_02,\n" +
|
||||
" AI_10,\n" +
|
||||
" AI_15,\n" +
|
||||
" AI_3100,\n" +
|
||||
" AI_3101,\n" +
|
||||
" AI_3102,\n" +
|
||||
" AI_3103,\n" +
|
||||
" AI_3104,\n" +
|
||||
" AI_3105,\n" +
|
||||
" AI_3300,\n" +
|
||||
" AI_3301,\n" +
|
||||
" AI_3302,\n" +
|
||||
" AI_3303,\n" +
|
||||
" AI_3304,\n" +
|
||||
" AI_3305,\n" +
|
||||
" AI_37\n" +
|
||||
" FROM barcodes\n" +
|
||||
" )\n" +
|
||||
"SELECT CONCAT(AI_00,\n" +
|
||||
" dbo.getCheckDigitSSCC(AI_00)) AS AI_00,\n" +
|
||||
" AI_01,\n" +
|
||||
" AI_02,\n" +
|
||||
" AI_10,\n" +
|
||||
" AI_15,\n" +
|
||||
" AI_3100,\n" +
|
||||
" AI_3101,\n" +
|
||||
" AI_3102,\n" +
|
||||
" AI_3103,\n" +
|
||||
" AI_3104,\n" +
|
||||
" AI_3105,\n" +
|
||||
" AI_3300,\n" +
|
||||
" AI_3301,\n" +
|
||||
" AI_3302,\n" +
|
||||
" AI_3303,\n" +
|
||||
" AI_3304,\n" +
|
||||
" AI_3305,\n" +
|
||||
" AI_37\n" +
|
||||
"FROM appoggio");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240409163647 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateView("[cvw_saldiContAnno]", "CREATE view [dbo].[cvw_saldiContAnno] as \n" +
|
||||
"select cod_ccon, anno_comp, SUM(saldo_iniz) as saldo_iniz, SUM(dare) as dare, SUM(avere) as avere\n" +
|
||||
"from (\n" +
|
||||
"SELECT ctb_movr.cod_ccon, ctb_movt.anno_comp, 0 AS saldo_iniz, SUM(imp_dare) AS dare, SUM(imp_avere) AS avere\n" +
|
||||
"FROM ctb_cont,\n" +
|
||||
" ctb_caus,\n" +
|
||||
" ctb_movr,\n" +
|
||||
" ctb_movt\n" +
|
||||
"WHERE (ctb_caus.cod_ccau = ctb_movr.cod_ccau)\n" +
|
||||
" AND (ctb_cont.cod_ccon = ctb_movr.cod_ccon)\n" +
|
||||
" AND (ctb_movt.num_cmov = ctb_movr.num_cmov)\n" +
|
||||
" AND ((ctb_caus.flag_ap_ch <> 'A' AND ctb_caus.flag_ap_ch <> 'F'))\n" +
|
||||
"GROUP BY ctb_movr.cod_ccon, ctb_movt.anno_comp\n" +
|
||||
"UNION\n" +
|
||||
"SELECT ctb_movr.cod_ccon, ctb_movt.anno_comp, SUM(imp_dare - imp_avere) AS saldo_iniz, 0 AS dare, 0 AS avere\n" +
|
||||
"FROM ctb_cont,\n" +
|
||||
" ctb_caus,\n" +
|
||||
" ctb_movr,\n" +
|
||||
" ctb_movt\n" +
|
||||
"WHERE (ctb_caus.cod_ccau = ctb_movr.cod_ccau)\n" +
|
||||
" AND (ctb_cont.cod_ccon = ctb_movr.cod_ccon)\n" +
|
||||
" AND (ctb_movt.num_cmov = ctb_movr.num_cmov)\n" +
|
||||
" AND ((ctb_caus.flag_ap_ch = 'A'))\n" +
|
||||
"GROUP BY ctb_movr.cod_ccon, ctb_movt.anno_comp) t\n" +
|
||||
"GROUP BY cod_ccon, anno_comp");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240409165638 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateView("[cvw_mov_black_list]", "CREATE VIEW cvw_mov_black_list AS\n" +
|
||||
"SELECT crl_movt_rif_cmov.num_cmov, \n" +
|
||||
" ctb_movt.num_cmov as num_cmov_rif,\n" +
|
||||
" ctb_movt.data_cmov, \n" +
|
||||
" ctb_movt.cod_ccau, \n" +
|
||||
" ctb_movt.cod_anag, \n" +
|
||||
" gtb_anag.rag_soc,\n" +
|
||||
" ctb_movt.data_doc, \n" +
|
||||
" ctb_movt.ser_doc, \n" +
|
||||
" ctb_movt.num_doc,\n" +
|
||||
" ctb_movt.importo\n" +
|
||||
"FROM crl_movt_rif_cmov, ctb_movt, gtb_anag\n" +
|
||||
"WHERE crl_movt_rif_cmov.num_cmov_rif = ctb_movt.num_cmov AND \n" +
|
||||
" ctb_movt.cod_anag = gtb_anag.cod_anag");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240409184306 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
|
||||
|
||||
createOrUpdateView("[cvw_mov_black_list]", "CREATE VIEW cvw_mov_black_list AS\n" +
|
||||
"SELECT crl_movt_rif_cmov.num_cmov, \n" +
|
||||
" ctb_movt.num_cmov as num_cmov_rif,\n" +
|
||||
" ctb_movt.data_cmov, \n" +
|
||||
" ctb_movt.cod_ccau, \n" +
|
||||
" ctb_movt.cod_anag, \n" +
|
||||
" ctb_movt.cod_ireg, \n" +
|
||||
" gtb_anag.rag_soc,\n" +
|
||||
" ctb_movt.data_doc, \n" +
|
||||
" ctb_movt.ser_doc, \n" +
|
||||
" ctb_movt.num_doc,\n" +
|
||||
" ctb_movt.importo\n" +
|
||||
"FROM crl_movt_rif_cmov, ctb_movt, gtb_anag\n" +
|
||||
"WHERE crl_movt_rif_cmov.num_cmov_rif = ctb_movt.num_cmov AND \n" +
|
||||
" ctb_movt.cod_anag = gtb_anag.cod_anag");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -205,7 +205,7 @@ public class AccountingBusinessLogic {
|
||||
|
||||
public static void reverseCharge(Connection conn, CtbMovt testata) throws Exception {
|
||||
Integer numCmovRC = null, numProtRC = null, numIregRc = null;
|
||||
BigDecimal totImponib = BigDecimal.ZERO, totIva = BigDecimal.ZERO, totDoc = BigDecimal.ZERO;
|
||||
BigDecimal totImponib = BigDecimal.ZERO, totIva = BigDecimal.ZERO, totDoc;
|
||||
CtbMovt ctbMovtRC = null;
|
||||
List<CtbMovi> ctbMoviRC = new ArrayList<>();
|
||||
|
||||
@@ -243,7 +243,7 @@ public class AccountingBusinessLogic {
|
||||
if (numCmovRC == null) {
|
||||
sql =
|
||||
"SELECT TOP 1 " +
|
||||
"dtb_inum.num_ireg, " +
|
||||
"CAST(dtb_inum.num_ireg AS INT) AS num_ireg, " +
|
||||
"dtb_inum.ser_doc " +
|
||||
" FROM ctb_movt INNER JOIN ctb_caus ON ctb_movt.cod_ccau = ctb_caus.cod_ccau " +
|
||||
" INNER JOIN ctb_caus ctb_caus_rc ON ctb_caus.cod_ccau_rc = ctb_caus_rc.cod_ccau " +
|
||||
|
||||
@@ -20,6 +20,8 @@ import java.util.*;
|
||||
|
||||
|
||||
public class AccountingRules extends QueryRules {
|
||||
|
||||
|
||||
public static Integer completeNumIreg(Connection connection, String codIreg) throws Exception {
|
||||
String sql =
|
||||
"SELECT min(num_ireg) as min FROM ctb_inum WHERE cod_ireg = " + UtilityDB.valueToString(codIreg);
|
||||
@@ -118,19 +120,16 @@ public class AccountingRules extends QueryRules {
|
||||
}
|
||||
|
||||
|
||||
public static Integer completeAnnoComp(Connection conn, Date dataCmov) throws SQLException {
|
||||
if (dataCmov == null) {
|
||||
SimpleDateFormat formatDate = new SimpleDateFormat("yyyy");
|
||||
Date now = new Date();
|
||||
return Integer.valueOf(formatDate.format(now));
|
||||
}
|
||||
public static Integer getAnnoComp(Connection conn, Date dataCmov) throws SQLException {
|
||||
if (dataCmov == null)
|
||||
return UtilityLocalDate.getNow().getYear();
|
||||
|
||||
String sql =
|
||||
Query.format(
|
||||
"SELECT anno FROM gtb_periodo_fisc WHERE %s BETWEEN data_iniz AND data_fine",
|
||||
"SELECT dbo.f_getAnnoFisc(%s)",
|
||||
dataCmov );
|
||||
|
||||
Short annoComp = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
return annoComp.intValue();
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
}
|
||||
|
||||
public static String getCodBiva(Connection connection, String codAnag) throws Exception {
|
||||
|
||||
@@ -7,10 +7,7 @@ import it.integry.ems_model.entity.DtbDocr;
|
||||
import it.integry.ems_model.entity.DtbDoct;
|
||||
import it.integry.ems_model.entity.NtbDoct;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityDate;
|
||||
import it.integry.ems_model.utility.UtilityHashMap;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import it.integry.ems_model.utility.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Connection;
|
||||
@@ -35,7 +32,8 @@ public class DocumentCheckRules {
|
||||
Integer annoAtt = new Integer(DatiAzi.get("anno_attuale").toString());
|
||||
Integer annoContab = new Integer(DatiAzi.get("anno_contab").toString());
|
||||
Date ultDataGio = dateformat.parse(DatiAzi.get("ult_data_gio").toString());
|
||||
Integer annoMov = Integer.valueOf(annoFormat.format(dataCmov)).intValue();
|
||||
|
||||
Integer annoMov = AccountingRules.getAnnoComp(conn, dataCmov);
|
||||
|
||||
Integer numIreg = entity.getDtbTipi().getNumIreg();
|
||||
String codIreg = entity.getDtbTipi().getCodIreg();
|
||||
@@ -76,31 +74,26 @@ public class DocumentCheckRules {
|
||||
}
|
||||
|
||||
private static void checkData(DtbDoct entity, Connection conn) throws Exception {
|
||||
Date dataToChk = null;
|
||||
Integer ggUtili = 0, segnoLiquid = 0;
|
||||
PreparedStatement info;
|
||||
ResultSet res;
|
||||
SimpleDateFormat annoFormat = new SimpleDateFormat("yyyy");
|
||||
Date dataNow = new Date();
|
||||
// Date dataToChk = null;
|
||||
// Integer ggUtili = 0, segnoLiquid = 0;
|
||||
// PreparedStatement info;
|
||||
// ResultSet res;
|
||||
// SimpleDateFormat annoFormat = new SimpleDateFormat("yyyy");
|
||||
// Date dataNow = new Date();
|
||||
|
||||
// ACQUISIZION DATI DOCUMENTO
|
||||
String codCcau = entity.getDtbTipi().getCodCcau();
|
||||
|
||||
String codIreg = entity.getDtbTipi().getCodIreg();
|
||||
|
||||
// ACQUISIZIONE DATI REGISTRO
|
||||
String sql =
|
||||
"SELECT segno_liquid " +
|
||||
"SELECT Cast(segno_liquid as int)" +
|
||||
" FROM ctb_ireg" +
|
||||
" WHERE cod_ireg = " + UtilityDB.valueToString(codIreg);
|
||||
info = conn.prepareStatement(sql);
|
||||
res = info.executeQuery();
|
||||
while (res.next()) {
|
||||
segnoLiquid = res.getInt(1);
|
||||
}
|
||||
res.close();
|
||||
info.close();
|
||||
|
||||
Integer segnoLiquid = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
|
||||
Date dataToChk;
|
||||
if (segnoLiquid == 1) {
|
||||
dataToChk = entity.getDataDoc();
|
||||
} else {
|
||||
@@ -115,11 +108,16 @@ public class DocumentCheckRules {
|
||||
HashMap<String, Object> DatiAzi = Azienda.getDatiAzienda(conn);
|
||||
Integer annoAtt = new Integer(DatiAzi.get("anno_attuale").toString());
|
||||
Integer annoMagaz = new Integer(DatiAzi.get("anno_magaz").toString());
|
||||
|
||||
Integer ggUtili = 0;
|
||||
if (DatiAzi.get("gg_utili") != null) {
|
||||
ggUtili = new Integer(DatiAzi.get("gg_utili").toString());
|
||||
}
|
||||
Integer annoComp = Integer.valueOf(annoFormat.format(dataToChk)).intValue();
|
||||
Integer giorni = UtilityDate.DaysAfter(dataToChk, dataNow);
|
||||
|
||||
|
||||
Integer annoComp = AccountingRules.getAnnoComp(conn, dataToChk);
|
||||
|
||||
Integer giorni = UtilityDate.DaysAfter(dataToChk, UtilityDate.getTodayWithoutTime());
|
||||
|
||||
// CONTROLLO DATA MOVIMENTO
|
||||
if (codIreg != null && codCcau != null) {
|
||||
@@ -130,10 +128,8 @@ public class DocumentCheckRules {
|
||||
throw new Exception("Data non ammessa. Anno documento diverso da anno magazzino e anno attuale.");
|
||||
}
|
||||
// CONTROLLO GIORNI UTILI PER LA MODIFICA
|
||||
if (ggUtili != 0 && ggUtili > 0 && codCcau != null) {
|
||||
if (giorni > ggUtili) {
|
||||
throw new Exception("Data non ammessa. Giorni utili per la modifica " + ggUtili + ".");
|
||||
}
|
||||
if (ggUtili != 0 && ggUtili > 0 && codCcau != null && giorni > ggUtili) {
|
||||
throw new Exception("Data non ammessa. Giorni utili per la modifica " + ggUtili + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,12 +235,6 @@ public class DocumentCheckRules {
|
||||
}
|
||||
|
||||
public static Boolean checkDataDoc(Connection conn, DtbDoct entity) throws Exception {
|
||||
String sql;
|
||||
Date dataRegNew = null;
|
||||
PreparedStatement info;
|
||||
ResultSet res;
|
||||
SimpleDateFormat annoFormat = new SimpleDateFormat("yyyy");
|
||||
|
||||
// ACQUISIZIONE DATI CHIAVE
|
||||
String codAnag = entity.getCodAnag();
|
||||
String codDtip = entity.getCodDtip();
|
||||
@@ -255,22 +245,16 @@ public class DocumentCheckRules {
|
||||
String gestione = entity.getGestione(); /*LEGGERE DA ENTITY*/
|
||||
|
||||
// ACQUSIZIONE DATI DOCUMENTO
|
||||
Date dataRegNew = null;
|
||||
if (dataReg == null) {
|
||||
sql =
|
||||
"SELECT data_reg " +
|
||||
" FROM dtb_doct" +
|
||||
" WHERE cod_anag = " + UtilityDB.valueToString(codAnag) + " AND " +
|
||||
" cod_dtip = " + UtilityDB.valueToString(codDtip) + " AND " +
|
||||
" data_doc = " + UtilityDB.valueDateToString(dataDoc, CommonConstants.DATE_FORMAT_YMD) + " AND " +
|
||||
" ser_doc = " + UtilityDB.valueToString(serDoc) + " AND " +
|
||||
" num_doc = " + UtilityDB.valueToString(numDoc);
|
||||
info = conn.prepareStatement(sql);
|
||||
res = info.executeQuery();
|
||||
while (res.next()) {
|
||||
dataRegNew = res.getDate(1);
|
||||
}
|
||||
res.close();
|
||||
info.close();
|
||||
String sql = "SELECT data_reg " +
|
||||
" FROM dtb_doct" +
|
||||
" WHERE cod_anag = " + UtilityDB.valueToString(codAnag) + " AND " +
|
||||
" cod_dtip = " + UtilityDB.valueToString(codDtip) + " AND " +
|
||||
" data_doc = " + UtilityDB.valueDateToString(dataDoc, CommonConstants.DATE_FORMAT_YMD) + " AND " +
|
||||
" ser_doc = " + UtilityDB.valueToString(serDoc) + " AND " +
|
||||
" num_doc = " + UtilityDB.valueToString(numDoc);
|
||||
dataRegNew = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
} else {
|
||||
dataRegNew = dataReg;
|
||||
}
|
||||
@@ -309,7 +293,7 @@ public class DocumentCheckRules {
|
||||
}
|
||||
|
||||
HashMap<String, Object> DatiAzi = Azienda.getDatiAzienda(conn);
|
||||
Integer annoDoc = Integer.valueOf(annoFormat.format(dataRegNew)).intValue();
|
||||
Integer annoDoc = AccountingRules.getAnnoComp(conn, dataRegNew);
|
||||
Integer annoCont = new Integer(DatiAzi.get("anno_contab").toString());
|
||||
Integer annoAtt = new Integer(DatiAzi.get("anno_attuale").toString());
|
||||
if (!(annoDoc.equals(annoCont) || annoDoc.equals(annoAtt))) {
|
||||
|
||||
@@ -311,20 +311,9 @@ public class DocumentRules extends QueryRules {
|
||||
Integer annoContab = Integer.parseInt(datiAzienda.get("anno_contab").toString());
|
||||
Integer annoMagaz = Integer.parseInt(datiAzienda.get("anno_magaz").toString());
|
||||
|
||||
sql =
|
||||
Query.format(
|
||||
"SELECT anno\n" +
|
||||
"FROM gtb_periodo_fisc\n" +
|
||||
"WHERE %s BETWEEN data_iniz AND data_fine", dataReg);
|
||||
Short annoCompCosto = AccountingRules.getAnnoComp(conn, dataReg).shortValue();
|
||||
|
||||
Short annoCompCosto = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
|
||||
sql =
|
||||
Query.format(
|
||||
"SELECT anno\n" +
|
||||
"FROM gtb_periodo_fisc\n" +
|
||||
"WHERE %s BETWEEN data_iniz AND data_fine", dtbDocr.getDataReg());
|
||||
Short annoCompDoc = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
Short annoCompDoc = AccountingRules.getAnnoComp(conn, dtbDocr.getDataReg()).shortValue();
|
||||
|
||||
if (annoCompCosto < annoCompDoc && annoContab == annoCompDoc - 1 && annoMagaz == annoCompDoc - 1) {
|
||||
isDocAp = true;
|
||||
|
||||
@@ -852,11 +852,15 @@ public class CtbMovt extends EntityBase {
|
||||
ps.close();
|
||||
if (ctbScad == null || ctbScad.size() == 0) {
|
||||
query = "SELECT DISTINCT cs.tipo_anag,\n" + " cs.cod_anag,\n" + " cs.anno_part,\n" + " cs.ser_doc,\n" + " cs.num_doc,\n" + " cs.id_riga\n" + "FROM ctb_movt\n" + " INNER JOIN ctb_caus ON ctb_movt.cod_ccau = ctb_caus.cod_ccau\n" + " INNER JOIN ctb_scad cs ON DatePart(Year, ctb_movt.data_doc) = cs.anno_part AND\n" + " ctb_movt.tipo_anag = cs.tipo_anag AND\n" + " ctb_movt.cod_anag = cs.cod_anag AND\n" + " ctb_movt.ser_doc = cs.ser_doc AND\n" + " ctb_movt.num_doc = cs.num_doc\n" + "WHERE ctb_movt.num_cmov = " + getNumCmov() + "\n" + " AND ctb_caus.azione_su_partita = 0";
|
||||
ctbScad = new ResultSetMapper().mapQuerySetToList(connection, query, CtbScad.class, OperationType.DELETE);
|
||||
List<CtbScad> del = new ResultSetMapper().mapQuerySetToList(connection, query, CtbScad.class, OperationType.DELETE);
|
||||
if (del != null)
|
||||
for ( CtbScad s: del)
|
||||
s.manageWithParentConnection(connection, s.getOperation(), dataCompleting, entityHolder);
|
||||
}
|
||||
if (ctbPart == null) {
|
||||
query = "SELECT cs.tipo_anag,\n" + " cs.cod_anag,\n" + " cs.anno_part,\n" + " cs.ser_doc,\n" + " cs.num_doc\n" + "FROM ctb_movt\n" + " INNER JOIN ctb_caus ON ctb_movt.cod_ccau = ctb_caus.cod_ccau\n" + " INNER JOIN ctb_part cs ON DatePart(Year, ctb_movt.data_doc) = cs.anno_part AND\n" + " ctb_movt.tipo_anag = cs.tipo_anag AND\n" + " ctb_movt.cod_anag = cs.cod_anag AND\n" + " ctb_movt.ser_doc = cs.ser_doc AND\n" + " ctb_movt.num_doc = cs.num_doc\n" + "WHERE ctb_movt.num_cmov = " + getNumCmov() + "\n" + " AND ctb_caus.azione_su_partita = 0";
|
||||
ctbPart = new ResultSetMapper().mapQueryToObject(connection, query, CtbPart.class, OperationType.DELETE);
|
||||
if (ctbPart != null) ctbPart.manageWithParentConnection(connection, ctbPart.getOperation(), dataCompleting, entityHolder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ when
|
||||
eval(completeRulesEnabled)
|
||||
$entity : CtbMovt(annoComp == null)
|
||||
then
|
||||
Integer anno = AccountingRules.completeAnnoComp( conn, $entity.getDataCmov());
|
||||
Integer anno = AccountingRules.getAnnoComp( conn, $entity.getDataCmov());
|
||||
modify ( $entity ) { setAnnoComp(anno) }
|
||||
end
|
||||
|
||||
|
||||
@@ -75,17 +75,6 @@ public class AmmortamentiService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Integer getAnnoFisc(Date dataVal) throws Exception {
|
||||
query = "SELECT anno FROM gtb_periodo_fisc WHERE " + UtilityDB.valueDateToString(dataVal, CommonConstants.DATE_FORMAT_YMD) + " between data_iniz and data_fine";
|
||||
Integer annoFisc = (Integer) QueryRules.getSingleValue(multiDBTransactionManager.getPrimaryConnection(), query);
|
||||
if (annoFisc == null) {
|
||||
throw new Exception("Impossibile individuare l'anno fiscale dalla data " + UtilityDB.valueDateToString(dataVal, CommonConstants.DATE_FORMAT_DMY));
|
||||
}
|
||||
return annoFisc;
|
||||
}
|
||||
|
||||
private BigDecimal getResiduo(Integer anno, String codBene, String tipo) throws Exception {
|
||||
BigDecimal residuo = null;
|
||||
|
||||
|
||||
@@ -446,6 +446,12 @@ public class RossoGarganoSyncService {
|
||||
codDtip = "TD16";
|
||||
}
|
||||
|
||||
String sql = Query.format("SELECT segno_ireg FROM ctb_caus WHERE cod_ccau = %s ", ctbMovt.getCodCcau());
|
||||
BigDecimal segnoReg = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
if (UtilityBigDecimal.lowerThan(segnoReg, BigDecimal.ZERO) ) {
|
||||
codDtip = "N" + codDtip;
|
||||
}
|
||||
|
||||
AutofatturaDTO autofatturaDTO =
|
||||
new AutofatturaDTO().setCodDtip(codDtip)
|
||||
.setDescrizione(String.format("AUTOFATTURA EMESSA A FRONTE DELLA FATTURA N.%s DEL %s",
|
||||
|
||||
@@ -45,10 +45,8 @@ public class ScadenzeService {
|
||||
|
||||
if (ctbScads != null && ctbScads.size() > 0 ) {
|
||||
List<String> collect = ctbScads.stream().map(
|
||||
x -> {
|
||||
return String.format("Cod anag: %s - %s, anno_part: %s, numero: %s/%s ",
|
||||
x.getTipoAnag(), x.getCodAnag(), x.getAnnoPart(), x.getSerDoc(), x.getNumDoc());
|
||||
}
|
||||
x -> String.format("Cod anag: %s - %s, anno_part: %s, numero: %s/%s ",
|
||||
x.getTipoAnag(), x.getCodAnag(), x.getAnnoPart(), x.getSerDoc(), x.getNumDoc())
|
||||
).collect(Collectors.toList());
|
||||
|
||||
String elencoScadenze = String.join(CommonConstants.A_CAPO, collect);
|
||||
|
||||
@@ -52,7 +52,6 @@ public class ICONExportService {
|
||||
EntityExportResponse<List<FileItem>> response = new EntityExportResponse<>();
|
||||
JSONObjectMapper jsonObjectMapper = new JSONObjectMapper();
|
||||
MagAutoPickingRequestDTO ordT = jsonObjectMapper.readValue(body.toString(), MagAutoPickingRequestDTO.class);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
// Inizializzazione variabili
|
||||
Integer index = 0;
|
||||
@@ -66,7 +65,7 @@ public class ICONExportService {
|
||||
// Acquisizione dati configurazione
|
||||
String profileDBICON = setupGest.getSetup("ICON", "SETUP", "PROFILE_DB_INTERSCAMBIO");
|
||||
String gestisciQtaDaApprov = setupGest.getExportSetup(multiDBTransactionManager.getPrimaryConnection(), type, format, "GESTISCI_QTA_DA_APPROV");
|
||||
String tmparmte = "P|" + ordT.getInputCollo().getGestione() + "|" + sdf.format(ordT.getInputCollo().getDataCollo()) + "|" + ordT.getInputCollo().getSerCollo() + "|" + ordT.getInputCollo().getNumCollo().toString();
|
||||
String tmparmte = "P|" + ordT.getInputCollo().getGestione() + "|" + CommonConstants.DATE_YMD_DASHED_FORMATTER.format(ordT.getInputCollo().getDataCollo()) + "|" + ordT.getInputCollo().getSerCollo() + "|" + ordT.getInputCollo().getNumCollo().toString();
|
||||
|
||||
// Acquisizione dati ordine da passare alla missione
|
||||
String query =
|
||||
@@ -258,7 +257,7 @@ public class ICONExportService {
|
||||
+ " il " + CommonConstants.DATETIME_DMY_SLASHED_FORMATTER.format(UtilityLocalDate.getNowTime());
|
||||
|
||||
String tmparmte = "ACC" + "|" + colT.getGestione() +
|
||||
"|" + new SimpleDateFormat("yyyy-MM-dd").format(colT.getDataCollo()) +
|
||||
"|" + CommonConstants.DATE_YMD_DASHED_FORMATTER.format(colT.getDataCollo()) +
|
||||
"|" + colT.getSerCollo() +
|
||||
"|" + colT.getNumCollo().toString();
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.system.dto.SqlObjectDTO;
|
||||
import it.integry.ems.system.service.SystemMigrationService;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.entity.StbGestSetup;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -38,4 +40,19 @@ public class SystemMigrationController {
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "createFromGestSetup", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse createFromGestSetup(@RequestBody List<StbGestSetup> entityBaseList) throws Exception {
|
||||
|
||||
if (!UtilityDebug.isDebugExecution())
|
||||
throw new Exception("Puoi eseguire questa procedura solo in ambiente DEBUG!");
|
||||
|
||||
if (UtilityDebug.isIntegryServerDev())
|
||||
throw new Exception("Non puoi eseguire questa azione su SERVERDEV!");
|
||||
|
||||
systemMigrationService.createFromGestSetup(entityBaseList);
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,9 +5,17 @@ import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration.dto.SqlObjectTypeEnum;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.system.dto.SqlObjectDTO;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.entity.StbGestSetup;
|
||||
import it.integry.ems_model.entity.StbGestSetupQuery;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -17,8 +25,15 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Service
|
||||
@Scope(value = "request")
|
||||
@@ -73,6 +88,142 @@ public class SystemMigrationService {
|
||||
return readObjects;
|
||||
}
|
||||
|
||||
public void createFromGestSetup(List<StbGestSetup> entityBaseList) throws IOException {
|
||||
String migrationClassName = "Migration_" + CommonConstants.TIMESTAMP_FORMATTER.format(UtilityLocalDate.getNowTime());
|
||||
|
||||
StringBuilder classBuilder = new StringBuilder("package it.integry.ems.migration.model;\n" +
|
||||
"\n" +
|
||||
"import it.integry.ems.migration._base.BaseMigration;\n" +
|
||||
"import it.integry.ems.migration._base.MigrationModelInterface;\n" +
|
||||
"\n" +
|
||||
"public class " + migrationClassName + " extends BaseMigration implements MigrationModelInterface {\n" +
|
||||
"\n" +
|
||||
" @Override\n" +
|
||||
" public void up() throws Exception {\n" +
|
||||
" if (isHistoryDB())\n" +
|
||||
" return;\n" +
|
||||
"\n" +
|
||||
"\n");
|
||||
|
||||
|
||||
for (StbGestSetup setup:entityBaseList){
|
||||
|
||||
String operation;
|
||||
if (setup.getOperation() == OperationType.DELETE) {
|
||||
operation = formatSetup("deleteSetup(%s, %s, %s);", setup.getGestName(), setup.getSection(), setup.getKeySection());
|
||||
|
||||
classBuilder.append("\t\t" + operation)
|
||||
.append("\r\n");
|
||||
} else {
|
||||
if (!UtilityString.isNullOrEmpty(setup.getQueryDefault())){
|
||||
operation =
|
||||
formatSetup(
|
||||
"createSetupQuery(%s, %s, %s, %s);",
|
||||
setup.getCodQuery(),setup.getCodQuery(),setup.getQueryDefault(), false);
|
||||
classBuilder.append("\t\t" + operation)
|
||||
.append("\r\n");
|
||||
}
|
||||
|
||||
operation =
|
||||
formatSetup(
|
||||
"createSetup(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);",
|
||||
setup.getGestName(),
|
||||
setup.getSection(),
|
||||
setup.getKeySection(),
|
||||
setup.getValue(),
|
||||
setup.getDescription(),
|
||||
setup.getFlagSync().equalsIgnoreCase("S"),
|
||||
setup.getCodQuery(),
|
||||
setup.getFlagUserView().equalsIgnoreCase("S"),
|
||||
setup.getFlagSetupDepo().equalsIgnoreCase("S"),
|
||||
setup.getFlagSetupUserWeb().equalsIgnoreCase("S"),
|
||||
setup.getFlagTipoJson().equalsIgnoreCase("S"),
|
||||
UtilityString.equalsIgnoreCase(setup.getFlagTipoColore(),"S"),
|
||||
setup.getTipoSetup(),
|
||||
setup.getFlagMultiValue()==null?false:setup.getFlagMultiValue(),
|
||||
setup.getQueryDefault() );
|
||||
|
||||
classBuilder.append("\t\t" + operation)
|
||||
.append("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
classBuilder.append(
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" @Override\n" +
|
||||
" public void down() throws Exception {\n" +
|
||||
"\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
"}\n");
|
||||
|
||||
|
||||
String executionPath = new File(BaseMigration.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getAbsolutePath();
|
||||
final String baseProjectPath = executionPath.substring(0, executionPath.indexOf("ems-engine\\target")) + "ems-core\\src\\main\\";
|
||||
final String migrationsJavaPath = baseProjectPath + "java\\it\\integry\\ems\\migration\\model\\";
|
||||
final String migrationsJavaFile = migrationsJavaPath + migrationClassName + ".java";
|
||||
writeContentToFile(migrationsJavaFile, classBuilder.toString(), true);
|
||||
}
|
||||
|
||||
private static String formatSetup(String string, Object... params) {
|
||||
String[] formattedParams = new String[params.length];
|
||||
for(int i = 0; i < params.length; i++) {
|
||||
if (params[i] == null || params[i].equals(EmsRestConstants.NULL)) {
|
||||
formattedParams[i] = "null";
|
||||
} else {
|
||||
String className = params[i].getClass().getName();
|
||||
int pos = className.lastIndexOf(".");
|
||||
if (pos > 0) {
|
||||
String type = className.substring(pos + 1).toUpperCase();
|
||||
formattedParams[i] = params[i].toString();
|
||||
|
||||
if (formattedParams[i].length() == 0) {
|
||||
formattedParams[i] = "null";
|
||||
} else {
|
||||
switch (type) {
|
||||
case "STRING":
|
||||
formattedParams[i] = "\"" + formattedParams[i].replaceAll("\"", "''").replaceAll("’", "''") + "\"";
|
||||
break;
|
||||
case "DATE": {
|
||||
SimpleDateFormat dateFormatFile = new SimpleDateFormat("yyyy-MM-dd");
|
||||
formattedParams[i] = "\"" + dateFormatFile.format(params[i]) + "\"";
|
||||
break;
|
||||
}
|
||||
case "LOCALDATE": {
|
||||
formattedParams[i] = "\"" + CommonConstants.DATE_YMD_DASHED_FORMATTER.format((LocalDate) params[i]) + "\"";
|
||||
break;
|
||||
}
|
||||
case "LOCALDATETIME": {
|
||||
formattedParams[i] = "\"" + CommonConstants.DATETIME_YMD_DASHED_FORMATTER.format((LocalDateTime) params[i]) + "\"";
|
||||
break;
|
||||
}
|
||||
case "TIMESTAMP":
|
||||
case "INSTANT": {
|
||||
if (type.equalsIgnoreCase("INSTANT")) {
|
||||
params[i] = Date.from((Instant) params[i]);
|
||||
}
|
||||
|
||||
SimpleDateFormat dateFormatFile = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
formattedParams[i] = "\"" + dateFormatFile.format(params[i]) + "\"";
|
||||
break;
|
||||
}
|
||||
case "BOOLEAN":
|
||||
formattedParams[i] = ((Boolean) params[i]) ? "true" : "false";
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
formattedParams[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return String.format(string, formattedParams);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void createMigrationFileFromSqlObjects(List<SqlObjectDTO> sqlObjects) throws IOException {
|
||||
|
||||
@@ -107,7 +258,7 @@ public class SystemMigrationService {
|
||||
.append(typeName)
|
||||
.append("(\"").append(sqlObject.getName()).append("\"").append(", ")
|
||||
.append("\"").append(definition).append("\");")
|
||||
.append("\r\n\r\n");
|
||||
.append("\r\n");
|
||||
}
|
||||
|
||||
classBuilder.append(
|
||||
|
||||
Reference in New Issue
Block a user