use of com.axelor.apps.production.db.OperationOrder in project axelor-open-suite by axelor.
the class ManufOrderWorkFlowMaintenanceService method plan.
@Transactional(rollbackOn = { Exception.class })
@Override
public ManufOrder plan(ManufOrder manufOrder) throws AxelorException {
if (manufOrder.getTypeSelect() != ManufOrderRepository.TYPE_MAINTENANCE) {
return super.plan(manufOrder);
}
ManufOrderService manufOrderService = Beans.get(ManufOrderService.class);
if (Beans.get(SequenceService.class).isEmptyOrDraftSequenceNumber(manufOrder.getManufOrderSeq())) {
manufOrder.setManufOrderSeq(manufOrderService.getManufOrderSeq(manufOrder));
}
if (CollectionUtils.isEmpty(manufOrder.getOperationOrderList())) {
manufOrderService.preFillOperations(manufOrder);
}
if (!manufOrder.getIsConsProOnOperation() && CollectionUtils.isEmpty(manufOrder.getToConsumeProdProductList())) {
manufOrderService.createToConsumeProdProductList(manufOrder);
}
if (CollectionUtils.isEmpty(manufOrder.getToProduceProdProductList())) {
manufOrderService.createToProduceProdProductList(manufOrder);
}
if (manufOrder.getPlannedStartDateT() == null) {
manufOrder.setPlannedStartDateT(Beans.get(AppProductionService.class).getTodayDateTime().toLocalDateTime());
}
for (OperationOrder operationOrder : getSortedOperationOrderList(manufOrder)) {
operationOrderWorkflowService.plan(operationOrder, null);
}
manufOrder.setPlannedEndDateT(this.computePlannedEndDateT(manufOrder));
if (manufOrder.getBillOfMaterial() != null) {
manufOrder.setUnit(manufOrder.getBillOfMaterial().getUnit());
}
manufOrder.setStatusSelect(ManufOrderRepository.STATUS_PLANNED);
manufOrder.setCancelReason(null);
manufOrder.setCancelReasonStr(null);
return manufOrderRepo.save(manufOrder);
}
use of com.axelor.apps.production.db.OperationOrder in project axelor-open-suite by axelor.
the class ManufOrderWorkFlowMaintenanceService method finish.
@Transactional(rollbackOn = { Exception.class })
@Override
public boolean finish(ManufOrder manufOrder) throws AxelorException {
if (manufOrder.getTypeSelect() != ManufOrderRepository.TYPE_MAINTENANCE) {
return super.finish(manufOrder);
} else {
if (manufOrder.getOperationOrderList() != null) {
for (OperationOrder operationOrder : manufOrder.getOperationOrderList()) {
if (operationOrder.getStatusSelect() != OperationOrderRepository.STATUS_FINISHED) {
if (operationOrder.getStatusSelect() != OperationOrderRepository.STATUS_IN_PROGRESS && operationOrder.getStatusSelect() != OperationOrderRepository.STATUS_STANDBY) {
operationOrderWorkflowService.start(operationOrder);
}
operationOrderWorkflowService.finish(operationOrder);
}
}
}
manufOrder.setRealEndDateT(Beans.get(AppProductionService.class).getTodayDateTime().toLocalDateTime());
manufOrder.setStatusSelect(ManufOrderRepository.STATUS_FINISHED);
manufOrder.setEndTimeDifference(new BigDecimal(ChronoUnit.MINUTES.between(manufOrder.getPlannedEndDateT(), manufOrder.getRealEndDateT())));
manufOrderRepo.save(manufOrder);
return true;
}
}
use of com.axelor.apps.production.db.OperationOrder in project axelor-open-suite by axelor.
the class ManufOrderStockMoveService method partialFinish.
/**
* Call the method to realize in stock move, then the method to realize out stock move for the
* given manufacturing order.
*
* @param manufOrder
*/
@Transactional(rollbackOn = { Exception.class })
public void partialFinish(ManufOrder manufOrder) throws AxelorException {
if (manufOrder.getIsConsProOnOperation()) {
for (OperationOrder operationOrder : manufOrder.getOperationOrderList()) {
if (operationOrder.getStatusSelect() == OperationOrderRepository.STATUS_IN_PROGRESS) {
Beans.get(OperationOrderStockMoveService.class).partialFinish(operationOrder);
}
}
} else {
partialFinish(manufOrder, PART_FINISH_IN);
}
partialFinish(manufOrder, PART_FINISH_OUT);
Beans.get(ManufOrderRepository.class).save(manufOrder);
}
use of com.axelor.apps.production.db.OperationOrder in project axelor-open-suite by axelor.
the class ManufOrderWorkflowService method createPurchaseOrder.
@Transactional
public void createPurchaseOrder(ManufOrder manufOrder) throws AxelorException {
PurchaseOrder purchaseOrder = Beans.get(PurchaseOrderService.class).createPurchaseOrder(null, manufOrder.getCompany(), null, null, null, null, null, null, null, manufOrder.getProdProcess().getSubcontractors(), null);
purchaseOrder.setOutsourcingOrder(true);
if (manufOrder.getCompany() != null && manufOrder.getCompany().getStockConfig() != null) {
purchaseOrder.setStockLocation(manufOrder.getCompany().getStockConfig().getOutsourcingReceiptStockLocation());
}
this.setPurchaseOrderSupplierDetails(purchaseOrder);
for (OperationOrder operationOrder : manufOrder.getOperationOrderList()) {
if (operationOrder.getUseLineInGeneratedPurchaseOrder()) {
this.createPurchaseOrderLineProduction(operationOrder, purchaseOrder);
}
}
Beans.get(PurchaseOrderService.class).computePurchaseOrder(purchaseOrder);
manufOrder.setPurchaseOrder(purchaseOrder);
manufOrderRepo.save(manufOrder);
}
use of com.axelor.apps.production.db.OperationOrder in project axelor-open-suite by axelor.
the class ManufOrderWorkflowService method partialFinish.
/**
* Allows to finish partially a manufacturing order, by realizing current stock move and planning
* the difference with the planned prodproducts.
*
* @param manufOrder
* @throws AxelorException
*/
@Transactional(rollbackOn = { Exception.class })
public boolean partialFinish(ManufOrder manufOrder) throws AxelorException {
if (manufOrder.getIsConsProOnOperation()) {
for (OperationOrder operationOrder : manufOrder.getOperationOrderList()) {
if (operationOrder.getStatusSelect() == OperationOrderRepository.STATUS_PLANNED) {
operationOrderWorkflowService.start(operationOrder);
}
}
}
Beans.get(CostSheetService.class).computeCostPrice(manufOrder, CostSheetRepository.CALCULATION_PARTIAL_END_OF_PRODUCTION, Beans.get(AppBaseService.class).getTodayDate(manufOrder.getCompany()));
Beans.get(ManufOrderStockMoveService.class).partialFinish(manufOrder);
ProductionConfig productionConfig = manufOrder.getCompany() != null ? productionConfigRepo.findByCompany(manufOrder.getCompany()) : null;
if (productionConfig != null && productionConfig.getPartFinishMoAutomaticEmail()) {
return this.sendMail(manufOrder, productionConfig.getPartFinishMoMessageTemplate());
}
return true;
}
Aggregations