Parcourir la source

Merge branch 'feature/v4.7.61' of http://192.168.3.207:8080/qmx/jy into feature/v4.7.61

zhangyuhan il y a 2 ans
Parent
commit
5db5fff561
4 fichiers modifiés avec 44 ajouts et 22 suppressions
  1. 4 1
      src/config.json
  2. 11 11
      src/jfw/front/front.go
  3. 5 2
      src/jfw/front/supsearch.go
  4. 24 8
      src/jfw/front/websocket.go

+ 4 - 1
src/config.json

@@ -384,6 +384,9 @@
 	"messageCenter": {
 		"appid": "10000",
         "dbName": "messagetest",
-        "interval": 300
+        "interval": 300,
+        "createtime": "2023-01-04 00:00:00",
+        "limitDay": 7,
+        "limitCount": 3
     }
 }

+ 11 - 11
src/jfw/front/front.go

@@ -443,13 +443,13 @@ func (f *Front) Topics() error {
 	userId, _ := f.GetSession("userId").(string)
 	f.DisableHttpCache()
 	//底部最新招标数据  3*6 条信息
-	news := PCS_list("", 18, userId).([]interface{}) //Newbids("")[0].([]interface{})
+	news := PCS_list("", 18, userId) //Newbids("")[0].([]interface{})
 	listAll := [][]map[string]interface{}{}
 	i := 1
 	list := []map[string]interface{}{}
 	now := time.Now().Unix()
-	for _, v := range news {
-		if data, ok := v.(map[string]interface{}); ok {
+	if news != nil {
+		for _, data := range news {
 			if data["publishtime"] == nil && data["time"] != nil {
 				continue
 			}
@@ -463,14 +463,14 @@ func (f *Front) Topics() error {
 			data["index"] = i
 			i++
 			list = append(list, data)
-		}
-		if len(list) >= 6 {
-			listAll = append(listAll, list)
-			list = []map[string]interface{}{}
-			i = 1
-		}
-		if len(listAll) >= 3 {
-			break
+			if len(list) >= 6 {
+				listAll = append(listAll, list)
+				list = []map[string]interface{}{}
+				i = 1
+			}
+			if len(listAll) >= 3 {
+				break
+			}
 		}
 	}
 	f.T["list"] = listAll

+ 5 - 2
src/jfw/front/supsearch.go

@@ -94,7 +94,7 @@ func PCS_task() {
 }
 
 // 返回内存中列表也的数据,只获取首页,其他页面访问量暂时不多
-func PCS_list(page_type string, pageSize int, userId string) interface{} {
+func PCS_list(page_type string, pageSize int, userId string) []map[string]interface{} {
 	/*var _page_type = page_type
 	  //如果page_type为空,则是获取非拟建数据。
 	  if page_type == "" {
@@ -105,9 +105,12 @@ func PCS_list(page_type string, pageSize int, userId string) interface{} {
 	  if PCS_index[_page_type] == nil {
 	  	PCS_index[_page_type] = Newbids(page_type)[0]
 	  }*/
+	if pageSize == 0 {
+		pageSize = 50
+	}
 	newbid := Newbids(page_type, userId)
 	if len(newbid) > 0 {
-		return newbid[0:50]
+		return newbid[0:pageSize]
 	} else {
 		return nil
 	}

+ 24 - 8
src/jfw/front/websocket.go

@@ -330,7 +330,9 @@ func GetBuoyMsg(conn *websocket.Conn) {
 	messageCenter, _ := Sysconfig["messageCenter"].(map[string]interface{})
 	appid, _ := messageCenter["appid"].(string)
 	dbName, _ := messageCenter["dbName"].(string)
+	createtime := qutil.ObjToString(messageCenter["createtime"])
 	interval := qutil.IntAllDef(messageCenter["interval"], 300)
+	limitCount := qutil.IntAllDef(messageCenter["limitCount"], 3)
 	go func() {
 		defer qutil.Catch()
 		for {
@@ -349,15 +351,29 @@ func GetBuoyMsg(conn *websocket.Conn) {
 	}()
 	//发送消息
 	for {
-		reply := `{}`
-		list := public.BaseMysql.SelectBySql(`select id,title,link,content,show_content from `+dbName+`.message where receive_userid=? and isdel=1 and appid=? and isRead=0 and show_buoy=1 order by createtime desc limit 1`, userid, appid)
-		if list != nil && len(*list) == 1 {
-			reply = fmt.Sprintf(`{"id":%d,"title":"%s","content":"%s","show_content":"%s","link":"%s"}`, qutil.Int64All((*list)[0]["id"]), qutil.ObjToString((*list)[0]["title"]), qutil.ObjToString((*list)[0]["content"]), qutil.ObjToString((*list)[0]["show_content"]), strings.Split(qutil.ObjToString((*list)[0]["link"]), ",")[0])
+		timeA := time.Now().AddDate(0, 0, -qutil.IntAllDef(messageCenter["limitDay"], 7))
+		timeB, err := time.ParseInLocation(qutil.Date_Full_Layout, createtime, time.Local)
+		if err == nil && timeA.After(timeB) {
+			createtime = qutil.FormatDate(&timeA, qutil.Date_Full_Layout)
 		}
-		if err := websocket.Message.Send(conn, reply); err != nil {
-			//log.Println("websocket发送失败!", err)
-			conn.Close()
-			return
+		list := public.BaseMysql.SelectBySql(`select id,title,link,content,show_content,pc_tip from `+dbName+`.message where receive_userid=? and isdel=1 and appid=? and isRead=0 and createtime>? order by createtime desc limit ?`, userid, appid, createtime, limitCount)
+		if list != nil {
+			for _, v := range *list {
+				if qutil.IntAll(v["pc_tip"]) == 1 {
+					continue
+				}
+				id := qutil.Int64All(v["id"])
+				reply := fmt.Sprintf(`{"id":%d,"title":"%s","content":"%s","show_content":"%s","link":"%s"}`, id, qutil.ObjToString(v["title"]), qutil.ObjToString(v["content"]), qutil.ObjToString(v["show_content"]), strings.Split(qutil.ObjToString(v["link"]), ",")[0])
+				if err := websocket.Message.Send(conn, reply); err != nil {
+					//log.Println("websocket发送失败!", err)
+					conn.Close()
+					return
+				}
+				if id > 0 {
+					public.BaseMysql.UpdateOrDeleteBySql(`update `+dbName+`.message set pc_tip=1 where id=?`, id)
+				}
+				time.Sleep(time.Second)
+			}
 		}
 		time.Sleep(time.Duration(interval) * time.Second)
 	}