xuzhiheng 1 سال پیش
والد
کامیت
d179523da0

+ 1 - 0
api/etc/biservice-api.yaml

@@ -115,5 +115,6 @@ Mail:
     User: "public03@topnet.net.cn"
 UpdateProjectUrl: "http://192.168.3.206:7778/updateProject"
 ExportDirectory: "D:/top_git_projects/biService"
+CommonExportDir: "D:/top_git_projects/biComFileRes"
 ExportUrl: "https://jybx-webtest.jydev.jianyu360.com/tietaRes"
 ExportCount: 15000

+ 2 - 2
api/internal/logic/sendmaillogic.go

@@ -25,7 +25,7 @@ func NewSendMailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendMail
 }
 
 func (l *SendMailLogic) SendMail(req *types.ExportByDbReq) (resp *types.BiResp, err error) {
-	res, err := l.svcCtx.BiServiceRpc.ExportDataByDb(l.ctx, &biservice.ExportByDbReq{
+	res, err := l.svcCtx.BiServiceRpc.SendMail(l.ctx, &biservice.ExportByDbReq{
 		Token:   req.Token,
 		Title:   req.Title,
 		Content: req.Content,
@@ -33,5 +33,5 @@ func (l *SendMailLogic) SendMail(req *types.ExportByDbReq) (resp *types.BiResp,
 		Query:   req.Query,
 		Stype:   req.Stype,
 	})
-	return &types.BiResp{Error_code: res.ErrorCode, Error_msg: res.ErrorMsg}, err
+	return &types.BiResp{Error_code: res.ErrorCode, Error_msg: res.ErrorMsg, Data: string(res.Data)}, err
 }

+ 5 - 1
entity/entity.go

@@ -53,7 +53,9 @@ var (
 	GmailAuth        []*mail.GmailAuth
 	UpdataProjectUrl string
 	ExportDirectory  string
+	ComFileDir       string
 	ExportUrl        string
+	ComFileUrl       string
 	ExportCount      int
 )
 
@@ -230,10 +232,12 @@ func (h *Handler) HandleMessage(m *nsq.Message) error {
 	}
 	return nil
 }
-func InitConfig(directory, projectUrl, exportUrl string, count int) {
+func InitConfig(directory, dir2, projectUrl, exportUrl, url1 string, count int) {
 	ExportDirectory = directory
+	ComFileDir = dir2
 	UpdataProjectUrl = projectUrl
 	ExportUrl = exportUrl
+	ComFileUrl = url1
 	ExportCount = count
 }
 

+ 1 - 1
go.mod

@@ -3,7 +3,7 @@ module bp.jydev.jianyu360.cn/BaseService/biService
 go 1.19
 
 require (
-	app.yhyue.com/moapp/jybase v0.0.0-20240104022202-158734833402
+	app.yhyue.com/moapp/jybase v0.0.0-20240205092729-2959d78b7619
 	bp.jydev.jianyu360.cn/BaseService/gateway v1.3.4
 	bp.jydev.jianyu360.cn/BaseService/resourceCenter v0.1.3
 	bp.jydev.jianyu360.cn/BaseService/userCenter v1.2.16

+ 9 - 0
go.sum

@@ -1,11 +1,14 @@
 app.yhyue.com/moapp/esv1 v0.0.0-20220414031211-3da4123e648d h1:WPsYuuptAd3UEgN+jPzpnsDe/OvcshDUUtOTZPYGSJ8=
 app.yhyue.com/moapp/esv1 v0.0.0-20220414031211-3da4123e648d/go.mod h1:91/lSD/hS+ckMVP3WdidRzDhC60lLMdyce9QHy0cSMA=
+app.yhyue.com/moapp/jyInfo v1.0.0/go.mod h1:+RjyGNvk7PT1P8cglkVlaj1lLlBXuPB+f5LipoOtgPs=
 app.yhyue.com/moapp/jybase v0.0.0-20220415064050-37ce64b3e2d4/go.mod h1:qNRA0sHuYqcLoYoP8irpaWnW9YsXixe6obBIkwaXpD0=
 app.yhyue.com/moapp/jybase v0.0.0-20220418104200-46c3fff161c7/go.mod h1:qNRA0sHuYqcLoYoP8irpaWnW9YsXixe6obBIkwaXpD0=
 app.yhyue.com/moapp/jybase v0.0.0-20220420032112-668025915ee4/go.mod h1:qNRA0sHuYqcLoYoP8irpaWnW9YsXixe6obBIkwaXpD0=
 app.yhyue.com/moapp/jybase v0.0.0-20220421060131-a1001013ba46/go.mod h1:qNRA0sHuYqcLoYoP8irpaWnW9YsXixe6obBIkwaXpD0=
 app.yhyue.com/moapp/jybase v0.0.0-20240104022202-158734833402 h1:EgfYh6hyIwM8kAaroplqfeBh/AC5LffeFKgMLDGm1BI=
 app.yhyue.com/moapp/jybase v0.0.0-20240104022202-158734833402/go.mod h1:fjaD11Z3FIk9EyfOpdKAMQNs7nPZCpT/qKIw1oVsb9w=
+app.yhyue.com/moapp/jybase v0.0.0-20240205092729-2959d78b7619 h1:rzjJ4pK1P+DcoOYA4+hCOJUoLdSInQa3EHsYY2DKWqA=
+app.yhyue.com/moapp/jybase v0.0.0-20240205092729-2959d78b7619/go.mod h1:fjaD11Z3FIk9EyfOpdKAMQNs7nPZCpT/qKIw1oVsb9w=
 bp.jydev.jianyu360.cn/BP/jynsq v0.0.0-20220222052708-ebc43af90698/go.mod h1:ojo/AUH9Yr1wzarEjOaNMkj1Cet/9r8IgLyba64Z52E=
 bp.jydev.jianyu360.cn/BaseService/gateway v0.0.0-20220419090715-88ddb32961be/go.mod h1:Yj4oabIGItuMoF0BXYLz2XAnF581kxgXBrvlUtIJrkI=
 bp.jydev.jianyu360.cn/BaseService/gateway v1.3.4 h1:zl5eZrKDBENVVBUiPpzyQQ0/SBdGUmZS3thXycSEO1g=
@@ -183,6 +186,7 @@ github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vb
 github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
 github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
 github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
+github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
 github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
 github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
 github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
@@ -258,6 +262,7 @@ github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE=
 github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
 github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
 github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
 github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
 github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
 github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
@@ -292,6 +297,7 @@ github.com/gomodule/redigo v1.8.9 h1:Sl3u+2BI/kk+VEatbj0scLdrFhjPmbxOc1myhDP41ws
 github.com/gomodule/redigo v1.8.9/go.mod h1:7ArFNvsTjH8GMMzB4uy1snslv2BwmginuMs06a1uzZE=
 github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
 github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
+github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA=
 github.com/google/gnostic v0.5.7-v3refs h1:FhTMOKj2VhjpouxvWJAV1TL304uMlb9zcDqkl6cEI54=
 github.com/google/gnostic v0.5.7-v3refs/go.mod h1:73MKFl6jIHelAJNaBGFzt3SPtZULs9dYrGFt8OiIsHQ=
 github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
@@ -332,6 +338,7 @@ github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
 github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
 github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
 github.com/googleapis/gnostic v0.4.1/go.mod h1:LRhVm6pbyptWbWbuZ38d1eyptfvIytN3ir6b65WBswg=
+github.com/googleapis/gnostic v0.5.5/go.mod h1:7+EbHbldMins07ALC74bsA81Ovc97DwqyJO1AENw9kA=
 github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
 github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
 github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
@@ -433,6 +440,7 @@ github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182aff
 github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
 github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
 github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
+github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c=
 github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -495,6 +503,7 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
+github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
 github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
 github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
 github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=

+ 1 - 1
rpc/biService.proto

@@ -211,5 +211,5 @@ service BiService {
 	rpc getCompanyType (CompanyReq) returns (CompanyResp); //判断公司类型
 	rpc distributeClueShow (DistributeClueShowReq) returns (DistributeClueShowResp); //批量分配展示
 	rpc exportDataByDb (ExportByDbReq) returns (BiReply); //数据导出(通用)
-
+	rpc sendMail (ExportByDbReq) returns (BiReply); //数据导出(通用)
 }

+ 1 - 1
rpc/biservice.go

@@ -38,7 +38,7 @@ func main() {
 	entity.InitEntEs(c.EntEs.Version, c.EntEs.Address, c.EntEs.UserName, c.EntEs.Password, c.EntEs.DbSize)
 	entity.InitArea()
 	entity.InitRedis(c.RedisAddress)
-	entity.InitConfig(c.ExportDirectory, c.UpdateProjectUrl, c.ExportUrl, c.ExportCount)
+	entity.InitConfig(c.ExportDirectory, c.ComFileDir, c.UpdateProjectUrl, c.ExportUrl, c.ComFileUrl, c.ExportCount)
 	//合力亿捷
 	entity.GetHlyj(c.Hlyj.Appid, c.Hlyj.Account, c.Hlyj.Secret, c.Hlyj.TokenUrl, c.Hlyj.CallUrl, c.Hlyj.Integratedid, c.Hlyj.CallFlag)
 	//nsq

+ 6 - 0
rpc/biservice/biservice.go

@@ -62,6 +62,7 @@ type (
 		GetCompanyType(ctx context.Context, in *CompanyReq, opts ...grpc.CallOption) (*CompanyResp, error)
 		DistributeClueShow(ctx context.Context, in *DistributeClueShowReq, opts ...grpc.CallOption) (*DistributeClueShowResp, error)
 		ExportDataByDb(ctx context.Context, in *ExportByDbReq, opts ...grpc.CallOption) (*BiReply, error)
+		SendMail(ctx context.Context, in *ExportByDbReq, opts ...grpc.CallOption) (*BiReply, error)
 	}
 
 	defaultBiService struct {
@@ -164,3 +165,8 @@ func (m *defaultBiService) ExportDataByDb(ctx context.Context, in *ExportByDbReq
 	client := pb.NewBiServiceClient(m.cli.Conn())
 	return client.ExportDataByDb(ctx, in, opts...)
 }
+
+func (m *defaultBiService) SendMail(ctx context.Context, in *ExportByDbReq, opts ...grpc.CallOption) (*BiReply, error) {
+	client := pb.NewBiServiceClient(m.cli.Conn())
+	return client.SendMail(ctx, in, opts...)
+}

+ 2 - 0
rpc/etc/biservice.yaml

@@ -121,5 +121,7 @@ Mail:
     User: "public03@topnet.net.cn"
 UpdateProjectUrl: "http://192.168.3.206:7778/updateProject"
 ExportDirectory: "D:/top_git_projects/biService"
+ComFileDir: "D:/top_git_projects/biComFileRes"
 ExportUrl: "https://jybx-webtest.jydev.jianyu360.com/tietaRes"
+ComFileUrl: "https://jybx-webtest.jydev.jianyu360.com/tietaRes"
 ExportCount: 15000

+ 2 - 0
rpc/internal/config/config.go

@@ -80,6 +80,8 @@ type Config struct {
 	}
 	UpdateProjectUrl string
 	ExportDirectory  string
+	ComFileDir       string
 	ExportCount      int
 	ExportUrl        string
+	ComFileUrl       string
 }

+ 14 - 0
rpc/internal/logic/T_test.go

@@ -0,0 +1,14 @@
+package logic
+
+import (
+	"fmt"
+	"testing"
+)
+
+func TokenTest(t *testing.T) {
+	content := "你好老师,这是导出的数据"
+	mail := "516807046@qq.com"
+	query := "select t1.全称 as FULL_NAME,t0.CREATE_TIME as CREATE_TIME,coalesce(t0.pv_resp_person,t0.ofv_resp_person,t0.onv_resp_person) as SFZ,coalesce(t0.pv_visitor,t0.ofv_visitor,t0.onv_visitor) as BFZ,coalesce(t0.pv_visit_time,t0.ofv_visit_time,t0.onv_visit_time) as BFSJ,t0.FOLLOW_STATUS as FOLLOW_STATUS,coalesce(t0.pv_next_follow_time,t0.ofv_next_follow_time,t0.onv_next_follow_time) as XCGJSJ,coalesce(t0.pv_content,t0.ofv_content,t0.onv_content) as NR from crm.follow_record t0 left join (select t0.id as ID,t1.full_name as 全称 from crm.task t0 left join crm.custom t1 on (t0.source_id=t1.id) where (t0.source=3)) t1 on (t0.task_id=t1.ID) where (t0.CREATE_TIME>=str_to_date('2024-02-01','%Y-%m-%d') and t0.CREATE_TIME<str_to_date('2024-02-02','%Y-%m-%d') AND t0.CREATE_PERSON IN ('孙振杰','陈瑞文','朱凤超')) order by coalesce(t0.pv_visit_time,t0.ofv_visit_time,t0.onv_visit_time) desc limit 6"
+	title := "数据导出"
+	RsaEncrypt([]byte(fmt.Sprintf("%s&%s&%s&%s", content, mail, query, title)))
+}

+ 5 - 44
rpc/internal/logic/exportdatabydblogic.go

@@ -1,17 +1,12 @@
 package logic
 
 import (
-	"bp.jydev.jianyu360.cn/BaseService/biService/entity"
+	"context"
+
 	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/internal/svc"
 	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/pb"
-	"bp.jydev.jianyu360.cn/BaseService/biService/service"
-	"context"
-	"encoding/base64"
-	"fmt"
-	"github.com/gogf/gf/v2/util/gconv"
-	"github.com/tjfoc/gmsm/sm4"
+
 	"github.com/zeromicro/go-zero/core/logx"
-	"regexp"
 )
 
 type ExportDataByDbLogic struct {
@@ -28,42 +23,8 @@ func NewExportDataByDbLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ex
 	}
 }
 
-var reg1 = regexp.MustCompile("(?i)(insert|delete|update|master|truncate|declare|exec|alter|use)\\s")
-var reg2 = regexp.MustCompile("(?i)(select|from)\\s")
-
 func (l *ExportDataByDbLogic) ExportDataByDb(in *pb.ExportByDbReq) (*pb.BiReply, error) {
+	// todo: add your logic here and delete this line
 
-	if reg1.MatchString(in.Query) && !reg2.MatchString(in.Query) {
-		return &pb.BiReply{
-			ErrorCode: 1,
-			ErrorMsg:  "查询语句不合法",
-			Data:      nil,
-		}, nil
-	}
-	if RsaEncrypt([]byte(fmt.Sprintf("%s&%s&%s&%s", gconv.String(in.Content), gconv.String(in.Mails), gconv.String(in.Query), gconv.String(in.Title)))) == in.Token {
-		return &pb.BiReply{
-			ErrorCode: 1,
-			ErrorMsg:  "token验证不通过",
-			Data:      nil,
-		}, nil
-	}
-	res := (&service.ExportByDbReq{
-		Token:   in.Token,
-		Title:   in.Title,
-		Content: in.Content,
-		Mails:   in.Mails,
-		Query:   in.Query,
-		Stype:   in.Stype,
-	}).ExportDataByDb()
-	return &pb.BiReply{
-		ErrorCode: 0,
-		ErrorMsg:  "",
-		Data:      res,
-	}, nil
-}
-
-func RsaEncrypt(data []byte) string {
-	key := []byte(entity.PublicKey)
-	b, _ := sm4.Sm4Ecb(key, data, true)
-	return base64.StdEncoding.EncodeToString(b)
+	return &pb.BiReply{}, nil
 }

+ 77 - 0
rpc/internal/logic/sendmaillogic.go

@@ -0,0 +1,77 @@
+package logic
+
+import (
+	"app.yhyue.com/moapp/jybase/common"
+	"bp.jydev.jianyu360.cn/BaseService/biService/entity"
+	"bp.jydev.jianyu360.cn/BaseService/biService/service"
+	"context"
+	"fmt"
+	"github.com/gogf/gf/v2/util/gconv"
+	"github.com/tjfoc/gmsm/sm4"
+	"regexp"
+
+	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/internal/svc"
+	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/pb"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type SendMailLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewSendMailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendMailLogic {
+	return &SendMailLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+var reg1 = regexp.MustCompile("(?i)(insert|delete|update|master|truncate|declare|exec|alter|use)\\s")
+var reg2 = regexp.MustCompile("(?i)(select|from)\\s")
+
+func (l *SendMailLogic) SendMail(in *pb.ExportByDbReq) (*pb.BiReply, error) {
+	if in.Query == "" || in.Token == "" || in.Title == "" || in.Content == "" || in.Mails == "" {
+		return &pb.BiReply{
+			ErrorCode: 1,
+			ErrorMsg:  "参数不能为空",
+			Data:      nil,
+		}, nil
+	}
+	if reg1.MatchString(in.Query) && !reg2.MatchString(in.Query) {
+		return &pb.BiReply{
+			ErrorCode: 1,
+			ErrorMsg:  "查询语句不合法",
+			Data:      nil,
+		}, nil
+	}
+	if RsaEncrypt([]byte(fmt.Sprintf("%s&%s&%s&%s", gconv.String(in.Content), gconv.String(in.Mails), gconv.String(in.Query), gconv.String(in.Title)))) == in.Token {
+		return &pb.BiReply{
+			ErrorCode: 1,
+			ErrorMsg:  "token验证不通过",
+			Data:      nil,
+		}, nil
+	}
+	res := (&service.ExportByDbReq{
+		Token:   in.Token,
+		Title:   in.Title,
+		Content: in.Content,
+		Mails:   in.Mails,
+		Query:   in.Query,
+		Stype:   in.Stype,
+	}).ExportDataByDb()
+	return &pb.BiReply{
+		ErrorCode: 0,
+		ErrorMsg:  "",
+		Data:      res,
+	}, nil
+}
+
+func RsaEncrypt(data []byte) string {
+	key := []byte(entity.PublicKey)
+	b, _ := sm4.Sm4Ecb(key, data, true)
+	return common.GetMd5String(string(b))
+}

+ 5 - 0
rpc/internal/server/biserviceserver.go

@@ -111,3 +111,8 @@ func (s *BiServiceServer) ExportDataByDb(ctx context.Context, in *pb.ExportByDbR
 	l := logic.NewExportDataByDbLogic(ctx, s.svcCtx)
 	return l.ExportDataByDb(in)
 }
+
+func (s *BiServiceServer) SendMail(ctx context.Context, in *pb.ExportByDbReq) (*pb.BiReply, error) {
+	l := logic.NewSendMailLogic(ctx, s.svcCtx)
+	return l.SendMail(in)
+}

+ 27 - 23
rpc/pb/biService.pb.go

@@ -2209,7 +2209,7 @@ var file_biService_proto_rawDesc = []byte{
 	0x61, 0x69, 0x6c, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x05, 0x20,
 	0x01, 0x28, 0x09, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74,
 	0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x74, 0x79, 0x70, 0x65,
-	0x32, 0xa5, 0x06, 0x0a, 0x09, 0x42, 0x69, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x30,
+	0x32, 0xcb, 0x06, 0x0a, 0x09, 0x42, 0x69, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x30,
 	0x0a, 0x0b, 0x6d, 0x79, 0x44, 0x61, 0x74, 0x61, 0x41, 0x73, 0x73, 0x65, 0x74, 0x12, 0x0f, 0x2e,
 	0x4d, 0x79, 0x44, 0x61, 0x74, 0x61, 0x41, 0x73, 0x73, 0x65, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x10,
 	0x2e, 0x4d, 0x79, 0x44, 0x61, 0x74, 0x61, 0x41, 0x73, 0x73, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70,
@@ -2259,8 +2259,10 @@ var file_biService_proto_rawDesc = []byte{
 	0x43, 0x6c, 0x75, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2a, 0x0a, 0x0e,
 	0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x44, 0x61, 0x74, 0x61, 0x42, 0x79, 0x44, 0x62, 0x12, 0x0e,
 	0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x42, 0x79, 0x44, 0x62, 0x52, 0x65, 0x71, 0x1a, 0x08,
-	0x2e, 0x42, 0x69, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62,
-	0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x2e, 0x42, 0x69, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x24, 0x0a, 0x08, 0x73, 0x65, 0x6e, 0x64,
+	0x4d, 0x61, 0x69, 0x6c, 0x12, 0x0e, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x42, 0x79, 0x44,
+	0x62, 0x52, 0x65, 0x71, 0x1a, 0x08, 0x2e, 0x42, 0x69, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x42, 0x06,
+	0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
@@ -2333,26 +2335,28 @@ var file_biService_proto_depIdxs = []int32{
 	22, // 22: BiService.getCompanyType:input_type -> CompanyReq
 	24, // 23: BiService.distributeClueShow:input_type -> DistributeClueShowReq
 	28, // 24: BiService.exportDataByDb:input_type -> ExportByDbReq
-	1,  // 25: BiService.myDataAsset:output_type -> MyDataAssetResp
-	4,  // 26: BiService.addProject:output_type -> AddProjectResp
-	6,  // 27: BiService.getInfoId:output_type -> GetInfoIdResp
-	4,  // 28: BiService.drawClue:output_type -> AddProjectResp
-	9,  // 29: BiService.Call:output_type -> BiResp
-	4,  // 30: BiService.distributeClue:output_type -> AddProjectResp
-	14, // 31: BiService.clueImport:output_type -> ClueImportResp
-	4,  // 32: BiService.clueAdd:output_type -> AddProjectResp
-	14, // 33: BiService.clueImportTt:output_type -> ClueImportResp
-	14, // 34: BiService.autoFollow:output_type -> ClueImportResp
-	10, // 35: BiService.sqlManage:output_type -> BiReply
-	10, // 36: BiService.myInfo:output_type -> BiReply
-	10, // 37: BiService.allInfoExport:output_type -> BiReply
-	10, // 38: BiService.allProjectExport:output_type -> BiReply
-	10, // 39: BiService.infoOperate:output_type -> BiReply
-	23, // 40: BiService.getCompanyType:output_type -> CompanyResp
-	27, // 41: BiService.distributeClueShow:output_type -> DistributeClueShowResp
-	10, // 42: BiService.exportDataByDb:output_type -> BiReply
-	25, // [25:43] is the sub-list for method output_type
-	7,  // [7:25] is the sub-list for method input_type
+	28, // 25: BiService.sendMail:input_type -> ExportByDbReq
+	1,  // 26: BiService.myDataAsset:output_type -> MyDataAssetResp
+	4,  // 27: BiService.addProject:output_type -> AddProjectResp
+	6,  // 28: BiService.getInfoId:output_type -> GetInfoIdResp
+	4,  // 29: BiService.drawClue:output_type -> AddProjectResp
+	9,  // 30: BiService.Call:output_type -> BiResp
+	4,  // 31: BiService.distributeClue:output_type -> AddProjectResp
+	14, // 32: BiService.clueImport:output_type -> ClueImportResp
+	4,  // 33: BiService.clueAdd:output_type -> AddProjectResp
+	14, // 34: BiService.clueImportTt:output_type -> ClueImportResp
+	14, // 35: BiService.autoFollow:output_type -> ClueImportResp
+	10, // 36: BiService.sqlManage:output_type -> BiReply
+	10, // 37: BiService.myInfo:output_type -> BiReply
+	10, // 38: BiService.allInfoExport:output_type -> BiReply
+	10, // 39: BiService.allProjectExport:output_type -> BiReply
+	10, // 40: BiService.infoOperate:output_type -> BiReply
+	23, // 41: BiService.getCompanyType:output_type -> CompanyResp
+	27, // 42: BiService.distributeClueShow:output_type -> DistributeClueShowResp
+	10, // 43: BiService.exportDataByDb:output_type -> BiReply
+	10, // 44: BiService.sendMail:output_type -> BiReply
+	26, // [26:45] is the sub-list for method output_type
+	7,  // [7:26] is the sub-list for method input_type
 	7,  // [7:7] is the sub-list for extension type_name
 	7,  // [7:7] is the sub-list for extension extendee
 	0,  // [0:7] is the sub-list for field type_name

+ 37 - 0
rpc/pb/biService_grpc.pb.go

@@ -37,6 +37,7 @@ const (
 	BiService_GetCompanyType_FullMethodName     = "/BiService/getCompanyType"
 	BiService_DistributeClueShow_FullMethodName = "/BiService/distributeClueShow"
 	BiService_ExportDataByDb_FullMethodName     = "/BiService/exportDataByDb"
+	BiService_SendMail_FullMethodName           = "/BiService/sendMail"
 )
 
 // BiServiceClient is the client API for BiService service.
@@ -61,6 +62,7 @@ type BiServiceClient interface {
 	GetCompanyType(ctx context.Context, in *CompanyReq, opts ...grpc.CallOption) (*CompanyResp, error)
 	DistributeClueShow(ctx context.Context, in *DistributeClueShowReq, opts ...grpc.CallOption) (*DistributeClueShowResp, error)
 	ExportDataByDb(ctx context.Context, in *ExportByDbReq, opts ...grpc.CallOption) (*BiReply, error)
+	SendMail(ctx context.Context, in *ExportByDbReq, opts ...grpc.CallOption) (*BiReply, error)
 }
 
 type biServiceClient struct {
@@ -233,6 +235,15 @@ func (c *biServiceClient) ExportDataByDb(ctx context.Context, in *ExportByDbReq,
 	return out, nil
 }
 
+func (c *biServiceClient) SendMail(ctx context.Context, in *ExportByDbReq, opts ...grpc.CallOption) (*BiReply, error) {
+	out := new(BiReply)
+	err := c.cc.Invoke(ctx, BiService_SendMail_FullMethodName, in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // BiServiceServer is the server API for BiService service.
 // All implementations must embed UnimplementedBiServiceServer
 // for forward compatibility
@@ -255,6 +266,7 @@ type BiServiceServer interface {
 	GetCompanyType(context.Context, *CompanyReq) (*CompanyResp, error)
 	DistributeClueShow(context.Context, *DistributeClueShowReq) (*DistributeClueShowResp, error)
 	ExportDataByDb(context.Context, *ExportByDbReq) (*BiReply, error)
+	SendMail(context.Context, *ExportByDbReq) (*BiReply, error)
 	mustEmbedUnimplementedBiServiceServer()
 }
 
@@ -316,6 +328,9 @@ func (UnimplementedBiServiceServer) DistributeClueShow(context.Context, *Distrib
 func (UnimplementedBiServiceServer) ExportDataByDb(context.Context, *ExportByDbReq) (*BiReply, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method ExportDataByDb not implemented")
 }
+func (UnimplementedBiServiceServer) SendMail(context.Context, *ExportByDbReq) (*BiReply, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method SendMail not implemented")
+}
 func (UnimplementedBiServiceServer) mustEmbedUnimplementedBiServiceServer() {}
 
 // UnsafeBiServiceServer may be embedded to opt out of forward compatibility for this service.
@@ -653,6 +668,24 @@ func _BiService_ExportDataByDb_Handler(srv interface{}, ctx context.Context, dec
 	return interceptor(ctx, in, info, handler)
 }
 
+func _BiService_SendMail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(ExportByDbReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(BiServiceServer).SendMail(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: BiService_SendMail_FullMethodName,
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(BiServiceServer).SendMail(ctx, req.(*ExportByDbReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 // BiService_ServiceDesc is the grpc.ServiceDesc for BiService service.
 // It's only intended for direct use with grpc.RegisterService,
 // and not to be introspected or modified (even as a copy)
@@ -732,6 +765,10 @@ var BiService_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "exportDataByDb",
 			Handler:    _BiService_ExportDataByDb_Handler,
 		},
+		{
+			MethodName: "sendMail",
+			Handler:    _BiService_SendMail_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "biService.proto",

+ 36 - 26
service/exprot.go

@@ -53,7 +53,9 @@ func (a *ExportReq) AllProjectExport() {
 	timeStr = fmt.Sprintf("%s%s", timeStr, gconv.String(randomInt))
 	pathArr := export("customer_data_ttzl_project", tableColumn, exportKey, timeStr)
 	if len(pathArr) > 0 {
-		pathstr := compressFiles(pathArr, timeStr)
+		folderPath := fmt.Sprintf("%s/%s", ExportDirectory, timeStr)
+		compressFiles(pathArr, folderPath, timeStr)
+		pathstr := fmt.Sprintf("%s/%s/%s.zip", ExportUrl, timeStr, timeStr)
 		state := sendMail("项目", a.Mail, pathstr)
 		BiService.Insert("export_record", map[string]interface{}{
 			"positionId": a.PositionId,
@@ -81,7 +83,9 @@ func (a *ExportReq) AllInfoExport() {
 	timeStr = fmt.Sprintf("%s%s", timeStr, gconv.String(randomInt))
 	pathArr := export("customer_data_ttzl", tableColumn, exportKey, timeStr)
 	if len(pathArr) > 0 {
-		pathstr := compressFiles(pathArr, timeStr)
+		folderPath := fmt.Sprintf("%s/%s", ExportDirectory, timeStr)
+		compressFiles(pathArr, folderPath, timeStr)
+		pathstr := fmt.Sprintf("%s/%s/%s.zip", ExportUrl, timeStr, timeStr)
 		state := sendMail("标讯", a.Mail, pathstr)
 		BiService.Insert("export_record", map[string]interface{}{
 			"positionId": a.PositionId,
@@ -106,7 +110,7 @@ func export(table string, tableColumn []string, key []interface{}, timeStr strin
 		if a%ExportCount == 0 && a > 0 {
 			a = 0
 			//入excel处理
-			writer, file, path = Warehousing(writer, file, fileCounter, key, timeStr)
+			writer, file, path = Warehousing(writer, file, fileCounter, key, ExportDirectory, timeStr)
 			fileCounter++
 			pathArr = append(pathArr, path)
 		}
@@ -115,7 +119,7 @@ func export(table string, tableColumn []string, key []interface{}, timeStr strin
 		return true
 	}, sqlStr)
 	if a > 0 && a != ExportCount {
-		writer, file, path = Warehousing(writer, file, fileCounter, key, timeStr)
+		writer, file, path = Warehousing(writer, file, fileCounter, key, ExportDirectory, timeStr)
 		pathArr = append(pathArr, path)
 	}
 	return pathArr
@@ -134,10 +138,10 @@ func dataHandle(writer *excelize.StreamWriter, l *[]map[string]interface{}, a in
 }
 
 // 入excel
-func Warehousing(writer *excelize.StreamWriter, file *excelize.File, fileCounter int, key []interface{}, timeStr string) (*excelize.StreamWriter, *excelize.File, string) {
+func Warehousing(writer *excelize.StreamWriter, file *excelize.File, fileCounter int, key []interface{}, path, timeStr string) (*excelize.StreamWriter, *excelize.File, string) {
 	logx.Info(fmt.Sprintf("开始第%d数据", fileCounter))
 	writer.Flush()
-	folderPath := fmt.Sprintf("%s/%s", ExportDirectory, timeStr)
+	folderPath := fmt.Sprintf("%s/%s", path, timeStr)
 	_, err := os.Stat(folderPath)
 	if os.IsNotExist(err) {
 		//创建文件夹
@@ -190,17 +194,16 @@ func sendMail(title, target_mail string, path string) bool {
 }
 
 // 文件压缩
-func compressFiles(filePattern []string, timeStr string) string {
-	folderPath := fmt.Sprintf("%s/%s", ExportDirectory, timeStr)
-	_, err := os.Stat(folderPath)
+func compressFiles(filePattern []string, path, timeStr string) {
+	_, err := os.Stat(path)
 	if os.IsNotExist(err) {
 		//创建文件夹
-		err := os.MkdirAll(folderPath, os.ModePerm)
+		err := os.MkdirAll(path, os.ModePerm)
 		if err != nil {
 			logx.Info("创建文件夹失败:", err)
 		}
 	}
-	zipFilename := fmt.Sprintf("%s/%s.zip", folderPath, timeStr)
+	zipFilename := fmt.Sprintf("%s/%s.zip", path, timeStr)
 	// 创建 ZIP 文件
 	zipFile, err := os.Create(zipFilename)
 	if err != nil {
@@ -246,7 +249,8 @@ func compressFiles(filePattern []string, timeStr string) string {
 		log.Fatal(err)
 	}
 	log.Printf("Files compressed to: %s", absPath)
-	return fmt.Sprintf("%s/%s/%s.zip", ExportUrl, timeStr, timeStr)
+	//return fmt.Sprintf("%s/%s/%s.zip", url, timeStr, timeStr)
+	//return fmt.Sprintf("%s/%s/%s.zip", url, timeStr, timeStr)
 }
 
 // 数据导出(通用)
@@ -257,14 +261,17 @@ func (e *ExportByDbReq) ExportDataByDb() []byte {
 	rand.Seed(time.Now().UnixNano())
 	randomInt := rand.Intn(10000) // 生成0到9999之间的随机整数
 	timeStr = fmt.Sprintf("%s%s", timeStr, gconv.String(randomInt))
-	pathArr := exportA(e.Query, timeStr, key)
+	stype := e.Stype
+	if stype == "" {
+		stype = "public"
+	}
+	path1 := fmt.Sprintf("%s/%s", ComFileDir, stype)
+	pathArr := exportA(e.Query, path1, timeStr, key)
 	if len(pathArr) > 0 {
-		pathstr := compressFiles(pathArr, timeStr)
+		folderPath := fmt.Sprintf("%s/%s", path1, timeStr)
+		compressFiles(pathArr, folderPath, timeStr)
+		pathstr := fmt.Sprintf("%s/%s/%s/%s.zip", ComFileUrl, stype, timeStr, timeStr)
 		state := sendMailA(e.Title, e.Mails, e.Content, pathstr)
-		stype := e.Stype
-		if stype == "" {
-			stype = "public"
-		}
 		BiService.Insert("export_record", map[string]interface{}{
 			"positionId": "0",
 			"type":       stype,
@@ -273,8 +280,9 @@ func (e *ExportByDbReq) ExportDataByDb() []byte {
 			"sendState":  state,
 			"createTime": time.Now().Format(DateTime),
 		})
+		return gconv.Bytes(map[string]interface{}{"status": 1, "msg": "导出数据成功"})
 	}
-	return gconv.Bytes(map[string]interface{}{"status": 1})
+	return gconv.Bytes(map[string]interface{}{"status": -1, "msg": "导出数据失败,未查询到数据"})
 }
 
 // 表头
@@ -284,33 +292,35 @@ func hName(sql string) []interface{} {
 	keystr := strings.ReplaceAll(s[0], "select", "")
 	keystr = strings.ReplaceAll(keystr, " ", "")
 	for _, s1 := range strings.Split(keystr, ",") {
-		key = append(key, strings.Split(s1, "as")[1])
+		if strings.Contains(s1, "as") {
+			key = append(key, strings.Split(s1, "as")[1])
+		}
 	}
 	return key
 }
 
 // 导出开始
-func exportA(sql, timeStr string, key []interface{}) []string {
+func exportA(sql, path, timeStr string, key []interface{}) []string {
 	pathArr := []string{}
 	fileCounter := 1
 	writer, file := InirWrite(key)
 	a := 0
-	path := ""
+	fpath := ""
 	BiService.SelectByBath(1, func(l *[]map[string]interface{}) bool {
 		if a%ExportCount == 0 && a > 0 {
 			a = 0
 			//入excel处理
-			writer, file, path = Warehousing(writer, file, fileCounter, key, timeStr)
+			writer, file, fpath = Warehousing(writer, file, fileCounter, key, path, timeStr)
 			fileCounter++
-			pathArr = append(pathArr, path)
+			pathArr = append(pathArr, fpath)
 		}
 		dataHandle(writer, l, a, common.ObjArrToStringArr(key))
 		a++
 		return true
 	}, sql)
 	if a > 0 && a != ExportCount {
-		writer, file, path = Warehousing(writer, file, fileCounter, key, timeStr)
-		pathArr = append(pathArr, path)
+		writer, file, fpath = Warehousing(writer, file, fileCounter, key, path, timeStr)
+		pathArr = append(pathArr, fpath)
 	}
 	return pathArr
 }

+ 6 - 11
updateData/config.json

@@ -1,11 +1,11 @@
 {
     "mongodb": {
-		"address": "192.168.3.206:27080",
+		"address": "192.168.3.206:27002",
 		"size": 5,
-		"dbName": "qfw",
+		"dbName": "mixdata",
 		"replSet": "",
-		"userName":"",
-		"password":""
+		"userName":"jyDevGroup",
+		"password":"jy@DevGroup"
 	},
     "tidb1": {
 	        "dbName": "base_service",
@@ -16,16 +16,11 @@
 			"maxIdleConns": 5
 	 },
     "tidb2": {
-	        "dbName": "base_service",
+	        "dbName": "zxl",
 	        "address": "192.168.3.14:4000",
 	        "userName": "root",
 	        "passWord": "=PDT49#80Z!RVv52_z",
 			"maxOpenConns": 5,
 			"maxIdleConns": 5
-	 },
-	"poolSize":20,
-	"testId":"5c3ecf30c9ebc245590dc5fa",
-	"timestamp":0,
-	"testEntId":0,
-	"testEntUserId":0
+	 }
 }

+ 98 - 5
updateData/main.go

@@ -3,6 +3,7 @@ package main
 import (
 	"fmt"
 	"log"
+	"sync"
 
 	qu "app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/mongodb"
@@ -67,14 +68,63 @@ func init() {
 
 func main() {
 	//
-	do1()
+	log.Println("电销 开始")
+	// do1()
+	log.Println("电销 结束")
 
 	//
-	do2()
+	log.Println("合力易捷 开始")
+	// do2()
+	log.Println("合力易捷 结束")
+
 }
 
 //电销线索刷库
 func do1() {
+	var (
+		pool = make(chan bool, 5)
+		wait = &sync.WaitGroup{}
+	)
+	i := 0
+	for {
+		count := TidbBi.CountBySql(`SELECT count(1) FROM dwd_f_crm_clue_info where company_nature is null`)
+		if count == 0 {
+			log.Println("find no data end")
+			return
+		}
+		TidbBi.SelectByBath(10, func(l *[]map[string]interface{}) bool {
+			for _, v := range *l {
+				pool <- true
+				wait.Add(1)
+				i++
+				go func(thisData map[string]interface{}) {
+					defer func() {
+						<-pool
+						wait.Done()
+					}()
+					id := gconv.Int64(thisData["id"])
+					query := map[string]interface{}{
+						"id": id,
+					}
+					cluename := gconv.String(thisData["cluename"])
+					update := getCompanyType(cluename)
+					ok := TidbBi.Update("dwd_f_crm_clue_info", query, update)
+					if !ok {
+						log.Println("crm clue info update err", query, update)
+					}
+				}(v)
+			}
+			if i%5000 == 0 {
+				log.Println(fmt.Sprintf("current --- %d ", i))
+			}
+			return true
+		}, `SELECT * FROM dwd_f_crm_clue_info where company_nature is null limit 500`)
+	}
+	wait.Wait()
+}
+
+//电销线索刷库 无并发
+func do1_bak() {
 	i := 0
 	for {
 		count := TidbBi.CountBySql(`SELECT count(1) FROM dwd_f_crm_clue_info where company_nature is null`)
@@ -103,11 +153,55 @@ func do1() {
 			return true
 		}, `SELECT * FROM dwd_f_crm_clue_info where company_nature is null limit 500`)
 	}
-
 }
 
 //合力易捷刷库
 func do2() {
+	i := 0
+	var (
+		pool = make(chan bool, 5)
+		wait = &sync.WaitGroup{}
+	)
+	for {
+		count := TidbCall.CountBySql(`SELECT count(1) FROM customer where company_nature is null`)
+		if count == 0 {
+			log.Println("find no data end")
+			return
+		}
+		TidbCall.SelectByBath(10, func(l *[]map[string]interface{}) bool {
+			for _, v := range *l {
+				pool <- true
+				wait.Add(1)
+				i++
+				go func(thisData map[string]interface{}) {
+					defer func() {
+						<-pool
+						wait.Done()
+					}()
+					id := gconv.String(thisData["unique_id"])
+					query := map[string]interface{}{
+						"unique_id": id,
+					}
+					company := gconv.String(thisData["company"])
+					update := getCompanyType(company)
+					ok := TidbCall.Update("customer", query, update)
+					if !ok {
+						log.Println("customer info update err", query, update)
+					}
+				}(v)
+			}
+
+			if i%5000 == 0 {
+				log.Println(fmt.Sprintf("current --- %d ", i))
+			}
+			return true
+		}, `SELECT * FROM customer where company_nature is null limit 1000`)
+	}
+	wait.Wait()
+}
+
+//合力易捷刷库 无并发
+func do2_bak() {
 	i := 0
 	for {
 		count := TidbCall.CountBySql(`SELECT count(1) FROM customer where company_nature is null`)
@@ -134,9 +228,8 @@ func do2() {
 				log.Println(fmt.Sprintf("current --- %d ", i))
 			}
 			return true
-		}, `SELECT * FROM customer where company_nature is null limit 500`)
+		}, `SELECT * FROM customer where company_nature is null limit 1000`)
 	}
-
 }
 
 //公司性质、公司核验