修复周日均价查询bug
This commit is contained in:
+27
-8
@@ -1604,9 +1604,13 @@ public class DistrictStatServiceImpl implements DistrictStatService {
|
||||
|
||||
if (startDate == null) {
|
||||
throw new IllegalArgumentException("开始日期不能为空");
|
||||
}else {
|
||||
startDate = DateUtil.truncateDay(startDate);
|
||||
}
|
||||
if (endDate == null) {
|
||||
throw new IllegalArgumentException("结束日期不能为空");
|
||||
}else {
|
||||
endDate = DateUtil.truncateDay(endDate);
|
||||
}
|
||||
if (StringUtils.isBlank(periodModel)) {
|
||||
periodModel = "weekly";
|
||||
@@ -1642,7 +1646,6 @@ public class DistrictStatServiceImpl implements DistrictStatService {
|
||||
sortParams.add(new SortParam("weekend", true));
|
||||
List<DistrictStat> dss = this.districtStatDao.findAllByParams(params, sortParams);
|
||||
if (null == dss || dss.isEmpty()) {// 如果没有在小区均价表中查到均价数据,通过城市的价格计算小区均价
|
||||
|
||||
List<QueryParam> cityQueryParams = new ArrayList<QueryParam>();
|
||||
cityQueryParams.add(new QueryParam("city", city));
|
||||
cityQueryParams.add(new QueryParam("region", region));
|
||||
@@ -1708,15 +1711,35 @@ public class DistrictStatServiceImpl implements DistrictStatService {
|
||||
}
|
||||
|
||||
List<Date> timeSeries = generateTimeSeries(weekendDates.get(0), endDate, periodModel);
|
||||
|
||||
Map<Date, DistrictStat> statMap = new HashMap<Date, DistrictStat>();
|
||||
|
||||
for (DistrictStat districtStat : dss) {
|
||||
if (timeSeries.contains(districtStat.getWeekend())) {
|
||||
statMap.put(districtStat.getWeekend(), districtStat);
|
||||
}
|
||||
}
|
||||
|
||||
if("monthly".equals(periodModel)){
|
||||
Date firstWeekendOfMonth = DateUtil.getFirstWeekendOfMonth(endDate);
|
||||
List<DistrictStat> stats = districtStatService.findDistrictStat(new DistrictKey(city, region, name), null , firstWeekendOfMonth, endDate);
|
||||
if(stats.isEmpty()){
|
||||
Date sunDay = DateUtil.getFirstDayOfWeek(endDate);
|
||||
if(!timeSeries.contains(sunDay)){
|
||||
timeSeries.add(sunDay);
|
||||
}
|
||||
}else{
|
||||
if(DateUtil.isSunday(endDate)){
|
||||
timeSeries.remove(endDate);
|
||||
}else{
|
||||
timeSeries.remove(DateUtil.getLastSunday(endDate));
|
||||
}
|
||||
for(int i = stats.size()-1; i >= 0; i--){
|
||||
if (!timeSeries.contains(stats.get(i).getWeekend())){
|
||||
statMap.put(stats.get(i).getWeekend(), stats.get(i));
|
||||
timeSeries.add(stats.get(i).getWeekend());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Date time : timeSeries) {
|
||||
if (!statMap.containsKey(time)) {
|
||||
DistrictStat districtStat = new DistrictStat();
|
||||
@@ -1772,10 +1795,6 @@ public class DistrictStatServiceImpl implements DistrictStatService {
|
||||
monthlyDates.add(date);
|
||||
}
|
||||
}
|
||||
Date sunDay = DateUtil.getFirstDayOfWeek(endDate);
|
||||
if (!monthlyDates.contains(sunDay)) {
|
||||
monthlyDates.add(sunDay);
|
||||
}
|
||||
return monthlyDates;
|
||||
} else {
|
||||
throw new IllegalArgumentException("非法的计算周期");
|
||||
|
||||
Reference in New Issue
Block a user