Compare commits

...

94 Commits

Author SHA1 Message Date
5fbf7975d2 Migliorata gestione profile di default in RequestDataDTO
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-17 18:32:02 +01:00
a75b66bd53 Fix su Hibernte che non funzionava correttamente con profileDb maiuscolo/minuscolo
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-17 18:21:09 +01:00
13439c236d Creato repository per StbEmail
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-17 16:34:21 +01:00
77d5a9cb9e aggiunta Roberta nelle notifiche
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-17 12:56:06 +01:00
d4cfada677 Merge remote-tracking branch 'origin/develop' into develop 2025-12-17 12:52:25 +01:00
27c6795b9f Merge remote-tracking branch 'origin/develop' into develop 2025-12-17 12:52:07 +01:00
dd9ff5c111 prova 2025-12-17 12:52:06 +01:00
1a4773659a Nella procedura di importazione CRONOTIME Geestito invio mail di errore quando un badge non esiste 2025-12-17 12:52:03 +01:00
0d2da1a92c prova
Some checks are pending
IntegryManagementSystem_Multi/pipeline/head Build queued...
2025-12-17 12:51:46 +01:00
b203e94836 gestita equivalenza su dati di magazzino dell'articolo
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-17 12:50:44 +01:00
b3c99f7937 Modificato formato data
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-17 12:40:34 +01:00
6257fd540d Migliorie email interna di errore di sistema
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-17 10:23:08 +01:00
635ac0a1c7 Merge remote-tracking branch 'origin/develop' into develop
Some checks failed
IntegryManagementSystem_Multi/pipeline/head There was a failure building this commit
2025-12-16 18:27:36 +01:00
8abf441a8a [carelli - ordini a]
- aggiunto controllo su qta_ord vs qta_cnf
- unificati tutti controlli di esportazione nei servizi
2025-12-16 18:27:29 +01:00
8781b406ff Rimossa cache su MtbAart, completata prima implementazione funzionante di MtbAartRepository e MtbUntMisRepository
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-16 18:21:17 +01:00
c9325674d9 Merge branch 'develop' into JpaTest 2025-12-16 12:26:54 +01:00
99ca1731b1 Aggiunta share samba su immagine docker. Cambiata immagine base da alpine e ubuntu noble (24)
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-16 12:26:16 +01:00
af6f465c0e modifiche per steup
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-16 11:34:12 +01:00
d981e59a7d Rimosso Containerfile
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-15 18:27:09 +01:00
6d7212ce97 Prima versione funzionante di Hybernate 2025-12-15 10:42:51 +01:00
5103830369 Finish Feature-SteUp
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-12 18:52:01 +01:00
5056d7e0c8 Merge branch 'develop' into feature/Feature-SteUp 2025-12-12 18:51:57 +01:00
4b5e46de7b varie steup 2025-12-12 18:51:48 +01:00
4d686ee145 Allineamento dati follies group su mtb_aart_anag
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-12 18:30:40 +01:00
e842326f5b Merge remote-tracking branch 'origin/develop' into develop 2025-12-12 18:30:32 +01:00
63ad11086f Allineamento dati follies group su mtb_aart_anag 2025-12-12 18:30:26 +01:00
21f6fc6717 Merge remote-tracking branch 'origin/develop' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-12 17:43:00 +01:00
8c2789b5f3 modificata in or la condizione dei db format e gestfood per la cancellazione dei duplicati 2025-12-12 17:42:54 +01:00
8f3ef405cf Merge branch 'develop' into feature/Feature-SteUp 2025-12-12 17:15:44 +01:00
76e76dfcf4 aggiunti parametri nella migration
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-12 17:13:14 +01:00
1df5ad7137 varie steup 2025-12-12 17:00:29 +01:00
a43ca46395 Spostato metodo downloadReportList da refactoring
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-12 16:06:38 +01:00
a63eba544b Allineamento dati Auricchio, levanplast e agricoper per cambio chiave mtb_aart_anag
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-12 13:20:49 +01:00
ce912bf103 Allineamento dati Auricchio, levanplast e agricoper per cambio chiave mtb_aart_anag 2025-12-12 13:20:44 +01:00
ababbf6142 Merge remote-tracking branch 'origin/develop' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-12 10:12:20 +01:00
e97fd0aacb inserita nota bio nella dtb_note_doc, associata ai tipi documenti e svuotata setup stampa_documenti per rossogargano 2025-12-12 10:12:09 +01:00
51c1ed1d23 Merge branch 'develop' into feature/Feature-SteUp 2025-12-12 09:59:37 +01:00
a9be8f7003 Merge branch 'master' into develop
Some checks failed
IntegryManagementSystem_Multi/pipeline/head There was a failure building this commit
2025-12-12 09:58:38 +01:00
7522092a12 Finish Hotfix-1
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-12 09:58:37 +01:00
4dc0174800 Fix su convert mvwSitart to mtbColr 2025-12-12 09:58:32 +01:00
a04b2fa4a1 Merge remote-tracking branch 'origin/develop' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-11 17:14:44 +01:00
04317470c6 creata setup per visualizzare dettaglio su report fatturato agente/clienti 2025-12-11 17:14:35 +01:00
187216dd9f Merge remote-tracking branch 'origin/develop' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-11 16:46:46 +01:00
e11172a90f Implementato servizio di reset selle posizioni MonoUl 2025-12-11 16:46:35 +01:00
51d5b05bd3 Merge branch 'master' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-11 16:31:10 +01:00
3a2ceaf217 Finish Hotfix-100
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-11 16:31:09 +01:00
c783f69a49 aggiunta setup per esportare 2025-12-11 16:30:22 +01:00
1c8695095b Merge remote-tracking branch 'origin/develop' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-11 16:06:11 +01:00
fc28af761c creato report personalizzato stampa registri iva per cosmapack 2025-12-11 16:06:02 +01:00
fd4db5ab3b Merge remote-tracking branch 'origin/develop' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-11 13:12:05 +01:00
f7e1d1f6ca [ROSSOGARGANO]
- fix riposizionamento in posizione monoUl
2025-12-11 13:11:57 +01:00
0b8f82f041 Create nuove utilities
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-11 12:45:12 +01:00
99680dccd8 Creata nuova utility getMtbUntMisFromCodMart
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-11 11:21:14 +01:00
e948855fc0 Merge branch 'hotfix/Hotfix-1' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-11 10:30:17 +01:00
0854acacfb Merge branch 'hotfix/Hotfix-1'
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-11 10:30:16 +01:00
1aba141c9f Aggiunto database tempestadi nei customer db 2025-12-11 10:30:02 +01:00
741cb960d4 Merge branch 'hotfix/Hotfix-1' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-11 10:13:39 +01:00
82d7efc00c Merge branch 'hotfix/Hotfix-1'
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-11 10:13:39 +01:00
c6c2739525 Aggiunto database tempestadi nei customer db 2025-12-11 10:13:21 +01:00
313bfc21ff Modificato messaggio di errore per documenti già esistente
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-11 09:44:12 +01:00
36f50ad846 Merge branch 'master' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-10 18:48:18 +01:00
798e5b532e Finish Hotfix-1
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-10 18:48:17 +01:00
c27c96c3d9 Aggiunto parallel stream in retrieve items dalla cache 2025-12-10 18:48:11 +01:00
4e3d15ebd8 Merge branch 'master' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-10 18:47:37 +01:00
0ba9297f39 Finish Hotfix-1
Some checks failed
IntegryManagementSystem_Multi/pipeline/head Something is wrong with the build of this commit
2025-12-10 18:47:36 +01:00
7c036172d8 Aggiunto parallel stream in retrieve items dalla cache 2025-12-10 18:47:22 +01:00
8afa01d8ef Corretto errore null di Ime quando svuotavano il campo tipo bene
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-10 17:34:59 +01:00
db1949b5b6 Merge branch 'master' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-10 16:22:41 +01:00
bb47dd458e Finish FixSavePreventivo
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-10 16:22:40 +01:00
530b6af4ef [CRM] fix completeOrder 2025-12-10 16:20:22 +01:00
92cd4b1af5 Merge branch 'master' into develop
Some checks failed
IntegryManagementSystem_Multi/pipeline/head There was a failure building this commit
2025-12-10 13:35:53 +01:00
6b71d6b784 Finish Hotfix-1
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-10 13:35:53 +01:00
de4d8d225f Aggiunto codMart nella richiesta di retrieveGiacenza 2025-12-10 13:35:43 +01:00
671c2e99d0 Merge branch 'master' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-10 12:19:31 +01:00
755e7394b4 Finish Hotfix-1
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-10 12:19:31 +01:00
ce06683722 Fix duplicate key su mtbCols 2025-12-10 12:19:11 +01:00
e8a1a8ca0b Merge branch 'master' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-10 12:16:14 +01:00
78dbf9f7e3 Merge branch 'hotfix/Hotfix-1' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-10 12:01:55 +01:00
1d52f79337 fix funzione pvm_getassortimentoClientePedane per "ambiguous column name" su cod_Vdes
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-10 11:20:28 +01:00
0e1adccb7c inserito campo cod_vdes nella mtb_aart_anag e cancellati duplicati su format e gestfood
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-10 10:33:57 +01:00
fa76a8e92d Merge remote-tracking branch 'origin/develop' into develop
Some checks are pending
IntegryManagementSystem_Multi/pipeline/head Build queued...
2025-12-10 10:33:11 +01:00
9b34a51bd9 inserito campo cod_vdes nella mtb_aart_anag e cancellati duplicati su format e gestfood 2025-12-10 10:32:58 +01:00
b75f7e3810 Finish DatiDocSpostaUL
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-10 09:57:30 +01:00
4aeccdfa76 Aggiunti dati doc in creazione documento sposta ul 2025-12-10 09:56:42 +01:00
39db8e6e1b Modifica migrations per DMS
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-10 09:27:37 +01:00
1b87cacca2 aggiunta fk su mtb_unt_mis
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-09 16:02:09 +01:00
326bd4294e Merge branch 'master' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-09 15:03:34 +01:00
e887aceaaf Merge branch 'hotfix/Hotfix-1' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-09 14:32:50 +01:00
55f23b2dfc aggiunti campi in importazione articoli
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
2025-12-09 13:28:33 +01:00
1ef49b87e8 Merge tag 'Release-1' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
Finish Release-anomalie
2025-12-09 12:44:05 +01:00
920257812c Merge branch 'develop' into feature/Feature-SteUp 2025-12-01 09:20:46 +01:00
77c79c6247 Merge branch 'develop' into feature/Feature-SteUp 2025-11-25 10:58:20 +01:00
c26f7feb35 Merge branch 'develop' into feature/Feature-SteUp 2025-11-25 10:10:30 +01:00
21cc88f295 varie per steup 2025-11-25 09:36:00 +01:00
115 changed files with 2945 additions and 535 deletions

18
.idea/copilotDiffState.xml generated Normal file

File diff suppressed because one or more lines are too long

33
.idea/dataSources.xml generated
View File

@@ -1,11 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="@SERVERDB2019" uuid="ff4f0bad-7271-429e-a4e1-bae28629efc8">
<data-source source="LOCAL" name="Biolevante@SERVERDB2019" uuid="ff4f0bad-7271-429e-a4e1-bae28629efc8">
<driver-ref>sqlserver.ms</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</jdbc-driver>
<jdbc-url>jdbc:sqlserver://SERVERDB2019</jdbc-url>
<jdbc-url>jdbc:sqlserver://SERVERDB2019\MSSQLSERVER;database=Biolevante</jdbc-url>
<jdbc-additional-properties>
<property name="com.intellij.clouds.kubernetes.db.host.port" />
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
<property name="com.intellij.clouds.kubernetes.db.container.port" />
</jdbc-additional-properties>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
<data-source source="LOCAL" name="Gramm@SERVERDB2019" uuid="02282d62-6d2a-4b83-bdcf-b558fa6db140">
<driver-ref>sqlserver.ms</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</jdbc-driver>
<jdbc-url>jdbc:sqlserver://SERVERDB2019\MSSQLSERVER;database=Gramm</jdbc-url>
<jdbc-additional-properties>
<property name="com.intellij.clouds.kubernetes.db.host.port" />
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
<property name="com.intellij.clouds.kubernetes.db.container.port" />
</jdbc-additional-properties>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
<data-source source="LOCAL" name="vgalimenti@SERVERDB" uuid="eaf0bcaf-4620-478b-b63c-42e77902813f">
<driver-ref>sqlserver.ms</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</jdbc-driver>
<jdbc-url>jdbc:sqlserver://SERVERDB\MSSQLSERVER;database=vgalimenti</jdbc-url>
<jdbc-additional-properties>
<property name="com.intellij.clouds.kubernetes.db.host.port" />
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
<property name="com.intellij.clouds.kubernetes.db.container.port" />
</jdbc-additional-properties>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>

8
.idea/data_source_mapping.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourcePerFileMappings">
<file url="file://$PROJECT_DIR$/.idea/queries/Query.sql" value="ff4f0bad-7271-429e-a4e1-bae28629efc8" />
<file url="file://$PROJECT_DIR$/.idea/queries/Query_1.sql" value="02282d62-6d2a-4b83-bdcf-b558fa6db140" />
<file url="file://$PROJECT_DIR$/.idea/queries/Query_2.sql" value="eaf0bcaf-4620-478b-b63c-42e77902813f" />
</component>
</project>

6
.idea/db-forest-config.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="db-tree-configuration">
<option name="data" value="----------------------------------------&#10;1:0:ff4f0bad-7271-429e-a4e1-bae28629efc8&#10;2:0:02282d62-6d2a-4b83-bdcf-b558fa6db140&#10;3:0:eaf0bcaf-4620-478b-b63c-42e77902813f&#10;" />
</component>
</project>

View File

@@ -1,6 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="central" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />

6
.idea/sqldialects.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SqlDialectMappings">
<file url="file://$PROJECT_DIR$/.idea/queries/Query_2.sql" dialect="TSQL" />
</component>
</project>

View File

@@ -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

View File

