Search in sources :

Example 1 with WorkCenterGroup

use of com.axelor.apps.production.db.WorkCenterGroup 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)

Example 2 with WorkCenterGroup

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

the class ProdProcessLineServiceImpl method copyWorkCenterGroup.

/**
 * Create a work center group from a template. Since a template is also a work center group, we
 * copy and set template field to false.
 */
protected ProdProcessLine copyWorkCenterGroup(ProdProcessLine prodProcessLine, WorkCenterGroup workCenterGroup) {
    WorkCenterGroup workCenterGroupCopy = JPA.copy(workCenterGroup, false);
    workCenterGroupCopy.setWorkCenterGroupModel(workCenterGroup);
    workCenterGroupCopy.setTemplate(false);
    workCenterGroup.getWorkCenterSet().forEach((workCenterGroupCopy::addWorkCenterSetItem));
    prodProcessLine.setWorkCenterGroup(workCenterGroupCopy);
    return Beans.get(ProdProcessLineRepository.class).save(prodProcessLine);
}
Also used : ProdProcessLineRepository(com.axelor.apps.production.db.repo.ProdProcessLineRepository) WorkCenterGroup(com.axelor.apps.production.db.WorkCenterGroup)

Example 3 with WorkCenterGroup

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

WorkCenterGroup (com.axelor.apps.production.db.WorkCenterGroup)3 ProdProcessLineRepository (com.axelor.apps.production.db.repo.ProdProcessLineRepository)2 ProdProcessLine (com.axelor.apps.production.db.ProdProcessLine)1 WorkCenter (com.axelor.apps.production.db.WorkCenter)1 WorkCenterGroupRepository (com.axelor.apps.production.db.repo.WorkCenterGroupRepository)1 ProdProcessLineService (com.axelor.apps.production.service.ProdProcessLineService)1 AxelorException (com.axelor.exception.AxelorException)1