Explorar el Código

新建

master
huangjiajun hace 10 meses
padre
commit
0bc07e4b76
Se han modificado 5 ficheros con 33 adiciones y 5 borrados
  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 Ver fichero

@@ -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 Ver fichero

@@ -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 Ver fichero

@@ -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 Ver fichero

@@ -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 Ver fichero

@@ -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
}

Cargando…
Cancelar
Guardar