|
|
|
|
@ -48,7 +48,6 @@ import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
@ -132,101 +131,52 @@ public class StockLocationLineServiceImpl implements StockLocationLineService {
|
|
|
|
|
boolean isIncrement,
|
|
|
|
|
LocalDate lastFutureStockMoveDate)
|
|
|
|
|
throws AxelorException {
|
|
|
|
|
|
|
|
|
|
List<Long> listOfIds = Arrays.asList(12L, 97L, 99L, 103L, 105L);
|
|
|
|
|
|
|
|
|
|
System.out.println("*****************uniiiiiiit***************");
|
|
|
|
|
System.out.println(stockLocation.getId());
|
|
|
|
|
StockLocationLine stockLocationLine = this.getOrCreateStockLocationLine(stockLocation, product);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(listOfIds.contains(stockLocation.getId())){
|
|
|
|
|
StockLocationLine stockLocationLine = this.getOrCreateStockLocationLine(stockLocation, product, stockMoveLineUnit);
|
|
|
|
|
System.out.println("*****************LABOOOOOOOOOOOO***************");
|
|
|
|
|
System.out.println(stockLocation.getId());
|
|
|
|
|
if (stockLocationLine == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UnitConversionService unitConversionService = Beans.get(UnitConversionService.class);
|
|
|
|
|
Unit stockLocationLineUnit = stockLocationLine.getUnit();
|
|
|
|
|
|
|
|
|
|
LOG.debug(
|
|
|
|
|
"Mise à jour du stock : Entrepot? {}, Produit? {}, Quantité? {}, Actuel? {}, Futur? {}, Incrément? {}, Date? {} ",
|
|
|
|
|
stockLocation.getName(),
|
|
|
|
|
product.getCode(),
|
|
|
|
|
qty,
|
|
|
|
|
current,
|
|
|
|
|
future,
|
|
|
|
|
isIncrement,
|
|
|
|
|
lastFutureStockMoveDate);
|
|
|
|
|
|
|
|
|
|
if (!isIncrement) {
|
|
|
|
|
minStockRules(product, qty, stockLocationLine, current, future);
|
|
|
|
|
} else {
|
|
|
|
|
maxStockRules(product, qty, stockLocationLine, current, future);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stockLocationLine =
|
|
|
|
|
this.updateLocation(
|
|
|
|
|
stockLocationLine,
|
|
|
|
|
stockMoveLineUnit,
|
|
|
|
|
product,
|
|
|
|
|
qty,
|
|
|
|
|
current,
|
|
|
|
|
future,
|
|
|
|
|
isIncrement,
|
|
|
|
|
lastFutureStockMoveDate);
|
|
|
|
|
|
|
|
|
|
this.checkStockMin(stockLocationLine, false);
|
|
|
|
|
|
|
|
|
|
stockLocationLineRepo.save(stockLocationLine);
|
|
|
|
|
} else {
|
|
|
|
|
StockLocationLine stockLocationLine = this.getOrCreateStockLocationLine(stockLocation, product);
|
|
|
|
|
|
|
|
|
|
if (stockLocationLine == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UnitConversionService unitConversionService = Beans.get(UnitConversionService.class);
|
|
|
|
|
Unit stockLocationLineUnit = stockLocationLine.getUnit();
|
|
|
|
|
|
|
|
|
|
if (stockLocationLineUnit != null && !stockLocationLineUnit.equals(stockMoveLineUnit)) {
|
|
|
|
|
qty =
|
|
|
|
|
unitConversionService.convert(
|
|
|
|
|
stockMoveLineUnit, stockLocationLineUnit, qty, qty.scale(), product);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LOG.debug(
|
|
|
|
|
"Mise à jour du stock : Entrepot? {}, Produit? {}, Quantité? {}, Actuel? {}, Futur? {}, Incrément? {}, Date? {} ",
|
|
|
|
|
stockLocation.getName(),
|
|
|
|
|
product.getCode(),
|
|
|
|
|
qty,
|
|
|
|
|
current,
|
|
|
|
|
future,
|
|
|
|
|
isIncrement,
|
|
|
|
|
lastFutureStockMoveDate);
|
|
|
|
|
|
|
|
|
|
if (!isIncrement) {
|
|
|
|
|
minStockRules(product, qty, stockLocationLine, current, future);
|
|
|
|
|
} else {
|
|
|
|
|
maxStockRules(product, qty, stockLocationLine, current, future);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stockLocationLine =
|
|
|
|
|
this.updateLocation(
|
|
|
|
|
stockLocationLine,
|
|
|
|
|
stockMoveLineUnit,
|
|
|
|
|
product,
|
|
|
|
|
qty,
|
|
|
|
|
current,
|
|
|
|
|
future,
|
|
|
|
|
isIncrement,
|
|
|
|
|
lastFutureStockMoveDate);
|
|
|
|
|
|
|
|
|
|
this.checkStockMin(stockLocationLine, false);
|
|
|
|
|
|
|
|
|
|
stockLocationLineRepo.save(stockLocationLine);
|
|
|
|
|
if (stockLocationLine == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UnitConversionService unitConversionService = Beans.get(UnitConversionService.class);
|
|
|
|
|
Unit stockLocationLineUnit = stockLocationLine.getUnit();
|
|
|
|
|
|
|
|
|
|
if (stockLocationLineUnit != null && !stockLocationLineUnit.equals(stockMoveLineUnit)) {
|
|
|
|
|
qty =
|
|
|
|
|
unitConversionService.convert(
|
|
|
|
|
stockMoveLineUnit, stockLocationLineUnit, qty, qty.scale(), product);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LOG.debug(
|
|
|
|
|
"Mise à jour du stock : Entrepot? {}, Produit? {}, Quantité? {}, Actuel? {}, Futur? {}, Incrément? {}, Date? {} ",
|
|
|
|
|
stockLocation.getName(),
|
|
|
|
|
product.getCode(),
|
|
|
|
|
qty,
|
|
|
|
|
current,
|
|
|
|
|
future,
|
|
|
|
|
isIncrement,
|
|
|
|
|
lastFutureStockMoveDate);
|
|
|
|
|
|
|
|
|
|
if (!isIncrement) {
|
|
|
|
|
minStockRules(product, qty, stockLocationLine, current, future);
|
|
|
|
|
} else {
|
|
|
|
|
maxStockRules(product, qty, stockLocationLine, current, future);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stockLocationLine =
|
|
|
|
|
this.updateLocation(
|
|
|
|
|
stockLocationLine,
|
|
|
|
|
stockMoveLineUnit,
|
|
|
|
|
product,
|
|
|
|
|
qty,
|
|
|
|
|
current,
|
|
|
|
|
future,
|
|
|
|
|
isIncrement,
|
|
|
|
|
lastFutureStockMoveDate);
|
|
|
|
|
|
|
|
|
|
this.checkStockMin(stockLocationLine, false);
|
|
|
|
|
|
|
|
|
|
stockLocationLineRepo.save(stockLocationLine);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@ -314,100 +264,49 @@ public class StockLocationLineServiceImpl implements StockLocationLineService {
|
|
|
|
|
LocalDate lastFutureStockMoveDate,
|
|
|
|
|
TrackingNumber trackingNumber)
|
|
|
|
|
throws AxelorException {
|
|
|
|
|
|
|
|
|
|
List<Long> listOfIds = Arrays.asList(12L, 97L, 99L, 103L, 105L);
|
|
|
|
|
|
|
|
|
|
System.out.println("*****************uniiiiiiit***************");
|
|
|
|
|
System.out.println(stockLocation.getId());
|
|
|
|
|
|
|
|
|
|
if(listOfIds.contains(stockLocation.getId())){
|
|
|
|
|
StockLocationLine detailLocationLine =
|
|
|
|
|
this.getOrCreateDetailLocationLine(stockLocation, product, trackingNumber, stockMoveLineUnit);
|
|
|
|
|
|
|
|
|
|
if (detailLocationLine == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UnitConversionService unitConversionService = Beans.get(UnitConversionService.class);
|
|
|
|
|
Unit stockLocationLineUnit = detailLocationLine.getUnit();
|
|
|
|
|
|
|
|
|
|
if (stockLocationLineUnit != null && !stockLocationLineUnit.equals(stockMoveLineUnit)) {
|
|
|
|
|
qty =
|
|
|
|
|
unitConversionService.convert(
|
|
|
|
|
stockMoveLineUnit, stockLocationLineUnit, qty, qty.scale(), product);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LOG.debug(
|
|
|
|
|
"Mise à jour du detail du stock : Entrepot? {}, Produit? {}, Quantité? {}, Actuel? {}, Futur? {}, Incrément? {}, Date? {}, Num de suivi? {} ",
|
|
|
|
|
stockLocation.getName(),
|
|
|
|
|
product.getCode(),
|
|
|
|
|
qty,
|
|
|
|
|
current,
|
|
|
|
|
future,
|
|
|
|
|
isIncrement,
|
|
|
|
|
lastFutureStockMoveDate,
|
|
|
|
|
trackingNumber);
|
|
|
|
|
|
|
|
|
|
detailLocationLine =
|
|
|
|
|
this.updateLocation(
|
|
|
|
|
detailLocationLine,
|
|
|
|
|
stockMoveLineUnit,
|
|
|
|
|
product,
|
|
|
|
|
qty,
|
|
|
|
|
current,
|
|
|
|
|
future,
|
|
|
|
|
isIncrement,
|
|
|
|
|
lastFutureStockMoveDate);
|
|
|
|
|
|
|
|
|
|
this.checkStockMin(detailLocationLine, true);
|
|
|
|
|
// detailLocationLine.setConformitySelect(StockLocationRepository.TYPE_QUARANTINE);
|
|
|
|
|
|
|
|
|
|
stockLocationLineRepo.save(detailLocationLine);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
StockLocationLine detailLocationLine =
|
|
|
|
|
StockLocationLine detailLocationLine =
|
|
|
|
|
this.getOrCreateDetailLocationLine(stockLocation, product, trackingNumber);
|
|
|
|
|
|
|
|
|
|
if (detailLocationLine == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UnitConversionService unitConversionService = Beans.get(UnitConversionService.class);
|
|
|
|
|
Unit stockLocationLineUnit = detailLocationLine.getUnit();
|
|
|
|
|
|
|
|
|
|
if (stockLocationLineUnit != null && !stockLocationLineUnit.equals(stockMoveLineUnit)) {
|
|
|
|
|
qty =
|
|
|
|
|
unitConversionService.convert(
|
|
|
|
|
stockMoveLineUnit, stockLocationLineUnit, qty, qty.scale(), product);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LOG.debug(
|
|
|
|
|
"Mise à jour du detail du stock : Entrepot? {}, Produit? {}, Quantité? {}, Actuel? {}, Futur? {}, Incrément? {}, Date? {}, Num de suivi? {} ",
|
|
|
|
|
stockLocation.getName(),
|
|
|
|
|
product.getCode(),
|
|
|
|
|
qty,
|
|
|
|
|
current,
|
|
|
|
|
future,
|
|
|
|
|
isIncrement,
|
|
|
|
|
lastFutureStockMoveDate,
|
|
|
|
|
trackingNumber);
|
|
|
|
|
|
|
|
|
|
detailLocationLine =
|
|
|
|
|
this.updateLocation(
|
|
|
|
|
detailLocationLine,
|
|
|
|
|
stockMoveLineUnit,
|
|
|
|
|
product,
|
|
|
|
|
qty,
|
|
|
|
|
current,
|
|
|
|
|
future,
|
|
|
|
|
isIncrement,
|
|
|
|
|
lastFutureStockMoveDate);
|
|
|
|
|
|
|
|
|
|
this.checkStockMin(detailLocationLine, true);
|
|
|
|
|
// detailLocationLine.setConformitySelect(StockLocationRepository.TYPE_QUARANTINE);
|
|
|
|
|
|
|
|
|
|
stockLocationLineRepo.save(detailLocationLine);
|
|
|
|
|
if (detailLocationLine == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UnitConversionService unitConversionService = Beans.get(UnitConversionService.class);
|
|
|
|
|
Unit stockLocationLineUnit = detailLocationLine.getUnit();
|
|
|
|
|
|
|
|
|
|
if (stockLocationLineUnit != null && !stockLocationLineUnit.equals(stockMoveLineUnit)) {
|
|
|
|
|
qty =
|
|
|
|
|
unitConversionService.convert(
|
|
|
|
|
stockMoveLineUnit, stockLocationLineUnit, qty, qty.scale(), product);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LOG.debug(
|
|
|
|
|
"Mise à jour du detail du stock : Entrepot? {}, Produit? {}, Quantité? {}, Actuel? {}, Futur? {}, Incrément? {}, Date? {}, Num de suivi? {} ",
|
|
|
|
|
stockLocation.getName(),
|
|
|
|
|
product.getCode(),
|
|
|
|
|
qty,
|
|
|
|
|
current,
|
|
|
|
|
future,
|
|
|
|
|
isIncrement,
|
|
|
|
|
lastFutureStockMoveDate,
|
|
|
|
|
trackingNumber);
|
|
|
|
|
|
|
|
|
|
detailLocationLine =
|
|
|
|
|
this.updateLocation(
|
|
|
|
|
detailLocationLine,
|
|
|
|
|
stockMoveLineUnit,
|
|
|
|
|
product,
|
|
|
|
|
qty,
|
|
|
|
|
current,
|
|
|
|
|
future,
|
|
|
|
|
isIncrement,
|
|
|
|
|
lastFutureStockMoveDate);
|
|
|
|
|
|
|
|
|
|
this.checkStockMin(detailLocationLine, true);
|
|
|
|
|
// detailLocationLine.setConformitySelect(StockLocationRepository.TYPE_QUARANTINE);
|
|
|
|
|
|
|
|
|
|
stockLocationLineRepo.save(detailLocationLine);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@ -520,31 +419,6 @@ public class StockLocationLineServiceImpl implements StockLocationLineService {
|
|
|
|
|
return stockLocationLine;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public StockLocationLine getOrCreateStockLocationLine(
|
|
|
|
|
StockLocation stockLocation, Product product, Unit unit) {
|
|
|
|
|
|
|
|
|
|
if (!product.getStockManaged()) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StockLocationLine stockLocationLine = this.getStockLocationLine(stockLocation, product, unit);
|
|
|
|
|
|
|
|
|
|
if (stockLocationLine == null) {
|
|
|
|
|
stockLocationLine = this.createLocationLine(stockLocation, product);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LOG.debug(
|
|
|
|
|
"Récupération ligne de stock: Entrepot? {}, Produit? {}, Qté actuelle? {}, Qté future? {}, Date? {} ",
|
|
|
|
|
stockLocationLine.getStockLocation().getName(),
|
|
|
|
|
product.getCode(),
|
|
|
|
|
stockLocationLine.getCurrentQty(),
|
|
|
|
|
stockLocationLine.getFutureQty(),
|
|
|
|
|
stockLocationLine.getLastFutureStockMoveDate());
|
|
|
|
|
|
|
|
|
|
return stockLocationLine;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public StockLocationLine getOrCreateDetailLocationLine(
|
|
|
|
|
StockLocation detailLocation, Product product, TrackingNumber trackingNumber) {
|
|
|
|
|
@ -569,31 +443,6 @@ public class StockLocationLineServiceImpl implements StockLocationLineService {
|
|
|
|
|
return detailLocationLine;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public StockLocationLine getOrCreateDetailLocationLine(
|
|
|
|
|
StockLocation detailLocation, Product product, TrackingNumber trackingNumber, Unit unit) {
|
|
|
|
|
|
|
|
|
|
StockLocationLine detailLocationLine =
|
|
|
|
|
this.getDetailLocationLine(detailLocation, product, trackingNumber, unit);
|
|
|
|
|
|
|
|
|
|
if (detailLocationLine == null) {
|
|
|
|
|
|
|
|
|
|
detailLocationLine = this.createDetailLocationLine(detailLocation, product, trackingNumber);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LOG.debug(
|
|
|
|
|
"Récupération ligne de détail de stock: Entrepot? {}, Produit? {}, Qté actuelle? {}, Qté future? {}, Date? {}, Variante? {}, Num de suivi? {} ",
|
|
|
|
|
detailLocationLine.getDetailsStockLocation().getName(),
|
|
|
|
|
product.getCode(),
|
|
|
|
|
detailLocationLine.getCurrentQty(),
|
|
|
|
|
detailLocationLine.getFutureQty(),
|
|
|
|
|
detailLocationLine.getLastFutureStockMoveDate(),
|
|
|
|
|
detailLocationLine.getTrackingNumber());
|
|
|
|
|
|
|
|
|
|
return detailLocationLine;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public StockLocationLine getStockLocationLine(StockLocation stockLocation, Product product) {
|
|
|
|
|
|
|
|
|
|
@ -609,21 +458,6 @@ public class StockLocationLineServiceImpl implements StockLocationLineService {
|
|
|
|
|
.fetchOne();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public StockLocationLine getStockLocationLine(StockLocation stockLocation, Product product, Unit unit) {
|
|
|
|
|
|
|
|
|
|
if (product == null || !product.getStockManaged()) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return stockLocationLineRepo
|
|
|
|
|
.all()
|
|
|
|
|
.filter("self.stockLocation.id = :_stockLocationId " + "AND self.product.id = :_productId " + "AND self.unit.id = :_unitId ")
|
|
|
|
|
.bind("_stockLocationId", stockLocation.getId())
|
|
|
|
|
.bind("_productId", product.getId())
|
|
|
|
|
.bind("_unitId", unit.getId())
|
|
|
|
|
.fetchOne();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<StockLocationLine> getStockLocationLines(Product product) {
|
|
|
|
|
|
|
|
|
|
@ -655,24 +489,6 @@ public class StockLocationLineServiceImpl implements StockLocationLineService {
|
|
|
|
|
.fetchOne();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public StockLocationLine getDetailLocationLine(
|
|
|
|
|
StockLocation stockLocation, Product product, TrackingNumber trackingNumber, Unit unit) {
|
|
|
|
|
|
|
|
|
|
return stockLocationLineRepo
|
|
|
|
|
.all()
|
|
|
|
|
.filter(
|
|
|
|
|
"self.detailsStockLocation.id = :_stockLocationId "
|
|
|
|
|
+ "AND self.product.id = :_productId "
|
|
|
|
|
+ "AND self.trackingNumber.id = :_trackingNumberId "
|
|
|
|
|
+ "AND self.unit.id = :_unitId "
|
|
|
|
|
)
|
|
|
|
|
.bind("_stockLocationId", stockLocation.getId())
|
|
|
|
|
.bind("_productId", product.getId())
|
|
|
|
|
.bind("_trackingNumberId", trackingNumber.getId())
|
|
|
|
|
.bind("_unitId", unit.getId())
|
|
|
|
|
.fetchOne();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public StockLocationLine createLocationLine(StockLocation stockLocation, Product product) {
|
|
|
|
|
|
|
|
|
|
|