|
@@ -4,6 +4,7 @@ import (
|
|
|
"errors"
|
|
|
"eta/eta_mobile/models/mgo"
|
|
|
"eta/eta_mobile/utils"
|
|
|
+ "eta/eta_mobile/utils/mgodb"
|
|
|
"fmt"
|
|
|
"github.com/beego/beego/v2/client/orm"
|
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
@@ -447,25 +448,15 @@ func getEdbDataListByMongo(source, subSource, edbInfoId int, startDate, endDate
|
|
|
queryConditions := bson.M{
|
|
|
"edb_info_id": edbInfoId,
|
|
|
}
|
|
|
-
|
|
|
- // 数据开始日期
|
|
|
- if startDate != `` {
|
|
|
- startDateTime, tmpErr := time.ParseInLocation(utils.FormatDate, startDate, time.Local)
|
|
|
- if tmpErr != nil {
|
|
|
- err = tmpErr
|
|
|
- return
|
|
|
- }
|
|
|
- queryConditions["data_time"] = bson.M{"$gte": startDateTime}
|
|
|
+ // 数据日期
|
|
|
+ dateCondition, err := mgodb.BuildDateCondition(startDate, endDate)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
}
|
|
|
- // 数据结束日期
|
|
|
- if endDate != "" {
|
|
|
- endDateTime, tmpErr := time.ParseInLocation(utils.FormatDate, endDate, time.Local)
|
|
|
- if tmpErr != nil {
|
|
|
- err = tmpErr
|
|
|
- return
|
|
|
- }
|
|
|
- queryConditions["data_time"] = bson.M{"$lte": endDateTime}
|
|
|
+ if len(dateCondition) > 0 {
|
|
|
+ queryConditions["data_time"] = dateCondition
|
|
|
}
|
|
|
+
|
|
|
// 获取列表数据
|
|
|
tmpDataList, tmpErr := mogDataObj.GetAllDataList(queryConditions, []string{"data_time"})
|
|
|
if tmpErr != nil {
|
|
@@ -581,24 +572,15 @@ func getEdbDataListMinAndMaxByMongo(source, subSource, edbInfoId int, startDate,
|
|
|
"edb_info_id": edbInfoId,
|
|
|
}
|
|
|
|
|
|
- // 数据开始日期
|
|
|
- if startDate != `` {
|
|
|
- startDateTime, tmpErr := time.ParseInLocation(utils.FormatDate, startDate, time.Local)
|
|
|
- if tmpErr != nil {
|
|
|
- err = tmpErr
|
|
|
- return
|
|
|
- }
|
|
|
- queryConditions["data_time"] = bson.M{"$gte": startDateTime}
|
|
|
+ // 数据日期
|
|
|
+ dateCondition, err := mgodb.BuildDateCondition(startDate, endDate)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
}
|
|
|
- // 数据结束日期
|
|
|
- if endDate != "" {
|
|
|
- endDateTime, tmpErr := time.ParseInLocation(utils.FormatDate, endDate, time.Local)
|
|
|
- if tmpErr != nil {
|
|
|
- err = tmpErr
|
|
|
- return
|
|
|
- }
|
|
|
- queryConditions["data_time"] = bson.M{"$lte": endDateTime}
|
|
|
+ if len(dateCondition) > 0 {
|
|
|
+ queryConditions["data_time"] = dateCondition
|
|
|
}
|
|
|
+
|
|
|
pipeline := []bson.M{
|
|
|
{"$match": queryConditions},
|
|
|
{"$group": bson.M{
|