Compare commits
63 Commits
933675b066
...
JpaTest
| Author | SHA1 | Date | |
|---|---|---|---|
| 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 | |||
| 313bfc21ff | |||
| 36f50ad846 | |||
| 4e3d15ebd8 | |||
| 8afa01d8ef | |||
| db1949b5b6 | |||
| 92cd4b1af5 | |||
| 671c2e99d0 | |||
| e8a1a8ca0b | |||
| 78dbf9f7e3 | |||
| 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
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" />
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -32,6 +32,7 @@ public class DbmsChangeTrackerComponent {
|
||||
add(MtbAartBarCode.ENTITY);
|
||||
add(MtbUntMis.ENTITY);
|
||||
add(MtbDepo.ENTITY);
|
||||
add(MtbDepoPosizioni.ENTITY);
|
||||
add(StbEditLimit.ENTITY);
|
||||
add(StbGestSetup.ENTITY);
|
||||
add(StbGestSetupDepo.ENTITY);
|
||||
|
||||
@@ -57,6 +57,7 @@ public class EntityCacheComponent implements ApplicationListener {
|
||||
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);
|
||||
|
||||
@@ -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();
|
||||
@@ -100,6 +103,24 @@ public class RequestDataDTO {
|
||||
} else {
|
||||
jsonObjectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
}
|
||||
|
||||
// Logica di fallback o recupero tenant da sessione/utente
|
||||
if (profileDB == null || profileDB.isEmpty()) {
|
||||
// Esempio: recupero da sessione se presente
|
||||
// tenantId = (String) request.getSession().getAttribute("TENANT_ID");
|
||||
|
||||
// Fallback temporaneo per test
|
||||
// tenantId = DEFAULT_TENANT;
|
||||
}
|
||||
|
||||
if (profileDB != null) {
|
||||
TenantContext.setCurrentTenant(profileDB);
|
||||
}
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void destroy() throws Exception {
|
||||
TenantContext.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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(), 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();
|
||||
}
|
||||
}
|
||||
|
||||
18
ems-core/src/main/java/it/integry/ems/jpa/TenantContext.java
Normal file
18
ems-core/src/main/java/it/integry/ems/jpa/TenantContext.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package it.integry.ems.jpa;
|
||||
|
||||
public class TenantContext {
|
||||
private static final ThreadLocal<String> currentTenant = new ThreadLocal<>();
|
||||
|
||||
public static void setCurrentTenant(String tenant) {
|
||||
currentTenant.set(tenant);
|
||||
}
|
||||
|
||||
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,20 @@
|
||||
package it.integry.ems.jpa.repository;
|
||||
|
||||
import it.integry.ems_model.entity.MtbAart;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
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);
|
||||
|
||||
List<MtbAart> findByCodMartIn(List<String> codMarts);
|
||||
|
||||
|
||||
@Query("SELECT m FROM MtbAart m WHERE m.untMis = 'KG'")
|
||||
List<MtbAart> findMtbAartsByUntMisKG();
|
||||
}
|
||||
@@ -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,8 +119,10 @@ public enum IntegryCustomer {
|
||||
IntegryCustomerDB.Suit_TenutaArianna,
|
||||
IntegryCustomerDB.Suit_Valpietro),
|
||||
Tempesta(IntegryCustomerDB.Tempesta_Tempesta,
|
||||
IntegryCustomerDB.Tempesta_DI,
|
||||
IntegryCustomerDB.Tempesta_VivaiTempesta,
|
||||
IntegryCustomerDB.Tempesta_DI),
|
||||
IntegryCustomerDB.Tempesta_VivaiTempesta_DI
|
||||
),
|
||||
Tosca(IntegryCustomerDB.Tosca_Ba,
|
||||
IntegryCustomerDB.Tosca_Ce,
|
||||
IntegryCustomerDB.Tosca_Cz,
|
||||
|
||||
@@ -198,8 +198,9 @@ public enum IntegryCustomerDB {
|
||||
|
||||
|
||||
Tempesta_Tempesta("tempesta"),
|
||||
Tempesta_VivaiTempesta("vivaitempesta"),
|
||||
Tempesta_DI("tempestadi"),
|
||||
Tempesta_VivaiTempesta("vivaitempesta"),
|
||||
Tempesta_VivaiTempesta_DI("vivaitempestadi"),
|
||||
|
||||
|
||||
Tosca_Ba("tosca_ba"),
|
||||
|
||||
@@ -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,6 +10,9 @@ public class Migration_20251205111526 extends BaseMigration implements Migration
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateView("mvw_sitart_udc_det_all","CREATE VIEW [dbo].[mvw_sitart_udc_det_all] AS\n" +
|
||||
"WITH SitMtbColr AS (\n" +
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251209113110 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
executeStatement("alter table mtb_aart alter column ingredienti varchar(8000)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251211085116 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetup("W_CREG_IVA_DISP", "DATAWINDOW", "D_CREG_IVA_REP", null,
|
||||
null, false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
|
||||
if(isCustomer(IntegryCustomer.Cosmapack)) {
|
||||
updateSetupValue("W_CREG_IVA_DISP", "DATAWINDOW", "D_CREG_IVA_REP", "d_creg_iva_cosmopack_rep");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251211165528 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetup("w_vriepfattagecomp_disp", "CB_VIS_DETTAGLIO", "VISIBLE", "N",
|
||||
null, false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
|
||||
if(isCustomer(IntegryCustomer.RossoGargano)) {
|
||||
updateSetupValue("w_vriepfattagecomp_disp", "CB_VIS_DETTAGLIO", "VISIBLE", "S");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 {
|
||||
}
|
||||
}
|
||||
@@ -184,7 +184,7 @@ public class AccountingRules extends QueryRules {
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(codBiva)) {
|
||||
for (CtbMovi ctbMovi : ctbMovt.getCtbMovi()) {
|
||||
if (UtilityString.isNullOrEmpty(ctbMovi.getCodBiva()) && !ctbMovi.getCodBiva().equalsIgnoreCase(EmsRestConstants.NULL)) {
|
||||
if (ctbMovi.getCodBiva() != null && ctbMovi.getCodBiva().trim().isEmpty()) {
|
||||
ctbMovi.setCodBiva(codBiva);
|
||||
}
|
||||
movi.add(ctbMovi);
|
||||
|
||||
@@ -730,7 +730,7 @@ public class CommonRules extends QueryRules {
|
||||
public static String completeFlagQtaCnfFissa(Connection connection, IntegryCustomerDB customerDB, String codMart) {
|
||||
final EntityCacheComponent entityCacheComponent = ApplicationContextProvider.getApplicationContext().getBean(EntityCacheComponent.class);
|
||||
|
||||
final List<MtbAart> cachedMtbAarts = entityCacheComponent.getCachedEntitiesList(customerDB, MtbAart.ENTITY, x -> x.getCodMart().equals(codMart));
|
||||
final List<MtbAart> cachedMtbAarts = entityCacheComponent.getCachedEntitiesList(customerDB, MtbAart.ENTITY, x -> x.getCodMart().equalsIgnoreCase(codMart));
|
||||
|
||||
if (cachedMtbAarts == null || cachedMtbAarts.isEmpty())
|
||||
return null;
|
||||
|
||||
@@ -435,12 +435,12 @@ public class DocumentCheckRules {
|
||||
}
|
||||
|
||||
if (returnVal && entity.getOperation() == OperationType.INSERT) {
|
||||
throw new Exception("DOCUMENTO INTESTATO A " + entity.getCodAnag() + " - " + entity.getCodDtip() + " N. " + entity.getNumDoc().toString() + "/" + entity.getSerDoc() + " DEL " + new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY).format(entity.getDataDoc()) + " GIA' ESISTENTE");
|
||||
throw new Exception(String.format("Documento intestato a %s - %s numero %s/%d già esistente", entity.getCodAnag(), entity.getCodDtip(), entity.getSerDoc(), entity.getNumDoc()));
|
||||
} else {
|
||||
if (checkDocInSequenza(conn, entity) == false && "AUTOMATICA".equalsIgnoreCase(tipoNumeraz) &&
|
||||
entity.getOperation() != OperationType.UPDATE) {
|
||||
String valueDataDoc = new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY).format(dataDoc);
|
||||
throw new Exception("(DOC. " + codDtip + " N° " + numDoc + "/" + serDoc + " DEL " + valueDataDoc + " INTESTATO A " + codAnag + " FUORI SEQUENZA)");
|
||||
throw new Exception("(Doc. " + codDtip + " N° " + numDoc + "/" + serDoc + " del " + valueDataDoc + " intestato a " + codAnag + " fuori sequenza)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -109,6 +109,20 @@ public class BasicConnectionPool {
|
||||
}
|
||||
}
|
||||
|
||||
public javax.sql.DataSource getDataSource(String profileName) {
|
||||
AvailableConnectionModel model = settingsModel.findConnectionModel(profileName);
|
||||
if (model == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
registerDataSourceIfNotExists(model);
|
||||
return registeredDatasources.get(model);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error retrieving DataSource for profile: " + profileName, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void registerDataSourceIfNotExists(AvailableConnectionModel connectionModel) throws Exception {
|
||||
if (!registeredDatasources.containsKey(connectionModel)) {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package it.integry.ems.utility.entity;
|
||||
|
||||
import it.integry.ems._context.ApplicationContextProvider;
|
||||
import it.integry.ems.dynamic_cache.EntityCacheComponent;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems_model.entity.MtbAartBarCode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MtbAartBarcodeUtils {
|
||||
|
||||
|
||||
public static final List<MtbAartBarCode> getAlternativeMtbAartBarCodes(List<String> codMarts, Connection conn) {
|
||||
codMarts = codMarts.stream()
|
||||
.distinct().collect(Collectors.toList());
|
||||
|
||||
final EntityCacheComponent entityCacheComponent = ApplicationContextProvider.getApplicationContext().getBean(EntityCacheComponent.class);
|
||||
|
||||
List<String> finalCodMarts = codMarts;
|
||||
List<MtbAartBarCode> barCodeList = entityCacheComponent.getCachedEntitiesList(
|
||||
conn.getIntegryCustomerDB(),
|
||||
MtbAartBarCode.ENTITY,
|
||||
x -> finalCodMarts.stream().anyMatch(y -> y.equalsIgnoreCase(x.getCodMart())));
|
||||
|
||||
return barCodeList != null ? barCodeList : new ArrayList<>();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package it.integry.ems.utility.entity;
|
||||
|
||||
import com.annimon.stream.Optional;
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.ems._context.ApplicationContextProvider;
|
||||
import it.integry.ems.dynamic_cache.EntityCacheComponent;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems_model.entity.MtbAart;
|
||||
import it.integry.ems_model.entity.MtbAartBarCode;
|
||||
import it.integry.ems_model.entity.MtbUntMis;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MtbAartUtils {
|
||||
|
||||
public static MtbAart getArticoloByCodMart(String codMart, Connection connection) throws Exception {
|
||||
if (UtilityString.isNullOrEmpty(codMart))
|
||||
return null;
|
||||
|
||||
List<MtbAart> mtbAarts = getArticoliByCodMarts(new ArrayList<>(Collections.singleton(codMart)), connection);
|
||||
if (mtbAarts == null || mtbAarts.isEmpty())
|
||||
return null;
|
||||
|
||||
return mtbAarts.get(0);
|
||||
}
|
||||
|
||||
public static List<MtbAart> getArticoliByCodMarts(List<String> codMarts, Connection connection) throws Exception {
|
||||
if (codMarts == null || codMarts.isEmpty()) return null;
|
||||
|
||||
codMarts.replaceAll(String::toUpperCase);
|
||||
|
||||
final EntityCacheComponent entityCacheComponent = ApplicationContextProvider.getApplicationContext().getBean(EntityCacheComponent.class);
|
||||
|
||||
List<MtbAart> listMtbAart = entityCacheComponent.getCachedEntitiesList(
|
||||
connection.getIntegryCustomerDB(), MtbAart.ENTITY, x -> codMarts.contains(x.getCodMart().toUpperCase()));
|
||||
|
||||
List<MtbAartBarCode> barCodeFromCod = MtbAartBarcodeUtils.getAlternativeMtbAartBarCodes(codMarts, connection);
|
||||
|
||||
if (listMtbAart != null && !listMtbAart.isEmpty()) {
|
||||
List<String> untMisStrings = listMtbAart.stream()
|
||||
.map(MtbAart::getUntMis)
|
||||
.collect(Collectors.toList());
|
||||
List<MtbUntMis> listUntMis = MtbUntMisUtils.getFromCods(untMisStrings, connection);
|
||||
|
||||
for (final MtbAart mtbAart : listMtbAart) {
|
||||
Optional<MtbUntMis> mtbUntMis = Stream.of(listUntMis)
|
||||
.filter(mtbUntMis1 -> mtbUntMis1.getUntMis().equalsIgnoreCase(mtbAart.getUntMis()))
|
||||
.findFirst();
|
||||
|
||||
List<MtbAartBarCode> barcodeList = Stream.of(barCodeFromCod)
|
||||
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbAart.getCodMart()))
|
||||
.toList();
|
||||
|
||||
if (!barcodeList.isEmpty()) {
|
||||
mtbAart.getMtbAartBarCode().addAll(barcodeList);
|
||||
}
|
||||
|
||||
if (mtbUntMis.isPresent()) {
|
||||
mtbAart.setMtbUntMis(new ArrayList<>());
|
||||
mtbAart.getMtbUntMis().add(mtbUntMis.get());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return listMtbAart;
|
||||
}
|
||||
|
||||
public static final HashMap<String, MtbAart> getArticoliByCodMartsAsMap(List<String> codMarts, Connection connection) throws Exception {
|
||||
List<MtbAart> mtbAarts = getArticoliByCodMarts(codMarts, connection);
|
||||
if (mtbAarts == null || mtbAarts.isEmpty()) return new HashMap<>();
|
||||
|
||||
return mtbAarts.stream()
|
||||
.collect(Collectors.toMap(MtbAart::getCodMart, a -> a, (a, b) -> a, HashMap::new));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package it.integry.ems.utility.entity;
|
||||
|
||||
import it.integry.ems._context.ApplicationContextProvider;
|
||||
import it.integry.ems.dynamic_cache.EntityCacheComponent;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems_model.entity.MtbDepoPosizioni;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MtbDepoPosizioniUtils {
|
||||
|
||||
|
||||
public static final List<MtbDepoPosizioni> getAllMonoUlPositions(IntegryCustomerDB customerDB) {
|
||||
final EntityCacheComponent entityCacheComponent = ApplicationContextProvider.getApplicationContext().getBean(EntityCacheComponent.class);
|
||||
|
||||
return entityCacheComponent.<MtbDepoPosizioni>getCachedEntitiesList(customerDB, MtbDepoPosizioni.ENTITY,
|
||||
x -> x.isFlagMonoCollo());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package it.integry.ems.utility.entity;
|
||||
|
||||
import it.integry.ems._context.ApplicationContextProvider;
|
||||
import it.integry.ems.dynamic_cache.EntityCacheComponent;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems_model.entity.MtbAart;
|
||||
import it.integry.ems_model.entity.MtbUntMis;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MtbUntMisUtils {
|
||||
|
||||
public static final MtbUntMis getMtbUntMisFromCodMart(IntegryCustomerDB customerDB, String codMart) throws SQLException {
|
||||
final EntityCacheComponent entityCacheComponent = ApplicationContextProvider.getApplicationContext().getBean(EntityCacheComponent.class);
|
||||
|
||||
MtbAart mtbAart = entityCacheComponent.<MtbAart>getCachedEntitiesStream(customerDB, MtbAart.ENTITY,
|
||||
x -> x.getCodMart().equalsIgnoreCase(codMart))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (mtbAart != null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
final MtbUntMis mtbUntMis = entityCacheComponent.<MtbUntMis>getCachedEntitiesStream(customerDB, MtbUntMis.ENTITY,
|
||||
x -> x.getUntMis().equalsIgnoreCase(mtbAart.getUntMis()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
return mtbUntMis;
|
||||
}
|
||||
|
||||
|
||||
public static List<MtbUntMis> getFromCods(List<String> untMisCods, Connection connection) {
|
||||
List<String> untMisStrings = untMisCods.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
final EntityCacheComponent entityCacheComponent = ApplicationContextProvider.getApplicationContext().getBean(EntityCacheComponent.class);
|
||||
|
||||
List<MtbUntMis> mtbUntMis = entityCacheComponent.getCachedEntitiesList(
|
||||
connection.getIntegryCustomerDB(),
|
||||
MtbUntMis.ENTITY,
|
||||
x -> untMisCods.contains(x.getUntMis()));
|
||||
|
||||
return mtbUntMis != null ? mtbUntMis : new ArrayList<>();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -116,6 +116,7 @@ public class EmsRestConstants {
|
||||
public static final String PATH_USERS = PATH + "getUser";
|
||||
public static final String PATH_EXPORT_ORDINI_ACQ = PATH + "exportOrdiniAcquisto";
|
||||
public static final String PATH_PROCESS_REPORT = PATH + "processReport";
|
||||
public static final String PATH_DOWNLOAD_REPORT_LIST = PATH + "downloadReportList";
|
||||
public static final String PATH_DOWNLOAD_REPORT = PATH + "downloadReport";
|
||||
public static final String PATH_PROCESS_REPORT_TYPE = PATH + "processReportType";
|
||||
public static final String PATH_PRINT_REPORT_TYPE = PATH + "printReportType";
|
||||
|
||||
@@ -13,12 +13,15 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
|
||||
import javax.persistence.Transient;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@javax.persistence.Entity
|
||||
@javax.persistence.Table(name = MtbAart.ENTITY)
|
||||
@Master
|
||||
@PropertyReactive
|
||||
@Table(MtbAart.ENTITY)
|
||||
@@ -31,341 +34,457 @@ public class MtbAart extends EntityBase implements EquatableEntityInterface<MtbA
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@javax.persistence.Id
|
||||
@javax.persistence.Column(name = "cod_mart")
|
||||
@PK
|
||||
@SqlField(value = "cod_mart", maxLength = 15, nullable = false)
|
||||
private String codMart;
|
||||
|
||||
@javax.persistence.Column(name = "descrizione")
|
||||
@SqlField(value = "descrizione", maxLength = 40, nullable = false)
|
||||
private String descrizione;
|
||||
|
||||
@javax.persistence.Column(name = "unt_mis")
|
||||
@FK(tableName = "mtb_unt_mis", columnName = "unt_mis")
|
||||
@SqlField(value = "unt_mis", maxLength = 3, nullable = false)
|
||||
private String untMis;
|
||||
|
||||
@javax.persistence.Column(name = "bar_code")
|
||||
@SqlField(value = "bar_code", maxLength = 40)
|
||||
private String barCode;
|
||||
|
||||
@javax.persistence.Column(name = "peso_kg")
|
||||
@SqlField(value = "peso_kg", nullable = false, defaultObjectValue = "0")
|
||||
private BigDecimal pesoKg;
|
||||
|
||||
@javax.persistence.Column(name = "qta_cnf")
|
||||
@SqlField(value = "qta_cnf", nullable = false, defaultObjectValue = "1")
|
||||
private BigDecimal qtaCnf;
|
||||
|
||||
@javax.persistence.Column(name = "cod_aliq")
|
||||
@SqlField(value = "cod_aliq", maxLength = 5)
|
||||
private String codAliq;
|
||||
|
||||
@javax.persistence.Column(name = "cod_sco_art")
|
||||
@SqlField(value = "cod_sco_art", maxLength = 5)
|
||||
private String codScoArt;
|
||||
|
||||
@javax.persistence.Column(name = "cod_tcol_ui")
|
||||
@SqlField(value = "cod_tcol_ui")
|
||||
private String codTcolUi;
|
||||
|
||||
@javax.persistence.Column(name = "cod_tcol_ul")
|
||||
@SqlField(value = "cod_tcol_ul")
|
||||
private String codTcolUl;
|
||||
|
||||
@javax.persistence.Column(name = "articolo_composto")
|
||||
@SqlField(value = "articolo_composto", maxLength = 1, nullable = false, defaultObjectValue = "N")
|
||||
private String articoloComposto;
|
||||
|
||||
@javax.persistence.Column(name = "esposizione_comp")
|
||||
@SqlField(value = "esposizione_comp", maxLength = 1, nullable = false, defaultObjectValue = "N")
|
||||
private String esposizioneComp;
|
||||
|
||||
@javax.persistence.Column(name = "descrizione_estesa")
|
||||
@SqlField(value = "descrizione_estesa", maxLength = 4096)
|
||||
private String descrizioneEstesa;
|
||||
|
||||
@javax.persistence.Column(name = "cod_ult_forn")
|
||||
@SqlField(value = "cod_ult_forn", maxLength = 5)
|
||||
private String codUltForn;
|
||||
|
||||
@javax.persistence.Column(name = "data_ult_car")
|
||||
@SqlField(value = "data_ult_car")
|
||||
private Date dataUltCar;
|
||||
|
||||
@javax.persistence.Column(name = "val_ult_car")
|
||||
@SqlField(value = "val_ult_car")
|
||||
private BigDecimal valUltCar;
|
||||
|
||||
@javax.persistence.Column(name = "cod_ult_clie")
|
||||
@SqlField(value = "cod_ult_clie", maxLength = 5)
|
||||
private String codUltClie;
|
||||
|
||||
@javax.persistence.Column(name = "data_ult_scar")
|
||||
@SqlField(value = "data_ult_scar")
|
||||
private Date dataUltScar;
|
||||
|
||||
@javax.persistence.Column(name = "val_ult_scar")
|
||||
@SqlField(value = "val_ult_scar")
|
||||
private BigDecimal valUltScar;
|
||||
|
||||
@javax.persistence.Column(name = "tipo_codice")
|
||||
@SqlField(value = "tipo_codice", maxLength = 10)
|
||||
private String tipoCodice;
|
||||
|
||||
@javax.persistence.Column(name = "note")
|
||||
@SqlField(value = "note", maxLength = 255)
|
||||
private String note;
|
||||
|
||||
@javax.persistence.Column(name = "posizione")
|
||||
@SqlField(value = "posizione", maxLength = 15)
|
||||
private String posizione;
|
||||
|
||||
@javax.persistence.Column(name = "colli_pedana")
|
||||
@SqlField(value = "colli_pedana", defaultObjectValue = "1")
|
||||
private BigDecimal colliPedana;
|
||||
|
||||
@SqlField(value = "unt_mis2", maxLength = 5)
|
||||
@javax.persistence.Column(name = "unt_mis2")
|
||||
@FK(tableName = "mtb_unt_mis", columnName = "unt_mis")
|
||||
@SqlField(value = "unt_mis2", maxLength = 3)
|
||||
private String untMis2;
|
||||
|
||||
@javax.persistence.Column(name = "rap_conv2")
|
||||
@SqlField(value = "rap_conv2", defaultObjectValue = "1")
|
||||
private BigDecimal rapConv2;
|
||||
|
||||
@javax.persistence.Column(name = "flag_incl_listino")
|
||||
@SqlField(value = "flag_incl_listino", maxLength = 1, nullable = false, defaultObjectValue = "S")
|
||||
private String flagInclListino;
|
||||
|
||||
@javax.persistence.Column(name = "unt_mis3")
|
||||
@FK(tableName = "mtb_unt_mis", columnName = "unt_mis")
|
||||
@SqlField(value = "unt_mis3", maxLength = 3)
|
||||
private String untMis3;
|
||||
|
||||
@javax.persistence.Column(name = "rap_conv3")
|
||||
@SqlField(value = "rap_conv3", defaultObjectValue = "1")
|
||||
private BigDecimal rapConv3;
|
||||
|
||||
@javax.persistence.Column(name = "cod_mart_stat")
|
||||
@SqlField(value = "cod_mart_stat", maxLength = 15)
|
||||
private String codMartStat;
|
||||
|
||||
@javax.persistence.Column(name = "cod_mcon")
|
||||
@SqlField(value = "cod_mcon", maxLength = 5)
|
||||
private String codMcon;
|
||||
|
||||
@javax.persistence.Column(name = "cod_mgrp")
|
||||
@SqlField(value = "cod_mgrp", maxLength = 5, nullable = false)
|
||||
private String codMgrp;
|
||||
|
||||
@javax.persistence.Column(name = "cod_msfa")
|
||||
@SqlField(value = "cod_msfa", maxLength = 6)
|
||||
private String codMsfa;
|
||||
|
||||
@javax.persistence.Column(name = "cod_msgr")
|
||||
@SqlField(value = "cod_msgr", maxLength = 5, nullable = false)
|
||||
private String codMsgr;
|
||||
|
||||
@javax.persistence.Column(name = "cod_mstp")
|
||||
@SqlField(value = "cod_mstp", maxLength = 5)
|
||||
private String codMstp;
|
||||
|
||||
@javax.persistence.Column(name = "cod_mtip")
|
||||
@SqlField(value = "cod_mtip", maxLength = 5)
|
||||
private String codMtip;
|
||||
|
||||
@javax.persistence.Column(name = "descrizione_stat")
|
||||
@SqlField(value = "descrizione_stat", maxLength = 40)
|
||||
private String descrizioneStat;
|
||||
|
||||
@javax.persistence.Column(name = "flag_stato")
|
||||
@SqlField(value = "flag_stato", maxLength = 1, nullable = false, defaultObjectValue = "A")
|
||||
private String flagStato;
|
||||
|
||||
@javax.persistence.Column(name = "cambio_divi_car")
|
||||
@SqlField(value = "cambio_divi_car", nullable = false)
|
||||
private BigDecimal cambioDiviCar;
|
||||
|
||||
@javax.persistence.Column(name = "cambio_divi_scar")
|
||||
@SqlField(value = "cambio_divi_scar", nullable = false)
|
||||
private BigDecimal cambioDiviScar;
|
||||
|
||||
@javax.persistence.Column(name = "gg_scad_partita")
|
||||
@SqlField(value = "gg_scad_partita", nullable = false, defaultObjectValue = "0")
|
||||
private Integer ggScadPartita;
|
||||
|
||||
@javax.persistence.Column(name = "volume_mc")
|
||||
@SqlField(value = "volume_mc", defaultObjectValue = "0")
|
||||
private BigDecimal volumeMc;
|
||||
|
||||
@javax.persistence.Column(name = "flag_esponi_prz")
|
||||
@SqlField(value = "flag_esponi_prz", maxLength = 1, nullable = false, defaultObjectValue = "N")
|
||||
private String flagEsponiPrz;
|
||||
|
||||
@javax.persistence.Column(name = "data_ult_var")
|
||||
@SqlField(value = "data_ult_var", format = CommonConstants.SYSDATE)
|
||||
private Date dataUltVar;
|
||||
|
||||
@javax.persistence.Column(name = "perc_sfrido")
|
||||
@SqlField(value = "perc_sfrido", nullable = false, defaultObjectValue = "0")
|
||||
private BigDecimal percSfrido;
|
||||
|
||||
@javax.persistence.Column(name = "cod_barre_imb")
|
||||
@SqlField(value = "cod_barre_imb", maxLength = 40)
|
||||
private String codBarreImb;
|
||||
|
||||
@javax.persistence.Column(name = "flag_calc_prz")
|
||||
@SqlField(value = "flag_calc_prz", maxLength = 1, nullable = false, defaultObjectValue = "K")
|
||||
private String flagCalcPrz;
|
||||
|
||||
@javax.persistence.Column(name = "esposizione_comp_acq")
|
||||
@SqlField(value = "esposizione_comp_acq", maxLength = 1, nullable = false, defaultObjectValue = "N")
|
||||
private String esposizioneCompAcq;
|
||||
|
||||
@javax.persistence.Column(name = "flag_calc_prz_acq")
|
||||
@SqlField(value = "flag_calc_prz_acq", maxLength = 1, nullable = false, defaultObjectValue = "K")
|
||||
private String flagCalcPrzAcq;
|
||||
|
||||
@javax.persistence.Column(name = "diacod")
|
||||
@SqlField(value = "diacod", maxLength = 40)
|
||||
private String diacod;
|
||||
|
||||
@javax.persistence.Column(name = "plu")
|
||||
@SqlField(value = "plu", maxLength = 6)
|
||||
private String plu;
|
||||
|
||||
@javax.persistence.Column(name = "part_iva_prod")
|
||||
@SqlField(value = "part_iva_prod", maxLength = 20)
|
||||
private String partIvaProd;
|
||||
|
||||
@javax.persistence.Column(name = "rag_soc_prod")
|
||||
@SqlField(value = "rag_soc_prod", maxLength = 40)
|
||||
private String ragSocProd;
|
||||
|
||||
@javax.persistence.Column(name = "flag_rap_conv_variabile")
|
||||
@SqlField(value = "flag_rap_conv_variabile", maxLength = 1, nullable = false, defaultObjectValue = "N")
|
||||
private String flagRapConvVariabile;
|
||||
|
||||
@javax.persistence.Column(name = "flag_mov_art_mag")
|
||||
@SqlField(value = "flag_mov_art_mag", maxLength = 1, nullable = false, defaultObjectValue = "S")
|
||||
private String flagMovArtMag;
|
||||
|
||||
@javax.persistence.Column(name = "flag_tracciabilita")
|
||||
@SqlField(value = "flag_tracciabilita", maxLength = 1, nullable = false, defaultObjectValue = "N")
|
||||
private String flagTracciabilita;
|
||||
|
||||
@javax.persistence.Column(name = "tara_kg")
|
||||
@SqlField(value = "tara_kg", defaultObjectValue = "0")
|
||||
private BigDecimal taraKg;
|
||||
|
||||
@javax.persistence.Column(name = "colli_strato")
|
||||
@SqlField(value = "colli_strato", nullable = false, defaultObjectValue = "1")
|
||||
private BigDecimal colliStrato;
|
||||
|
||||
@javax.persistence.Column(name = "flag_qta_cnf_fissa")
|
||||
@SqlField(value = "flag_qta_cnf_fissa", maxLength = 1, nullable = false, defaultObjectValue = "S")
|
||||
private String flagQtaCnfFissa;
|
||||
|
||||
@javax.persistence.Column(name = "flag_colli_pedana_fisso")
|
||||
@SqlField(value = "flag_colli_pedana_fisso", maxLength = 1, nullable = false, defaultObjectValue = "S")
|
||||
private String flagColliPedanaFisso;
|
||||
|
||||
@javax.persistence.Column(name = "cod_ccon_costi")
|
||||
@SqlField(value = "cod_ccon_costi", maxLength = 6)
|
||||
private String codCconCosti;
|
||||
|
||||
@javax.persistence.Column(name = "cod_ccon_ricavi")
|
||||
@SqlField(value = "cod_ccon_ricavi", maxLength = 6)
|
||||
private String codCconRicavi;
|
||||
|
||||
@javax.persistence.Column(name = "cod_dgrp_art")
|
||||
@SqlField(value = "cod_dgrp_art", maxLength = 5)
|
||||
private String codDgrpArt;
|
||||
|
||||
@javax.persistence.Column(name = "cod_divi_car")
|
||||
@SqlField(value = "cod_divi_car", maxLength = 5, nullable = false)
|
||||
private String codDiviCar;
|
||||
|
||||
@javax.persistence.Column(name = "cod_divi_scar")
|
||||
@SqlField(value = "cod_divi_scar", maxLength = 5, nullable = false)
|
||||
private String codDiviScar;
|
||||
|
||||
@javax.persistence.Column(name = "cod_ecr_cat")
|
||||
@SqlField(value = "cod_ecr_cat", maxLength = 10)
|
||||
private String codEcrCat;
|
||||
|
||||
@javax.persistence.Column(name = "cod_ecr_mcat")
|
||||
@SqlField(value = "cod_ecr_mcat", maxLength = 10)
|
||||
private String codEcrMcat;
|
||||
|
||||
@javax.persistence.Column(name = "cod_ecr_rep")
|
||||
@SqlField(value = "cod_ecr_rep", maxLength = 10)
|
||||
private String codEcrRep;
|
||||
|
||||
@javax.persistence.Column(name = "cod_ecr_stipo")
|
||||
@SqlField(value = "cod_ecr_stipo", maxLength = 10)
|
||||
private String codEcrStipo;
|
||||
|
||||
@javax.persistence.Column(name = "cod_ecr_tipo")
|
||||
@SqlField(value = "cod_ecr_tipo", maxLength = 10)
|
||||
private String codEcrTipo;
|
||||
|
||||
@javax.persistence.Column(name = "cod_grp_bolla")
|
||||
@SqlField(value = "cod_grp_bolla", maxLength = 5)
|
||||
private String codGrpBolla;
|
||||
|
||||
@SqlField(value = "ingredienti", maxLength = 1024)
|
||||
@javax.persistence.Column(name = "ingredienti")
|
||||
@SqlField(value = "ingredienti", maxLength = 8000)
|
||||
private String ingredienti;
|
||||
|
||||
@javax.persistence.Column(name = "id_art_equi")
|
||||
@SqlField(value = "id_art_equi", maxLength = 25)
|
||||
private String idArtEqui;
|
||||
|
||||
@javax.persistence.Column(name = "descr_cassa")
|
||||
@SqlField(value = "descr_cassa", maxLength = 40)
|
||||
private String descrCassa;
|
||||
|
||||
@javax.persistence.Column(name = "cod_nc_intracee")
|
||||
@SqlField(value = "cod_nc_intracee", maxLength = 20)
|
||||
private String codNcIntracee;
|
||||
|
||||
@javax.persistence.Column(name = "marchio")
|
||||
@SqlField(value = "marchio", maxLength = 255)
|
||||
private String marchio;
|
||||
|
||||
@javax.persistence.Column(name = "sezione")
|
||||
@SqlField(value = "sezione")
|
||||
private Integer sezione;
|
||||
|
||||
@javax.persistence.Column(name = "tipo_reg")
|
||||
@SqlField(value = "tipo_reg", maxLength = 1)
|
||||
private String tipoReg;
|
||||
|
||||
@javax.persistence.Column(name = "tipo_stock")
|
||||
@SqlField(value = "tipo_stock", maxLength = 1)
|
||||
private String tipoStock;
|
||||
|
||||
@javax.persistence.Column(name = "qta_multipla_ord")
|
||||
@SqlField(value = "qta_multipla_ord")
|
||||
private BigDecimal qtaMultiplaOrd;
|
||||
|
||||
@MapToTable(value = "flag_kit")
|
||||
@Transient
|
||||
private String flagKit;
|
||||
|
||||
@javax.persistence.Column(name = "cod_forn_cv")
|
||||
@SqlField(value = "cod_forn_cv", maxLength = 5)
|
||||
private String codFornCv;
|
||||
|
||||
@javax.persistence.Column(name = "cpa")
|
||||
@SqlField(value = "cpa", maxLength = 5)
|
||||
private String cpa;
|
||||
|
||||
@javax.persistence.Column(name = "taric")
|
||||
@SqlField(value = "taric", maxLength = 5)
|
||||
private String taric;
|
||||
|
||||
@javax.persistence.Column(name = "sezione_dogana")
|
||||
@SqlField(value = "sezione_dogana", maxLength = 6)
|
||||
private String sezioneDogana;
|
||||
|
||||
@javax.persistence.Column(name = "flag_peso_egalizzato")
|
||||
@SqlField(value = "flag_peso_egalizzato", nullable = false, defaultObjectValue = "0")
|
||||
private Boolean flagPesoEgalizzato;
|
||||
|
||||
@javax.persistence.Column(name = "cod_jfas_costi")
|
||||
@SqlField(value = "cod_jfas_costi", maxLength = 5)
|
||||
private String codJfasCosti;
|
||||
|
||||
@javax.persistence.Column(name = "cod_jfas_ricavi")
|
||||
@SqlField(value = "cod_jfas_ricavi", maxLength = 5)
|
||||
private String codJfasRicavi;
|
||||
|
||||
@Transient
|
||||
private String mtbAartEqui_descrizione;
|
||||
|
||||
@javax.persistence.Column(name = "flag_arr_prz_vend_iva")
|
||||
@SqlField(value = "flag_arr_prz_vend_iva", nullable = false, defaultObjectValue = "1")
|
||||
private Boolean flagArrPrzVendIva;
|
||||
|
||||
@javax.persistence.Column(name = "classificazione_abc")
|
||||
@SqlField(value = "classificazione_abc", maxLength = 1)
|
||||
private String classificazioneAbc;
|
||||
|
||||
@javax.persistence.Column(name = "tipo_codice_imballo")
|
||||
@SqlField(value = "tipo_codice_imballo", maxLength = 10)
|
||||
private String tipoCodiceImballo;
|
||||
|
||||
@javax.persistence.Column(name = "flag_stampa_docu_vend")
|
||||
@SqlField(value = "flag_stampa_docu_vend", nullable = false, defaultObjectValue = "1")
|
||||
private Boolean flagStampaDocuVend;
|
||||
|
||||
@javax.persistence.Column(name = "flag_reso_tec")
|
||||
@SqlField(value = "flag_reso_tec", nullable = false, defaultObjectValue = "0")
|
||||
private Boolean flagResoTec;
|
||||
|
||||
@javax.persistence.Column(name = "cod_mssfa")
|
||||
@SqlField(value = "cod_mssfa", maxLength = 6)
|
||||
private String codMssfa;
|
||||
|
||||
@javax.persistence.Column(name = "cod_linea")
|
||||
@SqlField(value = "cod_linea", maxLength = 6)
|
||||
private String codLinea;
|
||||
|
||||
@javax.persistence.Column(name = "cod_slinea")
|
||||
@SqlField(value = "cod_slinea", maxLength = 6)
|
||||
private String codSlinea;
|
||||
|
||||
@javax.persistence.Column(name = "cod_sslinea")
|
||||
@SqlField(value = "cod_sslinea", maxLength = 6)
|
||||
private String codSslinea;
|
||||
|
||||
@Priority(1)
|
||||
@Transient
|
||||
private MtbAartMarchio mtbAartMarchio;
|
||||
|
||||
@Priority(1)
|
||||
@Transient
|
||||
private MtbAartEqui mtbAartEqui;
|
||||
|
||||
@Priority(1)
|
||||
@Transient
|
||||
private List<MtbUntMis> mtbUntMis;
|
||||
|
||||
@EntityChild
|
||||
@Transient
|
||||
private List<MtbAartBarCode> mtbAartBarCode = new ArrayList<>();
|
||||
|
||||
/*@EntityChild
|
||||
private List<MtbPart> mtbPart;*/
|
||||
@EntityChild
|
||||
@Transient
|
||||
private List<MtbAartCarat> mtbAartCarat = new ArrayList<>();
|
||||
|
||||
@EntityChild
|
||||
@Transient
|
||||
private List<MtbAartAnag> mtbAartAnag = new ArrayList<>();
|
||||
|
||||
@EntityChild
|
||||
@Transient
|
||||
private List<MtbSpes> mtbSpes = new ArrayList<>();
|
||||
|
||||
@EntityChild
|
||||
@Transient
|
||||
private List<MtbComp> mtbComp = new ArrayList<>();
|
||||
|
||||
@EntityChild
|
||||
@Transient
|
||||
private List<MtbAartDesc> mtbAartDesc = new ArrayList<>();
|
||||
|
||||
@EntityChild
|
||||
@Transient
|
||||
private List<MtbAartLink> mtbAartLink = new ArrayList<>();
|
||||
|
||||
@EntityChild
|
||||
@Transient
|
||||
private List<MtbPartitaMag> mtbPartitaMag = new ArrayList<>();
|
||||
|
||||
@EntityChild
|
||||
@Transient
|
||||
private List<MrlAartSchTecSet> mrlAartSchTecSet = new ArrayList<>();
|
||||
|
||||
@EntityChild
|
||||
@Transient
|
||||
private List<MtbAartColori> mtbAartColori = new ArrayList<>();
|
||||
|
||||
@Priority(101)
|
||||
@Transient
|
||||
List<JtbCicl> jtbCicl;
|
||||
|
||||
@Transient
|
||||
private List<MtbLisa> mtbLisa;
|
||||
|
||||
public MtbAart() {
|
||||
@@ -1258,8 +1377,9 @@ public class MtbAart extends EntityBase implements EquatableEntityInterface<MtbA
|
||||
return mtbAartCarat;
|
||||
}
|
||||
|
||||
public void setMtbAartCarat(List<MtbAartCarat> mtbAartCarat) {
|
||||
public MtbAart setMtbAartCarat(List<MtbAartCarat> mtbAartCarat) {
|
||||
this.mtbAartCarat = mtbAartCarat;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<MtbAartLink> getMtbAartLink() {
|
||||
|
||||
@@ -63,6 +63,9 @@ public class MtbAartAnag extends EntityBase {
|
||||
@SqlField(value = "note", maxLength = 255)
|
||||
private String note;
|
||||
|
||||
@SqlField(value = "cod_vdes", maxLength = 5)
|
||||
private String codVdes;
|
||||
|
||||
public MtbAartAnag() {
|
||||
super(logger);
|
||||
}
|
||||
@@ -174,4 +177,13 @@ public class MtbAartAnag extends EntityBase {
|
||||
this.note = note;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodVdes() {
|
||||
return codVdes;
|
||||
}
|
||||
|
||||
public MtbAartAnag setCodVdes(String codVdes) {
|
||||
this.codVdes = codVdes;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,14 +5,17 @@ import it.integry.ems_model.annotation.PK;
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
import it.integry.ems_model.annotation.Table;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.base.EquatableEntityInterface;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@PropertyReactive
|
||||
@Table(MtbAartDesc.ENTITY)
|
||||
@JsonTypeName(MtbAartDesc.ENTITY)
|
||||
public class MtbAartDesc extends EntityBase {
|
||||
public class MtbAartDesc extends EntityBase implements EquatableEntityInterface<MtbAartDesc> {
|
||||
|
||||
private final static Logger logger = LogManager.getLogger();
|
||||
|
||||
@@ -34,6 +37,9 @@ public class MtbAartDesc extends EntityBase {
|
||||
@SqlField(value = "descrizione", maxLength = 40, nullable = false)
|
||||
private String descrizione;
|
||||
|
||||
@SqlField(value = "descrizione_html")
|
||||
private String descrizioneHtml;
|
||||
|
||||
public MtbAartDesc() {
|
||||
super(logger);
|
||||
}
|
||||
@@ -69,4 +75,40 @@ public class MtbAartDesc extends EntityBase {
|
||||
public void setDescrizione(String descrizione) {
|
||||
this.descrizione = descrizione;
|
||||
}
|
||||
|
||||
public String getDescrizioneHtml() {
|
||||
return descrizioneHtml;
|
||||
}
|
||||
|
||||
public MtbAartDesc setDescrizioneHtml(String descrizioneHtml) {
|
||||
this.descrizioneHtml = descrizioneHtml;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof MtbAartDesc)) return false;
|
||||
MtbAartDesc that = (MtbAartDesc) o;
|
||||
return Objects.equals(getCodMart(), that.getCodMart()) && Objects.equals(getCodLingua(), that.getCodLingua()) && Objects.equals(getDescrizioneEstesa(), that.getDescrizioneEstesa()) && Objects.equals(getDescrizione(), that.getDescrizione()) && Objects.equals(getDescrizioneHtml(), that.getDescrizioneHtml());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(getCodMart(), getCodLingua(), getDescrizioneEstesa(), getDescrizione(), getDescrizioneHtml());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCodeKey() {
|
||||
return Objects.hash(getCodMart(), getCodLingua());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsKey(MtbAartDesc other) {
|
||||
if (this == other) return true;
|
||||
if (!(other instanceof MtbAartDesc)) return false;
|
||||
MtbAartDesc mtbAartDesc = other;
|
||||
return Objects.equals(getCodLingua(), mtbAartDesc.getCodLingua()) &&
|
||||
Objects.equals(getCodMart(), mtbAartDesc.getCodMart());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,9 @@ public class MtbAartEqui extends EntityBase implements EquatableEntityInterface<
|
||||
@SqlField(value = "descrizione_estera", maxLength = 255, nullable = false)
|
||||
private String descrizioneEstera;
|
||||
|
||||
@SqlField(value = "flag_equi_anag", maxLength = 1, nullable = false, defaultObjectValue = "0")
|
||||
private Boolean flagEquiAnag;
|
||||
|
||||
public MtbAartEqui() {
|
||||
super(logger);
|
||||
}
|
||||
@@ -89,16 +92,26 @@ public class MtbAartEqui extends EntityBase implements EquatableEntityInterface<
|
||||
this.descrizioneEstera = descrizioneEstera;
|
||||
}
|
||||
|
||||
public Boolean getFlagEquiAnag() {
|
||||
return flagEquiAnag;
|
||||
}
|
||||
|
||||
public MtbAartEqui setFlagEquiAnag(Boolean flagEquiAnag) {
|
||||
this.flagEquiAnag = flagEquiAnag;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof MtbAartEqui)) return false;
|
||||
MtbAartEqui that = (MtbAartEqui) o;
|
||||
return Objects.equals(getIdArtEqui(), that.getIdArtEqui()) && Objects.equals(getDescrizione(), that.getDescrizione()) && Objects.equals(getFlagEquiPrezzo(), that.getFlagEquiPrezzo()) && Objects.equals(getFlagEquiCosto(), that.getFlagEquiCosto()) && Objects.equals(getDescrizioneEstera(), that.getDescrizioneEstera());
|
||||
return Objects.equals(getIdArtEqui(), that.getIdArtEqui()) && Objects.equals(getDescrizione(), that.getDescrizione()) && Objects.equals(getFlagEquiPrezzo(), that.getFlagEquiPrezzo()) && Objects.equals(getFlagEquiCosto(), that.getFlagEquiCosto()) && Objects.equals(getDescrizioneEstera(), that.getDescrizioneEstera())
|
||||
&& Objects.equals(getFlagEquiAnag(), that.getFlagEquiAnag());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(getIdArtEqui(), getDescrizione(), getFlagEquiPrezzo(), getFlagEquiCosto(), getDescrizioneEstera());
|
||||
return Objects.hash(getIdArtEqui(), getDescrizione(), getFlagEquiPrezzo(), getFlagEquiCosto(), getDescrizioneEstera(),getFlagEquiAnag());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.time.LocalDate
|
||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.IntegryCustomer
|
||||
import it.integry.ems.utility.entity.MtbUntMisUtils
|
||||
|
||||
global Connection conn
|
||||
global String username
|
||||
@@ -225,14 +226,13 @@ when
|
||||
eval(completeRulesEnabled)
|
||||
$entity : MtbColr(artAPeso == null && codMart != null )
|
||||
then
|
||||
String sql =
|
||||
"SELECT CASE WHEN dbo.f_getTipoUntMis(mtb_aart.unt_mis) = 'KG' THEN 'S' ELSE 'N' END " +
|
||||
" FROM mtb_aart WHERE cod_mart = " + UtilityDB.valueToString($entity.getCodMart());
|
||||
MtbUntMis mtbUntMis = MtbUntMisUtils.getMtbUntMisFromCodMart(customerDb, $entity.getCodMart());
|
||||
|
||||
String artAPeso = "N";
|
||||
|
||||
if (mtbUntMis != null)
|
||||
artAPeso = "KG".equalsIgnoreCase(mtbUntMis.getUntMis()) ? "S" : "N";
|
||||
|
||||
String artAPeso = (String) QueryRules.getSingleValue(conn, sql);
|
||||
if (artAPeso == null ) {
|
||||
artAPeso = "N";
|
||||
}
|
||||
modify ( $entity ) { setArtAPeso(artAPeso) }
|
||||
end
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.service.PrinterService;
|
||||
import it.integry.ems.service.ReportProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityPdf;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.entity.GrlAnagJrept;
|
||||
import it.integry.ems_model.entity.JtbDisegniFiles;
|
||||
@@ -88,6 +89,7 @@ public class EmsEngineController {
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_REPORT, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse downloadReport(HttpServletRequest request,
|
||||
@@ -100,6 +102,27 @@ public class EmsEngineController {
|
||||
return ServiceRestResponse.createNegativeResponse("Nessun report generato!");
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_REPORT_LIST, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse downloadReportList(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody JasperDTO[] jasperDTOList)throws Exception {
|
||||
|
||||
FileItem fi = new FileItem();
|
||||
List<byte[]> pdfList = new ArrayList<>();
|
||||
for (JasperDTO jasperDTO : jasperDTOList) {
|
||||
pdfList.add(emsEngineService.processReport(jasperDTO));
|
||||
}
|
||||
byte[] bytes = UtilityPdf.merge(pdfList);
|
||||
|
||||
if (bytes != null && bytes.length > 0) {
|
||||
return ServiceRestResponse.createPositiveResponse(downloadFileHandlerService.generateDownloadItem(new Date().getTime() + ".pdf", bytes));
|
||||
} else {
|
||||
return ServiceRestResponse.createNegativeResponse("Nessun report generato!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_PROCESS_REPORT_TYPE, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse processReportTypeList(HttpServletRequest request,
|
||||
@@ -122,14 +145,9 @@ public class EmsEngineController {
|
||||
public @ResponseBody
|
||||
ServiceRestResponse printReportTypeList(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody ReportTypeDTO reportTypeDTO) {
|
||||
try {
|
||||
printerService.printReportType(reportTypeDTO);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
return ServiceRestResponse.createNegativeResponse(configuration, e);
|
||||
}
|
||||
@RequestBody ReportTypeDTO reportTypeDTO) throws Exception {
|
||||
printerService.printReportType(reportTypeDTO);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_GET_SETUP_REPORT_TYPE, method = RequestMethod.POST)
|
||||
|
||||
@@ -393,6 +393,17 @@ public class SteUPController {
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@PostMapping(value = "analisiRottureDiStock")
|
||||
public @ResponseBody
|
||||
ServiceRestResponse analisiRottureDiStock(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDB,
|
||||
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate dataIspezione,
|
||||
@RequestParam (required = false) String codMdep) throws Exception {
|
||||
|
||||
steUPService.analisiRottureDiStock(dataIspezione, codMdep);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "recuperoIspezioni", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse recuperoIspezioni(HttpServletRequest request,
|
||||
|
||||
@@ -60,6 +60,7 @@ import java.util.stream.Collectors;
|
||||
import static it.integry.ems.order.dto.UserGroupENUM.RILEVATORE;
|
||||
import static it.integry.ems.order.dto.UserGroupENUM.TECNICO;
|
||||
import static java.util.stream.Collectors.groupingBy;
|
||||
import static org.codehaus.groovy.runtime.DefaultGroovyMethods.collect;
|
||||
|
||||
@Service
|
||||
@Scope("request")
|
||||
@@ -514,7 +515,7 @@ public class SteUPService {
|
||||
String tipoAttivitaInevasi = setup.get("TIPO_ATTIVITA_VERIFICA_INEVASI");
|
||||
String reportInevasi = setup.get("REPORT_INEVASI");
|
||||
String activityId = null;
|
||||
if ( !isNewIsepzione ) {
|
||||
if (!isNewIsepzione) {
|
||||
String sql =
|
||||
Query.format(
|
||||
"SELECT activity_id\n" +
|
||||
@@ -534,7 +535,7 @@ public class SteUPService {
|
||||
|
||||
activityId = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
}
|
||||
|
||||
|
||||
StbActivity activityItem =
|
||||
new StbActivity()
|
||||
.setActivityDescription(activityTypeId)
|
||||
@@ -665,9 +666,6 @@ public class SteUPService {
|
||||
String content = new String(contentB64);
|
||||
barcodes = UtilityString.splitStringToMultipleLine(content, CommonConstants.A_CAPO);
|
||||
saveFile = false;
|
||||
} else if (UtilityDebug.isDebugExecution()) {
|
||||
barcodes = UtilityDB.executeSimpleQueryOnlyFirstColumn(multiDBTransactionManager.getPrimaryConnection(),
|
||||
"select cod_mart from stb_activity where parent_activity_id = 'C0000843821'");
|
||||
} else {
|
||||
throw new Exception("File " + fileNameElencoArt + " non trovato.");
|
||||
}
|
||||
@@ -739,36 +737,9 @@ public class SteUPService {
|
||||
|
||||
if (barcodes != null && !barcodes.isEmpty()) {
|
||||
for (String barcode : barcodes) {
|
||||
sql =
|
||||
"SELECT activity_type_id_next " +
|
||||
" FROM srl_activity_type " +
|
||||
" WHERE activity_type_id = " + UtilityDB.valueToString(activityTypeId) + " AND " +
|
||||
"flag_tipologia = 'A' ";
|
||||
|
||||
String activityTypeArt = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
if (UtilityString.isNullOrEmpty(activityTypeArt)) {
|
||||
throw new Exception("Nessun tipo attività associato a " + activityTypeId + " per l'inserimento degli articoli.");
|
||||
}
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
String codMart = this.getCodMartFromBarcode(barcode);
|
||||
StbActivity item = new StbActivity()
|
||||
.setActivityDescription(activityTypeArt)
|
||||
.setNote(parentActivity.getNote())
|
||||
.setCodJfas(codJfas)
|
||||
.setCodMart(codMart)
|
||||
.setFlagTipologia("A")
|
||||
.setUserName(userNamePv)
|
||||
.setUserCreator(parentActivity.getUserCreator())
|
||||
.setUserModifier(parentActivity.getUserCreator())
|
||||
.setActivityTypeId(activityTypeArt)
|
||||
.setOraInsAct(now)
|
||||
.setEffectiveTime(dataCreation)
|
||||
.setParentActivityId(activityId);
|
||||
|
||||
item.setOperation(OperationType.INSERT);
|
||||
stbActivityList.add(item);
|
||||
StbActivity art = getArticoli(barcode, null, activityTypeId, codJfas, userNamePv);
|
||||
if( art != null)
|
||||
stbActivityList.add(art);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -814,6 +785,36 @@ public class SteUPService {
|
||||
return stbActivityList;
|
||||
}
|
||||
|
||||
private StbActivity getArticoli(String barcode, String codMart, String activityTypeId, String codJfas, String userNamePv) throws Exception {
|
||||
String sql;
|
||||
sql =
|
||||
"SELECT activity_type_id_next " +
|
||||
" FROM srl_activity_type " +
|
||||
" WHERE activity_type_id = " + UtilityDB.valueToString(activityTypeId) + " AND " +
|
||||
"flag_tipologia = 'A' ";
|
||||
|
||||
String activityTypeArt = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
if (UtilityString.isNullOrEmpty(activityTypeArt)) {
|
||||
throw new Exception("Nessun tipo attività associato a " + activityTypeId + " per l'inserimento degli articoli.");
|
||||
}
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
if (!UtilityString.isNullOrEmpty(barcode))
|
||||
codMart = this.getCodMartFromBarcode(barcode);
|
||||
StbActivity item = new StbActivity()
|
||||
.setActivityDescription(activityTypeArt)
|
||||
.setCodJfas(codJfas)
|
||||
.setCodMart(codMart)
|
||||
.setFlagTipologia("A")
|
||||
.setUserName(userNamePv)
|
||||
.setActivityTypeId(activityTypeArt)
|
||||
.setOraInsAct(now);
|
||||
|
||||
item.setOperation(OperationType.INSERT);
|
||||
return item;
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getPrezzo(String codMdep, String barcode) throws Exception {
|
||||
String sql =
|
||||
"SELECT p.descrizione, p.prz_vend_iva " +
|
||||
@@ -865,80 +866,61 @@ public class SteUPService {
|
||||
"ORDER BY mtb_aart.descrizione";
|
||||
sql = UtilityDB.addwhereCond(sql, whereCond, false);
|
||||
} else if (activityTypeId.equalsIgnoreCase(tipoAttivitaRotturaStock)) {
|
||||
if (repartiFreschi.contains(codJfas)) {
|
||||
String tipoGriglia = setupGest.getSetupDet(multiDBTransactionManager.getPrimaryConnection(), "PVM", "RILEVAZIONI_STEUP", "TIPO_GRIGLIA", codJfas);
|
||||
|
||||
String queryAssortimento = "";
|
||||
switch (tipoGriglia) {
|
||||
case "A":
|
||||
queryAssortimento = Query.format("SELECT cod_mart,descrizione,bar_code as barcode,cod_msgr\n" +
|
||||
"FROM steup_getAssortimento(%s,%s,%s) art\n",
|
||||
codMdep, codJfas, dataCreation
|
||||
);
|
||||
break;
|
||||
case "V":
|
||||
queryAssortimento =
|
||||
Query.format("SELECT griglia.cod_mart, \n" +
|
||||
"descrizione, \n" +
|
||||
(chkRotturaStock ? "mvw_barcode.cod_barre" : "griglia.bar_code") + " as barcode, \n" +
|
||||
"cod_msgr\n " +
|
||||
" from steup_getGrigliaVendita(%s, %s, %s) griglia " +
|
||||
(chkRotturaStock ? " INNER JOIN mvw_barcode on griglia.cod_mart_kit = mvw_barcode.cod_mart " : ""),
|
||||
codMdep, codJfas, dataCreation);
|
||||
break;
|
||||
}
|
||||
|
||||
if (repartiFreschi.contains(codJfas) || (chkRotturaStock && barcode != null & !barcode.isEmpty())) {
|
||||
sql =
|
||||
"SELECT griglia.cod_mart, \n" +
|
||||
"WITH assortimento AS ( " +
|
||||
queryAssortimento +
|
||||
") " +
|
||||
"SELECT griglia.cod_mart, \n" +
|
||||
"descrizione, \n" +
|
||||
(chkRotturaStock ? "mvw_barcode.cod_barre" : "griglia.bar_code") + " as barcode, \n" +
|
||||
"barcode, \n" +
|
||||
"cod_msgr\n " +
|
||||
" from steup_getGrigliaVendita(" + UtilityDB.valueToString(codMdep) + "," + UtilityDB.valueToString(codJfas) + ", " + UtilityDB.valueToString(dataCreation) + ") griglia " +
|
||||
(chkRotturaStock ? " INNER JOIN mvw_barcode on griglia.cod_mart_kit = mvw_barcode.cod_mart " : "") +
|
||||
" WHERE griglia.cod_mart NOT IN (SELECT cod_mart\n" +
|
||||
" from assortimento " +
|
||||
" WHERE assortimento.cod_mart NOT IN (SELECT cod_mart\n" +
|
||||
" FROM (SELECT cod_mart,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" data_validita,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN tipo_variazione = 'I' AND\n" +
|
||||
" LEAD(tipo_variazione, 1, NULL)\n" +
|
||||
" OVER (PARTITION BY cod_mart, cod_mdep ORDER BY data_validita, tipo_variazione DESC ) =\n" +
|
||||
" 'D' AND\n" +
|
||||
" LEAD(data_validita, 1, NULL)\n" +
|
||||
" OVER (PARTITION BY cod_mart, cod_mdep ORDER BY data_validita, tipo_variazione DESC ) =\n" +
|
||||
" data_validita THEN 'U'\n" +
|
||||
" ELSE tipo_variazione END AS tipo_variazione,\n" +
|
||||
" LEAD(tipo_variazione, 1, NULL)\n" +
|
||||
" OVER (PARTITION BY cod_mart, cod_mdep ORDER BY data_validita, tipo_variazione ) AS tipo_variazione_succ\n" +
|
||||
" FROM carelli.dbo.atb_griglie_art\n" +
|
||||
" WHERE atb_griglie_art.data_validita <= " + UtilityDB.valueToString(dataCreation) + "\n" +
|
||||
" AND atb_griglie_art.cod_mdep = " + UtilityDB.valueToString(codMdep) + ") g\n" +
|
||||
" WHERE g.tipo_variazione_succ IS NULL\n" +
|
||||
" AND DATEDIFF(DAY, data_validita, " + UtilityDB.valueToString(dataCreation) + ") < 7\n" +
|
||||
" tipo_variazione \n" +
|
||||
" FROM carelli.dbo.getGrigliaAssortimento([DATA_CREAZIONE], null,[COD_MDEP], null, null) g\n" +
|
||||
" WHERE DATEDIFF(DAY, data_validita, [DATA_CREAZIONE]) < 7\n" +
|
||||
" AND g.tipo_variazione = 'I'\n" +
|
||||
" UNION \n" +
|
||||
" SELECT cod_mart \n" +
|
||||
" FROM dbo.steup_getInevasi(" + UtilityDB.valueToString(codMdep) + ", " + UtilityDB.valueToString(codJfas) + ", " + UtilityDB.valueToString(dataCreation) + "))\n " +
|
||||
" FROM dbo.steup_getInevasi([COD_MDEP], [COD_JFAS], [DATA_CREAZIONE]))\n " +
|
||||
(chkRotturaStock && barcode != null & !barcode.isEmpty() ?
|
||||
"AND EXISTS(SELECT cod_mart from carelli.dbo.mvw_barcode WHERE cod_barre in (" + UtilityDB.listValueToString(barcode) + ") and art.cod_mart = mvw_barcode.cod_mart)\n" : "") +
|
||||
"order by descrizione";
|
||||
} else if (chkRotturaStock && barcode != null & !barcode.isEmpty()) {
|
||||
sql = "SELECT cod_mart,descrizione,bar_code as barcode,cod_msgr\n" +
|
||||
"FROM steup_getAssortimento(" + UtilityDB.valueToString(codMdep) + "," + UtilityDB.valueToString(codJfas) + ", " + UtilityDB.valueToString(dataCreation) + ") art\n" +
|
||||
"WHERE EXISTS(SELECT cod_mart from carelli.dbo.mvw_barcode WHERE cod_barre in (" + UtilityDB.listValueToString(barcode) + ") and art.cod_mart = mvw_barcode.cod_mart)\n" +
|
||||
" AND cod_mart NOT IN (SELECT cod_mart\n" +
|
||||
" FROM (SELECT cod_mart,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" data_validita,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN tipo_variazione = 'I' AND\n" +
|
||||
" LEAD(tipo_variazione, 1, NULL)\n" +
|
||||
" OVER (PARTITION BY cod_mart, cod_mdep ORDER BY data_validita, tipo_variazione DESC ) =\n" +
|
||||
" 'D' AND\n" +
|
||||
" LEAD(data_validita, 1, NULL)\n" +
|
||||
" OVER (PARTITION BY cod_mart, cod_mdep ORDER BY data_validita, tipo_variazione DESC ) =\n" +
|
||||
" data_validita THEN 'U'\n" +
|
||||
" ELSE tipo_variazione END AS tipo_variazione,\n" +
|
||||
" LEAD(tipo_variazione, 1, NULL)\n" +
|
||||
" OVER (PARTITION BY cod_mart, cod_mdep ORDER BY data_validita, tipo_variazione ) AS tipo_variazione_succ\n" +
|
||||
" FROM carelli.dbo.atb_griglie_art\n" +
|
||||
" WHERE atb_griglie_art.data_validita <= " + UtilityDB.valueToString(dataCreation) + "\n" +
|
||||
" AND atb_griglie_art.cod_mdep = " + UtilityDB.valueToString(codMdep) + ") g\n" +
|
||||
" WHERE g.tipo_variazione_succ IS NULL\n" +
|
||||
" AND DATEDIFF(DAY, data_validita, " + UtilityDB.valueToString(dataCreation) + ") < 7\n" +
|
||||
" AND g.tipo_variazione = 'I'\n" +
|
||||
" UNION \n" +
|
||||
" SELECT cod_mart \n" +
|
||||
" FROM dbo.steup_getInevasi(" + UtilityDB.valueToString(codMdep) + ", " + UtilityDB.valueToString(codJfas) + ", " + UtilityDB.valueToString(dataCreation) + "))";
|
||||
|
||||
sql = sql
|
||||
.replace("[DATA_CREAZIONE]", UtilityDB.valueToString(dataCreation))
|
||||
.replace("[COD_MDEP]", UtilityDB.valueToString(codMdep))
|
||||
.replace("[COD_JFAS]", UtilityDB.valueToString(codJfas));
|
||||
} else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
sql = "SELECT DISTINCT mtb_aart.cod_mart, " +
|
||||
" mtb_aart.descrizione, " +
|
||||
" mtb_aart.bar_code AS barcode," +
|
||||
" mtb_aart.cod_msgr " +
|
||||
"FROM dbo.steup_getAssortimento(" + UtilityDB.valueToString(codMdep) + ", " + UtilityDB.valueToString(codJfas) + " ) mtb_aart" +
|
||||
" WHERE mtb_aart.plu IS NOT NULL " +
|
||||
"ORDER BY mtb_aart.descrizione";
|
||||
*/
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@@ -950,7 +932,6 @@ public class SteUPService {
|
||||
logger.info("Uploading attachment activity ID: " + activityId);
|
||||
String fileName = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".zip";
|
||||
String pathFile = UtilityDirs.getEmsApiTempDirectoryPath() + File.separator + activityId + File.separator;
|
||||
//UtilityFile.createZipFromMultipartFile(pathFile, fileName, f);
|
||||
|
||||
UtilityFile.saveFile(pathFile, f.getOriginalFilename(), f.getBytes());
|
||||
|
||||
@@ -1425,7 +1406,7 @@ public class SteUPService {
|
||||
" activity_result_id,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" descr_deposito\n" +
|
||||
"FROM dbo.steup_getRilevazioni()\n" +
|
||||
"FROM dbo.steup_getRilevazioni(null, null, null)\n" +
|
||||
"WHERE CAST(effective_time AS DATE) BETWEEN %s AND %s",
|
||||
dataInizio,
|
||||
dataFine
|
||||
@@ -1493,4 +1474,290 @@ public class SteUPService {
|
||||
entityProcessor.processEntityList(entityList, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void analisiRottureDiStock(LocalDate dataIspezione, String codMdep) throws Exception {
|
||||
Map<String, String> setup = setupGest.getSetupSection(multiDBTransactionManager.getPrimaryConnection(), "PVM", "RILEVAZIONI_STEUP");
|
||||
|
||||
String tipoAttivitaRotturaStock = setup.get("TIPO_ATTIVITA_ROTTURA_STOCK");
|
||||
List<String> repartiFreschi = Arrays.asList(StringUtils.split(UtilityString.isNull(setup.get("REPARTI_FRESCHI"), ""), "|"));
|
||||
List<String> tipiEsclusi = Arrays.asList(StringUtils.split(UtilityString.isNull(setup.get("EXCLUDE_COD_MTIP"), ""), "|"));
|
||||
List<String> fornitori = Arrays.asList(StringUtils.split(UtilityString.isNull(setup.get("ELENCO_FORN_INEVASI"), ""), "|"));
|
||||
|
||||
String sql =
|
||||
Query.format(
|
||||
"select i.cod_mdep, stb_activity.cod_jfas, stb_activity.activity_id, stb_activity.user_name\n" +
|
||||
"from dbo.steup_getRilevazioni(%s, %s, null) i\n" +
|
||||
"inner join stb_activity on i.activity_id = stb_activity.parent_activity_id\n" +
|
||||
"where stb_activity.activity_type_id = %s",
|
||||
dataIspezione, codMdep, tipoAttivitaRotturaStock);
|
||||
|
||||
List<HashMap<String, Object>> ispezioni = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
if (ispezioni == null || ispezioni.isEmpty()) {
|
||||
throw new Exception("Nessuna ispezione trovata per la data e il punto vendita indicati.");
|
||||
}
|
||||
|
||||
Map<String, List<HashMap<String, Object>>> ispezioniDepo = ispezioni.stream().collect(groupingBy(x -> (String) x.get("cod_mdep")));
|
||||
|
||||
for (Map.Entry<String, List<HashMap<String, Object>>> entry : ispezioniDepo.entrySet()) {
|
||||
String userNamePv = entry.getValue().get(0).get("user_name").toString();
|
||||
Map<String, List<HashMap<String, Object>>> reparti = entry.getValue().stream().collect(groupingBy(x -> (String) x.get("cod_jfas")));
|
||||
for (Map.Entry<String, List<HashMap<String, Object>>> reparto : reparti.entrySet()) {
|
||||
String codJfas = reparto.getKey();
|
||||
List<String> barcodes = new ArrayList<>();
|
||||
|
||||
List<String> idAttivita = new ArrayList<>();
|
||||
for ( HashMap<String, Object> r: reparto.getValue() ) {
|
||||
String activityId = (String) r.get("activity_id");
|
||||
idAttivita.add(activityId);
|
||||
StbActivityFile stbActivityFile = new StbActivityFile()
|
||||
.setId(activityId)
|
||||
.setFileName("elenco_articoli.txt");
|
||||
stbActivityFile.setOperation(OperationType.SELECT_OBJECT);
|
||||
|
||||
entityProcessor.processEntity(stbActivityFile, multiDBTransactionManager);
|
||||
|
||||
byte[] contentB64 = stbActivityFile.getContent();
|
||||
if (contentB64 != null && contentB64.length > 0) {
|
||||
String content = new String(contentB64);
|
||||
barcodes.addAll(UtilityString.splitStringToMultipleLine(content, CommonConstants.A_CAPO));
|
||||
if (UtilityDebug.isDebugExecution()) {
|
||||
barcodes=Arrays.asList(
|
||||
("8001990030611\n" +
|
||||
"8003650000798\n" +
|
||||
"8054633830833\n" +
|
||||
"8410436393942\n" +
|
||||
"8002340012103\n" +
|
||||
"8007300004297\n" +
|
||||
"8002340012660\n" +
|
||||
"8033532102838\n" +
|
||||
"8052675290028\n" +
|
||||
"8000697001917\n" +
|
||||
"8055719541384\n" +
|
||||
"8055719541377\n" +
|
||||
"8018700037204\n" +
|
||||
"8001480720800\n" +
|
||||
"8001280070648\n" +
|
||||
"8054633831656\n" +
|
||||
"8720182641618\n" +
|
||||
"8011380002074\n" +
|
||||
"8230485606837\n" +
|
||||
"8033532107987\n" +
|
||||
"8033908800726\n" +
|
||||
"8021719130026\n" +
|
||||
"8051886470717\n" +
|
||||
"8700216772082\n" +
|
||||
"8033447586204\n" +
|
||||
"8006540891469\n" +
|
||||
"4012400502363\n" +
|
||||
"8051499395889\n" +
|
||||
"8051499393571\n" +
|
||||
"8051499395872\n" +
|
||||
"8034055535387\n" +
|
||||
"8056364996130\n" +
|
||||
"8056364993467\n" +
|
||||
"8007675733877").split("\n")
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (barcodes.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
List<String> articoli = verificaRottura(entry.getKey(), codJfas, dataIspezione, repartiFreschi, tipiEsclusi, fornitori, barcodes);
|
||||
|
||||
/*List<StbActivity> attivitaArticoli = new ArrayList<>();
|
||||
for (String articolo : articoli) {
|
||||
attivitaArticoli.add(getArticoli(null, articolo, tipoAttivitaRotturaStock, codJfas, userNamePv));
|
||||
} */
|
||||
|
||||
List<StbActivity> stbActivityList = new ArrayList<>();
|
||||
for (String activityId : idAttivita) {
|
||||
sql = "select *\n" +
|
||||
"from srl_activity_art\n" +
|
||||
"where activity_id = " + UtilityDB.valueToString(activityId) + "\n";
|
||||
|
||||
List<SrlActivityArt> articoliPresenti = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, SrlActivityArt.class);
|
||||
List<String> artP;
|
||||
if (articoliPresenti != null) {
|
||||
articoliPresenti
|
||||
.stream()
|
||||
.forEach(x -> {
|
||||
if (articoli.contains(x.getCodMart()))
|
||||
x.setOperation(OperationType.UPDATE);
|
||||
else
|
||||
x.setOperation(OperationType.DELETE);
|
||||
});
|
||||
artP = articoliPresenti.stream().map(x -> x.getCodMart()).distinct().collect(Collectors.toList());
|
||||
} else {
|
||||
artP = new ArrayList<>();
|
||||
}
|
||||
|
||||
List<SrlActivityArt> artNew = articoli
|
||||
.stream()
|
||||
.filter(x -> !artP.contains(x))
|
||||
.map(x -> {
|
||||
SrlActivityArt s = new SrlActivityArt().setCodMart(x);
|
||||
s.setOperation(OperationType.INSERT);
|
||||
return s;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
|
||||
StbActivity activityToUpdate = new StbActivity();
|
||||
activityToUpdate.setActivityId(activityId);
|
||||
activityToUpdate.setSrlActivityArt(articoliPresenti);
|
||||
activityToUpdate.getSrlActivityArt().addAll(artNew);
|
||||
activityToUpdate.setOperation(OperationType.UPDATE);
|
||||
stbActivityList.add(activityToUpdate);
|
||||
|
||||
}
|
||||
|
||||
UtilityEntity.throwEntitiesException(entityProcessor.processEntityList(stbActivityList, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> verificaRottura(String codMdep, String codJfas,
|
||||
LocalDate dataCreation,
|
||||
List<String> repartiFreschi,
|
||||
List<String> tipiEsclusi,
|
||||
List<String> fornitori,
|
||||
List<String> barcode) throws Exception {
|
||||
|
||||
String tipoGriglia = setupGest.getSetupDet(multiDBTransactionManager.getPrimaryConnection(), "PVM", "RILEVAZIONI_STEUP", "TIPO_GRIGLIA", codJfas);
|
||||
|
||||
String profileDb = setupGest.getSetupDepo(multiDBTransactionManager.getPrimaryConnection(), "DATI_AZIENDA", "DATI_DEPOSITO", "PROFILE_DB", codMdep);
|
||||
|
||||
String sql = Query.format("SELECT cod_mgrp FROM jrl_fasi_mtb_grup WHERE cod_jfas = %s", codJfas);
|
||||
|
||||
List<String> gruppiMerc = UtilityDB.executeSimpleQueryOnlyFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
String queryAssortimento = "";
|
||||
switch (tipoGriglia) {
|
||||
case "A":
|
||||
queryAssortimento =
|
||||
"SELECT DISTINCT mtb_aart.cod_mart\n" +
|
||||
" FROM mvw_barcode INNER JOIN mtb_aart ON mtb_aart.cod_mart = mvw_barcode.cod_mart \n";
|
||||
break;
|
||||
case "V":
|
||||
queryAssortimento =
|
||||
"SELECT DISTINCT vtb_griglia_art.cod_mart\n" +
|
||||
"FROM vtb_griglia_art\n" +
|
||||
" INNER JOIN mvw_barcode ON vtb_griglia_art.cod_mart = mvw_barcode.cod_mart\n" +
|
||||
" INNER JOIN mtb_aart ON vtb_griglia_art.cod_mart = mtb_aart.cod_mart\n" +
|
||||
"WHERE cod_griglia = [COD_MDEP]\n" +
|
||||
" AND data_validita = [DATA_ISPEZIONE]\n" +
|
||||
" AND (SELECT MAX(data_validita)\n" +
|
||||
" FROM vtb_griglia_art\n" +
|
||||
" WHERE cod_griglia = [COD_MDEP]\n" +
|
||||
" AND data_validita <= [DATA_ISPEZIONE])";
|
||||
|
||||
queryAssortimento = queryAssortimento.replace("[COD_MDEP]", UtilityDB.valueToString(codMdep))
|
||||
.replace("[DATA_ISPEZIONE]", UtilityDB.valueToString(dataCreation));
|
||||
break;
|
||||
}
|
||||
|
||||
queryAssortimento = UtilityDB.addwhereCond(queryAssortimento, "mtb_aart.cod_mgrp IN (" + UtilityDB.listValueToString(gruppiMerc) + ")", false);
|
||||
String whereCondBarcode = "";
|
||||
if (repartiFreschi.contains(codJfas)) {
|
||||
whereCondBarcode = "mvw_barcode.cod_barre not in (" + UtilityDB.listValueToString(barcode) + ")";
|
||||
} else {
|
||||
whereCondBarcode = "mvw_barcode.cod_barre in (" + UtilityDB.listValueToString(barcode) + ")";
|
||||
}
|
||||
queryAssortimento = UtilityDB.addwhereCond(queryAssortimento, whereCondBarcode, false);
|
||||
|
||||
/*Nella query dei kit prendiamo componenti, composti, articoli sostitutivi ( cod_mart_stat) E componeni della distinta*/
|
||||
String queryKit =
|
||||
"SELECT mtb_aart.cod_mart, mtb_aart.cod_mart AS cod_mart_griglia\n" +
|
||||
"FROM mtb_aart\n" +
|
||||
"WHERE mtb_aart.articolo_composto = 'N'\n" +
|
||||
"UNION\n" +
|
||||
"SELECT mtb_aart.cod_mart, mtb_comp.cod_comp AS cod_mart_griglia\n" +
|
||||
"FROM mtb_aart\n" +
|
||||
" INNER JOIN mtb_comp ON mtb_aart.cod_mart = mtb_comp.cod_mart\n" +
|
||||
"WHERE mtb_aart.articolo_composto = 'S'\n" +
|
||||
"UNION\n" +
|
||||
"SELECT mtb_comp.cod_comp, mtb_comp.cod_mart\n" +
|
||||
"FROM mtb_aart\n" +
|
||||
" INNER JOIN mtb_comp ON mtb_aart.cod_mart = mtb_comp.cod_mart\n" +
|
||||
"WHERE mtb_aart.articolo_composto = 'S'\n" +
|
||||
"UNION\n" +
|
||||
"SELECT mtb_aart.cod_mart, mtb_aart.cod_mart_stat\n" +
|
||||
"FROM mtb_aart\n" +
|
||||
"WHERE mtb_aart.cod_mart_stat IS NOT NULL\n" +
|
||||
"UNION\n" +
|
||||
"SELECT cod_prod, cod_mart\n" +
|
||||
"FROM jtb_dist_mate\n" +
|
||||
"WHERE cod_mart IS NOT NULL";
|
||||
|
||||
List<String> articoli = new ArrayList<>();
|
||||
try (MultiDBTransactionManager mdb = new MultiDBTransactionManager(profileDb)) {
|
||||
articoli = UtilityDB.executeSimpleQueryOnlyFirstColumn(mdb.getPrimaryConnection(), queryAssortimento);
|
||||
|
||||
//Eliminazione nuovi inserimenti in griglia
|
||||
String sqlGriglia =
|
||||
"WITH articoli AS ( \n" + queryKit + " ) \n" +
|
||||
"SELECT g.cod_mart\n" +
|
||||
"FROM dbo.getgrigliaacquisto([DATA_CREAZIONE], NULL, [COD_MDEP], NULL, NULL) g\n" +
|
||||
" INNER JOIN mtb_aart ON g.cod_mart = mtb_aart.cod_mart AND mtb_aart.cod_mgrp IN ([GRUPPI_MERC])\n" +
|
||||
" INNER JOIN articoli ON g.cod_mart = articoli.cod_mart_griglia\n" +
|
||||
"WHERE g.tipo_variazione = 'I'\n" +
|
||||
" AND g.data_validita >= DATEADD(DAY, -7, [DATA_CREAZIONE]) ";
|
||||
|
||||
sqlGriglia = sqlGriglia
|
||||
.replace("[DATA_CREAZIONE]", UtilityDB.valueToString(dataCreation))
|
||||
.replace("[COD_MDEP]", UtilityDB.valueToString(codMdep))
|
||||
.replace("[COD_JFAS]", UtilityDB.valueToString(codJfas))
|
||||
.replace("[GRUPPI_MERC]", UtilityDB.listValueToString(gruppiMerc));
|
||||
|
||||
if (!tipiEsclusi.isEmpty()) {
|
||||
sqlGriglia = UtilityDB.addwhereCond(sqlGriglia, "(mtb_aart.cod_mtip IS NULL OR mtb_aart.cod_mtip not in (" + UtilityDB.listValueToString(tipiEsclusi) + "))", true);
|
||||
}
|
||||
|
||||
List<String> nuoviInserimenti = UtilityDB.executeSimpleQueryOnlyFirstColumn(mdb.getPrimaryConnection(), sqlGriglia);
|
||||
|
||||
articoli = articoli.stream()
|
||||
.filter(x -> !nuoviInserimenti.contains(x))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
//Verifica Inevasi
|
||||
String sqlInevasi =
|
||||
"WITH articoli AS (" + queryKit + ")\n" +
|
||||
"SELECT DISTINCT articoli.cod_mart\n" +
|
||||
"FROM dtb_ordt\n" +
|
||||
" INNER JOIN dtb_ordr ON dtb_ordt.gestione = dtb_ordr.gestione\n" +
|
||||
" AND dtb_ordt.data_ord = dtb_ordr.data_ord\n" +
|
||||
" AND dtb_ordt.num_ord = dtb_ordr.num_ord\n" +
|
||||
" INNER JOIN gtb_anag ON dtb_ordt.cod_anag = gtb_anag.cod_anag\n" +
|
||||
" INNER JOIN mtb_aart ON dtb_ordr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" INNER JOIN articoli ON mtb_aart.cod_mart = articoli.cod_mart_griglia\n" +
|
||||
"WHERE dtb_ordt.gestione = 'A'\n" +
|
||||
" AND dtb_ordt.flag_annulla = 'N'\n" +
|
||||
" AND gtb_anag.part_iva IN ([ELENCO_FORNITORI])\n" +
|
||||
" AND dtb_ordt.cod_mdep = [COD_MDEP]\n" +
|
||||
" AND dtb_ordt.data_esportazione IS NOT NULL\n" +
|
||||
" AND mtb_aart.cod_mgrp IN ( [GRUPPI_MERC] ) \n" +
|
||||
" AND dtb_ordr.qta_evasa = 0\n" +
|
||||
" AND dtb_ordr.data_cons BETWEEN DATEADD(DAY, -7, [DATA_ISPEZIONE]) AND [DATA_ISPEZIONE]\n";
|
||||
|
||||
sqlInevasi =
|
||||
sqlInevasi
|
||||
.replace("[DATA_ISPEZIONE]", UtilityDB.valueToString(dataCreation))
|
||||
.replace("[COD_MDEP]", UtilityDB.valueToString(codMdep))
|
||||
.replace("[GRUPPI_MERC]", UtilityDB.listValueToString(gruppiMerc))
|
||||
.replace("[ELENCO_FORNITORI]", UtilityDB.listValueToString(fornitori));
|
||||
|
||||
if (!tipiEsclusi.isEmpty()) {
|
||||
sqlInevasi = UtilityDB.addwhereCond(sqlInevasi, "(mtb_aart.cod_mtip IS NULL OR mtb_aart.cod_mtip not in (" + UtilityDB.listValueToString(tipiEsclusi) + "))", true);
|
||||
}
|
||||
|
||||
List<String> inevasi = UtilityDB.executeSimpleQueryOnlyFirstColumn(mdb.getPrimaryConnection(), sqlInevasi);
|
||||
|
||||
articoli = articoli.stream()
|
||||
.filter(x -> !inevasi.contains(x))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return articoli;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package it.integry.ems.jpa;
|
||||
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
public class TenantInterceptor extends HandlerInterceptorAdapter {
|
||||
|
||||
@Autowired
|
||||
private RequestDataDTO requestDataDTO;
|
||||
|
||||
// private static final String TENANT_HEADER = "X-Tenant-ID";
|
||||
// private static final String DEFAULT_TENANT = "default"; // O recuperalo da configurazione
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
String profileDb = requestDataDTO.getProfileDB();
|
||||
|
||||
// String tenantId = request.getHeader(TENANT_HEADER);
|
||||
|
||||
// Logica di fallback o recupero tenant da sessione/utente
|
||||
if (profileDb == null || profileDb.isEmpty()) {
|
||||
// Esempio: recupero da sessione se presente
|
||||
// tenantId = (String) request.getSession().getAttribute("TENANT_ID");
|
||||
|
||||
// Fallback temporaneo per test
|
||||
// tenantId = DEFAULT_TENANT;
|
||||
}
|
||||
|
||||
if (profileDb != null) {
|
||||
TenantContext.setCurrentTenant(profileDb);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems._context.ApplicationContextProvider;
|
||||
import it.integry.ems.logistic.dto.sm2.FiltroDistribuzioneColloDTO;
|
||||
import it.integry.ems.product.importaz.service.ProductServices;
|
||||
import it.integry.ems.retail.wms.Utility.WMSUtility;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.entity.MtbAartUtils;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.base.EntityNotFound;
|
||||
import it.integry.ems_model.entity.*;
|
||||
@@ -116,7 +116,7 @@ public class DistribuzioneColliService {
|
||||
.map(MtbColr::getCodMart)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<MtbAart> mtbAarts = WMSUtility.getArticoliByCodMarts(codMarts, multiDBTransactionManager.getPrimaryConnection());
|
||||
List<MtbAart> mtbAarts = MtbAartUtils.getArticoliByCodMarts(codMarts, multiDBTransactionManager.getPrimaryConnection());
|
||||
|
||||
|
||||
//Lettura del filtro ordini
|
||||
|
||||
@@ -3,11 +3,11 @@ package it.integry.ems.order.Import.service;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems._context.ApplicationContextProvider;
|
||||
import it.integry.ems.exception.PrimaryDatabaseNotPresentException;
|
||||
import it.integry.ems.retail.wms.Utility.WMSUtility;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems.utility.entity.MtbAartUtils;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.entity.*;
|
||||
@@ -132,7 +132,7 @@ public class OrdiniMaxiDataImportService {
|
||||
if (schedeProduzione == null || schedeProduzione.isEmpty())
|
||||
return new ArrayList<>();
|
||||
|
||||
List<MtbAart> anafraficheArticoli = WMSUtility.getArticoliByCodMarts(
|
||||
List<MtbAart> anafraficheArticoli = MtbAartUtils.getArticoliByCodMarts(
|
||||
schedeProduzione.stream()
|
||||
.map(MaxidataUveBII40V2BLLUVE2kSchedeProd::getIdProdotto)
|
||||
.distinct()
|
||||
|
||||
@@ -10,11 +10,13 @@ import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.entity.DtbOrdr;
|
||||
import it.integry.ems_model.entity.DtbOrdt;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityBigDecimal;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityHashMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -26,6 +28,9 @@ public class OrdiniVSlim2kService {
|
||||
private final EntityProcessor entityProcessor;
|
||||
private final EmsServices emsServices;
|
||||
|
||||
@Autowired
|
||||
private SetupGest setupGest;
|
||||
|
||||
public OrdiniVSlim2kService(EntityProcessor entityProcessor, EmsServices emsServices) {
|
||||
this.entityProcessor = entityProcessor;
|
||||
this.emsServices = emsServices;
|
||||
@@ -43,11 +48,11 @@ public class OrdiniVSlim2kService {
|
||||
List<HashMap<String, Object>> articoli = new ArrayList<>();
|
||||
List<HashMap<String, Object>> export = new ArrayList<>();
|
||||
|
||||
for(DtbOrdt ord : groupOrdini.keySet()) {
|
||||
for (DtbOrdt ord : groupOrdini.keySet()) {
|
||||
for (DtbOrdr dtbOrdr : groupOrdini.get(ord)) {
|
||||
String sql =
|
||||
Query.format("SELECT * FROM dtb_ordt WHERE gestione = %s AND data_ord = %s AND num_ord = %s",
|
||||
ord.getGestione(), ord.getDataOrd(), ord.getNumOrd());
|
||||
ord.getGestione(), ord.getDataOrd(), ord.getNumOrd());
|
||||
|
||||
ord = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, DtbOrdt.class);
|
||||
BigDecimal qtaCnf;
|
||||
@@ -73,48 +78,51 @@ public class OrdiniVSlim2kService {
|
||||
}
|
||||
|
||||
entityProcessor.processEntity(ord, multiDBTransactionManager, false);
|
||||
boolean exportOrdini = setupGest.getSetupBoolean(multiDBTransactionManager.getPrimaryConnection(), "PVM", "ORDINI_V_SLIM2K", "EXPORT_ORDINI");
|
||||
|
||||
DtbOrdt finalOrd = ord;
|
||||
Optional<HashMap<String, Object>> exportOpt = export.stream()
|
||||
.filter(x -> ((String) x.get("cod_anag")).equalsIgnoreCase(finalOrd.getCodAnag())).findFirst();
|
||||
HashMap<String, Object> datiExport;
|
||||
if ( exportOpt.isPresent() ) {
|
||||
datiExport = exportOpt.get();
|
||||
} else {
|
||||
String query =
|
||||
Query.format(
|
||||
"SELECT wtb_clie.cod_anag, " +
|
||||
"wtb_users.user_name, wtb_users.password, wtb_users_info.format_file, COUNT(wtb_users_info.format_file) over (partition by wtb_users_info.user_name) as count_export" +
|
||||
" FROM wtb_users " +
|
||||
"INNER JOIN wtb_users_info ON wtb_users.User_name = wtb_users_info.user_name " +
|
||||
"INNER JOIN wtb_clie ON wtb_users.User_name = wtb_clie.user_name " +
|
||||
" WHERE wtb_users_info.flag_state = 'S' and " +
|
||||
" wtb_clie.cod_anag = %s AND \n" +
|
||||
" wtb_users_info.export_type = %s",
|
||||
ord.getCodAnag(), EntityExportType.ORDINI_VENDITA.getText());
|
||||
|
||||
datiExport = UtilityDB.executeSimpleQueryOnlyFirstRow(multiDBTransactionManager.getPrimaryConnection(), query);
|
||||
export.add(datiExport);
|
||||
}
|
||||
|
||||
if (UtilityHashMap.isPresent(datiExport)) {
|
||||
String userNameExport = UtilityHashMap.getValueIfExists(datiExport, "user_name");
|
||||
String passwordExport = UtilityHashMap.getValueIfExists(datiExport, "password");
|
||||
String formatExport = UtilityHashMap.getValueIfExists(datiExport, "format_file");
|
||||
Integer countExport = UtilityHashMap.getValueIfExists(datiExport, "count_export");
|
||||
|
||||
if (countExport == 1) {
|
||||
RequestDataDTO requestDataDTO = new RequestDataDTO();
|
||||
requestDataDTO.setUsername(userNameExport);
|
||||
requestDataDTO.setPassword(passwordExport);
|
||||
String whereCond =
|
||||
if (ord.getDataEsportazione() != null && exportOrdini) {
|
||||
DtbOrdt finalOrd = ord;
|
||||
Optional<HashMap<String, Object>> exportOpt = export.stream()
|
||||
.filter(x -> ((String) x.get("cod_anag")).equalsIgnoreCase(finalOrd.getCodAnag())).findFirst();
|
||||
HashMap<String, Object> datiExport;
|
||||
if (exportOpt.isPresent()) {
|
||||
datiExport = exportOpt.get();
|
||||
} else {
|
||||
String query =
|
||||
Query.format(
|
||||
"dtb_ordt.gestione = %s AND dtb_ordt.data_ord = %s AND dtb_ordt.num_ord = %s",
|
||||
ord.getGestione(), ord.getDataOrd(), ord.getNumOrd());
|
||||
"SELECT wtb_clie.cod_anag, " +
|
||||
"wtb_users.user_name, wtb_users.password, wtb_users_info.format_file, COUNT(wtb_users_info.format_file) over (partition by wtb_users_info.user_name) as count_export" +
|
||||
" FROM wtb_users " +
|
||||
"INNER JOIN wtb_users_info ON wtb_users.User_name = wtb_users_info.user_name " +
|
||||
"INNER JOIN wtb_clie ON wtb_users.User_name = wtb_clie.user_name " +
|
||||
" WHERE wtb_users_info.flag_state = 'S' and " +
|
||||
" wtb_clie.cod_anag = %s AND \n" +
|
||||
" wtb_users_info.export_type = %s",
|
||||
ord.getCodAnag(), EntityExportType.ORDINI_VENDITA.getText());
|
||||
|
||||
ObjectNode jsonNode = JsonNodeFactory.instance.objectNode();
|
||||
jsonNode.put("whereCond", whereCond);
|
||||
emsServices.export(multiDBTransactionManager, requestDataDTO, EntityExportType.ORDINI_VENDITA.getText(), formatExport, jsonNode, true);
|
||||
datiExport = UtilityDB.executeSimpleQueryOnlyFirstRow(multiDBTransactionManager.getPrimaryConnection(), query);
|
||||
export.add(datiExport);
|
||||
}
|
||||
|
||||
if (UtilityHashMap.isPresent(datiExport)) {
|
||||
String userNameExport = UtilityHashMap.getValueIfExists(datiExport, "user_name");
|
||||
String passwordExport = UtilityHashMap.getValueIfExists(datiExport, "password");
|
||||
String formatExport = UtilityHashMap.getValueIfExists(datiExport, "format_file");
|
||||
Integer countExport = UtilityHashMap.getValueIfExists(datiExport, "count_export");
|
||||
|
||||
if (countExport == 1) {
|
||||
RequestDataDTO requestDataDTO = new RequestDataDTO();
|
||||
requestDataDTO.setUsername(userNameExport);
|
||||
requestDataDTO.setPassword(passwordExport);
|
||||
String whereCond =
|
||||
Query.format(
|
||||
"dtb_ordt.gestione = %s AND dtb_ordt.data_ord = %s AND dtb_ordt.num_ord = %s",
|
||||
ord.getGestione(), ord.getDataOrd(), ord.getNumOrd());
|
||||
|
||||
ObjectNode jsonNode = JsonNodeFactory.instance.objectNode();
|
||||
jsonNode.put("whereCond", whereCond);
|
||||
emsServices.export(multiDBTransactionManager, requestDataDTO, EntityExportType.ORDINI_VENDITA.getText(), formatExport, jsonNode, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,9 @@ public class ProductController {
|
||||
@Autowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
|
||||
@Autowired
|
||||
private it.integry.ems.jpa.repository.MtbAartRepository mtbAartRepository;
|
||||
|
||||
@Autowired
|
||||
private ServiceChecker serviceChecker;
|
||||
|
||||
@@ -287,6 +290,18 @@ public class ProductController {
|
||||
return new ServiceRestResponse(EsitoType.OK, null, mtbAartList);
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_SMART_ENTERPRISE_GET_ART_BY_CODMART + "/jpa", method = RequestMethod.GET)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse getArticoloByCodMartJpa(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestParam("codMart") String codMartString) throws Exception {
|
||||
|
||||
List<String> codMarts = Arrays.asList(codMartString.split(","));
|
||||
List<MtbAart> mtbAartList = mtbAartRepository.findByCodMartIn(codMarts);
|
||||
|
||||
return new ServiceRestResponse(EsitoType.OK, null, mtbAartList);
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_POPOLA_TABELLA_RIASSEGNAZIONE, method = RequestMethod.POST)
|
||||
public ServiceRestResponse popolaTabellaRiassegnazione(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration) throws Exception {
|
||||
|
||||
@@ -11,12 +11,12 @@ import it.integry.ems.product.importaz.dto.ArticoliMorganteDTO;
|
||||
import it.integry.ems.product.importaz.dto.ContrattiVenditaDTO;
|
||||
import it.integry.ems.product.importaz.dto.StatoArticoloDTO;
|
||||
import it.integry.ems.properties.EmsProperties;
|
||||
import it.integry.ems.retail.wms.Utility.WMSUtility;
|
||||
import it.integry.ems.rules.completing.QueryRules;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems.utility.entity.MtbAartUtils;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.db.ResultSetMapper;
|
||||
import it.integry.ems_model.entity.*;
|
||||
@@ -235,7 +235,7 @@ public class ProductServices {
|
||||
}
|
||||
|
||||
public List<MtbAart> getArticoliByCodMarts(List<String> codMarts) throws Exception {
|
||||
return WMSUtility.getArticoliByCodMarts(codMarts, multiDBTransactionManager.getPrimaryConnection());
|
||||
return MtbAartUtils.getArticoliByCodMarts(codMarts, multiDBTransactionManager.getPrimaryConnection());
|
||||
}
|
||||
|
||||
public List<EntityBase> importArticoliBiolevante() throws Exception {
|
||||
|
||||
@@ -22,7 +22,6 @@ import it.integry.ems.production.event.ProductionUlCreatedEvent;
|
||||
import it.integry.ems.report.dto.JasperDTO;
|
||||
import it.integry.ems.report.dto.PairsDTO;
|
||||
import it.integry.ems.retail.pvmRetail.service.PvmService;
|
||||
import it.integry.ems.retail.wms.Utility.WMSUtility;
|
||||
import it.integry.ems.retail.wms.accettazione.service.WMSAccettazioneService;
|
||||
import it.integry.ems.retail.wms.dto.*;
|
||||
import it.integry.ems.retail.wms.generic.dto.MvwSitArtUdcDetInventarioDTO;
|
||||
@@ -42,6 +41,7 @@ import it.integry.ems.service.production.ProductionOrderDataHandlerService;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems.utility.entity.MtbAartUtils;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.business_logic.dto.DatiMaterialiDTO;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
@@ -1126,7 +1126,7 @@ public class MesProductionServiceV2 {
|
||||
entityProcessor.processEntity(ordineLav, true, multiDBTransactionManager);
|
||||
|
||||
MtbAart mtbAart =
|
||||
WMSUtility.getArticoloByCodMart(ordineLav.getCodProd(), multiDBTransactionManager.getPrimaryConnection());
|
||||
MtbAartUtils.getArticoloByCodMart(ordineLav.getCodProd(), multiDBTransactionManager.getPrimaryConnection());
|
||||
|
||||
if (UtilityBigDecimal.isNullOrZero(dto.getQtaCollo())) {
|
||||
if (UtilityBigDecimal.isNullOrZero(dto.getColliPedana())) {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package it.integry.ems.retail.wms.Utility;
|
||||
|
||||
import com.annimon.stream.Optional;
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.ems._context.ApplicationContextProvider;
|
||||
import it.integry.ems.dynamic_cache.EntityCacheComponent;
|
||||
import it.integry.ems.exception.MissingDataException;
|
||||
import it.integry.ems.exception.PrimaryDatabaseNotPresentException;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
@@ -19,6 +17,7 @@ import it.integry.ems.service.production.ProductionOrderDataHandlerService;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems.utility.entity.MtbAartUtils;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.entity._enum.GestioneEnum;
|
||||
import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
|
||||
@@ -30,7 +29,10 @@ import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WMSUtility {
|
||||
@@ -252,7 +254,7 @@ public class WMSUtility {
|
||||
if (targetMtbColt == null)
|
||||
throw new Exception("Nessun collo di destinazione specificato durante l'inserimento di una riga in una UDS (targetMtbColt null)");
|
||||
|
||||
MtbAart mtbAart = WMSUtility.getArticoloByCodMart(insertUDSRowRequestDTO.getCodMart(), connection);
|
||||
MtbAart mtbAart = MtbAartUtils.getArticoloByCodMart(insertUDSRowRequestDTO.getCodMart(), connection);
|
||||
if (mtbAart == null)
|
||||
throw new InvalidArticoloException(insertUDSRowRequestDTO.getCodMart());
|
||||
|
||||
@@ -538,7 +540,7 @@ public class WMSUtility {
|
||||
|
||||
|
||||
if (insertUDCRowRequestDTO.getCodMart() != null) {
|
||||
MtbAart mtbAart = getArticoloByCodMart(insertUDCRowRequestDTO.getCodMart(), multiDBTransactionManager.getPrimaryConnection());
|
||||
MtbAart mtbAart = MtbAartUtils.getArticoloByCodMart(insertUDCRowRequestDTO.getCodMart(), multiDBTransactionManager.getPrimaryConnection());
|
||||
if (mtbAart == null)
|
||||
throw new InvalidArticoloException(insertUDCRowRequestDTO.getCodMart());
|
||||
|
||||
@@ -567,84 +569,7 @@ public class WMSUtility {
|
||||
.setSavedMtbColr(targetMtbColr);
|
||||
}
|
||||
|
||||
public static MtbAart getArticoloByCodMart(String codMart, Connection connection) throws Exception {
|
||||
if (UtilityString.isNullOrEmpty(codMart))
|
||||
return null;
|
||||
|
||||
List<MtbAart> mtbAarts = getArticoliByCodMarts(new ArrayList<>(Collections.singleton(codMart)), connection);
|
||||
if (mtbAarts == null || mtbAarts.isEmpty())
|
||||
return null;
|
||||
|
||||
return mtbAarts.get(0);
|
||||
}
|
||||
|
||||
public static List<MtbAart> getArticoliByCodMarts(List<String> codMarts, Connection connection) throws Exception {
|
||||
if (codMarts == null || codMarts.isEmpty()) return null;
|
||||
|
||||
codMarts.replaceAll(String::toUpperCase);
|
||||
|
||||
final EntityCacheComponent entityCacheComponent = ApplicationContextProvider.getApplicationContext().getBean(EntityCacheComponent.class);
|
||||
|
||||
List<MtbAart> listMtbAart = entityCacheComponent.getCachedEntitiesList(
|
||||
connection.getIntegryCustomerDB(), MtbAart.ENTITY, x -> codMarts.contains(x.getCodMart().toUpperCase()));
|
||||
|
||||
List<MtbAartBarCode> barCodeFromCod = getAlternativeMtbAartBarCodes(codMarts, connection);
|
||||
|
||||
if (listMtbAart != null && !listMtbAart.isEmpty()) {
|
||||
List<String> untMisStrings = listMtbAart.stream()
|
||||
.map(MtbAart::getUntMis)
|
||||
.collect(Collectors.toList());
|
||||
List<MtbUntMis> listUntMis = getUntMisFromCod(untMisStrings, connection);
|
||||
|
||||
for (final MtbAart mtbAart : listMtbAart) {
|
||||
Optional<MtbUntMis> mtbUntMis = Stream.of(listUntMis)
|
||||
.filter(mtbUntMis1 -> mtbUntMis1.getUntMis().equalsIgnoreCase(mtbAart.getUntMis()))
|
||||
.findFirst();
|
||||
|
||||
List<MtbAartBarCode> barcodeList = Stream.of(barCodeFromCod)
|
||||
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbAart.getCodMart()))
|
||||
.toList();
|
||||
|
||||
if (!barcodeList.isEmpty()) {
|
||||
mtbAart.getMtbAartBarCode().addAll(barcodeList);
|
||||
}
|
||||
|
||||
if (mtbUntMis.isPresent()) {
|
||||
mtbAart.setMtbUntMis(new ArrayList<>());
|
||||
mtbAart.getMtbUntMis().add(mtbUntMis.get());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return listMtbAart;
|
||||
}
|
||||
|
||||
public static List<MtbUntMis> getUntMisFromCod(List<String> untMisCods, Connection connection) throws Exception {
|
||||
List<String> untMisStrings = Stream.of(untMisCods)
|
||||
.withoutNulls()
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
String queryUntMis = "SELECT * FROM mtb_unt_mis WHERE unt_mis IN (" + UtilityQuery.concatStringFieldsWithSeparator(untMisStrings, ",") + ")";
|
||||
final List<MtbUntMis> mtbUntMis = UtilityDB.executeSimpleQueryDTO(connection, queryUntMis, MtbUntMis.class);
|
||||
return mtbUntMis != null ? mtbUntMis : new ArrayList<>();
|
||||
}
|
||||
|
||||
public static List<MtbAartBarCode> getAlternativeMtbAartBarCodes(List<String> codMarts, Connection conn) {
|
||||
codMarts = codMarts.stream()
|
||||
.distinct().collect(Collectors.toList());
|
||||
|
||||
final EntityCacheComponent entityCacheComponent = ApplicationContextProvider.getApplicationContext().getBean(EntityCacheComponent.class);
|
||||
|
||||
List<String> finalCodMarts = codMarts;
|
||||
List<MtbAartBarCode> barCodeList = entityCacheComponent.getCachedEntitiesList(
|
||||
conn.getIntegryCustomerDB(),
|
||||
MtbAartBarCode.ENTITY,
|
||||
x -> finalCodMarts.stream().anyMatch(y -> y.equalsIgnoreCase(x.getCodMart())));
|
||||
|
||||
return barCodeList != null ? barCodeList : new ArrayList<>();
|
||||
}
|
||||
|
||||
public static MtbColt createInternalMovement(String codMdep) {
|
||||
|
||||
@@ -665,6 +590,10 @@ public class WMSUtility {
|
||||
return null;
|
||||
|
||||
return new MtbColr()
|
||||
.setNumCollo(inputData.getNumCollo())
|
||||
.setDataCollo(inputData.getDataCollo())
|
||||
.setGestione(inputData.getGestione())
|
||||
.setSerCollo(inputData.getSerCollo())
|
||||
.setCodMart(inputData.getCodMart())
|
||||
.setPartitaMag(inputData.getPartitaMag())
|
||||
// .setCodCol(inputData.getCodCol())
|
||||
@@ -728,4 +657,14 @@ public class WMSUtility {
|
||||
|
||||
return UtilityDB.executeSimpleQueryDTO(connection,Query.format("SELECT * from mtb_colt where barcode_ul in ("+UtilityDB.listValueToString(barcodeList)+")"), MtbColt.class);
|
||||
}
|
||||
|
||||
public static MtbColt getUlPosizioneMonoUl(Connection connection, String posizione) throws Exception {
|
||||
String sql = "SELECT * FROM mtb_colt " +
|
||||
" inner join mtb_depo_posizioni on mtb_colt.posizione = mtb_depo_posizioni.posizione" +
|
||||
" WHERE mtb_colt.segno = 1 AND mtb_depo_posizioni.flag_mono_collo = 'S' and mtb_depo_posizioni.posizione = " + UtilityDB.valueToString(posizione) ;
|
||||
List<MtbColt> listaUl = UtilityDB.executeSimpleQueryDTO(connection,sql,MtbColt.class);
|
||||
if (listaUl.isEmpty()) throw new Exception("Nessuna UL trovata per la posizione " + posizione);
|
||||
if (listaUl.size() > 1) throw new Exception("Ci sono più UL disponibili per la posizione " + posizione);
|
||||
return listaUl.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@ package it.integry.ems.retail.wms.accettazione.service;
|
||||
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.product.importaz.service.ProductServices;
|
||||
import it.integry.ems.retail.wms.Utility.WMSUtility;
|
||||
import it.integry.ems.retail.wms.accettazione.dto.AlreadyRegisteredUlDTO;
|
||||
import it.integry.ems.retail.wms.accettazione.dto.BollaAccettazioneDTO;
|
||||
import it.integry.ems.retail.wms.accettazione.dto.SitBollaAccettazioneDTO;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.user.UserSession;
|
||||
import it.integry.ems.utility.entity.MtbAartUtils;
|
||||
import it.integry.ems_model.entity.MtbAart;
|
||||
import it.integry.ems_model.entity.WdtbDoct;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
@@ -166,7 +166,7 @@ public class WMSAccettazioneBollaService {
|
||||
|
||||
if (sitBollaAccettazioneDTOS == null || sitBollaAccettazioneDTOS.isEmpty()) return null;
|
||||
|
||||
final List<MtbAart> articoliByCodMarts = WMSUtility.getArticoliByCodMarts(sitBollaAccettazioneDTOS.stream()
|
||||
final List<MtbAart> articoliByCodMarts = MtbAartUtils.getArticoliByCodMarts(sitBollaAccettazioneDTOS.stream()
|
||||
.map(SitBollaAccettazioneDTO::getCodMart)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
|
||||
@@ -4,11 +4,11 @@ import it.integry.ems.product.importaz.service.ProductServices;
|
||||
import it.integry.ems.retail.pvmRetail.dto.PvmArticoliChildDTO;
|
||||
import it.integry.ems.retail.pvmRetail.dto.PvmArticoliDTO;
|
||||
import it.integry.ems.retail.pvmRetail.service.PvmService;
|
||||
import it.integry.ems.retail.wms.Utility.WMSUtility;
|
||||
import it.integry.ems.retail.wms.documenti.dto.DocumentArtDTO;
|
||||
import it.integry.ems.retail.wms.documenti.dto.RetrieveLottiDTO;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.entity.MtbUntMisUtils;
|
||||
import it.integry.ems_model.entity.MtbUntMis;
|
||||
import it.integry.ems_model.entity._enum.GestioneEnum;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
@@ -114,7 +114,7 @@ public class WMSDocumentService {
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
final List<MtbUntMis> untMisFromCod = WMSUtility.getUntMisFromCod(untMiss,multiDBTransactionManager.getPrimaryConnection());
|
||||
final List<MtbUntMis> untMisFromCod = MtbUntMisUtils.getFromCods(untMiss, multiDBTransactionManager.getPrimaryConnection());
|
||||
|
||||
for (DocumentArtDTO art : arts) {
|
||||
final MtbUntMis mtbUntMis = untMisFromCod.stream().filter(x -> x.getUntMis().equalsIgnoreCase(art.getUntMis()))
|
||||
|
||||
@@ -556,9 +556,16 @@ public class WMSGenericController {
|
||||
public @ResponseBody
|
||||
ServiceRestResponse spostaULInPosizione(@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody SpostaUlRequestDTO requestDTO) throws Exception {
|
||||
wmsGenericService.spostaUL(requestDTO);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
|
||||
try {
|
||||
MtbColt mtbColt = wmsGenericService.spostaUL(requestDTO);
|
||||
if (mtbColt != null) {
|
||||
mtbColt.setOnlyPkMaster(false);
|
||||
}
|
||||
return ServiceRestResponse.createPositiveResponse(mtbColt);
|
||||
} catch (Exception e) {
|
||||
multiDBTransactionManager.rollbackAll();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -705,4 +712,11 @@ public class WMSGenericController {
|
||||
) throws Exception {
|
||||
return ServiceRestResponse.createPositiveResponse(WMSUtility.retrieveBarcodesByBarcodeAndCodJfas(multiDBTransactionManager.getPrimaryConnection(),barcodeUl,codJfas, maxResults));
|
||||
}
|
||||
|
||||
@GetMapping("wms/resetta-posizioni-mono-ul")
|
||||
ServiceRestResponse resettaPosizioniMonoUl() throws Exception {
|
||||
wmsGenericService.resettaPosizioniMonoUL(multiDBTransactionManager, entityProcessor);
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package it.integry.ems.retail.wms.generic.dto;
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class SpostaUlRequestDTO {
|
||||
@@ -10,6 +11,9 @@ public class SpostaUlRequestDTO {
|
||||
private String codMdep;
|
||||
private String posizione;
|
||||
private String annotazioni;
|
||||
private Date dataTrasf;
|
||||
private Integer numTrasf;
|
||||
private String codVvet;
|
||||
private boolean createDocAutomatically = true;
|
||||
private List<MtbColt> mtbColtsToMove = new ArrayList<>();
|
||||
|
||||
@@ -49,6 +53,33 @@ public class SpostaUlRequestDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDataTrasf() {
|
||||
return dataTrasf;
|
||||
}
|
||||
|
||||
public SpostaUlRequestDTO setDataTrasf(Date dataTrasf) {
|
||||
this.dataTrasf = dataTrasf;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getNumTrasf() {
|
||||
return numTrasf;
|
||||
}
|
||||
|
||||
public SpostaUlRequestDTO setNumTrasf(Integer numTrasf) {
|
||||
this.numTrasf = numTrasf;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodVvet() {
|
||||
return codVvet;
|
||||
}
|
||||
|
||||
public SpostaUlRequestDTO setCodVvet(String codVvet) {
|
||||
this.codVvet = codVvet;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isCreateDocAutomatically() {
|
||||
return createDocAutomatically;
|
||||
}
|
||||
|
||||
@@ -36,10 +36,13 @@ import it.integry.ems.service.dto.production.OrdineInevasoGroupMercDTO;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.user.UserSession;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems.utility.entity.MtbAartUtils;
|
||||
import it.integry.ems.utility.entity.MtbDepoPosizioniUtils;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.db.ResultSetMapper;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.exception.GestSetupNotFoundException;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.types.SetupGestKeySection;
|
||||
@@ -101,6 +104,8 @@ public class WMSGenericService {
|
||||
|
||||
@Autowired
|
||||
private WMSAccettazioneService wmsAccettazioneService;
|
||||
@Autowired
|
||||
private WMSGiacenzaULService wmsGiacenzaULService;
|
||||
|
||||
public List<AvailableCodMdepDTO> getAvailableCodMdepsForUser() throws Exception {
|
||||
|
||||
@@ -782,7 +787,7 @@ public class WMSGenericService {
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
final List<MtbAart> mtbAarts = WMSUtility.getArticoliByCodMarts(codMarts, multiDBTransactionManager.getPrimaryConnection());
|
||||
final List<MtbAart> mtbAarts = MtbAartUtils.getArticoliByCodMarts(codMarts, multiDBTransactionManager.getPrimaryConnection());
|
||||
|
||||
|
||||
//Carico la giacenza degli articoli
|
||||
@@ -1714,11 +1719,16 @@ public class WMSGenericService {
|
||||
anomalieList.add(AnomalieDTO.error("Non è stato trovato alcun articolo in giacenza"));
|
||||
continue;
|
||||
}
|
||||
List<String> articoliDaScaricare = Stream.of(results).map(MvwSitArtUdcDetInventarioDTO::getCodMart).distinct().toList();
|
||||
List<String> articoliDaScaricare = results.stream()
|
||||
.map(MvwSitArtUdcDetInventarioDTO::getCodMart)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
for (String codMart : articoliDaScaricare) {
|
||||
List<MvwSitArtUdcDetInventarioDTO> giacenzeArticolo = Stream.of(results).filter(x -> x.getCodMart().equalsIgnoreCase(codMart)).toList();
|
||||
List<MvwSitArtUdcDetInventarioDTO> giacenzeArticolo = results.stream()
|
||||
.filter(x -> x.getCodMart().equalsIgnoreCase(codMart))
|
||||
.collect(Collectors.toList());
|
||||
if (giacenzeArticolo.isEmpty()) {
|
||||
anomalieList.add(AnomalieDTO.warning("Non è stato possibile scaricare la quantita di materia prima dell'articolo " + codMart + ". "));
|
||||
continue; //throw new Exception("Non è stato trovato alcun articolo in giacenza");
|
||||
@@ -2017,7 +2027,7 @@ public class WMSGenericService {
|
||||
UtilityEntity.throwEntitiesException(entitiesToSave);
|
||||
}
|
||||
|
||||
public void spostaUL(SpostaUlRequestDTO requestDTO) throws Exception {
|
||||
public MtbColt spostaUL(SpostaUlRequestDTO requestDTO) throws Exception {
|
||||
if (UtilityString.isNullOrEmpty(requestDTO.getCodMdep()))
|
||||
throw new Exception("Nessun deposito di arrivo selezionato");
|
||||
|
||||
@@ -2040,9 +2050,9 @@ public class WMSGenericService {
|
||||
|
||||
boolean gestisciColli = WMSUtility.isGestisciColli(mtbDepo, entityProcessor, multiDBTransactionManager);
|
||||
|
||||
MtbDepoPosizioni mtbDepoPosizioni = new MtbDepoPosizioni();
|
||||
if (!UtilityString.isNullOrEmpty(requestDTO.getPosizione())) {
|
||||
MtbDepoPosizioni mtbDepoPosizioni = new MtbDepoPosizioni()
|
||||
.setCodMdep(requestDTO.getCodMdep())
|
||||
mtbDepoPosizioni.setCodMdep(requestDTO.getCodMdep())
|
||||
.setPosizione(requestDTO.getPosizione());
|
||||
mtbDepoPosizioni.setOperation(OperationType.SELECT_OBJECT);
|
||||
|
||||
@@ -2060,7 +2070,7 @@ public class WMSGenericService {
|
||||
String codDtipToUse = setupGest.getSetupDepo(multiDBTransactionManager.getPrimaryConnection(), "PICKING", "LOGISTICA", "COD_DTIP_DOC_TRASF_INTERNI", requestDTO.getCodMdep());
|
||||
|
||||
if (UtilityString.isNullOrEmpty(codDtipToUse))
|
||||
throw new Exception("La configurazione della setup gest non è completa per gestire gli spostamenti tra depositi");
|
||||
throw new GestSetupNotFoundException("PICKING", "LOGISTICA", "COD_DTIP_DOC_TRASF_INTERNI");
|
||||
|
||||
String codAnag = mtbDepo.getCodAnag();
|
||||
String codVdes = mtbDepo.getCodVdes();
|
||||
@@ -2092,6 +2102,9 @@ public class WMSGenericService {
|
||||
.setCodMdep(codMdepDoc)
|
||||
.setCodVdes(codVdes)
|
||||
.setCodAnag(codAnag)
|
||||
.setDataDoc(requestDTO.getDataTrasf())
|
||||
.setNumDoc(requestDTO.getNumTrasf())
|
||||
.setCodVvet(requestDTO.getCodVvet())
|
||||
.setAnnotazioni(requestDTO.getAnnotazioni())
|
||||
.setCodDtip(codDtipToUse);
|
||||
|
||||
@@ -2155,13 +2168,19 @@ public class WMSGenericService {
|
||||
WMSUtility.trasferisciPedane(mtbColtToMove, listaPedane, dtbDoct);
|
||||
}
|
||||
|
||||
mtbColtToMove.setOperation(OperationType.UPDATE);
|
||||
mtbColtToMove
|
||||
.setMtbColr(new ArrayList<>())
|
||||
.setPosizione(UtilityString.isNull(requestDTO.getPosizione(), EmsRestConstants.NULL))
|
||||
.setCodMdep(requestDTO.getCodMdep());
|
||||
if (!UtilityString.isNullOrEmpty(mtbDepoPosizioni.getPosizione()) && mtbDepoPosizioni.isFlagMonoCollo()) {
|
||||
MtbColt ulMonocollo = WMSUtility.getUlPosizioneMonoUl(multiDBTransactionManager.getPrimaryConnection(),mtbDepoPosizioni.getPosizione());
|
||||
WMSUtility.spostaArtsTraUL(multiDBTransactionManager.getPrimaryConnection(), mtbColtToMove, ulMonocollo, false, entityProcessor, requestDataDTO);
|
||||
} else {
|
||||
|
||||
mtbColtToMove.setOperation(OperationType.UPDATE);
|
||||
mtbColtToMove
|
||||
.setMtbColr(new ArrayList<>())
|
||||
.setPosizione(UtilityString.isNull(requestDTO.getPosizione(), EmsRestConstants.NULL))
|
||||
.setCodMdep(requestDTO.getCodMdep());
|
||||
entitiesToSave.add(mtbColtToMove);
|
||||
}
|
||||
|
||||
entitiesToSave.add(mtbColtToMove);
|
||||
}
|
||||
|
||||
if (dtbDoct != null && !UtilityString.isNullOrEmpty(requestDTO.getAnnotazioni())) {
|
||||
@@ -2175,6 +2194,8 @@ public class WMSGenericService {
|
||||
|
||||
entityProcessor.processEntityList(entitiesToSave, true);
|
||||
UtilityEntity.throwEntitiesException(entitiesToSave);
|
||||
|
||||
return mtbCotlList.stream().findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public void spostaULInPosizione(MtbColt mtbColtToMove, MtbDepoPosizioni mtbDepoPosizioni) throws Exception {
|
||||
@@ -2509,7 +2530,7 @@ public class WMSGenericService {
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
List<MtbAart> mtbAarts = WMSUtility.getArticoliByCodMarts(codMarts, multiDBTransactionManager.getPrimaryConnection());
|
||||
List<MtbAart> mtbAarts = MtbAartUtils.getArticoliByCodMarts(codMarts, multiDBTransactionManager.getPrimaryConnection());
|
||||
|
||||
List<MtbColt> mtbColtToSave = new ArrayList<>();
|
||||
List<MtbColr> successMtbColr = new ArrayList<>();
|
||||
@@ -3088,4 +3109,59 @@ public class WMSGenericService {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void resettaPosizioniMonoUL(MultiDBTransactionManager multiDBTransactionManager, EntityProcessor entityProcessor) throws Exception {
|
||||
List<MtbDepoPosizioni> posizioniMonoUL = MtbDepoPosizioniUtils.getAllMonoUlPositions(multiDBTransactionManager.getPrimaryConnection().getIntegryCustomerDB());
|
||||
|
||||
try {
|
||||
for (MtbDepoPosizioni posizione : posizioniMonoUL) {
|
||||
final List<MtbColt> oldUdcs = getULInPosizione(posizione, false);
|
||||
|
||||
if (oldUdcs == null)
|
||||
continue;
|
||||
|
||||
oldUdcs.removeIf(ul -> ul.getSegno() != 1); //consider only Lavorazione UDCs
|
||||
|
||||
|
||||
if (oldUdcs.isEmpty()) {
|
||||
//skip position
|
||||
continue;
|
||||
} else if (oldUdcs.size() > 1) {
|
||||
throw new Exception("Posizione " + posizione.getPosizione() + " contiene più di una UDC in una posizione mono UL");
|
||||
}
|
||||
final MtbColt newUdc = wmsLavorazioneService.createUDC(new CreateUDCRequestDTO()
|
||||
.setCodMdep(posizione.getCodMdep())
|
||||
.setPosizione(posizione.getPosizione()));
|
||||
|
||||
final MtbColt oldUdc = oldUdcs.get(0);
|
||||
|
||||
final List<MvwSitArtUdcDetInventarioDTO> giacenzaItems = wmsGiacenzaULService.retrieveArtsInGiacenzaByPosition(multiDBTransactionManager.getPrimaryConnection(), posizione.getPosizione());
|
||||
|
||||
if (giacenzaItems != null) {
|
||||
oldUdc.setMtbColr(WMSUtility.convertMvwItemsToMtbColrs(giacenzaItems));
|
||||
|
||||
WMSUtility.spostaArtsTraUL(multiDBTransactionManager.getPrimaryConnection(),
|
||||
oldUdc, newUdc, false, entityProcessor, RequestDataDTO.systemMockupData());
|
||||
|
||||
}
|
||||
|
||||
//remove position from old UL
|
||||
UtilityDB.executeStatement(multiDBTransactionManager.getPrimaryConnection(),
|
||||
"UPDATE mtb_colt SET posizione = NULL " +
|
||||
"WHERE gestione = " + UtilityDB.valueToString(oldUdc.getGestione()) + " " +
|
||||
"AND data_collo = " + UtilityDB.valueToString(oldUdc.getDataCollo()) + " " +
|
||||
"AND ser_collo = " + UtilityDB.valueToString(oldUdc.getSerCollo()) + " " +
|
||||
"AND num_collo = " + UtilityDB.valueToString(oldUdc.getNumCollo())
|
||||
);
|
||||
|
||||
//save all
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
multiDBTransactionManager.rollbackAll();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@ import it.integry.ems.product.importaz.service.ProductServices;
|
||||
import it.integry.ems.retail.pvmRetail.dto.PvmArticoliChildDTO;
|
||||
import it.integry.ems.retail.pvmRetail.dto.PvmArticoliDTO;
|
||||
import it.integry.ems.retail.pvmRetail.service.PvmService;
|
||||
import it.integry.ems.retail.wms.Utility.WMSUtility;
|
||||
import it.integry.ems.retail.wms.inventario.dto.InventarioArtDTO;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityDirs;
|
||||
import it.integry.ems.utility.UtilityFile;
|
||||
import it.integry.ems.utility.entity.MtbUntMisUtils;
|
||||
import it.integry.ems_model.entity.MtbInvenr;
|
||||
import it.integry.ems_model.entity.MtbInvent;
|
||||
import it.integry.ems_model.entity.MtbUntMis;
|
||||
@@ -136,7 +136,7 @@ public class WMSInventarioService {
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
final List<MtbUntMis> untMisFromCod = WMSUtility.getUntMisFromCod(untMiss,multiDBTransactionManager.getPrimaryConnection());
|
||||
final List<MtbUntMis> untMisFromCod = MtbUntMisUtils.getFromCods(untMiss, multiDBTransactionManager.getPrimaryConnection());
|
||||
|
||||
for (InventarioArtDTO art : arts) {
|
||||
final MtbUntMis mtbUntMis = untMisFromCod.stream().filter(x -> x.getUntMis().equalsIgnoreCase(art.getUntMis()))
|
||||
|
||||
@@ -23,6 +23,7 @@ import it.integry.ems.service.production.ProductionOrderDataHandlerService;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.user.UserSession;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems.utility.entity.MtbAartUtils;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.entity._enum.GestioneEnum;
|
||||
@@ -264,7 +265,7 @@ public class WMSLavorazioneService {
|
||||
entityProcessor.processEntity(targetMtbColt, true, multiDBTransactionManager);
|
||||
|
||||
|
||||
MtbAart mtbAart = WMSUtility.getArticoloByCodMart(insertUDSRowRequestDTO.getCodMart(), multiDBTransactionManager.getPrimaryConnection());
|
||||
MtbAart mtbAart = MtbAartUtils.getArticoloByCodMart(insertUDSRowRequestDTO.getCodMart(), multiDBTransactionManager.getPrimaryConnection());
|
||||
if (mtbAart == null)
|
||||
throw new InvalidArticoloException(insertUDSRowRequestDTO.getCodMart());
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.user.UserSession;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems.utility.entity.MtbAartUtils;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
@@ -93,7 +94,7 @@ public class WMSMaterialiService {
|
||||
if (!versamentoDirettoEnabled) {
|
||||
MvwSitArtUdcDetInventarioDTO itemDaVersare = artsInGiacenza.get(0);
|
||||
|
||||
MtbAart mtbAart = WMSUtility.getArticoloByCodMart(itemDaVersare.getCodMart(), multiDBTransactionManager.getPrimaryConnection());
|
||||
MtbAart mtbAart = MtbAartUtils.getArticoloByCodMart(itemDaVersare.getCodMart(), multiDBTransactionManager.getPrimaryConnection());
|
||||
if (mtbAart == null)
|
||||
throw new InvalidArticoloException(request.getCodMart());
|
||||
|
||||
@@ -134,7 +135,7 @@ public class WMSMaterialiService {
|
||||
// throw new Exception("Impossibile recuperare le informazioni della posizione (" + request.getPosizioneVersamento() + ")");
|
||||
//
|
||||
// for(MvwSitArtUdcDetInventarioDTO artInGiacenza : artsInGiacenza) {
|
||||
// final MtbAart currentArtAnag = WMSUtility.getArticoloByCodMart(artInGiacenza.getCodMart(), multiDBTransactionManager.getPrimaryConnection());
|
||||
// final MtbAart currentArtAnag = MtbAartUtils.getArticoloByCodMart(artInGiacenza.getCodMart(), multiDBTransactionManager.getPrimaryConnection());
|
||||
//
|
||||
// if(currentArtAnag == null)
|
||||
// continue;
|
||||
@@ -275,7 +276,7 @@ public class WMSMaterialiService {
|
||||
final boolean versamentoDirettoEnabled = setupGest.getSetupBoolean(multiDBTransactionManager.getPrimaryConnection(), "PICKING", "PRODUZIONE", "FLAG_VERSAMENTO_DIRETTO");
|
||||
final boolean forceAllToColli = setupGest.getSetupBoolean(multiDBTransactionManager.getPrimaryConnection(), "PICKING", "SETUP", "FLAG_FORCE_ALL_TO_COLLI");
|
||||
|
||||
MtbAart mtbAart = WMSUtility.getArticoloByCodMart(request.getCodMart(), multiDBTransactionManager.getPrimaryConnection());
|
||||
MtbAart mtbAart = MtbAartUtils.getArticoloByCodMart(request.getCodMart(), multiDBTransactionManager.getPrimaryConnection());
|
||||
if (mtbAart == null)
|
||||
throw new InvalidArticoloException(request.getCodMart());
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.user.UserSession;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems.utility.entity.MtbAartUtils;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.entity.DtbOrdt;
|
||||
import it.integry.ems_model.entity.MtbAart;
|
||||
@@ -244,7 +245,7 @@ public class WMSSpedizioneService {
|
||||
entityProcessor.processEntity(targetMtbColt, multiDBTransactionManager);
|
||||
|
||||
|
||||
MtbAart mtbAart = WMSUtility.getArticoloByCodMart(insertUDSRowRequestDTO.getCodMart(), multiDBTransactionManager.getPrimaryConnection());
|
||||
MtbAart mtbAart = MtbAartUtils.getArticoloByCodMart(insertUDSRowRequestDTO.getCodMart(), multiDBTransactionManager.getPrimaryConnection());
|
||||
if (mtbAart == null)
|
||||
throw new InvalidArticoloException(insertUDSRowRequestDTO.getCodMart());
|
||||
|
||||
|
||||
@@ -106,6 +106,7 @@ public class ExchangeArticoliImportService {
|
||||
x.getMtbAartBarCode().forEach(y -> y.setOperation(y.getOperation() == OperationType.INSERT ? OperationType.INSERT_OR_UPDATE : y.getOperation()));
|
||||
x.getMtbAartCarat().forEach(y -> y.setOperation(y.getOperation() == OperationType.INSERT ? OperationType.INSERT_OR_UPDATE : y.getOperation()));
|
||||
x.getMtbAartColori().forEach(y -> y.setOperation(y.getOperation() == OperationType.INSERT ? OperationType.INSERT_OR_UPDATE : y.getOperation()));
|
||||
x.getMtbAartDesc().forEach(y -> y.setOperation(y.getOperation() == OperationType.INSERT ? OperationType.INSERT_OR_UPDATE : y.getOperation()));
|
||||
});
|
||||
|
||||
final Exception[] firstExceptionToThrow = {null};
|
||||
@@ -150,6 +151,7 @@ public class ExchangeArticoliImportService {
|
||||
final List<MtbAartBarCode> mtbAartBarCode = retrieveMtbAartBarcode(connection, retrieveAlreadyImported, useTempTable);
|
||||
final List<MtbAartColori> mtbAartColori = retrieveMtbAartColori(connection, retrieveAlreadyImported, useTempTable);
|
||||
final List<MtbAartCarat> mtbAartCarat = retrieveMtbAartCarat(connection, retrieveAlreadyImported, useTempTable);
|
||||
final List<MtbAartDesc> mtbAartDesc = retrieveMtbAartDesc(connection, retrieveAlreadyImported, useTempTable);
|
||||
|
||||
mtbAart
|
||||
.parallelStream()
|
||||
@@ -162,6 +164,10 @@ public class ExchangeArticoliImportService {
|
||||
.filter(y -> y.getCodMart().equalsIgnoreCase(x.getCodMart()))
|
||||
.collect(Collectors.toList()))
|
||||
.setMtbAartCarat(mtbAartCarat.stream()
|
||||
.map(y -> y)
|
||||
.filter(y -> y.getCodMart().equalsIgnoreCase(x.getCodMart()))
|
||||
.collect(Collectors.toList()))
|
||||
.setMtbAartDesc(mtbAartDesc.stream()
|
||||
.map(y -> y)
|
||||
.filter(y -> y.getCodMart().equalsIgnoreCase(x.getCodMart()))
|
||||
.collect(Collectors.toList())));
|
||||
@@ -178,13 +184,38 @@ public class ExchangeArticoliImportService {
|
||||
|
||||
exchangeImportDataManagerService.updateImportedStatus(connection, "mtb_aart", importedKey, useTempTable);
|
||||
|
||||
final List<HashMap<String, Object>> importedMtbSgrpKeys = importedMtbAart.getMtbAartColori().stream()
|
||||
final List<HashMap<String, Object>> importedMtbAartColori = importedMtbAart.getMtbAartColori().stream()
|
||||
.map(x -> new HashMap<String, Object>() {{
|
||||
put("cod_col", x.getCodCol());
|
||||
}})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
exchangeImportDataManagerService.updateImportedStatus(connection, "mtb_aart_colori", importedMtbSgrpKeys, useTempTable);
|
||||
exchangeImportDataManagerService.updateImportedStatus(connection, "mtb_aart_colori", importedMtbAartColori, useTempTable);
|
||||
|
||||
final List<HashMap<String, Object>> importedMtbAartCarat = importedMtbAart.getMtbAartCarat().stream()
|
||||
.map(x -> new HashMap<String, Object>() {{
|
||||
put("carat", x.getCarat());
|
||||
}})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
exchangeImportDataManagerService.updateImportedStatus(connection, "mtb_aart_carat", importedMtbAartCarat, useTempTable);
|
||||
|
||||
final List<HashMap<String, Object>> importedMtbAartBarcode = importedMtbAart.getMtbAartBarCode().stream()
|
||||
.map(x -> new HashMap<String, Object>() {{
|
||||
put("cod_barre", x.getCodBarre());
|
||||
}})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
exchangeImportDataManagerService.updateImportedStatus(connection, "mtb_aart_bar_code", importedMtbAartBarcode, useTempTable);
|
||||
|
||||
|
||||
final List<HashMap<String, Object>> importedMtbAartDesc = importedMtbAart.getMtbAartDesc().stream()
|
||||
.map(x -> new HashMap<String, Object>() {{
|
||||
put("cod_lingua", x.getCodLingua());
|
||||
}})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
exchangeImportDataManagerService.updateImportedStatus(connection, "mtb_aart_desc", importedMtbAartDesc, useTempTable);
|
||||
}
|
||||
|
||||
|
||||
@@ -677,7 +708,7 @@ public class ExchangeArticoliImportService {
|
||||
false, useTempTable);
|
||||
|
||||
List<EquatableEntityInterface> allData = exchangeImportDataManagerService
|
||||
.runSync(MtbAartMarchio.class, exchangeImportedData, exchangeUpdatedData);
|
||||
.runSync(MtbTipi.class, exchangeImportedData, exchangeUpdatedData);
|
||||
|
||||
allData.forEach(x -> x.setOperation(x.getOperation() == OperationType.INSERT ? OperationType.INSERT_OR_UPDATE : x.getOperation()));
|
||||
|
||||
@@ -993,5 +1024,22 @@ public class ExchangeArticoliImportService {
|
||||
tableName, null, retrieveAlreadyImported);
|
||||
}
|
||||
|
||||
private List<MtbAartDesc> retrieveMtbAartDesc(Connection connection, boolean retrieveAlreadyImported, boolean useTempTable) throws Exception {
|
||||
String originalTableName = "mtb_aart_desc";
|
||||
String tableName = originalTableName + (useTempTable ? "_tmp" : "");
|
||||
|
||||
|
||||
if (useTempTable) {
|
||||
UtilityDB.executeStatement(connection,
|
||||
"INSERT INTO " + tableName +
|
||||
" SELECT * FROM " + originalTableName
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return exchangeImportDataManagerService.retrieveDataFromExchange(connection, MtbAartDesc.class,
|
||||
tableName, null, retrieveAlreadyImported);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -108,6 +108,7 @@ public class ExchangeImportSchemaManagerService {
|
||||
put("mtb_aart_bar_code", MtbAartBarCode.class);
|
||||
put("mtb_aart_carat", MtbAartCarat.class);
|
||||
put("mtb_aart_equi", MtbAartEqui.class);
|
||||
put("mtb_aart_desc", MtbAartDesc.class);
|
||||
}});
|
||||
put(SchemaType.PartiteMagazzinoLavorazione, new HashMap<String, Class<? extends EntityInterface>>() {{
|
||||
put("mtb_partita_mag_lav", MtbPartitaMag.class);
|
||||
|
||||
5
ems-engine/src/main/resources/configs/jpa.properties
Normal file
5
ems-engine/src/main/resources/configs/jpa.properties
Normal file
@@ -0,0 +1,5 @@
|
||||
hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
|
||||
hibernate.show_sql=false
|
||||
hibernate.format_sql=false
|
||||
hibernate.hbm2ddl.auto=none
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd">
|
||||
<context:component-scan base-package="it.integry"/>
|
||||
|
||||
<import resource="hibernate-context.xml"/>
|
||||
|
||||
<bean id="ppConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="ignoreUnresolvablePlaceholders" value="false"/>
|
||||
<property name="locations">
|
||||
|
||||
54
ems-engine/src/main/resources/spring/hibernate-context.xml
Normal file
54
ems-engine/src/main/resources/spring/hibernate-context.xml
Normal file
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/data/jpa
|
||||
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
|
||||
http://www.springframework.org/schema/tx
|
||||
http://www.springframework.org/schema/tx/spring-tx.xsd">
|
||||
|
||||
<!-- MultiTenant DataSource -->
|
||||
<bean id="multiTenantDataSource" class="it.integry.ems.jpa.MultiTenantDataSource">
|
||||
<constructor-arg ref="basicConnectionPool"/>
|
||||
<constructor-arg ref="settingsModel"/>
|
||||
</bean>
|
||||
|
||||
<!-- JPA EntityManagerFactory -->
|
||||
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
|
||||
<property name="dataSource" ref="multiTenantDataSource"/>
|
||||
<property name="packagesToScan">
|
||||
<list>
|
||||
<value>it.integry.ems_model.entity</value>
|
||||
</list>
|
||||
</property>
|
||||
<property name="jpaVendorAdapter">
|
||||
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
|
||||
<property name="showSql" value="false"/>
|
||||
<property name="generateDdl" value="false"/> <!-- Disabilitato per sicurezza su DB esistenti -->
|
||||
</bean>
|
||||
</property>
|
||||
<property name="jpaProperties">
|
||||
<props>
|
||||
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
|
||||
<prop key="hibernate.temp.use_jdbc_metadata_defaults">false</prop> <!-- Per startup più veloce -->
|
||||
<prop key="hibernate.jdbc.lob.non_contextual_creation">true</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Transaction Manager -->
|
||||
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
|
||||
<property name="entityManagerFactory" ref="entityManagerFactory"/>
|
||||
</bean>
|
||||
|
||||
<!-- Abilita i repository JPA -->
|
||||
<jpa:repositories base-package="it.integry.ems.jpa.repository"/>
|
||||
|
||||
<!-- Abilita la gestione delle transazioni tramite annotazioni -->
|
||||
<tx:annotation-driven transaction-manager="transactionManager"/>
|
||||
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user