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