This commit is contained in:
沈健
2025-06-26 09:54:09 +08:00
parent 5b3d997e01
commit 36d87966e9
3 changed files with 32 additions and 2 deletions
@@ -167,7 +167,7 @@ public class TrendController {
model.setRegionItems(getRegionItems(model));
model.setBlockItems(getRegionBlocks(model));
List<CitySellStat> citySellStats = citySellStatService.getAllWithMonths(city, 2);
List<CitySellStat> citySellStats = citySellStatService.getAllWithCurrMonths(city, 2);
model.setCityStatInfoBos(findCitysAvgPricePlus(city,citySellStats.get(0).getDate(), 10));
model.setDefaultCityName(city);
TrendView trendView = TrendViewFactory.getInstance().create(model);
@@ -712,7 +712,7 @@ public class TrendController {
} else if (city != null) {
//regionStatList = regionStatService.findRegionStat(city, null, null, currentDate, weeks);
int month = weeks / 4;
citySellStatList = citySellStatService.getAllWithMonths(city, month);
citySellStatList = citySellStatService.getAllWithCurrMonths(city, month);
oprions.put("name", city);
}
@@ -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 取的名次数
@@ -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;