|
@@ -7,11 +7,17 @@ import (
|
|
|
)
|
|
|
|
|
|
func GetDictIndex(condition string, pars []interface{}) (dictIndexList []DictIndex, err error) {
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ global.LOG.Info("获取桥接服务指标信息失败 Err:" + err.Error())
|
|
|
+ }
|
|
|
+ }()
|
|
|
selectVals := "ID, CODE, NAME, UNIT, FREQUENCY, DESCRIPTION, TABLE_NAME, SOURCE_TYPE, SOURCE_CODE, SOURCE_DESCRIPTION, INDUSTRY, TYPE, COMMODITY, SJB_ID, USER_ID, ROWS_COUNT, DATE_FIRST, DATE_LAST, TIME_LAST_UPDATE, TIME_LAST_REQUEST, PRIORITY, STATUS, SHORT_NAME, UPDATE_DESCRIPTION, FORECAST_FLAG, MANUAL_FLAG, VARIABLE_FLAG, MARKETDATA_FLAG, CREATE_USER, CREATE_TIME, UPDATE_USER, UPDATE_TIME"
|
|
|
sqlStatement := fmt.Sprintf("SELECT %s FROM DICT_INDEX WHERE %s", selectVals, condition)
|
|
|
dictIndexList, err = getDictIndex(sqlStatement, pars)
|
|
|
if err != nil {
|
|
|
fmt.Printf("查询指标信息失败 %s", err)
|
|
|
+ err = fmt.Errorf("查询指标信息失败 %s", err)
|
|
|
return
|
|
|
}
|
|
|
fmt.Printf("查询指标信息成功")
|
|
@@ -19,11 +25,17 @@ func GetDictIndex(condition string, pars []interface{}) (dictIndexList []DictInd
|
|
|
}
|
|
|
|
|
|
func GetDictData(tableName string, condition string, pars []interface{}) (dictIndexData []DictData, err error) {
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ global.LOG.Info("获取桥接服务指标数据失败 Err:" + err.Error())
|
|
|
+ }
|
|
|
+ }()
|
|
|
sqlStatement := fmt.Sprintf("SELECT ID, INDEX_ID, INDEX_VALUE, INDEX_DATE, UPDATE_TIME FROM %s WHERE %s", tableName, condition)
|
|
|
|
|
|
dictIndexData, err = getDictData(sqlStatement, pars)
|
|
|
if err != nil {
|
|
|
- fmt.Printf("查询指标信息失败 %s", err)
|
|
|
+ fmt.Printf("查询指标数据失败 %s", err)
|
|
|
+ err = fmt.Errorf("查询指标数据失败 %s", err)
|
|
|
return
|
|
|
}
|
|
|
fmt.Printf("查询指标信息成功")
|
|
@@ -143,6 +155,7 @@ func getDictIndex(sqlStatement string, pars []interface{}) (dictIndexs []DictInd
|
|
|
err = rows.Scan(&tmp.Id, &tmp.Code, &tmp.Name, &tmp.Unit, &tmp.Frequency, &tmp.Description, &tmp.TableName, &tmp.SourceType, &tmp.SourceCode, &tmp.SourceDescription, &tmp.Industry, &tmp.Type, &tmp.Commodity, &tmp.SjbId, &tmp.UserId, &tmp.RowsCount, &tmp.DateFirst, &tmp.DateLast, &tmp.TimeLastUpdate, &tmp.TimeLastRequest, &tmp.Priority, &tmp.Status, &tmp.ShortName, &tmp.UpdateDescription, &tmp.ForecastFlag, &tmp.ManualFlag, &tmp.VariableFlag, &tmp.MarketDataFlag, &tmp.CreateUser, &tmp.CreateTime, &tmp.UpdateUser, &tmp.UpdateTime)
|
|
|
if err != nil {
|
|
|
fmt.Printf("扫描错误:", err)
|
|
|
+ err = fmt.Errorf("扫描错误:" + err.Error())
|
|
|
return
|
|
|
}
|
|
|
dictTmp := DictIndex{
|
|
@@ -183,7 +196,8 @@ func getDictIndex(sqlStatement string, pars []interface{}) (dictIndexs []DictInd
|
|
|
}
|
|
|
if err = rows.Err(); err != nil {
|
|
|
// handle the error here
|
|
|
- _ = fmt.Errorf(err.Error())
|
|
|
+ err = fmt.Errorf("解析行数据失败" + err.Error())
|
|
|
+ return
|
|
|
}
|
|
|
defer stmt.Close()
|
|
|
|
|
@@ -223,6 +237,7 @@ func getDictData(sqlStatement string, pars []interface{}) (dictData []DictData,
|
|
|
err = rows.Scan(&tmp.Id, &tmp.IndexId, &tmp.IndexValue, &tmp.IndexDate, &tmp.UpdateTime)
|
|
|
if err != nil {
|
|
|
fmt.Printf("扫描错误:", err)
|
|
|
+ err = fmt.Errorf("扫描错误" + err.Error())
|
|
|
return
|
|
|
}
|
|
|
dictTmp := DictData{
|
|
@@ -236,7 +251,8 @@ func getDictData(sqlStatement string, pars []interface{}) (dictData []DictData,
|
|
|
}
|
|
|
if err = rows.Err(); err != nil {
|
|
|
// handle the error here
|
|
|
- _ = fmt.Errorf(err.Error())
|
|
|
+ err = fmt.Errorf("解析行数据失败" + err.Error())
|
|
|
+ return
|
|
|
}
|
|
|
defer stmt.Close()
|
|
|
|