Ver código fonte

工单分配调整

WH01243 1 mês atrás
pai
commit
bad7320716
4 arquivos alterados com 145 adições e 788 exclusões
  1. 116 6
      clueSync/go.mod
  2. 0 749
      clueSync/go.sum
  3. 26 29
      clueSync/jobutil.go
  4. 3 4
      clueSync/main.go

+ 116 - 6
clueSync/go.mod

@@ -1,21 +1,131 @@
 module clueSync
 
-go 1.14
+go 1.20
 
 require (
 	app.yhyue.com/moapp/jybase v0.0.0-20240912091212-401647f2624b
 	bp.jydev.jianyu360.cn/BaseService/pushpkg v0.0.0-20240917100248-b3a720df70c0
 	github.com/ClickHouse/clickhouse-go/v2 v2.2.0
-	github.com/go-xweb/httpsession v0.0.0-20141220075701-356d3b4d38d6 // indirect
-	github.com/go-xweb/log v0.0.0-20140701090824-270d183ad77e // indirect
-	github.com/go-xweb/uuid v0.0.0-20140604020037-d7dce341f851 // indirect
 	github.com/go-xweb/xweb v0.2.1
 	github.com/gogf/gf v1.16.9
 	github.com/gogf/gf/v2 v2.7.0
-	github.com/lunny/csession v0.0.0-20130910075847-fe53c5de3dfd // indirect
 	github.com/robfig/cron v1.2.0
-	github.com/robfig/cron/v3 v3.0.1
 	github.com/tealeg/xlsx v1.0.5
 	github.com/zeromicro/go-zero v1.5.2
 	gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
 )
