Search in sources :

Example 1 with WorkCenter

use of com.axelor.apps.production.db.WorkCenter 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 2 with WorkCenter

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

the class CostSheetServiceImpl method computeRealProcess.

protected void computeRealProcess(List<OperationOrder> operationOrders, Unit pieceUnit, BigDecimal producedQty, int bomLevel, CostSheetLine parentCostSheetLine, LocalDate previousCostSheetDate) throws AxelorException {
    for (OperationOrder operationOrder : operationOrders) {
        WorkCenter workCenter = operationOrder.getWorkCenter();
        if (workCenter == null) {
            continue;
        }
        int workCenterTypeSelect = workCenter.getWorkCenterTypeSelect();
        if (workCenterTypeSelect == WorkCenterRepository.WORK_CENTER_TYPE_HUMAN || workCenterTypeSelect == WorkCenterRepository.WORK_CENTER_TYPE_BOTH) {
            this.computeRealHumanResourceCost(operationOrder, operationOrder.getPriority(), bomLevel, parentCostSheetLine, previousCostSheetDate);
        }
        if (workCenterTypeSelect == WorkCenterRepository.WORK_CENTER_TYPE_MACHINE || workCenterTypeSelect == WorkCenterRepository.WORK_CENTER_TYPE_BOTH) {
            this.computeRealMachineCost(operationOrder, workCenter, producedQty, pieceUnit, bomLevel, parentCostSheetLine, previousCostSheetDate);
        }
    }
}
Also used : WorkCenter(com.axelor.apps.production.db.WorkCenter) OperationOrder(com.axelor.apps.production.db.OperationOrder)

Example 3 with WorkCenter

use of com.axelor.apps.production.db.WorkCenter 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 4 with WorkCenter

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

the class ProdProcessLineServiceImpl method setWorkCenterGroup.

@Override
@Transactional(rollbackOn = { Exception.class })
public void setWorkCenterGroup(ProdProcessLine prodProcessLine, WorkCenterGroup workCenterGroup) throws AxelorException {
    prodProcessLine = copyWorkCenterGroup(prodProcessLine, workCenterGroup);
    WorkCenter workCenter = getMainWorkCenterFromGroup(prodProcessLine);
    prodProcessLine.setWorkCenter(workCenter);
    prodProcessLine.setDurationPerCycle(getProdProcessLineDurationFromWorkCenter(workCenter));
    prodProcessLine.setMinCapacityPerCycle(getProdProcessLineMinCapacityPerCycleFromWorkCenter(workCenter));
    prodProcessLine.setMaxCapacityPerCycle(getProdProcessLineMaxCapacityPerCycleFromWorkCenter(workCenter));
}
Also used : WorkCenter(com.axelor.apps.production.db.WorkCenter) Transactional(com.google.inject.persist.Transactional)

Example 5 with WorkCenter

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

the class ProdProcessLineServiceImpl method getMainWorkCenterFromGroup.

@Override
public WorkCenter getMainWorkCenterFromGroup(ProdProcessLine prodProcessLine) throws AxelorException {
    WorkCenterGroup workCenterGroup = prodProcessLine.getWorkCenterGroup();
    if (workCenterGroup == null) {
        return null;
    }
    Set<WorkCenter> workCenterSet = workCenterGroup.getWorkCenterSet();
    if (workCenterSet == null || workCenterSet.isEmpty()) {
        throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.NO_WORK_CENTER_GROUP));
    }
    return workCenterSet.stream().min(Comparator.comparing(WorkCenter::getSequence)).orElseThrow(() -> new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.NO_WORK_CENTER_GROUP)));
}
Also used : AxelorException(com.axelor.exception.AxelorException) WorkCenter(com.axelor.apps.production.db.WorkCenter) WorkCenterGroup(com.axelor.apps.production.db.WorkCenterGroup)

Aggregations

WorkCenter (com.axelor.apps.production.db.WorkCenter)8 ProdProcessLine (com.axelor.apps.production.db.ProdProcessLine)4 AxelorException (com.axelor.exception.AxelorException)4 Machine (com.axelor.apps.production.db.Machine)2 BigDecimal (java.math.BigDecimal)2 OperationOrder (com.axelor.apps.production.db.OperationOrder)1 WorkCenterGroup (com.axelor.apps.production.db.WorkCenterGroup)1 Transactional (com.google.inject.persist.Transactional)1