Search in sources :

Example 1 with ProdProcessLine

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

the class OperationOrderStockMoveService method _createToConsumeStockMove.

protected StockMove _createToConsumeStockMove(OperationOrder operationOrder, Company company) throws AxelorException {
    StockConfigProductionService stockConfigService = Beans.get(StockConfigProductionService.class);
    StockConfig stockConfig = stockConfigService.getStockConfig(company);
    StockLocation virtualStockLocation = stockConfigService.getProductionVirtualStockLocation(stockConfig, operationOrder.getManufOrder().getProdProcess().getOutsourcing());
    StockLocation fromStockLocation;
    ProdProcessLine prodProcessLine = operationOrder.getProdProcessLine();
    if (operationOrder.getManufOrder().getIsConsProOnOperation() && prodProcessLine != null && prodProcessLine.getStockLocation() != null) {
        fromStockLocation = prodProcessLine.getStockLocation();
    } else if (!operationOrder.getManufOrder().getIsConsProOnOperation() && prodProcessLine != null && prodProcessLine.getProdProcess() != null && prodProcessLine.getProdProcess().getStockLocation() != null) {
        fromStockLocation = prodProcessLine.getProdProcess().getStockLocation();
    } else {
        fromStockLocation = stockConfigService.getComponentDefaultStockLocation(stockConfig);
    }
    return stockMoveService.createStockMove(null, null, company, fromStockLocation, virtualStockLocation, null, operationOrder.getPlannedStartDateT().toLocalDate(), null, StockMoveRepository.TYPE_INTERNAL);
}
Also used : StockConfig(com.axelor.apps.stock.db.StockConfig) StockLocation(com.axelor.apps.stock.db.StockLocation) StockConfigProductionService(com.axelor.apps.production.service.config.StockConfigProductionService) ProdProcessLine(com.axelor.apps.production.db.ProdProcessLine)

Example 2 with ProdProcessLine

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

the class OperationOrderWorkflowService method getMachineSetupDuration.

public long getMachineSetupDuration(OperationOrder operationOrder) throws AxelorException {
    ProdProcessLine prodProcessLine = operationOrder.getProdProcessLine();
    long duration = 0;
    WorkCenter workCenter = prodProcessLine.getWorkCenter();
    if (workCenter == null) {
        return 0;
    }
    int workCenterTypeSelect = workCenter.getWorkCenterTypeSelect();
    if (workCenterTypeSelect == WorkCenterRepository.WORK_CENTER_TYPE_MACHINE || workCenterTypeSelect == WorkCenterRepository.WORK_CENTER_TYPE_BOTH) {
        Machine machine = workCenter.getMachine();
        if (machine == null) {
            throw new AxelorException(workCenter, TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.WORKCENTER_NO_MACHINE), workCenter.getName());
        }
        duration += machine.getStartingDuration();
        duration += machine.getEndingDuration();
        duration += machine.getSetupDuration();
    }
    return duration;
}
Also used : AxelorException(com.axelor.exception.AxelorException) WorkCenter(com.axelor.apps.production.db.WorkCenter) ProdProcessLine(com.axelor.apps.production.db.ProdProcessLine) Machine(com.axelor.apps.production.db.Machine)

Example 3 with ProdProcessLine

use of com.axelor.apps.production.db.ProdProcessLine 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;
}
Also used : ProdProcessLine(com.axelor.apps.production.db.ProdProcessLine) ConfiguratorProdProcessLine(com.axelor.apps.production.db.ConfiguratorProdProcessLine) BigDecimal(java.math.BigDecimal)

Example 4 with ProdProcessLine

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

the class ProdProcessLineController method updateDuration.

public void updateDuration(ActionRequest request, ActionResponse response) {
    try {
        ProdProcessLine prodProcess = request.getContext().asType(ProdProcessLine.class);
        WorkCenter workCenter = prodProcess.getWorkCenter();
        if (workCenter != null) {
            response.setValue("durationPerCycle", Beans.get(ProdProcessLineService.class).getProdProcessLineDurationFromWorkCenter(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 5 with ProdProcessLine

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

the class ProdProcessLineController method setWorkCenterGroup.

public void setWorkCenterGroup(ActionRequest request, ActionResponse response) {
    try {
        Long prodProcessId = request.getContext().asType(ProdProcessLine.class).getId();
        ProdProcessLine prodProcess = Beans.get(ProdProcessLineRepository.class).find(prodProcessId);
        Map<String, Object> workCenterGroupMap = ((LinkedHashMap<String, Object>) request.getContext().get("workCenterGroupWizard"));
        if (workCenterGroupMap != null && workCenterGroupMap.containsKey("id")) {
            WorkCenterGroup workCenterGroup = Beans.get(WorkCenterGroupRepository.class).find(Long.valueOf(workCenterGroupMap.get("id").toString()));
            Beans.get(ProdProcessLineService.class).setWorkCenterGroup(prodProcess, workCenterGroup);
        }
        response.setCanClose(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : WorkCenterGroupRepository(com.axelor.apps.production.db.repo.WorkCenterGroupRepository) ProdProcessLineService(com.axelor.apps.production.service.ProdProcessLineService) ProdProcessLineRepository(com.axelor.apps.production.db.repo.ProdProcessLineRepository) ProdProcessLine(com.axelor.apps.production.db.ProdProcessLine) WorkCenterGroup(com.axelor.apps.production.db.WorkCenterGroup)

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