|
@@ -96,7 +96,6 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
|
|
|
now := time.Now()
|
|
|
importDataNum := 0
|
|
|
|
|
|
- var saveEsArr []map[string]interface{}
|
|
|
binary, _ := io.ReadAll(mf)
|
|
|
xls, _ := xlsx.OpenBinary(binary)
|
|
|
mField, _ := FiledFuc()
|
|
@@ -220,23 +219,20 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
|
|
|
//util.EsCus.DelById("bidding_customer", "", fmt.Sprint(id))
|
|
|
binfo := util.EntMysql.FindOne("customer_data_yys_gl", bson.M{"info_id": infoid}, "", "")
|
|
|
if binfo != nil && len(*binfo) > 0 {
|
|
|
- esSaveFuc(tmp, common.ObjToString((*binfo)["detail"]), &saveEsArr)
|
|
|
+ esSaveFuc(tmp, common.ObjToString((*binfo)["detail"]))
|
|
|
} else {
|
|
|
- esSaveFuc(tmp, "", &saveEsArr)
|
|
|
+ esSaveFuc(tmp, "")
|
|
|
}
|
|
|
} else {
|
|
|
log.Debug(tmp)
|
|
|
id := util.EntMysql.Insert("customer_data", tmp)
|
|
|
tmp["id"] = id
|
|
|
detail := detailFuc(common.ObjToString(tmp["infoid"]))
|
|
|
- esSaveFuc(tmp, detail, &saveEsArr)
|
|
|
+ esSaveFuc(tmp, detail)
|
|
|
}
|
|
|
}(row.Cells, &importDataNum)
|
|
|
}
|
|
|
wg.Wait()
|
|
|
- if len(saveEsArr) > 0 {
|
|
|
- util.BulkSave("bidding_customer", &saveEsArr, false, util.EsCus.(*elastic.EsV7))
|
|
|
- }
|
|
|
log.Debug("Load Excel Count:", importDataNum)
|
|
|
return importDataNum, now.Unix(), "文档导入成功"
|
|
|
}
|
|
@@ -355,7 +351,7 @@ func detailFuc(infoid string) string {
|
|
|
return detail
|
|
|
}
|
|
|
|
|
|
-func esSaveFuc(tmp map[string]interface{}, detail string, saveEsArr *[]map[string]interface{}) {
|
|
|
+func esSaveFuc(tmp map[string]interface{}, detail string) {
|
|
|
saveEs := make(map[string]interface{})
|
|
|
for _, f := range []string{"id", "tagname", "publishtime", "toptype", "subtype", "area", "city", "district", "title", "buyerclass",
|
|
|
"detail", "ent_id", "matchkey", "region", "industry", "winner_tag", "buyer", "budget", "s_winner", "bidamount", "pici"} {
|
|
@@ -390,9 +386,5 @@ func esSaveFuc(tmp map[string]interface{}, detail string, saveEsArr *[]map[strin
|
|
|
saveEs[f] = tmp[f]
|
|
|
}
|
|
|
}
|
|
|
- //*saveEsArr = append(*saveEsArr, saveEs)
|
|
|
- //if len(*saveEsArr) > 50 {
|
|
|
- // util.BulkSave("bidding_customer", saveEsArr, false, util.EsCus.(*elastic.EsV7))
|
|
|
- // saveEsArr = &[]map[string]interface{}{}
|
|
|
- //}
|
|
|
+ util.EsCus.Save("bidding_customer", "", saveEs)
|
|
|
}
|