|
@@ -9,6 +9,7 @@ import com.cdf.util.DateUtil;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@@ -30,7 +31,8 @@ public class TotalDataServiceImpl extends ServiceImpl<ITotalDataMapper, TotalDat
|
|
if(StringUtils.isEmpty(time)){
|
|
if(StringUtils.isEmpty(time)){
|
|
time = DateUtil.getDay(new Date(),-1);
|
|
time = DateUtil.getDay(new Date(),-1);
|
|
}
|
|
}
|
|
- return this.getById(time);
|
|
|
|
|
|
+ TotalData byId = this.getById(time);
|
|
|
|
+ return byId == null ? newTotalData(time) : byId;
|
|
case 1: //周
|
|
case 1: //周
|
|
String weekStart =null;
|
|
String weekStart =null;
|
|
if(StringUtils.isEmpty(time)){
|
|
if(StringUtils.isEmpty(time)){
|
|
@@ -41,6 +43,9 @@ public class TotalDataServiceImpl extends ServiceImpl<ITotalDataMapper, TotalDat
|
|
}
|
|
}
|
|
String weekEnd = DateUtil.getWeekEnd(weekStart);
|
|
String weekEnd = DateUtil.getWeekEnd(weekStart);
|
|
TotalData week = this.getBaseMapper().getWeek(weekStart, weekEnd);
|
|
TotalData week = this.getBaseMapper().getWeek(weekStart, weekEnd);
|
|
|
|
+ if(week == null){
|
|
|
|
+ week = newTotalData(weekStart);
|
|
|
|
+ }
|
|
week.setId(weekStart);
|
|
week.setId(weekStart);
|
|
return week;
|
|
return week;
|
|
case 2: //月
|
|
case 2: //月
|
|
@@ -49,10 +54,25 @@ public class TotalDataServiceImpl extends ServiceImpl<ITotalDataMapper, TotalDat
|
|
}
|
|
}
|
|
time = DateUtil.getMonth(time);
|
|
time = DateUtil.getMonth(time);
|
|
TotalData month = this.getBaseMapper().getMonth(time);
|
|
TotalData month = this.getBaseMapper().getMonth(time);
|
|
|
|
+ if(month == null){
|
|
|
|
+ month = newTotalData(time);
|
|
|
|
+ }
|
|
month.setId(time);
|
|
month.setId(time);
|
|
return month;
|
|
return month;
|
|
default:
|
|
default:
|
|
throw new IllegalStateException("Unexpected value: " + type);
|
|
throw new IllegalStateException("Unexpected value: " + type);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private TotalData newTotalData(String id ){
|
|
|
|
+ TotalData totalData = new TotalData();
|
|
|
|
+ totalData.setId(id);
|
|
|
|
+ totalData.setAvgStopTime(0L);
|
|
|
|
+ totalData.setAvgStepNum(0L);
|
|
|
|
+ totalData.setVideoNum(0L);
|
|
|
|
+ totalData.setAvgJump(BigDecimal.ZERO);
|
|
|
|
+ totalData.setAvgClickGame(BigDecimal.ZERO);
|
|
|
|
+ totalData.setAvgClickShop(BigDecimal.ZERO);
|
|
|
|
+ return totalData;
|
|
|
|
+ }
|
|
}
|
|
}
|