Jianghan hai 1 ano
pai
achega
26065ab020
Modificáronse 1 ficheiros con 16 adicións e 14 borrados
  1. 16 14
      CMPlatform/service/data_ent.go

+ 16 - 14
CMPlatform/service/data_ent.go

@@ -123,7 +123,7 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
 		}
 		ch <- true
 		wg.Add(1)
-		go func(cells []*xlsx.Cell) {
+		go func(cells []*xlsx.Cell, importDataNum *int) {
 			defer func() {
 				<-ch
 				wg.Done()
@@ -202,9 +202,7 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
 			if tmp["infoid"] == nil {
 				return
 			}
-			numLock.Lock()
-			importDataNum++
-			numLock.Unlock()
+			*importDataNum++
 			if common.ObjToString(tmp["href"]) == "#" || strings.Contains(common.ObjToString(tmp["href"]), "jianyu360.cn") {
 				tmp["isCompetitors"] = "是"
 			} else {
@@ -234,7 +232,7 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
 				detail := detailFuc(common.ObjToString(tmp["infoid"]))
 				esSaveFuc(tmp, detail, &saveEsArr)
 			}
-		}(row.Cells)
+		}(row.Cells, &importDataNum)
 	}
 	wg.Wait()
 	if len(saveEsArr) > 0 {
@@ -335,23 +333,27 @@ func (e *EntData) DelData() {
 
 // 正文信息
 func detailFuc(infoid string) string {
-	binfo := util.EntMysql.FindOne("customer_data_yys_gl", bson.M{"info_id": infoid}, "", "")
-	if binfo != nil && len(*binfo) > 0 {
-		return common.ObjToString((*binfo)["ES_detail"])
-	}
+	//binfo := util.EntMysql.FindOne("customer_data_yys_gl", bson.M{"info_id": infoid}, "", "")
+	//if binfo != nil && len(*binfo) > 0 {
+	//	return common.ObjToString((*binfo)["ES_detail"])
+	//}
 	info, _ := util.MgoBidding.FindById("bidding", infoid, bson.M{"detail": 1, "contenthtml": 1})
 	if info != nil && len(*info) == 0 {
 		info, _ = util.MgoBidding.FindById("bidding_back", infoid, bson.M{"detail": 1, "contenthtml": 1})
 	}
+	save, detail := make(map[string]interface{}), ""
 	if info != nil && len(*info) > 0 {
-		save := make(map[string]interface{})
 		save["info_id"] = infoid
 		save["ES_detail"] = (*info)["detail"]
-		save["details"] = (*info)["contenthtml"]
-		util.EntMysql.Insert("customer_data_yys_gl", save)
-		return common.ObjToString((*info)["detail"])
+		detail = common.ObjToString((*info)["contenthtml"])
+		save["details"] = detail
 	}
-	return ""
+	go func() {
+		if util.EntMysql.Count("customer_data_yys_gl", bson.M{"info_id": infoid}) == 0 {
+			util.EntMysql.Insert("customer_data_yys_gl", save)
+		}
+	}()
+	return detail
 }
 
 func esSaveFuc(tmp map[string]interface{}, detail string, saveEsArr *[]map[string]interface{}) {