+
+require (
+	app.yhyue.com/moapp/esv1 v0.0.0-20220414031211-3da4123e648d // indirect
+	bp.jydev.jianyu360.cn/BaseService/resourceCenter v0.1.0 // indirect
+	bp.jydev.jianyu360.cn/BaseService/userCenter v1.2.17 // indirect
+	github.com/beorn7/perks v1.0.1 // indirect
+	github.com/cenkalti/backoff/v4 v4.2.0 // indirect
+	github.com/cespare/xxhash/v2 v2.2.0 // indirect
+	github.com/coreos/go-semver v0.3.1 // indirect
+	github.com/coreos/go-systemd/v22 v22.5.0 // indirect
+	github.com/davecgh/go-spew v1.1.1 // indirect
+	github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
+	github.com/emicklei/go-restful/v3 v3.9.0 // indirect
+	github.com/fatih/color v1.15.0 // indirect
+	github.com/felixge/fgprof v0.9.3 // indirect
+	github.com/garyburd/redigo v1.6.2 // indirect
+	github.com/go-logr/logr v1.2.3 // indirect
+	github.com/go-logr/stdr v1.2.2 // indirect
+	github.com/go-openapi/jsonpointer v0.19.6 // indirect
+	github.com/go-openapi/jsonreference v0.20.1 // indirect
+	github.com/go-openapi/swag v0.22.3 // indirect
+	github.com/go-redis/redis/v8 v8.11.5 // indirect
+	github.com/go-sql-driver/mysql v1.7.0 // indirect
+	github.com/go-xweb/httpsession v0.0.0-20141220075701-356d3b4d38d6 // indirect
+	github.com/go-xweb/log v0.0.0-20140701090824-270d183ad77e // indirect
+	github.com/go-xweb/uuid v0.0.0-20140604020037-d7dce341f851 // indirect
+	github.com/gogo/protobuf v1.3.2 // indirect
+	github.com/golang/mock v1.6.0 // indirect
+	github.com/golang/protobuf v1.5.3 // indirect
+	github.com/golang/snappy v0.0.4 // indirect
+	github.com/gomodule/redigo v1.8.9 // indirect
+	github.com/google/gnostic v0.5.7-v3refs // indirect
+	github.com/google/go-cmp v0.5.9 // indirect
+	github.com/google/gofuzz v1.2.0 // indirect
+	github.com/google/pprof v0.0.0-20211214055906-6f57359322fd // indirect
+	github.com/google/uuid v1.3.0 // indirect
+	github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 // indirect
+	github.com/howeyc/fsnotify v0.9.0 // indirect
+	github.com/jinzhu/inflection v1.0.0 // indirect
+	github.com/jinzhu/now v1.1.1 // indirect
+	github.com/josharian/intern v1.0.0 // indirect
+	github.com/json-iterator/go v1.1.12 // indirect
+	github.com/klauspost/compress v1.15.15 // indirect
+	github.com/lunny/csession v0.0.0-20130910075847-fe53c5de3dfd // indirect
+	github.com/mailru/easyjson v0.7.7 // indirect
+	github.com/mattn/go-colorable v0.1.13 // indirect
+	github.com/mattn/go-isatty v0.0.17 // indirect
+	github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
+	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
+	github.com/modern-go/reflect2 v1.0.2 // indirect
+	github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
+	github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
+	github.com/olivere/elastic v6.2.37+incompatible // indirect
+	github.com/olivere/elastic/v7 v7.0.22 // indirect
+	github.com/openzipkin/zipkin-go v0.4.1 // indirect
+	github.com/paulmach/orb v0.7.1 // indirect
+	github.com/pelletier/go-toml/v2 v2.0.7 // indirect
+	github.com/pierrec/lz4/v4 v4.1.17 // indirect
+	github.com/pkg/errors v0.9.1 // indirect
+	github.com/prometheus/client_golang v1.15.0 // indirect
+	github.com/prometheus/client_model v0.3.0 // indirect
+	github.com/prometheus/common v0.42.0 // indirect
+	github.com/prometheus/procfs v0.9.0 // indirect
+	github.com/shopspring/decimal v1.3.1 // indirect
+	github.com/spaolacci/murmur3 v1.1.0 // indirect
+	github.com/xdg-go/pbkdf2 v1.0.0 // indirect
+	github.com/xdg-go/scram v1.1.1 // indirect
+	github.com/xdg-go/stringprep v1.0.3 // indirect
+	github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
+	go.etcd.io/etcd/api/v3 v3.5.8 // indirect
+	go.etcd.io/etcd/client/pkg/v3 v3.5.8 // indirect
+	go.etcd.io/etcd/client/v3 v3.5.8 // indirect
+	go.mongodb.org/mongo-driver v1.11.4 // indirect
+	go.opentelemetry.io/otel v1.14.0 // indirect
+	go.opentelemetry.io/otel/exporters/jaeger v1.14.0 // indirect
+	go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.14.0 // indirect
+	go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.14.0 // indirect
+	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.14.0 // indirect
+	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.14.0 // indirect
+	go.opentelemetry.io/otel/exporters/zipkin v1.14.0 // indirect
+	go.opentelemetry.io/otel/sdk v1.14.0 // indirect
+	go.opentelemetry.io/otel/trace v1.14.0 // indirect
+	go.opentelemetry.io/proto/otlp v0.19.0 // indirect
+	go.uber.org/atomic v1.10.0 // indirect
+	go.uber.org/automaxprocs v1.5.2 // indirect
+	go.uber.org/multierr v1.9.0 // indirect
+	go.uber.org/zap v1.24.0 // indirect
+	golang.org/x/crypto v0.14.0 // indirect
+	golang.org/x/net v0.17.0 // indirect
+	golang.org/x/oauth2 v0.6.0 // indirect
+	golang.org/x/sync v0.1.0 // indirect
+	golang.org/x/sys v0.13.0 // indirect
+	golang.org/x/term v0.13.0 // indirect
+	golang.org/x/text v0.13.0 // indirect
+	golang.org/x/time v0.3.0 // indirect
+	google.golang.org/appengine v1.6.7 // indirect
+	google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect
+	google.golang.org/grpc v1.55.0 // indirect
+	google.golang.org/protobuf v1.30.0 // indirect
+	gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
+	gopkg.in/inf.v0 v0.9.1 // indirect
+	gopkg.in/yaml.v2 v2.4.0 // indirect
+	gopkg.in/yaml.v3 v3.0.1 // indirect
+	gorm.io/driver/mysql v1.0.5 // indirect
+	gorm.io/gorm v1.21.3 // indirect
+	k8s.io/api v0.26.3 // indirect
+	k8s.io/apimachinery v0.27.0-alpha.3 // indirect
+	k8s.io/client-go v0.26.3 // indirect
+	k8s.io/klog/v2 v2.90.1 // indirect
+	k8s.io/kube-openapi v0.0.0-20230307230338-69ee2d25a840 // indirect
+	k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
+	sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
+	sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
+	sigs.k8s.io/yaml v1.3.0 // indirect
+)

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 749
clueSync/go.sum


