Browse Source

Merge branch 'master' of http://8.136.199.33:3000/hongze/hongze_data_crawler

xingzai 3 years ago
parent
commit
d530015194
2 changed files with 6 additions and 6 deletions
  1. 5 5
      services/commodity_trade_ine.go
  2. 1 1
      services/task.go

+ 5 - 5
services/commodity_trade_ine.go

@@ -43,10 +43,10 @@ type message struct {
 var ineIndexCode string
 var ineIndexCodeMap = make(map[string]string)
 
-func IneIndexCodeGenerator(indexName string) string {
+func IneIndexCodeGenerator(indexName,suffix  string) string {
 	ineIndexCode,_ := ineIndexCodeMap[indexName]
 	if ineIndexCode == "" {
-		ineIndexCode = fmt.Sprintf("INE%s", time.Now().Format(utils.FormatDateTimeUnSpace)+strconv.Itoa(utils.GetRandInt(1, 100)))
+		ineIndexCode = fmt.Sprintf("INE%s", time.Now().Format(utils.FormatDateTimeUnSpace)+strconv.Itoa(utils.GetRandInt(1, 100))+suffix)
 		ineIndexCodeMap[indexName] = ineIndexCode
 		err := models.AddBaseFromTradeMapping(indexName, ineIndexCode, "INE")
 		if err != nil {
@@ -107,9 +107,9 @@ func SyncRankingFromIne() {
 				item.DealName = strings.Replace(fmt.Sprintf("%s", p.ParticipantName1+"_成交量"+"_"+p.ProductName+"_"+p.ContractCode), " ", "", -1)
 				item.BuyName = strings.Replace(fmt.Sprintf("%s", p.ParticipantName2+"_持买单量"+"_"+p.ProductName+"_"+p.ContractCode), " ", "", -1)
 				item.SoldName = strings.Replace(fmt.Sprintf("%s", p.ParticipantName3+"_持卖单量"+"_"+p.ProductName+"_"+p.ContractCode), " ", "", -1)
-				item.DealCode = IneIndexCodeGenerator(item.DealName)
-				item.BuyCode = IneIndexCodeGenerator(item.BuyName)
-				item.SoldCode = IneIndexCodeGenerator(item.SoldName)
+				item.DealCode = IneIndexCodeGenerator(item.DealName, "deal")
+				item.BuyCode = IneIndexCodeGenerator(item.BuyName, "buy")
+				item.SoldCode = IneIndexCodeGenerator(item.SoldName, "sold")
 				item.DealValue = p.Deal
 				item.DealChange = p.Change1
 				item.BuyValue = p.BuyIn

+ 1 - 1
services/task.go

@@ -10,7 +10,7 @@ func Task() {
 	//SyncRankingFromZhengzhou()
 
 	//SyncRankingFromShangHai()
-	//SyncRankingFromIne()
+	SyncRankingFromIne()
 	//SyncRankingFromCffex()
 
 	SyncRankingFromDalianDo()