|
@@ -1,23 +1,24 @@
|
|
|
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/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"
|
|
|
+ "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/mail"
|
|
|
+ "app.yhyue.com/moapp/jybase/mongodb"
|
|
|
+ "github.com/tealeg/xlsx"
|
|
|
+ "go.mongodb.org/mongo-driver/bson"
|
|
|
+ "go.mongodb.org/mongo-driver/bson/primitive"
|
|
|
)
|
|
|
|
|
|
var (
|
|
@@ -222,7 +223,7 @@ func (s *SecondPush) SaveSpushRule() {
|
|
|
}
|
|
|
|
|
|
func (s *SecondPush) SecondPushTask() {
|
|
|
- log.Debug("开始二次推送任务...")
|
|
|
+ log.Println("开始二次推送任务...")
|
|
|
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)
|
|
@@ -238,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.Debug("ruleid", mongodb.BsonIdToSId(m.(map[string]interface{})["_id"]))
|
|
|
+ log.Println("ruleid", mongodb.BsonIdToSId(m.(map[string]interface{})["_id"]))
|
|
|
q := bson.M{
|
|
|
"ruleid": bson.M{"$regex": mongodb.BsonIdToSId(m.(map[string]interface{})["_id"])},
|
|
|
"bget": 1,
|
|
@@ -274,7 +275,7 @@ func (s *SecondPush) SecondPushTask() {
|
|
|
"$lte": endtime,
|
|
|
},
|
|
|
}
|
|
|
- d, _ := util.MgoCus.Find("usermail", q, nil, nil, false, 0, 0)
|
|
|
+ d, _ := util.MgoCus.Find("usermail", q, nil, nil, false, -1, -1)
|
|
|
for _, l := range *d {
|
|
|
// 项目匹配为"1" 以及项目id为空时进行项目id匹配 同时更新数据库
|
|
|
if projectIdSearch == "1" && (l["projectId"] == "" || l["projectId"] == nil) {
|
|
@@ -287,9 +288,9 @@ func (s *SecondPush) SecondPushTask() {
|
|
|
}
|
|
|
}
|
|
|
if len(xlsxArr) == 0 {
|
|
|
- log.Debug("查询数据为空")
|
|
|
+ log.Println("查询数据为空")
|
|
|
} else {
|
|
|
- log.Debug(len(xlsxArr))
|
|
|
+ log.Println(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{}{
|
|
@@ -299,7 +300,7 @@ func (s *SecondPush) SecondPushTask() {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- log.Debug("初始化客户信息失败")
|
|
|
+ log.Println("初始化客户信息失败")
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -342,7 +343,7 @@ func GetProjectId(id string) string {
|
|
|
projectIdArr = append(projectIdArr, common.ObjToString(v["_id"]))
|
|
|
}
|
|
|
projectId = strings.Join(projectIdArr, ",")
|
|
|
- log.Debug("id", id, "projectId", projectId)
|
|
|
+ log.Println("id", id, "projectId", projectId)
|
|
|
}
|
|
|
return projectId
|
|
|
}
|
|
@@ -465,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.Debug("fields file not foud", err.Error())
|
|
|
+ log.Println("fields file not foud", err.Error())
|
|
|
}
|
|
|
newFile := xlsx.NewFile()
|
|
|
style := xlsx.NewStyle()
|
|
@@ -1028,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.Debug("mkdir err", dir)
|
|
|
+ log.Println("mkdir err", dir)
|
|
|
}
|
|
|
}
|
|
|
fname := fmt.Sprintf("%s_%s_%s.xlsx", fn, t, common.GetRandom(4))
|
|
|
- log.Debug("fname", fname)
|
|
|
+ log.Println("fname", fname)
|
|
|
err = newFile.Save(dir + fname)
|
|
|
if err != nil {
|
|
|
- log.Debug("xls error", err, fname)
|
|
|
+ log.Println("xls error", err, fname)
|
|
|
} 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.Debug("send mail success", fname, email)
|
|
|
+ log.Println("send mail success", fname, email)
|
|
|
break
|
|
|
}
|
|
|
}
|