Prechádzať zdrojové kódy

更新分类程序,支持二阶字段

wcc 1 rok pred
rodič
commit
6cb5d9b872
2 zmenil súbory, kde vykonal 12 pridanie a 4 odobranie
  1. 2 4
      src/task/task.go
  2. 10 0
      src/task/updatetask.go

+ 2 - 4
src/task/task.go

@@ -659,7 +659,7 @@ func NewTaskRunAll(tt *TTask, budp bool, mapInfo map[string]interface{}) int {
 							}
 						}
 						//按id查询,为了保证有新数据入库,每次休息2分钟
-						time.Sleep(time.Second * 60)
+						//time.Sleep(time.Second * 60)
 						//测试环境q的赋值执行下述代码
 						//if tt.LastId != "" && q["_id"] == nil {
 						//	q["_id"] = map[string]interface{}{
@@ -773,9 +773,8 @@ func NewTaskRunAll(tt *TTask, budp bool, mapInfo map[string]interface{}) int {
 						if strings.Contains(tt.S_name, "招标分类") || tt.S_name == "招标分类" {
 							//1.一级分类时,符合结果中成交规则时
 							//todo  如果没有打上分类,调用ai 模型分类
-							if _, ok := SMap.Map["toptype"]; !ok || util.ObjToString(SMap.Map["toptype"]) == "其它" {
+							if _, ok := SMap.Map["toptype"]; !ok {
 								if util.ObjToString(tools.Config["aiurl"]) != "" {
-									now := time.Now()
 									data := map[string]interface{}{
 										"title":  tmp["title"],
 										"detail": tmp["detail"],
@@ -784,7 +783,6 @@ func NewTaskRunAll(tt *TTask, budp bool, mapInfo map[string]interface{}) int {
 										"texts": []interface{}{data},
 									}
 									rai := SendAi(reqData, util.ObjToString(tools.Config["aiurl"]))
-									log.Println("ai 分类时长", time.Since(now).Seconds())
 									if len(rai) > 0 {
 										resa := rai["result"]
 										if dataa, ok := resa.([]interface{}); ok {

+ 10 - 0
src/task/updatetask.go

@@ -275,6 +275,16 @@ func NewClassificationRun(tt *TTask, tmp map[string]interface{}) *tools.SortMap
 					if ok {
 						//strArr := tools.ObjArrToStringArr(strArr)
 						val = strings.Join(strArr, "")
+					} else if strings.Contains(f, ".") {
+						//有.,说明是个二级字段,比如gov_classify.zc_code
+						ffields := strings.Split(f, ".")
+						ffValue := tmp[ffields[0]]
+						if fffValue, ok2 := ffValue.(map[string]interface{}); ok2 {
+							key := ffields[1]
+							if ffffValue, ok3 := fffValue[key].(string); ok3 {
+								val = ffffValue
+							}
+						}
 					} else {
 						val = util.ObjToString(tmp[f]) //取识别内容
 					}