use of com.axelor.apps.production.db.ConfiguratorProdProcessLine in project axelor-open-suite by axelor.
the class ConfiguratorProdProcessLineServiceImpl method generateProdProcessLine.
@Override
public ProdProcessLine generateProdProcessLine(ConfiguratorProdProcessLine confProdProcessLine, JsonContext attributes) throws AxelorException {
if (confProdProcessLine == null) {
return null;
}
ProdProcessLine prodProcessLine = new ProdProcessLine();
BigDecimal minCapacityPerCycle;
BigDecimal maxCapacityPerCycle;
long durationPerCycle;
if (confProdProcessLine.getDefMinCapacityFormula()) {
minCapacityPerCycle = new BigDecimal(configuratorService.computeFormula(confProdProcessLine.getMinCapacityPerCycleFormula(), attributes).toString());
} else {
minCapacityPerCycle = confProdProcessLine.getMinCapacityPerCycle();
}
if (confProdProcessLine.getDefMaxCapacityFormula()) {
maxCapacityPerCycle = new BigDecimal(configuratorService.computeFormula(confProdProcessLine.getMaxCapacityPerCycleFormula(), attributes).toString());
} else {
maxCapacityPerCycle = confProdProcessLine.getMaxCapacityPerCycle();
}
if (confProdProcessLine.getDefDurationFormula()) {
durationPerCycle = Long.decode(configuratorService.computeFormula(confProdProcessLine.getDurationPerCycleFormula(), attributes).toString());
} else {
durationPerCycle = confProdProcessLine.getDurationPerCycle();
}
prodProcessLine.setName(confProdProcessLine.getName());
prodProcessLine.setPriority(confProdProcessLine.getPriority());
prodProcessLine.setWorkCenter(confProdProcessLine.getWorkCenter());
prodProcessLine.setOutsourcing(confProdProcessLine.getOutsourcing());
prodProcessLine.setStockLocation(confProdProcessLine.getStockLocation());
prodProcessLine.setDescription(confProdProcessLine.getDescription());
prodProcessLine.setMinCapacityPerCycle(minCapacityPerCycle);
prodProcessLine.setMaxCapacityPerCycle(maxCapacityPerCycle);
prodProcessLine.setDurationPerCycle(durationPerCycle);
return prodProcessLine;
}
use of com.axelor.apps.production.db.ConfiguratorProdProcessLine in project axelor-open-suite by axelor.
the class ConfiguratorProdProcessServiceImpl method generateProdProcessService.
@Override
public ProdProcess generateProdProcessService(ConfiguratorProdProcess confProdProcess, JsonContext attributes, Product product) throws AxelorException {
if (confProdProcess == null) {
return null;
}
String code;
StockLocation stockLocation;
StockLocation producedProductStockLocation;
StockLocation workshopStockLocation;
if (confProdProcess.getDefCodeAsFormula()) {
code = String.valueOf(configuratorService.computeFormula(confProdProcess.getCodeFormula(), attributes));
} else {
code = confProdProcess.getCode();
}
if (confProdProcess.getDefStockLocationAsFormula()) {
stockLocation = (StockLocation) configuratorService.computeFormula(confProdProcess.getStockLocationFormula(), attributes);
} else {
stockLocation = confProdProcess.getStockLocation();
}
if (confProdProcess.getDefProducedProductStockLocationAsFormula()) {
producedProductStockLocation = (StockLocation) configuratorService.computeFormula(confProdProcess.getProducedProductStockLocationFormula(), attributes);
} else {
producedProductStockLocation = confProdProcess.getProducedProductStockLocation();
}
if (confProdProcess.getDefWorkshopStockLocationAsFormula()) {
workshopStockLocation = (StockLocation) configuratorService.computeFormula(confProdProcess.getWorkshopStockLocationFormula(), attributes);
} else {
workshopStockLocation = confProdProcess.getWorkshopStockLocation();
}
ProdProcess prodProcess = createProdProcessHeader(confProdProcess, code, stockLocation, producedProductStockLocation, workshopStockLocation, product);
List<ConfiguratorProdProcessLine> confLines = confProdProcess.getConfiguratorProdProcessLineList();
if (confLines != null) {
for (ConfiguratorProdProcessLine confLine : confLines) {
prodProcess.addProdProcessLineListItem(confProdProcessLineService.generateProdProcessLine(confLine, attributes));
}
}
return prodProcess;
}
Aggregations