use of com.axelor.apps.production.service.ProdProductProductionRepository in project axelor-open-suite by axelor.
the class ManufOrderController method multiLevelManufOrderOnLoad.
/**
* Called from manuf order form, on clicking "Multi-level planning" button.
*
* @param request
* @param response
*/
public void multiLevelManufOrderOnLoad(ActionRequest request, ActionResponse response) {
try {
Long moId = Long.valueOf(request.getContext().get("id").toString());
ManufOrder mo = Beans.get(ManufOrderRepository.class).find(moId);
boolean showOnlyMissingQty = request.getContext().get("_showOnlyMissingQty") != null && Boolean.parseBoolean(request.getContext().get("_showOnlyMissingQty").toString());
ProdProductProductionRepository prodProductProductionRepository = Beans.get(ProdProductProductionRepository.class);
List<ProdProduct> prodProducts = mo.getToConsumeProdProductList().stream().filter(prodProduct -> prodProduct.getProduct().getProductSubTypeSelect() == ProductRepository.PRODUCT_SUB_TYPE_FINISHED_PRODUCT || prodProduct.getProduct().getProductSubTypeSelect() == ProductRepository.PRODUCT_SUB_TYPE_SEMI_FINISHED_PRODUCT).filter(prodProduct -> !showOnlyMissingQty || prodProductProductionRepository.computeMissingQty(prodProduct.getProduct().getId(), prodProduct.getQty(), moId).compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
response.setValue("$components", prodProducts);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations