Search in sources :

Example 1 with ProdHumanResource

use of com.axelor.apps.production.db.ProdHumanResource in project axelor-open-suite by axelor.

the class OperationOrderServiceBusinessImpl method copyProdHumanResource.

@Override
protected ProdHumanResource copyProdHumanResource(ProdHumanResource prodHumanResource) {
    AppProductionService appProductionService = Beans.get(AppProductionService.class);
    if (!appProductionService.isApp("production") || !appProductionService.getAppProduction().getManageBusinessProduction()) {
        return super.copyProdHumanResource(prodHumanResource);
    }
    ProdHumanResource prodHumanResourceCopy = new ProdHumanResource(prodHumanResource.getProduct(), prodHumanResource.getDuration());
    prodHumanResourceCopy.setEmployee(prodHumanResource.getEmployee());
    return prodHumanResourceCopy;
}
Also used : ProdHumanResource(com.axelor.apps.production.db.ProdHumanResource) AppProductionService(com.axelor.apps.production.service.app.AppProductionService)

Example 2 with ProdHumanResource

use of com.axelor.apps.production.db.ProdHumanResource in project axelor-open-suite by axelor.

the class ManufOrderWorkflowService method createPurchaseOrderLineProduction.

private void createPurchaseOrderLineProduction(OperationOrder operationOrder, PurchaseOrder purchaseOrder) throws AxelorException {
    UnitConversionService unitConversionService = Beans.get(UnitConversionService.class);
    PurchaseOrderLineService purchaseOrderLineService = Beans.get(PurchaseOrderLineService.class);
    PurchaseOrderLine purchaseOrderLine;
    BigDecimal quantity = BigDecimal.ONE;
    Unit startUnit = Beans.get(UnitRepository.class).all().filter("self.name = 'Hour' AND self.unitTypeSelect = 3").fetchOne();
    for (ProdHumanResource humanResource : operationOrder.getProdHumanResourceList()) {
        Product product = humanResource.getProduct();
        Unit purchaseUnit = product.getPurchasesUnit();
        if (purchaseUnit != null) {
            quantity = unitConversionService.convert(startUnit, purchaseUnit, new BigDecimal(humanResource.getDuration() / 3600), 0, humanResource.getProduct());
        }
        purchaseOrderLine = purchaseOrderLineService.createPurchaseOrderLine(purchaseOrder, product, null, null, quantity, purchaseUnit);
        purchaseOrder.getPurchaseOrderLineList().add(purchaseOrderLine);
    }
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) UnitConversionService(com.axelor.apps.base.service.UnitConversionService) ProdHumanResource(com.axelor.apps.production.db.ProdHumanResource) UnitRepository(com.axelor.apps.base.db.repo.UnitRepository) Product(com.axelor.apps.base.db.Product) PurchaseOrderLineService(com.axelor.apps.purchase.service.PurchaseOrderLineService) ChronoUnit(java.time.temporal.ChronoUnit) Unit(com.axelor.apps.base.db.Unit) BigDecimal(java.math.BigDecimal)

Example 3 with ProdHumanResource

use of com.axelor.apps.production.db.ProdHumanResource in project axelor-open-suite by axelor.

the class CostSheetServiceImpl method computeRealHumanResourceCost.

protected void computeRealHumanResourceCost(OperationOrder operationOrder, int priority, int bomLevel, CostSheetLine parentCostSheetLine, LocalDate previousCostSheetDate) throws AxelorException {
    if (operationOrder.getProdHumanResourceList() != null) {
        Long duration = 0L;
        if (parentCostSheetLine.getCostSheet().getCalculationTypeSelect() == CostSheetRepository.CALCULATION_END_OF_PRODUCTION || parentCostSheetLine.getCostSheet().getCalculationTypeSelect() == CostSheetRepository.CALCULATION_PARTIAL_END_OF_PRODUCTION) {
            Period period = previousCostSheetDate != null ? Period.between(parentCostSheetLine.getCostSheet().getCalculationDate(), previousCostSheetDate) : null;
            duration = period != null ? Long.valueOf(period.getDays() * 24) : operationOrder.getRealDuration();
        } else if (parentCostSheetLine.getCostSheet().getCalculationTypeSelect() == CostSheetRepository.CALCULATION_WORK_IN_PROGRESS) {
            BigDecimal ratio = costSheet.getManufOrderProducedRatio();
            Long plannedDuration = DurationTool.getSecondsDuration(Duration.between(operationOrder.getPlannedStartDateT(), operationOrder.getPlannedEndDateT())) * ratio.longValue();
            Long totalPlannedDuration = 0L;
            for (OperationOrder manufOperationOrder : operationOrder.getManufOrder().getOperationOrderList()) {
                if (manufOperationOrder.equals(operationOrder)) {
                    totalPlannedDuration += manufOperationOrder.getPlannedDuration();
                }
            }
            duration = Math.abs(totalPlannedDuration - plannedDuration);
        }
        for (ProdHumanResource prodHumanResource : operationOrder.getProdHumanResourceList()) {
            this.computeRealHumanResourceCost(prodHumanResource, operationOrder.getWorkCenter(), priority, bomLevel, parentCostSheetLine, duration);
        }
    }
}
Also used : ProdHumanResource(com.axelor.apps.production.db.ProdHumanResource) Period(java.time.Period) OperationOrder(com.axelor.apps.production.db.OperationOrder) BigDecimal(java.math.BigDecimal)

Aggregations

ProdHumanResource (com.axelor.apps.production.db.ProdHumanResource)3 BigDecimal (java.math.BigDecimal)2 Product (com.axelor.apps.base.db.Product)1 Unit (com.axelor.apps.base.db.Unit)1 UnitRepository (com.axelor.apps.base.db.repo.UnitRepository)1 UnitConversionService (com.axelor.apps.base.service.UnitConversionService)1 OperationOrder (com.axelor.apps.production.db.OperationOrder)1 AppProductionService (com.axelor.apps.production.service.app.AppProductionService)1 PurchaseOrderLine (com.axelor.apps.purchase.db.PurchaseOrderLine)1 PurchaseOrderLineService (com.axelor.apps.purchase.service.PurchaseOrderLineService)1 Period (java.time.Period)1 ChronoUnit (java.time.temporal.ChronoUnit)1