|
@@ -2,6 +2,7 @@ package controllers
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
+ "eta/eta_index_lib/logic"
|
|
|
"eta/eta_index_lib/models"
|
|
|
shanghaismm "eta/eta_index_lib/services/shanghai_smm"
|
|
|
"eta/eta_index_lib/utils"
|
|
@@ -28,13 +29,17 @@ var ShanghaiSmmNameToCodeMap = make(map[string]string)
|
|
|
// @router /refresh/list [post]
|
|
|
func (this *ShanghaiSmmController) RefreshData() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
+ var err error
|
|
|
defer func() {
|
|
|
+ if err != nil {
|
|
|
+ utils.FileLog.Error("SMM-RefreshData err:", err)
|
|
|
+ }
|
|
|
this.Data["json"] = br
|
|
|
this.ServeJSON()
|
|
|
}()
|
|
|
|
|
|
var req []*shanghaismm.EdbInfoData
|
|
|
- if err := json.Unmarshal(this.Ctx.Input.RequestBody, &req); err != nil {
|
|
|
+ if err = json.Unmarshal(this.Ctx.Input.RequestBody, &req); err != nil {
|
|
|
br.Msg = "参数解析异常!"
|
|
|
br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
return
|
|
@@ -201,6 +206,38 @@ func (this *ShanghaiSmmController) RefreshData() {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
+ var messages []string
|
|
|
+ defer func() {
|
|
|
+ if len(messages) > 0 {
|
|
|
+ errMsg := strings.Join(messages, ",")
|
|
|
+ utils.FileLog.Info("SMM RefreshData errMsg: %s", errMsg)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ for _, v := range updateIndexList {
|
|
|
+ itemInfo, err := models.GetSmmIndexInfoMaxAndMinInfo(v.IndexCode)
|
|
|
+ if err == nil && itemInfo != nil {
|
|
|
+ e := models.ModifySmmIndexMaxAndMinInfo(v.IndexCode, itemInfo)
|
|
|
+ if e != nil {
|
|
|
+ messages = append(messages, fmt.Sprintf("更新指标最大最小值失败, indexCode: %s, err: %s", v.IndexCode, e.Error()))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 同步刷新ETA图库有色的指标
|
|
|
+ {
|
|
|
+ // 获取指标详情
|
|
|
+ edbInfo, e := models.GetEdbInfoByEdbCode(utils.DATA_SOURCE_YS, v.IndexCode)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ messages = append(messages, fmt.Sprintf("刷新ETA指标异常, indexCode: %s, err: %s", v.IndexCode, e.Error()))
|
|
|
+ }
|
|
|
+
|
|
|
+ // 已经加入到指标库的话,那么就去更新ETA指标库吧
|
|
|
+ if edbInfo != nil {
|
|
|
+ go logic.RefreshBaseEdbInfo(edbInfo, ``)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
br.Msg = "数据刷新成功"
|
|
|
br.Success = true
|
|
|
br.Ret = 200
|
|
@@ -345,6 +382,38 @@ func (this *ShanghaiSmmController) RefreshExcel() {
|
|
|
}
|
|
|
// 不修改
|
|
|
fmt.Println(len(updateDataList))
|
|
|
+ var messages []string
|
|
|
+ defer func() {
|
|
|
+ if len(messages) > 0 {
|
|
|
+ errMsg := strings.Join(messages, ",")
|
|
|
+ utils.FileLog.Info("SMM RefreshExcel errMsg: %s", errMsg)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ for _, v := range updateDataList {
|
|
|
+ itemInfo, err := models.GetSmmIndexInfoMaxAndMinInfo(v.IndexCode)
|
|
|
+ if err == nil && itemInfo != nil {
|
|
|
+ e := models.ModifySmmIndexMaxAndMinInfo(v.IndexCode, itemInfo)
|
|
|
+ if e != nil {
|
|
|
+ messages = append(messages, fmt.Sprintf("更新指标最大最小值失败, indexCode: %s, err: %s", v.IndexCode, e.Error()))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 同步刷新ETA图库有色的指标
|
|
|
+ {
|
|
|
+ // 获取指标详情
|
|
|
+ edbInfo, e := models.GetEdbInfoByEdbCode(utils.DATA_SOURCE_YS, v.IndexCode)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ messages = append(messages, fmt.Sprintf("刷新ETA指标异常, indexCode: %s, err: %s", v.IndexCode, e.Error()))
|
|
|
+ }
|
|
|
+
|
|
|
+ // 已经加入到指标库的话,那么就去更新ETA指标库吧
|
|
|
+ if edbInfo != nil {
|
|
|
+ go logic.RefreshBaseEdbInfo(edbInfo, ``)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
// if len(updateDataList) > 0 {
|
|
|
// err = models.UpdateBaseFromSmmDataListByIndexCode(updateDataList)
|
|
|
// if err != nil {
|