|
@@ -143,27 +143,74 @@ func GetRzdIndexFrequency(classify int) ([]*string, error) {
|
|
|
}
|
|
|
|
|
|
// RzdIndexAddValidate 指标添加校验
|
|
|
-func RzdIndexAddValidate(indexCodes []string) (*[]data_manage.RzdIndexCheckData, error) {
|
|
|
- // 根据指标编码获取指标库 指标信息
|
|
|
- edbInfos, err := data_manage.GetEdbInfoByEdbCodeList(utils.DATA_SOURCE_RZD, indexCodes)
|
|
|
+func RzdIndexAddValidate(req *data_manage.BaseFromRzdIndexBatchAddCheckReq) (*data_manage.BaseFromRzdIndexPage, error) {
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+
|
|
|
+ if req.IsCheckAll {
|
|
|
+ if len(req.ClassifyIdList) >= 0 {
|
|
|
+ condition += ` AND base_from_rzd_classify_id in (` + utils.GetOrmInReplace(len(req.ClassifyIdList)) + `)`
|
|
|
+ for _, id := range req.ClassifyIdList {
|
|
|
+ pars = append(pars, id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if req.Frequency != "" {
|
|
|
+ condition += ` AND frequency=? `
|
|
|
+ pars = append(pars, req.Frequency)
|
|
|
+ }
|
|
|
+ if req.SearchParams != "" {
|
|
|
+ condition += ` AND index_name like ? or index_code ?`
|
|
|
+ pars = append(pars, "%"+req.SearchParams+"%", "%"+req.SearchParams+"%")
|
|
|
+ }
|
|
|
+ if len(req.IndexCodes) > 0 {
|
|
|
+ condition += ` AND index_code not in (` + utils.GetOrmInReplace(len(req.IndexCodes)) + `)`
|
|
|
+ for _, code := range req.IndexCodes {
|
|
|
+ pars = append(pars, code)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if len(req.IndexCodes) > 0 {
|
|
|
+ condition += ` AND index_code in (` + utils.GetOrmInReplace(len(req.IndexCodes)) + `)`
|
|
|
+ for _, code := range req.IndexCodes {
|
|
|
+ pars = append(pars, code)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.PageSize <= 0 {
|
|
|
+ req.PageSize = utils.PageSize20
|
|
|
+ }
|
|
|
+ if req.CurrentIndex <= 0 {
|
|
|
+ req.CurrentIndex = 1
|
|
|
+ }
|
|
|
+ startSize := utils.StartIndex(req.CurrentIndex, req.PageSize)
|
|
|
+
|
|
|
+ count, err := data_manage.GetRzdIndexNotExistEdbInfoCount(condition, pars)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- var respList []data_manage.RzdIndexCheckData
|
|
|
- if len(edbInfos) > 0 {
|
|
|
- for _, ebdInfo := range edbInfos {
|
|
|
- respList = append(respList, data_manage.RzdIndexCheckData{
|
|
|
- IndexCode: ebdInfo.EdbCode,
|
|
|
- IndexName: ebdInfo.EdbName,
|
|
|
- Unit: ebdInfo.Unit,
|
|
|
- Frequency: ebdInfo.Frequency,
|
|
|
- EdbInfoId: ebdInfo.EdbInfoId,
|
|
|
- ClassifyId: ebdInfo.ClassifyId,
|
|
|
- UniqueCode: ebdInfo.UniqueCode,
|
|
|
- })
|
|
|
- }
|
|
|
+ page := paging.GetPaging(req.CurrentIndex, req.PageSize, count)
|
|
|
+
|
|
|
+ result := data_manage.BaseFromRzdIndexPage{}
|
|
|
+ result.Paging = page
|
|
|
+
|
|
|
+ if count <= 0 {
|
|
|
+ return &result, nil
|
|
|
+ } else if count > 30 {
|
|
|
+ return &result, fmt.Errorf("批量添加指标数量不得超过30个")
|
|
|
+ }
|
|
|
+
|
|
|
+ condition += ` ORDER BY base_from_rzd_index_id asc`
|
|
|
+
|
|
|
+ condition += ` limit ?, ?`
|
|
|
+ pars = append(pars, startSize, req.PageSize)
|
|
|
+
|
|
|
+ indexList, err := data_manage.GetRzdIndexNotExistEdbInfoPage(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
}
|
|
|
- return &respList, nil
|
|
|
+ result.List = indexList
|
|
|
+ return &result, nil
|
|
|
}
|
|
|
|
|
|
// RzdIndexNameCheck 指标名称校验
|
|
@@ -268,8 +315,8 @@ func GetRzdIndexInfo(keyWord string, classifyIdList []string, frequencyList []st
|
|
|
var condition string
|
|
|
var pars []interface{}
|
|
|
if keyWord != "" {
|
|
|
- condition += ` AND CONCAT(index_name,index_code) LIKE '%` + keyWord + `%'`
|
|
|
- pars = append(pars, keyWord)
|
|
|
+ condition += ` AND (index_name like ? or index_code like ?)`
|
|
|
+ pars = append(pars, "%"+keyWord+"%", "%"+keyWord+"%")
|
|
|
}
|
|
|
if len(classifyIdList) > 0 {
|
|
|
condition += ` AND base_from_rzd_classify_id IN (`
|
|
@@ -288,12 +335,6 @@ func GetRzdIndexInfo(keyWord string, classifyIdList []string, frequencyList []st
|
|
|
condition = condition[:len(condition)-1] + `)`
|
|
|
}
|
|
|
|
|
|
- condition += ` ORDER BY base_from_rzd_index_id asc`
|
|
|
-
|
|
|
- // 分页
|
|
|
- condition += ` LIMIT ?, ?`
|
|
|
- pars = append(pars, startSize, pageSize)
|
|
|
-
|
|
|
count, err := data_manage.GetRzdIndexInfoCount(condition, pars)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
@@ -305,6 +346,12 @@ func GetRzdIndexInfo(keyWord string, classifyIdList []string, frequencyList []st
|
|
|
return &indexPage, nil
|
|
|
}
|
|
|
|
|
|
+ condition += ` ORDER BY base_from_rzd_index_id asc`
|
|
|
+
|
|
|
+ // 分页
|
|
|
+ condition += ` LIMIT ?, ?`
|
|
|
+ pars = append(pars, startSize, pageSize)
|
|
|
+
|
|
|
indexInfoPage, err := data_manage.GetRzdIndexInfoPage(condition, pars)
|
|
|
if err != nil {
|
|
|
return nil, err
|