|
@@ -5,7 +5,6 @@ import (
|
|
"log"
|
|
"log"
|
|
"strconv"
|
|
"strconv"
|
|
"strings"
|
|
"strings"
|
|
- "sync"
|
|
|
|
"time"
|
|
"time"
|
|
|
|
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
@@ -99,120 +98,86 @@ func DistributeClueShow(this *biservice.DistributeClueShowReq, allocationCap int
|
|
clueArrs1 := []string{}
|
|
clueArrs1 := []string{}
|
|
clueArrs1 = strings.Split(this.ClueIdList, ",")
|
|
clueArrs1 = strings.Split(this.ClueIdList, ",")
|
|
logx.Info("clueArrs1 ", clueArrs1)
|
|
logx.Info("clueArrs1 ", clueArrs1)
|
|
- if len(clueArrs1) > 0 {
|
|
|
|
- sql3 := `SELECT cluename,COUNT(*) AS count FROM dwd_f_crm_clue_info WHERE id in (` + strings.Join(clueArrs1, ",") + `) GROUP BY cluename ORDER BY count desc`
|
|
|
|
- logx.Info("sql3 ", sql3) //从大到小排列这一列线索名称分组及数量情况
|
|
|
|
- cdata := JyBiTidb.SelectBySql(sql3)
|
|
|
|
- if cdata != nil && len(*cdata) > 0 {
|
|
|
|
- for _, v := range *cdata {
|
|
|
|
- count := common.IntAll(v["count"])
|
|
|
|
- cluename := common.ObjToString(v["cluename"])
|
|
|
|
- minCount, minIndex := int64(0), -1
|
|
|
|
- isindexok := false
|
|
|
|
- k1 := 0
|
|
|
|
- for _, r := range rdata {
|
|
|
|
- if !r.FullStatus {
|
|
|
|
- if this.DataType == 1 {
|
|
|
|
- if k1 == 0 {
|
|
|
|
- minCount = r.CompanyCounts
|
|
|
|
- break
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- if r.CompanyCounts < r.CompanyCount {
|
|
|
|
- minCount = r.CompanyCounts
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- for _, r := range rdata {
|
|
|
|
- if !r.FullStatus {
|
|
|
|
- if this.DataType == 1 {
|
|
|
|
- if r.CompanyCounts < minCount {
|
|
|
|
- minCount = r.CompanyCounts
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- if r.CompanyCounts < minCount && r.CompanyCounts < r.CompanyCount {
|
|
|
|
- minCount = r.CompanyCounts
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ for _, v := range strings.Split(this.ClueIdList, ",") {
|
|
|
|
+ count := 1
|
|
|
|
+ id := v
|
|
|
|
+ minCount, minIndex := int64(0), -1
|
|
|
|
+ isindexok := false
|
|
|
|
+ k1 := 0
|
|
|
|
+ for _, r := range rdata {
|
|
|
|
+ if !r.FullStatus {
|
|
|
|
+ if this.DataType == 1 {
|
|
|
|
+ if k1 == 0 {
|
|
|
|
+ minCount = r.CompanyCounts
|
|
|
|
+ break
|
|
}
|
|
}
|
|
- }
|
|
|
|
- for k, r := range rdata {
|
|
|
|
- countNumber := r.ExistingCount + r.ClueCount + int64(count)
|
|
|
|
- if this.DataType == 1 {
|
|
|
|
- if countNumber <= allocationCap {
|
|
|
|
- if r.CompanyCounts <= minCount {
|
|
|
|
- minCount = r.CompanyCounts
|
|
|
|
- minIndex = k
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- if countNumber <= allocationCap {
|
|
|
|
- if r.CompanyCounts <= minCount && r.CompanyCounts < r.CompanyCount {
|
|
|
|
- minCount = r.CompanyCounts
|
|
|
|
- minIndex = k
|
|
|
|
- }
|
|
|
|
- } /* else {
|
|
|
|
- if this.DataType == 2 {
|
|
|
|
- if r.CompanyCounts <= minCount && r.CompanyCounts < r.CompanyCount && this.UpdatePositionID == r.PositionId {
|
|
|
|
- return &biservice.DistributeClueShowResp{
|
|
|
|
- ErrorCode: 1,
|
|
|
|
- ErrorMsg: "超出私海线索上限",
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }*/
|
|
|
|
|
|
+ } else {
|
|
|
|
+ if r.CompanyCounts < r.CompanyCount {
|
|
|
|
+ minCount = r.CompanyCounts
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if minIndex == -1 {
|
|
|
|
- continue
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for _, r := range rdata {
|
|
|
|
+ if !r.FullStatus {
|
|
if this.DataType == 1 {
|
|
if this.DataType == 1 {
|
|
- countNumber := rdata[minIndex].ExistingCount + rdata[minIndex].ClueCount + int64(count)
|
|
|
|
- if countNumber == allocationCap {
|
|
|
|
- rdata[minIndex].FullStatus = true
|
|
|
|
|
|
+ if r.CompanyCounts < minCount {
|
|
|
|
+ minCount = r.CompanyCounts
|
|
}
|
|
}
|
|
- rdata[minIndex].CompanyCount++
|
|
|
|
- rdata[minIndex].CompanyCounts++
|
|
|
|
- rdata[minIndex].ClueCount += int64(count)
|
|
|
|
} else {
|
|
} else {
|
|
- countNumber := rdata[minIndex].ExistingCount + rdata[minIndex].ClueCount + int64(count)
|
|
|
|
- if rdata[minIndex].CompanyCounts < rdata[minIndex].CompanyCount {
|
|
|
|
- isindexok = true
|
|
|
|
- rdata[minIndex].CompanyCounts++
|
|
|
|
- rdata[minIndex].ClueCount += int64(count)
|
|
|
|
- if countNumber == allocationCap {
|
|
|
|
- rdata[minIndex].FullStatus = true
|
|
|
|
- }
|
|
|
|
|
|
+ if r.CompanyCounts < minCount && r.CompanyCounts < r.CompanyCount {
|
|
|
|
+ minCount = r.CompanyCounts
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- if this.DataType == 3 && isindexok {
|
|
|
|
- iddata := JyBiTidb.SelectBySql(`SELECT id FROM dwd_f_crm_clue_info WHERE cluename = "` + cluename + `" and id in (` + strings.Join(clueArrs1, ",") + `) ORDER BY createtime DESC LIMIT ` + gconv.String(count))
|
|
|
|
- if iddata != nil { //分线索
|
|
|
|
- wg := new(sync.WaitGroup)
|
|
|
|
- ch := make(chan bool, 10)
|
|
|
|
- for _, i := range *iddata {
|
|
|
|
- wg.Add(1)
|
|
|
|
- ch <- true
|
|
|
|
- go func(i map[string]interface{}) {
|
|
|
|
- defer func() {
|
|
|
|
- wg.Done()
|
|
|
|
- <-ch
|
|
|
|
- }()
|
|
|
|
- id := common.Int64All(i["id"])
|
|
|
|
- dclue(id, rdata[minIndex].PositionId, this.IsTask, this.PositionId)
|
|
|
|
- log.Println("3333", id, rdata[minIndex].PositionId)
|
|
|
|
- }(i)
|
|
|
|
- }
|
|
|
|
- wg.Wait()
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for k, r := range rdata {
|
|
|
|
+ countNumber := r.ExistingCount + r.ClueCount + int64(count)
|
|
|
|
+ if this.DataType == 1 {
|
|
|
|
+ if countNumber <= allocationCap {
|
|
|
|
+ if r.CompanyCounts <= minCount {
|
|
|
|
+ minCount = r.CompanyCounts
|
|
|
|
+ minIndex = k
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ if countNumber <= allocationCap {
|
|
|
|
+ if r.CompanyCounts <= minCount && r.CompanyCounts < r.CompanyCount {
|
|
|
|
+ minCount = r.CompanyCounts
|
|
|
|
+ minIndex = k
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if minIndex == -1 {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ if this.DataType == 1 {
|
|
|
|
+ countNumber := rdata[minIndex].ExistingCount + rdata[minIndex].ClueCount + int64(count)
|
|
|
|
+ if countNumber == allocationCap {
|
|
|
|
+ rdata[minIndex].FullStatus = true
|
|
|
|
+ }
|
|
|
|
+ rdata[minIndex].CompanyCount++
|
|
|
|
+ rdata[minIndex].CompanyCounts++
|
|
|
|
+ rdata[minIndex].ClueCount += int64(count)
|
|
|
|
+ } else {
|
|
|
|
+ countNumber := rdata[minIndex].ExistingCount + rdata[minIndex].ClueCount + int64(count)
|
|
|
|
+ if rdata[minIndex].CompanyCounts < rdata[minIndex].CompanyCount {
|
|
|
|
+ isindexok = true
|
|
|
|
+ rdata[minIndex].CompanyCounts++
|
|
|
|
+ rdata[minIndex].ClueCount += int64(count)
|
|
|
|
+ if countNumber == allocationCap {
|
|
|
|
+ rdata[minIndex].FullStatus = true
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if this.DataType == 3 && isindexok {
|
|
|
|
+ dclue(gconv.Int64(id), rdata[minIndex].PositionId, this.IsTask, this.PositionId)
|
|
|
|
+ log.Println("3333", id, rdata[minIndex].PositionId)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- if this.DataType == 2 {
|
|
|
|
|
|
+ /*if this.DataType == 2 {
|
|
for _, v := range rdata {
|
|
for _, v := range rdata {
|
|
if this.UpdatePositionID == v.PositionId {
|
|
if this.UpdatePositionID == v.PositionId {
|
|
if v.CompanyCounts < v.CompanyCount {
|
|
if v.CompanyCounts < v.CompanyCount {
|
|
@@ -223,7 +188,7 @@ func DistributeClueShow(this *biservice.DistributeClueShowReq, allocationCap int
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
return &biservice.DistributeClueShowResp{
|
|
return &biservice.DistributeClueShowResp{
|
|
ErrorCode: 0,
|
|
ErrorCode: 0,
|
|
Data: rdata,
|
|
Data: rdata,
|