Search in sources :

Example 6 with ProdProcessLine

use of com.axelor.apps.production.db.ProdProcessLine in project axelor-open-suite by axelor.

the class ProdProcessLineController method fillWorkCenter.

public void fillWorkCenter(ActionRequest request, ActionResponse response) {
    try {
        ProdProcessLine prodProcessLine = request.getContext().asType(ProdProcessLine.class);
        response.setValue("workCenter", Beans.get(ProdProcessLineService.class).getMainWorkCenterFromGroup(prodProcessLine));
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : ProdProcessLine(com.axelor.apps.production.db.ProdProcessLine)

Example 7 with ProdProcessLine

use of com.axelor.apps.production.db.ProdProcessLine in project axelor-open-suite by axelor.

the class ProdProcessService method validateProdProcess.

public void validateProdProcess(ProdProcess prodProcess, BillOfMaterial bom) throws AxelorException {
    Map<Product, BigDecimal> bomMap = new HashMap<Product, BigDecimal>();
    Set<BillOfMaterial> setBoM = MoreObjects.firstNonNull(bom.getBillOfMaterialSet(), Collections.emptySet());
    for (BillOfMaterial bomIt : setBoM) {
        bomMap.put(bomIt.getProduct(), bomIt.getQty());
    }
    List<ProdProcessLine> listPPL = MoreObjects.firstNonNull(prodProcess.getProdProcessLineList(), Collections.emptyList());
    for (ProdProcessLine prodProcessLine : listPPL) {
        List<ProdProduct> listPP = MoreObjects.firstNonNull(prodProcessLine.getToConsumeProdProductList(), Collections.emptyList());
        for (ProdProduct prodProduct : listPP) {
            if (!bomMap.containsKey(prodProduct.getProduct())) {
                throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.PROD_PROCESS_USELESS_PRODUCT), prodProduct.getProduct().getName());
            }
            bomMap.put(prodProduct.getProduct(), bomMap.get(prodProduct.getProduct()).subtract(prodProduct.getQty()));
        }
    }
    Set<Product> keyList = bomMap.keySet();
    Map<Product, BigDecimal> copyMap = new HashMap<Product, BigDecimal>();
    List<String> nameProductList = new ArrayList<String>();
    for (Product product : keyList) {
        if (bomMap.get(product).compareTo(BigDecimal.ZERO) > 0) {
            copyMap.put(product, bomMap.get(product));
            nameProductList.add(product.getName());
        }
    }
    if (!copyMap.isEmpty()) {
        throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.PROD_PROCESS_MISS_PRODUCT), Joiner.on(",").join(nameProductList));
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ProdProduct(com.axelor.apps.production.db.ProdProduct) Product(com.axelor.apps.base.db.Product) ProdProduct(com.axelor.apps.production.db.ProdProduct) ProdProcessLine(com.axelor.apps.production.db.ProdProcessLine) BigDecimal(java.math.BigDecimal) BillOfMaterial(com.axelor.apps.production.db.BillOfMaterial)

Example 8 with ProdProcessLine

use of com.axelor.apps.production.db.ProdProcessLine in project axelor-open-suite by axelor.

the class ProdProcessLineController method updateCapacitySettings.

