|
@@ -56,7 +56,6 @@ func ClueImportTtSync(this *biservice.ClueImportReq) (string, int) {
|
|
|
<-ch
|
|
|
}()
|
|
|
v["isCompetitors"] = "否"
|
|
|
- details := ""
|
|
|
id := common.ObjToString(v["id"])
|
|
|
href := common.ObjToString(v["href"])
|
|
|
for _, vv := range strings.Split(competitors, ",") {
|
|
@@ -64,39 +63,16 @@ func ClueImportTtSync(this *biservice.ClueImportReq) (string, int) {
|
|
|
v["isCompetitors"] = "是"
|
|
|
}
|
|
|
}
|
|
|
+ delete(v, "temp_id")
|
|
|
delete(v, "import_pc")
|
|
|
delete(v, "projectId")
|
|
|
- customer_data := BiService.FindOne("customer_data_ttzl", map[string]interface{}{"id": id}, "", "")
|
|
|
+ id_new := common.GetMd5String(fmt.Sprintf("%s_%s", common.ObjToString(v["id"]), common.ObjToString(v["multipackage_id"])))
|
|
|
+ v["id_new"] = id_new
|
|
|
+ customer_data := BiService.FindOne("customer_data_ttzl", map[string]interface{}{"id_new": id_new}, "", "")
|
|
|
if customer_data != nil {
|
|
|
log.Println("数据重复", id)
|
|
|
- msg_id := common.Int64All((*customer_data)["msg_id"])
|
|
|
- bok := BiService.Update("customer_data_ttzl", map[string]interface{}{"msg_id": msg_id}, v)
|
|
|
- if bok {
|
|
|
- //
|
|
|
- biddingData, ok := Bidding.FindOne("bidding", map[string]interface{}{"_id": mongodb.StringTOBsonId(id)})
|
|
|
- if ok && biddingData != nil && len(*biddingData) > 0 {
|
|
|
- details = common.ObjToString((*biddingData)["detail"])
|
|
|
- }
|
|
|
- //
|
|
|
- delete(v, "isCompetitors")
|
|
|
- delete(v, "msg_id")
|
|
|
- v["_id"] = v["id"]
|
|
|
- delete(v, "id")
|
|
|
- v["details"] = cleanHTML(details)
|
|
|
- if common.ObjToString(v["publishtime"]) != "" {
|
|
|
- v["publishtime2"] = common.ObjToString(v["publishtime"])
|
|
|
- publishtime, _ := time.ParseInLocation(date.Date_Full_Layout, common.ObjToString(v["publishtime"]), time.Local)
|
|
|
- v["publishtime"] = publishtime.UnixMilli()
|
|
|
- } else {
|
|
|
- delete(v, "publishtime")
|
|
|
- }
|
|
|
- for k, vv := range v {
|
|
|
- if vv == nil {
|
|
|
- delete(v, k)
|
|
|
- }
|
|
|
- }
|
|
|
- oks := Es.UpdateNewDoc("ttbid", "ttbid", v)
|
|
|
- if oks {
|
|
|
+ if BiService.Update("customer_data_ttzl", map[string]interface{}{"msg_id": common.Int64All((*customer_data)["msg_id"])}, v) {
|
|
|
+ if _, nv := getEsV(id, v); Es.UpdateNewDoc("ttbid", "ttbid", nv) {
|
|
|
counts++
|
|
|
log.Println("es更新成功", id)
|
|
|
} else {
|
|
@@ -106,34 +82,11 @@ func ClueImportTtSync(this *biservice.ClueImportReq) (string, int) {
|
|
|
log.Println("tidb更新失败!!", id)
|
|
|
}
|
|
|
} else {
|
|
|
- dataId := BiService.Insert("customer_data_ttzl", v)
|
|
|
- if dataId > 0 {
|
|
|
- //
|
|
|
- biddingData, ok := Bidding.FindOne("bidding", map[string]interface{}{"_id": mongodb.StringTOBsonId(id)})
|
|
|
- if ok && biddingData != nil && len(*biddingData) > 0 {
|
|
|
- details = common.ObjToString((*biddingData)["detail"])
|
|
|
- }
|
|
|
+ if dataId := BiService.Insert("customer_data_ttzl", v); dataId > 0 {
|
|
|
+ details, nv := getEsV(id, v)
|
|
|
//
|
|
|
BiService.Insert("customer_data_ttzl_gl", map[string]interface{}{"msg_id": dataId, "info_id": id, "details": details, "isHistory": "否"})
|
|
|
- delete(v, "isCompetitors")
|
|
|
- delete(v, "msg_id")
|
|
|
- v["_id"] = v["id"]
|
|
|
- delete(v, "id")
|
|
|
- v["details"] = cleanHTML(details)
|
|
|
- if common.ObjToString(v["publishtime"]) != "" {
|
|
|
- v["publishtime2"] = common.ObjToString(v["publishtime"])
|
|
|
- publishtime, _ := time.ParseInLocation(date.Date_Full_Layout, common.ObjToString(v["publishtime"]), time.Local)
|
|
|
- v["publishtime"] = publishtime.UnixMilli()
|
|
|
- } else {
|
|
|
- delete(v, "publishtime")
|
|
|
- }
|
|
|
- for k, vv := range v {
|
|
|
- if vv == nil {
|
|
|
- delete(v, k)
|
|
|
- }
|
|
|
- }
|
|
|
- oks := Es.Save("ttbid", "ttbid", v)
|
|
|
- if oks {
|
|
|
+ if Es.Save("ttbid", "ttbid", nv) {
|
|
|
counts++
|
|
|
log.Println("es存入成功", id)
|
|
|
} else {
|
|
@@ -162,6 +115,33 @@ func ClueImportTtSync(this *biservice.ClueImportReq) (string, int) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+func getEsV(id string, v map[string]interface{}) (string, map[string]interface{}) {
|
|
|
+ details := ""
|
|
|
+ biddingData, ok := Bidding.FindOne("bidding", map[string]interface{}{"_id": mongodb.StringTOBsonId(id)})
|
|
|
+ if ok && biddingData != nil && len(*biddingData) > 0 {
|
|
|
+ details = common.ObjToString((*biddingData)["detail"])
|
|
|
+ }
|
|
|
+ delete(v, "isCompetitors")
|
|
|
+ delete(v, "msg_id")
|
|
|
+ v["_id"] = v["id_new"]
|
|
|
+ delete(v, "id")
|
|
|
+ delete(v, "id_new")
|
|
|
+ v["details"] = cleanHTML(details)
|
|
|
+ if common.ObjToString(v["publishtime"]) != "" {
|
|
|
+ v["publishtime2"] = common.ObjToString(v["publishtime"])
|
|
|
+ publishtime, _ := time.ParseInLocation(date.Date_Full_Layout, common.ObjToString(v["publishtime"]), time.Local)
|
|
|
+ v["publishtime"] = publishtime.UnixMilli()
|
|
|
+ } else {
|
|
|
+ delete(v, "publishtime")
|
|
|
+ }
|
|
|
+ for k, vv := range v {
|
|
|
+ if vv == nil {
|
|
|
+ delete(v, k)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return details, v
|
|
|
+}
|
|
|
+
|
|
|
func cleanHTML(htmlString string) string {
|
|
|
// 清理HTML标签
|
|
|
htmlRegex := regexp.MustCompile("<[^>]*>")
|