Browse Source

新建

master
huangjiajun 10 months ago
parent
commit
0bc07e4b76
5 changed files with 33 additions and 5 deletions
  1. +2
    -1
      app/task/init.go
  2. +2
    -1
      app/task/md/cron_key.go
  3. +7
    -2
      app/task/svc/svc_data_collect_cron_haodanku_real_news.go
  4. +1
    -1
      app/task/task_data_collect_cron_haodanku_real_news.go
  5. +21
    -0
      app/task/task_data_collect_cron_haodanku_real_news10.go

+ 2
- 1
app/task/init.go View File

@@ -84,6 +84,7 @@ func doTask(fnName string) func() {
// 增加自动任务队列 // 增加自动任务队列
func initTasks() { func initTasks() {


jobs[taskMd.DataCollectCronHaodankuRealNews] = taskDataCollectCronHaodankuRealNews //
jobs[taskMd.DataCollectCronHaodankuRealNews] = taskDataCollectCronHaodankuRealNews //
jobs[taskMd.DataCollectCronHaodankuRealNews10] = taskDataCollectCronHaodankuRealNews10 //


} }

+ 2
- 1
app/task/md/cron_key.go View File

@@ -1,5 +1,6 @@
package md package md


const ( const (
DataCollectCronHaodankuRealNews = "data_collect_cron_haodanku_real_news"
DataCollectCronHaodankuRealNews = "data_collect_cron_haodanku_real_news"
DataCollectCronHaodankuRealNews10 = "data_collect_cron_haodanku_real_news10"
) )

+ 7
- 2
app/task/svc/svc_data_collect_cron_haodanku_real_news.go View File

@@ -15,10 +15,15 @@ import (
"time" "time"
) )


func DataCollectCronHaodankuRealNews() {
func DataCollectCronHaodankuRealNews(types int) {
key := md.ZhiosRealNewsData key := md.ZhiosRealNewsData
//es.CreateIndexIfNotExists(key, md.ZhiosRealNewsDataField) //es.CreateIndexIfNotExists(key, md.ZhiosRealNewsDataField)
ids := []int{10001, 10002, 10003, 10004} ids := []int{10001, 10002, 10003, 10004}
num := 10
if types == 0 {
ids = []int{0}
num = 3
}
size := 100 size := 100
now := time.Now() now := time.Now()
fmt.Println("============", time.Since(now)) fmt.Println("============", time.Since(now))
@@ -27,7 +32,7 @@ func DataCollectCronHaodankuRealNews() {
third_zm_app_key := sysCfgDb.SysCfgGetOneData("third_zm_app_key") third_zm_app_key := sysCfgDb.SysCfgGetOneData("third_zm_app_key")
third_zm_app_secret := sysCfgDb.SysCfgGetOneData("third_zm_app_secret") third_zm_app_secret := sysCfgDb.SysCfgGetOneData("third_zm_app_secret")
for _, v := range ids { for _, v := range ids {
for i := 1; i <= 10; i++ {
for i := 1; i <= num; i++ {
tianMaoChaoZhiData, err := haodanku.HaodankuRealTime(utils.IntToStr(v), utils.IntToStr(i), utils.IntToStr(size), "") tianMaoChaoZhiData, err := haodanku.HaodankuRealTime(utils.IntToStr(v), utils.IntToStr(i), utils.IntToStr(size), "")
if err != nil { if err != nil {
return return


+ 1
- 1
app/task/task_data_collect_cron_haodanku_real_news.go View File

@@ -16,6 +16,6 @@ func taskDataCollectCronHaodankuRealNews() {
} }
START: START:
ch <- 1 ch <- 1
svc.DataCollectCronHaodankuRealNews()
svc.DataCollectCronHaodankuRealNews(1)
<-ch <-ch
} }

+ 21
- 0
app/task/task_data_collect_cron_haodanku_real_news10.go View File

@@ -0,0 +1,21 @@
package task

import (
"applet/app/task/svc"
"math/rand"
"time"
)

func taskDataCollectCronHaodankuRealNews10() {
for {
if len(ch) > workerNum {
time.Sleep(time.Millisecond * time.Duration(rand.Intn(1000)))
} else {
goto START
}
}
START:
ch <- 1
svc.DataCollectCronHaodankuRealNews(0)
<-ch
}

Loading…
Cancel
Save