use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class ProductionTrackingServiceImpl method copyTrackingOperationProductInComponents.
private void copyTrackingOperationProductInComponents(Entity productionTracking, Entity correctingProductionTracking) {
EntityList trackingOperationProductInComponents = productionTracking.getHasManyField(ProductionTrackingFields.TRACKING_OPERATION_PRODUCT_IN_COMPONENTS);
List<Entity> copiedTrackingOperationProductInComponents = Lists.newArrayList();
trackingOperationProductInComponents.forEach(t -> {
Entity operationProductInComponent = t.getDataDefinition().copy(t.getId()).get(0);
List<Entity> batches = t.getHasManyField(TrackingOperationProductInComponentFields.USED_BATCHES);
List<Entity> copiedBatches = Lists.newArrayList();
batches.forEach(batch -> {
Entity copiedBatch = batch.getDataDefinition().create();
copiedBatch.setField(UsedBatchFields.QUANTITY, batch.getDecimalField(UsedBatchFields.QUANTITY));
copiedBatch.setField(UsedBatchFields.BATCH, batch.getBelongsToField(UsedBatchFields.BATCH).getId());
copiedBatch.setField(UsedBatchFields.TRACKING_OPERATION_PRODUCT_IN_COMPONENT, operationProductInComponent.getId());
copiedBatch = copiedBatch.getDataDefinition().save(copiedBatch);
copiedBatches.add(copiedBatch);
});
operationProductInComponent.setField(TrackingOperationProductInComponentFields.USED_BATCHES, copiedBatches);
copiedTrackingOperationProductInComponents.add(operationProductInComponent);
});
correctingProductionTracking.setField(ProductionTrackingFields.TRACKING_OPERATION_PRODUCT_IN_COMPONENTS, copiedTrackingOperationProductInComponents);
}
use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class ProductionTrackingServiceImpl method copyTrackingOperationProductOutComponents.
private void copyTrackingOperationProductOutComponents(Entity productionTracking, Entity correctingProductionTracking) {
EntityList trackingOperationProductOutComponents = productionTracking.getHasManyField(ProductionTrackingFields.TRACKING_OPERATION_PRODUCT_OUT_COMPONENTS);
List<Entity> copiedTrackingOperationProductOutComponents = Lists.newArrayList();
trackingOperationProductOutComponents.forEach(t -> copiedTrackingOperationProductOutComponents.add(t.getDataDefinition().copy(t.getId()).get(0)));
correctingProductionTracking.setField(ProductionTrackingFields.TRACKING_OPERATION_PRODUCT_OUT_COMPONENTS, copiedTrackingOperationProductOutComponents);
}
use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class ProductionTrackingServiceImpl method copyStaffWorkTimes.
private void copyStaffWorkTimes(Entity productionTracking, Entity correctingProductionTracking) {
EntityList staffWorkTimes = productionTracking.getHasManyField(ProductionTrackingFields.STAFF_WORK_TIMES);
List<Entity> copiedStaffWorkTimes = Lists.newArrayList();
for (Entity staffWorkTime : staffWorkTimes) {
Entity newStaffWorkTime = staffWorkTime.getDataDefinition().create();
newStaffWorkTime.setField(StaffWorkTimeFields.PRODUCTION_RECORD, correctingProductionTracking);
newStaffWorkTime.setField(StaffWorkTimeFields.WORKER, staffWorkTime.getField(StaffWorkTimeFields.WORKER));
newStaffWorkTime.setField(StaffWorkTimeFields.EFFECTIVE_EXECUTION_TIME_END, staffWorkTime.getField(StaffWorkTimeFields.EFFECTIVE_EXECUTION_TIME_END));
newStaffWorkTime.setField(StaffWorkTimeFields.EFFECTIVE_EXECUTION_TIME_START, staffWorkTime.getField(StaffWorkTimeFields.EFFECTIVE_EXECUTION_TIME_START));
newStaffWorkTime.setField(StaffWorkTimeFields.LABOR_TIME, staffWorkTime.getIntegerField(StaffWorkTimeFields.LABOR_TIME));
copiedStaffWorkTimes.add(newStaffWorkTime);
}
correctingProductionTracking.setField(ProductionTrackingFields.STAFF_WORK_TIMES, copiedStaffWorkTimes);
correctingProductionTracking.setField(ProductionTrackingFields.MACHINE_TIME, productionTracking.getField(ProductionTrackingFields.MACHINE_TIME));
correctingProductionTracking.setField(ProductionTrackingFields.LABOR_TIME, productionTracking.getField(ProductionTrackingFields.LABOR_TIME));
}
use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class ProductionTrackingDetailsListeners method copyPlannedQuantityToUsedQuantity.
public void copyPlannedQuantityToUsedQuantity(final ViewDefinitionState view, final ComponentState state, final String[] args) {
FormComponent productionRecordForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Long productionRecordId = productionRecordForm.getEntityId();
if (Objects.isNull(productionRecordId)) {
return;
}
Entity productionRecord = productionRecordForm.getEntity().getDataDefinition().get(productionRecordId);
EntityList trackingOperationProductInComponents = productionRecord.getHasManyField(ProductionTrackingFields.TRACKING_OPERATION_PRODUCT_IN_COMPONENTS);
clearWasteUsedDetails(trackingOperationProductInComponents);
copyPlannedQuantityToUsedQuantity(trackingOperationProductInComponents);
copyPlannedQuantityToUsedQuantity(productionRecord.getHasManyField(ProductionTrackingFields.TRACKING_OPERATION_PRODUCT_OUT_COMPONENTS));
}
use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class OrderClosingHelperTest method init.
@Before
public final void init() {
orderClosingHelper = new OrderClosingHelper();
MockitoAnnotations.initMocks(this);
ReflectionTestUtils.setField(orderClosingHelper, "parameterService", parameterService);
given(parameterService.getParameter()).willReturn(parameter);
given(productionTracking.getId()).willReturn(PRODUCTION_RECORD_ID);
given(productionTracking.getDataDefinition()).willReturn(productionTrackingDD);
given(productionTracking.getField(ProductionTrackingFields.ORDER)).willReturn(order);
given(productionTracking.getBelongsToField(ProductionTrackingFields.ORDER)).willReturn(order);
EntityList tiocs = mockEntityList(NUM_OF_OPERATIONS);
given(order.getBelongsToField(OrderFields.TECHNOLOGY)).willReturn(technology);
given(technology.getHasManyField(TechnologyFields.OPERATION_COMPONENTS)).willReturn(tiocs);
}
Aggregations