@@ -1,11 +1,45 @@
FROM tomcat:9-jre8-alpine
RUN apk add --no-cache fontconfig ttf-dejavu
FROM tomcat:9-jre8
ENV TZ="Europe/Rome"
ENV JAVA_OPTS="-DDISABLE_DROOLS_COMPILE=TRUE -Xms512M -Xmx2G -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
ENV USERDOMAIN="STUDIO-ML"
# Install Samba
RUN apt-get update && \
apt-get install -y samba samba-common-bin && \
rm -rf /var/lib/apt/lists/*
# Ensure log directory exists and is readable
RUN mkdir -p /usr/local/tomcat/logs && \
chmod -R 755 /usr/local/tomcat/logs
# Create samba user (no login) and add to root group
RUN useradd -M -s /usr/sbin/nologin sambauser && \
printf "sambapass\nsambapass\n" | smbpasswd -a -s sambauser && \
usermod -aG root sambauser
# Samba configuration
RUN printf "\
[global]\n\
workgroup = STUDIO-ML\n\
security = user\n\
map to guest = never\n\
server role = standalone server\n\
unix extensions = no\n\
client min protocol = NT1\n\
\n\
[tomcat-logs]\n\
comment = Tomcat logs (read-only)\n\
path = /usr/local/tomcat/logs\n\
browseable = yes\n\
read only = yes\n\
guest ok = no\n\
valid users = sambauser\n\
force user = root\n\
create mask = 0644\n\
directory mask = 0755\n\
" > /etc/samba/smb.conf
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/

View File

@@ -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}"

View File

@@ -404,6 +404,17 @@
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>2.7.18</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.6.15.Final</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>

View File

@@ -28,10 +28,8 @@ public class DbmsChangeTrackerComponent {
private final HashMap<IntegryCustomerDB, DbmsChangeTracker> activeChangeTrackers = new HashMap<>();
private final ArrayList<String> trackedTables = new ArrayList<String>() {{
add(MtbAart.ENTITY);
add(MtbAartBarCode.ENTITY);
add(MtbUntMis.ENTITY);
add(MtbDepo.ENTITY);
add(MtbDepoPosizioni.ENTITY);
add(StbEditLimit.ENTITY);
add(StbGestSetup.ENTITY);
add(StbGestSetupDepo.ENTITY);

View File

@@ -53,10 +53,8 @@ public class EntityCacheComponent implements ApplicationListener {
}
private final HashMap<String, Class<? extends EntityBase>> enabledEntities = new HashMap<String, Class<? extends EntityBase>>() {{
put(MtbAart.ENTITY, MtbAart.class);
put(MtbAartBarCode.ENTITY, MtbAartBarCode.class);
put(MtbUntMis.ENTITY, MtbUntMis.class);
put(MtbDepo.ENTITY, MtbDepo.class);
put(MtbDepoPosizioni.ENTITY, MtbDepoPosizioni.class);
put(StbEditLimit.ENTITY, StbEditLimit.class);
put(StbGestSetup.ENTITY, StbGestSetup.class);
put(StbGestSetupDepo.ENTITY, StbGestSetupDepo.class);
@@ -152,7 +150,7 @@ public class EntityCacheComponent implements ApplicationListener {
snapshot = entityCache.get(customerDB)
.get(tableName)
.values()
.stream()
.parallelStream()
.map(x -> (T) x.clone());
if (filterPredicate != null)

View File

@@ -357,8 +357,8 @@ public abstract class BaseEntityExporter implements IEntityExporter {
case EMAIL:
if (UtilityString.isNullOrEmpty(wtbUserInfo.getEmail()) &&
UtilityString.isNullOrEmpty(wtbUserInfo.getEmailCc()) &&
UtilityString.isNullOrEmpty(wtbUserInfo.getEmailCcn())) {
UtilityString.isNullOrEmpty(wtbUserInfo.getEmailCc()) &&
UtilityString.isNullOrEmpty(wtbUserInfo.getEmailCcn())) {
break;
}
@@ -369,7 +369,8 @@ public abstract class BaseEntityExporter implements IEntityExporter {
entityExportResponse.setMessageContent("Messaggio creato automaticamente: " + "INVIO " + type + " formato " + format);
}
fileSharerSettings = MailService.readParameter(multiDBTransactionManager.getPrimaryConnection(), null);
fileSharerSettings = ApplicationContextProvider.getApplicationContext().getBean(MailService.class)
.readParameter(multiDBTransactionManager.getPrimaryConnection(), null);
((EmailFileSharerSettings) fileSharerSettings)
.withSubject(entityExportResponse.getMessageSubject())
.withTextMessage(entityExportResponse.getMessageContent())
@@ -403,7 +404,7 @@ public abstract class BaseEntityExporter implements IEntityExporter {
}
}
if (counterTotalSend > 0 && counterFailedSend == counterTotalSend && retException != null) {
if (counterTotalSend > 0 && counterFailedSend == counterTotalSend && retException != null) {
//Se gli invii precedenti sono andati bene usciamo
throw retException;
}

View File

@@ -3,6 +3,7 @@ package it.integry.ems.javabeans;
import com.fasterxml.jackson.annotation.JsonInclude;
import it.integry.common.var.CommonConstants;
import it.integry.ems._context.ApplicationContextProvider;
import it.integry.ems.jpa.TenantContext;
import it.integry.ems.json.ResponseJSONObjectMapper;
import it.integry.ems.migration._base.IntegryCustomerDB;
import it.integry.ems.model.IntegryApplicationEnum;
@@ -19,13 +20,15 @@ import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import org.springframework.web.context.WebApplicationContext;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
@Component
@Scope("request")
@Scope(WebApplicationContext.SCOPE_REQUEST)
public class RequestDataDTO {
private final Logger logger = LogManager.getLogger();
@@ -36,6 +39,9 @@ public class RequestDataDTO {
@Autowired
private ResponseJSONObjectMapper jsonObjectMapper;
@Autowired
private SettingsModel settingsModel;
private String requestURI;
private String requestClientIP;
@@ -100,6 +106,21 @@ public class RequestDataDTO {
} else {
jsonObjectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
// Logica di fallback o recupero tenant da sessione/utente
if (profileDB == null || profileDB.isEmpty()) {
profileDB = settingsModel.getDefaultProfile();
}
if (profileDB != null) {
TenantContext.setCurrentTenant(profileDB);
}
}
@PreDestroy
public void destroy() throws Exception {
TenantContext.clear();
}
@@ -109,10 +130,10 @@ public class RequestDataDTO {
.setPassword("sql");
}
public static RequestDataDTO scheduledOperationsMockupData() {
return new RequestDataDTO()
.setUsername("INTEGRY")
.setPassword("INTEGRY");
public static RequestDataDTO systemMockupData(String profileDb) {
final RequestDataDTO requestDataDTO = systemMockupData();
requestDataDTO.profileDB = profileDb;
return requestDataDTO;
}
public boolean isValidProfileDB() {

View File

@@ -0,0 +1,56 @@
package it.integry.ems.jpa;
import it.integry.ems.settings.Model.AvailableConnectionModel;
import it.integry.ems.settings.Model.SettingsModel;
import it.integry.ems.sync.MultiDBTransaction.BasicConnectionPool;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
import javax.sql.DataSource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MultiTenantDataSource extends AbstractRoutingDataSource {
private final BasicConnectionPool basicConnectionPool;
private final SettingsModel settingsModel;
public MultiTenantDataSource(BasicConnectionPool basicConnectionPool, SettingsModel settingsModel) {
this.basicConnectionPool = basicConnectionPool;
this.settingsModel = settingsModel;
}
@Override
protected Object determineCurrentLookupKey() {
return TenantContext.getCurrentTenant();
}
@Override
public void afterPropertiesSet() {
Map<Object, Object> targetDataSources = new HashMap<>();
List<AvailableConnectionModel> connections = settingsModel.getAvailableConnections(false);
// Imposta il primo come default se necessario, o gestisci il caso null
// DataSource defaultDataSource = null;
for (AvailableConnectionModel model : connections) {
DataSource ds = basicConnectionPool.getDataSource(model.getProfileName());
if (ds != null) {
targetDataSources.put(model.getProfileName().toLowerCase(), ds);
// if (defaultDataSource == null) {
// defaultDataSource = ds;
// }
}
}
this.setTargetDataSources(targetDataSources);
//this.setDefaultTargetDataSource(defaultDataSource);
super.afterPropertiesSet();
}
// Metodo per ricaricare i datasource se vengono aggiunti nuovi tenant a runtime
public void refreshDataSources() {
this.afterPropertiesSet();
}
}

View File

@@ -0,0 +1,21 @@
package it.integry.ems.jpa;
public class TenantContext {
private static final ThreadLocal<String> currentTenant = new ThreadLocal<>();
public static void setCurrentTenant(String tenant) {
if (tenant == null)
throw new IllegalArgumentException("Tenant identifier cannot be null");
currentTenant.set(tenant.toLowerCase());
}
public static String getCurrentTenant() {
return currentTenant.get();
}
public static void clear() {
currentTenant.remove();
}
}

View File

@@ -0,0 +1,10 @@
package it.integry.ems.jpa.entity;
import javax.persistence.MappedSuperclass;
import java.io.Serializable;
@MappedSuperclass
public abstract class BaseEntity implements Serializable {
// Classe base per le entity JPA
}

View File

@@ -0,0 +1,10 @@
package it.integry.ems.jpa.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.NoRepositoryBean;
@NoRepositoryBean
public interface BaseRepository<T, ID> extends JpaRepository<T, ID> {
// Interfaccia base per i repository
}

View File

@@ -0,0 +1,36 @@
package it.integry.ems.jpa.repository;
import it.integry.ems_model.entity.MtbAart;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional;
@Repository
public interface MtbAartRepository extends BaseRepository<MtbAart, String> {
Optional<MtbAart> findByCodMart(String codMart);
@EntityGraph(attributePaths = {"mtbUntMis"})
Optional<MtbAart> findWithUntMisByCodMart(String codMart);
List<MtbAart> findByCodMartIn(List<String> codMarts);
@EntityGraph(attributePaths = {"mtbUntMis"})
List<MtbAart> findWithUntMisByCodMartIn(List<String> codMarts);
@EntityGraph(attributePaths = {"mtbUntMis", "mtbAartBarCode"})
List<MtbAart> findWithBarcodeWithUntMisByCodMartIn(List<String> codMarts);
@EntityGraph(attributePaths = {"mtbAartBarCode"})
Optional<MtbAart> findWithBarcodeByCodMart(String codMart);
@Query("SELECT m FROM MtbAart m WHERE m.untMis = 'KG'")
List<MtbAart> findByUntMisKG();
@Query("SELECT m.flagQtaCnfFissa FROM MtbAart m WHERE m.codMart = :codMart")
Optional<String> findFlagQtaCnfFissaByCodMart(@Param("codMart") String codMart);
}

View File

@@ -0,0 +1,24 @@
package it.integry.ems.jpa.repository;
import it.integry.ems_model.entity.MtbUntMis;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.math.BigDecimal;
import java.util.List;
import java.util.Optional;
public interface MtbUntMisRepository extends BaseRepository<MtbUntMis, String> {
Optional<MtbUntMis> findByUntMis(String untMis);
List<MtbUntMis> findByUntMisIn(List<String> untMis);
@Query("SELECT a.mtbUntMis FROM MtbAart a WHERE a.codMart = :codMart")
Optional<MtbUntMis> findByCodMart(@Param("codMart") String codMart);
int countByUntMis(String untMis);
@Query("SELECT u.cifreDec FROM MtbUntMis u WHERE u.flagUnitaKg = :flagUnitaKg")
List<BigDecimal> findCifreDecByFlagUnitaKg(@Param("flagUnitaKg") String flagUnitaKg);
}

View File

@@ -0,0 +1,15 @@
package it.integry.ems.jpa.repository;
import it.integry.ems_model.entity.StbEmail;
import org.springframework.data.jpa.repository.Query;
import java.util.Optional;
public interface StbEmailRepository extends BaseRepository<StbEmail, Integer> {
@Query("SELECT e FROM StbEmail e WHERE e.flagDefault = 'S'")
Optional<StbEmail> findByFlagDefaultTrue();
@Query("SELECT e FROM StbEmail e WHERE UPPER(e.eMail) = UPPER(?1)")
Optional<StbEmail> findByEmailIgnoreCase(String email);
}

View File

@@ -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 {

View File

@@ -119,7 +119,10 @@ public enum IntegryCustomer {
IntegryCustomerDB.Suit_TenutaArianna,
IntegryCustomerDB.Suit_Valpietro),
Tempesta(IntegryCustomerDB.Tempesta_Tempesta,
IntegryCustomerDB.Tempesta_VivaiTempesta),
IntegryCustomerDB.Tempesta_DI,
IntegryCustomerDB.Tempesta_VivaiTempesta,
IntegryCustomerDB.Tempesta_VivaiTempesta_DI
),
Tosca(IntegryCustomerDB.Tosca_Ba,
IntegryCustomerDB.Tosca_Ce,
IntegryCustomerDB.Tosca_Cz,

View File

@@ -198,7 +198,9 @@ public enum IntegryCustomerDB {
Tempesta_Tempesta("tempesta"),
Tempesta_DI("tempestadi"),
Tempesta_VivaiTempesta("vivaitempesta"),
Tempesta_VivaiTempesta_DI("vivaitempestadi"),
Tosca_Ba("tosca_ba"),

View File

@@ -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 {
}
}

View File

@@ -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 {
}
}

View File

@@ -13,6 +13,10 @@ public class Migration_20251201105344 extends BaseMigration implements Migration
if (isDMS())
return;
if (isDMS())
return;
createOrUpdateTrigger("tr_changeTipoRiep", "CREATE TRIGGER [dbo].[tr_changeTipoRiep]\n" +
" ON [dbo].[ctb_cont]\n" +
" INSTEAD OF update\n" +

View File

@@ -10,6 +10,10 @@ public class Migration_20251202161223 extends BaseMigration implements Migration
if (isHistoryDB())
return;
if (isDMS())
return;
createOrUpdateView("cvw_saldo_scad", "CREATE VIEW dbo.cvw_saldo_scad\n" +
" WITH SCHEMABINDING\n" +
" AS\n" +

View File

@@ -10,6 +10,9 @@ public class Migration_20251203121227 extends BaseMigration implements Migration
if (isHistoryDB())
return;
if (isDMS())
return;
createOrUpdateFunction("f_AggiungiGiorniScad", "CREATE FUNCTION [dbo].[f_AggiungiGiorniScad](@dataIniz DateTime, @giorni int, @ls_dataRif varchar(20)) \n" +
"RETURNS dateTime\n" +

View File

@@ -10,6 +10,10 @@ public class Migration_20251205101442 extends BaseMigration implements Migration
if (isHistoryDB())
return;
if (isDMS())
return;
executeStatement("alter table srl_activity_type_user add activity_default bit not null default 0;\n",
"CREATE UNIQUE INDEX ux_srl_activity_type_user_default\n" +
"ON srl_activity_type_user (user_name, flag_tipologia)\n" +

View File

@@ -10,6 +10,9 @@ public class Migration_20251205111526 extends BaseMigration implements Migration
if (isHistoryDB())
return;
if (isDMS())
return;
createOrUpdateView("mvw_sitart_udc_det_all","CREATE VIEW [dbo].[mvw_sitart_udc_det_all] AS\n" +
"WITH SitMtbColr AS (\n" +

View File

@@ -0,0 +1,22 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20251209113110 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
if (isDMS())
return;
executeStatement("alter table mtb_aart alter column ingredienti varchar(8000)");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,42 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20251209154901 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
if (isDMS())
return;
executeStatement(
"insert into mtb_unt_mis ( unt_mis)\n" +
"select *\n" +
"from (\n" +
"select unt_mis\n" +
"from mtb_aart\n" +
"union\n" +
"select unt_mis2\n" +
"from mtb_aart\n" +
"where unt_mis2 is not null\n" +
"union\n" +
"select unt_mis3\n" +
"from mtb_aart\n" +
"where unt_mis3 is not null\n" +
") um \n" +
"where not exists (select 1 from mtb_unt_mis where mtb_unt_mis.unt_mis = um.unt_mis )",
"ALTER TABLE MTB_AART ADD CONSTRAINT FK_MTB_AART_UNT_MIS FOREIGN KEY (UNT_MIS) REFERENCES DBO.MTB_UNT_MIS (UNT_MIS)",
"ALTER TABLE MTB_AART ALTER COLUMN UNT_MIS2 VARCHAR(3)",
"ALTER TABLE MTB_AART ADD CONSTRAINT FK_MTB_AART_UNT_MIS2 FOREIGN KEY (UNT_MIS2) REFERENCES DBO.MTB_UNT_MIS (UNT_MIS)",
"ALTER TABLE MTB_AART ADD CONSTRAINT FK_MTB_AART_UNT_MIS3 FOREIGN KEY (UNT_MIS3) REFERENCES DBO.MTB_UNT_MIS (UNT_MIS)" );
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,28 @@
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_20251210095206 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
executeStatement("ALTER TABLE mtb_aart_anag ADD cod_vdes varchar(5);");
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" +
"from mtb_aart_anag ) m inner join mtb_aart_anag on m.cod_anag = mtb_aart_anag.cod_anag and m.cod_mart = mtb_aart_anag.cod_mart and mtb_aart_anag.cod_mart_anag = m.cod_mart_anag\n" +
"and m.id > 1");
}
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,253 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20251210111441 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createOrUpdateFunction("pvm_getassortimentoClientePedane","CREATE FUNCTION [dbo].[pvm_getassortimentoClientePedane](\n" +
" @codAnag VARCHAR(5), @codVlis VARCHAR(5), @codVdes VARCHAR(5), @dataValidita DATETIME, @viewPromo BIT,\n" +
" @pedane INT = 0\n" +
")\n" +
" RETURNS TABLE\n" +
" AS\n" +
" RETURN( /*\n" +
"\n" +
"\t\t\tdeclare @codAnag VARCHAR(5), @codVlis VARCHAR(5), @dataValidita DATETIME, @viewPromo BIT\n" +
"\t\t\tset @codAnag = 'C3355'\n" +
"\t\t\tset @codVlis = 'C3355'\n" +
"\t\t\tset @dataValidita = '2023/04/04'\n" +
"\t\t\tset @viewPromo = 1;\n" +
"\t\t\t*/\n" +
" WITH assortimento AS (SELECT vtb_griglia_art.cod_mart\n" +
" FROM vtb_clie\n" +
" INNER JOIN vtb_griglia ON vtb_clie.cod_griglia = vtb_griglia.cod_griglia\n" +
" INNER JOIN vtb_griglia_art\n" +
" ON vtb_griglia.cod_griglia = vtb_griglia_art.cod_griglia AND\n" +
" vtb_griglia.data_validita = vtb_griglia_art.data_validita\n" +
" WHERE vtb_clie.cod_anag = @codAnag\n" +
" AND vtb_griglia.data_validita = (SELECT MAX(g.data_validita)\n" +
" FROM vtb_griglia g\n" +
" WHERE g.cod_griglia = vtb_clie.cod_griglia\n" +
" AND g.data_validita <= ISNULL(@dataValidita, CAST(GETDATE() AS DATE)))),\n" +
" lisv AS (SELECT cod_vlis, cod_vlis AS cod_vlis_rif\n" +
" FROM vtb_list\n" +
" WHERE cod_vlis_rif IS NULL\n" +
" UNION ALL\n" +
" SELECT cod_vlis, cod_vlis_rif\n" +
" FROM vtb_list\n" +
" WHERE cod_vlis_rif IS NOT NULL),\n" +
" listino AS (SELECT DISTINCT cod_mart, tipo_variazione\n" +
" FROM (SELECT lisv.cod_vlis,\n" +
" mtb_lisv.cod_mart,\n" +
" LAST_VALUE(CASE\n" +
" WHEN vtb_list_data.data_iniz IS NULL THEN NULL\n" +
" ELSE mtb_lisv_data.tipo_variazione END)\n" +
" OVER (PARTITION BY lisv.cod_vlis, mtb_lisv.cod_mart\n" +
" ORDER BY vtb_list_data.data_iniz, CASE WHEN vtb_list_data.cod_promo IS NULL THEN 0 ELSE 1 END, vtb_list_data.versione\n" +
" RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS tipo_variazione\n" +
" FROM lisv\n" +
" INNER JOIN mtb_lisv ON lisv.cod_vlis_rif = mtb_lisv.cod_vlis\n" +
" INNER JOIN mtb_lisv_data ON mtb_lisv.cod_vlis = mtb_lisv_data.cod_vlis AND\n" +
" mtb_lisv.cod_mart = mtb_lisv_data.cod_mart\n" +
" LEFT OUTER JOIN vtb_list_data\n" +
" ON mtb_lisv_data.cod_vlis = vtb_list_data.cod_vlis AND\n" +
" mtb_lisv_data.versione = vtb_list_data.versione AND\n" +
" vtb_list_data.data_iniz <=\n" +
" ISNULL(@dataValidita, CAST(GETDATE() AS DATE))\n" +
" WHERE lisv.cod_vlis = @codVlis\n" +
" AND NOT EXISTS(SELECT cod_mart FROM assortimento)) t\n" +
" WHERE (t.tipo_variazione IS NULL OR t.tipo_variazione <> 'D')),\n" +
" tmp_lisv AS (SELECT l.cod_mart,\n" +
" l.cod_vlis,\n" +
" ISNULL(p.data_iniz, l.data_iniz) AS data_iniz,\n" +
" p.data_fine,\n" +
" l.da,\n" +
" l.a,\n" +
" ISNULL(p.prz_vend, l.prz_vend_trasp) AS prz_vend,\n" +
" ISNULL(p.prz_vend_netto, l.prz_vend_trasp_netto) AS prz_vend_netto,\n" +
" ISNULL(p.perc_sco1, l.perc_sco1) AS perc_sco1,\n" +
" ISNULL(p.perc_sco2, l.perc_sco2) AS perc_sco2,\n" +
" ISNULL(p.perc_sco3, l.perc_sco3) AS perc_sco3,\n" +
" ISNULL(p.perc_sco4, l.perc_sco4) AS perc_sco4,\n" +
" p.perc_prov,\n" +
" CONVERT(NUMERIC(20, 5), 0) AS qta_residua,\n" +
" CONVERT(BIGINT, NULL) AS id_contratto,\n" +
" ISNULL(p.rap_conv, l.rap_conv) AS rap_conv,\n" +
" ISNULL(p.note, l.note) AS note,\n" +
" CAST(NULL AS VARCHAR(5)) AS cod_vdes,\n" +
" l.cod_tcol_ul AS cod_tcol_ul,\n" +
" ISNULL(p.unt_mis_ven, l.unt_mis_ven) AS unt_mis_ven,\n" +
" l.colli_pedana AS colli_pedana,\n" +
" ISNULL(p.tipo_variazione, l.tipo_variazione) AS tipo_variazione,\n" +
" CONVERT(VARCHAR(1), CASE\n" +
" WHEN p.cod_promo IS NULL THEN NULL\n" +
" ELSE 'P' END) AS tipo_promo,\n" +
" CONVERT(VARCHAR(5), NULL) AS cod_paga,\n" +
" CONVERT(VARCHAR(5), NULL) AS descr_paga,\n" +
" l.porto,\n" +
" l.qta_cnf,\n" +
" NULL AS note_incoterms,\n" +
" NULL AS data_rif_scad,\n" +
" NULL AS note_carico,\n" +
" NULL AS term_cons,\n" +
" NULL AS cod_banc,\n" +
" NULL AS descr_banc,\n" +
" l.flag_primario\n" +
" FROM dbo.getListinoVenditaPedane(@dataValidita, @codVlis, NULL, @pedane) l\n" +
" LEFT OUTER JOIN dbo.getPromozioneVendita(@dataValidita, @dataValidita,\n" +
" @codVlis, NULL, NULL) p\n" +
" ON l.cod_vlis = p.cod_vlis AND l.cod_mart = p.cod_mart AND\n" +
" ISNULL(@viewPromo, 0) = 1\n" +
" WHERE l.cod_vlis = @codVlis\n" +
" AND l.cod_mart IN (SELECT cod_mart\n" +
" FROM assortimento\n" +
" UNION ALL\n" +
" SELECT cod_mart\n" +
" FROM listino)\n" +
" AND l.tipo_variazione <> 'D'\n" +
" AND l.tipo_variazione IS NOT NULL\n" +
" AND l.flag_attivo = 'S'\n" +
" UNION ALL\n" +
" SELECT l.cod_mart,\n" +
" l.cod_vlis,\n" +
" NULL AS data_iniz,\n" +
" NULL AS data_fine,\n" +
" NULL AS da,\n" +
" NULL AS a,\n" +
" NULL AS prz_vend,\n" +
" NULL AS prz_vend_netto,\n" +
" NULL AS perc_sco1,\n" +
" NULL AS perc_sco2,\n" +
" NULL AS perc_sco3,\n" +
" NULL AS perc_sco4,\n" +
" NULL AS perc_prov,\n" +
" NULL AS qta_residua,\n" +
" NULL AS id_contratto,\n" +
" um.rap_conv AS rap_conv,\n" +
" NULL AS note,\n" +
" CAST(NULL AS VARCHAR(5)) AS cod_vdes,\n" +
" NULL AS cod_tcol_ul,\n" +
" l.unt_mis_ven AS unt_mis_ven,\n" +
" NULL AS colli_pedana,\n" +
" NULL AS tipo_variazione,\n" +
" NULL AS tipo_promo,\n" +
" CONVERT(VARCHAR(5), NULL) AS cod_paga,\n" +
" CONVERT(VARCHAR(5), NULL) AS descr_paga,\n" +
" NULL porto,\n" +
" mtb_aart.qta_cnf,\n" +
" NULL AS note_incoterms,\n" +
" NULL AS data_rif_scad,\n" +
" NULL AS note_carico,\n" +
" NULL AS term_cons,\n" +
" NULL AS cod_banc,\n" +
" NULL AS descr_banc,\n" +
" 1 AS flag_primario\n" +
" FROM mtb_lisv l\n" +
" INNER JOIN listino ON l.cod_mart = listino.cod_mart\n" +
" INNER JOIN mtb_aart ON l.cod_mart = mtb_aart.cod_mart\n" +
" CROSS APPLY dbo.getUntMisArticolo(l.cod_mart, l.unt_mis_ven) um\n" +
" WHERE l.cod_vlis = @codVlis\n" +
" AND listino.tipo_variazione IS NULL\n" +
" UNION ALL\n" +
" SELECT vvw_contratti_vendita.cod_mart,\n" +
" NULL AS cod_vlis,\n" +
" vvw_contratti_vendita.data_iniz,\n" +
" vvw_contratti_vendita.data_fine,\n" +
" NULL AS da,\n" +
" NULL AS a,\n" +
" vvw_contratti_vendita.prz_vend,\n" +
" ROUND(vvw_contratti_vendita.prz_vend *\n" +
" (1 - ISNULL(vvw_contratti_vendita.perc_sco1, 0))\n" +
" * (1 - ISNULL(vvw_contratti_vendita.perc_sco2, 0))\n" +
" * (1 - ISNULL(vvw_contratti_vendita.perc_sco3, 0))\n" +
" * (1 - ISNULL(vvw_contratti_vendita.perc_sco4, 0)),\n" +
" 5) AS prz_vend_netto,\n" +
" vvw_contratti_vendita.perc_sco1,\n" +
" vvw_contratti_vendita.perc_sco2,\n" +
" vvw_contratti_vendita.perc_sco3,\n" +
" vvw_contratti_vendita.perc_sco4,\n" +
" vvw_contratti_vendita.perc_prov,\n" +
" vvw_contratti_vendita.qta_residua,\n" +
" vvw_contratti_vendita.id_contratto,\n" +
" vvw_contratti_vendita.rap_conv,\n" +
" vvw_contratti_vendita.note,\n" +
" vvw_contratti_vendita.cod_vdes,\n" +
" NULL,\n" +
" vvw_contratti_vendita.unt_mis_ven,\n" +
" NULL,\n" +
" NULL,\n" +
" 'C' AS tipo_promo,\n" +
" vvw_contratti_vendita.cod_paga,\n" +
" vvw_contratti_vendita.descrizione_paga AS descr_paga,\n" +
" vvw_contratti_vendita.incoterms AS porto,\n" +
" mtb_aart.qta_cnf,\n" +
" vvw_contratti_vendita.note_incoterms,\n" +
" vvw_contratti_vendita.data_rif_scad,\n" +
" vvw_contratti_vendita.note_carico,\n" +
" vvw_contratti_vendita.term_cons,\n" +
" vvw_contratti_vendita.cod_banc,\n" +
" vvw_contratti_vendita.descr_banc,\n" +
" 1 AS flag_primario\n" +
" FROM vvw_contratti_vendita\n" +
" INNER JOIN mtb_aart ON vvw_contratti_vendita.cod_mart = mtb_aart.cod_mart\n" +
" WHERE vvw_contratti_vendita.cod_anag = @codAnag\n" +
" AND (@codVdes IS NULL OR vvw_contratti_vendita.cod_vdes IS NULL OR\n" +
" vvw_contratti_vendita.cod_vdes = @codVdes)\n" +
" AND (ISNULL(@dataValidita, CAST(GETDATE() AS DATE)) BETWEEN\n" +
" vvw_contratti_vendita.data_iniz AND vvw_contratti_vendita.data_fine)\n" +
"-- AND vvw_contratti_vendita.qta_residua >= 0\n" +
" )\n" +
"\n" +
" SELECT tmp_lisv.cod_mart,\n" +
" ISNULL(maa.cod_mart_anag, tmp_lisv.cod_mart) AS cod_mart_anag,\n" +
" cod_vlis,\n" +
" data_iniz,\n" +
" data_fine,\n" +
" da,\n" +
" a,\n" +
" prz_vend,\n" +
" prz_vend_netto,\n" +
" perc_sco1,\n" +
" perc_sco2,\n" +
" perc_sco3,\n" +
" perc_sco4,\n" +
" perc_prov,\n" +
" qta_residua,\n" +
" id_contratto,\n" +
" rap_conv,\n" +
" ISNULL(maa.note, tmp_lisv.note) AS note,\n" +
" cod_tcol_ul,\n" +
" unt_mis_ven,\n" +
" CASE\n" +
" WHEN maa.colli_pedana IS NULL OR maa.colli_pedana = 0 THEN tmp_lisv.colli_pedana\n" +
" ELSE maa.colli_pedana END AS colli_pedana,\n" +
" tipo_variazione,\n" +
" tipo_promo,\n" +
" cod_paga,\n" +
" descr_paga,\n" +
" porto,\n" +
" qta_cnf,\n" +
" CAST(CASE WHEN tmp_lisv.data_iniz IS NULL THEN 0 ELSE 1 END AS BIT) AS art_lisv,\n" +
" tmp_lisv.cod_vdes,\n" +
" note_incoterms,\n" +
" data_rif_scad,\n" +
" note_carico,\n" +
" term_cons,\n" +
" cod_banc,\n" +
" descr_banc,\n" +
" flag_primario\n" +
" FROM tmp_lisv\n" +
" LEFT OUTER JOIN mtb_aart_anag maa\n" +
" ON tmp_lisv.cod_mart = maa.cod_mart AND maa.cod_anag = @codAnag)");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,30 @@
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_20251211085116 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createSetup("W_CREG_IVA_DISP", "DATAWINDOW", "D_CREG_IVA_REP", null,
null, false, null, false, false,
false, false, false, null, false, null);
if(isCustomer(IntegryCustomer.Cosmapack)) {
updateSetupValue("W_CREG_IVA_DISP", "DATAWINDOW", "D_CREG_IVA_REP", "d_creg_iva_cosmopack_rep");
}
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,24 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20251211162655 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createSetupQuery("SI_NO", "SI_NO", "SELECT 'S' UNION ALL SELECT 'N'");
createSetup("PVM", "ORDINI_V_SLIM2K", "EXPORT_ORDINI", "N",
"Esporta gli ordini già esportati", false, "SI_NO", false, false,
false, false, false, null, false, "SELECT 'S' UNION ALL SELECT 'N'");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,28 @@
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_20251211165528 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createSetup("w_vriepfattagecomp_disp", "CB_VIS_DETTAGLIO", "VISIBLE", "N",
null, false, null, false, false,
false, false, false, null, false, null);
if(isCustomer(IntegryCustomer.RossoGargano)) {
updateSetupValue("w_vriepfattagecomp_disp", "CB_VIS_DETTAGLIO", "VISIBLE", "S");
}
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,68 @@
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_20251212095000 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
if(isCustomer(IntegryCustomer.RossoGargano)) {
executeStatement("INSERT INTO dtb_note_doc (note, data_iniz, data_fine, flag_bio)\n" +
"SELECT \n" +
" (\n" +
" SELECT value \n" +
" FROM stb_gest_setup \n" +
" WHERE gest_name = 'stampa_documenti'\n" +
" AND section = 'bio'\n" +
" AND key_section = 'descrizione'\n" +
" )\n" +
" + ' ' +\n" +
" (\n" +
" SELECT value \n" +
" FROM stb_gest_setup \n" +
" WHERE gest_name = 'stampa_documenti'\n" +
" AND section = 'bio'\n" +
" AND key_section = 'certificato'\n" +
" ) AS note,\n" +
" '2025-07-01',\n" +
" '2099-12-31',\n" +
" 1;",
"INSERT INTO drl_tipi_note_doc (cod_dtip, id_note, id_riga)\n" +
"SELECT\n" +
" t.cod_dtip,\n" +
" n.id_note,\n" +
" ISNULL(\n" +
" (\n" +
" SELECT MAX(d.id_riga)\n" +
" FROM drl_tipi_note_doc d\n" +
" WHERE d.cod_dtip = t.cod_dtip\n" +
" ), 0\n" +
" ) + 1 AS id_riga\n" +
"FROM (\n" +
" SELECT MAX(id) AS id_note\n" +
" FROM dtb_note_doc\n" +
" WHERE flag_bio = 1\n" +
" ) n\n" +
"JOIN (\n" +
" SELECT cod_dtip\n" +
" FROM dtb_tipi\n" +
" WHERE gestione = 'V'\n" +
" AND mod_stamp IN ('bolac', 'fat', 'fatac')\n" +
" ) t\n" +
"ON 1 = 1;",
"UPDATE stb_gest_setup set value = null \n" +
"WHERE gest_name = 'stampa_documenti'\n" +
" AND section = 'bio'\n" +
" AND key_section IN ('certificato','descrizione');");
}
}
@Override
public void down() throws Exception {
}
}

