|
@@ -190,14 +190,69 @@ type EdbInfoSearchData struct {
|
|
|
DataTimestamp int64 `description:"时间戳"`
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-func GetEdbDataListAll(condition string, pars []interface{}, source, subSource, order int) (item []*EdbInfoSearchData, err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
+type FindEdbDataListAllCond struct {
|
|
|
+ EdbInfoId int
|
|
|
+ StartDataTime string
|
|
|
+ StartDataTimeCond string
|
|
|
+ EndDataTime string
|
|
|
+ EndDataTimeCond string
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func GetEdbDataListAll(source, subSource int, findEdbDataListAllCond FindEdbDataListAllCond, order int) (item []*EdbInfoSearchData, err error) {
|
|
|
+ if source == utils.DATA_SOURCE_BUSINESS {
|
|
|
+ return GetEdbDataListAllByMongo(source, subSource, findEdbDataListAllCond, order)
|
|
|
+ }
|
|
|
+
|
|
|
+ return GetEdbDataListAllByMysql(source, subSource, findEdbDataListAllCond, order)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func GetEdbDataListAllByMysql(source, subSource int, findEdbDataListAllCond FindEdbDataListAllCond, order int) (item []*EdbInfoSearchData, err error) {
|
|
|
+ if findEdbDataListAllCond.EdbInfoId <= 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ to := orm.NewOrm()
|
|
|
+
|
|
|
sql := ``
|
|
|
tableName := GetEdbDataTableName(source, subSource)
|
|
|
sql = ` SELECT * FROM %s WHERE 1=1 `
|
|
|
sql = fmt.Sprintf(sql, tableName)
|
|
|
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition += " AND edb_info_id=? "
|
|
|
+ pars = append(pars, findEdbDataListAllCond.EdbInfoId)
|
|
|
+
|
|
|
+
|
|
|
+ if findEdbDataListAllCond.StartDataTime != "" && findEdbDataListAllCond.StartDataTimeCond != `` {
|
|
|
+ condition += fmt.Sprintf(" AND data_time %s ? ", findEdbDataListAllCond.StartDataTimeCond)
|
|
|
+ pars = append(pars, findEdbDataListAllCond.StartDataTime)
|
|
|
+ }
|
|
|
+
|
|
|
+ if findEdbDataListAllCond.EndDataTime != "" && findEdbDataListAllCond.EndDataTimeCond != `` {
|
|
|
+ condition += fmt.Sprintf(" AND data_time %s ? ", findEdbDataListAllCond.EndDataTimeCond)
|
|
|
+ pars = append(pars, findEdbDataListAllCond.EndDataTime)
|
|
|
+ }
|
|
|
+
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
|
}
|
|
@@ -206,11 +261,21 @@ func GetEdbDataListAll(condition string, pars []interface{}, source, subSource,
|
|
|
} else {
|
|
|
sql += ` ORDER BY data_time DESC `
|
|
|
}
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&item)
|
|
|
+ _, err = to.Raw(sql, pars).QueryRows(&item)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
func GetEdbDataListAllByTo(to orm.TxOrmer, source, subSource int, findEdbDataListAllCond FindEdbDataListAllCond, order int) (item []*EdbInfoSearchData, err error) {
|
|
|
if source == utils.DATA_SOURCE_BUSINESS {
|
|
|
return GetEdbDataListAllByMongo(source, subSource, findEdbDataListAllCond, order)
|
|
@@ -219,15 +284,17 @@ func GetEdbDataListAllByTo(to orm.TxOrmer, source, subSource int, findEdbDataLis
|
|
|
return GetEdbDataListAllByMysqlTo(to, source, subSource, findEdbDataListAllCond, order)
|
|
|
}
|
|
|
|
|
|
-type FindEdbDataListAllCond struct {
|
|
|
- EdbInfoId int
|
|
|
- StartDataTime string
|
|
|
- StartDataTimeCond string
|
|
|
- EndDataTime string
|
|
|
- EndDataTimeCond string
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
func GetEdbDataListAllByMysqlTo(to orm.TxOrmer, source, subSource int, findEdbDataListAllCond FindEdbDataListAllCond, order int) (item []*EdbInfoSearchData, err error) {
|
|
|
if findEdbDataListAllCond.EdbInfoId <= 0 {
|
|
|
return
|
|
@@ -265,7 +332,16 @@ func GetEdbDataListAllByMysqlTo(to orm.TxOrmer, source, subSource int, findEdbDa
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
func GetEdbDataListAllByMongo(source, subSource int, findEdbDataListAllCond FindEdbDataListAllCond, order int) (dataList []*EdbInfoSearchData, err error) {
|
|
|
dataList = make([]*EdbInfoSearchData, 0)
|
|
|
if findEdbDataListAllCond.EdbInfoId <= 0 {
|
|
@@ -319,10 +395,12 @@ func GetEdbDataListAllByMongo(source, subSource int, findEdbDataListAllCond Find
|
|
|
}
|
|
|
for k, v := range tmpDataList {
|
|
|
dataList = append(dataList, &EdbInfoSearchData{
|
|
|
- EdbDataId: k + 1,
|
|
|
- EdbCode: v.EdbCode,
|
|
|
- DataTime: v.DataTime.Format(utils.FormatDate),
|
|
|
- Value: v.Value,
|
|
|
+ EdbDataId: k + 1,
|
|
|
+ EdbInfoId: v.EdbInfoId,
|
|
|
+ EdbCode: v.EdbCode,
|
|
|
+ DataTime: v.DataTime.Format(utils.FormatDate),
|
|
|
+ Value: v.Value,
|
|
|
+ DataTimestamp: v.DataTimestamp,
|
|
|
})
|
|
|
}
|
|
|
return
|
|
@@ -1007,29 +1085,29 @@ func GetPredictDataListByPredictEdbInfo(edbInfo *EdbInfo, order int, startDate s
|
|
|
|
|
|
|
|
|
func GetPredictDataListByPredictEdbConfList(edbInfo, sourceEdbInfoItem *EdbInfo, predictEdbConfList []*PredictEdbConfAndData, order int, startDate string) (dataList []*EdbInfoSearchData, err error, errMsg string) {
|
|
|
-
|
|
|
allDataList := make([]*EdbInfoSearchData, 0)
|
|
|
|
|
|
- var condition string
|
|
|
- var pars []interface{}
|
|
|
- condition += " AND edb_info_id=? "
|
|
|
- pars = append(pars, sourceEdbInfoItem.EdbInfoId)
|
|
|
- if startDate != "" {
|
|
|
- condition += " AND data_time>=? "
|
|
|
- pars = append(pars, startDate)
|
|
|
- }
|
|
|
- tmpDataList, err := GetEdbDataListAll(condition, pars, sourceEdbInfoItem.Source, sourceEdbInfoItem.SubSource, 1)
|
|
|
+ tmpDataList, err := GetEdbDataListAll(sourceEdbInfoItem.Source, sourceEdbInfoItem.SubSource, FindEdbDataListAllCond{
|
|
|
+ EdbInfoId: sourceEdbInfoItem.EdbInfoId,
|
|
|
+ StartDataTime: startDate,
|
|
|
+ StartDataTimeCond: ">=",
|
|
|
+ }, 1)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ allDataList = tmpDataList
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
if startDate != `` {
|
|
|
- allDataList, err = GetEdbDataListAll(" AND edb_info_id=? ", []interface{}{sourceEdbInfoItem.EdbInfoId}, sourceEdbInfoItem.Source, sourceEdbInfoItem.SubSource, 1)
|
|
|
+ allDataList, err = GetEdbDataListAll(sourceEdbInfoItem.Source, sourceEdbInfoItem.SubSource, FindEdbDataListAllCond{
|
|
|
+ EdbInfoId: sourceEdbInfoItem.EdbInfoId,
|
|
|
+ }, 1)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
- } else {
|
|
|
- allDataList = tmpDataList
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1083,11 +1161,9 @@ func GetPredictEdbDataListAll(edbInfo *EdbInfo, order int) (items []*EdbInfoSear
|
|
|
if edbInfo.Source == utils.DATA_SOURCE_PREDICT {
|
|
|
items, _, err, _ = GetPredictDataListByPredictEdbInfo(edbInfo, 1, "")
|
|
|
} else {
|
|
|
- var condition string
|
|
|
- var pars []interface{}
|
|
|
- condition += " AND edb_info_id=? "
|
|
|
- pars = append(pars, edbInfo.EdbInfoId)
|
|
|
- items, err = GetEdbDataListAll(condition, pars, edbInfo.Source, edbInfo.SubSource, order)
|
|
|
+ items, err = GetEdbDataListAll(edbInfo.Source, edbInfo.SubSource, FindEdbDataListAllCond{
|
|
|
+ EdbInfoId: edbInfo.EdbInfoId,
|
|
|
+ }, order)
|
|
|
}
|
|
|
return
|
|
|
}
|
|
@@ -1097,15 +1173,11 @@ func GetPredictEdbDataListAllByStartDate(edbInfo *EdbInfo, order int, startDate
|
|
|
if edbInfo.Source == utils.DATA_SOURCE_PREDICT {
|
|
|
items, _, err, _ = GetPredictDataListByPredictEdbInfo(edbInfo, order, startDate)
|
|
|
} else {
|
|
|
- var condition string
|
|
|
- var pars []interface{}
|
|
|
- condition += " AND edb_info_id=? "
|
|
|
- pars = append(pars, edbInfo.EdbInfoId)
|
|
|
- if startDate != "" {
|
|
|
- condition += " AND data_time>=? "
|
|
|
- pars = append(pars, startDate)
|
|
|
- }
|
|
|
- items, err = GetEdbDataListAll(condition, pars, edbInfo.Source, edbInfo.SubSource, order)
|
|
|
+ items, err = GetEdbDataListAll(edbInfo.Source, edbInfo.SubSource, FindEdbDataListAllCond{
|
|
|
+ EdbInfoId: edbInfo.EdbInfoId,
|
|
|
+ StartDataTime: startDate,
|
|
|
+ StartDataTimeCond: ">=",
|
|
|
+ }, order)
|
|
|
}
|
|
|
return
|
|
|
}
|