use of com.axelor.apps.production.service.app.AppProductionService in project axelor-open-suite by axelor.
the class OperationOrderServiceBusinessImpl method createOperationOrder.
@Override
@Transactional(rollbackOn = { Exception.class })
public OperationOrder createOperationOrder(ManufOrder manufOrder, ProdProcessLine prodProcessLine) throws AxelorException {
AppProductionService appProductionService = Beans.get(AppProductionService.class);
if (!appProductionService.isApp("production") || !appProductionService.getAppProduction().getManageBusinessProduction()) {
return super.createOperationOrder(manufOrder, prodProcessLine);
}
if (prodProcessLine.getWorkCenter() == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.PROD_PROCESS_LINE_MISSING_WORK_CENTER), prodProcessLine.getProdProcess() != null ? prodProcessLine.getProdProcess().getCode() : "null", prodProcessLine.getName());
}
OperationOrder operationOrder = this.createOperationOrder(manufOrder, prodProcessLine.getPriority(), manufOrder.getIsToInvoice(), prodProcessLine.getWorkCenter(), prodProcessLine.getWorkCenter().getMachine(), prodProcessLine.getMachineTool(), prodProcessLine);
return Beans.get(OperationOrderRepository.class).save(operationOrder);
}
use of com.axelor.apps.production.service.app.AppProductionService in project axelor-open-suite by axelor.
the class ProductionConfigService method getManufOrderSequence.
/**
* Find the configured sequence for a manufacturing order.
*
* <p>A company can have a different sequence per workshop. If no sequence is found per workshop,
* then return {@link ProductionConfig#manufOrderSequence}.
*
* @param productionConfig the config corresponding to the company.
* @param workshop the workshop of the manufacturing order.
* @return the found sequence.
* @throws AxelorException if no sequence is found for the given workshop, and if no default
* sequence is filled.
*/
public Sequence getManufOrderSequence(ProductionConfig productionConfig, StockLocation workshop) throws AxelorException {
Sequence sequence = null;
AppProductionService appProductionService = Beans.get(AppProductionService.class);
if (appProductionService.isApp("production")) {
if (productionConfig.getWorkshopSequenceConfigLineList() != null && appProductionService.getAppProduction().getManageWorkshop()) {
sequence = productionConfig.getWorkshopSequenceConfigLineList().stream().filter(workshopSequenceConfigLine -> workshopSequenceConfigLine.getWorkshopStockLocation().equals(workshop)).map(WorkshopSequenceConfigLine::getSequence).findFirst().orElseGet(productionConfig::getManufOrderSequence);
} else {
sequence = productionConfig.getManufOrderSequence();
}
}
if (sequence == null) {
throw new AxelorException(productionConfig, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.PRODUCTION_CONFIG_MISSING_MANUF_ORDER_SEQ), productionConfig.getCompany().getName());
}
return sequence;
}
use of com.axelor.apps.production.service.app.AppProductionService in project axelor-open-suite by axelor.
the class PurchaseOrderServiceProductionImpl method setMergedPurchaseOrderForManufOrder.
@SuppressWarnings("unchecked")
private void setMergedPurchaseOrderForManufOrder(PurchaseOrder mergedPurchaseOrder, List<PurchaseOrder> purchaseOrderList) {
AppProductionService appProductionService = Beans.get(AppProductionService.class);
if (appProductionService.isApp("production") && appProductionService.getAppProduction().getManageOutsourcing()) {
ManufOrderRepository manufOrderRepository = Beans.get(ManufOrderRepository.class);
for (PurchaseOrder purchaseOrder : purchaseOrderList) {
List<ManufOrder> manufOrderList = (List<ManufOrder>) manufOrderRepository.all().filter("self.purchaseOrder.id = ?1", purchaseOrder.getId());
for (ManufOrder manufOrder : manufOrderList) {
manufOrder.setPurchaseOrder(mergedPurchaseOrder);
manufOrderRepository.save(manufOrder);
}
}
}
}
Aggregations