优化
This commit is contained in:
+10
@@ -21,6 +21,16 @@ public interface CitySellStatService {
|
||||
*/
|
||||
List<CitySellStat> getAllWithMonths(String city, int monthCount);
|
||||
|
||||
/**
|
||||
* 获取过去 monCount 个月的数据(包含本月数据)
|
||||
* @param city
|
||||
* @param region
|
||||
* @param name
|
||||
* @param monthCount
|
||||
* @return
|
||||
*/
|
||||
List<CitySellStat> getAllWithCurrMonths(String city, int monthCount);
|
||||
|
||||
/**
|
||||
* 查找城市均价排名前Top条数据
|
||||
* @param top 取的名次数
|
||||
|
||||
+20
@@ -58,6 +58,26 @@ public class CitySellStatServiceImpl implements CitySellStatService {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CitySellStat> getAllWithCurrMonths(final String city, final int monthCount) {
|
||||
Date now = new Date();
|
||||
Date nowMonth = DateUtil.getBeforeDate(now, 0);
|
||||
Date lastMonth = DateUtil.getBeforeDate(now, -1 * monthCount);
|
||||
|
||||
int nowMonthNum = DateUtil.getYear(nowMonth) * 100 + DateUtil.getMonth(now);
|
||||
int lastMonthNum = DateUtil.getYear(lastMonth) * 100 + DateUtil.getMonth(lastMonth);
|
||||
|
||||
List<QueryParam> queryParams = ImmutableList.of(
|
||||
new QueryParam("city", city),
|
||||
new QueryParam("date", QueryParam.LESS_THAN_EQUAL_OPERATOR, nowMonthNum),
|
||||
new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, lastMonthNum)
|
||||
);
|
||||
List<SortParam> sortParams = ImmutableList.of(
|
||||
new SortParam("date", false)
|
||||
);
|
||||
return citySellStatDao.findAllByParams(queryParams, sortParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CitySellStat> findTopCitySellStat(final int top, final int type) {
|
||||
String key = top + "_" + type;
|
||||
|
||||
Reference in New Issue
Block a user