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;
}
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);
}
}
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);
}
}
}
Aggregations