private Long toId(Entity entity) { if (entity == null) { return null; } return entity.getId(); }
private boolean isCoverageLocationAlreadyUsed(final Entity coverageLocation, final Entity addedCoverageLocation, final Entity location, final Entity addedLocation) { return ((coverageLocation.getId() == null) || !coverageLocation.getId().equals(addedCoverageLocation.getId())) && addedLocation.getId().equals(location.getId()); }
private boolean storageLocationChanged(final Entity oldResourde, final Entity newStorageLocation) { Entity oldStorageLocation = oldStorageLocation(oldResourde); return (newStorageLocation != null && oldStorageLocation != null) ? (newStorageLocation.getId().compareTo( oldStorageLocation.getId()) != 0) : !(newStorageLocation == null && oldStorageLocation == null); }
private boolean checkIfWarehouseHasChanged(final Entity oldDocument, final Entity newDocument, final String warehouseField) { Entity oldWarehouse = oldDocument.getBelongsToField(warehouseField); Entity newWarehouse = newDocument.getBelongsToField(warehouseField); if (oldWarehouse == null && newWarehouse == null) { return false; } else if (oldWarehouse != null && newWarehouse != null) { return oldWarehouse.getId().compareTo(newWarehouse.getId()) != 0; } return true; }
@Override public void updateCostNormsForProductsFromWarehouses(final List<Entity> products, final List<Entity> warehouses) { List<Long> productIds = products.stream().map(product -> product.getId()).collect(Collectors.toList()); List<Long> warehousesIds = warehouses.stream().filter(warehouse -> warehouse != null).map(warehouse -> warehouse.getId()) .collect(Collectors.toList()); List<CostNorm> lastPurchases = costNormsDao.getLastPurchaseCostsForProducts(productIds, warehousesIds); List<CostNorm> averageCosts = costNormsDao.getAverageCostForProducts(productIds, warehousesIds); costNormsDao.updateCostNormsForProducts(mergeCostNorms(lastPurchases, averageCosts)); }
private void clearAssociatedBarcodeOperationComponents(final StateChangeContext stateChangeContext) { final Entity order = stateChangeContext.getOwner(); if (order != null && order.getId() != null) { String query = "DELETE FROM technologies_barcodeoperationcomponent WHERE order_id = :id"; jdbcTemplate.update(query, new MapSqlParameterSource("id", order.getId())); } }
private void fillCoverageProductForDelivery(final Map<Long, Entity> productAndCoverageProducts, final Entity product, final Entity coverageProductLogging) { if (coverageProductLogging != null) { if (productAndCoverageProducts.containsKey(product.getId())) { updateCoverageProductForDelivery(productAndCoverageProducts, product, coverageProductLogging); } else { addCoverageProductForDelivery(productAndCoverageProducts, product, coverageProductLogging); } } }
public List<Entity> findComponentRegistryEntries(final Entity order) { StringBuilder query = new StringBuilder(); query.append("select registry from #orderSupplies_coverageRegister as registry, "); query.append("#technologies_operationProductInComponent as operationProductInComponent "); query.append("where registry.order.id = :orderId and eventType in ('04orderInput','03operationInput') "); query.append("and productType = '02intermediate' "); query.append("and operationProductInComponent.operationComponent = registry.technologyOperationComponent "); query.append("and operationProductInComponent.product = registry.product order by operationProductInComponent.priority "); return dataDefinitionService.get(OrderSuppliesConstants.PLUGIN_IDENTIFIER, "coverageRegister").find(query.toString()) .setParameter("orderId", order.getId()).list().getEntities(); }
public List<Long> getRegisterOrderProductsIds(final List<Entity> order) { List<Long> orderIds = order.stream().map(o -> o.getId()).collect(Collectors.toList()); List<Entity> entries = dataDefinitionService .get(OrderSuppliesConstants.PLUGIN_IDENTIFIER, OrderSuppliesConstants.MODEL_COVERAGE_REGISTER).find() .createAlias(CoverageRegisterFields.ORDER, "ord", JoinType.LEFT) .add(SearchRestrictions.in("ord.id", Lists.newArrayList(orderIds))).list().getEntities(); return entries.stream().map(r -> r.getBelongsToField(CoverageRegisterFields.PRODUCT).getId()) .collect(Collectors.toList()); }
private Date findCalculatedStartAllOrders(final Entity order) { List<Entity> ordersTimeCalculations = dataDefinitionService .get(TimeNormsConstants.PLUGIN_PRODUCTION_SCHEDULING_IDENTIFIER, TimeNormsConstants.MODEL_ORDER_TIME_CALCULATION) .find().createAlias("order", "ord", JoinType.LEFT) .add(SearchRestrictions.in("ord.id", getOrderAndSubOrders(order.getId()).stream().map(entity -> entity.getId()).collect(Collectors.toList()))) .list().getEntities(); return ordersTimeCalculations.stream().map(e -> e.getDateField(OrderTimeCalculationFields.EFFECTIVE_DATE_FROM)) .min(Comparator.<Date>naturalOrder()).get(); }
private Integer getWorkstationsQuantityFromMap(final Map<Long, Integer> workstations, final Entity operationComponent) { Entity operComp = operationComponent; String entityType = operationComponent.getDataDefinition().getName(); if (!TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(entityType)) { operComp = operComp.getBelongsToField(L_TECHNOLOGY_OPERATION_COMPONENT).getDataDefinition() .get(operComp.getBelongsToField(L_TECHNOLOGY_OPERATION_COMPONENT).getId()); } return workstations.get(operComp.getId()); }
private BigDecimal getOperationRunsFromMap(final Map<Long, BigDecimal> operationRuns, final Entity operationComponent) { Entity operComp = operationComponent; String entityType = operationComponent.getDataDefinition().getName(); if (!TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(entityType)) { operComp = operComp.getBelongsToField(L_TECHNOLOGY_OPERATION_COMPONENT).getDataDefinition() .get(operComp.getBelongsToField(L_TECHNOLOGY_OPERATION_COMPONENT).getId()); } return BigDecimalUtils.convertNullToZero(operationRuns.get(operComp.getId())); }
public void restrictToUserLocations(final SearchCriteriaBuilder scb, final FilterValueHolder filterValue) { Long currentUserId = securityService.getCurrentUserId(); if (Objects.nonNull(currentUserId)) { EntityList userLocations = userDataDefinition().get(currentUserId).getHasManyField(UserFieldsMF.USER_LOCATIONS); if (!userLocations.isEmpty()) { Set<Integer> locationIds = userLocations.stream().map(ul -> ul.getBelongsToField(UserLocationFields.LOCATION)) .mapToInt(e -> e.getId().intValue()).boxed().collect(Collectors.toSet()); scb.add(SearchRestrictions.in(LOCATION_ID, locationIds)); } } }
public List<Entity> generateMaterialAvailabilityForOrder(Entity order) { Entity technology = order.getBelongsToField(OrderFields.TECHNOLOGY); if (order.getId() == null || technology == null) { return Collections.EMPTY_LIST; } List<Entity> materialsAvailability = createMaterialAvailability(order, technology); updateQuantityAndAvailability(materialsAvailability); return materialsAvailability; }
public Entity findOrderForTechnology(Entity technology) { String sql = "select o from #orders_order o left join o.technology tech where tech.id = :technologyID"; return dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER).find(sql) .setParameter("technologyID", technology.getId()).setMaxResults(1).uniqueResult(); }
private List<Entity> findReservationsForDelivery(final Entity delivery) { String query = buildQueryForDeliveredProductReservations(delivery); return dataDefinitionService .get(DeliveriesConstants.PLUGIN_IDENTIFIER, DeliveriesConstants.MODEL_DELIVERED_PRODUCT_RESERVATION).find(query) .setParameter(DELIVER_ID, delivery.getId()).list().getEntities(); }
private Entity copyTechnology(final Entity technologyPrototype, final Entity order) { String number = technologyServiceO.generateNumberForTechnologyInOrder(order, technologyPrototype); Entity copyOfTechnology = technologyServiceO.getTechnologyDD().copy(technologyPrototype.getId()).get(0); copyOfTechnology.setField(TechnologyFields.NUMBER, number); copyOfTechnology.setField(TechnologyFields.TECHNOLOGY_PROTOTYPE, technologyPrototype); copyOfTechnology.setField(TechnologyFields.TECHNOLOGY_TYPE, getTechnologyType(order)); copyOfTechnology = copyOfTechnology.getDataDefinition().save(copyOfTechnology); return copyOfTechnology; }
private void fillForComponentsOne(final Entity technology) { List<Entity> opics = operationComponentDataProvider.getOperationProductsForTechnology(technology.getId()); Entity componentsLocation = technology.getBelongsToField(OperationProductOutComponentFieldsPFTD.COMPONENTS_LOCATION); Entity componentsOutputLocation = technology.getBelongsToField(TechnologyFieldsPFTD.COMPONENTS_OUTPUT_LOCATION); for (Entity op : opics) { cleanOperationProduct(op); op.setField(OperationProductInComponentFieldsPFTD.COMPONENTS_LOCATION, componentsLocation); op.setField(OperationProductInComponentFieldsPFTD.COMPONENTS_OUTPUT_LOCATION, componentsOutputLocation); op.getDataDefinition().fastSave(op); } }