فهرست منبع

更新分类,支持没有 查询条件,直接从起始ID 查询

wcc 1 سال پیش
والد
کامیت
272b266475
3فایلهای تغییر یافته به همراه52 افزوده شده و 37 حذف شده
  1. 43 30
      src/task/task.go
  2. 8 6
      src/task/updatetask.go
  3. 1 1
      src/web/task.go

+ 43 - 30
src/task/task.go

@@ -619,7 +619,11 @@ func NewTaskRunAll(tt *TTask, budp bool, mapInfo map[string]interface{}) int {
 				if tt.S_querycon == "1" { //id查询
 					if tt.S_query != "" {
 						//页面上配置了查询条件,直接使用,不再单独查询上次任务结束ID
-
+						if tt.LastId != "" && q["_id"] == nil {
+							q["_id"] = map[string]interface{}{
+								"$gt": u.StringTOBsonId(tt.LastId),
+							}
+						}
 					} else {
 						//临时修改查询id区间段
 						comeintime := time.Now().Unix() - 5*60
@@ -637,22 +641,25 @@ func NewTaskRunAll(tt *TTask, budp bool, mapInfo map[string]interface{}) int {
 						}
 						if tt.LastId != "" && q["_id"] == nil {
 							sid := tt.LastId
-							if eId <= sid || eId == "" {
-								return
-							}
 							q["_id"] = map[string]interface{}{
-								"$gt":  u.StringTOBsonId(sid),
-								"$lte": u.StringTOBsonId(eId),
+								"$gt": u.StringTOBsonId(sid),
+							}
+
+							if eId != "" {
+								q["_id"] = map[string]interface{}{
+									"$gt":  u.StringTOBsonId(sid),
+									"$lte": u.StringTOBsonId(eId),
+								}
 							}
 						}
 						//按id查询,为了保证有新数据入库,每次休息2分钟
 						time.Sleep(time.Second * 60)
 						//测试环境q的赋值执行下述代码
-						if tt.LastId != "" && q["_id"] == nil {
-							q["_id"] = map[string]interface{}{
-								"$gt": u.StringTOBsonId(tt.LastId),
-							}
-						}
+						//if tt.LastId != "" && q["_id"] == nil {
+						//	q["_id"] = map[string]interface{}{
+						//		"$gt": u.StringTOBsonId(tt.LastId),
+						//	}
+						//}
 					}
 
 				} else { //时间查询
@@ -694,7 +701,7 @@ func NewTaskRunAll(tt *TTask, budp bool, mapInfo map[string]interface{}) int {
 		for tmp := make(map[string]interface{}); extractquery.Next(&tmp); sum++ {
 			tid := tmp["_id"]
 			if !timespan && sum%2000 == 0 {
-				log.Println("current:", sum)
+				log.Println("current:", sum, tt.S_name)
 			}
 			pool <- true
 			wg.Add(1)
@@ -752,12 +759,14 @@ func NewTaskRunAll(tt *TTask, budp bool, mapInfo map[string]interface{}) int {
 						SMap = NewClassificationRun(tt, tmp)
 						//一级分类时,符合结果中成交规则时
 						if SMap.Map["toptype"] == "招标" && SMap.Map["subtype"] != "单一" {
-							if u.ChargeDetailResult(tmp["detail"].(string)) {
-								SMap.Map["toptype"] = "结果"
-								resa := ReSub(tt, tmp, "结果")
-								subtype := resa.Map["subtype"]
-								delete(SMap.Map, "subtype")
-								SMap.Map["subtype"] = subtype
+							if _, ok := tmp["detail"]; ok {
+								if u.ChargeDetailResult(util.ObjToString(tmp["detail"])) {
+									SMap.Map["toptype"] = "结果"
+									resa := ReSub(tt, tmp, "结果")
+									subtype := resa.Map["subtype"]
+									delete(SMap.Map, "subtype")
+									SMap.Map["subtype"] = subtype
+								}
 							}
 						}
 						//一级分类是预告,但是标题含有招标计划,同时含有 预公告|预公示,变为 采购意向
@@ -1114,12 +1123,14 @@ func UdpTaskRunAll(tt *TTask, budp bool, mapInfo map[string]interface{}, stype s
 							SMap = NewClassificationRun(tt, result)
 							//一级分类时,符合结果中成交规则时
 							if SMap.Map["toptype"] == "招标" && SMap.Map["subtype"] != "单一" {
-								if u.ChargeDetailResult(tmp["detail"].(string)) {
-									SMap.Map["toptype"] = "结果"
-									resa := ReSub(tt, tmp, "结果")
-									subtype := resa.Map["subtype"]
-									delete(SMap.Map, "subtype")
-									SMap.Map["subtype"] = subtype
+								if _, ok := tmp["detail"]; ok {
+									if u.ChargeDetailResult(util.ObjToString(tmp["detail"])) {
+										SMap.Map["toptype"] = "结果"
+										resa := ReSub(tt, tmp, "结果")
+										subtype := resa.Map["subtype"]
+										delete(SMap.Map, "subtype")
+										SMap.Map["subtype"] = subtype
+									}
 								}
 							}
 						}
@@ -1583,12 +1594,14 @@ func StartTask(t *TTask) {
 				if len(SMap.Map) > 0 {
 					//一级分类时,符合结果中成交规则时
 					if SMap.Map["toptype"] == "招标" && SMap.Map["subtype"] != "单一" {
-						if u.ChargeDetailResult(tmp["detail"].(string)) {
-							SMap.Map["toptype"] = "结果"
-							resa := ReSub(t, tmp, "结果")
-							subtype := resa.Map["subtype"]
-							delete(SMap.Map, "subtype")
-							SMap.Map["subtype"] = subtype
+						if _, ok := tmp["detail"]; ok {
+							if u.ChargeDetailResult(util.ObjToString(tmp["detail"])) {
+								SMap.Map["toptype"] = "结果"
+								resa := ReSub(t, tmp, "结果")
+								subtype := resa.Map["subtype"]
+								delete(SMap.Map, "subtype")
+								SMap.Map["subtype"] = subtype
+							}
 						}
 					}
 					update = append(update, map[string]interface{}{"$set": SMap.Map})

+ 8 - 6
src/task/updatetask.go

@@ -1033,12 +1033,14 @@ func LoadUpdateTask(_id, s_mgourl, s_mgodb, s_coll, i_poolsize, s_esurl, s_esdb,
 					SMap = NewClassificationRun(tt, tmp)
 					//一级分类时,符合结果中成交规则时
 					if SMap.Map["toptype"] == "招标" && SMap.Map["subtype"] != "单一" {
-						if u.ChargeDetailResult(tmp["detail"].(string)) {
-							SMap.Map["toptype"] = "结果"
-							resa := ReSub(tt, tmp, "结果")
-							subtype := resa.Map["subtype"]
-							delete(SMap.Map, "subtype")
-							SMap.Map["subtype"] = subtype
+						if _, ok := tmp["detail"]; ok {
+							if u.ChargeDetailResult(util.ObjToString(tmp["detail"])) {
+								SMap.Map["toptype"] = "结果"
+								resa := ReSub(tt, tmp, "结果")
+								subtype := resa.Map["subtype"]
+								delete(SMap.Map, "subtype")
+								SMap.Map["subtype"] = subtype
+							}
 						}
 					}
 				}

+ 1 - 1
src/web/task.go

@@ -17,7 +17,7 @@ func Main(w http.ResponseWriter, r *http.Request) {
 		ss, _ := Store.Get(r, SN)
 		data := map[string]interface{}{"s_name": ss.Values["s_name"]}
 		//查询配置规则
-		res, _ := MgoClass.Find(COLL_TASK, nil, `{"l_lasttime":-1}`, nil, false, 0, 200)
+		res, _ := MgoClass.Find(COLL_TASK, nil, `{"_id":-1}`, nil, false, 0, 200)
 		for _, r := range *res {
 			if r["s_starttime"] == nil || r["s_starttime"] == int64(0) {
 				r["s_starttime"] = ""