View File

@@ -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 {
}
}

View File

@@ -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 {
}
}

View File

@@ -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 {
}
}

View File

@@ -0,0 +1,44 @@
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_20251216103055 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createSetup("PVM", "RILEVAZIONI_STEUP", "FORN_INEVASI", null, "Inserire un json [\n" +
"\t{\n" +
"\t\t\"partitaIva\": \"\",\n" +
"\t\t\"ggCons\": 7\n" +
"\t}]", false,
null,
true, false, false, true, false, null, false, null);
if (!isCustomerDb(IntegryCustomerDB.Carelli_Winact)) return;
String json = "[\n" +
"\t{\n" +
"\t\t\"partitaIva\": \"05848860721\",\n" +
"\t\t\"ggCons\": 7\n" +
"\t},\n" +
"\t{\n" +
"\t\t\"partitaIva\": \"05754810728\",\n" +
"\t\t\"ggCons\": 7\n" +
"\t},\n" +
"\t{\n" +
"\t\t\"partitaIva\": \"07716650721\",\n" +
"\t\t\"ggCons\": 1\n" +
"\t}\n" +
"]";
updateSetupValue("PVM", "RILEVAZIONI_STEUP", "FORN_INEVASI", json);
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,23 @@
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_20251217111203 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
enableSaveToRest("maart_equi");
if ( !isCustomer(IntegryCustomer.Smetar)) return;
executeStatement("update mtb_aart_equi set flag_equi_anag = 1");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -184,7 +184,7 @@ public class AccountingRules extends QueryRules {
if (!UtilityString.isNullOrEmpty(codBiva)) {
for (CtbMovi ctbMovi : ctbMovt.getCtbMovi()) {
if (UtilityString.isNullOrEmpty(ctbMovi.getCodBiva()) && !ctbMovi.getCodBiva().equalsIgnoreCase(EmsRestConstants.NULL)) {
if (ctbMovi.getCodBiva() != null && ctbMovi.getCodBiva().trim().isEmpty()) {
ctbMovi.setCodBiva(codBiva);
}
movi.add(ctbMovi);

View File

@@ -4,7 +4,8 @@ import com.annimon.stream.ComparatorCompat;
import com.annimon.stream.Stream;
import it.integry.common.var.CommonConstants;
import it.integry.ems._context.ApplicationContextProvider;
import it.integry.ems.dynamic_cache.EntityCacheComponent;
import it.integry.ems.jpa.repository.MtbAartRepository;
import it.integry.ems.jpa.repository.MtbUntMisRepository;
import it.integry.ems.json.ResponseJSONObjectMapper;
import it.integry.ems.migration._base.IntegryCustomerDB;
import it.integry.ems.sync.MultiDBTransaction.Connection;
@@ -21,6 +22,7 @@ import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
import it.integry.ems_model.types.ApplicationName;
import it.integry.ems_model.types.OperationType;
import it.integry.ems_model.utility.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
@@ -674,41 +676,46 @@ public class CommonRules extends QueryRules {
public static String completeCodBarre(IntegryCustomerDB customerDB, Connection connection, String codMart)
throws SQLException {
final EntityCacheComponent entityCacheComponent = ApplicationContextProvider.getApplicationContext().getBean(EntityCacheComponent.class);
final MtbAartRepository mtbAartRepository = ApplicationContextProvider.getApplicationContext().getBean(MtbAartRepository.class);
List<HashMap<String, Object>> result = new ArrayList<>();
entityCacheComponent.<MtbAart>getCachedEntitiesStream(customerDB, MtbAart.ENTITY,
x -> x.getCodMart().equalsIgnoreCase(codMart) && !UtilityString.isNullOrEmpty(x.getBarCode()))
.forEach(x -> result.add(new HashMap<String, Object>() {{
put("cod_mart", x.getCodMart());
put("cod_barre", x.getBarCode());
Optional<MtbAart> optMtbAart = mtbAartRepository.findWithBarcodeByCodMart(codMart);
if (optMtbAart.isPresent()) {
MtbAart mtbAart = optMtbAart.get();
if (!UtilityString.isNullOrEmpty(mtbAart.getBarCode())) {
result.add(new HashMap<String, Object>() {{
put("cod_mart", mtbAart.getCodMart());
put("cod_barre", mtbAart.getBarCode());
put("cod_col", null);
put("cod_tagl", null);
put("qta_cnf", BigDecimal.ONE);
}}));
}});
}
entityCacheComponent.<MtbAart>getCachedEntitiesStream(customerDB, MtbAart.ENTITY,
x -> x.getCodMart().equalsIgnoreCase(codMart) && !UtilityString.isNullOrEmpty(x.getCodBarreImb()))
.forEach(x -> result.add(new HashMap<String, Object>() {{
put("cod_mart", x.getCodMart());
put("cod_barre", x.getCodBarreImb());
if (!UtilityString.isNullOrEmpty(mtbAart.getCodBarreImb())) {
result.add(new HashMap<String, Object>() {{
put("cod_mart", mtbAart.getCodMart());
put("cod_barre", mtbAart.getCodBarreImb());
put("cod_col", null);
put("cod_tagl", null);
put("qta_cnf", x.getQtaCnf());
}}));
entityCacheComponent.<MtbAartBarCode>getCachedEntitiesStream(customerDB, MtbAartBarCode.ENTITY,
x -> x.getCodMart().equalsIgnoreCase(codMart))
.forEach(x -> result.add(new HashMap<String, Object>() {{
put("cod_mart", x.getCodMart());
put("cod_barre", x.getCodBarre());
put("cod_col", null);
put("cod_tagl", null);
put("qta_cnf", x.getQtaCnf());
}}));
put("qta_cnf", mtbAart.getQtaCnf());
}});
}
if (mtbAart.getMtbAartBarCode() != null) {
mtbAart.getMtbAartBarCode()
.forEach(x -> result.add(new HashMap<String, Object>() {{
put("cod_mart", x.getCodMart());
put("cod_barre", x.getCodBarre());
put("cod_col", null);
put("cod_tagl", null);
put("qta_cnf", x.getQtaCnf());
}}));
}
}
String barcode = null;
@@ -728,14 +735,12 @@ public class CommonRules extends QueryRules {
}
public static String completeFlagQtaCnfFissa(Connection connection, IntegryCustomerDB customerDB, String codMart) {
final EntityCacheComponent entityCacheComponent = ApplicationContextProvider.getApplicationContext().getBean(EntityCacheComponent.class);
final MtbAartRepository mtbAartRepository = ApplicationContextProvider.getApplicationContext().getBean(MtbAartRepository.class);
final List<MtbAart> cachedMtbAarts = entityCacheComponent.getCachedEntitiesList(customerDB, MtbAart.ENTITY, x -> x.getCodMart().equals(codMart));
final String flagQtaCnfFissaArt = mtbAartRepository.findFlagQtaCnfFissaByCodMart(codMart)
.orElse(null);
if (cachedMtbAarts == null || cachedMtbAarts.isEmpty())
return null;
return cachedMtbAarts.get(0).getFlagQtaCnfFissa();
return flagQtaCnfFissaArt;
}
public static String getApplicationName(Connection connection) throws Exception {
@@ -1092,6 +1097,8 @@ public class CommonRules extends QueryRules {
}
public static List<MtbUntMis> insUntMis(Connection conn, MtbAart mtbAart) throws Exception {
MtbUntMisRepository mtbUntMisRepository = ApplicationContextProvider.getApplicationContext().getBean(MtbUntMisRepository.class);
List<MtbUntMis> mtbUntMisList = new ArrayList<>();
List<String> untMisList = new ArrayList<>();
@@ -1106,8 +1113,7 @@ public class CommonRules extends QueryRules {
}
for (String untMis : untMisList) {
String sql = "SELECT count(*) FROM mtb_unt_mis WHERE unt_mis = " + UtilityDB.valueToString(untMis);
Integer countUM = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
Integer countUM = mtbUntMisRepository.countByUntMis(untMis);
if (countUM == null || countUM == 0) {
MtbUntMis mtbUntMis = new MtbUntMis();
mtbUntMis.setUntMis(untMis);
@@ -1378,16 +1384,73 @@ public class CommonRules extends QueryRules {
public static boolean getChkCompatibilitaCarat(Connection connection, String codMart, String carat) throws SQLException {
String sql =
Query.format("SELECT chk_compatibilita\n" +
"FROM mtb_aart\n" +
" INNER JOIN mtb_tipi_carat ON mtb_aart.cod_mtip = mtb_tipi_carat.cod_mtip AND\n" +
" mtb_aart.cod_mstp = mtb_tipi_carat.cod_mstp\n" +
"WHERE mtb_aart.cod_mart = %s\n" +
" AND mtb_tipi_carat.carat = %s\n" ,
codMart, carat);
"FROM mtb_aart\n" +
" INNER JOIN mtb_tipi_carat ON mtb_aart.cod_mtip = mtb_tipi_carat.cod_mtip AND\n" +
" mtb_aart.cod_mstp = mtb_tipi_carat.cod_mstp\n" +
"WHERE mtb_aart.cod_mart = %s\n" +
" AND mtb_tipi_carat.carat = %s\n",
codMart, carat);
Boolean chkCompatibilita = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
if (chkCompatibilita == null) chkCompatibilita = false;
return chkCompatibilita;
}
public static void updArtEqui(Connection conn, MtbAart mtbAart) throws Exception {
if (UtilityString.isNullOrEmpty(mtbAart.getIdArtEqui())) return;
if (!mtbAart.isUpdArtEqui()) return;
boolean equiAnag = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn,
Query.format("select flag_equi_anag \n" +
"FROM mtb_aart_equi \n" +
"WHERE id_art_equi = {} ",
mtbAart.getIdArtEqui()));
if (!equiAnag) return;
boolean modify = true;
if (mtbAart.getOriginalEntity() != null) {
MtbAart originalMtbAart = (MtbAart) mtbAart.getOriginalEntity();
modify = (!UtilityString.isNullOrEmpty(originalMtbAart.getUntMis()) ||
!UtilityString.isNullOrEmpty(originalMtbAart.getUntMis2()) ||
!UtilityString.isNullOrEmpty(originalMtbAart.getUntMis3()) ||
!UtilityBigDecimal.isNullOrZero(originalMtbAart.getRapConv2()) ||
!UtilityBigDecimal.isNullOrZero(originalMtbAart.getRapConv3()) ||
!UtilityBigDecimal.isNullOrZero(originalMtbAart.getPesoKg()) ||
!UtilityBigDecimal.isNullOrZero(originalMtbAart.getQtaCnf()) ||
!UtilityBigDecimal.isNullOrZero(originalMtbAart.getColliPedana()) ||
!UtilityBigDecimal.isNullOrZero(originalMtbAart.getColliStrato()) ||
!UtilityBigDecimal.isNullOrZero(originalMtbAart.getTaraKg()));
}
if (!modify) return;
List<MtbAart> mtbAarts = UtilityDB.executeSimpleQueryDTO(conn,
Query.format("SELECT * \n" +
"FROM mtb_aart \n" +
"WHERE id_art_equi is not null AND \n" +
"id_art_equi = {} AND \n " +
"cod_mart <> {}",
mtbAart.getIdArtEqui(),
mtbAart.getCodMart()), MtbAart.class);
if ( mtbAarts == null || mtbAarts.isEmpty()) return;
for (MtbAart m : mtbAarts) {
m.setUntMis(mtbAart.getUntMis())
.setUntMis2(mtbAart.getUntMis2())
.setUntMis3(mtbAart.getUntMis3())
.setRapConv2(mtbAart.getRapConv2())
.setRapConv3(mtbAart.getRapConv3())
.setPesoKg(mtbAart.getPesoKg())
.setQtaCnf(mtbAart.getQtaCnf())
.setColliPedana(mtbAart.getColliPedana())
.setColliStrato(mtbAart.getColliStrato())
.setTaraKg(mtbAart.getTaraKg())
.setUpdArtEqui(false)
.setOperation(OperationType.UPDATE);
}
mtbAart.setArticoliEquivalenti(mtbAarts);
}
}

View File

@@ -435,12 +435,12 @@ public class DocumentCheckRules {
}
if (returnVal && entity.getOperation() == OperationType.INSERT) {
throw new Exception("DOCUMENTO INTESTATO A " + entity.getCodAnag() + " - " + entity.getCodDtip() + " N. " + entity.getNumDoc().toString() + "/" + entity.getSerDoc() + " DEL " + new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY).format(entity.getDataDoc()) + " GIA' ESISTENTE");
throw new Exception(String.format("Documento intestato a %s - %s numero %s/%d già esistente", entity.getCodAnag(), entity.getCodDtip(), entity.getSerDoc(), entity.getNumDoc()));
} else {
if (checkDocInSequenza(conn, entity) == false && "AUTOMATICA".equalsIgnoreCase(tipoNumeraz) &&
entity.getOperation() != OperationType.UPDATE) {
String valueDataDoc = new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY).format(dataDoc);
throw new Exception("(DOC. " + codDtip + "" + numDoc + "/" + serDoc + " DEL " + valueDataDoc + " INTESTATO A " + codAnag + " FUORI SEQUENZA)");
throw new Exception("(Doc. " + codDtip + "" + numDoc + "/" + serDoc + " del " + valueDataDoc + " intestato a " + codAnag + " fuori sequenza)");
}
}

View File

@@ -27,7 +27,7 @@ public class DocumentRules extends QueryRules {
public static Date getDataRicezioneAllegati(Connection conn, List<DrlDocAttached> drlDocAttached) throws Exception {
String minDataRic = setupGest.getSetup(conn, "CTB_MOVI", "SETUP", "SET_DATA_RICEZIONE");
LocalDateTime dataRicMin = LocalDateTime.parse(minDataRic, CommonConstants.DATETIME_YMD_DASHED_FORMATTER);
LocalDateTime dataRicMin = UtilityString.parseLocalDateTime(minDataRic);
String idAttach = drlDocAttached.get(0).getIdAttach();
String sqlAttach =

View File

@@ -2,7 +2,8 @@ package it.integry.ems.rules.completing;
import com.annimon.stream.Stream;
import it.integry.ems._context.ApplicationContextProvider;
import it.integry.ems.dynamic_cache.EntityCacheComponent;
import it.integry.ems.jpa.repository.MtbAartRepository;
import it.integry.ems.jpa.repository.MtbUntMisRepository;
import it.integry.ems.migration._base.IntegryCustomerDB;
import it.integry.ems.rules.completing.dto.DatiPartitaMagDTO;
import it.integry.ems.sync.MultiDBTransaction.Connection;
@@ -333,16 +334,14 @@ public class PackagesRules extends QueryRules {
public static HashMap<String, Object> calcPeso(IntegryCustomerDB customerDB, Connection conn, MtbColr entity) throws Exception {
final EntityCacheComponent entityCacheComponent = ApplicationContextProvider.getApplicationContext().getBean(EntityCacheComponent.class);
final MtbAartRepository mtbAartRepository = ApplicationContextProvider.getApplicationContext().getBean(MtbAartRepository.class);
final MtbUntMisRepository mtbUntMisRepository = ApplicationContextProvider.getApplicationContext().getBean(MtbUntMisRepository.class);
BigDecimal cifreDec = entityCacheComponent.<MtbUntMis>getCachedEntitiesStream(customerDB, MtbUntMis.ENTITY,
x -> x.getFlagUnitaKg().equalsIgnoreCase("S"))
.map(MtbUntMis::getCifreDec)
BigDecimal cifreDec = mtbUntMisRepository.findCifreDecByFlagUnitaKg("S").stream()
.findFirst()
.orElse(BigDecimal.valueOf(5));
HashMap<String, Object> anagArt = entityCacheComponent.<MtbAart>getCachedEntitiesStream(customerDB, MtbAart.ENTITY,
x -> x.getCodMart().equalsIgnoreCase(entity.getCodMart()))
HashMap<String, Object> anagArt = mtbAartRepository.findByCodMart(entity.getCodMart())
.map(x -> new HashMap<String, Object>() {{
put("unt_mis", x.getUntMis());
put("tara_kg", x.getTaraKg());
@@ -350,7 +349,6 @@ public class PackagesRules extends QueryRules {
put("flag_peso_egalizzato", x.getFlagPesoEgalizzato());
put("peso_egalizzato", x.getFlagPesoEgalizzato() ? x.getQtaCnf().multiply(x.getPesoKg()) : null);
}})
.findFirst()
.orElse(null);
@@ -365,10 +363,8 @@ public class PackagesRules extends QueryRules {
BigDecimal pesoNetto = BigDecimal.ZERO, pesoLordo = BigDecimal.ZERO;
if (anagArt != null) {
String flagUnitaKg = entityCacheComponent.<MtbUntMis>getCachedEntitiesStream(customerDB, MtbUntMis.ENTITY,
x -> x.getUntMis().equalsIgnoreCase(String.valueOf(anagArt.get("unt_mis"))))
String flagUnitaKg = mtbUntMisRepository.findByUntMis((String) anagArt.get("unt_mis"))
.map(MtbUntMis::getFlagUnitaKg)
.findFirst()
.orElse(null);
BigDecimal taraKg = (BigDecimal) anagArt.get("tara_kg");

View File

@@ -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);

View File

@@ -9,6 +9,7 @@ import it.integry.ems.file_sharer.IFileSharerAttachment;
import it.integry.ems.file_sharer.sharers.email.EmailFileAttachment;
import it.integry.ems.file_sharer.sharers.email.EmailFileSharer;
import it.integry.ems.file_sharer.sharers.email.EmailFileSharerSettings;
import it.integry.ems.jpa.repository.StbEmailRepository;
import it.integry.ems.json.ResponseJSONObjectMapper;
import it.integry.ems.media.MimeTypesHandler;
import it.integry.ems.response.FileItem;
@@ -24,7 +25,6 @@ import it.integry.ems.utility.UtilityDebug;
import it.integry.ems_model.base.EntityBase;
import it.integry.ems_model.entity.StbEmail;
import it.integry.ems_model.service.SetupGest;
import it.integry.ems_model.utility.UtilityDB;
import it.integry.ems_model.utility.UtilityList;
import it.integry.ems_model.utility.UtilityLocalDate;
import it.integry.ems_model.utility.UtilityString;
@@ -78,6 +78,9 @@ public class MailService {
@Autowired
private EmsDBConst emsDBConst;
@Autowired
private StbEmailRepository stbEmailRepository;
private final Logger logger = LogManager.getLogger();
public enum Level {
@@ -87,7 +90,7 @@ public class MailService {
ERROR
}
public static EmailFileSharerSettings readParameter(@NotNull Connection connection, String fromEmail) throws Exception {
public EmailFileSharerSettings readParameter(@NotNull Connection connection, String fromEmail) throws Exception {
if (UtilityDebug.isIntegryServerDev()) {
return useSystemParams();
}
@@ -95,15 +98,16 @@ public class MailService {
EmailFileSharerSettings emailSettings = new EmailFileSharerSettings();
String sql;
StbEmail stbEmail = null;
if (!UtilityString.isNullOrEmpty(fromEmail)) {
sql = "SELECT * from stb_email WHERE e_mail = " + UtilityDB.valueToString(fromEmail);
stbEmail = stbEmailRepository.findByEmailIgnoreCase(fromEmail)
.orElse(null);
} else {
sql = "SELECT * from stb_email WHERE flag_default = 'S'";
stbEmail = stbEmailRepository.findByFlagDefaultTrue()
.orElse(null);
}
List<StbEmail> listEmail = UtilityDB.executeSimpleQueryDTO(connection, sql, StbEmail.class);
StbEmail stbEmail = listEmail != null && !listEmail.isEmpty() ? listEmail.get(0) : null;
if (stbEmail != null && stbEmail.getIdRiga() != null) {
EmailFileSharerSettings.ENCRYPTION encryption = EmailFileSharerSettings.ENCRYPTION.NONE;
@@ -204,7 +208,7 @@ public class MailService {
}
public Message sendMailPrimary(Connection connection, String from, String
fromName, String to, String cc, String ccn,
fromName, String to, String cc, String ccn,
String subject, String msgText, Boolean isHtml, Boolean isDebug, String replyTo, String
replyToName, List<IFileSharerAttachment> emailFileAttachmentList, boolean requestDeliveryNotification,
String deliveryNotificationTo) throws
@@ -231,7 +235,7 @@ public class MailService {
}
public Message sendMailPrimary(Connection connection, String from, String
fromName, List<String> listTo, List<String> listCc, List<String> ListCcn,
fromName, List<String> listTo, List<String> listCc, List<String> ListCcn,
String subject, String msgText, Boolean isHtml, Boolean isDebug, String replyTo, String
replyToName, List<IFileSharerAttachment> emailFileAttachmentList, boolean requestDeliveryNotification,
String deliveryNotificationTo) throws
@@ -300,7 +304,7 @@ public class MailService {
}
public EmailFileSharerSettings internalReadParameter(Connection connection, String fromEmail) throws Exception {
return MailService.readParameter(connection, fromEmail);
return readParameter(connection, fromEmail);
}
public Message sendMail(String from, String fromName, String to, String cc, String subject, String msg) throws Exception {
@@ -492,56 +496,29 @@ public class MailService {
internalSendSystemMail(Level.SUCCESS, mailSubject, mailTitle, mailContent, footerDate);
}
public void sendSystemWarningLog(String mailSubject, String mailTitle, String mailContent, String exceptionMessage, Date footerDate) throws Exception {
mailContent += "<br /><br /><br />\n" +
"<hr noshade size=\"1\"><br />" +
"<p style=\"text-align: left; font-weight: bold;font-size: 12px;\">ERROR LOG</p>" +
"<p style=\"text-align: left; font-size: 12px; color: gray; font-family: consolas;\">" + exceptionMessage + "</p>";
internalSendSystemMail(Level.WARNING, mailSubject, mailTitle, mailContent, footerDate);
}
public void sendSystemWarningLog(String mailSubject, String mailTitle, String mailContent, Exception ex, Date footerDate) throws Exception {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
ex.printStackTrace(pw);
mailContent += "<br /><br /><br />\n" +
"<hr noshade size=\"1\"><br />" +
"<p style=\"text-align: left; font-weight: bold;font-size: 12px;\">ERROR LOG</p>" +
"<p style=\"text-align: left; font-size: 12px; color: gray; font-family: consolas;\">" + sw + "</p>";
pw.close();
sw.close();
internalSendSystemMail(Level.WARNING, mailSubject, mailTitle, mailContent, footerDate);
}
public void sendSystemErrorLog(String mailSubject, String mailTitle, String mailContent, String exceptionMessage, Date footerDate) throws Exception {
mailContent += "<br /><br /><br />\n" +
"<hr noshade size=\"1\"><br />" +
"<p style=\"text-align: left; font-weight: bold;font-size: 12px;\">ERROR LOG</p>" +
"<p style=\"text-align: left; font-size: 12px; color: gray; font-family: consolas;\">" + exceptionMessage + "</p>";
internalSendSystemMail(Level.ERROR, mailSubject, mailTitle, mailContent, footerDate);
internalSendSystemLogMail(Level.WARNING, mailSubject, mailTitle, mailContent, ex, footerDate);
}
public void sendSystemErrorLog(String mailSubject, String mailTitle, String mailContent, Exception ex, Date footerDate) throws Exception {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
ex.printStackTrace(pw);
internalSendSystemLogMail(Level.ERROR, mailSubject, mailTitle, mailContent, ex, footerDate);
}
private void internalSendSystemLogMail(Level mailLevel, String mailSubject, String mailTitle, String mailContent, Exception ex, Date footerDate) throws Exception {
if (ex != null) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
ex.printStackTrace(pw);
mailContent += "<br /><br /><br />\n" +
"<hr noshade size=\"1\"><br />" +
"<p style=\"text-align: left; font-weight: bold;font-size: 12px;\">ERROR LOG</p>" +
"<p style=\"text-align: left; font-size: 12px; color: gray; font-family: consolas;\">" + sw + "</p>";
pw.close();
sw.close();
mailContent += "<br /><br /><br />\n" +
"<p style=\"text-align: left; font-weight: bold;font-size: 12px;\">Stacktrace</p>" +
"<pre>" + sw + "</pre>";
pw.close();
sw.close();
}
internalSendSystemMail(Level.ERROR, mailSubject, mailTitle, mailContent, footerDate);
internalSendSystemMail(mailLevel, mailSubject, mailTitle, mailContent, footerDate);
}
private void internalSendSystemMail(Level mailLevel, String mailSubject, String mailTitle, String mailContent, Date footerDate) throws Exception {

View File

@@ -25,7 +25,7 @@ public class MailTemplateService {
URL url = new URL(baseUrl + fileName);
InputStream inputStream = url.openStream();
String htmlMailBody = IOUtils.toString(inputStream, StandardCharsets.ISO_8859_1);
String htmlMailBody = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
inputStream.close();
return htmlMailBody;

View File

@@ -109,6 +109,20 @@ public class BasicConnectionPool {
}
}
public javax.sql.DataSource getDataSource(String profileName) {
AvailableConnectionModel model = settingsModel.findConnectionModel(profileName);
if (model == null) {
return null;
}
try {
registerDataSourceIfNotExists(model);
return registeredDatasources.get(model);
} catch (Exception e) {
logger.error("Error retrieving DataSource for profile: " + profileName, e);
return null;
}
}
private void registerDataSourceIfNotExists(AvailableConnectionModel connectionModel) throws Exception {
if (!registeredDatasources.containsKey(connectionModel)) {

View File

@@ -101,7 +101,7 @@ public class MultiDBTransactionManager implements AutoCloseable {
return;
}
try {
String profileDb = settingsModel.getDefaultProfile();
String profileDb = null;
if (requestData != null && requestData.isValidProfileDB()) {
profileDb = requestData.getProfileDB();
}

View File

@@ -0,0 +1,20 @@
package it.integry.ems.utility.entity;
import it.integry.ems._context.ApplicationContextProvider;
import it.integry.ems.dynamic_cache.EntityCacheComponent;
import it.integry.ems.migration._base.IntegryCustomerDB;
import it.integry.ems_model.entity.MtbDepoPosizioni;
import java.util.List;
public class MtbDepoPosizioniUtils {
public static final List<MtbDepoPosizioni> getAllMonoUlPositions(IntegryCustomerDB customerDB) {
final EntityCacheComponent entityCacheComponent = ApplicationContextProvider.getApplicationContext().getBean(EntityCacheComponent.class);
return entityCacheComponent.<MtbDepoPosizioni>getCachedEntitiesList(customerDB, MtbDepoPosizioni.ENTITY,
x -> x.isFlagMonoCollo());
}
}

View File

@@ -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";

View File

@@ -13,12 +13,15 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.kie.api.definition.type.PropertyReactive;
import javax.persistence.Transient;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@javax.persistence.Entity
@javax.persistence.Table(name = MtbAart.ENTITY)
@Master
@PropertyReactive
@Table(MtbAart.ENTITY)
@@ -31,341 +34,469 @@ public class MtbAart extends EntityBase implements EquatableEntityInterface<MtbA
private static final long serialVersionUID = 1L;
@javax.persistence.Id
@javax.persistence.Column(name = "cod_mart")
@PK
@SqlField(value = "cod_mart", maxLength = 15, nullable = false)
private String codMart;
@javax.persistence.Column(name = "descrizione")
@SqlField(value = "descrizione", maxLength = 40, nullable = false)
private String descrizione;
@javax.persistence.Column(name = "unt_mis")
@FK(tableName = "mtb_unt_mis", columnName = "unt_mis")
@SqlField(value = "unt_mis", maxLength = 3, nullable = false)
private String untMis;
@javax.persistence.Column(name = "bar_code")
@SqlField(value = "bar_code", maxLength = 40)
private String barCode;
@javax.persistence.Column(name = "peso_kg")
@SqlField(value = "peso_kg", nullable = false, defaultObjectValue = "0")
private BigDecimal pesoKg;
@javax.persistence.Column(name = "qta_cnf")
@SqlField(value = "qta_cnf", nullable = false, defaultObjectValue = "1")
private BigDecimal qtaCnf;
@javax.persistence.Column(name = "cod_aliq")
@SqlField(value = "cod_aliq", maxLength = 5)
private String codAliq;
@javax.persistence.Column(name = "cod_sco_art")
@SqlField(value = "cod_sco_art", maxLength = 5)
private String codScoArt;
@javax.persistence.Column(name = "cod_tcol_ui")
@SqlField(value = "cod_tcol_ui")
private String codTcolUi;
@javax.persistence.Column(name = "cod_tcol_ul")
@SqlField(value = "cod_tcol_ul")
private String codTcolUl;
@javax.persistence.Column(name = "articolo_composto")
@SqlField(value = "articolo_composto", maxLength = 1, nullable = false, defaultObjectValue = "N")
private String articoloComposto;
@javax.persistence.Column(name = "esposizione_comp")
@SqlField(value = "esposizione_comp", maxLength = 1, nullable = false, defaultObjectValue = "N")
private String esposizioneComp;
@javax.persistence.Column(name = "descrizione_estesa")
@SqlField(value = "descrizione_estesa", maxLength = 4096)
private String descrizioneEstesa;
@javax.persistence.Column(name = "cod_ult_forn")
@SqlField(value = "cod_ult_forn", maxLength = 5)
private String codUltForn;
@javax.persistence.Column(name = "data_ult_car")
@SqlField(value = "data_ult_car")
private Date dataUltCar;
@javax.persistence.Column(name = "val_ult_car")
@SqlField(value = "val_ult_car")
private BigDecimal valUltCar;
@javax.persistence.Column(name = "cod_ult_clie")
@SqlField(value = "cod_ult_clie", maxLength = 5)
private String codUltClie;
@javax.persistence.Column(name = "data_ult_scar")
@SqlField(value = "data_ult_scar")
private Date dataUltScar;
@javax.persistence.Column(name = "val_ult_scar")
@SqlField(value = "val_ult_scar")
private BigDecimal valUltScar;
@javax.persistence.Column(name = "tipo_codice")
@SqlField(value = "tipo_codice", maxLength = 10)
private String tipoCodice;
@javax.persistence.Column(name = "note")
@SqlField(value = "note", maxLength = 255)
private String note;
@javax.persistence.Column(name = "posizione")
@SqlField(value = "posizione", maxLength = 15)
private String posizione;
@javax.persistence.Column(name = "colli_pedana")
@SqlField(value = "colli_pedana", defaultObjectValue = "1")
private BigDecimal colliPedana;
@SqlField(value = "unt_mis2", maxLength = 5)
@javax.persistence.Column(name = "unt_mis2")
@FK(tableName = "mtb_unt_mis", columnName = "unt_mis")
@SqlField(value = "unt_mis2", maxLength = 3)
private String untMis2;
@javax.persistence.Column(name = "rap_conv2")
@SqlField(value = "rap_conv2", defaultObjectValue = "1")
private BigDecimal rapConv2;
@javax.persistence.Column(name = "flag_incl_listino")
@SqlField(value = "flag_incl_listino", maxLength = 1, nullable = false, defaultObjectValue = "S")
private String flagInclListino;
@javax.persistence.Column(name = "unt_mis3")
@FK(tableName = "mtb_unt_mis", columnName = "unt_mis")
@SqlField(value = "unt_mis3", maxLength = 3)
private String untMis3;
@javax.persistence.Column(name = "rap_conv3")
@SqlField(value = "rap_conv3", defaultObjectValue = "1")
private BigDecimal rapConv3;
@javax.persistence.Column(name = "cod_mart_stat")
@SqlField(value = "cod_mart_stat", maxLength = 15)
private String codMartStat;
@javax.persistence.Column(name = "cod_mcon")
@SqlField(value = "cod_mcon", maxLength = 5)
private String codMcon;
@javax.persistence.Column(name = "cod_mgrp")
@SqlField(value = "cod_mgrp", maxLength = 5, nullable = false)
private String codMgrp;
@javax.persistence.Column(name = "cod_msfa")
@SqlField(value = "cod_msfa", maxLength = 6)
private String codMsfa;
@javax.persistence.Column(name = "cod_msgr")
@SqlField(value = "cod_msgr", maxLength = 5, nullable = false)
private String codMsgr;
@javax.persistence.Column(name = "cod_mstp")
@SqlField(value = "cod_mstp", maxLength = 5)
private String codMstp;
@javax.persistence.Column(name = "cod_mtip")
@SqlField(value = "cod_mtip", maxLength = 5)
private String codMtip;
@javax.persistence.Column(name = "descrizione_stat")
@SqlField(value = "descrizione_stat", maxLength = 40)
private String descrizioneStat;
@javax.persistence.Column(name = "flag_stato")
@SqlField(value = "flag_stato", maxLength = 1, nullable = false, defaultObjectValue = "A")
private String flagStato;
@javax.persistence.Column(name = "cambio_divi_car")
@SqlField(value = "cambio_divi_car", nullable = false)
private BigDecimal cambioDiviCar;
@javax.persistence.Column(name = "cambio_divi_scar")
@SqlField(value = "cambio_divi_scar", nullable = false)
private BigDecimal cambioDiviScar;
@javax.persistence.Column(name = "gg_scad_partita")
@SqlField(value = "gg_scad_partita", nullable = false, defaultObjectValue = "0")
private Integer ggScadPartita;
@javax.persistence.Column(name = "volume_mc")
@SqlField(value = "volume_mc", defaultObjectValue = "0")
private BigDecimal volumeMc;
@javax.persistence.Column(name = "flag_esponi_prz")
@SqlField(value = "flag_esponi_prz", maxLength = 1, nullable = false, defaultObjectValue = "N")
private String flagEsponiPrz;
@javax.persistence.Column(name = "data_ult_var")
@SqlField(value = "data_ult_var", format = CommonConstants.SYSDATE)
private Date dataUltVar;
@javax.persistence.Column(name = "perc_sfrido")
@SqlField(value = "perc_sfrido", nullable = false, defaultObjectValue = "0")
private BigDecimal percSfrido;
@javax.persistence.Column(name = "cod_barre_imb")
@SqlField(value = "cod_barre_imb", maxLength = 40)
private String codBarreImb;
@javax.persistence.Column(name = "flag_calc_prz")
@SqlField(value = "flag_calc_prz", maxLength = 1, nullable = false, defaultObjectValue = "K")
private String flagCalcPrz;
@javax.persistence.Column(name = "esposizione_comp_acq")
@SqlField(value = "esposizione_comp_acq", maxLength = 1, nullable = false, defaultObjectValue = "N")
private String esposizioneCompAcq;
@javax.persistence.Column(name = "flag_calc_prz_acq")
@SqlField(value = "flag_calc_prz_acq", maxLength = 1, nullable = false, defaultObjectValue = "K")
private String flagCalcPrzAcq;
@javax.persistence.Column(name = "diacod")
@SqlField(value = "diacod", maxLength = 40)
private String diacod;
@javax.persistence.Column(name = "plu")
@SqlField(value = "plu", maxLength = 6)
private String plu;
@javax.persistence.Column(name = "part_iva_prod")
@SqlField(value = "part_iva_prod", maxLength = 20)
private String partIvaProd;
@javax.persistence.Column(name = "rag_soc_prod")
@SqlField(value = "rag_soc_prod", maxLength = 40)
private String ragSocProd;
@javax.persistence.Column(name = "flag_rap_conv_variabile")
@SqlField(value = "flag_rap_conv_variabile", maxLength = 1, nullable = false, defaultObjectValue = "N")
private String flagRapConvVariabile;
@javax.persistence.Column(name = "flag_mov_art_mag")
@SqlField(value = "flag_mov_art_mag", maxLength = 1, nullable = false, defaultObjectValue = "S")
private String flagMovArtMag;
@javax.persistence.Column(name = "flag_tracciabilita")
@SqlField(value = "flag_tracciabilita", maxLength = 1, nullable = false, defaultObjectValue = "N")
private String flagTracciabilita;
@javax.persistence.Column(name = "tara_kg")
@SqlField(value = "tara_kg", defaultObjectValue = "0")
private BigDecimal taraKg;
@javax.persistence.Column(name = "colli_strato")
@SqlField(value = "colli_strato", nullable = false, defaultObjectValue = "1")
private BigDecimal colliStrato;
@javax.persistence.Column(name = "flag_qta_cnf_fissa")
@SqlField(value = "flag_qta_cnf_fissa", maxLength = 1, nullable = false, defaultObjectValue = "S")
private String flagQtaCnfFissa;
@javax.persistence.Column(name = "flag_colli_pedana_fisso")
@SqlField(value = "flag_colli_pedana_fisso", maxLength = 1, nullable = false, defaultObjectValue = "S")
private String flagColliPedanaFisso;
@javax.persistence.Column(name = "cod_ccon_costi")
@SqlField(value = "cod_ccon_costi", maxLength = 6)
private String codCconCosti;
@javax.persistence.Column(name = "cod_ccon_ricavi")
@SqlField(value = "cod_ccon_ricavi", maxLength = 6)
private String codCconRicavi;
@javax.persistence.Column(name = "cod_dgrp_art")
@SqlField(value = "cod_dgrp_art", maxLength = 5)
private String codDgrpArt;
@javax.persistence.Column(name = "cod_divi_car")
@SqlField(value = "cod_divi_car", maxLength = 5, nullable = false)
private String codDiviCar;
@javax.persistence.Column(name = "cod_divi_scar")
@SqlField(value = "cod_divi_scar", maxLength = 5, nullable = false)
private String codDiviScar;
@javax.persistence.Column(name = "cod_ecr_cat")
@SqlField(value = "cod_ecr_cat", maxLength = 10)
private String codEcrCat;
@javax.persistence.Column(name = "cod_ecr_mcat")
@SqlField(value = "cod_ecr_mcat", maxLength = 10)
private String codEcrMcat;
@javax.persistence.Column(name = "cod_ecr_rep")
@SqlField(value = "cod_ecr_rep", maxLength = 10)
private String codEcrRep;
@javax.persistence.Column(name = "cod_ecr_stipo")
@SqlField(value = "cod_ecr_stipo", maxLength = 10)
private String codEcrStipo;
@javax.persistence.Column(name = "cod_ecr_tipo")
@SqlField(value = "cod_ecr_tipo", maxLength = 10)
private String codEcrTipo;
@javax.persistence.Column(name = "cod_grp_bolla")
@SqlField(value = "cod_grp_bolla", maxLength = 5)
private String codGrpBolla;
@SqlField(value = "ingredienti", maxLength = 1024)
@javax.persistence.Column(name = "ingredienti")
@SqlField(value = "ingredienti", maxLength = 8000)
private String ingredienti;
@javax.persistence.Column(name = "id_art_equi")
@SqlField(value = "id_art_equi", maxLength = 25)
private String idArtEqui;
@javax.persistence.Column(name = "descr_cassa")
@SqlField(value = "descr_cassa", maxLength = 40)
private String descrCassa;
@javax.persistence.Column(name = "cod_nc_intracee")
@SqlField(value = "cod_nc_intracee", maxLength = 20)
private String codNcIntracee;
@javax.persistence.Column(name = "marchio")
@SqlField(value = "marchio", maxLength = 255)
private String marchio;
@javax.persistence.Column(name = "sezione")
@SqlField(value = "sezione")
private Integer sezione;
@javax.persistence.Column(name = "tipo_reg")
@SqlField(value = "tipo_reg", maxLength = 1)
private String tipoReg;
@javax.persistence.Column(name = "tipo_stock")
@SqlField(value = "tipo_stock", maxLength = 1)
private String tipoStock;
@javax.persistence.Column(name = "qta_multipla_ord")
@SqlField(value = "qta_multipla_ord")
private BigDecimal qtaMultiplaOrd;
@MapToTable(value = "flag_kit")
@Transient
private String flagKit;
@javax.persistence.Column(name = "cod_forn_cv")
@SqlField(value = "cod_forn_cv", maxLength = 5)
private String codFornCv;
@javax.persistence.Column(name = "cpa")
@SqlField(value = "cpa", maxLength = 5)
private String cpa;
@javax.persistence.Column(name = "taric")
@SqlField(value = "taric", maxLength = 5)
private String taric;
@javax.persistence.Column(name = "sezione_dogana")
@SqlField(value = "sezione_dogana", maxLength = 6)
private String sezioneDogana;
@javax.persistence.Column(name = "flag_peso_egalizzato")
@SqlField(value = "flag_peso_egalizzato", nullable = false, defaultObjectValue = "0")
private Boolean flagPesoEgalizzato;
@javax.persistence.Column(name = "cod_jfas_costi")
@SqlField(value = "cod_jfas_costi", maxLength = 5)
private String codJfasCosti;
@javax.persistence.Column(name = "cod_jfas_ricavi")
@SqlField(value = "cod_jfas_ricavi", maxLength = 5)
private String codJfasRicavi;
@Transient
private String mtbAartEqui_descrizione;
@javax.persistence.Column(name = "flag_arr_prz_vend_iva")
@SqlField(value = "flag_arr_prz_vend_iva", nullable = false, defaultObjectValue = "1")
private Boolean flagArrPrzVendIva;
@javax.persistence.Column(name = "classificazione_abc")
@SqlField(value = "classificazione_abc", maxLength = 1)
private String classificazioneAbc;
@javax.persistence.Column(name = "tipo_codice_imballo")
@SqlField(value = "tipo_codice_imballo", maxLength = 10)
private String tipoCodiceImballo;
@javax.persistence.Column(name = "flag_stampa_docu_vend")
@SqlField(value = "flag_stampa_docu_vend", nullable = false, defaultObjectValue = "1")
private Boolean flagStampaDocuVend;
@javax.persistence.Column(name = "flag_reso_tec")
@SqlField(value = "flag_reso_tec", nullable = false, defaultObjectValue = "0")
private Boolean flagResoTec;
@javax.persistence.Column(name = "cod_mssfa")
@SqlField(value = "cod_mssfa", maxLength = 6)
private String codMssfa;
@javax.persistence.Column(name = "cod_linea")
@SqlField(value = "cod_linea", maxLength = 6)
private String codLinea;
@javax.persistence.Column(name = "cod_slinea")
@SqlField(value = "cod_slinea", maxLength = 6)
private String codSlinea;
@javax.persistence.Column(name = "cod_sslinea")
@SqlField(value = "cod_sslinea", maxLength = 6)
private String codSslinea;
@javax.persistence.ManyToOne(fetch = javax.persistence.FetchType.LAZY)
@javax.persistence.JoinColumn(name = "unt_mis", insertable = false, updatable = false)
private MtbUntMis mtbUntMis;
@Transient
private boolean updArtEqui = true;
@Priority(1)
@Transient
//Compatible with EntityBase
private List<MtbUntMis> mtbUntMisList;
@Priority(1)
@Transient
private MtbAartMarchio mtbAartMarchio;
@Priority(1)
@Transient
private MtbAartEqui mtbAartEqui;
@Priority(1)
private List<MtbUntMis> mtbUntMis;
@Priority(value = 101, copyPk = false)
@Transient
private List<MtbAart> articoliEquivalenti;
@EntityChild
@javax.persistence.OneToMany(fetch = javax.persistence.FetchType.LAZY, mappedBy = "mtbAart")
private List<MtbAartBarCode> mtbAartBarCode = new ArrayList<>();
/*@EntityChild
private List<MtbPart> mtbPart;*/
@EntityChild
@Transient
private List<MtbAartCarat> mtbAartCarat = new ArrayList<>();
@EntityChild
@Transient
private List<MtbAartAnag> mtbAartAnag = new ArrayList<>();
@EntityChild
@Transient
private List<MtbSpes> mtbSpes = new ArrayList<>();
@EntityChild
@Transient
private List<MtbComp> mtbComp = new ArrayList<>();
@EntityChild
@Transient
private List<MtbAartDesc> mtbAartDesc = new ArrayList<>();
@EntityChild
@Transient
private List<MtbAartLink> mtbAartLink = new ArrayList<>();
@EntityChild
@Transient
private List<MtbPartitaMag> mtbPartitaMag = new ArrayList<>();
@EntityChild
@Transient
private List<MrlAartSchTecSet> mrlAartSchTecSet = new ArrayList<>();
@EntityChild
@Transient
private List<MtbAartColori> mtbAartColori = new ArrayList<>();
@Priority(101)
@Transient
List<JtbCicl> jtbCicl;
@Transient
private List<MtbLisa> mtbLisa;
public MtbAart() {
@@ -1178,15 +1309,24 @@ public class MtbAart extends EntityBase implements EquatableEntityInterface<MtbA
return this;
}
public List<MtbUntMis> getMtbUntMis() {
public MtbUntMis getMtbUntMis() {
return mtbUntMis;
}
public MtbAart setMtbUntMis(List<MtbUntMis> mtbUntMis) {
public MtbAart setMtbUntMis(MtbUntMis mtbUntMis) {
this.mtbUntMis = mtbUntMis;
return this;
}
public List<MtbUntMis> getMtbUntMisList() {
return mtbUntMisList;
}
public MtbAart setMtbUntMisList(List<MtbUntMis> mtbUntMisList) {
this.mtbUntMisList = mtbUntMisList;
return this;
}
public String getClassificazioneAbc() {
return classificazioneAbc;
}
@@ -1258,8 +1398,9 @@ public class MtbAart extends EntityBase implements EquatableEntityInterface<MtbA
return mtbAartCarat;
}
public void setMtbAartCarat(List<MtbAartCarat> mtbAartCarat) {
public MtbAart setMtbAartCarat(List<MtbAartCarat> mtbAartCarat) {
this.mtbAartCarat = mtbAartCarat;
return this;
}
public List<MtbAartLink> getMtbAartLink() {
@@ -1321,6 +1462,24 @@ public class MtbAart extends EntityBase implements EquatableEntityInterface<MtbA
this.mtbAartEqui = mtbAartEqui;
}
public boolean isUpdArtEqui() {
return updArtEqui;
}
public MtbAart setUpdArtEqui(boolean updArtEqui) {
this.updArtEqui = updArtEqui;
return this;
}
public List<MtbAart> getArticoliEquivalenti() {
return articoliEquivalenti;
}
public MtbAart setArticoliEquivalenti(List<MtbAart> articoliEquivalenti) {
this.articoliEquivalenti = articoliEquivalenti;
return this;
}
public List<JtbCicl> getJtbCicl() {
return jtbCicl;
}

View File

@@ -63,6 +63,9 @@ public class MtbAartAnag extends EntityBase {
@SqlField(value = "note", maxLength = 255)
private String note;
@SqlField(value = "cod_vdes", maxLength = 5)
private String codVdes;
public MtbAartAnag() {
super(logger);
}
@@ -174,4 +177,13 @@ public class MtbAartAnag extends EntityBase {
this.note = note;
return this;
}
public String getCodVdes() {
return codVdes;
}
public MtbAartAnag setCodVdes(String codVdes) {
this.codVdes = codVdes;
return this;
}
}

View File

@@ -13,6 +13,8 @@ import org.kie.api.definition.type.PropertyReactive;
import java.math.BigDecimal;
import java.util.Objects;
@javax.persistence.Entity
@javax.persistence.Table(name = MtbAartBarCode.ENTITY)
@PropertyReactive
@Table(MtbAartBarCode.ENTITY)
@JsonTypeName(MtbAartBarCode.ENTITY)
@@ -26,18 +28,28 @@ public class MtbAartBarCode extends EntityBase implements EquatableEntityInterfa
@PK
@SqlField(value = "cod_barre", maxLength = 40, nullable = false)
@javax.persistence.Id
@javax.persistence.Column(name = "cod_barre")
private String codBarre;
@SqlField(value = "cod_mart", maxLength = 15)
@javax.persistence.Column(name = "cod_mart")
private String codMart;
@javax.persistence.ManyToOne(fetch = javax.persistence.FetchType.LAZY)
@javax.persistence.JoinColumn(name = "cod_mart", insertable = false, updatable = false)
private MtbAart mtbAart;
@SqlField(value = "qta_cnf", nullable = false, defaultObjectValue = "1")
@javax.persistence.Column(name = "qta_cnf")
private BigDecimal qtaCnf;
@SqlField(value = "flag_primario", maxLength = 1, nullable = false, defaultObjectValue = "N")
@javax.persistence.Column(name = "flag_primario")
private String flagPrimario;
@SqlField(value = "tipo_cod_barre", maxLength = 10)
@javax.persistence.Column(name = "tipo_cod_barre")
private String tipoCodBarre;
public MtbAartBarCode() {
@@ -62,6 +74,14 @@ public class MtbAartBarCode extends EntityBase implements EquatableEntityInterfa
return this;
}
public MtbAart getMtbAart() {
return mtbAart;
}
public void setMtbAart(MtbAart mtbAart) {
this.mtbAart = mtbAart;
}
public BigDecimal getQtaCnf() {
return qtaCnf;
}

View File

@@ -5,14 +5,17 @@ import it.integry.ems_model.annotation.PK;
import it.integry.ems_model.annotation.SqlField;
import it.integry.ems_model.annotation.Table;
import it.integry.ems_model.base.EntityBase;
import it.integry.ems_model.base.EquatableEntityInterface;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.kie.api.definition.type.PropertyReactive;
import java.util.Objects;
@PropertyReactive
@Table(MtbAartDesc.ENTITY)
@JsonTypeName(MtbAartDesc.ENTITY)
public class MtbAartDesc extends EntityBase {
public class MtbAartDesc extends EntityBase implements EquatableEntityInterface<MtbAartDesc> {
private final static Logger logger = LogManager.getLogger();
@@ -34,6 +37,9 @@ public class MtbAartDesc extends EntityBase {
@SqlField(value = "descrizione", maxLength = 40, nullable = false)
private String descrizione;
@SqlField(value = "descrizione_html")
private String descrizioneHtml;
public MtbAartDesc() {
super(logger);
}
@@ -69,4 +75,40 @@ public class MtbAartDesc extends EntityBase {
public void setDescrizione(String descrizione) {
this.descrizione = descrizione;
}
public String getDescrizioneHtml() {
return descrizioneHtml;
}
public MtbAartDesc setDescrizioneHtml(String descrizioneHtml) {
this.descrizioneHtml = descrizioneHtml;
return this;
}
@Override
public boolean equals(Object o) {
if (!(o instanceof MtbAartDesc)) return false;
MtbAartDesc that = (MtbAartDesc) o;
return Objects.equals(getCodMart(), that.getCodMart()) && Objects.equals(getCodLingua(), that.getCodLingua()) && Objects.equals(getDescrizioneEstesa(), that.getDescrizioneEstesa()) && Objects.equals(getDescrizione(), that.getDescrizione()) && Objects.equals(getDescrizioneHtml(), that.getDescrizioneHtml());
}
@Override
public int hashCode() {
return Objects.hash(getCodMart(), getCodLingua(), getDescrizioneEstesa(), getDescrizione(), getDescrizioneHtml());
}
@Override
public int hashCodeKey() {
return Objects.hash(getCodMart(), getCodLingua());
}
@Override
public boolean equalsKey(MtbAartDesc other) {
if (this == other) return true;
if (!(other instanceof MtbAartDesc)) return false;
MtbAartDesc mtbAartDesc = other;
return Objects.equals(getCodLingua(), mtbAartDesc.getCodLingua()) &&
Objects.equals(getCodMart(), mtbAartDesc.getCodMart());
}
}

View File

@@ -41,6 +41,9 @@ public class MtbAartEqui extends EntityBase implements EquatableEntityInterface<
@SqlField(value = "descrizione_estera", maxLength = 255, nullable = false)
private String descrizioneEstera;
@SqlField(value = "flag_equi_anag", maxLength = 1, nullable = false, defaultObjectValue = "0")
private Boolean flagEquiAnag;
public MtbAartEqui() {
super(logger);
}
@@ -89,16 +92,26 @@ public class MtbAartEqui extends EntityBase implements EquatableEntityInterface<
this.descrizioneEstera = descrizioneEstera;
}
public Boolean getFlagEquiAnag() {
return flagEquiAnag;
}
public MtbAartEqui setFlagEquiAnag(Boolean flagEquiAnag) {
this.flagEquiAnag = flagEquiAnag;
return this;
}
@Override
public boolean equals(Object o) {
if (!(o instanceof MtbAartEqui)) return false;
MtbAartEqui that = (MtbAartEqui) o;
return Objects.equals(getIdArtEqui(), that.getIdArtEqui()) && Objects.equals(getDescrizione(), that.getDescrizione()) && Objects.equals(getFlagEquiPrezzo(), that.getFlagEquiPrezzo()) && Objects.equals(getFlagEquiCosto(), that.getFlagEquiCosto()) && Objects.equals(getDescrizioneEstera(), that.getDescrizioneEstera());
return Objects.equals(getIdArtEqui(), that.getIdArtEqui()) && Objects.equals(getDescrizione(), that.getDescrizione()) && Objects.equals(getFlagEquiPrezzo(), that.getFlagEquiPrezzo()) && Objects.equals(getFlagEquiCosto(), that.getFlagEquiCosto()) && Objects.equals(getDescrizioneEstera(), that.getDescrizioneEstera())
&& Objects.equals(getFlagEquiAnag(), that.getFlagEquiAnag());
}
@Override
public int hashCode() {
return Objects.hash(getIdArtEqui(), getDescrizione(), getFlagEquiPrezzo(), getFlagEquiCosto(), getDescrizioneEstera());
return Objects.hash(getIdArtEqui(), getDescrizione(), getFlagEquiPrezzo(), getFlagEquiCosto(), getDescrizioneEstera(),getFlagEquiAnag());
}
@Override

View File

@@ -9,12 +9,15 @@ import it.integry.ems_model.annotation.SqlField;
import it.integry.ems_model.annotation.Table;
import it.integry.ems_model.base.EntityBase;
import it.integry.ems_model.entity._enum.IBaseEnum;
import org.kie.api.definition.type.PropertyReactive;
import java.math.BigDecimal;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.kie.api.definition.type.PropertyReactive;
import javax.persistence.Transient;
import java.math.BigDecimal;
@javax.persistence.Entity
@javax.persistence.Table(name = MtbUntMis.ENTITY)
@Master
@PropertyReactive
@Table(MtbUntMis.ENTITY)
@@ -27,29 +30,40 @@ public class MtbUntMis extends EntityBase {
private static final long serialVersionUID = 1L;
@javax.persistence.Id
@javax.persistence.Column(name = "unt_mis")
@PK
@SqlField(value = "unt_mis", maxLength = 3, nullable = false)
private String untMis;
@javax.persistence.Column(name = "flag_dig")
@SqlField(value = "flag_dig", maxLength = 1, nullable = false, defaultObjectValue = "N")
private String flagDig;
@javax.persistence.Column(name = "cifre_dec")
@SqlField(value = "cifre_dec", nullable = false, defaultObjectValue = "0")
private BigDecimal cifreDec;
@javax.persistence.Column(name = "tipo_um")
@javax.persistence.Enumerated(javax.persistence.EnumType.STRING)
@SqlField(value = "tipo_um", maxLength = 2)
private TipoUM tipoUm;
@javax.persistence.Column(name = "flag_unita_kg")
@SqlField(value = "flag_unita_kg", maxLength = 1, nullable = false)
private String flagUnitaKg;
@javax.persistence.Column(name = "flag_attivo")
@SqlField(value = "flag_attivo", maxLength = 1, nullable = false)
private String flagAttivo;
@javax.persistence.Column(name = "grandezza")
@javax.persistence.Enumerated(javax.persistence.EnumType.STRING)
@SqlField(value = "grandezza")
private Grandezza grandezza;
@JsonProperty(value = "ordinamento")
@Transient
private Integer ordinamento;
public MtbUntMis() {

View File

@@ -3,10 +3,12 @@ package it.integry.ems_model.entity;
import com.fasterxml.jackson.annotation.JsonTypeName;
import it.integry.ems_model.annotation.*;
import it.integry.ems_model.base.EntityBase;
import org.kie.api.definition.type.PropertyReactive;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.kie.api.definition.type.PropertyReactive;
@javax.persistence.Entity
@javax.persistence.Table(name = StbEmail.ENTITY)
@Master
@PropertyReactive
@Table(StbEmail.ENTITY)
@@ -19,44 +21,58 @@ public class StbEmail extends EntityBase {
private static final long serialVersionUID = 1L;
@javax.persistence.Id
@javax.persistence.Column(name = "id_riga")
@PK
@SqlDetailId
@SqlField(value = "id_riga", nullable = false)
private Integer idRiga;
@javax.persistence.Column(name = "e_mail")
@SqlField(value = "e_mail", maxLength = 255, nullable = false)
private String eMail;
@javax.persistence.Column(name = "smtp")
@SqlField(value = "smtp", maxLength = 255)
private String smtp;
@javax.persistence.Column(name = "authentication")
@SqlField(value = "authentication", maxLength = 1, nullable = false, defaultObjectValue = "S")
private String authentication;
@javax.persistence.Column(name = "user_name")
@SqlField(value = "user_name", maxLength = 255)
private String userName;
@javax.persistence.Column(name = "password")
@SqlField(value = "password", maxLength = 255)
private String password;
@javax.persistence.Column(name = "port")
@SqlField(value = "port", maxLength = 255)
private String port;
@javax.persistence.Column(name = "SSL")
@SqlField(value = "SSL", maxLength = 1, nullable = false, defaultObjectValue = "N")
private String ssl;
@javax.persistence.Column(name = "crypt_password")
@SqlField(value = "crypt_password", maxLength = 1, nullable = false, defaultObjectValue = "S")
private String cryptPassword;
@javax.persistence.Column(name = "flag_default")
@SqlField(value = "flag_default", maxLength = 1, nullable = false, defaultObjectValue = "N")
private String flagDefault;
@javax.persistence.Column(name = "flag_default_contabilita")
@SqlField(value = "flag_default_contabilita", maxLength = 1, nullable = false, defaultObjectValue = "N")
private String flagDefaultContabilita;
@javax.persistence.Column(name = "imap")
@SqlField(value = "imap", maxLength = 255)
private String imap;
@javax.persistence.Column(name = "imap_port")
@SqlField(value = "imap_port", maxLength = 255)
private String imapPort;

View File

@@ -5,9 +5,11 @@ import java.util.Objects;
public class DtbOrdtKey {
private final String gestione;
private final Date dataOrd;
private final Integer numOrd;
private String gestione;
private Date dataOrd;
private Integer numOrd;
public DtbOrdtKey() {}
public DtbOrdtKey(String gestione, Date dataOrd, Integer numOrd) {
this.gestione = gestione;

View File

@@ -155,7 +155,7 @@ when
$entity : MtbAart((untMis != null || untMis2 != null || untMis3 != null ) && operation != OperationType.DELETE)
then
List<MtbUntMis> mtbUntMis = CommonRules.insUntMis(conn, $entity);
modify($entity){setMtbUntMis(mtbUntMis)}
modify($entity){setMtbUntMisList(mtbUntMis)}
end

View File

@@ -18,6 +18,8 @@ import java.time.LocalDate
import it.integry.ems_model.utility.UtilityLocalDate;
import it.integry.ems.migration._base.IntegryCustomerDB;
import it.integry.ems.migration._base.IntegryCustomer
import it.integry.ems.jpa.repository.MtbUntMisRepository
import it.integry.ems._context.ApplicationContextProvider
global Connection conn
global String username
@@ -225,14 +227,16 @@ when
eval(completeRulesEnabled)
$entity : MtbColr(artAPeso == null && codMart != null )
then
String sql =
"SELECT CASE WHEN dbo.f_getTipoUntMis(mtb_aart.unt_mis) = 'KG' THEN 'S' ELSE 'N' END " +
" FROM mtb_aart WHERE cod_mart = " + UtilityDB.valueToString($entity.getCodMart());
MtbUntMisRepository mtbUntMisRepository = ApplicationContextProvider.getApplicationContext().getBean(MtbUntMisRepository.class);
MtbUntMis mtbUntMis = mtbUntMisRepository.findByCodMart($entity.getCodMart())
.orElse(null);
String artAPeso = "N";
if (mtbUntMis != null)
artAPeso = "KG".equalsIgnoreCase(mtbUntMis.getUntMis()) ? "S" : "N";
String artAPeso = (String) QueryRules.getSingleValue(conn, sql);
if (artAPeso == null ) {
artAPeso = "N";
}
modify ( $entity ) { setArtAPeso(artAPeso) }
end

View File

@@ -123,6 +123,7 @@ when
then
CommonRules.setIdArtEqui(conn, $mtbAart);
CommonRules.updateDescrDistintaBase(conn, $mtbAart);
CommonRules.updArtEqui(conn, $mtbAart);
end
rule "completeIdRigaCtbScad"

View File

@@ -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)

View File

@@ -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,

View File

@@ -0,0 +1,24 @@
package it.integry.ems.activity.dto;
public class SteUpFornitoriDTO {
private String partitaIva;
private Integer ggCons;
public String getPartitaIva() {
return partitaIva;
}
public SteUpFornitoriDTO setPartitaIva(String partitaIva) {
this.partitaIva = partitaIva;
return this;
}
public Integer getGgCons() {
return ggCons;
}
public SteUpFornitoriDTO setGgCons(Integer ggCons) {
this.ggCons = ggCons;
return this;
}
}

View File

@@ -687,6 +687,7 @@ public class ActivityService {
utenti.add("F0003");
utenti.add("F0237");
utenti.add("F0060");
utenti.add("L0019");
} else
utenti.add(user.getUsername());
@@ -1377,6 +1378,7 @@ public class ActivityService {
utenti.add("F0003");
utenti.add("F0237");
utenti.add("F0060");
utenti.add("L0019");
} else if (!activity.getEsito().equalsIgnoreCase(EmsRestConstants.NULL)) {
sql = Query.format(
"SELECT CAST(IIF(flag_invio_notifica = 'N', 0, 1) AS BIT)\n" +

View File

@@ -2,20 +2,20 @@ package it.integry.ems.activity.service;
import com.annimon.stream.Optional;
import com.annimon.stream.Stream;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import it.integry.common.var.CommonConstants;
import it.integry.ems.activity.dto.DescrizioneTipiAttivitaDTO;
import it.integry.ems.activity.dto.ModellinoDTO;
import it.integry.ems.activity.dto.SteUPEntryDTO;
import it.integry.ems.activity.dto.SteUpScoreDTO;
import it.integry.ems.activity.dto.*;
import it.integry.ems.entity_logger.db_schema_manager.component.SQLServerDBSchemaManager;
import it.integry.ems.entity_logger.db_schema_manager.dto.DatabaseTable;
import it.integry.ems.entity_logger.db_schema_manager.dto.DatabaseTableColumn;
import it.integry.ems.entity_logger.db_schema_manager.dto.DatabaseTableView;
import it.integry.ems.javabeans.RequestDataDTO;
import it.integry.ems.json.ResponseJSONObjectMapper;
import it.integry.ems.order.dto.UserGroupENUM;
import it.integry.ems.report.dto.JasperDTO;
import it.integry.ems.report.dto.PairsDTO;
import it.integry.ems.retail.pvmRetail.dto.FiltroArtDTO;
import it.integry.ems.service.EntityProcessor;
import it.integry.ems.service.MailService;
import it.integry.ems.service.ReportProcessor;
@@ -43,6 +43,7 @@ import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
@@ -60,6 +61,8 @@ 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;
import static org.json.XMLTokener.entity;
@Service
@Scope("request")
@@ -514,7 +517,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 +537,7 @@ public class SteUPService {
activityId = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
}
StbActivity activityItem =
new StbActivity()
.setActivityDescription(activityTypeId)
@@ -665,9 +668,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 +739,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 +787,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 +868,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 +934,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 +1408,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 +1476,310 @@ 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"), ""), "|"));
String jsonFornitori = setup.get("FORN_INEVASI");
List<SteUpFornitoriDTO> fornitori = new ArrayList<>();
if (!UtilityString.isNullOrEmpty(jsonFornitori)) {
TypeReference<List<SteUpFornitoriDTO>> mapType = new TypeReference<List<SteUpFornitoriDTO>>() {
};
fornitori = new ResponseJSONObjectMapper().readValue(jsonFornitori, mapType);
}
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<SteUpFornitoriDTO> 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());
if (fornitori.size() > 0) {
String whereCondFornitori = fornitori.stream().map(
x -> {
return "(gtb_anag.part_iva = " + UtilityDB.valueToString(x.getPartitaIva()) + " AND \n" +
" dtb_ordr.data_cons BETWEEN DATEADD(DAY, - (" + x.getGgCons() + "-1), " + UtilityDB.valueToString(dataCreation) + ") AND " + UtilityDB.valueToString(dataCreation) + ")\n";
}
).collect(Collectors.joining(" OR \n", " AND ( \n", " ) \n"));
//Verifica Inevasi
String sqlInevasi =
"WITH articoli AS (" + queryKit + "), \n" +
" ordini AS (SELECT articoli.cod_mart,\n" +
" dtb_ordt.data_ord,\n" +
" dtb_ordt.num_ord,\n" +
" dtb_ordr.qta_evasa,\n" +
" DENSE_RANK() OVER (PARTITION BY dtb_ordt.cod_anag, dtb_ordt.cod_mdep ORDER BY dtb_ordr.data_cons DESC) id_ord\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 dtb_ordt.cod_mdep = [COD_MDEP]\n" +
" [WHERE_COND_FORN]\n" +
(!tipiEsclusi.isEmpty()?
" AND (mtb_aart.cod_mtip IS NULL OR mtb_aart.cod_mtip not in (" + UtilityDB.listValueToString(tipiEsclusi) + "))\n":""
) +
" AND dtb_ordt.data_esportazione IS NOT NULL\n" +
" AND mtb_aart.cod_mgrp IN ( [GRUPPI_MERC] ) \n)\n"+
"SELECT DISTINCT cod_mart\n" +
"FROM ordini\n" +
"WHERE id_ord <= 2\n" +
" AND qta_evasa = 0 ";
;
sqlInevasi =
sqlInevasi
.replace("[DATA_ISPEZIONE]", UtilityDB.valueToString(dataCreation))
.replace("[COD_MDEP]", UtilityDB.valueToString(codMdep))
.replace("[GRUPPI_MERC]", UtilityDB.listValueToString(gruppiMerc))
.replace("[WHERE_COND_FORN]", whereCondFornitori);
List<String> inevasi = UtilityDB.executeSimpleQueryOnlyFirstColumn(mdb.getPrimaryConnection(), sqlInevasi);
articoli = articoli.stream()
.filter(x -> !inevasi.contains(x))
.collect(Collectors.toList());
}
}
return articoli;
}
}

View File

@@ -469,7 +469,7 @@ public class AutofatturaService {
mailService.sendSystemErrorLog("[" + model.getProfileName() + " - " + azienda.getNomeDitta() + "][" + UtilityServer.getHostName() + "] Verifica autofatture ",
"Verifica autofatture",
"Sull'azienda " + azienda.getNomeDitta() + " non è presente nessuna email con flag default contabilità, non sarà possibile inviare la mail di verifica.",
(String) null, new Date());
(Exception) null, new Date());
} else {
String elencoMovimenti = String.join(CommonConstants.A_CAPO, listMov);
String elencoEmail = String.join(",", email);

View File

@@ -3,6 +3,7 @@ package it.integry.ems.contabil.service;
import it.integry.common.var.CommonConstants;
import it.integry.ems.service.EntityProcessor;
import it.integry.ems.service.MailService;
import it.integry.ems.sync.MultiDBTransaction.Connection;
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
import it.integry.ems.utility.UtilityDebug;
import it.integry.ems.utility.UtilityEntity;
@@ -18,9 +19,6 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import it.integry.ems.sync.MultiDBTransaction.Connection;
import java.sql.SQLException;
import java.time.LocalDate;
import java.time.ZoneId;
@@ -279,7 +277,7 @@ public class PassaggioAnno {
private void sendMail(String message, List<String> email) throws Exception {
if (email == null || email.isEmpty()) {
mailService.sendSystemErrorLog("ATTENZIONE", "ATTENZIONE", message, (String) null, new Date());
mailService.sendSystemErrorLog("ATTENZIONE", "ATTENZIONE", message, (Exception) null, new Date());
} else {
String elencoEmail = String.join(",", email);
mailService.sendMail(elencoEmail, null, "ATTENZIONE", message);

View File

@@ -46,7 +46,7 @@ public class ScadenzeService {
mailService.sendSystemErrorLog("[" + multiDBTransactionManager.getPrimaryConnection().getProfileName() + "][" + UtilityServer.getHostName() + "] Verifica scadenze ",
"Verifica scadenze",
"Sull'azienda " + multiDBTransactionManager.getPrimaryConnection().getProfileName() + " ci sono scadenze con data documenti disallineata: " + CommonConstants.A_CAPO + elencoScadenze,
(String) null, new Date());
(Exception) null, new Date());
}
}

View File

@@ -74,6 +74,16 @@ public class DocumentiDirettiService {
throw new Exception("Tipo documento obbligatorio");
}
if ( dtbDoct.getDtbDocCarat() != null && !dtbDoct.getDtbDocCarat().isEmpty() ) {
dtbDoct.getDtbDocCarat().stream()
.filter(dc -> dc.getOperation().equals(OperationType.UPDATE))
.forEach(dc -> {
if ( UtilityString.isNullOrEmpty( dc.getValoreCarat() ) ) {
dc.setOperation( OperationType.DELETE );
}
} );
}
if ( dtbDoct.getMtbColt() != null ) {
dtbDoct.getMtbColt().stream().forEach(ul -> {
ul.getMtbColr().stream()

View File

@@ -0,0 +1,40 @@
package it.integry.ems.jpa;
import it.integry.ems.javabeans.RequestDataDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class TenantInterceptor extends HandlerInterceptorAdapter {
@Autowired
private RequestDataDTO requestDataDTO;
// private static final String TENANT_HEADER = "X-Tenant-ID";
// private static final String DEFAULT_TENANT = "default"; // O recuperalo da configurazione
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
String profileDb = requestDataDTO.getProfileDB();
// String tenantId = request.getHeader(TENANT_HEADER);
// Logica di fallback o recupero tenant da sessione/utente
if (profileDb == null || profileDb.isEmpty()) {
// Esempio: recupero da sessione se presente
// tenantId = (String) request.getSession().getAttribute("TENANT_ID");
// Fallback temporaneo per test
// tenantId = DEFAULT_TENANT;
}
if (profileDb != null) {
TenantContext.setCurrentTenant(profileDb);
}
return true;
}
}

View File

@@ -5,9 +5,9 @@ import com.annimon.stream.function.Predicate;
import com.fasterxml.jackson.databind.JsonNode;
import it.integry.common.var.CommonConstants;
import it.integry.ems._context.ApplicationContextProvider;
import it.integry.ems.jpa.repository.MtbAartRepository;
import it.integry.ems.logistic.dto.sm2.FiltroDistribuzioneColloDTO;
import it.integry.ems.product.importaz.service.ProductServices;
import it.integry.ems.retail.wms.Utility.WMSUtility;
import it.integry.ems.service.EntityProcessor;
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
import it.integry.ems_model.base.EntityBase;
@@ -31,12 +31,13 @@ import static java.util.stream.Collectors.groupingBy;
@Component
public class DistribuzioneColliService {
private final List<MtbColt> mCurrentlyDistributingMtbColt = new ArrayList<>();
public List<MtbColt> distribuzioneRigheColloNew(final FiltroDistribuzioneColloDTO filtroDistribuzioneColloDTO, boolean skipCommit) throws Exception {
MtbAartRepository mtbAartRepository = ContextLoader.getCurrentWebApplicationContext().getBean(MtbAartRepository.class);
MultiDBTransactionManager multiDBTransactionManager = ContextLoader.getCurrentWebApplicationContext().getBean(MultiDBTransactionManager.class);
EntityProcessor entityProcessor = ApplicationContextProvider.getApplicationContext().getBean(EntityProcessor.class);
ProductServices productServices = ContextLoader.getCurrentWebApplicationContext().getBean(ProductServices.class);
@@ -116,8 +117,7 @@ public class DistribuzioneColliService {
.map(MtbColr::getCodMart)
.collect(Collectors.toList());
List<MtbAart> mtbAarts = WMSUtility.getArticoliByCodMarts(codMarts, multiDBTransactionManager.getPrimaryConnection());
List<MtbAart> mtbAarts = mtbAartRepository.findByCodMartIn(codMarts);
//Lettura del filtro ordini
String filtroOrdini = sourceMtbColt.getFiltroOrdini();

View File

@@ -3,7 +3,7 @@ package it.integry.ems.order.Import.service;
import it.integry.common.var.CommonConstants;
import it.integry.ems._context.ApplicationContextProvider;
import it.integry.ems.exception.PrimaryDatabaseNotPresentException;
import it.integry.ems.retail.wms.Utility.WMSUtility;
import it.integry.ems.jpa.repository.MtbAartRepository;
import it.integry.ems.service.EntityProcessor;
import it.integry.ems.sync.MultiDBTransaction.Connection;
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
@@ -44,6 +44,8 @@ public class OrdiniMaxiDataImportService {
private EntityProcessor entityProcessor;
private MaxiDataApiService maxiDataApiService;
@Autowired
private MtbAartRepository mtbAartRepository;
@PostConstruct
private void init() throws PrimaryDatabaseNotPresentException {
@@ -132,12 +134,11 @@ public class OrdiniMaxiDataImportService {
if (schedeProduzione == null || schedeProduzione.isEmpty())
return new ArrayList<>();
List<MtbAart> anafraficheArticoli = WMSUtility.getArticoliByCodMarts(
List<MtbAart> anafraficheArticoli = mtbAartRepository.findByCodMartIn(
schedeProduzione.stream()
.map(MaxidataUveBII40V2BLLUVE2kSchedeProd::getIdProdotto)
.distinct()
.collect(Collectors.toList()),
conn);
.collect(Collectors.toList()));
List<DtbOrdt> generatedOrders = new ArrayList<>();

View File

@@ -338,7 +338,7 @@ public class CrmService {
);
HashMap<String, Object> ordineImportato = UtilityDB.executeSimpleQueryOnlyFirstRow(conn, sql);
if ((ordineImportato != null || ordineImportato.get("activity_id") != null) && completeOrder.getActivityId() == null)
if (completeOrder.getActivityId() == null && ordineImportato != null && ordineImportato.get("activity_id") != null)
completeOrder.setActivityId(ordineImportato.get("activity_id").toString());
if ("S".equals(ordineImportato.get("flag_elaborato").toString()))

View File

@@ -10,11 +10,13 @@ import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
import it.integry.ems_model.base.EntityBase;
import it.integry.ems_model.entity.DtbOrdr;
import it.integry.ems_model.entity.DtbOrdt;
import it.integry.ems_model.service.SetupGest;
import it.integry.ems_model.types.OperationType;
import it.integry.ems_model.utility.Query;
import it.integry.ems_model.utility.UtilityBigDecimal;
import it.integry.ems_model.utility.UtilityDB;
import it.integry.ems_model.utility.UtilityHashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
@@ -26,6 +28,9 @@ public class OrdiniVSlim2kService {
private final EntityProcessor entityProcessor;
private final EmsServices emsServices;
@Autowired
private SetupGest setupGest;
public OrdiniVSlim2kService(EntityProcessor entityProcessor, EmsServices emsServices) {
this.entityProcessor = entityProcessor;
this.emsServices = emsServices;
@@ -43,11 +48,11 @@ public class OrdiniVSlim2kService {
List<HashMap<String, Object>> articoli = new ArrayList<>();
List<HashMap<String, Object>> export = new ArrayList<>();
for(DtbOrdt ord : groupOrdini.keySet()) {
for (DtbOrdt ord : groupOrdini.keySet()) {
for (DtbOrdr dtbOrdr : groupOrdini.get(ord)) {
String sql =
Query.format("SELECT * FROM dtb_ordt WHERE gestione = %s AND data_ord = %s AND num_ord = %s",
ord.getGestione(), ord.getDataOrd(), ord.getNumOrd());
ord.getGestione(), ord.getDataOrd(), ord.getNumOrd());
ord = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, DtbOrdt.class);
BigDecimal qtaCnf;
@@ -73,48 +78,51 @@ public class OrdiniVSlim2kService {
}
entityProcessor.processEntity(ord, multiDBTransactionManager, false);
boolean exportOrdini = setupGest.getSetupBoolean(multiDBTransactionManager.getPrimaryConnection(), "PVM", "ORDINI_V_SLIM2K", "EXPORT_ORDINI");
DtbOrdt finalOrd = ord;
Optional<HashMap<String, Object>> exportOpt = export.stream()
.filter(x -> ((String) x.get("cod_anag")).equalsIgnoreCase(finalOrd.getCodAnag())).findFirst();
HashMap<String, Object> datiExport;
if ( exportOpt.isPresent() ) {
datiExport = exportOpt.get();
} else {
String query =
Query.format(
"SELECT wtb_clie.cod_anag, " +
"wtb_users.user_name, wtb_users.password, wtb_users_info.format_file, COUNT(wtb_users_info.format_file) over (partition by wtb_users_info.user_name) as count_export" +
" FROM wtb_users " +
"INNER JOIN wtb_users_info ON wtb_users.User_name = wtb_users_info.user_name " +
"INNER JOIN wtb_clie ON wtb_users.User_name = wtb_clie.user_name " +
" WHERE wtb_users_info.flag_state = 'S' and " +
" wtb_clie.cod_anag = %s AND \n" +
" wtb_users_info.export_type = %s",
ord.getCodAnag(), EntityExportType.ORDINI_VENDITA.getText());
datiExport = UtilityDB.executeSimpleQueryOnlyFirstRow(multiDBTransactionManager.getPrimaryConnection(), query);
export.add(datiExport);
}
if (UtilityHashMap.isPresent(datiExport)) {
String userNameExport = UtilityHashMap.getValueIfExists(datiExport, "user_name");
String passwordExport = UtilityHashMap.getValueIfExists(datiExport, "password");
String formatExport = UtilityHashMap.getValueIfExists(datiExport, "format_file");
Integer countExport = UtilityHashMap.getValueIfExists(datiExport, "count_export");
if (countExport == 1) {
RequestDataDTO requestDataDTO = new RequestDataDTO();
requestDataDTO.setUsername(userNameExport);
requestDataDTO.setPassword(passwordExport);
String whereCond =
if (ord.getDataEsportazione() != null && exportOrdini) {
DtbOrdt finalOrd = ord;
Optional<HashMap<String, Object>> exportOpt = export.stream()
.filter(x -> ((String) x.get("cod_anag")).equalsIgnoreCase(finalOrd.getCodAnag())).findFirst();
HashMap<String, Object> datiExport;
if (exportOpt.isPresent()) {
datiExport = exportOpt.get();
} else {
String query =
Query.format(
"dtb_ordt.gestione = %s AND dtb_ordt.data_ord = %s AND dtb_ordt.num_ord = %s",
ord.getGestione(), ord.getDataOrd(), ord.getNumOrd());
"SELECT wtb_clie.cod_anag, " +
"wtb_users.user_name, wtb_users.password, wtb_users_info.format_file, COUNT(wtb_users_info.format_file) over (partition by wtb_users_info.user_name) as count_export" +
" FROM wtb_users " +
"INNER JOIN wtb_users_info ON wtb_users.User_name = wtb_users_info.user_name " +
"INNER JOIN wtb_clie ON wtb_users.User_name = wtb_clie.user_name " +
" WHERE wtb_users_info.flag_state = 'S' and " +
" wtb_clie.cod_anag = %s AND \n" +
" wtb_users_info.export_type = %s",
ord.getCodAnag(), EntityExportType.ORDINI_VENDITA.getText());
ObjectNode jsonNode = JsonNodeFactory.instance.objectNode();
jsonNode.put("whereCond", whereCond);
emsServices.export(multiDBTransactionManager, requestDataDTO, EntityExportType.ORDINI_VENDITA.getText(), formatExport, jsonNode, true);
datiExport = UtilityDB.executeSimpleQueryOnlyFirstRow(multiDBTransactionManager.getPrimaryConnection(), query);
export.add(datiExport);
}
if (UtilityHashMap.isPresent(datiExport)) {
String userNameExport = UtilityHashMap.getValueIfExists(datiExport, "user_name");
String passwordExport = UtilityHashMap.getValueIfExists(datiExport, "password");
String formatExport = UtilityHashMap.getValueIfExists(datiExport, "format_file");
Integer countExport = UtilityHashMap.getValueIfExists(datiExport, "count_export");
if (countExport == 1) {
RequestDataDTO requestDataDTO = new RequestDataDTO();
requestDataDTO.setUsername(userNameExport);
requestDataDTO.setPassword(passwordExport);
String whereCond =
Query.format(
"dtb_ordt.gestione = %s AND dtb_ordt.data_ord = %s AND dtb_ordt.num_ord = %s",
ord.getGestione(), ord.getDataOrd(), ord.getNumOrd());
ObjectNode jsonNode = JsonNodeFactory.instance.objectNode();
jsonNode.put("whereCond", whereCond);
emsServices.export(multiDBTransactionManager, requestDataDTO, EntityExportType.ORDINI_VENDITA.getText(), formatExport, jsonNode, true);
}
}
}
}

View File

@@ -64,6 +64,9 @@ public class ProductController {
@Autowired
private MultiDBTransactionManager multiDBTransactionManager;
@Autowired
private it.integry.ems.jpa.repository.MtbAartRepository mtbAartRepository;
@Autowired
private ServiceChecker serviceChecker;
@@ -282,7 +285,20 @@ public class ProductController {
@RequestParam("codMart") String codMartString) throws Exception {
List<String> codMarts = Arrays.asList(codMartString.split(","));
List<MtbAart> mtbAartList = productServices.getArticoliByCodMarts(codMarts);
List<MtbAart> mtbAartList = mtbAartRepository.findWithBarcodeWithUntMisByCodMartIn(codMarts);
return new ServiceRestResponse(EsitoType.OK, null, mtbAartList);
}
@RequestMapping(value = EmsRestConstants.PATH_SMART_ENTERPRISE_GET_ART_BY_CODMART + "/jpa", method = RequestMethod.GET)
public @ResponseBody
ServiceRestResponse getArticoloByCodMartJpa(HttpServletRequest request,
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
@RequestParam("codMart") String codMartString) throws Exception {
List<String> codMarts = Arrays.asList(codMartString.split(","));
List<MtbAart> mtbAartList = mtbAartRepository.findByCodMartIn(codMarts);
return new ServiceRestResponse(EsitoType.OK, null, mtbAartList);
}

View File

@@ -11,7 +11,6 @@ import it.integry.ems.product.importaz.dto.ArticoliMorganteDTO;
import it.integry.ems.product.importaz.dto.ContrattiVenditaDTO;
import it.integry.ems.product.importaz.dto.StatoArticoloDTO;
import it.integry.ems.properties.EmsProperties;
import it.integry.ems.retail.wms.Utility.WMSUtility;
import it.integry.ems.rules.completing.QueryRules;
import it.integry.ems.service.EntityProcessor;
import it.integry.ems.sync.MultiDBTransaction.Connection;
@@ -234,10 +233,6 @@ public class ProductServices {
return results;
}
public List<MtbAart> getArticoliByCodMarts(List<String> codMarts) throws Exception {
return WMSUtility.getArticoliByCodMarts(codMarts, multiDBTransactionManager.getPrimaryConnection());
}
public List<EntityBase> importArticoliBiolevante() throws Exception {
List<EntityBase> toBeProcessed = new ArrayList<EntityBase>();
List<EntityBase> entitiesReturn = new ArrayList<EntityBase>();

View File

@@ -148,7 +148,7 @@ public class ContrattiDiAcquistoHandlerService {
.setAtbOffr(value));
});
List<EntityBase> ret = entityProcessor.processEntityList(atbOfftsToSave, mdb, false, RequestDataDTO.systemMockupData());
List<EntityBase> ret = entityProcessor.processEntityList(atbOfftsToSave, mdb, false, RequestDataDTO.systemMockupData(mdb.getPrimaryConnection().getProfileName()));
UtilityEntity.throwEntitiesException(ret);
return ret;

View File

@@ -167,7 +167,10 @@ public class ContrattiDiVenditaHandlerService {
.setVtbOffr(value));
});
List<EntityBase> ret = entityProcessor.processEntityList(vtbOfftsToSave, multiDBTransactionManager, false, RequestDataDTO.systemMockupData());
List<EntityBase> ret = entityProcessor.processEntityList(vtbOfftsToSave,
multiDBTransactionManager,
false,
RequestDataDTO.systemMockupData(multiDBTransactionManager.getPrimaryConnection().getProfileName()));
UtilityEntity.throwEntitiesException(ret);
return ret;

View File

@@ -39,7 +39,6 @@ import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
@@ -214,7 +213,7 @@ public class ListiniVenditaServices {
"Allineamento prezzi articoli equivalenti ",
"Sull'azienda " + multiDBTransactionManager.getPrimaryConnection().getDbName() +
" errore nella procedura di allineamento prezzi articoli equivalenti " + vtbListData.getCodVlis(),
vtbListData.getException().getMessage(), new Date());
vtbListData.getException(), new Date());
}
}
}
@@ -443,7 +442,7 @@ public class ListiniVenditaServices {
mailService.sendSystemErrorLog("Consolida listini di vendita ",
"Consolida listini di vendita ",
"Sull'azienda " + multiDBTransactionManager.getPrimaryConnection().getDbName() + " errore nella procedura di cosolidamento listini sul listino " + vtbListData.getCodVlis(),
vtbListData.getException().getMessage(), new Date());
vtbListData.getException(), new Date());
}
}

View File

@@ -235,7 +235,7 @@ public class ImportRapportiniCronotime {
anomalie.add(AnomalieDTO.warning("Dispositivo : " + disp + " non codificato"));
}
for (String badge : badgeSet) {
anomalie.add(AnomalieDTO.warning("Badge num: " + badge + " non codificato"));
anomalie.add(AnomalieDTO.error("Badge num: " + badge + " non codificato"));
}
List<EntityBase> entities = entityProcessor.processEntityList(rapportini, true);

View File

@@ -14,6 +14,7 @@ import it.integry.ems.document.dto.ScaricoLavorazioneDTO;
import it.integry.ems.document.service.DocumentProdService;
import it.integry.ems.exception.MissingDataException;
import it.integry.ems.exception.PrimaryDatabaseNotPresentException;
import it.integry.ems.jpa.repository.MtbAartRepository;
import it.integry.ems.migration._base.IntegryCustomerDB;
import it.integry.ems.production.dto.*;
import it.integry.ems.production.event.ProductionOrderPausedEvent;
@@ -22,7 +23,6 @@ import it.integry.ems.production.event.ProductionUlCreatedEvent;
import it.integry.ems.report.dto.JasperDTO;
import it.integry.ems.report.dto.PairsDTO;
import it.integry.ems.retail.pvmRetail.service.PvmService;
import it.integry.ems.retail.wms.Utility.WMSUtility;
import it.integry.ems.retail.wms.accettazione.service.WMSAccettazioneService;
import it.integry.ems.retail.wms.dto.*;
import it.integry.ems.retail.wms.generic.dto.MvwSitArtUdcDetInventarioDTO;
@@ -129,6 +129,8 @@ public class MesProductionServiceV2 {
@Autowired
private ApplicationEventPublisher applicationEventPublisher;
@Autowired
private MtbAartRepository mtbAartRepository;
public BasePanelAnswerDTO callSupervisorServiceGET(String serviceIp, int servicePort, String serviceName, HashMap<String, String> queryParams) throws Exception {
Integer timeout = setupGest.getSetupInteger(multiDBTransactionManager.getPrimaryConnection(), "MES", "HMI", "TIMEOUT_MACHINE_CONNECTION", 5);
@@ -1126,7 +1128,8 @@ public class MesProductionServiceV2 {
entityProcessor.processEntity(ordineLav, true, multiDBTransactionManager);
MtbAart mtbAart =
WMSUtility.getArticoloByCodMart(ordineLav.getCodProd(), multiDBTransactionManager.getPrimaryConnection());
mtbAartRepository.findByCodMart(ordineLav.getCodProd())
.orElse(null);
if (UtilityBigDecimal.isNullOrZero(dto.getQtaCollo())) {
if (UtilityBigDecimal.isNullOrZero(dto.getColliPedana())) {

View File

@@ -0,0 +1,34 @@
package it.integry.ems.retail.pvmRetail.controller;
import it.integry.ems.javabeans.RequestDataDTO;
import it.integry.ems.response.ServiceRestResponse;
import it.integry.ems.retail.pvmRetail.service.OrdiniAService;
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
import it.integry.ems_model.entity.key.DtbOrdtKey;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@Scope("request")
@RequestMapping("pvm/ordini_a")
public class OrdiniAController {
private final RequestDataDTO requestDataDTO;
private final MultiDBTransactionManager multiDBTransactionManager;
private final OrdiniAService ordiniAService;
public OrdiniAController(RequestDataDTO requestDataDTO, MultiDBTransactionManager multiDBTransactionManager, OrdiniAService ordiniAService) {
this.requestDataDTO = requestDataDTO;
this.multiDBTransactionManager = multiDBTransactionManager;
this.ordiniAService = ordiniAService;
}
@PostMapping("/checkOrder")
public ServiceRestResponse checkOrder(@RequestBody DtbOrdtKey orderKey) throws Exception{
return ServiceRestResponse.createPositiveResponse(ordiniAService.checkOrder(multiDBTransactionManager.getPrimaryConnection(),orderKey));
}
}

View File

@@ -0,0 +1,110 @@
package it.integry.ems.retail.pvmRetail.dto;
import it.integry.ems_model.annotation.SqlField;
import it.integry.ems_model.entity.DtbOrdr;
import it.integry.ems_model.entity.key.DtbOrdtKey;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class CheckOrderResponseDTO {
@SqlField("gestione")
private String gestione;
@SqlField("data_ord")
private Date dataOrd;
@SqlField("num_ord")
private Integer numOrd;
@SqlField("tot_merce")
private BigDecimal totMerce;
@SqlField("valore_min_ord")
private BigDecimal valoreMinOrd;
@SqlField("valore_minimo_superato")
private boolean valoreMinimoSuperato = true;
private Integer articoliInPromo = 0;
private List<DtbOrdr> articoliFuoriGriglia = new ArrayList<>();
private List<DtbOrdr> articoliQtaInvalida = new ArrayList<>();
public BigDecimal getTotMerce() {
return totMerce;
}
public CheckOrderResponseDTO setTotMerce(BigDecimal totMerce) {
this.totMerce = totMerce;
return this;
}
public BigDecimal getValoreMinOrd() {
return valoreMinOrd;
}
public CheckOrderResponseDTO setValoreMinOrd(BigDecimal valoreMinOrd) {
this.valoreMinOrd = valoreMinOrd;
return this;
}
public boolean isValoreMinimoSuperato() {
return valoreMinimoSuperato;
}
public CheckOrderResponseDTO setValoreMinimoSuperato(boolean valoreMinimoSuperato) {
this.valoreMinimoSuperato = valoreMinimoSuperato;
return this;
}
public Integer getArticoliInPromo() {
return articoliInPromo;
}
public CheckOrderResponseDTO setArticoliInPromo(Integer articoliInPromo) {
this.articoliInPromo = articoliInPromo;
return this;
}
public List<DtbOrdr> getArticoliFuoriGriglia() {
return articoliFuoriGriglia;
}
public CheckOrderResponseDTO setArticoliFuoriGriglia(List<DtbOrdr> articoliFuoriGriglia) {
this.articoliFuoriGriglia = articoliFuoriGriglia;
return this;
}
public List<DtbOrdr> getArticoliQtaInvalida() {
return articoliQtaInvalida;
}
public CheckOrderResponseDTO setArticoliQtaInvalida(List<DtbOrdr> articoliQtaInvalida) {
this.articoliQtaInvalida = articoliQtaInvalida;
return this;
}
public String getGestione() {
return gestione;
}
public CheckOrderResponseDTO setGestione(String gestione) {
this.gestione = gestione;
return this;
}
public Date getDataOrd() {
return dataOrd;
}
public CheckOrderResponseDTO setDataOrd(Date dataOrd) {
this.dataOrd = dataOrd;
return this;
}
public Integer getNumOrd() {
return numOrd;
}
public CheckOrderResponseDTO setNumOrd(Integer numOrd) {
this.numOrd = numOrd;
return this;
}
}

View File

@@ -0,0 +1,99 @@
package it.integry.ems.retail.pvmRetail.service;
import it.integry.ems.retail.pvmRetail.dto.CheckOrderResponseDTO;
import it.integry.ems.sync.MultiDBTransaction.Connection;
import it.integry.ems_model.entity.DtbOrdr;
import it.integry.ems_model.entity.key.DtbOrdtKey;
import it.integry.ems_model.utility.Query;
import it.integry.ems_model.utility.UtilityDB;
import it.integry.ems_model.utility.UtilityList;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class OrdiniAService {
public CheckOrderResponseDTO checkOrder(Connection connection, DtbOrdtKey orderKey) throws Exception {
CheckOrderResponseDTO response = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(connection, Query.format(
"select gestione,\n" +
"data_ord,\n" +
"num_ord,\n" +
"tot_merce,\n" +
" valore_min_ord,\n" +
" cast(case\n" +
" when valore_min_ord is not null then\n" +
" case when tot_merce > valore_min_ord then 1 else 0 end\n" +
" else 1 end as bit) as valore_minimo_superato\n" +
"from dtb_ordt\n" +
" inner join atb_list al on al.cod_alis = dtb_ordt.listino\n" +
"where dtb_ordt.gestione = {}\n" +
" and dtb_ordt.data_ord = {}\n" +
" and dtb_ordt.num_ord = {}"
, orderKey.getGestione(), orderKey.getDataOrd(), orderKey.getNumOrd()), CheckOrderResponseDTO.class);
Integer articoliInPromo = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
Query.format("select count(*)\n" +
"from dtb_ordt\n" +
" inner join dtb_ordr on dtb_ordt.gestione = dtb_ordr.gestione and\n" +
" dtb_ordt.data_ord = dtb_ordr.data_ord and\n" +
" dtb_ordt.num_ord = dtb_ordr.num_ord\n" +
" inner join mtb_depo on dtb_ordt.cod_mdep = mtb_depo.cod_mdep\n" +
"where dtb_ordt.gestione = {}\n" +
" AND dtb_ordt.data_ord = {}\n" +
" AND dtb_ordt.num_ord = {}\n" +
" and dtb_ordr.cod_mart in (\n" +
" select distinct griglia.cod_mart\n" +
" from dbo.getGrigliaAcquisto({}, dtb_ordt.listino, mtb_depo.cod_mdep, null, null) griglia\n" +
" inner join\n" +
" dbo.getPromozioneVendita({}, {}, mtb_depo.cod_vlis, null, null) promo_vend\n" +
" on griglia.cod_mart = promo_vend.cod_mart\n" +
")\n", orderKey.getGestione(), orderKey.getDataOrd(), orderKey.getNumOrd(), orderKey.getDataOrd(), orderKey.getDataOrd(), orderKey.getDataOrd())
);
response.setArticoliInPromo(articoliInPromo);
List<DtbOrdr> righeFuoriGriglia = UtilityDB.executeSimpleQueryDTO(connection, Query.format(
"SELECT dtb_ordr.cod_mart, dtb_ordr.descrizione, dtb_ordr.qta_ord, dtb_ordr.unt_ord\n" +
"FROM dtb_ordt\n" +
" INNER JOIN dtb_ordr ON dtb_ordt.gestione = dtb_ordr.gestione AND\n" +
" dtb_ordt.data_ord = dtb_ordr.data_ord AND\n" +
" dtb_ordt.num_ord = dtb_ordr.num_ord\n" +
"\n" +
"WHERE dtb_ordt.gestione = {}\n" +
" AND dtb_ordt.data_ord = {}\n" +
" AND dtb_ordt.num_ord = {}\n" +
" AND NOT EXISTS (SELECT *\n" +
" FROM dbo.getgrigliaacquisto({}, NULL, NULL, NULL, NULL) griglia\n" +
" WHERE tipo_variazione <> 'D'\n" +
" AND dtb_ordt.listino = griglia.cod_alis\n" +
" AND dtb_ordt.cod_mdep = griglia.cod_mdep\n" +
" AND dtb_ordr.cod_mart = griglia.cod_mart\n" +
" AND (dtb_ordr.cod_art_for IS NULL OR dtb_ordr.cod_art_for = griglia.cod_art_for))\n",
orderKey.getGestione(), orderKey.getDataOrd(), orderKey.getNumOrd(), orderKey.getDataOrd()
), DtbOrdr.class);
if (!UtilityList.isNullOrEmpty(righeFuoriGriglia)) {
response.setArticoliFuoriGriglia(righeFuoriGriglia);
}
List<DtbOrdr> articoliQtaOrdInvalida = UtilityDB.executeSimpleQueryDTO(connection, Query.format(
"select gestione,data_ord,num_ord, riga_ord, cod_mart, descrizione, unt_ord , qta_ord, qta_cnf\n" +
"from dtb_ordr\n" +
"where gestione = {}\n" +
" and data_ord = {}\n" +
" and num_ord = {}\n" +
" and unt_ord = 'pz'\n" +
"and not qta_ord %% qta_cnf = 0",
orderKey.getGestione(), orderKey.getDataOrd(), orderKey.getNumOrd()
), DtbOrdr.class);
if (!UtilityList.isNullOrEmpty(articoliQtaOrdInvalida)) {
response.setArticoliQtaInvalida(articoliQtaOrdInvalida);
}
return response;
}
}

View File

@@ -1,45 +1,48 @@
package it.integry.ems.retail.service;
import it.integry.ems.dynamic_cache.EntityCacheComponent;
import it.integry.ems.production.agribook.model.AgribookOrderDTO;
import it.integry.ems.jpa.repository.MtbAartRepository;
import it.integry.ems.retail.dto.AnomalieMerceDTO;
import it.integry.ems.retail.dto.DettaglioULDTO;
import it.integry.ems.retail.dto.SaveAnomaliaRequestDTO;
import it.integry.ems.retail.dto.SaveLivelloAnomaliaRequestDTO;
import it.integry.ems.retail.utility.AnomalieUlUtility;
import it.integry.ems.retail.wms.Utility.WMSUtility;
import it.integry.ems.retail.wms.generic.dto.MvwSitArtUdcDetInventarioDTO;
import it.integry.ems.service.EntityProcessor;
import it.integry.ems.sync.MultiDBTransaction.Connection;
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.entity.MtbAart;
import it.integry.ems_model.entity.MtbAnomalieUl;
import it.integry.ems_model.entity.MtbColt;
import it.integry.ems_model.entity.MtbLivelliAnomalie;
import it.integry.ems_model.types.OperationType;
import it.integry.ems_model.utility.*;
import it.integry.ems_model.utility.UtilityDB;
import it.integry.ems_model.utility.UtilityList;
import it.integry.ems_model.utility.UtilityLong;
import it.integry.ems_model.utility.UtilityString;
import it.integry.ems_model.utility.dto.PageableRequestDTO;
import it.integry.ems_model.utility.dto.PaginatedDTO;
import org.jfree.util.ObjectList;
import org.springframework.stereotype.Service;
import javax.validation.constraints.NotNull;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Service
public class AnomalieUlService {
private final EntityCacheComponent entityCacheComponent;
private final EntityProcessor entityProcessor;
private final MtbAartRepository mtbAartRepository;
public AnomalieUlService(EntityCacheComponent entityCacheComponent, EntityProcessor entityProcessor) {
public AnomalieUlService(EntityCacheComponent entityCacheComponent, EntityProcessor entityProcessor, MtbAartRepository mtbAartRepository) {
this.entityCacheComponent = entityCacheComponent;
this.entityProcessor = entityProcessor;
this.mtbAartRepository = mtbAartRepository;
}
public PaginatedDTO<AnomalieMerceDTO> getAnomalieProd(PageableRequestDTO requestDTO, Connection connection) throws Exception {
@@ -78,14 +81,13 @@ public class AnomalieUlService {
if (UtilityList.isNullOrEmpty(ulDetails))
return new ArrayList<>();
List<String> codMarts = ulDetails.stream().map(DettaglioULDTO::getCodMart).distinct().collect(Collectors.toList());
Map<String, MtbAart> artMap = entityCacheComponent.<MtbAart>getCachedEntitiesStream(connection.getIntegryCustomerDB(), MtbAart.ENTITY, art -> codMarts.contains(art.getCodMart())).collect(Collectors.toMap(MtbAart::getCodMart, x -> x));
ulDetails.forEach(ul -> {
MtbAart art = artMap.get(ul.getCodMart());
ul.setDescrizione(art.getDescrizione())
.setDescrizioneEstesa(art.getDescrizioneEstesa())
.setUntMis(art.getUntMis());
});
for (DettaglioULDTO ulDetail : ulDetails) {
final MtbAart mtbAart = mtbAartRepository.findByCodMart(ulDetail.getCodMart()).get();
ulDetail.setDescrizione(mtbAart.getDescrizione())
.setDescrizioneEstesa(mtbAart.getDescrizioneEstesa())
.setUntMis(mtbAart.getUntMis());
}
return ulDetails;
}

View File

@@ -1,20 +1,16 @@
package it.integry.ems.retail.service;
import com.annimon.stream.Stream;
import com.fasterxml.jackson.databind.ObjectMapper;
import it.integry.ems.exception.PrimaryDatabaseNotPresentException;
import it.integry.ems.expansion.RunnableThrowable;
import it.integry.ems.javabeans.RequestDataDTO;
import it.integry.ems.json.ResponseJSONObjectMapper;
import it.integry.ems.retail.dto.GiacenzaDTO;
import it.integry.ems.retail.pvmRetail.service.PvmService;
import it.integry.ems.service.EntityProcessor;
import it.integry.ems.service.MailService;
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
import it.integry.ems.utility.UtilityDebug;
import it.integry.ems.utility.UtilityDirs;
import it.integry.ems.utility.UtilityEntity;
import it.integry.ems.utility.UtilityFile;
import it.integry.ems_model.base.EntityBase;
import it.integry.ems_model.db.ResultSetMapper;
import it.integry.ems_model.entity.CarelliGiacenzaProg;
@@ -31,12 +27,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
@@ -209,7 +202,7 @@ public class GiacenzaService {
List<CarelliGiacenzaProg> carelliGiacenzaProgs = new ResultSetMapper().mapQuerySetToList(multiDBTransactionManager.getPrimaryConnection(), sql, CarelliGiacenzaProg.class, OperationType.INSERT);
List<EntityBase> entityRet = entityProcessor.processEntityList(carelliGiacenzaProgs, null, false, true, false, multiDBTransactionManager, false, false,
RequestDataDTO.systemMockupData());
RequestDataDTO.systemMockupData(multiDBTransactionManager.getPrimaryConnection().getProfileName()));
UtilityEntity.throwEntitiesException(entityRet);
}
@@ -224,7 +217,7 @@ public class GiacenzaService {
List<CarelliGiacenzaProg> carelliGiacenzaProgs = new ResultSetMapper().mapQuerySetToList(multiDBTransactionManager.getPrimaryConnection(), sql, CarelliGiacenzaProg.class, OperationType.DELETE);
List<EntityBase> entityRet = entityProcessor.processEntityList(carelliGiacenzaProgs, null, false, true, false, multiDBTransactionManager, false, false,
RequestDataDTO.systemMockupData());
RequestDataDTO.systemMockupData(multiDBTransactionManager.getPrimaryConnection().getProfileName()));
UtilityEntity.throwEntitiesException(entityRet);
}
@@ -489,7 +482,9 @@ public class GiacenzaService {
.setDataDoc(UtilityLocalDate.localDateToDate(collo.getDataCollo()))
.setDataDistribuzione(new Date());
collo.setOperation(OperationType.UPDATE);
entityProcessor.processEntity(collo, false, false, "", multiDBTransactionManager, RequestDataDTO.systemMockupData(), false, false);
entityProcessor.processEntity(collo, false, false, "",
multiDBTransactionManager,
RequestDataDTO.systemMockupData(multiDBTransactionManager.getPrimaryConnection().getProfileName()), false, false);
UtilityEntity.throwEntityException(collo);
}
}
@@ -510,7 +505,8 @@ public class GiacenzaService {
calls.add(() -> {
try {
for (EntityBase entityBase : entityList) {
entityProcessor.processEntity(entityBase, false, true, "", multiDBTransactionManager, RequestDataDTO.systemMockupData(), false, false);
entityProcessor.processEntity(entityBase, false, true, "", multiDBTransactionManager,
RequestDataDTO.systemMockupData(multiDBTransactionManager.getPrimaryConnection().getProfileName()), false, false);
}
} catch (Exception ex) {
@@ -522,7 +518,8 @@ public class GiacenzaService {
UtilityThread.executeParallel(calls);
} else {
for (EntityBase entityBase : entityBases) {
entityProcessor.processEntity(entityBase, false, true, "", multiDBTransactionManager, RequestDataDTO.systemMockupData(), false, false);
entityProcessor.processEntity(entityBase, false, true, "", multiDBTransactionManager,
RequestDataDTO.systemMockupData(multiDBTransactionManager.getPrimaryConnection().getProfileName()), false, false);
}
}
multiDBTransactionManager.commitAll();
@@ -580,16 +577,14 @@ public class GiacenzaService {
}
public List<GiacenzaDTO> retrieveGiacenza(String codMdep, boolean readOrdini, String codMart) throws Exception {
String sql = Query.format(
"SELECT cod_mdep FROM stb_gest_setup_depo WHERE gest_name = %s AND section = %s AND key_section = %S AND value = %S",
gestName, section, "REPLACE_DEPO", codMdep);
String codMdepNew = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
String whereCond = UtilityDB.valueToString(codMdep);
if (codMdepNew != null) {
if (codMdepNew != null)
whereCond += ", " + UtilityDB.valueToString(codMdepNew);
}
sql = "WITH art AS (SELECT mtb_aart.cod_mart AS cod_mart,\n" +
" IIF(mtb_aart.articolo_composto = 'S'\n" +

View File

@@ -1,12 +1,11 @@
package it.integry.ems.retail.wms.Utility;
import com.annimon.stream.Optional;
import com.annimon.stream.Stream;
import it.integry.ems._context.ApplicationContextProvider;
import it.integry.ems.dynamic_cache.EntityCacheComponent;
import it.integry.ems.exception.MissingDataException;
import it.integry.ems.exception.PrimaryDatabaseNotPresentException;
import it.integry.ems.javabeans.RequestDataDTO;
import it.integry.ems.jpa.repository.MtbAartRepository;
import it.integry.ems.retail.wms.dto.*;
import it.integry.ems.retail.wms.exceptions.InvalidArticoloException;
import it.integry.ems.retail.wms.generic.dto.MvwSitArtUdcDetInventarioDTO;
@@ -30,7 +29,10 @@ import java.io.IOException;
import java.math.BigDecimal;
import java.sql.SQLException;
import java.time.LocalDate;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
public class WMSUtility {
@@ -246,15 +248,16 @@ public class WMSUtility {
public static InsertUDSRowResponseDTO insertUDSLavorazioneRowMovement(Connection connection, InsertUDSRowRequestDTO insertUDSRowRequestDTO, String username) throws Exception {
DroolsDataCompleting droolsDataCompleting = ApplicationContextProvider.getApplicationContext().getBean(DroolsDataCompleting.class);
MtbAartRepository mtbAartRepository = ApplicationContextProvider.getApplicationContext().getBean(MtbAartRepository.class);
//Prendo solo la chiave
MtbColt targetMtbColt = insertUDSRowRequestDTO.getTargetMtbColt();
if (targetMtbColt == null)
throw new Exception("Nessun collo di destinazione specificato durante l'inserimento di una riga in una UDS (targetMtbColt null)");
MtbAart mtbAart = WMSUtility.getArticoloByCodMart(insertUDSRowRequestDTO.getCodMart(), connection);
if (mtbAart == null)
throw new InvalidArticoloException(insertUDSRowRequestDTO.getCodMart());
MtbAart mtbAart = mtbAartRepository.findByCodMart(insertUDSRowRequestDTO.getCodMart())
.orElseThrow(() -> new InvalidArticoloException(insertUDSRowRequestDTO.getCodMart()));
MtbColrInfoProd mtbColrInfoProd = null;
@@ -503,7 +506,13 @@ public class WMSUtility {
public static InsertUDCRowResponseDTO insertUDCRow(InsertUDCRowRequestDTO insertUDCRowRequestDTO, EntityProcessor entityProcessor, MultiDBTransactionManager multiDBTransactionManager) throws Exception {
MtbAartRepository mtbAartRepository = ApplicationContextProvider.getApplicationContext().getBean(MtbAartRepository.class);
MtbColt targetMtbColt = insertUDCRowRequestDTO.getTargetMtbColt();
if (targetMtbColt == null)
throw new MissingDataException("UL di destinazione non presente");
targetMtbColt.setOperation(OperationType.SELECT_OBJECT);
entityProcessor.processEntity(targetMtbColt, true, multiDBTransactionManager);
@@ -534,9 +543,8 @@ public class WMSUtility {
if (insertUDCRowRequestDTO.getCodMart() != null) {
MtbAart mtbAart = getArticoloByCodMart(insertUDCRowRequestDTO.getCodMart(), multiDBTransactionManager.getPrimaryConnection());
if (mtbAart == null)
throw new InvalidArticoloException(insertUDCRowRequestDTO.getCodMart());
MtbAart mtbAart = mtbAartRepository.findByCodMart(insertUDCRowRequestDTO.getCodMart())
.orElseThrow(() -> new InvalidArticoloException(insertUDCRowRequestDTO.getCodMart()));
targetMtbColr
.setCodMart(mtbAart.getCodMart())
@@ -563,82 +571,7 @@ public class WMSUtility {
.setSavedMtbColr(targetMtbColr);
}
public static MtbAart getArticoloByCodMart(String codMart, Connection connection) throws Exception {
if (UtilityString.isNullOrEmpty(codMart))
return null;
List<MtbAart> mtbAarts = getArticoliByCodMarts(new ArrayList<>(Collections.singleton(codMart)), connection);
if (mtbAarts == null || mtbAarts.isEmpty())
return null;
return mtbAarts.get(0);
}
public static List<MtbAart> getArticoliByCodMarts(List<String> codMarts, Connection connection) throws Exception {
if (codMarts == null || codMarts.isEmpty()) return null;
final EntityCacheComponent entityCacheComponent = ApplicationContextProvider.getApplicationContext().getBean(EntityCacheComponent.class);
List<MtbAart> listMtbAart = entityCacheComponent.getCachedEntitiesList(
connection.getIntegryCustomerDB(), MtbAart.ENTITY, x -> codMarts.parallelStream().anyMatch(y -> y.equalsIgnoreCase(x.getCodMart())));
List<MtbAartBarCode> barCodeFromCod = getAlternativeMtbAartBarCodes(codMarts, connection);
if (listMtbAart != null && !listMtbAart.isEmpty()) {
List<String> untMisStrings = listMtbAart.stream()
.map(MtbAart::getUntMis)
.collect(Collectors.toList());
List<MtbUntMis> listUntMis = getUntMisFromCod(untMisStrings, connection);
for (final MtbAart mtbAart : listMtbAart) {
Optional<MtbUntMis> mtbUntMis = Stream.of(listUntMis)
.filter(mtbUntMis1 -> mtbUntMis1.getUntMis().equalsIgnoreCase(mtbAart.getUntMis()))
.findFirst();
List<MtbAartBarCode> barcodeList = Stream.of(barCodeFromCod)
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbAart.getCodMart()))
.toList();
if (!barcodeList.isEmpty()) {
mtbAart.getMtbAartBarCode().addAll(barcodeList);
}
if (mtbUntMis.isPresent()) {
mtbAart.setMtbUntMis(new ArrayList<>());
mtbAart.getMtbUntMis().add(mtbUntMis.get());
}
}
}
return listMtbAart;
}
public static List<MtbUntMis> getUntMisFromCod(List<String> untMisCods, Connection connection) throws Exception {
List<String> untMisStrings = Stream.of(untMisCods)
.withoutNulls()
.distinct()
.toList();
String queryUntMis = "SELECT * FROM mtb_unt_mis WHERE unt_mis IN (" + UtilityQuery.concatStringFieldsWithSeparator(untMisStrings, ",") + ")";
final List<MtbUntMis> mtbUntMis = UtilityDB.executeSimpleQueryDTO(connection, queryUntMis, MtbUntMis.class);
return mtbUntMis != null ? mtbUntMis : new ArrayList<>();
}
public static List<MtbAartBarCode> getAlternativeMtbAartBarCodes(List<String> codMarts, Connection conn) {
codMarts = codMarts.stream()
.distinct().collect(Collectors.toList());
final EntityCacheComponent entityCacheComponent = ApplicationContextProvider.getApplicationContext().getBean(EntityCacheComponent.class);
List<String> finalCodMarts = codMarts;
List<MtbAartBarCode> barCodeList = entityCacheComponent.getCachedEntitiesList(
conn.getIntegryCustomerDB(),
MtbAartBarCode.ENTITY,
x -> finalCodMarts.stream().anyMatch(y -> y.equalsIgnoreCase(x.getCodMart())));
return barCodeList != null ? barCodeList : new ArrayList<>();
}
public static MtbColt createInternalMovement(String codMdep) {
@@ -659,6 +592,10 @@ public class WMSUtility {
return null;
return new MtbColr()
.setNumCollo(inputData.getNumCollo())
.setDataCollo(inputData.getDataCollo())
.setGestione(inputData.getGestione())
.setSerCollo(inputData.getSerCollo())
.setCodMart(inputData.getCodMart())
.setPartitaMag(inputData.getPartitaMag())
// .setCodCol(inputData.getCodCol())
@@ -722,4 +659,14 @@ public class WMSUtility {
return UtilityDB.executeSimpleQueryDTO(connection,Query.format("SELECT * from mtb_colt where barcode_ul in ("+UtilityDB.listValueToString(barcodeList)+")"), MtbColt.class);
}
public static MtbColt getUlPosizioneMonoUl(Connection connection, String posizione) throws Exception {
String sql = "SELECT * FROM mtb_colt " +
" inner join mtb_depo_posizioni on mtb_colt.posizione = mtb_depo_posizioni.posizione" +
" WHERE mtb_colt.segno = 1 AND mtb_depo_posizioni.flag_mono_collo = 'S' and mtb_depo_posizioni.posizione = " + UtilityDB.valueToString(posizione) ;
List<MtbColt> listaUl = UtilityDB.executeSimpleQueryDTO(connection,sql,MtbColt.class);
if (listaUl.isEmpty()) throw new Exception("Nessuna UL trovata per la posizione " + posizione);
if (listaUl.size() > 1) throw new Exception("Ci sono più UL disponibili per la posizione " + posizione);
return listaUl.get(0);
}
}

View File

@@ -1,8 +1,8 @@
package it.integry.ems.retail.wms.accettazione.service;
import it.integry.ems.javabeans.RequestDataDTO;
import it.integry.ems.jpa.repository.MtbAartRepository;
import it.integry.ems.product.importaz.service.ProductServices;
import it.integry.ems.retail.wms.Utility.WMSUtility;
import it.integry.ems.retail.wms.accettazione.dto.AlreadyRegisteredUlDTO;
import it.integry.ems.retail.wms.accettazione.dto.BollaAccettazioneDTO;
import it.integry.ems.retail.wms.accettazione.dto.SitBollaAccettazioneDTO;
@@ -43,6 +43,8 @@ public class WMSAccettazioneBollaService {
@Autowired
private UserSession userSession;
@Autowired
private MtbAartRepository mtbAartRepository;
public List<BollaAccettazioneDTO> retrieveBolleDaAccettare() throws Exception {
@@ -166,11 +168,11 @@ public class WMSAccettazioneBollaService {
if (sitBollaAccettazioneDTOS == null || sitBollaAccettazioneDTOS.isEmpty()) return null;
final List<MtbAart> articoliByCodMarts = WMSUtility.getArticoliByCodMarts(sitBollaAccettazioneDTOS.stream()
final List<MtbAart> articoliByCodMarts = mtbAartRepository.findByCodMartIn(sitBollaAccettazioneDTOS.stream()
.map(SitBollaAccettazioneDTO::getCodMart)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList()), multiDBTransactionManager.getPrimaryConnection());
.collect(Collectors.toList()));
final Map<String, BigDecimal> qtaCnfsByArt = articoliByCodMarts.stream()
.collect(Collectors.toMap(MtbAart::getCodMart, MtbAart::getQtaCnf));

View File

@@ -2,6 +2,7 @@ package it.integry.ems.retail.wms.accettazione.service;
import it.integry.ems.exception.PrimaryDatabaseNotPresentException;
import it.integry.ems.javabeans.RequestDataDTO;
import it.integry.ems.jpa.repository.MtbAartRepository;
import it.integry.ems.product.importaz.service.ProductServices;
import it.integry.ems.retail.pvmRetail.dto.OrdineInevasoDTO;
import it.integry.ems.retail.wms.Utility.WMSUtility;
@@ -69,6 +70,9 @@ public class WMSAccettazioneService {
@Autowired
private AziendaService aziendaService;
@Autowired
private MtbAartRepository mtbAartRepository;
public MtbColt createUDC(CreateUDCRequestDTO createUDCRequestDTO) throws Exception {
if (!userSession.isAttivo()) {
throw new UsernameNotFoundException("Utente " + userSession.getUsername() + " non riconoscuto!");
@@ -85,7 +89,7 @@ public class WMSAccettazioneService {
.setCodVdes(createUDCRequestDTO.getCodVdes())
.setDataCollo(createUDCRequestDTO.getDataCollo())
.setOraInizPrep(new Date())
.setPreparatoDa(requestDataDTO.getUsername())
.setPreparatoDa(userSession.getUsername())
.setPosizione(UtilityString.isNullOrEmpty(createUDCRequestDTO.getPosizione()) ? defaultPosizioneColliAccettazione : createUDCRequestDTO.getPosizione())
.setCodTcol(createUDCRequestDTO.getCodTcol())
.setAnnotazioni(createUDCRequestDTO.getAnnotazioni())
@@ -162,7 +166,9 @@ public class WMSAccettazioneService {
udcMtbColt.setOperation(OperationType.INSERT);
entityProcessor.processEntity(udcMtbColt, multiDBTransactionManager);
udcMtbColt.setOnlyPkMaster(false);
udcMtbColt
.setMtbCols(new ArrayList<>())
.setOnlyPkMaster(false);
return udcMtbColt;
}
@@ -289,7 +295,7 @@ public class WMSAccettazioneService {
.distinct()
.collect(Collectors.toList());
List<MtbAart> mtbAarts = productServices.getArticoliByCodMarts(codMarts);
List<MtbAart> mtbAarts = mtbAartRepository.findByCodMartIn(codMarts);
MtbColt targetMtbColt = inputData.getTargetMtbColt();
targetMtbColt.setOperation(OperationType.SELECT_OBJECT);

View File

@@ -1,10 +1,10 @@
package it.integry.ems.retail.wms.documenti.service;
import it.integry.ems.jpa.repository.MtbUntMisRepository;
import it.integry.ems.product.importaz.service.ProductServices;
import it.integry.ems.retail.pvmRetail.dto.PvmArticoliChildDTO;
import it.integry.ems.retail.pvmRetail.dto.PvmArticoliDTO;
import it.integry.ems.retail.pvmRetail.service.PvmService;
import it.integry.ems.retail.wms.Utility.WMSUtility;
import it.integry.ems.retail.wms.documenti.dto.DocumentArtDTO;
import it.integry.ems.retail.wms.documenti.dto.RetrieveLottiDTO;
import it.integry.ems.sync.MultiDBTransaction.Connection;
@@ -38,6 +38,8 @@ public class WMSDocumentService {
@Autowired
private SetupGest setupGest;
@Autowired
private MtbUntMisRepository mtbUntMisRepository;
public Boolean checkDoc(String fornitore, String numDoc, Date dataDoc, String tipoDoc) throws Exception {
Connection conn = multiDBTransactionManager.getPrimaryConnection();
@@ -114,7 +116,8 @@ public class WMSDocumentService {
.distinct()
.collect(Collectors.toList());
final List<MtbUntMis> untMisFromCod = WMSUtility.getUntMisFromCod(untMiss,multiDBTransactionManager.getPrimaryConnection());
final List<MtbUntMis> untMisFromCod = mtbUntMisRepository.findByUntMisIn(untMiss);
for (DocumentArtDTO art : arts) {
final MtbUntMis mtbUntMis = untMisFromCod.stream().filter(x -> x.getUntMis().equalsIgnoreCase(art.getUntMis()))

View File

@@ -1,6 +1,7 @@
package it.integry.ems.retail.wms.generic.controller;
import it.integry.common.var.CommonConstants;
import it.integry.ems.jpa.repository.MtbAartRepository;
import it.integry.ems.product.importaz.service.ProductServices;
import it.integry.ems.response.ServiceRestResponse;
import it.integry.ems.retail.wms.generic.dto.*;
@@ -37,6 +38,8 @@ public class WMSArticoloController {
@Autowired
private UserSession userSession;
@Autowired
private MtbAartRepository mtbAartRepository;
@RequestMapping(value = "", method = RequestMethod.GET)
@@ -93,8 +96,7 @@ public class WMSArticoloController {
ServiceRestResponse searchByCodMartOrBarcode(@RequestParam(CommonConstants.PROFILE_DB) String profileDB,
@RequestBody RetrieveArticoloByCodMartRequestDTO retrieveArticoloByCodMartRequest) throws Exception {
return ServiceRestResponse.createPositiveResponse(
productServices.getArticoliByCodMarts(retrieveArticoloByCodMartRequest.getCodMarts()));
return ServiceRestResponse.createPositiveResponse(mtbAartRepository.findByCodMartIn(retrieveArticoloByCodMartRequest.getCodMarts()));
}

View File

@@ -556,9 +556,16 @@ public class WMSGenericController {
public @ResponseBody
ServiceRestResponse spostaULInPosizione(@RequestParam(CommonConstants.PROFILE_DB) String configuration,
@RequestBody SpostaUlRequestDTO requestDTO) throws Exception {
wmsGenericService.spostaUL(requestDTO);
return ServiceRestResponse.createPositiveResponse();
try {
MtbColt mtbColt = wmsGenericService.spostaUL(requestDTO);
if (mtbColt != null) {
mtbColt.setOnlyPkMaster(false);
}
return ServiceRestResponse.createPositiveResponse(mtbColt);
} catch (Exception e) {
multiDBTransactionManager.rollbackAll();
throw e;
}
}
@@ -705,4 +712,11 @@ public class WMSGenericController {
) throws Exception {
return ServiceRestResponse.createPositiveResponse(WMSUtility.retrieveBarcodesByBarcodeAndCodJfas(multiDBTransactionManager.getPrimaryConnection(),barcodeUl,codJfas, maxResults));
}
@GetMapping("wms/resetta-posizioni-mono-ul")
ServiceRestResponse resettaPosizioniMonoUl() throws Exception {
wmsGenericService.resettaPosizioniMonoUL(multiDBTransactionManager, entityProcessor);
return ServiceRestResponse.createPositiveResponse();
}
}

View File

@@ -3,6 +3,7 @@ package it.integry.ems.retail.wms.generic.dto;
import it.integry.ems_model.entity.MtbColt;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class SpostaUlRequestDTO {
@@ -10,6 +11,9 @@ public class SpostaUlRequestDTO {
private String codMdep;
private String posizione;
private String annotazioni;
private Date dataTrasf;
private Integer numTrasf;
private String codVvet;
private boolean createDocAutomatically = true;
private List<MtbColt> mtbColtsToMove = new ArrayList<>();
@@ -49,6 +53,33 @@ public class SpostaUlRequestDTO {
return this;
}
public Date getDataTrasf() {
return dataTrasf;
}
public SpostaUlRequestDTO setDataTrasf(Date dataTrasf) {
this.dataTrasf = dataTrasf;
return this;
}
public Integer getNumTrasf() {
return numTrasf;
}
public SpostaUlRequestDTO setNumTrasf(Integer numTrasf) {
this.numTrasf = numTrasf;
return this;
}
public String getCodVvet() {
return codVvet;
}
public SpostaUlRequestDTO setCodVvet(String codVvet) {
this.codVvet = codVvet;
return this;
}
public boolean isCreateDocAutomatically() {
return createDocAutomatically;
}

Some files were not shown because too many files have changed in this diff Show More