瀏覽代碼

新建

master
huangjiajun 10 月之前
父節點
當前提交
0bc07e4b76
共有 5 個文件被更改,包括 33 次插入5 次删除
  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 查看文件

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

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

}

+ 2
- 1
app/task/md/cron_key.go 查看文件

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

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 查看文件

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

func DataCollectCronHaodankuRealNews() {
func DataCollectCronHaodankuRealNews(types int) {
key := md.ZhiosRealNewsData
//es.CreateIndexIfNotExists(key, md.ZhiosRealNewsDataField)
ids := []int{10001, 10002, 10003, 10004}
num := 10
if types == 0 {
ids = []int{0}
num = 3
}
size := 100
now := time.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_secret := sysCfgDb.SysCfgGetOneData("third_zm_app_secret")
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), "")
if err != nil {
return


+ 1
- 1
app/task/task_data_collect_cron_haodanku_real_news.go 查看文件

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

+ 21
- 0
app/task/task_data_collect_cron_haodanku_real_news10.go 查看文件

@@ -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…
取消
儲存