|
@@ -54,9 +54,9 @@ func (c *EdbBusinessController) SourceList() {
|
|
|
// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
// @Param Frequency query string true "频度"
|
|
|
// @Param Source query int true "来源"
|
|
|
-// @Param KeyWord query string true "编码/名称关键词"
|
|
|
+// @Param Keywords query string true "编码/名称关键词"
|
|
|
// @Success 200 {object} models.DataListResp
|
|
|
-// @router /business_data/index/list [get]
|
|
|
+// @router /business_data/list [get]
|
|
|
func (c *EdbBusinessController) List() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
defer func() {
|
|
@@ -65,7 +65,7 @@ func (c *EdbBusinessController) List() {
|
|
|
}()
|
|
|
pageSize, _ := c.GetInt("PageSize")
|
|
|
currentIndex, _ := c.GetInt("CurrentIndex")
|
|
|
- keyword := c.GetString("KeyWord")
|
|
|
+ keywords := c.GetString("Keywords")
|
|
|
frequency := c.GetString("Frequency")
|
|
|
source, _ := c.GetInt("Source") //分类
|
|
|
|
|
@@ -81,12 +81,12 @@ func (c *EdbBusinessController) List() {
|
|
|
var condition string
|
|
|
var pars []interface{}
|
|
|
|
|
|
- if keyword != "" {
|
|
|
- keywordSlice := strings.Split(keyword, " ")
|
|
|
+ if keywords != "" {
|
|
|
+ keywordSlice := strings.Split(keywords, " ")
|
|
|
if len(keywordSlice) > 0 {
|
|
|
tmpConditionSlice := make([]string, 0)
|
|
|
tmpConditionSlice = append(tmpConditionSlice, ` a.index_name like ? or a.index_code like ? `)
|
|
|
- pars = utils.GetLikeKeywordPars(pars, keyword, 2)
|
|
|
+ pars = utils.GetLikeKeywordPars(pars, keywords, 2)
|
|
|
|
|
|
for _, v := range keywordSlice {
|
|
|
if v == ` ` || v == `` {
|
|
@@ -99,7 +99,7 @@ func (c *EdbBusinessController) List() {
|
|
|
|
|
|
} else {
|
|
|
condition += ` a.index_name like ? or a.index_code like ? `
|
|
|
- pars = utils.GetLikeKeywordPars(pars, keyword, 2)
|
|
|
+ pars = utils.GetLikeKeywordPars(pars, keywords, 2)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -146,7 +146,7 @@ func (c *EdbBusinessController) List() {
|
|
|
// AddCheck
|
|
|
// @Title 新增校验
|
|
|
// @Description 新增校验
|
|
|
-// @Param request body data_manage.BloombergSourceBatchAddCheckReq true "type json string"
|
|
|
+// @Param request body request.BusinessDataBatchAddCheckReq true "type json string"
|
|
|
// @Success 200 string "操作成功"
|
|
|
// @router /business_data/add_check [post]
|
|
|
func (c *EdbBusinessController) AddCheck() {
|
|
@@ -186,11 +186,10 @@ func (c *EdbBusinessController) AddCheck() {
|
|
|
existMap[v.EdbCode] = v
|
|
|
}
|
|
|
|
|
|
- // 非全选-不需要频率等筛选条件
|
|
|
- bloombergOb := new(data_manage.BaseFromBloombergIndex)
|
|
|
+ list := make([]*data_manage.BaseFromBusinessIndexItem, 0)
|
|
|
obj := data_manage.BaseFromBusinessIndex{}
|
|
|
-
|
|
|
if !req.ListAll {
|
|
|
+ // 非全选-不需要频率等筛选条件
|
|
|
if codeLen == 0 {
|
|
|
br.Msg = "请选择指标"
|
|
|
return
|
|
@@ -204,74 +203,157 @@ func (c *EdbBusinessController) AddCheck() {
|
|
|
cond := fmt.Sprintf(` AND %s IN (%s)`, data_manage.BaseFromBusinessIndexCols.IndexCode, utils.GetOrmInReplace(codeLen))
|
|
|
pars := make([]interface{}, 0)
|
|
|
pars = append(pars, req.IndexCodes)
|
|
|
- list, e := obj.GeItemsByCondition(cond, pars, 0)
|
|
|
+ list, e = obj.GeItemsByCondition(cond, pars, 0)
|
|
|
if e != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取Bloomberg原始指标列表失败, Err: " + e.Error()
|
|
|
return
|
|
|
}
|
|
|
- resp := make([]*data_manage.BaseFromBloombergIndexItem, 0)
|
|
|
- for _, v := range list {
|
|
|
- t := data_manage.FormatBaseFromBloombergIndex2Item(v)
|
|
|
- ed := existMap[v.IndexCode]
|
|
|
- if ed != nil {
|
|
|
- t.EdbExist = 1
|
|
|
- t.EdbInfoId = ed.EdbInfoId
|
|
|
- t.EdbUniqueCode = ed.UniqueCode
|
|
|
- t.EdbClassifyId = ed.ClassifyId
|
|
|
+ } else {
|
|
|
+ // 全选-需要频率等筛选条件
|
|
|
+ condition := ``
|
|
|
+ pars := make([]interface{}, 0)
|
|
|
+
|
|
|
+ // 筛选项
|
|
|
+ req.Keywords = strings.TrimSpace(req.Keywords)
|
|
|
+ if req.Keywords != "" {
|
|
|
+ keywordSlice := strings.Split(req.Keywords, " ")
|
|
|
+ if len(keywordSlice) > 0 {
|
|
|
+ tmpConditionSlice := make([]string, 0)
|
|
|
+ tmpConditionSlice = append(tmpConditionSlice, ` a.index_name like ? or a.index_code like ? `)
|
|
|
+ pars = utils.GetLikeKeywordPars(pars, req.Keywords, 2)
|
|
|
+
|
|
|
+ for _, v := range keywordSlice {
|
|
|
+ if v == ` ` || v == `` {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ tmpConditionSlice = append(tmpConditionSlice, ` a.index_name like ? or a.index_code like ? `)
|
|
|
+ pars = utils.GetLikeKeywordPars(pars, v, 2)
|
|
|
+ }
|
|
|
+ condition += ` AND (` + strings.Join(tmpConditionSlice, " or ") + `)`
|
|
|
+
|
|
|
+ } else {
|
|
|
+ condition += ` a.index_name like ? or a.index_code like ? `
|
|
|
+ pars = utils.GetLikeKeywordPars(pars, req.Keywords, 2)
|
|
|
}
|
|
|
- resp = append(resp, t)
|
|
|
}
|
|
|
|
|
|
- br.Data = resp
|
|
|
- br.Msg = "校验成功"
|
|
|
- br.Ret = 200
|
|
|
- br.Success = true
|
|
|
- return
|
|
|
+ if req.Frequency != "" {
|
|
|
+ condition += ` AND a.frequency = ? `
|
|
|
+ pars = append(pars, req.Frequency)
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.Source > 0 {
|
|
|
+ condition += ` AND a.source = ? `
|
|
|
+ pars = append(pars, req.Source)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 排除对应指标
|
|
|
+ if codeLen > 0 {
|
|
|
+ condition += fmt.Sprintf(` AND a.%s NOT IN (%s)`, data_manage.BaseFromBloombergIndexCols.IndexCode, utils.GetOrmInReplace(codeLen))
|
|
|
+ pars = append(pars, req.IndexCodes)
|
|
|
+ }
|
|
|
+ // 查询max+1个指标
|
|
|
+ list, e = obj.GeItemsByCondition(condition, pars, codeMax+1)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取外部原始指标列表失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- // 全选-需要频率等筛选条件
|
|
|
- cond := ``
|
|
|
- pars := make([]interface{}, 0)
|
|
|
- // 筛选项
|
|
|
- req.Keywords = strings.TrimSpace(req.Keywords)
|
|
|
- if req.Keywords != "" {
|
|
|
- cond += fmt.Sprintf(` AND (%s LIKE ? OR %s LIKE ?)`, data_manage.BaseFromBloombergIndexCols.IndexCode, data_manage.BaseFromBloombergIndexCols.IndexName)
|
|
|
- kw := fmt.Sprint("%", req.Keywords, "%")
|
|
|
- pars = append(pars, kw, kw)
|
|
|
+ if len(list) > codeMax {
|
|
|
+ br.Msg = fmt.Sprintf("最多只能选择%d个指标", codeMax)
|
|
|
+ return
|
|
|
}
|
|
|
- if req.Frequency != "" {
|
|
|
- cond += fmt.Sprintf(` AND %s = ?`, data_manage.BaseFromBloombergIndexCols.Frequency)
|
|
|
- pars = append(pars, req.Frequency)
|
|
|
+
|
|
|
+ resp := make([]*data_manage.BaseFromBusinessIndexItem, 0)
|
|
|
+ for _, v := range list {
|
|
|
+ if v.EdbInfoId > 0 {
|
|
|
+ v.EdbExist = 1
|
|
|
+ }
|
|
|
+ resp = append(resp, v)
|
|
|
}
|
|
|
- // 排除对应指标
|
|
|
- if codeLen > 0 {
|
|
|
- cond += fmt.Sprintf(` AND %s NOT IN (%s)`, data_manage.BaseFromBloombergIndexCols.IndexCode, utils.GetOrmInReplace(codeLen))
|
|
|
- pars = append(pars, req.IndexCodes)
|
|
|
+
|
|
|
+ br.Data = resp
|
|
|
+ br.Msg = "校验成功"
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+}
|
|
|
+
|
|
|
+// NameCheck
|
|
|
+// @Title 重名校验
|
|
|
+// @Description 批量新增
|
|
|
+// @Param request body data_manage.AddEdbInfoReq true "type json string"
|
|
|
+// @Success 200 string "操作成功"
|
|
|
+// @router /business_data/name_check [post]
|
|
|
+func (c *EdbBusinessController) NameCheck() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ if br.ErrMsg == "" {
|
|
|
+ br.IsSendEmail = false
|
|
|
+ }
|
|
|
+ c.Data["json"] = br
|
|
|
+ c.ServeJSON()
|
|
|
+ }()
|
|
|
+ sysUser := c.SysUser
|
|
|
+ if sysUser == nil {
|
|
|
+ br.Msg = "请登录"
|
|
|
+ br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
}
|
|
|
- // 查询max+1个指标
|
|
|
- list, e := bloombergOb.GetItemsByCondition(cond, pars, []string{}, orderRule, codeMax+1)
|
|
|
- if e != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取Bloomberg原始指标列表失败, Err: " + e.Error()
|
|
|
+ var req []*data_manage.AddEdbInfoReq
|
|
|
+ if e := json.Unmarshal(c.Ctx.Input.RequestBody, &req); e != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + e.Error()
|
|
|
return
|
|
|
}
|
|
|
- if len(list) > codeMax {
|
|
|
- br.Msg = fmt.Sprintf("最多只能选择%d个指标", codeMax)
|
|
|
+ if len(req) == 0 {
|
|
|
+ br.Msg = "请选择指标"
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- resp := make([]*data_manage.BaseFromBloombergIndexItem, 0)
|
|
|
- for _, v := range list {
|
|
|
- t := data_manage.FormatBaseFromBloombergIndex2Item(v)
|
|
|
- ed := existMap[v.IndexCode]
|
|
|
- if ed != nil {
|
|
|
- t.EdbExist = 1
|
|
|
- t.EdbInfoId = ed.EdbInfoId
|
|
|
- t.EdbUniqueCode = ed.UniqueCode
|
|
|
- t.EdbClassifyId = ed.ClassifyId
|
|
|
+ type NameCheckResult struct {
|
|
|
+ EdbCode string
|
|
|
+ EdbName string
|
|
|
+ Exist bool
|
|
|
+ }
|
|
|
+ indexNames := make([]string, 0)
|
|
|
+ resp := make([]*NameCheckResult, 0)
|
|
|
+ for _, v := range req {
|
|
|
+ v.EdbCode = strings.TrimSpace(v.EdbCode)
|
|
|
+ if v.EdbCode == "" {
|
|
|
+ br.Msg = "指标ID不可为空"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ v.EdbName = strings.TrimSpace(v.EdbName)
|
|
|
+ if v.EdbName == "" {
|
|
|
+ br.Msg = "请输入指标名称"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ indexNames = append(indexNames, v.EdbName)
|
|
|
+ resp = append(resp, &NameCheckResult{
|
|
|
+ EdbCode: v.EdbCode,
|
|
|
+ EdbName: v.EdbName,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ // 重名校验
|
|
|
+ edbList, e := data_manage.GetEdbInfoByNameArr(indexNames, utils.EDB_INFO_TYPE)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "获取重名指标失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ nameExists := make(map[string]bool)
|
|
|
+ for _, v := range edbList {
|
|
|
+ nameExists[v.EdbName] = true
|
|
|
+ }
|
|
|
+ if len(nameExists) > 0 {
|
|
|
+ for _, v := range resp {
|
|
|
+ v.Exist = nameExists[v.EdbName]
|
|
|
}
|
|
|
- resp = append(resp, t)
|
|
|
}
|
|
|
|
|
|
br.Data = resp
|
|
@@ -359,9 +441,9 @@ func (c *EdbBusinessController) BatchAdd() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 限定同一时间最多批量新增30个指标
|
|
|
+ // 限定同一时间最多批量新增100个指标
|
|
|
for _, v := range req {
|
|
|
- var r data.BloombergIndexSource2EdbReq
|
|
|
+ var r data.BusinessIndexSource2EdbReq
|
|
|
r.EdbCode = v.EdbCode
|
|
|
r.EdbName = v.EdbName
|
|
|
r.Frequency = v.Frequency
|
|
@@ -370,7 +452,7 @@ func (c *EdbBusinessController) BatchAdd() {
|
|
|
r.AdminId = sysUser.AdminId
|
|
|
r.AdminRealName = sysUser.RealName
|
|
|
|
|
|
- edbInfo, e, errMsg, skip := data.BloombergIndexSource2Edb(r)
|
|
|
+ edbInfo, e, errMsg, skip := data.BusinessIndexSource2Edb(r)
|
|
|
if e != nil {
|
|
|
br.Msg = "操作失败"
|
|
|
if errMsg != "" {
|
|
@@ -425,84 +507,3 @@ func (c *EdbBusinessController) BatchAdd() {
|
|
|
br.Success = true
|
|
|
br.IsAddLog = true
|
|
|
}
|
|
|
-
|
|
|
-// NameCheck
|
|
|
-// @Title 重名校验
|
|
|
-// @Description 批量新增
|
|
|
-// @Param request body data_manage.AddEdbInfoReq true "type json string"
|
|
|
-// @Success 200 string "操作成功"
|
|
|
-// @router /business_data/name_check [post]
|
|
|
-func (c *EdbBusinessController) NameCheck() {
|
|
|
- br := new(models.BaseResponse).Init()
|
|
|
- defer func() {
|
|
|
- if br.ErrMsg == "" {
|
|
|
- br.IsSendEmail = false
|
|
|
- }
|
|
|
- c.Data["json"] = br
|
|
|
- c.ServeJSON()
|
|
|
- }()
|
|
|
- sysUser := c.SysUser
|
|
|
- if sysUser == nil {
|
|
|
- br.Msg = "请登录"
|
|
|
- br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
- br.Ret = 408
|
|
|
- return
|
|
|
- }
|
|
|
- var req []*data_manage.AddEdbInfoReq
|
|
|
- if e := json.Unmarshal(c.Ctx.Input.RequestBody, &req); e != nil {
|
|
|
- br.Msg = "参数解析异常!"
|
|
|
- br.ErrMsg = "参数解析失败,Err:" + e.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- if len(req) == 0 {
|
|
|
- br.Msg = "请选择指标"
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- type NameCheckResult struct {
|
|
|
- EdbCode string
|
|
|
- EdbName string
|
|
|
- Exist bool
|
|
|
- }
|
|
|
- indexNames := make([]string, 0)
|
|
|
- resp := make([]*NameCheckResult, 0)
|
|
|
- for _, v := range req {
|
|
|
- v.EdbCode = strings.TrimSpace(v.EdbCode)
|
|
|
- if v.EdbCode == "" {
|
|
|
- br.Msg = "指标ID不可为空"
|
|
|
- return
|
|
|
- }
|
|
|
- v.EdbName = strings.TrimSpace(v.EdbName)
|
|
|
- if v.EdbName == "" {
|
|
|
- br.Msg = "请输入指标名称"
|
|
|
- return
|
|
|
- }
|
|
|
- indexNames = append(indexNames, v.EdbName)
|
|
|
- resp = append(resp, &NameCheckResult{
|
|
|
- EdbCode: v.EdbCode,
|
|
|
- EdbName: v.EdbName,
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- // 重名校验
|
|
|
- edbList, e := data_manage.GetEdbInfoByNameArr(indexNames)
|
|
|
- if e != nil {
|
|
|
- br.Msg = "操作失败"
|
|
|
- br.ErrMsg = "获取重名指标失败, Err: " + e.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- nameExists := make(map[string]bool)
|
|
|
- for _, v := range edbList {
|
|
|
- nameExists[v.EdbName] = true
|
|
|
- }
|
|
|
- if len(nameExists) > 0 {
|
|
|
- for _, v := range resp {
|
|
|
- v.Exist = nameExists[v.EdbName]
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- br.Data = resp
|
|
|
- br.Msg = "操作成功"
|
|
|
- br.Ret = 200
|
|
|
- br.Success = true
|
|
|
-}
|