Search in sources :

Example 6 with EntityList

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);
}
Also used : Entity(com.qcadoo.model.api.Entity) EntityList(com.qcadoo.model.api.EntityList)

Example 7 with EntityList

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);
}
Also used : Entity(com.qcadoo.model.api.Entity) EntityList(com.qcadoo.model.api.EntityList)

Example 8 with EntityList

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));
}
Also used : Entity(com.qcadoo.model.api.Entity) EntityList(com.qcadoo.model.api.EntityList)

Example 9 with EntityList

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));
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) EntityList(com.qcadoo.model.api.EntityList)

Example 10 with EntityList

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);
}
Also used : EntityList(com.qcadoo.model.api.EntityList) Before(org.junit.Before)

Aggregations

EntityList (com.qcadoo.model.api.EntityList)103 Entity (com.qcadoo.model.api.Entity)52 Test (org.junit.Test)27 DataDefinition (com.qcadoo.model.api.DataDefinition)16 SearchCriteriaBuilder (com.qcadoo.model.api.search.SearchCriteriaBuilder)16 Before (org.junit.Before)11 UserFieldsMF (com.qcadoo.mes.materialFlow.constants.UserFieldsMF)10 UserLocationFields (com.qcadoo.mes.materialFlow.constants.UserLocationFields)10 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)10 SearchRestrictions (com.qcadoo.model.api.search.SearchRestrictions)10 SecurityService (com.qcadoo.security.api.SecurityService)10 QcadooSecurityConstants (com.qcadoo.security.constants.QcadooSecurityConstants)10 Objects (java.util.Objects)10 Set (java.util.Set)10 Collectors (java.util.stream.Collectors)10 Autowired (org.springframework.beans.factory.annotation.Autowired)10 Service (org.springframework.stereotype.Service)10 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)9 BigDecimal (java.math.BigDecimal)9 StateChangeTest (com.qcadoo.mes.states.StateChangeTest)5