You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
161 lines
7.4 KiB
161 lines
7.4 KiB
package customChartesing
|
|
|
|
import (
|
|
"appPlatform/overall/publicmethod"
|
|
"fmt"
|
|
"strconv"
|
|
)
|
|
|
|
func (c *ChartInfo) JieXiSearchTime() (xAlist []string) {
|
|
if searchMap, isOk := c.Search.(map[string]interface{}); isOk {
|
|
if factor, isOk := searchMap["factor"]; isOk {
|
|
|
|
if factorMap, isOk := factor.([]interface{}); isOk {
|
|
for _, v := range factorMap {
|
|
if val, isOk := v.(map[string]interface{}); isOk {
|
|
if _, isOk := val["field"]; isOk {
|
|
if isTime, isOk := val["isTime"]; isOk {
|
|
if isTrue, isOk := isTime.(bool); isOk {
|
|
if isTrue {
|
|
var startTime int64 = 0
|
|
var endTime int64 = 0
|
|
if valData, isOk := val["value"]; isOk {
|
|
if valMap, isok := valData.([]interface{}); isok {
|
|
if len(valMap) > 0 {
|
|
startTime, _ = publicmethod.StringToInt64(valMap[0])
|
|
endTime, _ = publicmethod.StringToInt64(valMap[len(valMap)-1])
|
|
|
|
if publicmethod.GetIntLength(startTime) >= 13 {
|
|
startTime = startTime / 1000
|
|
}
|
|
if publicmethod.GetIntLength(endTime) >= 13 {
|
|
endTime = endTime / 1000
|
|
}
|
|
|
|
if timeType, isOk := val["timeType"]; isOk {
|
|
timeTypeStr := publicmethod.TypeToInterface(timeType)
|
|
switch timeTypeStr {
|
|
case "year":
|
|
starYear := publicmethod.UnixTimeToDay(startTime, 16)
|
|
endYear := publicmethod.UnixTimeToDay(endTime, 16)
|
|
starYearInt, _ := strconv.ParseInt(starYear, 10, 64)
|
|
endYearInt, _ := strconv.ParseInt(endYear, 10, 64)
|
|
buJinzhi := endYearInt - starYearInt
|
|
fmt.Printf("年度计算:%v-------->%v-------->%v\n\n", endYearInt, starYearInt, buJinzhi)
|
|
if buJinzhi == 0 {
|
|
xAlist = append(xAlist, fmt.Sprintf("%v", buJinzhi))
|
|
} else {
|
|
var i int64
|
|
for i = 0; i <= buJinzhi; i++ {
|
|
xAlist = append(xAlist, fmt.Sprintf("%v", starYearInt+i))
|
|
}
|
|
}
|
|
case "month":
|
|
starYear := publicmethod.UnixTimeToDay(startTime, 16)
|
|
beginMonth := publicmethod.UnixTimeToDay(startTime, 17)
|
|
endYear := publicmethod.UnixTimeToDay(endTime, 16)
|
|
endMonth := publicmethod.UnixTimeToDay(endTime, 17)
|
|
// fmt.Printf("年度计算:%v-------->%v-------->%v-------->%v\n\n", starYear, beginMonth, endYear, endMonth)
|
|
if starYear == endYear && beginMonth == endMonth {
|
|
xAlist = append(xAlist, fmt.Sprintf("%v-%v", starYear, beginMonth))
|
|
} else if starYear == endYear && beginMonth != endMonth {
|
|
beginMonthInt, _ := strconv.ParseInt(beginMonth, 10, 64)
|
|
endMonthInt, _ := strconv.ParseInt(endMonth, 10, 64)
|
|
for i := beginMonthInt; i <= endMonthInt; i++ {
|
|
xAlist = append(xAlist, fmt.Sprintf("%v-%v", starYear, i))
|
|
}
|
|
// fmt.Printf("年度计算:%v-----1--->%v-------->%v-------->%v\n\n", starYear, beginMonthInt, endYear, xAlist)
|
|
} else {
|
|
|
|
beginMonthInt, _ := strconv.ParseInt(beginMonth, 10, 64)
|
|
endMonthInt, _ := strconv.ParseInt(endMonth, 10, 64)
|
|
// fmt.Printf("年度计算:%v-----2--->%v-------->%v-------->%v\n\n", starYear, beginMonthInt, endYear, endMonthInt)
|
|
for i := beginMonthInt; i <= 12; i++ {
|
|
xAlist = append(xAlist, fmt.Sprintf("%v-%v", starYear, beginMonthInt+i))
|
|
}
|
|
var j int64
|
|
for j = 0; j < endMonthInt; j++ {
|
|
xAlist = append(xAlist, fmt.Sprintf("%v-%v", endYear, j))
|
|
}
|
|
}
|
|
// fmt.Printf("年度计算:%v-----3--->%v-------->%v-------->%v\n\n", starYear, xAlist, endYear, xAlist)
|
|
case "day":
|
|
starday := publicmethod.UnixTimeToDay(startTime, 14)
|
|
endday := publicmethod.UnixTimeToDay(endTime, 14)
|
|
beginDayInt := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", starday))
|
|
endDayInt := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", endday))
|
|
|
|
for beginDayInt <= endDayInt {
|
|
xAlist = append(xAlist, publicmethod.UnixTimeToDay(beginDayInt, 14))
|
|
beginDayInt = beginDayInt + 86400
|
|
}
|
|
case "hour":
|
|
starday := publicmethod.UnixTimeToDay(startTime, 13)
|
|
endday := publicmethod.UnixTimeToDay(endTime, 13)
|
|
beginDayInt := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", starday))
|
|
endDayInt := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", endday))
|
|
for beginDayInt <= endDayInt {
|
|
xAlist = append(xAlist, publicmethod.UnixTimeToDay(beginDayInt, 13))
|
|
beginDayInt = beginDayInt + 60
|
|
}
|
|
case "minute":
|
|
starday := publicmethod.UnixTimeToDay(startTime, 12)
|
|
endday := publicmethod.UnixTimeToDay(endTime, 12)
|
|
beginDayInt := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", starday))
|
|
endDayInt := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", endday))
|
|
for beginDayInt <= endDayInt {
|
|
xAlist = append(xAlist, publicmethod.UnixTimeToDay(beginDayInt, 12))
|
|
beginDayInt = beginDayInt + 60
|
|
}
|
|
case "second":
|
|
// starday := publicmethod.UnixTimeToDay(startTime, 11)
|
|
// endday := publicmethod.UnixTimeToDay(endTime, 11)
|
|
// beginDayInt := publicmethod.DateToTimeStampOld(starday)
|
|
// endDayInt := publicmethod.DateToTimeStampOld(endday)
|
|
for startTime <= endTime {
|
|
xAlist = append(xAlist, publicmethod.UnixTimeToDay(startTime, 11))
|
|
startTime = startTime + 1
|
|
}
|
|
default:
|
|
starYear := publicmethod.UnixTimeToDay(startTime, 16)
|
|
beginMonth := publicmethod.UnixTimeToDay(startTime, 17)
|
|
endYear := publicmethod.UnixTimeToDay(endTime, 16)
|
|
endMonth := publicmethod.UnixTimeToDay(endTime, 17)
|
|
if starYear == endYear && beginMonth == endMonth {
|
|
xAlist = append(xAlist, fmt.Sprintf("%v-%v", starYear, beginMonth))
|
|
} else if starYear == endYear && beginMonth != endMonth {
|
|
beginMonthInt, _ := strconv.ParseInt(beginMonth, 10, 64)
|
|
endMonthInt, _ := strconv.ParseInt(endMonth, 10, 64)
|
|
for i := beginMonthInt; i <= endMonthInt; i++ {
|
|
xAlist = append(xAlist, fmt.Sprintf("%v-%v", starYear, beginMonthInt+i))
|
|
}
|
|
} else {
|
|
|
|
beginMonthInt, _ := strconv.ParseInt(beginMonth, 10, 64)
|
|
endMonthInt, _ := strconv.ParseInt(endMonth, 10, 64)
|
|
|
|
for i := beginMonthInt; i <= 12; i++ {
|
|
xAlist = append(xAlist, fmt.Sprintf("%v-%v", starYear, beginMonthInt+i))
|
|
}
|
|
var j int64
|
|
for j = 0; j <= endMonthInt; j++ {
|
|
xAlist = append(xAlist, fmt.Sprintf("%v-%v", endYear, j))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
return
|
|
}
|
|
|