Bläddra i källkod

Merge branch 'aj_wind_wsd' into debug

tuoling805 1 år sedan
förälder
incheckning
958a0a3b43
3 ändrade filer med 50 tillägg och 33 borttagningar
  1. 44 28
      controllers/data_manage/edb_info.go
  2. 4 3
      models/data_manage/edb_info.go
  3. 2 2
      services/data/base_edb_lib.go

+ 44 - 28
controllers/data_manage/edb_info.go

@@ -34,7 +34,7 @@ type EdbInfoController struct {
 // @Param   Source   query   int  true       "来源:1:同花顺,2:wind,3:彭博"
 // @Param   SubSource   query   int  true       "子数据来源:0:经济数据库,1:日期序列"
 // @Param   EdbCode   query   string  false       "指标编码/指标代码"
-// @Param   SecuritiesCode   query   string  false       "证券代码"
+// @Param   StockCode   query   string  false       "证券代码"
 // @Success 200 {object} data_manage.EdbInfoSearchResp
 // @router /edb_info/search [get]
 func (this *EdbInfoController) EdbInfoSearch() {
@@ -49,7 +49,7 @@ func (this *EdbInfoController) EdbInfoSearch() {
 	edbCode = strings.Trim(edbCode, " ")
 	edbCode = strings.Replace(edbCode, "\t", "", -1)
 	subSource, _ := this.GetInt("SubSource")
-	securitiesCode := this.GetString("SecuritiesCode")
+	stockCode := this.GetString("StockCode")
 
 	if source <= 0 {
 		br.Msg = "无效的数据来源"
@@ -250,7 +250,7 @@ func (this *EdbInfoController) EdbInfoSearch() {
 					isAdd = true
 				}
 			} else if subSource == utils.DATA_SUB_SOURCE_DATE {
-				if securitiesCode == "" {
+				if stockCode == "" {
 					br.Msg = "请输入证券代码"
 					return
 				}
@@ -258,7 +258,7 @@ func (this *EdbInfoController) EdbInfoSearch() {
 					br.Msg = "请输入指标代码"
 					return
 				}
-				respItem, err := data.AddEdbDataWindWsd(source, securitiesCode, edbCode)
+				respItem, err := data.AddEdbDataWindWsd(source, stockCode, edbCode)
 				if err != nil {
 					br.Msg = "获取失败"
 					br.ErrMsg = "获取失败,Err:" + err.Error()
@@ -277,7 +277,8 @@ func (this *EdbInfoController) EdbInfoSearch() {
 				}
 				isAdd = true
 			} else {
-
+				br.Msg = "无效的渠道来源"
+				return
 			}
 		} else if source == utils.DATA_SOURCE_PB || source == utils.DATA_SOURCE_PB_FINANCE {
 			fmt.Println("pb data exist")
@@ -1661,31 +1662,45 @@ func (this *EdbInfoController) EdbInfoSearch() {
 			}
 		}
 		if isAdd {
-			dataList, err := data_manage.GetEdbDataAllByEdbCode(edbCode, source, utils.EDB_DATA_LIMIT)
-			if err != nil && err.Error() != utils.ErrNoRow() {
-				br.Msg = "获取失败"
-				br.ErrMsg = "获取数据失败,GetEdbDataAllByEdbCode Err:" + err.Error()
-				return
-			}
-			searchItem.DataList = dataList
+			if subSource == utils.DATA_SUB_SOURCE_DATE {
+				var indexCodeArr []string
+				edbCodeArr := strings.Split(edbCode, ",")
+				stockCodeArr := strings.Split(stockCode, ",")
+
+				for _, sv := range stockCodeArr {
+					for _, ev := range edbCodeArr {
+						indexCode := utils.WindDbWsd + sv + ev
+						indexCodeArr = append(indexCodeArr, indexCode)
+					}
+				}
 
-			edbInfoMaxAndMinInfo, err := data_manage.GetEdbInfoMaxAndMinInfo(source, edbCode)
-			if err != nil && err.Error() != utils.ErrNoRow() {
-				br.Msg = "获取失败"
-				br.ErrMsg = "获取数据失败,GetEdbInfoMaxAndMinInfo Err:" + err.Error()
-				return
-			}
-			searchItem.EdbCode = edbCode
-			searchItem.DataList = dataList
-			if edbInfoMaxAndMinInfo != nil {
-				searchItem.StartDate = edbInfoMaxAndMinInfo.MinDate
-				searchItem.EndDate = edbInfoMaxAndMinInfo.MaxDate
-			}
+			} else {
+				dataList, err := data_manage.GetEdbDataAllByEdbCode(edbCode, source, utils.EDB_DATA_LIMIT)
+				if err != nil && err.Error() != utils.ErrNoRow() {
+					br.Msg = "获取失败"
+					br.ErrMsg = "获取数据失败,GetEdbDataAllByEdbCode Err:" + err.Error()
+					return
+				}
+				searchItem.DataList = dataList
+
+				edbInfoMaxAndMinInfo, err := data_manage.GetEdbInfoMaxAndMinInfo(source, edbCode)
+				if err != nil && err.Error() != utils.ErrNoRow() {
+					br.Msg = "获取失败"
+					br.ErrMsg = "获取数据失败,GetEdbInfoMaxAndMinInfo Err:" + err.Error()
+					return
+				}
+				searchItem.EdbCode = edbCode
+				searchItem.DataList = dataList
+				if edbInfoMaxAndMinInfo != nil {
+					searchItem.StartDate = edbInfoMaxAndMinInfo.MinDate
+					searchItem.EndDate = edbInfoMaxAndMinInfo.MaxDate
+				}
 
-			//edb指标信息
-			edbInfoItem, err := data_manage.GetEdbInfoByEdbCode(source, edbCode)
-			if edbInfoItem != nil {
-				searchItem.EdbName = edbInfoItem.EdbName
+				//edb指标信息
+				edbInfoItem, err := data_manage.GetEdbInfoByEdbCode(source, edbCode)
+				if edbInfoItem != nil {
+					searchItem.EdbName = edbInfoItem.EdbName
+				}
 			}
 		}
 		resp.Status = 2
@@ -4973,4 +4988,5 @@ func (this *EdbInfoController) EdbInfoExistCheck() {
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"
+	br.Data = resp
 }

+ 4 - 3
models/data_manage/edb_info.go

@@ -112,9 +112,10 @@ type EdbInfoSearchData struct {
 }
 
 type EdbInfoSearchResp struct {
-	SearchItem   *EdbInfoSearch `description:"指标分类"`
-	Status       int            `description:"1:数据已存在于弘则数据库,2:新数据,3:数据已存在于弘则数据库,但是当前账号无权限"`
-	ClassifyList []*EdbClassifySimplify
+	SearchItem      *EdbInfoSearch `description:"指标分类"`
+	Status          int            `description:"1:数据已存在于弘则数据库,2:新数据,3:数据已存在于弘则数据库,但是当前账号无权限"`
+	ClassifyList    []*EdbClassifySimplify
+	StockSearchList []*EdbInfoSearch
 }
 
 func GetEdbInfoByEdbCode(source int, edbCode string) (item *EdbInfo, err error) {

+ 2 - 2
services/data/base_edb_lib.go

@@ -81,10 +81,10 @@ func AddEdbData(source int, edbCode string) (resp *models.BaseResponse, err erro
 }
 
 // AddEdbData 新增指标数据
-func AddEdbDataWindWsd(source int, securitiesCode, edbCode string) (resp *models.BaseResponse, err error) {
+func AddEdbDataWindWsd(source int, stockCode, edbCode string) (resp *models.BaseResponse, err error) {
 	param := make(map[string]interface{})
 	param["EdbCode"] = edbCode
-	param["SecuritiesCode"] = securitiesCode
+	param["StockCode"] = stockCode
 	param["Source"] = source
 	urlStr := `wind/wsd/add`
 	if urlStr == "" {