Merge remote-tracking branch 'origin/feature/RefactoringGestioneColli' into feature/RefactoringGestioneColli
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:
@@ -132,7 +132,7 @@ public class DbmsChangeTracker {
|
||||
|
||||
final List<String> trackedTables = retrieveTrackedTables();
|
||||
|
||||
HashMap<Long, DetectedChangeDataDTO> changesByVersion = new HashMap<>();
|
||||
HashMap<Long, List<DetectedChangeDataDTO>> changesByVersion = new HashMap<>();
|
||||
|
||||
for (String trackedTable : trackedTables) {
|
||||
long minValidVersion = getMinValidVersion(trackedTable);
|
||||
@@ -140,13 +140,12 @@ public class DbmsChangeTracker {
|
||||
throw new SQLException("Change Tracking on table " + trackedTable + " has been reset. Current version: " + currentVersion + ", Min valid version: " + minValidVersion);
|
||||
}
|
||||
|
||||
|
||||
final List<DetectedChangeDataDTO> detectedChanges = retrieveChangeList(trackedTable);
|
||||
|
||||
detectedChanges.forEach(detectedChangeDataDTO -> {
|
||||
changesByVersion.put(detectedChangeDataDTO.getSysChangeVersion(), detectedChangeDataDTO);
|
||||
changesByVersion.putIfAbsent(detectedChangeDataDTO.getSysChangeVersion(), new ArrayList<>());
|
||||
changesByVersion.get(detectedChangeDataDTO.getSysChangeVersion()).add(detectedChangeDataDTO);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
logTrace("Detected " + changesByVersion.size() + " changes since version " + currentVersion);
|
||||
@@ -154,32 +153,33 @@ public class DbmsChangeTracker {
|
||||
dispatchChanges(changesByVersion);
|
||||
}
|
||||
|
||||
private void dispatchChanges(HashMap<Long, DetectedChangeDataDTO> changesByVersion) throws Exception {
|
||||
private void dispatchChanges(HashMap<Long, List<DetectedChangeDataDTO>> changesByVersion) throws Exception {
|
||||
final List<Long> sortedChanges = changesByVersion.keySet().stream()
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
for (Long changeId : sortedChanges) {
|
||||
final DetectedChangeDataDTO detectedChange = changesByVersion.get(changeId);
|
||||
final List<DetectedChangeDataDTO> detectedChanges = changesByVersion.get(changeId);
|
||||
|
||||
switch (detectedChange.getSysChangeOperation()) {
|
||||
case INSERT:
|
||||
if (eventListener != null)
|
||||
eventListener.onInsertDetected(detectedChange.getTableName(), detectedChange.getPrimaryKey());
|
||||
break;
|
||||
for (DetectedChangeDataDTO detectedChange : detectedChanges) {
|
||||
switch (detectedChange.getSysChangeOperation()) {
|
||||
case INSERT:
|
||||
if (eventListener != null)
|
||||
eventListener.onInsertDetected(detectedChange.getTableName(), detectedChange.getPrimaryKey());
|
||||
break;
|
||||
|
||||
case UPDATE:
|
||||
if (eventListener != null)
|
||||
eventListener.onUpdateDetected(detectedChange.getTableName(), detectedChange.getPrimaryKey());
|
||||
break;
|
||||
case UPDATE:
|
||||
if (eventListener != null)
|
||||
eventListener.onUpdateDetected(detectedChange.getTableName(), detectedChange.getPrimaryKey());
|
||||
break;
|
||||
|
||||
case DELETE:
|
||||
if (eventListener != null)
|
||||
eventListener.onDeleteDetected(detectedChange.getTableName(), detectedChange.getPrimaryKey());
|
||||
break;
|
||||
case DELETE:
|
||||
if (eventListener != null)
|
||||
eventListener.onDeleteDetected(detectedChange.getTableName(), detectedChange.getPrimaryKey());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
currentVersion = changeId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,14 +9,12 @@ import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.exception.DataConverterNotFoundException;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -32,6 +30,7 @@ public class DbmsChangeTrackerComponent {
|
||||
add(MtbAart.ENTITY);
|
||||
add(MtbAartBarCode.ENTITY);
|
||||
add(MtbUntMis.ENTITY);
|
||||
add(MtbDepo.ENTITY);
|
||||
add(StbEditLimit.ENTITY);
|
||||
add(StbGestSetup.ENTITY);
|
||||
add(StbGestSetupDepo.ENTITY);
|
||||
@@ -60,37 +59,42 @@ public class DbmsChangeTrackerComponent {
|
||||
}
|
||||
|
||||
|
||||
private void enableAllChangeTracking() throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||
private void enableAllChangeTracking() throws Exception {
|
||||
for (Map.Entry<IntegryCustomerDB, DbmsChangeTracker> entrySet : activeChangeTrackers.entrySet()) {
|
||||
IntegryCustomerDB customerDB = entrySet.getKey();
|
||||
DbmsChangeTracker dbmsChangeTracker = entrySet.getValue();
|
||||
|
||||
dbmsChangeTracker.enableTrackerInDbms();
|
||||
try {
|
||||
|
||||
for (String tableName : trackedTables) {
|
||||
dbmsChangeTracker.enableTrackerOnTable(tableName);
|
||||
dbmsChangeTracker.enableTrackerInDbms();
|
||||
|
||||
for (String tableName : trackedTables) {
|
||||
dbmsChangeTracker.enableTrackerOnTable(tableName);
|
||||
}
|
||||
|
||||
dbmsChangeTracker.disableTrackerOnNotUsedTables(trackedTables);
|
||||
|
||||
dbmsChangeTracker.setEventListener(new DbmsChangeTracker.Listener() {
|
||||
@Override
|
||||
public void onInsertDetected(String tableName, HashMap<String, Object> primaryKey) {
|
||||
onItemInserted(customerDB, tableName, primaryKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateDetected(String tableName, HashMap<String, Object> primaryKey) {
|
||||
onItemUpdated(customerDB, tableName, primaryKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteDetected(String tableName, HashMap<String, Object> primaryKey) {
|
||||
onItemDeleted(customerDB, tableName, primaryKey);
|
||||
}
|
||||
});
|
||||
|
||||
dbmsChangeTracker.startTracking();
|
||||
} catch (Exception e) {
|
||||
throw new Exception("Errore durante l'abilitazione del DbmsChangeTracker per il customer: " + customerDB.getValue(), e);
|
||||
}
|
||||
|
||||
dbmsChangeTracker.disableTrackerOnNotUsedTables(trackedTables);
|
||||
|
||||
dbmsChangeTracker.setEventListener(new DbmsChangeTracker.Listener() {
|
||||
@Override
|
||||
public void onInsertDetected(String tableName, HashMap<String, Object> primaryKey) {
|
||||
onItemInserted(customerDB, tableName, primaryKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateDetected(String tableName, HashMap<String, Object> primaryKey) {
|
||||
onItemUpdated(customerDB, tableName, primaryKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteDetected(String tableName, HashMap<String, Object> primaryKey) {
|
||||
onItemDeleted(customerDB, tableName, primaryKey);
|
||||
}
|
||||
});
|
||||
|
||||
dbmsChangeTracker.startTracking();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ public class EntityCacheComponent implements ApplicationListener {
|
||||
put(MtbAart.ENTITY, MtbAart.class);
|
||||
put(MtbAartBarCode.ENTITY, MtbAartBarCode.class);
|
||||
put(MtbUntMis.ENTITY, MtbUntMis.class);
|
||||
put(MtbDepo.ENTITY, MtbDepo.class);
|
||||
put(StbEditLimit.ENTITY, StbEditLimit.class);
|
||||
put(StbGestSetup.ENTITY, StbGestSetup.class);
|
||||
put(StbGestSetupDepo.ENTITY, StbGestSetupDepo.class);
|
||||
|
||||
@@ -95,7 +95,7 @@ public enum IntegryCustomerDB {
|
||||
Gramm_Gramm("gramm_peppe"),
|
||||
Gramm_PrimeOlive("primeolive"),
|
||||
Gramm_ProveStage("grammprovestage"),
|
||||
Gramm_2MHolding("2M_HOLDING"),
|
||||
Gramm_2MHolding("dueemme"),
|
||||
|
||||
|
||||
Idrotecnica_Idrotecnica("idrotecnica"),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package it.integry.ems.sync.MultiDBTransaction;
|
||||
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -354,4 +355,8 @@ public class Connection implements java.sql.Connection {
|
||||
isInternalDb = internalDb;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IntegryCustomerDB getIntegryCustomerDB() {
|
||||
return IntegryCustomerDB.parse(getDbName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,8 @@ public class UserSession {
|
||||
try {
|
||||
currentUser = UtilityUser.getCurrentUser(multiDBTransactionManager, requestDataDTO);
|
||||
|
||||
if(currentUser != null) currentUserDepo = UtilityUser.getDefaultUserDepo(multiDBTransactionManager, currentUser);
|
||||
if (currentUser != null)
|
||||
currentUserDepo = UtilityUser.getDefaultUserDepo(multiDBTransactionManager.getPrimaryConnection().getIntegryCustomerDB(), currentUser);
|
||||
} catch (Exception ex) {
|
||||
//logger.trace(UserSession.class.getName() + ": errore durante l'inizializzazione", ex);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@ package it.integry.ems.user;
|
||||
|
||||
import it.integry.ems._context.ApplicationContextProvider;
|
||||
import it.integry.ems.dto.EntityPermissionsDTO;
|
||||
import it.integry.ems.dynamic_cache.EntityCacheComponent;
|
||||
import it.integry.ems.exception.PrimaryDatabaseNotPresentException;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
@@ -69,23 +71,30 @@ public class UtilityUser {
|
||||
}
|
||||
|
||||
|
||||
public static MtbDepo getDefaultUserDepo(MultiDBTransactionManager multiDBTransactionManager, UserDTO userDTO) throws SQLException, IOException, PrimaryDatabaseNotPresentException, DataConverterNotFoundException, InstantiationException, IllegalAccessException, InvalidUserException {
|
||||
public static MtbDepo getDefaultUserDepo(IntegryCustomerDB integryCustomerDB, UserDTO userDTO) throws SQLException, IOException, PrimaryDatabaseNotPresentException, DataConverterNotFoundException, InstantiationException, IllegalAccessException, InvalidUserException {
|
||||
if (userDTO == null) throw new InvalidUserException();
|
||||
|
||||
String sql = "SELECT md.* FROM " + MtbDepo.ENTITY + " md " +
|
||||
" INNER JOIN " + WtbDepo.ENTITY + " wd " +
|
||||
" ON md.cod_mdep = wd.cod_mdep" +
|
||||
" WHERE wd.user_name = " + UtilityDB.valueToString(userDTO.getUsername()) +
|
||||
" order by wd.default_depo desc";
|
||||
final EntityCacheComponent entityCacheComponent = ApplicationContextProvider.getApplicationContext().getBean(EntityCacheComponent.class);
|
||||
|
||||
List<MtbDepo> depos = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, MtbDepo.class);
|
||||
MtbDepo defaultDepo = entityCacheComponent.<MtbDepo>getCachedEntitiesStream(integryCustomerDB, MtbDepo.ENTITY,
|
||||
x -> x.getCodMdep().equalsIgnoreCase(userDTO.getCodMdep()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (depos == null || depos.isEmpty()) {
|
||||
// String sql = "SELECT md.* FROM " + MtbDepo.ENTITY + " md " +
|
||||
// " INNER JOIN " + WtbDepo.ENTITY + " wd " +
|
||||
// " ON md.cod_mdep = wd.cod_mdep" +
|
||||
// " WHERE wd.user_name = " + UtilityDB.valueToString(userDTO.getUsername()) +
|
||||
// " order by wd.default_depo desc";
|
||||
|
||||
// List<MtbDepo> depos = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, MtbDepo.class);
|
||||
|
||||
if (defaultDepo == null) {
|
||||
logger.trace("Nessun deposito trovato per l'utente " + userDTO.getUsername());
|
||||
return null;
|
||||
}
|
||||
|
||||
return depos.get(0);
|
||||
return defaultDepo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -208,7 +208,13 @@ public class MtbColr extends EntityBase implements EquatableEntityInterface<MtbC
|
||||
|
||||
|
||||
public MtbColrKey getKey() {
|
||||
return new MtbColrKey(gestione, serCollo, dataCollo, numCollo, riga);
|
||||
return UtilityString.isNullOrEmpty(gestione) ||
|
||||
UtilityString.isNullOrEmpty(serCollo) ||
|
||||
dataCollo == null ||
|
||||
numCollo == null ||
|
||||
riga == null ?
|
||||
null :
|
||||
new MtbColrKey(gestione, serCollo, dataCollo, numCollo, riga);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -218,11 +218,11 @@ public class MtbColt extends EntityBase implements EquatableEntityInterface<MtbC
|
||||
|
||||
public MtbColtKey getKey() {
|
||||
return UtilityString.isNullOrEmpty(gestione) ||
|
||||
UtilityString.isNullOrEmpty(dataCollo) ||
|
||||
UtilityString.isNullOrEmpty(serCollo) ||
|
||||
dataCollo == null ||
|
||||
numCollo == null ?
|
||||
null :
|
||||
new MtbColtKey(gestione, serCollo, getDataCollo(), numCollo);
|
||||
new MtbColtKey(gestione, serCollo, dataCollo, numCollo);
|
||||
}
|
||||
|
||||
public String getGestione() {
|
||||
|
||||
@@ -166,7 +166,7 @@ public class RefreshTokenService {
|
||||
HashMap<String, AuthTokenProfileDetails> profilesData = new HashMap<>();
|
||||
|
||||
try {
|
||||
MtbDepo defaultUserDepo = UtilityUser.getDefaultUserDepo(multiDBTransactionManager, user);
|
||||
MtbDepo defaultUserDepo = UtilityUser.getDefaultUserDepo(multiDBTransactionManager.getPrimaryConnection().getIntegryCustomerDB(), user);
|
||||
|
||||
if (defaultUserDepo != null) {
|
||||
AuthTokenProfileDetails authTokenProfileDetails = new AuthTokenProfileDetails(AuthTokenDepoDetails.fromMtbDepo(defaultUserDepo));
|
||||
|
||||
@@ -591,7 +591,7 @@ end
|
||||
rule "completeFlagSetNumProtDtbTipi"
|
||||
when
|
||||
eval(completeRulesEnabled)
|
||||
$dTip : DtbTipi((gestione == "V" || codCcau != null) && flagSetNumProt)
|
||||
$dTip : DtbTipi((gestione == "V" || codCcau != null) && (flagSetNumProt == null || flagSetNumProt))
|
||||
then
|
||||
modify ( $dTip ) { setFlagSetNumProt(false) }
|
||||
end
|
||||
|
||||
@@ -11,7 +11,6 @@ import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -61,10 +60,14 @@ public class MovimentiContabiliService {
|
||||
}
|
||||
|
||||
if (ctbMovt.getCtbMovr() != null) {
|
||||
if ( ctbMovt.getOperation() == null) {
|
||||
OperationType operationType = ctbMovt.getOperation();
|
||||
boolean existMov = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(),
|
||||
Query.format("SELECT Cast(count(*) as bit) FROM ctb_movt WHERE num_cmov = %s", ctbMovt.getNumCmov()));
|
||||
|
||||
if ( existMov ) {
|
||||
ctbMovt.setOperation(OperationType.SELECT_OBJECT);
|
||||
entityProcessor.processEntity(ctbMovt, multiDBTransactionManager);
|
||||
ctbMovt.setOperation(OperationType.NO_OP);
|
||||
ctbMovt.setOperation(operationType);
|
||||
}
|
||||
String sql = Query.format("SELECT azione_su_partita FROM ctb_caus WHERE cod_ccau = %s", ctbMovt.getCodCcau());
|
||||
Integer azioneSuPartita = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
@@ -80,7 +83,7 @@ public class MovimentiContabiliService {
|
||||
Objects.equals(x.getNumDoc(), ctbMovt.getNumDoc()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
CtbMovr rigaPaga = righe.isEmpty() && righe.size() > 1 ? null : righe.get(righe.size() - 1);
|
||||
CtbMovr rigaPaga = righe.isEmpty() || righe.size() <= 1 ? null : righe.get(righe.size() - 1);
|
||||
|
||||
if (rigaPaga != null) {
|
||||
if (rigaPaga.getCtbScad() == null || rigaPaga.getCtbScad().isEmpty()) {
|
||||
|
||||
@@ -19,6 +19,7 @@ import it.integry.ems.rules.businessLogic.enums.TipoEmissione;
|
||||
import it.integry.ems.rules.completing.ConfigActivityRules;
|
||||
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_model.base.EntityBase;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
@@ -36,7 +37,6 @@ import org.springframework.stereotype.Service;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -77,6 +77,9 @@ public class DocumentiDirettiService {
|
||||
@Autowired
|
||||
private WMSGenericService wmsGenericService;
|
||||
|
||||
@Autowired
|
||||
private UserSession userSession;
|
||||
|
||||
public List<EntityBase> save(DtbDoct dtbDoct, boolean isInsert) throws Exception {
|
||||
List<EntityBase> entityList = new ArrayList<>();
|
||||
|
||||
@@ -1170,13 +1173,15 @@ public class DocumentiDirettiService {
|
||||
}
|
||||
|
||||
if (isLavorazione) {
|
||||
uds = wmsLavorazioneService.createUDSMovement(
|
||||
uds = WMSUtility.createUDSLavorazioneMovement(
|
||||
multiDBTransactionManager,
|
||||
new CreateUDSRequestDTO()
|
||||
.setCodAnag(createUDSFromDocuments.getCodAnag())
|
||||
.setCodMdep(createUDSFromDocuments.getCodMdep())
|
||||
.setCodVdes(createUDSFromDocuments.getCodVdes())
|
||||
.setCausaleCollo(CreateUDSRequestDTO.Causale.SCARICO)
|
||||
.setOrders(createUDSRequestOrderDTO));
|
||||
.setOrders(createUDSRequestOrderDTO),
|
||||
userSession.getUsername());
|
||||
} else {
|
||||
uds = wmsSpedizioneService.createUDSMovement(
|
||||
new CreateUDSRequestDTO()
|
||||
@@ -1200,7 +1205,8 @@ public class DocumentiDirettiService {
|
||||
}
|
||||
|
||||
if (isLavorazione) {
|
||||
wmsLavorazioneService.insertUDSRowMovement(
|
||||
WMSUtility.insertUDSLavorazioneRowMovement(
|
||||
multiDBTransactionManager.getPrimaryConnection(),
|
||||
new InsertUDSRowRequestDTO()
|
||||
.setCodMart(ulRowDTO.getCodMart())
|
||||
.setPartitaMag(ulRowDTO.getPartitaMag())
|
||||
@@ -1209,7 +1215,8 @@ public class DocumentiDirettiService {
|
||||
.setNumOrd(ulRowDTO.getNumOrd())
|
||||
.setRigaOrd(ulRowDTO.getRigaOrd())
|
||||
.setTargetMtbColt(uds)
|
||||
.setSourceMtbColr(sourceMtbColr));
|
||||
.setSourceMtbColr(sourceMtbColr),
|
||||
userSession.getUsername());
|
||||
|
||||
} else {
|
||||
wmsSpedizioneService.insertUDSRowMovement(
|
||||
|
||||
@@ -9,6 +9,7 @@ import it.integry.ems.retail.wms.Utility.WMSUtility;
|
||||
import it.integry.ems.retail.wms.generic.dto.MvwSitArtUdcDetInventarioDTO;
|
||||
import it.integry.ems.retail.wms.generic.service.WMSGiacenzaULService;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
@@ -37,10 +38,12 @@ public class EuroforkDataSyncronizerService {
|
||||
|
||||
private final WMSGiacenzaULService wmsGiacenzaULService;
|
||||
private final EntityProcessor entityProcessor;
|
||||
private final SettingsModel settingsModel;
|
||||
|
||||
public EuroforkDataSyncronizerService(WMSGiacenzaULService wmsGiacenzaULService, EntityProcessor entityProcessor) {
|
||||
public EuroforkDataSyncronizerService(WMSGiacenzaULService wmsGiacenzaULService, EntityProcessor entityProcessor, SettingsModel settingsModel) {
|
||||
this.wmsGiacenzaULService = wmsGiacenzaULService;
|
||||
this.entityProcessor = entityProcessor;
|
||||
this.settingsModel = settingsModel;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
@@ -54,6 +57,11 @@ public class EuroforkDataSyncronizerService {
|
||||
if (UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer())
|
||||
return;
|
||||
|
||||
if (!settingsModel.isPrimaryInstance())
|
||||
return;
|
||||
|
||||
logger.trace("Avvio sincronizzazione posizioni Eurofork -> Integry");
|
||||
|
||||
String sqlRetrieveEuroforkStatus = "SELECT barcode_ul,\n" +
|
||||
" posizione,\n" +
|
||||
" IIF(ColumnSide = 'L',\n" +
|
||||
@@ -158,8 +166,9 @@ public class EuroforkDataSyncronizerService {
|
||||
throw new IllegalStateException("Errore durante la creazione del movimento di cambio posizione per UL: " + ulRow.getKey());
|
||||
|
||||
|
||||
cambiaPosizioneUlMovement.get(0)
|
||||
.setDatetimeRow(dateTimePosizionamento.plusSeconds(ulRow.getValue().getV3()));
|
||||
if (ulRow.getValue().getV3() != null)
|
||||
cambiaPosizioneUlMovement.get(0)
|
||||
.setDatetimeRow(dateTimePosizionamento.plusSeconds(ulRow.getValue().getV3()));
|
||||
|
||||
internalMovement.getMtbColr().addAll(cambiaPosizioneUlMovement);
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ public class OrdiniDaApprov {
|
||||
String descrizioneFabb = rs.getString(5);
|
||||
String codForn = rs.getString(6);
|
||||
String codAlis = rs.getString(7);
|
||||
LocalDateTime dataCons = UtilityLocalDate.localDateTimeFromDate(rs.getDate(8));
|
||||
LocalDateTime dataCons = UtilityLocalDate.localDateTimeFromDate(rs.getTimestamp(8));
|
||||
String untMis = rs.getString(9);
|
||||
BigDecimal rapConv = rs.getBigDecimal(10);
|
||||
BigDecimal qtaAcq = rs.getBigDecimal(11);
|
||||
|
||||
@@ -445,8 +445,8 @@ public class ProductionOrdersLifecycleService {
|
||||
dtbOrdSteps
|
||||
.setCodJfas(ripianificaOrdineLavRequestDTO.getCodJfasNew())
|
||||
.setIdRiga(0)
|
||||
.setDataIniz(null)
|
||||
.setDataFine(null)
|
||||
.setDataIniz(LocalDateTime.now())
|
||||
.setDataFine(LocalDateTime.now())
|
||||
.setFlagStepAttivo("S");
|
||||
dtbOrdSteps.setOperation(OperationType.INSERT);
|
||||
dtbOrdl.getDtbOrdSteps().add(dtbOrdSteps);
|
||||
|
||||
@@ -4,10 +4,10 @@ import com.annimon.stream.Optional;
|
||||
import com.annimon.stream.Stream;
|
||||
import groovy.lang.Tuple2;
|
||||
import it.integry.ems._context.ApplicationContextProvider;
|
||||
import it.integry.ems.dynamic_cache.EntityCacheComponent;
|
||||
import it.integry.ems.exception.MissingDataException;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.retail.wms.dto.InsertUDCRowRequestDTO;
|
||||
import it.integry.ems.retail.wms.dto.InsertUDCRowResponseDTO;
|
||||
import it.integry.ems.retail.wms.dto.*;
|
||||
import it.integry.ems.retail.wms.exceptions.InvalidArticoloException;
|
||||
import it.integry.ems.retail.wms.generic.dto.MvwSitArtUdcDetInventarioDTO;
|
||||
import it.integry.ems.retail.wms.generic.dto.SpostaArtsTraULResponseDTO;
|
||||
@@ -18,10 +18,13 @@ import it.integry.ems.rules.businessLogic.dto.LoadColliDTO;
|
||||
import it.integry.ems.rules.businessLogic.enums.FlagSezione;
|
||||
import it.integry.ems.rules.completing.PackagesRules;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.service.dto.production.OrdineLavorazioneDTO;
|
||||
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_model.entity.*;
|
||||
import it.integry.ems_model.entity._enum.GestioneEnum;
|
||||
import it.integry.ems_model.exception.ConverterNotConfiguredException;
|
||||
import it.integry.ems_model.exception.RulesNotCompiledException;
|
||||
import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
|
||||
@@ -35,10 +38,7 @@ import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WMSUtility {
|
||||
@@ -154,6 +154,229 @@ public class WMSUtility {
|
||||
return mtbColtMap;
|
||||
}
|
||||
|
||||
public static MtbColt createUDSLavorazioneMovement(MultiDBTransactionManager multiDBTransactionManager, CreateUDSRequestDTO createUDSRequestDTO, String username) throws Exception {
|
||||
DroolsDataCompleting droolsDataCompleting = ApplicationContextProvider.getApplicationContext().getBean(DroolsDataCompleting.class);
|
||||
EntityProcessor entityProcessor = ApplicationContextProvider.getApplicationContext().getBean(EntityProcessor.class);
|
||||
ProductionOrderDataHandlerService productionOrderDataHandlerService = ApplicationContextProvider.getApplicationContext().getBean(ProductionOrderDataHandlerService.class);
|
||||
|
||||
if (createUDSRequestDTO.getCausaleCollo() == null) {
|
||||
throw new MissingDataException("Causale collo non specificata");
|
||||
}
|
||||
|
||||
List<DtbOrdt> foundDtbOrdts = new ArrayList<>();
|
||||
|
||||
if (createUDSRequestDTO.getOrders() != null) {
|
||||
for (CreateUDSRequestOrderDTO orderDTO : createUDSRequestDTO.getOrders()) {
|
||||
DtbOrdt dtbOrdt = orderDTO.toDtbOrdtEntity();
|
||||
dtbOrdt.setOperation(OperationType.SELECT_OBJECT);
|
||||
|
||||
entityProcessor.processEntity(dtbOrdt, true, multiDBTransactionManager);
|
||||
foundDtbOrdts.add(dtbOrdt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MtbColt udsMtbColt = new MtbColt()
|
||||
.setGestione(GestioneEnum.LAVORAZIONE.getText())
|
||||
.setDataCollo(createUDSRequestDTO.getDataCollo() != null ? createUDSRequestDTO.getDataCollo() : UtilityLocalDate.getNow())
|
||||
.setNumCollo(createUDSRequestDTO.getNumCollo())
|
||||
.setSerCollo(createUDSRequestDTO.getSerCollo())
|
||||
.setCodMdep(createUDSRequestDTO.getCodMdep())
|
||||
.setSegno(createUDSRequestDTO.getSegno())
|
||||
.setAnnotazioni(createUDSRequestDTO.getAnnotazioni())
|
||||
.setOraInizPrep(UtilityDate.isNull(UtilityLocalDate.localDateTimeToDate(createUDSRequestDTO.getOraInizPrep()), new Date()))
|
||||
.setPreparatoDa(username)
|
||||
.setPosizione(createUDSRequestDTO.getPosizione())
|
||||
.setCodJfas(createUDSRequestDTO.getCodJfas())
|
||||
.setRifOrd(createUDSRequestDTO.getRifOrd())
|
||||
.setCodAnag(createUDSRequestDTO.getCodAnag())
|
||||
.setCodVdes(createUDSRequestDTO.getCodVdes())
|
||||
.setCodTcol(createUDSRequestDTO.getCodTcol())
|
||||
.setIdLotto(createUDSRequestDTO.getIdLotto());
|
||||
udsMtbColt.setOperation(OperationType.INSERT);
|
||||
|
||||
switch (createUDSRequestDTO.getCausaleCollo()) {
|
||||
case SCARICO:
|
||||
final List<String> foundCodJfasList = foundDtbOrdts.stream()
|
||||
.map(DtbOrdt::getCodJfas)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (foundCodJfasList.size() == 1)
|
||||
udsMtbColt.setCodJfas(foundCodJfasList.get(0));
|
||||
|
||||
udsMtbColt.setSegno(-1);
|
||||
break;
|
||||
|
||||
case POSIZIONAMENTO:
|
||||
udsMtbColt.setSegno(1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (UtilityString.isNullOrEmpty(udsMtbColt.getSerCollo())) {
|
||||
udsMtbColt.setSerCollo(PackagesRules.getSerCollo(
|
||||
multiDBTransactionManager.getPrimaryConnection(),
|
||||
createUDSRequestDTO.getCodMdep()));
|
||||
}
|
||||
|
||||
if (foundDtbOrdts.size() == 1) {
|
||||
DtbOrdt foundDtbOrdt = foundDtbOrdts.get(0);
|
||||
|
||||
udsMtbColt.setNumOrd(foundDtbOrdt.getNumOrd())
|
||||
.setDataOrd(foundDtbOrdt.getDataOrd())
|
||||
.setRifOrd(foundDtbOrdt.getRifOrd())
|
||||
.setCodAnag(foundDtbOrdt.getCodAnag());
|
||||
}
|
||||
|
||||
if (createUDSRequestDTO.getOrders() != null) {
|
||||
String filtroOrdini = MtbColtUtils.generaFiltroOrdini(null,
|
||||
createUDSRequestDTO.getOrders().stream()
|
||||
.map(CreateUDSRequestOrderDTO::toDtbOrdrEntity)
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
udsMtbColt.setFiltroOrdini(filtroOrdini);
|
||||
}
|
||||
|
||||
if (createUDSRequestDTO.isOrderRequired() && foundDtbOrdts.isEmpty()) {
|
||||
|
||||
final List<OrdineLavorazioneDTO> ordiniLavorazioneInCorso = productionOrderDataHandlerService.getOrdiniLavorazioneInCorso(createUDSRequestDTO.getCodJfas());
|
||||
//Try to retrieve
|
||||
|
||||
//Se non trovo niente allora eccezione
|
||||
if (ordiniLavorazioneInCorso == null || ordiniLavorazioneInCorso.isEmpty()) {
|
||||
throw new Exception("Nessun ordine in corso sulla linea " + createUDSRequestDTO.getCodJfas());
|
||||
}
|
||||
|
||||
if (udsMtbColt.getIdLotto() == null) {
|
||||
List<Integer> idLotto = Stream.of(ordiniLavorazioneInCorso)
|
||||
.map(OrdineLavorazioneDTO::getIdLotto)
|
||||
.withoutNulls()
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
if (idLotto.size() == 1) {
|
||||
//Assegnare l'ordine o l'id lotto al collo appena creato
|
||||
udsMtbColt
|
||||
.setIdLotto(idLotto.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
final List<Integer> foundInCorsoOrders = ordiniLavorazioneInCorso.stream()
|
||||
.map(OrdineLavorazioneDTO::getNumOrd)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (foundInCorsoOrders.size() == 1) {
|
||||
OrdineLavorazioneDTO ordineLavorazioneDTO = ordiniLavorazioneInCorso.get(0);
|
||||
udsMtbColt
|
||||
.setDataOrd(ordineLavorazioneDTO.getDataOrd())
|
||||
.setNumOrd(ordineLavorazioneDTO.getNumOrd());
|
||||
}
|
||||
}
|
||||
|
||||
droolsDataCompleting.complete(udsMtbColt, multiDBTransactionManager.getPrimaryConnection(), username);
|
||||
|
||||
return udsMtbColt;
|
||||
}
|
||||
|
||||
public static InsertUDSRowResponseDTO insertUDSLavorazioneRowMovement(Connection connection, InsertUDSRowRequestDTO insertUDSRowRequestDTO, String username) throws Exception {
|
||||
DroolsDataCompleting droolsDataCompleting = ApplicationContextProvider.getApplicationContext().getBean(DroolsDataCompleting.class);
|
||||
|
||||
//Prendo solo la chiave
|
||||
MtbColt targetMtbColt = insertUDSRowRequestDTO.getTargetMtbColt();
|
||||
if (targetMtbColt == null)
|
||||
throw new Exception("Nessun collo di destinazione specificato durante l'inserimento di una riga in una UDS (targetMtbColt null)");
|
||||
|
||||
MtbAart mtbAart = WMSUtility.getArticoloByCodMart(insertUDSRowRequestDTO.getCodMart(), connection);
|
||||
if (mtbAart == null)
|
||||
throw new InvalidArticoloException(insertUDSRowRequestDTO.getCodMart());
|
||||
|
||||
MtbColrInfoProd mtbColrInfoProd = null;
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(insertUDSRowRequestDTO.getContrassegnoDa())) {
|
||||
mtbColrInfoProd = new MtbColrInfoProd()
|
||||
.setContrassegnoDa(insertUDSRowRequestDTO.getContrassegnoDa());
|
||||
mtbColrInfoProd.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
}
|
||||
|
||||
final MtbColr targetMtbColr = new MtbColr()
|
||||
.setCausale(MtbColr.Causale.DEFAULT)
|
||||
.setCodMart(mtbAart.getCodMart())
|
||||
.setPartitaMag(insertUDSRowRequestDTO.getPartitaMag())
|
||||
.setDataScadPartita(UtilityLocalDate.localDateToDate(insertUDSRowRequestDTO.getDataScad()))
|
||||
.setQtaCol(insertUDSRowRequestDTO.getQtaTot())
|
||||
.setQtaCnf(insertUDSRowRequestDTO.getQtaCnf())
|
||||
.setNumCnf(insertUDSRowRequestDTO.getNumCnf())
|
||||
.setDescrizione(mtbAart.getDescrizioneEstesa())
|
||||
.setUtente(username)
|
||||
.setDataOrd(insertUDSRowRequestDTO.getDataOrd())
|
||||
.setNumOrd(insertUDSRowRequestDTO.getNumOrd())
|
||||
.setRigaOrd(insertUDSRowRequestDTO.getRigaOrd())
|
||||
.setDatetimeRow(UtilityLocalDate.isNull(insertUDSRowRequestDTO.getDatetimeRow(), UtilityLocalDate.getNowTime()))
|
||||
.setCodJcom(insertUDSRowRequestDTO.getCodJcom())
|
||||
.setMtbColrInfoProd(mtbColrInfoProd);
|
||||
targetMtbColr.setOperation(OperationType.INSERT);
|
||||
targetMtbColt.getMtbColr().add(targetMtbColr);
|
||||
|
||||
if (insertUDSRowRequestDTO.getSourceMtbColr() != null) {
|
||||
MtbColr sourceMtbColr = insertUDSRowRequestDTO.getSourceMtbColr();
|
||||
|
||||
String sqlCodTcol = Query.format("SELECT cod_tcol\n" +
|
||||
"FROM mtb_colt\n" +
|
||||
"WHERE gestione = {}\n" +
|
||||
" AND data_collo = {}\n" +
|
||||
" AND num_collo = {}\n" +
|
||||
" AND ser_collo = {}",
|
||||
sourceMtbColr.getGestione(),
|
||||
sourceMtbColr.getDataCollo(),
|
||||
sourceMtbColr.getNumCollo(),
|
||||
sourceMtbColr.getSerCollo());
|
||||
|
||||
final String sourceCodTcol = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sqlCodTcol);
|
||||
|
||||
if (UtilityString.isNullOrEmpty(targetMtbColt.getCodTcol()) && !UtilityString.isNullOrEmpty(sourceCodTcol)) {
|
||||
targetMtbColt.setCodTcol(sourceCodTcol);
|
||||
targetMtbColt.setOperation(OperationType.UPDATE);
|
||||
}
|
||||
|
||||
targetMtbColr
|
||||
// .setCodJcom(UtilityString.emptyStr2Null(sourceMtbColr.getCodJcom()))
|
||||
.setSerColloRif(sourceMtbColr.getSerCollo())
|
||||
.setDataColloRif(sourceMtbColr.getDataCollo())
|
||||
.setNumColloRif(sourceMtbColr.getNumCollo())
|
||||
.setGestioneRif(sourceMtbColr.getGestione());
|
||||
|
||||
if (sourceMtbColr.getPesoNettoKg() != null) {
|
||||
//Proporzione
|
||||
BigDecimal pesoNettoKg = UtilityBigDecimal.divide(UtilityBigDecimal.multiply(insertUDSRowRequestDTO.getQtaTot(), sourceMtbColr.getPesoNettoKg()), sourceMtbColr.getQtaCol());
|
||||
targetMtbColr.setPesoNettoKg(pesoNettoKg);
|
||||
}
|
||||
|
||||
if (sourceMtbColr.getPesoLordoKg() != null) {
|
||||
//Proporzione
|
||||
BigDecimal pesoLordoKg = UtilityBigDecimal.divide(UtilityBigDecimal.multiply(insertUDSRowRequestDTO.getQtaTot(), sourceMtbColr.getPesoLordoKg()), sourceMtbColr.getQtaCol());
|
||||
targetMtbColr.setPesoLordoKg(pesoLordoKg);
|
||||
}
|
||||
|
||||
targetMtbColr
|
||||
.setPosizioneOut(sourceMtbColr.getPosizioneIn())
|
||||
.setCodMdepOut(sourceMtbColr.getCodMdepIn())
|
||||
.setBarcodeUlOut(sourceMtbColr.getBarcodeUlIn());
|
||||
|
||||
//Non valorizzo i campi IN perchè si è ritenuto errato negli L-
|
||||
// .setBarcodeUlIn(targetMtbColt.getBarcodeUl())
|
||||
// .setPosizioneIn(targetMtbColt.getPosizione())
|
||||
// .setCodMdepIn(targetMtbColt.getCodMdep());
|
||||
}
|
||||
|
||||
droolsDataCompleting.complete(targetMtbColt, connection, username);
|
||||
|
||||
return new InsertUDSRowResponseDTO()
|
||||
.setSavedMtbColr(targetMtbColr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static List<MtbColr> createCambiaPosizioneUlMovement(Connection connection, String sscc, boolean changeCodMdep, String newCodMdep, String newPosizione) throws Exception {
|
||||
return createCambiaPosizioneUlMovements(connection, Collections.singletonList(sscc), changeCodMdep, newCodMdep, newPosizione);
|
||||
}
|
||||
@@ -423,7 +646,7 @@ public class WMSUtility {
|
||||
|
||||
targetMtbColt.setOperation(OperationType.SELECT_OBJECT);
|
||||
entityProcessor.processEntity(targetMtbColt, true, multiDBTransactionManager);
|
||||
|
||||
targetMtbColt.setOperation(OperationType.NO_OP);
|
||||
|
||||
final MtbColr targetMtbColr = new MtbColr()
|
||||
.setCausale(MtbColr.Causale.DEFAULT)
|
||||
@@ -511,13 +734,18 @@ public class WMSUtility {
|
||||
public static List<MtbAart> getArticoliByCodMarts(List<String> codMarts, Connection connection) throws Exception {
|
||||
if (codMarts == null || codMarts.isEmpty()) return null;
|
||||
|
||||
String query =
|
||||
"SELECT DISTINCT mtb_aart.*"
|
||||
+ " FROM mtb_aart "
|
||||
+ " WHERE cod_mart IN (" + UtilityQuery.concatStringFieldsWithSeparator(codMarts, ",") + ")";
|
||||
final EntityCacheComponent entityCacheComponent = ApplicationContextProvider.getApplicationContext().getBean(EntityCacheComponent.class);
|
||||
|
||||
List<MtbAart> listMtbAart = entityCacheComponent.getCachedEntitiesList(
|
||||
connection.getIntegryCustomerDB(), MtbAart.ENTITY, x -> codMarts.contains(x.getCodMart()));
|
||||
|
||||
List<MtbAart> listMtbAart = UtilityDB.executeSimpleQueryDTO(connection, query, MtbAart.class);
|
||||
// String query =
|
||||
// "SELECT DISTINCT mtb_aart.*"
|
||||
// + " FROM mtb_aart "
|
||||
// + " WHERE cod_mart IN (" + UtilityQuery.concatStringFieldsWithSeparator(codMarts, ",") + ")";
|
||||
//
|
||||
//
|
||||
// List<MtbAart> listMtbAart = UtilityDB.executeSimpleQueryDTO(connection, query, MtbAart.class);
|
||||
|
||||
List<MtbAartBarCode> barCodeFromCod = getAlternativeMtbAartBarCodes(codMarts, connection);
|
||||
|
||||
@@ -559,14 +787,19 @@ public class WMSUtility {
|
||||
.collect(Collectors.toMap(MtbAart::getCodMart, a -> a, (a, b) -> a, HashMap::new));
|
||||
}
|
||||
|
||||
public static List<MtbUntMis> getUntMisFromCod(List<String> untMisCods, Connection connection) throws Exception {
|
||||
List<String> untMisStrings = Stream.of(untMisCods)
|
||||
.withoutNulls()
|
||||
public static List<MtbUntMis> getUntMisFromCod(List<String> untMisCods, Connection connection) {
|
||||
List<String> untMisStrings = untMisCods.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.toList();
|
||||
.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()));
|
||||
|
||||
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<>();
|
||||
}
|
||||
|
||||
@@ -576,12 +809,18 @@ public class WMSUtility {
|
||||
" FROM mtb_colt WHERE barcode_ul = " + UtilityDB.valueToString(barcodeUl));
|
||||
}
|
||||
|
||||
public static List<MtbAartBarCode> getAlternativeMtbAartBarCodes(List<String> codMarts, Connection conn) throws Exception {
|
||||
public static List<MtbAartBarCode> getAlternativeMtbAartBarCodes(List<String> codMarts, Connection conn) {
|
||||
codMarts = codMarts.stream()
|
||||
.distinct().collect(Collectors.toList());
|
||||
|
||||
String sql = "SELECT * FROM mtb_aart_bar_code WHERE cod_mart IN (" + UtilityQuery.concatStringFieldsWithSeparator(codMarts, ",") + ")";
|
||||
final List<MtbAartBarCode> barCodeList = UtilityDB.executeSimpleQueryDTO(conn, sql, MtbAartBarCode.class);
|
||||
final EntityCacheComponent entityCacheComponent = ApplicationContextProvider.getApplicationContext().getBean(EntityCacheComponent.class);
|
||||
|
||||
List<String> finalCodMarts = codMarts;
|
||||
List<MtbAartBarCode> barCodeList = entityCacheComponent.getCachedEntitiesList(
|
||||
conn.getIntegryCustomerDB(),
|
||||
MtbAartBarCode.ENTITY,
|
||||
x -> finalCodMarts.contains(x.getCodMart()));
|
||||
|
||||
return barCodeList != null ? barCodeList : new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
@@ -294,6 +294,7 @@ public class WMSAccettazioneService {
|
||||
MtbColt targetMtbColt = inputData.getTargetMtbColt();
|
||||
targetMtbColt.setOperation(OperationType.SELECT_OBJECT);
|
||||
entityProcessor.processEntity(targetMtbColt, multiDBTransactionManager);
|
||||
targetMtbColt.setOperation(OperationType.NO_OP);
|
||||
|
||||
for (InsertUDCRowRequestDTO insertUDCRowRequestDTO : inputData.getRows()) {
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ public class RetrieveArtsInGiacenzaByArtRequestDTO {
|
||||
private String codCol;
|
||||
private String codTagl;
|
||||
private String codJcom;
|
||||
private String codJfas;
|
||||
|
||||
private String barcodeUl;
|
||||
private String posizione;
|
||||
@@ -73,6 +74,15 @@ public class RetrieveArtsInGiacenzaByArtRequestDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodJfas() {
|
||||
return codJfas;
|
||||
}
|
||||
|
||||
public RetrieveArtsInGiacenzaByArtRequestDTO setCodJfas(String codJfas) {
|
||||
this.codJfas = codJfas;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBarcodeUl() {
|
||||
return barcodeUl;
|
||||
}
|
||||
|
||||
@@ -1534,7 +1534,7 @@ public class WMSGenericService {
|
||||
}
|
||||
scarico.getPosizioni().add(scaricoMateriaPrimaDTO.getPosizione());
|
||||
}
|
||||
return this.scaricoMateriaPrimadaOrdine(codMdep, codJfas, useRapportoMatPrima, listScarichiOrdine);
|
||||
return this.scaricoMateriaPrimaDaOrdine(codMdep, codJfas, useRapportoMatPrima, listScarichiOrdine);
|
||||
|
||||
}
|
||||
|
||||
@@ -1608,18 +1608,18 @@ public class WMSGenericService {
|
||||
mtbColtToInsert.setOperation(OperationType.NO_OP);
|
||||
} else {
|
||||
|
||||
|
||||
mtbColtToInsert = new MtbColt()
|
||||
.setMtbColr(new ArrayList<>())
|
||||
.setGestione("L")
|
||||
.setSegno(-1)
|
||||
.setCodMdep(codMdep)
|
||||
.setCodJfas(codJfas == null ? scaricoMateriaPrimaDTO.getCodJfas() : codJfas)
|
||||
.setPosizione(scaricoMateriaPrimaDTO.getPosizione())
|
||||
.setDataOrd(scaricoMateriaPrimaDTO.getDataOrd())
|
||||
.setNumOrd(scaricoMateriaPrimaDTO.getNumOrd())
|
||||
.setCodAnag(codAnag);
|
||||
mtbColtToInsert.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
mtbColtToInsert = WMSUtility.createUDSLavorazioneMovement(multiDBTransactionManager,
|
||||
new CreateUDSRequestDTO()
|
||||
.setCausaleCollo(CreateUDSRequestDTO.Causale.SCARICO)
|
||||
.setCodMdep(codMdep)
|
||||
.setCodJfas(codJfas == null ? scaricoMateriaPrimaDTO.getCodJfas() : codJfas)
|
||||
.setPosizione(scaricoMateriaPrimaDTO.getPosizione())
|
||||
.setCodAnag(codAnag)
|
||||
.setOrders(Collections.singletonList(new CreateUDSRequestOrderDTO()
|
||||
.setDataOrd(scaricoMateriaPrimaDTO.getDataOrd())
|
||||
.setNumOrd(scaricoMateriaPrimaDTO.getNumOrd())
|
||||
.setGestione(scaricoMateriaPrimaDTO.getGestioneOrd()))),
|
||||
userSession.getUsername());
|
||||
}
|
||||
|
||||
|
||||
@@ -1653,21 +1653,19 @@ public class WMSGenericService {
|
||||
|
||||
if (UtilityBigDecimal.equalsOrLowerThan(qtaToTake, BigDecimal.ZERO)) continue;
|
||||
|
||||
MtbColr mtbColr = new MtbColr()
|
||||
.setCodMart(giacInPosizioneItem.getCodMart())
|
||||
.setCodJcom(giacInPosizioneItem.getCodJcom())
|
||||
.setNumOrd(scaricoMateriaPrimaDTO.getNumOrd())
|
||||
.setDataOrd(scaricoMateriaPrimaDTO.getDataOrd())
|
||||
.setRigaOrd(giacInPosizioneItem.getRigaOrd())
|
||||
.setQtaCol(qtaToTake)
|
||||
.setPartitaMag(giacInPosizioneItem.getPartitaMag())
|
||||
.setNumColloRif(giacInPosizioneItem.getNumCollo())
|
||||
.setDataColloRif(giacInPosizioneItem.getDataCollo())
|
||||
.setSerColloRif(giacInPosizioneItem.getSerCollo())
|
||||
.setGestioneRif(giacInPosizioneItem.getGestione())
|
||||
.setDatetimeRow(UtilityLocalDate.getNowTime());
|
||||
mtbColr.setOperation(OperationType.INSERT);
|
||||
mtbColtToInsert.getMtbColr().add(mtbColr);
|
||||
final InsertUDSRowResponseDTO insertedUds = WMSUtility.insertUDSLavorazioneRowMovement(multiDBTransactionManager.getPrimaryConnection(),
|
||||
new InsertUDSRowRequestDTO()
|
||||
.setTargetMtbColt(mtbColtToInsert)
|
||||
.setCodMart(giacInPosizioneItem.getCodMart())
|
||||
.setCodJcom(giacInPosizioneItem.getCodJcom())
|
||||
.setNumOrd(scaricoMateriaPrimaDTO.getNumOrd())
|
||||
.setDataOrd(scaricoMateriaPrimaDTO.getDataOrd())
|
||||
.setRigaOrd(giacInPosizioneItem.getRigaOrd())
|
||||
.setQtaTot(qtaToTake)
|
||||
.setPartitaMag(giacInPosizioneItem.getPartitaMag())
|
||||
.setSourceMtbColr(WMSUtility.convertMvwItemToMtbColr(giacInPosizioneItem))
|
||||
.setDatetimeRow(UtilityLocalDate.getNowTime()),
|
||||
userSession.getUsername());
|
||||
|
||||
qtaScaricata = qtaScaricata.add(qtaToTake);
|
||||
}
|
||||
@@ -1687,7 +1685,7 @@ public class WMSGenericService {
|
||||
|
||||
}
|
||||
|
||||
private List<AnomalieDTO> scaricoMateriaPrimadaOrdine(String codMdep, String codJfas, boolean useRapportoMatPrima, List<ScaricoMateriaPrimaDaOrdineDTO> listScarichiOrdine) throws Exception {
|
||||
private List<AnomalieDTO> scaricoMateriaPrimaDaOrdine(String codMdep, String codJfas, boolean useRapportoMatPrima, List<ScaricoMateriaPrimaDaOrdineDTO> listScarichiOrdine) throws Exception {
|
||||
final List<AnomalieDTO> anomalieList = new ArrayList<>();
|
||||
List<MtbColt> mtbColtsToInsert = new ArrayList<>();
|
||||
|
||||
@@ -1755,11 +1753,16 @@ public class WMSGenericService {
|
||||
break;
|
||||
}
|
||||
|
||||
MtbColt mtbColt = Stream.of(mtbColtsToInsert).filter(x -> scaricoDaOrdine.getDataOrd().equals(x.getDataOrd()) &&
|
||||
scaricoDaOrdine.getNumOrd().equals(x.getNumOrd()) &&
|
||||
scaricoDaOrdine.getGestioneOrd().equals(x.getGestione()) &&
|
||||
giacenza.getPosizione().equals(x.getPosizione()) &&
|
||||
(codJfasScarico != null && codJfasScarico.equalsIgnoreCase(x.getCodJfas()))).findFirst().orElse(null);
|
||||
MtbColt mtbColt = mtbColtsToInsert
|
||||
.stream()
|
||||
.filter(x -> scaricoDaOrdine.getDataOrd().equals(x.getDataOrd()) &&
|
||||
scaricoDaOrdine.getNumOrd().equals(x.getNumOrd()) &&
|
||||
scaricoDaOrdine.getGestioneOrd().equals(x.getGestione()) &&
|
||||
giacenza.getPosizione().equals(x.getPosizione()) &&
|
||||
(codJfasScarico != null && codJfasScarico.equalsIgnoreCase(x.getCodJfas())))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (mtbColt == null) {
|
||||
String queryMtbColt = "SELECT *" +
|
||||
" FROM mtb_colt" +
|
||||
@@ -1780,19 +1783,20 @@ public class WMSGenericService {
|
||||
mtbColt = alreadyPresentMtbColts.get(0);
|
||||
mtbColt.setOperation(OperationType.NO_OP);
|
||||
} else {
|
||||
|
||||
mtbColt = new MtbColt()
|
||||
.setMtbColr(new ArrayList<>())
|
||||
.setGestione("L")
|
||||
.setSegno(-1)
|
||||
.setCodMdep(codMdep)
|
||||
.setCodJfas(codJfasScarico)
|
||||
.setPosizione(giacenza.getPosizione())
|
||||
.setDataOrd(scaricoDaOrdine.getDataOrd())
|
||||
.setNumOrd(scaricoDaOrdine.getNumOrd())
|
||||
.setCodAnag(codAnag);
|
||||
mtbColt.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
mtbColt = WMSUtility.createUDSLavorazioneMovement(multiDBTransactionManager,
|
||||
new CreateUDSRequestDTO()
|
||||
.setCodMdep(codMdep)
|
||||
.setCodJfas(codJfasScarico)
|
||||
.setPosizione(giacenza.getPosizione())
|
||||
.setCodAnag(codAnag)
|
||||
.setCausaleCollo(CreateUDSRequestDTO.Causale.SCARICO)
|
||||
.setOrders(Collections.singletonList(new CreateUDSRequestOrderDTO()
|
||||
.setDataOrd(scaricoDaOrdine.getDataOrd())
|
||||
.setNumOrd(scaricoDaOrdine.getNumOrd())
|
||||
.setGestione(scaricoDaOrdine.getGestioneOrd()))),
|
||||
userSession.getUsername());
|
||||
}
|
||||
|
||||
mtbColtsToInsert.add(mtbColt);
|
||||
}
|
||||
|
||||
@@ -1805,21 +1809,20 @@ public class WMSGenericService {
|
||||
|
||||
if (UtilityBigDecimal.equalsOrLowerThan(qtaToTake, BigDecimal.ZERO)) continue;
|
||||
|
||||
MtbColr mtbColr = new MtbColr()
|
||||
.setCodMart(giacenza.getCodMart())
|
||||
.setCodJcom(giacenza.getCodJcom())
|
||||
.setNumOrd(scaricoDaOrdine.getNumOrd())
|
||||
.setDataOrd(scaricoDaOrdine.getDataOrd())
|
||||
.setRigaOrd(giacenza.getRigaOrd())
|
||||
.setQtaCol(qtaToTake)
|
||||
.setPartitaMag(giacenza.getPartitaMag())
|
||||
.setNumColloRif(giacenza.getNumCollo())
|
||||
.setDataColloRif(giacenza.getDataCollo())
|
||||
.setSerColloRif(giacenza.getSerCollo())
|
||||
.setGestioneRif(giacenza.getGestione())
|
||||
.setDatetimeRow(UtilityLocalDate.getNowTime());
|
||||
mtbColr.setOperation(OperationType.INSERT);
|
||||
mtbColt.getMtbColr().add(mtbColr);
|
||||
|
||||
WMSUtility.insertUDSLavorazioneRowMovement(multiDBTransactionManager.getPrimaryConnection(),
|
||||
new InsertUDSRowRequestDTO()
|
||||
.setTargetMtbColt(mtbColt)
|
||||
.setCodMart(giacenza.getCodMart())
|
||||
.setCodJcom(giacenza.getCodJcom())
|
||||
.setNumOrd(scaricoDaOrdine.getNumOrd())
|
||||
.setDataOrd(scaricoDaOrdine.getDataOrd())
|
||||
.setRigaOrd(giacenza.getRigaOrd())
|
||||
.setQtaTot(qtaToTake)
|
||||
.setPartitaMag(giacenza.getPartitaMag())
|
||||
.setSourceMtbColr(WMSUtility.convertMvwItemToMtbColr(giacenza))
|
||||
.setDatetimeRow(UtilityLocalDate.getNowTime()),
|
||||
userSession.getUsername());
|
||||
|
||||
qtaRimanente = qtaRimanente.subtract(qtaToTake);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package it.integry.ems.retail.wms.generic.service;
|
||||
|
||||
import core.utility.StringUtils;
|
||||
import it.integry.ems.retail.wms.generic.dto.*;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
@@ -7,7 +8,6 @@ import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityHashMap;
|
||||
import it.integry.ems_model.utility.UtilityQuery;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import core.utility.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -343,6 +343,9 @@ public class WMSGiacenzaULService {
|
||||
if (!UtilityString.isNullOrEmpty(x.getCodJcom()))
|
||||
map.put("sit_art.cod_jcom", x.getCodJcom());
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(x.getCodJfas()))
|
||||
map.put("sit_art.cod_jfas", x.getCodJfas());
|
||||
|
||||
if (x.isMandatoryPosizione())
|
||||
map.put("sit_art.posizione", EmsRestConstants.NOT_NULL);
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package it.integry.ems.retail.wms.lavorazione.service;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import groovy.lang.Tuple2;
|
||||
import it.integry.ems.document.dto.ArticoloProdottoDTO;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
@@ -16,10 +15,8 @@ import it.integry.ems.retail.wms.generic.dto.MvwSitArtUdcDetInventarioDTO;
|
||||
import it.integry.ems.retail.wms.generic.service.WMSGiacenzaULService;
|
||||
import it.integry.ems.rules.businessLogic.LoadColliService;
|
||||
import it.integry.ems.rules.businessLogic.dto.LoadColliDTO;
|
||||
import it.integry.ems.rules.completing.PackagesRules;
|
||||
import it.integry.ems.service.AziendaService;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.service.dto.production.OrdineLavorazioneDTO;
|
||||
import it.integry.ems.service.production.ProductionOrderDataHandlerService;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.user.UserSession;
|
||||
@@ -76,12 +73,15 @@ public class WMSLavorazioneService {
|
||||
|
||||
@Autowired
|
||||
private AziendaService aziendaService;
|
||||
|
||||
@Autowired
|
||||
private DroolsDataCompleting droolsDataCompleting;
|
||||
|
||||
|
||||
public MtbColt createUDS(CreateUDSRequestDTO createUDSRequestDTO) throws Exception {
|
||||
MtbColt generatedMtbColt = createUDSMovement(createUDSRequestDTO);
|
||||
userSession.checkUser();
|
||||
|
||||
MtbColt generatedMtbColt = WMSUtility.createUDSLavorazioneMovement(multiDBTransactionManager, createUDSRequestDTO, userSession.getUsername());
|
||||
|
||||
generatedMtbColt.setOperation(OperationType.INSERT);
|
||||
entityProcessor.processEntity(generatedMtbColt, true, multiDBTransactionManager);
|
||||
@@ -91,124 +91,7 @@ public class WMSLavorazioneService {
|
||||
return generatedMtbColt;
|
||||
}
|
||||
|
||||
public MtbColt createUDSMovement(CreateUDSRequestDTO createUDSRequestDTO) throws Exception {
|
||||
userSession.checkUser();
|
||||
|
||||
List<DtbOrdt> foundDtbOrdts = new ArrayList<>();
|
||||
|
||||
if (createUDSRequestDTO.getOrders() != null) {
|
||||
for (CreateUDSRequestOrderDTO orderDTO : createUDSRequestDTO.getOrders()) {
|
||||
DtbOrdt dtbOrdt = orderDTO.toDtbOrdtEntity();
|
||||
dtbOrdt.setOperation(OperationType.SELECT_OBJECT);
|
||||
|
||||
entityProcessor.processEntity(dtbOrdt, true, multiDBTransactionManager);
|
||||
foundDtbOrdts.add(dtbOrdt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MtbColt udsMtbColt = new MtbColt()
|
||||
.setGestione(GestioneEnum.LAVORAZIONE.getText())
|
||||
.setDataCollo(createUDSRequestDTO.getDataCollo() != null ? createUDSRequestDTO.getDataCollo() : UtilityLocalDate.getNow())
|
||||
.setNumCollo(createUDSRequestDTO.getNumCollo())
|
||||
.setSerCollo(createUDSRequestDTO.getSerCollo())
|
||||
.setCodMdep(createUDSRequestDTO.getCodMdep())
|
||||
.setSegno(createUDSRequestDTO.getSegno())
|
||||
.setAnnotazioni(createUDSRequestDTO.getAnnotazioni())
|
||||
.setOraInizPrep(UtilityDate.isNull(UtilityLocalDate.localDateTimeToDate(createUDSRequestDTO.getOraInizPrep()), new Date()))
|
||||
.setPreparatoDa(userSession.getUsername())
|
||||
.setPosizione(createUDSRequestDTO.getPosizione())
|
||||
.setCodJfas(createUDSRequestDTO.getCodJfas())
|
||||
.setRifOrd(createUDSRequestDTO.getRifOrd())
|
||||
.setCodAnag(createUDSRequestDTO.getCodAnag())
|
||||
.setCodVdes(createUDSRequestDTO.getCodVdes())
|
||||
.setCodTcol(createUDSRequestDTO.getCodTcol())
|
||||
.setIdLotto(createUDSRequestDTO.getIdLotto());
|
||||
udsMtbColt.setOperation(OperationType.INSERT);
|
||||
|
||||
switch (createUDSRequestDTO.getCausaleCollo()) {
|
||||
case SCARICO:
|
||||
final List<String> foundCodJfasList = foundDtbOrdts.stream()
|
||||
.map(DtbOrdt::getCodJfas)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (foundCodJfasList.size() == 1)
|
||||
udsMtbColt.setCodJfas(foundCodJfasList.get(0));
|
||||
|
||||
udsMtbColt.setSegno(-1);
|
||||
break;
|
||||
|
||||
case POSIZIONAMENTO:
|
||||
udsMtbColt.setSegno(1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (UtilityString.isNullOrEmpty(udsMtbColt.getSerCollo())) {
|
||||
udsMtbColt.setSerCollo(PackagesRules.getSerCollo(
|
||||
multiDBTransactionManager.getPrimaryConnection(),
|
||||
createUDSRequestDTO.getCodMdep()));
|
||||
}
|
||||
|
||||
if (foundDtbOrdts.size() == 1) {
|
||||
DtbOrdt foundDtbOrdt = foundDtbOrdts.get(0);
|
||||
|
||||
udsMtbColt.setNumOrd(foundDtbOrdt.getNumOrd())
|
||||
.setDataOrd(foundDtbOrdt.getDataOrd())
|
||||
.setRifOrd(foundDtbOrdt.getRifOrd())
|
||||
.setCodAnag(foundDtbOrdt.getCodAnag());
|
||||
}
|
||||
|
||||
if (createUDSRequestDTO.getOrders() != null) {
|
||||
String filtroOrdini = MtbColtUtils.generaFiltroOrdini(null,
|
||||
createUDSRequestDTO.getOrders().stream()
|
||||
.map(CreateUDSRequestOrderDTO::toDtbOrdrEntity)
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
udsMtbColt.setFiltroOrdini(filtroOrdini);
|
||||
}
|
||||
|
||||
if (createUDSRequestDTO.isOrderRequired() && foundDtbOrdts.isEmpty()) {
|
||||
|
||||
final List<OrdineLavorazioneDTO> ordiniLavorazioneInCorso = productionOrderDataHandlerService.getOrdiniLavorazioneInCorso(createUDSRequestDTO.getCodJfas());
|
||||
//Try to retrieve
|
||||
|
||||
//Se non trovo niente allora eccezione
|
||||
if (ordiniLavorazioneInCorso == null || ordiniLavorazioneInCorso.isEmpty()) {
|
||||
throw new Exception("Nessun ordine in corso sulla linea " + createUDSRequestDTO.getCodJfas());
|
||||
}
|
||||
|
||||
if (udsMtbColt.getIdLotto() == null) {
|
||||
List<Integer> idLotto = Stream.of(ordiniLavorazioneInCorso)
|
||||
.map(OrdineLavorazioneDTO::getIdLotto)
|
||||
.withoutNulls()
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
if (idLotto.size() == 1) {
|
||||
//Assegnare l'ordine o l'id lotto al collo appena creato
|
||||
udsMtbColt
|
||||
.setIdLotto(idLotto.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
final List<Integer> foundInCorsoOrders = ordiniLavorazioneInCorso.stream()
|
||||
.map(OrdineLavorazioneDTO::getNumOrd)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (foundInCorsoOrders.size() == 1) {
|
||||
OrdineLavorazioneDTO ordineLavorazioneDTO = ordiniLavorazioneInCorso.get(0);
|
||||
udsMtbColt
|
||||
.setDataOrd(ordineLavorazioneDTO.getDataOrd())
|
||||
.setNumOrd(ordineLavorazioneDTO.getNumOrd());
|
||||
}
|
||||
}
|
||||
|
||||
droolsDataCompleting.complete(udsMtbColt, multiDBTransactionManager.getPrimaryConnection(), requestDataDTO.getUsername());
|
||||
|
||||
return udsMtbColt;
|
||||
}
|
||||
|
||||
public CloseUDSLavorazioneResponseDTO closeUDS(CloseUDSLavorazioneRequestDTO closeUDSRequestDTO) throws Exception {
|
||||
userSession.checkUser();
|
||||
@@ -275,12 +158,12 @@ public class WMSLavorazioneService {
|
||||
.setGestione(insertUDSRowRequestDTO.getTargetMtbColt().getGestione());
|
||||
targetMtbColt.setOperation(OperationType.SELECT_OBJECT);
|
||||
entityProcessor.processEntity(targetMtbColt, multiDBTransactionManager);
|
||||
targetMtbColt.setOperation(OperationType.NO_OP);
|
||||
|
||||
insertUDSRowRequestDTO.setTargetMtbColt(targetMtbColt);
|
||||
|
||||
InsertUDSRowResponseDTO generatedMovement = insertUDSRowMovement(insertUDSRowRequestDTO);
|
||||
InsertUDSRowResponseDTO generatedMovement = WMSUtility.insertUDSLavorazioneRowMovement(multiDBTransactionManager.getPrimaryConnection(), insertUDSRowRequestDTO, userSession.getUsername());
|
||||
|
||||
targetMtbColt.setOperation(OperationType.UPDATE);
|
||||
entityProcessor.processEntity(targetMtbColt, true, multiDBTransactionManager);
|
||||
|
||||
targetMtbColt.getMtbColr().forEach(x -> x.setOperation(OperationType.SELECT_OBJECT));
|
||||
@@ -290,94 +173,6 @@ public class WMSLavorazioneService {
|
||||
return generatedMovement;
|
||||
}
|
||||
|
||||
public InsertUDSRowResponseDTO insertUDSRowMovement(InsertUDSRowRequestDTO insertUDSRowRequestDTO) throws Exception {
|
||||
userSession.checkUser();
|
||||
|
||||
//Prendo solo la chiave
|
||||
MtbColt targetMtbColt = insertUDSRowRequestDTO.getTargetMtbColt();
|
||||
|
||||
MtbAart mtbAart = WMSUtility.getArticoloByCodMart(insertUDSRowRequestDTO.getCodMart(), multiDBTransactionManager.getPrimaryConnection());
|
||||
if (mtbAart == null)
|
||||
throw new InvalidArticoloException(insertUDSRowRequestDTO.getCodMart());
|
||||
|
||||
MtbColrInfoProd mtbColrInfoProd = null;
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(insertUDSRowRequestDTO.getContrassegnoDa())) {
|
||||
mtbColrInfoProd = new MtbColrInfoProd()
|
||||
.setContrassegnoDa(insertUDSRowRequestDTO.getContrassegnoDa());
|
||||
mtbColrInfoProd.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
}
|
||||
|
||||
final MtbColr targetMtbColr = new MtbColr()
|
||||
.setCausale(MtbColr.Causale.DEFAULT)
|
||||
.setCodMart(mtbAart.getCodMart())
|
||||
.setPartitaMag(insertUDSRowRequestDTO.getPartitaMag())
|
||||
.setDataScadPartita(UtilityLocalDate.localDateToDate(insertUDSRowRequestDTO.getDataScad()))
|
||||
.setQtaCol(insertUDSRowRequestDTO.getQtaTot())
|
||||
.setQtaCnf(insertUDSRowRequestDTO.getQtaCnf())
|
||||
.setNumCnf(insertUDSRowRequestDTO.getNumCnf())
|
||||
.setDescrizione(mtbAart.getDescrizioneEstesa())
|
||||
.setUtente(userSession.getUsername())
|
||||
.setDataOrd(insertUDSRowRequestDTO.getDataOrd())
|
||||
.setNumOrd(insertUDSRowRequestDTO.getNumOrd())
|
||||
.setRigaOrd(insertUDSRowRequestDTO.getRigaOrd())
|
||||
.setDatetimeRow(UtilityLocalDate.isNull(insertUDSRowRequestDTO.getDatetimeRow(), UtilityLocalDate.getNowTime()))
|
||||
.setCodJcom(insertUDSRowRequestDTO.getCodJcom())
|
||||
.setMtbColrInfoProd(mtbColrInfoProd);
|
||||
targetMtbColr.setOperation(OperationType.INSERT);
|
||||
targetMtbColt.getMtbColr().add(targetMtbColr);
|
||||
|
||||
if (insertUDSRowRequestDTO.getSourceMtbColr() != null) {
|
||||
MtbColr sourceMtbColr = insertUDSRowRequestDTO.getSourceMtbColr();
|
||||
|
||||
MtbColt sourceMtbColt = new MtbColt(
|
||||
sourceMtbColr.getGestione(),
|
||||
sourceMtbColr.getDataCollo(),
|
||||
sourceMtbColr.getNumCollo(),
|
||||
sourceMtbColr.getSerCollo());
|
||||
sourceMtbColt.setOperation(OperationType.SELECT_OBJECT);
|
||||
|
||||
entityProcessor.processEntity(sourceMtbColt, true, multiDBTransactionManager);
|
||||
|
||||
if (UtilityString.isNullOrEmpty(targetMtbColt.getCodTcol()) && !UtilityString.isNullOrEmpty(sourceMtbColt.getCodTcol()))
|
||||
targetMtbColt.setCodTcol(sourceMtbColt.getCodTcol());
|
||||
|
||||
targetMtbColr
|
||||
// .setCodJcom(UtilityString.emptyStr2Null(sourceMtbColr.getCodJcom()))
|
||||
.setSerColloRif(sourceMtbColr.getSerCollo())
|
||||
.setDataColloRif(sourceMtbColr.getDataCollo())
|
||||
.setNumColloRif(sourceMtbColr.getNumCollo())
|
||||
.setGestioneRif(sourceMtbColr.getGestione());
|
||||
|
||||
if (sourceMtbColr.getPesoNettoKg() != null) {
|
||||
//Proporzione
|
||||
BigDecimal pesoNettoKg = UtilityBigDecimal.divide(UtilityBigDecimal.multiply(insertUDSRowRequestDTO.getQtaTot(), sourceMtbColr.getPesoNettoKg()), sourceMtbColr.getQtaCol());
|
||||
targetMtbColr.setPesoNettoKg(pesoNettoKg);
|
||||
}
|
||||
|
||||
if (sourceMtbColr.getPesoLordoKg() != null) {
|
||||
//Proporzione
|
||||
BigDecimal pesoLordoKg = UtilityBigDecimal.divide(UtilityBigDecimal.multiply(insertUDSRowRequestDTO.getQtaTot(), sourceMtbColr.getPesoLordoKg()), sourceMtbColr.getQtaCol());
|
||||
targetMtbColr.setPesoLordoKg(pesoLordoKg);
|
||||
}
|
||||
|
||||
targetMtbColr
|
||||
.setPosizioneOut(sourceMtbColr.getPosizioneIn())
|
||||
.setCodMdepOut(sourceMtbColr.getCodMdepIn())
|
||||
.setBarcodeUlOut(sourceMtbColr.getBarcodeUlIn());
|
||||
|
||||
//Non valorizzo i campi IN perchè si è ritenuto errato negli L-
|
||||
// .setBarcodeUlIn(targetMtbColt.getBarcodeUl())
|
||||
// .setPosizioneIn(targetMtbColt.getPosizione())
|
||||
// .setCodMdepIn(targetMtbColt.getCodMdep());
|
||||
}
|
||||
|
||||
droolsDataCompleting.complete(targetMtbColt, multiDBTransactionManager.getPrimaryConnection(), requestDataDTO.getUsername());
|
||||
|
||||
return new InsertUDSRowResponseDTO()
|
||||
.setSavedMtbColr(targetMtbColr);
|
||||
}
|
||||
|
||||
|
||||
public InsertUDSRowsResponseDTO insertUDSRows(InsertUDSRowsRequestDTO inputData) throws Exception {
|
||||
if (!userSession.isAttivo()) {
|
||||
@@ -399,7 +194,7 @@ public class WMSLavorazioneService {
|
||||
.setGestione(inputData.getTargetMtbColt().getGestione());
|
||||
targetMtbColt.setOperation(OperationType.SELECT_OBJECT);
|
||||
entityProcessor.processEntity(targetMtbColt, true, multiDBTransactionManager);
|
||||
|
||||
targetMtbColt.setOperation(OperationType.NO_OP);
|
||||
|
||||
for (InsertUDSRowRequestDTO row : inputData.getRows()) {
|
||||
|
||||
@@ -985,7 +780,7 @@ public class WMSLavorazioneService {
|
||||
.setGestione(articoloProdotto.getOrdine().getGestione())));
|
||||
|
||||
|
||||
MtbColt newUds = createUDSMovement(createUdsRequestDTO);
|
||||
MtbColt newUds = WMSUtility.createUDSLavorazioneMovement(multiDBTransactionManager, createUdsRequestDTO, userSession.getUsername());
|
||||
newUds.setOperation(OperationType.INSERT);
|
||||
newUdsToSave.add(newUds);
|
||||
articoloProdotto.setScarichiProduzione(Collections.singletonList(newUds));
|
||||
@@ -1037,7 +832,7 @@ public class WMSLavorazioneService {
|
||||
final Tuple2<ArrayList<MtbColr>, ArrayList<MtbColr>> generatedMovements = WMSUtility.generateSpostaArtsTraUlMovements(
|
||||
udsMtbColtClone, newUds.getBarcodeUl(), newUds.getCodMdep(), newUds.getPosizione(), newUds.getGestione(), false, requestDataDTO, false);
|
||||
|
||||
List<MtbColr> generatedMovementsInNewUds = generatedMovements.getSecond();
|
||||
List<MtbColr> generatedMovementsInNewUds = generatedMovements.getV2();
|
||||
generatedMovementsInNewUds.forEach(x -> x.setOperation(OperationType.INSERT));
|
||||
|
||||
oldScarico.setQtaCol(oldScarico.getQtaCol().subtract(qtaDaScaricare))
|
||||
@@ -1102,7 +897,7 @@ public class WMSLavorazioneService {
|
||||
if (!notProcessedRowPresentInSourceMtbColtToUpdate)
|
||||
originalUdsMateriaPrima.getMtbColr().add(notProcessedRow);
|
||||
|
||||
latestUdsGenerated.getMtbColr().addAll(generatedMovements.getSecond());
|
||||
latestUdsGenerated.getMtbColr().addAll(generatedMovements.getV2());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1157,11 +952,11 @@ public class WMSLavorazioneService {
|
||||
public CreateUDSResponseDTO createUDSWithRows(CreateUDSWithRowsRequestDTO data) throws Exception {
|
||||
userSession.checkUser();
|
||||
|
||||
MtbColt uds = this.createUDSMovement(data);
|
||||
MtbColt uds = WMSUtility.createUDSLavorazioneMovement(multiDBTransactionManager, data, userSession.getUsername());
|
||||
|
||||
for (InsertUDSRowRequestDTO row : data.getUdsRows()) {
|
||||
row.setTargetMtbColt(uds);
|
||||
insertUDSRowMovement(row);
|
||||
WMSUtility.insertUDSLavorazioneRowMovement(multiDBTransactionManager.getPrimaryConnection(), row, userSession.getUsername());
|
||||
}
|
||||
|
||||
entityProcessor.processEntity(uds, true, multiDBTransactionManager);
|
||||
|
||||
@@ -246,6 +246,7 @@ public class WMSSpedizioneService {
|
||||
.setGestione(insertUDSRowRequestDTO.getTargetMtbColt().getGestione());
|
||||
targetMtbColt.setOperation(OperationType.SELECT_OBJECT);
|
||||
entityProcessor.processEntity(targetMtbColt, multiDBTransactionManager);
|
||||
targetMtbColt.setOperation(OperationType.NO_OP);
|
||||
|
||||
insertUDSRowRequestDTO.setTargetMtbColt(targetMtbColt);
|
||||
|
||||
@@ -292,17 +293,23 @@ public class WMSSpedizioneService {
|
||||
if (insertUDSRowRequestDTO.getSourceMtbColr() != null) {
|
||||
MtbColr sourceMtbColr = insertUDSRowRequestDTO.getSourceMtbColr();
|
||||
|
||||
MtbColt sourceMtbColt = new MtbColt(
|
||||
String sqlCodTcol = Query.format("SELECT cod_tcol\n" +
|
||||
"FROM mtb_colt\n" +
|
||||
"WHERE gestione = {}\n" +
|
||||
" AND data_collo = {}\n" +
|
||||
" AND num_collo = {}\n" +
|
||||
" AND ser_collo = {}",
|
||||
sourceMtbColr.getGestione(),
|
||||
sourceMtbColr.getDataCollo(),
|
||||
sourceMtbColr.getNumCollo(),
|
||||
sourceMtbColr.getSerCollo());
|
||||
sourceMtbColt.setOperation(OperationType.SELECT_OBJECT);
|
||||
|
||||
entityProcessor.processEntity(sourceMtbColt, multiDBTransactionManager);
|
||||
final String sourceCodTcol = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sqlCodTcol);
|
||||
|
||||
if (UtilityString.isNullOrEmpty(targetMtbColt.getCodTcol()) && !UtilityString.isNullOrEmpty(sourceMtbColt.getCodTcol()))
|
||||
targetMtbColt.setCodTcol(sourceMtbColt.getCodTcol());
|
||||
if (UtilityString.isNullOrEmpty(targetMtbColt.getCodTcol()) && !UtilityString.isNullOrEmpty(sourceCodTcol)) {
|
||||
targetMtbColt.setCodTcol(sourceCodTcol);
|
||||
targetMtbColt.setOperation(OperationType.UPDATE);
|
||||
}
|
||||
|
||||
targetMtbColr
|
||||
.setCodJcom(UtilityString.emptyStr2Null(sourceMtbColr.getCodJcom()))
|
||||
|
||||
Reference in New Issue
Block a user