|
@@ -204,6 +204,7 @@ func (edbInfo *EdbInfo) Update(cols []string) (err error) {
|
|
|
}
|
|
|
|
|
|
// EdbInfoSearchData
|
|
|
+// @Description: 指标数据
|
|
|
type EdbInfoSearchData struct {
|
|
|
EdbDataId int `description:"数据ID"`
|
|
|
EdbInfoId int `description:"指标ID"`
|
|
@@ -213,6 +214,15 @@ type EdbInfoSearchData struct {
|
|
|
DataTimestamp int64 `description:"时间戳"`
|
|
|
}
|
|
|
|
|
|
+// ConvertTimeStr
|
|
|
+// @Description: 转成需要输出的格式
|
|
|
+// @receiver m
|
|
|
+func (m *EdbInfoSearchData) ConvertTimeStr() {
|
|
|
+ m.DataTime = utils.GormDateStrToDateStr(m.DataTime)
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
type FindEdbDataListAllCond struct {
|
|
|
EdbInfoId int
|
|
|
StartDataTime string
|
|
@@ -247,9 +257,9 @@ func GetEdbDataListAll(source, subSource int, findEdbDataListAllCond FindEdbData
|
|
|
// @param subSource int
|
|
|
// @param findEdbDataListAllCond FindEdbDataListAllCond
|
|
|
// @param order int
|
|
|
-// @return item []*EdbInfoSearchData
|
|
|
+// @return items []*EdbInfoSearchData
|
|
|
// @return err error
|
|
|
-func GetEdbDataListAllByMysql(source, subSource int, findEdbDataListAllCond FindEdbDataListAllCond, order int) (item []*EdbInfoSearchData, err error) {
|
|
|
+func GetEdbDataListAllByMysql(source, subSource int, findEdbDataListAllCond FindEdbDataListAllCond, order int) (items []*EdbInfoSearchData, err error) {
|
|
|
if findEdbDataListAllCond.EdbInfoId <= 0 {
|
|
|
return
|
|
|
}
|
|
@@ -284,7 +294,15 @@ func GetEdbDataListAllByMysql(source, subSource int, findEdbDataListAllCond Find
|
|
|
sql += ` ORDER BY data_time DESC `
|
|
|
}
|
|
|
// todo
|
|
|
- err = global.DEFAULT_DmSQL.Raw(sql, pars...).Scan(&item).Error
|
|
|
+ err = global.DEFAULT_DmSQL.Raw(sql, pars...).Scan(&items).Error
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 统一处理日期
|
|
|
+ for _, v := range items {
|
|
|
+ v.ConvertTimeStr()
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -316,9 +334,9 @@ func GetEdbDataListAllByTo(to *gorm.DB, source, subSource int, findEdbDataListAl
|
|
|
// @param subSource int
|
|
|
// @param findEdbDataListAllCond FindEdbDataListAllCond
|
|
|
// @param order int
|
|
|
-// @return item []*EdbInfoSearchData
|
|
|
+// @return items []*EdbInfoSearchData
|
|
|
// @return err error
|
|
|
-func GetEdbDataListAllByMysqlTo(to *gorm.DB, source, subSource int, findEdbDataListAllCond FindEdbDataListAllCond, order int) (item []*EdbInfoSearchData, err error) {
|
|
|
+func GetEdbDataListAllByMysqlTo(to *gorm.DB, source, subSource int, findEdbDataListAllCond FindEdbDataListAllCond, order int) (items []*EdbInfoSearchData, err error) {
|
|
|
if findEdbDataListAllCond.EdbInfoId <= 0 {
|
|
|
return
|
|
|
}
|
|
@@ -351,7 +369,15 @@ func GetEdbDataListAllByMysqlTo(to *gorm.DB, source, subSource int, findEdbDataL
|
|
|
} else {
|
|
|
sql += ` ORDER BY data_time DESC `
|
|
|
}
|
|
|
- err = to.Raw(sql, pars...).Scan(&item).Error
|
|
|
+ err = to.Raw(sql, pars...).Scan(&items).Error
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 统一处理日期
|
|
|
+ for _, v := range items {
|
|
|
+ v.ConvertTimeStr()
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -588,7 +614,6 @@ func GetLteZeroEdbDataCountByMongo(source, subSource, edbInfoId int) (count int,
|
|
|
// @return count int
|
|
|
// @return err error
|
|
|
func GetLteZeroEdbDataCountByMysql(source, subSource, edbInfoId int) (count int, err error) {
|
|
|
-
|
|
|
sql := ``
|
|
|
tableName := GetEdbDataTableName(source, subSource)
|
|
|
sql = ` SELECT COUNT(1) AS count FROM %s WHERE 1=1 AND edb_info_id =? AND value <=0 `
|