Compare commits
97 Commits
feature-re
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| 5fbf7975d2 | |||
| a75b66bd53 | |||
| 13439c236d | |||
| 77d5a9cb9e | |||
| d4cfada677 | |||
| 27c6795b9f | |||
| dd9ff5c111 | |||
| 1a4773659a | |||
| 0d2da1a92c | |||
| b203e94836 | |||
| b3c99f7937 | |||
| 6257fd540d | |||
| 635ac0a1c7 | |||
| 8abf441a8a | |||
| 8781b406ff | |||
| c9325674d9 | |||
| 99ca1731b1 | |||
| af6f465c0e | |||
| d981e59a7d | |||
| 6d7212ce97 | |||
| 5103830369 | |||
| 5056d7e0c8 | |||
| 4b5e46de7b | |||
| 4d686ee145 | |||
| e842326f5b | |||
| 63ad11086f | |||
| 21f6fc6717 | |||
| 8c2789b5f3 | |||
| 8f3ef405cf | |||
| 76e76dfcf4 | |||
| 1df5ad7137 | |||
| a43ca46395 | |||
| a63eba544b | |||
| ce912bf103 | |||
| ababbf6142 | |||
| e97fd0aacb | |||
| 51c1ed1d23 | |||
| a9be8f7003 | |||
| 7522092a12 | |||
| 4dc0174800 | |||
| a04b2fa4a1 | |||
| 04317470c6 | |||
| 187216dd9f | |||
| e11172a90f | |||
| 51d5b05bd3 | |||
| 3a2ceaf217 | |||
| c783f69a49 | |||
| 1c8695095b | |||
| fc28af761c | |||
| fd4db5ab3b | |||
| f7e1d1f6ca | |||
| 0b8f82f041 | |||
| 99680dccd8 | |||
| e948855fc0 | |||
| 0854acacfb | |||
| 1aba141c9f | |||
| 741cb960d4 | |||
| 82d7efc00c | |||
| c6c2739525 | |||
| 313bfc21ff | |||
| 36f50ad846 | |||
| 798e5b532e | |||
| c27c96c3d9 | |||
| 4e3d15ebd8 | |||
| 0ba9297f39 | |||
| 7c036172d8 | |||
| 8afa01d8ef | |||
| db1949b5b6 | |||
| bb47dd458e | |||
| 530b6af4ef | |||
| 92cd4b1af5 | |||
| 6b71d6b784 | |||
| de4d8d225f | |||
| 671c2e99d0 | |||
| 755e7394b4 | |||
| ce06683722 | |||
| e8a1a8ca0b | |||
| 7a5c024005 | |||
| c82f2a57d8 | |||
| 78dbf9f7e3 | |||
| d7012d4e1f | |||
| 1d52f79337 | |||
| 0e1adccb7c | |||
| fa76a8e92d | |||
| 9b34a51bd9 | |||
| b75f7e3810 | |||
| 4aeccdfa76 | |||
| 39db8e6e1b | |||
| 1b87cacca2 | |||
| 326bd4294e | |||
| e887aceaaf | |||
| 55f23b2dfc | |||
| 1ef49b87e8 | |||
| 920257812c | |||
| 77c79c6247 | |||
| c26f7feb35 | |||
| 21cc88f295 |
18
.idea/copilotDiffState.xml
generated
Normal file
18
.idea/copilotDiffState.xml
generated
Normal file
File diff suppressed because one or more lines are too long
33
.idea/dataSources.xml
generated
33
.idea/dataSources.xml
generated
@@ -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
8
.idea/data_source_mapping.xml
generated
Normal 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
6
.idea/db-forest-config.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="db-tree-configuration">
|
||||
<option name="data" value="---------------------------------------- 1:0:ff4f0bad-7271-429e-a4e1-bae28629efc8 2:0:02282d62-6d2a-4b83-bdcf-b558fa6db140 3:0:eaf0bcaf-4620-478b-b63c-42e77902813f " />
|
||||
</component>
|
||||
</project>
|
||||
5
.idea/jarRepositories.xml
generated
5
.idea/jarRepositories.xml
generated
@@ -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" />
|
||||
|
||||
1
.idea/runConfigurations/MenuStaticCreator.xml
generated
1
.idea/runConfigurations/MenuStaticCreator.xml
generated
@@ -2,7 +2,6 @@
|
||||
<configuration default="false" name="MenuStaticCreator" type="Application" factoryName="Application" nameIsGenerated="true">
|
||||
<option name="MAIN_CLASS_NAME" value="it.integry.ems.menu.MenuStaticCreator" />
|
||||
<module name="ems-core" />
|
||||
<shortenClasspath name="MANIFEST" />
|
||||
<extension name="coverage">
|
||||
<pattern>
|
||||
<option name="PATTERN" value="it.integry.ems.menu.*" />
|
||||
|
||||
2
.idea/sqldialects.xml
generated
2
.idea/sqldialects.xml
generated
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="SqlDialectMappings">
|
||||
<file url="file://$PROJECT_DIR$/ems-engine/src/main/java/it/integry/ems/document/farm_mes/service/FarmMesImportService.java" dialect="GenericSQL" />
|
||||
<file url="file://$PROJECT_DIR$/.idea/queries/Query_2.sql" dialect="TSQL" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -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
|
||||
40
Dockerfile
40
Dockerfile
@@ -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/
|
||||
|
||||
@@ -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}"
|
||||
|
||||
@@ -269,7 +269,7 @@
|
||||
{
|
||||
"profileName": "GRAMM",
|
||||
"connectionType": "MSSQL",
|
||||
"dbName": "gramm_peppe",
|
||||
"dbName": "gramm",
|
||||
"username": "SA",
|
||||
"password": "sZ",
|
||||
"host": "192.168.2.220",
|
||||
@@ -299,7 +299,7 @@
|
||||
{
|
||||
"profileName": "IME_TE",
|
||||
"connectionType": "MSSQL",
|
||||
"dbName": "IME_TE_peppe",
|
||||
"dbName": "IME_TE",
|
||||
"username": "SA",
|
||||
"password": "sZ",
|
||||
"host": "192.168.2.214",
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -19,7 +19,6 @@ import it.integry.WooCommerce.dto.product.variation.WooCommerceProductVariationD
|
||||
import it.integry.WooCommerce.enums.ArticoloException;
|
||||
import it.integry.WooCommerce.enums.StockStatus;
|
||||
import it.integry.WooCommerce.enums.SyncOrigin;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.Import.dto.AnomalieDTO;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.service.MailService;
|
||||
@@ -30,6 +29,7 @@ import it.integry.ems_model.entity.WdtbOrds;
|
||||
import it.integry.ems_model.entity.WdtbOrdt;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.UtilityDate;
|
||||
import it.integry.ems_model.utility.UtilityStream;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
@@ -41,7 +41,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -445,8 +445,7 @@ public class WooCommerceService {
|
||||
}
|
||||
|
||||
//CHIAVE ORDINE
|
||||
LocalDate dataOrd = UtilityString.parseLocalDateTime(orderDTO.getDateCreated(), "yyyy-MM-dd'T'HH:mm:ss")
|
||||
.toLocalDate();
|
||||
Date dataOrd = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(orderDTO.getDateCreated());
|
||||
|
||||
ordineWeb
|
||||
.setGestione("V")
|
||||
@@ -454,7 +453,7 @@ public class WooCommerceService {
|
||||
.setNumOrd(Integer.parseInt(orderDTO.getNumber()))
|
||||
//CHIAVE RIFERIMENTO ORDINE WOOCOMMERCE
|
||||
.setSerie(dataManager.getSetup("SERIE"))
|
||||
.setRifOrd(UtilityString.left("RIF N." + orderDTO.getNumber() + " DEL " + CommonConstants.DATE_DMY_DASHED_FORMATTER.format(dataOrd) + " " + orderDTO.getOrderKey(), 40))
|
||||
.setRifOrd(UtilityString.left("RIF N." + orderDTO.getNumber() + " DEL " + UtilityDate.formatDate(dataOrd, "dd-MM-yy") + " " + orderDTO.getOrderKey(), 40))
|
||||
.setDataOrdRif(dataOrd)
|
||||
.setNumOrdRif(Integer.parseInt(orderDTO.getNumber()))
|
||||
.setListino(dataManager.getSetup("LISTINO"));
|
||||
|
||||
@@ -22,16 +22,16 @@ public class CommonConstants {
|
||||
|
||||
|
||||
public static final String DATE_FORMAT_YMD_SLASHED = "yyyy/MM/dd";
|
||||
public static final String DATE_FORMAT_YMD_DASHED = "yyyy-MM-dd";
|
||||
public static final String DATE_FORMAT_DMY_SLASHED = "dd/MM/yyyy";
|
||||
public static final String DATE_FORMAT_YMD = "yyyy-MM-dd";
|
||||
public static final String DATE_FORMAT_DMY = "dd/MM/yyyy";
|
||||
public static final String DATE_FORMAT_DMY_DASHED = "dd-MM-yyyy";
|
||||
public static final String DATE_FORMAT_DMYHMS_UNSPACED = "ddMMyyyyHHmmss";
|
||||
|
||||
public static final String TIME_FORMAT = "HH:mm:ss";
|
||||
|
||||
public static final String DATETIME_FORMAT_YMD = String.format("%s %s", DATE_FORMAT_YMD_DASHED, TIME_FORMAT);
|
||||
public static final String DATETIME_FORMAT_YMD = String.format("%s %s", DATE_FORMAT_YMD_SLASHED, TIME_FORMAT);
|
||||
public static final String DATETIME_FORMAT_DMY = String.format("%s %s", DATE_FORMAT_DMY_DASHED, TIME_FORMAT);
|
||||
public static final String DATETIME_FORMAT_DMY_SLASHED = String.format("%s %s", DATE_FORMAT_DMY_SLASHED, TIME_FORMAT);
|
||||
public static final String DATETIME_FORMAT_DMY_SLASHED = String.format("%s %s", DATE_FORMAT_DMY, TIME_FORMAT);
|
||||
public static final String DATETIME_FORMAT_DMY_DASHED = String.format("%s %s", DATE_FORMAT_DMY_DASHED, TIME_FORMAT);
|
||||
|
||||
|
||||
@@ -52,13 +52,12 @@ public class CommonConstants {
|
||||
.withZone(ZoneId.systemDefault());
|
||||
public static final DateTimeFormatter DATETIME_YMD_SLASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATETIME_FORMAT_YMD)
|
||||
.withZone(ZoneId.systemDefault());
|
||||
public static final DateTimeFormatter DATE_YMD_DASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATE_FORMAT_YMD_DASHED)
|
||||
public static final DateTimeFormatter DATE_YMD_DASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATE_FORMAT_YMD)
|
||||
.withZone(ZoneId.systemDefault());
|
||||
public static final DateTimeFormatter DATETIME_YMD_DASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATETIME_FORMAT_YMD)
|
||||
.withZone(ZoneId.systemDefault());
|
||||
|
||||
|
||||
public static final DateTimeFormatter DATE_DMY_SLASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATE_FORMAT_DMY_SLASHED)
|
||||
public static final DateTimeFormatter DATE_DMY_SLASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATE_FORMAT_DMY)
|
||||
.withZone(ZoneId.systemDefault());
|
||||
public static final DateTimeFormatter DATE_DMY_DASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATE_FORMAT_DMY_DASHED)
|
||||
.withZone(ZoneId.systemDefault());
|
||||
|
||||
@@ -1,269 +0,0 @@
|
||||
package it.integry.ems.anonymizer;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Generatore di nomi e cognomi italiani per l'anonimizzazione dei dati.
|
||||
* Mantiene la coerenza del sesso tra nome e genere.
|
||||
*/
|
||||
public class ItalianNameGenerator {
|
||||
|
||||
private final Random random;
|
||||
|
||||
// Nomi maschili italiani (200+ nomi)
|
||||
public static final List<String> MALE_NAMES = Arrays.asList(
|
||||
"Alessandro", "Andrea", "Antonio", "Francesco", "Marco", "Matteo", "Giuseppe", "Luca",
|
||||
"Giovanni", "Roberto", "Stefano", "Paolo", "Davide", "Michele", "Simone", "Federico",
|
||||
"Riccardo", "Fabio", "Daniele", "Massimo", "Claudio", "Nicola", "Gabriele", "Vincenzo",
|
||||
"Lorenzo", "Salvatore", "Emanuele", "Alberto", "Diego", "Tommaso", "Alessio", "Filippo",
|
||||
"Giorgio", "Mattia", "Franco", "Bruno", "Enrico", "Mario", "Carlo", "Gianluca",
|
||||
"Cristian", "Domenico", "Raffaele", "Sergio", "Pasquale", "Gianni", "Carmine", "Gennaro",
|
||||
"Antonino", "Gaetano", "Rocco", "Mauro", "Pierluigi", "Valerio", "Mirko", "Dario",
|
||||
"Enzo", "Alfredo", "Renzo", "Giancarlo", "Giampaolo", "Pierpaolo", "Gianfranco", "Guido",
|
||||
"Nino", "Piero", "Armando", "Luciano", "Renato", "Angelo", "Aldo", "Giulio",
|
||||
"Marcello", "Rodolfo", "Umberto", "Silvano", "Ivano", "Giampiero", "Silvio", "Maurizio",
|
||||
"Leonardo", "Adriano", "Ferdinando", "Bernardo", "Teodoro", "Edoardo", "Arturo", "Gino",
|
||||
"Biagio", "Fabrizio", "Fausto", "Ettore", "Cesare", "Elio", "Amerigo", "Italo",
|
||||
"Orlando", "Romeo", "Sandro", "Tiziano", "Ignazio", "Ciro", "Loris", "Orazio",
|
||||
"Lino", "Nello", "Rino", "Primo", "Secondo", "Terzo", "Quarto", "Quinto",
|
||||
"Sesto", "Settimo", "Ottavio", "Nono", "Decimo", "Benito", "Dante", "Virgilio",
|
||||
"Omero", "Eugenio", "Aurelio", "Valentino", "Corrado", "Manlio", "Emilio", "Tullio",
|
||||
"Attilio", "Marcello", "Romolo", "Remo", "Amedeo", "Cosimo", "Damiano", "Sebastiano",
|
||||
"Cristoforo", "Bartolomeo", "Giacomo", "Simone", "Pietro", "Girolamo", "Leopoldo", "Gaspare",
|
||||
"Melchiorre", "Baldassarre", "Epifanio", "Gerardo", "Ruggero", "Tancredi", "Arnaldo", "Osvaldo",
|
||||
"Rinaldo", "Romualdo", "Ubaldo", "Raimondo", "Edmondo", "Redento", "Crescenzo", "Innocenzo",
|
||||
"Fiorenzo", "Vincenzo", "Enzo", "Renzo", "Nunzio", "Maurizio", "Patrizio", "Orazio",
|
||||
"Flavio", "Claudio", "Giuliano", "Adriano", "Emiliano", "Massimiliano", "Gianmarco", "Marcantonio",
|
||||
"Gianbattista", "Giovanbattista", "Giammarco", "Gianluigi", "Giampiero", "Gianmaria", "Giandomenico", "Gianpaolo",
|
||||
"Pierfrancesco", "Piergiorgio", "Pierangelo", "Piermario", "Piercarlo", "Piergiuseppe", "Gioacchino", "Bartolomeo",
|
||||
"Benedetto", "Benvenuto", "Bonaventura", "Bonifacio", "Camillo", "Calogero", "Carmelo", "Demetrio",
|
||||
"Dionisio", "Donato", "Egidio", "Eliseo", "Erminio", "Eustachio", "Evandro", "Ezio",
|
||||
"Fermo", "Fernando", "Ferruccio", "Fortunato", "Fulvio", "Gaetano", "Germano", "Giosuè",
|
||||
"Gregorio", "Guglielmo", "Lamberto", "Lanfranco", "Liborio", "Lucio", "Luigi", "Manfredo"
|
||||
);
|
||||
|
||||
// Nomi femminili italiani (200+ nomi)
|
||||
public static final List<String> FEMALE_NAMES = Arrays.asList(
|
||||
"Giulia", "Francesca", "Chiara", "Federica", "Sara", "Martina", "Valentina", "Alessandra",
|
||||
"Silvia", "Elisa", "Giorgia", "Elena", "Paola", "Laura", "Roberta", "Alice", "Serena",
|
||||
"Barbara", "Anna", "Maria", "Simona", "Claudia", "Monica", "Cristina", "Elisabetta",
|
||||
"Stefania", "Valeria", "Daniela", "Manuela", "Antonella", "Giovanna", "Sabrina", "Emanuela",
|
||||
"Ilaria", "Cinzia", "Rosanna", "Patrizia", "Teresa", "Carmela", "Giuseppina", "Rosa",
|
||||
"Antonietta", "Concetta", "Caterina", "Angela", "Raffaella", "Luisa", "Lucia", "Michela",
|
||||
"Franceschina", "Graziella", "Isabella", "Benedetta", "Beatrice", "Margherita", "Alessia", "Andrea",
|
||||
"Cristiana", "Fabiana", "Gabriella", "Gianna", "Lorena", "Marisa", "Nicoletta", "Ornella",
|
||||
"Rosaria", "Silvana", "Susanna", "Tiziana", "Viviana", "Adriana", "Agnese", "Albina",
|
||||
"Amelia", "Andreina", "Angelica", "Antonella", "Arianna", "Armida", "Augusta", "Aurora",
|
||||
"Bruna", "Brunella", "Camilla", "Carla", "Carolina", "Cecilia", "Clara", "Clelia",
|
||||
"Concettina", "Corinna", "Cosima", "Costanza", "Cristiana", "Delia", "Diana", "Dora",
|
||||
"Donatella", "Edvige", "Eleonora", "Elvira", "Emma", "Enrichetta", "Ester", "Eugenia",
|
||||
"Eva", "Fabia", "Fabiola", "Fernanda", "Fiorella", "Fiorenza", "Flora", "Franca",
|
||||
"Gaia", "Gemma", "Gilda", "Gina", "Gloria", "Grazia", "Ida", "Ilda",
|
||||
"Immacolata", "Ines", "Iolanda", "Irene", "Iris", "Ivana", "Ivanka", "Lara",
|
||||
"Letizia", "Licia", "Lidia", "Liliana", "Lina", "Linda", "Lisa", "Livia",
|
||||
"Loredana", "Lorella", "Lorenza", "Luana", "Luciana", "Lucilla", "Lucrezia", "Ludovica",
|
||||
"Luigia", "Luna", "Maddalena", "Mafalda", "Marcella", "Marella", "Marilena", "Marina",
|
||||
"Marisa", "Marta", "Matilde", "Maura", "Mirella", "Miriam", "Morena", "Nadia",
|
||||
"Natalia", "Natalina", "Nella", "Nelly", "Nicole", "Noemi", "Norma", "Olga",
|
||||
"Olimpia", "Orietta", "Palmira", "Pamela", "Pascale", "Pasqualina", "Pia", "Piera",
|
||||
"Pierina", "Priscilla", "Raffaela", "Rebecca", "Regina", "Renata", "Rita", "Romina",
|
||||
"Rosalba", "Rosalia", "Rosangela", "Rosanna", "Rosella", "Rosetta", "Rosina", "Rossana",
|
||||
"Rossella", "Samanta", "Sandra", "Santina", "Sebastiana", "Serafina", "Sonia", "Stella",
|
||||
"Tecla", "Tina", "Tosca", "Tullia", "Uberta", "Umberta", "Ursula", "Vera",
|
||||
"Veronica", "Vincenza", "Viola", "Virginia", "Vittoria", "Wanda", "Yvonne", "Zaira",
|
||||
"Zelda", "Zita", "Zoe", "Ambra", "Azzurra", "Bianca", "Celeste", "Diamante",
|
||||
"Fiamma", "Giada", "Perla", "Sole", "Stella", "Alba", "Alma", "Anya"
|
||||
);
|
||||
|
||||
// Cognomi italiani (300+ cognomi)
|
||||
public static final List<String> SURNAMES = Arrays.asList(
|
||||
"Rossi", "Ferrari", "Russo", "Bianchi", "Romano", "Gallo", "Costa", "Fontana",
|
||||
"Esposito", "Ricci", "Bruno", "Moretti", "Marino", "Greco", "Barbieri", "Lombardi",
|
||||
"Giordano", "Colombo", "Rizzo", "Benedetti", "Palumbo", "Pellegrini", "Caruso", "Ferretti",
|
||||
"Galli", "Marchetti", "Villa", "Mancini", "Conte", "Serra", "Ferrero", "Martinelli",
|
||||
"Mariani", "Giuliani", "Vitale", "Santoro", "Ferrara", "Leone", "Longo", "Gentile",
|
||||
"Martino", "Fabbri", "Rinaldi", "Messina", "Riva", "Conti", "Silvestri", "Coppola",
|
||||
"Negri", "Milani", "Parisi", "Sala", "Cattaneo", "Orlando", "Fiore", "Marini",
|
||||
"Guerra", "Pagano", "Bernardi", "Valenti", "Farina", "Ruggiero", "Caputo", "Monti",
|
||||
"Grassi", "Montanari", "Santini", "Morelli", "Amato", "Neri", "Donati", "Testa",
|
||||
"Bianco", "Sorrentino", "Rossini", "Giuliano", "Sartori", "De Angelis", "De Rosa",
|
||||
"Basile", "Costantini", "Rizzi", "Barone", "Martini", "De Santis", "Basso", "Pellegrino",
|
||||
"Carbone", "Gatti", "Coppola", "Rossetto", "Piras", "Ricci", "Martinelli", "Sanna",
|
||||
"Torrisi", "Scuderi", "Priolo", "Anastasi", "Puglisi", "La Rosa", "Catalano", "Garofalo",
|
||||
"Aiello", "Trovato", "Pappalardo", "Pulvirenti", "Marletta", "Di Marco", "Biondi", "Ferri",
|
||||
"Testa", "Marchi", "Baldini", "Benedetti", "Colombi", "Gasparini", "Orlandi", "Barbera",
|
||||
"Damico", "Guerriero", "Napolitano", "Romano", "Mazza", "Caruso", "Ferraro", "Gaeta",
|
||||
"Di Stefano", "Palma", "Carbone", "Morrone", "Milazzo", "Calabrese", "Ventura", "Palmieri",
|
||||
"Martello", "Fico", "Pastore", "Arena", "Maggio", "Sciacca", "Pagliaro", "Lupo",
|
||||
"Mangano", "Capra", "Finocchiaro", "Grasso", "Morabito", "Pellicano", "Castelli", "Castaldo",
|
||||
"Mauro", "Piazza", "Battaglia", "D Amico", "Forte", "Antonelli", "Delia", "Marino",
|
||||
"Cosentino", "Lazzaro", "Vitale", "Lombardo", "Crisafulli", "Nicolosi", "Bellomo", "Morreale",
|
||||
"Messina", "Vaccaro", "Nicosia", "Fazio", "Spina", "Russo", "Parisi", "Zappala",
|
||||
"Riccobono", "Camilleri", "Barbagallo", "Oliveri", "Pistone", "Gambino", "Cavallaro", "Burgio",
|
||||
"Gentile", "Restivo", "Di Bella", "Genovese", "Ferrante", "Gianninoto", "Vitrano", "Gargano",
|
||||
"Lombardi", "Milani", "Picci", "De Luca", "Foti", "Giardina", "Di Pietro", "Russo",
|
||||
"La Spina", "Morello", "Moschetti", "Penna", "Ferretti", "Colombo", "Marra", "De Simone",
|
||||
"Cozzi", "Grimaldi", "Pellegrini", "Galdi", "Paolini", "Ferrara", "Santangelo", "Di Giovanni",
|
||||
"Iannone", "Lucchese", "Orsini", "Mastroianni", "Fiorentino", "Capasso", "Di Napoli", "Giannini",
|
||||
"Romano", "Vitale", "Fontana", "Galdi", "Giuliani", "Barbieri", "Lombardo", "Martinelli",
|
||||
"De Rosa", "Ferri", "Caputo", "Castaldi", "Mauro", "Monti", "Villa", "Marcello",
|
||||
"Ricci", "Ferretti", "Gallo", "Fabbri", "Marini", "Grasso", "Carbone", "Bevilacqua",
|
||||
"Giannone", "Perna", "Pellegrino", "Di Lorenzo", "Napoli", "Amato", "Donato", "Riccio",
|
||||
"Giuliano", "Mancuso", "Bellotti", "Bianchini", "Rossetti", "Mazza", "Silvestri", "Baldini",
|
||||
"Martinelli", "Galli", "Colombo", "Ferraro", "Palumbo", "Marchetti", "Ferrera", "Rossi",
|
||||
"Caruso", "Serra", "Marchese", "Benedetti", "Franzese", "Basile", "Di Mauro", "Torrisi",
|
||||
"Licata", "Scuderi", "Platania", "Priolo", "Marletta", "Biondi", "Grassi", "Fontana",
|
||||
"Pagano", "Gentile", "Moretti", "Guerra", "Santoro", "Longo", "Giordano", "Fiore",
|
||||
"Marchetti", "Parisi", "Milani", "Orlando", "Sala", "Costa", "Cattaneo", "Neri",
|
||||
"Donati", "Mancini", "Montanari", "Caputo", "De Angelis", "Sartori", "De Santis", "Basso"
|
||||
);
|
||||
|
||||
public enum Gender {
|
||||
MALE, FEMALE
|
||||
}
|
||||
|
||||
/**
|
||||
* Costruttore con seed random sicuro
|
||||
*/
|
||||
public ItalianNameGenerator() {
|
||||
this.random = new SecureRandom();
|
||||
}
|
||||
|
||||
/**
|
||||
* Costruttore con seed personalizzato per risultati riproducibili
|
||||
* @param seed seed per il generatore random
|
||||
*/
|
||||
public ItalianNameGenerator(long seed) {
|
||||
this.random = new Random(seed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Genera un genere casuale
|
||||
* @return Gender casuale (MALE o FEMALE)
|
||||
*/
|
||||
public Gender generateGender() {
|
||||
return random.nextBoolean() ? Gender.MALE : Gender.FEMALE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Genera un nome casuale in base al sesso specificato
|
||||
* @param gender il sesso per cui generare il nome
|
||||
* @return nome casuale del sesso specificato
|
||||
*/
|
||||
public String generateFirstName(Gender gender) {
|
||||
List<String> names = (gender == Gender.MALE) ? MALE_NAMES : FEMALE_NAMES;
|
||||
return names.get(random.nextInt(names.size()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Genera un cognome casuale
|
||||
* @return cognome casuale
|
||||
*/
|
||||
public String generateSurname() {
|
||||
return SURNAMES.get(random.nextInt(SURNAMES.size()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Genera un nome completo (nome + cognome) in base al sesso
|
||||
* @param gender il sesso per cui generare il nome completo
|
||||
* @return nome completo del sesso specificato
|
||||
*/
|
||||
public String generateFullName(Gender gender) {
|
||||
return generateFirstName(gender) + " " + generateSurname();
|
||||
}
|
||||
|
||||
/**
|
||||
* Genera un nome completo con sesso casuale
|
||||
* @return nome completo con sesso casuale
|
||||
*/
|
||||
public String generateRandomFullName() {
|
||||
Gender randomGender = random.nextBoolean() ? Gender.MALE : Gender.FEMALE;
|
||||
return generateFullName(randomGender);
|
||||
}
|
||||
|
||||
/**
|
||||
* Genera una persona completa con nome, cognome e sesso
|
||||
* @return oggetto Person con i dati generati
|
||||
*/
|
||||
public Person generatePerson() {
|
||||
Gender gender = random.nextBoolean() ? Gender.MALE : Gender.FEMALE;
|
||||
return new Person(generateFirstName(gender), generateSurname(), gender);
|
||||
}
|
||||
|
||||
/**
|
||||
* Genera una persona mantenendo il sesso specificato
|
||||
* @param gender il sesso da mantenere
|
||||
* @return oggetto Person con i dati generati
|
||||
*/
|
||||
public Person generatePerson(Gender gender) {
|
||||
return new Person(generateFirstName(gender), generateSurname(), gender);
|
||||
}
|
||||
|
||||
/**
|
||||
* Classe interna per rappresentare una persona generata
|
||||
*/
|
||||
public static class Person {
|
||||
private final String firstName;
|
||||
private final String surname;
|
||||
private final Gender gender;
|
||||
|
||||
public Person(String firstName, String surname, Gender gender) {
|
||||
this.firstName = firstName;
|
||||
this.surname = surname;
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public String getSurname() {
|
||||
return surname;
|
||||
}
|
||||
|
||||
public Gender getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return firstName + " " + surname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("Person{firstName='%s', surname='%s', gender=%s}",
|
||||
firstName, surname, gender);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Metodo di utilità per ottenere il sesso da una stringa
|
||||
* @param genderString stringa rappresentante il sesso ("M", "F", "MALE", "FEMALE", etc.)
|
||||
* @return enum Gender corrispondente
|
||||
* @throws IllegalArgumentException se la stringa non è riconosciuta
|
||||
*/
|
||||
public static Gender parseGender(String genderString) {
|
||||
if (genderString == null) {
|
||||
throw new IllegalArgumentException("Gender string cannot be null");
|
||||
}
|
||||
|
||||
String normalized = genderString.trim().toUpperCase();
|
||||
switch (normalized) {
|
||||
case "M":
|
||||
case "MALE":
|
||||
case "MASCHIO":
|
||||
case "UOMO":
|
||||
return Gender.MALE;
|
||||
case "F":
|
||||
case "FEMALE":
|
||||
case "FEMMINA":
|
||||
case "DONNA":
|
||||
return Gender.FEMALE;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unrecognized gender: " + genderString);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,7 @@ import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.Base64Utility;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityDate;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
@@ -68,7 +69,6 @@ import java.lang.reflect.ParameterizedType;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
@@ -840,7 +840,7 @@ public class EmsController {
|
||||
@RequestParam Integer versione) throws Exception {
|
||||
|
||||
DtbDocPdf dtbDocPdf = new DtbDocPdf();
|
||||
dtbDocPdf.setDataDoc(UtilityString.parseLocalDate(dataDoc));
|
||||
dtbDocPdf.setDataDoc(UtilityDate.RecognizeDate(dataDoc));
|
||||
dtbDocPdf.setSerDoc(serDoc);
|
||||
dtbDocPdf.setNumDoc(numDoc);
|
||||
dtbDocPdf.setCodAnag(codAnag);
|
||||
@@ -893,7 +893,7 @@ public class EmsController {
|
||||
|
||||
DtbOrdPdf dtbOrdPdf = new DtbOrdPdf();
|
||||
dtbOrdPdf.setGestione(gestione);
|
||||
dtbOrdPdf.setDataOrd(UtilityString.parseLocalDate(dataOrd));
|
||||
dtbOrdPdf.setDataOrd(UtilityDate.RecognizeDate(dataOrd));
|
||||
dtbOrdPdf.setNumOrd(numOrd);
|
||||
dtbOrdPdf.setVersione(versione);
|
||||
dtbOrdPdf.setOperation(OperationType.SELECT_OBJECT);
|
||||
@@ -1047,7 +1047,7 @@ public class EmsController {
|
||||
byte[] content = files[0].getBytes();
|
||||
// content = UtilityZip.zlib_compress(content);
|
||||
|
||||
LocalDate dataDoc = UtilityString.parseLocalDate(dataDocStr);
|
||||
Date dataDoc = UtilityDate.RecognizeDate(dataDocStr);
|
||||
|
||||
DtbDocPdf dtbDocPdf = new DtbDocPdf();
|
||||
dtbDocPdf.setDataDoc(dataDoc);
|
||||
@@ -1099,7 +1099,7 @@ public class EmsController {
|
||||
|
||||
String idAttach = null;
|
||||
StbFilesAttached.TypeAttach typeAttach = null;
|
||||
LocalDate dataDoc = UtilityString.parseLocalDate(dataDocStr);
|
||||
Date dataDoc = UtilityDate.RecognizeDate(dataDocStr);
|
||||
|
||||
DrlDocAttached drlDocAttached =
|
||||
new DrlDocAttached()
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
package it.integry.ems.dto;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class ArticoloPartitaCommessaDTO extends ArticoloPartitaDTO {
|
||||
|
||||
private String codJcom;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof ArticoloPartitaCommessaDTO)) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
ArticoloPartitaCommessaDTO that = (ArticoloPartitaCommessaDTO) o;
|
||||
return Objects.equals(getCodJcom(), that.getCodJcom());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), getCodJcom());
|
||||
}
|
||||
|
||||
public String getCodJcom() {
|
||||
return codJcom;
|
||||
}
|
||||
|
||||
public ArticoloPartitaCommessaDTO setCodJcom(String codJcom) {
|
||||
this.codJcom = codJcom;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -1,371 +0,0 @@
|
||||
package it.integry.ems.entity_logger.db_schema_manager.component;
|
||||
|
||||
import it.integry.ems.entity_logger.db_schema_manager.dto.ForeignKeyDependency;
|
||||
import it.integry.ems.entity_logger.db_schema_manager.dto.ForeignKeyDependencyReport;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SQLServerForeignKeyManager {
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
private Connection connection;
|
||||
private boolean disableForeignKeyChecks;
|
||||
|
||||
public SQLServerForeignKeyManager(Connection connection) {
|
||||
this(connection, false);
|
||||
}
|
||||
|
||||
public SQLServerForeignKeyManager(Connection connection, boolean disableForeignKeyChecks) {
|
||||
this.connection = connection;
|
||||
this.disableForeignKeyChecks = disableForeignKeyChecks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggiorna una foreign key e tutte le sue dipendenze in un'unica transazione
|
||||
*
|
||||
* @param tableName Nome della tabella principale
|
||||
* @param columnName Nome della colonna che contiene la chiave primaria
|
||||
* @param oldValue Valore attuale della chiave
|
||||
* @param newValue Nuovo valore della chiave
|
||||
* @return true se l'operazione è completata con successo
|
||||
* @throws SQLException in caso di errore
|
||||
*/
|
||||
public <T> boolean updateForeignKeyWithDependencies(String tableName, String columnName,
|
||||
T oldValue, T newValue) throws SQLException {
|
||||
|
||||
boolean originalAutoCommit = connection.getAutoCommit();
|
||||
List<String> disabledConstraints = new ArrayList<>();
|
||||
|
||||
try {
|
||||
// Disabilita auto-commit per gestire la transazione manualmente
|
||||
connection.setAutoCommit(false);
|
||||
|
||||
logger.info(String.format("Inizio aggiornamento FK: %s.%s da %s a %s",
|
||||
tableName, columnName, oldValue, newValue));
|
||||
|
||||
// 1. Disabilita i vincoli foreign key se richiesto
|
||||
if (disableForeignKeyChecks) {
|
||||
disabledConstraints = disableForeignKeyConstraints(tableName, columnName);
|
||||
logger.info(String.format("Disabilitati %d vincoli foreign key", disabledConstraints.size()));
|
||||
}
|
||||
|
||||
// 2. Trova tutte le dipendenze
|
||||
List<ForeignKeyDependency> dependencies = findAllDependencies(tableName, columnName);
|
||||
logger.info(String.format("Trovate %d dipendenze da aggiornare", dependencies.size()));
|
||||
|
||||
if (disableForeignKeyChecks) {
|
||||
// Se i vincoli sono disabilitati, possiamo aggiornare in qualsiasi ordine
|
||||
// Aggiorniamo prima la tabella principale per semplicità
|
||||
updateMainTable(tableName, columnName, oldValue, newValue);
|
||||
|
||||
// Poi aggiorniamo tutte le tabelle dipendenti
|
||||
for (ForeignKeyDependency dependency : dependencies) {
|
||||
updateDependentTable(dependency, oldValue, newValue);
|
||||
}
|
||||
} else {
|
||||
// Ordine normale: prima le dipendenti, poi la principale
|
||||
for (ForeignKeyDependency dependency : dependencies) {
|
||||
updateDependentTable(dependency, oldValue, newValue);
|
||||
}
|
||||
updateMainTable(tableName, columnName, oldValue, newValue);
|
||||
}
|
||||
|
||||
// 3. Riabilita i vincoli foreign key se erano stati disabilitati
|
||||
if (disableForeignKeyChecks && !disabledConstraints.isEmpty()) {
|
||||
enableForeignKeyConstraints(disabledConstraints);
|
||||
logger.info("Vincoli foreign key riabilitati");
|
||||
|
||||
// 4. Verifica l'integrità dei dati dopo aver riabilitato i vincoli
|
||||
if (!checkConstraintIntegrity(disabledConstraints)) {
|
||||
throw new SQLException("Violazione dell'integrità referenziale dopo l'aggiornamento");
|
||||
}
|
||||
}
|
||||
|
||||
// Commit della transazione
|
||||
connection.commit();
|
||||
logger.info("Aggiornamento completato con successo");
|
||||
|
||||
return true;
|
||||
|
||||
} catch (SQLException e) {
|
||||
// Rollback in caso di errore
|
||||
try {
|
||||
connection.rollback();
|
||||
logger.error("Errore durante l'aggiornamento, rollback eseguito: " + e.getMessage(), e);
|
||||
|
||||
// Se i vincoli erano stati disabilitati, prova a riabilitarli anche dopo il rollback
|
||||
if (disableForeignKeyChecks && !disabledConstraints.isEmpty()) {
|
||||
try {
|
||||
enableForeignKeyConstraints(disabledConstraints);
|
||||
logger.info("Vincoli foreign key riabilitati dopo rollback");
|
||||
} catch (SQLException enableEx) {
|
||||
logger.error("ATTENZIONE: Impossibile riabilitare i vincoli dopo rollback: " + enableEx.getMessage(), enableEx);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException rollbackEx) {
|
||||
logger.error("Errore durante il rollback: " + rollbackEx.getMessage(), rollbackEx);
|
||||
}
|
||||
throw e;
|
||||
|
||||
} finally {
|
||||
// Ripristina l'auto-commit originale
|
||||
connection.setAutoCommit(originalAutoCommit);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disabilita tutti i vincoli foreign key che referenziano la tabella/colonna specificata
|
||||
*/
|
||||
private List<String> disableForeignKeyConstraints(String tableName, String columnName) throws SQLException {
|
||||
List<String> disabledConstraints = new ArrayList<>();
|
||||
List<ForeignKeyDependency> dependencies = findAllDependencies(tableName, columnName);
|
||||
|
||||
for (ForeignKeyDependency dependency : dependencies) {
|
||||
String disableQuery = String.format(
|
||||
"ALTER TABLE [%s].[%s] NOCHECK CONSTRAINT [%s]",
|
||||
dependency.getDependentSchema(),
|
||||
dependency.getDependentTable(),
|
||||
dependency.getConstraintName()
|
||||
);
|
||||
|
||||
try (Statement stmt = connection.createStatement()) {
|
||||
stmt.execute(disableQuery);
|
||||
disabledConstraints.add(String.format("%s.%s.%s",
|
||||
dependency.getDependentSchema(),
|
||||
dependency.getDependentTable(),
|
||||
dependency.getConstraintName()));
|
||||
|
||||
logger.trace(String.format("Disabilitato vincolo: %s", dependency.getConstraintName()));
|
||||
}
|
||||
}
|
||||
|
||||
return disabledConstraints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Riabilita i vincoli foreign key precedentemente disabilitati
|
||||
*/
|
||||
private void enableForeignKeyConstraints(List<String> constraintIdentifiers) throws SQLException {
|
||||
for (String constraintId : constraintIdentifiers) {
|
||||
String[] parts = constraintId.split("\\.");
|
||||
if (parts.length != 3) {
|
||||
logger.warn("Formato constraint identifier non valido: " + constraintId);
|
||||
continue;
|
||||
}
|
||||
|
||||
String schema = parts[0];
|
||||
String table = parts[1];
|
||||
String constraint = parts[2];
|
||||
|
||||
String enableQuery = String.format(
|
||||
"ALTER TABLE [%s].[%s] CHECK CONSTRAINT [%s]",
|
||||
schema, table, constraint
|
||||
);
|
||||
|
||||
try (Statement stmt = connection.createStatement()) {
|
||||
stmt.execute(enableQuery);
|
||||
logger.trace(String.format("Riabilitato vincolo: %s", constraint));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifica l'integrità dei vincoli dopo averli riabilitati
|
||||
*/
|
||||
private boolean checkConstraintIntegrity(List<String> constraintIdentifiers) throws SQLException {
|
||||
boolean allValid = true;
|
||||
|
||||
for (String constraintId : constraintIdentifiers) {
|
||||
String[] parts = constraintId.split("\\.");
|
||||
if (parts.length != 3) continue;
|
||||
|
||||
String schema = parts[0];
|
||||
String table = parts[1];
|
||||
String constraint = parts[2];
|
||||
|
||||
// Verifica se ci sono violazioni del vincolo
|
||||
String checkQuery = String.format("SELECT COUNT(*) as violations\n" +
|
||||
" FROM [%s].[%s] child\n" +
|
||||
" LEFT JOIN (\n" +
|
||||
" SELECT fkc.referenced_object_id, fkc.referenced_column_id,\n" +
|
||||
" fkc.parent_object_id, fkc.parent_column_id\n" +
|
||||
" FROM sys.foreign_key_columns fkc\n" +
|
||||
" INNER JOIN sys.foreign_keys fk ON fkc.constraint_object_id = fk.object_id\n" +
|
||||
" WHERE fk.name = '%s'\n" +
|
||||
" ) fk_info ON 1=1\n" +
|
||||
" LEFT JOIN sys.tables ref_table ON fk_info.referenced_object_id = ref_table.object_id\n" +
|
||||
" LEFT JOIN sys.schemas ref_schema ON ref_table.schema_id = ref_schema.schema_id\n" +
|
||||
" WHERE child.[%s] IS NOT NULL\n" +
|
||||
" AND NOT EXISTS (\n" +
|
||||
" SELECT 1 FROM [%s].[%s] parent\n" +
|
||||
" WHERE parent.[%s] = child.[%s]\n" +
|
||||
" )", schema, table, constraint,
|
||||
"temp_col", // Questo dovrebbe essere sostituito con la colonna effettiva
|
||||
"temp_schema", "temp_table", "temp_parent_col", "temp_col");
|
||||
|
||||
// Query semplificata per il check di integrità
|
||||
String simpleCheckQuery = String.format(
|
||||
"DBCC CHECKCONSTRAINTS('[%s].[%s].[%s]') WITH ALL_CONSTRAINTS",
|
||||
schema, table, constraint
|
||||
);
|
||||
|
||||
try (Statement stmt = connection.createStatement()) {
|
||||
try (ResultSet rs = stmt.executeQuery("SELECT 1")) {
|
||||
// Se la query non solleva eccezioni, il vincolo è valido
|
||||
logger.trace(String.format("Vincolo %s superato controllo integrità", constraint));
|
||||
} catch (SQLException e) {
|
||||
logger.warn(String.format("Violazione integrità per vincolo %s: %s", constraint, e.getMessage()));
|
||||
allValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return allValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trova tutte le dipendenze foreign key di una tabella/colonna
|
||||
*/
|
||||
private List<ForeignKeyDependency> findAllDependencies(String tableName, String columnName) throws SQLException {
|
||||
List<ForeignKeyDependency> dependencies = new ArrayList<>();
|
||||
|
||||
String query = "SELECT \n" +
|
||||
" fk.name AS constraint_name,\n" +
|
||||
" OBJECT_SCHEMA_NAME(fk.parent_object_id) AS dependent_schema,\n" +
|
||||
" OBJECT_NAME(fk.parent_object_id) AS dependent_table,\n" +
|
||||
" COL_NAME(fkc.parent_object_id, fkc.parent_column_id) AS dependent_column,\n" +
|
||||
" OBJECT_SCHEMA_NAME(fk.referenced_object_id) AS referenced_schema,\n" +
|
||||
" OBJECT_NAME(fk.referenced_object_id) AS referenced_table,\n" +
|
||||
" COL_NAME(fkc.referenced_object_id, fkc.referenced_column_id) AS referenced_column\n" +
|
||||
" FROM sys.foreign_keys fk\n" +
|
||||
" INNER JOIN sys.foreign_key_columns fkc ON fk.object_id = fkc.constraint_object_id\n" +
|
||||
" WHERE OBJECT_NAME(fk.referenced_object_id) = ?\n" +
|
||||
" AND COL_NAME(fkc.referenced_object_id, fkc.referenced_column_id) = ?\n" +
|
||||
" ORDER BY dependent_table";
|
||||
|
||||
try (PreparedStatement stmt = connection.prepareStatement(query)) {
|
||||
stmt.setString(1, tableName);
|
||||
stmt.setString(2, columnName);
|
||||
|
||||
try (ResultSet rs = stmt.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
ForeignKeyDependency dependency = new ForeignKeyDependency(
|
||||
rs.getString("constraint_name"),
|
||||
rs.getString("dependent_schema"),
|
||||
rs.getString("dependent_table"),
|
||||
rs.getString("dependent_column"),
|
||||
rs.getString("referenced_schema"),
|
||||
rs.getString("referenced_table"),
|
||||
rs.getString("referenced_column")
|
||||
);
|
||||
dependencies.add(dependency);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggiorna una tabella dipendente
|
||||
*/
|
||||
private void updateDependentTable(ForeignKeyDependency dependency, Object oldValue, Object newValue) throws SQLException {
|
||||
String updateQuery = String.format(
|
||||
"UPDATE [%s].[%s] SET [%s] = ? WHERE [%s] = ?",
|
||||
dependency.getDependentSchema(),
|
||||
dependency.getDependentTable(),
|
||||
dependency.getDependentColumn(),
|
||||
dependency.getDependentColumn()
|
||||
);
|
||||
|
||||
try (PreparedStatement stmt = connection.prepareStatement(updateQuery)) {
|
||||
stmt.setObject(1, newValue);
|
||||
stmt.setObject(2, oldValue);
|
||||
|
||||
int rowsAffected = stmt.executeUpdate();
|
||||
logger.info(String.format("Aggiornate %d righe in %s.%s",
|
||||
rowsAffected, dependency.getDependentTable(), dependency.getDependentColumn()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggiorna la tabella principale
|
||||
*/
|
||||
private void updateMainTable(String tableName, String columnName, Object oldValue, Object newValue) throws SQLException {
|
||||
String updateQuery = String.format("UPDATE [%s] SET [%s] = ? WHERE [%s] = ?",
|
||||
tableName, columnName, columnName);
|
||||
|
||||
try (PreparedStatement stmt = connection.prepareStatement(updateQuery)) {
|
||||
stmt.setObject(1, newValue);
|
||||
stmt.setObject(2, oldValue);
|
||||
|
||||
int rowsAffected = stmt.executeUpdate();
|
||||
logger.info(String.format("Aggiornate %d righe nella tabella principale %s.%s",
|
||||
rowsAffected, tableName, columnName));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifica se un valore esiste già come chiave primaria
|
||||
*/
|
||||
public boolean checkIfValueExists(String tableName, String columnName, Object value) throws SQLException {
|
||||
String query = String.format("SELECT COUNT(*) FROM [%s] WHERE [%s] = ?", tableName, columnName);
|
||||
|
||||
try (PreparedStatement stmt = connection.prepareStatement(query)) {
|
||||
stmt.setObject(1, value);
|
||||
|
||||
try (ResultSet rs = stmt.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
return rs.getInt(1) > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ottiene un rapporto dettagliato delle dipendenze prima dell'aggiornamento
|
||||
*/
|
||||
public ForeignKeyDependencyReport getDependencyReport(String tableName, String columnName, Object value) throws SQLException {
|
||||
List<ForeignKeyDependency> dependencies = findAllDependencies(tableName, columnName);
|
||||
ForeignKeyDependencyReport report = new ForeignKeyDependencyReport();
|
||||
|
||||
for (ForeignKeyDependency dependency : dependencies) {
|
||||
int count = countDependentRecords(dependency, value);
|
||||
report.addDependency(dependency, count);
|
||||
}
|
||||
|
||||
return report;
|
||||
}
|
||||
|
||||
private int countDependentRecords(ForeignKeyDependency dependency, Object value) throws SQLException {
|
||||
String countQuery = String.format(
|
||||
"SELECT COUNT(*) FROM [%s].[%s] WHERE [%s] = ?",
|
||||
dependency.getDependentSchema(),
|
||||
dependency.getDependentTable(),
|
||||
dependency.getDependentColumn()
|
||||
);
|
||||
|
||||
try (PreparedStatement stmt = connection.prepareStatement(countQuery)) {
|
||||
stmt.setObject(1, value);
|
||||
|
||||
try (ResultSet rs = stmt.executeQuery()) {
|
||||
return rs.next() ? rs.getInt(1) : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Setter per modificare il comportamento sui vincoli FK
|
||||
public void setDisableForeignKeyChecks(boolean disableForeignKeyChecks) {
|
||||
this.disableForeignKeyChecks = disableForeignKeyChecks;
|
||||
}
|
||||
|
||||
public boolean isDisableForeignKeyChecks() {
|
||||
return disableForeignKeyChecks;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package it.integry.ems.entity_logger.db_schema_manager.dto;
|
||||
|
||||
public class ForeignKeyDependency {
|
||||
private final String constraintName;
|
||||
private final String dependentSchema;
|
||||
private final String dependentTable;
|
||||
private final String dependentColumn;
|
||||
private final String referencedSchema;
|
||||
private final String referencedTable;
|
||||
private final String referencedColumn;
|
||||
|
||||
public ForeignKeyDependency(String constraintName, String dependentSchema,
|
||||
String dependentTable, String dependentColumn,
|
||||
String referencedSchema, String referencedTable,
|
||||
String referencedColumn) {
|
||||
this.constraintName = constraintName;
|
||||
this.dependentSchema = dependentSchema;
|
||||
this.dependentTable = dependentTable;
|
||||
this.dependentColumn = dependentColumn;
|
||||
this.referencedSchema = referencedSchema;
|
||||
this.referencedTable = referencedTable;
|
||||
this.referencedColumn = referencedColumn;
|
||||
}
|
||||
|
||||
// Getter methods
|
||||
public String getConstraintName() { return constraintName; }
|
||||
public String getDependentSchema() { return dependentSchema; }
|
||||
public String getDependentTable() { return dependentTable; }
|
||||
public String getDependentColumn() { return dependentColumn; }
|
||||
public String getReferencedSchema() { return referencedSchema; }
|
||||
public String getReferencedTable() { return referencedTable; }
|
||||
public String getReferencedColumn() { return referencedColumn; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s.%s.%s -> %s.%s.%s",
|
||||
dependentSchema, dependentTable, dependentColumn,
|
||||
referencedSchema, referencedTable, referencedColumn);
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package it.integry.ems.entity_logger.db_schema_manager.dto;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ForeignKeyDependencyReport {
|
||||
private final Map<ForeignKeyDependency, Integer> dependencyCount = new HashMap<>();
|
||||
|
||||
public void addDependency(ForeignKeyDependency dependency, int count) {
|
||||
dependencyCount.put(dependency, count);
|
||||
}
|
||||
|
||||
public Map<ForeignKeyDependency, Integer> getDependencies() {
|
||||
return new HashMap<>(dependencyCount);
|
||||
}
|
||||
|
||||
public int getTotalRecordsAffected() {
|
||||
return dependencyCount.values().stream().mapToInt(Integer::intValue).sum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("=== RAPPORTO DIPENDENZE ===\n");
|
||||
|
||||
for (Map.Entry<ForeignKeyDependency, Integer> entry : dependencyCount.entrySet()) {
|
||||
sb.append(String.format("Tabella: %s.%s, Colonna: %s, Record da aggiornare: %d\n",
|
||||
entry.getKey().getDependentSchema(),
|
||||
entry.getKey().getDependentTable(),
|
||||
entry.getKey().getDependentColumn(),
|
||||
entry.getValue()));
|
||||
}
|
||||
|
||||
sb.append(String.format("TOTALE RECORD DA AGGIORNARE: %d\n", getTotalRecordsAffected()));
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
21
ems-core/src/main/java/it/integry/ems/jpa/TenantContext.java
Normal file
21
ems-core/src/main/java/it/integry/ems/jpa/TenantContext.java
Normal 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
@Component
|
||||
public class LooperService {
|
||||
public class LooperService {
|
||||
private final ArrayList<LoopDTO> mLoopsHandler = new ArrayList<>();
|
||||
private final ArrayList<TaskModel> mLoopsTask = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -93,7 +93,7 @@ public enum IntegryCustomerDB {
|
||||
Frudis_Frudis("frudis"),
|
||||
|
||||
|
||||
Gramm_Gramm("gramm_peppe"),
|
||||
Gramm_Gramm("gramm"),
|
||||
Gramm_PrimeOlive("primeolive"),
|
||||
Gramm_ProveStage("grammprovestage"),
|
||||
Gramm_2MHolding("dueemme"),
|
||||
@@ -108,7 +108,7 @@ public enum IntegryCustomerDB {
|
||||
Igood_ShopService("shop_service"),
|
||||
|
||||
|
||||
Ime_ImeTe("ime_te_peppe"),
|
||||
Ime_ImeTe("ime_te"),
|
||||
|
||||
|
||||
Integry_Studioml("studioml"),
|
||||
@@ -198,7 +198,9 @@ public enum IntegryCustomerDB {
|
||||
|
||||
|
||||
Tempesta_Tempesta("tempesta"),
|
||||
Tempesta_DI("tempestadi"),
|
||||
Tempesta_VivaiTempesta("vivaitempesta"),
|
||||
Tempesta_VivaiTempesta_DI("vivaitempestadi"),
|
||||
|
||||
|
||||
Tosca_Ba("tosca_ba"),
|
||||
|
||||
@@ -1,508 +0,0 @@
|
||||
package it.integry.ems.migration.dto.common;
|
||||
|
||||
import it.integry.ems.migration.dto.SqlObjectTypeEnum;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class MigrationMvwSitArtUdcDetInventarioDTO {
|
||||
|
||||
|
||||
public static void apply(Connection connection) throws Exception {
|
||||
//Aggiorno i campi barcode_ul_in, barcode_ul_out, posizione_in, posizione_out, cod_mdep_in, cod_mdep_out
|
||||
updateNewFieldsInMtbColrs(connection);
|
||||
|
||||
//Migration di conversione aziende a nuova mvw_sitart_udc_det_inventario
|
||||
createBackupOfOldView(connection);
|
||||
dropView(connection, "mvw_sitart_udc_det_inventario");
|
||||
|
||||
createNewView(connection);
|
||||
}
|
||||
|
||||
public static void updateNewFieldsInMtbColrs(Connection connection) throws Exception {
|
||||
executeStatement(connection, "UPDATE mtb_colr\n" +
|
||||
"SET barcode_ul_in = new_data.barcode_ul_in,\n" +
|
||||
" barcode_ul_out = new_data.barcode_ul_out,\n" +
|
||||
" posizione_in = new_data.posizione_in,\n" +
|
||||
" posizione_out = new_data.posizione_out,\n" +
|
||||
" cod_mdep_in = new_data.cod_mdep_in,\n" +
|
||||
" cod_mdep_out = new_data.cod_mdep_out\n" +
|
||||
"FROM mtb_colr\n" +
|
||||
" INNER JOIN (SELECT mtb_colt.barcode_ul AS barcode_ul_in,\n" +
|
||||
" IIF(num_collo_rif IS NOT NULL, mtb_colt_rif.barcode_ul, NULL) AS barcode_ul_out,\n" +
|
||||
" mtb_colt.posizione AS posizione_in,\n" +
|
||||
" IIF(num_collo_rif IS NOT NULL, mtb_colt_rif.posizione, NULL) AS posizione_out,\n" +
|
||||
" mtb_colt.cod_mdep AS cod_mdep_in,\n" +
|
||||
" IIF(num_collo_rif IS NOT NULL, mtb_colt_rif.cod_mdep, NULL) AS cod_mdep_out,\n" +
|
||||
"\n" +
|
||||
" mtb_colr.gestione,\n" +
|
||||
" mtb_colr.data_collo,\n" +
|
||||
" mtb_colr.ser_collo,\n" +
|
||||
" mtb_colr.num_collo,\n" +
|
||||
" mtb_colr.riga\n" +
|
||||
"\n" +
|
||||
" FROM dbo.mtb_colr\n" +
|
||||
" INNER JOIN dbo.mtb_colt ON mtb_colr.gestione = mtb_colt.gestione AND\n" +
|
||||
" mtb_colr.data_collo = mtb_colt.data_collo AND\n" +
|
||||
" mtb_colr.ser_collo = mtb_colt.ser_collo AND\n" +
|
||||
" mtb_colr.num_collo = mtb_colt.num_collo\n" +
|
||||
"\n" +
|
||||
" LEFT OUTER JOIN dbo.mtb_colt mtb_colt_rif\n" +
|
||||
" ON mtb_colr.gestione_rif = mtb_colt_rif.gestione AND\n" +
|
||||
" mtb_colr.data_collo_rif = mtb_colt_rif.data_collo AND\n" +
|
||||
" mtb_colr.ser_collo_rif = mtb_colt_rif.ser_collo AND\n" +
|
||||
" mtb_colr.num_collo_rif = mtb_colt_rif.num_collo) new_data\n" +
|
||||
" ON mtb_colr.gestione = new_data.gestione AND\n" +
|
||||
" mtb_colr.num_collo = new_data.num_collo AND\n" +
|
||||
" mtb_colr.ser_collo = new_data.ser_collo AND\n" +
|
||||
" mtb_colr.data_collo = new_data.data_collo AND\n" +
|
||||
" mtb_colr.riga = new_data.riga");
|
||||
}
|
||||
|
||||
public static void alignGiacenza(Connection connection) throws Exception {
|
||||
//Creo un collo di scarico vuoto
|
||||
MtbColt mtbColt = new MtbColt()
|
||||
.setGestione("L")
|
||||
.setSerCollo("RT")
|
||||
.setSegno(-1)
|
||||
.setDataCollo(LocalDate.now())
|
||||
.setAnnotazioni("PASSAGGIO NUOVA MVW_SITART_UDC_DET_INVENTARIO")
|
||||
.setCodMdep(getInternalCodMdep(connection));
|
||||
mtbColt.setOperation(OperationType.INSERT);
|
||||
|
||||
mtbColt.dataCompleting(connection);
|
||||
mtbColt.manageWithParentConnection(connection);
|
||||
|
||||
|
||||
executeStatement(connection, Query.format(
|
||||
"INSERT INTO mtb_colr (gestione, ser_collo, num_collo, data_collo, riga, cod_mart, cod_col, cod_tagl, partita_mag, gestione_rif, data_collo_rif, ser_collo_rif, num_collo_rif, datetime_row,\n" +
|
||||
" cod_jcom, qta_col, num_cnf, qta_cnf, barcode_ul_out, cod_mdep_out, posizione_out)" +
|
||||
" SELECT {} AS gestione,\n" +
|
||||
" {} AS ser_collo,\n" +
|
||||
" {} AS num_collo,\n" +
|
||||
" CAST({} AS DATE) AS data_collo,\n" +
|
||||
" ROW_NUMBER() OVER (PARTITION BY (SELECT NULL) ORDER BY v.data_collo) AS riga,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.gestione AS gestion_rif,\n" +
|
||||
" v.data_collo AS data_collo_rif,\n" +
|
||||
" v.ser_collo AS ser_collo_rif,\n" +
|
||||
" v.num_collo AS num_collo_rif,\n" +
|
||||
" GETDATE() AS datetime_row,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.qta_col,\n" +
|
||||
" v.num_cnf,\n" +
|
||||
" v.qta_cnf,\n" +
|
||||
" v.barcode_ul AS barcode_ul_out,\n" +
|
||||
" v.cod_mdep AS cod_mdep_out,\n" +
|
||||
" v.posizione AS posizione_out\n" +
|
||||
"FROM mvw_sitart_udc_det_inventario v\n" +
|
||||
" INNER JOIN (SELECT ser_collo,\n" +
|
||||
" gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" posizione,\n" +
|
||||
" cod_mart,\n" +
|
||||
" partita_mag,\n" +
|
||||
" cod_jcom-- Elenca tutte le colonne coinvolte\n" +
|
||||
" FROM mvw_sitart_udc_det_inventario\n" +
|
||||
"\n" +
|
||||
" EXCEPT\n" +
|
||||
"\n" +
|
||||
" SELECT ser_collo,\n" +
|
||||
" gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" posizione,\n" +
|
||||
" cod_mart,\n" +
|
||||
" partita_mag,\n" +
|
||||
" cod_jcom -- Elenca le stesse colonne dalla vista vecchia\n" +
|
||||
" FROM mvw_sitart_udc_det_inventario_old) t\n" +
|
||||
" ON v.num_collo = t.num_collo AND v.data_collo = t.data_collo AND\n" +
|
||||
" v.ser_collo = t.ser_collo AND v.gestione = t.gestione AND\n" +
|
||||
" v.cod_mart = t.cod_mart AND v.cod_mdep = t.cod_mdep AND\n" +
|
||||
" ISNULL(v.partita_mag, '') = ISNULL(t.partita_mag, '') AND\n" +
|
||||
" ISNULL(v.posizione, '') = ISNULL(t.posizione, '') AND\n" +
|
||||
" ISNULL(v.cod_jcom, '') = ISNULL(t.cod_jcom, '')" +
|
||||
" WHERE qta_col > 0",
|
||||
mtbColt.getGestione(), mtbColt.getSerCollo(), mtbColt.getNumCollo(), mtbColt.getDataCollo()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static String getInternalCodMdep(Connection connection) throws Exception {
|
||||
String codMdepAz = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, "SELECT TOP 1 cod_mdep" +
|
||||
" FROM mtb_depo" +
|
||||
" INNER JOIN dbo.gtb_anag ga ON mtb_depo.cod_anag = ga.cod_anag" +
|
||||
" inner join azienda on ga.part_iva = azienda.part_iva");
|
||||
|
||||
if(UtilityString.isNullOrEmpty(codMdepAz)) {
|
||||
codMdepAz = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, "SELECT TOP 1 cod_mdep FROM mtb_depo");
|
||||
}
|
||||
|
||||
return codMdepAz;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static void createBackupOfOldView(Connection connection) throws Exception {
|
||||
if (existsView(connection, "mvw_sitart_udc_det_inventario_old"))
|
||||
return;
|
||||
|
||||
createOrUpdateView(connection, "mvw_sitart_udc_det_inventario_old", "CREATE VIEW [dbo].[mvw_sitart_udc_det_inventario_old] AS\n" +
|
||||
"SELECT UL.gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" ser_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" segno,\n" +
|
||||
" UL.cod_mdep,\n" +
|
||||
" UL.posizione,\n" +
|
||||
" mtb_depo_posizioni.priorita,\n" +
|
||||
" mtb_aart.cod_mgrp AS codGruppo,\n" +
|
||||
" mtb_grup.descrizione AS Gruppo,\n" +
|
||||
" mtb_aart.cod_msgr AS CodSgruppo,\n" +
|
||||
" mtb_sgrp.descrizione AS Sottogruppo,\n" +
|
||||
" UL.cod_mart,\n" +
|
||||
" diacod,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" partita_mag,\n" +
|
||||
" UL.cod_jcom,\n" +
|
||||
" jtb_comt.descrizione AS commessa,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" qta_col,\n" +
|
||||
" num_cnf,\n" +
|
||||
" UL.qta_cnf,\n" +
|
||||
" UL.peso_netto_kg,\n" +
|
||||
" UL.peso_lordo_kg,\n" +
|
||||
" UL.cod_jfas\n" +
|
||||
"FROM [mvw_sitart_udc_det] UL\n" +
|
||||
" LEFT OUTER JOIN jtb_comt ON UL.cod_jcom = jtb_comt.cod_jcom\n" +
|
||||
" LEFT OUTER JOIN mtb_depo_posizioni\n" +
|
||||
" ON UL.cod_mdep = mtb_depo_posizioni.cod_mdep AND UL.posizione = mtb_depo_posizioni.posizione,\n" +
|
||||
" mtb_aart,\n" +
|
||||
" mtb_grup,\n" +
|
||||
" mtb_sgrp\n" +
|
||||
"WHERE UL.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" AND mtb_aart.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" AND mtb_aart.cod_mgrp = mtb_sgrp.cod_mgrp\n" +
|
||||
" AND mtb_aart.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
" AND qta_col <> 0");
|
||||
}
|
||||
|
||||
private static void createNewView(Connection connection) throws Exception {
|
||||
|
||||
if (!existsTable(connection, "stb_multiplier")) {
|
||||
executeStatement(connection, "CREATE TABLE stb_multiplier\n" +
|
||||
"(\n" +
|
||||
" moltiplicatore INT NOT NULL\n" +
|
||||
")",
|
||||
"INSERT INTO stb_multiplier (moltiplicatore) VALUES (1)",
|
||||
"INSERT INTO stb_multiplier (moltiplicatore) VALUES (-1)");
|
||||
}
|
||||
|
||||
|
||||
createOrUpdateView(connection, "mvw_mtb_colr_with_giacenza", "CREATE VIEW dbo.mvw_mtb_colr_with_giacenza\n" +
|
||||
" WITH SCHEMABINDING\n" +
|
||||
" AS\n" +
|
||||
"SELECT COUNT_BIG(*) AS c,\n" +
|
||||
" IIF(moltiplicatore = -1, mtb_colr.barcode_ul_out,\n" +
|
||||
" mtb_colr.barcode_ul_in) AS barcode_ul,\n" +
|
||||
" IIF(moltiplicatore = -1, mtb_colr.cod_mdep_out,\n" +
|
||||
" mtb_colr.cod_mdep_in) AS cod_mdep,\n" +
|
||||
" IIF(moltiplicatore = -1, mtb_colr.posizione_out,\n" +
|
||||
" mtb_colr.posizione_in) AS posizione,\n" +
|
||||
" SUM(mtb_colr.qta_col * moltiplicatore) AS qta_col,\n" +
|
||||
" SUM(IIF(mtb_aart.flag_qta_cnf_fissa = 'S', mtb_colr.qta_col / mtb_aart.qta_cnf, mtb_colr.num_cnf) *\n" +
|
||||
" moltiplicatore) AS num_cnf,\n" +
|
||||
" mtb_colr.cod_mart,\n" +
|
||||
" mtb_colr.cod_col,\n" +
|
||||
" mtb_colr.cod_tagl,\n" +
|
||||
" mtb_colr.partita_mag,\n" +
|
||||
" SUM(mtb_colr.peso_netto_kg * moltiplicatore) AS peso_netto_kg,\n" +
|
||||
" SUM(mtb_colr.peso_lordo_kg * moltiplicatore) AS peso_lordo_kg,\n" +
|
||||
" IIF(mtb_colr.cod_jcom = 'MAG', NULL, mtb_colr.cod_jcom) AS cod_jcom,\n" +
|
||||
" mtb_aart.flag_qta_cnf_fissa,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" mtb_aart.diacod,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" mtb_aart.cod_mgrp,\n" +
|
||||
" mtb_aart.cod_msgr,\n" +
|
||||
" mtb_aart.cod_mtip,\n" +
|
||||
" mtb_aart.cod_mstp,\n" +
|
||||
" mtb_aart.cod_msfa,\n" +
|
||||
" mtb_aart.qta_cnf AS qta_cnf_anag\n" +
|
||||
"FROM dbo.mtb_colr\n" +
|
||||
" INNER JOIN dbo.stb_multiplier ON (moltiplicatore = 1 AND mtb_colr.barcode_ul_in IS NOT NULL) OR\n" +
|
||||
" (moltiplicatore = -1 AND mtb_colr.barcode_ul_out IS NOT NULL)\n" +
|
||||
" INNER JOIN dbo.mtb_aart ON mtb_colr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
"GROUP BY mtb_colr.cod_mart,\n" +
|
||||
" mtb_colr.cod_col,\n" +
|
||||
" mtb_colr.cod_tagl,\n" +
|
||||
" mtb_colr.partita_mag,\n" +
|
||||
" IIF(moltiplicatore = -1, mtb_colr.barcode_ul_out,\n" +
|
||||
" mtb_colr.barcode_ul_in),\n" +
|
||||
" IIF(moltiplicatore = -1, mtb_colr.cod_mdep_out,\n" +
|
||||
" mtb_colr.cod_mdep_in),\n" +
|
||||
" IIF(moltiplicatore = -1, mtb_colr.posizione_out,\n" +
|
||||
" mtb_colr.posizione_in),\n" +
|
||||
" IIF(mtb_colr.cod_jcom = 'MAG', NULL, mtb_colr.cod_jcom),\n" +
|
||||
" mtb_aart.flag_qta_cnf_fissa,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" mtb_aart.diacod,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" mtb_aart.cod_mgrp,\n" +
|
||||
" mtb_aart.cod_msgr,\n" +
|
||||
" mtb_aart.cod_mtip,\n" +
|
||||
" mtb_aart.cod_mstp,\n" +
|
||||
" mtb_aart.cod_msfa,\n" +
|
||||
" mtb_aart.qta_cnf");
|
||||
|
||||
dropIndex(connection, "mvw_mtb_colr_with_giacenza", "IDX_CLUSTERED_mvw_mtb_colr_with_giacenza");
|
||||
createIndex(connection, new IndexTableDTO()
|
||||
.setIndexName("IDX_CLUSTERED_mvw_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setUnique(true)
|
||||
.setClustered(true)
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("barcode_ul"));
|
||||
add(new IndexTableDTO.ColumnIndex("posizione"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_mdep"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_mart"));
|
||||
add(new IndexTableDTO.ColumnIndex("partita_mag"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_tagl"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_col"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_jcom"));
|
||||
}}));
|
||||
|
||||
dropIndex(connection, "mvw_mtb_colr_with_giacenza", "IDX_mvw_qta_mtb_colr_with_giacenza");
|
||||
createIndex(connection, new IndexTableDTO()
|
||||
.setIndexName("IDX_mvw_qta_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("qta_col"));
|
||||
add(new IndexTableDTO.ColumnIndex("num_cnf"));
|
||||
}}));
|
||||
|
||||
dropIndex(connection, "mvw_mtb_colr_with_giacenza", "IDX_mvw_articolo_mtb_colr_with_giacenza");
|
||||
createIndex(connection, new IndexTableDTO()
|
||||
.setIndexName("IDX_mvw_articolo_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("cod_mart"));
|
||||
add(new IndexTableDTO.ColumnIndex("partita_mag"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_tagl"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_col"));
|
||||
}}));
|
||||
|
||||
dropIndex(connection, "mvw_mtb_colr_with_giacenza", "IDX_mvw_articolo_giac_mtb_colr_with_giacenza");
|
||||
createIndex(connection, new IndexTableDTO()
|
||||
.setIndexName("IDX_mvw_articolo_giac_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("cod_mart"));
|
||||
add(new IndexTableDTO.ColumnIndex("partita_mag"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_tagl"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_col"));
|
||||
}})
|
||||
.setColumnsInclude("qta_col", "num_cnf"));
|
||||
|
||||
executeStatement(connection, "UPDATE STATISTICS dbo.mvw_mtb_colr_with_giacenza");
|
||||
|
||||
|
||||
createOrUpdateView(connection, "mvw_sitart_udc_det_inventario", "CREATE VIEW [dbo].[mvw_sitart_udc_det_inventario] AS\n" +
|
||||
" WITH baseMtbColr AS (SELECT c,\n" +
|
||||
"\n" +
|
||||
" ROUND(v.qta_col, cifre_dec) AS qta_col,\n" +
|
||||
" ROUND(v.num_cnf, cifre_dec) AS num_cnf,\n" +
|
||||
" IIF(flag_qta_cnf_fissa = 'S',\n" +
|
||||
" v.qta_cnf_anag, v.qta_col / IIF(v.num_cnf = 0, 1, v.num_cnf)) AS qta_cnf,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" mtb_colt.gestione,\n" +
|
||||
" mtb_colt.data_collo,\n" +
|
||||
" mtb_colt.ser_collo,\n" +
|
||||
" mtb_colt.num_collo,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.cod_mgrp,\n" +
|
||||
" mtb_grup.descrizione AS descrizione_gruppo,\n" +
|
||||
" v.cod_msgr,\n" +
|
||||
" mtb_sgrp.descrizione AS descrizione_sottogruppo,\n" +
|
||||
" mtb_unt_mis.flag_dig,\n" +
|
||||
" mtb_unt_mis.cifre_dec,\n" +
|
||||
" mtb_colt.segno,\n" +
|
||||
" v.cod_mdep,\n" +
|
||||
" v.posizione,\n" +
|
||||
" mtb_colt.cod_dtip,\n" +
|
||||
" mtb_colt.cod_jfas,\n" +
|
||||
" v.barcode_ul,\n" +
|
||||
" v.qta_cnf_anag\n" +
|
||||
" FROM mvw_mtb_colr_with_giacenza v WITH (NOEXPAND)\n" +
|
||||
" INNER JOIN mtb_colt\n" +
|
||||
" ON v.barcode_ul = mtb_colt.barcode_ul\n" +
|
||||
" INNER JOIN dbo.mtb_unt_mis ON v.unt_mis = mtb_unt_mis.unt_mis\n" +
|
||||
"\n" +
|
||||
" INNER JOIN dbo.mtb_grup ON v.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" INNER JOIN dbo.mtb_sgrp ON v.cod_mgrp = mtb_sgrp.cod_mgrp\n" +
|
||||
" AND v.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
" WHERE qta_col > 0\n" +
|
||||
" AND (segno = 1 OR (segno = -1 AND cod_dtip IS NULL AND mtb_colt.gestione = 'V'))\n" +
|
||||
" ),\n" +
|
||||
" final_stock AS (SELECT v.qta_col,\n" +
|
||||
" v.num_cnf,\n" +
|
||||
" v.qta_cnf,\n" +
|
||||
" v.gestione,\n" +
|
||||
" v.data_collo,\n" +
|
||||
" v.ser_collo,\n" +
|
||||
" v.num_collo,\n" +
|
||||
" v.cod_mdep AS cod_mdep,\n" +
|
||||
" v.posizione AS posizione,\n" +
|
||||
" mtb_depo_posizioni.priorita,\n" +
|
||||
" v.cod_mgrp AS codGruppo,\n" +
|
||||
" v.descrizione_gruppo AS Gruppo,\n" +
|
||||
" v.cod_msgr AS CodSgruppo,\n" +
|
||||
" v.descrizione_sottogruppo AS Sottogruppo,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" v.cod_jfas,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.segno,\n" +
|
||||
" v.barcode_ul\n" +
|
||||
" FROM baseMtbColr v\n" +
|
||||
"\n" +
|
||||
" LEFT OUTER JOIN mtb_depo_posizioni\n" +
|
||||
" ON v.cod_mdep = mtb_depo_posizioni.cod_mdep\n" +
|
||||
" AND v.posizione = mtb_depo_posizioni.posizione)\n" +
|
||||
"\n" +
|
||||
" SELECT qta_col,\n" +
|
||||
" num_cnf,\n" +
|
||||
" qta_cnf,\n" +
|
||||
" gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" ser_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" posizione,\n" +
|
||||
" priorita,\n" +
|
||||
" codGruppo,\n" +
|
||||
" Gruppo,\n" +
|
||||
" CodSgruppo,\n" +
|
||||
" Sottogruppo,\n" +
|
||||
" cod_mart,\n" +
|
||||
" diacod,\n" +
|
||||
" descrizione_estesa,\n" +
|
||||
" partita_mag,\n" +
|
||||
" cod_col,\n" +
|
||||
" cod_tagl,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" peso_netto_kg,\n" +
|
||||
" peso_lordo_kg,\n" +
|
||||
" cod_jfas,\n" +
|
||||
" flag_qta_cnf_fissa,\n" +
|
||||
" unt_mis,\n" +
|
||||
" segno,\n" +
|
||||
" barcode_ul\n" +
|
||||
" FROM final_stock");
|
||||
}
|
||||
|
||||
|
||||
private static boolean existsView(Connection connection, String objectName) throws SQLException {
|
||||
return UtilityDB.<Integer>executeSimpleQueryOnlyFirstRowFirstColumn(connection, "SELECT COUNT(*) FROM SYSOBJECTS WHERE id = object_id('" + objectName + "')") > 0;
|
||||
}
|
||||
|
||||
|
||||
private static void dropView(Connection connection, String objectName) throws SQLException, IOException {
|
||||
UtilityDB.executeStatement(connection, "IF EXISTS (SELECT * FROM SYSOBJECTS WHERE id = object_id('" + objectName + "'))\r\n" +
|
||||
"\tDROP " + SqlObjectTypeEnum.VIEW.toString() + " " + objectName);
|
||||
}
|
||||
|
||||
private static boolean existsTable(Connection connection, String tableName) throws SQLException, IOException {
|
||||
String schema = null;
|
||||
if (tableName.contains(".")) {
|
||||
schema = tableName.substring(0, tableName.indexOf("."));
|
||||
tableName = tableName.replace(schema + ".", "");
|
||||
}
|
||||
|
||||
String sql = Query.format("SELECT CAST(COUNT(*) AS BIT) AS exist FROM INFORMATION_SCHEMA.TABLES " +
|
||||
"WHERE TABLE_NAME = N%s ", tableName);
|
||||
|
||||
if (schema != null)
|
||||
sql += Query.format("AND TABLE_SCHEMA = N%s", schema);
|
||||
|
||||
return UtilityDB.<Boolean>executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static void createIndex(Connection connection, IndexTableDTO indexTableDTO) throws Exception {
|
||||
UtilityDB.createIndex(connection, indexTableDTO);
|
||||
}
|
||||
|
||||
private static void dropIndex(Connection connection, String tableName, String indexName) throws Exception {
|
||||
UtilityDB.dropIndex(connection, tableName, indexName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static void executeStatement(Connection connection, String... sqls) throws SQLException {
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
for (String sql : sqls) {
|
||||
statement.execute(sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static void createOrUpdateView(Connection connection, String objectName, String createViewSql) throws SQLException, IOException {
|
||||
alterObject(connection, SqlObjectTypeEnum.VIEW, objectName, createViewSql);
|
||||
}
|
||||
|
||||
private static void alterObject(Connection connection, SqlObjectTypeEnum sqlObject, String objectName, String sql) throws SQLException, IOException {
|
||||
executeStatement(connection, "IF EXISTS (SELECT * FROM SYSOBJECTS WHERE id = object_id('" + objectName + "'))\r\n" +
|
||||
"\tDROP " + sqlObject.toString() + " " + objectName,
|
||||
sql);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,14 @@ 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;
|
||||
import it.integry.ems.migration.dto.common.MigrationMvwSitArtUdcDetInventarioDTO;
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Migration_20241213163759 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@@ -15,8 +22,381 @@ public class Migration_20241213163759 extends BaseMigration implements Migration
|
||||
if (!isCustomer(IntegryCustomer.RossoGargano))
|
||||
return;
|
||||
|
||||
MigrationMvwSitArtUdcDetInventarioDTO.apply(connection);
|
||||
MigrationMvwSitArtUdcDetInventarioDTO.alignGiacenza(connection);
|
||||
//Migration di conversione aziende a nuova mvw_sitart_udc_det_inventario
|
||||
createBackupOfOldView();
|
||||
dropView("mvw_sitart_udc_det_inventario");
|
||||
|
||||
createNewView();
|
||||
|
||||
alignGiacenza();
|
||||
|
||||
}
|
||||
|
||||
private void createBackupOfOldView() throws Exception {
|
||||
if (existsView("mvw_sitart_udc_det_inventario_old"))
|
||||
return;
|
||||
|
||||
createOrUpdateView("mvw_sitart_udc_det_inventario_old", "CREATE VIEW [dbo].[mvw_sitart_udc_det_inventario_old] AS\n" +
|
||||
"SELECT UL.gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" ser_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" segno,\n" +
|
||||
" UL.cod_mdep,\n" +
|
||||
" UL.posizione,\n" +
|
||||
" mtb_depo_posizioni.priorita,\n" +
|
||||
" mtb_aart.cod_mgrp AS codGruppo,\n" +
|
||||
" mtb_grup.descrizione AS Gruppo,\n" +
|
||||
" mtb_aart.cod_msgr AS CodSgruppo,\n" +
|
||||
" mtb_sgrp.descrizione AS Sottogruppo,\n" +
|
||||
" UL.cod_mart,\n" +
|
||||
" diacod,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" partita_mag,\n" +
|
||||
" UL.cod_jcom,\n" +
|
||||
" jtb_comt.descrizione AS commessa,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" qta_col,\n" +
|
||||
" num_cnf,\n" +
|
||||
" UL.qta_cnf,\n" +
|
||||
" UL.peso_netto_kg,\n" +
|
||||
" UL.peso_lordo_kg,\n" +
|
||||
" UL.cod_jfas\n" +
|
||||
"FROM [mvw_sitart_udc_det] UL\n" +
|
||||
" LEFT OUTER JOIN jtb_comt ON UL.cod_jcom = jtb_comt.cod_jcom\n" +
|
||||
" LEFT OUTER JOIN mtb_depo_posizioni\n" +
|
||||
" ON UL.cod_mdep = mtb_depo_posizioni.cod_mdep AND UL.posizione = mtb_depo_posizioni.posizione,\n" +
|
||||
" mtb_aart,\n" +
|
||||
" mtb_grup,\n" +
|
||||
" mtb_sgrp\n" +
|
||||
"WHERE UL.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" AND mtb_aart.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" AND mtb_aart.cod_mgrp = mtb_sgrp.cod_mgrp\n" +
|
||||
" AND mtb_aart.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
" AND qta_col <> 0");
|
||||
}
|
||||
|
||||
private void createNewView() throws Exception {
|
||||
|
||||
if (!existsTable("stb_multiplier")) {
|
||||
executeStatement("CREATE TABLE stb_multiplier\n" +
|
||||
"(\n" +
|
||||
" moltiplicatore INT NOT NULL\n" +
|
||||
")",
|
||||
"INSERT INTO stb_multiplier (moltiplicatore) VALUES (1)",
|
||||
"INSERT INTO stb_multiplier (moltiplicatore) VALUES (-1)");
|
||||
}
|
||||
|
||||
|
||||
createOrUpdateView("mvw_mtb_colr_with_giacenza", "CREATE VIEW dbo.mvw_mtb_colr_with_giacenza\n" +
|
||||
" WITH SCHEMABINDING\n" +
|
||||
"AS\n" +
|
||||
"SELECT COUNT_BIG(*) AS c,\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.gestione_rif,\n" +
|
||||
" mtb_colr.gestione) AS gestione,\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.data_collo_rif,\n" +
|
||||
" mtb_colr.data_collo) AS data_collo,\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.ser_collo_rif,\n" +
|
||||
" mtb_colr.ser_collo) AS ser_collo,\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.num_collo_rif,\n" +
|
||||
" mtb_colr.num_collo) AS num_collo,\n" +
|
||||
" SUM(mtb_colr.qta_col * moltiplicatore) AS qta_col,\n" +
|
||||
"\n" +
|
||||
" SUM(IIF(mtb_aart.flag_qta_cnf_fissa = 'S', mtb_colr.qta_col / mtb_aart.qta_cnf, mtb_colr.num_cnf) *\n" +
|
||||
" moltiplicatore) AS num_cnf,\n" +
|
||||
" mtb_colr.cod_mart,\n" +
|
||||
" mtb_colr.cod_col,\n" +
|
||||
" mtb_colr.cod_tagl,\n" +
|
||||
" mtb_colr.partita_mag,\n" +
|
||||
" SUM(mtb_colr.peso_netto_kg * moltiplicatore) AS peso_netto_kg,\n" +
|
||||
" SUM(mtb_colr.peso_lordo_kg * moltiplicatore) AS peso_lordo_kg,\n" +
|
||||
" IIF(mtb_colr.cod_jcom = 'MAG', NULL, mtb_colr.cod_jcom) AS cod_jcom,\n" +
|
||||
" mtb_aart.flag_qta_cnf_fissa,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" mtb_aart.diacod,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" mtb_aart.cod_mgrp,\n" +
|
||||
" mtb_aart.cod_msgr,\n" +
|
||||
" mtb_aart.cod_mtip,\n" +
|
||||
" mtb_aart.cod_mstp,\n" +
|
||||
" mtb_aart.cod_msfa,\n" +
|
||||
" mtb_aart.qta_cnf AS qta_cnf_anag\n" +
|
||||
"FROM dbo.mtb_colr\n" +
|
||||
" INNER JOIN dbo.stb_multiplier ON moltiplicatore = 1 OR mtb_colr.num_collo_rif IS NOT NULL\n" +
|
||||
" INNER JOIN dbo.mtb_aart ON mtb_colr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
"GROUP BY mtb_colr.cod_mart,\n" +
|
||||
" mtb_colr.cod_col,\n" +
|
||||
" mtb_colr.cod_tagl,\n" +
|
||||
" mtb_colr.partita_mag,\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.gestione_rif, mtb_colr.gestione),\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.data_collo_rif,\n" +
|
||||
" mtb_colr.data_collo),\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.ser_collo_rif,\n" +
|
||||
" mtb_colr.ser_collo),\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.num_collo_rif,\n" +
|
||||
" mtb_colr.num_collo),\n" +
|
||||
" IIF(mtb_colr.cod_jcom = 'MAG', NULL, mtb_colr.cod_jcom),\n" +
|
||||
" mtb_aart.flag_qta_cnf_fissa,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" mtb_aart.diacod,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" mtb_aart.cod_mgrp,\n" +
|
||||
" mtb_aart.cod_msgr,\n" +
|
||||
" mtb_aart.cod_mtip,\n" +
|
||||
" mtb_aart.cod_mstp,\n" +
|
||||
" mtb_aart.cod_msfa,\n" +
|
||||
" mtb_aart.qta_cnf");
|
||||
|
||||
dropIndex("mvw_mtb_colr_with_giacenza", "IDX_CLUSTERED_mvw_mtb_colr_with_giacenza");
|
||||
createIndex(new IndexTableDTO()
|
||||
.setIndexName("IDX_CLUSTERED_mvw_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setUnique(true)
|
||||
.setClustered(true)
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("gestione"));
|
||||
add(new IndexTableDTO.ColumnIndex("data_collo"));
|
||||
add(new IndexTableDTO.ColumnIndex("num_collo"));
|
||||
add(new IndexTableDTO.ColumnIndex("ser_collo"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_mart"));
|
||||
add(new IndexTableDTO.ColumnIndex("partita_mag"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_tagl"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_col"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_jcom"));
|
||||
}}));
|
||||
|
||||
dropIndex("mvw_mtb_colr_with_giacenza", "IDX_mvw_qta_mtb_colr_with_giacenza");
|
||||
createIndex(new IndexTableDTO()
|
||||
.setIndexName("IDX_mvw_qta_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("qta_col"));
|
||||
add(new IndexTableDTO.ColumnIndex("num_cnf"));
|
||||
}}));
|
||||
|
||||
dropIndex("mvw_mtb_colr_with_giacenza", "IDX_mvw_articolo_mtb_colr_with_giacenza");
|
||||
createIndex(new IndexTableDTO()
|
||||
.setIndexName("IDX_mvw_articolo_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("cod_mart"));
|
||||
add(new IndexTableDTO.ColumnIndex("partita_mag"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_tagl"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_col"));
|
||||
}}));
|
||||
|
||||
dropIndex("mvw_mtb_colr_with_giacenza", "IDX_mvw_articolo_giac_mtb_colr_with_giacenza");
|
||||
createIndex(new IndexTableDTO()
|
||||
.setIndexName("IDX_mvw_articolo_giac_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("cod_mart"));
|
||||
add(new IndexTableDTO.ColumnIndex("partita_mag"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_tagl"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_col"));
|
||||
}})
|
||||
.setColumnsInclude("qta_col", "num_cnf"));
|
||||
|
||||
executeStatement("UPDATE STATISTICS dbo.mvw_mtb_colr_with_giacenza");
|
||||
|
||||
|
||||
createOrUpdateView("mvw_sitart_udc_det_inventario", "CREATE VIEW mvw_sitart_udc_det_inventario AS\n" +
|
||||
" WITH baseMtbColr AS (SELECT c,\n" +
|
||||
"\n" +
|
||||
" ROUND(v.qta_col, cifre_dec) AS qta_col,\n" +
|
||||
" ROUND(v.num_cnf, cifre_dec) AS num_cnf,\n" +
|
||||
" IIF(flag_qta_cnf_fissa = 'S',\n" +
|
||||
" v.qta_cnf_anag, v.qta_col / IIF(v.num_cnf = 0, 1, v.num_cnf)) AS qta_cnf,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" v.gestione,\n" +
|
||||
" v.data_collo,\n" +
|
||||
" v.ser_collo,\n" +
|
||||
" v.num_collo,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.cod_mgrp,\n" +
|
||||
" mtb_grup.descrizione AS descrizione_gruppo,\n" +
|
||||
" v.cod_msgr,\n" +
|
||||
" mtb_sgrp.descrizione AS descrizione_sottogruppo,\n" +
|
||||
" mtb_unt_mis.flag_dig,\n" +
|
||||
" mtb_unt_mis.cifre_dec,\n" +
|
||||
" mtb_colt.segno,\n" +
|
||||
" mtb_colt.cod_mdep,\n" +
|
||||
" mtb_colt.posizione,\n" +
|
||||
" mtb_colt.cod_dtip,\n" +
|
||||
" mtb_colt.cod_jfas,\n" +
|
||||
" mtb_colt.barcode_ul,\n" +
|
||||
" v.qta_cnf_anag\n" +
|
||||
" FROM mvw_mtb_colr_with_giacenza v WITH (NOEXPAND)\n" +
|
||||
" INNER JOIN mtb_colt\n" +
|
||||
" ON v.num_collo = mtb_colt.num_collo AND v.gestione = mtb_colt.gestione AND\n" +
|
||||
" v.ser_collo = mtb_colt.ser_collo AND v.data_collo = mtb_colt.data_collo\n" +
|
||||
" INNER JOIN dbo.mtb_unt_mis ON v.unt_mis = mtb_unt_mis.unt_mis\n" +
|
||||
"\n" +
|
||||
" INNER JOIN dbo.mtb_grup ON v.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" INNER JOIN dbo.mtb_sgrp ON v.cod_mgrp = mtb_sgrp.cod_mgrp\n" +
|
||||
" AND v.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
" WHERE qta_col > 0\n" +
|
||||
" AND (segno = 1 OR (segno = -1 AND cod_dtip IS NULL AND v.gestione = 'V'))),\n" +
|
||||
" final_stock AS (SELECT v.qta_col,\n" +
|
||||
" v.num_cnf,\n" +
|
||||
" v.qta_cnf,\n" +
|
||||
" v.gestione,\n" +
|
||||
" v.data_collo,\n" +
|
||||
" v.ser_collo,\n" +
|
||||
" v.num_collo,\n" +
|
||||
" v.cod_mdep AS cod_mdep,\n" +
|
||||
" v.posizione AS posizione,\n" +
|
||||
" mtb_depo_posizioni.priorita,\n" +
|
||||
" v.cod_mgrp AS codGruppo,\n" +
|
||||
" v.descrizione_gruppo AS Gruppo,\n" +
|
||||
" v.cod_msgr AS CodSgruppo,\n" +
|
||||
" v.descrizione_sottogruppo AS Sottogruppo,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" v.cod_jfas,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.segno,\n" +
|
||||
" v.barcode_ul\n" +
|
||||
" FROM baseMtbColr v\n" +
|
||||
"\n" +
|
||||
" LEFT OUTER JOIN mtb_depo_posizioni\n" +
|
||||
" ON v.cod_mdep = mtb_depo_posizioni.cod_mdep\n" +
|
||||
" AND v.posizione = mtb_depo_posizioni.posizione)\n" +
|
||||
"\n" +
|
||||
" SELECT qta_col,\n" +
|
||||
" num_cnf,\n" +
|
||||
" qta_cnf,\n" +
|
||||
" gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" ser_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" posizione,\n" +
|
||||
" priorita,\n" +
|
||||
" codGruppo,\n" +
|
||||
" Gruppo,\n" +
|
||||
" CodSgruppo,\n" +
|
||||
" Sottogruppo,\n" +
|
||||
" cod_mart,\n" +
|
||||
" diacod,\n" +
|
||||
" descrizione_estesa,\n" +
|
||||
" partita_mag,\n" +
|
||||
" cod_col,\n" +
|
||||
" cod_tagl,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" peso_netto_kg,\n" +
|
||||
" peso_lordo_kg,\n" +
|
||||
" cod_jfas,\n" +
|
||||
" flag_qta_cnf_fissa,\n" +
|
||||
" unt_mis,\n" +
|
||||
" segno,\n" +
|
||||
" barcode_ul\n" +
|
||||
" FROM final_stock");
|
||||
}
|
||||
|
||||
private void alignGiacenza() throws Exception {
|
||||
//Creo un collo di scarico vuoto
|
||||
MtbColt mtbColt = new MtbColt()
|
||||
.setGestione("L")
|
||||
.setSerCollo("RT")
|
||||
.setSegno(-1)
|
||||
.setDataCollo(LocalDate.now())
|
||||
.setAnnotazioni("PASSAGGIO NUOVA MVW_SITART_UDC_DET_INVENTARIO")
|
||||
.setCodMdep(getInternalCodMdep());
|
||||
mtbColt.setOperation(OperationType.INSERT);
|
||||
|
||||
mtbColt.dataCompleting(connection);
|
||||
mtbColt.manageWithParentConnection(connection);
|
||||
|
||||
|
||||
executeStatement(Query.format(
|
||||
"INSERT INTO mtb_colr (gestione, ser_collo, num_collo, data_collo, riga, cod_mart, cod_col, cod_tagl, partita_mag, gestione_rif, data_collo_rif, ser_collo_rif, num_collo_rif, datetime_row,\n" +
|
||||
" cod_jcom, qta_col, num_cnf, qta_cnf)" +
|
||||
" SELECT {} AS gestione,\n" +
|
||||
" {} AS ser_collo,\n" +
|
||||
" {} AS num_collo,\n" +
|
||||
" CAST({} AS DATE) AS data_collo,\n" +
|
||||
" ROW_NUMBER() OVER (PARTITION BY (SELECT NULL) ORDER BY v.data_collo) AS riga,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.gestione AS gestion_rif,\n" +
|
||||
" v.data_collo AS data_collo_rif,\n" +
|
||||
" v.ser_collo AS ser_collo_rif,\n" +
|
||||
" v.num_collo AS num_collo_rif,\n" +
|
||||
" GETDATE() AS datetime_row,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.qta_col,\n" +
|
||||
" v.num_cnf,\n" +
|
||||
" v.qta_cnf\n" +
|
||||
"FROM mvw_sitart_udc_det_inventario v\n" +
|
||||
" INNER JOIN (SELECT ser_collo,\n" +
|
||||
" gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" posizione,\n" +
|
||||
" cod_mart,\n" +
|
||||
" partita_mag,\n" +
|
||||
" cod_jcom-- Elenca tutte le colonne coinvolte\n" +
|
||||
" FROM mvw_sitart_udc_det_inventario\n" +
|
||||
"\n" +
|
||||
" EXCEPT\n" +
|
||||
"\n" +
|
||||
" SELECT ser_collo,\n" +
|
||||
" gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" posizione,\n" +
|
||||
" cod_mart,\n" +
|
||||
" partita_mag,\n" +
|
||||
" cod_jcom -- Elenca le stesse colonne dalla vista vecchia\n" +
|
||||
" FROM mvw_sitart_udc_det_inventario_old) t\n" +
|
||||
" ON v.num_collo = t.num_collo AND v.data_collo = t.data_collo AND\n" +
|
||||
" v.ser_collo = t.ser_collo AND v.gestione = t.gestione AND\n" +
|
||||
" v.cod_mart = t.cod_mart AND v.cod_mdep = t.cod_mdep AND\n" +
|
||||
" ISNULL(v.partita_mag, '') = ISNULL(t.partita_mag, '') AND\n" +
|
||||
" ISNULL(v.posizione, '') = ISNULL(t.posizione, '') AND\n" +
|
||||
" ISNULL(v.cod_jcom, '') = ISNULL(t.cod_jcom, '')" +
|
||||
" WHERE qta_col > 0",
|
||||
mtbColt.getGestione(), mtbColt.getSerCollo(), mtbColt.getNumCollo(), mtbColt.getDataCollo()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private String getInternalCodMdep() throws Exception {
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, "SELECT TOP 1 cod_mdep" +
|
||||
" FROM mtb_depo" +
|
||||
" INNER JOIN dbo.gtb_anag ga ON mtb_depo.cod_anag = ga.cod_anag" +
|
||||
" inner join azienda on ga.part_iva = azienda.part_iva");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,323 @@
|
||||
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;
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Migration_20250320121611 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isCustomer(IntegryCustomer.Tosca))
|
||||
return;
|
||||
|
||||
//Migration di conversione aziende a nuova mvw_sitart_udc_det_inventario
|
||||
createBackupOfOldView();
|
||||
dropView("mvw_sitart_udc_det_inventario");
|
||||
|
||||
createNewView();
|
||||
|
||||
}
|
||||
|
||||
private void createBackupOfOldView() throws Exception {
|
||||
if (existsView("mvw_sitart_udc_det_inventario_old"))
|
||||
return;
|
||||
|
||||
createOrUpdateView("mvw_sitart_udc_det_inventario_old", "CREATE VIEW [dbo].[mvw_sitart_udc_det_inventario_old] AS\n" +
|
||||
"SELECT UL.gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" ser_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" segno,\n" +
|
||||
" UL.cod_mdep,\n" +
|
||||
" UL.posizione,\n" +
|
||||
" mtb_depo_posizioni.priorita,\n" +
|
||||
" mtb_aart.cod_mgrp AS codGruppo,\n" +
|
||||
" mtb_grup.descrizione AS Gruppo,\n" +
|
||||
" mtb_aart.cod_msgr AS CodSgruppo,\n" +
|
||||
" mtb_sgrp.descrizione AS Sottogruppo,\n" +
|
||||
" UL.cod_mart,\n" +
|
||||
" diacod,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" partita_mag,\n" +
|
||||
" UL.cod_jcom,\n" +
|
||||
" jtb_comt.descrizione AS commessa,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" qta_col,\n" +
|
||||
" num_cnf,\n" +
|
||||
" UL.qta_cnf,\n" +
|
||||
" UL.peso_netto_kg,\n" +
|
||||
" UL.peso_lordo_kg,\n" +
|
||||
" UL.cod_jfas\n" +
|
||||
"FROM [mvw_sitart_udc_det] UL\n" +
|
||||
" LEFT OUTER JOIN jtb_comt ON UL.cod_jcom = jtb_comt.cod_jcom\n" +
|
||||
" LEFT OUTER JOIN mtb_depo_posizioni\n" +
|
||||
" ON UL.cod_mdep = mtb_depo_posizioni.cod_mdep AND UL.posizione = mtb_depo_posizioni.posizione,\n" +
|
||||
" mtb_aart,\n" +
|
||||
" mtb_grup,\n" +
|
||||
" mtb_sgrp\n" +
|
||||
"WHERE UL.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" AND mtb_aart.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" AND mtb_aart.cod_mgrp = mtb_sgrp.cod_mgrp\n" +
|
||||
" AND mtb_aart.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
" AND qta_col <> 0");
|
||||
}
|
||||
|
||||
private void createNewView() throws Exception {
|
||||
|
||||
if (!existsTable("stb_multiplier")) {
|
||||
executeStatement("CREATE TABLE stb_multiplier\n" +
|
||||
"(\n" +
|
||||
" moltiplicatore INT NOT NULL\n" +
|
||||
")",
|
||||
"INSERT INTO stb_multiplier (moltiplicatore) VALUES (1)",
|
||||
"INSERT INTO stb_multiplier (moltiplicatore) VALUES (-1)");
|
||||
}
|
||||
|
||||
|
||||
createOrUpdateView("mvw_mtb_colr_with_giacenza", "CREATE VIEW dbo.mvw_mtb_colr_with_giacenza\n" +
|
||||
" WITH SCHEMABINDING\n" +
|
||||
"AS\n" +
|
||||
"SELECT COUNT_BIG(*) AS c,\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.gestione_rif,\n" +
|
||||
" mtb_colr.gestione) AS gestione,\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.data_collo_rif,\n" +
|
||||
" mtb_colr.data_collo) AS data_collo,\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.ser_collo_rif,\n" +
|
||||
" mtb_colr.ser_collo) AS ser_collo,\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.num_collo_rif,\n" +
|
||||
" mtb_colr.num_collo) AS num_collo,\n" +
|
||||
" SUM(mtb_colr.qta_col * moltiplicatore) AS qta_col,\n" +
|
||||
"\n" +
|
||||
" SUM(IIF(mtb_aart.flag_qta_cnf_fissa = 'S', mtb_colr.qta_col / mtb_aart.qta_cnf, mtb_colr.num_cnf) *\n" +
|
||||
" moltiplicatore) AS num_cnf,\n" +
|
||||
" mtb_colr.cod_mart,\n" +
|
||||
" mtb_colr.cod_col,\n" +
|
||||
" mtb_colr.cod_tagl,\n" +
|
||||
" mtb_colr.partita_mag,\n" +
|
||||
" SUM(mtb_colr.peso_netto_kg * moltiplicatore) AS peso_netto_kg,\n" +
|
||||
" SUM(mtb_colr.peso_lordo_kg * moltiplicatore) AS peso_lordo_kg,\n" +
|
||||
" IIF(mtb_colr.cod_jcom = 'MAG', NULL, mtb_colr.cod_jcom) AS cod_jcom,\n" +
|
||||
" mtb_aart.flag_qta_cnf_fissa,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" mtb_aart.diacod,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" mtb_aart.cod_mgrp,\n" +
|
||||
" mtb_aart.cod_msgr,\n" +
|
||||
" mtb_aart.cod_mtip,\n" +
|
||||
" mtb_aart.cod_mstp,\n" +
|
||||
" mtb_aart.cod_msfa,\n" +
|
||||
" mtb_aart.qta_cnf AS qta_cnf_anag\n" +
|
||||
"FROM dbo.mtb_colr\n" +
|
||||
" INNER JOIN dbo.stb_multiplier ON moltiplicatore = 1 OR mtb_colr.num_collo_rif IS NOT NULL\n" +
|
||||
" INNER JOIN dbo.mtb_aart ON mtb_colr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
"GROUP BY mtb_colr.cod_mart,\n" +
|
||||
" mtb_colr.cod_col,\n" +
|
||||
" mtb_colr.cod_tagl,\n" +
|
||||
" mtb_colr.partita_mag,\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.gestione_rif, mtb_colr.gestione),\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.data_collo_rif,\n" +
|
||||
" mtb_colr.data_collo),\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.ser_collo_rif,\n" +
|
||||
" mtb_colr.ser_collo),\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.num_collo_rif,\n" +
|
||||
" mtb_colr.num_collo),\n" +
|
||||
" IIF(mtb_colr.cod_jcom = 'MAG', NULL, mtb_colr.cod_jcom),\n" +
|
||||
" mtb_aart.flag_qta_cnf_fissa,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" mtb_aart.diacod,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" mtb_aart.cod_mgrp,\n" +
|
||||
" mtb_aart.cod_msgr,\n" +
|
||||
" mtb_aart.cod_mtip,\n" +
|
||||
" mtb_aart.cod_mstp,\n" +
|
||||
" mtb_aart.cod_msfa,\n" +
|
||||
" mtb_aart.qta_cnf");
|
||||
|
||||
dropIndex("mvw_mtb_colr_with_giacenza", "IDX_CLUSTERED_mvw_mtb_colr_with_giacenza");
|
||||
createIndex(new IndexTableDTO()
|
||||
.setIndexName("IDX_CLUSTERED_mvw_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setUnique(true)
|
||||
.setClustered(true)
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("gestione"));
|
||||
add(new IndexTableDTO.ColumnIndex("data_collo"));
|
||||
add(new IndexTableDTO.ColumnIndex("num_collo"));
|
||||
add(new IndexTableDTO.ColumnIndex("ser_collo"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_mart"));
|
||||
add(new IndexTableDTO.ColumnIndex("partita_mag"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_tagl"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_col"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_jcom"));
|
||||
}}));
|
||||
|
||||
dropIndex("mvw_mtb_colr_with_giacenza", "IDX_mvw_qta_mtb_colr_with_giacenza");
|
||||
createIndex(new IndexTableDTO()
|
||||
.setIndexName("IDX_mvw_qta_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("qta_col"));
|
||||
add(new IndexTableDTO.ColumnIndex("num_cnf"));
|
||||
}}));
|
||||
|
||||
dropIndex("mvw_mtb_colr_with_giacenza", "IDX_mvw_articolo_mtb_colr_with_giacenza");
|
||||
createIndex(new IndexTableDTO()
|
||||
.setIndexName("IDX_mvw_articolo_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("cod_mart"));
|
||||
add(new IndexTableDTO.ColumnIndex("partita_mag"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_tagl"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_col"));
|
||||
}}));
|
||||
|
||||
dropIndex("mvw_mtb_colr_with_giacenza", "IDX_mvw_articolo_giac_mtb_colr_with_giacenza");
|
||||
createIndex(new IndexTableDTO()
|
||||
.setIndexName("IDX_mvw_articolo_giac_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("cod_mart"));
|
||||
add(new IndexTableDTO.ColumnIndex("partita_mag"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_tagl"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_col"));
|
||||
}})
|
||||
.setColumnsInclude("qta_col", "num_cnf"));
|
||||
|
||||
executeStatement("UPDATE STATISTICS dbo.mvw_mtb_colr_with_giacenza");
|
||||
|
||||
|
||||
createOrUpdateView("mvw_sitart_udc_det_inventario", "CREATE VIEW mvw_sitart_udc_det_inventario AS\n" +
|
||||
" WITH baseMtbColr AS (SELECT c,\n" +
|
||||
"\n" +
|
||||
" ROUND(v.qta_col, cifre_dec) AS qta_col,\n" +
|
||||
" ROUND(v.num_cnf, cifre_dec) AS num_cnf,\n" +
|
||||
" IIF(flag_qta_cnf_fissa = 'S',\n" +
|
||||
" v.qta_cnf_anag, v.qta_col / IIF(v.num_cnf = 0, 1, v.num_cnf)) AS qta_cnf,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" v.gestione,\n" +
|
||||
" v.data_collo,\n" +
|
||||
" v.ser_collo,\n" +
|
||||
" v.num_collo,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.cod_mgrp,\n" +
|
||||
" mtb_grup.descrizione AS descrizione_gruppo,\n" +
|
||||
" v.cod_msgr,\n" +
|
||||
" mtb_sgrp.descrizione AS descrizione_sottogruppo,\n" +
|
||||
" mtb_unt_mis.flag_dig,\n" +
|
||||
" mtb_unt_mis.cifre_dec,\n" +
|
||||
" mtb_colt.segno,\n" +
|
||||
" mtb_colt.cod_mdep,\n" +
|
||||
" mtb_colt.posizione,\n" +
|
||||
" mtb_colt.cod_dtip,\n" +
|
||||
" mtb_colt.cod_jfas,\n" +
|
||||
" mtb_colt.barcode_ul,\n" +
|
||||
" v.qta_cnf_anag\n" +
|
||||
" FROM mvw_mtb_colr_with_giacenza v WITH (NOEXPAND)\n" +
|
||||
" INNER JOIN mtb_colt\n" +
|
||||
" ON v.num_collo = mtb_colt.num_collo AND v.gestione = mtb_colt.gestione AND\n" +
|
||||
" v.ser_collo = mtb_colt.ser_collo AND v.data_collo = mtb_colt.data_collo\n" +
|
||||
" INNER JOIN dbo.mtb_unt_mis ON v.unt_mis = mtb_unt_mis.unt_mis\n" +
|
||||
"\n" +
|
||||
" INNER JOIN dbo.mtb_grup ON v.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" INNER JOIN dbo.mtb_sgrp ON v.cod_mgrp = mtb_sgrp.cod_mgrp\n" +
|
||||
" AND v.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
" WHERE qta_col > 0\n" +
|
||||
" AND (segno = 1 OR (segno = -1 AND cod_dtip IS NULL AND v.gestione = 'V'))),\n" +
|
||||
" final_stock AS (SELECT v.qta_col,\n" +
|
||||
" v.num_cnf,\n" +
|
||||
" v.qta_cnf,\n" +
|
||||
" v.gestione,\n" +
|
||||
" v.data_collo,\n" +
|
||||
" v.ser_collo,\n" +
|
||||
" v.num_collo,\n" +
|
||||
" v.cod_mdep AS cod_mdep,\n" +
|
||||
" v.posizione AS posizione,\n" +
|
||||
" mtb_depo_posizioni.priorita,\n" +
|
||||
" v.cod_mgrp AS codGruppo,\n" +
|
||||
" v.descrizione_gruppo AS Gruppo,\n" +
|
||||
" v.cod_msgr AS CodSgruppo,\n" +
|
||||
" v.descrizione_sottogruppo AS Sottogruppo,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" v.cod_jfas,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.segno,\n" +
|
||||
" v.barcode_ul\n" +
|
||||
" FROM baseMtbColr v\n" +
|
||||
"\n" +
|
||||
" LEFT OUTER JOIN mtb_depo_posizioni\n" +
|
||||
" ON v.cod_mdep = mtb_depo_posizioni.cod_mdep\n" +
|
||||
" AND v.posizione = mtb_depo_posizioni.posizione)\n" +
|
||||
"\n" +
|
||||
" SELECT qta_col,\n" +
|
||||
" num_cnf,\n" +
|
||||
" qta_cnf,\n" +
|
||||
" gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" ser_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" posizione,\n" +
|
||||
" priorita,\n" +
|
||||
" codGruppo,\n" +
|
||||
" Gruppo,\n" +
|
||||
" CodSgruppo,\n" +
|
||||
" Sottogruppo,\n" +
|
||||
" cod_mart,\n" +
|
||||
" diacod,\n" +
|
||||
" descrizione_estesa,\n" +
|
||||
" partita_mag,\n" +
|
||||
" cod_col,\n" +
|
||||
" cod_tagl,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" peso_netto_kg,\n" +
|
||||
" peso_lordo_kg,\n" +
|
||||
" cod_jfas,\n" +
|
||||
" flag_qta_cnf_fissa,\n" +
|
||||
" unt_mis,\n" +
|
||||
" segno,\n" +
|
||||
" barcode_ul\n" +
|
||||
" FROM final_stock");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250402112610 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
// //Gia aggiornato
|
||||
// if (isCustomer(IntegryCustomer.RossoGargano) ||
|
||||
// isCustomer(IntegryCustomer.Tosca))
|
||||
// return;
|
||||
//
|
||||
// //Azienda da aggiornare
|
||||
// if (!isCustomer(IntegryCustomer.Gramm))
|
||||
// return;
|
||||
//
|
||||
// MigrationMvwSitArtUdcDetInventarioDTO.apply(connection);
|
||||
// MigrationMvwSitArtUdcDetInventarioDTO.alignGiacenza(connection);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
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;
|
||||
import it.integry.ems.migration.dto.common.MigrationMvwSitArtUdcDetInventarioDTO;
|
||||
import it.integry.ems.rules.completing.PackagesRules;
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Migration_20250403174531 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isCustomer(IntegryCustomer.RossoGargano))
|
||||
return;
|
||||
|
||||
//Rigenero barcodeUl testate con barcode duplicato
|
||||
regenerateDuplicatedBarcodeUlTestate();
|
||||
|
||||
//Aggiorno la view mvw_mtb_colr_with_giacenza
|
||||
MigrationMvwSitArtUdcDetInventarioDTO.apply(connection);
|
||||
|
||||
MigrationMvwSitArtUdcDetInventarioDTO.alignGiacenza(connection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
|
||||
|
||||
private void regenerateDuplicatedBarcodeUlTestate() throws Exception {
|
||||
String retrieveDuplicatedSql = "SELECT barcode_ul\n" +
|
||||
"FROM mtb_colt\n" +
|
||||
"GROUP BY barcode_ul, ser_collo\n" +
|
||||
"HAVING COUNT(barcode_ul) > 1";
|
||||
|
||||
|
||||
final List<String> duplicatedBarcodes = UtilityDB.executeSimpleQueryOnlyFirstColumn(connection, retrieveDuplicatedSql);
|
||||
|
||||
for (String barcode : duplicatedBarcodes) {
|
||||
String sql = Query.format("SELECT * FROM mtb_colt WHERE barcode_ul = {}", barcode);
|
||||
List<MtbColt> loadedMtbColts = executeQueryDTO(sql, MtbColt.class);
|
||||
|
||||
for (MtbColt colt : loadedMtbColts) {
|
||||
if (colt.getSerCollo().equalsIgnoreCase("T")) {
|
||||
String newBarcodeUl = PackagesRules.completeBarcodeUl(connection,
|
||||
colt.getGestione(),
|
||||
colt.getDataCollo(),
|
||||
colt.getSerCollo(),
|
||||
colt.getNumCollo(),
|
||||
null,
|
||||
null);
|
||||
|
||||
colt.setBarcodeUl(newBarcodeUl);
|
||||
colt.setOperation(OperationType.UPDATE);
|
||||
colt.manageWithParentConnection(connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,181 +0,0 @@
|
||||
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_20250403174532 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
if (isCustomer(IntegryCustomer.Gramm) ||
|
||||
isCustomer(IntegryCustomer.RossoGargano) ||
|
||||
isCustomer(IntegryCustomer.Carelli) ||
|
||||
isDMS())
|
||||
return;
|
||||
|
||||
//Cancello tutti i barcode UL dalle testate degli scarichi a lavorazione
|
||||
executeStatement("UPDATE mtb_colt SET barcode_ul = NULL\n" +
|
||||
"WHERE gestione = 'L' AND segno = -1\n" +
|
||||
"AND barcode_ul IS NOT NULL");
|
||||
|
||||
|
||||
executeStatement("UPDATE mtb_colt\n" +
|
||||
"SET barcode_ul = EAN128.AI_00\n" +
|
||||
"FROM mtb_colt\n" +
|
||||
" CROSS APPLY (SELECT TOP 1 * FROM (SELECT DISTINCT AI_00\n" +
|
||||
" FROM f_getEAN128UL(mtb_colt.gestione, mtb_colt.data_collo, mtb_colt.ser_collo,\n" +
|
||||
" mtb_colt.num_collo,\n" +
|
||||
" NULL)" +
|
||||
" WHERE mtb_colt.ser_collo <> 'UL'\n" +
|
||||
" UNION\n" +
|
||||
" SELECT CONCAT('U', RIGHT(YEAR(mtb_colt.data_collo), 2), FORMAT(mtb_colt.num_collo, '0000000')) AS AI_00\n" +
|
||||
" WHERE mtb_colt.ser_collo = 'UL') tmp) EAN128");
|
||||
|
||||
createOrUpdateFunction("f_getEAN128UL", "CREATE FUNCTION [dbo].[f_getEAN128UL](@gestione VARCHAR(1), @dataCollo DATETIME, @serCollo VARCHAR(2), @numCollo INT,\n" +
|
||||
" @customPrefissoEan VARCHAR(7))\n" +
|
||||
" RETURNS TABLE AS\n" +
|
||||
" RETURN\n" +
|
||||
" -- DECLARE @gestione AS VARCHAR(1) = 'L'\n" +
|
||||
"-- DECLARE @serCollo AS VARCHAR(10) = 'GG'\n" +
|
||||
"-- DECLARE @numCollo AS INT = 7837\n" +
|
||||
"-- DECLARE @dataCollo AS DATETIME = '2025-03-10';\n" +
|
||||
"-- DECLARE @customPrefissoEan AS VARCHAR(7);-- = '8017596';\n" +
|
||||
"\n" +
|
||||
" WITH barcodes AS (SELECT mtb_colt.barcode_ul AS AI_00,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_aart.cod_barre_imb IS NOT NULL AND LEN(mtb_aart.cod_barre_imb) < 14 THEN\n" +
|
||||
" FORMAT(CONVERT(NUMERIC, ISNULL(NULLIF(mtb_aart.cod_barre_imb, ''), '0')),\n" +
|
||||
" REPLICATE('0', 14))\n" +
|
||||
" ELSE mtb_aart.cod_barre_imb\n" +
|
||||
" END AS AI_01,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_aart.bar_code IS NOT NULL AND LEN(mtb_aart.bar_code) < 14\n" +
|
||||
" THEN\n" +
|
||||
" FORMAT(CONVERT(BIGINT, mtb_aart.bar_code), REPLICATE('0', 14))\n" +
|
||||
" ELSE mtb_aart.bar_code\n" +
|
||||
" END AS AI_02,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_colr.partita_mag IS NOT NULL THEN\n" +
|
||||
" mtb_colr.partita_mag + CHAR(29)\n" +
|
||||
" END AS AI_10,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_partita_mag.data_scad IS NOT NULL THEN\n" +
|
||||
" REPLACE(CONVERT(VARCHAR(10), mtb_partita_mag.data_scad, 2), '.', '')\n" +
|
||||
" END AS AI_15,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 6 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '000000'), '.', '')\n" +
|
||||
" END AS AI_3100,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 5 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '00000.0'), '.', '')\n" +
|
||||
" END AS AI_3101,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 4 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '0000.00'), '.', '')\n" +
|
||||
" END AS AI_3102,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 3 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '000.000'), '.', '')\n" +
|
||||
" END AS AI_3103,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 2 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '00.0000'), '.', '')\n" +
|
||||
" END AS AI_3104,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 1 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '0.00000'), '.', '')\n" +
|
||||
" END AS AI_3105,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 6 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_colt.peso_kg, '000000'), '.', '')\n" +
|
||||
" END AS AI_3300,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 5 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_colt.peso_kg, '00000.0'), '.', '')\n" +
|
||||
" END AS AI_3301,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 4 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_colt.peso_kg, '0000.00'), '.', '')\n" +
|
||||
" END AS AI_3302,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 3 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_colt.peso_kg, '000.000'), '.', '')\n" +
|
||||
" END AS AI_3303,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 2 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_colt.peso_kg, '00.0000'), '.', '')\n" +
|
||||
" END AS AI_3304,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 1 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_colt.peso_kg, '0.00000'), '.', '')\n" +
|
||||
" END AS AI_3305,\n" +
|
||||
" CONVERT(VARCHAR, CONVERT(INTEGER, SUM(mtb_colr.qta_col / mtb_colr.qta_cnf))) AS AI_37\n" +
|
||||
" FROM mtb_colt\n" +
|
||||
" INNER JOIN mtb_colr\n" +
|
||||
" ON mtb_colt.gestione = mtb_colr.gestione AND\n" +
|
||||
" mtb_colt.data_collo = mtb_colr.data_collo AND\n" +
|
||||
" mtb_colt.ser_collo = mtb_colr.ser_collo AND\n" +
|
||||
" mtb_colt.num_collo = mtb_colr.num_collo\n" +
|
||||
" INNER JOIN mtb_aart ON mtb_colr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" LEFT OUTER JOIN mtb_partita_mag ON mtb_colr.cod_mart = mtb_partita_mag.cod_mart AND\n" +
|
||||
" mtb_colr.partita_mag =\n" +
|
||||
" mtb_partita_mag.partita_mag,\n" +
|
||||
" azienda\n" +
|
||||
" WHERE mtb_colt.gestione = @gestione\n" +
|
||||
" AND mtb_colt.data_collo = @dataCollo\n" +
|
||||
" AND mtb_colt.ser_collo = @serCollo\n" +
|
||||
" AND mtb_colt.num_collo = @numCollo\n" +
|
||||
" GROUP BY mtb_colr.qta_cnf,\n" +
|
||||
" mtb_colt.data_vers,\n" +
|
||||
" nome_ditta,\n" +
|
||||
" azienda.indirizzo,\n" +
|
||||
" azienda.cap,\n" +
|
||||
" azienda.citta,\n" +
|
||||
" azienda.prov,\n" +
|
||||
" prefisso_ean,\n" +
|
||||
" mtb_colt.data_collo,\n" +
|
||||
" mtb_colt.num_collo,\n" +
|
||||
" mtb_aart.cod_barre_imb,\n" +
|
||||
" mtb_aart.bar_code,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" mtb_colr.partita_mag,\n" +
|
||||
" mtb_partita_mag.data_scad,\n" +
|
||||
" mtb_colt.peso_netto_kg,\n" +
|
||||
" mtb_colr.cod_mart,\n" +
|
||||
" mtb_colt.gestione,\n" +
|
||||
" mtb_colt.peso_kg,\n" +
|
||||
" mtb_aart.peso_kg, \n" +
|
||||
" mtb_colt.barcode_ul)\n" +
|
||||
" SELECT AI_00,\n" +
|
||||
" IIF(AI_01 IS NOT NULL AND LEN(AI_01) = 13,\n" +
|
||||
" CONCAT(AI_01, dbo.getCheckDigitITF14(AI_01)), AI_01) AS AI_01,\n" +
|
||||
" AI_02,\n" +
|
||||
" AI_10,\n" +
|
||||
" AI_15,\n" +
|
||||
" AI_3100,\n" +
|
||||
" AI_3101,\n" +
|
||||
" AI_3102,\n" +
|
||||
" AI_3103,\n" +
|
||||
" AI_3104,\n" +
|
||||
" AI_3105,\n" +
|
||||
" AI_3300,\n" +
|
||||
" AI_3301,\n" +
|
||||
" AI_3302,\n" +
|
||||
" AI_3303,\n" +
|
||||
" AI_3304,\n" +
|
||||
" AI_3305,\n" +
|
||||
" AI_37\n" +
|
||||
" FROM barcodes\n" +
|
||||
"GO");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
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;
|
||||
import it.integry.ems.migration.dto.common.MigrationMvwSitArtUdcDetInventarioDTO;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class Migration_20250417110238 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
//Migration per aggiornare la view mvw_sitart_udc_det_inventario
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isCustomer(IntegryCustomer.Maggio) &&
|
||||
!isCustomer(IntegryCustomer.Biolevante) &&
|
||||
!isCustomer(IntegryCustomer.Ime) &&
|
||||
!isCustomerDb(IntegryCustomerDB.Gramm_Gramm))
|
||||
return;
|
||||
|
||||
//Aggiorno la view mvw_mtb_colr_with_giacenza
|
||||
MigrationMvwSitArtUdcDetInventarioDTO.apply(connection);
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Gramm_Gramm))
|
||||
resetCodJcomColli();
|
||||
//alignCodJcomScarichiFromCarichi();
|
||||
|
||||
MigrationMvwSitArtUdcDetInventarioDTO.alignGiacenza(connection);
|
||||
}
|
||||
|
||||
private void resetCodJcomColli() throws SQLException {
|
||||
executeStatement("UPDATE mtb_colr SET cod_jcom = NULL");
|
||||
}
|
||||
|
||||
private void alignCodJcomScarichiFromCarichi() throws Exception {
|
||||
String updateSql = "UPDATE mtb_colr\n" +
|
||||
"SET mtb_colr.cod_jcom = tmp.cod_jcom_carico\n" +
|
||||
" FROM mtb_colr\n" +
|
||||
" INNER JOIN\n" +
|
||||
" (SELECT mr_scarico.num_collo,\n" +
|
||||
" mr_scarico.data_collo,\n" +
|
||||
" mr_scarico.ser_collo,\n" +
|
||||
" mr_scarico.gestione,\n" +
|
||||
" mr_scarico.riga,\n" +
|
||||
" mr_scarico.cod_mart,\n" +
|
||||
" mr_scarico.partita_mag,\n" +
|
||||
" mr_scarico.cod_jcom AS cod_jcom_scarico,\n" +
|
||||
" mr_carico.num_collo AS num_collo_ccarico,\n" +
|
||||
" mr_carico.cod_jcom AS cod_jcom_carico\n" +
|
||||
" FROM mtb_colr mr_scarico\n" +
|
||||
" INNER JOIN mtb_colt mt_scarico\n" +
|
||||
" ON mr_scarico.gestione = mt_scarico.gestione AND\n" +
|
||||
" mr_scarico.data_collo = mt_scarico.data_collo AND\n" +
|
||||
" mr_scarico.num_collo = mt_scarico.num_collo AND\n" +
|
||||
" mr_scarico.ser_collo = mt_scarico.ser_collo\n" +
|
||||
" LEFT OUTER JOIN mtb_colr mr_carico\n" +
|
||||
" ON mr_scarico.gestione_rif = mr_carico.gestione AND\n" +
|
||||
" mr_scarico.data_collo_rif = mr_carico.data_collo AND\n" +
|
||||
" mr_scarico.num_collo_rif = mr_carico.num_collo AND\n" +
|
||||
" mr_scarico.ser_collo_rif = mr_carico.ser_collo AND\n" +
|
||||
" mr_scarico.cod_mart = mr_carico.cod_mart AND\n" +
|
||||
" ISNULL(mr_scarico.partita_mag, '') = ISNULL(mr_carico.partita_mag, '')\n" +
|
||||
" WHERE\n" +
|
||||
// " mt_scarico.segno = -1 AND\n" +
|
||||
" mr_carico.num_collo IS NOT NULL\n" +
|
||||
" AND ISNULL(mr_carico.cod_jcom, '') <> ISNULL(mr_scarico.cod_jcom, '')) tmp\n" +
|
||||
"ON mtb_colr.num_collo = tmp.num_collo AND\n" +
|
||||
" mtb_colr.data_collo = tmp.data_collo AND\n" +
|
||||
" mtb_colr.gestione = tmp.gestione AND\n" +
|
||||
" mtb_colr.ser_collo = tmp.ser_collo AND\n" +
|
||||
" mtb_colr.riga = tmp.riga";
|
||||
|
||||
executeStatement(updateSql);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -1,207 +0,0 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250604172635 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateView("WMS_OrdPrelievo", "CREATE VIEW [dbo].[WMS_OrdPrelievo] AS\n" +
|
||||
"WITH elencoFornitoriInterni AS (SELECT value_string AS fornitore\n" +
|
||||
" FROM dbo.ParseStringIntoArray((SELECT value\n" +
|
||||
" FROM stb_gest_setup\n" +
|
||||
" WHERE gest_name = 'PICKING'\n" +
|
||||
" AND section = 'SPEDIZIONE'\n" +
|
||||
" AND key_section = 'ELENCO_FORNITORI_INTERNI'),\n" +
|
||||
" '|')),\n" +
|
||||
" riservatoPerOrd AS (\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"SELECT mtb_colt.gestione,\n" +
|
||||
" mtb_colr.data_ord,\n" +
|
||||
" mtb_colr.num_ord,\n" +
|
||||
" mtb_colr.riga_ord,\n" +
|
||||
" SUM(mtb_colr.qta_col) AS qtaCollo,\n" +
|
||||
" SUM(mtb_colr.num_cnf) AS numCnfCollo,\n" +
|
||||
" COUNT(DISTINCT mtb_colr.num_ord) AS ColliRiservati\n" +
|
||||
" FROM mtb_colr\n" +
|
||||
" INNER JOIN mtb_colt ON mtb_colr.gestione = mtb_colt.gestione AND\n" +
|
||||
" mtb_colr.data_collo = mtb_colt.data_collo AND\n" +
|
||||
" mtb_colr.ser_collo = mtb_colt.ser_collo AND\n" +
|
||||
" mtb_colr.num_collo = mtb_colt.num_collo\n" +
|
||||
" WHERE segno = - 1\n" +
|
||||
" AND mtb_colr.gestione IN ('L', 'V')\n" +
|
||||
" AND mtb_colr.data_ord IS NOT NULL\n" +
|
||||
" GROUP BY mtb_colt.gestione, mtb_colr.data_ord, mtb_colr.num_ord, mtb_colr.riga_ord\n" +
|
||||
"\n" +
|
||||
" ), OrdVr AS (\n" +
|
||||
" SELECT dtb_ordr.gestione,\n" +
|
||||
" dtb_ordr.data_ord,\n" +
|
||||
" dtb_ordr.num_ord,\n" +
|
||||
" dtb_ordt.cod_vdes,\n" +
|
||||
" IIF(dtb_ordr.gestione = 'V', LEFT(ISNULL(vtb_dest.citta + ' - ', '') + vtb_dest.indirizzo, 40),\n" +
|
||||
" dtb_ordt.rif_ord) AS rif_ord,\n" +
|
||||
" dtb_ordt.cod_anag,\n" +
|
||||
" dtb_ordt.cod_prod,\n" +
|
||||
" CASE dtb_ordr.gestione WHEN 'L' THEN '2' WHEN 'V' THEN '3' END +\n" +
|
||||
" REPLACE(CONVERT(VARCHAR(10), dtb_ordr.data_ord, 105), '-', '') +\n" +
|
||||
" REPLICATE('0', 5 - LEN(dtb_ordr.num_ord)) +\n" +
|
||||
" CONVERT(VARCHAR(6), dtb_ordr.num_ord) AS chiave_ordine,\n" +
|
||||
" dtb_ordr.cod_jcom,\n" +
|
||||
" dtb_ordr.cod_mart,\n" +
|
||||
" SUM(ROUND(dtb_ordr.qta_ord - dtb_ordr.qta_evasa, mtb_unt_mis.cifre_dec)) *\n" +
|
||||
" dtb_ordr.rap_conv AS qta_inevasa,\n" +
|
||||
" dtb_ordt.listino,\n" +
|
||||
" dtb_ordt.term_cons,\n" +
|
||||
" dtb_ordt.cod_auto,\n" +
|
||||
" dtb_ordt.cod_vvet,\n" +
|
||||
" dtb_ordt.data_iniz_trasp,\n" +
|
||||
" dtb_ordt.cod_mdep,\n" +
|
||||
" dtb_ordr.data_cons AS data_cons,\n" +
|
||||
" dtb_ordr.id_viaggio,\n" +
|
||||
" dtb_ordt.cod_vage,\n" +
|
||||
" SUM(colli.qtaCollo) AS qtaCollo,\n" +
|
||||
" SUM(ROUND((dtb_ordr.qta_ord - dtb_ordr.qta_evasa) * dtb_ordr.rap_conv -\n" +
|
||||
" ISNULL(colli.qtaCollo, 0),\n" +
|
||||
" mtb_unt_mis.cifre_dec)) AS qtaInevasaColli,\n" +
|
||||
" SUM(colli.numCnfCollo) AS numCnfCollo,\n" +
|
||||
" SUM(dtb_ordr.num_cnf - dtb_ordr.num_cnf_evasa -\n" +
|
||||
" ISNULL(colli.numCnfCollo, 0)) AS numCnfInevasaColli,\n" +
|
||||
" IIF((dtb_ordr.gestione = 'L' AND dtb_ordt.gestione_rif = 'T') OR\n" +
|
||||
" elencoFornitoriInterni.fornitore IS NOT NULL, 'S', 'N') AS ord_trasf\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_unt_mis ON mtb_unt_mis.unt_mis = dtb_ordr.unt_ord\n" +
|
||||
" INNER JOIN mtb_aart ON dtb_ordr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" LEFT OUTER JOIN vtb_dest ON dtb_ordt.cod_anag = vtb_dest.cod_anag AND\n" +
|
||||
" dtb_ordt.cod_vdes = vtb_dest.cod_vdes\n" +
|
||||
" LEFT OUTER JOIN riservatoPerOrd colli\n" +
|
||||
" ON dtb_ordt.gestione = colli.gestione AND\n" +
|
||||
" dtb_ordt.data_ord = colli.data_ord AND\n" +
|
||||
" dtb_ordt.num_ord = colli.num_ord\n" +
|
||||
" LEFT OUTER JOIN elencoFornitoriInterni ON fornitore = dtb_ordt.cod_anag\n" +
|
||||
" WHERE dtb_ordt.flag_annulla = 'N'\n" +
|
||||
" AND dtb_ordt.flag_sospeso = 'N'\n" +
|
||||
" AND dtb_ordr.flag_evaso = 'I'\n" +
|
||||
" AND dtb_ordt.flag_evaso_forzato = 'N'\n" +
|
||||
" AND dtb_ordt.gestione IN ('L', 'V')\n" +
|
||||
" AND ((mtb_aart.flag_qta_cnf_fissa = 'S' AND qta_ord > qta_evasa) OR\n" +
|
||||
" (mtb_aart.flag_qta_cnf_fissa <> 'S' AND num_cnf > num_cnf_evasa))\n" +
|
||||
" GROUP BY dtb_ordr.gestione, dtb_ordr.data_ord, dtb_ordr.num_ord, dtb_ordt.cod_vdes,\n" +
|
||||
" vtb_dest.indirizzo,\n" +
|
||||
" vtb_dest.citta, dtb_ordt.rif_ord, dtb_ordt.cod_anag, dtb_ordr.cod_jcom, dtb_ordr.cod_mart,\n" +
|
||||
" dtb_ordt.cod_prod, dtb_ordt.listino, dtb_ordt.term_cons, dtb_ordt.cod_auto,\n" +
|
||||
" dtb_ordt.cod_vvet, fornitore,\n" +
|
||||
" dtb_ordt.data_iniz_trasp, dtb_ordt.cod_mdep, dtb_ordt.cod_vage, dtb_ordr.id_viaggio,\n" +
|
||||
" colli.num_ord, dtb_ordr.data_cons, dtb_ordt.gestione_rif, dtb_ordr.rap_conv\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
" ), OrdV AS (\n" +
|
||||
" SELECT gestione,\n" +
|
||||
" data_ord,\n" +
|
||||
" num_ord,\n" +
|
||||
" rif_ord,\n" +
|
||||
" cod_anag,\n" +
|
||||
" chiave_ordine,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" cod_prod,\n" +
|
||||
" listino,\n" +
|
||||
" term_cons,\n" +
|
||||
" cod_auto,\n" +
|
||||
" cod_vvet,\n" +
|
||||
" data_iniz_trasp,\n" +
|
||||
" data_cons,\n" +
|
||||
" cod_vdes,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" COUNT(DISTINCT cod_mart) AS arts_da_evadere,\n" +
|
||||
" SUM(qtaInevasaColli) AS qtaInevasa,\n" +
|
||||
" SUM(numCnfInevasaColli) AS numCnfInevasa,\n" +
|
||||
" id_viaggio,\n" +
|
||||
" cod_vage,\n" +
|
||||
" COUNT(DISTINCT qtaCollo) AS colliRiservati,\n" +
|
||||
" ord_trasf\n" +
|
||||
" FROM OrdVr\n" +
|
||||
" GROUP BY gestione, data_ord, num_ord, rif_ord, cod_anag, chiave_ordine, cod_jcom, cod_prod, listino,\n" +
|
||||
" term_cons, cod_auto, cod_vvet, data_iniz_trasp, data_cons, cod_vdes, cod_mdep, cod_vage,\n" +
|
||||
" id_viaggio, ord_trasf\n" +
|
||||
"\n" +
|
||||
" ),\n" +
|
||||
" OrdV2 AS (SELECT OrdV.gestione,\n" +
|
||||
" OrdV.data_ord,\n" +
|
||||
" OrdV.num_ord,\n" +
|
||||
" rif_ord,\n" +
|
||||
" OrdV.cod_anag,\n" +
|
||||
" chiave_ordine,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" cod_prod,\n" +
|
||||
" listino,\n" +
|
||||
" term_cons,\n" +
|
||||
" OrdV.cod_auto,\n" +
|
||||
" ISNULL(vtb_viaggi.cod_vvet, OrdV.cod_vvet) AS cod_vvet,\n" +
|
||||
" data_iniz_trasp,\n" +
|
||||
" ISNULL(CONVERT(DATETIME, CONVERT(VARCHAR(10), vtb_viaggi.data_ora_iniz_trasp, 121)),\n" +
|
||||
" data_cons) AS data_cons,\n" +
|
||||
" cod_vdes,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" arts_da_evadere AS ArtDaEvadere,\n" +
|
||||
" OrdV.id_viaggio,\n" +
|
||||
" cod_vage,\n" +
|
||||
" ISNULL(ordV.ColliRiservati, 0) AS colli_riservati,\n" +
|
||||
" qtaInevasa,\n" +
|
||||
" numCnfInevasa,\n" +
|
||||
" CAST(IIF(ISNULL(ordV.ColliRiservati, 0) > 0, 1, 0) AS BIT) exist_collo,\n" +
|
||||
" CAST(IIF(ISNULL(qtaInevasa, 0) > 0,\n" +
|
||||
" IIF(ISNULL(numCnfInevasa, 0) > 0, 0, IIF(ordV.colliRiservati > 0, 1, 0)), 1) AS BIT) AS flag_evaso,\n" +
|
||||
" ord_trasf,\n" +
|
||||
" IIF((SELECT azienda.part_iva\n" +
|
||||
" FROM azienda\n" +
|
||||
" WHERE azienda.part_iva = gtb_anag.part_iva) IS NULL, 'N', 'S') AS ord_aziendale\n" +
|
||||
" FROM Ordv\n" +
|
||||
" INNER JOIN gtb_anag ON OrdV.cod_anag = gtb_anag.cod_anag\n" +
|
||||
" LEFT OUTER JOIN vtb_viaggi ON OrdV.id_viaggio = vtb_viaggi.id_viaggio\n" +
|
||||
" WHERE (arts_da_evadere > 0 OR ISNULL(ColliRiservati, 0) > 0))\n" +
|
||||
"SELECT gestione,\n" +
|
||||
" data_ord,\n" +
|
||||
" num_ord,\n" +
|
||||
" rif_ord,\n" +
|
||||
" cod_anag,\n" +
|
||||
" chiave_ordine,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" cod_prod,\n" +
|
||||
" listino,\n" +
|
||||
" term_cons,\n" +
|
||||
" cod_auto,\n" +
|
||||
" cod_vvet,\n" +
|
||||
" data_iniz_trasp,\n" +
|
||||
" data_cons,\n" +
|
||||
" cod_vdes,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" SUM(ArtDaEvadere) AS ArtDaEvadere,\n" +
|
||||
" id_viaggio,\n" +
|
||||
" cod_vage,\n" +
|
||||
" SUM(colli_riservati) AS colli_riservati,\n" +
|
||||
" SUM(qtaInevasa) AS qtaInevasa,\n" +
|
||||
" SUM(numCnfInevasa) AS numCnfInevasa,\n" +
|
||||
" exist_collo,\n" +
|
||||
" flag_evaso,\n" +
|
||||
" ord_trasf,\n" +
|
||||
" ord_aziendale\n" +
|
||||
"FROM OrdV2\n" +
|
||||
"GROUP BY gestione, data_ord, num_ord, rif_ord, cod_anag, chiave_ordine, cod_jcom, cod_prod, listino, term_cons,\n" +
|
||||
" cod_auto, cod_vvet, data_iniz_trasp, data_cons, cod_vdes, cod_mdep, id_viaggio, cod_vage, exist_collo,\n" +
|
||||
" flag_evaso, ord_trasf, ord_aziendale");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250618195259 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateView("dvw_situazione_qta_docs", "CREATE VIEW dvw_situazione_qta_docs AS\n" +
|
||||
"SELECT dtb_docr.[cod_anag],\n" +
|
||||
" dtb_docr.[cod_dtip],\n" +
|
||||
" dtb_docr.[data_doc],\n" +
|
||||
" dtb_docr.[ser_doc],\n" +
|
||||
" dtb_docr.[num_doc],\n" +
|
||||
" dtb_docr.[id_riga],\n" +
|
||||
" dtb_docr.[cod_mart],\n" +
|
||||
" dtb_docr.[descrizione],\n" +
|
||||
" dtb_docr.[unt_doc],\n" +
|
||||
" (dtb_docr.[rap_conv] / dtb_docr.[rap_conv]) AS rap_conv,\n" +
|
||||
" (dtb_docr.[qta_doc] * dtb_docr.[rap_conv]) - ISNULL(mtb_colr.qta_col, 0) AS qta_doc,\n" +
|
||||
" dtb_docr.[val_unt],\n" +
|
||||
" dtb_docr.[sconto5],\n" +
|
||||
" dtb_docr.[sconto6],\n" +
|
||||
" dtb_docr.[sconto7],\n" +
|
||||
" dtb_docr.[sconto8],\n" +
|
||||
" dtb_docr.[cod_aliq],\n" +
|
||||
" dtb_docr.[perc_prov],\n" +
|
||||
" dtb_docr.[val_prov],\n" +
|
||||
" dtb_docr.[data_ord],\n" +
|
||||
" dtb_docr.[num_ord],\n" +
|
||||
" dtb_docr.[riga_ord],\n" +
|
||||
" dtb_docr.[importo_riga],\n" +
|
||||
" dtb_docr.[cod_col],\n" +
|
||||
" dtb_docr.[cod_tagl],\n" +
|
||||
" dtb_docr.[cod_jcom],\n" +
|
||||
" dtb_docr.[cod_mdep],\n" +
|
||||
" dtb_docr.[perc_gest],\n" +
|
||||
" dtb_docr.[val_gest],\n" +
|
||||
" dtb_docr.[partita_mag],\n" +
|
||||
" dtb_docr.[val_unt_iva],\n" +
|
||||
" (dtb_docr.[qta_cnf] * dtb_docr.[rap_conv]) AS qta_cnf,\n" +
|
||||
" dtb_docr.[descrizione_estesa],\n" +
|
||||
" dtb_docr.[costo_unt],\n" +
|
||||
" dtb_docr.[perc_ispe],\n" +
|
||||
" dtb_docr.[val_ispe],\n" +
|
||||
" dtb_docr.[perc_promo],\n" +
|
||||
" dtb_docr.[val_promo],\n" +
|
||||
" dtb_docr.[perc_oneri],\n" +
|
||||
" dtb_docr.[val_oneri],\n" +
|
||||
" dtb_docr.[flag_evaso_forzato],\n" +
|
||||
" dtb_docr.[cod_dtip_comp],\n" +
|
||||
" dtb_docr.[data_doc_comp],\n" +
|
||||
" dtb_docr.[ser_doc_comp],\n" +
|
||||
" dtb_docr.[num_doc_comp],\n" +
|
||||
" dtb_docr.[cod_promo],\n" +
|
||||
" dtb_docr.[perc_prov2],\n" +
|
||||
" dtb_docr.[val_prov2],\n" +
|
||||
" dtb_docr.[cod_art_for],\n" +
|
||||
" dtb_docr.[unt_doc2],\n" +
|
||||
" dtb_docr.[qta_doc2],\n" +
|
||||
" dtb_docr.[unt_doc3],\n" +
|
||||
" dtb_docr.[qta_doc3],\n" +
|
||||
" dtb_docr.[num_cnf] - ISNULL(mtb_colr.num_cnf, 0) AS num_cnf,\n" +
|
||||
" dtb_docr.[peso_lordo],\n" +
|
||||
" dtb_docr.[posizione],\n" +
|
||||
" dtb_docr.[cod_anag_comp],\n" +
|
||||
" dtb_docr.[cod_mtip],\n" +
|
||||
" dtb_docr.[matricola],\n" +
|
||||
" dtb_docr.[data_iniz_comp],\n" +
|
||||
" dtb_docr.[data_fine_comp],\n" +
|
||||
" dtb_docr.[cod_kit],\n" +
|
||||
" dtb_docr.[cod_alis],\n" +
|
||||
" dtb_docr.[data_ins_row],\n" +
|
||||
" dtb_docr.[note],\n" +
|
||||
" dtb_doct.[gestione],\n" +
|
||||
" mtb_partita_mag.[data_scad] AS data_scad_partita_mag\n" +
|
||||
"FROM dtb_docr\n" +
|
||||
" INNER JOIN dtb_doct ON dtb_docr.num_doc = dtb_doct.num_doc AND dtb_docr.data_doc = dtb_doct.data_doc AND\n" +
|
||||
" dtb_docr.cod_anag = dtb_doct.cod_anag AND dtb_docr.cod_dtip = dtb_doct.cod_dtip AND\n" +
|
||||
" dtb_docr.ser_doc = dtb_doct.ser_doc\n" +
|
||||
" INNER JOIN mtb_aart ON dtb_docr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" LEFT OUTER JOIN mtb_partita_mag ON dtb_docr.cod_mart = mtb_partita_mag.cod_mart AND\n" +
|
||||
" dtb_docr.partita_mag = mtb_partita_mag.partita_mag\n" +
|
||||
" LEFT OUTER JOIN ctb_cont ON mtb_aart.cod_ccon_ricavi = ctb_cont.cod_ccon\n" +
|
||||
" LEFT OUTER JOIN ctb_grup ON ctb_cont.cod_cgrp = ctb_grup.cod_cgrp\n" +
|
||||
" LEFT OUTER JOIN (SELECT gestione,\n" +
|
||||
" cod_mart,\n" +
|
||||
" cod_col,\n" +
|
||||
" cod_tagl,\n" +
|
||||
" SUM(qta_col) AS qta_col,\n" +
|
||||
" data_ord,\n" +
|
||||
" num_ord,\n" +
|
||||
" riga_ord,\n" +
|
||||
" partita_mag,\n" +
|
||||
" qta_cnf,\n" +
|
||||
" gestione_rif,\n" +
|
||||
" data_collo_rif,\n" +
|
||||
" ser_collo_rif,\n" +
|
||||
" num_collo_rif,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" SUM(num_cnf) AS num_cnf,\n" +
|
||||
" cod_anag_doc,\n" +
|
||||
" cod_dtip_doc,\n" +
|
||||
" data_doc,\n" +
|
||||
" ser_doc,\n" +
|
||||
" num_doc,\n" +
|
||||
" id_riga_doc\n" +
|
||||
" FROM mtb_colr\n" +
|
||||
" GROUP BY gestione, cod_barre, cod_mart, cod_col, cod_tagl, data_ord, num_ord, riga_ord,\n" +
|
||||
" partita_mag, qta_cnf, gestione_rif, data_collo_rif, ser_collo_rif, num_collo_rif,\n" +
|
||||
" cod_jcom, cod_anag_doc, cod_dtip_doc, data_doc, ser_doc, num_doc,\n" +
|
||||
" id_riga_doc) mtb_colr\n" +
|
||||
" ON dtb_docr.cod_anag = mtb_colr.cod_anag_doc AND dtb_docr.cod_dtip = mtb_colr.cod_dtip_doc AND\n" +
|
||||
" dtb_docr.ser_doc = mtb_colr.ser_doc AND dtb_docr.data_doc = mtb_colr.data_doc AND\n" +
|
||||
" dtb_docr.num_doc = mtb_colr.num_doc AND dtb_docr.id_riga = mtb_colr.id_riga_doc\n" +
|
||||
"WHERE (ctb_grup.sezione <> 1 OR ctb_grup.sezione IS NULL)\n" +
|
||||
" AND (dtb_docr.[qta_doc] * dtb_docr.[rap_conv]) - ISNULL(mtb_colr.qta_col, 0) > 0");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250625155432 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateView("mvw_sitart_udc_det_inventario", "CREATE VIEW [dbo].[mvw_sitart_udc_det_inventario] AS\n" +
|
||||
"WITH baseMtbColr AS (SELECT c,\n" +
|
||||
"\n" +
|
||||
" ROUND(v.qta_col, cifre_dec) AS qta_col,\n" +
|
||||
" ROUND(v.num_cnf, cifre_dec) AS num_cnf,\n" +
|
||||
" IIF(flag_qta_cnf_fissa = 'S',\n" +
|
||||
" v.qta_cnf_anag, v.qta_col / IIF(v.num_cnf = 0, 1, v.num_cnf)) AS qta_cnf,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" mtb_colt.gestione,\n" +
|
||||
" mtb_colt.data_collo,\n" +
|
||||
" mtb_colt.ser_collo,\n" +
|
||||
" mtb_colt.num_collo,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.cod_mgrp,\n" +
|
||||
" mtb_grup.descrizione AS descrizione_gruppo,\n" +
|
||||
" v.cod_msgr,\n" +
|
||||
" mtb_sgrp.descrizione AS descrizione_sottogruppo,\n" +
|
||||
" mtb_unt_mis.flag_dig,\n" +
|
||||
" mtb_unt_mis.cifre_dec,\n" +
|
||||
" mtb_colt.segno,\n" +
|
||||
" v.cod_mdep,\n" +
|
||||
" v.posizione,\n" +
|
||||
" mtb_colt.cod_dtip,\n" +
|
||||
" mtb_colt.cod_jfas,\n" +
|
||||
" v.barcode_ul,\n" +
|
||||
" v.qta_cnf_anag,\n" +
|
||||
" mtb_colr.datetime_row AS datetime_posizionamento\n" +
|
||||
" FROM mvw_mtb_colr_with_giacenza v WITH (NOEXPAND)\n" +
|
||||
" INNER JOIN mtb_colt\n" +
|
||||
" ON v.barcode_ul = mtb_colt.barcode_ul\n" +
|
||||
" LEFT OUTER JOIN mtb_colr ON\n" +
|
||||
" v.barcode_ul = mtb_colr.barcode_ul_in AND\n" +
|
||||
" v.cod_mart = mtb_colr.cod_mart AND\n" +
|
||||
" ISNULL(v.partita_mag, '') = ISNULL(mtb_colr.partita_mag, '') AND\n" +
|
||||
" ISNULL(v.cod_col, '') = ISNULL(mtb_colr.cod_col, '') AND\n" +
|
||||
" ISNULL(v.cod_tagl, '') = ISNULL(mtb_colr.cod_tagl, '') AND\n" +
|
||||
" ISNULL(v.cod_jcom, '') = ISNULL(mtb_colr.cod_jcom, '') AND\n" +
|
||||
" ISNULL(v.posizione, '') = ISNULL(mtb_colr.posizione_in, '') AND\n" +
|
||||
" ISNULL(v.cod_mdep, '') = ISNULL(mtb_colr.cod_mdep_in, '') AND\n" +
|
||||
" ISNULL(mtb_colr.posizione_in, '') <> ISNULL(mtb_colr.posizione_out, '')\n" +
|
||||
" INNER JOIN dbo.mtb_unt_mis ON v.unt_mis = mtb_unt_mis.unt_mis\n" +
|
||||
"\n" +
|
||||
" INNER JOIN dbo.mtb_grup ON v.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" INNER JOIN dbo.mtb_sgrp ON v.cod_mgrp = mtb_sgrp.cod_mgrp\n" +
|
||||
" AND v.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
" WHERE v.qta_col > 0\n" +
|
||||
" AND (segno = 1 OR (segno = -1 AND cod_dtip IS NULL AND mtb_colt.gestione = 'V'))),\n" +
|
||||
" final_stock AS (SELECT v.qta_col,\n" +
|
||||
" v.num_cnf,\n" +
|
||||
" v.qta_cnf,\n" +
|
||||
" v.gestione,\n" +
|
||||
" v.data_collo,\n" +
|
||||
" v.ser_collo,\n" +
|
||||
" v.num_collo,\n" +
|
||||
" v.cod_mdep AS cod_mdep,\n" +
|
||||
" v.posizione AS posizione,\n" +
|
||||
" mtb_depo_posizioni.priorita,\n" +
|
||||
" v.cod_mgrp AS codGruppo,\n" +
|
||||
" v.descrizione_gruppo AS Gruppo,\n" +
|
||||
" v.cod_msgr AS CodSgruppo,\n" +
|
||||
" v.descrizione_sottogruppo AS Sottogruppo,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" v.cod_jfas,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.segno,\n" +
|
||||
" v.barcode_ul,\n" +
|
||||
" v.datetime_posizionamento\n" +
|
||||
" FROM baseMtbColr v\n" +
|
||||
"\n" +
|
||||
" LEFT OUTER JOIN mtb_depo_posizioni\n" +
|
||||
" ON v.cod_mdep = mtb_depo_posizioni.cod_mdep\n" +
|
||||
" AND v.posizione = mtb_depo_posizioni.posizione)\n" +
|
||||
"\n" +
|
||||
"SELECT qta_col,\n" +
|
||||
" num_cnf,\n" +
|
||||
" qta_cnf,\n" +
|
||||
" gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" ser_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" posizione,\n" +
|
||||
" priorita,\n" +
|
||||
" codGruppo,\n" +
|
||||
" Gruppo,\n" +
|
||||
" CodSgruppo,\n" +
|
||||
" Sottogruppo,\n" +
|
||||
" cod_mart,\n" +
|
||||
" diacod,\n" +
|
||||
" descrizione_estesa,\n" +
|
||||
" partita_mag,\n" +
|
||||
" cod_col,\n" +
|
||||
" cod_tagl,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" peso_netto_kg,\n" +
|
||||
" peso_lordo_kg,\n" +
|
||||
" cod_jfas,\n" +
|
||||
" flag_qta_cnf_fissa,\n" +
|
||||
" unt_mis,\n" +
|
||||
" segno,\n" +
|
||||
" barcode_ul,\n" +
|
||||
" datetime_posizionamento\n" +
|
||||
"FROM final_stock");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
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_20250627184608 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
String value = null;
|
||||
if (isCustomer(IntegryCustomer.RossoGargano)){
|
||||
value = "ControlloGiacenzeSintetico";
|
||||
}
|
||||
createSetup("PVM","CONTROLLO_GIACENZE","REPORT_NAME_ELENCO_SINTETICO",value,"Report name per report giacenze sintetico da portale web","REPORT_NAME");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -1,174 +0,0 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250630164505 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateView("mvw_sitart_udc_det_inventario", "CREATE VIEW [dbo].[mvw_sitart_udc_det_inventario] AS\n" +
|
||||
"WITH baseMtbColr AS (SELECT c,\n" +
|
||||
"\n" +
|
||||
" ROUND(v.qta_col, cifre_dec) AS qta_col,\n" +
|
||||
" ROUND(v.num_cnf, cifre_dec) AS num_cnf,\n" +
|
||||
" IIF(flag_qta_cnf_fissa = 'S',\n" +
|
||||
" v.qta_cnf_anag, v.qta_col / IIF(v.num_cnf = 0, 1, v.num_cnf)) AS qta_cnf,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" mtb_colt.gestione,\n" +
|
||||
" mtb_colt.data_collo,\n" +
|
||||
" mtb_colt.ser_collo,\n" +
|
||||
" mtb_colt.num_collo,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.cod_mgrp,\n" +
|
||||
" mtb_grup.descrizione AS descrizione_gruppo,\n" +
|
||||
" v.cod_msgr,\n" +
|
||||
" mtb_sgrp.descrizione AS descrizione_sottogruppo,\n" +
|
||||
" mtb_unt_mis.flag_dig,\n" +
|
||||
" mtb_unt_mis.cifre_dec,\n" +
|
||||
" mtb_colt.segno,\n" +
|
||||
" v.cod_mdep,\n" +
|
||||
" v.posizione,\n" +
|
||||
" mtb_colt.cod_dtip,\n" +
|
||||
" mtb_colt.cod_jfas,\n" +
|
||||
" v.barcode_ul,\n" +
|
||||
" v.qta_cnf_anag,\n" +
|
||||
" MAX(mtb_colr.datetime_row) AS datetime_posizionamento\n" +
|
||||
" FROM mvw_mtb_colr_with_giacenza v WITH (NOEXPAND)\n" +
|
||||
" INNER JOIN mtb_colt\n" +
|
||||
" ON v.barcode_ul = mtb_colt.barcode_ul\n" +
|
||||
" LEFT OUTER JOIN mtb_colr ON\n" +
|
||||
" v.barcode_ul = mtb_colr.barcode_ul_in AND\n" +
|
||||
" v.cod_mart = mtb_colr.cod_mart AND\n" +
|
||||
" ((v.partita_mag IS NULL AND mtb_colr.partita_mag IS NULL) OR\n" +
|
||||
" (v.partita_mag = mtb_colr.partita_mag)) AND\n" +
|
||||
" ((v.cod_col IS NULL AND mtb_colr.cod_col IS NULL) OR (v.cod_col = mtb_colr.cod_col)) AND\n" +
|
||||
" ((v.cod_tagl IS NULL AND mtb_colr.cod_tagl IS NULL) OR (v.cod_tagl = mtb_colr.cod_tagl)) AND\n" +
|
||||
" ((v.cod_jcom IS NULL AND mtb_colr.cod_jcom IS NULL) OR (v.cod_jcom = mtb_colr.cod_jcom)) AND\n" +
|
||||
" ((v.posizione IS NULL AND mtb_colr.posizione_in IS NULL) OR (v.posizione = mtb_colr.posizione_in)) AND\n" +
|
||||
" ((v.cod_mdep IS NULL AND mtb_colr.cod_mdep_in IS NULL) OR (v.cod_mdep = mtb_colr.cod_mdep_in)) AND\n" +
|
||||
" ISNULL(mtb_colr.posizione_in, '') <> ISNULL(mtb_colr.posizione_out, '')\n" +
|
||||
" INNER JOIN dbo.mtb_unt_mis ON v.unt_mis = mtb_unt_mis.unt_mis\n" +
|
||||
"\n" +
|
||||
" INNER JOIN dbo.mtb_grup ON v.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" INNER JOIN dbo.mtb_sgrp ON v.cod_mgrp = mtb_sgrp.cod_mgrp\n" +
|
||||
" AND v.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
" WHERE v.qta_col > 0\n" +
|
||||
" AND (segno = 1 OR (segno = -1 AND cod_dtip IS NULL AND mtb_colt.gestione = 'V'))\n" +
|
||||
" GROUP BY c,\n" +
|
||||
" ROUND(v.qta_col, cifre_dec),\n" +
|
||||
" ROUND(v.num_cnf, cifre_dec),\n" +
|
||||
" IIF(flag_qta_cnf_fissa = 'S',\n" +
|
||||
" v.qta_cnf_anag, v.qta_col / IIF(v.num_cnf = 0, 1, v.num_cnf)),\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" mtb_colt.gestione,\n" +
|
||||
" mtb_colt.data_collo,\n" +
|
||||
" mtb_colt.ser_collo,\n" +
|
||||
" mtb_colt.num_collo,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.cod_mgrp,\n" +
|
||||
" mtb_grup.descrizione,\n" +
|
||||
" v.cod_msgr,\n" +
|
||||
" mtb_sgrp.descrizione,\n" +
|
||||
" mtb_unt_mis.flag_dig,\n" +
|
||||
" mtb_unt_mis.cifre_dec,\n" +
|
||||
" mtb_colt.segno,\n" +
|
||||
" v.cod_mdep,\n" +
|
||||
" v.posizione,\n" +
|
||||
" mtb_colt.cod_dtip,\n" +
|
||||
" mtb_colt.cod_jfas,\n" +
|
||||
" v.barcode_ul,\n" +
|
||||
" v.qta_cnf_anag),\n" +
|
||||
" final_stock AS (SELECT v.qta_col,\n" +
|
||||
" v.num_cnf,\n" +
|
||||
" v.qta_cnf,\n" +
|
||||
" v.gestione,\n" +
|
||||
" v.data_collo,\n" +
|
||||
" v.ser_collo,\n" +
|
||||
" v.num_collo,\n" +
|
||||
" v.cod_mdep AS cod_mdep,\n" +
|
||||
" v.posizione AS posizione,\n" +
|
||||
" mtb_depo_posizioni.priorita,\n" +
|
||||
" v.cod_mgrp AS codGruppo,\n" +
|
||||
" v.descrizione_gruppo AS Gruppo,\n" +
|
||||
" v.cod_msgr AS CodSgruppo,\n" +
|
||||
" v.descrizione_sottogruppo AS Sottogruppo,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" v.cod_jfas,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.segno,\n" +
|
||||
" v.barcode_ul,\n" +
|
||||
" v.datetime_posizionamento\n" +
|
||||
" FROM baseMtbColr v\n" +
|
||||
"\n" +
|
||||
" LEFT OUTER JOIN mtb_depo_posizioni\n" +
|
||||
" ON v.cod_mdep = mtb_depo_posizioni.cod_mdep\n" +
|
||||
" AND v.posizione = mtb_depo_posizioni.posizione)\n" +
|
||||
"\n" +
|
||||
"SELECT qta_col,\n" +
|
||||
" num_cnf,\n" +
|
||||
" qta_cnf,\n" +
|
||||
" gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" ser_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" posizione,\n" +
|
||||
" priorita,\n" +
|
||||
" codGruppo,\n" +
|
||||
" Gruppo,\n" +
|
||||
" CodSgruppo,\n" +
|
||||
" Sottogruppo,\n" +
|
||||
" cod_mart,\n" +
|
||||
" diacod,\n" +
|
||||
" descrizione_estesa,\n" +
|
||||
" partita_mag,\n" +
|
||||
" cod_col,\n" +
|
||||
" cod_tagl,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" peso_netto_kg,\n" +
|
||||
" peso_lordo_kg,\n" +
|
||||
" cod_jfas,\n" +
|
||||
" flag_qta_cnf_fissa,\n" +
|
||||
" unt_mis,\n" +
|
||||
" segno,\n" +
|
||||
" barcode_ul,\n" +
|
||||
" datetime_posizionamento\n" +
|
||||
"FROM final_stock");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250714164813 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateFunction("WMS_GetUltimeConsegneClienti", "CREATE FUNCTION [dbo].[WMS_GetUltimeConsegneClienti](@numConsegnePerClie INT, @codAnag VARCHAR(5), @codMart VARCHAR(15),\n" +
|
||||
" @codMdep VARCHAR(5), @daysDiff INT)\n" +
|
||||
"/*Funzione che restituisce le ultime consegne effettuate per conto di un cliente con possibilitàdi filtrare per articolo/deposito.\n" +
|
||||
"Se il cliente non viene passato allora la funzione restituiràle ultime consegne di tutti i clienti. */\n" +
|
||||
" RETURNS TABLE AS RETURN\n" +
|
||||
" SELECT DISTINCT *\n" +
|
||||
" FROM (SELECT dtb_doct.cod_anag,\n" +
|
||||
" DENSE_RANK() OVER (PARTITION BY dtb_doct.cod_anag ORDER BY dtb_doct.cod_anag ASC, dtb_doct.data_doc DESC, dtb_doct.num_doc) AS counter_consegna,\n" +
|
||||
" dtb_doct.cod_dtip,\n" +
|
||||
" dtb_doct.data_doc,\n" +
|
||||
" dtb_doct.ser_doc,\n" +
|
||||
" dtb_doct.num_doc,\n" +
|
||||
" dtb_doct.compilato_da,\n" +
|
||||
" dtb_doct.rif_ord,\n" +
|
||||
" dtb_doct.data_ord,\n" +
|
||||
" vtb_dest.destinatario,\n" +
|
||||
" vtb_dest.indirizzo,\n" +
|
||||
" dtb_doct.data_iniz_trasp\n" +
|
||||
" FROM dtb_doct\n" +
|
||||
" INNER JOIN dtb_docr ON dtb_doct.cod_anag = dtb_docr.cod_anag AND\n" +
|
||||
" dtb_doct.cod_dtip = dtb_docr.cod_dtip AND\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc AND\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc AND\n" +
|
||||
" dtb_doct.ser_doc = dtb_docr.ser_doc\n" +
|
||||
" INNER JOIN dtb_tipi ON dtb_doct.cod_dtip = dtb_tipi.cod_dtip\n" +
|
||||
" LEFT OUTER JOIN vtb_dest\n" +
|
||||
" ON dtb_doct.cod_anag = vtb_dest.cod_anag\n" +
|
||||
" AND dtb_doct.cod_vdes = vtb_dest.cod_vdes\n" +
|
||||
"\n" +
|
||||
" WHERE dtb_doct.gestione = 'V'\n" +
|
||||
" AND dtb_tipi.tipo_emissione = 'DIRETTA'\n" +
|
||||
" AND dtb_tipi.segno_qta_scar = 1\n" +
|
||||
" AND DATEDIFF(DAY, dtb_doct.data_doc, GETDATE()) <= @daysDiff\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
" AND (@codMdep IS NULL\n" +
|
||||
" OR dtb_doct.cod_mdep = @codMdep)\n" +
|
||||
" AND (@codMart IS NULL\n" +
|
||||
" OR dtb_docr.cod_mart = @codMart)\n" +
|
||||
" AND (@codAnag IS NULL\n" +
|
||||
" OR dtb_doct.cod_anag = @codAnag)) grouped_consegne\n" +
|
||||
" WHERE @numConsegnePerClie IS NULL\n" +
|
||||
" OR grouped_consegne.counter_consegna <= @numConsegnePerClie");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250715110408 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateFunction("WMS_GetUltimeConsegneClienti", "CREATE FUNCTION [dbo].[WMS_GetUltimeConsegneClienti](@numConsegnePerClie INT, @codAnag VARCHAR(5), @codVdes VARCHAR(5), @codMart VARCHAR(15),\n" +
|
||||
" @codMdep VARCHAR(5), @daysDiff INT)\n" +
|
||||
"/*Funzione che restituisce le ultime consegne effettuate per conto di un cliente con possibilitàdi filtrare per articolo/deposito.\n" +
|
||||
"Se il cliente non viene passato allora la funzione restituiràle ultime consegne di tutti i clienti. */\n" +
|
||||
" RETURNS TABLE AS RETURN\n" +
|
||||
" SELECT DISTINCT *\n" +
|
||||
" FROM (SELECT dtb_doct.cod_anag,\n" +
|
||||
" DENSE_RANK() OVER (PARTITION BY dtb_doct.cod_anag ORDER BY dtb_doct.cod_anag ASC, dtb_doct.data_doc DESC, dtb_doct.num_doc) AS counter_consegna,\n" +
|
||||
" dtb_doct.cod_dtip,\n" +
|
||||
" dtb_doct.data_doc,\n" +
|
||||
" dtb_doct.ser_doc,\n" +
|
||||
" dtb_doct.num_doc,\n" +
|
||||
" dtb_doct.compilato_da,\n" +
|
||||
" dtb_doct.rif_ord,\n" +
|
||||
" dtb_doct.data_ord,\n" +
|
||||
" vtb_dest.destinatario,\n" +
|
||||
" vtb_dest.indirizzo,\n" +
|
||||
" dtb_doct.data_iniz_trasp\n" +
|
||||
" FROM dtb_doct\n" +
|
||||
" INNER JOIN dtb_docr ON dtb_doct.cod_anag = dtb_docr.cod_anag AND\n" +
|
||||
" dtb_doct.cod_dtip = dtb_docr.cod_dtip AND\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc AND\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc AND\n" +
|
||||
" dtb_doct.ser_doc = dtb_docr.ser_doc\n" +
|
||||
" INNER JOIN dtb_tipi ON dtb_doct.cod_dtip = dtb_tipi.cod_dtip\n" +
|
||||
" LEFT OUTER JOIN vtb_dest\n" +
|
||||
" ON dtb_doct.cod_anag = vtb_dest.cod_anag\n" +
|
||||
" AND dtb_doct.cod_vdes = vtb_dest.cod_vdes\n" +
|
||||
"\n" +
|
||||
" WHERE dtb_doct.gestione = 'V'\n" +
|
||||
" AND dtb_tipi.tipo_emissione = 'DIRETTA'\n" +
|
||||
" AND dtb_tipi.segno_qta_scar = 1\n" +
|
||||
" AND DATEDIFF(DAY, dtb_doct.data_doc, GETDATE()) <= @daysDiff\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
" AND (@codMdep IS NULL\n" +
|
||||
" OR dtb_doct.cod_mdep = @codMdep)\n" +
|
||||
" AND (@codMart IS NULL\n" +
|
||||
" OR dtb_docr.cod_mart = @codMart)\n" +
|
||||
" AND (@codAnag IS NULL\n" +
|
||||
" OR dtb_doct.cod_anag = @codAnag)\n" +
|
||||
" AND (@codVdes IS NULL\n" +
|
||||
" OR dtb_doct.cod_vdes = @codVdes)) grouped_consegne\n" +
|
||||
" WHERE @numConsegnePerClie IS NULL\n" +
|
||||
" OR grouped_consegne.counter_consegna <= @numConsegnePerClie");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
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_20250728125101 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
String reportNameScar = null;
|
||||
String reportNameLav = null;
|
||||
|
||||
if (isCustomer(IntegryCustomer.RossoGargano)) {
|
||||
reportNameScar = "ReportScaricoProdotto";
|
||||
reportNameLav = "RiepilogoLavorazioniMateriaPrimaGrezza";
|
||||
}
|
||||
|
||||
createSetup("PVM","PIAN_ACC_ROSSG","REPORT_NAME_RIEP_SCARICO_PRODOTTO",reportNameScar,"Nome report stampa riepilogo scarico prodotti (da tab omonima in pagina accettazione da campo)","REPORT_NAME");
|
||||
createSetup("PVM","PIAN_ACC_ROSSG","REPORT_NAME_RIEP_LAV_MATERIALE",reportNameLav,"Nome report stampa riepilogo lavorazioni del giorno (da tab Laborazioni in pagina accettazione da campo)","REPORT_NAME");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
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.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250909162127 extends BaseMigration implements MigrationModelInterface {
|
||||
@@ -10,8 +10,7 @@ public class Migration_20250909162127 extends BaseMigration implements Migration
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isCustomerDb(IntegryCustomerDB.Biolevante_Biolevante))
|
||||
if (!isCustomer(IntegryCustomer.Biolevante))
|
||||
return;
|
||||
|
||||
executeStatement(
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250925103840 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
String sqlCreateMaster = "CREATE TABLE dbo.mtb_missione_mag_auto\n" +
|
||||
"(\n" +
|
||||
" id BIGINT IDENTITY\n" +
|
||||
" CONSTRAINT mtb_missione_mag_auto_pk\n" +
|
||||
" PRIMARY KEY,\n" +
|
||||
" cod_mdep VARCHAR(5) NOT NULL,\n" +
|
||||
" cod_area VARCHAR(15) NOT NULL,\n" +
|
||||
" CONSTRAINT table_name_mtb_depo_area_cod_area_cod_mdep_fk\n" +
|
||||
" FOREIGN KEY (cod_mdep, cod_area) REFERENCES dbo.mtb_depo_area (cod_mdep, cod_area),\n" +
|
||||
" created_by VARCHAR(40) NOT NULL\n" +
|
||||
" CONSTRAINT mtb_missione_mag_auto_stb_user_user_name_fk\n" +
|
||||
" REFERENCES dbo.stb_user,\n" +
|
||||
" created_at DATETIME DEFAULT GETDATE() NOT NULL\n" +
|
||||
")";
|
||||
|
||||
String sqlCreateDetail = "CREATE TABLE dbo.mtb_missione_mag_auto_det\n" +
|
||||
"(\n" +
|
||||
" id BIGINT IDENTITY\n" +
|
||||
" CONSTRAINT mtb_missione_mag_auto_det_pk\n" +
|
||||
" PRIMARY KEY,\n" +
|
||||
" parent_id BIGINT NOT NULL\n" +
|
||||
" CONSTRAINT mtb_missione_mag_auto_det_mtb_missione_mag_auto_id_fk\n" +
|
||||
" REFERENCES dbo.mtb_missione_mag_auto (id),\n" +
|
||||
" sscc VARCHAR(18),\n" +
|
||||
" posizione_in VARCHAR(40),\n" +
|
||||
" posizione_out VARCHAR(40),\n" +
|
||||
" error_message VARCHAR(MAX),\n" +
|
||||
" completed BIT DEFAULT 0 NOT NULL,\n" +
|
||||
" skipped BIT DEFAULT 0 NOT NULL,\n" +
|
||||
" started_at DATETIME,\n" +
|
||||
" ended_at DATETIME,\n" +
|
||||
" created_at DATETIME DEFAULT GETDATE(),\n" +
|
||||
" updated_at DATETIME DEFAULT GETDATE() NOT NULL\n" +
|
||||
")";
|
||||
|
||||
executeStatement(sqlCreateMaster, sqlCreateDetail);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -1,610 +0,0 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251015111701 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateFunction("MES_GetWorkOrders", "CREATE FUNCTION [dbo].[MES_GetWorkOrders](@codJfas VARCHAR(50), @dateStart DATE, @dateEnd DATE, @flagEvaso VARCHAR(1),\n" +
|
||||
" @codAnag VARCHAR(5))\n" +
|
||||
" RETURNS TABLE\n" +
|
||||
" AS RETURN\n" +
|
||||
" -- DECLARE @codJfas VARCHAR(5) = 'L1'\n" +
|
||||
" -- DECLARE @dateStart DATE = DATEADD(MONTH, -1, GETDATE())\n" +
|
||||
" -- DECLARE @dateEnd DATE = DATEADD(MONTH, 1, GETDATE())\n" +
|
||||
" -- DECLARE @flagEvaso VARCHAR(1) = 'I'\n" +
|
||||
" -- DECLARE @codAnag VARCHAR(5) = null;\n" +
|
||||
"\n" +
|
||||
"--Funzione per calcolare la sequenza di ordini su una linea e il RunTimeEND\n" +
|
||||
" WITH setup AS (SELECT ISNULL(@dateStart, DATEADD(DAY, -14, GETDATE())) AS date_start,\n" +
|
||||
" ISNULL(@dateEnd, GETDATE()) AS date_end,\n" +
|
||||
" ISNULL(@flagEvaso, 'I') AS flag_evaso,\n" +
|
||||
" @codJfas AS cod_jfas,\n" +
|
||||
" @codAnag AS cod_anag),\n" +
|
||||
"\n" +
|
||||
" setup_depo AS (SELECT cod_mdep, value AS flag_carico_scarico_immediato\n" +
|
||||
" FROM stb_gest_setup_depo\n" +
|
||||
" WHERE gest_name = 'CARICO_SCARICO_PF'\n" +
|
||||
" AND section = 'SETUP'\n" +
|
||||
" AND key_section = 'GENERA_CARICO_SCARICO_IMMEDIATO'),\n" +
|
||||
"\n" +
|
||||
" setup_run_time AS (SELECT value AS flag_restart\n" +
|
||||
" FROM stb_gest_setup\n" +
|
||||
" WHERE gest_name = 'PVM'\n" +
|
||||
" AND section = 'MONITORAGGIO_LINEE_V2'\n" +
|
||||
" AND key_section = 'RESTART_RUN_TIME_END'),\n" +
|
||||
"\n" +
|
||||
" mtb_colr_sum_filtered_rows AS (SELECT gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" ser_collo,\n" +
|
||||
" cod_mart,\n" +
|
||||
" data_ord,\n" +
|
||||
" num_ord,\n" +
|
||||
" qta_col,\n" +
|
||||
" num_cnf\n" +
|
||||
" FROM mtb_colr\n" +
|
||||
" WHERE gestione_rif IS NULL\n" +
|
||||
" AND data_collo_rif IS NULL\n" +
|
||||
" AND ser_collo_rif IS NULL\n" +
|
||||
" AND num_collo_rif IS NULL),\n" +
|
||||
"\n" +
|
||||
" mtb_colr_sum_valid_colli AS (SELECT DISTINCT gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" ser_collo,\n" +
|
||||
" num_collo\n" +
|
||||
" FROM mtb_colt\n" +
|
||||
" CROSS APPLY setup\n" +
|
||||
" WHERE segno = 1\n" +
|
||||
" AND data_ord BETWEEN setup.date_start AND setup.date_end),\n" +
|
||||
"\n" +
|
||||
" mtb_colr_sum AS (SELECT colr.gestione,\n" +
|
||||
" colr.data_collo,\n" +
|
||||
" colr.num_collo,\n" +
|
||||
" colr.ser_collo,\n" +
|
||||
" colr.cod_mart,\n" +
|
||||
" colr.data_ord,\n" +
|
||||
" colr.num_ord,\n" +
|
||||
" SUM(colr.qta_col) AS qta_col,\n" +
|
||||
" SUM(colr.num_cnf) AS num_cnf\n" +
|
||||
" FROM mtb_colr_sum_valid_colli colt\n" +
|
||||
" INNER JOIN mtb_colr_sum_filtered_rows colr\n" +
|
||||
" ON colr.gestione = colt.gestione\n" +
|
||||
" AND colr.data_collo = colt.data_collo\n" +
|
||||
" AND colr.num_collo = colt.num_collo\n" +
|
||||
" AND colr.ser_collo = colt.ser_collo\n" +
|
||||
" GROUP BY colr.gestione,\n" +
|
||||
" colr.data_collo,\n" +
|
||||
" colr.num_collo,\n" +
|
||||
" colr.ser_collo,\n" +
|
||||
" colr.cod_mart,\n" +
|
||||
" colr.data_ord,\n" +
|
||||
" colr.num_ord),\n" +
|
||||
"\n" +
|
||||
" machine_last_event AS (SELECT gestione,\n" +
|
||||
" data_ord,\n" +
|
||||
" num_ord,\n" +
|
||||
" cod_cmac,\n" +
|
||||
" MAX(data_mov) AS max_data_mov\n" +
|
||||
" FROM dtb_ord_macc\n" +
|
||||
" GROUP BY gestione, data_ord, num_ord, cod_cmac),\n" +
|
||||
"\n" +
|
||||
" machine_event_values AS (SELECT evento,\n" +
|
||||
" IIF(tipologia = 'ENTRATA', 1, -1) AS value\n" +
|
||||
" FROM dtb_ord_macc_eventi),\n" +
|
||||
"\n" +
|
||||
" in_production_machines AS (SELECT dtb.gestione,\n" +
|
||||
" dtb.data_ord,\n" +
|
||||
" dtb.num_ord,\n" +
|
||||
" LAST_VALUE(dtb.data_mov) OVER (ORDER BY dtb.gestione,\n" +
|
||||
" dtb.data_ord,\n" +
|
||||
" dtb.num_ord) AS max_data_mov,\n" +
|
||||
" LAST_VALUE(ev.value) OVER (ORDER BY dtb.gestione,\n" +
|
||||
" dtb.data_ord,\n" +
|
||||
" dtb.num_ord) AS final_value\n" +
|
||||
" FROM dtb_ord_macc dtb\n" +
|
||||
" INNER JOIN machine_last_event le\n" +
|
||||
" ON dtb.data_ord = le.data_ord\n" +
|
||||
" AND dtb.num_ord = le.num_ord\n" +
|
||||
" AND dtb.gestione = le.gestione\n" +
|
||||
" AND dtb.cod_cmac = le.cod_cmac\n" +
|
||||
" AND dtb.data_mov = le.max_data_mov\n" +
|
||||
" INNER JOIN machine_event_values ev\n" +
|
||||
" ON dtb.evento = ev.evento\n" +
|
||||
" CROSS APPLY setup\n" +
|
||||
" WHERE dtb.data_ord BETWEEN setup.date_start AND setup.date_end),\n" +
|
||||
"\n" +
|
||||
" dtb_ord_with_max_step AS (SELECT gestione,\n" +
|
||||
" data_ord,\n" +
|
||||
" num_ord,\n" +
|
||||
" id_step AS id_step,\n" +
|
||||
" MAX(id_step) OVER (PARTITION BY gestione,\n" +
|
||||
" data_ord,\n" +
|
||||
" num_ord,\n" +
|
||||
" dtb_ord_steps.cod_jfas,\n" +
|
||||
" dtb_ord_steps.num_fase) AS max_id_step,\n" +
|
||||
" num_fase,\n" +
|
||||
" MAX(num_fase) OVER (PARTITION BY gestione,\n" +
|
||||
" data_ord,\n" +
|
||||
" num_ord) AS max_fase,\n" +
|
||||
" dtb_ord_steps.cod_jfas,\n" +
|
||||
" dtb_ord_steps.flag_step_attivo,\n" +
|
||||
" dtb_ord_steps.data_iniz,\n" +
|
||||
" dtb_ord_steps.data_fine,\n" +
|
||||
" dtb_ord_steps.qta_lav,\n" +
|
||||
" dtb_ord_steps.qta_prod,\n" +
|
||||
" dtb_ord_steps.hr_num,\n" +
|
||||
" dtb_ord_steps.posizione_out,\n" +
|
||||
" dtb_ord_steps.descrizione_attivita,\n" +
|
||||
" SUM(CAST(DATEDIFF(S, data_iniz, ISNULL(data_fine, GETDATE())) AS BIGINT))\n" +
|
||||
" OVER (PARTITION BY gestione,\n" +
|
||||
" data_ord,\n" +
|
||||
" num_ord,\n" +
|
||||
" num_fase,\n" +
|
||||
" dtb_ord_steps.cod_jfas) AS elapsed_time\n" +
|
||||
" FROM dtb_ord_steps\n" +
|
||||
" CROSS APPLY setup\n" +
|
||||
" WHERE data_ord BETWEEN setup.date_start AND setup.date_end\n" +
|
||||
" AND gestione = 'L'),\n" +
|
||||
"\n" +
|
||||
" dtb_ord_max_step AS (SELECT DISTINCT IIF(in_production_machines.max_data_mov IS NOT NULL AND\n" +
|
||||
" (dtb_ord_with_max_step.id_step = 0 OR\n" +
|
||||
" (dtb_ord_with_max_step.id_step > 0 AND\n" +
|
||||
" dtb_ord_with_max_step.data_fine IS NOT NULL AND\n" +
|
||||
" DATEDIFF(MINUTE,\n" +
|
||||
" dtb_ord_with_max_step.data_fine,\n" +
|
||||
" in_production_machines.max_data_mov) >\n" +
|
||||
" 5)), 1, 0) AS starting_machines,\n" +
|
||||
" dtb_ord_with_max_step.*\n" +
|
||||
" FROM dtb_ord_with_max_step\n" +
|
||||
" LEFT OUTER JOIN in_production_machines\n" +
|
||||
" ON dtb_ord_with_max_step.data_ord =\n" +
|
||||
" in_production_machines.data_ord\n" +
|
||||
" AND\n" +
|
||||
" dtb_ord_with_max_step.num_ord =\n" +
|
||||
" in_production_machines.num_ord\n" +
|
||||
" AND\n" +
|
||||
" dtb_ord_with_max_step.gestione =\n" +
|
||||
" in_production_machines.gestione\n" +
|
||||
" AND in_production_machines.final_value = 1\n" +
|
||||
"\n" +
|
||||
" WHERE max_id_step = id_step),\n" +
|
||||
"\n" +
|
||||
" riga_ord_prod_w_materia_prima AS (SELECT dtb_ordr.data_ord AS data_ord_prod,\n" +
|
||||
" dtb_ordr.num_ord AS num_ord_prod,\n" +
|
||||
" dtb_ordr.riga_ord AS riga_ord_prod,\n" +
|
||||
" dtb_ordr.gestione AS gestione_ord_prod,\n" +
|
||||
" IIF(CONVERT(DATE, dtb_ordr.data_ord) >= CONVERT(DATE, GETDATE()),\n" +
|
||||
" 'S',\n" +
|
||||
" 'N') AS flag_avviabile,\n" +
|
||||
" mtb_aart_prod.flag_tracciabilita,\n" +
|
||||
" dtb_ordr.unt_ord,\n" +
|
||||
" dtb_ordr.rap_conv,\n" +
|
||||
" dtb_ordr.unt_ord2,\n" +
|
||||
" CAST(ROUND(dtb_ordr.qta_ord2 /\n" +
|
||||
" ISNULL(NULLIF(dtb_ordr.qta_ord, 0), 1),\n" +
|
||||
" 5) AS NUMERIC(20, 5)) AS rap_conv2,\n" +
|
||||
" dtb_ordr.unt_ord3,\n" +
|
||||
" CAST(ROUND(dtb_ordr.qta_ord3 /\n" +
|
||||
" ISNULL(NULLIF(dtb_ordr.qta_ord, 0), 1),\n" +
|
||||
" 5) AS NUMERIC(20, 5)) AS rap_conv3,\n" +
|
||||
" dtb_ordr.qta_ord,\n" +
|
||||
" dtb_ordr.qta_ord2,\n" +
|
||||
" dtb_ordr.qta_ord3,\n" +
|
||||
" dtb_ordr.num_cnf,\n" +
|
||||
" IIF(mtb_aart_prod.unt_mis IN ('PZ', 'NR'), mtb_aart_prod.qta_cnf,\n" +
|
||||
" IIF(mtb_aart_prod.unt_mis2 IN ('PZ', 'NR'),\n" +
|
||||
" mtb_aart_prod.qta_cnf /\n" +
|
||||
" ISNULL(NULLIF(mtb_aart_prod.rap_conv2, 0), 1),\n" +
|
||||
" mtb_aart_prod.qta_cnf)) AS cal_qta_cnf,\n" +
|
||||
" IIF(dtb_ordr.colli_pedana = 0 OR dtb_ordr.colli_pedana = 1,\n" +
|
||||
" IIF(mtb_aart_prod.colli_pedana = 0, 1, mtb_aart_prod.colli_pedana),\n" +
|
||||
" dtb_ordr.colli_pedana)\n" +
|
||||
" AS colli_pedana,\n" +
|
||||
" dtb_ordr.pos_riga,\n" +
|
||||
" dtb_ordr.cod_mdep,\n" +
|
||||
"\n" +
|
||||
" IIF(mtb_aart_prod.unt_mis IN ('PZ', 'NR'), 1,\n" +
|
||||
" IIF(mtb_aart_prod.unt_mis2 IN ('PZ', 'NR') AND\n" +
|
||||
" NULLIF(mtb_aart_prod.rap_conv2, 0) IS NOT NULL,\n" +
|
||||
" mtb_aart_prod.rap_conv2,\n" +
|
||||
" 1)) AS calc_rap_conv,\n" +
|
||||
" mtb_aart_prod.gg_scad_partita,\n" +
|
||||
" mtb_aart_prod.qta_cnf\n" +
|
||||
" FROM dtb_ordr\n" +
|
||||
" INNER JOIN mtb_aart mtb_aart_prod ON mtb_aart_prod.cod_mart = dtb_ordr.cod_mart\n" +
|
||||
" WHERE dtb_ordr.gestione = 'A'),\n" +
|
||||
"\n" +
|
||||
" ord_lav AS (SELECT dtb_ordt.cod_jcom,\n" +
|
||||
" riga_ord_prod_w_materia_prima.data_ord_prod,\n" +
|
||||
" riga_ord_prod_w_materia_prima.num_ord_prod,\n" +
|
||||
" riga_ord_prod_w_materia_prima.riga_ord_prod,\n" +
|
||||
" riga_ord_prod_w_materia_prima.flag_avviabile,\n" +
|
||||
" riga_ord_prod_w_materia_prima.flag_tracciabilita,\n" +
|
||||
" riga_ord_prod_w_materia_prima.unt_ord,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_partita_mag.partita_mag IS NULL THEN\n" +
|
||||
" riga_ord_prod_w_materia_prima.rap_conv\n" +
|
||||
" ELSE CASE\n" +
|
||||
" WHEN riga_ord_prod_w_materia_prima.unt_ord = mtb_aart.unt_mis THEN\n" +
|
||||
" riga_ord_prod_w_materia_prima.rap_conv\n" +
|
||||
" WHEN riga_ord_prod_w_materia_prima.unt_ord = mtb_aart.unt_mis2 THEN\n" +
|
||||
" IIF(mtb_partita_mag.rap_conv2 IS NULL OR mtb_partita_mag.rap_conv2 = 0,\n" +
|
||||
" riga_ord_prod_w_materia_prima.rap_conv2, mtb_partita_mag.rap_conv2)\n" +
|
||||
" WHEN riga_ord_prod_w_materia_prima.unt_ord = mtb_aart.unt_mis3 THEN\n" +
|
||||
" IIF(mtb_partita_mag.rap_conv3 IS NULL OR mtb_partita_mag.rap_conv3 = 0,\n" +
|
||||
" riga_ord_prod_w_materia_prima.rap_conv3, mtb_partita_mag.rap_conv3)\n" +
|
||||
" END\n" +
|
||||
" END\n" +
|
||||
" AS rap_conv,\n" +
|
||||
" riga_ord_prod_w_materia_prima.unt_ord2,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_partita_mag.partita_mag IS NULL THEN\n" +
|
||||
" riga_ord_prod_w_materia_prima.rap_conv2\n" +
|
||||
" ELSE CASE\n" +
|
||||
" WHEN riga_ord_prod_w_materia_prima.unt_ord2 = mtb_aart.unt_mis THEN\n" +
|
||||
" riga_ord_prod_w_materia_prima.rap_conv2\n" +
|
||||
" WHEN riga_ord_prod_w_materia_prima.unt_ord2 = mtb_aart.unt_mis2 THEN\n" +
|
||||
" IIF(mtb_partita_mag.rap_conv2 IS NULL OR mtb_partita_mag.rap_conv2 = 0,\n" +
|
||||
" riga_ord_prod_w_materia_prima.rap_conv2, mtb_partita_mag.rap_conv2)\n" +
|
||||
" WHEN riga_ord_prod_w_materia_prima.unt_ord2 = mtb_aart.unt_mis3 THEN\n" +
|
||||
" IIF(mtb_partita_mag.rap_conv3 IS NULL OR mtb_partita_mag.rap_conv3 = 0,\n" +
|
||||
" riga_ord_prod_w_materia_prima.rap_conv3, mtb_partita_mag.rap_conv3)\n" +
|
||||
" END\n" +
|
||||
" END\n" +
|
||||
" AS rap_conv2,\n" +
|
||||
" riga_ord_prod_w_materia_prima.unt_ord3,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_partita_mag.partita_mag IS NULL THEN\n" +
|
||||
" riga_ord_prod_w_materia_prima.rap_conv3\n" +
|
||||
" ELSE CASE\n" +
|
||||
" WHEN riga_ord_prod_w_materia_prima.unt_ord3 = mtb_aart.unt_mis THEN\n" +
|
||||
" riga_ord_prod_w_materia_prima.rap_conv3\n" +
|
||||
" WHEN riga_ord_prod_w_materia_prima.unt_ord3 = mtb_aart.unt_mis2 THEN\n" +
|
||||
" IIF(mtb_partita_mag.rap_conv2 IS NULL OR mtb_partita_mag.rap_conv2 = 0,\n" +
|
||||
" riga_ord_prod_w_materia_prima.rap_conv2, mtb_partita_mag.rap_conv2)\n" +
|
||||
" WHEN riga_ord_prod_w_materia_prima.unt_ord3 = mtb_aart.unt_mis3 THEN\n" +
|
||||
" IIF(mtb_partita_mag.rap_conv3 IS NULL OR mtb_partita_mag.rap_conv3 = 0,\n" +
|
||||
" riga_ord_prod_w_materia_prima.rap_conv3, mtb_partita_mag.rap_conv3)\n" +
|
||||
" END\n" +
|
||||
" END\n" +
|
||||
" AS rap_conv3,\n" +
|
||||
" ISNULL(dtb_ordt.descr_estesa_prod, dtb_ordt.descrizione_prod) AS descrizione_prod,\n" +
|
||||
" riga_ord_prod_w_materia_prima.num_cnf *\n" +
|
||||
" riga_ord_prod_w_materia_prima.cal_qta_cnf AS num_pezzi,\n" +
|
||||
" riga_ord_prod_w_materia_prima.num_cnf,\n" +
|
||||
" riga_ord_prod_w_materia_prima.gg_scad_partita,\n" +
|
||||
" riga_ord_prod_w_materia_prima.qta_cnf,\n" +
|
||||
" riga_ord_prod_w_materia_prima.colli_pedana,\n" +
|
||||
" riga_ord_prod_w_materia_prima.num_cnf /\n" +
|
||||
" riga_ord_prod_w_materia_prima.colli_pedana AS num_pedane,\n" +
|
||||
" riga_ord_prod_w_materia_prima.pos_riga,\n" +
|
||||
" dtb_ordt.flag_evaso_prod,\n" +
|
||||
" dtb_ordt.flag_evaso_forzato,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN (dtb_ordt.flag_evaso_prod = 'I' OR\n" +
|
||||
" (setupCaricoImmediato.flag_carico_scarico_immediato = 'S' AND\n" +
|
||||
" flag_evaso_prod = 'E'))\n" +
|
||||
" AND dtb_ordt.flag_evaso_forzato = 'N'\n" +
|
||||
" THEN 'I'\n" +
|
||||
" WHEN flag_evaso_prod <> 'I' AND dtb_ordt.flag_evaso_forzato = 'S'\n" +
|
||||
" THEN flag_evaso_prod\n" +
|
||||
" END AS flag_ordine_evaso,\n" +
|
||||
" dtb_ordt.gestione,\n" +
|
||||
" dtb_ordt.data_ord,\n" +
|
||||
" dtb_ordt.cod_tcol_UL,\n" +
|
||||
" mtb_tcol.descrizione AS descrizione_tcol,\n" +
|
||||
" dtb_ordt.cod_anag,\n" +
|
||||
" gtb_anag.rag_soc AS rag_soc_anag,\n" +
|
||||
" gtb_anag.part_iva,\n" +
|
||||
" dtb_ordt.rif_ord,\n" +
|
||||
" dtb_ordt.cod_vdes,\n" +
|
||||
" dtb_ordt.cod_mdep,\n" +
|
||||
" ISNULL(riga_ord_prod_w_materia_prima.cod_mdep, dtb_ordt.cod_mdep) AS cod_mdep_prod,\n" +
|
||||
" dtb_ordt.num_ord,\n" +
|
||||
" dtb_ord_steps.cod_jfas,\n" +
|
||||
" dtb_ordt.cod_jfas AS cod_jfas_lav,\n" +
|
||||
" mtb_partita_mag.partita_mag,\n" +
|
||||
" ISNULL(mtb_partita_mag.partita_mag_prod,\n" +
|
||||
" mtb_partita_mag.partita_mag) AS partita_mag_prod,\n" +
|
||||
" dtb_ordt.note AS note_lav,\n" +
|
||||
" mtb_partita_mag.data_scad,\n" +
|
||||
" dtb_ordt.cod_prod,\n" +
|
||||
" jtb_comt.descrizione AS descrizione_commessa,\n" +
|
||||
" dtb_ordt.data_iniz_prod,\n" +
|
||||
" dtb_ord_steps.id_step,\n" +
|
||||
" dtb_ord_steps.max_fase,\n" +
|
||||
" dtb_ord_steps.num_fase,\n" +
|
||||
" IIF(mtb_aart.flag_qta_cnf_fissa = 'S' AND\n" +
|
||||
" (mtb_aart.qta_cnf > 1 OR riga_ord_prod_w_materia_prima.colli_pedana > 1), 'Colli',\n" +
|
||||
" jtb_cicl.unt_mis_prod)\n" +
|
||||
" AS unt_mis_prod,\n" +
|
||||
" IIF(mtb_aart.flag_qta_cnf_fissa = 'S' AND\n" +
|
||||
" (mtb_aart.qta_cnf > 1 OR riga_ord_prod_w_materia_prima.colli_pedana > 1),\n" +
|
||||
" riga_ord_prod_w_materia_prima.colli_pedana, jtb_cicl.qta_prod)\n" +
|
||||
" AS qta_batch_prod,\n" +
|
||||
" IIF(mtb_aart.qta_cnf > 1 OR riga_ord_prod_w_materia_prima.colli_pedana > 1,\n" +
|
||||
" mtb_aart.qta_cnf,\n" +
|
||||
" jtb_cicl.rap_conv_prod) AS rap_conv_prod,\n" +
|
||||
" dtb_ord_steps.data_iniz,\n" +
|
||||
" dtb_ord_steps.data_fine,\n" +
|
||||
" dtb_ord_steps.qta_lav AS qta_lav,\n" +
|
||||
" IIF(dtb_ord_steps.qta_prod <> 0, dtb_ord_steps.qta_prod,\n" +
|
||||
" dtb_ordt.qta_prod) AS qta_prod,\n" +
|
||||
" dtb_ord_steps.hr_num,\n" +
|
||||
" dtb_ord_steps.descrizione_attivita,\n" +
|
||||
" dtb_ord_steps.posizione_out,\n" +
|
||||
" 3600 / (ISNULL(NULLIF(jtb_dist_clav_dir.duration, 0), 1) /\n" +
|
||||
" ISNULL(NULLIF(jtb_cicl.rap_conv_prod, 0), 1)) AS prod_std,\n" +
|
||||
" dtb_ord_steps.elapsed_time,\n" +
|
||||
" SUM(ISNULL(mtb_colr_carico.qta_col, 0)) AS qta_trasferite,\n" +
|
||||
" COUNT(mtb_colr_carico.num_collo) AS udc_trasferiti,\n" +
|
||||
" COUNT(colli_lotto.num_collo) AS uds_scaricati,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN dtb_ord_steps.id_step = 0\n" +
|
||||
" THEN IIF(dtb_ord_steps.starting_machines = 1, 'IN AVVIO', 'PROGRAMMATO')\n" +
|
||||
" WHEN dtb_ord_steps.data_fine IS NULL\n" +
|
||||
" THEN 'IN CORSO'\n" +
|
||||
" ELSE 'IN PAUSA'\n" +
|
||||
" END AS stato,\n" +
|
||||
" CONVERT(INT, SUM(ISNULL(\n" +
|
||||
" mtb_colr_carico.qta_col / riga_ord_prod_w_materia_prima.calc_rap_conv,\n" +
|
||||
" 0))) AS pz_trasferiti,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN (jtb_dist_clav_dir.duration / ISNULL(NULLIF(jtb_cicl.rap_conv_prod, 0), 1)) *\n" +
|
||||
" (dtb_ordt.qta_prod * dtb_ordt.rap_conv_prod -\n" +
|
||||
" SUM(ISNULL(mtb_colr_carico.qta_col, 0))) > 0\n" +
|
||||
" THEN\n" +
|
||||
" (jtb_dist_clav_dir.duration /\n" +
|
||||
" ISNULL(NULLIF(jtb_cicl.rap_conv_prod, 0), 1)) *\n" +
|
||||
" (dtb_ordt.qta_prod * dtb_ordt.rap_conv_prod -\n" +
|
||||
" SUM(ISNULL(mtb_colr_carico.qta_col, 0)))\n" +
|
||||
" ELSE 0 END AS run_time_sec,\n" +
|
||||
" jl.id_lotto,\n" +
|
||||
" jlt.data_lotto,\n" +
|
||||
" mtb_aart.peso_kg,\n" +
|
||||
" dtb_ordt.data_cons_prod_max\n" +
|
||||
" FROM dtb_ord_max_step dtb_ord_steps\n" +
|
||||
" INNER JOIN dtb_ordt ON dtb_ord_steps.data_ord = dtb_ordt.data_ord\n" +
|
||||
" AND dtb_ord_steps.num_ord = dtb_ordt.num_ord\n" +
|
||||
" AND dtb_ord_steps.gestione = dtb_ordt.gestione\n" +
|
||||
" LEFT OUTER JOIN setup_depo setupCaricoImmediato\n" +
|
||||
" ON dtb_ordt.cod_mdep = setupCaricoImmediato.cod_mdep\n" +
|
||||
" LEFT OUTER JOIN jtb_dist_clav_dir\n" +
|
||||
" ON dtb_ordt.cod_prod = jtb_dist_clav_dir.cod_prod AND\n" +
|
||||
" dtb_ordt.cod_jfas = jtb_dist_clav_dir.cod_jfas\n" +
|
||||
" LEFT OUTER JOIN mtb_partita_mag\n" +
|
||||
" ON dtb_ordt.partita_mag = mtb_partita_mag.partita_mag AND\n" +
|
||||
" dtb_ordt.cod_prod = mtb_partita_mag.cod_mart AND\n" +
|
||||
" mtb_partita_mag.flag_stato = 'A'\n" +
|
||||
" LEFT OUTER JOIN mtb_colr_sum mtb_colr_carico\n" +
|
||||
" ON dtb_ordt.data_ord = mtb_colr_carico.data_ord AND\n" +
|
||||
" dtb_ordt.gestione = mtb_colr_carico.gestione AND\n" +
|
||||
" dtb_ordt.num_ord = mtb_colr_carico.num_ord AND\n" +
|
||||
" dtb_ordt.cod_prod = mtb_colr_carico.cod_mart\n" +
|
||||
" LEFT OUTER JOIN jtb_comt ON dtb_ordt.cod_jcom = jtb_comt.cod_jcom\n" +
|
||||
" LEFT OUTER JOIN riga_ord_prod_w_materia_prima\n" +
|
||||
" ON riga_ord_prod_w_materia_prima.gestione_ord_prod =\n" +
|
||||
" dtb_ordt.gestione_rif AND\n" +
|
||||
" riga_ord_prod_w_materia_prima.data_ord_prod =\n" +
|
||||
" dtb_ordt.data_ord_rif AND\n" +
|
||||
" riga_ord_prod_w_materia_prima.num_ord_prod =\n" +
|
||||
" dtb_ordt.num_ord_rif AND\n" +
|
||||
" riga_ord_prod_w_materia_prima.riga_ord_prod = dtb_ordt.riga_ord_rif\n" +
|
||||
" LEFT OUTER JOIN jtb_cicl ON jtb_cicl.cod_prod = dtb_ordt.cod_prod\n" +
|
||||
" LEFT OUTER JOIN mtb_aart ON mtb_aart.cod_mart = dtb_ordt.cod_prod\n" +
|
||||
" LEFT OUTER JOIN gtb_anag ON dtb_ordt.cod_anag = gtb_anag.cod_anag\n" +
|
||||
" LEFT OUTER JOIN mtb_tcol ON dtb_ordt.cod_tcol_UL = mtb_tcol.cod_tcol\n" +
|
||||
" LEFT OUTER JOIN jtb_lotr jl\n" +
|
||||
" ON dtb_ord_steps.cod_jfas = jl.cod_jfas AND\n" +
|
||||
" dtb_ordt.gestione = jl.gestione AND\n" +
|
||||
" dtb_ordt.data_ord = jl.data_ord AND\n" +
|
||||
" dtb_ordt.num_ord = jl.num_ord\n" +
|
||||
" LEFT OUTER JOIN jtb_lott jlt\n" +
|
||||
" ON jl.cod_jfas = jlt.cod_jfas AND jl.id_lotto = jlt.id_lotto\n" +
|
||||
" LEFT OUTER JOIN mtb_colt colli_lotto ON jlt.id_lotto = colli_lotto.id_lotto\n" +
|
||||
"\n" +
|
||||
" CROSS APPLY setup\n" +
|
||||
" WHERE dtb_ordt.flag_annulla = 'N'\n" +
|
||||
" AND dtb_ord_steps.data_ord BETWEEN setup.date_start AND setup.date_end\n" +
|
||||
" AND (setup.flag_evaso IS NULL\n" +
|
||||
" OR (\n" +
|
||||
" (setup.flag_evaso = 'I'\n" +
|
||||
" AND\n" +
|
||||
" dtb_ord_steps.flag_step_attivo = 'S'\n" +
|
||||
" AND (flag_evaso_prod = 'I'\n" +
|
||||
" OR\n" +
|
||||
" (setupCaricoImmediato.flag_carico_scarico_immediato = 'S'\n" +
|
||||
" AND\n" +
|
||||
" flag_evaso_prod = 'E'))\n" +
|
||||
" AND dtb_ordt.flag_evaso_forzato = 'N'\n" +
|
||||
" )\n" +
|
||||
" OR (setup.flag_evaso = 'E'\n" +
|
||||
" AND (flag_evaso_prod = 'E' OR jlt.data_chiusura IS NOT NULL)\n" +
|
||||
" AND dtb_ordt.flag_evaso_forzato = 'S')\n" +
|
||||
" )\n" +
|
||||
" )\n" +
|
||||
" AND (setup.cod_jfas IS NULL\n" +
|
||||
" OR dtb_ord_steps.cod_jfas = setup.cod_jfas)\n" +
|
||||
" AND (setup.cod_anag IS NULL\n" +
|
||||
" OR dtb_ordt.cod_anag = setup.cod_anag)\n" +
|
||||
" GROUP BY riga_ord_prod_w_materia_prima.data_ord_prod,\n" +
|
||||
" riga_ord_prod_w_materia_prima.num_ord_prod,\n" +
|
||||
" riga_ord_prod_w_materia_prima.riga_ord_prod,\n" +
|
||||
" riga_ord_prod_w_materia_prima.flag_avviabile,\n" +
|
||||
" riga_ord_prod_w_materia_prima.flag_tracciabilita,\n" +
|
||||
" riga_ord_prod_w_materia_prima.unt_ord,\n" +
|
||||
" mtb_partita_mag.rap_conv2,\n" +
|
||||
" mtb_partita_mag.rap_conv3,\n" +
|
||||
" dtb_ordt.note,\n" +
|
||||
" riga_ord_prod_w_materia_prima.rap_conv,\n" +
|
||||
" dtb_ordt.descrizione_prod,\n" +
|
||||
" dtb_ordt.descr_estesa_prod,\n" +
|
||||
" riga_ord_prod_w_materia_prima.num_cnf,\n" +
|
||||
" mtb_aart.qta_cnf,\n" +
|
||||
" mtb_aart.gg_scad_partita,\n" +
|
||||
" mtb_aart.flag_qta_cnf_fissa,\n" +
|
||||
" riga_ord_prod_w_materia_prima.pos_riga,\n" +
|
||||
" dtb_ordt.flag_evaso_prod,\n" +
|
||||
" dtb_ordt.flag_evaso_forzato,\n" +
|
||||
" dtb_ordt.gestione,\n" +
|
||||
" dtb_ordt.data_ord,\n" +
|
||||
" dtb_ordt.num_ord,\n" +
|
||||
" dtb_ord_steps.cod_jfas,\n" +
|
||||
" dtb_ordt.cod_jfas,\n" +
|
||||
" dtb_ordt.cod_jcom,\n" +
|
||||
" mtb_partita_mag.partita_mag,\n" +
|
||||
" mtb_partita_mag.partita_mag_prod,\n" +
|
||||
" mtb_partita_mag.data_scad,\n" +
|
||||
" dtb_ordt.cod_prod,\n" +
|
||||
" dtb_ordt.data_iniz_prod,\n" +
|
||||
" dtb_ord_steps.id_step,\n" +
|
||||
" dtb_ord_steps.data_iniz,\n" +
|
||||
" dtb_ord_steps.data_fine,\n" +
|
||||
" dtb_ordt.cod_tcol_UL,\n" +
|
||||
" dtb_ordt.cod_anag,\n" +
|
||||
" gtb_anag.rag_soc,\n" +
|
||||
" gtb_anag.part_iva,\n" +
|
||||
" dtb_ordt.rif_ord,\n" +
|
||||
" dtb_ordt.cod_vdes,\n" +
|
||||
" dtb_ordt.cod_mdep,\n" +
|
||||
" riga_ord_prod_w_materia_prima.cod_mdep,\n" +
|
||||
" mtb_aart.colli_pedana,\n" +
|
||||
" dtb_ord_steps.qta_prod,\n" +
|
||||
" dtb_ordt.qta_prod,\n" +
|
||||
" jtb_dist_clav_dir.duration,\n" +
|
||||
" jtb_comt.descrizione,\n" +
|
||||
" dtb_ord_steps.elapsed_time,\n" +
|
||||
" riga_ord_prod_w_materia_prima.colli_pedana,\n" +
|
||||
" dtb_ord_steps.hr_num,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" mtb_aart.unt_mis2,\n" +
|
||||
" mtb_aart.rap_conv2,\n" +
|
||||
" mtb_aart.unt_mis3,\n" +
|
||||
" mtb_aart.rap_conv3,\n" +
|
||||
" riga_ord_prod_w_materia_prima.unt_ord2,\n" +
|
||||
" riga_ord_prod_w_materia_prima.unt_ord3,\n" +
|
||||
" riga_ord_prod_w_materia_prima.qta_ord,\n" +
|
||||
" riga_ord_prod_w_materia_prima.qta_ord2,\n" +
|
||||
" riga_ord_prod_w_materia_prima.qta_ord3,\n" +
|
||||
" riga_ord_prod_w_materia_prima.rap_conv2,\n" +
|
||||
" riga_ord_prod_w_materia_prima.rap_conv3,\n" +
|
||||
" riga_ord_prod_w_materia_prima.qta_cnf,\n" +
|
||||
" riga_ord_prod_w_materia_prima.cal_qta_cnf,\n" +
|
||||
" riga_ord_prod_w_materia_prima.gg_scad_partita,\n" +
|
||||
" jtb_cicl.qta_prod,\n" +
|
||||
" jtb_cicl.rap_conv_prod,\n" +
|
||||
" dtb_ord_steps.descrizione_attivita,\n" +
|
||||
" dtb_ord_steps.posizione_out,\n" +
|
||||
" jtb_cicl.unt_mis_prod,\n" +
|
||||
" mtb_tcol.descrizione,\n" +
|
||||
" dtb_ordt.qta_prod,\n" +
|
||||
" dtb_ordt.rap_conv_prod,\n" +
|
||||
" setupCaricoImmediato.flag_carico_scarico_immediato,\n" +
|
||||
" dtb_ord_steps.num_fase, dtb_ord_steps.qta_lav,\n" +
|
||||
" jl.id_lotto, jlt.data_lotto, mtb_aart.peso_kg, dtb_ordt.data_cons_prod_max,\n" +
|
||||
" dtb_ord_steps.id_step,\n" +
|
||||
" dtb_ord_steps.max_fase,\n" +
|
||||
" dtb_ord_steps.starting_machines)\n" +
|
||||
" SELECT ROW_NUMBER() OVER (ORDER BY data_ord, num_ord_prod, pos_riga, num_ord) AS sort,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" data_ord_prod,\n" +
|
||||
" num_ord_prod,\n" +
|
||||
" riga_ord_prod,\n" +
|
||||
" flag_avviabile,\n" +
|
||||
" flag_tracciabilita,\n" +
|
||||
" unt_ord,\n" +
|
||||
" rap_conv,\n" +
|
||||
" unt_ord2,\n" +
|
||||
" rap_conv2,\n" +
|
||||
" unt_ord3,\n" +
|
||||
" rap_conv3,\n" +
|
||||
" descrizione_prod,\n" +
|
||||
" num_pezzi,\n" +
|
||||
" num_cnf,\n" +
|
||||
" gg_scad_partita,\n" +
|
||||
" qta_cnf,\n" +
|
||||
" colli_pedana,\n" +
|
||||
" num_pedane,\n" +
|
||||
" pos_riga,\n" +
|
||||
" flag_evaso_prod,\n" +
|
||||
" flag_evaso_forzato,\n" +
|
||||
" flag_ordine_evaso,\n" +
|
||||
" gestione,\n" +
|
||||
" data_ord,\n" +
|
||||
" cod_tcol_UL,\n" +
|
||||
" descrizione_tcol,\n" +
|
||||
" cod_anag,\n" +
|
||||
" rag_soc_anag,\n" +
|
||||
" part_iva,\n" +
|
||||
" rif_ord,\n" +
|
||||
" cod_vdes,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" cod_mdep_prod,\n" +
|
||||
" num_ord,\n" +
|
||||
" cod_jfas,\n" +
|
||||
" cod_jfas_lav,\n" +
|
||||
" partita_mag,\n" +
|
||||
" partita_mag_prod,\n" +
|
||||
" note_lav,\n" +
|
||||
" data_scad,\n" +
|
||||
" cod_prod,\n" +
|
||||
" descrizione_commessa,\n" +
|
||||
" data_iniz_prod,\n" +
|
||||
" id_step,\n" +
|
||||
" unt_mis_prod,\n" +
|
||||
" qta_batch_prod,\n" +
|
||||
" rap_conv_prod,\n" +
|
||||
" data_iniz,\n" +
|
||||
" data_fine,\n" +
|
||||
" qta_prod,\n" +
|
||||
" qta_lav,\n" +
|
||||
" max_fase,\n" +
|
||||
" num_fase,\n" +
|
||||
" hr_num,\n" +
|
||||
" descrizione_attivita,\n" +
|
||||
" posizione_out,\n" +
|
||||
" prod_std,\n" +
|
||||
" elapsed_time,\n" +
|
||||
" qta_trasferite,\n" +
|
||||
" udc_trasferiti,\n" +
|
||||
" uds_scaricati,\n" +
|
||||
" stato,\n" +
|
||||
" pz_trasferiti,\n" +
|
||||
" run_time_sec,\n" +
|
||||
" SUM(run_time_sec) OVER (PARTITION BY cod_jfas, data_ord_prod) AS cumulative_run_time_sec,\n" +
|
||||
" CONVERT(INT, run_time_sec / 3600) AS run_time_hour,\n" +
|
||||
" ROUND((run_time_sec / 3600 - CONVERT(INT, run_time_sec / 3600)) * 60, 0) AS run_time_min,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN setup_run_time.flag_restart = 'S' THEN\n" +
|
||||
" DATEADD(SECOND, SUM(run_time_sec)\n" +
|
||||
" OVER (PARTITION BY cod_jfas, data_ord_prod ORDER BY stato, cod_jfas, data_ord_prod, pos_riga ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),\n" +
|
||||
" CASE\n" +
|
||||
" WHEN (data_ord_prod > GETDATE() AND (data_iniz IS NULL OR data_fine IS NOT NULL))\n" +
|
||||
" THEN DATEADD(HH, 7, data_ord_prod)\n" +
|
||||
" ELSE GETDATE() END)\n" +
|
||||
" ELSE\n" +
|
||||
" DATEADD(SECOND, SUM(run_time_sec)\n" +
|
||||
" OVER (PARTITION BY cod_jfas ORDER BY stato, cod_jfas, data_ord_prod, num_ord_prod, pos_riga ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),\n" +
|
||||
" GETDATE())\n" +
|
||||
" END AS run_time_end,\n" +
|
||||
" id_lotto,\n" +
|
||||
" data_lotto,\n" +
|
||||
" peso_kg,\n" +
|
||||
" data_cons_prod_max\n" +
|
||||
" FROM ord_lav\n" +
|
||||
" CROSS APPLY setup_run_time");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,179 +0,0 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251015120629 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createOrUpdateView("mvw_sitart_udc_det_inventario", "CREATE VIEW [dbo].[mvw_sitart_udc_det_inventario] AS\n" +
|
||||
"WITH baseMtbColr AS (SELECT c,\n" +
|
||||
"\n" +
|
||||
" ROUND(v.qta_col, cifre_dec) AS qta_col,\n" +
|
||||
" ROUND(v.num_cnf, cifre_dec) AS num_cnf,\n" +
|
||||
" IIF(flag_qta_cnf_fissa = 'S',\n" +
|
||||
" v.qta_cnf_anag, v.qta_col / IIF(v.num_cnf = 0, 1, v.num_cnf)) AS qta_cnf,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" mtb_colt.gestione,\n" +
|
||||
" mtb_colt.data_collo,\n" +
|
||||
" mtb_colt.ser_collo,\n" +
|
||||
" mtb_colt.num_collo,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.cod_mgrp,\n" +
|
||||
" mtb_grup.descrizione AS descrizione_gruppo,\n" +
|
||||
" v.cod_msgr,\n" +
|
||||
" mtb_sgrp.descrizione AS descrizione_sottogruppo,\n" +
|
||||
" mtb_unt_mis.flag_dig,\n" +
|
||||
" mtb_unt_mis.cifre_dec,\n" +
|
||||
" mtb_colt.segno,\n" +
|
||||
" v.cod_mdep,\n" +
|
||||
" v.posizione,\n" +
|
||||
" mtb_colt.cod_dtip,\n" +
|
||||
" mtb_colt.cod_jfas,\n" +
|
||||
" v.barcode_ul,\n" +
|
||||
" v.qta_cnf_anag,\n" +
|
||||
" MAX(mtb_colr.datetime_row) AS datetime_posizionamento,\n" +
|
||||
" mtb_colt.progressivo_ul\n" +
|
||||
" FROM mvw_mtb_colr_with_giacenza v WITH (NOEXPAND)\n" +
|
||||
" INNER JOIN mtb_colt\n" +
|
||||
" ON v.barcode_ul = mtb_colt.barcode_ul\n" +
|
||||
" LEFT OUTER JOIN mtb_colr ON\n" +
|
||||
" v.barcode_ul = mtb_colr.barcode_ul_in AND\n" +
|
||||
" v.cod_mart = mtb_colr.cod_mart AND\n" +
|
||||
" ((v.partita_mag IS NULL AND mtb_colr.partita_mag IS NULL) OR\n" +
|
||||
" (v.partita_mag = mtb_colr.partita_mag)) AND\n" +
|
||||
" ((v.cod_col IS NULL AND mtb_colr.cod_col IS NULL) OR (v.cod_col = mtb_colr.cod_col)) AND\n" +
|
||||
" ((v.cod_tagl IS NULL AND mtb_colr.cod_tagl IS NULL) OR (v.cod_tagl = mtb_colr.cod_tagl)) AND\n" +
|
||||
" ((v.cod_jcom IS NULL AND mtb_colr.cod_jcom IS NULL) OR (v.cod_jcom = mtb_colr.cod_jcom)) AND\n" +
|
||||
" ((v.posizione IS NULL AND mtb_colr.posizione_in IS NULL) OR (v.posizione = mtb_colr.posizione_in)) AND\n" +
|
||||
" ((v.cod_mdep IS NULL AND mtb_colr.cod_mdep_in IS NULL) OR (v.cod_mdep = mtb_colr.cod_mdep_in)) AND\n" +
|
||||
" ISNULL(mtb_colr.posizione_in, '') <> ISNULL(mtb_colr.posizione_out, '')\n" +
|
||||
" INNER JOIN dbo.mtb_unt_mis ON v.unt_mis = mtb_unt_mis.unt_mis\n" +
|
||||
"\n" +
|
||||
" INNER JOIN dbo.mtb_grup ON v.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" INNER JOIN dbo.mtb_sgrp ON v.cod_mgrp = mtb_sgrp.cod_mgrp\n" +
|
||||
" AND v.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
" WHERE v.qta_col > 0\n" +
|
||||
" AND (segno = 1 OR (segno = -1 AND cod_dtip IS NULL AND mtb_colt.gestione = 'V'))\n" +
|
||||
" GROUP BY c,\n" +
|
||||
" ROUND(v.qta_col, cifre_dec),\n" +
|
||||
" ROUND(v.num_cnf, cifre_dec),\n" +
|
||||
" IIF(flag_qta_cnf_fissa = 'S',\n" +
|
||||
" v.qta_cnf_anag, v.qta_col / IIF(v.num_cnf = 0, 1, v.num_cnf)),\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" mtb_colt.gestione,\n" +
|
||||
" mtb_colt.data_collo,\n" +
|
||||
" mtb_colt.ser_collo,\n" +
|
||||
" mtb_colt.num_collo,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.cod_mgrp,\n" +
|
||||
" mtb_grup.descrizione,\n" +
|
||||
" v.cod_msgr,\n" +
|
||||
" mtb_sgrp.descrizione,\n" +
|
||||
" mtb_unt_mis.flag_dig,\n" +
|
||||
" mtb_unt_mis.cifre_dec,\n" +
|
||||
" mtb_colt.segno,\n" +
|
||||
" v.cod_mdep,\n" +
|
||||
" v.posizione,\n" +
|
||||
" mtb_colt.cod_dtip,\n" +
|
||||
" mtb_colt.cod_jfas,\n" +
|
||||
" v.barcode_ul,\n" +
|
||||
" v.qta_cnf_anag,\n" +
|
||||
" mtb_colt.progressivo_ul),\n" +
|
||||
" final_stock AS (SELECT v.qta_col,\n" +
|
||||
" v.num_cnf,\n" +
|
||||
" v.qta_cnf,\n" +
|
||||
" v.gestione,\n" +
|
||||
" v.data_collo,\n" +
|
||||
" v.ser_collo,\n" +
|
||||
" v.num_collo,\n" +
|
||||
" v.cod_mdep AS cod_mdep,\n" +
|
||||
" v.posizione AS posizione,\n" +
|
||||
" mtb_depo_posizioni.priorita,\n" +
|
||||
" v.cod_mgrp AS codGruppo,\n" +
|
||||
" v.descrizione_gruppo AS Gruppo,\n" +
|
||||
" v.cod_msgr AS CodSgruppo,\n" +
|
||||
" v.descrizione_sottogruppo AS Sottogruppo,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" v.cod_jfas,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.segno,\n" +
|
||||
" v.barcode_ul,\n" +
|
||||
" v.datetime_posizionamento,\n" +
|
||||
" v.progressivo_ul\n" +
|
||||
" FROM baseMtbColr v\n" +
|
||||
"\n" +
|
||||
" LEFT OUTER JOIN mtb_depo_posizioni\n" +
|
||||
" ON v.cod_mdep = mtb_depo_posizioni.cod_mdep\n" +
|
||||
" AND v.posizione = mtb_depo_posizioni.posizione)\n" +
|
||||
"\n" +
|
||||
"SELECT qta_col,\n" +
|
||||
" num_cnf,\n" +
|
||||
" qta_cnf,\n" +
|
||||
" gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" ser_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" posizione,\n" +
|
||||
" priorita,\n" +
|
||||
" codGruppo,\n" +
|
||||
" Gruppo,\n" +
|
||||
" CodSgruppo,\n" +
|
||||
" Sottogruppo,\n" +
|
||||
" cod_mart,\n" +
|
||||
" diacod,\n" +
|
||||
" descrizione_estesa,\n" +
|
||||
" partita_mag,\n" +
|
||||
" cod_col,\n" +
|
||||
" cod_tagl,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" peso_netto_kg,\n" +
|
||||
" peso_lordo_kg,\n" +
|
||||
" cod_jfas,\n" +
|
||||
" flag_qta_cnf_fissa,\n" +
|
||||
" unt_mis,\n" +
|
||||
" segno,\n" +
|
||||
" barcode_ul,\n" +
|
||||
" datetime_posizionamento,\n" +
|
||||
" progressivo_ul\n" +
|
||||
"FROM final_stock");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,186 +0,0 @@
|
||||
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_20251015152419 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
if (isCustomer(IntegryCustomer.Biolevante))
|
||||
createOrUpdateFunction("MPS_grid", "Create function dbo.MPS_grid(@timeBucket char(1) = 'W' )\n" +
|
||||
" RETURNS TABLE AS\n" +
|
||||
" RETURN\n" +
|
||||
" (\n" +
|
||||
" --@timeBucket D=giorno; W=settimana (default); M=Mese\n" +
|
||||
" with horizon as\n" +
|
||||
" (\n" +
|
||||
" select dateadd(day,-1,convert(date, getdate())) as t0_from, dateadd(day,-1,convert(date, getdate())) as t0_to,\n" +
|
||||
" dateadd(day, 0,convert(date, getdate())) as t1_from, \n" +
|
||||
" case @timeBucket \n" +
|
||||
" when 'D' then CONVERT(date, getdate())\n" +
|
||||
" when 'W' then DATEADD(DAY, 8 - DATEPART(WEEKDAY, GETDATE()), CAST(GETDATE() AS DATE)) \n" +
|
||||
" when 'M' then EOMonth(getdate())\n" +
|
||||
" end as t1_to,\n" +
|
||||
" case @timeBucket \n" +
|
||||
" when 'D' then dateadd(day,1,CONVERT(date, getdate()))\n" +
|
||||
" when 'W' then dateadd(DAY,1,DATEADD(DAY, 8 - DATEPART(WEEKDAY, GETDATE()), CAST(GETDATE() AS DATE)))\n" +
|
||||
" when 'M' then dateadd(day,1,EOMonth(getdate()))\n" +
|
||||
" end as t2_from,\n" +
|
||||
" case @timeBucket \n" +
|
||||
" when 'D' then dateadd(day,1,CONVERT(date, getdate()))\n" +
|
||||
" when 'W' then dateadd(WEEK,1,DATEADD(DAY, 8 - DATEPART(WEEKDAY, GETDATE()), CAST(GETDATE() AS DATE)))\n" +
|
||||
" when 'M' then dateadd(MONTH,1,EOMonth(getdate()))\n" +
|
||||
" end as t2_to,\n" +
|
||||
" case @timeBucket \n" +
|
||||
" when 'D' then dateadd(day,1,dateadd(day,1,CONVERT(date, getdate())))\n" +
|
||||
" when 'W' then dateadd(day,1,dateadd(WEEK,1,DATEADD(DAY, 8 - DATEPART(WEEKDAY, GETDATE()), CAST(GETDATE() AS DATE))))\n" +
|
||||
" when 'M' then dateadd(day,1,dateadd(MONTH,1,EOMonth(getdate())))\n" +
|
||||
" end as t3_from,\n" +
|
||||
" case @timeBucket \n" +
|
||||
" when 'D' then dateadd(day,2,CONVERT(date, getdate()))\n" +
|
||||
" when 'W' then dateadd(WEEK,2,DATEADD(DAY, 8 - DATEPART(WEEKDAY, GETDATE()), CAST(GETDATE() AS DATE)))\n" +
|
||||
" when 'M' then dateadd(MONTH,2,EOMonth(getdate()))\n" +
|
||||
" end as t3_to,\n" +
|
||||
" case @timeBucket \n" +
|
||||
" when 'D' then dateadd(day,3,CONVERT(date, getdate()))\n" +
|
||||
" when 'W' then dateadd(day,1,dateadd(WEEK,2,DATEADD(DAY, 8 - DATEPART(WEEKDAY, GETDATE()), CAST(GETDATE() AS DATE))))\n" +
|
||||
" when 'M' then dateadd(day,1,dateadd(MONTH,2,EOMonth(getdate())))\n" +
|
||||
" end as t4_from,\n" +
|
||||
" case @timeBucket \n" +
|
||||
" when 'D' then dateadd(day,3,CONVERT(date, getdate()))\n" +
|
||||
" when 'W' then dateadd(WEEK,3,DATEADD(DAY, 8 - DATEPART(WEEKDAY, GETDATE()), CAST(GETDATE() AS DATE)))\n" +
|
||||
" when 'M' then dateadd(MONTH,3,EOMonth(getdate()))\n" +
|
||||
" end as t4_to,\n" +
|
||||
" case @timeBucket \n" +
|
||||
" when 'D' then dateadd(day,4,CONVERT(date, getdate()))\n" +
|
||||
" when 'W' then dateadd(day,1,dateadd(WEEK,3,DATEADD(DAY, 8 - DATEPART(WEEKDAY, GETDATE()), CAST(GETDATE() AS DATE))))\n" +
|
||||
" when 'M' then dateadd(day,1,dateadd(MONTH,3,EOMonth(getdate())))\n" +
|
||||
" end as t5_from,\n" +
|
||||
" case @timeBucket \n" +
|
||||
" when 'D' then dateadd(day,4,CONVERT(date, getdate()))\n" +
|
||||
" when 'W' then dateadd(WEEK,4,DATEADD(DAY, 8 - DATEPART(WEEKDAY, GETDATE()), CAST(GETDATE() AS DATE)))\n" +
|
||||
" when 'M' then dateadd(MONTH,4,EOMonth(getdate()))\n" +
|
||||
" end as t5_to,\n" +
|
||||
" case @timeBucket \n" +
|
||||
" when 'D' then dateadd(day,5,CONVERT(date, getdate()))\n" +
|
||||
" when 'W' then dateadd(day,1,dateadd(WEEK,4,DATEADD(DAY, 8 - DATEPART(WEEKDAY, GETDATE()), CAST(GETDATE() AS DATE))))\n" +
|
||||
" when 'M' then dateadd(day,1,dateadd(MONTH,4,EOMonth(getdate())))\n" +
|
||||
" end as t6_from,\n" +
|
||||
" case @timeBucket \n" +
|
||||
" when 'D' then dateadd(day,5,CONVERT(date, getdate()))\n" +
|
||||
" when 'W' then dateadd(WEEK,5,DATEADD(DAY, 8 - DATEPART(WEEKDAY, GETDATE()), CAST(GETDATE() AS DATE)))\n" +
|
||||
" when 'M' then dateadd(MONTH,5,EOMonth(getdate()))\n" +
|
||||
" end as t6_to\n" +
|
||||
" ),\n" +
|
||||
"\n" +
|
||||
" AlberoDiCLassificazione as\n" +
|
||||
" --Albero classificazione Articoli personalizzato per Olio Levante, da sostituire con vista su database di AI per forecast con algoritmo Tuidi\n" +
|
||||
" (select distinct --mtb_aart.cod_mart, mtb_aart.descrizione, \n" +
|
||||
" mtb_aart.cod_mgrp + Replicate('_',3-len(mtb_aart.cod_mgrp))+\n" +
|
||||
" isNull(mtb_aart.cod_mstp,'0000')+\n" +
|
||||
" ISNULL(mtb_aart.cod_msfa,'') as hierarchy_code,\n" +
|
||||
" mtb_aart.cod_mgrp as level_1_code, mtb_grup.descrizione as level_1_description,\n" +
|
||||
" isNull(mtb_aart.cod_mstp,'000') as level_2_code, isNull(mtb_tipi.descrizione+' '+mtb_stip.descrizione,'000') as level_2_description,\n" +
|
||||
" mtb_aart.cod_msfa as level_3_code, mtb_sfam.descrizione as level_3_description\n" +
|
||||
" from mtb_aart inner join mtb_grup on mtb_aart.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" inner join mtb_sgrp on mtb_aart.cod_mgrp = mtb_sgrp.cod_mgrp and mtb_aart.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
" left outer join mtb_sfam on mtb_aart.cod_mgrp = mtb_sfam.cod_mgrp and mtb_aart.cod_msgr = mtb_sfam.cod_msgr and mtb_aart.cod_msfa = mtb_sfam.cod_msfa\n" +
|
||||
" left outer join mtb_tipi on mtb_aart.cod_mtip = mtb_tipi.cod_mtip\n" +
|
||||
" left outer join mtb_stip on mtb_aart.cod_mtip = mtb_stip.cod_mtip and mtb_aart.cod_mstp = mtb_stip.cod_mstp\n" +
|
||||
" \n" +
|
||||
" Where mtb_aart.cod_mgrp in ('AP','C','CO','S','SO','SOR') and mtb_aart.flag_stato = 'A'\n" +
|
||||
" )\n" +
|
||||
" ,\n" +
|
||||
" ArticoliRiclassificati as\n" +
|
||||
" (\n" +
|
||||
" --Vista Articoli personalizzata per Olio Levante, da sostituire con vista su database di AI per forecast con algoritmo Tuidi\n" +
|
||||
" select \n" +
|
||||
" cod_mart as art_code,\n" +
|
||||
" descrizione_estesa as description,\n" +
|
||||
" null as art_info,\n" +
|
||||
" marchio as brand,\n" +
|
||||
" bar_code as ean,\n" +
|
||||
" null as img_url,\n" +
|
||||
" gg_scad_partita as shelf_life,\n" +
|
||||
" unt_mis as uom_purchase,\n" +
|
||||
" unt_mis as uom_selling,\n" +
|
||||
" peso_kg as weight,\n" +
|
||||
" IIF(flag_stato='A',1,0) as status,\n" +
|
||||
" mtb_aart.cod_mgrp + Replicate('_',3-len(mtb_aart.cod_mgrp))+\n" +
|
||||
" isNull(mtb_aart.cod_mstp,'0000')+\n" +
|
||||
" ISNULL(mtb_aart.cod_msfa,'') as hierarchy_code\n" +
|
||||
" from mtb_aart inner join mtb_grup on mtb_aart.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" inner join mtb_sgrp on mtb_aart.cod_mgrp = mtb_sgrp.cod_mgrp and mtb_aart.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
" left outer join mtb_sfam on mtb_aart.cod_mgrp = mtb_sfam.cod_mgrp and mtb_aart.cod_msgr = mtb_sfam.cod_msgr and mtb_aart.cod_msfa = mtb_sfam.cod_msfa\n" +
|
||||
" left outer join mtb_tipi on mtb_aart.cod_mtip = mtb_tipi.cod_mtip\n" +
|
||||
" left outer join mtb_stip on mtb_aart.cod_mtip = mtb_stip.cod_mtip and mtb_aart.cod_mstp = mtb_stip.cod_mstp\n" +
|
||||
" where mtb_aart.cod_mgrp in ('AP','C','CO','S','SO','SOR') and mtb_aart.flag_stato = 'A'\n" +
|
||||
" ),\n" +
|
||||
"\n" +
|
||||
" forecast as\n" +
|
||||
" (\n" +
|
||||
" select 'FORECAST' as causale,\n" +
|
||||
" mtb_aart.cod_mgrp, mtb_aart.cod_msgr,\n" +
|
||||
" mtb_aart.cod_mart,\n" +
|
||||
" mtb_aart.descrizione,\n" +
|
||||
" dateadd(year, 1,vend.data_doc) as data_vend,\n" +
|
||||
" -vend.qtaVendUM1 as qtaPrevista,\n" +
|
||||
" null as partita_mag,\n" +
|
||||
" 0 as qta_progressiva,\n" +
|
||||
" null as gestione, null as data_ord, null as num_ord,\n" +
|
||||
" null as cod_mdep,\n" +
|
||||
" 'N' as isOrdTrasf,\n" +
|
||||
" 'N' as flag_sospeso,\n" +
|
||||
" null as stato_partita\n" +
|
||||
" \n" +
|
||||
" from OlapPPVendite vend inner join mtb_aart on vend.cod_prod = mtb_aart.cod_mart\n" +
|
||||
" where data_doc between dateadd(year, -1, CONVERT(date, getDate())) and \n" +
|
||||
" case @timeBucket\n" +
|
||||
" when 'D' then DATEADD(DAY,6,dateadd(year, -1, CONVERT(date, getDate())))\n" +
|
||||
" WHEN 'W' then DATEADD(week,6,dateadd(year, -1, CONVERT(date, getDate())))\n" +
|
||||
" WHEN 'M' then DATEADD(month,6,dateadd(year, -1, CONVERT(date, getDate())))\n" +
|
||||
" end\n" +
|
||||
" )\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
" SELECT clas.*, --mrp.cod_mart, mrp.descrizione,\n" +
|
||||
"\n" +
|
||||
" --inserire qui la riga del forecast\n" +
|
||||
" case when causale like 'FORECAST' then '1 - FORECAST'\n" +
|
||||
" when causale like '%GIACENZA%' then '3 - DISPONIBILITA'\n" +
|
||||
" when causale like '%ORD.VEND.%' then '2 - ORDINI VENDITA'\n" +
|
||||
" when causale like '%ORD.LAVORAZ.%' then '4 - ORDINI LAVORAZIONE' end as MPS_row,\n" +
|
||||
" case when causale like '%GIACENZA%' then mrp.qta else 0 end as bucket0,\n" +
|
||||
" case when (mrp.data_mrp < horizon.t1_from OR mrp.data_mrp between horizon.t1_from and horizon.t1_to) and causale not like '%GIACENZA%' then mrp.qta else 0 end as bucket1,\n" +
|
||||
" case when mrp.data_mrp between horizon.t2_from and horizon.t2_to then mrp.qta else 0 end as bucket2,\n" +
|
||||
" case when mrp.data_mrp between horizon.t3_from and horizon.t3_to then mrp.qta else 0 end as bucket3,\n" +
|
||||
" case when mrp.data_mrp between horizon.t4_from and horizon.t4_to then mrp.qta else 0 end as bucket4,\n" +
|
||||
" case when mrp.data_mrp between horizon.t5_from and horizon.t5_to then mrp.qta else 0 end as bucket5,\n" +
|
||||
" case when mrp.data_mrp between horizon.t6_from and horizon.t6_to then mrp.qta else 0 end as bucket6,\n" +
|
||||
" case when mrp.data_mrp > horizon.t6_to then mrp.qta else 0 end as bucketOver,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" mtb_aart.qta_cnf,\n" +
|
||||
" isNull(jtb_cicl.lotto_min_ord, mtb_aart.qta_cnf*mtb_aart.colli_pedana) as LotSize,\n" +
|
||||
" mrp.*\n" +
|
||||
" FROM (\n" +
|
||||
" select * from [dbo].[MRP_DailyMaterialReq] () \n" +
|
||||
" union\n" +
|
||||
" select * from forecast\n" +
|
||||
" )\n" +
|
||||
" \n" +
|
||||
" mrp inner join ArticoliRiclassificati art on mrp.cod_mart = art.art_code\n" +
|
||||
" inner join AlberoDiCLassificazione clas on art.hierarchy_code = clas.hierarchy_code\n" +
|
||||
" inner join horizon on mrp.data_mrp >= horizon.t0_from\n" +
|
||||
" inner join mtb_aart on mrp.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" left outer join jtb_cicl on mrp.cod_mart = jtb_cicl.cod_mart\n" +
|
||||
" )");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
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_20251020113516 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createOrUpdateView("MPS_albero_classificazione","create view MPS_albero_classificazione as\n" +
|
||||
"select distinct mtb_aart.cod_mart, mtb_aart.descrizione,\n" +
|
||||
" mtb_aart.cod_mgrp + Replicate('_', 3 - len(mtb_aart.cod_mgrp)) +\n" +
|
||||
" isNull(mtb_aart.cod_mstp, '0000') +\n" +
|
||||
" ISNULL(mtb_aart.cod_msfa, '') as hierarchy_code,\n" +
|
||||
" mtb_aart.cod_mgrp as level_1_code,\n" +
|
||||
" mtb_grup.descrizione as level_1_description,\n" +
|
||||
" isNull(mtb_aart.cod_mstp, '000') as level_2_code,\n" +
|
||||
" isNull(mtb_tipi.descrizione + ' ' + mtb_stip.descrizione, '000') as level_2_description,\n" +
|
||||
" mtb_aart.cod_msfa as level_3_code,\n" +
|
||||
" mtb_sfam.descrizione as level_3_description\n" +
|
||||
"from mtb_aart\n" +
|
||||
" inner join mtb_grup on mtb_aart.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" inner join mtb_sgrp\n" +
|
||||
" on mtb_aart.cod_mgrp = mtb_sgrp.cod_mgrp and mtb_aart.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
" left outer join mtb_sfam on mtb_aart.cod_mgrp = mtb_sfam.cod_mgrp and\n" +
|
||||
" mtb_aart.cod_msgr = mtb_sfam.cod_msgr and\n" +
|
||||
" mtb_aart.cod_msfa = mtb_sfam.cod_msfa\n" +
|
||||
" left outer join mtb_tipi on mtb_aart.cod_mtip = mtb_tipi.cod_mtip\n" +
|
||||
" left outer join mtb_stip on mtb_aart.cod_mtip = mtb_stip.cod_mtip and\n" +
|
||||
" mtb_aart.cod_mstp = mtb_stip.cod_mstp\n" +
|
||||
"\n" +
|
||||
"Where mtb_grup.tipo_mgrp in ('PF', 'SL')\n" +
|
||||
" and mtb_aart.flag_stato = 'A'\n");
|
||||
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Biolevante_Biolevante)){
|
||||
createOrUpdateView("MPS_albero_classificazione","CREATE view MPS_albero_classificazione as\n" +
|
||||
" select distinct mtb_aart.cod_mgrp + Replicate('_', 3 - len(mtb_aart.cod_mgrp)) +\n" +
|
||||
" isNull(mtb_aart.cod_mstp, '0000') +\n" +
|
||||
" ISNULL(mtb_aart.cod_msfa, '') as hierarchy_code,\n" +
|
||||
" mtb_aart.cod_mart,\n" +
|
||||
" mtb_aart.descrizione,\n" +
|
||||
" mtb_aart.cod_mgrp as level_1_code,\n" +
|
||||
" mtb_grup.descrizione as level_1_description,\n" +
|
||||
" mtb_aart.cod_mstp as level_2_code,\n" +
|
||||
" mtb_tipi.descrizione + ' ' + mtb_stip.descrizione as level_2_description,\n" +
|
||||
" mtb_aart.cod_msfa as level_3_code,\n" +
|
||||
" mtb_sfam.descrizione as level_3_description,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" (IIF(jtb_cicl.lotto_min_ord > 0, jtb_cicl.lotto_min_ord * jtb_cicl.rap_conv_prod,\n" +
|
||||
" mtb_aart.qta_cnf * mtb_aart.colli_pedana)) as lot_size\n" +
|
||||
" from mtb_aart\n" +
|
||||
" inner join mtb_grup on mtb_aart.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" inner join mtb_sgrp\n" +
|
||||
" on mtb_aart.cod_mgrp = mtb_sgrp.cod_mgrp and mtb_aart.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
" left outer join mtb_sfam on mtb_aart.cod_mgrp = mtb_sfam.cod_mgrp and\n" +
|
||||
" mtb_aart.cod_msgr = mtb_sfam.cod_msgr and\n" +
|
||||
" mtb_aart.cod_msfa = mtb_sfam.cod_msfa\n" +
|
||||
" left outer join mtb_tipi on mtb_aart.cod_mtip = mtb_tipi.cod_mtip\n" +
|
||||
" left outer join mtb_stip on mtb_aart.cod_mtip = mtb_stip.cod_mtip and\n" +
|
||||
" mtb_aart.cod_mstp = mtb_stip.cod_mstp\n" +
|
||||
" left outer join jtb_cicl on mtb_aart.cod_mart = jtb_cicl.cod_prod\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
" Where mtb_aart.cod_mgrp in ('AP', 'C', 'CO', 'S', 'SO', 'SOR')\n" +
|
||||
" and not tipo_mgrp = 'ACC'\n" +
|
||||
" and mtb_aart.flag_stato = 'A'\n" +
|
||||
" \n");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251024113416 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("ALTER TABLE mtb_missione_mag_auto_det " +
|
||||
"ALTER COLUMN posizione_in VARCHAR (MAX);",
|
||||
|
||||
"ALTER TABLE mtb_missione_mag_auto_det " +
|
||||
"ALTER COLUMN posizione_out VARCHAR (MAX);",
|
||||
|
||||
"ALTER TABLE dtb_ord_steps " +
|
||||
"ALTER COLUMN posizione_out VARCHAR (MAX);");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems_model.entity.MtbDepoPosizioni;
|
||||
import it.integry.ems_model.utility.UtilityList;
|
||||
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Migration_20251028122833 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createIndex(
|
||||
new IndexTableDTO()
|
||||
.setIndexName("ix_metb_depo_posizioni_posizione_cod_mdep")
|
||||
.setTableName(MtbDepoPosizioni.ENTITY)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("posizione"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_mdep"));
|
||||
}})
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
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;
|
||||
import it.integry.ems_model.entity.CtbAmac;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
|
||||
public class Migration_20251106114932 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Biolevante_Biolevante)){
|
||||
CtbAmac eurofork = new CtbAmac();
|
||||
eurofork.setCodCmac("MAG-WH1")
|
||||
.setDescrizione("MAGAZZINO AUTOMATICO EUROFORK L7")
|
||||
.setCodJfas("L7")
|
||||
.setPosizione("WH1C3")
|
||||
.setFlagAttivo(true)
|
||||
.setMachineType(CtbAmac.MachineType.SILOS_MACHINE.getValue())
|
||||
.setOperation(OperationType.INSERT);
|
||||
|
||||
eurofork.manageWithParentConnection(connection);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251124143153 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetupQuery("TIPO_GRIGLIA", "tipo griglia", "SELECT 'A|GRIGLIA DI ACQUISTO'\n" +
|
||||
"UNION ALL\n" +
|
||||
"SELECT 'V|GRIGLIA DI VENDITA'");
|
||||
createSetup
|
||||
("PVM", "RILEVAZIONI_STEUP", "TIPO_GRIGLIA", null,
|
||||
"Indicare per ogni reparto se la griglia per l'assortimento è quella di acquisto o di vendita",
|
||||
false, "TIPO_GRIGLIA", true, false, false, false, false, "jtb_fasi", false,
|
||||
"SELECT 'A|GRIGLIA DI ACQUISTO'\n" +
|
||||
"UNION ALL\n" +
|
||||
"SELECT 'V|GRIGLIA DI VENDITA'");
|
||||
|
||||
if (!isCustomerDb(IntegryCustomerDB.Carelli_Winact)) return;
|
||||
|
||||
executeStatement("insert into stb_gest_setup_det \n" +
|
||||
"select gest_name, section, key_section, tipo_setup, f.cod_jfas, f.valUe\n" +
|
||||
"from stb_gest_setup\n" +
|
||||
"cross apply (\n" +
|
||||
"select distinct jtb_fasi.cod_jfas,\n" +
|
||||
"IIF (jtb_fasi.cod_jfas = '01' OR jtb_fasi.cod_jfas = '02', 'V', 'A') as valUe\n" +
|
||||
"from jtb_fasi inner join jrl_fasi_mtb_grup on jtb_fasi.cod_jfas = jrl_fasi_mtb_grup.cod_jfas ) f\n" +
|
||||
"where gest_name = 'PVM' \n" +
|
||||
"and section = 'RILEVAZIONI_STEUP'\n" +
|
||||
"and key_section = 'TIPO_GRIGLIA'\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251124161416 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isCustomerDb(IntegryCustomerDB.Carelli_Winact)) return;
|
||||
|
||||
createOrUpdateFunction("[steup_getGrigliaVendita]", "CREATE FUNCTION [dbo].[steup_getGrigliaVendita](\n" +
|
||||
" @codMdep VARCHAR(5), @codJfas VARCHAR(5), @dataIspezione datetime\n" +
|
||||
")\n" +
|
||||
" RETURNS TABLE\n" +
|
||||
" AS\n" +
|
||||
" RETURN(WITH tipiArt AS (SELECT value_string AS cod_mtip\n" +
|
||||
" FROM dbo.ParseStringIntoArray((SELECT value\n" +
|
||||
" FROM stb_gest_setup\n" +
|
||||
" WHERE gest_name = 'PVM'\n" +
|
||||
" AND section = 'RILEVAZIONI_STEUP'\n" +
|
||||
" AND key_section = 'EXCLUDE_COD_MTIP'), '|') t)\n" +
|
||||
" , art AS (SELECT DISTINCT cod_griglia, cod_mart\n" +
|
||||
" FROM carelli.dbo.vtb_griglia_art\n" +
|
||||
" WHERE cod_griglia = @codMdep\n" +
|
||||
" AND data_validita =\n" +
|
||||
" (SELECT MAX(data_validita) FROM carelli.dbo.vtb_griglia_art WHERE cod_griglia = @codMdep AND data_validita <=@dataIspezione)\n" +
|
||||
" )\n" +
|
||||
" \n" +
|
||||
" SELECT DISTINCT case when @codJfas = '01' then art_det.cod_mart_griglia else mtb_aart.cod_mart end as cod_mart,\n" +
|
||||
" mtb_aart.descrizione,\n" +
|
||||
" mtb_aart.bar_code,\n" +
|
||||
" mtb_aart.cod_msgr,\n" +
|
||||
" mtb_aart.plu,\n" +
|
||||
" art_det.cod_mart AS cod_mart_kit \n" +
|
||||
" FROM carelli.dbo.mtb_aart\n" +
|
||||
" INNER JOIN jrl_fasi_mtb_grup ON\n" +
|
||||
" mtb_aart.cod_mgrp = jrl_fasi_mtb_grup.cod_mgrp\n" +
|
||||
" INNER JOIN (SELECT cod_mart, cod_comp AS cod_mart_griglia\n" +
|
||||
" FROM carelli.dbo.mtb_comp\n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT cod_comp AS cod_mart, cod_mart AS cod_mart_griglia\n" +
|
||||
" FROM carelli.dbo.mtb_comp \n" +
|
||||
" where @codJfas <> '01'\n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT cod_mart, cod_mart AS cod_mart_griglia\n" +
|
||||
" FROM carelli.dbo.mtb_aart\n" +
|
||||
" WHERE cod_mart NOT IN (SELECT cod_mart FROM carelli.dbo.mtb_comp)) AS art_det\n" +
|
||||
" ON mtb_aart.cod_mart = art_det.cod_mart\n" +
|
||||
" INNER JOIN art ON art_det.cod_mart_griglia = art.cod_mart\n" +
|
||||
" WHERE jrl_fasi_mtb_grup.cod_jfas = @codJfas\n" +
|
||||
" AND flag_stato = 'A'\n" +
|
||||
" AND (mtb_aart.cod_mtip IS NULL OR mtb_aart.cod_mtip NOT IN (SELECT cod_mtip FROM tipiArt)) \n" +
|
||||
" )");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,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" +
|
||||
|
||||
@@ -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" +
|
||||
|
||||
@@ -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" +
|
||||
|
||||
@@ -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" +
|
||||
|
||||
@@ -10,170 +10,247 @@ public class Migration_20251205111526 extends BaseMigration implements Migration
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createOrUpdateView("mvw_sitart_udc_det_inventario","CREATE VIEW [dbo].[mvw_sitart_udc_det_inventario] AS\n" +
|
||||
"WITH baseMtbColr AS (SELECT c,\n" +
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateView("mvw_sitart_udc_det_all","CREATE VIEW [dbo].[mvw_sitart_udc_det_all] AS\n" +
|
||||
"WITH SitMtbColr AS (\n" +
|
||||
" /*Vengono presi tutti i Colli di carico*/\n" +
|
||||
" SELECT mtb_colt.gestione,\n" +
|
||||
" mtb_colt.data_collo,\n" +
|
||||
" mtb_colt.ser_collo,\n" +
|
||||
" mtb_colt.num_collo,\n" +
|
||||
" mtb_colt.segno,\n" +
|
||||
" mtb_colt.cod_anag,\n" +
|
||||
" mtb_colt.cod_vdes,\n" +
|
||||
" mtb_colt.cod_mdep,\n" +
|
||||
" mtb_colr.cod_mart,\n" +
|
||||
" mtb_colr.cod_col,\n" +
|
||||
" mtb_colr.cod_tagl,\n" +
|
||||
" mtb_colr.partita_mag,\n" +
|
||||
" mtb_colr.cod_jcom,\n" +
|
||||
" qta_col,\n" +
|
||||
" num_cnf,\n" +
|
||||
" qta_cnf,\n" +
|
||||
" mtb_colr.peso_netto_kg,\n" +
|
||||
" peso_lordo_kg,\n" +
|
||||
" mtb_colt.posizione,\n" +
|
||||
" mtb_colt.cod_jfas,\n" +
|
||||
" mtb_colt.id_anomalia as id_anomalia\n" +
|
||||
" FROM mtb_colr\n" +
|
||||
" inner join mtb_colt on\n" +
|
||||
" mtb_colt.gestione = mtb_colr.gestione\n" +
|
||||
" AND mtb_colt.data_collo = mtb_colr.data_collo\n" +
|
||||
" AND mtb_colt.num_collo = mtb_colr.num_collo\n" +
|
||||
" AND mtb_colt.ser_collo = mtb_colr.ser_collo\n" +
|
||||
" WHERE mtb_colr.data_collo >= '2020/01/01'\n" +
|
||||
" AND segno = 1\n" +
|
||||
"\n" +
|
||||
" ROUND(v.qta_col, cifre_dec) AS qta_col,\n" +
|
||||
" ROUND(v.num_cnf, cifre_dec) AS num_cnf,\n" +
|
||||
" IIF(flag_qta_cnf_fissa = 'S',\n" +
|
||||
" v.qta_cnf_anag, v.qta_col / IIF(v.num_cnf = 0, 1, v.num_cnf)) AS qta_cnf,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" mtb_colt.gestione,\n" +
|
||||
" mtb_colt.data_collo,\n" +
|
||||
" mtb_colt.ser_collo,\n" +
|
||||
" mtb_colt.num_collo,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.cod_mgrp,\n" +
|
||||
" mtb_grup.descrizione AS descrizione_gruppo,\n" +
|
||||
" v.cod_msgr,\n" +
|
||||
" mtb_sgrp.descrizione AS descrizione_sottogruppo,\n" +
|
||||
" mtb_unt_mis.flag_dig,\n" +
|
||||
" mtb_unt_mis.cifre_dec,\n" +
|
||||
" mtb_colt.segno,\n" +
|
||||
" v.cod_mdep,\n" +
|
||||
" v.posizione,\n" +
|
||||
" mtb_colt.cod_dtip,\n" +
|
||||
" mtb_colt.cod_jfas,\n" +
|
||||
" v.barcode_ul,\n" +
|
||||
" v.qta_cnf_anag,\n" +
|
||||
" MAX(mtb_colr.datetime_row) AS datetime_posizionamento,\n" +
|
||||
" mtb_colt.progressivo_ul,\n" +
|
||||
" mtb_colt.id_anomalia\n" +
|
||||
" FROM mvw_mtb_colr_with_giacenza v WITH (NOEXPAND)\n" +
|
||||
" INNER JOIN mtb_colt\n" +
|
||||
" ON v.barcode_ul = mtb_colt.barcode_ul\n" +
|
||||
" LEFT OUTER JOIN mtb_colr ON\n" +
|
||||
" v.barcode_ul = mtb_colr.barcode_ul_in AND\n" +
|
||||
" v.cod_mart = mtb_colr.cod_mart AND\n" +
|
||||
" ((v.partita_mag IS NULL AND mtb_colr.partita_mag IS NULL) OR\n" +
|
||||
" (v.partita_mag = mtb_colr.partita_mag)) AND\n" +
|
||||
" ((v.cod_col IS NULL AND mtb_colr.cod_col IS NULL) OR (v.cod_col = mtb_colr.cod_col)) AND\n" +
|
||||
" ((v.cod_tagl IS NULL AND mtb_colr.cod_tagl IS NULL) OR (v.cod_tagl = mtb_colr.cod_tagl)) AND\n" +
|
||||
" ((v.cod_jcom IS NULL AND mtb_colr.cod_jcom IS NULL) OR (v.cod_jcom = mtb_colr.cod_jcom)) AND\n" +
|
||||
" ((v.posizione IS NULL AND mtb_colr.posizione_in IS NULL) OR (v.posizione = mtb_colr.posizione_in)) AND\n" +
|
||||
" ((v.cod_mdep IS NULL AND mtb_colr.cod_mdep_in IS NULL) OR (v.cod_mdep = mtb_colr.cod_mdep_in)) AND\n" +
|
||||
" ISNULL(mtb_colr.posizione_in, '') <> ISNULL(mtb_colr.posizione_out, '')\n" +
|
||||
" INNER JOIN dbo.mtb_unt_mis ON v.unt_mis = mtb_unt_mis.unt_mis\n" +
|
||||
"\n" +
|
||||
" INNER JOIN dbo.mtb_grup ON v.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" INNER JOIN dbo.mtb_sgrp ON v.cod_mgrp = mtb_sgrp.cod_mgrp\n" +
|
||||
" AND v.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
" WHERE v.qta_col > 0\n" +
|
||||
" AND (segno = 1 OR (segno = -1 AND cod_dtip IS NULL AND mtb_colt.gestione = 'V'))\n" +
|
||||
" GROUP BY c,\n" +
|
||||
" ROUND(v.qta_col, cifre_dec),\n" +
|
||||
" ROUND(v.num_cnf, cifre_dec),\n" +
|
||||
" IIF(flag_qta_cnf_fissa = 'S',\n" +
|
||||
" v.qta_cnf_anag, v.qta_col / IIF(v.num_cnf = 0, 1, v.num_cnf)),\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" mtb_colt.gestione,\n" +
|
||||
" mtb_colt.data_collo,\n" +
|
||||
" mtb_colt.ser_collo,\n" +
|
||||
" mtb_colt.num_collo,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.cod_mgrp,\n" +
|
||||
" mtb_grup.descrizione,\n" +
|
||||
" v.cod_msgr,\n" +
|
||||
" mtb_sgrp.descrizione,\n" +
|
||||
" mtb_unt_mis.flag_dig,\n" +
|
||||
" mtb_unt_mis.cifre_dec,\n" +
|
||||
" mtb_colt.segno,\n" +
|
||||
" v.cod_mdep,\n" +
|
||||
" v.posizione,\n" +
|
||||
" mtb_colt.cod_dtip,\n" +
|
||||
" mtb_colt.cod_jfas,\n" +
|
||||
" v.barcode_ul,\n" +
|
||||
" v.qta_cnf_anag,\n" +
|
||||
" mtb_colt.progressivo_ul,\n" +
|
||||
" mtb_colt.id_anomalia\n" +
|
||||
" ),\n" +
|
||||
" final_stock AS (SELECT v.qta_col,\n" +
|
||||
" v.num_cnf,\n" +
|
||||
" v.qta_cnf,\n" +
|
||||
" v.gestione,\n" +
|
||||
" v.data_collo,\n" +
|
||||
" v.ser_collo,\n" +
|
||||
" v.num_collo,\n" +
|
||||
" v.cod_mdep AS cod_mdep,\n" +
|
||||
" v.posizione AS posizione,\n" +
|
||||
" mtb_depo_posizioni.priorita,\n" +
|
||||
" v.cod_mgrp AS codGruppo,\n" +
|
||||
" v.descrizione_gruppo AS Gruppo,\n" +
|
||||
" v.cod_msgr AS CodSgruppo,\n" +
|
||||
" v.descrizione_sottogruppo AS Sottogruppo,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" v.cod_jfas,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.segno,\n" +
|
||||
" v.barcode_ul,\n" +
|
||||
" v.datetime_posizionamento,\n" +
|
||||
" v.progressivo_ul,\n" +
|
||||
" v.id_anomalia\n" +
|
||||
" FROM baseMtbColr v\n" +
|
||||
"\n" +
|
||||
" LEFT OUTER JOIN mtb_depo_posizioni\n" +
|
||||
" ON v.cod_mdep = mtb_depo_posizioni.cod_mdep\n" +
|
||||
" AND v.posizione = mtb_depo_posizioni.posizione)\n" +
|
||||
"\n" +
|
||||
"SELECT qta_col,\n" +
|
||||
" num_cnf,\n" +
|
||||
" qta_cnf,\n" +
|
||||
" gestione,\n" +
|
||||
" UNION ALL\n" +
|
||||
" /*Vengono presi, a storno, tutti i colli che fanno riferimento ad altri colli di carico*/\n" +
|
||||
" SELECT mtb_colr.gestione_rif,\n" +
|
||||
" mtb_colr.data_collo_rif,\n" +
|
||||
" mtb_colr.ser_collo_rif,\n" +
|
||||
" mtb_colr.num_collo_rif,\n" +
|
||||
" collo_rif.segno,\n" +
|
||||
" collo_rif.cod_anag,\n" +
|
||||
" collo_rif.cod_vdes,\n" +
|
||||
" collo_rif.cod_mdep,\n" +
|
||||
" mtb_colr.cod_mart,\n" +
|
||||
" mtb_colr.cod_col,\n" +
|
||||
" mtb_colr.cod_tagl,\n" +
|
||||
" mtb_colr.partita_mag,\n" +
|
||||
" NULL AS cod_jcom,\n" +
|
||||
" -qta_col,\n" +
|
||||
" -num_cnf,\n" +
|
||||
" qta_cnf,\n" +
|
||||
" -mtb_colr.peso_netto_kg,\n" +
|
||||
" -peso_lordo_kg,\n" +
|
||||
" collo_rif.posizione,\n" +
|
||||
" collo_rif.cod_jfas,\n" +
|
||||
" NULL as id_anomalia\n" +
|
||||
" FROM mtb_colr\n" +
|
||||
" LEFT OUTER JOIN mtb_colt AS collo_rif\n" +
|
||||
" ON mtb_colr.gestione_rif = collo_rif.gestione AND\n" +
|
||||
" mtb_colr.data_collo_rif = collo_rif.data_collo AND\n" +
|
||||
" mtb_colr.num_collo_rif = collo_rif.num_collo AND\n" +
|
||||
" mtb_colr.ser_collo_rif = collo_rif.ser_collo\n" +
|
||||
" WHERE mtb_colr.data_collo >= '2020/01/01'\n" +
|
||||
" AND gestione_rif IS NOT NULL /*and mtb_colt.segno = -1 */\n" +
|
||||
" UNION ALL\n" +
|
||||
" /*Vengono presi anche tutti i colli di scarico non ancora agganciati a documento tranne quelli di scarico a lavorazione perche' il materiale versato nelle linee di produzione si ritiene subito consumato*/\n" +
|
||||
" SELECT mtb_colt.gestione,\n" +
|
||||
" mtb_colt.data_collo,\n" +
|
||||
" mtb_colt.ser_collo,\n" +
|
||||
" mtb_colt.num_collo,\n" +
|
||||
" mtb_colt.segno,\n" +
|
||||
" mtb_colt.cod_anag,\n" +
|
||||
" mtb_colt.cod_vdes,\n" +
|
||||
" mtb_colt.cod_mdep,\n" +
|
||||
" mtb_colr.cod_mart,\n" +
|
||||
" mtb_colr.cod_col,\n" +
|
||||
" mtb_colr.cod_tagl,\n" +
|
||||
" mtb_colr.partita_mag,\n" +
|
||||
" mtb_colr.cod_jcom,\n" +
|
||||
" qta_col,\n" +
|
||||
" num_cnf,\n" +
|
||||
" qta_cnf,\n" +
|
||||
" mtb_colr.peso_netto_kg,\n" +
|
||||
" peso_lordo_kg,\n" +
|
||||
" mtb_colt.posizione,\n" +
|
||||
" mtb_colt.cod_jfas,\n" +
|
||||
" NULL as id_anomalia\n" +
|
||||
" FROM mtb_colr\n" +
|
||||
" inner join mtb_colt on\n" +
|
||||
" mtb_colt.gestione = mtb_colr.gestione\n" +
|
||||
" AND mtb_colt.data_collo = mtb_colr.data_collo\n" +
|
||||
" AND mtb_colt.num_collo = mtb_colr.num_collo\n" +
|
||||
" AND mtb_colt.ser_collo = mtb_colr.ser_collo\n" +
|
||||
" WHERE mtb_colr.data_collo >= '2020/01/01'\n" +
|
||||
" AND segno = -1\n" +
|
||||
" AND cod_dtip IS NULL\n" +
|
||||
" AND mtb_colt.gestione <> 'L'),\n" +
|
||||
" SitMtbColt AS (SELECT SitMtbColr.gestione,\n" +
|
||||
" SitMtbColr.data_collo,\n" +
|
||||
" SitMtbColr.ser_collo,\n" +
|
||||
" SitMtbColr.num_collo,\n" +
|
||||
" SitMtbColr.segno,\n" +
|
||||
" SitMtbColr.cod_mdep,\n" +
|
||||
" SitMtbColr.posizione,\n" +
|
||||
" SitMtbColr.cod_mart,\n" +
|
||||
" SitMtbColr.cod_col,\n" +
|
||||
" SitMtbColr.cod_tagl,\n" +
|
||||
" SitMtbColr.partita_mag,\n" +
|
||||
" mtb_partita_mag.data_scad,\n" +
|
||||
" MAX(SitMtbColr.cod_jcom) AS cod_jcom,\n" +
|
||||
" SUM(qta_col) AS qta_col,\n" +
|
||||
" SUM(num_cnf) AS num_cnf,\n" +
|
||||
" AVG(SitMtbColr.qta_cnf) AS qta_cnf,\n" +
|
||||
" SUM(SitMtbColr.peso_netto_kg) AS peso_netto_kg,\n" +
|
||||
" SUM(peso_lordo_kg) AS peso_lordo_kg,\n" +
|
||||
" SitMtbColr.cod_jfas,\n" +
|
||||
" flag_qta_cnf_fissa,\n" +
|
||||
" MAX(SitMtbColr.id_anomalia) as id_anomalia\n" +
|
||||
" FROM SitMtbColr\n" +
|
||||
" LEFT OUTER JOIN mtb_partita_mag ON SitMtbColr.cod_mart = mtb_partita_mag.cod_mart AND\n" +
|
||||
" SitMtbColr.partita_mag = mtb_partita_mag.partita_mag\n" +
|
||||
" INNER JOIN mtb_aart ON SitMtbColr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" GROUP BY SitMtbColr.gestione, SitMtbColr.data_collo, SitMtbColr.ser_collo, SitMtbColr.num_collo,\n" +
|
||||
" SitMtbColr.segno, SitMtbColr.cod_mdep,\n" +
|
||||
" SitMtbColr.posizione, SitMtbColr.cod_mart, SitMtbColr.cod_col, SitMtbColr.cod_tagl,\n" +
|
||||
" SitMtbColr.partita_mag,\n" +
|
||||
" mtb_partita_mag.data_scad, SitMtbColr.cod_jfas, mtb_aart.flag_qta_cnf_fissa)\n" +
|
||||
"SELECT gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" ser_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" segno,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" posizione,\n" +
|
||||
" priorita,\n" +
|
||||
" codGruppo,\n" +
|
||||
" Gruppo,\n" +
|
||||
" CodSgruppo,\n" +
|
||||
" Sottogruppo,\n" +
|
||||
" cod_mart,\n" +
|
||||
" diacod,\n" +
|
||||
" descrizione_estesa,\n" +
|
||||
" partita_mag,\n" +
|
||||
" SitMtbColt.posizione,\n" +
|
||||
" SitMtbColt.cod_mart,\n" +
|
||||
" cod_col,\n" +
|
||||
" cod_tagl,\n" +
|
||||
" partita_mag,\n" +
|
||||
" data_scad,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN flag_dig = 'S' THEN\n" +
|
||||
" CAST(qta_col AS INT)\n" +
|
||||
" ELSE ROUND(qta_col, cifre_dec)\n" +
|
||||
" END as qta_col,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN flag_dig = 'S' THEN\n" +
|
||||
" CASE\n" +
|
||||
" WHEN flag_dig = 'S' THEN\n" +
|
||||
" CAST(qta_col AS INT)\n" +
|
||||
" ELSE ROUND(qta_col, cifre_dec)\n" +
|
||||
" END / case when SitMtbColt.qta_cnf = 0 then 1 else SitMtbColt.qta_cnf end\n" +
|
||||
" ELSE num_cnf\n" +
|
||||
" END as num_cnf,\n" +
|
||||
" --qta_col,\n" +
|
||||
" --num_cnf,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN SitMtbColt.flag_qta_cnf_fissa = 'S'\n" +
|
||||
" THEN SitMtbColt.qta_cnf\n" +
|
||||
" ELSE qta_col / CASE WHEN num_cnf = 0 THEN 1 ELSE num_cnf END\n" +
|
||||
" END AS qta_cnf,\n" +
|
||||
" peso_netto_kg,\n" +
|
||||
" peso_lordo_kg,\n" +
|
||||
" cod_jfas,\n" +
|
||||
" flag_qta_cnf_fissa,\n" +
|
||||
" unt_mis,\n" +
|
||||
" SitMtbColt.flag_qta_cnf_fissa,\n" +
|
||||
" mtb_unt_mis.flag_dig,\n" +
|
||||
" mtb_unt_mis.cifre_dec,\n" +
|
||||
" SitMtbColt.id_anomalia\n" +
|
||||
"FROM SitMtbColt\n" +
|
||||
" INNER JOIN mtb_aart ON SitMtbColt.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" INNER JOIN mtb_unt_mis ON mtb_aart.unt_mis = mtb_unt_mis.unt_mis");
|
||||
|
||||
|
||||
|
||||
createOrUpdateView("mvw_sitart_udc_det","CREATE VIEW [dbo].[mvw_sitart_udc_det] AS\n" +
|
||||
"SELECT gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" ser_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" segno,\n" +
|
||||
" barcode_ul,\n" +
|
||||
" datetime_posizionamento,\n" +
|
||||
" progressivo_ul,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" posizione,\n" +
|
||||
" cod_mart,\n" +
|
||||
" cod_col,\n" +
|
||||
" cod_tagl,\n" +
|
||||
" partita_mag,\n" +
|
||||
" data_scad,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" qta_col,\n" +
|
||||
" num_cnf,\n" +
|
||||
" qta_cnf,\n" +
|
||||
" peso_netto_kg,\n" +
|
||||
" peso_lordo_kg,\n" +
|
||||
" cod_jfas,\n" +
|
||||
" id_anomalia\n" +
|
||||
"FROM final_stock\n");
|
||||
"FROM mvw_sitart_udc_det_all\n" +
|
||||
"WHERE qta_col > 0");
|
||||
|
||||
createOrUpdateView("mvw_sitart_udc_det_inventario","CREATE VIEW [dbo].[mvw_sitart_udc_det_inventario] as\n" +
|
||||
"SELECT UL.gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" ser_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" segno,\n" +
|
||||
" UL.cod_mdep,\n" +
|
||||
" UL.posizione,\n" +
|
||||
" mtb_depo_posizioni.priorita,\n" +
|
||||
" mtb_aart.cod_mgrp AS codGruppo,\n" +
|
||||
" mtb_grup.descrizione AS Gruppo,\n" +
|
||||
" mtb_aart.cod_msgr AS CodSgruppo,\n" +
|
||||
" mtb_sgrp.descrizione AS Sottogruppo,\n" +
|
||||
" UL.cod_mart,\n" +
|
||||
" diacod,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" partita_mag,\n" +
|
||||
" UL.cod_jcom,\n" +
|
||||
" jtb_comt.descrizione AS commessa,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" qta_col,\n" +
|
||||
" num_cnf,\n" +
|
||||
" UL.qta_cnf,\n" +
|
||||
" UL.peso_netto_kg,\n" +
|
||||
" UL.peso_lordo_kg,\n" +
|
||||
" UL.cod_jfas,\n" +
|
||||
" UL.id_anomalia\n" +
|
||||
"FROM [mvw_sitart_udc_det] UL\n" +
|
||||
" LEFT OUTER JOIN jtb_comt ON UL.cod_jcom = jtb_comt.cod_jcom\n" +
|
||||
" LEFT OUTER JOIN mtb_depo_posizioni\n" +
|
||||
" on UL.cod_mdep = mtb_depo_posizioni.cod_mdep and UL.posizione = mtb_depo_posizioni.posizione,\n" +
|
||||
" mtb_aart,\n" +
|
||||
" mtb_grup,\n" +
|
||||
" mtb_sgrp\n" +
|
||||
"WHERE UL.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" AND mtb_aart.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" AND mtb_aart.cod_mgrp = mtb_sgrp.cod_mgrp\n" +
|
||||
" AND mtb_aart.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
" AND qta_col <> 0\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,15 +3,17 @@ package it.integry.ems.migration.model;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251021114611 extends BaseMigration implements MigrationModelInterface {
|
||||
public class Migration_20251209113110 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("ALTER TABLE mtb_missione_mag_auto\n" +
|
||||
" ADD priorita SMALLINT DEFAULT 0 NOT NULL");
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
executeStatement("alter table mtb_aart alter column ingredienti varchar(8000)");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -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 {
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
}
|
||||
}
|
||||
@@ -4,23 +4,27 @@ import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250626142053 extends BaseMigration implements 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);
|
||||
|
||||
String reportNamePackingList = null;
|
||||
if (isCustomer(IntegryCustomer.RossoGargano)) {
|
||||
reportNamePackingList = "PackingListScarico";
|
||||
if(isCustomer(IntegryCustomer.Cosmapack)) {
|
||||
updateSetupValue("W_CREG_IVA_DISP", "DATAWINDOW", "D_CREG_IVA_REP", "d_creg_iva_cosmopack_rep");
|
||||
}
|
||||
createSetup("PVM", "CONTROLLO_GIACENZE", "REPORT_NAME_PACKING_LIST", reportNamePackingList, "Nome report per stampa packing list post trasferimento", "REPORT_NAME");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,22 +4,25 @@ import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250728095637 extends BaseMigration implements MigrationModelInterface {
|
||||
public class Migration_20251211165528 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("alter table dbo.atb_tipi add socio_aziendale BIT default 0 not null");
|
||||
createSetup("w_vriepfattagecomp_disp", "CB_VIS_DETTAGLIO", "VISIBLE", "N",
|
||||
null, false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
|
||||
|
||||
if (isCustomer(IntegryCustomer.RossoGargano)) {
|
||||
executeStatement("UPDATE dbo.atb_tipi SET socio_aziendale = 1 where cod_atip in (N'C1050', N'C1055')");
|
||||
if(isCustomer(IntegryCustomer.RossoGargano)) {
|
||||
updateSetupValue("w_vriepfattagecomp_disp", "CB_VIS_DETTAGLIO", "VISIBLE", "S");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251212130317 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomer(IntegryCustomer.Auricchio) || isCustomer(IntegryCustomer.Levanplast) || isCustomer(IntegryCustomer.Agricoper) || isCustomerDb(IntegryCustomerDB.Auricchio_Ind05)){
|
||||
executeStatement("delete from mtb_aart_anag\n" +
|
||||
"from \n" +
|
||||
"(select mtb_aart_anag.cod_anag,\n" +
|
||||
"\t\tmtb_aart_anag.cod_mart, \n" +
|
||||
"\t\tmax(id) as id\n" +
|
||||
"from (select cod_anag, cod_mart, row_number() over (partition by cod_anag, cod_mart order by cod_anag, cod_mart) as riga \n" +
|
||||
"\t\tfrom dbo.mtb_aart_anag\t\t\n" +
|
||||
"\t\t)error inner join mtb_aart_anag on mtb_aart_anag.cod_anag = error.cod_anag and\n" +
|
||||
"\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tmtb_aart_anag.cod_mart = error.cod_mart\n" +
|
||||
"where riga > 1\n" +
|
||||
"group by mtb_aart_anag.cod_anag,\n" +
|
||||
"\t\tmtb_aart_anag.cod_mart)rowDelete inner join mtb_aart_anag on rowDelete.id = mtb_aart_anag.id");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251212151308 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if ( !isCustomer(IntegryCustomer.Carelli) ) return;
|
||||
|
||||
createOrUpdateFunction("steup_getRilevazioni", "CREATE FUNCTION [dbo].[steup_getRilevazioni]\n" +
|
||||
"(\n" +
|
||||
" @dataIspezione DATETIME,\n" +
|
||||
" @codMdep VARCHAR(5),\n" +
|
||||
" @userRilevatore VARCHAR(20)\n" +
|
||||
")\n" +
|
||||
"RETURNS TABLE AS return \n" +
|
||||
"SELECT activity_id,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" user_creator,\n" +
|
||||
" ISNULL(effective_time, ora_ins_act) AS effective_time,\n" +
|
||||
" effective_endtime,\n" +
|
||||
" activity_result_id,\n" +
|
||||
" mtb_depo.cod_mdep,\n" +
|
||||
" mtb_depo.descrizione AS descr_deposito,\n" +
|
||||
" ISNULL(effective_date, data_ins_act) AS data_isp\n" +
|
||||
"FROM winact.dbo.stb_activity INNER JOIN winact.dbo.wtb_depo ON stb_activity.user_name = wtb_depo.user_name\n" +
|
||||
" INNER JOIN winact.dbo.mtb_depo ON wtb_depo.cod_mdep = mtb_depo.cod_mdep\n" +
|
||||
"WHERE flag_tipologia = 'P' AND\n" +
|
||||
" activity_type_id = 'ISPEZIONE' AND \n" +
|
||||
" (@dataIspezione is null or stb_activity.effective_date = @dataIspezione ) AND \n" +
|
||||
" (@codMdep is null or mtb_depo.cod_mdep = @codMdep ) AND \n" +
|
||||
" (@userRilevatore is null or stb_activity.user_creator = @userRilevatore );");
|
||||
createOrUpdateFunction("steup_getEntriesRilevazione", "CREATE FUNCTION [dbo].[steup_getEntriesRilevazione](@idIspezione varchar(20))\n" +
|
||||
" RETURNS TABLE AS return\n" +
|
||||
"WITH steup_ispezioni AS (SELECT * FROM steup_getRilevazioni(null, null, null)),\n" +
|
||||
"\n" +
|
||||
" steup_activities AS (SELECT stb_activity.activity_id,\n" +
|
||||
" stb_activity.activity_type_id,\n" +
|
||||
" stb_activity.data_ins_act,\n" +
|
||||
" ISNULL(stb_activity.effective_time, stb_activity.ora_ins_act) AS effective_time,\n" +
|
||||
" stb_activity.cod_mart,\n" +
|
||||
" mtb_aart.descrizione AS descr_art,\n" +
|
||||
" stb_activity.activity_play_counter,\n" +
|
||||
" stb_activity.note,\n" +
|
||||
" stb_activity.cod_jfas,\n" +
|
||||
" stb_activity.flag_tipologia,\n" +
|
||||
" stb_activity.persona_rif,\n" +
|
||||
" stb_activity.priorita,\n" +
|
||||
" wtb_depo.cod_mdep,\n" +
|
||||
" jtb_fasi.descrizione AS descr_fase,\n" +
|
||||
" stb_activity.parent_activity_id as id_ispezione,\n" +
|
||||
" stb_activity.indice_gradimento,\n" +
|
||||
" stb_activity.user_creator,\n" +
|
||||
" jtb_fasi.max_allocazione,\n" +
|
||||
" SUM(indice_gradimento)\n" +
|
||||
" OVER ( PARTITION BY parent_activity_id,wtb_depo.cod_mdep,jtb_fasi.cod_jfas ) AS gradimento_reparto,\n" +
|
||||
" steup_ispezioni.data_isp\n" +
|
||||
" FROM winact.dbo.stb_activity\n" +
|
||||
" INNER JOIN steup_ispezioni ON parent_activity_id = steup_ispezioni.activity_id\n" +
|
||||
" LEFT OUTER JOIN winact.dbo.jtb_fasi ON stb_activity.cod_jfas = jtb_fasi.cod_jfas\n" +
|
||||
" LEFT OUTER JOIN winact.dbo.mtb_aart ON stb_activity.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" LEFT OUTER JOIN winact.dbo.wtb_depo ON stb_activity.user_name = wtb_depo.user_name\n" +
|
||||
" WHERE ISNULL(cod_jcom, '') <> 'MODEL'\n" +
|
||||
" and stb_activity.cod_mart is null\n" +
|
||||
" AND stb_activity.flag_tipologia = 'A')\n" +
|
||||
" ,\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
" gradimento_reparto AS (SELECT DISTINCT id_ispezione,\n" +
|
||||
" cod_jfas,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" data_isp,\n" +
|
||||
" gradimento_reparto,\n" +
|
||||
" LAG(gradimento_reparto, 1, 0)\n" +
|
||||
" OVER (PARTITION BY cod_mdep,cod_jfas ORDER BY data_isp ) AS grad_1,\n" +
|
||||
" LAG(gradimento_reparto, 2, 0)\n" +
|
||||
" OVER (PARTITION BY cod_mdep,cod_jfas ORDER BY data_isp ) AS grad_2\n" +
|
||||
"\n" +
|
||||
" FROM (SELECT DISTINCT id_ispezione, cod_mdep, cod_jfas, gradimento_reparto, data_isp\n" +
|
||||
" FROM steup_activities) acti)\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"SELECT steup_activities.*,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN gradimento_reparto.grad_1 > max_allocazione AND gradimento_reparto.grad_2 > max_allocazione THEN 1\n" +
|
||||
" ELSE 0 END AS recidiva,\n" +
|
||||
" ((SELECT COUNT(*)\n" +
|
||||
" FROM stb_activity art\n" +
|
||||
" WHERE steup_activities.activity_id = art.parent_activity_id) + (SELECT COUNT(*)\n" +
|
||||
" FROM mtb_colt\n" +
|
||||
" INNER JOIN mtb_colr\n" +
|
||||
" ON mtb_colt.gestione =\n" +
|
||||
" mtb_colr.gestione AND\n" +
|
||||
" mtb_colt.data_collo =\n" +
|
||||
" mtb_colr.data_collo AND\n" +
|
||||
" mtb_colt.ser_collo =\n" +
|
||||
" mtb_colr.ser_collo AND\n" +
|
||||
" mtb_colt.num_collo =\n" +
|
||||
" mtb_colr.num_collo\n" +
|
||||
" WHERE mtb_colt.activity_id = steup_activities.activity_id)) AS count_art\n" +
|
||||
"FROM steup_activities\n" +
|
||||
" left outer JOIN gradimento_reparto ON steup_activities.id_ispezione = gradimento_reparto.id_ispezione\n" +
|
||||
" AND steup_activities.cod_mdep = gradimento_reparto.cod_mdep\n" +
|
||||
" AND steup_activities.cod_jfas = gradimento_reparto.cod_jfas\n" +
|
||||
"WHERE (@idIspezione is null or steup_activities.id_ispezione = @idIspezione)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251212182900 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.FolliesGroup_FolliesGroup)) {
|
||||
executeStatement("delete from mtb_aart_anag\n" +
|
||||
"from (select mtb_aart_anag.cod_anag, mtb_aart_anag.cod_mart, mtb_aart_anag.cod_col, mtb_aart_anag.cod_tagl, max(id) as id \n" +
|
||||
"\t\tfrom (select cod_anag, cod_mart, cod_col, cod_tagl, row_number() over (partition by cod_anag, cod_mart, cod_col, cod_tagl order by cod_anag, cod_mart, cod_col, cod_tagl, id desc) as riga \n" +
|
||||
"\t\tfrom dbo.mtb_aart_anag \n" +
|
||||
"\t\t)error inner join mtb_aart_anag on mtb_aart_anag.cod_anag = error.cod_anag and \n" +
|
||||
"\t\t\t\t\t\t\t\t\t\t\tmtb_aart_anag.cod_mart = error.cod_mart \n" +
|
||||
"where riga > 1 \n" +
|
||||
"group by mtb_aart_anag.cod_anag, mtb_aart_anag.cod_col, mtb_aart_anag.cod_tagl, mtb_aart_anag.cod_mart)rowDelete inner join mtb_aart_anag on rowDelete.id = mtb_aart_anag.id");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,20 @@
|
||||
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_20251015111009 extends BaseMigration implements MigrationModelInterface {
|
||||
public class Migration_20251217111203 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("alter table dbo.dtb_ord_steps add posizione_out varchar(40)");
|
||||
enableSaveToRest("maart_equi");
|
||||
|
||||
if ( !isCustomer(IntegryCustomer.Smetar)) return;
|
||||
executeStatement("update mtb_aart_equi set flag_equi_anag = 1");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -8,10 +8,7 @@ public enum IntegryApplicationEnum {
|
||||
TASK("478f3a4c51824ad23cb50c1c60670c0f"),
|
||||
SALESBOOK("f0484398-1f8b-42f5-ab79-5282c164e1d8"),
|
||||
CONSEGNA("c012124f-4f11-471c-ae12-81bd4a97626c"),
|
||||
WINCLOCK("54ceebf0-494f-49f1-850b-b15c57666146"),
|
||||
|
||||
//Service Applications
|
||||
SERVICE_EUROFORK_CONNECTOR("eadadd1c-13bb-4aae-87fd-4672573f8088");
|
||||
WINCLOCK("54ceebf0-494f-49f1-850b-b15c57666146");
|
||||
|
||||
private final String text;
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ public class AccountingBusinessLogic {
|
||||
"Attezione, codice pagamento non presente nel documento %s/%s del %s, %s %s",
|
||||
testata.getSerDoc(),
|
||||
testata.getNumDoc(),
|
||||
new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY_SLASHED).format(testata.getDataDoc()),
|
||||
new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY).format(testata.getDataDoc()),
|
||||
(testata.getTipoAnag().equalsIgnoreCase("F") ? "fornitore" : "cliente"),
|
||||
testata.getCodAnag()));
|
||||
|
||||
@@ -420,7 +420,7 @@ public class AccountingBusinessLogic {
|
||||
+ "ctb_caur_rc.cod_ccon as 'cod_ccon',"
|
||||
+ "ctb_caur_rc.tipo_anag as 'tipo_anag', "
|
||||
+ "CASE WHEN ctb_caur_rc.tipo_anag is not null and ctb_grup.tipo = 2 and ctb_grup.sezione = 1 then " + UtilityDB.valueToString(testata.getCodAnag()) + " else null end as 'cod_anag', "
|
||||
+ "CAST(CASE WHEN ctb_caur_rc.tipo_anag is not null and ctb_grup.tipo = 2 and ctb_grup.sezione = 1 then Cast(DatePart(yy, " + UtilityDB.valueDateToString(testata.getDataDoc(), CommonConstants.DATE_FORMAT_YMD_SLASHED) + ") as varchar) else null end as int) as 'anno_part', "
|
||||
+ "CAST(CASE WHEN ctb_caur_rc.tipo_anag is not null and ctb_grup.tipo = 2 and ctb_grup.sezione = 1 then Cast(DatePart(yy, " + UtilityDB.valueDateToString(testata.getDataDoc(), CommonConstants.DATE_FORMAT_YMD) + ") as varchar) else null end as int) as 'anno_part', "
|
||||
+ "CASE WHEN ctb_caur_rc.tipo_anag is not null and ctb_grup.tipo = 2 and ctb_grup.sezione = 1 then " + UtilityDB.valueToString(testata.getSerDoc()) + " else null end as 'ser_doc', "
|
||||
+ "CAST( CASE WHEN ctb_caur_rc.tipo_anag is not null and ctb_grup.tipo = 2 and ctb_grup.sezione = 1 then " + UtilityDB.valueToString(testata.getNumDoc()) + " else null end as int) as 'num_doc', "
|
||||
+ "CONVERT ( numeric(20,5), CASE ctb_caur_rc.imp_dare "
|
||||
@@ -642,7 +642,7 @@ public class AccountingBusinessLogic {
|
||||
String whereCond = String.format("%s BETWEEN data_iniz AND data_fine", UtilityDB.valueToString(data));
|
||||
GtbPeriodoFisc gtbPeriodoFisc = getPeriodoFisc(conn, whereCond);
|
||||
if (gtbPeriodoFisc == null) {
|
||||
throw new Exception("Impossibile individuare il periodo fiscale per la data " + new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY_SLASHED).format(data));
|
||||
throw new Exception("Impossibile individuare il periodo fiscale per la data " + new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY).format(data));
|
||||
}
|
||||
return gtbPeriodoFisc;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -84,7 +83,7 @@ public class DocumentBusinessLogic {
|
||||
Optional<DtbDoct> bollaMax = Stream.of(dtbDoct.getDtbDoctBolle()).max((o1, o2) -> o1.getDataDoc().compareTo(o2.getDataDoc()));
|
||||
|
||||
if (bollaMax.isPresent()) {
|
||||
ctbMovt.setDataCompIva(UtilityLocalDate.localDateToDate(bollaMax.get().getDataDoc()));
|
||||
ctbMovt.setDataCompIva(bollaMax.get().getDataDoc());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -142,11 +141,11 @@ public class DocumentBusinessLogic {
|
||||
codCconPaga = (String) datiCausPaga.get("cod_ccon_cassa");
|
||||
}
|
||||
|
||||
LocalDate dataReg = UtilityLocalDate.localDateFromDate(dtbDoct.getDataCmov());
|
||||
Date dataReg = dtbDoct.getDataCmov();
|
||||
if (dataReg == null) {
|
||||
dataReg = dtbDoct.getDataReg();
|
||||
}
|
||||
LocalDate dataDoc = dtbDoct.getDataDoc();
|
||||
Date dataDoc = dtbDoct.getDataDoc();
|
||||
String serDoc = dtbDoct.getSerDoc();
|
||||
Integer numDoc = dtbDoct.getNumDoc();
|
||||
String codJcom = dtbDoct.getCodJcom();
|
||||
@@ -167,10 +166,10 @@ public class DocumentBusinessLogic {
|
||||
//TESTATA
|
||||
ctbMovt
|
||||
.setNumCmov(numCmov)
|
||||
.setDataCmov(UtilityLocalDate.localDateToDate(dataReg))
|
||||
.setDataCmov(dataReg)
|
||||
.setCodJcom(codJcom)
|
||||
.setCodCcau(codCcau)
|
||||
.setDataDoc(UtilityLocalDate.localDateToDate(dataDoc))
|
||||
.setDataDoc(dataDoc)
|
||||
.setNumDoc(numDoc)
|
||||
.setSerDoc(serDoc)
|
||||
.setNumProt(numProt)
|
||||
@@ -196,7 +195,7 @@ public class DocumentBusinessLogic {
|
||||
|
||||
String idAttach = dtbDoct.getDrlDocAttached().get(0).getIdAttach();
|
||||
String sqlAttach =
|
||||
"SELECT CASE WHEN " + UtilityDB.valueDateToString(dataRicMin, CommonConstants.DATE_FORMAT_YMD_DASHED) + " is not null AND datetime_attach >= " + UtilityDB.valueDateToString(dataRicMin, CommonConstants.DATE_FORMAT_YMD_DASHED) + " THEN datetime_attach ELSE null END " +
|
||||
"SELECT CASE WHEN " + UtilityDB.valueDateToString(dataRicMin, CommonConstants.DATE_FORMAT_YMD) + " is not null AND datetime_attach >= " + UtilityDB.valueDateToString(dataRicMin, CommonConstants.DATE_FORMAT_YMD) + " THEN datetime_attach ELSE null END " +
|
||||
" FROM stb_files_attached " +
|
||||
" WHERE id_attach = " + UtilityDB.valueToString(idAttach);
|
||||
|
||||
@@ -219,7 +218,7 @@ public class DocumentBusinessLogic {
|
||||
"SELECT * " +
|
||||
" FROM ctb_part " +
|
||||
"WHERE cod_anag = " + UtilityDB.valueToString(dtbDoct.getCodAnag()) + " AND " +
|
||||
" data_doc = " + UtilityDB.valueToString(dtbDoct.getDataDoc()) + " AND " +
|
||||
" data_doc = " + UtilityDB.valueDateToString(dtbDoct.getDataDoc(), CommonConstants.DATE_FORMAT_YMD) + " AND " +
|
||||
" ser_doc = " + UtilityDB.valueToString(dtbDoct.getSerDoc()) + " AND " +
|
||||
" num_doc = " + UtilityDB.valueToString(dtbDoct.getNumDoc()) + " AND " +
|
||||
" tipo_partita = " + UtilityDB.valueToString(tipoPartita);
|
||||
@@ -347,9 +346,9 @@ public class DocumentBusinessLogic {
|
||||
|
||||
//REGISTRAZIONE ACCONTO
|
||||
if (!UtilityString.isNullOrEmpty(codCcauAnt) && acconto.compareTo(BigDecimal.ZERO) != 0) {
|
||||
Integer annoPart = dataDoc.getYear();
|
||||
Integer annoPart = Integer.parseInt(new SimpleDateFormat("yyyy").format(dataDoc));
|
||||
regAcconto(insImpDare, codIreg, codCcauAnt, codCconAnt, numIreg, numProt, riga, ctbMovt, righeMov,
|
||||
UtilityLocalDate.localDateToDate(dataReg), tipoAnag, codAnag, codJcom, acconto, numCmov, codCconAnag,
|
||||
dataReg, tipoAnag, codAnag, codJcom, acconto, numCmov, codCconAnag,
|
||||
annoPart, serDoc, numDoc);
|
||||
if ("S".equalsIgnoreCase(ctbMovt.getGeneraScad()) && stornaAcconto) {
|
||||
AccountingBusinessLogic.pagaScadenze(ctbMovt.getDataCmov(), acconto, elencoScad);
|
||||
@@ -362,7 +361,7 @@ public class DocumentBusinessLogic {
|
||||
if (!UtilityString.isNullOrEmpty(codCcauAnt)) {
|
||||
totDoc = totDoc.subtract(acconto);
|
||||
}
|
||||
regPagamento(insImpDare, regIva, riga, righeMov, UtilityLocalDate.localDateToDate(dataDoc), tipoAnag, codAnag, serDoc, numDoc, totDoc,
|
||||
regPagamento(insImpDare, regIva, riga, righeMov, dataDoc, tipoAnag, codAnag, serDoc, numDoc, totDoc,
|
||||
codCconAnag, codCconPaga, codCcauPaga, elencoScad,
|
||||
ctbMovt.getGeneraScad(), ctbMovt.getDataCmov());
|
||||
|
||||
@@ -565,7 +564,7 @@ public class DocumentBusinessLogic {
|
||||
|
||||
if (regIva) {
|
||||
ctbMovr
|
||||
.setAnnoPart(dtbDoct.getDataDoc().getYear())
|
||||
.setAnnoPart(Integer.parseInt(new SimpleDateFormat("yyyy").format(dtbDoct.getDataDoc())))
|
||||
.setSerDoc(dtbDoct.getSerDoc())
|
||||
.setNumDoc(dtbDoct.getNumDoc());
|
||||
}
|
||||
@@ -787,7 +786,7 @@ public class DocumentBusinessLogic {
|
||||
.setCodAnag(dtbDoct.getCodAnag());
|
||||
if (regIva) {
|
||||
ctbMovr
|
||||
.setAnnoPart(dtbDoct.getDataDoc().getYear())
|
||||
.setAnnoPart(Integer.parseInt(new SimpleDateFormat("yyyy").format(dtbDoct.getDataDoc())))
|
||||
.setSerDoc(dtbDoct.getSerDoc())
|
||||
.setNumDoc(dtbDoct.getNumDoc());
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ import it.integry.ems.rules.businessLogic.enums.FlagSezione;
|
||||
import it.integry.ems.rules.completing.PackagesRules;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.db.ResultSetMapper;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.entity.key.MtbColtKey;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.*;
|
||||
@@ -24,7 +24,6 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static it.integry.ems.rules.completing.QueryRules.getSingleValue;
|
||||
|
||||
@@ -56,24 +55,12 @@ public class LoadColliService {
|
||||
|
||||
this.currentAzienda = Azienda.getDefaultAzienda(multiDBTransactionManager.getPrimaryConnection());
|
||||
|
||||
String whereCond = "";
|
||||
|
||||
for (MtbColt mtbColt : loadColli.getColli()) {
|
||||
mtbColt.setOperation(OperationType.SELECT_OBJECT);
|
||||
mtbColt.getMtbColr().forEach(mtbColr -> mtbColr.setOperation(OperationType.SELECT_OBJECT));
|
||||
mtbColt.getMtbCols().forEach(mtbCols -> mtbCols.setOperation(OperationType.SELECT_OBJECT));
|
||||
|
||||
if(loadDatiFromDB){
|
||||
entityProcessor.processEntity(mtbColt, true, multiDBTransactionManager);
|
||||
}
|
||||
|
||||
if (mtbColt.getNumCollo() == null && mtbColt.getDataCollo() == null) {
|
||||
mtbColt.setDataCollo(UtilityLocalDate.getNow());
|
||||
int numCollo = PackagesRules.completeNumCollo(multiDBTransactionManager.getPrimaryConnection(),
|
||||
mtbColt.getSerCollo(),
|
||||
mtbColt.getDataCollo(),
|
||||
mtbColt.getGestione());
|
||||
mtbColt.setNumCollo(numCollo);
|
||||
}
|
||||
}
|
||||
|
||||
if (UtilityString.isNullOrEmpty(loadColli.getGestione()) && !UtilityString.isNullOrEmpty(loadColli.getCodDtip())) {
|
||||
@@ -87,31 +74,35 @@ public class LoadColliService {
|
||||
}
|
||||
|
||||
|
||||
// String whereCond = "";
|
||||
// for (MtbColt collo : loadColli.getColli()) {
|
||||
// if (!UtilityString.isNullOrEmpty(whereCond)) {
|
||||
// whereCond += " OR ";
|
||||
// }
|
||||
//
|
||||
// whereCond += "( mtb_colt.gestione = " + UtilityDB.valueToString(collo.getGestione()) + " AND " +
|
||||
// " mtb_colt.data_collo = " + UtilityDB.valueToString(collo.getDataCollo()) + " AND " +
|
||||
// " mtb_colt.ser_collo = " + UtilityDB.valueToString(collo.getSerCollo()) + " AND " +
|
||||
// " mtb_colt.num_collo = " + UtilityDB.valueToString(collo.getNumCollo()) + ") ";
|
||||
// }
|
||||
checkColli(loadColli.getColli().stream()
|
||||
.map(MtbColt::getKey)
|
||||
.collect(Collectors.toList()), loadColli);
|
||||
if (loadDatiFromDB) {
|
||||
for (EntityBase entity : loadColli.getColli()) {
|
||||
entityProcessor.processEntity(entity, false, multiDBTransactionManager);
|
||||
}
|
||||
}
|
||||
|
||||
String whereCondColli = UtilityQuery.concatFieldListInWhereCond(loadColli.getColli().stream()
|
||||
.map(x -> new HashMap<String, Object>() {{
|
||||
put("mtb_colt.gestione", x.getGestione());
|
||||
put("mtb_colt.num_collo", x.getNumCollo());
|
||||
put("mtb_colt.data_collo", x.getDataCollo());
|
||||
put("mtb_colt.ser_collo", x.getSerCollo());
|
||||
}})
|
||||
.collect(Collectors.toList()));
|
||||
for (MtbColt mtbColt : loadColli.getColli()) {
|
||||
if (mtbColt.getNumCollo() == null && mtbColt.getDataCollo() == null) {
|
||||
mtbColt.setDataCollo(UtilityLocalDate.getNow());
|
||||
int numCollo = PackagesRules.completeNumCollo(multiDBTransactionManager.getPrimaryConnection(),
|
||||
mtbColt.getSerCollo(),
|
||||
mtbColt.getDataCollo(),
|
||||
mtbColt.getGestione());
|
||||
mtbColt.setNumCollo(numCollo);
|
||||
}
|
||||
}
|
||||
|
||||
for (MtbColt collo : loadColli.getColli()) {
|
||||
if (!UtilityString.isNullOrEmpty(whereCond)) {
|
||||
whereCond += " OR ";
|
||||
}
|
||||
|
||||
whereCond += "( mtb_colt.gestione = " + UtilityDB.valueToString(collo.getGestione()) + " AND " +
|
||||
" mtb_colt.data_collo = " + UtilityDB.valueToString(collo.getDataCollo()) + " AND " +
|
||||
" mtb_colt.ser_collo = " + UtilityDB.valueToString(collo.getSerCollo()) + " AND " +
|
||||
" mtb_colt.num_collo = " + UtilityDB.valueToString(collo.getNumCollo()) + ") ";
|
||||
}
|
||||
|
||||
checkColli(whereCond, loadColli);
|
||||
|
||||
DtbDoct dtbDoct;
|
||||
String query;
|
||||
@@ -184,7 +175,7 @@ public class LoadColliService {
|
||||
" gtb_divi," +
|
||||
"(SELECT segno_qta_scar FROM dtb_tipi WHERE cod_dtip = " + UtilityDB.valueToString(loadColli.getCodDtip()) + ") tipoDoc " +
|
||||
" WHERE dtb_ordt.gestione =" + UtilityDB.valueToString(loadColli.getGestione()) + " AND" +
|
||||
" dtb_ordt.data_ord = " + UtilityDB.valueToString(loadColli.getDataOrd()) + " AND" +
|
||||
" dtb_ordt.data_ord = " + UtilityDB.valueDateToString(loadColli.getDataOrd(), CommonConstants.DATE_FORMAT_YMD) + " AND" +
|
||||
" dtb_ordt.num_ord = " + UtilityDB.valueToString(loadColli.getNumOrd()) + " AND" +
|
||||
" gtb_divi.cod_divi = dtb_ordt.cod_divi ";
|
||||
|
||||
@@ -194,17 +185,15 @@ public class LoadColliService {
|
||||
throw new Exception("Codice Deposito obbligatorio");
|
||||
}
|
||||
|
||||
|
||||
if (loadDatiFromDB) {
|
||||
query = "SELECT DISTINCT mtb_colt.cod_vlis AS listino, " +
|
||||
" mtb_colt.cod_vdes " +
|
||||
" FROM mtb_colt " +
|
||||
" INNER JOIN mtb_colr ON mtb_colr.gestione = mtb_colt.gestione AND " +
|
||||
" FROM mtb_colt, mtb_colr " +
|
||||
"WHERE mtb_colr.gestione = mtb_colt.gestione AND " +
|
||||
" mtb_colr.data_collo = mtb_colt.data_collo AND " +
|
||||
" mtb_colr.ser_collo = mtb_colt.ser_collo AND " +
|
||||
" mtb_colr.num_collo = mtb_colt.num_collo " +
|
||||
" WHERE " + whereCondColli;
|
||||
|
||||
" mtb_colr.num_collo = mtb_colt.num_collo ";
|
||||
query = UtilityDB.addwhereCond(query, whereCond, false);
|
||||
dtbDoct = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), query, DtbDoct.class);
|
||||
} else {
|
||||
dtbDoct = new DtbDoct();
|
||||
@@ -240,7 +229,7 @@ public class LoadColliService {
|
||||
" vtb_list.descrizione ";
|
||||
|
||||
|
||||
query = UtilityDB.addwhereCond(query, whereCondColli, false);
|
||||
query = UtilityDB.addwhereCond(query, whereCond, false);
|
||||
List<HashMap<String, Object>> results = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), query);
|
||||
if (!results.isEmpty()) {
|
||||
dtbDoct.setCodDivi(UtilityHashMap.<String>getValueIfExists(results.get(0), "cod_divi"));
|
||||
@@ -253,7 +242,7 @@ public class LoadColliService {
|
||||
if (loadColli.getColli().isEmpty() && loadDatiFromDB) {
|
||||
query = "SELECT gestione, data_collo, ser_collo, num_collo " +
|
||||
" FROM mtb_colt ";
|
||||
query = UtilityDB.addwhereCond(query, whereCondColli, false);
|
||||
query = UtilityDB.addwhereCond(query, whereCond, false);
|
||||
PreparedStatement ps = multiDBTransactionManager.prepareStatement(query);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
@@ -267,7 +256,7 @@ public class LoadColliService {
|
||||
// Acquisizione ID_LOTTO del primo collo da agganciare
|
||||
if (loadDatiFromDB) {
|
||||
query = "SELECT TOP 1 id_lotto FROM mtb_colt ";
|
||||
query = UtilityDB.addwhereCond(query, whereCondColli, false);
|
||||
query = UtilityDB.addwhereCond(query, whereCond, false);
|
||||
Integer idLotto = (Integer) getSingleValue(multiDBTransactionManager.getPrimaryConnection(), query);
|
||||
if (idLotto != null) {
|
||||
dtbDoct.setIdLotto(idLotto);
|
||||
@@ -311,7 +300,7 @@ public class LoadColliService {
|
||||
|
||||
|
||||
//VERIFICARE CHE USERNAME VENGA PASSATO
|
||||
List<DtbDocr> dtbDocr = loadRigheCollo(whereCondColli, loadColli);
|
||||
List<DtbDocr> dtbDocr = loadRigheCollo(whereCond, loadColli);
|
||||
|
||||
if (!dtbDocr.isEmpty()) {
|
||||
dtbDocr.stream()
|
||||
@@ -332,19 +321,9 @@ public class LoadColliService {
|
||||
|
||||
}
|
||||
|
||||
private void checkColli(final List<MtbColtKey> mtbColtKeys, final LoadColliDTO loadColliDTO) throws Exception {
|
||||
private void checkColli(String whereCond, final LoadColliDTO loadColliDTO) throws Exception {
|
||||
String query;
|
||||
|
||||
|
||||
String whereCondColli = UtilityQuery.concatFieldListInWhereCond(mtbColtKeys.stream()
|
||||
.map(x -> new HashMap<String, Object>() {{
|
||||
put("mtb_colt.gestione", x.getGestione());
|
||||
put("mtb_colt.num_collo", x.getNumCollo());
|
||||
put("mtb_colt.data_collo", x.getDataCollo());
|
||||
put("mtb_colt.ser_collo", x.getSerCollo());
|
||||
}})
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
//CONTROLLO COLLI AGGANCIATI A DOCUMENTI
|
||||
if (loadDatiFromDB) {
|
||||
query =
|
||||
@@ -362,7 +341,7 @@ public class LoadColliService {
|
||||
" mtb_colt.ser_collo = mtb_colr.ser_collo and " +
|
||||
" mtb_colt.num_collo = mtb_colr.num_collo ";
|
||||
|
||||
query = UtilityDB.addwhereCond(query, whereCondColli, false);
|
||||
query = UtilityDB.addwhereCond(query, whereCond, false);
|
||||
|
||||
List<HashMap<String, Object>> results = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), query);
|
||||
for (HashMap<String, Object> result : results) {
|
||||
@@ -374,21 +353,20 @@ public class LoadColliService {
|
||||
int numDoc = UtilityHashMap.getValueIfExists(result, "num_doc");
|
||||
|
||||
throw new Exception("Il collo n° " + numCollo +
|
||||
" del " + new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY_SLASHED).format(dataCollo) +
|
||||
" del " + new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY).format(dataCollo) +
|
||||
" già agganciato al documento " + codDtip +
|
||||
" del " + new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY_SLASHED).format(dataDoc) +
|
||||
" del " + new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY).format(dataDoc) +
|
||||
" n. " + numDoc);
|
||||
}
|
||||
} else {
|
||||
List<MtbColt> mtbColtWithDocAlready = loadColliDTO.getColli().stream()
|
||||
.filter(mtbColt -> !UtilityString.isNullOrEmpty(mtbColt.getCodDtip()))
|
||||
.collect(Collectors.toList());
|
||||
List<MtbColt> mtbColtWithDocAlready = Stream.of(loadColliDTO.getColli())
|
||||
.filter(mtbColt -> !UtilityString.isNullOrEmpty(mtbColt.getCodDtip())).toList();
|
||||
|
||||
if (!mtbColtWithDocAlready.isEmpty()) {
|
||||
if (mtbColtWithDocAlready != null && !mtbColtWithDocAlready.isEmpty()) {
|
||||
throw new Exception("Il collo n° " + mtbColtWithDocAlready.get(0).getNumCollo() +
|
||||
" del " + CommonConstants.DATE_DMY_SLASHED_FORMATTER.format(mtbColtWithDocAlready.get(0).getDataCollo()) +
|
||||
" già agganciato al documento " + mtbColtWithDocAlready.get(0).getCodDtip() +
|
||||
" del " + CommonConstants.DATE_DMY_SLASHED_FORMATTER.format(mtbColtWithDocAlready.get(0).getDataDoc()) +
|
||||
" del " + new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY).format(mtbColtWithDocAlready.get(0).getDataDoc()) +
|
||||
" n. " + mtbColtWithDocAlready.get(0).getNumDoc());
|
||||
}
|
||||
}
|
||||
@@ -403,7 +381,7 @@ public class LoadColliService {
|
||||
"FROM mtb_colt " +
|
||||
"WHERE mtb_colt.cod_mdep <> " + UtilityDB.valueToString(loadColliDTO.getCodMdep());
|
||||
|
||||
query = UtilityDB.addwhereCond(query, whereCondColli, false);
|
||||
query = UtilityDB.addwhereCond(query, whereCond, false);
|
||||
List<HashMap<String, Object>> results = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), query);
|
||||
|
||||
if (!results.isEmpty()) {
|
||||
@@ -429,7 +407,7 @@ public class LoadColliService {
|
||||
" mtb_colr.data_ord = dtb_ordt.data_ord AND " +
|
||||
" mtb_colr.num_ord = dtb_ordt.num_ord ";
|
||||
|
||||
query = UtilityDB.addwhereCond(query, whereCondColli, false);
|
||||
query = UtilityDB.addwhereCond(query, whereCond, false);
|
||||
List<HashMap<String, Object>> results = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), query);
|
||||
|
||||
if (!results.isEmpty()) {
|
||||
@@ -453,7 +431,7 @@ public class LoadColliService {
|
||||
" mtb_colr.num_ord = dtb_ordt.num_ord " +
|
||||
"WHERE dtb_ordt.flag_sospeso = 'S'";
|
||||
|
||||
query = UtilityDB.addwhereCond(query, whereCondColli, false);
|
||||
query = UtilityDB.addwhereCond(query, whereCond, false);
|
||||
|
||||
List<HashMap<String, Object>> results = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), query);
|
||||
|
||||
@@ -704,7 +682,7 @@ public class LoadColliService {
|
||||
mtbTcol.setOperation(OperationType.SELECT_OBJECT);
|
||||
mtbTcol.setCodTcol(mtbColt.getCodTcol());
|
||||
|
||||
entityProcessor.processEntity(mtbTcol,true, multiDBTransactionManager);
|
||||
entityProcessor.processEntity(mtbTcol, multiDBTransactionManager);
|
||||
|
||||
if (mtbColt.getPesoKg() == null) mtbColt.setPesoKg(BigDecimal.ZERO);
|
||||
|
||||
@@ -726,18 +704,18 @@ public class LoadColliService {
|
||||
MtbAart mtbAart = new MtbAart();
|
||||
mtbAart.setCodMart(mtbColr.getCodMart());
|
||||
mtbAart.setOperation(OperationType.SELECT_OBJECT);
|
||||
entityProcessor.processEntity(mtbAart,true, multiDBTransactionManager);
|
||||
entityProcessor.processEntity(mtbAart, multiDBTransactionManager);
|
||||
|
||||
//Retrieve della riga ordine
|
||||
DtbOrdr dtbOrdr = null;
|
||||
if (mtbColr.getNumOrd() != null && mtbColr.getRigaOrd() != null && mtbColr.getDataOrd() != null) {
|
||||
dtbOrdr = new DtbOrdr();
|
||||
dtbOrdr.setNumOrd(mtbColr.getNumOrd());
|
||||
dtbOrdr.setDataOrd(mtbColr.getDataOrd());
|
||||
dtbOrdr.setDataOrd(UtilityLocalDate.localDateToDate(mtbColr.getDataOrd()));
|
||||
dtbOrdr.setRigaOrd(mtbColr.getRigaOrd());
|
||||
dtbOrdr.setOperation(OperationType.SELECT_OBJECT);
|
||||
|
||||
entityProcessor.processEntity(dtbOrdr,true, multiDBTransactionManager);
|
||||
entityProcessor.processEntity(dtbOrdr, multiDBTransactionManager);
|
||||
}
|
||||
|
||||
DtbDocr dtbDocr = new DtbDocr();
|
||||
|
||||
@@ -3,7 +3,6 @@ package it.integry.ems.rules.businessLogic.dto;
|
||||
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -14,13 +13,13 @@ public class LoadColliDTO {
|
||||
private String codDtip;
|
||||
private String codAnag;
|
||||
private String codVdes;
|
||||
private LocalDate dataDoc;
|
||||
private Date dataDoc;
|
||||
private String serDoc;
|
||||
private Integer numDoc;
|
||||
private String codMdep;
|
||||
private String calcPrz;
|
||||
private boolean flagLeggiDatiOrd;
|
||||
private LocalDate dataOrd;
|
||||
private Date dataOrd;
|
||||
private Integer numOrd;
|
||||
private String flagEvasoForzato;
|
||||
private Date dataVers;
|
||||
@@ -75,11 +74,11 @@ public class LoadColliDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDate getDataDoc() {
|
||||
public Date getDataDoc() {
|
||||
return dataDoc;
|
||||
}
|
||||
|
||||
public LoadColliDTO setDataDoc(LocalDate dataDoc) {
|
||||
public LoadColliDTO setDataDoc(Date dataDoc) {
|
||||
this.dataDoc = dataDoc;
|
||||
return this;
|
||||
}
|
||||
@@ -129,11 +128,11 @@ public class LoadColliDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDate getDataOrd() {
|
||||
public Date getDataOrd() {
|
||||
return dataOrd;
|
||||
}
|
||||
|
||||
public LoadColliDTO setDataOrd(LocalDate dataOrd) {
|
||||
public LoadColliDTO setDataOrd(Date dataOrd) {
|
||||
this.dataOrd = dataOrd;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -140,13 +140,14 @@ public class AccountingRules extends QueryRules {
|
||||
|
||||
public static Integer completeNumDocMov(Connection conn, CtbMovt entity) throws Exception {
|
||||
return DocumentRules.nextNumDoc(conn,
|
||||
UtilityLocalDate.localDateFromDate(entity.getDataDoc()),
|
||||
entity.getDataDoc(),
|
||||
entity.getCodIreg(),
|
||||
entity.getSerDoc(),
|
||||
entity.getNumIreg(),
|
||||
entity.getNumDoc() == null ? 0 : entity.getNumDoc());
|
||||
}
|
||||
|
||||
|
||||
public static Integer getAnnoComp(Connection conn, LocalDate dataCmov) throws SQLException {
|
||||
if (dataCmov == null)
|
||||
return UtilityLocalDate.getNow().getYear();
|
||||
@@ -183,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);
|
||||
@@ -205,7 +206,7 @@ public class AccountingRules extends QueryRules {
|
||||
|
||||
String setCompetenzaDaDoc = setupGest.getSetup(connection, "CTB_MOVI", "SETUP", "COMPETENZA_IVA_" + gestione);
|
||||
|
||||
sql = "SELECT dbo.f_getDataLiquidazioneIva(" + UtilityDB.valueDateToString(ctbMovt.getDataDoc(), CommonConstants.DATE_FORMAT_YMD_SLASHED) + ")";
|
||||
sql = "SELECT dbo.f_getDataLiquidazioneIva(" + UtilityDB.valueDateToString(ctbMovt.getDataDoc(), CommonConstants.DATE_FORMAT_YMD) + ")";
|
||||
|
||||
Date dataCheck = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
|
||||
|
||||
@@ -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 {
|
||||
@@ -950,7 +955,7 @@ public class CommonRules extends QueryRules {
|
||||
BigDecimal rapConv = entity.getRapConv();
|
||||
|
||||
|
||||
LocalDate dataValidita = null;
|
||||
Date dataValidita = null;
|
||||
if (entity instanceof DtbOrdr || entity instanceof WdtbOrdr) {
|
||||
dataValidita = entity.getDataOrd();
|
||||
} else if (entity instanceof DtbDocr || entity instanceof WdtbDocr) {
|
||||
@@ -964,10 +969,10 @@ public class CommonRules extends QueryRules {
|
||||
return valUnt;
|
||||
}
|
||||
|
||||
public static BigDecimal completeValUntULTC(Connection conn, String codMdep, String codMart, LocalDate dataValidita, BigDecimal rapConv) throws Exception {
|
||||
public static BigDecimal completeValUntULTC(Connection conn, String codMdep, String codMart, Date dataValidita, BigDecimal rapConv) throws Exception {
|
||||
if (rapConv.compareTo(BigDecimal.ZERO) == 0) rapConv = BigDecimal.ONE;
|
||||
String sql = "SELECT Round(isNull(dbo.f_GetCostoUltArt_depo("
|
||||
+ UtilityDB.valueToString(dataValidita) + ","
|
||||
+ UtilityDB.valueDateToString(dataValidita, CommonConstants.DATE_FORMAT_YMD) + ","
|
||||
+ UtilityDB.valueToString(codMdep) + "," + UtilityDB.valueToString(codMart) + "), 0)*" + UtilityDB.valueToString(rapConv) + ", 5) as costo_ult";
|
||||
BigDecimal valUnt = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
return valUnt;
|
||||
@@ -976,7 +981,7 @@ public class CommonRules extends QueryRules {
|
||||
|
||||
public static BigDecimal completeValUntDIST(Connection conn, EntityBase entity) throws SQLException {
|
||||
String codMart = null, codMdep = null;
|
||||
LocalDate dataValidita = null;
|
||||
Date dataValidita = null;
|
||||
if (entity instanceof DtbOrdr) {
|
||||
codMart = ((DtbOrdr) entity).getCodMart();
|
||||
codMdep = ((DtbOrdr) entity).getCodMdep();
|
||||
@@ -994,7 +999,7 @@ public class CommonRules extends QueryRules {
|
||||
+ UtilityDB.valueToString(codMart) + ","
|
||||
+ "1, "
|
||||
+ "0, "
|
||||
+ UtilityDB.valueToString(dataValidita) + ","
|
||||
+ UtilityDB.valueDateToString(dataValidita, CommonConstants.DATE_FORMAT_YMD) + ","
|
||||
+ UtilityDB.valueToString(codMdep) + ") as costo_dist";
|
||||
BigDecimal valUnt = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
if (valUnt == null)
|
||||
@@ -1005,7 +1010,7 @@ public class CommonRules extends QueryRules {
|
||||
|
||||
public static BigDecimal completeValUntCMED(Connection conn, EntityBase entity) throws SQLException {
|
||||
String codMart = null;
|
||||
LocalDate dataValidita = null;
|
||||
Date dataValidita = null;
|
||||
if (entity instanceof DtbOrdr) {
|
||||
codMart = ((DtbOrdr) entity).getCodMart();
|
||||
dataValidita = ((DtbOrdr) entity).getDataOrd();
|
||||
@@ -1014,7 +1019,7 @@ public class CommonRules extends QueryRules {
|
||||
dataValidita = ((MtbInvenr) entity).getDataInventario();
|
||||
}
|
||||
String sql = "SELECT dbo.f_GetCostoMedArt("
|
||||
+ UtilityDB.valueToString(dataValidita) + ","
|
||||
+ UtilityDB.valueDateToString(dataValidita, CommonConstants.DATE_FORMAT_YMD) + ","
|
||||
+ UtilityDB.valueToString(codMart) + ") as costo_med";
|
||||
List<HashMap<String, Object>> list = execQuery(conn, sql);
|
||||
if (list.isEmpty()) {
|
||||
@@ -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);
|
||||
@@ -1170,7 +1176,7 @@ public class CommonRules extends QueryRules {
|
||||
" FROM wdtb_doct " +
|
||||
" WHERE wdtb_doct.cod_anag = " + UtilityDB.valueToString(entity.getCodAnag()) + " AND " +
|
||||
" wdtb_doct.cod_dtip = " + UtilityDB.valueToString(entity.getCodDtip()) + " AND " +
|
||||
" wdtb_doct.data_doc = " + UtilityDB.valueToString(entity.getDataDoc()) + " AND " +
|
||||
" wdtb_doct.data_doc = " + UtilityDB.valueDateToString(entity.getDataDoc(), CommonConstants.DATE_FORMAT_YMD) + " AND " +
|
||||
" wdtb_doct.ser_doc = " + UtilityDB.valueToString(entity.getSerDoc()) + " AND " +
|
||||
" wdtb_doct.num_doc = " + UtilityDB.valueToString(entity.getNumDoc());
|
||||
|
||||
@@ -1311,41 +1317,28 @@ public class CommonRules extends QueryRules {
|
||||
return maxProgressivoUl + 1;
|
||||
}
|
||||
|
||||
public static int retrieveNextProgressivoUlRG(Connection conn, String gestione, LocalDate dataOrd, int numOrd, int segno, String codJfas) throws Exception {
|
||||
return CommonRules.retrieveNextProgressivoUlRG(conn, gestione, dataOrd, numOrd, segno, codJfas, null);
|
||||
}
|
||||
|
||||
public static int retrieveNextProgressivoUlRG(Connection conn, String gestione, LocalDate dataOrd, int numOrd, int segno, String codJfas, String partitaMag) throws Exception {
|
||||
// boolean isScadenzaMultipla = setupGest.getSetupDetBoolean(conn, "MES", "SETUP", "CONTROLLO_SCADENZA_MULTIPLA", codJfas);
|
||||
// if (!isScadenzaMultipla) {
|
||||
// return retrieveNextProgressivoUl(conn, gestione, dataOrd, numOrd, segno);
|
||||
// }
|
||||
|
||||
partitaMag = UtilityString.isNull(partitaMag, "dot.partita_mag");
|
||||
|
||||
public static int retrieveNextProgressivoUlRG(Connection conn, String gestione, LocalDate dataOrd, int numOrd, int segno) throws SQLException {
|
||||
String sql = Query.format(
|
||||
"WITH partite AS (SELECT dot.cod_prod AS cod_mart, mpm.partita_mag_prod, dot.cod_jfas\n" +
|
||||
" FROM dtb_ordt dot\n" +
|
||||
" INNER JOIN mtb_partita_mag mpm\n" +
|
||||
" ON dot.cod_prod = mpm.cod_mart AND [partitaMag] = mpm.partita_mag\n" +
|
||||
" WHERE dot.data_ord = %s\n" +
|
||||
" AND dot.num_ord = %s\n" +
|
||||
" AND dot.gestione = [gestione])\n" +
|
||||
"SELECT ISNULL(MAX(progressivo_ul), 0) AS progressivo_ul\n" +
|
||||
"FROM mtb_colt\n" +
|
||||
" INNER JOIN mtb_colr mcr ON mtb_colt.gestione = mcr.gestione AND mtb_colt.data_collo = mcr.data_collo AND\n" +
|
||||
" mtb_colt.ser_collo = mcr.ser_collo AND mtb_colt.num_collo = mcr.num_collo\n" +
|
||||
" INNER JOIN mtb_partita_mag mpm ON mcr.cod_mart = mpm.cod_mart AND mcr.partita_mag = mpm.partita_mag\n" +
|
||||
" INNER JOIN partite ON mcr.cod_mart = partite.cod_mart AND mpm.partita_mag_prod = partite.partita_mag_prod\n" +
|
||||
" AND mtb_colt.cod_jfas = partite.cod_jfas\n" +
|
||||
"WHERE mtb_colt.gestione = [gestione]\n" +
|
||||
" AND segno = %s",
|
||||
dataOrd,
|
||||
numOrd,
|
||||
segno
|
||||
)
|
||||
.replace("[partitaMag]", partitaMag.equalsIgnoreCase("dot.partita_mag") ? partitaMag : UtilityDB.valueToString(partitaMag))
|
||||
.replace("[gestione]", UtilityDB.valueToString(gestione));
|
||||
"WITH partite AS (SELECT dot.cod_prod AS cod_mart, mpm.partita_mag_prod, dot.cod_jfas\n" +
|
||||
" FROM dtb_ordt dot\n" +
|
||||
" INNER JOIN mtb_partita_mag mpm\n" +
|
||||
" ON dot.cod_prod = mpm.cod_mart AND dot.partita_mag = mpm.partita_mag\n" +
|
||||
" WHERE dot.data_ord = %s\n" +
|
||||
" AND dot.num_ord = %s\n" +
|
||||
" AND dot.gestione = [gestione])\n" +
|
||||
"SELECT ISNULL(MAX(progressivo_ul), 0) AS progressivo_ul\n" +
|
||||
"FROM mtb_colt\n" +
|
||||
" INNER JOIN mtb_colr mcr ON mtb_colt.gestione = mcr.gestione AND mtb_colt.data_collo = mcr.data_collo AND\n" +
|
||||
" mtb_colt.ser_collo = mcr.ser_collo AND mtb_colt.num_collo = mcr.num_collo\n" +
|
||||
" INNER JOIN mtb_partita_mag mpm ON mcr.cod_mart = mpm.cod_mart AND mcr.partita_mag = mpm.partita_mag\n" +
|
||||
" INNER JOIN partite ON mcr.cod_mart = partite.cod_mart AND mpm.partita_mag_prod = partite.partita_mag_prod\n" +
|
||||
" AND mtb_colt.cod_jfas = partite.cod_jfas\n" +
|
||||
"WHERE mtb_colt.gestione = [gestione]\n" +
|
||||
" AND segno = %s",
|
||||
dataOrd,
|
||||
numOrd,
|
||||
segno
|
||||
).replace("[gestione]", UtilityDB.valueToString(gestione));
|
||||
|
||||
int maxProgressivoUl = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
return maxProgressivoUl + 1;
|
||||
@@ -1354,7 +1347,7 @@ public class CommonRules extends QueryRules {
|
||||
public static void updateDatiInv(Connection conn, DtbDoct entity) throws Exception {
|
||||
String codAnagOld = null, serDocOld = null, codDtipOld = null;
|
||||
Integer numDocOld = null;
|
||||
LocalDate dataDocOld = null;
|
||||
Date dataDocOld = null;
|
||||
|
||||
HashMap<String, Object> oldPk = entity.getOldPk();
|
||||
if (oldPk != null && !oldPk.isEmpty()) {
|
||||
@@ -1363,7 +1356,7 @@ public class CommonRules extends QueryRules {
|
||||
else codAnagOld = entity.getCodAnag();
|
||||
if (oldPk.containsKey("codDtip")) codDtipOld = (String) oldPk.get("codDtip");
|
||||
else codDtipOld = entity.getCodDtip();
|
||||
if (oldPk.containsKey("dataDoc")) dataDocOld = UtilityString.parseLocalDate((String) oldPk.get("dataDoc"));
|
||||
if (oldPk.containsKey("dataDoc")) dataDocOld = UtilityString.parseDate((String) oldPk.get("dataDoc"));
|
||||
else dataDocOld = entity.getDataDoc();
|
||||
if (oldPk.containsKey("serDoc")) serDocOld = (String) oldPk.get("serDoc");
|
||||
else serDocOld = entity.getSerDoc();
|
||||
@@ -1379,7 +1372,7 @@ public class CommonRules extends QueryRules {
|
||||
"UPDATE mtb_invent " +
|
||||
"SET cod_anag = " + UtilityDB.valueToString(entity.getCodAnag()) + ", " +
|
||||
"cod_dtip = " + UtilityDB.valueToString(entity.getCodDtip()) + ", " +
|
||||
"data_doc = " + UtilityDB.valueToString(entity.getDataDoc()) + ", " +
|
||||
"data_doc = " + UtilityDB.valueDateToString(entity.getDataDoc(), CommonConstants.DATE_FORMAT_YMD) + ", " +
|
||||
"ser_doc = " + UtilityDB.valueToString(entity.getSerDoc()) + ", " +
|
||||
"num_doc = " + UtilityDB.valueToString(entity.getNumDoc());
|
||||
sql = UtilityDB.addwhereCond(sql, entity.getWhereCondOldPk(null), false);
|
||||
@@ -1403,4 +1396,61 @@ public class CommonRules extends QueryRules {
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@ import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@@ -40,7 +39,7 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
segno = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
}
|
||||
|
||||
LocalDate dataReg = null, dataValidita = null;
|
||||
Date dataReg = null, dataValidita = null;
|
||||
if (row instanceof DtbDocr) {
|
||||
dataReg = ((DtbDocr) row).getDataReg();
|
||||
dataValidita = ((DtbDocr) row).getDataDoc();
|
||||
@@ -191,22 +190,22 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
componenti.add(rigaDocOrd);
|
||||
} else if (!esponiComp && "C".equals(flagCalcPrz)) {
|
||||
if (CommonConstants.ULTC.equalsIgnoreCase(listino)) {
|
||||
sql = " SELECT dbo.f_GetCostoUltArt_depo( " + UtilityDB.valueToString(dataReg) + ", "
|
||||
sql = " SELECT dbo.f_GetCostoUltArt_depo( " + UtilityDB.valueDateToString(dataReg, CommonConstants.DATE_FORMAT_YMD) + ", "
|
||||
+ UtilityDB.valueToString(codMdep) + ", "
|
||||
+ UtilityDB.valueToString(codComp) + ") as val_unt ";
|
||||
} else if ("V".equalsIgnoreCase(gestione)) {
|
||||
if (flagPrzIva) {
|
||||
sql = "SELECT dbo.f_getPrzVendIva(" + UtilityDB.valueToString(dataValidita) + ", "
|
||||
sql = "SELECT dbo.f_getPrzVendIva(" + UtilityDB.valueDateToString(dataValidita, CommonConstants.DATE_FORMAT_YMD) + ", "
|
||||
+ UtilityDB.valueToString(listino) + ","
|
||||
+ UtilityDB.valueToString(codComp) + ", 'S' ) as val_unt ";
|
||||
} else {
|
||||
sql = "SELECT dbo.f_getPrzVend(" + UtilityDB.valueToString(dataValidita) + ", "
|
||||
sql = "SELECT dbo.f_getPrzVend(" + UtilityDB.valueDateToString(dataValidita, CommonConstants.DATE_FORMAT_YMD) + ", "
|
||||
+ UtilityDB.valueToString(listino) + ","
|
||||
+ UtilityDB.valueToString(codComp) + ", 'S' ) as val_unt ";
|
||||
}
|
||||
|
||||
} else if ("A".equalsIgnoreCase(gestione)) {
|
||||
sql = "SELECT dbo.f_getPrzNettoAcqArt (" + UtilityDB.valueToString(dataValidita) + ", "
|
||||
sql = "SELECT dbo.f_getPrzNettoAcqArt (" + UtilityDB.valueDateToString(dataValidita, CommonConstants.DATE_FORMAT_YMD) + ", "
|
||||
+ UtilityDB.valueToString(listino) + ", "
|
||||
+ "NULL, "
|
||||
+ UtilityDB.valueToString(codComp) + ") as val_unt ";
|
||||
@@ -241,7 +240,7 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
public static void calcSconti(Connection conn, DtbDoct testata) throws Exception {
|
||||
List<DtbDocOrdR> rows = new ArrayList<>(Stream.of(testata.getDtbDocr()).filter(x -> x.getRigaOrd() == null).toList());
|
||||
|
||||
calcSconti(conn, UtilityLocalDate.localDateToDate(testata.getDataDoc()), rows);
|
||||
calcSconti(conn, testata.getDataDoc(), rows);
|
||||
|
||||
testata.setDtbDocr(Stream.of(rows).map(x -> (DtbDocr) x).toList());
|
||||
testata.getDtbDocr().addAll(Stream.of(testata.getDtbDocr()).filter(x -> x.getRigaOrd() != null).toList());
|
||||
@@ -266,7 +265,7 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
|
||||
for (HashMap<String, String> artLisv : distinctArtLisv) {
|
||||
String sql = "SELECT cod_mart, sconto_cartoni, sconto_strato, sconto_pedane " +
|
||||
"FROM getListinoVendita (" + UtilityDB.valueDateToString(dataListino, CommonConstants.DATE_FORMAT_YMD_DASHED) + ", " +
|
||||
"FROM getListinoVendita (" + UtilityDB.valueDateToString(dataListino, CommonConstants.DATE_FORMAT_YMD) + ", " +
|
||||
UtilityDB.valueToString(UtilityHashMap.getValueIfExists(artLisv, "listino")) + ", " +
|
||||
UtilityDB.valueToString(UtilityHashMap.getValueIfExists(artLisv, "cod_mart")) + ")";
|
||||
|
||||
@@ -473,7 +472,7 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
|
||||
//Dati Bolla
|
||||
String codDtipBolla = null, serDocBolla = null;
|
||||
LocalDate dataDocBolla = null;
|
||||
Date dataDocBolla = null;
|
||||
Integer numDocBolla = null;
|
||||
|
||||
if (testata.getOperation() == OperationType.NO_OP) {
|
||||
@@ -648,12 +647,12 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
}
|
||||
throw new Exception(String.format(
|
||||
"Impossibile salvare l'ordine %s del %s n. %s, riga %s senza aliquota IVA",
|
||||
gestione, CommonConstants.DATE_DMY_SLASHED_FORMATTER.format(row.getDataOrd()), row.getNumOrd(), riga));
|
||||
gestione, UtilityDate.formatDate(row.getDataOrd(), CommonConstants.DATE_FORMAT_DMY), row.getNumOrd(), riga));
|
||||
} else {
|
||||
throw new Exception(String.format(
|
||||
"Impossibile salvare il documento %s del %s n. %s/%s, articolo %s senza aliquota IVA",
|
||||
((DtbBaseDocR) row).getCodDtip(),
|
||||
CommonConstants.DATE_DMY_SLASHED_FORMATTER.format(((DtbBaseDocR) row).getDataDoc()),
|
||||
UtilityDate.formatDate(((DtbBaseDocR) row).getDataDoc(), CommonConstants.DATE_FORMAT_DMY),
|
||||
((DtbBaseDocR) row).getSerDoc(),
|
||||
((DtbBaseDocR) row).getNumDoc(), (codMart == null ? "" : codMart + " - ") + row.getDescrizione()
|
||||
));
|
||||
@@ -726,7 +725,7 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
" FROM dtb_docr " +
|
||||
" WHERE dtb_docr.cod_anag = " + UtilityDB.valueToString(dtbDocr.getCodAnag()) + " AND " +
|
||||
"dtb_docr.cod_dtip = " + UtilityDB.valueToString(dtbDocr.getCodDtipBolla()) + " AND " +
|
||||
"dtb_docr.data_doc = " + UtilityDB.valueDateToString(dtbDocr.getDataDocBolla(), CommonConstants.DATE_FORMAT_YMD_DASHED) + " AND " +
|
||||
"dtb_docr.data_doc = " + UtilityDB.valueDateToString(dtbDocr.getDataDocBolla(), CommonConstants.DATE_FORMAT_YMD) + " AND " +
|
||||
"dtb_docr.ser_doc = " + UtilityDB.valueToString(dtbDocr.getSerDocBolla()) + " AND " +
|
||||
"dtb_docr.num_doc = " + UtilityDB.valueToString(dtbDocr.getNumDocBolla()) + " AND " +
|
||||
"dtb_docr.id_riga = " + UtilityDB.valueToString(dtbDocr.getIdRigaBolla());
|
||||
@@ -1184,7 +1183,7 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
}
|
||||
|
||||
private static List<CostiDTO> addCosti(final DtbDocr dtbDocr, List<
|
||||
BigDecimal> sconti, List<CostiDTO> listaCosti, String codJfasTestata) {
|
||||
BigDecimal> sconti, List<CostiDTO> listaCosti, String codJfasTestata) throws Exception {
|
||||
BigDecimal importo = dtbDocr.getImportoRiga();
|
||||
for (BigDecimal sconto : sconti) {
|
||||
if (sconto != null) {
|
||||
@@ -1195,8 +1194,8 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
|
||||
if (!UtilityBigDecimal.isNullOrZero(importo)) {
|
||||
String codJfas = UtilityString.isNull(dtbDocr.getCodJfas(), codJfasTestata);
|
||||
Date dataInizComp = UtilityDate.isNull(dtbDocr.getDataInizComp(), UtilityLocalDate.localDateToDate(dtbDocr.getDataDoc()));
|
||||
Date dataFineComp = UtilityDate.isNull(dtbDocr.getDataFineComp(), UtilityLocalDate.localDateToDate(dtbDocr.getDataDoc()));
|
||||
Date dataInizComp = UtilityDate.isNull(dtbDocr.getDataInizComp(), dtbDocr.getDataDoc());
|
||||
Date dataFineComp = UtilityDate.isNull(dtbDocr.getDataFineComp(), dtbDocr.getDataDoc());
|
||||
Optional<CostiDTO> optCosti = Stream.of(listaCosti)
|
||||
.filter(value -> UtilityString.equalsIgnoreCase(value.getCodCcon(), dtbDocr.getCodCcon()) &&
|
||||
UtilityString.equalsIgnoreCase(value.getCodJcom(), dtbDocr.getCodJcom()) &&
|
||||
@@ -1261,7 +1260,7 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
" FROM mtb_spes INNER JOIN gtb_spes ON gtb_spes.cod_spes = mtb_spes.cod_spes " +
|
||||
" INNER JOIN mtb_aart ON mtb_aart.cod_mart = mtb_spes.cod_mart " +
|
||||
" LEFT OUTER JOIN mtb_unt_mis ON gtb_spes.unt_mis = mtb_unt_mis.unt_mis " +
|
||||
" LEFT OUTER JOIN dbo.getDatiCodSpesCONAI(null, " + UtilityDB.valueToString(testata.getCodAnag()) + ", " + UtilityDB.valueToString(testata.getDataDoc()) + ")spesConai ON mtb_spes.cod_spes = spesConai.cod_conai " +
|
||||
" LEFT OUTER JOIN dbo.getDatiCodSpesCONAI(null, " + UtilityDB.valueToString(testata.getCodAnag()) + ", " + UtilityDB.valueDateToString(testata.getDataDoc(), CommonConstants.DATE_FORMAT_YMD) + ")spesConai ON mtb_spes.cod_spes = spesConai.cod_conai " +
|
||||
" WHERE mtb_spes.cod_mart = " + UtilityDB.valueToString(row.getCodMart()) + " AND " +
|
||||
" mtb_spes.flag_inc_in_prz = 'N' AND " +
|
||||
" dbo.f_chkFlagSpesaArtGestione(mtb_spes.cod_mart, mtb_spes.cod_spes, " + UtilityDB.valueToString(testata.getGestione()) + ") = 'S'";
|
||||
@@ -1411,7 +1410,7 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
private static Integer setDtbDocs(DtbDoct testata, List<CtbMovi> castelletto,
|
||||
GtbSpes gtbSpes, BigDecimal qta, BigDecimal importo,
|
||||
List<DtbDocs> speseCalc, Integer maxRigaSpesa,
|
||||
Boolean ventilazione) {
|
||||
Boolean ventilazione) throws Exception {
|
||||
maxRigaSpesa++;
|
||||
DtbDocs dtbDocs = new DtbDocs();
|
||||
dtbDocs.setEntityHolder(testata.getEntityHolder());
|
||||
@@ -1637,7 +1636,7 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
"SELECT saldo " +
|
||||
" FROM dbo.GetSaldoContoAnalitico(" + UtilityDB.valueToString(testata.getDtbTipi().getCodCcauAnt()) + ','
|
||||
+ UtilityDB.valueToString(testata.getCodAnag()) + ","
|
||||
+ UtilityDB.valueToString(testata.getDataDoc()) + ")";
|
||||
+ UtilityDB.valueDateToString(testata.getDataDoc(), CommonConstants.DATE_FORMAT_YMD) + ")";
|
||||
BigDecimal saldoAcconto = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
|
||||
if (UtilityBigDecimal.isNullOrZero(saldoAcconto)) {
|
||||
@@ -1655,7 +1654,7 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
} else if (DtbTipi.AccontoDa.fromValue(testata.getDtbTipi().getFlagAcconto()) == DtbTipi.AccontoDa.BOLLA && testata.getDtbTipi().getTipoEmissioneEnum() == TipoEmissione.DIFFERITA) {
|
||||
List<DtbDoct> elencoBolle = Stream.of(testata.getDtbDoctBolle()).distinctBy(dtbDoct -> dtbDoct.getCodAnag() + " - " +
|
||||
dtbDoct.getCodDtip() + " - " +
|
||||
CommonConstants.DATE_YMD_DASHED_FORMATTER.format(dtbDoct.getDataDoc()) + " - " +
|
||||
UtilityDate.formatDate(dtbDoct.getDataDoc(), CommonConstants.DATETIME_FORMAT_YMD) + " - " +
|
||||
dtbDoct.getSerDoc() + " - " +
|
||||
dtbDoct.getNumDoc()).toList();
|
||||
for (DtbDoct bolla : elencoBolle) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.annimon.stream.Stream;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.base.EntityInterface;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.db.ResultSetMapper;
|
||||
import it.integry.ems_model.entity.*;
|
||||
@@ -23,7 +24,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -52,7 +53,7 @@ public class DocOrdRules extends QueryRules {
|
||||
"SELECT DISTINCT id_viaggio " +
|
||||
" FROM dtb_ordr " +
|
||||
"WHERE gestione = " + UtilityDB.valueToString(ordT.getGestione()) + " AND " +
|
||||
" data_ord = " + UtilityDB.valueToString(ordT.getDataOrd()) + " AND " +
|
||||
" data_ord = " + UtilityDB.valueDateToString(ordT.getDataOrd(), CommonConstants.DATE_FORMAT_YMD) + " AND " +
|
||||
" num_ord = " + UtilityDB.valueToString(ordT.getNumOrd()) + " AND " +
|
||||
" id_viaggio IS NOT NULL;";
|
||||
PreparedStatement ps = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
@@ -115,7 +116,7 @@ public class DocOrdRules extends QueryRules {
|
||||
String listino = entity.getListino();
|
||||
String gestione = entity.getGestione();
|
||||
|
||||
LocalDate dataDivisa;
|
||||
Date dataDivisa;
|
||||
String errorMessage;
|
||||
|
||||
if (entity instanceof DtbDoct || entity instanceof WdtbDoct) {
|
||||
@@ -154,7 +155,7 @@ public class DocOrdRules extends QueryRules {
|
||||
codDivi = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, query);
|
||||
|
||||
if (UtilityString.isNullOrEmpty(codDivi)) {
|
||||
query = "SELECT cod_divi_cont_prima as cod_divi from gtb_anni_divi WHERE anno = DatePart(yy, " + UtilityDB.valueToString(dataDivisa) + ")";
|
||||
query = "SELECT cod_divi_cont_prima as cod_divi from gtb_anni_divi WHERE anno = DatePart(yy, " + UtilityDB.valueDateToString(dataDivisa, CommonConstants.DATE_FORMAT_YMD) + ")";
|
||||
codDivi = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, query);
|
||||
}
|
||||
|
||||
@@ -365,6 +366,7 @@ public class DocOrdRules extends QueryRules {
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (isOrdine) {
|
||||
sql = "SELECT gtb_spes.descrizione, "
|
||||
+ " CAST(0 AS NUMERIC(20, 5)) as qta, "
|
||||
@@ -376,6 +378,7 @@ public class DocOrdRules extends QueryRules {
|
||||
+ " gtb_divi "
|
||||
+ " WHERE gtb_divi.cod_divi = " + UtilityDB.valueToString(codDivi) + " and "
|
||||
+ " gtb_spes.cod_spes = " + UtilityDB.valueToString(codSpes);
|
||||
|
||||
} else {
|
||||
sql = "SELECT gtb_spes.descrizione, "
|
||||
+ " CAST(0 AS NUMERIC(20, 5)) as qta, "
|
||||
@@ -417,6 +420,8 @@ public class DocOrdRules extends QueryRules {
|
||||
} else if (columnName.equals("untMis")) {
|
||||
columnValue = untMisServ;
|
||||
}
|
||||
} else if (spese instanceof DtbOrds && ((DtbOrds) spese).getValUnt() != null && columnName.equals("importo")) {
|
||||
valueEntity = ((DtbOrds) spese).getValUnt().multiply(((DtbOrds) spese).getQta());
|
||||
}
|
||||
|
||||
if (valueEntity == null) {
|
||||
@@ -613,24 +618,24 @@ public class DocOrdRules extends QueryRules {
|
||||
}
|
||||
|
||||
|
||||
public static BigDecimal completeDatiQtaInProdOrd(Connection conn, DtbOrdSteps entity) throws Exception {
|
||||
public static BigDecimal completeDatiQtaInProdOrd(Connection conn, EntityBase entity) throws Exception {
|
||||
HashMap<String, Object> campi = new HashMap<String, Object>();
|
||||
BigDecimal qtaImmesseDB = BigDecimal.ZERO, qtaScartateDB = BigDecimal.ZERO, qtaTrasferiteDB = BigDecimal.ZERO, qtaInProdNew = BigDecimal.ZERO;
|
||||
|
||||
LocalDate dataOrd = entity.getDataOrd();
|
||||
Integer numOrd = entity.getNumOrd();
|
||||
String gestione = entity.getGestione();
|
||||
Integer idRiga = entity.getIdRiga();
|
||||
Integer idStep = entity.getIdStep();
|
||||
BigDecimal qtaImmessa = entity.getQtaImmesse();
|
||||
BigDecimal qtaTrasferite = entity.getQtaTrasferite();
|
||||
BigDecimal qtaScartate = entity.getQtaScartate();
|
||||
Date dataOrd = (Date) DroolsUtil.getEntityFieldValue(entity, "data_ord");
|
||||
Integer numOrd = (Integer) DroolsUtil.getEntityFieldValue(entity, "num_ord");
|
||||
String gestione = (String) DroolsUtil.getEntityFieldValue(entity, "gestione");
|
||||
Integer idRiga = (Integer) DroolsUtil.getEntityFieldValue(entity, "id_riga");
|
||||
Integer idStep = (Integer) DroolsUtil.getEntityFieldValue(entity, "id_step");
|
||||
BigDecimal qtaImmessa = (BigDecimal) DroolsUtil.getEntityFieldValue(entity, "qta_immesse");
|
||||
BigDecimal qtaTrasferite = (BigDecimal) DroolsUtil.getEntityFieldValue(entity, "qta_trasferite");
|
||||
BigDecimal qtaScartate = (BigDecimal) DroolsUtil.getEntityFieldValue(entity, "qta_scartate");
|
||||
|
||||
String query =
|
||||
" select qta_immesse, qta_trasferite, qta_scartate, qta_in_prod " +
|
||||
" from dtb_ord_steps " +
|
||||
" where gestione = " + UtilityDB.valueToString(gestione) + " and " +
|
||||
" data_ord = " + UtilityDB.valueToString(dataOrd) + " and " +
|
||||
" data_ord = " + UtilityDB.valueDateToString(dataOrd, CommonConstants.DATE_FORMAT_YMD) + " and " +
|
||||
" num_ord = " + UtilityDB.valueToString(numOrd) + " and " +
|
||||
" id_riga = " + UtilityDB.valueToString(idRiga) + " and " +
|
||||
" id_step = " + UtilityDB.valueToString(idStep);
|
||||
@@ -674,7 +679,7 @@ public class DocOrdRules extends QueryRules {
|
||||
" from (select gestione, data_ord, num_ord, cod_jfas, num_fase, MAX(id_step) as id_step_max " +
|
||||
" from dtb_ord_steps " +
|
||||
" where gestione = " + UtilityDB.valueToString(dtbOrdSteps.getGestione()) + " and " +
|
||||
" data_ord = " + UtilityDB.valueToString(dtbOrdSteps.getDataOrd()) + " and " +
|
||||
" data_ord = " + UtilityDB.valueDateToString(dtbOrdSteps.getDataOrd(), CommonConstants.DATE_FORMAT_YMD) + " and " +
|
||||
" num_ord = " + UtilityDB.valueToString(dtbOrdSteps.getNumOrd()) + " and " +
|
||||
" num_fase = " + UtilityDB.valueToString(dtbOrdSteps.getNumFase()) + " and " +
|
||||
" cod_jfas = " + UtilityDB.valueToString(dtbOrdSteps.getCodJfas()) + " " +
|
||||
@@ -812,7 +817,7 @@ public class DocOrdRules extends QueryRules {
|
||||
public static DtbDocr completeDatiDocComp(Connection connection, DtbDocr dtbDocr) throws Exception {
|
||||
if (!dtbDocr.getCodDtip().equalsIgnoreCase(dtbDocr.getCodDtipComp()) ||
|
||||
!dtbDocr.getSerDoc().equalsIgnoreCase(dtbDocr.getSerDocComp()) ||
|
||||
!dtbDocr.getDataDoc().isEqual(dtbDocr.getDataDocComp()) ||
|
||||
dtbDocr.getDataDoc().compareTo(dtbDocr.getDataDocComp()) != 0 ||
|
||||
!dtbDocr.getNumDoc().equals(dtbDocr.getNumDocComp())) {
|
||||
String sql =
|
||||
"SELECT TOP 1 * " +
|
||||
@@ -972,12 +977,12 @@ public class DocOrdRules extends QueryRules {
|
||||
.setGeneraOrdLavDaProd(false);
|
||||
dtbOrdtProd.setOperation(OperationType.NO_OP);
|
||||
|
||||
/*
|
||||
/*
|
||||
BigDecimal valUnt = new BigDecimal(0);
|
||||
if (dtbOrdt.getQtaProd().compareTo(BigDecimal.ZERO) > 0) {
|
||||
valUnt = dtbOrdt.getTotImponib().divide(dtbOrdt.getQtaProd(), 5, BigDecimal.ROUND_HALF_UP);
|
||||
}*/
|
||||
|
||||
}
|
||||
*/
|
||||
DtbOrdr dtbOrdrProd =
|
||||
new DtbOrdr().setRigaOrd(dtbOrdt.getRigaOrdRif());
|
||||
if (dtbOrdt.getOperation() == OperationType.DELETE) {
|
||||
@@ -993,7 +998,7 @@ public class DocOrdRules extends QueryRules {
|
||||
.setRapConv(dtbOrdt.getRapConvProd())
|
||||
.setQtaOrd(dtbOrdt.getQtaProd())
|
||||
.setQtaEvasa(dtbOrdt.getQtaEvasaProd())
|
||||
/*.setValUnt(valUnt)*/
|
||||
//.setValUnt(valUnt)
|
||||
.setSconto5(dtbOrdt.getSconto1())
|
||||
.setSconto6(dtbOrdt.getSconto2())
|
||||
.setSconto7(dtbOrdt.getSconto3())
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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 =
|
||||
@@ -69,7 +69,7 @@ public class DocumentRules extends QueryRules {
|
||||
Integer numDocOld = entity.getNumDoc() == null ? 0 : entity.getNumDoc();
|
||||
String tipoNumeraz = entity.getDtbTipi().getTipoNumeraz();
|
||||
if (!tipoNumeraz.equalsIgnoreCase("MANUALE")) {
|
||||
LocalDate dataDoc = entity.getDataDoc();
|
||||
Date dataDoc = entity.getDataDoc();
|
||||
String serDoc = entity.getSerDoc();
|
||||
String codIreg = entity.getDtbTipi().getCodIreg();
|
||||
Integer numIreg = entity.getDtbTipi().getNumIreg();
|
||||
@@ -86,125 +86,9 @@ public class DocumentRules extends QueryRules {
|
||||
return numDocNew;
|
||||
}
|
||||
|
||||
public static Boolean chkNumeroFuoriSequenza(Connection conn, DtbDoct entity) {
|
||||
Boolean numeroFuoriSequenza = false;
|
||||
/*
|
||||
int li_annoDoc, li_numIreg, li_numDoc, li_count;
|
||||
String ls_codIreg, ls_tipoNumeraz, ls_serDoc;
|
||||
Date ld_dataDoc = null;
|
||||
ResultSet res;
|
||||
boolean lb_returnVal;
|
||||
PreparedStatement Info;
|
||||
SimpleDateFormat annoFormat = new SimpleDateFormat("yyyy");
|
||||
return_class lcl_return = new return_class();
|
||||
public static Integer nextNumDoc(Connection conn, Date dataDoc, String codIreg, String serDoc, Integer numIreg, Integer numDoc) throws SQLException {
|
||||
|
||||
try{
|
||||
|
||||
// ACQUISIZIONE DATI DOCUMENTO
|
||||
li_annoDoc = Integer.valueOf(annoFormat.format(getDataDoc())).intValue();
|
||||
li_numDoc = getNumDoc().intValue();
|
||||
ls_serDoc = getSerDoc();
|
||||
|
||||
// ACQUISIZIONE DATI TIPO DOCUMENTO
|
||||
lb_returnVal = true;
|
||||
ls_codIreg = getValueTipoDoc(nameFieldsTipiDoc.is_codIreg);
|
||||
li_numIreg = utilityNumber.StringToInt(getValueTipoDoc(nameFieldsTipiDoc.is_numIreg));
|
||||
ls_tipoNumeraz = getValueTipoDoc(nameFieldsTipiDoc.is_tipoNumeraz);
|
||||
|
||||
|
||||
if (ls_tipoNumeraz.compareTo(nameFieldsTipiDoc.is_tipoNumMANUALE) != 0){
|
||||
if (li_numDoc > 1){
|
||||
// CONTROLLO PRESENZA DOCUMENTO PRECEDENTE ALL'ATTUALE
|
||||
li_count = 0;
|
||||
is_query =
|
||||
"SELECT data_doc, " +
|
||||
" ser_doc, " +
|
||||
" num_doc " +
|
||||
" FROM dtb_doct, " +
|
||||
" dtb_tipi" +
|
||||
" WHERE dtb_doct.cod_dtip = dtb_tipi.cod_dtip and " +
|
||||
" dtb_tipi.cod_ireg = " + utilityDB.valueToString(ls_codIreg) + " AND " +
|
||||
" dtb_tipi.num_ireg = " + utilityDB.valueIntToString(li_numIreg) + " AND " +
|
||||
" Datepart(year, dtb_doct.data_doc) = " + utilityDB.valueIntToString(li_annoDoc) + " AND " +
|
||||
" ser_doc = " + utilityDB.valueToString(ls_serDoc) + " AND " +
|
||||
" num_doc = " + utilityDB.valueIntToString(li_numDoc -1);
|
||||
|
||||
Info = connect.prepareStatement(is_query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
res = Info.executeQuery();
|
||||
while(res.next()){
|
||||
li_count++;
|
||||
ld_dataDoc = res.getDate(1);
|
||||
ls_serDoc = res.getString(2);
|
||||
li_numDoc = res.getInt(3);
|
||||
}
|
||||
res.close();Info.close();
|
||||
|
||||
|
||||
if (li_count == 0){
|
||||
// ERRORE: NON ESISTE IL DOCUMENTO PRECEDENTE
|
||||
lb_returnVal = false;
|
||||
}else{
|
||||
if (ld_dataDoc.after(getDataDoc())){
|
||||
// ERRORE: IL DOCUMENTO PRECEDENTE HA DATA MAGGIORE
|
||||
lb_returnVal = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lb_returnVal == true){
|
||||
// CONTROLLO DELLA PRESENZA DEL DOCUMENTO SUCCESSIVO
|
||||
li_count = 0;
|
||||
is_query =
|
||||
"SELECT data_doc, " +
|
||||
" ser_doc, " +
|
||||
" num_doc " +
|
||||
" FROM dtb_doct, " +
|
||||
" dtb_tipi " +
|
||||
" WHERE dtb_doct.cod_dtip = dtb_tipi.cod_dtip and " +
|
||||
" dtb_tipi.cod_ireg = " + utilityDB.valueToString(ls_codIreg) + " AND " +
|
||||
" dtb_tipi.num_ireg = " + utilityDB.valueIntToString(li_numIreg) + " AND " +
|
||||
" Datepart(year, dtb_doct.data_doc) = " + utilityDB.valueIntToString(li_annoDoc) + " AND " +
|
||||
" ser_doc = " + utilityDB.valueToString(ls_serDoc) + " AND " +
|
||||
" num_doc = " + utilityDB.valueIntToString(li_numDoc + 1);
|
||||
|
||||
Info = connect.prepareStatement(is_query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
res = Info.executeQuery();
|
||||
while(res.next()){
|
||||
li_count++;
|
||||
ld_dataDoc = res.getDate(1);
|
||||
ls_serDoc = res.getString(2);
|
||||
li_numDoc = res.getInt(3);
|
||||
}
|
||||
res.close();Info.close();
|
||||
|
||||
if (li_count == 0){
|
||||
// NON ESISTE IL DOCUMENTO SUCCESSIVO
|
||||
if (ld_dataDoc != null){
|
||||
if (getDataDoc().before(ld_dataDoc)){
|
||||
// ERRORE: IL DOCUMENTO SUCCESSIVO A DATA MINORE
|
||||
lb_returnVal = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SEGNALAZIONE ERRORE
|
||||
if (lb_returnVal == false){
|
||||
lcl_return.setReturnId(GlobalVariables.stateKO);
|
||||
lcl_return.setErrorText("DOCUMENTO INTESTATO A " + getCodAnag() + " - " + getCodDtip() + " N° " + utilityString.IntegerToString(getNumDoc()) + "/" + getSerDoc() + " DEL " + utilityString.DateToString(getDataDoc(), "dd-MM-yyyy") + " FUORI SEQUENZA");
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
lcl_return = utilityOBJ.GetExceptionMessage(utilityOBJ.GetCurrentClassName(this), utilityOBJ.GetCurrentMethodName(this), getProfileDB(), e, is_query);
|
||||
}
|
||||
return lcl_return;
|
||||
*/
|
||||
return numeroFuoriSequenza;
|
||||
}
|
||||
|
||||
public static Integer nextNumDoc(Connection conn, LocalDate dataDoc, String codIreg, String serDoc, Integer numIreg, Integer numDoc) throws SQLException {
|
||||
|
||||
short anno = (short) dataDoc.getYear();
|
||||
Short anno = new Short(new SimpleDateFormat("yyyy").format(dataDoc));
|
||||
|
||||
CallableStatement cs = conn.prepareCall("{call dbo.NextNumDoc(?, ?, ?, ?, ?)}");
|
||||
|
||||
@@ -303,7 +187,7 @@ public class DocumentRules extends QueryRules {
|
||||
public static HashMap<String, Boolean> checkDatiContab(Connection conn, DtbDocr dtbDocr) throws Exception {
|
||||
|
||||
boolean isDocAp = false;
|
||||
LocalDate dataReg = dtbDocr.getDataDoc();
|
||||
Date dataReg = dtbDocr.getDataDoc();
|
||||
String codMdep = UtilityString.isNull(dtbDocr.getCodMdep(), ((DtbDoct) dtbDocr.getParent()).getCodMdep());
|
||||
if (dtbDocr.getTipoEmissione().equalsIgnoreCase(String.valueOf(TipoEmissione.DIFFERITA)) &&
|
||||
dtbDocr.getDataDocBolla() != null &&
|
||||
@@ -315,7 +199,7 @@ public class DocumentRules extends QueryRules {
|
||||
" FROM dtb_doct " +
|
||||
" WHERE cod_anag = " + UtilityDB.valueToString(dtbDocr.getCodAnag()) + " AND " +
|
||||
" cod_dtip = " + UtilityDB.valueToString(dtbDocr.getCodDtipBolla()) + " AND " +
|
||||
" data_doc = " + UtilityDB.valueToString(dtbDocr.getDataDocBolla()) + " AND " +
|
||||
" data_doc = " + UtilityDB.valueDateToString(dtbDocr.getDataDocBolla(), CommonConstants.DATE_FORMAT_YMD) + " AND " +
|
||||
" ser_doc = " + UtilityDB.valueToString(dtbDocr.getSerDocBolla()) + " AND " +
|
||||
" num_doc = " + UtilityDB.valueToString(dtbDocr.getNumDocBolla());
|
||||
dataReg = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
@@ -324,12 +208,12 @@ public class DocumentRules extends QueryRules {
|
||||
String sql = "SELECT anno_contab, anno_magaz FROM azienda";
|
||||
HashMap<String, Object> datiAzienda = UtilityDB.executeSimpleQueryOnlyFirstRow(conn, sql);
|
||||
|
||||
int annoContab = Integer.parseInt(datiAzienda.get("anno_contab").toString());
|
||||
int annoMagaz = Integer.parseInt(datiAzienda.get("anno_magaz").toString());
|
||||
Integer annoContab = Integer.parseInt(datiAzienda.get("anno_contab").toString());
|
||||
Integer annoMagaz = Integer.parseInt(datiAzienda.get("anno_magaz").toString());
|
||||
|
||||
short annoCompCosto = AccountingRules.getAnnoComp(conn, dataReg).shortValue();
|
||||
Short annoCompCosto = AccountingRules.getAnnoComp(conn, dataReg).shortValue();
|
||||
|
||||
short annoCompDoc = AccountingRules.getAnnoComp(conn, dtbDocr.getDataReg()).shortValue();
|
||||
Short annoCompDoc = AccountingRules.getAnnoComp(conn, dtbDocr.getDataReg()).shortValue();
|
||||
|
||||
if (annoCompCosto < annoCompDoc && annoContab == annoCompDoc - 1 && annoMagaz == annoCompDoc - 1) {
|
||||
isDocAp = true;
|
||||
@@ -360,11 +244,11 @@ public class DocumentRules extends QueryRules {
|
||||
String codJfas = null;
|
||||
if ("L".compareTo(gestione) == 0) {
|
||||
Integer numord = entity.getNumOrd();
|
||||
LocalDate dataOrd = entity.getDataOrd();
|
||||
Date dataOrd = entity.getDataOrd();
|
||||
|
||||
sql = "SELECT cod_jfas FROM dtb_ordt " +
|
||||
"WHERE gestione = " + UtilityDB.valueToString(gestione) + " AND " +
|
||||
" data_ord = " + UtilityDB.valueToString(dataOrd) + " AND " +
|
||||
" data_ord = " + UtilityDB.valueDateToString(dataOrd, CommonConstants.DATE_FORMAT_YMD) + " AND " +
|
||||
" num_ord = " + UtilityDB.valueToString(numord);
|
||||
codJfas = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
}
|
||||
@@ -381,15 +265,15 @@ public class DocumentRules extends QueryRules {
|
||||
public static String completeSerDoc(Connection conn, DtbBaseDocT entity) throws Exception {
|
||||
String codDtip = entity.getCodDtip();
|
||||
String codMdep = entity.getCodMdep();
|
||||
LocalDate dataDoc = entity.getDataDoc();
|
||||
Date dataDoc = entity.getDataDoc();
|
||||
|
||||
String serDoc = getSerDoc(conn, codDtip, codMdep, dataDoc);
|
||||
return serDoc;
|
||||
}
|
||||
|
||||
public static String getSerDoc(Connection conn, String codDtip, String codMdep, LocalDate dataDoc) throws Exception {
|
||||
public static String getSerDoc(Connection conn, String codDtip, String codMdep, Date dataDoc) throws Exception {
|
||||
String sql =
|
||||
"SELECT dbo.f_getSerDoc(" + UtilityDB.valueToString(codDtip) + "," + UtilityDB.valueToString(codMdep) + ", " + UtilityDB.valueToString(dataDoc) + ")";
|
||||
"SELECT dbo.f_getSerDoc(" + UtilityDB.valueToString(codDtip) + "," + UtilityDB.valueToString(codMdep) + ", " + UtilityDB.valueDateToString(dataDoc, CommonConstants.DATE_FORMAT_YMD) + ")";
|
||||
|
||||
String serDoc = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
return serDoc;
|
||||
@@ -483,7 +367,7 @@ public class DocumentRules extends QueryRules {
|
||||
String codMart = entity.getCodMart();
|
||||
BigDecimal rapConv = entity.getRapConv();
|
||||
String codMdep = entity.getCodMdep();
|
||||
LocalDate dataReg = entity.getDataReg();
|
||||
Date dataReg = entity.getDataReg();
|
||||
if (UtilityBigDecimal.isNullOrZero(costoUnt)) {
|
||||
if (flagCosto) {
|
||||
BigDecimal sconto1 = entity.getSconto1();
|
||||
@@ -521,7 +405,7 @@ public class DocumentRules extends QueryRules {
|
||||
} else if (tipoEmissione == TipoEmissione.DIRETTA) {
|
||||
String sql = "SELECT dbo.f_getCostoCriterioValGrup("
|
||||
+ UtilityDB.valueToString(codMart) + ","
|
||||
+ UtilityDB.valueToString(dataReg) + ","
|
||||
+ UtilityDB.valueDateToString(dataReg, CommonConstants.DATE_FORMAT_YMD) + ","
|
||||
+ UtilityDB.valueToString(codMdep) + ") as costo";
|
||||
costoUnt = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
if (!UtilityBigDecimal.isNullOrZero(costoUnt)) {
|
||||
@@ -564,7 +448,7 @@ public class DocumentRules extends QueryRules {
|
||||
for (NtbDoct ntbDoct : testata.getNtbDoct()) {
|
||||
ntbDoct.setCodAnagVal(testata.getCodAnag());
|
||||
ntbDoct.setCodDtipVal(testata.getCodDtip());
|
||||
ntbDoct.setDataDocVal(testata.getDataDoc());
|
||||
ntbDoct.setDataDocVal(UtilityLocalDate.localDateFromDate(testata.getDataDoc()));
|
||||
ntbDoct.setSerDocVal(testata.getSerDoc());
|
||||
ntbDoct.setNumDocVal(testata.getNumDoc());
|
||||
}
|
||||
@@ -576,7 +460,6 @@ public class DocumentRules extends QueryRules {
|
||||
for (MtbColt mtbColt : colli) {
|
||||
boolean isDelete = false;
|
||||
boolean cancellaRifDoc = false;
|
||||
|
||||
if (mtbColt.getOperation() == OperationType.DELETE) {
|
||||
cancellaRifDoc = true;
|
||||
isDelete = true;
|
||||
@@ -591,12 +474,13 @@ public class DocumentRules extends QueryRules {
|
||||
mtbColt.getDataCollo(),
|
||||
mtbColt.getSerCollo(),
|
||||
mtbColt.getNumCollo());
|
||||
Boolean colloAnonimo = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
|
||||
boolean colloAnonimo = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
|
||||
mtbColt
|
||||
.setCodAnag(cancellaRifDoc && (colloAnonimo != null && colloAnonimo) ? EmsRestConstants.NULL : testata.getCodAnag())
|
||||
.setCodAnag(cancellaRifDoc && colloAnonimo ? EmsRestConstants.NULL : testata.getCodAnag())
|
||||
.setCodDtip(cancellaRifDoc ? EmsRestConstants.NULL : testata.getCodDtip())
|
||||
.setDataDoc(cancellaRifDoc ? EmsRestConstants.LOCAL_DATE_NULL : testata.getDataDoc())
|
||||
.setDataDoc(cancellaRifDoc ? EmsRestConstants.DATE_NULL : testata.getDataDoc())
|
||||
.setSerDoc(cancellaRifDoc ? EmsRestConstants.NULL : testata.getSerDoc())
|
||||
.setNumDoc(cancellaRifDoc ? EmsRestConstants.INTEGER_NULL : testata.getNumDoc());
|
||||
mtbColt.setOperation(OperationType.UPDATE);
|
||||
@@ -612,9 +496,10 @@ public class DocumentRules extends QueryRules {
|
||||
}
|
||||
}
|
||||
|
||||
if (!colliDaCanc.isEmpty()) {
|
||||
if (colliDaCanc.size() > 0) {
|
||||
testata.getMtbColt().addAll(colliDaCanc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Integer completeVersione(Connection conn, DtbDocPdf dtbDocPdf) throws SQLException {
|
||||
@@ -623,29 +508,20 @@ public class DocumentRules extends QueryRules {
|
||||
" FROM dtb_doc_pdf " +
|
||||
" WHERE cod_anag = " + UtilityDB.valueToString(dtbDocPdf.getCodAnag()) +
|
||||
" AND cod_dtip = " + UtilityDB.valueToString(dtbDocPdf.getCodDtip()) +
|
||||
" AND data_doc = " + UtilityDB.valueToString(dtbDocPdf.getDataDoc()) +
|
||||
" AND data_doc = " + UtilityDB.valueDateToString(dtbDocPdf.getDataDoc(), CommonConstants.DATE_FORMAT_YMD) +
|
||||
" AND ser_doc = " + UtilityDB.valueToString(dtbDocPdf.getSerDoc()) +
|
||||
" AND num_doc = " + UtilityDB.valueToString(dtbDocPdf.getNumDoc());
|
||||
|
||||
PreparedStatement ps = conn.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
Integer versione = null;
|
||||
|
||||
if (rs.next()) {
|
||||
versione = rs.getInt("next_versione");
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
Integer versione = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
if (versione == null) {
|
||||
versione = 0;
|
||||
}
|
||||
return versione;
|
||||
|
||||
}
|
||||
|
||||
public static String completeFileName(DtbDocPdf docPdf) {
|
||||
String fileName, serDocSave;
|
||||
String dataDoc = UtilityLocalDate.formatDate(docPdf.getDataDoc(), "yyyyMMdd");
|
||||
String dataDoc = new SimpleDateFormat("yyyyMMdd").format(docPdf.getDataDoc());
|
||||
String serDoc = docPdf.getSerDoc();
|
||||
String numDoc = UtilityString.FillString(docPdf.getNumDoc().toString(), '0', 5, "L");
|
||||
String versione = UtilityString.FillString(docPdf.getVersione().toString(), '0', 2, "L");
|
||||
@@ -675,7 +551,7 @@ public class DocumentRules extends QueryRules {
|
||||
|
||||
}
|
||||
|
||||
public static DtbDocr setDatiBolla(Connection conn, DtbDocr dtbDocr, String codDtipBolla, LocalDate dataDocBolla, String serDocBolla, Integer numDocBolla) throws Exception {
|
||||
public static DtbDocr setDatiBolla(Connection conn, DtbDocr dtbDocr, String codDtipBolla, Date dataDocBolla, String serDocBolla, Integer numDocBolla) throws Exception {
|
||||
if (UtilityString.isNullOrEmpty(codDtipBolla)) {
|
||||
throw new Exception("Tipo Documento Bolla inesistente ");
|
||||
}
|
||||
@@ -712,7 +588,7 @@ public class DocumentRules extends QueryRules {
|
||||
}
|
||||
|
||||
public static DtbDocr completeDatiBolla(Connection conn, DtbDocr dtbDocr) throws Exception {
|
||||
DtbDocr dtbDocrBolla = setDatiBolla(conn, dtbDocr, dtbDocr.getCodDtipBolla(), UtilityLocalDate.localDateFromDate(dtbDocr.getDataDocBolla()), dtbDocr.getSerDocBolla(), dtbDocr.getNumDocBolla());
|
||||
DtbDocr dtbDocrBolla = setDatiBolla(conn, dtbDocr, dtbDocr.getCodDtipBolla(), dtbDocr.getDataDocBolla(), dtbDocr.getSerDocBolla(), dtbDocr.getNumDocBolla());
|
||||
dtbDocrBolla.setIdRiga(dtbDocr.getIdRigaBolla());
|
||||
dtbDocrBolla.setCodDtipBolla(null);
|
||||
dtbDocrBolla.setDataDocBolla(null);
|
||||
@@ -727,7 +603,7 @@ public class DocumentRules extends QueryRules {
|
||||
" FROM dtb_doct " +
|
||||
" WHERE dtb_doct.cod_anag = " + UtilityDB.valueToString(dtbDocr.getCodAnag()) + " AND " +
|
||||
" dtb_doct.cod_dtip = " + UtilityDB.valueToString(dtbDocr.getCodDtipBolla()) + " AND " +
|
||||
" dtb_doct.data_doc = " + UtilityDB.valueDateToString(dtbDocr.getDataDocBolla(), CommonConstants.DATE_FORMAT_YMD_DASHED) + " AND " +
|
||||
" dtb_doct.data_doc = " + UtilityDB.valueDateToString(dtbDocr.getDataDocBolla(), CommonConstants.DATE_FORMAT_YMD) + " AND " +
|
||||
" dtb_doct.ser_doc = " + UtilityDB.valueToString(dtbDocr.getSerDocBolla()) + " AND " +
|
||||
" dtb_doct.num_doc = " + UtilityDB.valueToString(dtbDocr.getNumDocBolla());
|
||||
HashMap<String, Object> datiBolla = UtilityDB.executeSimpleQueryOnlyFirstRow(conn, sql);
|
||||
@@ -745,15 +621,15 @@ public class DocumentRules extends QueryRules {
|
||||
|
||||
public static List<DtbDoct> setElencoBolle(final Connection conn, final DtbDoct testata) throws Exception {
|
||||
List<DtbDoct> bolle = Stream.of(testata.getDtbDocr()).filter(value -> value.getCodDtipBolla() != null && value.getIdRigaBolla() != null && value.getIdRigaBolla() != -1).
|
||||
distinctBy(dtbDocrB -> UtilityDate.formatDate(dtbDocrB.getDataDocBolla(), CommonConstants.DATE_FORMAT_YMD_DASHED) + dtbDocrB.getCodDtipBolla() + dtbDocrB.getSerDocBolla() + dtbDocrB.getNumDocBolla()).map(dtbDocr -> {
|
||||
distinctBy(dtbDocrB -> UtilityDate.formatDate(dtbDocrB.getDataDocBolla(), CommonConstants.DATE_FORMAT_YMD) + dtbDocrB.getCodDtipBolla() + dtbDocrB.getSerDocBolla() + dtbDocrB.getNumDocBolla()).map(dtbDocr -> {
|
||||
DtbDoct dtbDoct = new DtbDoct();
|
||||
dtbDoct.setCodAnag(dtbDocr.getCodAnag());
|
||||
dtbDoct.setCodDtip(dtbDocr.getCodDtipBolla());
|
||||
dtbDoct.setDataDoc(UtilityLocalDate.localDateFromDate(dtbDocr.getDataDocBolla()));
|
||||
dtbDoct.setDataDoc(dtbDocr.getDataDocBolla());
|
||||
dtbDoct.setSerDoc(dtbDocr.getSerDocBolla());
|
||||
dtbDoct.setNumDoc(dtbDocr.getNumDocBolla());
|
||||
dtbDoct.setCodDtipVal(testata.getCodDtip());
|
||||
dtbDoct.setDataDocVal(UtilityLocalDate.localDateToDate(testata.getDataDoc()));
|
||||
dtbDoct.setDataDocVal(testata.getDataDoc());
|
||||
dtbDoct.setSerDocVal(testata.getSerDoc());
|
||||
dtbDoct.setNumDocVal(testata.getNumDoc());
|
||||
dtbDoct.setCodPaga(testata.getCodPaga());
|
||||
@@ -818,7 +694,7 @@ public class DocumentRules extends QueryRules {
|
||||
bolla -> {
|
||||
bolla
|
||||
.setCodDtipVal(testata.getCodDtip())
|
||||
.setDataDocVal(UtilityLocalDate.localDateToDate(testata.getDataDoc()))
|
||||
.setDataDocVal(testata.getDataDoc())
|
||||
.setSerDocVal(testata.getSerDoc())
|
||||
.setNumDocVal(testata.getNumDoc())
|
||||
.setCodPaga(testata.getCodPaga())
|
||||
@@ -932,7 +808,7 @@ public class DocumentRules extends QueryRules {
|
||||
sql = String.format(sql,
|
||||
UtilityDB.valueToString(dtbDoct.getCodAnag()),
|
||||
UtilityDB.valueToString(dtbDoct.getCodDtip()),
|
||||
UtilityDB.valueToString(dtbDoct.getDataDoc()),
|
||||
UtilityDB.valueToString(new SimpleDateFormat(CommonConstants.DATE_FORMAT_YMD).format(dtbDoct.getDataDoc())),
|
||||
UtilityDB.valueToString(dtbDoct.getSerDoc()),
|
||||
UtilityDB.valueToString(dtbDoct.getNumDoc()));
|
||||
|
||||
@@ -976,7 +852,7 @@ public class DocumentRules extends QueryRules {
|
||||
" FROM dtb_tipi INNER JOIN dtb_inum ON dtb_tipi.cod_ireg = dtb_inum.cod_ireg " +
|
||||
" WHERE dtb_tipi.cod_dtip = " + UtilityDB.valueToString(dtbDoct.getCodDtip()) + " AND " +
|
||||
" dtb_tipi.tipo_numeraz <> 'MANUALE' AND " +
|
||||
" dtb_inum.anno = DatePart(year, " + UtilityDB.valueToString(dtbDoct.getDataReg()) + ") AND " +
|
||||
" dtb_inum.anno = DatePart(year, " + UtilityDB.valueDateToString(dtbDoct.getDataReg(), CommonConstants.DATE_FORMAT_YMD) + ") AND " +
|
||||
" dtb_inum.ser_doc = " + UtilityDB.valueToString(dtbDoct.getSerDoc()) + " AND " +
|
||||
" dtb_inum.num_doc = " + UtilityDB.valueToString(dtbDoct.getNumDoc());
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package it.integry.ems.rules.completing;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems_model.base.EntityInterface;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.entity.common.DtbDocOrdT;
|
||||
@@ -14,12 +15,11 @@ import it.integry.ems_model.utility.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.*;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ public class OrderRules extends QueryRules {
|
||||
return "A".equalsIgnoreCase(gestione) && UtilityString.equalsIgnoreCase(gestione, gestioneRif);
|
||||
}
|
||||
|
||||
public static Integer completeNumOrd(Connection conn, String gestione, LocalDate dataOrd, String gestioneRif) throws Exception {
|
||||
short anno = (short) dataOrd.getYear();
|
||||
public static Integer completeNumOrd(Connection conn, String gestione, Date dataOrd, String gestioneRif) throws Exception {
|
||||
short anno = (short) UtilityDate.datePart(Calendar.YEAR, dataOrd);
|
||||
boolean isOrdProd = isOrdProd(gestione, gestioneRif);
|
||||
|
||||
String gestioneParm = gestione;
|
||||
@@ -98,26 +98,26 @@ public class OrderRules extends QueryRules {
|
||||
return tipoAnag;
|
||||
}
|
||||
|
||||
public static LocalDateTime completeDataCons(Connection conn, DtbOrdr dtbOrdr) throws Exception {
|
||||
LocalDateTime dataCons = null;
|
||||
public static Date completeDataCons(Connection conn, DtbOrdr dtbOrdr) throws Exception {
|
||||
Date dataCons = null;
|
||||
if (!UtilityString.isNullOrEmpty(dtbOrdr.getListino()) && "A".equalsIgnoreCase(dtbOrdr.getGestione()) &&
|
||||
(!UtilityString.isNullOrEmpty(dtbOrdr.getCodMart()) || !UtilityString.isNullOrEmpty(dtbOrdr.getCodArtFor()))) {
|
||||
String sql = "SELECT dbo.getDataConsAcq( " + UtilityDB.valueToString(dtbOrdr.getDataOrd()) + ", "
|
||||
String sql = "SELECT dbo.getDataConsAcq( " + UtilityDB.valueDateToString(dtbOrdr.getDataOrd(), CommonConstants.DATE_FORMAT_YMD) + ", "
|
||||
+ UtilityDB.valueToString(dtbOrdr.getListino()) + ", "
|
||||
+ UtilityDB.valueToString(dtbOrdr.getCodArtFor()) + ", "
|
||||
+ UtilityDB.valueToString(dtbOrdr.getCodMart()) + ", "
|
||||
+ UtilityDB.valueToString(dtbOrdr.getCodMdep()) + ")";
|
||||
dataCons = UtilityLocalDate.localDateTimeFromDate(UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql));
|
||||
dataCons = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
}
|
||||
|
||||
if (dataCons == null) {
|
||||
dataCons = dtbOrdr.getDataOrd().atStartOfDay();
|
||||
dataCons = dtbOrdr.getDataOrd();
|
||||
}
|
||||
return dataCons;
|
||||
}
|
||||
|
||||
public static LocalDate completeDataInizProdOrdP(Connection conn, DtbOrdr dtbOrdr) {
|
||||
return dtbOrdr.getDataOrd();
|
||||
return UtilityLocalDate.localDateFromDate(dtbOrdr.getDataOrd());
|
||||
}
|
||||
|
||||
public static String completeCausaleTrasp(String gestione) {
|
||||
@@ -143,7 +143,7 @@ public class OrderRules extends QueryRules {
|
||||
if (dtbOrdt.getNumOrd() != null && dtbOrdt.getNumOrd() != 0 && gestioneRif == null) {
|
||||
sql = "SELECT gestione_rif FROM dtb_ordt " +
|
||||
" WHERE gestione = " + UtilityDB.valueToString(dtbOrdt.getGestione()) + " AND " +
|
||||
"data_ord = " + UtilityDB.valueToString(dtbOrdt.getDataOrd()) + " AND " +
|
||||
"data_ord = " + UtilityDB.valueDateToString(dtbOrdt.getDataOrd(), CommonConstants.DATE_FORMAT_YMD) + " AND " +
|
||||
"num_ord = " + UtilityDB.valueToString(dtbOrdt.getNumOrd());
|
||||
|
||||
gestioneRif = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
@@ -166,21 +166,22 @@ public class OrderRules extends QueryRules {
|
||||
}
|
||||
|
||||
public static HashMap<String, Object> completeRifOrdLavOrdP(Connection connection, DtbOrdr dtbOrdr) throws SQLException {
|
||||
DateFormat formato = new SimpleDateFormat("yyyy/MM/dd");
|
||||
String gestione = dtbOrdr.getGestione();
|
||||
LocalDate dataOrd = dtbOrdr.getDataOrd();
|
||||
Date dataOrd = dtbOrdr.getDataOrd();
|
||||
Integer numOrd = dtbOrdr.getNumOrd();
|
||||
Integer rigaOrd = dtbOrdr.getRigaOrd();
|
||||
String sql =
|
||||
"SELECT data_ord, num_ord "
|
||||
+ "FROM dtb_ordt "
|
||||
+ "WHERE gestione_rif = '" + gestione + "' AND "
|
||||
+ " data_ord_rif = " + UtilityDB.valueToString(dataOrd) + " AND "
|
||||
+ " data_ord_rif = '" + formato.format(dataOrd) + "' AND "
|
||||
+ " num_ord_rif = " + numOrd.toString() + " AND "
|
||||
+ " riga_ord_rif = " + rigaOrd.toString();
|
||||
return execSingleQuery(connection, sql);
|
||||
}
|
||||
|
||||
public static BigDecimal completeQtaOrd(Connection connection, DtbOrdr dtbOrdr) {
|
||||
public static BigDecimal completeQtaOrd(Connection connection, DtbOrdr dtbOrdr) throws SQLException {
|
||||
|
||||
BigDecimal qtaCnf = dtbOrdr.getQtaCnf();
|
||||
BigDecimal numCnf = dtbOrdr.getNumCnf();
|
||||
@@ -287,7 +288,7 @@ public class OrderRules extends QueryRules {
|
||||
jtbComt.setDescrizione(descrizioneCommessa.length() > 40 ? descrizioneCommessa.substring(0, 40) : descrizioneCommessa);
|
||||
jtbComt.setDescrizioneEstesa(descrizioneCommessa);
|
||||
jtbComt.setGestione(dtbOrdt.getGestione());
|
||||
jtbComt.setDataOrd(UtilityLocalDate.localDateToDate(dtbOrdt.getDataOrd()));
|
||||
jtbComt.setDataOrd(dtbOrdt.getDataOrd());
|
||||
jtbComt.setNumOrd(dtbOrdt.getNumOrd());
|
||||
|
||||
String codJcom = CommesseRules.getNextCodJcom(conn, jtbComt);
|
||||
@@ -340,7 +341,7 @@ public class OrderRules extends QueryRules {
|
||||
" ISNULL(rif_ord, ''))) = " +
|
||||
" dbo.MD5_encode(LOWER(" +
|
||||
" ISNULL(CONVERT(VARCHAR, " + UtilityDB.valueToString(wdtbOrdt.getNumOrdRif()) + "), '') + " +
|
||||
" ISNULL(CONVERT(VARCHAR, CONVERT(DATETIME, " + UtilityDB.valueToString(wdtbOrdt.getDataOrdRif()) + ", 111), 103), '') + " +
|
||||
" ISNULL(CONVERT(VARCHAR, CONVERT(DATETIME, " + UtilityDB.valueDateToString(wdtbOrdt.getDataOrdRif(), CommonConstants.DATE_FORMAT_YMD) + ", 111), 103), '') + " +
|
||||
" ISNULL(" + UtilityDB.valueToString(wdtbOrdt.getRifOrd()) + ", ''))) " +
|
||||
" AND t.cod_mdep = " + UtilityDB.valueToString(wdtbOrdt.getCodMdep()) +
|
||||
" AND t.listino = " + UtilityDB.valueToString(wdtbOrdt.getListino());
|
||||
@@ -392,7 +393,7 @@ public class OrderRules extends QueryRules {
|
||||
public static Integer completeVersione(Connection conn, DtbOrdPdf ordPdf) throws SQLException {
|
||||
String sql = "SELECT isNull(Max(versione) + 1, 0) next_versione " +
|
||||
" FROM dtb_ord_pdf " +
|
||||
" WHERE data_ord = " + UtilityDB.valueToString(ordPdf.getDataOrd()) +
|
||||
" WHERE data_ord = " + UtilityDB.valueDateToString(ordPdf.getDataOrd(), CommonConstants.DATE_FORMAT_YMD) +
|
||||
" AND gestione = " + UtilityDB.valueToString(ordPdf.getGestione()) +
|
||||
" AND num_ord = " + UtilityDB.valueToString(ordPdf.getNumOrd());
|
||||
|
||||
@@ -414,7 +415,7 @@ public class OrderRules extends QueryRules {
|
||||
}
|
||||
|
||||
public static String completeFileName(DtbOrdPdf ordPdf) {
|
||||
String dataOrd = UtilityLocalDate.formatDate(ordPdf.getDataOrd(), "yyyyMMdd");
|
||||
String dataOrd = new SimpleDateFormat("yyyyMMdd").format(ordPdf.getDataOrd());
|
||||
String gestione = ordPdf.getGestione();
|
||||
String numOrd = UtilityString.FillString(ordPdf.getNumOrd().toString(), '0', 5, "L");
|
||||
String versione = UtilityString.FillString(ordPdf.getVersione().toString(), '0', 2, "L");
|
||||
@@ -479,7 +480,7 @@ public class OrderRules extends QueryRules {
|
||||
throw new Exception(String.format(
|
||||
"Impossibile cancellare l'ordine %s del %s. %s",
|
||||
dtbOrdt.getNumOrd(),
|
||||
CommonConstants.DATE_DMY_SLASHED_FORMATTER.format(dtbOrdt.getDataOrd()),
|
||||
UtilityDate.formatDate(dtbOrdt.getDataOrd(), CommonConstants.DATE_FORMAT_DMY),
|
||||
msg
|
||||
));
|
||||
}
|
||||
@@ -510,9 +511,9 @@ public class OrderRules extends QueryRules {
|
||||
}
|
||||
|
||||
public static void setRifOrd(Connection conn, DtbOrdt dtbOrdt) throws Exception {
|
||||
Boolean completeRifOrd = setupGest.getSetupBoolean(conn, "w_vordi_rc", "SETUP", "RIF_ORD_AUTOCOMP");
|
||||
Boolean completeRifOrd = setupGest.getSetupBoolean("w_vordi_rc", "SETUP", "RIF_ORD_AUTOCOMP");
|
||||
if (UtilityString.isNullOrEmpty(dtbOrdt.getRifOrd()) && completeRifOrd) {
|
||||
String setupRifOrd = setupGest.getSetup(conn, "w_vordi_rc", "SETUP", "RIF_ORD_FORMATO");
|
||||
String setupRifOrd = setupGest.getSetup("w_vordi_rc", "SETUP", "RIF_ORD_FORMATO");
|
||||
if (!UtilityString.isNullOrEmpty(setupRifOrd) &&
|
||||
dtbOrdt.getRifDataOrd() != null && !dtbOrdt.getRifDataOrd().equals(EmsRestConstants.DATE_NULL) &&
|
||||
dtbOrdt.getRifNumOrd() != null && dtbOrdt.getRifNumOrd() != EmsRestConstants.NULL) {
|
||||
@@ -529,6 +530,7 @@ public class OrderRules extends QueryRules {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void completeImportoRigaOrdProd(Connection connection, DtbOrdt dtbOrdt) throws Exception {
|
||||
SetupGest setup = new SetupGest();
|
||||
boolean disableTriggerOrdl = setup.getSetupBoolean(connection, "DTB_ORDT", "SETUP", "DISABLE_TRIGGER_ORDL");
|
||||
@@ -571,7 +573,7 @@ public class OrderRules extends QueryRules {
|
||||
|
||||
}
|
||||
|
||||
public static boolean checkDeleteOrd(Connection conn, String gestione, LocalDate dataOrd, Integer numOrd, Integer rigaOrd) throws Exception {
|
||||
public static boolean checkDeleteOrd(Connection conn, String gestione, Date dataOrd, Integer numOrd, Integer rigaOrd) throws Exception {
|
||||
String sql =
|
||||
Query.format(
|
||||
"SELECT Cast(count(*) As BIT)\n" +
|
||||
|
||||
@@ -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;
|
||||
@@ -44,7 +45,7 @@ public class PackagesRules extends QueryRules {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static String completeBarcodeUl(Connection connection, String gestione, LocalDate dataCollo, String serCollo, Integer numCollo, String codJfas, String customPrefissoEan) throws Exception {
|
||||
public static String completeBarcodeUl(Connection connection, String gestione, LocalDate dataCollo, String serCollo, Integer numCollo, String codJfas) throws Exception {
|
||||
|
||||
CallableStatement cs = connection.prepareCall("{call dbo.NextIdBarcodeUl(?, ?, ?, ?, ?, ?)}");
|
||||
cs.setString(1, gestione);
|
||||
@@ -56,7 +57,7 @@ public class PackagesRules extends QueryRules {
|
||||
cs.execute();
|
||||
Integer numBarcode = cs.getInt(6);
|
||||
cs.close();
|
||||
String sql = Query.format("SELECT dbo.f_suggestBarcodeUl(%s,%s,%s,%s,%s,%s,%s)", gestione, UtilityLocalDate.localDateToDate(dataCollo), serCollo, codJfas, numCollo, customPrefissoEan, numBarcode);
|
||||
String sql = Query.format("SELECT dbo.f_suggestBarcodeUl(%s,%s,%s,%s,%s,%s,%s)", gestione, UtilityLocalDate.localDateToDate(dataCollo), serCollo, codJfas, numCollo, null, numBarcode);
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package it.integry.ems.rules.completing;
|
||||
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.entity.DtbOrdt;
|
||||
import it.integry.ems_model.entity.PtbPrevn;
|
||||
@@ -9,6 +9,8 @@ import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
|
||||
import java.sql.Statement;
|
||||
|
||||
public class PreventRules extends QueryRules {
|
||||
@@ -56,7 +58,7 @@ public class PreventRules extends QueryRules {
|
||||
"SELECT rif_ord " +
|
||||
"FROM dtb_ordt " +
|
||||
" WHERE gestione = " + UtilityDB.valueToString(entity.getGestione()) + " AND " +
|
||||
" data_ord = " + UtilityDB.valueToString(entity.getDataOrd()) + " AND " +
|
||||
" data_ord = " + UtilityDB.valueDateToString(entity.getDataOrd(), CommonConstants.DATE_FORMAT_YMD) + " AND " +
|
||||
" num_ord = " + UtilityDB.valueToString(entity.getNumOrd());
|
||||
String rifOrdOffertaOld = UtilityString.streNull((String) QueryRules.getSingleValue(conn, sql));
|
||||
|
||||
@@ -85,7 +87,7 @@ public class PreventRules extends QueryRules {
|
||||
sql =
|
||||
"UPDATE ptb_prevt " +
|
||||
" SET gestione = " + UtilityDB.valueToString(entity.getGestione()) + ", " +
|
||||
" data_ord = " + UtilityDB.valueToString(entity.getDataOrd()) + ", " +
|
||||
" data_ord = " + UtilityDB.valueDateToString(entity.getDataOrd(), CommonConstants.DATE_FORMAT_YMD) + ", " +
|
||||
" num_ord = " + UtilityDB.valueToString(entity.getNumOrd()) + " " +
|
||||
" WHERE id_offerta = " + UtilityDB.valueToString(idOfferta);
|
||||
Statement cmd = conn.createStatement();
|
||||
|
||||
@@ -1,426 +1,428 @@
|
||||
package it.integry.ems.rules.completing;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ProductionsRules extends QueryRules {
|
||||
public static String completeCodJflavNew(Connection connection, String precode) throws SQLException {
|
||||
String sql = "SELECT dbo.f_suggestCodeCodJflav(" + UtilityDB.valueToString(precode) + ")";
|
||||
PreparedStatement ps = connection.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
String codJflav = null;
|
||||
if (rs.next()) {
|
||||
codJflav = rs.getString(1);
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
return codJflav;
|
||||
}
|
||||
|
||||
public static void checkDistintaKitVendita(Connection connection, String codProd) throws Exception {
|
||||
String sql =
|
||||
"select count(*) " +
|
||||
" from mtb_aart " +
|
||||
" where articolo_composto = 'S' and esposizione_comp = 'S' and " +
|
||||
" cod_mart = " + UtilityDB.valueToString(codProd);
|
||||
PreparedStatement ps = connection.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
Integer isKit = 0;
|
||||
if (rs.next()) {
|
||||
isKit = rs.getInt(1);
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
|
||||
if (isKit != 0) {
|
||||
throw new Exception("Impossibile associare la distinta base al prodotto " + codProd + ", perchè risulta evere un kit di vendita con esplosione dei componenti già associato.");
|
||||
}
|
||||
}
|
||||
|
||||
public static String completeDescMacchinari(Connection connection, String codMart)
|
||||
throws SQLException {
|
||||
String sql = "SELECT ISNULL(descrizione_estesa, descrizione) as desc" +
|
||||
" FROM mtb_aart WHERE cod_mart = " + UtilityDB.valueToString(codMart);
|
||||
List<HashMap<String, Object>> list = execQuery(connection, sql);
|
||||
if (list.isEmpty()) {
|
||||
return "";
|
||||
} else {
|
||||
return list.get(0).get("desc").toString();
|
||||
}
|
||||
}
|
||||
|
||||
public static String completeCodJfas(Connection connection, String codJflav) throws SQLException {
|
||||
String sql = "SELECT jtb_flav.cod_jfas " + " FROM jtb_flav"
|
||||
+ " WHERE jtb_flav.cod_jflav = '" + codJflav + "'";
|
||||
|
||||
List<HashMap<String, Object>> list = execQuery(connection, sql);
|
||||
if (list.isEmpty()) {
|
||||
return null;
|
||||
} else if (UtilityString.isNullOrEmpty(list.get(0).get("cod_jfas"))) {
|
||||
return null;
|
||||
} else {
|
||||
return list.get(0).get("cod_jfas").toString();
|
||||
}
|
||||
}
|
||||
|
||||
public static String completeCostoOra(Connection connection, String tipoOrelav, JtbRLavt jtbRLavt) throws SQLException {
|
||||
// if("O".equals(tipoOrelav))
|
||||
// return jtbRLavt.getc
|
||||
// else if("S".equals(tipoOrelav))
|
||||
// return
|
||||
// else if("V".equals(tipoOrelav))
|
||||
// return
|
||||
return null;
|
||||
}
|
||||
|
||||
public static BigDecimal completeOre(Connection connection, JtbRLavr jtbRLavr) {
|
||||
BigDecimal ore = BigDecimal.ZERO;
|
||||
|
||||
LocalDateTime daOra = jtbRLavr.getDaOra();
|
||||
LocalDateTime aOra = jtbRLavr.getaOra();
|
||||
if (UtilityLocalDate.isNull(daOra) ||UtilityLocalDate.isNull(aOra) )
|
||||
return ore;
|
||||
|
||||
Duration diff = Duration.between(daOra, aOra);
|
||||
long minute = diff.toMinutes();
|
||||
ore = BigDecimal.valueOf(minute / 60);
|
||||
return ore;
|
||||
}
|
||||
|
||||
public static String completeFlagAutorizza(Connection connection, String codJcau) throws SQLException {
|
||||
String flagRichiediAutor = "", flagAutorizza = "";
|
||||
String query = "SELECT flag_richiedi_autoriz FROM jtb_caus_eventi WHERE cod_jcau = '" + codJcau + "'";
|
||||
PreparedStatement ps = connection.prepareStatement(query);
|
||||
ResultSet res = ps.executeQuery();
|
||||
if (res.next()) {
|
||||
flagRichiediAutor = res.getString("flag_richiedi_autoriz");
|
||||
}
|
||||
res.close();
|
||||
ps.close();
|
||||
if (("N").equals(flagRichiediAutor)) {
|
||||
flagAutorizza = "S";
|
||||
} else {
|
||||
flagAutorizza = "N";
|
||||
}
|
||||
return flagAutorizza;
|
||||
}
|
||||
|
||||
//TODO da finire
|
||||
public static void completeAutorizzazione(Connection connection, JtbFlav jtbFlav,
|
||||
JtbFlavEventi jtbFlavEventi) throws SQLException {
|
||||
/*
|
||||
String query = "SELECT tipo_evento, flag_ripeti FROM jtb_caus_eventi WHERE cod_jcau = '" + jtbFlavEventi.getCodJcau() + "'";
|
||||
PreparedStatement ps = connection.prepareStatement(query);
|
||||
ResultSet res = ps.executeQuery();
|
||||
String tipoEvento, flagRipeti;
|
||||
if(res.next()){
|
||||
tipoEvento = res.getString("tipo_evento");
|
||||
flagRipeti = res.getString("flag_ripeti");
|
||||
}
|
||||
res.close();ps.close();
|
||||
|
||||
if("INIZIO LAVORO".equals(tipoEvento)){
|
||||
jtbFlav.setDataInizLav(jtbFlavEventi.getDataEvento());
|
||||
} else if("ASSUNZIONE".equals(tipoEvento)){
|
||||
jtbFlav.setDataAssunz(jtbFlavEventi.getDataEvento());
|
||||
} else if("FINE LAVORO".equals(tipoEvento)){
|
||||
jtbFlav.setDataFineLavoro(jtbFlavEventi.getDataEvento());
|
||||
} else if("VARIAZIONE PAGA BASE".equals(tipoEvento)){
|
||||
if ("S".equals(jtbFlavEventi.getFlagAutorizza())) {
|
||||
valore = jtbFlav.getCostoOrd() + getValPagaBase(ai_rowID);
|
||||
} else {
|
||||
if (lb_existRow) {
|
||||
valore = jtbFlav.getCostoOrd() - getValPagaBase(ai_rowID);
|
||||
} else {
|
||||
valore = jtbFlav.getCostoOrd();
|
||||
}
|
||||
}
|
||||
jtbFlav.setCostoOrd(valore);
|
||||
} else if("VARIAZIONE INDENNITA".equals(tipoEvento)){
|
||||
if ("S".equals(jtbFlavEventi.getFlagAutorizza())) {
|
||||
valore = jtbFlav.getIndennita() + getValIndennita(ai_rowID);
|
||||
} else {
|
||||
if (lb_existRow){
|
||||
valore = jtbFlav.getIndennita() - getValIndennita(ai_rowID);
|
||||
} else {
|
||||
valore = jtbFlav.getIndennita();
|
||||
}
|
||||
}
|
||||
|
||||
jtbFlav.setIndennita(valore);
|
||||
}
|
||||
// jtbCausFlav.setRipetiEvento(ls_flagRipeti);*/
|
||||
}
|
||||
|
||||
public static String completeCausaleTrasp(String gestione) {
|
||||
if ("A".equals(gestione)) {
|
||||
return "ACQUISTO";
|
||||
} else if ("V".equals(gestione)) {
|
||||
return "VENDITA";
|
||||
} else if ("L".equals(gestione)) {
|
||||
return "LAVORAZIONE";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String completePorto(Connection connection, String codAnag) throws SQLException {
|
||||
String sql = "SELECT vtb_clie.porto FROM vtb_clie "
|
||||
+ " WHERE vtb_clie.cod_anag = " + UtilityDB.valueToString(codAnag);
|
||||
PreparedStatement ps = connection.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
String porto = null;
|
||||
if (rs.next()) {
|
||||
porto = rs.getString(1);
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
return porto;
|
||||
}
|
||||
|
||||
/*public static List<HashMap<String, Object>> completeSconto(
|
||||
Connection connection, String codAnag, String field)
|
||||
throws SQLException {
|
||||
String sql = "SELECT vtb_clie." + field + " FROM vtb_clie "
|
||||
+ " WHERE vtb_clie.cod_anag = '" + codAnag + "'";
|
||||
return execQuery(connection, sql);
|
||||
}*/
|
||||
|
||||
public static String completeMezzo(Connection connection, String codAnag) throws SQLException {
|
||||
String sql = "SELECT vtb_clie.mezzo FROM vtb_clie "
|
||||
+ " WHERE vtb_clie.cod_anag = " + UtilityDB.valueToString(codAnag);
|
||||
PreparedStatement ps = connection.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
String mezzo = null;
|
||||
if (rs.next()) {
|
||||
mezzo = rs.getString(1);
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
return mezzo;
|
||||
}
|
||||
|
||||
public static String completeCodLingua(Connection connection, String codAnag) throws SQLException {
|
||||
String sql = "SELECT case when gtb_anag.nazione is null then (select cod_lingua from azienda inner join gtb_nazi on azienda.nazione = gtb_nazi.nazione) else gtb_nazi.cod_lingua end " +
|
||||
" FROM gtb_anag left outer join gtb_nazi on gtb_anag.nazione = gtb_nazi.nazione " +
|
||||
" left outer join gtb_lingue on gtb_nazi.cod_lingua = gtb_lingue.cod_lingua " +
|
||||
" WHERE gtb_anag.cod_anag = " + UtilityDB.valueToString(codAnag);
|
||||
PreparedStatement ps = connection.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
String codLingua = null;
|
||||
if (rs.next()) {
|
||||
codLingua = rs.getString(1);
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
return codLingua;
|
||||
}
|
||||
|
||||
public static Integer completeNumOrdWeb(Connection connection, String serie,
|
||||
String gestione, LocalDate dataOrd) throws Exception {
|
||||
|
||||
Short anno = (short) dataOrd.getYear();
|
||||
CallableStatement cs = connection.prepareCall("{call dbo.NextNumOrdWeb(?, ?, ?, ?)}");
|
||||
cs.setString(1, serie);
|
||||
cs.setString(2, gestione);
|
||||
cs.setShort(3, anno);
|
||||
cs.setInt(4, 0);
|
||||
cs.registerOutParameter(4, Types.INTEGER);
|
||||
cs.execute();
|
||||
Integer numOrd = cs.getInt(4);
|
||||
return numOrd;
|
||||
}
|
||||
|
||||
public static Integer completeRigaOrdWeb(Connection connection,
|
||||
String gestione, Date dataOrd, Integer numOrd, String serie)
|
||||
throws SQLException {
|
||||
String sql = "SELECT IsNull(max(riga_ord), 0) as riga "
|
||||
+ " FROM wdtb_ordr WHERE gestione = '" + gestione + "' "
|
||||
+ " AND data_ord = '" + new SimpleDateFormat(CommonConstants.DATETIME_FORMAT_YMD).format(dataOrd) + "' "
|
||||
+ " AND num_ord = " + numOrd + " AND serie = '" + serie + "'";
|
||||
List<HashMap<String, Object>> list = execQuery(connection, sql);
|
||||
if (list.isEmpty()) {
|
||||
return new Integer("0");
|
||||
} else {
|
||||
return new Integer(list.get(0).get("riga").toString()) + 1;
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
//RosannaR 08/02/17 spostata nelle regole generiche su documenti e ordini
|
||||
|
||||
public static BigDecimal completeValUnt(Connection conn, WdtbOrdr row) throws SQLException {
|
||||
Double cambioDiviCont = completeCambioDiviCont(conn);
|
||||
|
||||
String query;
|
||||
Double valUnt = new Double(0);
|
||||
|
||||
String listino = row.getListino();
|
||||
String gestione = row.getGestione();
|
||||
String codMart = row.getCodMart();
|
||||
String codCol = row.getCodCol();
|
||||
String codTagl = row.getCodTagl();
|
||||
// Date dataOrd = row.getDataOrd();
|
||||
Double rapConv = row.getRapConv();
|
||||
|
||||
String applName = getApplicationName(conn);
|
||||
if (ApplicationName.WINGEST.toString().equals(applName)) {
|
||||
// ACQUISIZIONE PREZZO VENDITA
|
||||
if ("V".equals(gestione)) {
|
||||
if (listino == null) {
|
||||
// SE IL LISTINO E' NUL ALLORA IL PREZZO DEVE ESSERE PRESO DALL'ULTIMO PREZZO DI VENDITA
|
||||
query = "SELECT val_ult_scar FROM mtb_aart WHERE cod_mart = "
|
||||
+ UtilityDB.valueToString(codMart);
|
||||
|
||||
List<HashMap<String, String>> res = execQuery(conn, query);
|
||||
Double valUntScar = Double.valueOf(res.get(0).get("val_ult_scar").toString());
|
||||
valUnt = valUntScar * rapConv * cambioDiviCont;
|
||||
valUnt = IntegerUtility.round(valUnt, EmsRestConstants.cifreDecMax);
|
||||
} else {
|
||||
}
|
||||
} else if ("A".equals(gestione)) {
|
||||
} else if ("L".equals(gestione)) {
|
||||
}
|
||||
} else if (ApplicationName.TEXTILES.toString().equals(applName)) {
|
||||
if (CommonConstants.ULTC.equals(listino)){
|
||||
// ACQUISIZIONE COSTO ULTIMO
|
||||
// getCostoUltimo(conn, codMart, dataOrd, codMdep);
|
||||
// valUnt = InfoCosti.getCostoUltimo() * rapConv;
|
||||
return BigDecimal.ONE;
|
||||
}else if (CommonConstants.CMPPF.equals(listino)) {
|
||||
// COSTO DA ANAGRAFICA
|
||||
// calcCostoArticolo(getProfileDB(), codMart, codCol, codTagl, cambioDiviCont);
|
||||
// valUnt = InfoCosti.getCostoUltimo() * rapConv;
|
||||
return BigDecimal.ONE;
|
||||
}else{
|
||||
// ACQUISIZIONE PREZZO DI VENDITA
|
||||
if ("V".equals(gestione)) {
|
||||
BigDecimal przVend = BigDecimal.ZERO;
|
||||
String sql = "select dbo.f_CalcPrzTextiles("+UtilityDB.valueToString(codMart)+", "+
|
||||
UtilityDB.valueToString(codCol) +", "+ UtilityDB.valueToString(codTagl) + ", " +
|
||||
UtilityDB.valueToString(listino) + ", 'N') as prz_vend";
|
||||
PreparedStatement ps = conn.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
if(rs.next()){
|
||||
przVend = rs.getBigDecimal("prz_vend");
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
|
||||
return przVend.multiply(BigDecimal.valueOf(rapConv));
|
||||
}
|
||||
}
|
||||
}
|
||||
row.setValUnt(BigDecimal.valueOf(valUnt));
|
||||
return BigDecimal.valueOf(valUnt);
|
||||
}
|
||||
*/
|
||||
|
||||
public static LocalDateTime recalcDataRapp(LocalDate dataLav, LocalDateTime dateTime) {
|
||||
|
||||
/*FABIO (21-09-2018): ho dovuto gestire DATR_NULL = 01/01/1900 00:00:00, perchè da PB pur passando NULL veniva sempre
|
||||
impostato 01/01/1900 00:00:00 nella classe e quindi tutte le regole che lavorano sul NULL partivano comunque e a
|
||||
CARELLI avevano la necessità di poter modificare direttamente dalla gestione dei rapportini di WINGEST per manutenzione.
|
||||
todo Dobbiamo capire come mai accade ciò, ma credo sia un problema comune. */
|
||||
if (dateTime != EmsRestConstants.LOCAL_DATE_TIME_NULL) {
|
||||
dateTime = dataLav.atStartOfDay().plusHours(dateTime.getHour())
|
||||
.plusMinutes(dateTime.getMinute())
|
||||
.plusSeconds(dateTime.getSecond());
|
||||
}
|
||||
|
||||
return dateTime;
|
||||
}
|
||||
|
||||
public static void checkCanCloseOrder(Connection connection, DtbOrdt dtbOrdt) throws Exception {
|
||||
String sql = Query.format(
|
||||
"WITH steps AS (SELECT DISTINCT gestione,\n" +
|
||||
" data_ord,\n" +
|
||||
" num_ord,\n" +
|
||||
" MAX(id_step)\n" +
|
||||
" OVER (PARTITION BY gestione, data_ord, num_ord, id_riga ORDER BY id_riga) AS id_step,\n" +
|
||||
" id_riga\n" +
|
||||
" FROM dtb_ord_steps\n" +
|
||||
" WHERE gestione = %s\n" +
|
||||
" AND data_ord = %s\n" +
|
||||
" AND num_ord = %s\n" +
|
||||
" AND cod_jfas <> %s)\n" +
|
||||
"SELECT dos.gestione,\n" +
|
||||
" dos.data_ord,\n" +
|
||||
" dos.num_ord,\n" +
|
||||
" dos.id_step,\n" +
|
||||
" dos.id_riga,\n" +
|
||||
" dos.cod_jfas,\n" +
|
||||
" dos.data_iniz,\n" +
|
||||
" dos.data_fine,\n" +
|
||||
" dos.qta_prod,\n" +
|
||||
" dos.qta_allocata,\n" +
|
||||
" dos.descrizione_attivita,\n" +
|
||||
" dos.note,\n" +
|
||||
" dos.qta_trasferite,\n" +
|
||||
" dos.qta_scartate,\n" +
|
||||
" dos.qta_in_prod,\n" +
|
||||
" dos.qta_disp,\n" +
|
||||
" dos.qta_immesse,\n" +
|
||||
" dos.qta_disp_immessa,\n" +
|
||||
" dos.cod_mdep,\n" +
|
||||
" dos.cod_dtip,\n" +
|
||||
" dos.cod_anag,\n" +
|
||||
" dos.data_doc,\n" +
|
||||
" dos.ser_doc,\n" +
|
||||
" dos.num_doc,\n" +
|
||||
" dos.id_riga_doc,\n" +
|
||||
" dos.num_fase,\n" +
|
||||
" dos.flag_tipo_tempo,\n" +
|
||||
" dos.hr_time,\n" +
|
||||
" dos.hr_num,\n" +
|
||||
" dos.qta_lav,\n" +
|
||||
" dos.unt_mis_lav,\n" +
|
||||
" dos.rap_conv_lav,\n" +
|
||||
" dos.cod_prod_pri,\n" +
|
||||
" dos.activity_id,\n" +
|
||||
" dos.flag_step_attivo\n" +
|
||||
"FROM dtb_ord_steps dos\n" +
|
||||
" INNER JOIN steps ON dos.gestione = steps.gestione AND dos.data_ord = steps.data_ord AND\n" +
|
||||
" dos.num_ord = steps.num_ord AND dos.id_step = steps.id_step AND\n" +
|
||||
" dos.id_riga = steps.id_riga\n" +
|
||||
"WHERE dos.data_iniz IS NOT NULL\n" +
|
||||
" AND (dos.data_fine IS NULL OR dos.flag_step_attivo = 'S')\n" +
|
||||
"ORDER BY dos.id_riga",
|
||||
dtbOrdt.getGestione(),
|
||||
dtbOrdt.getDataOrd(),
|
||||
dtbOrdt.getNumOrd(),
|
||||
dtbOrdt.getDtbOrdSteps().get(0).getCodJfas()
|
||||
);
|
||||
|
||||
List<DtbOrdSteps> ordSteps = UtilityDB.executeSimpleQueryDTO(connection, sql, DtbOrdSteps.class);
|
||||
|
||||
if (ordSteps == null || ordSteps.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String message = String.format(
|
||||
"Impossibile chiudere un ordine con fasi aperte. Fasi aperte:\n%s\n",
|
||||
ordSteps.stream().map(DtbOrdSteps::getCodJfas).collect(Collectors.joining("\n"))
|
||||
);
|
||||
|
||||
throw new Exception(message);
|
||||
}
|
||||
package it.integry.ems.rules.completing;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.utility.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
|
||||
import java.sql.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static it.integry.ems_model.config.EmsRestConstants.DATE_NULL;
|
||||
|
||||
public class ProductionsRules extends QueryRules {
|
||||
public static String completeCodJflavNew(Connection connection, String precode) throws SQLException {
|
||||
String sql = "SELECT dbo.f_suggestCodeCodJflav(" + UtilityDB.valueToString(precode) + ")";
|
||||
PreparedStatement ps = connection.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
String codJflav = null;
|
||||
if (rs.next()) {
|
||||
codJflav = rs.getString(1);
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
return codJflav;
|
||||
}
|
||||
|
||||
public static void checkDistintaKitVendita(Connection connection, String codProd) throws Exception {
|
||||
String sql =
|
||||
"select count(*) " +
|
||||
" from mtb_aart " +
|
||||
" where articolo_composto = 'S' and esposizione_comp = 'S' and " +
|
||||
" cod_mart = " + UtilityDB.valueToString(codProd);
|
||||
PreparedStatement ps = connection.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
Integer isKit = 0;
|
||||
if (rs.next()) {
|
||||
isKit = rs.getInt(1);
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
|
||||
if (isKit != 0) {
|
||||
throw new Exception("Impossibile associare la distinta base al prodotto " + codProd + ", perchè risulta evere un kit di vendita con esplosione dei componenti già associato.");
|
||||
}
|
||||
}
|
||||
|
||||
public static String completeDescMacchinari(Connection connection, String codMart)
|
||||
throws SQLException {
|
||||
String sql = "SELECT ISNULL(descrizione_estesa, descrizione) as desc" +
|
||||
" FROM mtb_aart WHERE cod_mart = " + UtilityDB.valueToString(codMart);
|
||||
List<HashMap<String, Object>> list = execQuery(connection, sql);
|
||||
if (list.isEmpty()) {
|
||||
return "";
|
||||
} else {
|
||||
return list.get(0).get("desc").toString();
|
||||
}
|
||||
}
|
||||
|
||||
public static String completeCodJfas(Connection connection, String codJflav) throws SQLException {
|
||||
String sql = "SELECT jtb_flav.cod_jfas " + " FROM jtb_flav"
|
||||
+ " WHERE jtb_flav.cod_jflav = '" + codJflav + "'";
|
||||
|
||||
List<HashMap<String, Object>> list = execQuery(connection, sql);
|
||||
if (list.isEmpty()) {
|
||||
return null;
|
||||
} else if (UtilityString.isNullOrEmpty(list.get(0).get("cod_jfas"))) {
|
||||
return null;
|
||||
} else {
|
||||
return list.get(0).get("cod_jfas").toString();
|
||||
}
|
||||
}
|
||||
|
||||
public static String completeCostoOra(Connection connection, String tipoOrelav, JtbRLavt jtbRLavt) throws SQLException {
|
||||
// if("O".equals(tipoOrelav))
|
||||
// return jtbRLavt.getc
|
||||
// else if("S".equals(tipoOrelav))
|
||||
// return
|
||||
// else if("V".equals(tipoOrelav))
|
||||
// return
|
||||
return null;
|
||||
}
|
||||
|
||||
public static BigDecimal completeOre(Connection connection, JtbRLavr jtbRLavr) {
|
||||
BigDecimal ore = BigDecimal.ZERO;
|
||||
|
||||
LocalDateTime daOra = jtbRLavr.getDaOra();
|
||||
LocalDateTime aOra = jtbRLavr.getaOra();
|
||||
if (UtilityLocalDate.isNull(daOra) ||UtilityLocalDate.isNull(aOra) )
|
||||
return ore;
|
||||
|
||||
Duration diff = Duration.between(daOra, aOra);
|
||||
long minute = diff.toMinutes();
|
||||
ore = BigDecimal.valueOf(minute / 60);
|
||||
return ore;
|
||||
}
|
||||
|
||||
public static String completeFlagAutorizza(Connection connection, String codJcau) throws SQLException {
|
||||
String flagRichiediAutor = "", flagAutorizza = "";
|
||||
String query = "SELECT flag_richiedi_autoriz FROM jtb_caus_eventi WHERE cod_jcau = '" + codJcau + "'";
|
||||
PreparedStatement ps = connection.prepareStatement(query);
|
||||
ResultSet res = ps.executeQuery();
|
||||
if (res.next()) {
|
||||
flagRichiediAutor = res.getString("flag_richiedi_autoriz");
|
||||
}
|
||||
res.close();
|
||||
ps.close();
|
||||
if (("N").equals(flagRichiediAutor)) {
|
||||
flagAutorizza = "S";
|
||||
} else {
|
||||
flagAutorizza = "N";
|
||||
}
|
||||
return flagAutorizza;
|
||||
}
|
||||
|
||||
//TODO da finire
|
||||
public static void completeAutorizzazione(Connection connection, JtbFlav jtbFlav,
|
||||
JtbFlavEventi jtbFlavEventi) throws SQLException {
|
||||
/*
|
||||
String query = "SELECT tipo_evento, flag_ripeti FROM jtb_caus_eventi WHERE cod_jcau = '" + jtbFlavEventi.getCodJcau() + "'";
|
||||
PreparedStatement ps = connection.prepareStatement(query);
|
||||
ResultSet res = ps.executeQuery();
|
||||
String tipoEvento, flagRipeti;
|
||||
if(res.next()){
|
||||
tipoEvento = res.getString("tipo_evento");
|
||||
flagRipeti = res.getString("flag_ripeti");
|
||||
}
|
||||
res.close();ps.close();
|
||||
|
||||
if("INIZIO LAVORO".equals(tipoEvento)){
|
||||
jtbFlav.setDataInizLav(jtbFlavEventi.getDataEvento());
|
||||
} else if("ASSUNZIONE".equals(tipoEvento)){
|
||||
jtbFlav.setDataAssunz(jtbFlavEventi.getDataEvento());
|
||||
} else if("FINE LAVORO".equals(tipoEvento)){
|
||||
jtbFlav.setDataFineLavoro(jtbFlavEventi.getDataEvento());
|
||||
} else if("VARIAZIONE PAGA BASE".equals(tipoEvento)){
|
||||
if ("S".equals(jtbFlavEventi.getFlagAutorizza())) {
|
||||
valore = jtbFlav.getCostoOrd() + getValPagaBase(ai_rowID);
|
||||
} else {
|
||||
if (lb_existRow) {
|
||||
valore = jtbFlav.getCostoOrd() - getValPagaBase(ai_rowID);
|
||||
} else {
|
||||
valore = jtbFlav.getCostoOrd();
|
||||
}
|
||||
}
|
||||
jtbFlav.setCostoOrd(valore);
|
||||
} else if("VARIAZIONE INDENNITA".equals(tipoEvento)){
|
||||
if ("S".equals(jtbFlavEventi.getFlagAutorizza())) {
|
||||
valore = jtbFlav.getIndennita() + getValIndennita(ai_rowID);
|
||||
} else {
|
||||
if (lb_existRow){
|
||||
valore = jtbFlav.getIndennita() - getValIndennita(ai_rowID);
|
||||
} else {
|
||||
valore = jtbFlav.getIndennita();
|
||||
}
|
||||
}
|
||||
|
||||
jtbFlav.setIndennita(valore);
|
||||
}
|
||||
// jtbCausFlav.setRipetiEvento(ls_flagRipeti);*/
|
||||
}
|
||||
|
||||
public static String completeCausaleTrasp(String gestione) {
|
||||
if ("A".equals(gestione)) {
|
||||
return "ACQUISTO";
|
||||
} else if ("V".equals(gestione)) {
|
||||
return "VENDITA";
|
||||
} else if ("L".equals(gestione)) {
|
||||
return "LAVORAZIONE";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String completePorto(Connection connection, String codAnag) throws SQLException {
|
||||
String sql = "SELECT vtb_clie.porto FROM vtb_clie "
|
||||
+ " WHERE vtb_clie.cod_anag = " + UtilityDB.valueToString(codAnag);
|
||||
PreparedStatement ps = connection.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
String porto = null;
|
||||
if (rs.next()) {
|
||||
porto = rs.getString(1);
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
return porto;
|
||||
}
|
||||
|
||||
/*public static List<HashMap<String, Object>> completeSconto(
|
||||
Connection connection, String codAnag, String field)
|
||||
throws SQLException {
|
||||
String sql = "SELECT vtb_clie." + field + " FROM vtb_clie "
|
||||
+ " WHERE vtb_clie.cod_anag = '" + codAnag + "'";
|
||||
return execQuery(connection, sql);
|
||||
}*/
|
||||
|
||||
public static String completeMezzo(Connection connection, String codAnag) throws SQLException {
|
||||
String sql = "SELECT vtb_clie.mezzo FROM vtb_clie "
|
||||
+ " WHERE vtb_clie.cod_anag = " + UtilityDB.valueToString(codAnag);
|
||||
PreparedStatement ps = connection.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
String mezzo = null;
|
||||
if (rs.next()) {
|
||||
mezzo = rs.getString(1);
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
return mezzo;
|
||||
}
|
||||
|
||||
public static String completeCodLingua(Connection connection, String codAnag) throws SQLException {
|
||||
String sql = "SELECT case when gtb_anag.nazione is null then (select cod_lingua from azienda inner join gtb_nazi on azienda.nazione = gtb_nazi.nazione) else gtb_nazi.cod_lingua end " +
|
||||
" FROM gtb_anag left outer join gtb_nazi on gtb_anag.nazione = gtb_nazi.nazione " +
|
||||
" left outer join gtb_lingue on gtb_nazi.cod_lingua = gtb_lingue.cod_lingua " +
|
||||
" WHERE gtb_anag.cod_anag = " + UtilityDB.valueToString(codAnag);
|
||||
PreparedStatement ps = connection.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
String codLingua = null;
|
||||
if (rs.next()) {
|
||||
codLingua = rs.getString(1);
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
return codLingua;
|
||||
}
|
||||
|
||||
public static Integer completeNumOrdWeb(Connection connection, String serie,
|
||||
String gestione, Date dataOrd) throws Exception {
|
||||
|
||||
Short anno = new Short(new SimpleDateFormat("yyyy").format(dataOrd));
|
||||
CallableStatement cs = connection.prepareCall("{call dbo.NextNumOrdWeb(?, ?, ?, ?)}");
|
||||
cs.setString(1, serie);
|
||||
cs.setString(2, gestione);
|
||||
cs.setShort(3, anno);
|
||||
cs.setInt(4, 0);
|
||||
cs.registerOutParameter(4, Types.INTEGER);
|
||||
cs.execute();
|
||||
Integer numOrd = cs.getInt(4);
|
||||
return numOrd;
|
||||
}
|
||||
|
||||
public static Integer completeRigaOrdWeb(Connection connection,
|
||||
String gestione, Date dataOrd, Integer numOrd, String serie)
|
||||
throws SQLException {
|
||||
String sql = "SELECT IsNull(max(riga_ord), 0) as riga "
|
||||
+ " FROM wdtb_ordr WHERE gestione = '" + gestione + "' "
|
||||
+ " AND data_ord = '" + new SimpleDateFormat(CommonConstants.DATETIME_FORMAT_YMD).format(dataOrd) + "' "
|
||||
+ " AND num_ord = " + numOrd + " AND serie = '" + serie + "'";
|
||||
List<HashMap<String, Object>> list = execQuery(connection, sql);
|
||||
if (list.isEmpty()) {
|
||||
return new Integer("0");
|
||||
} else {
|
||||
return new Integer(list.get(0).get("riga").toString()) + 1;
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
//RosannaR 08/02/17 spostata nelle regole generiche su documenti e ordini
|
||||
|
||||
public static BigDecimal completeValUnt(Connection conn, WdtbOrdr row) throws SQLException {
|
||||
Double cambioDiviCont = completeCambioDiviCont(conn);
|
||||
|
||||
String query;
|
||||
Double valUnt = new Double(0);
|
||||
|
||||
String listino = row.getListino();
|
||||
String gestione = row.getGestione();
|
||||
String codMart = row.getCodMart();
|
||||
String codCol = row.getCodCol();
|
||||
String codTagl = row.getCodTagl();
|
||||
// Date dataOrd = row.getDataOrd();
|
||||
Double rapConv = row.getRapConv();
|
||||
|
||||
String applName = getApplicationName(conn);
|
||||
if (ApplicationName.WINGEST.toString().equals(applName)) {
|
||||
// ACQUISIZIONE PREZZO VENDITA
|
||||
if ("V".equals(gestione)) {
|
||||
if (listino == null) {
|
||||
// SE IL LISTINO E' NUL ALLORA IL PREZZO DEVE ESSERE PRESO DALL'ULTIMO PREZZO DI VENDITA
|
||||
query = "SELECT val_ult_scar FROM mtb_aart WHERE cod_mart = "
|
||||
+ UtilityDB.valueToString(codMart);
|
||||
|
||||
List<HashMap<String, String>> res = execQuery(conn, query);
|
||||
Double valUntScar = Double.valueOf(res.get(0).get("val_ult_scar").toString());
|
||||
valUnt = valUntScar * rapConv * cambioDiviCont;
|
||||
valUnt = IntegerUtility.round(valUnt, EmsRestConstants.cifreDecMax);
|
||||
} else {
|
||||
}
|
||||
} else if ("A".equals(gestione)) {
|
||||
} else if ("L".equals(gestione)) {
|
||||
}
|
||||
} else if (ApplicationName.TEXTILES.toString().equals(applName)) {
|
||||
if (CommonConstants.ULTC.equals(listino)){
|
||||
// ACQUISIZIONE COSTO ULTIMO
|
||||
// getCostoUltimo(conn, codMart, dataOrd, codMdep);
|
||||
// valUnt = InfoCosti.getCostoUltimo() * rapConv;
|
||||
return BigDecimal.ONE;
|
||||
}else if (CommonConstants.CMPPF.equals(listino)) {
|
||||
// COSTO DA ANAGRAFICA
|
||||
// calcCostoArticolo(getProfileDB(), codMart, codCol, codTagl, cambioDiviCont);
|
||||
// valUnt = InfoCosti.getCostoUltimo() * rapConv;
|
||||
return BigDecimal.ONE;
|
||||
}else{
|
||||
// ACQUISIZIONE PREZZO DI VENDITA
|
||||
if ("V".equals(gestione)) {
|
||||
BigDecimal przVend = BigDecimal.ZERO;
|
||||
String sql = "select dbo.f_CalcPrzTextiles("+UtilityDB.valueToString(codMart)+", "+
|
||||
UtilityDB.valueToString(codCol) +", "+ UtilityDB.valueToString(codTagl) + ", " +
|
||||
UtilityDB.valueToString(listino) + ", 'N') as prz_vend";
|
||||
PreparedStatement ps = conn.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
if(rs.next()){
|
||||
przVend = rs.getBigDecimal("prz_vend");
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
|
||||
return przVend.multiply(BigDecimal.valueOf(rapConv));
|
||||
}
|
||||
}
|
||||
}
|
||||
row.setValUnt(BigDecimal.valueOf(valUnt));
|
||||
return BigDecimal.valueOf(valUnt);
|
||||
}
|
||||
*/
|
||||
|
||||
public static LocalDateTime recalcDataRapp(LocalDate dataLav, LocalDateTime dateTime) {
|
||||
|
||||
/*FABIO (21-09-2018): ho dovuto gestire DATR_NULL = 01/01/1900 00:00:00, perchè da PB pur passando NULL veniva sempre
|
||||
impostato 01/01/1900 00:00:00 nella classe e quindi tutte le regole che lavorano sul NULL partivano comunque e a
|
||||
CARELLI avevano la necessità di poter modificare direttamente dalla gestione dei rapportini di WINGEST per manutenzione.
|
||||
todo Dobbiamo capire come mai accade ciò, ma credo sia un problema comune. */
|
||||
if (dateTime != EmsRestConstants.LOCAL_DATE_TIME_NULL) {
|
||||
dateTime = dataLav.atStartOfDay().plusHours(dateTime.getHour())
|
||||
.plusMinutes(dateTime.getMinute())
|
||||
.plusSeconds(dateTime.getSecond());
|
||||
}
|
||||
|
||||
return dateTime;
|
||||
}
|
||||
|
||||
public static void checkCanCloseOrder(Connection connection, DtbOrdt dtbOrdt) throws Exception {
|
||||
String sql = Query.format(
|
||||
"WITH steps AS (SELECT DISTINCT gestione,\n" +
|
||||
" data_ord,\n" +
|
||||
" num_ord,\n" +
|
||||
" MAX(id_step)\n" +
|
||||
" OVER (PARTITION BY gestione, data_ord, num_ord, id_riga ORDER BY id_riga) AS id_step,\n" +
|
||||
" id_riga\n" +
|
||||
" FROM dtb_ord_steps\n" +
|
||||
" WHERE gestione = %s\n" +
|
||||
" AND data_ord = %s\n" +
|
||||
" AND num_ord = %s\n" +
|
||||
" AND cod_jfas <> %s)\n" +
|
||||
"SELECT dos.gestione,\n" +
|
||||
" dos.data_ord,\n" +
|
||||
" dos.num_ord,\n" +
|
||||
" dos.id_step,\n" +
|
||||
" dos.id_riga,\n" +
|
||||
" dos.cod_jfas,\n" +
|
||||
" dos.data_iniz,\n" +
|
||||
" dos.data_fine,\n" +
|
||||
" dos.qta_prod,\n" +
|
||||
" dos.qta_allocata,\n" +
|
||||
" dos.descrizione_attivita,\n" +
|
||||
" dos.note,\n" +
|
||||
" dos.qta_trasferite,\n" +
|
||||
" dos.qta_scartate,\n" +
|
||||
" dos.qta_in_prod,\n" +
|
||||
" dos.qta_disp,\n" +
|
||||
" dos.qta_immesse,\n" +
|
||||
" dos.qta_disp_immessa,\n" +
|
||||
" dos.cod_mdep,\n" +
|
||||
" dos.cod_dtip,\n" +
|
||||
" dos.cod_anag,\n" +
|
||||
" dos.data_doc,\n" +
|
||||
" dos.ser_doc,\n" +
|
||||
" dos.num_doc,\n" +
|
||||
" dos.id_riga_doc,\n" +
|
||||
" dos.num_fase,\n" +
|
||||
" dos.flag_tipo_tempo,\n" +
|
||||
" dos.hr_time,\n" +
|
||||
" dos.hr_num,\n" +
|
||||
" dos.qta_lav,\n" +
|
||||
" dos.unt_mis_lav,\n" +
|
||||
" dos.rap_conv_lav,\n" +
|
||||
" dos.cod_prod_pri,\n" +
|
||||
" dos.activity_id,\n" +
|
||||
" dos.flag_step_attivo\n" +
|
||||
"FROM dtb_ord_steps dos\n" +
|
||||
" INNER JOIN steps ON dos.gestione = steps.gestione AND dos.data_ord = steps.data_ord AND\n" +
|
||||
" dos.num_ord = steps.num_ord AND dos.id_step = steps.id_step AND\n" +
|
||||
" dos.id_riga = steps.id_riga\n" +
|
||||
"WHERE dos.data_iniz IS NOT NULL\n" +
|
||||
" AND (dos.data_fine IS NULL OR dos.flag_step_attivo = 'S')\n" +
|
||||
"ORDER BY dos.id_riga",
|
||||
dtbOrdt.getGestione(),
|
||||
dtbOrdt.getDataOrd(),
|
||||
dtbOrdt.getNumOrd(),
|
||||
dtbOrdt.getDtbOrdSteps().get(0).getCodJfas()
|
||||
);
|
||||
|
||||
List<DtbOrdSteps> ordSteps = UtilityDB.executeSimpleQueryDTO(connection, sql, DtbOrdSteps.class);
|
||||
|
||||
if (ordSteps == null || ordSteps.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String message = String.format(
|
||||
"Impossibile chiudere un ordine con fasi aperte. Fasi aperte:\n%s\n",
|
||||
ordSteps.stream().map(DtbOrdSteps::getCodJfas).collect(Collectors.joining("\n"))
|
||||
);
|
||||
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
@@ -369,7 +368,7 @@ public class PurchasesRules extends QueryRules {
|
||||
String fielsNameUntMis = "unt_doc";
|
||||
if (entity instanceof DtbOrdr || entity instanceof WdtbOrdr) fielsNameUntMis = "unt_ord";
|
||||
|
||||
LocalDate dataValidita;
|
||||
Date dataValidita;
|
||||
switch (tipoCalcPrz) {
|
||||
case 0: //dataord
|
||||
dataValidita = entity.getDataOrd();
|
||||
@@ -380,7 +379,7 @@ public class PurchasesRules extends QueryRules {
|
||||
case 1://datadoc
|
||||
case 2://datareg
|
||||
if (entity instanceof DtbOrdCommonR) {
|
||||
dataValidita = ((DtbOrdCommonR) entity).getDataCons().toLocalDate();
|
||||
dataValidita = ((DtbOrdCommonR) entity).getDataCons();
|
||||
if (dataValidita == null) dataValidita = entity.getDataOrd();
|
||||
} else {
|
||||
if (tipoCalcPrz == 1) {
|
||||
@@ -400,7 +399,7 @@ public class PurchasesRules extends QueryRules {
|
||||
}
|
||||
|
||||
if (UtilityString.isNullOrEmpty(entity.getCodArtFor())) {
|
||||
LocalDate dataGriglia = ((DtbDocOrdT) entity.getParent()).getDataOrd();
|
||||
Date dataGriglia = ((DtbDocOrdT) entity.getParent()).getDataOrd();
|
||||
if (dataGriglia == null && entity instanceof DtbBaseDocR) {
|
||||
dataGriglia = ((DtbBaseDocR) entity).getDataDoc();
|
||||
}
|
||||
@@ -745,10 +744,10 @@ public class PurchasesRules extends QueryRules {
|
||||
sql = String.format(sql,
|
||||
UtilityDB.valueToString(mtbAartQta.getCodMdep()),
|
||||
UtilityDB.valueToString(mtbAartQta.getCodMart()),
|
||||
UtilityDB.valueDateToString(mtbAartQta.getDataIniz(), CommonConstants.DATE_FORMAT_YMD_DASHED));
|
||||
UtilityDB.valueDateToString(mtbAartQta.getDataIniz(), CommonConstants.DATE_FORMAT_YMD));
|
||||
|
||||
if (mtbAartQta.getDataFine() != null) {
|
||||
sql = UtilityDB.addwhereCond(sql, "data_fine = " + UtilityDB.valueDateToString(mtbAartQta.getDataFine(), CommonConstants.DATE_FORMAT_YMD_DASHED), false);
|
||||
sql = UtilityDB.addwhereCond(sql, "data_fine = " + UtilityDB.valueDateToString(mtbAartQta.getDataFine(), CommonConstants.DATE_FORMAT_YMD), false);
|
||||
}
|
||||
|
||||
Long idRiga = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
|
||||
@@ -1,244 +1,245 @@
|
||||
package it.integry.ems.rules.completing;
|
||||
|
||||
import com.annimon.stream.Optional;
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityHashMap;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ReceiptRules extends QueryRules {
|
||||
|
||||
|
||||
public static MtbDepoCasse completeMtbDepoCasse(Connection connection, String codMdep, String codCassa) throws Exception {
|
||||
String sql = "select * from mtb_depo_casse where cod_mdep='" + codMdep + "' and cod_cassa = " + codCassa;
|
||||
|
||||
List<HashMap<String, Object>> list = execQuery(connection, sql);
|
||||
if (list.isEmpty()) {
|
||||
MtbDepoCasse casse = new MtbDepoCasse();
|
||||
casse.setCodMdep(codMdep);
|
||||
casse.setCodCassa(codCassa);
|
||||
casse.setMatricola(codCassa);
|
||||
return casse;
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void completeUntMisVend(Connection conn, NtbDoct ntbDoct) throws Exception {
|
||||
List<String> articoli =
|
||||
Stream.of(ntbDoct.getNtbDocr())
|
||||
.filter(x -> x.getUntMis() == null)
|
||||
.map(NtbDocr::getCodMart)
|
||||
.withoutNulls()
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
if (!articoli.isEmpty()) {
|
||||
String whereCondArt = StringUtils.join(articoli, "','");
|
||||
if (!UtilityString.isNullOrEmpty(whereCondArt)) {
|
||||
whereCondArt = "lisv.cod_mart in ('" + whereCondArt + "')";
|
||||
}
|
||||
|
||||
String sql =
|
||||
"SELECT cod_mart, unt_mis_ven " +
|
||||
" FROM dbo.getListinoVendita(" + UtilityDB.valueToString(ntbDoct.getDataDoc()) + ", "
|
||||
+ UtilityDB.valueToString(ntbDoct.getCodVlis()) + ", null ) lisv ";
|
||||
|
||||
sql = UtilityDB.addwhereCond(sql, whereCondArt, true);
|
||||
List<HashMap<String, Object>> datiListino = UtilityDB.executeSimpleQuery(conn, sql);
|
||||
|
||||
if (datiListino == null) return;
|
||||
|
||||
for (String articolo : articoli) {
|
||||
Optional<HashMap<String, Object>> firstUntMis = Stream.of(datiListino)
|
||||
.filter(x -> UtilityString.equalsIgnoreCase(UtilityHashMap.getValueIfExists(x, "cod_mart"), articolo))
|
||||
.findFirst();
|
||||
|
||||
|
||||
if (firstUntMis.isPresent()) {
|
||||
String untMisVen = UtilityHashMap.getValueIfExists(firstUntMis.get(), "unt_mis_ven");
|
||||
Stream.of(ntbDoct.getNtbDocr()).filter(x -> UtilityString.equalsIgnoreCase(x.getCodMart(), articolo)).forEach(x -> {
|
||||
x.setUntMis(untMisVen);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static MtbDepoOper completeMtbDepoOper(Connection connection, String codMdep, String codOper) throws Exception {
|
||||
String sql = "select * from mtb_depo_oper where cod_mdep='" + codMdep + "' and cod_mdep_oper='" + codOper + "'";
|
||||
|
||||
List<HashMap<String, Object>> list = execQuery(connection, sql);
|
||||
if (list.isEmpty()) {
|
||||
MtbDepoOper oper = new MtbDepoOper();
|
||||
|
||||
Pattern p = Pattern.compile("^[0-9]+");
|
||||
Matcher matcher = p.matcher(codOper);
|
||||
String codBarreOp;
|
||||
if (matcher.find()) {
|
||||
NumberFormat formatter = new DecimalFormat("00");
|
||||
String s = formatter.format(Integer.parseInt(codOper));
|
||||
codBarreOp = "O" + codMdep + s;
|
||||
} else {
|
||||
codBarreOp = codOper;
|
||||
}
|
||||
oper.setCodMdep(codMdep);
|
||||
oper.setCodMdepOper(codOper);
|
||||
oper.setDescrizione("NUOVO OPERATORE");
|
||||
oper.setFlagStorno("N");
|
||||
oper.setCodBarre(codBarreOp);
|
||||
return oper;
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String completeCodMart(Connection connection, String codBarre) throws Exception {
|
||||
String sql =
|
||||
"SELECT DISTINCT mvw_barcode_det.cod_mart " +
|
||||
" FROM mvw_barcode_det, mtb_aart " +
|
||||
" WHERE ( mvw_barcode_det.cod_barre = " + UtilityDB.valueToString(codBarre) + " OR " +
|
||||
" ( LEN('" + codBarre + "') = 7 and left('" + codBarre + "', 1) = '2' and right('" + codBarre + "', 6) = cod_barre ) OR " +
|
||||
" mvw_barcode_det.cod_barre + Replicate('0', 13 - len(mvw_barcode_det.cod_barre)) = " + UtilityDB.valueToString(codBarre) + ") ";
|
||||
String codMart = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
return codMart;
|
||||
}
|
||||
|
||||
|
||||
public static String completeCodAliq(Connection connection, String codMart) throws Exception {
|
||||
String codAliq = CommonRules.completeCodAliqSimple(connection, codMart);
|
||||
if (UtilityString.isNullOrEmpty(codAliq)) {
|
||||
String codAliqDefault = setupGest.getImportSetup(connection, "SCONTRINI", "MMPOS_SERVICES", "IVA_DEFAULT");
|
||||
codAliq = codAliqDefault;
|
||||
}
|
||||
return codAliq;
|
||||
}
|
||||
|
||||
public static String completePromozione(Connection connection, String codMart,
|
||||
String codMdep, LocalDateTime dataDoc) throws Exception {
|
||||
/*ESCLUDI_PROMO_INFORMATIVE*/
|
||||
boolean esludiPromo = setupGest.getSetupBoolean(connection, "NTB_DOCT", "PROMOZIONI", "ESCLUDI_PROMO_INFORMATIVE");
|
||||
String whereCond = "";
|
||||
if (esludiPromo) {
|
||||
whereCond = "(flag_tipologia is null or flag_tipologia <> 'I')";
|
||||
}
|
||||
|
||||
String sql =
|
||||
Query.format(
|
||||
"SELECT cod_promo " +
|
||||
" FROM dbo.getPromozioneVendita(%s, null, null, null, %s) as promo_vend , " +
|
||||
" mtb_depo WHERE promo_vend.cod_vlis = mtb_depo.cod_vlis AND " +
|
||||
" mtb_depo.cod_mdep = %s",
|
||||
dataDoc,
|
||||
codMart,
|
||||
codMdep);
|
||||
sql = UtilityDB.addwhereCond(sql, whereCond, true);
|
||||
String codPromo = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
return codPromo;
|
||||
}
|
||||
|
||||
public static NtbTipiInca insTipiInca(Connection connection, EntityBase entity) throws Exception {
|
||||
String codMdep = null, tipoInca = null, descrPaga = null;
|
||||
|
||||
if (entity instanceof NtbDocp) {
|
||||
codMdep = ((NtbDocp) entity).getCodMdep();
|
||||
tipoInca = ((NtbDocp) entity).getTipoInca();
|
||||
descrPaga = ((NtbDocp) entity).getDescrPaga();
|
||||
} else if (entity instanceof NtbRapp) {
|
||||
codMdep = ((NtbRapp) entity).getCodMdep();
|
||||
tipoInca = ((NtbRapp) entity).getTipoInca();
|
||||
}
|
||||
|
||||
if (UtilityString.isNullOrEmpty(descrPaga)) {
|
||||
descrPaga = tipoInca;
|
||||
}
|
||||
|
||||
String sql =
|
||||
"SELECT count(*) FROM ntb_tipi_inca "
|
||||
+ "WHERE cod_mdep = " + UtilityDB.valueToString(codMdep)
|
||||
+ " AND tipo_inca = " + UtilityDB.valueToString(tipoInca);
|
||||
Integer countTipiInca = (Integer) getSingleValue(connection, sql);
|
||||
|
||||
NtbTipiInca ntbTipiInca = new NtbTipiInca();
|
||||
OperationType operationType = OperationType.NO_OP;
|
||||
ntbTipiInca.setCodMdep(codMdep);
|
||||
ntbTipiInca.setTipoInca(tipoInca);
|
||||
ntbTipiInca.setDescrizione(descrPaga);
|
||||
if (countTipiInca == 0) {
|
||||
operationType = OperationType.INSERT;
|
||||
}
|
||||
ntbTipiInca.setOperation(operationType);
|
||||
return ntbTipiInca;
|
||||
}
|
||||
|
||||
public static DtbOrdt evadiOrdine(Connection conn, NtbDocr ntbDocr) throws Exception {
|
||||
|
||||
List<DtbOrdr> righe = new ArrayList<DtbOrdr>();
|
||||
String sql = "SELECT qta_ord - qta_evasa, qta_evasa, riga_ord from dtb_ordt inner join dtb_ordr on dtb_ordt.gestione = dtb_ordr.gestione and dtb_ordt.data_ord = dtb_ordr.data_ord and dtb_ordt.num_ord = dtb_ordr.num_ord " +
|
||||
"WHERE dtb_ordr.cod_mart = " + UtilityDB.valueToString(ntbDocr.getCodMart()) + " and " +
|
||||
"dtb_ordt.num_ord = " + UtilityDB.valueToString(ntbDocr.getNumOrd()) + " and " +
|
||||
"dtb_ordt.data_ord = " + UtilityDB.valueToString(ntbDocr.getDataOrd()) + " and " +
|
||||
"dtb_ordt.flag_prz_iva = 'S' and " +
|
||||
"qta_ord > qta_evasa and " +
|
||||
"dtb_ordt.flag_sospeso = 'N'";
|
||||
|
||||
PreparedStatement ps = conn.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
BigDecimal qtaDoc = ntbDocr.getQtaDoc();
|
||||
|
||||
while (rs.next() && qtaDoc.doubleValue() > 0) {
|
||||
BigDecimal qtaOrd = rs.getBigDecimal(1);
|
||||
BigDecimal qtaEvasa = rs.getBigDecimal(2);
|
||||
Integer rigaOrd = rs.getInt(3);
|
||||
|
||||
DtbOrdr dtbOrdr = new DtbOrdr();
|
||||
dtbOrdr.setGestione("V");
|
||||
dtbOrdr.setDataOrd(ntbDocr.getDataOrd());
|
||||
dtbOrdr.setNumOrd(ntbDocr.getNumOrd());
|
||||
dtbOrdr.setRigaOrd(rigaOrd);
|
||||
dtbOrdr.setOperation(OperationType.UPDATE);
|
||||
|
||||
if (qtaDoc.doubleValue() >= qtaOrd.doubleValue()) {
|
||||
dtbOrdr.setQtaEvasa(qtaEvasa.add(qtaOrd));
|
||||
qtaDoc.subtract(qtaOrd);
|
||||
} else {
|
||||
dtbOrdr.setQtaEvasa(qtaEvasa.add(qtaDoc));
|
||||
qtaDoc = BigDecimal.ZERO;
|
||||
}
|
||||
righe.add(dtbOrdr);
|
||||
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
DtbOrdt dtbOrdt = new DtbOrdt();
|
||||
dtbOrdt.setGestione("V")
|
||||
.setDataOrd(ntbDocr.getDataOrd())
|
||||
.setNumOrd(ntbDocr.getNumOrd())
|
||||
.setDtbOrdr(righe);
|
||||
|
||||
return dtbOrdt;
|
||||
}
|
||||
public static BigDecimal calcValScoArt(NtbDocr ntbDocr) {
|
||||
if ( ntbDocr.getNtbDocs().size() > 0 ) {
|
||||
return ntbDocr.getNtbDocs().stream().map(NtbDocs::getValSco).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
} else
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
}
|
||||
package it.integry.ems.rules.completing;
|
||||
|
||||
import com.annimon.stream.Optional;
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ReceiptRules extends QueryRules {
|
||||
|
||||
|
||||
public static MtbDepoCasse completeMtbDepoCasse(Connection connection, String codMdep, String codCassa) throws Exception {
|
||||
String sql = "select * from mtb_depo_casse where cod_mdep='" + codMdep + "' and cod_cassa = " + codCassa;
|
||||
|
||||
List<HashMap<String, Object>> list = execQuery(connection, sql);
|
||||
if (list.isEmpty()) {
|
||||
MtbDepoCasse casse = new MtbDepoCasse();
|
||||
casse.setCodMdep(codMdep);
|
||||
casse.setCodCassa(codCassa);
|
||||
casse.setMatricola(codCassa);
|
||||
return casse;
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void completeUntMisVend(Connection conn, NtbDoct ntbDoct) throws Exception {
|
||||
List<String> articoli =
|
||||
Stream.of(ntbDoct.getNtbDocr())
|
||||
.filter(x -> x.getUntMis() == null)
|
||||
.map(NtbDocr::getCodMart)
|
||||
.withoutNulls()
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
if (!articoli.isEmpty()) {
|
||||
String whereCondArt = StringUtils.join(articoli, "','");
|
||||
if (!UtilityString.isNullOrEmpty(whereCondArt)) {
|
||||
whereCondArt = "lisv.cod_mart in ('" + whereCondArt + "')";
|
||||
}
|
||||
|
||||
String sql =
|
||||
"SELECT cod_mart, unt_mis_ven " +
|
||||
" FROM dbo.getListinoVendita(" + UtilityDB.valueToString(ntbDoct.getDataDoc()) + ", "
|
||||
+ UtilityDB.valueToString(ntbDoct.getCodVlis()) + ", null ) lisv ";
|
||||
|
||||
sql = UtilityDB.addwhereCond(sql, whereCondArt, true);
|
||||
List<HashMap<String, Object>> datiListino = UtilityDB.executeSimpleQuery(conn, sql);
|
||||
|
||||
if (datiListino == null) return;
|
||||
|
||||
for (String articolo : articoli) {
|
||||
Optional<HashMap<String, Object>> firstUntMis = Stream.of(datiListino)
|
||||
.filter(x -> UtilityString.equalsIgnoreCase(UtilityHashMap.getValueIfExists(x, "cod_mart"), articolo))
|
||||
.findFirst();
|
||||
|
||||
|
||||
if (firstUntMis.isPresent()) {
|
||||
String untMisVen = UtilityHashMap.getValueIfExists(firstUntMis.get(), "unt_mis_ven");
|
||||
Stream.of(ntbDoct.getNtbDocr()).filter(x -> UtilityString.equalsIgnoreCase(x.getCodMart(), articolo)).forEach(x -> {
|
||||
x.setUntMis(untMisVen);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static MtbDepoOper completeMtbDepoOper(Connection connection, String codMdep, String codOper) throws Exception {
|
||||
String sql = "select * from mtb_depo_oper where cod_mdep='" + codMdep + "' and cod_mdep_oper='" + codOper + "'";
|
||||
|
||||
List<HashMap<String, Object>> list = execQuery(connection, sql);
|
||||
if (list.isEmpty()) {
|
||||
MtbDepoOper oper = new MtbDepoOper();
|
||||
|
||||
Pattern p = Pattern.compile("^[0-9]+");
|
||||
Matcher matcher = p.matcher(codOper);
|
||||
String codBarreOp;
|
||||
if (matcher.find()) {
|
||||
NumberFormat formatter = new DecimalFormat("00");
|
||||
String s = formatter.format(Integer.parseInt(codOper));
|
||||
codBarreOp = "O" + codMdep + s;
|
||||
} else {
|
||||
codBarreOp = codOper;
|
||||
}
|
||||
oper.setCodMdep(codMdep);
|
||||
oper.setCodMdepOper(codOper);
|
||||
oper.setDescrizione("NUOVO OPERATORE");
|
||||
oper.setFlagStorno("N");
|
||||
oper.setCodBarre(codBarreOp);
|
||||
return oper;
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String completeCodMart(Connection connection, String codBarre) throws Exception {
|
||||
String sql =
|
||||
"SELECT DISTINCT mvw_barcode_det.cod_mart " +
|
||||
" FROM mvw_barcode_det, mtb_aart " +
|
||||
" WHERE ( mvw_barcode_det.cod_barre = " + UtilityDB.valueToString(codBarre) + " OR " +
|
||||
" ( LEN('" + codBarre + "') = 7 and left('" + codBarre + "', 1) = '2' and right('" + codBarre + "', 6) = cod_barre ) OR " +
|
||||
" mvw_barcode_det.cod_barre + Replicate('0', 13 - len(mvw_barcode_det.cod_barre)) = " + UtilityDB.valueToString(codBarre) + ") ";
|
||||
String codMart = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
return codMart;
|
||||
}
|
||||
|
||||
|
||||
public static String completeCodAliq(Connection connection, String codMart) throws Exception {
|
||||
String codAliq = CommonRules.completeCodAliqSimple(connection, codMart);
|
||||
if (UtilityString.isNullOrEmpty(codAliq)) {
|
||||
String codAliqDefault = setupGest.getImportSetup(connection, "SCONTRINI", "MMPOS_SERVICES", "IVA_DEFAULT");
|
||||
codAliq = codAliqDefault;
|
||||
}
|
||||
return codAliq;
|
||||
}
|
||||
|
||||
public static String completePromozione(Connection connection, String codMart,
|
||||
String codMdep, LocalDateTime dataDoc) throws Exception {
|
||||
/*ESCLUDI_PROMO_INFORMATIVE*/
|
||||
boolean esludiPromo = setupGest.getSetupBoolean(connection, "NTB_DOCT", "PROMOZIONI", "ESCLUDI_PROMO_INFORMATIVE");
|
||||
String whereCond = "";
|
||||
if (esludiPromo) {
|
||||
whereCond = "(flag_tipologia is null or flag_tipologia <> 'I')";
|
||||
}
|
||||
|
||||
String sql =
|
||||
Query.format(
|
||||
"SELECT cod_promo " +
|
||||
" FROM dbo.getPromozioneVendita(%s, null, null, null, %s) as promo_vend , " +
|
||||
" mtb_depo WHERE promo_vend.cod_vlis = mtb_depo.cod_vlis AND " +
|
||||
" mtb_depo.cod_mdep = %s",
|
||||
dataDoc,
|
||||
codMart,
|
||||
codMdep);
|
||||
sql = UtilityDB.addwhereCond(sql, whereCond, true);
|
||||
String codPromo = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
return codPromo;
|
||||
}
|
||||
|
||||
public static NtbTipiInca insTipiInca(Connection connection, EntityBase entity) throws Exception {
|
||||
String codMdep = null, tipoInca = null, descrPaga = null;
|
||||
|
||||
if (entity instanceof NtbDocp) {
|
||||
codMdep = ((NtbDocp) entity).getCodMdep();
|
||||
tipoInca = ((NtbDocp) entity).getTipoInca();
|
||||
descrPaga = ((NtbDocp) entity).getDescrPaga();
|
||||
} else if (entity instanceof NtbRapp) {
|
||||
codMdep = ((NtbRapp) entity).getCodMdep();
|
||||
tipoInca = ((NtbRapp) entity).getTipoInca();
|
||||
}
|
||||
|
||||
if (UtilityString.isNullOrEmpty(descrPaga)) {
|
||||
descrPaga = tipoInca;
|
||||
}
|
||||
|
||||
String sql =
|
||||
"SELECT count(*) FROM ntb_tipi_inca "
|
||||
+ "WHERE cod_mdep = " + UtilityDB.valueToString(codMdep)
|
||||
+ " AND tipo_inca = " + UtilityDB.valueToString(tipoInca);
|
||||
Integer countTipiInca = (Integer) getSingleValue(connection, sql);
|
||||
|
||||
NtbTipiInca ntbTipiInca = new NtbTipiInca();
|
||||
OperationType operationType = OperationType.NO_OP;
|
||||
ntbTipiInca.setCodMdep(codMdep);
|
||||
ntbTipiInca.setTipoInca(tipoInca);
|
||||
ntbTipiInca.setDescrizione(descrPaga);
|
||||
if (countTipiInca == 0) {
|
||||
operationType = OperationType.INSERT;
|
||||
}
|
||||
ntbTipiInca.setOperation(operationType);
|
||||
return ntbTipiInca;
|
||||
}
|
||||
|
||||
public static DtbOrdt evadiOrdine(Connection conn, NtbDocr ntbDocr) throws Exception {
|
||||
|
||||
List<DtbOrdr> righe = new ArrayList<DtbOrdr>();
|
||||
String sql = "SELECT qta_ord - qta_evasa, qta_evasa, riga_ord from dtb_ordt inner join dtb_ordr on dtb_ordt.gestione = dtb_ordr.gestione and dtb_ordt.data_ord = dtb_ordr.data_ord and dtb_ordt.num_ord = dtb_ordr.num_ord " +
|
||||
"WHERE dtb_ordr.cod_mart = " + UtilityDB.valueToString(ntbDocr.getCodMart()) + " and " +
|
||||
"dtb_ordt.num_ord = " + UtilityDB.valueToString(ntbDocr.getNumOrd()) + " and " +
|
||||
"dtb_ordt.data_ord = " + UtilityDB.valueToString(ntbDocr.getDataOrd()) + " and " +
|
||||
"dtb_ordt.flag_prz_iva = 'S' and " +
|
||||
"qta_ord > qta_evasa and " +
|
||||
"dtb_ordt.flag_sospeso = 'N'";
|
||||
|
||||
PreparedStatement ps = conn.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
BigDecimal qtaDoc = ntbDocr.getQtaDoc();
|
||||
|
||||
while (rs.next() && qtaDoc.doubleValue() > 0) {
|
||||
BigDecimal qtaOrd = rs.getBigDecimal(1);
|
||||
BigDecimal qtaEvasa = rs.getBigDecimal(2);
|
||||
Integer rigaOrd = rs.getInt(3);
|
||||
|
||||
DtbOrdr dtbOrdr = new DtbOrdr();
|
||||
dtbOrdr.setGestione("V");
|
||||
dtbOrdr.setDataOrd(UtilityLocalDate.localDateToDate(ntbDocr.getDataOrd()));
|
||||
dtbOrdr.setNumOrd(ntbDocr.getNumOrd());
|
||||
dtbOrdr.setRigaOrd(rigaOrd);
|
||||
dtbOrdr.setOperation(OperationType.UPDATE);
|
||||
|
||||
if (qtaDoc.doubleValue() >= qtaOrd.doubleValue()) {
|
||||
dtbOrdr.setQtaEvasa(qtaEvasa.add(qtaOrd));
|
||||
qtaDoc.subtract(qtaOrd);
|
||||
} else {
|
||||
dtbOrdr.setQtaEvasa(qtaEvasa.add(qtaDoc));
|
||||
qtaDoc = BigDecimal.ZERO;
|
||||
}
|
||||
righe.add(dtbOrdr);
|
||||
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
DtbOrdt dtbOrdt = new DtbOrdt();
|
||||
dtbOrdt.setGestione("V")
|
||||
.setDataOrd(UtilityLocalDate.localDateToDate(ntbDocr.getDataOrd()))
|
||||
.setNumOrd(ntbDocr.getNumOrd())
|
||||
.setDtbOrdr(righe);
|
||||
|
||||
return dtbOrdt;
|
||||
}
|
||||
public static BigDecimal calcValScoArt(NtbDocr ntbDocr) {
|
||||
if ( ntbDocr.getNtbDocs().size() > 0 ) {
|
||||
return ntbDocr.getNtbDocs().stream().map(NtbDocs::getValSco).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
} else
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,14 +3,16 @@ package it.integry.ems.rules.completing.dto;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
|
||||
public class DatiPartitaMagDTO {
|
||||
private String codMart;
|
||||
private String partitaMag;
|
||||
private String codAnag;
|
||||
private String gestione;
|
||||
private LocalDate dataOrd;
|
||||
private Date dataOrd;
|
||||
private Integer numOrd;
|
||||
private String codJfas;
|
||||
private LocalDate dataScad;
|
||||
@@ -53,11 +55,11 @@ public class DatiPartitaMagDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDate getDataOrd() {
|
||||
public Date getDataOrd() {
|
||||
return dataOrd;
|
||||
}
|
||||
|
||||
public DatiPartitaMagDTO setDataOrd(LocalDate dataOrd) {
|
||||
public DatiPartitaMagDTO setDataOrd(Date dataOrd) {
|
||||
this.dataOrd = dataOrd;
|
||||
return this;
|
||||
}
|
||||
@@ -113,7 +115,7 @@ public class DatiPartitaMagDTO {
|
||||
UtilityString.streNull(this.getPartitaMag()) + ";" +
|
||||
UtilityString.streNull(this.getCodAnag()) + ";" +
|
||||
UtilityString.streNull(this.getGestione()) + ";" +
|
||||
(this.getDataOrd() == null ? "" : CommonConstants.DATE_YMD_DASHED_FORMATTER.format(this.getDataOrd())) + ";" +
|
||||
(this.getDataOrd() == null ? "" : new SimpleDateFormat(CommonConstants.DATE_FORMAT_YMD).format(this.getDataOrd())) + ";" +
|
||||
(this.getNumOrd() == null ? "" : this.getNumOrd().toString()) + ";" +
|
||||
UtilityString.streNull(this.getCodJfas()) + ";" +
|
||||
(this.getDataScad() == null ? "" : CommonConstants.DATE_YMD_DASHED_FORMATTER.format(this.getDataScad())) + ";" +
|
||||
|
||||
@@ -7,7 +7,6 @@ import java.util.HashMap;
|
||||
public class ForeignKeyDTO {
|
||||
|
||||
public static HashMap<String, String> tableConstraintBindings = new HashMap<String, String>() {{
|
||||
put(CtbAmac.ENTITY, "Codice macchina inesistente");
|
||||
put(MtbAart.ENTITY, "Codice articolo inesistente");
|
||||
put(MtbPartitaMag.ENTITY, "Partita di magazzino inesistente");
|
||||
put(DtbDoct.ENTITY, "Documento inesistente");
|
||||
|
||||
@@ -1,34 +1,40 @@
|
||||
package it.integry.ems.service;
|
||||
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@Scope("request")
|
||||
public class AziendaService {
|
||||
|
||||
public String retrieveInternalCodAnagFornitore(Connection connection) throws Exception {
|
||||
@Autowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
|
||||
public String retrieveInternalCodAnagFornitore() throws Exception {
|
||||
String internalCodAnagsQuery = "SELECT CAST(ga.cod_anag AS VARCHAR(5)) AS cod_anag\n" +
|
||||
"FROM azienda\n" +
|
||||
" INNER JOIN gtb_anag ga ON azienda.part_iva = ga.part_iva\n" +
|
||||
" INNER JOIN atb_forn af ON ga.cod_anag = af.cod_anag AND af.flag_stato = 'A'";
|
||||
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, internalCodAnagsQuery);
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), internalCodAnagsQuery);
|
||||
}
|
||||
|
||||
public String retrieveInternalCodAnagCliente(Connection connection) throws Exception {
|
||||
public String retrieveInternalCodAnagCliente() throws Exception {
|
||||
String internalCodAnagsQuery = "SELECT CAST(ga.cod_anag AS VARCHAR(5)) AS cod_anag\n" +
|
||||
"FROM azienda\n" +
|
||||
" INNER JOIN gtb_anag ga ON azienda.part_iva = ga.part_iva\n" +
|
||||
" INNER JOIN vtb_clie vc ON ga.cod_anag = vc.cod_anag AND vc.flag_stato = 'A'";
|
||||
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, internalCodAnagsQuery);
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), internalCodAnagsQuery);
|
||||
}
|
||||
|
||||
public String retrieveInternalPartIva(Connection connection) throws Exception {
|
||||
public String retrieveInternalPartIva() throws Exception {
|
||||
String internalCodAnagsQuery = "SELECT part_iva\n" +
|
||||
"FROM azienda";
|
||||
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, internalCodAnagsQuery);
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), internalCodAnagsQuery);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user