use of com.axelor.apps.production.db.ProdProcessLine in project axelor-open-suite by axelor.
the class ProdProcessLineController method fillWorkCenter.
public void fillWorkCenter(ActionRequest request, ActionResponse response) {
try {
ProdProcessLine prodProcessLine = request.getContext().asType(ProdProcessLine.class);
response.setValue("workCenter", Beans.get(ProdProcessLineService.class).getMainWorkCenterFromGroup(prodProcessLine));
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.production.db.ProdProcessLine in project axelor-open-suite by axelor.
the class ProdProcessService method validateProdProcess.
public void validateProdProcess(ProdProcess prodProcess, BillOfMaterial bom) throws AxelorException {
Map<Product, BigDecimal> bomMap = new HashMap<Product, BigDecimal>();
Set<BillOfMaterial> setBoM = MoreObjects.firstNonNull(bom.getBillOfMaterialSet(), Collections.emptySet());
for (BillOfMaterial bomIt : setBoM) {
bomMap.put(bomIt.getProduct(), bomIt.getQty());
}
List<ProdProcessLine> listPPL = MoreObjects.firstNonNull(prodProcess.getProdProcessLineList(), Collections.emptyList());
for (ProdProcessLine prodProcessLine : listPPL) {
List<ProdProduct> listPP = MoreObjects.firstNonNull(prodProcessLine.getToConsumeProdProductList(), Collections.emptyList());
for (ProdProduct prodProduct : listPP) {
if (!bomMap.containsKey(prodProduct.getProduct())) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.PROD_PROCESS_USELESS_PRODUCT), prodProduct.getProduct().getName());
}
bomMap.put(prodProduct.getProduct(), bomMap.get(prodProduct.getProduct()).subtract(prodProduct.getQty()));
}
}
Set<Product> keyList = bomMap.keySet();
Map<Product, BigDecimal> copyMap = new HashMap<Product, BigDecimal>();
List<String> nameProductList = new ArrayList<String>();
for (Product product : keyList) {
if (bomMap.get(product).compareTo(BigDecimal.ZERO) > 0) {
copyMap.put(product, bomMap.get(product));
nameProductList.add(product.getName());
}
}
if (!copyMap.isEmpty()) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.PROD_PROCESS_MISS_PRODUCT), Joiner.on(",").join(nameProductList));
}
}
use of com.axelor.apps.production.db.ProdProcessLine in project axelor-open-suite by axelor.
the class ProdProcessLineController method updateCapacitySettings.
public void updateCapacitySettings(ActionRequest request, ActionResponse response) {
try {
ProdProcessLine prodProcess = request.getContext().asType(ProdProcessLine.class);
WorkCenter workCenter = prodProcess.getWorkCenter();
if (workCenter != null) {
response.setValue("minCapacityPerCycle", Beans.get(ProdProcessLineService.class).getProdProcessLineMinCapacityPerCycleFromWorkCenter(workCenter));
response.setValue("maxCapacityPerCycle", Beans.get(ProdProcessLineService.class).getProdProcessLineMaxCapacityPerCycleFromWorkCenter(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 ManufOrderServiceImpl method createManufOrder.
@Override
public ManufOrder createManufOrder(Product product, BigDecimal qty, int priority, boolean isToInvoice, Company company, BillOfMaterial billOfMaterial, LocalDateTime plannedStartDateT, LocalDateTime plannedEndDateT) throws AxelorException {
logger.debug("Création d'un OF {}", priority);
ProdProcess prodProcess = billOfMaterial.getProdProcess();
ManufOrder manufOrder = new ManufOrder(qty, company, null, priority, this.isManagedConsumedProduct(billOfMaterial), billOfMaterial, product, prodProcess, plannedStartDateT, plannedEndDateT, ManufOrderRepository.STATUS_DRAFT, prodProcess.getOutsourcing());
manufOrder = manufOrderRepo.save(manufOrder);
if (appProductionService.getAppProduction().getManageWorkshop()) {
manufOrder.setWorkshopStockLocation(billOfMaterial.getWorkshopStockLocation());
}
if (prodProcess != null && prodProcess.getProdProcessLineList() != null) {
for (ProdProcessLine prodProcessLine : this._sortProdProcessLineByPriority(prodProcess.getProdProcessLineList())) {
manufOrder.addOperationOrderListItem(operationOrderService.createOperationOrder(manufOrder, prodProcessLine));
}
}
return manufOrder;
}
use of com.axelor.apps.production.db.ProdProcessLine in project axelor-open-suite by axelor.
the class ManufOrderServiceImpl method preFillOperations.
@Override
@Transactional(rollbackOn = { Exception.class })
public void preFillOperations(ManufOrder manufOrder) throws AxelorException {
BillOfMaterial billOfMaterial = manufOrder.getBillOfMaterial();
if (manufOrder.getProdProcess() == null) {
manufOrder.setProdProcess(billOfMaterial.getProdProcess());
}
ProdProcess prodProcess = manufOrder.getProdProcess();
if (manufOrder.getPlannedStartDateT() == null) {
manufOrder.setPlannedStartDateT(appProductionService.getTodayDateTime().toLocalDateTime());
}
if (prodProcess != null && prodProcess.getProdProcessLineList() != null) {
for (ProdProcessLine prodProcessLine : this._sortProdProcessLineByPriority(prodProcess.getProdProcessLineList())) {
manufOrder.addOperationOrderListItem(operationOrderService.createOperationOrder(manufOrder, prodProcessLine));
}
}
manufOrderRepo.save(manufOrder);
manufOrder.setPlannedEndDateT(manufOrderWorkflowService.computePlannedEndDateT(manufOrder));
manufOrderRepo.save(manufOrder);
}
Aggregations