|
@@ -161,46 +161,79 @@ func (this *EdbInfoController) EdbInfoSearch() {
|
|
|
|
|
|
searchItem := new(data_manage.EdbInfoSearch)
|
|
|
if source == utils.DATA_SOURCE_THS {
|
|
|
- dataItems, err := data_manage.GetEdbDataAllByEdbCode(edbCode, utils.DATA_SOURCE_THS, subSource, utils.EDB_DATA_LIMIT)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取Ths已存在信息失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- fmt.Println("ths len:", len(dataItems))
|
|
|
- if len(dataItems) > 0 {
|
|
|
- fmt.Println("ths data exist")
|
|
|
- searchItem.EdbCode = edbCode
|
|
|
- minDate, maxDate, err := data_manage.GetEdbDataThsMaxOrMinDate(edbCode)
|
|
|
- if err != nil {
|
|
|
+ fmt.Println("subSource:", subSource)
|
|
|
+ if subSource == utils.DATA_SUB_SOURCE_EDB {
|
|
|
+ dataItems, err := data_manage.GetEdbDataAllByEdbCode(edbCode, utils.DATA_SOURCE_THS, subSource, utils.EDB_DATA_LIMIT)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取Ths日期信息失败,Err:" + err.Error()
|
|
|
+ br.ErrMsg = "获取Ths已存在信息失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- searchItem.DataList = dataItems
|
|
|
- searchItem.StartDate = minDate
|
|
|
- searchItem.EndDate = maxDate
|
|
|
- } else {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- respItem, err := data.AddEdbData(source, edbCode)
|
|
|
+
|
|
|
+ fmt.Println("ths len:", len(dataItems))
|
|
|
+ if len(dataItems) > 0 {
|
|
|
+ fmt.Println("ths data exist")
|
|
|
+ searchItem.EdbCode = edbCode
|
|
|
+ minDate, maxDate, err := data_manage.GetEdbDataThsMaxOrMinDate(edbCode)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取Ths日期信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ searchItem.DataList = dataItems
|
|
|
+ searchItem.StartDate = minDate
|
|
|
+ searchItem.EndDate = maxDate
|
|
|
+ } else {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ respItem, err := data.AddEdbData(source, edbCode)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if respItem.Ret != 200 {
|
|
|
+ br.Msg = "未搜索到该指标"
|
|
|
+ br.ErrMsg = respItem.ErrMsg + ";EdbCode:" + edbCode
|
|
|
+ return
|
|
|
+ }
|
|
|
+ isAdd = true
|
|
|
+ }
|
|
|
+ } else if subSource == utils.DATA_SUB_SOURCE_DATE {
|
|
|
+ if stockCode == "" {
|
|
|
+ br.Msg = "请输入证券代码"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if edbCode == "" {
|
|
|
+ br.Msg = "请输入指标代码"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ respItem, err := data.AddEdbDataThsDs(source, stockCode, edbCode)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
if respItem.Ret != 200 {
|
|
|
- br.Msg = "未搜索到该指标"
|
|
|
+ if respItem.Ret == 421 {
|
|
|
+ br.Msg = "该渠道已超过添加上限"
|
|
|
+ } else if respItem.Ret == 4052 {
|
|
|
+ br.Msg = "该指标已下架"
|
|
|
+ } else {
|
|
|
+ br.Msg = "未搜索到该指标"
|
|
|
+ }
|
|
|
br.ErrMsg = respItem.ErrMsg + ";EdbCode:" + edbCode
|
|
|
return
|
|
|
}
|
|
|
isAdd = true
|
|
|
+ } else {
|
|
|
+ br.Msg = "无效的渠道来源"
|
|
|
+ return
|
|
|
}
|
|
|
} else if source == utils.DATA_SOURCE_WIND {
|
|
|
fmt.Println("subSource:", subSource)
|
|
@@ -1664,87 +1697,113 @@ func (this *EdbInfoController) EdbInfoSearch() {
|
|
|
}
|
|
|
if isAdd {
|
|
|
if subSource == utils.DATA_SUB_SOURCE_DATE {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- stockList := make([]*data_manage.StockInfo, 0)
|
|
|
- edbCodeArr := strings.Split(edbCode, ",")
|
|
|
- for _, v := range edbCodeArr {
|
|
|
- indexCode := utils.WindDbWsd + stockCode + v
|
|
|
+ if source == utils.DATA_SOURCE_WIND {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ stockList := make([]*data_manage.StockInfo, 0)
|
|
|
+ edbCodeArr := strings.Split(edbCode, ",")
|
|
|
+ for _, v := range edbCodeArr {
|
|
|
+ indexCode := utils.WindDbWsd + stockCode + v
|
|
|
+
|
|
|
+ dataList, err := data_manage.GetEdbDataAllByEdbCodeAndSubSource(indexCode, source, utils.DATA_SUB_SOURCE_DATE, utils.EDB_DATA_LIMIT)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取数据失败,GetEdbDataAllByEdbCode Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- dataList, err := data_manage.GetEdbDataAllByEdbCodeAndSubSource(indexCode, source, utils.DATA_SUB_SOURCE_DATE, utils.EDB_DATA_LIMIT)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取数据失败,GetEdbDataAllByEdbCode Err:" + err.Error()
|
|
|
- return
|
|
|
+ stockInfo := new(data_manage.StockInfo)
|
|
|
+ stockInfo.StockCode = stockCode
|
|
|
+ stockInfo.EdbCode = v
|
|
|
+ stockInfo.DataList = dataList
|
|
|
+ stockList = append(stockList, stockInfo)
|
|
|
}
|
|
|
+ searchItem.StockList = stockList
|
|
|
+ } else if source == utils.DATA_SOURCE_THS {
|
|
|
+ stockList := make([]*data_manage.StockInfo, 0)
|
|
|
+ edbCodeArr := strings.Split(edbCode, ",")
|
|
|
+ for _, v := range edbCodeArr {
|
|
|
+ indexCode := utils.ThsDs + stockCode + v
|
|
|
+
|
|
|
+ dataList, err := data_manage.GetEdbDataAllByEdbCodeAndSubSource(indexCode, source, utils.DATA_SUB_SOURCE_DATE, utils.EDB_DATA_LIMIT)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取数据失败,GetEdbDataAllByEdbCode Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- stockInfo := new(data_manage.StockInfo)
|
|
|
- stockInfo.StockCode = stockCode
|
|
|
- stockInfo.EdbCode = v
|
|
|
- stockInfo.DataList = dataList
|
|
|
- stockList = append(stockList, stockInfo)
|
|
|
+ stockInfo := new(data_manage.StockInfo)
|
|
|
+ stockInfo.StockCode = stockCode
|
|
|
+ stockInfo.EdbCode = v
|
|
|
+ stockInfo.DataList = dataList
|
|
|
+ stockList = append(stockList, stockInfo)
|
|
|
+ }
|
|
|
+ searchItem.StockList = stockList
|
|
|
+ } else {
|
|
|
+ br.Msg = "来源错误"
|
|
|
+ br.ErrMsg = "来源错误"
|
|
|
+ return
|
|
|
}
|
|
|
- searchItem.StockList = stockList
|
|
|
} else {
|
|
|
dataList, err := data_manage.GetEdbDataAllByEdbCode(edbCode, source, subSource, utils.EDB_DATA_LIMIT)
|
|
|
if err != nil && err.Error() != utils.ErrNoRow() {
|
|
@@ -1901,20 +1960,41 @@ func (this *EdbInfoController) EdbInfoList() {
|
|
|
dataPars = append(dataPars, edbInfoItem.EdbInfoId)
|
|
|
|
|
|
if edbInfoItem.SubSource == utils.DATA_SUB_SOURCE_DATE {
|
|
|
- dataCount, err := data_manage.GetEdbWsdDataCountByCondition(dataCondition, dataPars, edbInfoItem.Source)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- br.Msg = "获取指标信息失败"
|
|
|
- br.ErrMsg = "获取指标数据总数失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- page = paging.GetPaging(currentIndex, pageSize, dataCount)
|
|
|
- dataList, err := data_manage.GetEdbWsdDataListByCondition(dataCondition, dataPars, edbInfoItem.Source, pageSize, startSize)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取指标信息失败"
|
|
|
- br.ErrMsg = "获取指标数据失败,Err:" + err.Error()
|
|
|
+ if edbInfoItem.Source == utils.DATA_SOURCE_WIND {
|
|
|
+ dataCount, err := data_manage.GetEdbWsdDataCountByCondition(dataCondition, dataPars, edbInfoItem.Source)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取指标信息失败"
|
|
|
+ br.ErrMsg = "获取指标数据总数失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ page = paging.GetPaging(currentIndex, pageSize, dataCount)
|
|
|
+ dataList, err := data_manage.GetEdbWsdDataListByCondition(dataCondition, dataPars, edbInfoItem.Source, pageSize, startSize)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取指标信息失败"
|
|
|
+ br.ErrMsg = "获取指标数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ edbInfoItem.DataList = dataList
|
|
|
+ } else if edbInfoItem.Source == utils.DATA_SOURCE_THS {
|
|
|
+ dataCount, err := data_manage.GetTHsDsDataCountByCondition(dataCondition, dataPars, edbInfoItem.Source)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取指标信息失败"
|
|
|
+ br.ErrMsg = "获取指标数据总数失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ page = paging.GetPaging(currentIndex, pageSize, dataCount)
|
|
|
+ dataList, err := data_manage.GetThsDsDataListByCondition(dataCondition, dataPars, edbInfoItem.Source, pageSize, startSize)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取指标信息失败"
|
|
|
+ br.ErrMsg = "获取指标数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ edbInfoItem.DataList = dataList
|
|
|
+ } else {
|
|
|
+ br.Msg = "指标数据源id错误"
|
|
|
+ br.ErrMsg = "指标数据源id错误"
|
|
|
return
|
|
|
}
|
|
|
- edbInfoItem.DataList = dataList
|
|
|
} else {
|
|
|
dataCount, err := data_manage.GetEdbDataCountByCondition(dataCondition, dataPars, edbInfoItem.Source, edbInfoItem.SubSource)
|
|
|
if err != nil && err.Error() != utils.ErrNoRow() {
|
|
@@ -5027,7 +5107,7 @@ func (this *EdbInfoController) EdbInfoExistCheck() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if source != utils.DATA_SOURCE_WIND {
|
|
|
+ if source != utils.DATA_SOURCE_WIND && source != utils.DATA_SOURCE_THS {
|
|
|
br.Msg = "无效的数据来源"
|
|
|
return
|
|
|
}
|
|
@@ -5040,9 +5120,19 @@ func (this *EdbInfoController) EdbInfoExistCheck() {
|
|
|
edbCodeArr := strings.Split(edbCode, ",")
|
|
|
stockCodeArr := strings.Split(stockCode, ",")
|
|
|
|
|
|
+ var prefix string
|
|
|
+ if source == utils.DATA_SOURCE_WIND {
|
|
|
+ prefix = utils.WindDbWsd
|
|
|
+ } else if source == utils.DATA_SOURCE_THS {
|
|
|
+ prefix = utils.ThsDs
|
|
|
+ } else {
|
|
|
+ br.Msg = "来源错误"
|
|
|
+ br.ErrMsg = "来源错误"
|
|
|
+ return
|
|
|
+ }
|
|
|
for _, sv := range stockCodeArr {
|
|
|
for _, ev := range edbCodeArr {
|
|
|
- indexCode := utils.WindDbWsd + sv + ev
|
|
|
+ indexCode := prefix + sv + ev
|
|
|
indexCodeArr = append(indexCodeArr, indexCode)
|
|
|
}
|
|
|
}
|
|
@@ -5054,6 +5144,9 @@ func (this *EdbInfoController) EdbInfoExistCheck() {
|
|
|
}
|
|
|
var existStockCodeArr []string
|
|
|
var existEdbCodeArr []string
|
|
|
+ var existClassifyId []int
|
|
|
+ var existIndexId []int
|
|
|
+
|
|
|
for _, indexItem := range indexList {
|
|
|
for _, sv := range stockCodeArr {
|
|
|
for _, ev := range edbCodeArr {
|
|
@@ -5062,6 +5155,8 @@ func (this *EdbInfoController) EdbInfoExistCheck() {
|
|
|
}
|
|
|
if strings.Contains(indexItem.EdbCode, ev) {
|
|
|
existEdbCodeArr = append(existEdbCodeArr, ev)
|
|
|
+ existClassifyId = append(existClassifyId, indexItem.ClassifyId)
|
|
|
+ existIndexId = append(existIndexId, indexItem.EdbInfoId)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -5073,6 +5168,9 @@ func (this *EdbInfoController) EdbInfoExistCheck() {
|
|
|
}
|
|
|
resp.ExistEdbCodeArr = existEdbCodeArr
|
|
|
resp.ExistStockCodeArr = existStockCodeArr
|
|
|
+ resp.ExistClassifyId = existClassifyId
|
|
|
+ resp.ExistIndexId = existIndexId
|
|
|
+ resp.ExistEdbInfo = indexList
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
br.Msg = "获取成功"
|
|
@@ -5120,19 +5218,39 @@ func (this *EdbInfoController) EdbInfoBatchAdd() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- source := utils.DATA_SOURCE_WIND
|
|
|
- if source <= 0 {
|
|
|
- br.Msg = "无效的数据来源"
|
|
|
+ resp := new(data_manage.AddEdbInfoResp)
|
|
|
+
|
|
|
+ var edbNames string
|
|
|
+ for _, v := range req.BatchList {
|
|
|
+ edbNames += "'" + v.EdbName + "',"
|
|
|
+ }
|
|
|
+ edbNames = strings.Trim(edbNames, ",")
|
|
|
+ infoList, err := data_manage.GetEdbInfoByNames(edbNames)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "查询指标名称重复错误!"
|
|
|
+ br.ErrMsg = "GetEdbInfoByNames,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(infoList) > 0 {
|
|
|
+ for _, v := range infoList {
|
|
|
+ resp.ExistEdbName = append(resp.ExistEdbName, v.EdbName)
|
|
|
+ }
|
|
|
+ br.Data = resp
|
|
|
+ br.Msg = "指标名称重复!"
|
|
|
+ br.ErrMsg = "指标名称重复"
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- resp := new(data_manage.AddEdbInfoResp)
|
|
|
|
|
|
for k, v := range req.BatchList {
|
|
|
v.EdbName = strings.Trim(v.EdbName, " ")
|
|
|
v.EdbCode = strings.Trim(v.EdbCode, " ")
|
|
|
v.StockCode = strings.Trim(v.StockCode, " ")
|
|
|
|
|
|
+ if v.Source <= 0 {
|
|
|
+ br.Msg = "无效的数据来源"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
if v.EdbCode == "" {
|
|
|
br.Msg = "指标ID不能为空"
|
|
|
return
|
|
@@ -5159,14 +5277,17 @@ func (this *EdbInfoController) EdbInfoBatchAdd() {
|
|
|
}
|
|
|
|
|
|
edbInfoItem := new(data_manage.EdbInfo)
|
|
|
- edbInfoItem.Source = source
|
|
|
- switch source {
|
|
|
+ edbInfoItem.Source = v.Source
|
|
|
+ switch v.Source {
|
|
|
case utils.DATA_SOURCE_WIND:
|
|
|
edbInfoItem.SourceName = "wind"
|
|
|
+ edbInfoItem.EdbCode = utils.WindDbWsd + v.StockCode + v.EdbCode
|
|
|
+ case utils.DATA_SOURCE_THS:
|
|
|
+ edbInfoItem.SourceName = "ths"
|
|
|
+ edbInfoItem.EdbCode = utils.ThsDs + v.StockCode + v.EdbCode
|
|
|
}
|
|
|
edbInfoItem.SubSource = 1
|
|
|
edbInfoItem.SubSourceName = "日期序列"
|
|
|
- edbInfoItem.EdbCode = utils.WindDbWsd + v.StockCode + v.EdbCode
|
|
|
edbInfoItem.EdbName = v.EdbName
|
|
|
edbInfoItem.Frequency = v.Frequency
|
|
|
edbInfoItem.Unit = v.Unit
|