|
@@ -162,7 +162,7 @@ func (service *DeduplicationService) DataDeduplicateByAccountId(data *deduplicat
|
|
|
tableName := PREFIX + fmt.Sprintf("%03d", number%100)
|
|
|
|
|
|
// 查询
|
|
|
- var rs entity.Deduplication
|
|
|
+ //var rs entity.Deduplication
|
|
|
var tmpList []string
|
|
|
var valueList []interface{}
|
|
|
var selectSql string
|
|
@@ -175,12 +175,12 @@ func (service *DeduplicationService) DataDeduplicateByAccountId(data *deduplicat
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+ var rs []*entity.Deduplication
|
|
|
selectSql = fmt.Sprintf("account_id=? and data_desc=? and info_id in (%s)", strings.Join(tmpList, ","))
|
|
|
infoIdList := strings.Split(data.InfoId, ",")
|
|
|
totalInfoCount := len(infoIdList)
|
|
|
- count, err := orm.Table(tableName).Where(selectSql, valueList...).Count(rs)
|
|
|
- log.Println(count, "已存在数据量")
|
|
|
+ err := orm.Table(tableName).Cols("info_id").Where(selectSql, valueList...).Find(&rs)
|
|
|
+
|
|
|
if err != nil {
|
|
|
log.Println(err, "判重查询失败")
|
|
|
return &deduplication.Info{
|
|
@@ -190,7 +190,16 @@ func (service *DeduplicationService) DataDeduplicateByAccountId(data *deduplicat
|
|
|
IsInsert: false,
|
|
|
}, "判重查询失败"
|
|
|
}
|
|
|
-
|
|
|
+ existInfoIdMap := map[string]bool{}
|
|
|
+ existIdList := []string{}
|
|
|
+ for _, v := range rs {
|
|
|
+ if existInfoIdMap[v.InfoId] {
|
|
|
+ continue
|
|
|
+ }else {
|
|
|
+ existIdList = append(existIdList,v.InfoId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ count := int64(len(existIdList))
|
|
|
return &deduplication.Info{
|
|
|
TotalCount: int64(totalInfoCount),
|
|
|
ExistCount: count,
|
|
@@ -235,8 +244,17 @@ func (service *DeduplicationService) DataDeduplicateAndSave(data *deduplication.
|
|
|
infoIdList := strings.Split(data.InfoId, ",")
|
|
|
totalInfoCount := len(infoIdList)
|
|
|
err := orm.Table(tableName).Cols("info_id").Where(selectSql, valueList...).Find(&rs)
|
|
|
- totalExist := len(rs)
|
|
|
- log.Println(totalExist, "已存在数据量")
|
|
|
+ existInfoIdMap := map[string]bool{}
|
|
|
+ existIdList := []string{}
|
|
|
+ for _, v := range rs {
|
|
|
+ if existInfoIdMap[v.InfoId] {
|
|
|
+ continue
|
|
|
+ }else {
|
|
|
+ existIdList = append(existIdList,v.InfoId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ count := len(existIdList)
|
|
|
+ log.Println(count, "已存在数据量")
|
|
|
if err != nil {
|
|
|
log.Println(err, "判重查询失败")
|
|
|
return &deduplication.Info{
|
|
@@ -277,8 +295,8 @@ func (service *DeduplicationService) DataDeduplicateAndSave(data *deduplication.
|
|
|
log.Println(err3, "新增数据失败")
|
|
|
return &deduplication.Info{
|
|
|
TotalCount: int64(totalInfoCount),
|
|
|
- ExistCount: int64(totalExist),
|
|
|
- NewCount: int64(totalInfoCount - totalExist),
|
|
|
+ ExistCount: int64(count),
|
|
|
+ NewCount: int64(totalInfoCount - count),
|
|
|
}, "新增数据失败"
|
|
|
}
|
|
|
}
|
|
@@ -290,8 +308,8 @@ func (service *DeduplicationService) DataDeduplicateAndSave(data *deduplication.
|
|
|
log.Println(err3, "新增数据失败")
|
|
|
return &deduplication.Info{
|
|
|
TotalCount: int64(totalInfoCount),
|
|
|
- ExistCount: int64(totalExist),
|
|
|
- NewCount: int64(totalInfoCount - totalExist),
|
|
|
+ ExistCount: int64(count),
|
|
|
+ NewCount: int64(totalInfoCount - count),
|
|
|
}, "新增数据失败"
|
|
|
}
|
|
|
}
|
|
@@ -300,15 +318,16 @@ func (service *DeduplicationService) DataDeduplicateAndSave(data *deduplication.
|
|
|
log.Println("提交失败")
|
|
|
return &deduplication.Info{
|
|
|
TotalCount: int64(totalInfoCount),
|
|
|
- ExistCount: int64(totalExist),
|
|
|
- NewCount: int64(totalInfoCount - totalExist),
|
|
|
+ ExistCount: int64(count),
|
|
|
+ NewCount: int64(totalInfoCount - count),
|
|
|
}, "提交失败"
|
|
|
} else {
|
|
|
log.Println("提交成功")
|
|
|
+ log.Println(count,"2222",int64(count),int64(totalInfoCount - count))
|
|
|
return &deduplication.Info{
|
|
|
TotalCount: int64(totalInfoCount),
|
|
|
- ExistCount: int64(totalExist),
|
|
|
- NewCount: int64(totalInfoCount - totalExist),
|
|
|
+ ExistCount: int64(count),
|
|
|
+ NewCount: int64(totalInfoCount - count),
|
|
|
}, ""
|
|
|
|
|
|
}
|