Bladeren bron

根据comeintime 定时任务,不再等待业主分类结束信号

wcc 1 jaar geleden
bovenliggende
commit
d13e989edd
2 gewijzigde bestanden met toevoegingen van 9 en 6 verwijderingen
  1. 3 3
      src/config.json
  2. 6 3
      src/task/task.go

+ 3 - 3
src/config.json

@@ -6,8 +6,8 @@
     "dbname_dis": "classfication",
     "dbinfo": {
     	"bidding":{
-			"username": "dataAnyWrite",
-   			"password": "data@dataAnyWrite"
+			"username": "root",
+   			"password": "root"
 		},
         "userkey":{
             "username": "jianyu",
@@ -114,7 +114,7 @@
     },
     "yonghuhangye": {
         "name": "用户行业分类",
-        "taskid": "641c34903d7382f00e3ec755"
+        "taskid": "64268577e18de3c9fefa600b"
     },
     "biaoqian":{
         "name": "标签分类",

+ 6 - 3
src/task/task.go

@@ -522,7 +522,7 @@ OVER:
 			}
 			//上一轮任务执行完毕再走下一轮(上一轮任务执行完毕的标志是业主分类执行完)
 			//util.Debug("ControlTaskRun---", tools.ControlTaskRun, "AllTaskFinish---", tools.AllTaskFinish)
-			if !tools.ControlTaskRun { //线下环境不控制定时任务
+			if !tools.ControlTaskRun || tt.S_querycon == "0" { //线下环境不控制定时任务;或者线上通过时间定时执行
 				newtaskrun(tt)
 			} else if tools.ControlTaskRun && tools.AllTaskFinish { //线上控制
 				tools.AllTaskFinish = false
@@ -586,7 +586,9 @@ func NewTaskRunAll(tt *TTask, budp bool, mapInfo map[string]interface{}) int {
 		//有结果表有关联字段,在结果表上根据关联字段更新;有结果表没有关联字段,在结果表根据_id段更新
 		//没有结果表在查询表上更新
 		//log.Println("lastid:", tt.LastId, "查询方式:", tt.S_querycon, "时间:", tt.S_starttime, "条件:", tt.S_query, "table:", tt.S_table, "s_timefieldname:", tt.S_timefieldname)
+		sort := ""
 		if !budp { //非udp查询条件
+			sort = "_id"
 			if tt.S_query != "" { //有查询条件
 				json.Unmarshal([]byte(strings.Replace(tt.S_query, "'", "\"", -1)), &q)
 			}
@@ -674,6 +676,7 @@ func NewTaskRunAll(tt *TTask, budp bool, mapInfo map[string]interface{}) int {
 				}
 			}
 		} else { //udp查询条件
+			sort = "-_id"
 			if tt.S_query != "" { //有查询条件
 				json.Unmarshal([]byte(strings.Replace(tt.S_query, "'", "\"", -1)), &q)
 			}
@@ -700,7 +703,7 @@ func NewTaskRunAll(tt *TTask, budp bool, mapInfo map[string]interface{}) int {
 			log.Println("select:", tt.Task_QueryFieldMap, tt.Task_QueryFieldArr)
 		}
 
-		extractquery := tasksess.DB(tt.S_mgodb).C(tt.S_coll).Find(q).Select(tt.Task_QueryFieldMap).Sort("_id").Iter()
+		extractquery := tasksess.DB(tt.S_mgodb).C(tt.S_coll).Find(q).Select(tt.Task_QueryFieldMap).Sort(sort).Iter()
 		arr := [][]map[string]interface{}{}
 		if tt.I_wordcount == 1 {
 			tt.WordCount = map[string]map[string]int{}
@@ -881,7 +884,7 @@ func NewTaskRunAll(tt *TTask, budp bool, mapInfo map[string]interface{}) int {
 				//}
 			}(tmp)
 			ttid := u.BsonIdToSId(tid)
-			if ttid > tt.LastId {
+			if ttid > tt.LastId && !budp {
 				tt.LastId = ttid
 			}
 			tmp = make(map[string]interface{})