Compare commits
46 Commits
ababbf6142
...
feature/Fe
| Author | SHA1 | Date | |
|---|---|---|---|
| 2bbc01c4ef | |||
| d981e59a7d | |||
| 5103830369 | |||
| 5056d7e0c8 | |||
| 4b5e46de7b | |||
| 4d686ee145 | |||
| e842326f5b | |||
| 63ad11086f | |||
| 21f6fc6717 | |||
| 8c2789b5f3 | |||
| 8f3ef405cf | |||
| 76e76dfcf4 | |||
| 1df5ad7137 | |||
| a43ca46395 | |||
| a63eba544b | |||
| ce912bf103 | |||
| 51c1ed1d23 | |||
| c1c39b76e6 | |||
| 3a5bccab1b | |||
| c376b967ed | |||
| fc5b6ae3d6 | |||
| b3ac0f8755 | |||
| 920257812c | |||
| 77c79c6247 | |||
| c26f7feb35 | |||
| 21cc88f295 | |||
| dac2e6cc71 | |||
| d46667d442 | |||
| ab8733b2ff | |||
| 62e3a824c9 | |||
| 9f28aebf78 | |||
| 398513b0cc | |||
| c3ad19b51f | |||
| b8453cd688 | |||
| 84dc40249f | |||
| b544a9e0d4 | |||
| 77aee05f12 | |||
| 41dbd2ac51 | |||
| 0060ac32e7 | |||
| 413da7ec86 | |||
| e79e9e107f | |||
| 9d7a0f8e22 | |||
| 9f8d1af53e | |||
| a4ae2e70bd | |||
| 76ff6f4371 | |||
| 2bf1779c23 |
@@ -1,18 +0,0 @@
|
||||
FROM tomcat:9-jre8-alpine
|
||||
|
||||
RUN apk add --no-cache fontconfig ttf-dejavu
|
||||
|
||||
ENV TZ="Europe/Rome"
|
||||
ENV JAVA_OPTS="-DDISABLE_DROOLS_COMPILE=TRUE -Xms512M -Xmx1G -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
|
||||
ENV USERDOMAIN="STUDIO-ML"
|
||||
|
||||
COPY docker/tomcat/conf/integry/ems.properties /usr/local/tomcat/conf/integry/
|
||||
COPY docker/tomcat/conf/integry/ems_automated_operations.json /usr/local/tomcat/conf/integry/
|
||||
COPY docker/tomcat/conf/integry/ems_settings.json /usr/local/tomcat/conf/integry/
|
||||
COPY ems-engine/target/ems-api.war /usr/local/tomcat/webapps/
|
||||
|
||||
#COPY docker/FontTest.class .
|
||||
#ENTRYPOINT ["java","FontTest"]
|
||||
|
||||
EXPOSE 8080
|
||||
EXPOSE 5005
|
||||
@@ -42,7 +42,7 @@ pipeline {
|
||||
bat(script: 'mvn clean install -t toolchains-jenkins.xml', returnStdout: true)
|
||||
archiveArtifacts(artifacts: 'ems-engine/target/ems-api.war', onlyIfSuccessful: true)
|
||||
}
|
||||
stash includes: 'ems-engine/target/ems-api.war,docker/**,Containerfile', name: 'container-files'
|
||||
stash includes: 'ems-engine/target/ems-api.war,docker/**,Dockerfile', name: 'container-files'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ sleep 10''', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaul
|
||||
}
|
||||
|
||||
// bat "docker buildx build --platform linux/amd64,linux/arm64 --push -t \"git.studioml.it/integry/ems-api${branchVersion}:latest\" ."
|
||||
bat "podman build -f .\\Containerfile -t \"git.studioml.it/integry/ems-api${branchVersion}:latest\" ."
|
||||
bat "podman build -t \"git.studioml.it/integry/ems-api${branchVersion}:latest\" ."
|
||||
bat "podman push \"git.studioml.it/integry/ems-api${branchVersion}:latest\""
|
||||
|
||||
//containerImageLink "git.studioml.it/integry/ems-api-${env.GIT_BRANCH.toLowerCase().replace('/', '-')}:latest}"
|
||||
|
||||
@@ -524,6 +524,16 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
||||
stbGestSetup.manageWithParentConnection(connection);
|
||||
}
|
||||
|
||||
protected void dropSetup(String gestName, String section, String keySection) throws Exception {
|
||||
StbGestSetup stbGestSetup = new StbGestSetup()
|
||||
.setGestName(gestName)
|
||||
.setSection(section)
|
||||
.setKeySection(keySection);
|
||||
|
||||
stbGestSetup.setOperation(OperationType.DELETE);
|
||||
stbGestSetup.manageWithParentConnection(connection);
|
||||
}
|
||||
|
||||
protected void addAutomatedOperation(BaseScheduledOperationDTO operation) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
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_20251027170624 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
if (!isCustomer(IntegryCustomer.Integry)) return;
|
||||
|
||||
executeStatement("UPDATE jtb_rlavr set da_ora = stb_activity.effective_time,\n" +
|
||||
" a_ora = stb_activity.effective_endtime\n" +
|
||||
" from jtb_rlavr inner join stb_activity on jtb_rlavr.activity_id = stb_activity.activity_id\n" +
|
||||
" inner join jvw_flav_nominativo on jtb_rlavr.cod_jflav = jvw_flav_nominativo.cod_jflav\n" +
|
||||
" where data_lav >= '2025/01/01'\n" +
|
||||
" and ore > 0\n" +
|
||||
" and da_ora is null",
|
||||
"update jtb_rlavr\n" +
|
||||
" set a_ora = DateAdd(MINUTE, (ore * 0.6) * 100, da_ora)\n" +
|
||||
" from jtb_rlavr\n" +
|
||||
" where data_lav >= '2025/01/01'\n" +
|
||||
" and ore > 0\n" +
|
||||
" and da_ora = a_ora",
|
||||
" update stb_activity\n" +
|
||||
" set effective_endtime = DateAdd(MINUTE, (ore * 0.6) * 100, effective_time)\n" +
|
||||
" from jtb_rlavr inner join stb_activity on stb_activity.activity_id = jtb_rlavr.activity_id\n" +
|
||||
" where data_lav >= '2025/01/01'\n" +
|
||||
" and ore > 0\n" +
|
||||
" and effective_endtime = effective_time");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251124143153 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetupQuery("TIPO_GRIGLIA", "tipo griglia", "SELECT 'A|GRIGLIA DI ACQUISTO'\n" +
|
||||
"UNION ALL\n" +
|
||||
"SELECT 'V|GRIGLIA DI VENDITA'");
|
||||
createSetup
|
||||
("PVM", "RILEVAZIONI_STEUP", "TIPO_GRIGLIA", null,
|
||||
"Indicare per ogni reparto se la griglia per l'assortimento è quella di acquisto o di vendita",
|
||||
false, "TIPO_GRIGLIA", true, false, false, false, false, "jtb_fasi", false,
|
||||
"SELECT 'A|GRIGLIA DI ACQUISTO'\n" +
|
||||
"UNION ALL\n" +
|
||||
"SELECT 'V|GRIGLIA DI VENDITA'");
|
||||
|
||||
if (!isCustomerDb(IntegryCustomerDB.Carelli_Winact)) return;
|
||||
|
||||
executeStatement("insert into stb_gest_setup_det \n" +
|
||||
"select gest_name, section, key_section, tipo_setup, f.cod_jfas, f.valUe\n" +
|
||||
"from stb_gest_setup\n" +
|
||||
"cross apply (\n" +
|
||||
"select distinct jtb_fasi.cod_jfas,\n" +
|
||||
"IIF (jtb_fasi.cod_jfas = '01' OR jtb_fasi.cod_jfas = '02', 'V', 'A') as valUe\n" +
|
||||
"from jtb_fasi inner join jrl_fasi_mtb_grup on jtb_fasi.cod_jfas = jrl_fasi_mtb_grup.cod_jfas ) f\n" +
|
||||
"where gest_name = 'PVM' \n" +
|
||||
"and section = 'RILEVAZIONI_STEUP'\n" +
|
||||
"and key_section = 'TIPO_GRIGLIA'\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251124161416 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isCustomerDb(IntegryCustomerDB.Carelli_Winact)) return;
|
||||
|
||||
createOrUpdateFunction("[steup_getGrigliaVendita]", "CREATE FUNCTION [dbo].[steup_getGrigliaVendita](\n" +
|
||||
" @codMdep VARCHAR(5), @codJfas VARCHAR(5), @dataIspezione datetime\n" +
|
||||
")\n" +
|
||||
" RETURNS TABLE\n" +
|
||||
" AS\n" +
|
||||
" RETURN(WITH tipiArt AS (SELECT value_string AS cod_mtip\n" +
|
||||
" FROM dbo.ParseStringIntoArray((SELECT value\n" +
|
||||
" FROM stb_gest_setup\n" +
|
||||
" WHERE gest_name = 'PVM'\n" +
|
||||
" AND section = 'RILEVAZIONI_STEUP'\n" +
|
||||
" AND key_section = 'EXCLUDE_COD_MTIP'), '|') t)\n" +
|
||||
" , art AS (SELECT DISTINCT cod_griglia, cod_mart\n" +
|
||||
" FROM carelli.dbo.vtb_griglia_art\n" +
|
||||
" WHERE cod_griglia = @codMdep\n" +
|
||||
" AND data_validita =\n" +
|
||||
" (SELECT MAX(data_validita) FROM carelli.dbo.vtb_griglia_art WHERE cod_griglia = @codMdep AND data_validita <=@dataIspezione)\n" +
|
||||
" )\n" +
|
||||
" \n" +
|
||||
" SELECT DISTINCT case when @codJfas = '01' then art_det.cod_mart_griglia else mtb_aart.cod_mart end as cod_mart,\n" +
|
||||
" mtb_aart.descrizione,\n" +
|
||||
" mtb_aart.bar_code,\n" +
|
||||
" mtb_aart.cod_msgr,\n" +
|
||||
" mtb_aart.plu,\n" +
|
||||
" art_det.cod_mart AS cod_mart_kit \n" +
|
||||
" FROM carelli.dbo.mtb_aart\n" +
|
||||
" INNER JOIN jrl_fasi_mtb_grup ON\n" +
|
||||
" mtb_aart.cod_mgrp = jrl_fasi_mtb_grup.cod_mgrp\n" +
|
||||
" INNER JOIN (SELECT cod_mart, cod_comp AS cod_mart_griglia\n" +
|
||||
" FROM carelli.dbo.mtb_comp\n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT cod_comp AS cod_mart, cod_mart AS cod_mart_griglia\n" +
|
||||
" FROM carelli.dbo.mtb_comp \n" +
|
||||
" where @codJfas <> '01'\n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT cod_mart, cod_mart AS cod_mart_griglia\n" +
|
||||
" FROM carelli.dbo.mtb_aart\n" +
|
||||
" WHERE cod_mart NOT IN (SELECT cod_mart FROM carelli.dbo.mtb_comp)) AS art_det\n" +
|
||||
" ON mtb_aart.cod_mart = art_det.cod_mart\n" +
|
||||
" INNER JOIN art ON art_det.cod_mart_griglia = art.cod_mart\n" +
|
||||
" WHERE jrl_fasi_mtb_grup.cod_jfas = @codJfas\n" +
|
||||
" AND flag_stato = 'A'\n" +
|
||||
" AND (mtb_aart.cod_mtip IS NULL OR mtb_aart.cod_mtip NOT IN (SELECT cod_mtip FROM tipiArt)) \n" +
|
||||
" )");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,7 +13,7 @@ public class Migration_20251210095206 extends BaseMigration implements Migration
|
||||
|
||||
executeStatement("ALTER TABLE mtb_aart_anag ADD cod_vdes varchar(5);");
|
||||
|
||||
if(isCustomerDb(IntegryCustomerDB.Carelli_Format) && isCustomerDb(IntegryCustomerDB.Carelli_GestFood)){
|
||||
if(isCustomerDb(IntegryCustomerDB.Carelli_Format) || isCustomerDb(IntegryCustomerDB.Carelli_GestFood)){
|
||||
executeStatement("delete from mtb_aart_anag\n" +
|
||||
"from (\n" +
|
||||
"select cod_mart, cod_mart_anag, cod_anag, ROW_NUMBER() over (partition by cod_mart, cod_anag order by cod_mart, cod_mart_anag, cod_anag ) as id\n" +
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
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.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251212130317 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomer(IntegryCustomer.Auricchio) || isCustomer(IntegryCustomer.Levanplast) || isCustomer(IntegryCustomer.Agricoper) || isCustomerDb(IntegryCustomerDB.Auricchio_Ind05)){
|
||||
executeStatement("delete from mtb_aart_anag\n" +
|
||||
"from \n" +
|
||||
"(select mtb_aart_anag.cod_anag,\n" +
|
||||
"\t\tmtb_aart_anag.cod_mart, \n" +
|
||||
"\t\tmax(id) as id\n" +
|
||||
"from (select cod_anag, cod_mart, row_number() over (partition by cod_anag, cod_mart order by cod_anag, cod_mart) as riga \n" +
|
||||
"\t\tfrom dbo.mtb_aart_anag\t\t\n" +
|
||||
"\t\t)error inner join mtb_aart_anag on mtb_aart_anag.cod_anag = error.cod_anag and\n" +
|
||||
"\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tmtb_aart_anag.cod_mart = error.cod_mart\n" +
|
||||
"where riga > 1\n" +
|
||||
"group by mtb_aart_anag.cod_anag,\n" +
|
||||
"\t\tmtb_aart_anag.cod_mart)rowDelete inner join mtb_aart_anag on rowDelete.id = mtb_aart_anag.id");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
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_20251212151308 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if ( !isCustomer(IntegryCustomer.Carelli) ) return;
|
||||
|
||||
createOrUpdateFunction("steup_getRilevazioni", "CREATE FUNCTION [dbo].[steup_getRilevazioni]\n" +
|
||||
"(\n" +
|
||||
" @dataIspezione DATETIME,\n" +
|
||||
" @codMdep VARCHAR(5),\n" +
|
||||
" @userRilevatore VARCHAR(20)\n" +
|
||||
")\n" +
|
||||
"RETURNS TABLE AS return \n" +
|
||||
"SELECT activity_id,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" user_creator,\n" +
|
||||
" ISNULL(effective_time, ora_ins_act) AS effective_time,\n" +
|
||||
" effective_endtime,\n" +
|
||||
" activity_result_id,\n" +
|
||||
" mtb_depo.cod_mdep,\n" +
|
||||
" mtb_depo.descrizione AS descr_deposito,\n" +
|
||||
" ISNULL(effective_date, data_ins_act) AS data_isp\n" +
|
||||
"FROM winact.dbo.stb_activity INNER JOIN winact.dbo.wtb_depo ON stb_activity.user_name = wtb_depo.user_name\n" +
|
||||
" INNER JOIN winact.dbo.mtb_depo ON wtb_depo.cod_mdep = mtb_depo.cod_mdep\n" +
|
||||
"WHERE flag_tipologia = 'P' AND\n" +
|
||||
" activity_type_id = 'ISPEZIONE' AND \n" +
|
||||
" (@dataIspezione is null or stb_activity.effective_date = @dataIspezione ) AND \n" +
|
||||
" (@codMdep is null or mtb_depo.cod_mdep = @codMdep ) AND \n" +
|
||||
" (@userRilevatore is null or stb_activity.user_creator = @userRilevatore );");
|
||||
createOrUpdateFunction("steup_getEntriesRilevazione", "CREATE FUNCTION [dbo].[steup_getEntriesRilevazione](@idIspezione varchar(20))\n" +
|
||||
" RETURNS TABLE AS return\n" +
|
||||
"WITH steup_ispezioni AS (SELECT * FROM steup_getRilevazioni(null, null, null)),\n" +
|
||||
"\n" +
|
||||
" steup_activities AS (SELECT stb_activity.activity_id,\n" +
|
||||
" stb_activity.activity_type_id,\n" +
|
||||
" stb_activity.data_ins_act,\n" +
|
||||
" ISNULL(stb_activity.effective_time, stb_activity.ora_ins_act) AS effective_time,\n" +
|
||||
" stb_activity.cod_mart,\n" +
|
||||
" mtb_aart.descrizione AS descr_art,\n" +
|
||||
" stb_activity.activity_play_counter,\n" +
|
||||
" stb_activity.note,\n" +
|
||||
" stb_activity.cod_jfas,\n" +
|
||||
" stb_activity.flag_tipologia,\n" +
|
||||
" stb_activity.persona_rif,\n" +
|
||||
" stb_activity.priorita,\n" +
|
||||
" wtb_depo.cod_mdep,\n" +
|
||||
" jtb_fasi.descrizione AS descr_fase,\n" +
|
||||
" stb_activity.parent_activity_id as id_ispezione,\n" +
|
||||
" stb_activity.indice_gradimento,\n" +
|
||||
" stb_activity.user_creator,\n" +
|
||||
" jtb_fasi.max_allocazione,\n" +
|
||||
" SUM(indice_gradimento)\n" +
|
||||
" OVER ( PARTITION BY parent_activity_id,wtb_depo.cod_mdep,jtb_fasi.cod_jfas ) AS gradimento_reparto,\n" +
|
||||
" steup_ispezioni.data_isp\n" +
|
||||
" FROM winact.dbo.stb_activity\n" +
|
||||
" INNER JOIN steup_ispezioni ON parent_activity_id = steup_ispezioni.activity_id\n" +
|
||||
" LEFT OUTER JOIN winact.dbo.jtb_fasi ON stb_activity.cod_jfas = jtb_fasi.cod_jfas\n" +
|
||||
" LEFT OUTER JOIN winact.dbo.mtb_aart ON stb_activity.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" LEFT OUTER JOIN winact.dbo.wtb_depo ON stb_activity.user_name = wtb_depo.user_name\n" +
|
||||
" WHERE ISNULL(cod_jcom, '') <> 'MODEL'\n" +
|
||||
" and stb_activity.cod_mart is null\n" +
|
||||
" AND stb_activity.flag_tipologia = 'A')\n" +
|
||||
" ,\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
" gradimento_reparto AS (SELECT DISTINCT id_ispezione,\n" +
|
||||
" cod_jfas,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" data_isp,\n" +
|
||||
" gradimento_reparto,\n" +
|
||||
" LAG(gradimento_reparto, 1, 0)\n" +
|
||||
" OVER (PARTITION BY cod_mdep,cod_jfas ORDER BY data_isp ) AS grad_1,\n" +
|
||||
" LAG(gradimento_reparto, 2, 0)\n" +
|
||||
" OVER (PARTITION BY cod_mdep,cod_jfas ORDER BY data_isp ) AS grad_2\n" +
|
||||
"\n" +
|
||||
" FROM (SELECT DISTINCT id_ispezione, cod_mdep, cod_jfas, gradimento_reparto, data_isp\n" +
|
||||
" FROM steup_activities) acti)\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"SELECT steup_activities.*,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN gradimento_reparto.grad_1 > max_allocazione AND gradimento_reparto.grad_2 > max_allocazione THEN 1\n" +
|
||||
" ELSE 0 END AS recidiva,\n" +
|
||||
" ((SELECT COUNT(*)\n" +
|
||||
" FROM stb_activity art\n" +
|
||||
" WHERE steup_activities.activity_id = art.parent_activity_id) + (SELECT COUNT(*)\n" +
|
||||
" FROM mtb_colt\n" +
|
||||
" INNER JOIN mtb_colr\n" +
|
||||
" ON mtb_colt.gestione =\n" +
|
||||
" mtb_colr.gestione AND\n" +
|
||||
" mtb_colt.data_collo =\n" +
|
||||
" mtb_colr.data_collo AND\n" +
|
||||
" mtb_colt.ser_collo =\n" +
|
||||
" mtb_colr.ser_collo AND\n" +
|
||||
" mtb_colt.num_collo =\n" +
|
||||
" mtb_colr.num_collo\n" +
|
||||
" WHERE mtb_colt.activity_id = steup_activities.activity_id)) AS count_art\n" +
|
||||
"FROM steup_activities\n" +
|
||||
" left outer JOIN gradimento_reparto ON steup_activities.id_ispezione = gradimento_reparto.id_ispezione\n" +
|
||||
" AND steup_activities.cod_mdep = gradimento_reparto.cod_mdep\n" +
|
||||
" AND steup_activities.cod_jfas = gradimento_reparto.cod_jfas\n" +
|
||||
"WHERE (@idIspezione is null or steup_activities.id_ispezione = @idIspezione)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251212182900 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.FolliesGroup_FolliesGroup)) {
|
||||
executeStatement("delete from mtb_aart_anag\n" +
|
||||
"from (select mtb_aart_anag.cod_anag, mtb_aart_anag.cod_mart, mtb_aart_anag.cod_col, mtb_aart_anag.cod_tagl, max(id) as id \n" +
|
||||
"\t\tfrom (select cod_anag, cod_mart, cod_col, cod_tagl, row_number() over (partition by cod_anag, cod_mart, cod_col, cod_tagl order by cod_anag, cod_mart, cod_col, cod_tagl, id desc) as riga \n" +
|
||||
"\t\tfrom dbo.mtb_aart_anag \n" +
|
||||
"\t\t)error inner join mtb_aart_anag on mtb_aart_anag.cod_anag = error.cod_anag and \n" +
|
||||
"\t\t\t\t\t\t\t\t\t\t\tmtb_aart_anag.cod_mart = error.cod_mart \n" +
|
||||
"where riga > 1 \n" +
|
||||
"group by mtb_aart_anag.cod_anag, mtb_aart_anag.cod_col, mtb_aart_anag.cod_tagl, mtb_aart_anag.cod_mart)rowDelete inner join mtb_aart_anag on rowDelete.id = mtb_aart_anag.id");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -76,12 +76,11 @@ public class PurchasesRules extends QueryRules {
|
||||
if ( !UtilityString.isNullOrEmpty(tipoVariazione) ) return tipoVariazione;
|
||||
|
||||
sql =
|
||||
Query.format("SELECT tipo_variazione"
|
||||
+ " FROM dbo.getGrigliaAcquisto(%s, %s,%s, %s, %s)",
|
||||
Query.format("SELECT TOP 1 tipo_variazione"
|
||||
+ " FROM dbo.getGrigliaAcquisto(%s, NULL,%s, NULL, %s) g\n" +
|
||||
"ORDER BY data_validita DESC, tipo_variazione DESC",
|
||||
atbGriglieArt.getDataValidita(),
|
||||
atbGriglieArt.getCodAlis(),
|
||||
atbGriglieArt.getCodMdep(),
|
||||
atbGriglieArt.getCodArtFor(),
|
||||
atbGriglieArt.getCodMart());
|
||||
|
||||
tipoVariazione = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
|
||||
@@ -116,6 +116,7 @@ public class EmsRestConstants {
|
||||
public static final String PATH_USERS = PATH + "getUser";
|
||||
public static final String PATH_EXPORT_ORDINI_ACQ = PATH + "exportOrdiniAcquisto";
|
||||
public static final String PATH_PROCESS_REPORT = PATH + "processReport";
|
||||
public static final String PATH_DOWNLOAD_REPORT_LIST = PATH + "downloadReportList";
|
||||
public static final String PATH_DOWNLOAD_REPORT = PATH + "downloadReport";
|
||||
public static final String PATH_PROCESS_REPORT_TYPE = PATH + "processReportType";
|
||||
public static final String PATH_PRINT_REPORT_TYPE = PATH + "printReportType";
|
||||
@@ -275,9 +276,7 @@ public class EmsRestConstants {
|
||||
public static final String PATH_ACTIVITY_CHANGE_COD_JCOM = PATH + "activity/changeCodJcom";
|
||||
public static final String PATH_ACTIVITY_UPDATE_WRIKE_ID = PATH + "activity/updateWrikeId";
|
||||
public static final String PATH_ACTIVITY_REMOVE_ALL_WRIKE_ID = PATH + "activity/removeAllWrikeId";
|
||||
public static final String PATH_ACTIVITY_GET_ACTIVITY = PATH + "activity/getActivity";
|
||||
public static final String PATH_ACTIVITY_GET_RESULT = PATH + "activity/getActivityResult";
|
||||
public static final String PATH_ACTIVITY_GET_TASKS = PATH + "activity/getActivityTasks";
|
||||
public static final String PATH_ACTIVITY_GET_TYPE = PATH + "activity/getActivityType";
|
||||
public static final String PATH_ACTIVITY_GET_TYPE_TASK = PATH + "activity/getActivityTypeTask";
|
||||
public static final String PATH_ACTIVITY_GET_FILE = PATH + "activity/getActivityFile";
|
||||
@@ -288,8 +287,6 @@ public class EmsRestConstants {
|
||||
public static final String PATH_ACTIVITY_GET_ALL_ACTIVITIES_BY_ACTIVE_CUSTOMERS = PATH + "activity/getAllActivitiesByActiveCustomers";
|
||||
public static final String PATH_ACTIVITY_GET_PERSONE_RIF = PATH + "activity/getPersoneRif";
|
||||
public static final String PATH_ACTIVITY_GET_TREE_VIEW = PATH + "activity/getTreeView";
|
||||
public static final String PATH_GET_ACTIVITY_CALENDAR = PATH + "activity/getActivityCalendar";
|
||||
public static final String PATH_DELETE_ACTIVITY = PATH + "activity/delete";
|
||||
public static final String PATH_GET_COMMESSA_FROM_USERNAME = PATH + "activity/getCommessaFromUsername";
|
||||
public static final String PATH_GET_ACTIVITY_HISTORY = PATH + "activity/getActivityHistory";
|
||||
public static final String PATH_SET_ACTIVITY_SOLVED = PATH + "activity/activitySolved";
|
||||
|
||||
@@ -14,6 +14,7 @@ import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.service.PrinterService;
|
||||
import it.integry.ems.service.ReportProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityPdf;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.entity.GrlAnagJrept;
|
||||
import it.integry.ems_model.entity.JtbDisegniFiles;
|
||||
@@ -88,6 +89,7 @@ public class EmsEngineController {
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_REPORT, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse downloadReport(HttpServletRequest request,
|
||||
@@ -100,6 +102,27 @@ public class EmsEngineController {
|
||||
return ServiceRestResponse.createNegativeResponse("Nessun report generato!");
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_REPORT_LIST, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse downloadReportList(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody JasperDTO[] jasperDTOList)throws Exception {
|
||||
|
||||
FileItem fi = new FileItem();
|
||||
List<byte[]> pdfList = new ArrayList<>();
|
||||
for (JasperDTO jasperDTO : jasperDTOList) {
|
||||
pdfList.add(emsEngineService.processReport(jasperDTO));
|
||||
}
|
||||
byte[] bytes = UtilityPdf.merge(pdfList);
|
||||
|
||||
if (bytes != null && bytes.length > 0) {
|
||||
return ServiceRestResponse.createPositiveResponse(downloadFileHandlerService.generateDownloadItem(new Date().getTime() + ".pdf", bytes));
|
||||
} else {
|
||||
return ServiceRestResponse.createNegativeResponse("Nessun report generato!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_PROCESS_REPORT_TYPE, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse processReportTypeList(HttpServletRequest request,
|
||||
@@ -122,14 +145,9 @@ public class EmsEngineController {
|
||||
public @ResponseBody
|
||||
ServiceRestResponse printReportTypeList(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody ReportTypeDTO reportTypeDTO) {
|
||||
try {
|
||||
printerService.printReportType(reportTypeDTO);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
return ServiceRestResponse.createNegativeResponse(configuration, e);
|
||||
}
|
||||
@RequestBody ReportTypeDTO reportTypeDTO) throws Exception {
|
||||
printerService.printReportType(reportTypeDTO);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_GET_SETUP_REPORT_TYPE, method = RequestMethod.POST)
|
||||
|
||||
@@ -150,18 +150,6 @@ public class ActivityController {
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_ACTIVITY_GET_ACTIVITY, method = RequestMethod.GET)
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
public ServiceRestResponse getActivity(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam(required = false) String activityId,
|
||||
@RequestParam(value = "daInstallare") boolean daInstallare,
|
||||
@RequestParam(value = "isTable") boolean isTable,
|
||||
@RequestParam(required = false) Integer year) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(activityService.getActivity(isTable, daInstallare, activityId, year));
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_ACTIVITY_GET_RESULT, method = RequestMethod.GET)
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
public ServiceRestResponse getActivityResult(HttpServletRequest request,
|
||||
@@ -170,18 +158,6 @@ public class ActivityController {
|
||||
return ServiceRestResponse.createPositiveResponse(activityService.getActivityResult());
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_ACTIVITY_GET_TASKS, method = RequestMethod.GET)
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
public ServiceRestResponse getActivityTasks(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam(required = false) String activityId,
|
||||
@RequestParam(required = false) Date effectiveDateStart,
|
||||
@RequestParam(required = false) Date effectiveDateEnd) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(activityService.getActivityTasks(activityId, requestDataDTO.getUsername(), effectiveDateStart, effectiveDateEnd));
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_ACTIVITY_GET_TYPE, method = RequestMethod.GET)
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
public ServiceRestResponse getActivityType(HttpServletRequest request,
|
||||
@@ -284,27 +260,6 @@ public class ActivityController {
|
||||
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = EmsRestConstants.PATH_GET_ACTIVITY_CALENDAR, method = RequestMethod.GET)
|
||||
public ServiceRestResponse getActivityCalendar(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam(value = "startDate") String startDate,
|
||||
@RequestParam(value = "endDate") String endDate) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(activityService.getActivityCalendar(requestDataDTO.getUsername(), startDate, endDate));
|
||||
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = EmsRestConstants.PATH_DELETE_ACTIVITY, method = RequestMethod.GET)
|
||||
public ServiceRestResponse deleteActivity(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam String activityId,
|
||||
@RequestParam(required = false) boolean deleteSubActivity) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(activityService.deleteActivity(activityId, deleteSubActivity));
|
||||
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = EmsRestConstants.PATH_GET_COMMESSA_FROM_USERNAME, method = RequestMethod.GET)
|
||||
public ServiceRestResponse getCommessaFromUsername(HttpServletRequest request,
|
||||
|
||||
@@ -393,6 +393,17 @@ public class SteUPController {
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@PostMapping(value = "analisiRottureDiStock")
|
||||
public @ResponseBody
|
||||
ServiceRestResponse analisiRottureDiStock(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDB,
|
||||
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate dataIspezione,
|
||||
@RequestParam (required = false) String codMdep) throws Exception {
|
||||
|
||||
steUPService.analisiRottureDiStock(dataIspezione, codMdep);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "recuperoIspezioni", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse recuperoIspezioni(HttpServletRequest request,
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package it.integry.ems.activity.controller;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.activity.dto.Task.TaskMemoRequestDTO;
|
||||
import it.integry.ems.activity.service.TaskService;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
|
||||
@RestController
|
||||
@Scope(value = "request")
|
||||
@RequestMapping("/task")
|
||||
public class TaskController {
|
||||
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
|
||||
@Autowired
|
||||
private RequestDataDTO requestDataDTO;
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@GetMapping(value = "getActivity")
|
||||
public ServiceRestResponse getActivity(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam(required = false) String activityId,
|
||||
@RequestParam(value = "daInstallare") boolean daInstallare,
|
||||
@RequestParam(value = "isTable") boolean isTable,
|
||||
@RequestParam(required = false) Integer year) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(taskService.getActivity(isTable, daInstallare, activityId, year));
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@GetMapping(value = "getActivityTasks")
|
||||
public ServiceRestResponse getActivityTasks(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam(required = false) String activityId,
|
||||
@RequestParam(required = false) Date effectiveDateStart,
|
||||
@RequestParam(required = false) Date effectiveDateEnd) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(taskService.getActivityTasks(activityId, requestDataDTO.getUsername(), effectiveDateStart, effectiveDateEnd));
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@GetMapping(value = "getActivityCalendar")
|
||||
public ServiceRestResponse getActivityCalendar(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam(value = "startDate") String startDate,
|
||||
@RequestParam(value = "endDate") String endDate) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(taskService.getActivityCalendar(requestDataDTO.getUsername(), startDate, endDate));
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@GetMapping(value = "delete")
|
||||
public ServiceRestResponse deleteActivity(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam String activityId,
|
||||
@RequestParam(required = false) boolean deleteSubActivity) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(taskService.deleteActivity(activityId, deleteSubActivity));
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@PostMapping(value = "insertOrUpdateMemo")
|
||||
public ServiceRestResponse insertOrUpdateMemo(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestBody TaskMemoRequestDTO taskMemoRequest) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(taskService.insertOrUpdateMemo(taskMemoRequest));
|
||||
}
|
||||
}
|
||||
@@ -28,9 +28,10 @@ public class UserAbsenceController {
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = "/retrieve", method = RequestMethod.GET)
|
||||
public ServiceRestResponse retrieveAssenze(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam(required = false) String username,
|
||||
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate startDate,
|
||||
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate endDate) throws Exception {
|
||||
return ServiceRestResponse.createPositiveResponse(userAbsenceService.retrieveAssenze(startDate, endDate));
|
||||
return ServiceRestResponse.createPositiveResponse(userAbsenceService.retrieveAssenze(username, startDate, endDate));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/available-justifications", method = RequestMethod.GET)
|
||||
|
||||
@@ -2,18 +2,17 @@ package it.integry.ems.activity.controller;
|
||||
|
||||
import it.integry.ems.activity.dto.UserWorkHoursClockInRequestDTO;
|
||||
import it.integry.ems.activity.dto.UserWorkHoursClockOutRequestDTO;
|
||||
import it.integry.ems.activity.dto.UserWorkHoursDeleteDTO;
|
||||
import it.integry.ems.activity.dto.UserWorkHoursUpdateDTO;
|
||||
import it.integry.ems.activity.service.UserWorkHoursService;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.time.LocalDate;
|
||||
|
||||
@RestController()
|
||||
@@ -21,44 +20,55 @@ import java.time.LocalDate;
|
||||
@Scope(value = "request")
|
||||
public class UserWorkHoursController {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private UserWorkHoursService userWorkHoursService;
|
||||
|
||||
@Autowired
|
||||
private RequestDataDTO requestDataDTO;
|
||||
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = "/clock-in", method = RequestMethod.POST)
|
||||
public ServiceRestResponse clockIn(HttpServletRequest request,
|
||||
@RequestBody UserWorkHoursClockInRequestDTO userWorkHoursClockInRequestDTO) throws Exception {
|
||||
@PostMapping(value = "/clock-in")
|
||||
public ServiceRestResponse clockIn(@RequestBody UserWorkHoursClockInRequestDTO userWorkHoursClockInRequestDTO) throws Exception {
|
||||
|
||||
userWorkHoursService.clockIn(requestDataDTO.getUsername(), userWorkHoursClockInRequestDTO);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = "/clock-out", method = RequestMethod.POST)
|
||||
public ServiceRestResponse clockIn(HttpServletRequest request,
|
||||
@RequestBody UserWorkHoursClockOutRequestDTO userWorkHoursClockOutRequestDTO) throws Exception {
|
||||
@PostMapping(value = "/clock-out")
|
||||
public ServiceRestResponse clockOut(@RequestBody UserWorkHoursClockOutRequestDTO userWorkHoursClockOutRequestDTO) throws Exception {
|
||||
|
||||
userWorkHoursService.clockOut(requestDataDTO.getUsername(), userWorkHoursClockOutRequestDTO);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@PostMapping(value = "/update-worked-hours")
|
||||
public ServiceRestResponse updateWorkedHours(@RequestBody UserWorkHoursUpdateDTO requestUpdate) throws Exception {
|
||||
|
||||
userWorkHoursService.updateWorkedHours(requestDataDTO.getUsername(), requestUpdate);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = "/clock-status", method = RequestMethod.GET)
|
||||
public ServiceRestResponse clockStatus(HttpServletRequest request,
|
||||
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate startDate,
|
||||
@PostMapping(value = "/delete-worked-hours")
|
||||
public ServiceRestResponse deleteWorkedHours(@RequestBody UserWorkHoursDeleteDTO requestDelete) throws Exception {
|
||||
|
||||
userWorkHoursService.deleteWorkedHours(requestDataDTO.getUsername(), requestDelete);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@GetMapping(value = "/clock-status")
|
||||
public ServiceRestResponse clockStatus(@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate startDate,
|
||||
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate endDate) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(userWorkHoursService.clockStatus(requestDataDTO.getUsername(), startDate, endDate));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/global-clocks-check")
|
||||
public ServiceRestResponse globalClocksCheck() throws Exception {
|
||||
|
||||
@RequestMapping(value = "/global-clocks-check", method = RequestMethod.POST)
|
||||
public ServiceRestResponse globalClocksCheck(HttpServletRequest request) throws Exception {
|
||||
userWorkHoursService.globalClocksCheck();
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@@ -115,8 +115,8 @@ public class ActivityDTO {
|
||||
@SqlField(value = "tags")
|
||||
private String tags;
|
||||
|
||||
@SqlField(value = "scaduta")
|
||||
private Boolean scaduta;
|
||||
@SqlField(value = "stato_scadenza")
|
||||
private Integer statoScadenza;
|
||||
|
||||
@SqlField(value = "user_creator")
|
||||
private String userCreator;
|
||||
@@ -130,6 +130,9 @@ public class ActivityDTO {
|
||||
@SqlField(value = "ultima_modifica")
|
||||
private LocalDateTime ultimaModifica;
|
||||
|
||||
@SqlField(value = "user_modifier")
|
||||
private String userModifier;
|
||||
|
||||
@SqlField(value = "rag_soc")
|
||||
private String ragSoc;
|
||||
|
||||
@@ -189,6 +192,15 @@ public class ActivityDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUserModifier() {
|
||||
return userModifier;
|
||||
}
|
||||
|
||||
public ActivityDTO setUserModifier(String userModifier) {
|
||||
this.userModifier = userModifier;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFlagTipologia() {
|
||||
return flagTipologia;
|
||||
}
|
||||
@@ -535,12 +547,12 @@ public class ActivityDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getScaduta() {
|
||||
return scaduta;
|
||||
public Integer getStatoScadenza() {
|
||||
return statoScadenza;
|
||||
}
|
||||
|
||||
public ActivityDTO setScaduta(Boolean scaduta) {
|
||||
this.scaduta = scaduta;
|
||||
public ActivityDTO setStatoScadenza(Integer statoScadenza) {
|
||||
this.statoScadenza = statoScadenza;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -662,6 +674,9 @@ public class ActivityDTO {
|
||||
@SqlField(value = "done_previous_quarter")
|
||||
private boolean donePreviousQuarter;
|
||||
|
||||
@SqlField(value = "activity_status")
|
||||
private Integer activityStatus;
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
@@ -770,5 +785,14 @@ public class ActivityDTO {
|
||||
this.donePreviousQuarter = donePreviousQuarter;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getActivityStatus() {
|
||||
return activityStatus;
|
||||
}
|
||||
|
||||
public WorkedHours setActivityStatus(Integer activityStatus) {
|
||||
this.activityStatus = activityStatus;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,9 @@ public class ActivityTaskDTO {
|
||||
@SqlField(value = "effective_endtime")
|
||||
private LocalDateTime effectiveEndtime;
|
||||
|
||||
@SqlField(value = "alarm_time")
|
||||
private LocalDateTime alarmTime;
|
||||
|
||||
public String getActivityId() {
|
||||
return activityId;
|
||||
}
|
||||
@@ -222,4 +225,13 @@ public class ActivityTaskDTO {
|
||||
this.effectiveEndtime = effectiveEndtime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDateTime getAlarmTime() {
|
||||
return alarmTime;
|
||||
}
|
||||
|
||||
public ActivityTaskDTO setAlarmTime(LocalDateTime alarmTime) {
|
||||
this.alarmTime = alarmTime;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package it.integry.ems.activity.dto.Task;
|
||||
|
||||
import it.integry.ems.activity.dto.ActivityTaskDTO;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class TaskMemoRequestDTO {
|
||||
|
||||
private ActivityTaskDTO activityTaskDTO;
|
||||
private LocalDateTime notificationDate;
|
||||
|
||||
public ActivityTaskDTO getActivityTaskDTO() {
|
||||
return activityTaskDTO;
|
||||
}
|
||||
|
||||
public TaskMemoRequestDTO setActivityTaskDTO(ActivityTaskDTO activityTaskDTO) {
|
||||
this.activityTaskDTO = activityTaskDTO;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDateTime getNotificationDate() {
|
||||
return notificationDate;
|
||||
}
|
||||
|
||||
public TaskMemoRequestDTO setNotificationDate(LocalDateTime notificationDate) {
|
||||
this.notificationDate = notificationDate;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package it.integry.ems.activity.dto;
|
||||
|
||||
import it.integry.ems_model.utility.UtilityBigDecimal;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@@ -11,7 +13,7 @@ public class UserWorkHoursClockInRequestDTO {
|
||||
private LocalDateTime timestamp;
|
||||
|
||||
public boolean isValidPosition() {
|
||||
return positionLatitude != null && positionLongitude != null;
|
||||
return !UtilityBigDecimal.isNullOrZero(positionLatitude) && !UtilityBigDecimal.isNullOrZero(positionLongitude);
|
||||
}
|
||||
|
||||
public BigDecimal getPositionLatitude() {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package it.integry.ems.activity.dto;
|
||||
|
||||
import it.integry.ems_model.utility.UtilityBigDecimal;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@@ -29,7 +31,7 @@ public class UserWorkHoursClockOutRequestDTO {
|
||||
|
||||
|
||||
public boolean isValidPosition() {
|
||||
return positionLatitude != null && positionLongitude != null;
|
||||
return !UtilityBigDecimal.isNullOrZero(positionLatitude) && !UtilityBigDecimal.isNullOrZero(positionLongitude);
|
||||
}
|
||||
|
||||
public boolean isTrasfertaEstera() {
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package it.integry.ems.activity.dto;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class UserWorkHoursDeleteDTO {
|
||||
|
||||
private LocalDateTime timestamp;
|
||||
|
||||
private boolean clockIn;
|
||||
|
||||
public LocalDateTime getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public UserWorkHoursDeleteDTO setTimestamp(LocalDateTime timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isClockIn() {
|
||||
return clockIn;
|
||||
}
|
||||
|
||||
public UserWorkHoursDeleteDTO setClockIn(boolean clockIn) {
|
||||
this.clockIn = clockIn;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package it.integry.ems.activity.dto;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class UserWorkHoursUpdateDTO {
|
||||
|
||||
private LocalDateTime timestamp;
|
||||
|
||||
private LocalDateTime oldTimestamp;
|
||||
|
||||
private boolean clockIn;
|
||||
|
||||
public LocalDateTime getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public UserWorkHoursUpdateDTO setTimestamp(LocalDateTime timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDateTime getOldTimestamp() {
|
||||
return oldTimestamp;
|
||||
}
|
||||
|
||||
public UserWorkHoursUpdateDTO setOldTimestamp(LocalDateTime oldTimestamp) {
|
||||
this.oldTimestamp = oldTimestamp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isClockIn() {
|
||||
return clockIn;
|
||||
}
|
||||
|
||||
public UserWorkHoursUpdateDTO setClockIn(boolean clockIn) {
|
||||
this.clockIn = clockIn;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package it.integry.ems.activity.service;
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.activity.dto.*;
|
||||
import it.integry.ems.activity.utility.TaskUtility;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.media.MediaImageService;
|
||||
import it.integry.ems.media.MediaVideoService;
|
||||
@@ -861,7 +862,8 @@ public class ActivityService {
|
||||
}
|
||||
|
||||
String newActivityId = ((StbActivity) entityBase).getActivityId();
|
||||
List<ActivityDTO> activityDTO = getActivity(true, false, newActivityId, null);
|
||||
//List<ActivityDTO> activityDTO = getActivity(true, false, newActivityId, null);
|
||||
List<ActivityDTO> activityDTO = new ArrayList<>();
|
||||
|
||||
return Stream.of(activityDTO).findFirst().orElse(null);
|
||||
}
|
||||
@@ -923,288 +925,12 @@ public class ActivityService {
|
||||
ps.close();
|
||||
}
|
||||
|
||||
public List<ActivityDTO> getActivity(boolean isTable, boolean daInstallare, String activityId, Integer year) throws Exception {
|
||||
String username = requestDataDTO.getUsername();
|
||||
|
||||
String sql = Query.format("SELECT case when key_group = 3 THEN IsNull(user_name_rif, user_name) ELSE user_name END AS user_name, \n" +
|
||||
"CAST( case when key_group = 3 THEN 1 ELSE 0 END as BIT) as isCliente,\n" +
|
||||
"CAST( case when key_group = 3 and user_name_rif is not null THEN 1 ELSE 0 END as BIT) as isPersonaRif FROM stb_user WHERE user_name = %s", username);
|
||||
|
||||
HashMap<String, Object> datiUtente = UtilityDB.executeSimpleQueryOnlyFirstRow(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
boolean isPersonaRif = false;
|
||||
boolean isCliente = false;
|
||||
if (!datiUtente.isEmpty()) {
|
||||
username = UtilityHashMap.getValueIfExists(datiUtente, "user_name");
|
||||
isCliente = UtilityHashMap.getValueIfExists(datiUtente, "isCliente");
|
||||
isPersonaRif = UtilityHashMap.getValueIfExists(datiUtente, "isPersonaRif");
|
||||
}
|
||||
|
||||
sql = "WITH escludi_commesse AS (SELECT value cod_jcom\n" +
|
||||
" FROM string_split((SELECT value\n" +
|
||||
" FROM stb_gest_setup\n" +
|
||||
" WHERE gest_name = 'STB_ACTIVITY'\n" +
|
||||
" AND section = 'SETUP'\n" +
|
||||
" AND key_section = 'ESCLUDI_COMMESSE'), '|') s)\n" +
|
||||
" SELECT stb_activity.cod_jcom as 'Commessa',\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" stb_activity.activity_id as 'Id_Attivita',\n" +
|
||||
" stb_activity.parent_activity_id,\n" +
|
||||
" stb_activity.activity_description as 'Descrizione',\n" +
|
||||
" stb_activity.estimated_time as 'Data_Inizio_prev',\n" +
|
||||
" stb_activity.estimated_endtime as 'data_fine_prev',\n" +
|
||||
" stb_activity.effective_time as 'Data_Inizio_Effettiva',\n" +
|
||||
" stb_activity.effective_endtime as 'Data_Fine_Effettiva',\n" +
|
||||
" stb_activity.flag_risolto,\n" +
|
||||
" stb_activity.estimated_hours as 'Ore_Stimate',\n" +
|
||||
" CAST(CASE WHEN stb_activity.effective_endtime IS NULL THEN 0 ELSE 1 END AS BIT) AS 'attivita_chiusa', \n" +
|
||||
" stb_activity.activity_result_id AS 'Esito',\n" +
|
||||
" stb_activity.result_description AS 'descr_esito',\n" +
|
||||
" ISNULL(stb_activity.priorita, 0) AS 'priorita',\n" +
|
||||
" stb_activity.activity_type_id AS 'tipo_attivita',\n" +
|
||||
" IsNull(stb_activity.ora_ins_act, stb_activity.data_ins_act) AS 'data_inserimento',\n" +
|
||||
" stb_activity.ora_mod_act AS 'ultima_modifica'," +
|
||||
" CAST(CASE WHEN estimated_enddate < CAST(GETDATE() AS DATE) THEN 1 ELSE 0 END AS BIT) AS scaduta,\n" +
|
||||
" stb_activity.persona_rif AS 'richiedente',\n" +
|
||||
" stb_activity.estimated_enddate,\n" +
|
||||
" stb_activity.cod_mart AS cod_mart,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN stb_activity.cod_mart IS NULL THEN 'NESSUN PRODOTTO'\n" +
|
||||
" ELSE ISNULL(mtb_aart.descr_cassa, mtb_aart.descrizione) END AS descr_prodotto,\n" +
|
||||
" stb_activity.user_creator,\n" +
|
||||
" stb_activity.note,\n" +
|
||||
" stb_user.full_name as 'Responsabile',\n" +
|
||||
" parent.responabile_progetto,\n" +
|
||||
" ISNULL(parent.project_description, '') AS 'project_description',\n" +
|
||||
" ISNULL(parent.activity_description, 'Altre Attività') AS 'parent_activity_description',\n" +
|
||||
" creator.full_name AS 'creata_da',\n" +
|
||||
" parent.activity_type_id AS 'parent_activity_type',\n" +
|
||||
" CASE\n" +
|
||||
" WHEN stb_activity_result.flag_stato_attivita IS NULL THEN 0 --backlog\n" +
|
||||
" WHEN stb_activity_result.flag_stato_attivita = 0 THEN 1 --programmato\n" +
|
||||
" WHEN stb_activity_result.flag_stato_attivita = 1 THEN 2 --in corso\n" +
|
||||
" WHEN stb_activity_result.flag_stato_attivita = 2 AND\n" +
|
||||
" stb_activity_result.flag_activity_result = -1 THEN 3 --sospesa\n" +
|
||||
" WHEN stb_activity_result.flag_stato_attivita = 2 AND\n" +
|
||||
" stb_activity_result.flag_activity_result = 1 THEN 4 --test\n" +
|
||||
" ELSE 5 /*completata*/ END AS stato_attivita,\n" +
|
||||
" CAST(ISNULL(integry_tag.is_bug, 0) AS BIT) AS is_bug,\n" +
|
||||
" integry_tag.tags,\n" +
|
||||
" DENSE_RANK() OVER (ORDER BY parent.project_description, parent.activity_description) AS id_processo,\n" +
|
||||
" gtb_anag.rag_soc,\n " +
|
||||
" task.dapagare AS da_pagare,\n " +
|
||||
" task.acanone AS a_canone\n ";
|
||||
if (daInstallare) {
|
||||
sql += ", CAST(lastUpdt.data AS DATETIME) AS ultimo_aggiornamento\n";
|
||||
} else {
|
||||
sql += ", CAST(NULL AS DATETIME) AS ultimo_aggiornamento\n";
|
||||
}
|
||||
sql += " FROM stb_activity\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n" +
|
||||
" INNER JOIN stb_user creator ON stb_activity.user_creator = creator.user_name\n" +
|
||||
" LEFT OUTER JOIN pvw_clienti_prospect gtb_anag on stb_activity.cod_anag = gtb_anag.cod_ppro and stb_activity.tipo_anag = gtb_anag.tipologia\n" +
|
||||
" AND gtb_anag.flag_stato = 'A'\n" +
|
||||
" LEFT OUTER JOIN mtb_aart ON stb_activity.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" LEFT OUTER JOIN (SELECT parent.activity_description AS project_description,\n" +
|
||||
" stb_activity.activity_description AS activity_description,\n" +
|
||||
" stb_activity.activity_id,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" stb_activity.activity_type_id,\n" +
|
||||
" stb_activity.persona_rif AS responabile_progetto\n" +
|
||||
" FROM stb_activity\n" +
|
||||
" LEFT OUTER JOIN stb_activity parent\n" +
|
||||
" ON stb_activity.parent_activity_id = parent.activity_id\n" +
|
||||
" WHERE stb_activity.flag_tipologia = 'P') parent\n" +
|
||||
" ON stb_activity.parent_activity_id = parent.activity_id\n" +
|
||||
" LEFT OUTER JOIN stb_activity_result\n" +
|
||||
" ON stb_activity.activity_result_id = stb_activity_result.activity_result_id\n" +
|
||||
" LEFT OUTER JOIN integry_tag ON stb_activity.activity_id = integry_tag.activity_id \n" +
|
||||
" OUTER APPLY ( SELECT CAST(MAX(CASE WHEN task.cod_jfas <> 'C01' THEN 0 ELSE 1 END) AS BIT) AS daPagare,\n" +
|
||||
" CAST(MAX(CASE WHEN task.cod_jfas = 'C01' THEN 0 ELSE 1 END) AS BIT) AS aCanone \n" +
|
||||
" FROM stb_activity task WHERE stb_activity.activity_id = task.parent_activity_id) task ";
|
||||
|
||||
if (daInstallare) {
|
||||
sql += " LEFT OUTER JOIN integry_last_upd_clie lastUpdt ON stb_activity.cod_anag = lastUpdt.cod_anag\n";
|
||||
}
|
||||
|
||||
sql += " WHERE stb_activity.flag_tipologia = 'P'\n" +
|
||||
" AND NOT EXISTS(SELECT *\n" +
|
||||
" FROM escludi_commesse\n" +
|
||||
" WHERE stb_activity.cod_jcom = escludi_commesse.cod_jcom)\n" +
|
||||
" AND EXISTS (SELECT *\n" +
|
||||
" FROM srl_activity_type inner join stb_activity_type a on srl_activity_type.activity_type_id_next = a.activity_type_id\n" +
|
||||
" WHERE stb_activity.activity_type_id = srl_activity_type.activity_type_id\n" +
|
||||
" and srl_activity_type.flag_tipologia = 'P' \n";
|
||||
if (activityId == null) {
|
||||
sql += " and srl_activity_type.flag_tipologia_next = 'A' \n";
|
||||
}
|
||||
sql += " and a.flag_attiva = 's'\n" +
|
||||
" GROUP BY srl_activity_type.activity_type_id\n" +
|
||||
" HAVING sum(IIF(flag_tipologia_next = 'A',0,1)) = 0 )\n ";
|
||||
|
||||
if (year == null && activityId == null) {
|
||||
sql += " AND EXISTS (SELECT *\n" +
|
||||
" FROM jtb_comt\n" +
|
||||
" WHERE stato_commessa IN ('IN CORSO', 'POST VENDITA', 'TRATTATIVA')\n" +
|
||||
" AND stb_activity.cod_jcom = jtb_comt.cod_jcom) \n";
|
||||
} else if (activityId == null) {
|
||||
sql += " AND EXISTS (SELECT *\n" +
|
||||
" FROM jtb_comt\n" +
|
||||
" WHERE stato_commessa = 'CHIUSA'\n" +
|
||||
" AND (YEAR(data_inizi_lav) = " + year + " OR YEAR(data_cons) = " + year + ")\n" +
|
||||
" AND stb_activity.cod_jcom = jtb_comt.cod_jcom )\n";
|
||||
}
|
||||
|
||||
if (!isTable) {
|
||||
sql += " AND stb_activity.effective_endtime IS NULL " +
|
||||
" AND stb_activity.activity_type_id <> 'AGGIORNAMENTI SOFTWARE'";
|
||||
|
||||
if (daInstallare) {
|
||||
sql += " AND stb_activity.activity_result_id = 'DA INSTALLARE' AND cod_jcom not like 'INTEGRY%'";
|
||||
}
|
||||
} else if (activityId != null) {
|
||||
sql += " AND stb_activity.activity_id = " + UtilityDB.valueToString(activityId);
|
||||
} else if (isCliente) {
|
||||
sql += " AND stb_activity.activity_result_id NOT IN ('ANNULLATA', 'SOSPESA')";
|
||||
|
||||
if (isPersonaRif) {
|
||||
String whereCondPersRif =
|
||||
Query.format(" AND EXISTS( SELECT *\n" +
|
||||
" from stb_user s inner join vtb_clie_pers_rif on s.e_mail = vtb_clie_pers_rif.e_mail\n" +
|
||||
" where S.USER_NAME = %s and vtb_clie_pers_rif.persona_rif = stb_activity.persona_rif)",
|
||||
requestDataDTO.getUsername());
|
||||
sql += whereCondPersRif;
|
||||
}
|
||||
}
|
||||
|
||||
List<ActivityDTO> activityDTOS = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ActivityDTO.class);
|
||||
|
||||
if (activityDTOS != null) {
|
||||
List<String> elencoId = Stream.of(activityDTOS).map(ActivityDTO::getIdAttivita).toList();
|
||||
sql =
|
||||
"SELECT stb_activity.parent_activity_id,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" stb_user.full_name,\n" +
|
||||
" MAX(IIF(effective_date <= CAST(GETDATE() AS DATE), effective_date, NULL)) AS last_activity_date,\n" +
|
||||
" MIN(IIF(estimated_date >= CAST(GETDATE() AS DATE), estimated_date, NULL)) AS next_activity_date,\n" +
|
||||
" MAX(IIF(((estimated_date BETWEEN dbo.f_getfirstdayofweek(GETDATE()) AND dbo.f_getlastdayofweek(GETDATE()) OR\n" +
|
||||
" estimated_date IS NULL) AND effective_date IS NULL), stb_activity.activity_description,\n" +
|
||||
" NULL)) AS activity_description,\n" +
|
||||
" CAST(MAX(IIF(\n" +
|
||||
" ISNULL(effective_date, estimated_date) BETWEEN dbo.f_getfirstdayofweek(GETDATE()) AND dbo.f_getlastdayofweek(GETDATE()),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS planned_this_week,\n" +
|
||||
" CAST(MAX(IIF(\n" +
|
||||
" ISNULL(effective_date, estimated_date) BETWEEN dbo.f_getfirstdayofweek(DATEADD(WEEK, -1, GETDATE())) AND dbo.f_getlastdayofweek(DATEADD(WEEK, -1, GETDATE())),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS planned_previous_week,\n" +
|
||||
" CAST(MAX(IIF(\n" +
|
||||
" ISNULL(effective_date, estimated_date) BETWEEN dbo.f_getfirstdayofweek(DATEADD(WEEK, 1, GETDATE())) AND dbo.f_getlastdayofweek(DATEADD(WEEK, 1, GETDATE())),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS planned_next_week,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND\n" +
|
||||
" effective_date BETWEEN dbo.f_getfirstdayofmonth(GETDATE()) AND EOMONTH(GETDATE()), 1,\n" +
|
||||
" 0)) AS BIT) AS done_this_month,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND\n" +
|
||||
" effective_date BETWEEN dbo.f_getfirstdayofmonth(DATEADD(MONTH, -1, GETDATE())) AND EOMONTH(DATEADD(MONTH, -1, GETDATE())),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS done_previous_month,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND\n" +
|
||||
" DATEPART(QUARTER, effective_date) = DATEPART(QUARTER, GETDATE()), 1,\n" +
|
||||
" 0)) AS BIT) AS done_this_quarter,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND DATEPART(QUARTER, effective_date) =\n" +
|
||||
" DATEPART(QUARTER, DATEADD(MONTH, -3, GETDATE())), 1,\n" +
|
||||
" 0)) AS BIT) AS done_previous_quarter,\n" +
|
||||
" SUM(jtb_rlavr.ore) AS ore_fatte\n" +
|
||||
"FROM stb_activity\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n" +
|
||||
" LEFT OUTER JOIN jtb_rlavr ON stb_activity.activity_id = jtb_rlavr.activity_id\n" +
|
||||
"WHERE stb_activity.flag_tipologia = 'A'\n" +
|
||||
" AND stb_activity.parent_activity_id IN (" + UtilityDB.listValueToString(elencoId) + ")\n" +
|
||||
"GROUP BY stb_activity.parent_activity_id,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" stb_user.full_name";
|
||||
|
||||
List<ActivityDTO.WorkedHours> activityResponseDtoWorkedHours = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ActivityDTO.WorkedHours.class);
|
||||
|
||||
if (activityResponseDtoWorkedHours != null) {
|
||||
final HashMap<String, List<ActivityDTO.WorkedHours>> subActivityList = activityResponseDtoWorkedHours.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
ActivityDTO.WorkedHours::getParentActivityId,
|
||||
LinkedHashMap::new,
|
||||
Collectors.toList()
|
||||
));
|
||||
|
||||
for (ActivityDTO activityResponse : activityDTOS) {
|
||||
if (subActivityList.containsKey(activityResponse.getIdAttivita())) {
|
||||
List<ActivityDTO.WorkedHours> workedHours = subActivityList.get(activityResponse.getIdAttivita());
|
||||
|
||||
for (ActivityDTO.WorkedHours workedHour : workedHours) {
|
||||
if (workedHour.getActivityDescription() != null &&
|
||||
workedHour.getActivityDescription().equals(activityResponse.getDescrizione())) {
|
||||
workedHour.setActivityDescription(null);
|
||||
}
|
||||
}
|
||||
|
||||
activityResponse.setWorkedHours(workedHours);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return activityDTOS;
|
||||
}
|
||||
|
||||
public List<ActivityResultDTO> getActivityResult() throws Exception {
|
||||
String sql = "select activity_result_id from stb_activity_result where flag_attivo LIKE 'S'";
|
||||
|
||||
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ActivityResultDTO.class);
|
||||
}
|
||||
|
||||
public List<ActivityTaskDTO> getActivityTasks(String activityId, String username, Date effectiveDateStart, Date effectiveDateEnd) throws Exception {
|
||||
String sql = "SELECT stb_activity.activity_id,\n" +
|
||||
" stb_activity.cod_jcom,\n" +
|
||||
" stb_activity.activity_type_id,\n" +
|
||||
" stb_activity.parent_activity_id,\n" +
|
||||
" activity_description,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" full_name,\n" +
|
||||
" effective_date,\n" +
|
||||
" activity_result_id,\n" +
|
||||
" result_description,\n" +
|
||||
" SUM(ore) ore_lav,\n" +
|
||||
" stb_activity.note,\n" +
|
||||
" estimated_date,\n" +
|
||||
" estimated_time,\n" +
|
||||
" estimated_endtime,\n" +
|
||||
" effective_time,\n" +
|
||||
" effective_endtime\n" +
|
||||
"FROM stb_activity\n" +
|
||||
" LEFT OUTER JOIN jtb_rlavr ON stb_activity.activity_id = jtb_rlavr.activity_id\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n";
|
||||
|
||||
List<String> conditions = new ArrayList<>();
|
||||
|
||||
if (activityId != null && !activityId.isEmpty()) {
|
||||
conditions.add("stb_activity.parent_activity_id = " + UtilityDB.valueToString(activityId));
|
||||
} else {
|
||||
conditions.add("stb_activity.user_name LIKE " + UtilityDB.valueToString(username));
|
||||
}
|
||||
|
||||
if (effectiveDateStart != null && effectiveDateEnd != null) {
|
||||
conditions.add("effective_date BETWEEN " +
|
||||
UtilityDB.valueToString(effectiveDateStart) + " AND " +
|
||||
UtilityDB.valueToString(effectiveDateEnd));
|
||||
}
|
||||
|
||||
conditions.add("stb_activity.flag_tipologia = 'A'");
|
||||
|
||||
sql += "WHERE " + String.join(" AND ", conditions);
|
||||
|
||||
sql += "\nGROUP BY stb_activity.activity_id, stb_activity.cod_jcom, stb_activity.activity_type_id, stb_activity.parent_activity_id, activity_description, stb_activity.user_name, full_name, effective_date, activity_result_id, result_description, stb_activity.note, estimated_date, estimated_time, estimated_endtime, effective_time, effective_endtime";
|
||||
|
||||
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ActivityTaskDTO.class);
|
||||
}
|
||||
|
||||
public List<ActivityTypeDTO> getActivityType() throws Exception {
|
||||
String sql = "SELECT DISTINCT srl_activity_type.activity_type_id, \n" +
|
||||
"srl_activity_type.flag_tipologia,\n" +
|
||||
@@ -1587,75 +1313,6 @@ public class ActivityService {
|
||||
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, TreeViewDTO.class);
|
||||
}
|
||||
|
||||
public List<ActivityTaskDTO> getActivityCalendar(String username, String startDate, String endDate) throws Exception {
|
||||
String sql = "WITH sottoattivita AS (SELECT stb_activity.activity_id, stb_activity.activity_type_id\n" +
|
||||
" FROM stb_activity\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n" +
|
||||
" LEFT OUTER JOIN jtb_rlavr ON stb_activity.activity_id = jtb_rlavr.activity_id\n" +
|
||||
" AND stb_activity.user_name = " + UtilityDB.valueToString(username) + "\n" +
|
||||
" GROUP BY stb_activity.activity_id, stb_activity.activity_type_id)\n" +
|
||||
"\n" +
|
||||
"SELECT stb_activity.activity_id,\n" +
|
||||
" stb_activity.cod_jcom,\n" +
|
||||
" stb_activity.parent_activity_id,\n" +
|
||||
"\t sottoattivita.activity_type_id AS 'parent_activity_type_id',\n" +
|
||||
" stb_activity.activity_type_id,\n" +
|
||||
" activity_description,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" full_name,\n" +
|
||||
" effective_date,\n" +
|
||||
" activity_result_id,\n" +
|
||||
" result_description,\n" +
|
||||
" SUM(ore) AS ore_lav,\n" +
|
||||
" stb_activity.note,\n" +
|
||||
" estimated_date,\n" +
|
||||
" estimated_time,\n" +
|
||||
" estimated_endtime,\n" +
|
||||
" effective_time,\n" +
|
||||
" effective_endtime\n" +
|
||||
"\n" +
|
||||
"FROM stb_activity\n" +
|
||||
" LEFT OUTER JOIN jtb_rlavr ON stb_activity.activity_id = jtb_rlavr.activity_id\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n" +
|
||||
" LEFT OUTER JOIN sottoattivita ON stb_activity.parent_activity_id = sottoattivita.activity_id\n" +
|
||||
"\n" +
|
||||
"WHERE stb_activity.flag_tipologia = 'A'\n" +
|
||||
" AND stb_activity.user_name = " + UtilityDB.valueToString(username) + "\n" +
|
||||
" AND (estimated_date BETWEEN " + UtilityDB.valueToString(startDate) + " AND " + UtilityDB.valueToString(endDate) + "\n" +
|
||||
" OR effective_date BETWEEN " + UtilityDB.valueToString(startDate) + " AND " + UtilityDB.valueToString(endDate) + ")\n" +
|
||||
"\n" +
|
||||
"GROUP BY stb_activity.activity_id, stb_activity.cod_jcom, stb_activity.parent_activity_id, sottoattivita.activity_type_id, stb_activity.activity_type_id, activity_description,\n" +
|
||||
" stb_activity.user_name, full_name, effective_date, activity_result_id, result_description, stb_activity.note,\n" +
|
||||
" estimated_date, estimated_time, estimated_endtime, effective_time, effective_endtime;";
|
||||
|
||||
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ActivityTaskDTO.class);
|
||||
}
|
||||
|
||||
public boolean deleteActivity(String activityId, boolean deleteSubActivity) throws Exception {
|
||||
StbActivity activity = new StbActivity();
|
||||
activity.setActivityId(activityId);
|
||||
activity.setOperation(OperationType.DELETE);
|
||||
|
||||
if (deleteSubActivity) {
|
||||
List<StbActivity> stbActivityList = new ArrayList<>();
|
||||
|
||||
List<ActivityTaskDTO> activityTasks = getActivityTasks(activityId, null, null, null);
|
||||
for (ActivityTaskDTO activityTask : activityTasks) {
|
||||
StbActivity stbActivity = new StbActivity();
|
||||
stbActivity.setActivityId(activityTask.getActivityId());
|
||||
stbActivity.setOperation(OperationType.DELETE);
|
||||
|
||||
stbActivityList.add(stbActivity);
|
||||
}
|
||||
|
||||
entityProcessor.processEntityList(stbActivityList, true);
|
||||
}
|
||||
|
||||
entityProcessor.processEntity(activity, multiDBTransactionManager);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> getCommessaFromUsername(String username) throws Exception {
|
||||
String sql = "SELECT DISTINCT jc.cod_jcom\n" +
|
||||
"FROM stb_user\n" +
|
||||
@@ -1721,8 +1378,8 @@ public class ActivityService {
|
||||
|
||||
public List<OldUpdateDTO> getOldUpdate() throws Exception {
|
||||
String sql = "WITH commesse AS (SELECT cod_jcom,\n" +
|
||||
" jtb_comt.cod_anag,\n" +
|
||||
" ROW_NUMBER() OVER (PARTITION BY jtb_comt.cod_anag ORDER BY cod_jcom DESC, servers.updated_at DESC, vtb_clie.flag_stato) AS conta,\n" +
|
||||
" wtb_clie2.cod_anag,\n" +
|
||||
" ROW_NUMBER() OVER (PARTITION BY wtb_clie2.cod_anag ORDER BY cod_jcom DESC, servers.updated_at DESC, vtb_clie.flag_stato) AS conta,\n" +
|
||||
" servers.last_update,\n" +
|
||||
" gtb_anag.rag_soc\n" +
|
||||
" FROM jtb_comt\n" +
|
||||
|
||||
@@ -60,6 +60,7 @@ import java.util.stream.Collectors;
|
||||
import static it.integry.ems.order.dto.UserGroupENUM.RILEVATORE;
|
||||
import static it.integry.ems.order.dto.UserGroupENUM.TECNICO;
|
||||
import static java.util.stream.Collectors.groupingBy;
|
||||
import static org.codehaus.groovy.runtime.DefaultGroovyMethods.collect;
|
||||
|
||||
@Service
|
||||
@Scope("request")
|
||||
@@ -514,7 +515,7 @@ public class SteUPService {
|
||||
String tipoAttivitaInevasi = setup.get("TIPO_ATTIVITA_VERIFICA_INEVASI");
|
||||
String reportInevasi = setup.get("REPORT_INEVASI");
|
||||
String activityId = null;
|
||||
if ( !isNewIsepzione ) {
|
||||
if (!isNewIsepzione) {
|
||||
String sql =
|
||||
Query.format(
|
||||
"SELECT activity_id\n" +
|
||||
@@ -534,7 +535,7 @@ public class SteUPService {
|
||||
|
||||
activityId = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
}
|
||||
|
||||
|
||||
StbActivity activityItem =
|
||||
new StbActivity()
|
||||
.setActivityDescription(activityTypeId)
|
||||
@@ -665,9 +666,6 @@ public class SteUPService {
|
||||
String content = new String(contentB64);
|
||||
barcodes = UtilityString.splitStringToMultipleLine(content, CommonConstants.A_CAPO);
|
||||
saveFile = false;
|
||||
} else if (UtilityDebug.isDebugExecution()) {
|
||||
barcodes = UtilityDB.executeSimpleQueryOnlyFirstColumn(multiDBTransactionManager.getPrimaryConnection(),
|
||||
"select cod_mart from stb_activity where parent_activity_id = 'C0000843821'");
|
||||
} else {
|
||||
throw new Exception("File " + fileNameElencoArt + " non trovato.");
|
||||
}
|
||||
@@ -739,36 +737,9 @@ public class SteUPService {
|
||||
|
||||
if (barcodes != null && !barcodes.isEmpty()) {
|
||||
for (String barcode : barcodes) {
|
||||
sql =
|
||||
"SELECT activity_type_id_next " +
|
||||
" FROM srl_activity_type " +
|
||||
" WHERE activity_type_id = " + UtilityDB.valueToString(activityTypeId) + " AND " +
|
||||
"flag_tipologia = 'A' ";
|
||||
|
||||
String activityTypeArt = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
if (UtilityString.isNullOrEmpty(activityTypeArt)) {
|
||||
throw new Exception("Nessun tipo attività associato a " + activityTypeId + " per l'inserimento degli articoli.");
|
||||
}
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
String codMart = this.getCodMartFromBarcode(barcode);
|
||||
StbActivity item = new StbActivity()
|
||||
.setActivityDescription(activityTypeArt)
|
||||
.setNote(parentActivity.getNote())
|
||||
.setCodJfas(codJfas)
|
||||
.setCodMart(codMart)
|
||||
.setFlagTipologia("A")
|
||||
.setUserName(userNamePv)
|
||||
.setUserCreator(parentActivity.getUserCreator())
|
||||
.setUserModifier(parentActivity.getUserCreator())
|
||||
.setActivityTypeId(activityTypeArt)
|
||||
.setOraInsAct(now)
|
||||
.setEffectiveTime(dataCreation)
|
||||
.setParentActivityId(activityId);
|
||||
|
||||
item.setOperation(OperationType.INSERT);
|
||||
stbActivityList.add(item);
|
||||
StbActivity art = getArticoli(barcode, null, activityTypeId, codJfas, userNamePv);
|
||||
if( art != null)
|
||||
stbActivityList.add(art);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -814,6 +785,36 @@ public class SteUPService {
|
||||
return stbActivityList;
|
||||
}
|
||||
|
||||
private StbActivity getArticoli(String barcode, String codMart, String activityTypeId, String codJfas, String userNamePv) throws Exception {
|
||||
String sql;
|
||||
sql =
|
||||
"SELECT activity_type_id_next " +
|
||||
" FROM srl_activity_type " +
|
||||
" WHERE activity_type_id = " + UtilityDB.valueToString(activityTypeId) + " AND " +
|
||||
"flag_tipologia = 'A' ";
|
||||
|
||||
String activityTypeArt = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
if (UtilityString.isNullOrEmpty(activityTypeArt)) {
|
||||
throw new Exception("Nessun tipo attività associato a " + activityTypeId + " per l'inserimento degli articoli.");
|
||||
}
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
if (!UtilityString.isNullOrEmpty(barcode))
|
||||
codMart = this.getCodMartFromBarcode(barcode);
|
||||
StbActivity item = new StbActivity()
|
||||
.setActivityDescription(activityTypeArt)
|
||||
.setCodJfas(codJfas)
|
||||
.setCodMart(codMart)
|
||||
.setFlagTipologia("A")
|
||||
.setUserName(userNamePv)
|
||||
.setActivityTypeId(activityTypeArt)
|
||||
.setOraInsAct(now);
|
||||
|
||||
item.setOperation(OperationType.INSERT);
|
||||
return item;
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getPrezzo(String codMdep, String barcode) throws Exception {
|
||||
String sql =
|
||||
"SELECT p.descrizione, p.prz_vend_iva " +
|
||||
@@ -865,80 +866,61 @@ public class SteUPService {
|
||||
"ORDER BY mtb_aart.descrizione";
|
||||
sql = UtilityDB.addwhereCond(sql, whereCond, false);
|
||||
} else if (activityTypeId.equalsIgnoreCase(tipoAttivitaRotturaStock)) {
|
||||
if (repartiFreschi.contains(codJfas)) {
|
||||
String tipoGriglia = setupGest.getSetupDet(multiDBTransactionManager.getPrimaryConnection(), "PVM", "RILEVAZIONI_STEUP", "TIPO_GRIGLIA", codJfas);
|
||||
|
||||
String queryAssortimento = "";
|
||||
switch (tipoGriglia) {
|
||||
case "A":
|
||||
queryAssortimento = Query.format("SELECT cod_mart,descrizione,bar_code as barcode,cod_msgr\n" +
|
||||
"FROM steup_getAssortimento(%s,%s,%s) art\n",
|
||||
codMdep, codJfas, dataCreation
|
||||
);
|
||||
break;
|
||||
case "V":
|
||||
queryAssortimento =
|
||||
Query.format("SELECT griglia.cod_mart, \n" +
|
||||
"descrizione, \n" +
|
||||
(chkRotturaStock ? "mvw_barcode.cod_barre" : "griglia.bar_code") + " as barcode, \n" +
|
||||
"cod_msgr\n " +
|
||||
" from steup_getGrigliaVendita(%s, %s, %s) griglia " +
|
||||
(chkRotturaStock ? " INNER JOIN mvw_barcode on griglia.cod_mart_kit = mvw_barcode.cod_mart " : ""),
|
||||
codMdep, codJfas, dataCreation);
|
||||
break;
|
||||
}
|
||||
|
||||
if (repartiFreschi.contains(codJfas) || (chkRotturaStock && barcode != null & !barcode.isEmpty())) {
|
||||
sql =
|
||||
"SELECT griglia.cod_mart, \n" +
|
||||
"WITH assortimento AS ( " +
|
||||
queryAssortimento +
|
||||
") " +
|
||||
"SELECT griglia.cod_mart, \n" +
|
||||
"descrizione, \n" +
|
||||
(chkRotturaStock ? "mvw_barcode.cod_barre" : "griglia.bar_code") + " as barcode, \n" +
|
||||
"barcode, \n" +
|
||||
"cod_msgr\n " +
|
||||
" from steup_getGrigliaVendita(" + UtilityDB.valueToString(codMdep) + "," + UtilityDB.valueToString(codJfas) + ", " + UtilityDB.valueToString(dataCreation) + ") griglia " +
|
||||
(chkRotturaStock ? " INNER JOIN mvw_barcode on griglia.cod_mart_kit = mvw_barcode.cod_mart " : "") +
|
||||
" WHERE griglia.cod_mart NOT IN (SELECT cod_mart\n" +
|
||||
" from assortimento " +
|
||||
" WHERE assortimento.cod_mart NOT IN (SELECT cod_mart\n" +
|
||||
" FROM (SELECT cod_mart,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" data_validita,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN tipo_variazione = 'I' AND\n" +
|
||||
" LEAD(tipo_variazione, 1, NULL)\n" +
|
||||
" OVER (PARTITION BY cod_mart, cod_mdep ORDER BY data_validita, tipo_variazione DESC ) =\n" +
|
||||
" 'D' AND\n" +
|
||||
" LEAD(data_validita, 1, NULL)\n" +
|
||||
" OVER (PARTITION BY cod_mart, cod_mdep ORDER BY data_validita, tipo_variazione DESC ) =\n" +
|
||||
" data_validita THEN 'U'\n" +
|
||||
" ELSE tipo_variazione END AS tipo_variazione,\n" +
|
||||
" LEAD(tipo_variazione, 1, NULL)\n" +
|
||||
" OVER (PARTITION BY cod_mart, cod_mdep ORDER BY data_validita, tipo_variazione ) AS tipo_variazione_succ\n" +
|
||||
" FROM carelli.dbo.atb_griglie_art\n" +
|
||||
" WHERE atb_griglie_art.data_validita <= " + UtilityDB.valueToString(dataCreation) + "\n" +
|
||||
" AND atb_griglie_art.cod_mdep = " + UtilityDB.valueToString(codMdep) + ") g\n" +
|
||||
" WHERE g.tipo_variazione_succ IS NULL\n" +
|
||||
" AND DATEDIFF(DAY, data_validita, " + UtilityDB.valueToString(dataCreation) + ") < 7\n" +
|
||||
" tipo_variazione \n" +
|
||||
" FROM carelli.dbo.getGrigliaAssortimento([DATA_CREAZIONE], null,[COD_MDEP], null, null) g\n" +
|
||||
" WHERE DATEDIFF(DAY, data_validita, [DATA_CREAZIONE]) < 7\n" +
|
||||
" AND g.tipo_variazione = 'I'\n" +
|
||||
" UNION \n" +
|
||||
" SELECT cod_mart \n" +
|
||||
" FROM dbo.steup_getInevasi(" + UtilityDB.valueToString(codMdep) + ", " + UtilityDB.valueToString(codJfas) + ", " + UtilityDB.valueToString(dataCreation) + "))\n " +
|
||||
" FROM dbo.steup_getInevasi([COD_MDEP], [COD_JFAS], [DATA_CREAZIONE]))\n " +
|
||||
(chkRotturaStock && barcode != null & !barcode.isEmpty() ?
|
||||
"AND EXISTS(SELECT cod_mart from carelli.dbo.mvw_barcode WHERE cod_barre in (" + UtilityDB.listValueToString(barcode) + ") and art.cod_mart = mvw_barcode.cod_mart)\n" : "") +
|
||||
"order by descrizione";
|
||||
} else if (chkRotturaStock && barcode != null & !barcode.isEmpty()) {
|
||||
sql = "SELECT cod_mart,descrizione,bar_code as barcode,cod_msgr\n" +
|
||||
"FROM steup_getAssortimento(" + UtilityDB.valueToString(codMdep) + "," + UtilityDB.valueToString(codJfas) + ", " + UtilityDB.valueToString(dataCreation) + ") art\n" +
|
||||
"WHERE EXISTS(SELECT cod_mart from carelli.dbo.mvw_barcode WHERE cod_barre in (" + UtilityDB.listValueToString(barcode) + ") and art.cod_mart = mvw_barcode.cod_mart)\n" +
|
||||
" AND cod_mart NOT IN (SELECT cod_mart\n" +
|
||||
" FROM (SELECT cod_mart,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" data_validita,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN tipo_variazione = 'I' AND\n" +
|
||||
" LEAD(tipo_variazione, 1, NULL)\n" +
|
||||
" OVER (PARTITION BY cod_mart, cod_mdep ORDER BY data_validita, tipo_variazione DESC ) =\n" +
|
||||
" 'D' AND\n" +
|
||||
" LEAD(data_validita, 1, NULL)\n" +
|
||||
" OVER (PARTITION BY cod_mart, cod_mdep ORDER BY data_validita, tipo_variazione DESC ) =\n" +
|
||||
" data_validita THEN 'U'\n" +
|
||||
" ELSE tipo_variazione END AS tipo_variazione,\n" +
|
||||
" LEAD(tipo_variazione, 1, NULL)\n" +
|
||||
" OVER (PARTITION BY cod_mart, cod_mdep ORDER BY data_validita, tipo_variazione ) AS tipo_variazione_succ\n" +
|
||||
" FROM carelli.dbo.atb_griglie_art\n" +
|
||||
" WHERE atb_griglie_art.data_validita <= " + UtilityDB.valueToString(dataCreation) + "\n" +
|
||||
" AND atb_griglie_art.cod_mdep = " + UtilityDB.valueToString(codMdep) + ") g\n" +
|
||||
" WHERE g.tipo_variazione_succ IS NULL\n" +
|
||||
" AND DATEDIFF(DAY, data_validita, " + UtilityDB.valueToString(dataCreation) + ") < 7\n" +
|
||||
" AND g.tipo_variazione = 'I'\n" +
|
||||
" UNION \n" +
|
||||
" SELECT cod_mart \n" +
|
||||
" FROM dbo.steup_getInevasi(" + UtilityDB.valueToString(codMdep) + ", " + UtilityDB.valueToString(codJfas) + ", " + UtilityDB.valueToString(dataCreation) + "))";
|
||||
|
||||
sql = sql
|
||||
.replace("[DATA_CREAZIONE]", UtilityDB.valueToString(dataCreation))
|
||||
.replace("[COD_MDEP]", UtilityDB.valueToString(codMdep))
|
||||
.replace("[COD_JFAS]", UtilityDB.valueToString(codJfas));
|
||||
} else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
sql = "SELECT DISTINCT mtb_aart.cod_mart, " +
|
||||
" mtb_aart.descrizione, " +
|
||||
" mtb_aart.bar_code AS barcode," +
|
||||
" mtb_aart.cod_msgr " +
|
||||
"FROM dbo.steup_getAssortimento(" + UtilityDB.valueToString(codMdep) + ", " + UtilityDB.valueToString(codJfas) + " ) mtb_aart" +
|
||||
" WHERE mtb_aart.plu IS NOT NULL " +
|
||||
"ORDER BY mtb_aart.descrizione";
|
||||
*/
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@@ -950,7 +932,6 @@ public class SteUPService {
|
||||
logger.info("Uploading attachment activity ID: " + activityId);
|
||||
String fileName = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".zip";
|
||||
String pathFile = UtilityDirs.getEmsApiTempDirectoryPath() + File.separator + activityId + File.separator;
|
||||
//UtilityFile.createZipFromMultipartFile(pathFile, fileName, f);
|
||||
|
||||
UtilityFile.saveFile(pathFile, f.getOriginalFilename(), f.getBytes());
|
||||
|
||||
@@ -1425,7 +1406,7 @@ public class SteUPService {
|
||||
" activity_result_id,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" descr_deposito\n" +
|
||||
"FROM dbo.steup_getRilevazioni()\n" +
|
||||
"FROM dbo.steup_getRilevazioni(null, null, null)\n" +
|
||||
"WHERE CAST(effective_time AS DATE) BETWEEN %s AND %s",
|
||||
dataInizio,
|
||||
dataFine
|
||||
@@ -1493,4 +1474,290 @@ public class SteUPService {
|
||||
entityProcessor.processEntityList(entityList, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void analisiRottureDiStock(LocalDate dataIspezione, String codMdep) throws Exception {
|
||||
Map<String, String> setup = setupGest.getSetupSection(multiDBTransactionManager.getPrimaryConnection(), "PVM", "RILEVAZIONI_STEUP");
|
||||
|
||||
String tipoAttivitaRotturaStock = setup.get("TIPO_ATTIVITA_ROTTURA_STOCK");
|
||||
List<String> repartiFreschi = Arrays.asList(StringUtils.split(UtilityString.isNull(setup.get("REPARTI_FRESCHI"), ""), "|"));
|
||||
List<String> tipiEsclusi = Arrays.asList(StringUtils.split(UtilityString.isNull(setup.get("EXCLUDE_COD_MTIP"), ""), "|"));
|
||||
List<String> fornitori = Arrays.asList(StringUtils.split(UtilityString.isNull(setup.get("ELENCO_FORN_INEVASI"), ""), "|"));
|
||||
|
||||
String sql =
|
||||
Query.format(
|
||||
"select i.cod_mdep, stb_activity.cod_jfas, stb_activity.activity_id, stb_activity.user_name\n" +
|
||||
"from dbo.steup_getRilevazioni(%s, %s, null) i\n" +
|
||||
"inner join stb_activity on i.activity_id = stb_activity.parent_activity_id\n" +
|
||||
"where stb_activity.activity_type_id = %s",
|
||||
dataIspezione, codMdep, tipoAttivitaRotturaStock);
|
||||
|
||||
List<HashMap<String, Object>> ispezioni = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
if (ispezioni == null || ispezioni.isEmpty()) {
|
||||
throw new Exception("Nessuna ispezione trovata per la data e il punto vendita indicati.");
|
||||
}
|
||||
|
||||
Map<String, List<HashMap<String, Object>>> ispezioniDepo = ispezioni.stream().collect(groupingBy(x -> (String) x.get("cod_mdep")));
|
||||
|
||||
for (Map.Entry<String, List<HashMap<String, Object>>> entry : ispezioniDepo.entrySet()) {
|
||||
String userNamePv = entry.getValue().get(0).get("user_name").toString();
|
||||
Map<String, List<HashMap<String, Object>>> reparti = entry.getValue().stream().collect(groupingBy(x -> (String) x.get("cod_jfas")));
|
||||
for (Map.Entry<String, List<HashMap<String, Object>>> reparto : reparti.entrySet()) {
|
||||
String codJfas = reparto.getKey();
|
||||
List<String> barcodes = new ArrayList<>();
|
||||
|
||||
List<String> idAttivita = new ArrayList<>();
|
||||
for ( HashMap<String, Object> r: reparto.getValue() ) {
|
||||
String activityId = (String) r.get("activity_id");
|
||||
idAttivita.add(activityId);
|
||||
StbActivityFile stbActivityFile = new StbActivityFile()
|
||||
.setId(activityId)
|
||||
.setFileName("elenco_articoli.txt");
|
||||
stbActivityFile.setOperation(OperationType.SELECT_OBJECT);
|
||||
|
||||
entityProcessor.processEntity(stbActivityFile, multiDBTransactionManager);
|
||||
|
||||
byte[] contentB64 = stbActivityFile.getContent();
|
||||
if (contentB64 != null && contentB64.length > 0) {
|
||||
String content = new String(contentB64);
|
||||
barcodes.addAll(UtilityString.splitStringToMultipleLine(content, CommonConstants.A_CAPO));
|
||||
if (UtilityDebug.isDebugExecution()) {
|
||||
barcodes=Arrays.asList(
|
||||
("8001990030611\n" +
|
||||
"8003650000798\n" +
|
||||
"8054633830833\n" +
|
||||
"8410436393942\n" +
|
||||
"8002340012103\n" +
|
||||
"8007300004297\n" +
|
||||
"8002340012660\n" +
|
||||
"8033532102838\n" +
|
||||
"8052675290028\n" +
|
||||
"8000697001917\n" +
|
||||
"8055719541384\n" +
|
||||
"8055719541377\n" +
|
||||
"8018700037204\n" +
|
||||
"8001480720800\n" +
|
||||
"8001280070648\n" +
|
||||
"8054633831656\n" +
|
||||
"8720182641618\n" +
|
||||
"8011380002074\n" +
|
||||
"8230485606837\n" +
|
||||
"8033532107987\n" +
|
||||
"8033908800726\n" +
|
||||
"8021719130026\n" +
|
||||
"8051886470717\n" +
|
||||
"8700216772082\n" +
|
||||
"8033447586204\n" +
|
||||
"8006540891469\n" +
|
||||
"4012400502363\n" +
|
||||
"8051499395889\n" +
|
||||
"8051499393571\n" +
|
||||
"8051499395872\n" +
|
||||
"8034055535387\n" +
|
||||
"8056364996130\n" +
|
||||
"8056364993467\n" +
|
||||
"8007675733877").split("\n")
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (barcodes.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
List<String> articoli = verificaRottura(entry.getKey(), codJfas, dataIspezione, repartiFreschi, tipiEsclusi, fornitori, barcodes);
|
||||
|
||||
/*List<StbActivity> attivitaArticoli = new ArrayList<>();
|
||||
for (String articolo : articoli) {
|
||||
attivitaArticoli.add(getArticoli(null, articolo, tipoAttivitaRotturaStock, codJfas, userNamePv));
|
||||
} */
|
||||
|
||||
List<StbActivity> stbActivityList = new ArrayList<>();
|
||||
for (String activityId : idAttivita) {
|
||||
sql = "select *\n" +
|
||||
"from srl_activity_art\n" +
|
||||
"where activity_id = " + UtilityDB.valueToString(activityId) + "\n";
|
||||
|
||||
List<SrlActivityArt> articoliPresenti = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, SrlActivityArt.class);
|
||||
List<String> artP;
|
||||
if (articoliPresenti != null) {
|
||||
articoliPresenti
|
||||
.stream()
|
||||
.forEach(x -> {
|
||||
if (articoli.contains(x.getCodMart()))
|
||||
x.setOperation(OperationType.UPDATE);
|
||||
else
|
||||
x.setOperation(OperationType.DELETE);
|
||||
});
|
||||
artP = articoliPresenti.stream().map(x -> x.getCodMart()).distinct().collect(Collectors.toList());
|
||||
} else {
|
||||
artP = new ArrayList<>();
|
||||
}
|
||||
|
||||
List<SrlActivityArt> artNew = articoli
|
||||
.stream()
|
||||
.filter(x -> !artP.contains(x))
|
||||
.map(x -> {
|
||||
SrlActivityArt s = new SrlActivityArt().setCodMart(x);
|
||||
s.setOperation(OperationType.INSERT);
|
||||
return s;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
|
||||
StbActivity activityToUpdate = new StbActivity();
|
||||
activityToUpdate.setActivityId(activityId);
|
||||
activityToUpdate.setSrlActivityArt(articoliPresenti);
|
||||
activityToUpdate.getSrlActivityArt().addAll(artNew);
|
||||
activityToUpdate.setOperation(OperationType.UPDATE);
|
||||
stbActivityList.add(activityToUpdate);
|
||||
|
||||
}
|
||||
|
||||
UtilityEntity.throwEntitiesException(entityProcessor.processEntityList(stbActivityList, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> verificaRottura(String codMdep, String codJfas,
|
||||
LocalDate dataCreation,
|
||||
List<String> repartiFreschi,
|
||||
List<String> tipiEsclusi,
|
||||
List<String> fornitori,
|
||||
List<String> barcode) throws Exception {
|
||||
|
||||
String tipoGriglia = setupGest.getSetupDet(multiDBTransactionManager.getPrimaryConnection(), "PVM", "RILEVAZIONI_STEUP", "TIPO_GRIGLIA", codJfas);
|
||||
|
||||
String profileDb = setupGest.getSetupDepo(multiDBTransactionManager.getPrimaryConnection(), "DATI_AZIENDA", "DATI_DEPOSITO", "PROFILE_DB", codMdep);
|
||||
|
||||
String sql = Query.format("SELECT cod_mgrp FROM jrl_fasi_mtb_grup WHERE cod_jfas = %s", codJfas);
|
||||
|
||||
List<String> gruppiMerc = UtilityDB.executeSimpleQueryOnlyFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
String queryAssortimento = "";
|
||||
switch (tipoGriglia) {
|
||||
case "A":
|
||||
queryAssortimento =
|
||||
"SELECT DISTINCT mtb_aart.cod_mart\n" +
|
||||
" FROM mvw_barcode INNER JOIN mtb_aart ON mtb_aart.cod_mart = mvw_barcode.cod_mart \n";
|
||||
break;
|
||||
case "V":
|
||||
queryAssortimento =
|
||||
"SELECT DISTINCT vtb_griglia_art.cod_mart\n" +
|
||||
"FROM vtb_griglia_art\n" +
|
||||
" INNER JOIN mvw_barcode ON vtb_griglia_art.cod_mart = mvw_barcode.cod_mart\n" +
|
||||
" INNER JOIN mtb_aart ON vtb_griglia_art.cod_mart = mtb_aart.cod_mart\n" +
|
||||
"WHERE cod_griglia = [COD_MDEP]\n" +
|
||||
" AND data_validita = [DATA_ISPEZIONE]\n" +
|
||||
" AND (SELECT MAX(data_validita)\n" +
|
||||
" FROM vtb_griglia_art\n" +
|
||||
" WHERE cod_griglia = [COD_MDEP]\n" +
|
||||
" AND data_validita <= [DATA_ISPEZIONE])";
|
||||
|
||||
queryAssortimento = queryAssortimento.replace("[COD_MDEP]", UtilityDB.valueToString(codMdep))
|
||||
.replace("[DATA_ISPEZIONE]", UtilityDB.valueToString(dataCreation));
|
||||
break;
|
||||
}
|
||||
|
||||
queryAssortimento = UtilityDB.addwhereCond(queryAssortimento, "mtb_aart.cod_mgrp IN (" + UtilityDB.listValueToString(gruppiMerc) + ")", false);
|
||||
String whereCondBarcode = "";
|
||||
if (repartiFreschi.contains(codJfas)) {
|
||||
whereCondBarcode = "mvw_barcode.cod_barre not in (" + UtilityDB.listValueToString(barcode) + ")";
|
||||
} else {
|
||||
whereCondBarcode = "mvw_barcode.cod_barre in (" + UtilityDB.listValueToString(barcode) + ")";
|
||||
}
|
||||
queryAssortimento = UtilityDB.addwhereCond(queryAssortimento, whereCondBarcode, false);
|
||||
|
||||
/*Nella query dei kit prendiamo componenti, composti, articoli sostitutivi ( cod_mart_stat) E componeni della distinta*/
|
||||
String queryKit =
|
||||
"SELECT mtb_aart.cod_mart, mtb_aart.cod_mart AS cod_mart_griglia\n" +
|
||||
"FROM mtb_aart\n" +
|
||||
"WHERE mtb_aart.articolo_composto = 'N'\n" +
|
||||
"UNION\n" +
|
||||
"SELECT mtb_aart.cod_mart, mtb_comp.cod_comp AS cod_mart_griglia\n" +
|
||||
"FROM mtb_aart\n" +
|
||||
" INNER JOIN mtb_comp ON mtb_aart.cod_mart = mtb_comp.cod_mart\n" +
|
||||
"WHERE mtb_aart.articolo_composto = 'S'\n" +
|
||||
"UNION\n" +
|
||||
"SELECT mtb_comp.cod_comp, mtb_comp.cod_mart\n" +
|
||||
"FROM mtb_aart\n" +
|
||||
" INNER JOIN mtb_comp ON mtb_aart.cod_mart = mtb_comp.cod_mart\n" +
|
||||
"WHERE mtb_aart.articolo_composto = 'S'\n" +
|
||||
"UNION\n" +
|
||||
"SELECT mtb_aart.cod_mart, mtb_aart.cod_mart_stat\n" +
|
||||
"FROM mtb_aart\n" +
|
||||
"WHERE mtb_aart.cod_mart_stat IS NOT NULL\n" +
|
||||
"UNION\n" +
|
||||
"SELECT cod_prod, cod_mart\n" +
|
||||
"FROM jtb_dist_mate\n" +
|
||||
"WHERE cod_mart IS NOT NULL";
|
||||
|
||||
List<String> articoli = new ArrayList<>();
|
||||
try (MultiDBTransactionManager mdb = new MultiDBTransactionManager(profileDb)) {
|
||||
articoli = UtilityDB.executeSimpleQueryOnlyFirstColumn(mdb.getPrimaryConnection(), queryAssortimento);
|
||||
|
||||
//Eliminazione nuovi inserimenti in griglia
|
||||
String sqlGriglia =
|
||||
"WITH articoli AS ( \n" + queryKit + " ) \n" +
|
||||
"SELECT g.cod_mart\n" +
|
||||
"FROM dbo.getgrigliaacquisto([DATA_CREAZIONE], NULL, [COD_MDEP], NULL, NULL) g\n" +
|
||||
" INNER JOIN mtb_aart ON g.cod_mart = mtb_aart.cod_mart AND mtb_aart.cod_mgrp IN ([GRUPPI_MERC])\n" +
|
||||
" INNER JOIN articoli ON g.cod_mart = articoli.cod_mart_griglia\n" +
|
||||
"WHERE g.tipo_variazione = 'I'\n" +
|
||||
" AND g.data_validita >= DATEADD(DAY, -7, [DATA_CREAZIONE]) ";
|
||||
|
||||
sqlGriglia = sqlGriglia
|
||||
.replace("[DATA_CREAZIONE]", UtilityDB.valueToString(dataCreation))
|
||||
.replace("[COD_MDEP]", UtilityDB.valueToString(codMdep))
|
||||
.replace("[COD_JFAS]", UtilityDB.valueToString(codJfas))
|
||||
.replace("[GRUPPI_MERC]", UtilityDB.listValueToString(gruppiMerc));
|
||||
|
||||
if (!tipiEsclusi.isEmpty()) {
|
||||
sqlGriglia = UtilityDB.addwhereCond(sqlGriglia, "(mtb_aart.cod_mtip IS NULL OR mtb_aart.cod_mtip not in (" + UtilityDB.listValueToString(tipiEsclusi) + "))", true);
|
||||
}
|
||||
|
||||
List<String> nuoviInserimenti = UtilityDB.executeSimpleQueryOnlyFirstColumn(mdb.getPrimaryConnection(), sqlGriglia);
|
||||
|
||||
articoli = articoli.stream()
|
||||
.filter(x -> !nuoviInserimenti.contains(x))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
//Verifica Inevasi
|
||||
String sqlInevasi =
|
||||
"WITH articoli AS (" + queryKit + ")\n" +
|
||||
"SELECT DISTINCT articoli.cod_mart\n" +
|
||||
"FROM dtb_ordt\n" +
|
||||
" INNER JOIN dtb_ordr ON dtb_ordt.gestione = dtb_ordr.gestione\n" +
|
||||
" AND dtb_ordt.data_ord = dtb_ordr.data_ord\n" +
|
||||
" AND dtb_ordt.num_ord = dtb_ordr.num_ord\n" +
|
||||
" INNER JOIN gtb_anag ON dtb_ordt.cod_anag = gtb_anag.cod_anag\n" +
|
||||
" INNER JOIN mtb_aart ON dtb_ordr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" INNER JOIN articoli ON mtb_aart.cod_mart = articoli.cod_mart_griglia\n" +
|
||||
"WHERE dtb_ordt.gestione = 'A'\n" +
|
||||
" AND dtb_ordt.flag_annulla = 'N'\n" +
|
||||
" AND gtb_anag.part_iva IN ([ELENCO_FORNITORI])\n" +
|
||||
" AND dtb_ordt.cod_mdep = [COD_MDEP]\n" +
|
||||
" AND dtb_ordt.data_esportazione IS NOT NULL\n" +
|
||||
" AND mtb_aart.cod_mgrp IN ( [GRUPPI_MERC] ) \n" +
|
||||
" AND dtb_ordr.qta_evasa = 0\n" +
|
||||
" AND dtb_ordr.data_cons BETWEEN DATEADD(DAY, -7, [DATA_ISPEZIONE]) AND [DATA_ISPEZIONE]\n";
|
||||
|
||||
sqlInevasi =
|
||||
sqlInevasi
|
||||
.replace("[DATA_ISPEZIONE]", UtilityDB.valueToString(dataCreation))
|
||||
.replace("[COD_MDEP]", UtilityDB.valueToString(codMdep))
|
||||
.replace("[GRUPPI_MERC]", UtilityDB.listValueToString(gruppiMerc))
|
||||
.replace("[ELENCO_FORNITORI]", UtilityDB.listValueToString(fornitori));
|
||||
|
||||
if (!tipiEsclusi.isEmpty()) {
|
||||
sqlInevasi = UtilityDB.addwhereCond(sqlInevasi, "(mtb_aart.cod_mtip IS NULL OR mtb_aart.cod_mtip not in (" + UtilityDB.listValueToString(tipiEsclusi) + "))", true);
|
||||
}
|
||||
|
||||
List<String> inevasi = UtilityDB.executeSimpleQueryOnlyFirstColumn(mdb.getPrimaryConnection(), sqlInevasi);
|
||||
|
||||
articoli = articoli.stream()
|
||||
.filter(x -> !inevasi.contains(x))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return articoli;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,403 @@
|
||||
package it.integry.ems.activity.service;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.ems.activity.dto.ActivityDTO;
|
||||
import it.integry.ems.activity.dto.ActivityTaskDTO;
|
||||
import it.integry.ems.activity.dto.Task.TaskMemoRequestDTO;
|
||||
import it.integry.ems.activity.utility.TaskUtility;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.order.crm.service.CrmService;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
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.db.ResultSetMapper;
|
||||
import it.integry.ems_model.entity.StbActivity;
|
||||
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.UtilityHashMap;
|
||||
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;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Scope("request")
|
||||
public class TaskService {
|
||||
|
||||
@Autowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
|
||||
@Autowired
|
||||
private EntityProcessor entityProcessor;
|
||||
|
||||
@Autowired
|
||||
private CrmService crmService;
|
||||
|
||||
@Autowired
|
||||
private RequestDataDTO requestDataDTO;
|
||||
|
||||
public List<ActivityDTO> getActivity(boolean isTable, boolean daInstallare, String activityId, Integer year) throws Exception {
|
||||
String username = requestDataDTO.getUsername();
|
||||
|
||||
String sql = Query.format("SELECT case when key_group = 3 THEN IsNull(user_name_rif, user_name) ELSE user_name END AS user_name, \n" +
|
||||
"CAST( case when key_group = 3 THEN 1 ELSE 0 END as BIT) as isCliente,\n" +
|
||||
"CAST( case when key_group = 3 and user_name_rif is not null THEN 1 ELSE 0 END as BIT) as isPersonaRif FROM stb_user WHERE user_name = %s", username);
|
||||
|
||||
HashMap<String, Object> datiUtente = UtilityDB.executeSimpleQueryOnlyFirstRow(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
boolean isPersonaRif = false;
|
||||
boolean isCliente = false;
|
||||
if (!datiUtente.isEmpty()) {
|
||||
username = UtilityHashMap.getValueIfExists(datiUtente, "user_name");
|
||||
isCliente = UtilityHashMap.getValueIfExists(datiUtente, "isCliente");
|
||||
isPersonaRif = UtilityHashMap.getValueIfExists(datiUtente, "isPersonaRif");
|
||||
}
|
||||
|
||||
sql = "WITH escludi_commesse AS (SELECT value cod_jcom\n" +
|
||||
" FROM string_split((SELECT value\n" +
|
||||
" FROM stb_gest_setup\n" +
|
||||
" WHERE gest_name = 'STB_ACTIVITY'\n" +
|
||||
" AND section = 'SETUP'\n" +
|
||||
" AND key_section = 'ESCLUDI_COMMESSE'), '|') s)\n" +
|
||||
" SELECT stb_activity.cod_jcom as 'Commessa',\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" stb_activity.activity_id as 'Id_Attivita',\n" +
|
||||
" stb_activity.parent_activity_id,\n" +
|
||||
" stb_activity.activity_description as 'Descrizione',\n" +
|
||||
" stb_activity.estimated_time as 'Data_Inizio_prev',\n" +
|
||||
" stb_activity.estimated_endtime as 'data_fine_prev',\n" +
|
||||
" stb_activity.effective_time as 'Data_Inizio_Effettiva',\n" +
|
||||
" stb_activity.effective_endtime as 'Data_Fine_Effettiva',\n" +
|
||||
" stb_activity.flag_risolto,\n" +
|
||||
" stb_activity.estimated_hours as 'Ore_Stimate',\n" +
|
||||
" CAST(CASE WHEN stb_activity.effective_endtime IS NULL THEN 0 ELSE 1 END AS BIT) AS attivita_chiusa, \n" +
|
||||
" stb_activity.activity_result_id AS Esito,\n" +
|
||||
" stb_activity.result_description AS descr_esito,\n" +
|
||||
" ISNULL(stb_activity.priorita, 0) AS priorita,\n" +
|
||||
" stb_activity.activity_type_id AS tipo_attivita,\n" +
|
||||
" IsNull(stb_activity.ora_ins_act, stb_activity.data_ins_act) AS data_inserimento,\n" +
|
||||
" stb_activity.ora_mod_act AS ultima_modifica,\n" +
|
||||
" stb_activity.user_modifier AS user_modifier,\n" +
|
||||
" CASE WHEN estimated_enddate is null then 0\n" +
|
||||
" WHEN estimated_enddate < CAST(GETDATE() AS DATE) THEN 4\n" +
|
||||
" WHEN estimated_enddate between DATEADD(WEEK, DATEDIFF(WEEK, 0, GETDATE()), 0) AND DATEADD(DAY, 6, DATEADD(WEEK, DATEDIFF(WEEK, 0, GETDATE()), 0)) THEN 3\n" +
|
||||
" WHEN estimated_enddate between DATEADD(WEEK, DATEDIFF(WEEK, 0, GETDATE()) + 1, 0) and DATEADD(DAY, 6, DATEADD(WEEK, DATEDIFF(WEEK, 0, GETDATE()) + 1, 0)) THEN 2\n " +
|
||||
" ELSE 1 END AS stato_scadenza,\n" +
|
||||
" stb_activity.persona_rif AS 'richiedente',\n" +
|
||||
" stb_activity.estimated_enddate,\n" +
|
||||
" stb_activity.cod_mart AS cod_mart,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN stb_activity.cod_mart IS NULL THEN 'NESSUN PRODOTTO'\n" +
|
||||
" ELSE ISNULL(mtb_aart.descr_cassa, mtb_aart.descrizione) END AS descr_prodotto,\n" +
|
||||
" stb_activity.user_creator,\n" +
|
||||
" stb_activity.note,\n" +
|
||||
" stb_user.full_name as 'Responsabile',\n" +
|
||||
" parent.responabile_progetto,\n" +
|
||||
" ISNULL(parent.project_description, '') AS 'project_description',\n" +
|
||||
" ISNULL(parent.activity_description, 'Altre Attività') AS 'parent_activity_description',\n" +
|
||||
" creator.full_name AS 'creata_da',\n" +
|
||||
" parent.activity_type_id AS 'parent_activity_type',\n" +
|
||||
" dbo.f_integry_gestStatusTask(stb_activity.activity_result_id) AS stato_attivita,\n" +
|
||||
" CAST(ISNULL(integry_tag.is_bug, 0) AS BIT) AS is_bug,\n" +
|
||||
" integry_tag.tags,\n" +
|
||||
" DENSE_RANK() OVER (ORDER BY parent.project_description, parent.activity_description) AS id_processo,\n" +
|
||||
" gtb_anag.rag_soc,\n " +
|
||||
" task.dapagare AS da_pagare,\n " +
|
||||
" task.acanone AS a_canone\n ";
|
||||
if (daInstallare) {
|
||||
sql += ", CAST(lastUpdt.data AS DATETIME) AS ultimo_aggiornamento\n";
|
||||
} else {
|
||||
sql += ", CAST(NULL AS DATETIME) AS ultimo_aggiornamento\n";
|
||||
}
|
||||
sql += " FROM stb_activity\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n" +
|
||||
" INNER JOIN stb_user creator ON stb_activity.user_creator = creator.user_name\n" +
|
||||
" LEFT OUTER JOIN pvw_clienti_prospect gtb_anag on stb_activity.cod_anag = gtb_anag.cod_ppro and stb_activity.tipo_anag = gtb_anag.tipologia\n" +
|
||||
" AND gtb_anag.flag_stato = 'A'\n" +
|
||||
" LEFT OUTER JOIN mtb_aart ON stb_activity.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" LEFT OUTER JOIN (SELECT parent.activity_description AS project_description,\n" +
|
||||
" stb_activity.activity_description AS activity_description,\n" +
|
||||
" stb_activity.activity_id,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" stb_activity.activity_type_id,\n" +
|
||||
" stb_activity.persona_rif AS responabile_progetto\n" +
|
||||
" FROM stb_activity\n" +
|
||||
" LEFT OUTER JOIN stb_activity parent\n" +
|
||||
" ON stb_activity.parent_activity_id = parent.activity_id\n" +
|
||||
" WHERE stb_activity.flag_tipologia = 'P') parent\n" +
|
||||
" ON stb_activity.parent_activity_id = parent.activity_id\n" +
|
||||
" LEFT OUTER JOIN stb_activity_result\n" +
|
||||
" ON stb_activity.activity_result_id = stb_activity_result.activity_result_id\n" +
|
||||
" LEFT OUTER JOIN integry_tag ON stb_activity.activity_id = integry_tag.activity_id \n" +
|
||||
" OUTER APPLY ( SELECT CAST(MAX(CASE WHEN task.cod_jfas <> 'C01' THEN 0 ELSE 1 END) AS BIT) AS daPagare,\n" +
|
||||
" CAST(MAX(CASE WHEN task.cod_jfas = 'C01' THEN 0 ELSE 1 END) AS BIT) AS aCanone \n" +
|
||||
" FROM stb_activity task WHERE stb_activity.activity_id = task.parent_activity_id) task ";
|
||||
|
||||
if (daInstallare) {
|
||||
sql += " LEFT OUTER JOIN integry_last_upd_clie lastUpdt ON stb_activity.cod_anag = lastUpdt.cod_anag\n";
|
||||
}
|
||||
|
||||
sql += " WHERE stb_activity.flag_tipologia = 'P'\n" +
|
||||
" AND NOT EXISTS(SELECT *\n" +
|
||||
" FROM escludi_commesse\n" +
|
||||
" WHERE stb_activity.cod_jcom = escludi_commesse.cod_jcom)\n" +
|
||||
" AND EXISTS (SELECT *\n" +
|
||||
" FROM srl_activity_type inner join stb_activity_type a on srl_activity_type.activity_type_id_next = a.activity_type_id\n" +
|
||||
" WHERE stb_activity.activity_type_id = srl_activity_type.activity_type_id\n" +
|
||||
" and srl_activity_type.flag_tipologia = 'P' \n";
|
||||
if (activityId == null) {
|
||||
sql += " and srl_activity_type.flag_tipologia_next = 'A' \n";
|
||||
}
|
||||
sql += " and a.flag_attiva = 's'\n" +
|
||||
" GROUP BY srl_activity_type.activity_type_id\n" +
|
||||
" HAVING sum(IIF(flag_tipologia_next = 'A',0,1)) = 0 )\n ";
|
||||
|
||||
if (year == null && activityId == null) {
|
||||
sql += " AND EXISTS (SELECT *\n" +
|
||||
" FROM jtb_comt\n" +
|
||||
" WHERE stato_commessa IN ('IN CORSO', 'POST VENDITA', 'TRATTATIVA')\n" +
|
||||
" AND stb_activity.cod_jcom = jtb_comt.cod_jcom) \n";
|
||||
} else if (activityId == null) {
|
||||
sql += " AND EXISTS (SELECT *\n" +
|
||||
" FROM jtb_comt\n" +
|
||||
" WHERE stato_commessa = 'CHIUSA'\n" +
|
||||
" AND (YEAR(data_inizi_lav) = " + year + " OR YEAR(data_cons) = " + year + ")\n" +
|
||||
" AND stb_activity.cod_jcom = jtb_comt.cod_jcom )\n";
|
||||
}
|
||||
|
||||
if (!isTable) {
|
||||
sql += " AND stb_activity.effective_endtime IS NULL " +
|
||||
" AND stb_activity.activity_type_id <> 'AGGIORNAMENTI SOFTWARE'";
|
||||
|
||||
if (daInstallare) {
|
||||
sql += " AND stb_activity.activity_result_id = 'DA INSTALLARE' AND cod_jcom not like 'INTEGRY%'";
|
||||
}
|
||||
} else if (activityId != null) {
|
||||
sql += " AND stb_activity.activity_id = " + UtilityDB.valueToString(activityId);
|
||||
} else if (isCliente) {
|
||||
sql += " AND stb_activity.activity_result_id NOT IN ('ANNULLATA', 'SOSPESA')";
|
||||
|
||||
if (isPersonaRif) {
|
||||
String whereCondPersRif =
|
||||
Query.format(" AND EXISTS( SELECT *\n" +
|
||||
" from stb_user s inner join vtb_clie_pers_rif on s.e_mail = vtb_clie_pers_rif.e_mail\n" +
|
||||
" where S.USER_NAME = %s and vtb_clie_pers_rif.persona_rif = stb_activity.persona_rif)",
|
||||
requestDataDTO.getUsername());
|
||||
sql += whereCondPersRif;
|
||||
}
|
||||
}
|
||||
|
||||
List<ActivityDTO> activityDTOS = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ActivityDTO.class);
|
||||
|
||||
if (activityDTOS != null) {
|
||||
List<String> elencoId = Stream.of(activityDTOS).map(ActivityDTO::getIdAttivita).toList();
|
||||
sql =
|
||||
"SELECT stb_activity.parent_activity_id,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" stb_user.full_name,\n" +
|
||||
" MAX(IIF(effective_date <= CAST(GETDATE() AS DATE), effective_date, NULL)) AS last_activity_date,\n" +
|
||||
" MIN(IIF(estimated_date >= CAST(GETDATE() AS DATE), estimated_date, NULL)) AS next_activity_date,\n" +
|
||||
" MAX(IIF(((estimated_date BETWEEN dbo.f_getfirstdayofweek(GETDATE()) AND dbo.f_getlastdayofweek(GETDATE()) OR\n" +
|
||||
" estimated_date IS NULL) AND effective_date IS NULL), stb_activity.activity_description,\n" +
|
||||
" NULL)) AS activity_description,\n" +
|
||||
" CAST(MAX(IIF(\n" +
|
||||
" ISNULL(effective_date, estimated_date) BETWEEN dbo.f_getfirstdayofweek(GETDATE()) AND dbo.f_getlastdayofweek(GETDATE()),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS planned_this_week,\n" +
|
||||
" CAST(MAX(IIF(\n" +
|
||||
" ISNULL(effective_date, estimated_date) BETWEEN dbo.f_getfirstdayofweek(DATEADD(WEEK, -1, GETDATE())) AND dbo.f_getlastdayofweek(DATEADD(WEEK, -1, GETDATE())),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS planned_previous_week,\n" +
|
||||
" CAST(MAX(IIF(\n" +
|
||||
" ISNULL(effective_date, estimated_date) BETWEEN dbo.f_getfirstdayofweek(DATEADD(WEEK, 1, GETDATE())) AND dbo.f_getlastdayofweek(DATEADD(WEEK, 1, GETDATE())),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS planned_next_week,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND\n" +
|
||||
" effective_date BETWEEN dbo.f_getfirstdayofmonth(GETDATE()) AND EOMONTH(GETDATE()), 1,\n" +
|
||||
" 0)) AS BIT) AS done_this_month,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND\n" +
|
||||
" effective_date BETWEEN dbo.f_getfirstdayofmonth(DATEADD(MONTH, -1, GETDATE())) AND EOMONTH(DATEADD(MONTH, -1, GETDATE())),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS done_previous_month,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND\n" +
|
||||
" DATEPART(QUARTER, effective_date) = DATEPART(QUARTER, GETDATE()), 1,\n" +
|
||||
" 0)) AS BIT) AS done_this_quarter,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND DATEPART(QUARTER, effective_date) =\n" +
|
||||
" DATEPART(QUARTER, DATEADD(MONTH, -3, GETDATE())), 1,\n" +
|
||||
" 0)) AS BIT) AS done_previous_quarter,\n" +
|
||||
" SUM(jtb_rlavr.ore) AS ore_fatte,\n" +
|
||||
" min(dbo.f_integry_gestStatusTask(stb_activity.activity_result_id)) AS activity_status \n" +
|
||||
"FROM stb_activity\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n" +
|
||||
" LEFT OUTER JOIN jtb_rlavr ON stb_activity.activity_id = jtb_rlavr.activity_id\n" +
|
||||
"WHERE stb_activity.flag_tipologia = 'A'\n" +
|
||||
" AND stb_activity.parent_activity_id IN (" + UtilityDB.listValueToString(elencoId) + ")\n" +
|
||||
"GROUP BY stb_activity.parent_activity_id,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" stb_user.full_name";
|
||||
|
||||
List<ActivityDTO.WorkedHours> activityResponseDtoWorkedHours = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ActivityDTO.WorkedHours.class);
|
||||
|
||||
if (activityResponseDtoWorkedHours != null) {
|
||||
final HashMap<String, List<ActivityDTO.WorkedHours>> subActivityList = activityResponseDtoWorkedHours.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
ActivityDTO.WorkedHours::getParentActivityId,
|
||||
LinkedHashMap::new,
|
||||
Collectors.toList()
|
||||
));
|
||||
|
||||
for (ActivityDTO activityResponse : activityDTOS) {
|
||||
if (subActivityList.containsKey(activityResponse.getIdAttivita())) {
|
||||
List<ActivityDTO.WorkedHours> workedHours = subActivityList.get(activityResponse.getIdAttivita());
|
||||
|
||||
for (ActivityDTO.WorkedHours workedHour : workedHours) {
|
||||
if (workedHour.getActivityDescription() != null &&
|
||||
workedHour.getActivityDescription().equals(activityResponse.getDescrizione())) {
|
||||
workedHour.setActivityDescription(null);
|
||||
}
|
||||
}
|
||||
|
||||
activityResponse.setWorkedHours(workedHours);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return activityDTOS;
|
||||
}
|
||||
|
||||
public List<ActivityTaskDTO> getActivityTasks(String activityId, String username, Date effectiveDateStart, Date effectiveDateEnd) throws Exception {
|
||||
String sql = "SELECT stb_activity.activity_id,\n" +
|
||||
" stb_activity.cod_jcom,\n" +
|
||||
" stb_activity.activity_type_id,\n" +
|
||||
" stb_activity.parent_activity_id,\n" +
|
||||
" activity_description,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" full_name,\n" +
|
||||
" effective_date,\n" +
|
||||
" activity_result_id,\n" +
|
||||
" result_description,\n" +
|
||||
" SUM(ore) ore_lav,\n" +
|
||||
" stb_activity.note,\n" +
|
||||
" estimated_date,\n" +
|
||||
" estimated_time,\n" +
|
||||
" estimated_endtime,\n" +
|
||||
" effective_time,\n" +
|
||||
" effective_endtime\n" +
|
||||
"FROM stb_activity\n" +
|
||||
" LEFT OUTER JOIN jtb_rlavr ON stb_activity.activity_id = jtb_rlavr.activity_id\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n";
|
||||
|
||||
List<String> conditions = new ArrayList<>();
|
||||
|
||||
if (activityId != null && !activityId.isEmpty()) {
|
||||
conditions.add("stb_activity.parent_activity_id = " + UtilityDB.valueToString(activityId));
|
||||
} else {
|
||||
conditions.add("stb_activity.user_name LIKE " + UtilityDB.valueToString(username));
|
||||
}
|
||||
|
||||
if (effectiveDateStart != null && effectiveDateEnd != null) {
|
||||
conditions.add("effective_date BETWEEN " +
|
||||
UtilityDB.valueToString(effectiveDateStart) + " AND " +
|
||||
UtilityDB.valueToString(effectiveDateEnd));
|
||||
}
|
||||
|
||||
conditions.add("stb_activity.flag_tipologia = 'A'");
|
||||
|
||||
sql += "WHERE " + String.join(" AND ", conditions);
|
||||
|
||||
sql += "\nGROUP BY stb_activity.activity_id, stb_activity.cod_jcom, stb_activity.activity_type_id, stb_activity.parent_activity_id, activity_description, stb_activity.user_name, full_name, effective_date, activity_result_id, result_description, stb_activity.note, estimated_date, estimated_time, estimated_endtime, effective_time, effective_endtime";
|
||||
|
||||
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ActivityTaskDTO.class);
|
||||
}
|
||||
|
||||
public List<ActivityTaskDTO> getActivityCalendar(String username, String startDate, String endDate) throws Exception {
|
||||
String sql = Query.format(
|
||||
"WITH progetto AS (SELECT stb_activity.activity_id, stb_activity.activity_type_id\n" +
|
||||
" FROM stb_activity\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n" +
|
||||
" LEFT OUTER JOIN jtb_rlavr ON stb_activity.activity_id = jtb_rlavr.activity_id\n" +
|
||||
" AND stb_activity.user_name = %s\n" +
|
||||
" GROUP BY stb_activity.activity_id, stb_activity.activity_type_id)\n" +
|
||||
"\n" +
|
||||
"SELECT stb_activity.activity_id,\n" +
|
||||
" stb_activity.cod_jcom,\n" +
|
||||
" stb_activity.parent_activity_id,\n" +
|
||||
" progetto.activity_type_id AS 'parent_activity_type_id',\n" +
|
||||
" stb_activity.activity_type_id,\n" +
|
||||
" activity_description,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" full_name,\n" +
|
||||
" activity_result_id,\n" +
|
||||
" result_description,\n" +
|
||||
" SUM(ore) AS ore_lav,\n" +
|
||||
" stb_activity.note,\n" +
|
||||
" estimated_time,\n" +
|
||||
" estimated_endtime,\n" +
|
||||
" ISNULL(jtb_rlavr.da_ora, effective_time) AS effective_time,\n" +
|
||||
" ISNULL(jtb_rlavr.a_ora, effective_endtime) AS effective_endtime\n" +
|
||||
"FROM stb_activity\n" +
|
||||
" LEFT OUTER JOIN jtb_rlavr ON stb_activity.activity_id = jtb_rlavr.activity_id\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n" +
|
||||
" LEFT OUTER JOIN progetto ON stb_activity.parent_activity_id = progetto.activity_id\n" +
|
||||
"WHERE stb_activity.flag_tipologia = 'A'\n" +
|
||||
" AND stb_activity.user_name = %s\n" +
|
||||
" AND (estimated_date BETWEEN %s AND %s\n" +
|
||||
" OR CAST(ISNULL(jtb_rlavr.da_ora, effective_time) AS DATE) BETWEEN %s AND %s)\n" +
|
||||
"GROUP BY stb_activity.activity_id, stb_activity.cod_jcom, stb_activity.parent_activity_id,\n" +
|
||||
" progetto.activity_type_id, stb_activity.activity_type_id, activity_description,\n" +
|
||||
" stb_activity.user_name, full_name, activity_result_id, result_description, stb_activity.note,\n" +
|
||||
" estimated_time, estimated_endtime, ISNULL(jtb_rlavr.da_ora, effective_time),\n" +
|
||||
" ISNULL(jtb_rlavr.a_ora, effective_endtime)",
|
||||
username, username, startDate, endDate, startDate, endDate
|
||||
);
|
||||
|
||||
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ActivityTaskDTO.class);
|
||||
}
|
||||
|
||||
public boolean deleteActivity(String activityId, boolean deleteSubActivity) throws Exception {
|
||||
StbActivity activity = new StbActivity().setActivityId(activityId);
|
||||
|
||||
if (deleteSubActivity) {
|
||||
List<StbActivity> stbActivityList = new ArrayList<>();
|
||||
|
||||
List<ActivityTaskDTO> activityTasks = getActivityTasks(activityId, null, null, null);
|
||||
for (ActivityTaskDTO activityTask : activityTasks) {
|
||||
StbActivity stbActivity = new StbActivity().setActivityId(activityTask.getActivityId());
|
||||
|
||||
stbActivity.setOperation(OperationType.DELETE);
|
||||
stbActivityList.add(stbActivity);
|
||||
}
|
||||
|
||||
entityProcessor.processEntityList(stbActivityList, true);
|
||||
}
|
||||
|
||||
activity.setOperation(OperationType.DELETE);
|
||||
entityProcessor.processEntity(activity, multiDBTransactionManager);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public ActivityTaskDTO insertOrUpdateMemo(TaskMemoRequestDTO taskMemoRequest) throws Exception {
|
||||
StbActivity activity = TaskUtility.buildStbActivityFromActivityTask(
|
||||
multiDBTransactionManager.getPrimaryConnection(),
|
||||
taskMemoRequest.getActivityTaskDTO()
|
||||
).setAlarmTime(
|
||||
taskMemoRequest.getNotificationDate() == null ?
|
||||
EmsRestConstants.LOCAL_DATE_TIME_NULL : taskMemoRequest.getNotificationDate()
|
||||
);
|
||||
|
||||
activity.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
entityProcessor.processEntity(activity, multiDBTransactionManager);
|
||||
|
||||
crmService.createActivityNotification(activity);
|
||||
|
||||
return TaskUtility.buildActivityTaskFromStbActivity(activity);
|
||||
}
|
||||
}
|
||||
@@ -57,21 +57,54 @@ public class UserAbsenceService {
|
||||
@Autowired
|
||||
private RequestDataDTO requestDataDTO;
|
||||
|
||||
public List<AssenzaDTO> retrieveAssenze(LocalDate startDate, LocalDate endDate) throws Exception {
|
||||
String sql = Query.format(
|
||||
"SELECT jrl_flav_users.user_name,\n" +
|
||||
" data_lav,\n" +
|
||||
" jtb_rlavt.giustificativo,\n" +
|
||||
" jtb_rlavt.note,\n" +
|
||||
" jtb_rlavt.ore_assenza,\n" +
|
||||
" jtb_rlavt.cod_jflav\n" +
|
||||
"FROM jtb_rlavt\n" +
|
||||
" LEFT OUTER JOIN jrl_flav_users\n" +
|
||||
" ON jrl_flav_users.cod_jflav = jtb_rlavt.cod_jflav AND jrl_flav_users.flag_jflav_default = 'S'\n" +
|
||||
"WHERE giustificativo IS NOT NULL\n" +
|
||||
" AND jtb_rlavt.data_lav BETWEEN %s AND %s",
|
||||
startDate, endDate
|
||||
);
|
||||
public List<AssenzaDTO> retrieveAssenze(String username, LocalDate startDate, LocalDate endDate) throws Exception {
|
||||
String sql;
|
||||
|
||||
if (startDate != null && endDate != null) {
|
||||
sql = Query.format(
|
||||
"SELECT jrl_flav_users.user_name,\n" +
|
||||
" data_lav,\n" +
|
||||
" jtb_rlavt.giustificativo,\n" +
|
||||
" jtb_rlavt.note,\n" +
|
||||
" jtb_rlavt.ore_assenza,\n" +
|
||||
" jtb_rlavt.cod_jflav\n" +
|
||||
"FROM jtb_rlavt\n" +
|
||||
" LEFT OUTER JOIN jrl_flav_users\n" +
|
||||
" ON jrl_flav_users.cod_jflav = jtb_rlavt.cod_jflav AND jrl_flav_users.flag_jflav_default = 'S'\n" +
|
||||
"WHERE giustificativo IS NOT NULL\n" +
|
||||
" AND jtb_rlavt.data_lav BETWEEN %s AND %s",
|
||||
startDate, endDate
|
||||
);
|
||||
} else {
|
||||
sql = "SELECT jrl_flav_users.user_name,\n" +
|
||||
" data_lav,\n" +
|
||||
" jtb_rlavt.giustificativo,\n" +
|
||||
" jtb_rlavt.note,\n" +
|
||||
" jtb_rlavt.ore_assenza,\n" +
|
||||
" jtb_rlavt.cod_jflav\n" +
|
||||
"FROM jtb_rlavt\n" +
|
||||
" LEFT OUTER JOIN jrl_flav_users\n" +
|
||||
" ON jrl_flav_users.cod_jflav = jtb_rlavt.cod_jflav AND jrl_flav_users.flag_jflav_default = 'S'\n" +
|
||||
" INNER JOIN jtb_giustifica ON jtb_rlavt.giustificativo = jtb_giustifica.giustificativo\n" +
|
||||
"WHERE jtb_rlavt.giustificativo IS NOT NULL\n" +
|
||||
" AND flag_recupero = 'N'\n";
|
||||
|
||||
if (startDate != null) {
|
||||
sql += Query.format(
|
||||
" AND jtb_rlavt.data_lav >= %s\n",
|
||||
startDate
|
||||
);
|
||||
} else if (endDate != null) {
|
||||
sql += Query.format(
|
||||
" AND jtb_rlavt.data_lav <= %s\n",
|
||||
endDate
|
||||
);
|
||||
}
|
||||
|
||||
if (username != null) {
|
||||
sql += Query.format(" AND user_name = %s\n", username);
|
||||
}
|
||||
}
|
||||
|
||||
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, AssenzaDTO.class);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package it.integry.ems.activity.service;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.activity.dto.UserWorkHoursClockHistoryDTO;
|
||||
import it.integry.ems.activity.dto.UserWorkHoursClockInRequestDTO;
|
||||
import it.integry.ems.activity.dto.UserWorkHoursClockOutRequestDTO;
|
||||
import it.integry.ems.activity.dto.UserWorkHoursStatusDTO;
|
||||
import it.integry.ems.activity.dto.*;
|
||||
import it.integry.ems.exception.PrimaryDatabaseNotPresentException;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.googleCloudApi.service.GeocodingService;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.system.service.SystemService;
|
||||
import it.integry.ems.user.dto.UserDTO;
|
||||
@@ -21,6 +19,7 @@ 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.googleCloudApi.dto.IndirizzoDTO;
|
||||
import it.integry.firebase.dto.MessageDTO;
|
||||
import it.integry.firebase.dto.NotificationDTO;
|
||||
import it.integry.firebase.dto.android.AndroidConfigDTO;
|
||||
@@ -28,8 +27,6 @@ import it.integry.firebase.dto.android.AndroidNotificationDTO;
|
||||
import it.integry.firebase.dto.apns.ApnsConfigDTO;
|
||||
import it.integry.firebase.dto.apns.ApsDTO;
|
||||
import it.integry.firebase.service.NotificationService;
|
||||
import it.integry.googleCloudApi.dto.IndirizzoDTO;
|
||||
import it.integry.googleCloudApi.service.GeocodingService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -72,11 +69,22 @@ public class UserWorkHoursService {
|
||||
private GeocodingService geocodingService;
|
||||
|
||||
public void clockIn(String username, UserWorkHoursClockInRequestDTO userWorkHoursClockInRequestDTO) throws Exception {
|
||||
if (!userWorkHoursClockInRequestDTO.isValidPosition())
|
||||
throw new Exception("Posizione di ingresso non valida");
|
||||
IndirizzoDTO positionFromCoords = new IndirizzoDTO();
|
||||
|
||||
if (userWorkHoursClockInRequestDTO.isValidPosition()) {
|
||||
positionFromCoords = geocodingService.getPositionFromCoords(
|
||||
multiDBTransactionManager,
|
||||
userWorkHoursClockInRequestDTO.getPositionLatitude(),
|
||||
userWorkHoursClockInRequestDTO.getPositionLongitude()
|
||||
);
|
||||
}
|
||||
|
||||
String codJflav = userService.retrieveCodJflav(username);
|
||||
UserWorkHoursStatusDTO userWorkHoursStatusDTO = retrieveUltimaTimbratura(codJflav, userWorkHoursClockInRequestDTO.getTimestamp() != null ? userWorkHoursClockInRequestDTO.getTimestamp().toLocalDate() : LocalDate.now());
|
||||
UserWorkHoursStatusDTO userWorkHoursStatusDTO = retrieveUltimaTimbratura(
|
||||
codJflav,
|
||||
userWorkHoursClockInRequestDTO.getTimestamp() != null ?
|
||||
userWorkHoursClockInRequestDTO.getTimestamp().toLocalDate() : LocalDate.now()
|
||||
);
|
||||
|
||||
if (userWorkHoursStatusDTO != null && userWorkHoursStatusDTO.isUserInside()) {
|
||||
throw new Exception("E' già presente un ingresso effettuato il " +
|
||||
@@ -87,15 +95,12 @@ public class UserWorkHoursService {
|
||||
JtbRLavt jtbRLavt = new JtbRLavt()
|
||||
.setCodJflav(codJflav)
|
||||
.setDataLav(userWorkHoursClockInRequestDTO.getTimestamp() != null ?
|
||||
userWorkHoursClockInRequestDTO.getTimestamp().toLocalDate() :LocalDate.now())
|
||||
userWorkHoursClockInRequestDTO.getTimestamp().toLocalDate() : LocalDate.now())
|
||||
.setInseritoDa(username)
|
||||
.setCodDiviCont(retrieveDefaultCodDiviCont());
|
||||
|
||||
jtbRLavt.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
final IndirizzoDTO positionFromCoords =
|
||||
geocodingService.getPositionFromCoords(multiDBTransactionManager, userWorkHoursClockInRequestDTO.getPositionLatitude(), userWorkHoursClockInRequestDTO.getPositionLongitude());
|
||||
|
||||
JtbRLavr jtbRLavr = new JtbRLavr()
|
||||
.setDaOra(userWorkHoursClockInRequestDTO.getTimestamp() != null ?
|
||||
userWorkHoursClockInRequestDTO.getTimestamp() : LocalDateTime.now())
|
||||
@@ -111,17 +116,27 @@ public class UserWorkHoursService {
|
||||
|
||||
|
||||
public void clockOut(String username, UserWorkHoursClockOutRequestDTO userWorkHoursClockOutRequestDTO) throws Exception {
|
||||
if (!userWorkHoursClockOutRequestDTO.isValidPosition())
|
||||
throw new Exception("Posizione di uscita non valida");
|
||||
IndirizzoDTO positionFromCoords = new IndirizzoDTO();
|
||||
|
||||
if (userWorkHoursClockOutRequestDTO.isValidPosition()) {
|
||||
positionFromCoords = geocodingService.getPositionFromCoords(
|
||||
multiDBTransactionManager,
|
||||
userWorkHoursClockOutRequestDTO.getPositionLatitude(),
|
||||
userWorkHoursClockOutRequestDTO.getPositionLongitude()
|
||||
);
|
||||
}
|
||||
|
||||
String codJflav = userService.retrieveCodJflav(username);
|
||||
UserWorkHoursStatusDTO userWorkHoursStatusDTO = retrieveUltimaTimbratura(codJflav, userWorkHoursClockOutRequestDTO.getTimestamp() != null ? userWorkHoursClockOutRequestDTO.getTimestamp().toLocalDate() : LocalDate.now());
|
||||
UserWorkHoursStatusDTO userWorkHoursStatusDTO = retrieveUltimaTimbratura(
|
||||
codJflav,
|
||||
userWorkHoursClockOutRequestDTO.getTimestamp() != null ?
|
||||
userWorkHoursClockOutRequestDTO.getTimestamp().toLocalDate() : LocalDate.now()
|
||||
);
|
||||
|
||||
if (userWorkHoursStatusDTO == null || !userWorkHoursStatusDTO.isUserInside()) {
|
||||
throw new Exception("Nessun ingresso rilevato");
|
||||
}
|
||||
|
||||
|
||||
JtbRLavt jtbRLavt = new JtbRLavt()
|
||||
.setCodJflav(codJflav)
|
||||
.setDataLav(userWorkHoursClockOutRequestDTO.getTimestamp() != null ?
|
||||
@@ -137,9 +152,6 @@ public class UserWorkHoursService {
|
||||
if (userWorkHoursClockOutRequestDTO.isTrasfertaItalia())
|
||||
jtbRLavt.setFlagTrasferta("S");
|
||||
|
||||
final IndirizzoDTO positionFromCoords =
|
||||
geocodingService.getPositionFromCoords(multiDBTransactionManager, userWorkHoursClockOutRequestDTO.getPositionLatitude(), userWorkHoursClockOutRequestDTO.getPositionLongitude());
|
||||
|
||||
JtbRLavr jtbRLavr = new JtbRLavr()
|
||||
.setCodJcom(userWorkHoursClockOutRequestDTO.getCodJcom())
|
||||
.setCodJfas(userWorkHoursClockOutRequestDTO.getCodJfas())
|
||||
@@ -157,6 +169,61 @@ public class UserWorkHoursService {
|
||||
}
|
||||
|
||||
|
||||
public void updateWorkedHours(String username, UserWorkHoursUpdateDTO requestUpdate) throws Exception {
|
||||
String codJflav = userService.retrieveCodJflav(username);
|
||||
|
||||
JtbRLavr jtbRLavr = retrieveRigaLavr(codJflav, requestUpdate.getOldTimestamp().toLocalDate(), requestUpdate.getOldTimestamp());
|
||||
|
||||
if (jtbRLavr == null) {
|
||||
throw new Exception("Timbratura non trovata");
|
||||
} else {
|
||||
jtbRLavr.setOperation(OperationType.UPDATE);
|
||||
|
||||
if (requestUpdate.isClockIn())
|
||||
jtbRLavr.setDaOra(requestUpdate.getTimestamp())
|
||||
.setModificatoDa(username);
|
||||
else
|
||||
jtbRLavr.setaOra(requestUpdate.getTimestamp())
|
||||
.setModificatoDa(username);
|
||||
|
||||
JtbRLavt jtbRLavt = new JtbRLavt()
|
||||
.setCodJflav(codJflav)
|
||||
.setDataLav(requestUpdate.getTimestamp() != null ?
|
||||
requestUpdate.getTimestamp().toLocalDate() : LocalDate.now())
|
||||
.setInseritoDa(username)
|
||||
.setCodDiviCont(retrieveDefaultCodDiviCont());
|
||||
|
||||
jtbRLavt.setOperation(OperationType.NO_OP);
|
||||
jtbRLavt.getJtbRlavr().add(jtbRLavr);
|
||||
|
||||
entityProcessor.processEntity(jtbRLavt, multiDBTransactionManager);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteWorkedHours(String username, UserWorkHoursDeleteDTO requestDelete) throws Exception {
|
||||
String codJflav = userService.retrieveCodJflav(username);
|
||||
|
||||
JtbRLavt jtbRLavt = new JtbRLavt()
|
||||
.setCodJflav(codJflav)
|
||||
.setDataLav(requestDelete.getTimestamp() != null ?
|
||||
requestDelete.getTimestamp().toLocalDate() : LocalDate.now())
|
||||
.setInseritoDa(username)
|
||||
.setCodDiviCont(retrieveDefaultCodDiviCont());
|
||||
|
||||
JtbRLavr jtbRLavr = retrieveRigaLavr(codJflav, requestDelete.getTimestamp().toLocalDate(), requestDelete.getTimestamp());
|
||||
|
||||
if (jtbRLavr == null) {
|
||||
throw new Exception("Timbratura non trovata");
|
||||
} else {
|
||||
jtbRLavr.setOperation(OperationType.DELETE);
|
||||
|
||||
jtbRLavt.setOperation(OperationType.NO_OP);
|
||||
jtbRLavt.getJtbRlavr().add(jtbRLavr);
|
||||
|
||||
entityProcessor.processEntity(jtbRLavt, multiDBTransactionManager);
|
||||
}
|
||||
}
|
||||
|
||||
private String retrieveDefaultCodDiviCont() throws SQLException, IOException, PrimaryDatabaseNotPresentException {
|
||||
return setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "WINACCESS", "SETUP", "COD_DIVI_CONT");
|
||||
}
|
||||
@@ -176,6 +243,20 @@ public class UserWorkHoursService {
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, UserWorkHoursStatusDTO.class);
|
||||
}
|
||||
|
||||
private JtbRLavr retrieveRigaLavr(String codJflav, LocalDate date, LocalDateTime timestamp) throws Exception {
|
||||
|
||||
String sql = Query.format(
|
||||
"SELECT *\n" +
|
||||
"FROM jtb_rlavr\n" +
|
||||
"WHERE data_lav = %s\n" +
|
||||
" AND cod_jflav = %s\n" +
|
||||
" AND ((da_ora IS NULL OR a_ora IS NULL) AND (da_ora = %s OR a_ora = %s))",
|
||||
date, codJflav, timestamp, timestamp
|
||||
);
|
||||
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, JtbRLavr.class);
|
||||
}
|
||||
|
||||
public List<UserWorkHoursClockHistoryDTO> clockStatus(String username, LocalDate startDate, LocalDate endDate) throws SQLException, IOException, PrimaryDatabaseNotPresentException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||
String codJflav = userService.retrieveCodJflav(username);
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package it.integry.ems.activity.utility;
|
||||
|
||||
import it.integry.ems.activity.dto.ActivityTaskDTO;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems_model.entity.StbActivity;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
|
||||
public class TaskUtility {
|
||||
|
||||
public static StbActivity buildStbActivityFromActivityTask(Connection conn, ActivityTaskDTO activity) throws Exception {
|
||||
StbActivity stbActivity = new StbActivity();
|
||||
|
||||
stbActivity.setActivityId(activity.getActivityId())
|
||||
.setActivityDescription(activity.getActivityDescription())
|
||||
.setNote(activity.getNote())
|
||||
.setResultDescription(activity.getResultDescription())
|
||||
.setActivityTypeId(activity.getActivityTypeId())
|
||||
.setActivityResultId(activity.getActivityResultId())
|
||||
.setUserName(activity.getUserName())
|
||||
.setEffectiveTime(activity.getEffectiveTime())
|
||||
.setEffectiveEndtime(activity.getEffectiveEndtime())
|
||||
.setEstimatedTime(activity.getEstimatedTime())
|
||||
.setEstimatedEndtime(activity.getEstimatedEndtime())
|
||||
.setOreRapportino(activity.getOreLav())
|
||||
.setFlagTipologia("A")
|
||||
.setCodJfas(retrieveCodJfas(conn, activity.getActivityTypeId(), stbActivity.getFlagTipologia()));
|
||||
|
||||
return stbActivity;
|
||||
}
|
||||
|
||||
public static ActivityTaskDTO buildActivityTaskFromStbActivity(StbActivity stbActivity) throws Exception {
|
||||
ActivityTaskDTO activity = new ActivityTaskDTO();
|
||||
|
||||
activity.setActivityId(stbActivity.getActivityId())
|
||||
.setActivityDescription(stbActivity.getActivityDescription())
|
||||
.setNote(stbActivity.getNote())
|
||||
.setResultDescription(stbActivity.getResultDescription())
|
||||
.setActivityTypeId(stbActivity.getActivityTypeId())
|
||||
.setActivityResultId(stbActivity.getActivityResultId())
|
||||
.setUserName(stbActivity.getUserName())
|
||||
.setEffectiveTime(stbActivity.getEffectiveTime())
|
||||
.setEffectiveEndtime(stbActivity.getEffectiveEndtime())
|
||||
.setEstimatedTime(stbActivity.getEstimatedTime())
|
||||
.setEstimatedEndtime(stbActivity.getEstimatedEndtime())
|
||||
.setOreLav(stbActivity.getOreRapportino())
|
||||
.setAlarmTime(stbActivity.getAlarmTime());
|
||||
|
||||
return activity;
|
||||
}
|
||||
|
||||
|
||||
public static String retrieveCodJfas(Connection conn, String activityType, String flagTipologia) throws Exception {
|
||||
String sql = Query.format(
|
||||
"SELECT cod_jfas\n" +
|
||||
"FROM stb_activity_type\n" +
|
||||
"WHERE activity_type_id = %s\n" +
|
||||
" AND flag_tipologia = %s",
|
||||
activityType, flagTipologia
|
||||
);
|
||||
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
}
|
||||
}
|
||||
@@ -557,8 +557,11 @@ public class WMSGenericController {
|
||||
ServiceRestResponse spostaULInPosizione(@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody SpostaUlRequestDTO requestDTO) throws Exception {
|
||||
try {
|
||||
wmsGenericService.spostaUL(requestDTO);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
MtbColt mtbColt = wmsGenericService.spostaUL(requestDTO);
|
||||
if (mtbColt != null) {
|
||||
mtbColt.setOnlyPkMaster(false);
|
||||
}
|
||||
return ServiceRestResponse.createPositiveResponse(mtbColt);
|
||||
} catch (Exception e) {
|
||||
multiDBTransactionManager.rollbackAll();
|
||||
throw e;
|
||||
|
||||
@@ -2027,7 +2027,7 @@ public class WMSGenericService {
|
||||
UtilityEntity.throwEntitiesException(entitiesToSave);
|
||||
}
|
||||
|
||||
public void spostaUL(SpostaUlRequestDTO requestDTO) throws Exception {
|
||||
public MtbColt spostaUL(SpostaUlRequestDTO requestDTO) throws Exception {
|
||||
if (UtilityString.isNullOrEmpty(requestDTO.getCodMdep()))
|
||||
throw new Exception("Nessun deposito di arrivo selezionato");
|
||||
|
||||
@@ -2194,6 +2194,8 @@ public class WMSGenericService {
|
||||
|
||||
entityProcessor.processEntityList(entitiesToSave, true);
|
||||
UtilityEntity.throwEntitiesException(entitiesToSave);
|
||||
|
||||
return mtbCotlList.stream().findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public void spostaULInPosizione(MtbColt mtbColtToMove, MtbDepoPosizioni mtbDepoPosizioni) throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user