public void updateCapacitySettings(ActionRequest request, ActionResponse response) {
    try {
        ProdProcessLine prodProcess = request.getContext().asType(ProdProcessLine.class);
        WorkCenter workCenter = prodProcess.getWorkCenter();
        if (workCenter != null) {
            response.setValue("minCapacityPerCycle", Beans.get(ProdProcessLineService.class).getProdProcessLineMinCapacityPerCycleFromWorkCenter(workCenter));
            response.setValue("maxCapacityPerCycle", Beans.get(ProdProcessLineService.class).getProdProcessLineMaxCapacityPerCycleFromWorkCenter(workCenter));
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : WorkCenter(com.axelor.apps.production.db.WorkCenter) ProdProcessLine(com.axelor.apps.production.db.ProdProcessLine)

Example 9 with ProdProcessLine

use of com.axelor.apps.production.db.ProdProcessLine in project axelor-open-suite by axelor.

the class ManufOrderServiceImpl method createManufOrder.

@Override
public ManufOrder createManufOrder(Product product, BigDecimal qty, int priority, boolean isToInvoice, Company company, BillOfMaterial billOfMaterial, LocalDateTime plannedStartDateT, LocalDateTime plannedEndDateT) throws AxelorException {
    logger.debug("Création d'un OF {}", priority);
    ProdProcess prodProcess = billOfMaterial.getProdProcess();
    ManufOrder manufOrder = new ManufOrder(qty, company, null, priority, this.isManagedConsumedProduct(billOfMaterial), billOfMaterial, product, prodProcess, plannedStartDateT, plannedEndDateT, ManufOrderRepository.STATUS_DRAFT, prodProcess.getOutsourcing());
    manufOrder = manufOrderRepo.save(manufOrder);
    if (appProductionService.getAppProduction().getManageWorkshop()) {
        manufOrder.setWorkshopStockLocation(billOfMaterial.getWorkshopStockLocation());
    }
    if (prodProcess != null && prodProcess.getProdProcessLineList() != null) {
        for (ProdProcessLine prodProcessLine : this._sortProdProcessLineByPriority(prodProcess.getProdProcessLineList())) {
            manufOrder.addOperationOrderListItem(operationOrderService.createOperationOrder(manufOrder, prodProcessLine));
        }
    }
    return manufOrder;
}
Also used : ProdProcess(com.axelor.apps.production.db.ProdProcess) ProdProcessLine(com.axelor.apps.production.db.ProdProcessLine) ManufOrder(com.axelor.apps.production.db.ManufOrder)

Example 10 with ProdProcessLine

use of com.axelor.apps.production.db.ProdProcessLine in project axelor-open-suite by axelor.

the class ManufOrderServiceImpl method preFillOperations.

@Override
@Transactional(rollbackOn = { Exception.class })
public void preFillOperations(ManufOrder manufOrder) throws AxelorException {
    BillOfMaterial billOfMaterial = manufOrder.getBillOfMaterial();
    if (manufOrder.getProdProcess() == null) {
        manufOrder.setProdProcess(billOfMaterial.getProdProcess());
    }
    ProdProcess prodProcess = manufOrder.getProdProcess();
    if (manufOrder.getPlannedStartDateT() == null) {
        manufOrder.setPlannedStartDateT(appProductionService.getTodayDateTime().toLocalDateTime());
    }
    if (prodProcess != null && prodProcess.getProdProcessLineList() != null) {
        for (ProdProcessLine prodProcessLine : this._sortProdProcessLineByPriority(prodProcess.getProdProcessLineList())) {
            manufOrder.addOperationOrderListItem(operationOrderService.createOperationOrder(manufOrder, prodProcessLine));
        }
    }
    manufOrderRepo.save(manufOrder);
    manufOrder.setPlannedEndDateT(manufOrderWorkflowService.computePlannedEndDateT(manufOrder));
    manufOrderRepo.save(manufOrder);
}
Also used : BillOfMaterial(com.axelor.apps.production.db.BillOfMaterial) ProdProcess(com.axelor.apps.production.db.ProdProcess) ProdProcessLine(com.axelor.apps.production.db.ProdProcessLine) Transactional(com.google.inject.persist.Transactional)

Aggregations

ProdProcessLine (com.axelor.apps.production.db.ProdProcessLine)12 WorkCenter (com.axelor.apps.production.db.WorkCenter)4 BigDecimal (java.math.BigDecimal)4 AxelorException (com.axelor.exception.AxelorException)3 BillOfMaterial (com.axelor.apps.production.db.BillOfMaterial)2 Machine (com.axelor.apps.production.db.Machine)2 ProdProcess (com.axelor.apps.production.db.ProdProcess)2 ProdProduct (com.axelor.apps.production.db.ProdProduct)2 Product (com.axelor.apps.base.db.Product)1 ConfiguratorProdProcessLine (com.axelor.apps.production.db.ConfiguratorProdProcessLine)1 ManufOrder (com.axelor.apps.production.db.ManufOrder)1 WorkCenterGroup (com.axelor.apps.production.db.WorkCenterGroup)1 ProdProcessLineRepository (com.axelor.apps.production.db.repo.ProdProcessLineRepository)1 WorkCenterGroupRepository (com.axelor.apps.production.db.repo.WorkCenterGroupRepository)1 ProdProcessLineService (com.axelor.apps.production.service.ProdProcessLineService)1 StockConfigProductionService (com.axelor.apps.production.service.config.StockConfigProductionService)1 ManufOrderService (com.axelor.apps.production.service.manuforder.ManufOrderService)1 StockConfig (com.axelor.apps.stock.db.StockConfig)1 StockLocation (com.axelor.apps.stock.db.StockLocation)1 Transactional (com.google.inject.persist.Transactional)1