+ 26 - 29
clueSync/jobutil.go

@@ -76,7 +76,7 @@ func WorkDataHandle(company, phone, demand, name, product string, acceptanceData
 	if cluename == "" {
 		cluename = phone //没有线索名,手机号代替
 	}
-	ok, data, saleData := false, map[string]interface{}{}, []map[string]interface{}{}
+	ok, data, saleData, isNewScore := false, map[string]interface{}{}, []map[string]interface{}{}, false
 	isGroup, isCommerce := GetCompanyType(cluename, uId)
 	uCount, _ := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"uid": uId}, "", ""), true //查当前线索是否已存在
 	if uCount != nil && len(*uCount) > 0 {
@@ -119,6 +119,7 @@ func WorkDataHandle(company, phone, demand, name, product string, acceptanceData
 		} else {
 			if positionId == 0 {
 				//线索变更
+				isNewScore = true
 				ok, data, saleData = FindPosition(0, "", gconv.String(acceptanceData["creator_time"]))
 				if !ok {
 					log.Println(positionId, "用户查询失败")
@@ -145,14 +146,15 @@ func WorkDataHandle(company, phone, demand, name, product string, acceptanceData
 		if !ok {
 			return false
 		}
+		isNewScore = true
 		SaveClue("", "", uId, "5", "169", "新增线索", "主动咨询客服留资客户", cluename, name, gconv.String(data["name"]), phone, "", "", "", "", "", "", gconv.String(data["seat_number"]), gconv.Int64(data["position_id"]), "", "", "", []string{}, "", isGroup, isCommerce, false, demand)
 	}
 	//工单生成
-	ok1 := AddOrderWork(acceptanceData, data, product, phone, company)
+	ok1 := AddOrderWork(acceptanceData, data, product, phone, company, isNewScore)
 	log.Println("工单创建", ok1, gconv.String(acceptanceData["acceptance_no"]))
 	return true
 }
-func AddOrderWork(acceptanceData map[string]interface{}, userData map[string]interface{}, product, phone, company string) bool {
+func AddOrderWork(acceptanceData map[string]interface{}, userData map[string]interface{}, product, phone, company string, isNewScore bool) bool {
 	nowTime := time.Now().Format(date.Date_Full_Layout)
 	work_order_no := fmt.Sprintf("GD%s%s", time.Now().Format(date.Date_yyyyMMdd), FindNumber("gd"))
 	productArr := []string{}
@@ -227,6 +229,19 @@ func AddOrderWork(acceptanceData map[string]interface{}, userData map[string]int
 			"update_time":         common.If(gconv.Int64(userData["orderStatus"]) == 0, nowTime, nil),
 		}
 		WorkOrder.Insert("approval_record", approvalRecordMap)
+		//工单分配记录添加
+		if isNewScore {
+			orderWorkAllocationRecord := map[string]interface{}{
+				"person_name":       userData["name"],
+				"position_id":       userData["position_id"],
+				"dept_name":         userData["deptName"],
+				"dept_id":           userData["deptId"],
+				"work_order_no":     work_order_no,
+				"create_time":       nowTime,
+				"company_dept_numb": common.If(gconv.String(userData["deptName"]) == "销售三部", 3, 1),
+			}
+			WorkOrder.Insert("order_work_allocation_record", orderWorkAllocationRecord)
+		}
 		WorkMail(personMap,
 			strings.Join(productArr, ","),
 			gconv.Int64(common.If(gconv.Int64(userData["orderStatus"]) == 0, 2, 1)),
@@ -322,7 +337,7 @@ func FindNumber(moudle string) string {
 
 // 人员查询
 func GetAllocation(proportion1, proportion3 float64, deptCount1, deptCount3 int64, administrators1, administrators3 map[string]interface{}, creatorTime string) map[string]interface{} {
-	log.Println("分配比例查询", proportion1, proportion3, deptCount1, deptCount3)
+	log.Println("分配比例查询", cfg.AllocationTime, cfg.AllocationRatio, proportion1, proportion3, deptCount1, deptCount3)
 	if deptCount1 == 0 {
 		return administrators1
 	}
@@ -456,37 +471,19 @@ FROM
 	}
 	//按照比例分配选择一部还是三部
 	//一部查询
-	deptCount1 := CalculateProportion(deptNameMap1)
+	deptCount1 := CalculateProportion(1)
 	//三部查询
-	deptCount3 := CalculateProportion(deptNameMap3)
+	deptCount3 := CalculateProportion(3)
 	return true, GetAllocation(proportion1, proportion3, deptCount1, deptCount3, administrators1, administrators3, creatorTime), allData
-	log.Println("电销信息获取失败", positionId)
-	return false, map[string]interface{}{}, allData
 }
 
-func CalculateProportion(deptNameMap map[string]interface{}) int64 {
-	deptNameStr := ""
-	for k := range deptNameMap {
-		if deptNameStr == "" {
-			deptNameStr = k
-		} else {
-			deptNameStr = fmt.Sprintf("%s,%s", deptNameStr, k)
-		}
-	}
-	if deptNameStr == "" {
-		return int64(0)
-	}
-	count := int64(0)
-	sql := fmt.Sprintf(`SELECT
+func CalculateProportion(deptNumb int64) int64 {
+	data := WorkOrder.SelectBySql(`SELECT
 	sum(1) as  count
 FROM
-	order_work a
-	INNER JOIN approval_record b ON a.creator_time >= "%s" 
-	AND FIND_IN_SET( a.department_no ,  "%s") 
-	AND a.work_order_no = b.work_order_no
-	and  (b.new_status!= 1 or  b.new_status   is null )
-	`, cfg.AllocationTime, deptNameStr)
-	data := WorkOrder.SelectBySql(sql)
+	order_work_allocation_record  where   create_time >? and   company_dept_numb=? )
+	`, cfg.AllocationTime, deptNumb)
+	count := int64(0)
 	if data != nil && len(*data) > 0 {
 		count = gconv.Int64((*data)[0]["count"])
 	}

+ 3 - 4
clueSync/main.go

@@ -7,11 +7,9 @@ import (
 	"app.yhyue.com/moapp/jybase/mongodb"
 	"app.yhyue.com/moapp/jybase/mysql"
 	"app.yhyue.com/moapp/jybase/redis"
-	"bp.jydev.jianyu360.cn/BaseService/pushpkg/p"
 	"flag"
 	"fmt"
 	"github.com/ClickHouse/clickhouse-go/v2/lib/driver"
-	"github.com/robfig/cron"
 	"log"
 )
 
@@ -159,7 +157,8 @@ func main() {
 	MgoQyxy = mongodb.NewMgoWithUser(db.MgoQyxy.Address, db.MgoQyxy.DbName, db.MgoQyxy.User, db.MgoQyxy.Password, db.MgoQyxy.DbSize)
 	InitArea()
 	InitProduct(db.ProductArr)
-	if *mode == 1 {
+	log.Println(FindPosition(0, "00", "2025-06-06"))
+	/*if *mode == 1 {
 		go ordersClue() //后台订单进线索
 		//一秒钟一次
 		go p.VarTimeTask.RunInSecondTimeLoop("1秒钟定时任务", "", "", db.CornExp8, true, true, nil, func() {
@@ -258,5 +257,5 @@ func main() {
 	} else {
 		users()
 		saleLeads()
-	}
+	}*/
 }

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff