Date from = (Date)criteria.get("from");
Date to = (Date)criteria.get("to");
String sellProduct =(String)criteria.get("sellProduct");
String buyProduct =(String)criteria.get("buyProduct");
boolean delivery =((Boolean)criteria.get("delivery")).booleanValue();//boolean delivery =(boolean)criteria.get("delivery"); 错误.object不能转化为boolean
String orderBy = order.get(0);
String orderType = order.get(1);
Filter filter = new Filter(LogicalType.AND);
filter.setEntityName(SpreadTradingRecord.class.getName());
if(orderType.equals("ASC")){
filter.addOrder(new Order(OrderType.ASC,orderBy));
}else{
filter.addOrder(new Order(OrderType.DESC,orderBy));
}
filter.addFilter(new Filter("time",ComparativeType.LESS,to));
filter.addFilter(new Filter("time",ComparativeType.GREATER,from));
//开市闭市的处理
Filter filter_or = new Filter(LogicalType.OR);
Filter filter_open = new Filter(LogicalType.AND);
Filter filter_close = new Filter(LogicalType.AND);
filter_open.addFilter(new Filter("sellProduct",ComparativeType.EQUAL,sellProduct));
filter_open.addFilter(new Filter("buyProduct", ComparativeType.EQUAL,buyProduct));
filter_open.addFilter(new Filter("type", ComparativeType.EQUAL,"OPEN"));
filter_close.addFilter(new Filter("sellProduct",ComparativeType.EQUAL,buyProduct));
filter_close.addFilter(new Filter("buyProduct", ComparativeType.EQUAL,sellProduct));
filter_close.addFilter(new Filter("type", ComparativeType.EQUAL,"CLOSE"));
filter_or.addFilter(filter_open);
filter_or.addFilter(filter_close);
filter.addFilter(filter_or);
// FIXME 没有delivery字段
//filter.addFilter(new Filter("delivery", ComparativeType.EQUAL,delivery));
return dao.findByFilter(filter);