Parcourir la source

附件总长度限制 550000

wcc il y a 2 ans
Parent
commit
7ff1d4a8a6
1 fichiers modifiés avec 30 ajouts et 1 suppressions
  1. 30 1
      createEsIndex/bidding_es.go

+ 30 - 1
createEsIndex/bidding_es.go

@@ -18,6 +18,7 @@ import (
 	"strings"
 	"sync"
 	"time"
+	"unicode/utf8"
 )
 
 var (
@@ -135,6 +136,23 @@ func biddingTask(mapInfo map[string]interface{}) {
 	wg.Wait()
 	log.Info("biddingTask over", zap.Int("count", c1), zap.Int("index", index))
 
+	//发送udp,
+	//data := map[string]interface{}{
+	//	"stype": "update",
+	//	"gtid":  mongodb.StringTOBsonId(mapInfo["gtid"].(string)),
+	//	"lteid": mongodb.StringTOBsonId(mapInfo["lteid"].(string)),
+	//}
+	//target := &net.UDPAddr{
+	//	Port: 1782,
+	//	IP:   net.ParseIP("127.0.0.1"),
+	//}
+	//bytes, _ := json.Marshal(data)
+	//err := UdpClient.WriteUdp(bytes, udp.OP_TYPE_DATA, target)
+	//if err != nil {
+	//	log.Info("biddingTask ", zap.Any("WriteUdp err", err), zap.Any("target", target))
+	//}
+	//
+	//log.Info("biddingTask ", zap.Any("target", target))
 	// 重采平台需要
 	//mapInfo["stype"] = ""
 	//datas, _ := json.Marshal(mapInfo)
@@ -589,8 +607,19 @@ func getFileText(tmp map[string]interface{}) (filetext string) {
 					if resultMap, ok := result.(map[string]interface{}); resultMap != nil && ok {
 						if attach_url := util.ObjToString(resultMap["attach_url"]); attach_url != "" {
 							bs := oss.OssGetObject(attach_url, mongodb.BsonIdToSId(tmp["_id"])) //oss读数据
-							if len(bs) > 0 {
+							if utf8.RuneCountInString(filetext+bs) < 550000 {
 								filetext += bs + "\n"
+							} else {
+								if len(bs) > 50000 {
+									filetext += bs[0:50000]
+								} else {
+									filetext += bs
+								}
+
+							}
+							//附件总长度限制550000
+							if utf8.RuneCountInString(filetext) >= 550000 {
+								return
 							}
 
 							//正式环境