|
@@ -14,9 +14,10 @@ import (
|
|
|
)
|
|
|
|
|
|
var (
|
|
|
- BridgeApiPCSGBloombergDailyUrl = "/api/pcsg/bloomberg/daily_index" // 日度指标API
|
|
|
- BridgeApiPCSGBloombergWeeklyUrl = "/api/pcsg/bloomberg/weekly_index" // 周度指标API
|
|
|
- BridgeApiPCSGBloombergMonthlyUrl = "/api/pcsg/bloomberg/monthly_index" // 月度指标API
|
|
|
+ BridgeApiPCSGBloombergDailyUrl = "/api/pcsg/bloomberg/daily_index" // 日度指标API
|
|
|
+ BridgeApiPCSGBloombergWeeklyUrl = "/api/pcsg/bloomberg/weekly_index" // 周度指标API
|
|
|
+ BridgeApiPCSGBloombergMonthlyUrl = "/api/pcsg/bloomberg/monthly_index" // 月度指标API
|
|
|
+ BridgeApiPCSGBloombergDailyRun3Url = "/api/pcsg/bloomberg/daily_index_run3" // 月度指标API
|
|
|
)
|
|
|
|
|
|
// GetPCSGBloombergDailyFromBridge 获取彭博日度指标
|
|
@@ -199,8 +200,68 @@ func GetPCSGBloombergMonthlyFromBridge() (indexes []models.BaseFromBloombergApiI
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// GetPCSGBloombergDailyFromBridgeRun3 获取彭博日度指标
|
|
|
+func GetPCSGBloombergDailyFromBridgeRun3() (indexes []models.BaseFromBloombergApiIndexAndData, err error) {
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ tips := fmt.Sprintf("GetPCSGBloombergDailyFromBridgeRun3-获取彭博日度指标失败, err: %s", err.Error())
|
|
|
+ utils.FileLog.Info(tips)
|
|
|
+ go alarm_msg.SendAlarmMsg(tips, 3)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+
|
|
|
+ url := fmt.Sprint(utils.EtaBridgeUrl, BridgeApiPCSGBloombergDailyRun3Url)
|
|
|
+ body := ioutil.NopCloser(strings.NewReader(""))
|
|
|
+ client := &http.Client{}
|
|
|
+ req, e := http.NewRequest("POST", url, body)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("http create request err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ checkToken := utils.MD5(utils.EtaBridgeAppNameEn + utils.EtaBridgeMd5Key)
|
|
|
+ contentType := "application/json;charset=utf-8"
|
|
|
+ req.Header.Set("Content-Type", contentType)
|
|
|
+ req.Header.Set("Authorization", checkToken)
|
|
|
+ resp, e := client.Do(req)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("http client do err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer func() {
|
|
|
+ _ = resp.Body.Close()
|
|
|
+ }()
|
|
|
+ b, e := ioutil.ReadAll(resp.Body)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("resp body read err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(b) == 0 {
|
|
|
+ err = fmt.Errorf("resp body is empty")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 生产环境解密
|
|
|
+ if utils.RunMode == "release" {
|
|
|
+ str := string(b)
|
|
|
+ str = strings.Trim(str, `"`)
|
|
|
+ b = utils.DesBase64Decrypt([]byte(str), utils.EtaBridgeDesKey)
|
|
|
+ }
|
|
|
+
|
|
|
+ result := new(models.BridgePCSGBloombergResultData)
|
|
|
+ if e = json.Unmarshal(b, &result); e != nil {
|
|
|
+ err = fmt.Errorf("result unmarshal err: %s\nresult: %s", e.Error(), string(b))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if result.Code != 200 {
|
|
|
+ err = fmt.Errorf("result: %s", string(b))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ indexes = result.Data
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// PCSGWrite2BaseBloomberg 写入彭博数据源
|
|
|
-func PCSGWrite2BaseBloomberg(indexes []models.BaseFromBloombergApiIndexAndData) (err error) {
|
|
|
+func PCSGWrite2BaseBloomberg(indexes []models.BaseFromBloombergApiIndexAndData, isVCode bool) (err error) {
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
tips := fmt.Sprintf("PCSGWrite2BaseBloomberg-写入彭博数据源失败, err: %s", err.Error())
|
|
@@ -217,6 +278,9 @@ func PCSGWrite2BaseBloomberg(indexes []models.BaseFromBloombergApiIndexAndData)
|
|
|
if len(v.Data) == 0 {
|
|
|
continue
|
|
|
}
|
|
|
+ if isVCode {
|
|
|
+ v.IndexCode = utils.InsertStr2StrIdx(v.IndexCode, " ", 1, "V")
|
|
|
+ }
|
|
|
|
|
|
// 指标是否存在
|
|
|
index, e := models.GetBaseFromBloombergIndexByCode(v.IndexCode)
|