瀏覽代碼

Merge branch 'pool/2022-11-22_report'

Roc 2 年之前
父節點
當前提交
bcc8151dc8
共有 2 個文件被更改,包括 47 次插入4 次删除
  1. 4 4
      services/company/permission.go
  2. 43 0
      services/report_push.go

+ 4 - 4
services/company/permission.go

@@ -962,7 +962,7 @@ func GetBindFiccPermissions(user user.UserInfo) (ret response.BindPermissionFicc
 	}
 	for _, v := range permissionFirstList {
 		permissionFirstMap[v.ClassifyName] = &response.BindPermissionFiccItem{
-			Id:          int(v.Id),
+			Id:           int(v.Id),
 			ClassifyName: v.YbIndexName,
 		}
 	}
@@ -1055,7 +1055,7 @@ func GetCommoditiesBindFiccPermissions(user user.UserInfo) (ret response.BindPer
 	}
 	for _, v := range permissionFirstList {
 		permissionFirstMap[v.ClassifyName] = &response.BindPermissionFiccItem{
-			Id:          int(v.Id),
+			Id:           int(v.Id),
 			ClassifyName: v.YbIndexName,
 		}
 	}
@@ -1092,9 +1092,9 @@ LOOP:
 			if temp.ClassifyName == "化工" {
 				count := 0
 				for i, secondItem := range temp.List {
-					if secondItem.ChartPermissionName == "PTA" || secondItem.ChartPermissionName == "MEG"{
+					if secondItem.ChartPermissionName == "PTA" || secondItem.ChartPermissionName == "MEG" {
 						count++
-						secondItem.ChartPermissionName = "PTA&MEG"
+						secondItem.ChartPermissionName = "PTA/MEG"
 						if count > 1 {
 							temp.List = append(temp.List[:i], temp.List[i+1:]...)
 						}

+ 43 - 0
services/report_push.go

@@ -14,6 +14,7 @@ import (
 	"io/ioutil"
 	"net/http"
 	"net/url"
+	"strings"
 	"time"
 )
 
@@ -44,6 +45,36 @@ var permissionMap map[string]string = map[string]string{
 	"黑色百家谈":     "钢材,铁矿,双焦(焦煤、焦炭)",
 }
 
+// permissionLabelMap 品种与同花顺标签的映射关系
+var permissionLabelMap = map[string]string{
+	"宏观经济":      "宏观",
+	"利率债":       "利率债",
+	"原油":        "原油",
+	"PTA":       "PTA",
+	"MEG":       "MEG",
+	"织造终端":      "织造终端",
+	"甲醇":        "甲醇",
+	"聚烯烃":       "聚烯烃",
+	"沥青":        "沥青",
+	"纯苯+苯乙烯":    "纯苯+苯乙烯",
+	"玻璃纯碱":      "玻璃纯碱",
+	"钢材":        "钢材",
+	"铁矿":        "铁矿",
+	"双焦(焦煤、焦炭)": "双焦(焦煤、焦炭)",
+	"有色(锌)":     "有色(锌)",
+	"有色(铜、铝)":   "有色(铜、铝)",
+	"镍+不锈钢":     "镍+不锈钢",
+	"PVC":       "PVC",
+	"聚酯":        "聚酯",
+	"钴锂":        "钴锂",
+	"策略":        "策略",
+	"苯乙烯":       "纯苯+苯乙烯",
+	"锌":         "有色(锌)",
+	"双焦":        "双焦(焦煤、焦炭)",
+	"铜/铝":       "有色(铜、铝)",
+	"镍/不锈钢":     "镍+不锈钢",
+}
+
 // TshResult 同花顺返回信息
 type TshResult struct {
 	ErrorCode int    `json:"error" description:"错误状态码"`
@@ -102,12 +133,24 @@ func SendThs(title, labelStr, abstract, jumpBaseUrl, logoUrl, dataType string) (
 		return
 	}
 
+	// 关联后的标签数据
+	newLabelList := make([]string, 0)
+	labelList := strings.Split(labelStr, ",")
+	for _, v := range labelList {
+		tmpLabel, ok := permissionLabelMap[v] //判断是否在关联标签里面
+		if !ok {                              //如果不在关联标签里面,那么就把原始的值赋值给
+			tmpLabel = v
+		}
+		newLabelList = append(newLabelList, tmpLabel)
+	}
+	labelStr = strings.Join(newLabelList, ",")
 	global.LOG.Info(fmt.Sprintf("labelStr:%s", labelStr))
 	label, err := gorsa.PublicEncrypt(labelStr, pubKey)
 	if err != nil {
 		return
 	}
 
+	// 跳转地址
 	jumpUrl, err := gorsa.PublicEncrypt(jumpBaseUrl, pubKey)
 	if err != nil {
 		return