优化
This commit is contained in:
+1
-1
@@ -707,7 +707,7 @@ public class TrendController {
|
||||
} else if (city != null && region != null) {
|
||||
//regionStatList = regionStatService.findRegionStat(city, region, null, currentDate, weeks);
|
||||
int month = weeks / 4;
|
||||
regionSellStatList = regionSellStatService.getAllWithMonths(city, region, month);
|
||||
regionSellStatList = regionSellStatService.getAllWithCurrMonths(city, region, month);
|
||||
oprions.put("name", region);
|
||||
} else if (city != null) {
|
||||
//regionStatList = regionStatService.findRegionStat(city, null, null, currentDate, weeks);
|
||||
|
||||
+9
@@ -18,6 +18,15 @@ public interface RegionSellStatService {
|
||||
*/
|
||||
List<RegionSellStat> getAllWithMonths(String city, String region, int monthCount);
|
||||
|
||||
/**
|
||||
* 获取过去 monCount 个月的数据(包含本月数据)
|
||||
* @param city
|
||||
* @param region
|
||||
* @param monthCount
|
||||
* @return
|
||||
*/
|
||||
List<RegionSellStat> getAllWithCurrMonths(String city, String region, int monthCount);
|
||||
|
||||
List<RegionSellStat> findNearCityStat(String city, final String region, Integer startDate, int count);
|
||||
|
||||
/**
|
||||
|
||||
+21
@@ -85,6 +85,27 @@ public class RegionSellStatServiceImpl implements RegionSellStatService {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RegionSellStat> getAllWithCurrMonths(final String city, final String region, final int monthCount) {
|
||||
Date now = new Date();
|
||||
Date lastMonth = DateUtil.getBeforeDate(now, 0);
|
||||
Date monthInLastYear = DateUtil.getBeforeDate(now, -1 * monthCount);
|
||||
int lastMonthNum = DateUtil.getYear(lastMonth) * 100 + DateUtil.getMonth(lastMonth);
|
||||
int monthInLastYearNum = DateUtil.getYear(monthInLastYear) * 100 + DateUtil.getMonth(monthInLastYear);
|
||||
|
||||
List<QueryParam> queryParams = ImmutableList.of(
|
||||
new QueryParam("city", city),
|
||||
new QueryParam("region", region),
|
||||
new QueryParam("date", QueryParam.LESS_THAN_EQUAL_OPERATOR, lastMonthNum),
|
||||
new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, monthInLastYearNum)
|
||||
);
|
||||
List<SortParam> sortParams = ImmutableList.of(
|
||||
new SortParam("date", false)
|
||||
);
|
||||
return regionSellStatDao.findAllByParams(queryParams, sortParams);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RegionSellStat> findNearCityStat(final String city, final String region, final Integer startDate, final int count) {
|
||||
|
||||
Reference in New Issue
Block a user