importazione trasferimenti slim
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
This commit is contained in:
@@ -11,6 +11,7 @@ public class Migration_20241014121636 extends BaseMigration implements Migration
|
||||
return;
|
||||
|
||||
if (!isTextiles()) return;
|
||||
|
||||
createOrUpdateView("tvvw_ordv_linee", "CREATE view [dbo].[tvvw_ordv_linee] as \n" +
|
||||
"select dtb_ordt.gestione, \n" +
|
||||
"dtb_ordt.data_ord,\n" +
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
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_20241115122521 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetupQuery(null, null, "select section from dbo.getImportProperties('colli', null) where attivo = 'S'");
|
||||
createSetup("pvm", "DOC_INTERNI", "IMPORT_TRASFERIMENTI", null,
|
||||
"inserire il formato del trasferimento", false, null, false, true,
|
||||
false, false, false, null, false, "select section from dbo.getImportProperties('colli', null) where attivo = 'S'");
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Carelli_Format)) {
|
||||
executeStatement(
|
||||
"INSERT INTO stb_gest_setup_depo\n" +
|
||||
"select depo.cod_mdep, gest_name, section, key_section, 'SLIM2K', flag_sync\n" +
|
||||
"from (\n" +
|
||||
"select gest_name, section, key_section, flag_sync\n" +
|
||||
"from stb_gest_setup \n" +
|
||||
"where gest_name = 'PVM' AND section = 'DOC_INTERNI' AND key_section = 'IMPORT_TRASFERIMENTI' ) setup\n" +
|
||||
"cross apply (select *\n" +
|
||||
"from mtb_depo where cod_mdep in ('07','01')) depo\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
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_20241115123316 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetup("IMPORT_COLLI", "SLIM2K", "COD_DTIP_TRASF", null,
|
||||
null, false, null, false, true,
|
||||
false, false, false, null, false, null);
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Carelli_Format)) {
|
||||
executeStatement(
|
||||
"INSERT INTO stb_gest_setup_depo\n" +
|
||||
"select depo.cod_mdep, gest_name, section, key_section, 'DDTTR', flag_sync\n" +
|
||||
"from (\n" +
|
||||
"select gest_name, section, key_section, flag_sync\n" +
|
||||
"from stb_gest_setup \n" +
|
||||
"where gest_name = 'IMPORT_COLLI' AND section = 'SLIM2K' AND key_section = 'COD_DTIP_TRASF' ) setup\n" +
|
||||
"cross apply (select *\n" +
|
||||
"from mtb_depo where cod_mdep in ('07','01')) depo\n");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -847,6 +847,9 @@ public class CommonRules extends QueryRules {
|
||||
MtbAart mtbAart = new ResultSetMapper()
|
||||
.mapQueryToObject(connection, sql, MtbAart.class);
|
||||
|
||||
if (mtbAart == null )
|
||||
throw new Exception(String.format("Codice Articolo %s non trovato", mtbColr.getCodMart()));
|
||||
|
||||
qtaCnf = DocOrdUntMisRules.calcQtaCnf(connection, mtbColr.getCodMart(), mtbColr.getPartitaMag(), mtbAart, mtbColr.getNumCnf(), BigDecimal.ONE, mtbColr.getQtaCol(), mtbColr.getQtaCnf());
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.lang.reflect.Field;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
|
||||
import java.sql.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -358,9 +359,8 @@ public class UtilityDB {
|
||||
return valueString;
|
||||
}
|
||||
|
||||
public static String listValueToString(List<String> lista) {
|
||||
lista = Stream.of(lista).map(UtilityDB::valueToString).toList();
|
||||
return StringUtils.join(lista, ",");
|
||||
public static <T> String listValueToString(List<T> lista) {
|
||||
return StringUtils.join(Stream.of(lista).map(UtilityDB::valueToString).toList(), ",");
|
||||
}
|
||||
|
||||
public static int countRow(ResultSet res) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import it.integry.ems.logistic.Import.service.*;
|
||||
import it.integry.ems.logistic.service.ColliBaioneImportService;
|
||||
import it.integry.ems.logistic.service.ColliEviosysImportService;
|
||||
import it.integry.ems.logistic.service.ColliImportService;
|
||||
import it.integry.ems.logistic.service.Slim2kLogisticService;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
@@ -62,6 +63,9 @@ public class ColliImporter extends BaseEntityImporter implements IEntityImporter
|
||||
case PIEGARESE:
|
||||
entities = context.getBean(ColliImportService.class).importColliVebad(type, format, requestDto, anomalie);
|
||||
break;
|
||||
case SLIM2K:
|
||||
entities = context.getBean(Slim2kLogisticService.class).importTrasferimenti(type, format);
|
||||
break;
|
||||
default:
|
||||
throw new Exception(String.format("Tipo %s non supportato", format));
|
||||
}
|
||||
@@ -83,7 +87,8 @@ public class ColliImporter extends BaseEntityImporter implements IEntityImporter
|
||||
METALSISTEM("METALSISTEM"),
|
||||
BAIONE("BAIONE"),
|
||||
EVIOSYS("EVIOSYS"),
|
||||
PIEGARESE("DESADV");
|
||||
PIEGARESE("DESADV"),
|
||||
SLIM2K("SLIM2K");
|
||||
|
||||
private String text;
|
||||
|
||||
|
||||
@@ -72,5 +72,4 @@ public class Slim2kLogisticController {
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
package it.integry.ems.logistic.service;
|
||||
|
||||
import it.integry.ems.Import.dto.AnomalieDTO;
|
||||
import it.integry.ems.Import.dto.ImportRequestDTO;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.menu.dto.StbMenuDTO;
|
||||
import it.integry.ems.properties.EmsProperties;
|
||||
import it.integry.ems.response.EsitoType;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.service.MailService;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.user.UserSession;
|
||||
import it.integry.ems.utility.UtilityDirs;
|
||||
import it.integry.ems.utility.UtilityFile;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
@@ -16,10 +21,8 @@ import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.resolver.SqlFieldHolder;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||
import it.integry.ems_model.utility.UtilityResultSet;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import it.integry.ems_model.utility.*;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -36,24 +39,27 @@ import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.stream.Collectors.groupingBy;
|
||||
|
||||
@Service
|
||||
@Scope("request")
|
||||
public class Slim2kLogisticService {
|
||||
@Autowired
|
||||
private EmsProperties properties;
|
||||
|
||||
@Autowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
|
||||
@Autowired
|
||||
private SetupGest setupGest;
|
||||
@Autowired
|
||||
private ResponseJSONObjectMapper jsonObjectMapper;
|
||||
|
||||
@Autowired
|
||||
private MailService mailService;
|
||||
|
||||
@Autowired
|
||||
private EntityProcessor entityProcessor;
|
||||
|
||||
@Autowired
|
||||
private UserSession userSession;
|
||||
|
||||
// IMPORTAZIONE COLLI DI VENDITA DA SHIPPINGPLAN_EXPORT
|
||||
public List<ServiceRestResponse> importListeDiScarico(String listType, String listCode) throws Exception {
|
||||
List<ServiceRestResponse> respList = new ArrayList<ServiceRestResponse>();
|
||||
@@ -272,6 +278,131 @@ public class Slim2kLogisticService {
|
||||
return respList;
|
||||
}
|
||||
|
||||
public List<EntityBase> importTrasferimenti(String type, String format) throws Exception {
|
||||
if ( userSession.getDefaultDepo() == null )
|
||||
throw new Exception(String.format("Nessun deposito trovato per l'utente %s", userSession.getUsername()));
|
||||
|
||||
String codMdep = userSession.getDefaultDepo().getCodMdep();
|
||||
Map<String, String> setup = setupGest.getImportSetupSection(multiDBTransactionManager.getPrimaryConnection(), type, format);
|
||||
String profileSlim2k = setup.get("PROFILE");
|
||||
|
||||
if (UtilityString.isNullOrEmpty(profileSlim2k)) {
|
||||
throw new Exception("Profile non configurato per la procedura di importazione liste di scarico SLIM2K");
|
||||
}
|
||||
|
||||
String codDtip = setupGest.getSetupDepo("IMPORT_"+type, format, "COD_DTIP_TRASF", codMdep);
|
||||
if ( UtilityString.isNullOrEmpty(codDtip) )
|
||||
throw new Exception(String.format("Tipo documento non confiutrato per il deposito %s", userSession.getUsername()));
|
||||
|
||||
List<EntityBase> colli = new ArrayList<>();
|
||||
DataSource dsSlim2k = new DataSource();
|
||||
try {
|
||||
dsSlim2k.initialize(profileSlim2k);
|
||||
|
||||
LocalDate today = UtilityLocalDate.getNow();
|
||||
|
||||
String sql =
|
||||
Query.format(
|
||||
"SELECT track_number\n" +
|
||||
"FROM mtb_colt\n" +
|
||||
"WHERE cod_mdep = %s\n" +
|
||||
" AND data_collo = %s\n" +
|
||||
" AND track_number IS NOT NULL",
|
||||
codMdep, today);
|
||||
|
||||
List<Integer> listTrackNumber = UtilityDB.executeSimpleQueryOnlyFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
sql =
|
||||
Query.format(
|
||||
"SELECT e.whouse AS cod_dest,\n" +
|
||||
" movements_export.whouse AS cod_mdep,\n" +
|
||||
" movements_export.item AS cod_mart,\n" +
|
||||
" movements_export.workorder AS lotto,\n" +
|
||||
" ABS(movements_export.qtymove) AS qta_collo,\n" +
|
||||
" movements_export.unum as track_number\n"+
|
||||
"FROM movements_export\n" +
|
||||
" INNER JOIN movements_export e ON movements_export.item = e.item\n" +
|
||||
" AND movements_export.trtype = e.trtype\n" +
|
||||
" AND movements_export.movedate = e.movedate\n" +
|
||||
" AND movements_export.whouse <> e.whouse\n" +
|
||||
" AND movements_export.workorder = e.workorder\n" +
|
||||
" AND movements_export.utime = e.utime\n" +
|
||||
"WHERE movements_export.movedate = %s\n" +
|
||||
" AND movements_export.qtymove < 0\n" +
|
||||
" AND movements_export.trtype LIKE (%s)\n" +
|
||||
" AND movements_export.whouse = %s \n",
|
||||
UtilityLocalDate.formatDate(today, "yyyyMMdd") , "W%", codMdep);
|
||||
|
||||
if ( !listTrackNumber.isEmpty()) {
|
||||
sql += " AND movements_export.unum not in ( " + UtilityDB.listValueToString(listTrackNumber) + " )";
|
||||
}
|
||||
|
||||
List<HashMap<String, Object>> listaColli = UtilityDB.executeSimpleQuery(dsSlim2k.getConnection(), sql);
|
||||
|
||||
Map<HashMap<String, Object>, List<HashMap<String, Object>>> trackNumber = listaColli.stream()
|
||||
.collect(groupingBy(x -> {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("track_number", x.get("track_number"));
|
||||
map.put("cod_mdep", x.get("cod_mdep"));
|
||||
map.put("cod_dest", x.get("cod_dest"));
|
||||
return map;
|
||||
}));
|
||||
|
||||
for (Map.Entry<HashMap<String, Object>, List<HashMap<String, Object>>> entry : trackNumber.entrySet()) {
|
||||
HashMap<String, Object> keyMap = entry.getKey();
|
||||
List<HashMap<String, Object>> righe = entry.getValue();
|
||||
|
||||
String codDest = (String) keyMap.get("cod_dest");
|
||||
|
||||
sql =
|
||||
Query.format(
|
||||
"SELECT cod_anag, cod_vdes FROM mtb_depo WHERE cod_mdep = %s AND cod_anag is not null",
|
||||
codDest.trim());
|
||||
|
||||
HashMap<String, Object> datiDepo = UtilityDB.executeSimpleQueryOnlyFirstRow(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
if (!UtilityHashMap.isPresent(datiDepo) )
|
||||
throw new Exception(String.format("Dati non trovati per il deposito %s", codDest));
|
||||
|
||||
MtbColt mtbColt =
|
||||
new MtbColt()
|
||||
.setDataCollo(today)
|
||||
.setCodMdep((String) keyMap.get("cod_mdep"))
|
||||
.setCodAnag((String) datiDepo.get("cod_anag"))
|
||||
.setCodVdes((String) datiDepo.get("cod_vdes"))
|
||||
.setGestione("L")
|
||||
.setTrackNumber(keyMap.get("track_number").toString())
|
||||
.setCodDtipProvv(codDtip);
|
||||
mtbColt.setOperation(OperationType.INSERT);
|
||||
mtbColt.setMtbColr(new ArrayList<>());
|
||||
colli.add(mtbColt);
|
||||
|
||||
|
||||
for (HashMap<String, Object> r : righe){
|
||||
MtbColr mtbColr =
|
||||
new MtbColr()
|
||||
.setCodMart(((String) r.get("cod_mart")).trim())
|
||||
.setPartitaMag(((String) r.get("lotto")).trim())
|
||||
.setQtaCol((BigDecimal) r.get("qta_collo"));
|
||||
mtbColt.getMtbColr().add(mtbColr);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (colli.size() > 0 ) {
|
||||
return entityProcessor.processEntityList(colli, false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
} finally {
|
||||
if (!dsSlim2k.isClosed()) {
|
||||
dsSlim2k.forceClose();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// IMPORTAZIONE COLLI DI VENDITA DA DOCUMENTS_EXPORT
|
||||
public List<ServiceRestResponse> importListeDiCarico(String scode, String dcode, String docDate, String docnum, String refdoc) throws Exception {
|
||||
Date ldt_dataOrd;
|
||||
|
||||
Reference in New Issue
Block a user