use of com.axelor.apps.production.db.ManufOrder in project axelor-open-suite by axelor.
the class ManufOrderController method checkProducedStockMoveLineList.
/**
* Called from manuf order form, on produced stock move line change. Call {@link
* ManufOrderService#checkProducedStockMoveLineList(ManufOrder, ManufOrder)}.
*
* @param request
* @param response
*/
public void checkProducedStockMoveLineList(ActionRequest request, ActionResponse response) {
try {
ManufOrder manufOrder = request.getContext().asType(ManufOrder.class);
ManufOrder oldManufOrder = Beans.get(ManufOrderRepository.class).find(manufOrder.getId());
Beans.get(ManufOrderService.class).checkProducedStockMoveLineList(manufOrder, oldManufOrder);
} catch (Exception e) {
TraceBackService.trace(response, e);
response.setReload(true);
}
}
use of com.axelor.apps.production.db.ManufOrder in project axelor-open-suite by axelor.
the class ManufOrderController method updateConsumedStockMoveFromManufOrder.
/**
* Called from manuf order form, on consumed stock move line change. Call {@link
* ManufOrderService#updateConsumedStockMoveFromManufOrder(ManufOrder)}.
*
* @param request
* @param response
*/
public void updateConsumedStockMoveFromManufOrder(ActionRequest request, ActionResponse response) {
try {
ManufOrder manufOrder = request.getContext().asType(ManufOrder.class);
manufOrder = Beans.get(ManufOrderRepository.class).find(manufOrder.getId());
Beans.get(ManufOrderService.class).updateConsumedStockMoveFromManufOrder(manufOrder);
response.setReload(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.production.db.ManufOrder in project axelor-open-suite by axelor.
the class ManufOrderController method printProdProcess.
public void printProdProcess(ActionRequest request, ActionResponse response) {
try {
ManufOrder manufOrder = request.getContext().asType(ManufOrder.class);
String prodProcessId = manufOrder.getProdProcess().getId().toString();
String prodProcessLable = manufOrder.getProdProcess().getName();
String fileLink = ReportFactory.createReport(IReport.PROD_PROCESS, prodProcessLable + "-${date}").addParam("Locale", ReportSettings.getPrintingLocale(null)).addParam("Timezone", manufOrder.getCompany() != null ? manufOrder.getCompany().getTimezone() : null).addParam("ProdProcessId", prodProcessId).generate().getFileLink();
response.setView(ActionView.define(prodProcessLable).add("html", fileLink).map());
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.production.db.ManufOrder in project axelor-open-suite by axelor.
the class ProductionOrderServiceImpl method updateProductionOrderStatus.
protected ProductionOrder updateProductionOrderStatus(ProductionOrder productionOrder) {
if (productionOrder.getStatusSelect() == null) {
return productionOrder;
}
int statusSelect = productionOrder.getStatusSelect();
if (productionOrder.getManufOrderSet().stream().allMatch(manufOrder -> manufOrder.getStatusSelect() == ManufOrderRepository.STATUS_DRAFT)) {
statusSelect = ProductionOrderRepository.STATUS_DRAFT;
productionOrder.setStatusSelect(statusSelect);
return productionOrderRepo.save(productionOrder);
}
boolean oneStarted = false;
boolean onePlanned = false;
boolean allCancel = true;
boolean allCompleted = true;
for (ManufOrder manufOrder : productionOrder.getManufOrderSet()) {
switch(manufOrder.getStatusSelect()) {
case (ManufOrderRepository.STATUS_PLANNED):
onePlanned = true;
allCancel = false;
allCompleted = false;
break;
case (ManufOrderRepository.STATUS_IN_PROGRESS):
case (ManufOrderRepository.STATUS_STANDBY):
oneStarted = true;
allCancel = false;
allCompleted = false;
break;
case (ManufOrderRepository.STATUS_FINISHED):
allCancel = false;
break;
case (ManufOrderRepository.STATUS_CANCELED):
break;
default:
allCompleted = false;
break;
}
}
if (allCancel) {
statusSelect = ProductionOrderRepository.STATUS_CANCELED;
} else if (allCompleted) {
statusSelect = ProductionOrderRepository.STATUS_COMPLETED;
} else if (oneStarted) {
statusSelect = ProductionOrderRepository.STATUS_STARTED;
} else if (onePlanned && (productionOrder.getStatusSelect() == ProductionOrderRepository.STATUS_DRAFT || productionOrder.getStatusSelect() == ProductionOrderRepository.STATUS_CANCELED || productionOrder.getStatusSelect() == ProductionOrderRepository.STATUS_COMPLETED)) {
statusSelect = ProductionOrderRepository.STATUS_PLANNED;
}
productionOrder.setStatusSelect(statusSelect);
return productionOrderRepo.save(productionOrder);
}
use of com.axelor.apps.production.db.ManufOrder in project axelor-open-suite by axelor.
the class ProductionOrderServiceImpl method addManufOrder.
@Override
@Transactional(rollbackOn = { Exception.class })
public ProductionOrder addManufOrder(ProductionOrder productionOrder, Product product, BillOfMaterial billOfMaterial, BigDecimal qtyRequested, LocalDateTime startDate, LocalDateTime endDate, SaleOrder saleOrder, int originType) throws AxelorException {
ManufOrder manufOrder = manufOrderService.generateManufOrder(product, qtyRequested, ManufOrderService.DEFAULT_PRIORITY, ManufOrderService.IS_TO_INVOICE, billOfMaterial, startDate, endDate, originType);
if (manufOrder != null) {
if (saleOrder != null) {
manufOrder.addSaleOrderSetItem(saleOrder);
manufOrder.setClientPartner(saleOrder.getClientPartner());
manufOrder.setMoCommentFromSaleOrder(saleOrder.getProductionNote());
}
productionOrder.addManufOrderSetItem(manufOrder);
manufOrder.addProductionOrderSetItem(productionOrder);
}
productionOrder = updateProductionOrderStatus(productionOrder);
return productionOrderRepo.save(productionOrder);
}
Aggregations