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();
|
final List<String> trackedTables = retrieveTrackedTables();
|
||||||
|
|
||||||
HashMap<Long, DetectedChangeDataDTO> changesByVersion = new HashMap<>();
|
HashMap<Long, List<DetectedChangeDataDTO>> changesByVersion = new HashMap<>();
|
||||||
|
|
||||||
for (String trackedTable : trackedTables) {
|
for (String trackedTable : trackedTables) {
|
||||||
long minValidVersion = getMinValidVersion(trackedTable);
|
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);
|
throw new SQLException("Change Tracking on table " + trackedTable + " has been reset. Current version: " + currentVersion + ", Min valid version: " + minValidVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final List<DetectedChangeDataDTO> detectedChanges = retrieveChangeList(trackedTable);
|
final List<DetectedChangeDataDTO> detectedChanges = retrieveChangeList(trackedTable);
|
||||||
|
|
||||||
detectedChanges.forEach(detectedChangeDataDTO -> {
|
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);
|
logTrace("Detected " + changesByVersion.size() + " changes since version " + currentVersion);
|
||||||
@@ -154,15 +153,16 @@ public class DbmsChangeTracker {
|
|||||||
dispatchChanges(changesByVersion);
|
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()
|
final List<Long> sortedChanges = changesByVersion.keySet().stream()
|
||||||
.sorted()
|
.sorted()
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
|
||||||
for (Long changeId : sortedChanges) {
|
for (Long changeId : sortedChanges) {
|
||||||
final DetectedChangeDataDTO detectedChange = changesByVersion.get(changeId);
|
final List<DetectedChangeDataDTO> detectedChanges = changesByVersion.get(changeId);
|
||||||
|
|
||||||
|
for (DetectedChangeDataDTO detectedChange : detectedChanges) {
|
||||||
switch (detectedChange.getSysChangeOperation()) {
|
switch (detectedChange.getSysChangeOperation()) {
|
||||||
case INSERT:
|
case INSERT:
|
||||||
if (eventListener != null)
|
if (eventListener != null)
|
||||||
@@ -179,7 +179,7 @@ public class DbmsChangeTracker {
|
|||||||
eventListener.onDeleteDetected(detectedChange.getTableName(), detectedChange.getPrimaryKey());
|
eventListener.onDeleteDetected(detectedChange.getTableName(), detectedChange.getPrimaryKey());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
currentVersion = changeId;
|
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.Connection;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
import it.integry.ems_model.entity.*;
|
import it.integry.ems_model.entity.*;
|
||||||
import it.integry.ems_model.exception.DataConverterNotFoundException;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.springframework.context.ApplicationEventPublisher;
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -32,6 +30,7 @@ public class DbmsChangeTrackerComponent {
|
|||||||
add(MtbAart.ENTITY);
|
add(MtbAart.ENTITY);
|
||||||
add(MtbAartBarCode.ENTITY);
|
add(MtbAartBarCode.ENTITY);
|
||||||
add(MtbUntMis.ENTITY);
|
add(MtbUntMis.ENTITY);
|
||||||
|
add(MtbDepo.ENTITY);
|
||||||
add(StbEditLimit.ENTITY);
|
add(StbEditLimit.ENTITY);
|
||||||
add(StbGestSetup.ENTITY);
|
add(StbGestSetup.ENTITY);
|
||||||
add(StbGestSetupDepo.ENTITY);
|
add(StbGestSetupDepo.ENTITY);
|
||||||
@@ -60,11 +59,13 @@ public class DbmsChangeTrackerComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void enableAllChangeTracking() throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
private void enableAllChangeTracking() throws Exception {
|
||||||
for (Map.Entry<IntegryCustomerDB, DbmsChangeTracker> entrySet : activeChangeTrackers.entrySet()) {
|
for (Map.Entry<IntegryCustomerDB, DbmsChangeTracker> entrySet : activeChangeTrackers.entrySet()) {
|
||||||
IntegryCustomerDB customerDB = entrySet.getKey();
|
IntegryCustomerDB customerDB = entrySet.getKey();
|
||||||
DbmsChangeTracker dbmsChangeTracker = entrySet.getValue();
|
DbmsChangeTracker dbmsChangeTracker = entrySet.getValue();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
dbmsChangeTracker.enableTrackerInDbms();
|
dbmsChangeTracker.enableTrackerInDbms();
|
||||||
|
|
||||||
for (String tableName : trackedTables) {
|
for (String tableName : trackedTables) {
|
||||||
@@ -91,6 +92,9 @@ public class DbmsChangeTrackerComponent {
|
|||||||
});
|
});
|
||||||
|
|
||||||
dbmsChangeTracker.startTracking();
|
dbmsChangeTracker.startTracking();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new Exception("Errore durante l'abilitazione del DbmsChangeTracker per il customer: " + customerDB.getValue(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public class EntityCacheComponent implements ApplicationListener {
|
|||||||
put(MtbAart.ENTITY, MtbAart.class);
|
put(MtbAart.ENTITY, MtbAart.class);
|
||||||
put(MtbAartBarCode.ENTITY, MtbAartBarCode.class);
|
put(MtbAartBarCode.ENTITY, MtbAartBarCode.class);
|
||||||
put(MtbUntMis.ENTITY, MtbUntMis.class);
|
put(MtbUntMis.ENTITY, MtbUntMis.class);
|
||||||
|
put(MtbDepo.ENTITY, MtbDepo.class);
|
||||||
put(StbEditLimit.ENTITY, StbEditLimit.class);
|
put(StbEditLimit.ENTITY, StbEditLimit.class);
|
||||||
put(StbGestSetup.ENTITY, StbGestSetup.class);
|
put(StbGestSetup.ENTITY, StbGestSetup.class);
|
||||||
put(StbGestSetupDepo.ENTITY, StbGestSetupDepo.class);
|
put(StbGestSetupDepo.ENTITY, StbGestSetupDepo.class);
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public enum IntegryCustomerDB {
|
|||||||
Gramm_Gramm("gramm_peppe"),
|
Gramm_Gramm("gramm_peppe"),
|
||||||
Gramm_PrimeOlive("primeolive"),
|
Gramm_PrimeOlive("primeolive"),
|
||||||
Gramm_ProveStage("grammprovestage"),
|
Gramm_ProveStage("grammprovestage"),
|
||||||
Gramm_2MHolding("2M_HOLDING"),
|
Gramm_2MHolding("dueemme"),
|
||||||
|
|
||||||
|
|
||||||
Idrotecnica_Idrotecnica("idrotecnica"),
|
Idrotecnica_Idrotecnica("idrotecnica"),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package it.integry.ems.sync.MultiDBTransaction;
|
package it.integry.ems.sync.MultiDBTransaction;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
@@ -354,4 +355,8 @@ public class Connection implements java.sql.Connection {
|
|||||||
isInternalDb = internalDb;
|
isInternalDb = internalDb;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IntegryCustomerDB getIntegryCustomerDB() {
|
||||||
|
return IntegryCustomerDB.parse(getDbName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ public class UserSession {
|
|||||||
try {
|
try {
|
||||||
currentUser = UtilityUser.getCurrentUser(multiDBTransactionManager, requestDataDTO);
|
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) {
|
} catch (Exception ex) {
|
||||||
//logger.trace(UserSession.class.getName() + ": errore durante l'inizializzazione", 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._context.ApplicationContextProvider;
|
||||||
import it.integry.ems.dto.EntityPermissionsDTO;
|
import it.integry.ems.dto.EntityPermissionsDTO;
|
||||||
|
import it.integry.ems.dynamic_cache.EntityCacheComponent;
|
||||||
import it.integry.ems.exception.PrimaryDatabaseNotPresentException;
|
import it.integry.ems.exception.PrimaryDatabaseNotPresentException;
|
||||||
import it.integry.ems.javabeans.RequestDataDTO;
|
import it.integry.ems.javabeans.RequestDataDTO;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
import it.integry.ems.service.EntityProcessor;
|
import it.integry.ems.service.EntityProcessor;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
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();
|
if (userDTO == null) throw new InvalidUserException();
|
||||||
|
|
||||||
String sql = "SELECT md.* FROM " + MtbDepo.ENTITY + " md " +
|
final EntityCacheComponent entityCacheComponent = ApplicationContextProvider.getApplicationContext().getBean(EntityCacheComponent.class);
|
||||||
" 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);
|
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());
|
logger.trace("Nessun deposito trovato per l'utente " + userDTO.getUsername());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return depos.get(0);
|
return defaultDepo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -208,7 +208,13 @@ public class MtbColr extends EntityBase implements EquatableEntityInterface<MtbC
|
|||||||
|
|
||||||
|
|
||||||
public MtbColrKey getKey() {
|
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() {
|
public MtbColtKey getKey() {
|
||||||
return UtilityString.isNullOrEmpty(gestione) ||
|
return UtilityString.isNullOrEmpty(gestione) ||
|
||||||
UtilityString.isNullOrEmpty(dataCollo) ||
|
UtilityString.isNullOrEmpty(serCollo) ||
|
||||||
dataCollo == null ||
|
dataCollo == null ||
|
||||||
numCollo == null ?
|
numCollo == null ?
|
||||||
null :
|
null :
|
||||||
new MtbColtKey(gestione, serCollo, getDataCollo(), numCollo);
|
new MtbColtKey(gestione, serCollo, dataCollo, numCollo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGestione() {
|
public String getGestione() {
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ public class RefreshTokenService {
|
|||||||
HashMap<String, AuthTokenProfileDetails> profilesData = new HashMap<>();
|
HashMap<String, AuthTokenProfileDetails> profilesData = new HashMap<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MtbDepo defaultUserDepo = UtilityUser.getDefaultUserDepo(multiDBTransactionManager, user);
|
MtbDepo defaultUserDepo = UtilityUser.getDefaultUserDepo(multiDBTransactionManager.getPrimaryConnection().getIntegryCustomerDB(), user);
|
||||||
|
|
||||||
if (defaultUserDepo != null) {
|
if (defaultUserDepo != null) {
|
||||||
AuthTokenProfileDetails authTokenProfileDetails = new AuthTokenProfileDetails(AuthTokenDepoDetails.fromMtbDepo(defaultUserDepo));
|
AuthTokenProfileDetails authTokenProfileDetails = new AuthTokenProfileDetails(AuthTokenDepoDetails.fromMtbDepo(defaultUserDepo));
|
||||||
|
|||||||
@@ -591,7 +591,7 @@ end
|
|||||||
rule "completeFlagSetNumProtDtbTipi"
|
rule "completeFlagSetNumProtDtbTipi"
|
||||||
when
|
when
|
||||||
eval(completeRulesEnabled)
|
eval(completeRulesEnabled)
|
||||||
$dTip : DtbTipi((gestione == "V" || codCcau != null) && flagSetNumProt)
|
$dTip : DtbTipi((gestione == "V" || codCcau != null) && (flagSetNumProt == null || flagSetNumProt))
|
||||||
then
|
then
|
||||||
modify ( $dTip ) { setFlagSetNumProt(false) }
|
modify ( $dTip ) { setFlagSetNumProt(false) }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import it.integry.ems_model.entity.*;
|
|||||||
import it.integry.ems_model.types.OperationType;
|
import it.integry.ems_model.types.OperationType;
|
||||||
import it.integry.ems_model.utility.*;
|
import it.integry.ems_model.utility.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Scope;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -61,10 +60,14 @@ public class MovimentiContabiliService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ctbMovt.getCtbMovr() != null) {
|
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);
|
ctbMovt.setOperation(OperationType.SELECT_OBJECT);
|
||||||
entityProcessor.processEntity(ctbMovt, multiDBTransactionManager);
|
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());
|
String sql = Query.format("SELECT azione_su_partita FROM ctb_caus WHERE cod_ccau = %s", ctbMovt.getCodCcau());
|
||||||
Integer azioneSuPartita = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
Integer azioneSuPartita = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||||
@@ -80,7 +83,7 @@ public class MovimentiContabiliService {
|
|||||||
Objects.equals(x.getNumDoc(), ctbMovt.getNumDoc()))
|
Objects.equals(x.getNumDoc(), ctbMovt.getNumDoc()))
|
||||||
.collect(Collectors.toList());
|
.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 != null) {
|
||||||
if (rigaPaga.getCtbScad() == null || rigaPaga.getCtbScad().isEmpty()) {
|
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.rules.completing.ConfigActivityRules;
|
||||||
import it.integry.ems.service.EntityProcessor;
|
import it.integry.ems.service.EntityProcessor;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
|
import it.integry.ems.user.UserSession;
|
||||||
import it.integry.ems.utility.UtilityEntity;
|
import it.integry.ems.utility.UtilityEntity;
|
||||||
import it.integry.ems_model.base.EntityBase;
|
import it.integry.ems_model.base.EntityBase;
|
||||||
import it.integry.ems_model.config.EmsRestConstants;
|
import it.integry.ems_model.config.EmsRestConstants;
|
||||||
@@ -36,7 +37,6 @@ import org.springframework.stereotype.Service;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -77,6 +77,9 @@ public class DocumentiDirettiService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private WMSGenericService wmsGenericService;
|
private WMSGenericService wmsGenericService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserSession userSession;
|
||||||
|
|
||||||
public List<EntityBase> save(DtbDoct dtbDoct, boolean isInsert) throws Exception {
|
public List<EntityBase> save(DtbDoct dtbDoct, boolean isInsert) throws Exception {
|
||||||
List<EntityBase> entityList = new ArrayList<>();
|
List<EntityBase> entityList = new ArrayList<>();
|
||||||
|
|
||||||
@@ -1170,13 +1173,15 @@ public class DocumentiDirettiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isLavorazione) {
|
if (isLavorazione) {
|
||||||
uds = wmsLavorazioneService.createUDSMovement(
|
uds = WMSUtility.createUDSLavorazioneMovement(
|
||||||
|
multiDBTransactionManager,
|
||||||
new CreateUDSRequestDTO()
|
new CreateUDSRequestDTO()
|
||||||
.setCodAnag(createUDSFromDocuments.getCodAnag())
|
.setCodAnag(createUDSFromDocuments.getCodAnag())
|
||||||
.setCodMdep(createUDSFromDocuments.getCodMdep())
|
.setCodMdep(createUDSFromDocuments.getCodMdep())
|
||||||
.setCodVdes(createUDSFromDocuments.getCodVdes())
|
.setCodVdes(createUDSFromDocuments.getCodVdes())
|
||||||
.setCausaleCollo(CreateUDSRequestDTO.Causale.SCARICO)
|
.setCausaleCollo(CreateUDSRequestDTO.Causale.SCARICO)
|
||||||
.setOrders(createUDSRequestOrderDTO));
|
.setOrders(createUDSRequestOrderDTO),
|
||||||
|
userSession.getUsername());
|
||||||
} else {
|
} else {
|
||||||
uds = wmsSpedizioneService.createUDSMovement(
|
uds = wmsSpedizioneService.createUDSMovement(
|
||||||
new CreateUDSRequestDTO()
|
new CreateUDSRequestDTO()
|
||||||
@@ -1200,7 +1205,8 @@ public class DocumentiDirettiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isLavorazione) {
|
if (isLavorazione) {
|
||||||
wmsLavorazioneService.insertUDSRowMovement(
|
WMSUtility.insertUDSLavorazioneRowMovement(
|
||||||
|
multiDBTransactionManager.getPrimaryConnection(),
|
||||||
new InsertUDSRowRequestDTO()
|
new InsertUDSRowRequestDTO()
|
||||||
.setCodMart(ulRowDTO.getCodMart())
|
.setCodMart(ulRowDTO.getCodMart())
|
||||||
.setPartitaMag(ulRowDTO.getPartitaMag())
|
.setPartitaMag(ulRowDTO.getPartitaMag())
|
||||||
@@ -1209,7 +1215,8 @@ public class DocumentiDirettiService {
|
|||||||
.setNumOrd(ulRowDTO.getNumOrd())
|
.setNumOrd(ulRowDTO.getNumOrd())
|
||||||
.setRigaOrd(ulRowDTO.getRigaOrd())
|
.setRigaOrd(ulRowDTO.getRigaOrd())
|
||||||
.setTargetMtbColt(uds)
|
.setTargetMtbColt(uds)
|
||||||
.setSourceMtbColr(sourceMtbColr));
|
.setSourceMtbColr(sourceMtbColr),
|
||||||
|
userSession.getUsername());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
wmsSpedizioneService.insertUDSRowMovement(
|
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.dto.MvwSitArtUdcDetInventarioDTO;
|
||||||
import it.integry.ems.retail.wms.generic.service.WMSGiacenzaULService;
|
import it.integry.ems.retail.wms.generic.service.WMSGiacenzaULService;
|
||||||
import it.integry.ems.service.EntityProcessor;
|
import it.integry.ems.service.EntityProcessor;
|
||||||
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
import it.integry.ems.utility.UtilityDebug;
|
import it.integry.ems.utility.UtilityDebug;
|
||||||
import it.integry.ems_model.config.EmsRestConstants;
|
import it.integry.ems_model.config.EmsRestConstants;
|
||||||
@@ -37,10 +38,12 @@ public class EuroforkDataSyncronizerService {
|
|||||||
|
|
||||||
private final WMSGiacenzaULService wmsGiacenzaULService;
|
private final WMSGiacenzaULService wmsGiacenzaULService;
|
||||||
private final EntityProcessor entityProcessor;
|
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.wmsGiacenzaULService = wmsGiacenzaULService;
|
||||||
this.entityProcessor = entityProcessor;
|
this.entityProcessor = entityProcessor;
|
||||||
|
this.settingsModel = settingsModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
@@ -54,6 +57,11 @@ public class EuroforkDataSyncronizerService {
|
|||||||
if (UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer())
|
if (UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!settingsModel.isPrimaryInstance())
|
||||||
|
return;
|
||||||
|
|
||||||
|
logger.trace("Avvio sincronizzazione posizioni Eurofork -> Integry");
|
||||||
|
|
||||||
String sqlRetrieveEuroforkStatus = "SELECT barcode_ul,\n" +
|
String sqlRetrieveEuroforkStatus = "SELECT barcode_ul,\n" +
|
||||||
" posizione,\n" +
|
" posizione,\n" +
|
||||||
" IIF(ColumnSide = 'L',\n" +
|
" IIF(ColumnSide = 'L',\n" +
|
||||||
@@ -158,6 +166,7 @@ public class EuroforkDataSyncronizerService {
|
|||||||
throw new IllegalStateException("Errore durante la creazione del movimento di cambio posizione per UL: " + ulRow.getKey());
|
throw new IllegalStateException("Errore durante la creazione del movimento di cambio posizione per UL: " + ulRow.getKey());
|
||||||
|
|
||||||
|
|
||||||
|
if (ulRow.getValue().getV3() != null)
|
||||||
cambiaPosizioneUlMovement.get(0)
|
cambiaPosizioneUlMovement.get(0)
|
||||||
.setDatetimeRow(dateTimePosizionamento.plusSeconds(ulRow.getValue().getV3()));
|
.setDatetimeRow(dateTimePosizionamento.plusSeconds(ulRow.getValue().getV3()));
|
||||||
|
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ public class OrdiniDaApprov {
|
|||||||
String descrizioneFabb = rs.getString(5);
|
String descrizioneFabb = rs.getString(5);
|
||||||
String codForn = rs.getString(6);
|
String codForn = rs.getString(6);
|
||||||
String codAlis = rs.getString(7);
|
String codAlis = rs.getString(7);
|
||||||
LocalDateTime dataCons = UtilityLocalDate.localDateTimeFromDate(rs.getDate(8));
|
LocalDateTime dataCons = UtilityLocalDate.localDateTimeFromDate(rs.getTimestamp(8));
|
||||||
String untMis = rs.getString(9);
|
String untMis = rs.getString(9);
|
||||||
BigDecimal rapConv = rs.getBigDecimal(10);
|
BigDecimal rapConv = rs.getBigDecimal(10);
|
||||||
BigDecimal qtaAcq = rs.getBigDecimal(11);
|
BigDecimal qtaAcq = rs.getBigDecimal(11);
|
||||||
|
|||||||
@@ -445,8 +445,8 @@ public class ProductionOrdersLifecycleService {
|
|||||||
dtbOrdSteps
|
dtbOrdSteps
|
||||||
.setCodJfas(ripianificaOrdineLavRequestDTO.getCodJfasNew())
|
.setCodJfas(ripianificaOrdineLavRequestDTO.getCodJfasNew())
|
||||||
.setIdRiga(0)
|
.setIdRiga(0)
|
||||||
.setDataIniz(null)
|
.setDataIniz(LocalDateTime.now())
|
||||||
.setDataFine(null)
|
.setDataFine(LocalDateTime.now())
|
||||||
.setFlagStepAttivo("S");
|
.setFlagStepAttivo("S");
|
||||||
dtbOrdSteps.setOperation(OperationType.INSERT);
|
dtbOrdSteps.setOperation(OperationType.INSERT);
|
||||||
dtbOrdl.getDtbOrdSteps().add(dtbOrdSteps);
|
dtbOrdl.getDtbOrdSteps().add(dtbOrdSteps);
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import com.annimon.stream.Optional;
|
|||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
import groovy.lang.Tuple2;
|
import groovy.lang.Tuple2;
|
||||||
import it.integry.ems._context.ApplicationContextProvider;
|
import it.integry.ems._context.ApplicationContextProvider;
|
||||||
|
import it.integry.ems.dynamic_cache.EntityCacheComponent;
|
||||||
import it.integry.ems.exception.MissingDataException;
|
import it.integry.ems.exception.MissingDataException;
|
||||||
import it.integry.ems.javabeans.RequestDataDTO;
|
import it.integry.ems.javabeans.RequestDataDTO;
|
||||||
import it.integry.ems.retail.wms.dto.InsertUDCRowRequestDTO;
|
import it.integry.ems.retail.wms.dto.*;
|
||||||
import it.integry.ems.retail.wms.dto.InsertUDCRowResponseDTO;
|
|
||||||
import it.integry.ems.retail.wms.exceptions.InvalidArticoloException;
|
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.MvwSitArtUdcDetInventarioDTO;
|
||||||
import it.integry.ems.retail.wms.generic.dto.SpostaArtsTraULResponseDTO;
|
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.businessLogic.enums.FlagSezione;
|
||||||
import it.integry.ems.rules.completing.PackagesRules;
|
import it.integry.ems.rules.completing.PackagesRules;
|
||||||
import it.integry.ems.service.EntityProcessor;
|
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.Connection;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
import it.integry.ems.utility.UtilityEntity;
|
import it.integry.ems.utility.UtilityEntity;
|
||||||
import it.integry.ems_model.entity.*;
|
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.ConverterNotConfiguredException;
|
||||||
import it.integry.ems_model.exception.RulesNotCompiledException;
|
import it.integry.ems_model.exception.RulesNotCompiledException;
|
||||||
import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
|
import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
|
||||||
@@ -35,10 +38,7 @@ import java.io.IOException;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WMSUtility {
|
public class WMSUtility {
|
||||||
@@ -154,6 +154,229 @@ public class WMSUtility {
|
|||||||
return mtbColtMap;
|
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 {
|
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);
|
return createCambiaPosizioneUlMovements(connection, Collections.singletonList(sscc), changeCodMdep, newCodMdep, newPosizione);
|
||||||
}
|
}
|
||||||
@@ -423,7 +646,7 @@ public class WMSUtility {
|
|||||||
|
|
||||||
targetMtbColt.setOperation(OperationType.SELECT_OBJECT);
|
targetMtbColt.setOperation(OperationType.SELECT_OBJECT);
|
||||||
entityProcessor.processEntity(targetMtbColt, true, multiDBTransactionManager);
|
entityProcessor.processEntity(targetMtbColt, true, multiDBTransactionManager);
|
||||||
|
targetMtbColt.setOperation(OperationType.NO_OP);
|
||||||
|
|
||||||
final MtbColr targetMtbColr = new MtbColr()
|
final MtbColr targetMtbColr = new MtbColr()
|
||||||
.setCausale(MtbColr.Causale.DEFAULT)
|
.setCausale(MtbColr.Causale.DEFAULT)
|
||||||
@@ -511,13 +734,18 @@ public class WMSUtility {
|
|||||||
public static List<MtbAart> getArticoliByCodMarts(List<String> codMarts, Connection connection) throws Exception {
|
public static List<MtbAart> getArticoliByCodMarts(List<String> codMarts, Connection connection) throws Exception {
|
||||||
if (codMarts == null || codMarts.isEmpty()) return null;
|
if (codMarts == null || codMarts.isEmpty()) return null;
|
||||||
|
|
||||||
String query =
|
final EntityCacheComponent entityCacheComponent = ApplicationContextProvider.getApplicationContext().getBean(EntityCacheComponent.class);
|
||||||
"SELECT DISTINCT mtb_aart.*"
|
|
||||||
+ " FROM mtb_aart "
|
|
||||||
+ " WHERE cod_mart IN (" + UtilityQuery.concatStringFieldsWithSeparator(codMarts, ",") + ")";
|
|
||||||
|
|
||||||
|
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);
|
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));
|
.collect(Collectors.toMap(MtbAart::getCodMart, a -> a, (a, b) -> a, HashMap::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<MtbUntMis> getUntMisFromCod(List<String> untMisCods, Connection connection) throws Exception {
|
public static List<MtbUntMis> getUntMisFromCod(List<String> untMisCods, Connection connection) {
|
||||||
List<String> untMisStrings = Stream.of(untMisCods)
|
List<String> untMisStrings = untMisCods.stream()
|
||||||
.withoutNulls()
|
.filter(Objects::nonNull)
|
||||||
.distinct()
|
.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<>();
|
return mtbUntMis != null ? mtbUntMis : new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -576,12 +809,18 @@ public class WMSUtility {
|
|||||||
" FROM mtb_colt WHERE barcode_ul = " + UtilityDB.valueToString(barcodeUl));
|
" 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()
|
codMarts = codMarts.stream()
|
||||||
.distinct().collect(Collectors.toList());
|
.distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
String sql = "SELECT * FROM mtb_aart_bar_code WHERE cod_mart IN (" + UtilityQuery.concatStringFieldsWithSeparator(codMarts, ",") + ")";
|
final EntityCacheComponent entityCacheComponent = ApplicationContextProvider.getApplicationContext().getBean(EntityCacheComponent.class);
|
||||||
final List<MtbAartBarCode> barCodeList = UtilityDB.executeSimpleQueryDTO(conn, sql, MtbAartBarCode.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<>();
|
return barCodeList != null ? barCodeList : new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -294,6 +294,7 @@ public class WMSAccettazioneService {
|
|||||||
MtbColt targetMtbColt = inputData.getTargetMtbColt();
|
MtbColt targetMtbColt = inputData.getTargetMtbColt();
|
||||||
targetMtbColt.setOperation(OperationType.SELECT_OBJECT);
|
targetMtbColt.setOperation(OperationType.SELECT_OBJECT);
|
||||||
entityProcessor.processEntity(targetMtbColt, multiDBTransactionManager);
|
entityProcessor.processEntity(targetMtbColt, multiDBTransactionManager);
|
||||||
|
targetMtbColt.setOperation(OperationType.NO_OP);
|
||||||
|
|
||||||
for (InsertUDCRowRequestDTO insertUDCRowRequestDTO : inputData.getRows()) {
|
for (InsertUDCRowRequestDTO insertUDCRowRequestDTO : inputData.getRows()) {
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ public class RetrieveArtsInGiacenzaByArtRequestDTO {
|
|||||||
private String codCol;
|
private String codCol;
|
||||||
private String codTagl;
|
private String codTagl;
|
||||||
private String codJcom;
|
private String codJcom;
|
||||||
|
private String codJfas;
|
||||||
|
|
||||||
private String barcodeUl;
|
private String barcodeUl;
|
||||||
private String posizione;
|
private String posizione;
|
||||||
@@ -73,6 +74,15 @@ public class RetrieveArtsInGiacenzaByArtRequestDTO {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCodJfas() {
|
||||||
|
return codJfas;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RetrieveArtsInGiacenzaByArtRequestDTO setCodJfas(String codJfas) {
|
||||||
|
this.codJfas = codJfas;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public String getBarcodeUl() {
|
public String getBarcodeUl() {
|
||||||
return barcodeUl;
|
return barcodeUl;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1534,7 +1534,7 @@ public class WMSGenericService {
|
|||||||
}
|
}
|
||||||
scarico.getPosizioni().add(scaricoMateriaPrimaDTO.getPosizione());
|
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);
|
mtbColtToInsert.setOperation(OperationType.NO_OP);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
mtbColtToInsert = WMSUtility.createUDSLavorazioneMovement(multiDBTransactionManager,
|
||||||
mtbColtToInsert = new MtbColt()
|
new CreateUDSRequestDTO()
|
||||||
.setMtbColr(new ArrayList<>())
|
.setCausaleCollo(CreateUDSRequestDTO.Causale.SCARICO)
|
||||||
.setGestione("L")
|
|
||||||
.setSegno(-1)
|
|
||||||
.setCodMdep(codMdep)
|
.setCodMdep(codMdep)
|
||||||
.setCodJfas(codJfas == null ? scaricoMateriaPrimaDTO.getCodJfas() : codJfas)
|
.setCodJfas(codJfas == null ? scaricoMateriaPrimaDTO.getCodJfas() : codJfas)
|
||||||
.setPosizione(scaricoMateriaPrimaDTO.getPosizione())
|
.setPosizione(scaricoMateriaPrimaDTO.getPosizione())
|
||||||
|
.setCodAnag(codAnag)
|
||||||
|
.setOrders(Collections.singletonList(new CreateUDSRequestOrderDTO()
|
||||||
.setDataOrd(scaricoMateriaPrimaDTO.getDataOrd())
|
.setDataOrd(scaricoMateriaPrimaDTO.getDataOrd())
|
||||||
.setNumOrd(scaricoMateriaPrimaDTO.getNumOrd())
|
.setNumOrd(scaricoMateriaPrimaDTO.getNumOrd())
|
||||||
.setCodAnag(codAnag);
|
.setGestione(scaricoMateriaPrimaDTO.getGestioneOrd()))),
|
||||||
mtbColtToInsert.setOperation(OperationType.INSERT_OR_UPDATE);
|
userSession.getUsername());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1653,21 +1653,19 @@ public class WMSGenericService {
|
|||||||
|
|
||||||
if (UtilityBigDecimal.equalsOrLowerThan(qtaToTake, BigDecimal.ZERO)) continue;
|
if (UtilityBigDecimal.equalsOrLowerThan(qtaToTake, BigDecimal.ZERO)) continue;
|
||||||
|
|
||||||
MtbColr mtbColr = new MtbColr()
|
final InsertUDSRowResponseDTO insertedUds = WMSUtility.insertUDSLavorazioneRowMovement(multiDBTransactionManager.getPrimaryConnection(),
|
||||||
|
new InsertUDSRowRequestDTO()
|
||||||
|
.setTargetMtbColt(mtbColtToInsert)
|
||||||
.setCodMart(giacInPosizioneItem.getCodMart())
|
.setCodMart(giacInPosizioneItem.getCodMart())
|
||||||
.setCodJcom(giacInPosizioneItem.getCodJcom())
|
.setCodJcom(giacInPosizioneItem.getCodJcom())
|
||||||
.setNumOrd(scaricoMateriaPrimaDTO.getNumOrd())
|
.setNumOrd(scaricoMateriaPrimaDTO.getNumOrd())
|
||||||
.setDataOrd(scaricoMateriaPrimaDTO.getDataOrd())
|
.setDataOrd(scaricoMateriaPrimaDTO.getDataOrd())
|
||||||
.setRigaOrd(giacInPosizioneItem.getRigaOrd())
|
.setRigaOrd(giacInPosizioneItem.getRigaOrd())
|
||||||
.setQtaCol(qtaToTake)
|
.setQtaTot(qtaToTake)
|
||||||
.setPartitaMag(giacInPosizioneItem.getPartitaMag())
|
.setPartitaMag(giacInPosizioneItem.getPartitaMag())
|
||||||
.setNumColloRif(giacInPosizioneItem.getNumCollo())
|
.setSourceMtbColr(WMSUtility.convertMvwItemToMtbColr(giacInPosizioneItem))
|
||||||
.setDataColloRif(giacInPosizioneItem.getDataCollo())
|
.setDatetimeRow(UtilityLocalDate.getNowTime()),
|
||||||
.setSerColloRif(giacInPosizioneItem.getSerCollo())
|
userSession.getUsername());
|
||||||
.setGestioneRif(giacInPosizioneItem.getGestione())
|
|
||||||
.setDatetimeRow(UtilityLocalDate.getNowTime());
|
|
||||||
mtbColr.setOperation(OperationType.INSERT);
|
|
||||||
mtbColtToInsert.getMtbColr().add(mtbColr);
|
|
||||||
|
|
||||||
qtaScaricata = qtaScaricata.add(qtaToTake);
|
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<>();
|
final List<AnomalieDTO> anomalieList = new ArrayList<>();
|
||||||
List<MtbColt> mtbColtsToInsert = new ArrayList<>();
|
List<MtbColt> mtbColtsToInsert = new ArrayList<>();
|
||||||
|
|
||||||
@@ -1755,11 +1753,16 @@ public class WMSGenericService {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
MtbColt mtbColt = Stream.of(mtbColtsToInsert).filter(x -> scaricoDaOrdine.getDataOrd().equals(x.getDataOrd()) &&
|
MtbColt mtbColt = mtbColtsToInsert
|
||||||
|
.stream()
|
||||||
|
.filter(x -> scaricoDaOrdine.getDataOrd().equals(x.getDataOrd()) &&
|
||||||
scaricoDaOrdine.getNumOrd().equals(x.getNumOrd()) &&
|
scaricoDaOrdine.getNumOrd().equals(x.getNumOrd()) &&
|
||||||
scaricoDaOrdine.getGestioneOrd().equals(x.getGestione()) &&
|
scaricoDaOrdine.getGestioneOrd().equals(x.getGestione()) &&
|
||||||
giacenza.getPosizione().equals(x.getPosizione()) &&
|
giacenza.getPosizione().equals(x.getPosizione()) &&
|
||||||
(codJfasScarico != null && codJfasScarico.equalsIgnoreCase(x.getCodJfas()))).findFirst().orElse(null);
|
(codJfasScarico != null && codJfasScarico.equalsIgnoreCase(x.getCodJfas())))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
if (mtbColt == null) {
|
if (mtbColt == null) {
|
||||||
String queryMtbColt = "SELECT *" +
|
String queryMtbColt = "SELECT *" +
|
||||||
" FROM mtb_colt" +
|
" FROM mtb_colt" +
|
||||||
@@ -1780,19 +1783,20 @@ public class WMSGenericService {
|
|||||||
mtbColt = alreadyPresentMtbColts.get(0);
|
mtbColt = alreadyPresentMtbColts.get(0);
|
||||||
mtbColt.setOperation(OperationType.NO_OP);
|
mtbColt.setOperation(OperationType.NO_OP);
|
||||||
} else {
|
} else {
|
||||||
|
mtbColt = WMSUtility.createUDSLavorazioneMovement(multiDBTransactionManager,
|
||||||
mtbColt = new MtbColt()
|
new CreateUDSRequestDTO()
|
||||||
.setMtbColr(new ArrayList<>())
|
|
||||||
.setGestione("L")
|
|
||||||
.setSegno(-1)
|
|
||||||
.setCodMdep(codMdep)
|
.setCodMdep(codMdep)
|
||||||
.setCodJfas(codJfasScarico)
|
.setCodJfas(codJfasScarico)
|
||||||
.setPosizione(giacenza.getPosizione())
|
.setPosizione(giacenza.getPosizione())
|
||||||
|
.setCodAnag(codAnag)
|
||||||
|
.setCausaleCollo(CreateUDSRequestDTO.Causale.SCARICO)
|
||||||
|
.setOrders(Collections.singletonList(new CreateUDSRequestOrderDTO()
|
||||||
.setDataOrd(scaricoDaOrdine.getDataOrd())
|
.setDataOrd(scaricoDaOrdine.getDataOrd())
|
||||||
.setNumOrd(scaricoDaOrdine.getNumOrd())
|
.setNumOrd(scaricoDaOrdine.getNumOrd())
|
||||||
.setCodAnag(codAnag);
|
.setGestione(scaricoDaOrdine.getGestioneOrd()))),
|
||||||
mtbColt.setOperation(OperationType.INSERT_OR_UPDATE);
|
userSession.getUsername());
|
||||||
}
|
}
|
||||||
|
|
||||||
mtbColtsToInsert.add(mtbColt);
|
mtbColtsToInsert.add(mtbColt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1805,21 +1809,20 @@ public class WMSGenericService {
|
|||||||
|
|
||||||
if (UtilityBigDecimal.equalsOrLowerThan(qtaToTake, BigDecimal.ZERO)) continue;
|
if (UtilityBigDecimal.equalsOrLowerThan(qtaToTake, BigDecimal.ZERO)) continue;
|
||||||
|
|
||||||
MtbColr mtbColr = new MtbColr()
|
|
||||||
|
WMSUtility.insertUDSLavorazioneRowMovement(multiDBTransactionManager.getPrimaryConnection(),
|
||||||
|
new InsertUDSRowRequestDTO()
|
||||||
|
.setTargetMtbColt(mtbColt)
|
||||||
.setCodMart(giacenza.getCodMart())
|
.setCodMart(giacenza.getCodMart())
|
||||||
.setCodJcom(giacenza.getCodJcom())
|
.setCodJcom(giacenza.getCodJcom())
|
||||||
.setNumOrd(scaricoDaOrdine.getNumOrd())
|
.setNumOrd(scaricoDaOrdine.getNumOrd())
|
||||||
.setDataOrd(scaricoDaOrdine.getDataOrd())
|
.setDataOrd(scaricoDaOrdine.getDataOrd())
|
||||||
.setRigaOrd(giacenza.getRigaOrd())
|
.setRigaOrd(giacenza.getRigaOrd())
|
||||||
.setQtaCol(qtaToTake)
|
.setQtaTot(qtaToTake)
|
||||||
.setPartitaMag(giacenza.getPartitaMag())
|
.setPartitaMag(giacenza.getPartitaMag())
|
||||||
.setNumColloRif(giacenza.getNumCollo())
|
.setSourceMtbColr(WMSUtility.convertMvwItemToMtbColr(giacenza))
|
||||||
.setDataColloRif(giacenza.getDataCollo())
|
.setDatetimeRow(UtilityLocalDate.getNowTime()),
|
||||||
.setSerColloRif(giacenza.getSerCollo())
|
userSession.getUsername());
|
||||||
.setGestioneRif(giacenza.getGestione())
|
|
||||||
.setDatetimeRow(UtilityLocalDate.getNowTime());
|
|
||||||
mtbColr.setOperation(OperationType.INSERT);
|
|
||||||
mtbColt.getMtbColr().add(mtbColr);
|
|
||||||
|
|
||||||
qtaRimanente = qtaRimanente.subtract(qtaToTake);
|
qtaRimanente = qtaRimanente.subtract(qtaToTake);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package it.integry.ems.retail.wms.generic.service;
|
package it.integry.ems.retail.wms.generic.service;
|
||||||
|
|
||||||
|
import core.utility.StringUtils;
|
||||||
import it.integry.ems.retail.wms.generic.dto.*;
|
import it.integry.ems.retail.wms.generic.dto.*;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
import it.integry.ems_model.config.EmsRestConstants;
|
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.UtilityHashMap;
|
||||||
import it.integry.ems_model.utility.UtilityQuery;
|
import it.integry.ems_model.utility.UtilityQuery;
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
import core.utility.StringUtils;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -343,6 +343,9 @@ public class WMSGiacenzaULService {
|
|||||||
if (!UtilityString.isNullOrEmpty(x.getCodJcom()))
|
if (!UtilityString.isNullOrEmpty(x.getCodJcom()))
|
||||||
map.put("sit_art.cod_jcom", 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())
|
if (x.isMandatoryPosizione())
|
||||||
map.put("sit_art.posizione", EmsRestConstants.NOT_NULL);
|
map.put("sit_art.posizione", EmsRestConstants.NOT_NULL);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package it.integry.ems.retail.wms.lavorazione.service;
|
package it.integry.ems.retail.wms.lavorazione.service;
|
||||||
|
|
||||||
import com.annimon.stream.Stream;
|
|
||||||
import groovy.lang.Tuple2;
|
import groovy.lang.Tuple2;
|
||||||
import it.integry.ems.document.dto.ArticoloProdottoDTO;
|
import it.integry.ems.document.dto.ArticoloProdottoDTO;
|
||||||
import it.integry.ems.javabeans.RequestDataDTO;
|
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.retail.wms.generic.service.WMSGiacenzaULService;
|
||||||
import it.integry.ems.rules.businessLogic.LoadColliService;
|
import it.integry.ems.rules.businessLogic.LoadColliService;
|
||||||
import it.integry.ems.rules.businessLogic.dto.LoadColliDTO;
|
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.AziendaService;
|
||||||
import it.integry.ems.service.EntityProcessor;
|
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.service.production.ProductionOrderDataHandlerService;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
import it.integry.ems.user.UserSession;
|
import it.integry.ems.user.UserSession;
|
||||||
@@ -76,12 +73,15 @@ public class WMSLavorazioneService {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AziendaService aziendaService;
|
private AziendaService aziendaService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DroolsDataCompleting droolsDataCompleting;
|
private DroolsDataCompleting droolsDataCompleting;
|
||||||
|
|
||||||
|
|
||||||
public MtbColt createUDS(CreateUDSRequestDTO createUDSRequestDTO) throws Exception {
|
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);
|
generatedMtbColt.setOperation(OperationType.INSERT);
|
||||||
entityProcessor.processEntity(generatedMtbColt, true, multiDBTransactionManager);
|
entityProcessor.processEntity(generatedMtbColt, true, multiDBTransactionManager);
|
||||||
@@ -91,124 +91,7 @@ public class WMSLavorazioneService {
|
|||||||
return generatedMtbColt;
|
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 {
|
public CloseUDSLavorazioneResponseDTO closeUDS(CloseUDSLavorazioneRequestDTO closeUDSRequestDTO) throws Exception {
|
||||||
userSession.checkUser();
|
userSession.checkUser();
|
||||||
@@ -275,12 +158,12 @@ public class WMSLavorazioneService {
|
|||||||
.setGestione(insertUDSRowRequestDTO.getTargetMtbColt().getGestione());
|
.setGestione(insertUDSRowRequestDTO.getTargetMtbColt().getGestione());
|
||||||
targetMtbColt.setOperation(OperationType.SELECT_OBJECT);
|
targetMtbColt.setOperation(OperationType.SELECT_OBJECT);
|
||||||
entityProcessor.processEntity(targetMtbColt, multiDBTransactionManager);
|
entityProcessor.processEntity(targetMtbColt, multiDBTransactionManager);
|
||||||
|
targetMtbColt.setOperation(OperationType.NO_OP);
|
||||||
|
|
||||||
insertUDSRowRequestDTO.setTargetMtbColt(targetMtbColt);
|
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);
|
entityProcessor.processEntity(targetMtbColt, true, multiDBTransactionManager);
|
||||||
|
|
||||||
targetMtbColt.getMtbColr().forEach(x -> x.setOperation(OperationType.SELECT_OBJECT));
|
targetMtbColt.getMtbColr().forEach(x -> x.setOperation(OperationType.SELECT_OBJECT));
|
||||||
@@ -290,94 +173,6 @@ public class WMSLavorazioneService {
|
|||||||
return generatedMovement;
|
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 {
|
public InsertUDSRowsResponseDTO insertUDSRows(InsertUDSRowsRequestDTO inputData) throws Exception {
|
||||||
if (!userSession.isAttivo()) {
|
if (!userSession.isAttivo()) {
|
||||||
@@ -399,7 +194,7 @@ public class WMSLavorazioneService {
|
|||||||
.setGestione(inputData.getTargetMtbColt().getGestione());
|
.setGestione(inputData.getTargetMtbColt().getGestione());
|
||||||
targetMtbColt.setOperation(OperationType.SELECT_OBJECT);
|
targetMtbColt.setOperation(OperationType.SELECT_OBJECT);
|
||||||
entityProcessor.processEntity(targetMtbColt, true, multiDBTransactionManager);
|
entityProcessor.processEntity(targetMtbColt, true, multiDBTransactionManager);
|
||||||
|
targetMtbColt.setOperation(OperationType.NO_OP);
|
||||||
|
|
||||||
for (InsertUDSRowRequestDTO row : inputData.getRows()) {
|
for (InsertUDSRowRequestDTO row : inputData.getRows()) {
|
||||||
|
|
||||||
@@ -985,7 +780,7 @@ public class WMSLavorazioneService {
|
|||||||
.setGestione(articoloProdotto.getOrdine().getGestione())));
|
.setGestione(articoloProdotto.getOrdine().getGestione())));
|
||||||
|
|
||||||
|
|
||||||
MtbColt newUds = createUDSMovement(createUdsRequestDTO);
|
MtbColt newUds = WMSUtility.createUDSLavorazioneMovement(multiDBTransactionManager, createUdsRequestDTO, userSession.getUsername());
|
||||||
newUds.setOperation(OperationType.INSERT);
|
newUds.setOperation(OperationType.INSERT);
|
||||||
newUdsToSave.add(newUds);
|
newUdsToSave.add(newUds);
|
||||||
articoloProdotto.setScarichiProduzione(Collections.singletonList(newUds));
|
articoloProdotto.setScarichiProduzione(Collections.singletonList(newUds));
|
||||||
@@ -1037,7 +832,7 @@ public class WMSLavorazioneService {
|
|||||||
final Tuple2<ArrayList<MtbColr>, ArrayList<MtbColr>> generatedMovements = WMSUtility.generateSpostaArtsTraUlMovements(
|
final Tuple2<ArrayList<MtbColr>, ArrayList<MtbColr>> generatedMovements = WMSUtility.generateSpostaArtsTraUlMovements(
|
||||||
udsMtbColtClone, newUds.getBarcodeUl(), newUds.getCodMdep(), newUds.getPosizione(), newUds.getGestione(), false, requestDataDTO, false);
|
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));
|
generatedMovementsInNewUds.forEach(x -> x.setOperation(OperationType.INSERT));
|
||||||
|
|
||||||
oldScarico.setQtaCol(oldScarico.getQtaCol().subtract(qtaDaScaricare))
|
oldScarico.setQtaCol(oldScarico.getQtaCol().subtract(qtaDaScaricare))
|
||||||
@@ -1102,7 +897,7 @@ public class WMSLavorazioneService {
|
|||||||
if (!notProcessedRowPresentInSourceMtbColtToUpdate)
|
if (!notProcessedRowPresentInSourceMtbColtToUpdate)
|
||||||
originalUdsMateriaPrima.getMtbColr().add(notProcessedRow);
|
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 {
|
public CreateUDSResponseDTO createUDSWithRows(CreateUDSWithRowsRequestDTO data) throws Exception {
|
||||||
userSession.checkUser();
|
userSession.checkUser();
|
||||||
|
|
||||||
MtbColt uds = this.createUDSMovement(data);
|
MtbColt uds = WMSUtility.createUDSLavorazioneMovement(multiDBTransactionManager, data, userSession.getUsername());
|
||||||
|
|
||||||
for (InsertUDSRowRequestDTO row : data.getUdsRows()) {
|
for (InsertUDSRowRequestDTO row : data.getUdsRows()) {
|
||||||
row.setTargetMtbColt(uds);
|
row.setTargetMtbColt(uds);
|
||||||
insertUDSRowMovement(row);
|
WMSUtility.insertUDSLavorazioneRowMovement(multiDBTransactionManager.getPrimaryConnection(), row, userSession.getUsername());
|
||||||
}
|
}
|
||||||
|
|
||||||
entityProcessor.processEntity(uds, true, multiDBTransactionManager);
|
entityProcessor.processEntity(uds, true, multiDBTransactionManager);
|
||||||
|
|||||||
@@ -246,6 +246,7 @@ public class WMSSpedizioneService {
|
|||||||
.setGestione(insertUDSRowRequestDTO.getTargetMtbColt().getGestione());
|
.setGestione(insertUDSRowRequestDTO.getTargetMtbColt().getGestione());
|
||||||
targetMtbColt.setOperation(OperationType.SELECT_OBJECT);
|
targetMtbColt.setOperation(OperationType.SELECT_OBJECT);
|
||||||
entityProcessor.processEntity(targetMtbColt, multiDBTransactionManager);
|
entityProcessor.processEntity(targetMtbColt, multiDBTransactionManager);
|
||||||
|
targetMtbColt.setOperation(OperationType.NO_OP);
|
||||||
|
|
||||||
insertUDSRowRequestDTO.setTargetMtbColt(targetMtbColt);
|
insertUDSRowRequestDTO.setTargetMtbColt(targetMtbColt);
|
||||||
|
|
||||||
@@ -292,17 +293,23 @@ public class WMSSpedizioneService {
|
|||||||
if (insertUDSRowRequestDTO.getSourceMtbColr() != null) {
|
if (insertUDSRowRequestDTO.getSourceMtbColr() != null) {
|
||||||
MtbColr sourceMtbColr = insertUDSRowRequestDTO.getSourceMtbColr();
|
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.getGestione(),
|
||||||
sourceMtbColr.getDataCollo(),
|
sourceMtbColr.getDataCollo(),
|
||||||
sourceMtbColr.getNumCollo(),
|
sourceMtbColr.getNumCollo(),
|
||||||
sourceMtbColr.getSerCollo());
|
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()))
|
if (UtilityString.isNullOrEmpty(targetMtbColt.getCodTcol()) && !UtilityString.isNullOrEmpty(sourceCodTcol)) {
|
||||||
targetMtbColt.setCodTcol(sourceMtbColt.getCodTcol());
|
targetMtbColt.setCodTcol(sourceCodTcol);
|
||||||
|
targetMtbColt.setOperation(OperationType.UPDATE);
|
||||||
|
}
|
||||||
|
|
||||||
targetMtbColr
|
targetMtbColr
|
||||||
.setCodJcom(UtilityString.emptyStr2Null(sourceMtbColr.getCodJcom()))
|
.setCodJcom(UtilityString.emptyStr2Null(sourceMtbColr.getCodJcom()))
|
||||||
|
|||||||
Reference in New Issue
Block a user