本文整理了Java中com.qcadoo.model.api.Entity.getLongField()
方法的一些代码示例,展示了Entity.getLongField()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.getLongField()
方法的具体详情如下:
包路径:com.qcadoo.model.api.Entity
类名称:Entity
方法名:getLongField
暂无
代码示例来源:origin: qcadoo/mes
private boolean hasTechnologyChanged(final Entity order, final Entity technology) {
Entity existingOrder = getExistingOrder(order);
if (existingOrder == null || technology == null) {
return false;
}
Long existingOrderTechnology = existingOrder.getLongField(TECHNOLOGY);
if (existingOrderTechnology == null) {
return true;
}
return !existingOrderTechnology.equals(technology.getId());
}
代码示例来源:origin: qcadoo/mes
private boolean checkIfTechnologyInOrderChange(final Entity order, final Entity orderDB) {
Entity technology = order.getBelongsToField(OrderFields.TECHNOLOGY);
Long technologyDBId = orderDB.getLongField(OrderFields.TECHNOLOGY);
if (technologyDBId == null) {
return true;
}
if (!technology.getId().equals(technologyDBId)) {
return true;
}
return false;
}
代码示例来源:origin: qcadoo/mes
public long getPalletsCountInStorageLocation(final Entity newStorageLocation) {
StringBuilder hql = new StringBuilder();
hql.append("select count(distinct p.number) as palletsCount from #materialFlowResources_resource r ");
hql.append("join r.palletNumber p ");
hql.append("join r.storageLocation sl ");
hql.append("where sl.id = '").append(newStorageLocation.getId()).append("'");
Entity result = dataDefinitionService
.get(MaterialFlowResourcesConstants.PLUGIN_IDENTIFIER, MaterialFlowResourcesConstants.MODEL_RESOURCE)
.find(hql.toString()).setMaxResults(1).uniqueResult();
return result.getLongField("palletsCount");
}
代码示例来源:origin: qcadoo/mes
public long getPalletsCountInStorageLocationWithoutPalletNumber(final Entity newStorageLocation, final Entity newPalletNumber) {
StringBuilder hql = new StringBuilder();
hql.append("select count(distinct p.number) as palletsCount from #materialFlowResources_resource r ");
hql.append("join r.palletNumber p ");
hql.append("join r.storageLocation sl ");
hql.append("where sl.id = '").append(newStorageLocation.getId()).append("' ");
hql.append("and p.number != '").append(newPalletNumber.getStringField(PalletNumberFields.NUMBER)).append("'");
Entity result = dataDefinitionService
.get(MaterialFlowResourcesConstants.PLUGIN_IDENTIFIER, MaterialFlowResourcesConstants.MODEL_RESOURCE)
.find(hql.toString()).setMaxResults(1).uniqueResult();
return result.getLongField("palletsCount");
}
代码示例来源:origin: qcadoo/mes
public List<Long> getIntermediateProducts(final List<Long> ids) {
if(ids.isEmpty()) {
return Collections.EMPTY_LIST;
}
String sql = "SELECT technology.id as technologyId, technology.product.id as productId " + "FROM #technologies_technology technology "
+ "WHERE technology.product.id in (:ids)"
+ " and technology.state = '02accepted' and technology.master = true) ";
List<Entity> entities = dataDefinitionService
.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY)
.find(sql).setParameterList("ids", ids).list().getEntities();
return entities.stream().map(en -> en.getLongField("productId")).collect(Collectors.toList());
}
}
代码示例来源:origin: qcadoo/mes
private boolean checkIfOrdersAssignedToMasterOrder(final Entity masterOrderProduct) {
Entity masterOrder = masterOrderProduct.getBelongsToField(MasterOrderProductFields.MASTER_ORDER);
StringBuilder query = new StringBuilder();
query.append("SELECT masterOrder.id AS masterOrderId, masterOrder.number AS masterOrderNumber, ");
query.append(
"(SELECT count(mproduct) FROM #masterOrders_masterOrderProduct mproduct WHERE mproduct.masterOrder.id = masterOrder.id) AS positions, ");
query.append("(SELECT count(morder) FROM #orders_order morder WHERE morder.masterOrder.id = masterOrder.id) AS orders ");
query.append("FROM #masterOrders_masterOrder masterOrder ");
query.append("WHERE masterOrder.id = :oid");
Entity masterOrderFromDB = masterOrder.getDataDefinition().find(query.toString()).setLong("oid", masterOrder.getId())
.setMaxResults(1).uniqueResult();
if (masterOrderFromDB.getLongField("orders") != 0l && masterOrderFromDB.getLongField("positions") == 0l) {
masterOrderProduct.addGlobalError("masterOrders.masterOrderProduct.alreadyExistsOrdersAssignedToMasterOrder", false);
return false;
}
return true;
}
代码示例来源:origin: qcadoo/mes
public boolean checkProductAndTechnology(final DataDefinition orderDD, final Entity order) {
Entity mo = order.getBelongsToField(OrderFieldsMO.MASTER_ORDER);
if (Objects.isNull(mo)) {
return true;
}
StringBuilder query = new StringBuilder();
query.append("SELECT masterOrder.id as masterOrderId, masterOrder.number as masterOrderNumber, ");
query.append(
"(select count(mproduct) FROM #masterOrders_masterOrderProduct mproduct WHERE mproduct.masterOrder.id = masterOrder.id) as positions ");
query.append("FROM #masterOrders_masterOrder masterOrder ");
query.append("WHERE masterOrder.id = :oid");
Entity masterOrder = orderDD.find(query.toString()).setLong("oid", mo.getId()).setMaxResults(1).uniqueResult();
if (Objects.isNull(masterOrder) || masterOrder.getLongField("positions") == 0l) {
return true;
}
return checkIfOrderMatchesAnyOfMasterOrderProductsWithTechnology(order, masterOrder);
}
代码示例来源:origin: qcadoo/mes
private BigDecimal getLaborCostForCumulatedTypeRecording(final Entity order, final Entity parameters) {
StringBuilder query = new StringBuilder();
query.append("SELECT sum(productionTracking.machineTime) AS machineTime, ");
query.append("sum(productionTracking.laborTime) AS laborTime ");
query.append("FROM #productionCounting_productionTracking productionTracking ");
query.append("LEFT JOIN productionTracking.order _order ");
query.append("WHERE _order.id = :orderId AND productionTracking.state = '02accepted'");
Entity costEntity = dataDefinitionService.get("productionCounting", "productionTracking").find(query.toString())
.setLong("orderId", order.getId()).setMaxResults(1).uniqueResult();
BigDecimal laborCostPerHour = BigDecimalUtils.convertNullToZero(parameters
.getDecimalField(ParameterFieldsPC.AVERAGE_LABOR_HOURLY_COST_PB));
BigDecimal machineCostPerHour = BigDecimalUtils.convertNullToZero(parameters
.getDecimalField(ParameterFieldsPC.AVERAGE_MACHINE_HOURLY_COST_PB));
BigDecimal machineCost = BigDecimalUtils.convertNullToZero(costEntity.getLongField("machineTime")).divide(new BigDecimal(3600),
numberService.getMathContext()).multiply(machineCostPerHour, numberService.getMathContext());
BigDecimal laborCost = BigDecimalUtils.convertNullToZero(costEntity.getLongField("laborTime")).divide(new BigDecimal(3600),
numberService.getMathContext()).multiply(laborCostPerHour, numberService.getMathContext());
return laborCost.add(machineCost, numberService.getMathContext());
}
代码示例来源:origin: qcadoo/mes
public void setFilterParameters(final LookupComponent staffLookup, Entity assignmentToShift) {
FilterValueHolder filter = staffLookup.getFilterValue();
Date startDate = assignmentToShift.getDateField(AssignmentToShiftFields.START_DATE);
String hql = "select staff.worker.id as workerId from #assignmentToShift_staffAssignmentToShift staff "
+ " where staff.assignmentToShift.startDate = '" + DateUtils.toDateString(startDate) + "'";
List<Entity> workersIds = dataDefinitionService
.get(AssignmentToShiftConstants.PLUGIN_IDENTIFIER, AssignmentToShiftConstants.MODEL_STAFF_ASSIGNMENT_TO_SHIFT)
.find(hql).list().getEntities();
if (!workersIds.isEmpty()) {
filter.put("workersIds", workersIds.stream().map(id -> id.getLongField("workerId")).collect(Collectors.toList()));
staffLookup.setFilterValue(filter);
}
}
}
代码示例来源:origin: qcadoo/mes
.get(DeliveriesConstants.PLUGIN_IDENTIFIER, DeliveriesConstants.MODEL_DELIVERY)
.find(queryForDelivered.toString()).setLong("productId", product.getId()).setDate("deliveryDate", coverageToDate)
.setMaxResults(1).uniqueResult().getLongField("cnt");
if (deliveredCount > 0) {
return RowStyle.YELLOW_BACKGROUND;
代码示例来源:origin: qcadoo/mes
private void updateOutProducts(final Entity productionTracking,
final OperationProductsExtractor.TrackingOperationProducts operationProducts) {
List<Entity> outputs = operationProducts.getOutputComponents();
List<Entity> productionTrackingOutputs = productionTracking
.getHasManyField(ProductionTrackingFields.TRACKING_OPERATION_PRODUCT_OUT_COMPONENTS).find()
.setProjection(alias(field(TrackingOperationProductOutComponentFields.PRODUCT + ".id"), PRODUCT_ID_FIELD_NAME))
.list().getEntities();
Map<Long, Entity> outputsMap = outputs.stream().collect(
Collectors.toMap(x -> x.getBelongsToField(TrackingOperationProductOutComponentFields.PRODUCT).getId(), x -> x));
Map<Long, Entity> productionTrackingOutputsMap = productionTrackingOutputs.stream()
.collect(Collectors.toMap(x -> x.getLongField(PRODUCT_ID_FIELD_NAME), x -> x));
Set<Long> newEntries = Sets.difference(outputsMap.keySet(), productionTrackingOutputsMap.keySet());
Set<Long> removedEntries = Sets.difference(productionTrackingOutputsMap.keySet(), outputsMap.keySet());
for (Long newEntry : newEntries) {
Entity trackingOperationProductOutComponent = outputsMap.get(newEntry);
trackingOperationProductOutComponent.setField(TrackingOperationProductOutComponentFields.PRODUCTION_TRACKING,
productionTracking);
trackingOperationProductOutComponent.getDataDefinition().save(trackingOperationProductOutComponent);
}
for (Long removedEntry : removedEntries) {
dataDefinitionService.get(ProductionCountingConstants.PLUGIN_IDENTIFIER,
ProductionCountingConstants.MODEL_TRACKING_OPERATION_PRODUCT_OUT_COMPONENT).delete(removedEntry);
}
}
代码示例来源:origin: qcadoo/mes
private void updateInProducts(final Entity productionTracking,
final OperationProductsExtractor.TrackingOperationProducts operationProducts) {
List<Entity> inputs = operationProducts.getInputComponents();
List<Entity> productionTrackingInputs = productionTracking
.getHasManyField(ProductionTrackingFields.TRACKING_OPERATION_PRODUCT_IN_COMPONENTS).find()
.setProjection(alias(field(TrackingOperationProductInComponentFields.PRODUCT + ".id"), PRODUCT_ID_FIELD_NAME))
.list().getEntities();
Map<Long, Entity> inputsMap = inputs.stream().collect(
Collectors.toMap(x -> x.getBelongsToField(TrackingOperationProductInComponentFields.PRODUCT).getId(), x -> x));
Map<Long, Entity> productionTrackingInputsMap = productionTrackingInputs.stream()
.collect(Collectors.toMap(x -> x.getLongField(PRODUCT_ID_FIELD_NAME), x -> x));
Set<Long> newEntries = Sets.difference(inputsMap.keySet(), productionTrackingInputsMap.keySet());
Set<Long> removedEntries = Sets.difference(productionTrackingInputsMap.keySet(), inputsMap.keySet());
for (Long newEntry : newEntries) {
Entity trackingOperationProductInComponent = inputsMap.get(newEntry);
trackingOperationProductInComponent.setField(TrackingOperationProductInComponentFields.PRODUCTION_TRACKING,
productionTracking);
trackingOperationProductInComponent.getDataDefinition().save(trackingOperationProductInComponent);
}
for (Long removedEntry : removedEntries) {
dataDefinitionService.get(ProductionCountingConstants.PLUGIN_IDENTIFIER,
ProductionCountingConstants.MODEL_TRACKING_OPERATION_PRODUCT_IN_COMPONENT).delete(removedEntry);
}
}
}
代码示例来源:origin: qcadoo/mes
machineCostPerHour = BigDecimalUtils.convertNullToZero(cost.getDecimalField("machineHourlyCost"));
BigDecimal machineHourlyCostPerToc = new BigDecimal(nullLongToZero(cost.getLongField("machineTime"))).divide(new BigDecimal(3600),
numberService.getMathContext()).multiply(machineCostPerHour, numberService.getMathContext());
machineCost = machineCost.add(machineHourlyCostPerToc, numberService.getMathContext());
BigDecimal laborHourlyCostPerToc = new BigDecimal(nullLongToZero(cost.getLongField("laborTime"))).divide(new BigDecimal(3600),
numberService.getMathContext()).multiply(laborCostPerHour, numberService.getMathContext());
laborCost = laborCost.add(laborHourlyCostPerToc, numberService.getMathContext());
代码示例来源:origin: qcadoo/mes
public void addRegisterEntryForOrder(List<Entity> entries, Entity order, Entity opic, BigDecimal quantity, String eventType,
List<Long> intermediateProducts) {
Entity registerEntry = dataDefinitionService.get(OrderSuppliesConstants.PLUGIN_IDENTIFIER,
OrderSuppliesConstants.MODEL_COVERAGE_REGISTER).create();
registerEntry.setField(CoverageRegisterFields.DATE, order.getDateField(OrderFields.START_DATE));
registerEntry.setField(CoverageRegisterFields.ORDER, order);
registerEntry.setField(CoverageRegisterFields.ORDER_NUMBER, order.getStringField(OrderFields.NUMBER));
registerEntry.setField(
CoverageRegisterFields.OPERATION,
opic.getLongField("operationId"));
registerEntry.setField(CoverageRegisterFields.PRODUCT, opic.getLongField("productId"));
registerEntry.setField(CoverageRegisterFields.PRODUCT_NUMBER, opic.getStringField("productNumber"));
registerEntry.setField(CoverageRegisterFields.QUANTITY, quantity);
registerEntry.setField(CoverageRegisterFields.PRODUCTION_COUNTING_QUANTITIES, quantity);
registerEntry.setField(CoverageRegisterFields.EVENT_TYPE, eventType);
registerEntry.setField(CoverageRegisterFields.TECHNOLOGY_OPERATION_COMPONENT, opic.getLongField("tocId"));
if (intermediateProducts.contains( opic.getLongField("productId"))) {
registerEntry.setField(CoverageRegisterFields.PRODUCT_TYPE, "02intermediate");
} else {
registerEntry.setField(CoverageRegisterFields.PRODUCT_TYPE, "01component");
}
entries.add(registerEntry);
}
代码示例来源:origin: qcadoo/mes
public void createRegistryEntriesForOrder(Entity order, boolean plannedQuantityChanged) {
OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer = productQuantitiesService
.getProductComponentQuantitiesWithoutNonComponents(Lists.newArrayList(order), true);
String typeOfProductionRecording = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING);
String eventType = null;
if (TypeOfProductionRecording.FOR_EACH.getStringValue().equals(typeOfProductionRecording)) {
eventType = CoverageProductLoggingEventType.OPERATION_INPUT.getStringValue();
} else if (TypeOfProductionRecording.CUMULATED.getStringValue().equals(typeOfProductionRecording)
|| TypeOfProductionRecording.BASIC.getStringValue().equals(typeOfProductionRecording)) {
eventType = CoverageProductLoggingEventType.ORDER_INPUT.getStringValue();
}
OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainerIn = operationProductComponentWithQuantityContainer
.getAllWithSameEntityType(TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT);
List<Entity> opics = registerService.getOPICForTechnology(order.getBelongsToField(OrderFields.TECHNOLOGY));
List<Entity> entries = Lists.newArrayList();
List<Long> productIds = opics.stream().map(en -> en.getLongField("productId")).collect(Collectors.toList());
List<Long> intermediateProducts = registerService.getIntermediateProducts(productIds);
for (Entity opic : opics) {
BigDecimal quantity = operationProductComponentWithQuantityContainerIn.get(opic.getBelongsToField("opic"));
if (quantity != null) {
registerService.addRegisterEntryForOrder(entries, order, opic, quantity, eventType, intermediateProducts);
}
}
addOutputEntry(operationProductComponentWithQuantityContainer, order, entries, plannedQuantityChanged);
order.setField(OrderFieldsOS.COVERAGE_REGISTERS, entries);
}
代码示例来源:origin: qcadoo/mes
public void addPositions(final ViewDefinitionState view, final ComponentState state, final String[] args) {
GridComponent grid = (GridComponent) view.getComponentByReference("resourceGrid");
Set<Long> selectedEntities = grid.getSelectedEntitiesIds();
CheckBoxComponent generated = (CheckBoxComponent) view.getComponentByReference("generated");
if (selectedEntities.isEmpty()) {
generated.setChecked(false);
view.addMessage("materialFlowResources.positionAddMulti.noSelectedResources", ComponentState.MessageType.INFO);
return;
}
FormComponent form = (FormComponent) view.getComponentByReference("form");
Entity helper = form.getPersistedEntityWithIncludedFormValues();
Entity document = dataDefinitionService.get(MaterialFlowResourcesConstants.PLUGIN_IDENTIFIER,
MaterialFlowResourcesConstants.MODEL_DOCUMENT).get(helper.getLongField("documentId"));
List<String> errorNumbers = Lists.newArrayList();
for (Long resourceId : selectedEntities) {
Entity resource = dataDefinitionService.get(MaterialFlowResourcesConstants.PLUGIN_IDENTIFIER,
MaterialFlowResourcesConstants.MODEL_RESOURCE).get(resourceId);
Entity newPosition = createPosition(document, resource);
if (!newPosition.isValid()) {
errorNumbers.add(resource.getStringField(ResourceFields.NUMBER));
}
}
if (!errorNumbers.isEmpty()) {
view.addMessage("materialFlowResources.positionAddMulti.errorForResource", ComponentState.MessageType.INFO,
errorNumbers.stream().collect(Collectors.joining(", ")));
}
generated.setChecked(true);
}
代码示例来源:origin: qcadoo/mes
public boolean isWorkstationTypeComponentsQuantityGreaterThanZero(final Entity productionLine, final Entity workstationType) {
Long sum = dataDefinitionService
.get(ProductionLinesConstants.PLUGIN_IDENTIFIER, ProductionLinesConstants.MODEL_WORKSTATION_TYPE_COMPONENT).find()
.add(SearchRestrictions.belongsTo(WorkstationTypeComponentFields.PRODUCTIONLINE, productionLine))
.add(SearchRestrictions.belongsTo(WorkstationTypeComponentFields.WORKSTATIONTYPE, workstationType))
.setProjection(list()
.add(SearchProjections.alias(SearchProjections.sum(WorkstationTypeComponentFields.QUANTITY), SUM_ALIAS))
.add(rowCount()))
.addOrder(SearchOrders.desc(SUM_ALIAS)).setMaxResults(1).uniqueResult().getLongField(SUM_ALIAS);
if (sum == null) {
return false;
} else {
return sum > 0;
}
}
代码示例来源:origin: qcadoo/mes
public boolean existsNewEventsToNotification(Long currentUserId) {
Entity user = dataDefinitionService.get(QcadooSecurityConstants.PLUGIN_IDENTIFIER, QcadooSecurityConstants.MODEL_USER)
.get(currentUserId);
Entity factory = user.getBelongsToField("factory");
SearchCriteriaBuilder scb = getMaintenanceEventDD()
.find()
.setProjection(SearchProjections.alias(SearchProjections.rowCount(), "countrows"))
.add(SearchRestrictions.eq(MaintenanceEventFields.SOUND_NOTIFICATIONS, true));
if (factory != null) {
scb = scb.add(SearchRestrictions.belongsTo("factory", factory));
}
scb = scb.addOrder(SearchOrders.asc("countrows"));
Entity entity = scb.setFirstResult(0).setMaxResults(1).uniqueResult();
if (entity.getLongField("countrows") > 0) {
return true;
}
return false;
}
}
代码示例来源:origin: qcadoo/mes
private boolean hasMatchingMasterOrderProducts(final Entity order, final Entity masterOrder) {
Entity orderTechnologyPrototype = order.getBelongsToField(OrderFields.TECHNOLOGY_PROTOTYPE);
Entity orderProduct = order.getBelongsToField(OrderFields.PRODUCT);
SearchCriteriaBuilder masterCriteria = dataDefinitionService
.get(MasterOrdersConstants.PLUGIN_IDENTIFIER, MasterOrdersConstants.MODEL_MASTER_ORDER).find();
masterCriteria.setProjection(alias(id(), "id"));
masterCriteria.add(idEq(masterOrder.getLongField("masterOrderId")));
SearchCriteriaBuilder masterProductsCriteria = masterCriteria.createCriteria(MasterOrderFields.MASTER_ORDER_PRODUCTS,
"masterProducts", JoinType.INNER);
masterProductsCriteria.add(belongsTo(MasterOrderProductFields.PRODUCT, orderProduct));
if (orderTechnologyPrototype == null) {
masterProductsCriteria.add(isNull(MasterOrderProductFields.TECHNOLOGY));
} else {
masterProductsCriteria.add(or(isNull(MasterOrderProductFields.TECHNOLOGY),
belongsTo(MasterOrderProductFields.TECHNOLOGY, orderTechnologyPrototype)));
}
return masterCriteria.setMaxResults(1).uniqueResult() != null;
}
内容来源于网络,如有侵权,请联系作者删除!