Ver código fonte

日志修改

Jianghan 1 ano atrás
pai
commit
a77ceb07b5

+ 3 - 2
CMPlatform/client/customerRule.go

@@ -3,14 +3,15 @@ package client
 import (
 	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/encrypt"
-	"app.yhyue.com/moapp/jybase/go-xweb/log"
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+	"app.yhyue.com/moapp/jybase/log"
 	"app.yhyue.com/moapp/jybase/mongodb"
 	"cmplatform/util"
 	"encoding/json"
 	"fmt"
 	"github.com/lauyoume/gopinyin"
 	"go.mongodb.org/mongo-driver/bson"
+	"go.uber.org/zap"
 	"io"
 	"regexp"
 	"strings"
@@ -221,7 +222,7 @@ func (c *CustomerRule) ProductData() {
 			totalCount += rangeCount
 		}
 
-		log.Debug("multi_match", multiMatchcount, s_esquery)
+		log.Debug("multi_match", zap.Int("multiMatchcount", multiMatchcount), zap.String("s_esquery", s_esquery))
 		if totalCount > 1000 && (s_startTime == 0 || s_endTime == 0) {
 			c.ServeJson(map[string]interface{}{
 				"rep": false,

+ 1 - 0
CMPlatform/config.json

@@ -8,6 +8,7 @@
   "dbnameen": "enterprise",
   "mongoenc": "winner_enterprise",
   "subday": 15,
+  "logpath": "",
   "customer": {
     "api": "https://jybx3-webtest.jydev.jianyu360.com/api1/user/jy_newuser",
     "mgodb": "192.168.3.206:27080",

+ 0 - 1
CMPlatform/front/front.go

@@ -8,7 +8,6 @@ import (
 	"cmplatform/util"
 	"go.mongodb.org/mongo-driver/bson"
 	"go.mongodb.org/mongo-driver/bson/primitive"
-
 	"strconv"
 	"time"
 )

+ 5 - 1
CMPlatform/go.mod

@@ -3,7 +3,7 @@ module cmplatform
 go 1.20
 
 require (
-	app.yhyue.com/moapp/jybase v0.0.0-20231026082242-8eb41c7bdda6
+	app.yhyue.com/moapp/jybase v0.0.0-20231222072535-dca21a393e0e
 	github.com/Chain-Zhang/pinyin v0.1.3
 	github.com/PuerkitoBio/goquery v1.8.1
 	github.com/antonmedv/expr v1.15.3
@@ -36,10 +36,14 @@ require (
 	github.com/xdg-go/scram v1.1.2 // indirect
 	github.com/xdg-go/stringprep v1.0.4 // indirect
 	github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
+	go.uber.org/atomic v1.9.0 // indirect
+	go.uber.org/multierr v1.8.0 // indirect
+	go.uber.org/zap v1.21.0 // indirect
 	golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
 	golang.org/x/net v0.7.0 // indirect
 	golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
 	gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
+	gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
 	gorm.io/driver/mysql v1.0.5 // indirect
 	gorm.io/gorm v1.21.3 // indirect
 )

+ 7 - 0
CMPlatform/go.sum

@@ -2,6 +2,8 @@ app.yhyue.com/moapp/esv1 v0.0.0-20220414031211-3da4123e648d h1:WPsYuuptAd3UEgN+j
 app.yhyue.com/moapp/esv1 v0.0.0-20220414031211-3da4123e648d/go.mod h1:91/lSD/hS+ckMVP3WdidRzDhC60lLMdyce9QHy0cSMA=
 app.yhyue.com/moapp/jybase v0.0.0-20231026082242-8eb41c7bdda6 h1:uyaBp5Iuc/Il4+O2n92CyU9LPvHetFzQVC8iS9iLFOc=
 app.yhyue.com/moapp/jybase v0.0.0-20231026082242-8eb41c7bdda6/go.mod h1:Hv9U/7oHRucqH315Tr1+d03NCvS9mOKPfk8pwwlOIwQ=
+app.yhyue.com/moapp/jybase v0.0.0-20231222072535-dca21a393e0e h1:3SOZl1ZdYiC/Midaf92FjtF77eNjUWDusLTn7xzoPXE=
+app.yhyue.com/moapp/jybase v0.0.0-20231222072535-dca21a393e0e/go.mod h1:fjaD11Z3FIk9EyfOpdKAMQNs7nPZCpT/qKIw1oVsb9w=
 cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
 cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
 cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
@@ -474,13 +476,16 @@ go.opentelemetry.io/otel/trace v1.7.0/go.mod h1:fzLSB9nqR2eXzxPXb2JW9IKE+ScyXA48
 go.opentelemetry.io/otel/trace v1.8.0/go.mod h1:0Bt3PXY8w+3pheS3hQUt+wow8b1ojPaTBoTCh2zIFI4=
 go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
 go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
+go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
 go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
 go.uber.org/automaxprocs v1.5.1/go.mod h1:BF4eumQw0P9GtnuxxovUd06vwm1o18oMzFtK66vU6XU=
 go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
 go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
 go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
+go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8=
 go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
 go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
+go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8=
 go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw=
 golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@@ -831,6 +836,8 @@ gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AW
 gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw=
 gopkg.in/h2non/gock.v1 v1.1.2/go.mod h1:n7UGz/ckNChHiK05rDoiC4MYSunEC/lyaUm2WWaDva0=
 gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
+gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
+gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
 gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
 gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

+ 5 - 4
CMPlatform/history/biddingRepeat.go

@@ -2,9 +2,10 @@ package history
 
 import (
 	"app.yhyue.com/moapp/jybase/common"
-	"app.yhyue.com/moapp/jybase/go-xweb/log"
+	"app.yhyue.com/moapp/jybase/log"
 	"cmplatform/util"
 	"fmt"
+	"go.uber.org/zap"
 	"regexp"
 	"strings"
 	"time"
@@ -19,7 +20,7 @@ func (this *HistoryData) BiddingRepeat(historyId string) {
 	if common.IntAll((*datatable)["i_datatable"]) > 0 {
 		dbName = "usermail"
 	}
-	log.Debug("公告去重开始,historyId: ", historyId)
+	log.Debug("公告去重开始,", zap.String("historyId", historyId))
 	count_total := util.MgoSave.Count(dbName, map[string]interface{}{"historyId": historyId})
 	msg += "查询条数 " + fmt.Sprintln(count_total)
 	times_start := time.Now().Format("2006-01-02 15:04:05")
@@ -30,7 +31,7 @@ func (this *HistoryData) BiddingRepeat(historyId string) {
 				count += 1
 				log.Debug("第" + fmt.Sprintln(count) + "条")
 				if count%500 == 0 {
-					log.Debug(count)
+					log.Debug("BiddingRepeat", zap.Int("count", count))
 					msg += fmt.Sprintln(count)
 				}
 				start_time := common.Int64All(v["publishtime"])
@@ -293,7 +294,7 @@ func (this *HistoryData) BiddingRepeat(historyId string) {
 						}
 					}
 					if len(repeat_2_id) > 0 {
-						log.Debug("有重复数据", repeat_2_id)
+						log.Debug("有重复数据", zap.Any("repeat_2_id", repeat_2_id))
 						util.MgoSave.UpdateById(dbName, v["_id"], map[string]interface{}{"$set": map[string]interface{}{"used_2": 1, "repeat_2": 1, "repeat_2_id": strings.Join(repeat_2_id, ",")}})
 					}
 				}

+ 26 - 27
CMPlatform/history/historytask.go

@@ -1,24 +1,23 @@
 package history
 
 import (
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+	"app.yhyue.com/moapp/jybase/log"
+	"app.yhyue.com/moapp/jybase/mongodb"
 	"cmplatform/util"
 	"encoding/json"
 	"fmt"
+	"github.com/antonmedv/expr"
+	"github.com/tealeg/xlsx"
+	"go.mongodb.org/mongo-driver/bson"
+	"go.uber.org/zap"
 	"io"
 	"os"
 	"regexp"
 	"strings"
 	"sync"
 	"time"
-
-	"log"
-
-	"app.yhyue.com/moapp/jybase/common"
-	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
-	"app.yhyue.com/moapp/jybase/mongodb"
-	"github.com/antonmedv/expr"
-	"github.com/tealeg/xlsx"
-	"go.mongodb.org/mongo-driver/bson"
 )
 
 type HistoryData struct {
@@ -45,10 +44,10 @@ var (
 )
 
 func (this *HistoryData) HistoryTask(history_id string) {
-	log.Println("开始历史任务...")
+	log.Debug("开始历史任务...")
 	go UpdateHistoryState(1, history_id, 0)
 	//加载一个客户
-	log.Println("history_id", history_id)
+	log.Debug("history_id", zap.String("history_id", history_id))
 	//是否根据项目id去重
 	xlsxData := &XlsxData{}
 	customer, _ := util.Mgo.Find("historylog", map[string]interface{}{"_id": mongodb.StringTOBsonId(history_id)}, nil, nil, false, -1, -1)
@@ -104,9 +103,9 @@ func (this *HistoryData) HistoryTask(history_id string) {
 		//
 		//if ProjectAppidMap[appId] {
 		if isFilter == 1 {
-			log.Println("g根据项目id去重。。。")
+			log.Debug("g根据项目id去重。。。")
 			start := time.Now().Unix()
-			log.Println("加载projectId---开始")
+			log.Debug("加载projectId---开始")
 			if dataTable == 0 {
 				InitProjectId(appId)
 			}
@@ -114,7 +113,7 @@ func (this *HistoryData) HistoryTask(history_id string) {
 				InitUsermailProjectId(appId)
 			}
 			end := time.Now().Unix()
-			log.Println("加载projectId---结束,耗时", end-start, "秒")
+			log.Debug(fmt.Sprintf("加载projectId---结束,耗时%d秒", end-start))
 		} else {
 			projectIdMap = sync.Map{}
 		}
@@ -153,7 +152,7 @@ func (this *HistoryData) HistoryTask(history_id string) {
 		dep_rules := common.ObjArrToMapArr(dep_rule)
 		cus.GetTagRules(tag_rules, tag_rules2, tag_rules3) //获取客户打标签规则
 		cus.GetDepartments("history", dep_rules)           //获取客户信息
-		log.Println("customer:", cus.ID, cus.Name, cus.PushModel, cus.AppId, cus.IsTagRule, cus.IsTagRule2, cus.IsTagRule3, cus.IsSearchHosp, cus.IsSearchEnps, len(cus.TagRules), len(cus.TagRules2), len(cus.TagRules3), len(cus.Departments))
+		log.Debug(fmt.Sprintf("customer: %s, %s, %d, %s, %t, %t, %t, %t, %t, %d, %d, %d, %d", cus.ID, cus.Name, cus.PushModel, cus.AppId, cus.IsTagRule, cus.IsTagRule2, cus.IsTagRule3, cus.IsSearchHosp, cus.IsSearchEnps, len(cus.TagRules), len(cus.TagRules2), len(cus.TagRules3), len(cus.Departments)))
 		cus.GetData("history", i_dataSource)                                                              //获取数据
 		cus.RemoveRepeatData()                                                                            //数据去重
 		cus.AssembelAndSaveData(history_id, isFilter, noticeFilter, dataTable, entId, iContact, xlsxData) //组装、保存数据
@@ -167,7 +166,7 @@ func (this *HistoryData) HistoryTask(history_id string) {
 		if i_pushtype == 0 {
 			time.Sleep(3 * time.Second)
 			if len(xlsxData.xlsxArr) != xlsxData.xlsxCount {
-				log.Println("excel数据量错误")
+				log.Error("excel数据量错误")
 			}
 			GetXlsxs(xlsxData.xlsxArr, iContact, customer_name, email, history_id, isfile, isHenanMobile, isfilehref, appId)
 			UpdateHistoryState(2, history_id, xlsxData.xlsxCount)
@@ -180,7 +179,7 @@ func (this *HistoryData) HistoryTask(history_id string) {
 		}
 		projectIdMap = sync.Map{}
 	} else {
-		log.Println("初始化客户信息失败")
+		log.Error("初始化客户信息失败")
 	}
 }
 
@@ -688,10 +687,10 @@ func (this *HistoryData) DataTest(id string) {
 func UpdateJyqyfwDatacount(appid string, newGetLen int) {
 	update_b := util.MgoCus.Update("user", bson.M{"appid": appid}, bson.M{"$inc": bson.M{"plan.current": -newGetLen}}, false, false)
 	if update_b {
-		log.Println("历史数据导入mysql表扣量成功 appid:" + appid + "扣除数据量:" + fmt.Sprintln(newGetLen))
+		log.Debug("历史数据导入mysql表扣量成功 appid:" + appid + "扣除数据量:" + fmt.Sprintln(newGetLen))
 		return
 	}
-	log.Println("历史数据导入mysql表扣量失败 appid:" + appid + "应扣除数据量:" + fmt.Sprintln(newGetLen))
+	log.Debug("历史数据导入mysql表扣量失败 appid:" + appid + "应扣除数据量:" + fmt.Sprintln(newGetLen))
 }
 
 func (this *HistoryData) HistoryDelete(hid string) {
@@ -702,10 +701,10 @@ func (this *HistoryData) HistoryDelete(hid string) {
 	}
 	ok := util.Mgo.UpdateById("historylog", mongodb.StringTOBsonId(hid), set)
 	if ok {
-		log.Println("历史任务逻辑删除成功", hid)
+		log.Debug("历史任务逻辑删除成功", zap.String("hid", hid))
 		delOk := util.Mgo.Del("usermail_history", bson.M{"historyId": hid})
 		if delOk {
-			log.Println("历史任务下数据总量删除成功")
+			log.Debug("历史任务下数据总量删除成功")
 		}
 	}
 }
@@ -902,7 +901,7 @@ func exactMatch(rule string, data []map[string]interface{}, nameArr []string) bo
 	//可以将编译后的表达式,存放在缓存中
 	program, err := expr.Compile(rule, expr.Env(realdata))
 	if err != nil {
-		log.Println("表达式错误 ", err)
+		log.Error("表达式错误 ", zap.Error(err))
 		return false
 	}
 
@@ -921,10 +920,10 @@ func exactMatch(rule string, data []map[string]interface{}, nameArr []string) bo
 			}
 		}
 	}
-	log.Println("匹配结果 ", realdata)
+	log.Debug("匹配结果 ", zap.Any("realdata", realdata))
 	output, err := expr.Run(program, realdata)
 	if err != nil {
-		log.Println("表达式执行错误 ", err)
+		log.Error("表达式执行错误 ", zap.Error(err))
 		return false
 	}
 	return output.(bool)
@@ -949,7 +948,7 @@ func exactMatchs(rule, title, detail string, match []map[string]string, nameArr
 	//可以将编译后的表达式,存放在缓存中
 	program, err := expr.Compile(rule, expr.Env(realdata))
 	if err != nil {
-		log.Println("表达式错误 ", err)
+		log.Error("表达式错误 ", zap.Error(err))
 		return false
 	}
 
@@ -972,10 +971,10 @@ func exactMatchs(rule, title, detail string, match []map[string]string, nameArr
 			}
 		}
 	}
-	log.Println("匹配结果 ", realdata)
+	log.Debug("匹配结果 ", zap.Any("realdata", realdata))
 	output, err := expr.Run(program, realdata)
 	if err != nil {
-		log.Println("表达式执行错误 ", err)
+		log.Error("表达式执行错误 ", zap.Error(err))
 		return false
 	}
 	return output.(bool)

+ 42 - 41
CMPlatform/history/task.go

@@ -1,27 +1,28 @@
 package history
 
 import (
+	"app.yhyue.com/moapp/jybase/common"
+	elastic "app.yhyue.com/moapp/jybase/es"
+	"app.yhyue.com/moapp/jybase/log"
+	"app.yhyue.com/moapp/jybase/mongodb"
+	"app.yhyue.com/moapp/jybase/redis"
 	"cmplatform/util"
 	sql "cmplatform/util/sqlmodel"
 	"context"
 	"encoding/json"
-	"log"
+	"fmt"
+	esV7 "github.com/olivere/elastic/v7"
+	"go.mongodb.org/mongo-driver/bson"
+	"go.uber.org/zap"
 	"regexp"
 	"strings"
 	"sync"
 	"time"
-
-	"app.yhyue.com/moapp/jybase/common"
-	elastic "app.yhyue.com/moapp/jybase/es"
-	"app.yhyue.com/moapp/jybase/mongodb"
-	"app.yhyue.com/moapp/jybase/redis"
-	esV7 "github.com/olivere/elastic/v7"
-	"go.mongodb.org/mongo-driver/bson"
 )
 
 // 获取客户打标签规则
 func (c *Customer) GetTagRules(tagRules, tagRules2, tagRules3 []map[string]interface{}) {
-	log.Println("开始加载标签规则...")
+	log.Debug("开始加载标签规则...")
 	defer common.Catch()
 	if len(tagRules) > 0 {
 		c.IsTagRule = true //查到打标签规则,表示打标签
@@ -117,7 +118,7 @@ func (c *Customer) GetTagRules(tagRules, tagRules2, tagRules3 []map[string]inter
 
 // 获取部门信息
 func (c *Customer) GetDepartments(stype string, departments []map[string]interface{}) {
-	log.Println("开始获取部门信息...")
+	log.Debug("开始获取部门信息...")
 	defer common.Catch()
 	if len(departments) > 0 {
 		departMap := map[string]interface{}{}
@@ -153,7 +154,7 @@ func (c *Customer) GetDepartments(stype string, departments []map[string]interfa
 
 // 获取数据
 func (c *Customer) GetData(stype string, dataSource int) {
-	log.Println("开始匹配数据...")
+	log.Debug("开始匹配数据...")
 	defer common.Catch()
 	esConfig := util.Sysconfig["es"].(map[string]interface{})
 	esversion := common.ObjToString(esConfig["version"])
@@ -163,10 +164,10 @@ func (c *Customer) GetData(stype string, dataSource int) {
 		for {
 			listLen := redis.GetInt("session", "es_status")
 			if listLen == 0 {
-				log.Println("es空闲!")
+				log.Debug("es空闲!")
 				break
 			} else if listLen == 1 || listLen == 2 {
-				log.Println("es繁忙,", listLen)
+				log.Debug("es繁忙,", zap.Int("listLen", listLen))
 			}
 			time.Sleep(5 * time.Second)
 		}
@@ -178,7 +179,7 @@ func (c *Customer) GetData(stype string, dataSource int) {
 				redis.LPOP("datag", "jyqyfw_es_query")
 				break
 			} else {
-				log.Println("企业级服务es进程数过多,", listLens)
+				log.Debug("企业级服务es进程数过多,", zap.Int("listLens", listLens))
 			}
 			time.Sleep(5 * time.Second)
 		}
@@ -198,8 +199,8 @@ func (c *Customer) EsConGetDataV7(stype string, dataSource int, esCon *elastic.E
 				esIndex = util.EsAllIndex
 			}
 			escount := esCon.Count(esIndex, "", sr.EsQuery)
-			log.Println("index", esIndex, "type")
-			log.Println("查询总数:", escount, "规则ID:", sr.ID, "EsQuery:", sr.EsQuery)
+			log.Debug("index: " + esIndex)
+			log.Debug(fmt.Sprintf("查询总数: %d, 规则ID: %s, EsQuery: %s", escount, sr.ID, sr.EsQuery))
 			if escount == 0 {
 				continue
 			}
@@ -220,7 +221,7 @@ func (c *Customer) EsConGetDataV7(stype string, dataSource int, esCon *elastic.E
 				count := 1
 				for {
 					if scrollId == "" {
-						log.Println("ScrollId Is Error")
+						log.Debug("ScrollId Is Error")
 						break
 					}
 					var searchResult *esV7.SearchResult
@@ -231,14 +232,14 @@ func (c *Customer) EsConGetDataV7(stype string, dataSource int, esCon *elastic.E
 						searchResult, err = client.Scroll(esIndex).Size(200).ScrollId(scrollId).Do(ctx) //查询
 						if err != nil {
 							if err.Error() == "EOS" { //迭代完毕
-								log.Println("Es Search Data Over:", err)
+								log.Error("Es Search Data Over:", zap.Error(err))
 							} else {
-								log.Println("Es Search Data Error:", err)
+								log.Error("Es Search Data Error:", zap.Error(err))
 							}
 							break
 						}
 					}
-					log.Println("此次处理条数 ", len(searchResult.Hits.Hits))
+					log.Debug(fmt.Sprintf("此次处理条数: %d", len(searchResult.Hits.Hits)))
 					for _, hit := range searchResult.Hits.Hits {
 						//开始处理数据
 						wg.Add(1)
@@ -252,7 +253,7 @@ func (c *Customer) EsConGetDataV7(stype string, dataSource int, esCon *elastic.E
 							if json.Unmarshal(tmpHit.Source, &tmp) == nil {
 								if stype != "history" {
 									if !SkipData(tmp) {
-										log.Println("跳过该条数据,发布时间在入库时间7天之前,", common.ObjToString(tmp["_id"]))
+										log.Debug(fmt.Sprintf("跳过该条数据,发布时间在入库时间7天之前,%s", common.ObjToString(tmp["_id"])))
 										return
 									}
 								}
@@ -263,7 +264,7 @@ func (c *Customer) EsConGetDataV7(stype string, dataSource int, esCon *elastic.E
 										bidopentime := common.Int64All(tmp["bidopentime"])
 										comeintime := common.Int64All(tmp["comeintime"])
 										if bidopentime-comeintime <= 7*24*60*60 {
-											log.Println("跳过该条数据,开标时间-入库时间<=7天,", id)
+											log.Debug(fmt.Sprintf("跳过该条数据,开标时间-入库时间<=7天,%s", id))
 											return
 										}
 									}
@@ -271,7 +272,7 @@ func (c *Customer) EsConGetDataV7(stype string, dataSource int, esCon *elastic.E
 								//河南移动,过滤掉中国移动采购网招标数据
 								if CheckBidHrefRuleIdMap[dm.ID] {
 									if strings.Contains(common.ObjToString(tmp["href"]), "b2b.10086.cn") {
-										log.Println("跳过该条数据,公告原网址中包含 b2b.10086.cn,", id)
+										log.Debug(fmt.Sprintf("跳过该条数据,公告原网址中包含 b2b.10086.cn,%s", id))
 										return
 									}
 								}
@@ -339,7 +340,7 @@ func (c *Customer) EsConGetDataV7(stype string, dataSource int, esCon *elastic.E
 										}
 									}
 									exactResult := exactMatchs(sr.ExactRule, common.ObjToString(tmp["title"]), common.ObjToString(tmp["detail"]), sr.Maths, nameArr)
-									log.Println("-------------------精准匹配", id, exactResult)
+									log.Debug("-------------------精准匹配", zap.String("id", id), zap.Any("exactResult", exactResult))
 									if !exactResult {
 										return
 									}
@@ -373,7 +374,7 @@ func (c *Customer) EsConGetDataV7(stype string, dataSource int, esCon *elastic.E
 								/*
 									到此已经匹配完数据
 								*/
-								log.Println("---------------------", id, IsMatch)
+								log.Debug("---------------------", zap.String("id", id), zap.Any("IsMatch", IsMatch))
 								if IsMatch { //匹配成功,数据上新增规则id,matchKey,item并临时保存数据
 									// tmpMatchKey := MapDataToArr(matchKey)
 									tmpMatchKeyType := MapDataToArr(matchKeyType)
@@ -415,7 +416,7 @@ func (c *Customer) EsConGetDataV7(stype string, dataSource int, esCon *elastic.E
 																			tempList = append(tempList, k)
 																		}
 																		tagname = strings.Join(tempList, ",")
-																		log.Println("=====tagname为空取匹配词为标签名称", tagname)
+																		log.Debug(fmt.Sprintf("=====tagname为空取匹配词为标签名称%s", tagname))
 																	}
 																	tagNameMap[tagname] = true
 																	tagIdMap[tr.ID] = true
@@ -427,7 +428,7 @@ func (c *Customer) EsConGetDataV7(stype string, dataSource int, esCon *elastic.E
 																		tempList = append(tempList, k)
 																	}
 																	tagname = strings.Join(tempList, ",")
-																	log.Println("=====tagname为空取匹配词为标签名称", tagname)
+																	log.Debug(fmt.Sprintf("=====tagname为空取匹配词为标签名称", tagname))
 																}
 																tagNameMap[tagname] = true
 																tagIdMap[tr.ID] = true
@@ -481,7 +482,7 @@ func (c *Customer) EsConGetDataV7(stype string, dataSource int, esCon *elastic.E
 																			tempList = append(tempList, k)
 																		}
 																		tagname = strings.Join(tempList, ",")
-																		log.Println("=====tagname为空取匹配词为标签名称", tagname)
+																		log.Debug(fmt.Sprintf("=====tagname为空取匹配词为标签名称%s", tagname))
 																	}
 																	tagNameMap[tagname] = true
 																	tagIdMap[tr.ID] = true
@@ -493,7 +494,7 @@ func (c *Customer) EsConGetDataV7(stype string, dataSource int, esCon *elastic.E
 																		tempList = append(tempList, k)
 																	}
 																	tagname = strings.Join(tempList, ",")
-																	log.Println("=====tagname为空取匹配词为标签名称", tagname)
+																	log.Debug(fmt.Sprintf("=====tagname为空取匹配词为标签名称%s", tagname))
 																}
 																tagNameMap[tagname] = true
 																tagIdMap[tr.ID] = true
@@ -547,7 +548,7 @@ func (c *Customer) EsConGetDataV7(stype string, dataSource int, esCon *elastic.E
 																			tempList = append(tempList, k)
 																		}
 																		tagname = strings.Join(tempList, ",")
-																		log.Println("=====tagname为空取匹配词为标签名称", tagname)
+																		log.Debug("=====tagname为空取匹配词为标签名称", zap.String("tagname", tagname))
 																	}
 																	tagNameMap[tagname] = true
 																	tagIdMap[tr.ID] = true
@@ -559,7 +560,7 @@ func (c *Customer) EsConGetDataV7(stype string, dataSource int, esCon *elastic.E
 																		tempList = append(tempList, k)
 																	}
 																	tagname = strings.Join(tempList, ",")
-																	log.Println("=====tagname为空取匹配词为标签名称", tagname)
+																	log.Debug("=====tagname为空取匹配词为标签名称", zap.String("tagname", tagname))
 																}
 																tagNameMap[tagname] = true
 																tagIdMap[tr.ID] = true
@@ -614,7 +615,7 @@ func (c *Customer) EsConGetDataV7(stype string, dataSource int, esCon *elastic.E
 						}(hit)
 						numDocs += 1
 						if numDocs%500 == 0 {
-							log.Println("Current:", numDocs)
+							log.Debug("Current:", zap.Int("numDocs", numDocs))
 						}
 					}
 					scrollId = searchResult.ScrollId
@@ -622,9 +623,9 @@ func (c *Customer) EsConGetDataV7(stype string, dataSource int, esCon *elastic.E
 				}
 				wg.Wait()
 				client.ClearScroll().ScrollId(scrollId).Do(ctx) //清理游标
-				log.Println("SearchRule ID", sr.ID, "Result Data Count:", numDocs)
+				log.Debug(fmt.Sprintf("SearchRule ID:%s, Result Data Count:%d", sr.ID, numDocs))
 			} else {
-				log.Println("Customer:", c.Name, "Departmnet", dm.Name, "TagName", sr.Name, "Es Search Data Error,Tag ID:", sr.ID)
+				log.Debug(fmt.Sprintf("Customer: %s, Departmnet: %s, TagName: %s, Es Search Data Error,Tag ID: %s", c.Name, dm.Name, sr.Name, sr.ID))
 			}
 		}
 	}
@@ -632,7 +633,7 @@ func (c *Customer) EsConGetDataV7(stype string, dataSource int, esCon *elastic.E
 
 // 数据去重
 func (c *Customer) RemoveRepeatData() {
-	log.Println("开始数据去重...")
+	log.Debug("开始数据去重...")
 	defer common.Catch()
 	for _, dm := range c.Departments {
 		for _, dataMapArr := range dm.DepartmentData { //一个部门的所有数据
@@ -684,7 +685,7 @@ func (c *Customer) RemoveRepeatData() {
 
 // 组装保存数据
 func (c *Customer) AssembelAndSaveData(historyId string, isFilter, noticeFilter, dataTable, entId, i_contact int, xlsxData *XlsxData) {
-	log.Println("开始组装保存数据...")
+	log.Debug("开始组装保存数据...")
 	defer common.Catch()
 	ch := make(chan bool, 10)
 	wg := &sync.WaitGroup{}
@@ -705,7 +706,7 @@ func (c *Customer) AssembelAndSaveData(historyId string, isFilter, noticeFilter,
 			}(tmp)
 			n++
 			if n%500 == 0 {
-				log.Println("Current:", n)
+				log.Debug("Current:", zap.Int("n", n))
 			}
 		}
 		wg.Wait()
@@ -726,7 +727,7 @@ func (c *Customer) AssembelAndSaveData(historyId string, isFilter, noticeFilter,
 					}(tmp)
 					n++
 					if n%500 == 0 {
-						log.Println("Current:", n)
+						log.Debug("Current:", zap.Int("n", n))
 					}
 				}
 			}
@@ -752,7 +753,7 @@ func (c *Customer) AssembelAndSaveData(historyId string, isFilter, noticeFilter,
 		}
 		wg.Wait()
 	}*/
-	log.Println("数据保存完毕...		Save Number:", n)
+	log.Debug(fmt.Sprintf("数据保存完毕...		Save Number:%d", n))
 }
 
 // 获取用户所有规则
@@ -851,10 +852,10 @@ func (sr *SearchRule) GetEs(department, esquery string, tmpRange bson.M) {
 		if err == nil {
 			sr.EsQuery = string(strquery)
 		} else {
-			log.Println("Department:", department, "Es Error,Tag ID:", sr.ID)
+			log.Debug(fmt.Sprintf("Department: %s, Es Error,Tag ID: %s", department, sr.ID))
 		}
 	} else {
-		log.Println("Department:", department, "Es Error,Tag ID:", sr.ID)
+		log.Debug(fmt.Sprintf("Department: %s, Es Error,Tag ID: %s", department, sr.ID))
 	}
 }
 

+ 98 - 95
CMPlatform/history/util_history.go

@@ -1,25 +1,24 @@
 package history
 
 import (
-	"cmplatform/util"
-	"encoding/json"
-	"fmt"
-	"os"
-	"regexp"
-	"sort"
-	"strings"
-	"time"
-
-	"log"
-
 	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/encrypt"
+	"app.yhyue.com/moapp/jybase/log"
 	"app.yhyue.com/moapp/jybase/mail"
 	"app.yhyue.com/moapp/jybase/mongodb"
 	"app.yhyue.com/moapp/jybase/redis"
+	"cmplatform/util"
+	"encoding/json"
+	"fmt"
 	"github.com/tealeg/xlsx"
 	"go.mongodb.org/mongo-driver/bson"
 	"go.mongodb.org/mongo-driver/bson/primitive"
+	"go.uber.org/zap"
+	"os"
+	"regexp"
+	"sort"
+	"strings"
+	"time"
 )
 
 var LetterCase = regexp.MustCompile("[A-Za-z]")
@@ -301,7 +300,7 @@ func GetIdRange() (bson.M, bool) {
 				return tmpRange, true
 			}
 		} else { //结束id不大于起始id 退出
-			log.Println("Search End ID Range Error. Sid:", util.LatestId, "Eid:", endId)
+			log.Debug(fmt.Sprintf("Search End ID Range Error. Sid:%s, Eid:%s", util.LatestId, endId))
 			break
 		}
 	}
@@ -535,7 +534,7 @@ func MergeDatas(history, tmp map[string]interface{}, isTagRule, isDepartRmvRep b
 	item2 := common.ObjToString(tmp["item"])
 	history["item"] = MergeField(item1, item2)
 	history["itemdist"].(map[string]interface{})[item2] = matchkey2
-	log.Println("组装后的item:", history["item"], history["itemdist"])
+	log.Debug("组装后的item:", zap.Any("item", history["item"]), zap.Any("itemdist", history["itemdist"]))
 
 	if isTagRule { //标签模式 tagname、tagid合并
 		tagname1 := common.ObjToString(history["tagname"])
@@ -612,9 +611,9 @@ func AssembelSave(tmp map[string]interface{}, IsSearchHosp, IsSearchEnps bool, h
 	if dataTable == 2 {
 		isExist, err := redis.Exists("other", "entexportdata_"+id+"_"+fmt.Sprintln(entId))
 		if err != nil {
-			log.Println("企业订阅数据导出redis判重失败")
+			log.Debug("企业订阅数据导出redis判重失败")
 		} else if isExist {
-			log.Println("数据重复,id ", id, "entid ", entId)
+			log.Debug(fmt.Sprintf("数据重复,id: %s, entid: %d", id, entId))
 			return
 		}
 	}
@@ -643,7 +642,7 @@ func AssembelSave(tmp map[string]interface{}, IsSearchHosp, IsSearchEnps bool, h
 			if !isOk {
 				util.MgoSave.Save(util.SaveCollProject, tmp)
 			}
-			log.Println("项目id去重,项目id:", projectId, isOk)
+			log.Debug(fmt.Sprintf("项目id去重,项目id:%s, %t", projectId, isOk))
 		}
 	} else {
 		tmp["projectId"] = ""
@@ -790,7 +789,7 @@ func AssembelSave(tmp map[string]interface{}, IsSearchHosp, IsSearchEnps bool, h
 							}
 						}
 					}
-					log.Println("查询附件结果:", id, "附件数量:", len(filesArr))
+					log.Debug("查询附件结果:" + id + ", 附件数量:" + fmt.Sprint(len(filesArr)))
 					if len(filesArr) > 0 {
 						if FilterFilehrefAppidMap[appid] {
 							filesArrs := []map[string]interface{}{}
@@ -847,7 +846,7 @@ func AssembelSave(tmp map[string]interface{}, IsSearchHosp, IsSearchEnps bool, h
 								}
 							}
 						}
-						log.Println("查询附件结果:", id, "附件数量:", len(filesArr))
+						log.Debug("查询附件结果:" + id + ",附件数量:" + fmt.Sprint(len(filesArr)))
 						if len(filesArr) > 0 {
 							if FilterFilehrefAppidMap[appid] {
 								filesArrs := []map[string]interface{}{}
@@ -1028,7 +1027,7 @@ func AssembelSave(tmp map[string]interface{}, IsSearchHosp, IsSearchEnps bool, h
 	}
 	if noticeFilter == 1 && (dataTable == 0 || dataTable == 1) && isOk {
 		ok := checkBidId(appid, id, dataTable)
-		log.Println("公告去重结果", id, dataTable, ok)
+		log.Debug("公告去重结果", zap.String("id", id), zap.Int("dataTable", dataTable), zap.Any("ok", ok))
 		if !ok {
 			isOk = false
 			tmp["chongfu"] = id
@@ -1291,7 +1290,7 @@ func SaveMgo() {
 
 // 数据存库
 func SaveUsermailMgo() {
-	log.Println("Mgo Save Usermail...")
+	log.Debug("Mgo Save Usermail...")
 	arru := make([]map[string]interface{}, 500)
 	indexu := 0
 	counts := 0
@@ -1330,84 +1329,88 @@ func SaveUsermailMgo() {
 
 // 打印初始化信息
 func PrintLog(cus *Customer) {
-	log.Println("----------------------打标签规则----------------------------")
+	log.Debug("----------------------打标签规则----------------------------")
 	for i, tr := range cus.TagRules {
-		log.Println("tagrules:", i, tr.ID, tr.Name, tr.CustomerId, tr.DepartRuleIds, tr.Fields)
+		log.Debug(fmt.Sprintf("tagrules: %d, %s, %s, %s", i, tr.ID, tr.Name, tr.CustomerId), zap.Any("tr.DepartRuleIds", tr.DepartRuleIds), zap.Any("tr.Fields", tr.Fields))
 		for j, kw := range tr.KW {
-			log.Println("kw_matchkey---", kw.MatchType, len(kw.MatchType))
-			log.Println("------------CReg--------------")
+			log.Debug("---", zap.Any("kw.MatchType", kw.MatchType), zap.Int("len(kw.MatchType)", len(kw.MatchType)))
+			log.Debug("------------CReg--------------")
 			for ck1, cr := range kw.KeyReg.CReg {
-				log.Println("CR---", ck1, cr.CrVal, cr.CsVal, cr.IsLetter)
+				log.Debug("cr---", zap.Any("ck1", ck1), zap.Any("cr.CrVal", cr.CrVal), zap.Any("cr.CsVal", cr.CsVal), zap.Any("cr.IsLetter", cr.IsLetter))
 			}
-			log.Println("------------AReg--------------")
+			log.Debug("------------AReg--------------")
 			for ck1, ar := range kw.KeyReg.AReg {
-				log.Println("AR---", ck1, ar.CsVal)
+				log.Debug("AR---", zap.Any("ck1", ck1), zap.Any("ar.CsVal", ar.CsVal))
 				for _, arc := range ar.AndRegKid {
-					log.Println("ARC---", arc.CrVal, arc.IsLetter)
+					log.Debug("ARC---", zap.Any("arc.CrVal", arc.CrVal), zap.Any("arc.IsLetter", arc.IsLetter))
 				}
 			}
-			log.Println("+++++++++++++++++++++AW++++++++++++++++++++++")
-			log.Println("aw_matchkey---", tr.AW[j].MatchType, len(tr.AW[j].MatchType))
-			log.Println("------------CReg--------------")
+			log.Debug("+++++++++++++++++++++AW++++++++++++++++++++++")
+			log.Debug("aw_matchkey---", zap.Any("tr.AW[j].MatchType", tr.AW[j].MatchType), zap.Any("len(tr.AW[j].MatchType", len(tr.AW[j].MatchType)))
+			log.Debug("------------CReg--------------")
 			for ck2, cr := range tr.AW[j].KeyReg.CReg {
-				log.Println("CR---", ck2, cr.CrVal, cr.CsVal, cr.IsLetter)
+				log.Debug("CR---", zap.Any("ck2", ck2), zap.Any("cr.CrVal", cr.CrVal), zap.Any("cr.CsVal", cr.CsVal), zap.Any("cr.IsLetter", cr.IsLetter))
 			}
-			log.Println("------------AReg--------------")
+			log.Debug("------------AReg--------------")
 			for ck2, ar := range tr.AW[j].KeyReg.AReg {
-				log.Println("AR---", ck2, ar.CsVal)
+				log.Debug("AR---", zap.Int("ck2", ck2), zap.String("ar.CsVal", ar.CsVal))
 				for _, arc := range ar.AndRegKid {
-					log.Println("ARC---", arc.CrVal, arc.IsLetter)
+					log.Debug("ARC---", zap.Any("arc.CrVal", arc.CrVal), zap.Any("arc.IsLetter", arc.IsLetter))
 				}
 			}
-			log.Println("++++++++++++++++++++NW+++++++++++++++++++++++")
-			log.Println("nw_matchkey---", tr.NW[j].MatchType, len(tr.NW[j].MatchType))
-			log.Println("------------CReg--------------")
+			log.Debug("++++++++++++++++++++NW+++++++++++++++++++++++")
+			log.Debug("nw_matchkey---", zap.Any("tr.NW[j].MatchType", tr.NW[j].MatchType), zap.Any("len(tr.NW[j].MatchType)", len(tr.NW[j].MatchType)))
+			log.Debug("------------CReg--------------")
 			for ck1, cr := range tr.NW[j].KeyReg.CReg {
-				log.Println("CR---", ck1, cr.CrVal, cr.CsVal, cr.IsLetter)
+				log.Debug("CR---", zap.Any("ck2", ck1), zap.Any("cr.CrVal", cr.CrVal), zap.Any("cr.CsVal", cr.CsVal), zap.Any("cr.IsLetter", cr.IsLetter))
 			}
-			log.Println("------------AReg--------------")
+			log.Debug("------------AReg--------------")
 			for ck1, ar := range tr.NW[j].KeyReg.AReg {
-				log.Println("AR---", ck1, ar.CsVal)
+				log.Debug("AR---", zap.Int("ck2", ck1), zap.String("ar.CsVal", ar.CsVal))
 				for _, arc := range ar.AndRegKid {
-					log.Println("ARC---", arc.CrVal, arc.IsLetter)
+					log.Debug("ARC---", zap.Any("arc.CrVal", arc.CrVal), zap.Any("arc.IsLetter", arc.IsLetter))
 				}
 			}
-			log.Println("tagname-------------", tr.TagNames[j])
-			log.Println("-------------------------------------------------")
+			log.Debug("tagname-------------" + tr.TagNames[j])
+			log.Debug("-------------------------------------------------")
 		}
 	}
-	log.Println("----------------------查询规则----------------------------")
+	log.Debug("----------------------查询规则----------------------------")
 	for i, dm := range cus.Departments {
-		log.Println("deparment:", i, dm.ID, dm.Name, dm.CustomerID)
+		log.Debug(fmt.Sprintf("deparment: %d, %s, %s, %s", i, dm.ID, dm.Name, dm.CustomerID))
 		for j, sr := range dm.Rules {
-			log.Println("ck---", j, sr.ID, sr.Name, sr.CustomerID, sr.DepartmentID, sr.GCW.KeyReg, len(sr.GCW.KeyReg), sr.GCW.MatchType, len(sr.GCW.MatchType), sr.Fields, len(sr.Fields), sr.EsQuery)
+			log.Debug(fmt.Sprintf("ck---: %d, %s, %s, %s, %s", j, sr.ID, sr.Name, sr.CustomerID, sr.DepartmentID))
+			log.Debug("ck---", zap.Any("sr.GCW.KeyReg", sr.GCW.KeyReg), zap.Any("len(sr.GCW.KeyReg)", len(sr.GCW.KeyReg)))
+			log.Debug("ck---", zap.Any("sr.GCW.MatchType", sr.GCW.MatchType), zap.Any("len(sr.GCW.MatchType)", len(sr.GCW.MatchType)))
+			log.Debug("ck---", zap.Any("sr.Fields", sr.Fields), zap.Any("len(sr.Fields)", len(sr.Fields)))
+			log.Debug(sr.EsQuery)
 			for j, kw := range sr.KW {
-				log.Println("kw_matchkey---", kw.MatchType, len(kw.MatchType))
-				log.Println("------------CReg--------------")
+				log.Debug("---", zap.Any("kw.MatchType", kw.MatchType), zap.Int("len(kw.MatchType)", len(kw.MatchType)))
+				log.Debug("------------CReg--------------")
 				for ck1, cr := range kw.KeyReg.CReg {
-					log.Println("CR---", ck1, cr.CrVal, cr.CsVal, cr.IsLetter)
+					log.Debug("CR---", zap.Any("ck2", ck1), zap.Any("cr.CrVal", cr.CrVal), zap.Any("cr.CsVal", cr.CsVal), zap.Any("cr.IsLetter", cr.IsLetter))
 				}
-				log.Println("------------AReg--------------")
+				log.Debug("------------AReg--------------")
 				for ck1, ar := range kw.KeyReg.AReg {
-					log.Println("AR---", ck1, ar.CsVal)
+					log.Debug("AR---", zap.Int("ck2", ck1), zap.String("ar.CsVal", ar.CsVal))
 					for _, arc := range ar.AndRegKid {
-						log.Println("ARC---", arc.CrVal, arc.IsLetter)
+						log.Debug("ARC---", zap.Any("arc.CrVal", arc.CrVal), zap.Any("arc.IsLetter", arc.IsLetter))
 					}
 				}
-				log.Println("+++++++++++++++++++++AW++++++++++++++++++++++")
-				log.Println("aw_matchkey---", sr.AW[j].MatchType, len(sr.AW[j].MatchType))
-				log.Println("------------CReg--------------")
+				log.Debug("+++++++++++++++++++++AW++++++++++++++++++++++")
+				log.Debug("aw_matchkey---", zap.Any("sr.AW[j].MatchType", sr.AW[j].MatchType), zap.Any("len(tr.AW[j].MatchType", len(sr.AW[j].MatchType)))
+				log.Debug("------------CReg--------------")
 				for ck2, cr := range sr.AW[j].KeyReg.CReg {
-					log.Println("CR---", ck2, cr.CrVal, cr.CsVal, cr.IsLetter)
+					log.Debug("CR---", zap.Any("ck2", ck2), zap.Any("cr.CrVal", cr.CrVal), zap.Any("cr.CsVal", cr.CsVal), zap.Any("cr.IsLetter", cr.IsLetter))
 				}
-				log.Println("------------AReg--------------")
+				log.Debug("------------AReg--------------")
 				for ck2, ar := range sr.AW[j].KeyReg.AReg {
-					log.Println("AR---", ck2, ar.CsVal)
+					log.Debug("AR---", zap.Int("ck2", ck2), zap.String("ar.CsVal", ar.CsVal))
 					for _, arc := range ar.AndRegKid {
-						log.Println("ARC---", arc.CrVal, arc.IsLetter)
+						log.Debug("ARC---", zap.Any("arc.CrVal", arc.CrVal), zap.Any("arc.IsLetter", arc.IsLetter))
 					}
 				}
-				log.Println("--------------------------------------------------------------------------------------")
+				log.Debug("--------------------------------------------------------------------------------------")
 			}
 		}
 	}
@@ -1416,25 +1419,25 @@ func PrintLog(cus *Customer) {
 // 匹配
 func RegMatchTest(fieldText map[string]interface{}, matchType []string, matchReg *Reg, matchKey map[string]bool, matchKeyType map[string]bool, goon, isAddWord bool) (match bool) {
 	defer common.Catch()
-	log.Println("matchType---", matchType)
+	log.Debug("matchType---", zap.Any("matchType", matchType))
 	if len(matchType) == 0 && isAddWord { //特殊处理附加词为空的情况
 		match = true
 		return
 	}
 	for _, mt := range matchType {
 		if text := common.ObjToString(fieldText[mt]); text != "" {
-			log.Println("匹配方式---", mt, "text---", text)
-			log.Println("--------------开始查找逗号分隔----------------", len(matchReg.CReg))
+			log.Debug("匹配方式---" + mt + ", text---" + text)
+			log.Debug("--------------开始查找逗号分隔----------------", zap.Int("len(matchReg.CReg)", len(matchReg.CReg)))
 			for i, cr := range matchReg.CReg { //逗号分隔,任意一个匹配表示匹配成功
-				log.Println("iiii---", i, cr.CrVal, goon, matchKey)
+				log.Debug(fmt.Sprintf("iiii--- %d, %v, %t, %v", i, cr.CrVal, goon, matchKey))
 				if goon && matchKey[cr.CsVal] { //matchkey已存在不在匹配
 					continue
 				}
 				if indexArr := cr.CrVal.FindAllStringIndex(text, -1); len(indexArr) > 0 { //匹配成功
 					if !cr.IsLetter { //reg无字母
-						log.Println("goon---", goon)
+						log.Debug("goon---", zap.Any("goon", goon))
 						if goon {
-							log.Println("key++++++++++ ++++++++++", cr.CsVal)
+							log.Debug("key++++++++++ ++++++++++" + cr.CsVal)
 							matchKey[cr.CsVal] = true
 							matchKeyType[mt] = true
 							match = true
@@ -1443,9 +1446,9 @@ func RegMatchTest(fieldText map[string]interface{}, matchType []string, matchReg
 							return
 						}
 					} else if cr.IsLetter && CheckLetter(text, cr.CrVal, indexArr) { //reg有字母,判断是否是包含关系(AAAIBBB or AI){//
-						log.Println("goon---", goon)
+						log.Debug("goon---", zap.Any("goon", goon))
 						if goon {
-							log.Println("key++++++++++++++++++++", cr.CsVal)
+							log.Debug("key++++++++++++++++++++" + cr.CsVal)
 							matchKey[cr.CsVal] = true
 							matchKeyType[mt] = true
 							match = true
@@ -1456,16 +1459,16 @@ func RegMatchTest(fieldText map[string]interface{}, matchType []string, matchReg
 					}
 				}
 			}
-			log.Println("--------------开始查找&&分隔----------------", len(matchReg.AReg))
+			log.Debug("--------------开始查找&&分隔----------------", zap.Int("len(matchReg.AReg)", len(matchReg.AReg)))
 			for j, ar := range matchReg.AReg { //&&分割,所有匹配表示匹配成功
-				log.Println("jjjj---", j, ar.CsVal, goon, matchKey)
+				log.Debug(fmt.Sprintf("jjjj--- %d, %v, %t, %v", j, ar.CsVal, goon, matchKey))
 				if goon && matchKey[ar.CsVal] {
 					continue
 				}
 				IsAregMatch := false
-				log.Println("ar.AndRegKid---", j, ar.AndRegKid, len(ar.AndRegKid))
+				log.Debug("ar.AndRegKid---", zap.Int("j", j), zap.Any("ar.AndRegKid", ar.AndRegKid), zap.Int("len(ar.AndRegKid)", len(ar.AndRegKid)))
 				for n, arc := range ar.AndRegKid { //ar.AndRegKid若有值必不小于2
-					log.Println("nnnn---", n, arc.CrVal, arc.IsLetter)
+					log.Debug("nnnn---", zap.Int("n", n), zap.Any("arc.CrVal", arc.CrVal), zap.Any("arc.IsLetter", arc.IsLetter))
 					if indexArr := arc.CrVal.FindAllStringIndex(text, -1); len(indexArr) < 1 { //匹配失败(ar.AndRegKid中任意一个未匹配则失败)
 						break
 					} else { //匹配成功,判断字母
@@ -1477,11 +1480,11 @@ func RegMatchTest(fieldText map[string]interface{}, matchType []string, matchReg
 						IsAregMatch = true
 					}
 				}
-				log.Println("IsAregMatch---", IsAregMatch)
+				log.Debug(fmt.Sprintf("IsAregMatch---%t", IsAregMatch))
 				if IsAregMatch {
-					log.Println("goon---", goon)
+					log.Debug(fmt.Sprintf("goon---%t", goon))
 					if goon {
-						log.Println("key++++++++++++++++++++", ar.CsVal)
+						log.Debug(fmt.Sprintf("key++++++++++++++++++++%s", ar.CsVal))
 						matchKey[ar.CsVal] = true
 						matchKeyType[mt] = true
 						match = true
@@ -1546,7 +1549,7 @@ func GetXlsxs(mMap []map[string]interface{}, i_contact int, fn, email, id string
 			if dataSource == 1 {
 				xf, err := xlsx.OpenFile("web/res/fields.xlsx")
 				if err != nil {
-					log.Println("fields file not foud", err.Error())
+					log.Error("fields file not foud", zap.Error(err))
 				}
 				style := xlsx.NewStyle()
 				style.Font.Size = 12
@@ -2274,21 +2277,21 @@ func GetXlsxs(mMap []map[string]interface{}, i_contact int, fn, email, id string
 				if b, _ := PathExists(dir); !b {
 					err1 := os.MkdirAll(dir, os.ModePerm)
 					if err1 != nil {
-						log.Println("mkdir err", dir)
+						log.Error("mkdir err", zap.Error(err))
 					}
 					//fname := t + ".xlsx"
 				}
 				fname := fmt.Sprintf("%s_%s_%s.xlsx", fn, t, common.GetRandom(4))
-				log.Println("fname", fname)
+				log.Debug("fname: " + fname)
 				err = xf.Save(dir + fname)
 				if err != nil {
-					log.Println("xls error", fname)
+					log.Error("xls error", zap.Error(err))
 				} else {
 					for i := 0; i < len(Gmails); i++ {
 						gmail := Gmails[i]
 						status := mail.GSendMail_q("剑鱼标讯", email, "", "", fn, "", dir+fname, fname, gmail)
 						if status {
-							log.Println("send mail success", fname, email)
+							log.Debug("send mail success" + fname + ", " + email)
 							break
 						}
 					}
@@ -2296,7 +2299,7 @@ func GetXlsxs(mMap []map[string]interface{}, i_contact int, fn, email, id string
 			} else {
 				xf, err := xlsx.OpenFile("web/res/full_field.xlsx")
 				if err != nil {
-					log.Println("fields file not foud", err.Error())
+					log.Error("fields file not foud", zap.Error(err))
 				}
 				style := xlsx.NewStyle()
 				style.Font.Size = 12
@@ -2327,21 +2330,21 @@ func GetXlsxs(mMap []map[string]interface{}, i_contact int, fn, email, id string
 				if b, _ := PathExists(dir); !b {
 					err1 := os.MkdirAll(dir, os.ModePerm)
 					if err1 != nil {
-						log.Println("mkdir err", dir)
+						log.Error("mkdir err", zap.Error(err))
 					}
 				}
 				//fname := t + ".xlsx"
 				fname := fmt.Sprintf("%s_%s_%s.xlsx", fn, t, common.GetRandom(4))
-				log.Println("fname", fname)
+				log.Debug("fname: " + fname)
 				err = xf.Save(dir + fname)
 				if err != nil {
-					log.Println("xls error", fname)
+					log.Error("xls error", zap.Error(err))
 				} else {
 					for i := 0; i < len(Gmails); i++ {
 						gmail := Gmails[i]
 						status := mail.GSendMail_q("剑鱼标讯", email, "", "", fn, "", dir+fname, fname, gmail)
 						if status {
-							log.Println("send mail success", fname, email)
+							log.Debug("send mail success" + fname + ", " + email)
 							break
 						}
 					}
@@ -2384,10 +2387,10 @@ func GetProjectId(id string) (string, int64, int64) {
 			}
 		}
 		projectId = strings.Join(projectIdArr, ",")
-		log.Println("projectId", projectId)
+		log.Debug("projectId: " + projectId)
 		//
 	} else {
-		log.Println("ES未查到项目id", id)
+		log.Debug("ES未查到项目id: " + id)
 	}
 	return projectId, zbtime, yitime
 }
@@ -2397,7 +2400,7 @@ func InitProjectId(appid string) {
 	count := 0
 	defer func() {
 		util.MgoSave.DestoryMongoConn(session)
-		log.Println("本次共取到%d个projectId\n", count)
+		log.Debug(fmt.Sprintf("本次共取到%d个projectId", count))
 	}()
 	save := util.Sysconfig["save"].(map[string]interface{})
 	query := map[string]interface{}{"appid": appid}
@@ -2422,7 +2425,7 @@ func InitUsermailProjectId(appid string) {
 	count := 0
 	defer func() {
 		util.MgoCus.DestoryMongoConn(session)
-		log.Println("本次共取到%d个projectId\n", count)
+		log.Debug(fmt.Sprintf("本次共取到%d个projectId", count))
 	}()
 	customer := util.Sysconfig["customer"].(map[string]interface{})
 	query := map[string]interface{}{"appid": appid}
@@ -2447,14 +2450,14 @@ func checkBidId(appid, id string, dataTable int) bool {
 	if dataTable == 1 {
 		countData, ok := util.MgoSave.FindOne(util.SaveUserMail, map[string]interface{}{"appid": appid, "id": id})
 		if ok && countData != nil && len(*countData) > 0 {
-			log.Println("用户 ", appid, " 在 ", util.SaveUserMail, " 中找到重复公告id ", id)
+			log.Debug("用户 " + appid + ", 在 " + util.SaveUserMail + " 中找到重复公告id " + id)
 			isOk = false
 		}
 	}
 	if dataTable == 0 {
 		countData, ok := util.MgoSave.FindOne(util.SaveColl, map[string]interface{}{"appid": appid, "id": id})
 		if ok && countData != nil && len(*countData) > 0 {
-			log.Println("用户 ", appid, " 在 ", util.SaveColl, " 中找到重复公告id ", id)
+			log.Debug("用户 " + appid + " 在 " + util.SaveColl + " 中找到重复公告id " + id)
 			isOk = false
 		}
 	}
@@ -2521,7 +2524,7 @@ func GetWinnerStyle(s_winner string, v map[string]interface{}) {
 		for _, vw := range strings.Split(s_winner, ",") {
 			//j := 1
 			for _, key := range keyList {
-				log.Println("中标类型匹配", key)
+				log.Debug("中标类型匹配 " + key)
 				vvs := util.Sysconfig["winner_style_match"].(map[string]interface{})[key].(map[string]interface{})
 				keyWord := common.ObjToString(vvs["keyWord"])
 				name := common.ObjToString(vvs["name"])
@@ -2553,7 +2556,7 @@ func GetWinnerStyle(s_winner string, v map[string]interface{}) {
 				}
 			}
 		}
-		log.Println("中标类型:", wname)
+		log.Debug("中标类型:" + wname)
 		v["winner_style"] = wname
 	} else {
 		v["winner_style"] = ""
@@ -2604,7 +2607,7 @@ func saveMysqlPush(tmp map[string]interface{}, entId int) bool {
 	}
 	b := util.JyMysql.Insert("pushentniche", saveMap)
 	if b <= 0 {
-		log.Println("数据插入pushentniche表失败,id ", common.ObjToString(tmp["id"]), "entid ", entId)
+		log.Debug("数据插入pushentniche表失败,id " + common.ObjToString(tmp["id"]) + "entid " + fmt.Sprint(entId))
 		return false
 	} else {
 		redis.Put("other", "entexportdata_"+infoid+"_"+fmt.Sprintln(entId), 1, -1)

+ 5 - 5
CMPlatform/main.go

@@ -1,6 +1,9 @@
 package main
 
 import (
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+	"app.yhyue.com/moapp/jybase/log"
 	"app.yhyue.com/moapp/jybase/mail"
 	"app.yhyue.com/moapp/jybase/redis"
 	"cmplatform/client"
@@ -10,11 +13,8 @@ import (
 	"cmplatform/push"
 	"cmplatform/service"
 	"cmplatform/util"
-	"log"
+	"fmt"
 	"time"
-
-	"app.yhyue.com/moapp/jybase/common"
-	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
 )
 
 func init() {
@@ -109,7 +109,7 @@ func initOther() {
 
 func main() {
 
-	log.Println("port:", util.Sysconfig["port"])
+	log.Debug("port:" + fmt.Sprint(util.Sysconfig["port"]))
 	xweb.Run(":" + common.ObjToString(util.Sysconfig["port"]))
 
 }

+ 32 - 34
CMPlatform/push/push.go

@@ -1,23 +1,21 @@
 package push
 
 import (
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
+	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+	"app.yhyue.com/moapp/jybase/log"
+	"app.yhyue.com/moapp/jybase/mongodb"
+	"app.yhyue.com/moapp/jybase/redis"
 	"bytes"
 	. "cmplatform/util"
 	"encoding/json"
 	"fmt"
+	"github.com/tealeg/xlsx"
+	"go.uber.org/zap"
 	"net/url"
 	"strings"
 	"time"
-
-	"app.yhyue.com/moapp/jybase/mongodb"
-
-	"log"
-
-	"app.yhyue.com/moapp/jybase/common"
-	"app.yhyue.com/moapp/jybase/encrypt"
-	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
-	"app.yhyue.com/moapp/jybase/redis"
-	"github.com/tealeg/xlsx"
 )
 
 type Push struct {
@@ -121,20 +119,20 @@ func (this *Push) DataPush() {
 		} else if getDataType == "1" {
 			dataMap["dataList"] = ExcelParse(dataType)
 		}
-		log.Println(dataMap)
+		log.Debug("", zap.Any("dataMap", dataMap))
 		databyte, _ := json.Marshal(dataMap)
 		dataStr := string(databyte)
 		//
 		token := getAccessToken()
 		// token := "f9cb92a6-356b-433f-a8bd-09f1deef6d52"
-		log.Println("token111:", token)
+		log.Debug("token111:" + token)
 		//
 		tokens := getAccessTokens(token)
-		log.Println("token222:", tokens)
+		log.Debug("token222:" + tokens)
 		//
 		dataStr = strings.ReplaceAll(dataStr, `"`, `\"`)
 		data := `{"access_token":"` + tokens + `","postjson":"` + dataStr + `"}`
-		log.Println("data:", data)
+		log.Debug("data:", zap.Any("data", data))
 		dataTypes := ""
 		if dataType == "0" {
 			dataTypes = "JY_TO_DICT_fishBid2"
@@ -142,7 +140,7 @@ func (this *Push) DataPush() {
 			dataTypes = "JY_TO_DICT_WinBid2"
 		}
 		apiurl := "http://111.7.112.55:20110/oppf?method=" + dataTypes + "&appId=1068246&appKey=15c1da231a946f9615ee9d56138952a2&format=json&busiSerial=1&OPCODE=A888888&version=1.0&accessToken=" + tokens + "&timestamp=" + fmt.Sprint(time.Now().Format("20060102150405")) + "&sign=abc"
-		log.Println("apiurl:", apiurl)
+		log.Debug("apiurl:" + apiurl)
 		errstr := ""
 		response, err := HttpPostJson(apiurl, data)
 		result := map[string]interface{}{}
@@ -150,18 +148,18 @@ func (this *Push) DataPush() {
 			errstr = string(response)
 			resMap := common.ObjToMap(string(response))
 			result = *resMap
-			log.Println("响应信息 ", *resMap)
+			log.Debug("---", zap.Any("响应信息: ", *resMap))
 			if resMap != nil && *resMap != nil {
 				respCode := common.ObjToString((*resMap)["respCode"])
 				if respCode == "00000" {
-					log.Println("成功")
+					log.Debug("成功")
 				} else {
-					log.Println("异常")
+					log.Debug("异常")
 				}
 			}
 		} else {
 			errstr = "响应失败 " + err.Error()
-			log.Println("响应失败 ", err)
+			log.Error("响应失败 ", zap.Error(err))
 		}
 		MgoSave.Save("dataPushLog", map[string]interface{}{
 			"dataLenth":   len(dataMap["dataList"]),
@@ -231,21 +229,21 @@ func getAccessToken() string {
 		bs, err := HttpPostForm(apiurls, map[string]string{
 			"timestamp": fmt.Sprint(now),
 		}, data)
-		log.Println("返回内容", err, string(bs))
+		log.Debug("返回内容", zap.Error(err), zap.String("string(bs)", string(bs)))
 		resMap := common.ObjToMap(string(bs))
 		if *resMap != nil {
-			log.Println("调用token成功 ", *resMap)
+			log.Debug("调用token成功 ", zap.Any("resMap", *resMap))
 			token := common.ObjToString((*resMap)["access_token"])
 			if token != "" {
-				log.Println("成功")
+				log.Debug("成功")
 				redis.Put("datag", "yidongtoken1", token, 60*60*24)
 				return token
 			} else {
-				log.Println("异常")
+				log.Debug("异常")
 				return ""
 			}
 		} else {
-			log.Println("调用token失败")
+			log.Debug("调用token失败")
 			return ""
 		}
 	}
@@ -257,7 +255,7 @@ func getAccessTokens(token string) string {
 		return res
 	} else {
 		apiurls := "http://111.7.112.55:20110/oppf?method=JY_TO_DICT_TOKEN&appId=1068246&appKey=15c1da231a946f9615ee9d56138952a2&format=json&busiSerial=1&OPCODE=A888888&version=1.0&accessToken=" + token + "&timestamp=" + fmt.Sprint(time.Now().Format("20060102150405")) + "&sign=abc"
-		log.Println("EPMtokenapiurl:", apiurls)
+		log.Debug("EPMtokenapiurl:" + apiurls)
 		grant_type := "client_credentials"
 		scope := "all"
 		client_id := "jianyu_client"
@@ -270,17 +268,17 @@ func getAccessTokens(token string) string {
 		bytestr, _ := json.Marshal(data)
 		bs, err := HttpPostJson(apiurls, string(bytestr))
 		if err != nil {
-			log.Println("调用 token 失败", err)
+			log.Error("调用 token 失败", zap.Error(err))
 		}
 		resMap := common.ObjToMap(string(bs))
 		if *resMap != nil {
-			log.Println("调用token成功 ", *resMap)
+			log.Debug("调用token成功 ", zap.Any("resMap", *resMap))
 			resMaps := common.ObjToMap((*resMap)["result"])
 			jsonMap := common.ObjToMap((*resMaps)["response"])
 			redis.Put("datag", "yidongtoken2", common.ObjToString((*jsonMap)["access_token"]), 7200)
 			return common.ObjToString((*jsonMap)["access_token"])
 		} else {
-			log.Println("调用token失败")
+			log.Debug("调用token失败")
 			return ""
 		}
 	}
@@ -349,7 +347,7 @@ func ttCRM(dataSource, historyId string) string {
 									}
 								}
 							}
-							log.Println("查询附件结果:", id, "附件数量:", len(filesArr))
+							log.Debug("查询附件结果:" + id + ", 附件数量:" + fmt.Sprint(len(filesArr)))
 							if len(filesArr) > 0 {
 								v["infoFile"] = strings.Join(filesArr, ",")
 							}
@@ -372,7 +370,7 @@ func ttCRM(dataSource, historyId string) string {
 
 func postTT(dataSource string, data map[string]interface{}) string {
 	apiurl := "https://zlbss-crm.chinatowercom.cn/erp/syncdata/open/objdata/push"
-	log.Println("apiurl:", apiurl)
+	log.Debug("apiurl:" + apiurl)
 	header := map[string]string{
 		"token":             "43f8e3c05a8edf8ee85bbc8755043b01",
 		"tenantId":          "40070007",
@@ -386,22 +384,22 @@ func postTT(dataSource string, data map[string]interface{}) string {
 	}
 	dataMap := map[string]interface{}{"objAPIName": "object_HDngT__c", "masterFieldVal": data, "detailFieldVals": map[string]interface{}{}}
 	dataJson, _ := json.Marshal(&dataMap)
-	log.Println("dataJson ", string(dataJson))
+	log.Debug("dataJson: " + string(dataJson))
 	response, err := HttpPost(apiurl, header, bytes.NewReader(dataJson))
 	errstr := ""
 	if err == nil {
 		errstr = string(response)
 		resMap := common.ObjToMap(string(response))
-		log.Println("响应信息 ", *resMap)
+		log.Debug("响应信息 ", zap.Any("resMap", *resMap))
 		if resMap != nil && *resMap != nil {
 			errMsg := common.ObjToString((*resMap)["errMsg"])
 			if errMsg == "成功" {
-				log.Println("成功")
+				log.Debug("成功")
 			}
 		}
 	} else {
 		errstr = "响应失败 " + err.Error()
-		log.Println("响应失败 ", err)
+		log.Debug("响应失败 ", zap.Error(err))
 	}
 	return errstr
 }

+ 16 - 16
CMPlatform/service/customer_service.go

@@ -1,9 +1,17 @@
 package service
 
 import (
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
+	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+	"app.yhyue.com/moapp/jybase/log"
+	"app.yhyue.com/moapp/jybase/mongodb"
 	"cmplatform/util"
 	"encoding/json"
 	"fmt"
+	"github.com/lauyoume/gopinyin"
+	"go.mongodb.org/mongo-driver/bson"
+	"go.uber.org/zap"
 	"io"
 	"net/http"
 	"net/rpc"
@@ -11,14 +19,6 @@ import (
 	"strconv"
 	"strings"
 	"time"
-
-	"app.yhyue.com/moapp/jybase/common"
-	"app.yhyue.com/moapp/jybase/encrypt"
-	"app.yhyue.com/moapp/jybase/go-xweb/log"
-	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
-	"app.yhyue.com/moapp/jybase/mongodb"
-	"github.com/lauyoume/gopinyin"
-	"go.mongodb.org/mongo-driver/bson"
 )
 
 type Customer struct {
@@ -184,12 +184,12 @@ func (c *Customer) CustomerSave() {
 			// 有手机号客户 注册企业
 			if ph := common.ObjToString(data["s_phone"]); ph != "" {
 				if eid := createCusRpc(common.ObjToString(data["s_name"]), ph); eid == 0 {
-					log.Error("createCusRpc:", "创建企业失败")
+					log.Debug("createCusRpc: 创建企业失败")
 				} else {
 					data["i_entid"] = eid
 				}
 			}
-			log.Debug(data)
+			log.Debug("---", zap.Any("data", data))
 			id = util.Mgo.Save("cuser", data)
 			if id != "" {
 				for _, v := range departArr {
@@ -213,7 +213,7 @@ func (c *Customer) CustomerSave() {
 				if (*bfo)["i_entid"] == nil {
 					if ph := common.ObjToString(data["s_phone"]); ph != "" {
 						if eid := createCusRpc(common.ObjToString(data["s_name"]), ph); eid == 0 {
-							log.Error("createCusRpc:", "创建企业失败")
+							log.Error("createCusRpc:创建企业失败")
 						} else {
 							data["i_entid"] = eid
 						}
@@ -223,7 +223,7 @@ func (c *Customer) CustomerSave() {
 			query := bson.M{
 				"_id": mongodb.StringTOBsonId(id),
 			}
-			log.Debug(data)
+			log.Debug("---", zap.Any("data", data))
 			rep = util.Mgo.Update("cuser", query, bson.M{"$set": data}, false, false)
 		}
 		c.ServeJson(map[string]interface{}{
@@ -427,7 +427,7 @@ func GetCustomerAppId(customer string) string {
 				}
 			}
 		} else {
-			log.Debug("调企业用户接口失败", err)
+			log.Error("调企业用户接口失败", zap.Error(err))
 		}
 	}
 	//if appid != "" { //保存
@@ -1707,7 +1707,7 @@ func createCusRpc(name, phone string) int {
 	conn, err := rpc.DialHTTP("tcp", util.RpcJyServer)
 	defer conn.Close()
 	if err != nil {
-		log.Error("rpc dail error: ", err)
+		log.Error("rpc dail error: ", zap.Error(err))
 	}
 	req := EntRequest{
 		Name:  name,
@@ -1715,11 +1715,11 @@ func createCusRpc(name, phone string) int {
 	}
 	var res EntResponse
 	err = conn.Call("CreateEnt.AutomaticallyCreateEnt", req, &res)
-	log.Debug(res.Status, res.Id)
+	log.Debug("---", zap.Int("res.Status", res.Status), zap.Int("res.Id", res.Id))
 	if err == nil || res.Status == 1 {
 		return res.Id
 	} else {
-		log.Error("createCusRpc error: ", err)
+		log.Error("createCusRpc error: ", zap.Error(err))
 		return 0
 	}
 }

+ 28 - 19
CMPlatform/service/data_ent.go

@@ -1,25 +1,24 @@
 package service
 
 import (
-	"cmplatform/push"
-	"cmplatform/util"
-	"fmt"
-	"io"
-	"mime/multipart"
-	"strings"
-	"time"
-
-	"sync"
-
 	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/date"
 	elastic "app.yhyue.com/moapp/jybase/es"
-	"app.yhyue.com/moapp/jybase/go-xweb/log"
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+	"app.yhyue.com/moapp/jybase/log"
 	"app.yhyue.com/moapp/jybase/mongodb"
+	"cmplatform/push"
+	"cmplatform/util"
+	"fmt"
 	es "github.com/olivere/elastic/v7"
 	"github.com/tealeg/xlsx"
 	"go.mongodb.org/mongo-driver/bson"
+	"go.uber.org/zap"
+	"io"
+	"mime/multipart"
+	"strings"
+	"sync"
+	"time"
 )
 
 type EntData struct {
@@ -95,11 +94,15 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
 	defer common.Catch()
 	now := time.Now()
 	importDataNum := 0
-
 	binary, _ := io.ReadAll(mf)
 	xls, _ := xlsx.OpenBinary(binary)
 	mField, _ := FiledFuc()
 	fMap := make(map[int]string) //字段位置
+	AreaM, IndustryM, WtM := CodeFieldFuc(eid)
+
+	var m1Lock sync.Mutex
+	var m2Lock sync.Mutex
+	var m3Lock sync.Mutex
 	sheet := xls.Sheets[0]
 	rows := sheet.Rows
 	ch := make(chan bool, 20) // 协程处理
@@ -113,11 +116,11 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
 				}
 
 			}
-			log.Debug(fMap)
+			log.Debug("ImportDataByExcel", zap.Any("fMap", fMap))
 			continue
 		}
 		if rn%2000 == 0 {
-			log.Debug("import current ---", rn)
+			log.Debug("import current ---", zap.Any("rn", rn))
 		}
 		ch <- true
 		wg.Add(1)
@@ -127,7 +130,6 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
 				wg.Done()
 			}()
 			tmp := map[string]interface{}{}
-			AreaM, IndustryM, WtM := CodeFieldFuc(eid)
 			for index, cell := range cells {
 				if val := cell.Value; val != "" {
 					if fMap[index] == "infoid" {
@@ -143,6 +145,9 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
 						} else {
 							id := util.EntMysql.Insert("d_yys_analyze_dimensions", bson.M{"ent_id": eid, "name": val,
 								"type": 1})
+							m1Lock.Lock()
+							AreaM[val] = id
+							m1Lock.Unlock()
 							tmp[fMap[index]] = id
 							info := util.EntMysql.FindOne("customer_data_yys_permission_elements", bson.M{"ent_id": eid, "element_field": "region", "pcode": "$isNull"}, "", "")
 							if info != nil && len(*info) > 0 {
@@ -157,6 +162,9 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
 						} else {
 							id := util.EntMysql.Insert("d_yys_analyze_dimensions", bson.M{"ent_id": eid, "name": val,
 								"type": 2})
+							m2Lock.Lock()
+							IndustryM[val] = id
+							m2Lock.Unlock()
 							tmp[fMap[index]] = id
 							info := util.EntMysql.FindOne("customer_data_yys_permission_elements", bson.M{"ent_id": eid, "element_field": "industry", "pcode": "$isNull"}, "", "")
 							if info != nil && len(*info) > 0 {
@@ -168,7 +176,7 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
 						if cell.Type() == xlsx.CellTypeNumeric {
 							dates, err := cell.GetTime(false)
 							if err != nil {
-								log.Debug("Error getting dates:", err)
+								log.Error("Error getting dates:", zap.Error(err))
 							} else {
 								tmp[fMap[index]] = dates.Format(date.Date_Short_Layout)
 							}
@@ -183,6 +191,9 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
 						} else {
 							id := util.EntMysql.Insert("d_yys_analyze_dimensions", bson.M{"ent_id": eid, "name": val,
 								"type": 3})
+							m3Lock.Lock()
+							WtM[val] = id
+							m3Lock.Unlock()
 							tmp[fMap[index]] = id
 							info := util.EntMysql.FindOne("customer_data_yys_permission_elements", bson.M{"ent_id": eid, "element_field": "winner_tag", "pcode": "$isNull"}, "", "")
 							if info != nil && len(*info) > 0 {
@@ -224,7 +235,6 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
 					esSaveFuc(tmp, "")
 				}
 			} else {
-				log.Debug(tmp)
 				id := util.EntMysql.Insert("customer_data", tmp)
 				tmp["id"] = id
 				detail := detailFuc(common.ObjToString(tmp["infoid"]))
@@ -233,7 +243,7 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
 		}(row.Cells, &importDataNum)
 	}
 	wg.Wait()
-	log.Debug("Load Excel Count:", importDataNum)
+	log.Debug("Load Excel Count:", zap.Int("importDataNum", importDataNum))
 	return importDataNum, now.Unix(), "文档导入成功"
 }
 
@@ -298,7 +308,6 @@ func (e *EntData) RecordRevoke() {
 		query["entid"] = entid
 		b := util.EntMysql.Update("customer_data", query, bson.M{"status": -1, "projectId": nil})
 		qEs := es.NewBoolQuery().Must(es.NewTermQuery("pici", pici)).Must(es.NewTermQuery("ent_id", eid))
-		log.Debug(pici, eid)
 		util.DelBy("bidding_customer", qEs, util.EsCus.(*elastic.EsV7))
 		if b {
 			util.Mgo.UpdateById("customer_import_record", _id, bson.M{"$set": bson.M{"del": true, "revokeTime": time.Now().Unix(), "revokeUser": userName}})

+ 23 - 22
CMPlatform/service/data_static.go

@@ -4,12 +4,13 @@ import (
 	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/date"
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+	"app.yhyue.com/moapp/jybase/log"
 	"cmplatform/util"
 	"fmt"
 	"github.com/tealeg/xlsx"
 	"go.mongodb.org/mongo-driver/bson"
+	"go.uber.org/zap"
 	"io"
-	"log"
 	"mime/multipart"
 	"strconv"
 	"strings"
@@ -46,19 +47,19 @@ func (d *DataStatistics) Index() {
 // 新增线下数据
 func (d *DataStatistics) AddData() {
 	url := common.ObjToString(util.Sysconfig["dedup_url"])
-	log.Println("啦啦啦")
-	log.Println(d.Method())
+	log.Debug("啦啦啦")
+	log.Debug(d.Method())
 	if d.Method() == "POST" {
 		entId := d.GetString("entId")
 		entName := d.GetString("entName")
 		isInsert := d.GetString("isInsert")
 		isDecode := d.GetString("isDecode")
 		remark := d.GetString("remark")
-		log.Println(entId, entName, isInsert)
+		log.Debug(entId + ", " + entName + ", " + isInsert)
 		//mf, err := d.GetString("isInsert")
 		mf, _, err := d.GetFile("xlsx")
 		if err != nil {
-			log.Println(err)
+			log.Error("---", zap.Error(err))
 			return
 		}
 		// 读取表格数据
@@ -68,7 +69,7 @@ func (d *DataStatistics) AddData() {
 		if isDecode == "1" {
 			for i, _ := range dataList_ {
 				t := SE.DecodeString(dataList_[i])
-				log.Println(t)
+				log.Debug(t)
 				dataList = append(dataList, t)
 			}
 		} else {
@@ -81,7 +82,7 @@ func (d *DataStatistics) AddData() {
 				"data": nil,
 			})
 		}
-		log.Println("ok读取完成====")
+		log.Debug("ok读取完成====")
 		var insertFlag = "false"
 		if isInsert == "1" {
 			insertFlag = "true"
@@ -112,7 +113,7 @@ func (d *DataStatistics) AddData() {
 					"isEnt":    "true",
 				})
 				if err5 != nil || common.IntAll(rs["code"]) != 0 {
-					log.Println("判重失败===", err5)
+					log.Debug("判重失败===", zap.Error(err5))
 					d.ServeJson(map[string]interface{}{
 						"err":  "判重失败",
 						"rep":  false,
@@ -129,7 +130,7 @@ func (d *DataStatistics) AddData() {
 			}
 		}
 		if len(searchList) > 0 {
-			log.Println(entId)
+			log.Debug(entId)
 			rs, err5 := util.Post(url, map[string]string{
 				"personId": "0",
 				"infoId":   strings.Join(searchList, ","),
@@ -138,7 +139,7 @@ func (d *DataStatistics) AddData() {
 				"isEnt":    "true",
 			})
 			if err5 != nil || common.IntAll(rs["code"]) != 0 {
-				log.Println("判重失败===", err5)
+				log.Debug("判重失败===", zap.Error(err5))
 				d.ServeJson(map[string]interface{}{
 					"err":  "判重失败",
 					"rep":  false,
@@ -178,7 +179,7 @@ func (d *DataStatistics) AddData() {
 				"existCount":       existCount,
 			},
 		})
-		log.Println(dataList)
+		log.Debug("---", zap.Any("dataList", dataList))
 		return
 	}
 }
@@ -220,7 +221,7 @@ func (d *DataStatistics) SubDataList() {
 	//	 查剑鱼主库用户
 	userRs := util.JyMysql.SelectBySql("select id,`name`,phone from entniche_user WHERE ent_id=" + entId)
 	//idRs :=JyzhshiMysql.SelectBySql("select id from entniche_user WHERE ent_id=10511")
-	log.Println(userRs)
+	log.Debug("", zap.Any("userRs", userRs))
 	idStrList := []string{}
 	for _, user := range *userRs {
 		//log.Println( user["id"],common.ObjToString( user["id"]))
@@ -233,7 +234,7 @@ func (d *DataStatistics) SubDataList() {
 		})
 	}
 	idStr := strings.Join(idStrList, ",")
-	log.Println("==============", idStr, endTime.Unix())
+	log.Debug("=============="+idStr, zap.Int64("endTime.Unix()", endTime.Unix()))
 	pushtjSql := fmt.Sprintf("SELECT userid,COUNT(*) count FROM pushentniche WHERE userid in (%s) and date <%d  GROUP BY userid ", idStr, endTime.Unix())
 	//	 聚合推送库信息
 	tjRs := util.JyPushMysql.SelectBySql(pushtjSql)
@@ -241,7 +242,7 @@ func (d *DataStatistics) SubDataList() {
 	for _, v := range *tjRs {
 		tjMap[v["userid"].(int64)] = v["count"]
 	}
-	log.Println(tjMap)
+	log.Debug("---", zap.Any("tjMap", tjMap))
 	//file := xlsx.NewFile()
 	//// Create a new sheet.
 	//sheet, _ := file.AddSheet("11")
@@ -294,9 +295,9 @@ func (d *DataStatistics) EntDataCount() {
 
 		"entId": entId,
 	})
-	log.Println(rs["code"])
+	log.Debug("", zap.Any("rs['code']", rs["code"]))
 	if err5 != nil || common.IntAll(rs["code"]) != 0 {
-		log.Println("查询失败===", err5)
+		log.Error("查询失败===", zap.Error(err5))
 		dataList = append(dataList, map[string]interface{}{
 			"count": 0,
 		})
@@ -309,7 +310,7 @@ func (d *DataStatistics) EntDataCount() {
 		})
 		return
 	}
-	log.Println(rs["data"])
+	log.Debug("", zap.Any("rs['code']", rs["code"]))
 	dataList = append(dataList, map[string]interface{}{
 		"count": rs["data"],
 	})
@@ -323,7 +324,7 @@ func (d *DataStatistics) EntDataCount() {
 func (d *DataStatistics) SearchEntName() {
 
 	entName := d.GetString("name")
-	log.Println(entName)
+	log.Debug(entName)
 	if entName == "" {
 		d.ServeJson(map[string]interface{}{
 			"rep":  false,
@@ -334,7 +335,7 @@ func (d *DataStatistics) SearchEntName() {
 
 	//	 查剑鱼主库企业
 	entRs := util.JyMysql.SelectBySql("select id,`name` from entniche_info WHERE name like '%" + entName + "%'")
-	log.Println(entRs)
+	log.Debug("", zap.Any("entRs", entRs))
 	d.ServeJson(map[string]interface{}{
 		"rep":  true,
 		"data": entRs,
@@ -345,7 +346,7 @@ func (d *DataStatistics) SearchEntName() {
 func GetXlsxData(mf multipart.File) ([]string, error) {
 	binary, err2 := io.ReadAll(mf)
 	if err2 != nil {
-		log.Println(err2)
+		log.Error("---", zap.Error(err2))
 		return nil, err2
 	}
 	file, err := xlsx.OpenBinary(binary)
@@ -361,9 +362,9 @@ func GetXlsxData(mf multipart.File) ([]string, error) {
 	flagIndex := 0
 	if len(mySlice[0]) > 0 {
 		for j := 0; j < len(mySlice[0][0]); j++ {
-			log.Println(mySlice[0][0][j])
+			log.Debug(mySlice[0][0][j])
 			if strings.TrimSpace(mySlice[0][0][j]) == "唯一标识" || strings.TrimSpace(mySlice[0][0][j]) == "信息标识" {
-				log.Println(flagIndex)
+				log.Debug(fmt.Sprint(flagIndex))
 				flagIndex = j
 				break
 			}

+ 0 - 1
CMPlatform/service/feedback_service.go

@@ -6,7 +6,6 @@ import (
 	"app.yhyue.com/moapp/jybase/mongodb"
 	"cmplatform/util"
 	"go.mongodb.org/mongo-driver/bson"
-
 	"strings"
 )
 

+ 15 - 14
CMPlatform/service/openAccount.go

@@ -4,10 +4,11 @@ import (
 	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/date"
 	"app.yhyue.com/moapp/jybase/encrypt"
+	"app.yhyue.com/moapp/jybase/log"
 	"cmplatform/util"
 	"database/sql"
 	"fmt"
-	"log"
+	"go.uber.org/zap"
 	"regexp"
 	"strconv"
 	"time"
@@ -30,7 +31,7 @@ func (this *SecondPush) OpenAccount() {
 	fieldType := this.GetString("fieldType")
 	openType := this.GetString("openType")
 	rechargeNum, _ := strconv.Atoi(this.GetString("rechargeNum"))
-	log.Println(rechargeNum)
+	log.Debug(fmt.Sprint(rechargeNum))
 	entId, userId, fieldTypes := 0, 0, 1
 	if fieldType == "1" {
 		fieldTypes = 1
@@ -39,7 +40,7 @@ func (this *SecondPush) OpenAccount() {
 	}
 	//
 	entId, userId = EntnicheInit(companyName, phone, startTime, endTime)
-	log.Println(entId, userId)
+	log.Debug("", zap.Int("entId", entId), zap.Int("userId", userId))
 
 	if openType == "1" {
 		if counts := util.JyMysqls.Count("entniche_export_limit", map[string]interface{}{"ent_id": entId}); counts > 0 {
@@ -102,38 +103,38 @@ func (this *SecondPush) OpenAccount() {
 }
 
 func EntnicheInit(companyName, phone, startTime, endTime string) (int, int) {
-	log.Println("开始初始化企业信息。。。")
+	log.Debug("开始初始化企业信息。。。")
 	ents := util.JyMysqls.SelectBySql(`select id,status from entniche_info where name=? and phone=? order by id desc`, companyName, phone)
 	flag := false
 	nowFormat := date.NowFormat(date.Date_Full_Layout)
 	s, err := time.ParseInLocation(date.Date_Full_Layout, startTime, time.Local)
 	if err != nil {
-		log.Fatalln(err)
+		log.Error("", zap.Error(err))
 	}
 	startdate := s.Unix()
 	e, err := time.ParseInLocation(date.Date_Full_Layout, endTime, time.Local)
 	if err != nil {
-		log.Fatalln(err)
+		log.Error("", zap.Error(err))
 	}
 	enddate := e.Unix()
 	var entId int64
 	var deptId int64
 	var userId int64
 	if ents != nil && len(*ents) > 0 {
-		log.Println("该企业已存在,执行修改操作!")
+		log.Debug("该企业已存在,执行修改操作!")
 		for _, v := range *ents {
 			if common.IntAll(v["status"]) == 1 {
-				log.Fatalln("该企业已购买过!")
+				log.Fatal("该企业已购买过!")
 			}
 		}
 		entId = common.Int64All((*ents)[0]["id"])
 		depts := util.JyMysqls.SelectBySql(`select id from entniche_department where ent_id=? and pid=0`, entId)
 		if depts == nil || len(*depts) == 0 {
-			log.Fatalln("没有该企业的部门信息")
+			log.Fatal("没有该企业的部门信息")
 		}
 		deptId = common.Int64All((*depts)[0]["id"])
 	} else {
-		log.Println("是个全新的企业,执行新增操作!")
+		log.Debug("是个全新的企业,执行新增操作!")
 		flag = util.JyMysqls.ExecTx("", func(tx *sql.Tx) bool {
 			entId = util.JyMysqls.InsertBySqlByTx(tx, `insert into entniche_info (name,phone,model,status,quota,startdate,enddate,createtime,admin) values (?,?,?,?,?,?,?,?,?)`,
 				companyName, phone, 1, 1, 0, startdate, enddate, nowFormat, "我")
@@ -147,9 +148,9 @@ func EntnicheInit(companyName, phone, startTime, endTime string) (int, int) {
 		})
 	}
 	if flag {
-		log.Println("开通成功!", "entId", entId, "deptId", deptId)
+		log.Debug("开通成功!", zap.Int64("entId", entId), zap.Int64("deptId", deptId))
 	} else {
-		log.Println("开通失败!")
+		log.Debug("开通失败!")
 	}
 	return int(entId), int(userId)
 }
@@ -161,12 +162,12 @@ func NewUser(companyName, phone, startTime, endTime string, rechargeNum int) {
 	key := common.GetComplexRandom(8, 3, 5)
 	s, err := time.ParseInLocation(date.Date_Full_Layout, startTime, time.Local)
 	if err != nil {
-		log.Fatalln(err)
+		log.Fatal("", zap.Error(err))
 	}
 	startdate := s.Unix()
 	e, err := time.ParseInLocation(date.Date_Full_Layout, endTime, time.Local)
 	if err != nil {
-		log.Fatalln(err)
+		log.Fatal("", zap.Error(err))
 	}
 	enddate := e.Unix()
 	util.MgoSave.Save("user", &map[string]interface{}{

+ 4 - 3
CMPlatform/service/private_service.go

@@ -3,13 +3,14 @@ package service
 import (
 	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/encrypt"
-	"app.yhyue.com/moapp/jybase/go-xweb/log"
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+	"app.yhyue.com/moapp/jybase/log"
 	"app.yhyue.com/moapp/jybase/mail"
 	"cmplatform/util"
 	"encoding/json"
 	"fmt"
 	"go.mongodb.org/mongo-driver/bson"
+	"go.uber.org/zap"
 	"io"
 	"net/http"
 	"regexp"
@@ -275,12 +276,12 @@ func sendMail(tag map[string]interface{}, option string) {
 	if jkmail != nil {
 		tomail, _ := jkmail["to"].(string)
 		api, _ := jkmail["api"].(string)
-		log.Debug("start send", tomail, util.Sysconfig["jkmail"])
+		log.Debug("start send" + tomail)
 		res, err := http.Get(fmt.Sprintf("%s?to=%s&title=%s&body=%s", api, tomail, title, content))
 		if err == nil {
 			defer res.Body.Close()
 			read, err := io.ReadAll(res.Body)
-			log.Debug("邮件发送:", string(read), err)
+			log.Debug("邮件发送:"+string(read), zap.Error(err))
 		}
 	}
 }

+ 6 - 5
CMPlatform/service/rpc_serveice.go

@@ -1,8 +1,9 @@
 package service
 
 import (
-	"app.yhyue.com/moapp/jybase/go-xweb/log"
+	"app.yhyue.com/moapp/jybase/log"
 	"cmplatform/util"
+	"go.uber.org/zap"
 	"net/rpc"
 )
 
@@ -19,18 +20,18 @@ type DelResponse struct {
 func DelFuc(infoid, eid int64) {
 	conn, err := rpc.DialHTTP("tcp", util.RpcProServer)
 	if err != nil {
-		log.Debug("dailing error: ", err)
+		log.Error("dailing error: ", zap.Error(err))
 	}
 	req := DelRequest{
 		Eid:    eid,
 		InfoId: infoid,
 	}
 	var res DelResponse
-	log.Debug(req.Eid, req.InfoId)
+	log.Debug("", zap.Int64("req.Eid", req.Eid), zap.Int64("req.InfoId", req.InfoId))
 	err = conn.Call("JyService.InfoDel", req, &res)
 	if err != nil {
-		log.Debug("JyService error: ", err)
+		log.Error("JyService error: ", zap.Error(err))
 	}
-	log.Debug(res.Msg, res.Status)
+	log.Debug(res.Msg)
 	_ = conn.Close()
 }

+ 21 - 21
CMPlatform/service/second_push.go

@@ -1,24 +1,24 @@
 package service
 
 import (
-	"cmplatform/history"
-	"cmplatform/util"
-	"encoding/json"
-	"fmt"
-	"log"
-	"os"
-	"strconv"
-	"strings"
-	"time"
-
 	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/encrypt"
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+	"app.yhyue.com/moapp/jybase/log"
 	"app.yhyue.com/moapp/jybase/mail"
 	"app.yhyue.com/moapp/jybase/mongodb"
+	"cmplatform/history"
+	"cmplatform/util"
+	"encoding/json"
+	"fmt"
 	"github.com/tealeg/xlsx"
 	"go.mongodb.org/mongo-driver/bson"
 	"go.mongodb.org/mongo-driver/bson/primitive"
+	"go.uber.org/zap"
+	"os"
+	"strconv"
+	"strings"
+	"time"
 )
 
 var (
@@ -223,7 +223,7 @@ func (s *SecondPush) SaveSpushRule() {
 }
 
 func (s *SecondPush) SecondPushTask() {
-	log.Println("开始二次推送任务...")
+	log.Debug("开始二次推送任务...")
 	s_pushid := s.GetString("s_pushid")
 	if s_pushid != "" {
 		customer, _ := util.Mgo.Find("second_push", map[string]interface{}{"_id": mongodb.StringTOBsonId(s_pushid)}, nil, nil, false, -1, -1)
@@ -239,7 +239,7 @@ func (s *SecondPush) SecondPushTask() {
 				if c["dep_rules"] != nil && len(c["dep_rules"].([]interface{})) != 0 {
 					idMap := map[primitive.ObjectID]bool{}
 					for _, m := range c["dep_rules"].([]interface{}) {
-						log.Println("ruleid", mongodb.BsonIdToSId(m.(map[string]interface{})["_id"]))
+						log.Debug("ruleid" + mongodb.BsonIdToSId(m.(map[string]interface{})["_id"]))
 						q := bson.M{
 							"ruleid": bson.M{"$regex": mongodb.BsonIdToSId(m.(map[string]interface{})["_id"])},
 							"bget":   1,
@@ -288,9 +288,9 @@ func (s *SecondPush) SecondPushTask() {
 					}
 				}
 				if len(xlsxArr) == 0 {
-					log.Println("查询数据为空")
+					log.Debug("查询数据为空")
 				} else {
-					log.Println(len(xlsxArr))
+					log.Debug(fmt.Sprint(len(xlsxArr)))
 					GetXlsxs(xlsxArr, customer_name, email, s_pushid, common.ObjToString(c["s_appid"]))
 					go UpdateHistoryState(2, s_pushid, len(xlsxArr))
 					s.ServeJson(map[string]interface{}{
@@ -300,7 +300,7 @@ func (s *SecondPush) SecondPushTask() {
 				}
 			}
 		} else {
-			log.Println("初始化客户信息失败")
+			log.Debug("初始化客户信息失败")
 		}
 
 	}
@@ -343,7 +343,7 @@ func GetProjectId(id string) string {
 			projectIdArr = append(projectIdArr, common.ObjToString(v["_id"]))
 		}
 		projectId = strings.Join(projectIdArr, ",")
-		log.Println("id", id, "projectId", projectId)
+		log.Debug("id" + id + ", projectId" + projectId)
 	}
 	return projectId
 }
@@ -466,7 +466,7 @@ func GetXlsxs(mMap []map[string]interface{}, fn, email, id, appid string) {
 			dataType := common.IntAll((*data)["i_extfieldstype"])
 			xf, err := xlsx.OpenFile("web/res/fields.xlsx")
 			if err != nil {
-				log.Println("fields file not foud", err.Error())
+				log.Error("fields file not foud", zap.Error(err))
 			}
 			newFile := xlsx.NewFile()
 			style := xlsx.NewStyle()
@@ -1029,20 +1029,20 @@ func GetXlsxs(mMap []map[string]interface{}, fn, email, id, appid string) {
 			if b, _ := history.PathExists(dir); !b {
 				err1 := os.MkdirAll(dir, os.ModePerm)
 				if err1 != nil {
-					log.Println("mkdir err", dir)
+					log.Error("mkdir err", zap.Error(err))
 				}
 			}
 			fname := fmt.Sprintf("%s_%s_%s.xlsx", fn, t, common.GetRandom(4))
-			log.Println("fname", fname)
+			log.Debug("fname" + fname)
 			err = newFile.Save(dir + fname)
 			if err != nil {
-				log.Println("xls error", err, fname)
+				log.Error("xls error", zap.Error(err))
 			} else {
 				for i := 0; i < len(history.Gmails); i++ {
 					gmail := history.Gmails[i]
 					status := mail.GSendMail_q("剑鱼标讯", email, "", "", fn, "", dir+fname, fname, gmail)
 					if status {
-						log.Println("send mail success", fname, email)
+						log.Debug("send mail success" + fname + "," + email)
 						break
 					}
 				}

+ 20 - 0
CMPlatform/util/config.go

@@ -3,14 +3,17 @@ package util
 import (
 	"app.yhyue.com/moapp/jybase/common"
 	elastic "app.yhyue.com/moapp/jybase/es"
+	"app.yhyue.com/moapp/jybase/log"
 	"app.yhyue.com/moapp/jybase/mongodb"
 	"app.yhyue.com/moapp/jybase/mysql"
 	"app.yhyue.com/moapp/jybase/redis"
 	"bytes"
+	"fmt"
 	"github.com/Chain-Zhang/pinyin"
 	"golang.org/x/text/encoding/simplifiedchinese"
 	"golang.org/x/text/transform"
 	"io"
+	"os"
 	"sort"
 )
 
@@ -120,6 +123,7 @@ func InitOther() {
 	initScopeClass()
 	initTaskType()
 	initEs()
+	InitLog()
 
 	// initMgoEn()
 	Subday = common.Float64All(Sysconfig["subday"])
@@ -400,6 +404,22 @@ func initdb() {
 	EntMysql.Init()
 }
 
+func InitLog() {
+	err := log.InitLog(
+		log.Path(common.ObjToString(Sysconfig["logpath"])),
+		log.Level("debug"),
+		log.Compress(true),
+		log.MaxSize(10), // M
+		log.MaxBackups(10),
+		log.MaxAge(7),
+		log.Format("text"), // text or json output
+	)
+	if err != nil {
+		fmt.Printf("InitLog failed: %v\n", err)
+		os.Exit(1)
+	}
+}
+
 type ByPinyin []string
 
 func (s ByPinyin) Len() int      { return len(s) }

+ 0 - 72
CMPlatform/util/jylog.go

@@ -1,72 +0,0 @@
-package util
-
-/**
-日志文件自动切换,默认保留15天内日志
-**/
-
-import (
-	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
-	"github.com/robfig/cron"
-	"log"
-	"os"
-	"path/filepath"
-	"regexp"
-	"time"
-)
-
-// 日志格式
-var fileReg = regexp.MustCompile("^(\\d{4}_[0-9_]{14})\\.log$")
-
-// 当前日志文件句柄
-var LogFile *os.File
-
-// 时间格式
-var FMT = "2006_01_02_15_04_05"
-
-// 日志目录
-var LogPath = "./jylog"
-
-func init() {
-	os.Mkdir(LogPath, os.ModePerm)
-	//默认保留15天内的日志,-1为永久保留
-	initLog(15)
-}
-
-func initLog(saveDay int) {
-	go logfile()
-	task := cron.New()
-	task.Start()
-	task.AddFunc("0 0 0 * * ?", func() {
-		go logfile()
-		time.Sleep(50 * time.Second)
-		if saveDay > 0 {
-			filepath.Walk(LogPath, func(path string, info os.FileInfo, err error) error {
-				str := fileReg.FindStringSubmatch(info.Name())
-				if len(str) == 2 {
-					t, er := time.ParseInLocation(FMT, str[1], time.Local)
-					if er == nil {
-						if (time.Now().Unix()-t.Unix())/86400 > int64(saveDay) {
-							log.Println("delete log file:", path, os.Remove(path))
-						}
-					}
-				}
-				return nil
-			})
-		}
-	})
-}
-
-// 创建并切换输出文件
-func logfile() {
-	now := time.Now().Format(FMT)
-	file, _ := os.Create(LogPath + "/" + now + ".log")
-	log.SetOutput(file)
-	xweb.RootApp().Logger.SetOutput(file)
-	go func(file *os.File) {
-		time.Sleep(5 * time.Second)
-		if LogFile != nil {
-			LogFile.Close()
-		}
-		LogFile = file
-	}(file)
-}

+ 6 - 5
CMPlatform/util/parsxlsx.go

@@ -4,11 +4,12 @@ import (
 	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/date"
 	"app.yhyue.com/moapp/jybase/encrypt"
-	"app.yhyue.com/moapp/jybase/go-xweb/log"
+	"app.yhyue.com/moapp/jybase/log"
 	"app.yhyue.com/moapp/jybase/mongodb"
 	"fmt"
 	"github.com/tealeg/xlsx"
 	"go.mongodb.org/mongo-driver/bson"
+	"go.uber.org/zap"
 	"strings"
 	"time"
 )
@@ -264,7 +265,7 @@ func ResponseXlsx_Data(id string) string {
 			}
 			xf, err := xlsx.OpenFile("web/res/fields.xlsx")
 			if err != nil {
-				log.Error("fields file not foud", err.Error())
+				log.Error("fields file not foud", zap.Error(err))
 				return ""
 			}
 			if isStandard {
@@ -299,7 +300,7 @@ func ResponseXlsx_Data(id string) string {
 				fname := fmt.Sprintf(bzpath, ruleName, t, common.GetRandom(4))
 				err := xf.Save(fname)
 				if err != nil {
-					log.Error(err)
+					log.Error("", zap.Error(err))
 					return ""
 				}
 				return fname
@@ -358,7 +359,7 @@ func ResponseXlsx_Data(id string) string {
 				fname := fmt.Sprintf(gjpath, ruleName, t, common.GetRandom(4))
 				err := xf.Save(fname)
 				if err != nil {
-					log.Error(err)
+					log.Error("", zap.Error(err))
 					return ""
 				}
 				return fname
@@ -378,7 +379,7 @@ func ResponseXlsx_Rule(id string) string {
 	exact := 0
 	xf, err := xlsx.OpenFile("web/res/export_rule.xlsx") //读取导出标签模板表
 	if err != nil {
-		log.Error("export_rule file not foud", err.Error())
+		log.Error("export_rule file not foud", zap.Error(err))
 		return ""
 	}
 	sh := xf.Sheets[0]

+ 1 - 1
CMPlatform/web/templates/private/customer_ent_data.html

@@ -302,7 +302,7 @@
                     } else {
                         showTip(r.msg, 2000);
                     }
-                }
+                },
             })
         } else {
             showTip("请选择上传文件");