java返回参数处理不返回null,java – 带参数的灵活搜索返回null值

我必须在服务

Java类中执行这种灵活的搜索查询:

select sum({oe:totalPrice})

from {Order as or join CustomerOrderStatus as os on {or:CustomerOrderStatus}={os:pk}

join OrderEntry as oe on {or.pk}={oe.order}}

where {or:versionID} is null and {or:orderType} in (8796093066999)

and {or:company} in (8796093710341)

and {or:pointOfSale} in (8796097413125)

and {oe:ecCode} in ('13','14')

and {or:yearSeason} in (8796093066981)

and {os:code} not in ('CANCELED', 'NOT_APPROVED')

当我在hybris管理控制台中执行此查询时,我正确获取:

1164.00000000

在我的Java服务类中,我写了这个:

private BigDecimal findGroupedOrdersData(String total, String uncDisc, String orderPromo,

Map queryParameters) {

BigDecimal aggregatedValue = new BigDecimal(0);

final StringBuilder queryBuilder = new StringBuilder();

queryBuilder.append("select sum({oe:").append(total).append("})");

queryBuilder.append(

" from {Order as or join CustomerOrderStatus as os on {or:CustomerOrderStatus}={os:pk} join OrderEntry as oe on {or.pk}={oe.order}}");

queryBuilder.append(" where {or:versionID} is null");

if (queryParameters != null && !queryParameters.isEmpty()) {

appendWhereClausesToBuilder(queryBuilder, queryParameters);

}

queryBuilder.append(" and {os:code} not in ('");

queryBuilder.append(CustomerOrderStatus.CANCELED.getCode()).append("', ");

queryBuilder.append("'").append(CustomerOrderStatus.NOT_APPROVED.getCode()).append("')");

FlexibleSearchQuery query = new FlexibleSearchQuery(queryBuilder.toString(), queryParameters);

List result = Lists.newArrayList();

query.setResultClassList(Arrays.asList(BigDecimal.class));

result = getFlexibleSearchService(). search(query).getResult();

if (!result.isEmpty() && result.get(0) != null) {

aggregatedValue = result.get(0);

}

return aggregatedValue;

}

private void appendWhereClausesToBuilder(StringBuilder builder, Map params) {

if ((params == null) || (params.isEmpty()))

return;

for (String paramName : params.keySet()) {

builder.append(" and ");

if (paramName.equalsIgnoreCase("exitCollection")) {

builder.append("{oe:ecCode}").append(" in (?").append(paramName).append(")");

} else {

builder.append("{or:").append(paramName).append("}").append(" in (?").append(paramName).append(")");

}

}

}

搜索(查询).getResult()函数之前的查询字符串是:

query: [select sum({oe:totalPrice}) from {Order as or join CustomerOrderStatus as os on {or:CustomerOrderStatus}={os:pk}

join OrderEntry as oe on {or.pk}={oe.order}} where {or:versionID} is null

and {or:orderType} in (?orderType) and {or:company} in (?company)

and {or:pointOfSale} in (?pointOfSale) and {oe:ecCode} in (?exitCollection)

and {or:yearSeason} in (?yearSeason) and {os:code} not in ('CANCELED', 'NOT_APPROVED')],

query parameters: [{orderType=OrderTypeModel (8796093230839),

pointOfSale=B2BUnitModel (8796097413125), company=CompanyModel (8796093710341),

exitCollection=[13, 14], yearSeason=YearSeasonModel (8796093066981)}]

但在搜索(查询)结果为[null]之后.

为什么?我在Java代码中哪里错了?谢谢.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值