|
@@ -706,21 +706,33 @@ func histogramStatisticsByMonth(start time.Time) ([]queryItem, []string) { |
|
@@ -706,21 +706,33 @@ func histogramStatisticsByMonth(start time.Time) ([]queryItem, []string) { |
706
|
var monthEnd = time.Date(year, month+1, 1, 0, 0, 0, 0, time.Local).Add(-time.Second)
|
706
|
var monthEnd = time.Date(year, month+1, 1, 0, 0, 0, 0, time.Local).Add(-time.Second)
|
707
|
var xAxisData []string
|
707
|
var xAxisData []string
|
708
|
for {
|
708
|
for {
|
709
|
- if beginTime.AddDate(0, 0, increaseDay).After(monthEnd) {
|
709
|
+ currentIncreaseDay := increaseDay
|
|
|
710
|
+ leftDay := monthEnd.Day() - endTime.Day()
|
|
|
711
|
+ if leftDay == 0 {
|
|
|
712
|
+ break
|
|
|
713
|
+ }
|
|
|
714
|
+ // 不足5天的情况,比如二月 28、29天
|
|
|
715
|
+ if leftDay > 0 && leftDay < increaseDay {
|
|
|
716
|
+ currentIncreaseDay = leftDay
|
|
|
717
|
+ }
|
|
|
718
|
+ if beginTime.AddDate(0, 0, currentIncreaseDay).After(monthEnd) {
|
710
|
endTime = monthEnd
|
719
|
endTime = monthEnd
|
711
|
break
|
720
|
break
|
712
|
} else {
|
721
|
} else {
|
713
|
- endTime = beginTime.AddDate(0, 0, increaseDay).Add(-time.Second)
|
722
|
+ endTime = beginTime.AddDate(0, 0, currentIncreaseDay).Add(-time.Second)
|
714
|
}
|
723
|
}
|
715
|
item := queryItem{
|
724
|
item := queryItem{
|
716
|
BeginTime: beginTime,
|
725
|
BeginTime: beginTime,
|
717
|
- EndTime: beginTime.AddDate(0, 0, increaseDay).Add(-time.Second),
|
726
|
+ EndTime: beginTime.AddDate(0, 0, currentIncreaseDay).Add(-time.Second),
|
|
|
727
|
+ }
|
|
|
728
|
+ // 30号接近月末时,如果有31号 就取月末值
|
|
|
729
|
+ left := monthEnd.Day() - item.EndTime.Day()
|
|
|
730
|
+ if left <= 1 {
|
|
|
731
|
+ item.EndTime = monthEnd
|
|
|
732
|
+ endTime = monthEnd
|
718
|
}
|
733
|
}
|
719
|
xAxisData = append(xAxisData, item.EndTime.Format("01-02"))
|
734
|
xAxisData = append(xAxisData, item.EndTime.Format("01-02"))
|
720
|
beginTime = endTime
|
735
|
beginTime = endTime
|
721
|
- if endTime == monthEnd {
|
|
|
722
|
- break
|
|
|
723
|
- }
|
|
|
724
|
ret = append(ret, item)
|
736
|
ret = append(ret, item)
|
725
|
}
|
737
|
}
|
726
|
return ret, xAxisData
|
738
|
return ret, xAxisData
|