|
@@ -2757,72 +2757,3 @@ type MaxMinLimitsData struct {
|
|
|
MaxValue float64 `description:"最大值"`
|
|
|
MinValue float64 `description:"最小值"`
|
|
|
}
|
|
|
-
|
|
|
-func getThsHfEdbDataListByMongo(source, subSource, edbInfoId int, startDate, endDate string) (list []*EdbDataList, err error) {
|
|
|
- list = make([]*EdbDataList, 0)
|
|
|
-
|
|
|
- mogDataObj := mgo.EdbDataThsHf{}
|
|
|
- // 构建查询条件
|
|
|
- queryConditions := bson.M{
|
|
|
- "edb_info_id": edbInfoId,
|
|
|
- }
|
|
|
-
|
|
|
- // 数据日期
|
|
|
- dateCondition, err := mgo.BuildDateCondition(startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- if len(dateCondition) > 0 {
|
|
|
- queryConditions["data_time"] = dateCondition
|
|
|
- }
|
|
|
-
|
|
|
- // 获取列表数据
|
|
|
- tmpDataList, tmpErr := mogDataObj.GetAllDataList(queryConditions, []string{"data_time"})
|
|
|
- if tmpErr != nil {
|
|
|
- err = tmpErr
|
|
|
- return
|
|
|
- }
|
|
|
- for k, v := range tmpDataList {
|
|
|
- list = append(list, &EdbDataList{
|
|
|
- EdbDataId: k + 1,
|
|
|
- EdbInfoId: v.EdbInfoId,
|
|
|
- DataTime: v.DataTime.Format(utils.FormatDate),
|
|
|
- DataTimestamp: v.DataTimestamp,
|
|
|
- Value: v.Value,
|
|
|
- })
|
|
|
- }
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-func getThsHfEdbDataListMinAndMaxByMongo(source, subSource, edbInfoId int, startDate, endDate string) (minData, maxData float64, err error) {
|
|
|
- mogDataObj := mgo.EdbDataThsHf{}
|
|
|
- // 构建查询条件
|
|
|
- queryConditions := bson.M{
|
|
|
- "edb_info_id": edbInfoId,
|
|
|
- }
|
|
|
- // 日期
|
|
|
- dateCondition, err := mgo.BuildDateCondition(startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- if len(dateCondition) > 0 {
|
|
|
- queryConditions["data_time"] = dateCondition
|
|
|
- }
|
|
|
-
|
|
|
- pipeline := []bson.M{
|
|
|
- {"$match": queryConditions},
|
|
|
- {"$group": bson.M{
|
|
|
- "_id": nil,
|
|
|
- "min_value": bson.M{"$min": "$value"},
|
|
|
- "max_value": bson.M{"$max": "$value"},
|
|
|
- }},
|
|
|
- {"$project": bson.M{"_id": 0}}, // 可选,如果不需要_id字段
|
|
|
- }
|
|
|
- result, err := mogDataObj.GetEdbInfoMaxAndMinInfo(pipeline)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- minData = result.MinValue
|
|
|
- maxData = result.MaxValue
|
|
|
- return
|
|
|
-}
|