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;
}
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);
}
}
}
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);
}
}
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));
}
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)));
}
Aggregations