Commit 48d6f114 by 朱继来

去掉钉钉通知

parent 4ee7b2e6
Showing with 20 additions and 18 deletions
......@@ -3,7 +3,7 @@ package main
import (
"crm-server/configs"
"crm-server/internal/dao"
"crm-server/internal/service"
_"crm-server/internal/service"
"encoding/json"
"flag"
"fmt"
......@@ -32,13 +32,13 @@ type BomOrder struct {
}
// 钉钉告警
func sendMsg(msg_text string) {
// 默认参数
var mobile []string = make([]string, 0)
var isAtAll bool = false
service.DingSend(configs.Ding_crm_msg, "队列任务", msg_text, mobile, isAtAll)
}
//func sendMsg(msg_text string) {
// // 默认参数
// var mobile []string = make([]string, 0)
// var isAtAll bool = false
//
// service.DingSend(configs.Ding_crm_msg, "队列任务", msg_text, mobile, isAtAll)
//}
// 用户账号
type Account struct {
......@@ -58,14 +58,14 @@ func main() {
conn, err := amqp.Dial("amqp://"+configs.RABBITMQBOM+"/")
if err != nil {
logger.Info("Failed to connect to RabbitMQ ", err.Error())
sendMsg("bom_crm队列任务,连接MQ失败,原因:"+err.Error())
//sendMsg("bom_crm队列任务,连接MQ失败,原因:"+err.Error())
}
defer conn.Close()
ch, err := conn.Channel()
if err != nil {
logger.Info("Failed to open a channel ", err.Error())
sendMsg("bom_crm队列任务,打开channel失败,原因:"+err.Error())
//sendMsg("bom_crm队列任务,打开channel失败,原因:"+err.Error())
}
defer ch.Close()
......@@ -86,13 +86,13 @@ func main() {
)
if err != nil {
logger.Info("Failed to declare a queue ", err.Error())
sendMsg("bom_crm队列任务,声明queue失败,原因:"+err.Error())
//sendMsg("bom_crm队列任务,声明queue失败,原因:"+err.Error())
}
err = ch.QueueBind(q.Name, "bom_crm", "bom", false, nil)
if nil != err {
logger.Info("Failed to bind a queue and exchange ", err.Error())
sendMsg("bom_crm队列任务,队列绑定失败,原因:"+err.Error())
//sendMsg("bom_crm队列任务,队列绑定失败,原因:"+err.Error())
}
msgs, err := ch.Consume(
......@@ -106,7 +106,7 @@ func main() {
)
if err != nil {
logger.Info("Failed to register a consumer ", err.Error())
sendMsg("bom_crm队列任务,注册消费者失败,原因:"+err.Error())
//sendMsg("bom_crm队列任务,注册消费者失败,原因:"+err.Error())
}
forever := make(chan bool)
......@@ -115,7 +115,7 @@ func main() {
go func() {
for d := range msgs {
fmt.Println(string(d.Body))
sendMsg("获取bom_crm队列:"+string(d.Body))
//sendMsg("获取bom_crm队列:"+string(d.Body))
json.Unmarshal(d.Body, &bom_order)
consume(bom_order)
}
......@@ -132,12 +132,13 @@ func consume(bom BomOrder) {
if err != nil {
logger.Info("Failed to connect crm db ", err.Error())
sendMsg("bom_crm队列任务,连接CRM数据库失败,原因:"+err.Error())
//sendMsg("bom_crm队列任务,连接CRM数据库失败,原因:"+err.Error())
return
}
if crmUserId == 0 { // 不存在推送告警
sendMsg("bom_crm队列任务,用户ID("+strconv.Itoa(bom.UserId)+")CRM不存在")
logger.Info("没有找到crm用户,用户ID:" + strconv.Itoa(bom.UserId))
//sendMsg("bom_crm队列任务,用户ID("+strconv.Itoa(bom.UserId)+")CRM不存在")
return
}
......@@ -168,9 +169,10 @@ func consume(bom BomOrder) {
if err != nil {
logger.Info("Failed to insert into lie_bom_extend db ", err.Error())
sendMsg("bom_crm队列任务,添加到lie_bom_extend表失败,原因:"+err.Error())
//sendMsg("bom_crm队列任务,添加到lie_bom_extend表失败,原因:"+err.Error())
return
}
sendMsg("bom_crm队列任务,添加到lie_bom_extend表成功")
logger.Info("已添加到lie_bom_extend,用户ID:" + strconv.Itoa(bom.UserId) + ",BOM-ID:"+ strconv.Itoa(bom.BomId))
//sendMsg("bom_crm队列任务,添加到lie_bom_extend表成功")
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment