소스 검색

新建

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
}

불러오는 중...
취소
저장