|
@@ -5369,3 +5369,129 @@ func (this *EdbInfoController) EdbInfoBatchAdd() {
|
|
|
br.Data = resp
|
|
|
br.IsAddLog = true
|
|
|
}
|
|
|
+
|
|
|
+// SmmExistCheck
|
|
|
+// @Title 新增指标-检验指标是否存在接口-smm
|
|
|
+// @Description 新增指标-检验指标是否存在接口-smm
|
|
|
+// @Param SubSource query int true "子数据来源:0:经济数据库,1:日期序列"
|
|
|
+// @Param EdbCode query string false "指标编码/指标代码"
|
|
|
+// @Param StockCode query string false "证券代码"
|
|
|
+// @Success 200 {object} data_manage.EdbInfoExistCheckResp
|
|
|
+// @router /edb_info/smm/exist/check [get]
|
|
|
+func (this *EdbInfoController) SmmExistCheck() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ selectAll, err := this.GetBool("SelectAll",false)
|
|
|
+ if err!= nil {
|
|
|
+ br.Msg = "参数解析失败"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ types := this.GetString("Types")
|
|
|
+ frequency := this.GetString("Frequency")
|
|
|
+ dataState := this.GetString("DataState")
|
|
|
+ keyword := this.GetString("Keyword")
|
|
|
+ edbCode := this.GetString("EdbCode")
|
|
|
+ edbCode = strings.Trim(edbCode, "\t")
|
|
|
+ edbCode = strings.Trim(edbCode, " ")
|
|
|
+ edbCode = strings.Replace(edbCode, "\t", "", -1)
|
|
|
+
|
|
|
+ if edbCode == "" {
|
|
|
+ br.Msg = "请输入指标ID"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var edbCodeArr []string
|
|
|
+
|
|
|
+ if selectAll {
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+
|
|
|
+ if types != "" {
|
|
|
+ typeArr := strings.Split(types,",")
|
|
|
+ for i, v := range typeArr {
|
|
|
+ typeStr := "type_"
|
|
|
+ typeStr += fmt.Sprintf("%d", i+1)
|
|
|
+ condition += " AND "+typeStr+" =? "
|
|
|
+ pars = append(pars, v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if dataState != "" {
|
|
|
+ if dataState == "normal" {
|
|
|
+ condition += " AND (data_state = 'normal' OR data_state = '') "
|
|
|
+ pars = append(pars)
|
|
|
+ } else {
|
|
|
+ condition += " AND data_state = ? "
|
|
|
+ pars = append(pars, dataState)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if keyword != "" {
|
|
|
+ condition += " AND (index_name LIKE ? OR index_code LIKE ?) "
|
|
|
+ pars = utils.GetLikeKeywordPars(pars, keyword, 2)
|
|
|
+ }
|
|
|
+
|
|
|
+ if frequency != "" {
|
|
|
+ condition += " AND frequency = ? "
|
|
|
+ pars = append(pars, frequency)
|
|
|
+ }
|
|
|
+
|
|
|
+ sortStr := " modify_time desc "
|
|
|
+
|
|
|
+ indexList, err := data_manage.GetSmmIndexDataList(condition, sortStr, pars, 1, 1000)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取指标列表失败"
|
|
|
+ br.ErrMsg = "获取指标列表失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range indexList {
|
|
|
+ edbCodeArr = append(edbCodeArr, v.IndexCode)
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ edbCodeArr = strings.Split(edbCode, ",")
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(edbCodeArr) > 30 {
|
|
|
+ br.Msg = "最多只能选择30个指标"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ indexList, err := data_manage.GetEdbInfoByEdbCodeList(utils.DATA_SOURCE_YS, edbCodeArr)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "校验指标是否存在失败"
|
|
|
+ br.ErrMsg = "校验指标是否存在失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var existEdbCodeArr []string
|
|
|
+ var existClassifyId []int
|
|
|
+ var existIndexId []int
|
|
|
+
|
|
|
+ for _, indexItem := range indexList {
|
|
|
+ for _, ev := range edbCodeArr {
|
|
|
+ if strings.Contains(indexItem.EdbCode, ev) {
|
|
|
+ existEdbCodeArr = append(existEdbCodeArr, ev)
|
|
|
+ existClassifyId = append(existClassifyId, indexItem.ClassifyId)
|
|
|
+ existIndexId = append(existIndexId, indexItem.EdbInfoId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ resp := new(data_manage.EdbInfoExistCheckResp)
|
|
|
+ if len(indexList) > 0 {
|
|
|
+ resp.IndexExist = true
|
|
|
+ }
|
|
|
+ resp.ExistEdbCodeArr = existEdbCodeArr
|
|
|
+ resp.ExistClassifyId = existClassifyId
|
|
|
+ resp.ExistIndexId = existIndexId
|
|
|
+ resp.ExistEdbInfo = indexList
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
+}
|