Commit 48d6f114 by 朱继来

去掉钉钉通知

parent 4ee7b2e6
Showing with 20 additions and 18 deletions
...@@ -3,7 +3,7 @@ package main ...@@ -3,7 +3,7 @@ package main
import ( import (
"crm-server/configs" "crm-server/configs"
"crm-server/internal/dao" "crm-server/internal/dao"
"crm-server/internal/service" _"crm-server/internal/service"
"encoding/json" "encoding/json"
"flag" "flag"
"fmt" "fmt"
...@@ -32,13 +32,13 @@ type BomOrder struct { ...@@ -32,13 +32,13 @@ type BomOrder struct {
} }
// 钉钉告警 // 钉钉告警
func sendMsg(msg_text string) { //func sendMsg(msg_text string) {
// 默认参数 // // 默认参数
var mobile []string = make([]string, 0) // var mobile []string = make([]string, 0)
var isAtAll bool = false // var isAtAll bool = false
//
service.DingSend(configs.Ding_crm_msg, "队列任务", msg_text, mobile, isAtAll) // service.DingSend(configs.Ding_crm_msg, "队列任务", msg_text, mobile, isAtAll)
} //}
// 用户账号 // 用户账号
type Account struct { type Account struct {
...@@ -58,14 +58,14 @@ func main() { ...@@ -58,14 +58,14 @@ func main() {
conn, err := amqp.Dial("amqp://"+configs.RABBITMQBOM+"/") conn, err := amqp.Dial("amqp://"+configs.RABBITMQBOM+"/")
if err != nil { if err != nil {
logger.Info("Failed to connect to RabbitMQ ", err.Error()) logger.Info("Failed to connect to RabbitMQ ", err.Error())
sendMsg("bom_crm队列任务,连接MQ失败,原因:"+err.Error()) //sendMsg("bom_crm队列任务,连接MQ失败,原因:"+err.Error())
} }
defer conn.Close() defer conn.Close()
ch, err := conn.Channel() ch, err := conn.Channel()
if err != nil { if err != nil {
logger.Info("Failed to open a channel ", err.Error()) logger.Info("Failed to open a channel ", err.Error())
sendMsg("bom_crm队列任务,打开channel失败,原因:"+err.Error()) //sendMsg("bom_crm队列任务,打开channel失败,原因:"+err.Error())
} }
defer ch.Close() defer ch.Close()
...@@ -86,13 +86,13 @@ func main() { ...@@ -86,13 +86,13 @@ func main() {
) )
if err != nil { if err != nil {
logger.Info("Failed to declare a queue ", err.Error()) 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) err = ch.QueueBind(q.Name, "bom_crm", "bom", false, nil)
if nil != err { if nil != err {
logger.Info("Failed to bind a queue and exchange ", err.Error()) 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( msgs, err := ch.Consume(
...@@ -106,7 +106,7 @@ func main() { ...@@ -106,7 +106,7 @@ func main() {
) )
if err != nil { if err != nil {
logger.Info("Failed to register a consumer ", err.Error()) logger.Info("Failed to register a consumer ", err.Error())
sendMsg("bom_crm队列任务,注册消费者失败,原因:"+err.Error()) //sendMsg("bom_crm队列任务,注册消费者失败,原因:"+err.Error())
} }
forever := make(chan bool) forever := make(chan bool)
...@@ -115,7 +115,7 @@ func main() { ...@@ -115,7 +115,7 @@ func main() {
go func() { go func() {
for d := range msgs { for d := range msgs {
fmt.Println(string(d.Body)) fmt.Println(string(d.Body))
sendMsg("获取bom_crm队列:"+string(d.Body)) //sendMsg("获取bom_crm队列:"+string(d.Body))
json.Unmarshal(d.Body, &bom_order) json.Unmarshal(d.Body, &bom_order)
consume(bom_order) consume(bom_order)
} }
...@@ -132,12 +132,13 @@ func consume(bom BomOrder) { ...@@ -132,12 +132,13 @@ func consume(bom BomOrder) {
if err != nil { if err != nil {
logger.Info("Failed to connect crm db ", err.Error()) logger.Info("Failed to connect crm db ", err.Error())
sendMsg("bom_crm队列任务,连接CRM数据库失败,原因:"+err.Error()) //sendMsg("bom_crm队列任务,连接CRM数据库失败,原因:"+err.Error())
return return
} }
if crmUserId == 0 { // 不存在推送告警 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 return
} }
...@@ -168,9 +169,10 @@ func consume(bom BomOrder) { ...@@ -168,9 +169,10 @@ func consume(bom BomOrder) {
if err != nil { if err != nil {
logger.Info("Failed to insert into lie_bom_extend db ", err.Error()) 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 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