Compare commits
1 Commits
feature/up
...
update/byp
| Author | SHA1 | Date | |
|---|---|---|---|
| 9cb7a5e7a3 |
@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Axelor Business Solutions
|
||||
*
|
||||
* Copyright (C) 2019 Axelor (<http://axelor.com>).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.axelor.apps.qvm.exception;
|
||||
|
||||
/** Interface of Exceptions. Enum all exception of axelor-human-resource. */
|
||||
public interface IExceptionMessage {
|
||||
|
||||
static final String ORIGIN_ALREDY_USED = /*$$(*/
|
||||
"origin alredy used : %s" /*)*/;
|
||||
|
||||
}
|
||||
@ -1,48 +0,0 @@
|
||||
package com.axelor.apps.qvm.job;
|
||||
|
||||
import com.axelor.exception.service.TraceBackService;
|
||||
import com.axelor.inject.Beans;
|
||||
import java.util.List;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.quartz.SchedulerException;
|
||||
import com.axelor.apps.qvm.service.QvmOperationService;
|
||||
import com.axelor.apps.qvm.service.QvmOperationServiceImpl;
|
||||
public class CalculateCountdownJob implements Job {
|
||||
private final Logger log = LoggerFactory.getLogger(CalculateCountdownJob.class);
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException{
|
||||
|
||||
if (isRunning(context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
log.debug("Calculating operation countdown ...");
|
||||
Beans.get(QvmOperationServiceImpl.class).updateAllCountdowns();
|
||||
}catch(Exception e){
|
||||
log.error("Error while operation countdown");
|
||||
TraceBackService.trace(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean isRunning(JobExecutionContext context) {
|
||||
try {
|
||||
return context
|
||||
.getScheduler()
|
||||
.getCurrentlyExecutingJobs()
|
||||
.stream()
|
||||
.anyMatch(
|
||||
j ->
|
||||
j.getTrigger().equals(context.getTrigger())
|
||||
&& !j.getFireInstanceId().equals(context.getFireInstanceId()));
|
||||
} catch (SchedulerException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -39,7 +39,4 @@ public interface QvmOperationService {
|
||||
@Transactional
|
||||
public QvmOperation createNextOperation(QvmOperation operation, Long userId)
|
||||
throws AxelorException;
|
||||
|
||||
@Transactional
|
||||
public void updateAllCountdowns()throws AxelorException;
|
||||
}
|
||||
|
||||
@ -29,20 +29,10 @@ import com.axelor.inject.Beans;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.persist.Transactional;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.axelor.apps.qvm.exception.IExceptionMessage;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
public class QvmOperationServiceImpl implements QvmOperationService {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(QvmOperationServiceImpl.class);
|
||||
@Inject protected SequenceService sequenceService;
|
||||
|
||||
@Inject
|
||||
private QvmOperationRepository qvmOperationRepo;
|
||||
@Transactional
|
||||
public QvmOperation createCalibrationSeq(Company company) throws AxelorException {
|
||||
|
||||
@ -113,69 +103,36 @@ public class QvmOperationServiceImpl implements QvmOperationService {
|
||||
return calibration;
|
||||
}
|
||||
|
||||
public QvmOperation createNextOperation(QvmOperation operation, Long userId) throws AxelorException{
|
||||
public QvmOperation createNextOperation(QvmOperation operation, Long userId) {
|
||||
QvmOperation nextOperation = Beans.get(QvmOperationRepository.class).copy(operation, true);
|
||||
if (operation != null) {
|
||||
List<QvmOperation> operations = qvmOperationRepo.all()
|
||||
.filter("self.operationOrigin = :serialNumber")
|
||||
.bind("serialNumber", operation.getSerialNumber())
|
||||
.fetch();
|
||||
int size = operations.size();
|
||||
if (size == 0){
|
||||
log.debug("Creating next operation");
|
||||
try{
|
||||
nextOperation.setStatusSelect(1);
|
||||
nextOperation.setOperationOrigin(operation.getSerialNumber());
|
||||
nextOperation.setCreationType(2);
|
||||
nextOperation.setPastOperationDate(operation.getOperationDate());
|
||||
nextOperation.setOperationDate(operation.getOperationDueDate());
|
||||
if (operation.getOperationFrequency() == 1){
|
||||
nextOperation.setOperationDueDate(operation.getOperationDueDate().plusYears(1));
|
||||
nextOperation.setCountdown(364);}
|
||||
if (operation.getOperationFrequency() == 2){
|
||||
nextOperation.setOperationDueDate(operation.getOperationDueDate().plusMonths(1));
|
||||
nextOperation.setCountdown(31);}
|
||||
if (operation.getOperationFrequency() == 3){
|
||||
nextOperation.setOperationDueDate(operation.getOperationDueDate().plusMonths(6));
|
||||
nextOperation.setCountdown(183);}
|
||||
nextOperation.setSerialNumber(null);
|
||||
nextOperation.setCreationType(2);
|
||||
try {
|
||||
nextOperation.setStatusSelect(1);
|
||||
nextOperation.setOperationOrigin(operation.getSerialNumber());
|
||||
nextOperation.setCreationType(2);
|
||||
nextOperation.setPastOperationDate(operation.getOperationDate());
|
||||
nextOperation.setOperationDate(operation.getOperationDueDate());
|
||||
if (operation.getOperationFrequency() == 1) {
|
||||
nextOperation.setOperationDueDate(operation.getOperationDueDate().plusYears(1));
|
||||
nextOperation.setCountdown(364);
|
||||
}
|
||||
catch (Exception exception){
|
||||
log.error("Error while creating next operation");
|
||||
System.out.println(exception);
|
||||
}}else{
|
||||
log.debug("Origin alredy used");
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_NO_UNIQUE_KEY,
|
||||
I18n.get(IExceptionMessage.ORIGIN_ALREDY_USED),
|
||||
operation.getSerialNumber());
|
||||
if (operation.getOperationFrequency() == 2) {
|
||||
nextOperation.setOperationDueDate(operation.getOperationDueDate().plusMonths(1));
|
||||
nextOperation.setCountdown(31);
|
||||
}
|
||||
if (operation.getOperationFrequency() == 3) {
|
||||
nextOperation.setOperationDueDate(operation.getOperationDueDate().plusMonths(6));
|
||||
nextOperation.setCountdown(183);
|
||||
}
|
||||
System.out.println(
|
||||
"operation.getOperationFrequency : " + operation.getOperationFrequency());
|
||||
nextOperation.setSerialNumber(null);
|
||||
nextOperation.setCreationType(2);
|
||||
} catch (Exception exception) {
|
||||
System.out.println(exception);
|
||||
}
|
||||
}
|
||||
System.out.println("Create next operation : "+nextOperation);
|
||||
// Beans.get(QvmOperationRepository.class).save(nextOperation);
|
||||
return nextOperation;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void updateCountdown(QvmOperation operation, LocalDate today) {
|
||||
if (operation.getOperationDate() != null) {
|
||||
|
||||
LocalDate operationDate = operation.getOperationDate();
|
||||
int daysBetween = (int) ChronoUnit.DAYS.between(today, operationDate);
|
||||
operation.setCountdown(daysBetween);
|
||||
qvmOperationRepo.save(operation);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAllCountdowns() {
|
||||
List<QvmOperation> operations = qvmOperationRepo.all()
|
||||
.filter("self.operationDate IS NOT NULL AND self.statusSelect = :status")
|
||||
.bind("status", 2)
|
||||
.fetch();
|
||||
LocalDate today = LocalDate.now();
|
||||
for (QvmOperation operation : operations){
|
||||
System.out.println("operation : "+operation);
|
||||
updateCountdown(operation,today);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,14 +165,4 @@ public class QvmOperationController {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateCountdowns(ActionRequest request, ActionResponse response) {
|
||||
try {
|
||||
Beans.get(QvmOperationService.class).updateAllCountdowns();
|
||||
} catch (AxelorException e) {
|
||||
TraceBackService.trace(e);
|
||||
response.setError(e.getMessage());
|
||||
}
|
||||
response.setFlash("Countdowns updated successfully");
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,6 +121,18 @@ public interface StockLocationLineService {
|
||||
public StockLocationLine getOrCreateStockLocationLine(
|
||||
StockLocation stockLocation, Product product);
|
||||
|
||||
/**
|
||||
* Getting the stock location line : We check if the location has a detailed line for a given
|
||||
* product. If no detailed location line is found, we create it.
|
||||
*
|
||||
* @param stockLocation A location
|
||||
* @param product A product
|
||||
* @param unit A unit
|
||||
* @return The found or created location line
|
||||
*/
|
||||
public StockLocationLine getOrCreateStockLocationLine(
|
||||
StockLocation stockLocation, Product product, Unit unit);
|
||||
|
||||
/**
|
||||
* Getting the detailed stock location line : We check if the location has a detailed line for a
|
||||
* given product, product variant and tracking number. If no detailed location line is found, we
|
||||
@ -134,6 +146,20 @@ public interface StockLocationLineService {
|
||||
public StockLocationLine getOrCreateDetailLocationLine(
|
||||
StockLocation detailLocation, Product product, TrackingNumber trackingNumber);
|
||||
|
||||
/**
|
||||
* Getting the detailed stock location line : We check if the location has a detailed line for a
|
||||
* given product, product variant and tracking number. If no detailed location line is found, we
|
||||
* create it.
|
||||
*
|
||||
* @param detailLocation A location
|
||||
* @param product A product
|
||||
* @param trackingNumber A tracking number
|
||||
* @param unit A unit
|
||||
* @return The found or created detailed location line
|
||||
*/
|
||||
public StockLocationLine getOrCreateDetailLocationLine(
|
||||
StockLocation detailLocation, Product product, TrackingNumber trackingNumber, Unit unit);
|
||||
|
||||
/**
|
||||
* Allow to get the location line of a given product in a given location.
|
||||
*
|
||||
|
||||
@ -48,6 +48,7 @@ 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;
|
||||
|
||||
@ -131,52 +132,101 @@ public class StockLocationLineServiceImpl implements StockLocationLineService {
|
||||
boolean isIncrement,
|
||||
LocalDate lastFutureStockMoveDate)
|
||||
throws AxelorException {
|
||||
|
||||
List<Long> listOfIds = Arrays.asList(12L, 97L, 99L, 103L, 105L);
|
||||
|
||||
StockLocationLine stockLocationLine = this.getOrCreateStockLocationLine(stockLocation, product);
|
||||
System.out.println("*****************uniiiiiiit***************");
|
||||
System.out.println(stockLocation.getId());
|
||||
|
||||
if (stockLocationLine == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
UnitConversionService unitConversionService = Beans.get(UnitConversionService.class);
|
||||
Unit stockLocationLineUnit = stockLocationLine.getUnit();
|
||||
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;
|
||||
}
|
||||
|
||||
if (stockLocationLineUnit != null && !stockLocationLineUnit.equals(stockMoveLineUnit)) {
|
||||
qty =
|
||||
unitConversionService.convert(
|
||||
stockMoveLineUnit, stockLocationLineUnit, qty, qty.scale(), product);
|
||||
}
|
||||
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);
|
||||
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);
|
||||
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 {
|
||||
maxStockRules(product, qty, stockLocationLine, current, future);
|
||||
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);
|
||||
}
|
||||
|
||||
stockLocationLine =
|
||||
this.updateLocation(
|
||||
stockLocationLine,
|
||||
stockMoveLineUnit,
|
||||
product,
|
||||
qty,
|
||||
current,
|
||||
future,
|
||||
isIncrement,
|
||||
lastFutureStockMoveDate);
|
||||
|
||||
this.checkStockMin(stockLocationLine, false);
|
||||
|
||||
stockLocationLineRepo.save(stockLocationLine);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -264,49 +314,100 @@ public class StockLocationLineServiceImpl implements StockLocationLineService {
|
||||
LocalDate lastFutureStockMoveDate,
|
||||
TrackingNumber trackingNumber)
|
||||
throws AxelorException {
|
||||
|
||||
List<Long> listOfIds = Arrays.asList(12L, 97L, 99L, 103L, 105L);
|
||||
|
||||
StockLocationLine detailLocationLine =
|
||||
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 =
|
||||
this.getOrCreateDetailLocationLine(stockLocation, product, trackingNumber);
|
||||
|
||||
if (detailLocationLine == null) {
|
||||
return;
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
@ -419,6 +520,31 @@ 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) {
|
||||
@ -443,6 +569,31 @@ 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) {
|
||||
|
||||
@ -458,6 +609,21 @@ 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) {
|
||||
|
||||
@ -489,6 +655,24 @@ 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) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user