|
@@ -135,8 +135,8 @@ func (robotService *RobotService) SyncIPMessage() {
|
|
|
// _, _ = robotService.PostRobotToEnterpriseWeChatByMarkdown(url, content)
|
|
// _, _ = robotService.PostRobotToEnterpriseWeChatByMarkdown(url, content)
|
|
|
//}
|
|
//}
|
|
|
fmt.Println("ip定时任务")
|
|
fmt.Println("ip定时任务")
|
|
|
- msg := "# IP异常播报 \n "
|
|
|
|
|
- personMsg := "# IP异常播报 \n "
|
|
|
|
|
|
|
+ msg := "# IP异常播报 \n"
|
|
|
|
|
+ personMsg := "# IP异常播报 \n"
|
|
|
var syncData task.SyncData
|
|
var syncData task.SyncData
|
|
|
var ipService log.ServiceIpLog
|
|
var ipService log.ServiceIpLog
|
|
|
|
|
|
|
@@ -164,6 +164,7 @@ func (robotService *RobotService) SyncIPMessage() {
|
|
|
}
|
|
}
|
|
|
var mobile []string
|
|
var mobile []string
|
|
|
mpsPerson, _ := syncData.Person.GetUserInfoData()
|
|
mpsPerson, _ := syncData.Person.GetUserInfoData()
|
|
|
|
|
+ fmt.Println(abnormalTodayIpList)
|
|
|
personMsgData := make(map[string]string, len(mpsPerson))
|
|
personMsgData := make(map[string]string, len(mpsPerson))
|
|
|
ipMsgData := make(map[string]string, len(mpsPerson))
|
|
ipMsgData := make(map[string]string, len(mpsPerson))
|
|
|
|
|
|
|
@@ -177,16 +178,16 @@ func (robotService *RobotService) SyncIPMessage() {
|
|
|
//if len(abnormalTodayIpList) != 0
|
|
//if len(abnormalTodayIpList) != 0
|
|
|
//将租机编号添加至消息体
|
|
//将租机编号添加至消息体
|
|
|
for k, v := range abnormalTodayIpList {
|
|
for k, v := range abnormalTodayIpList {
|
|
|
- ipMsgData[v.User] += fmt.Sprintf("<font color=\"warning\">%s</font>", v.PcCode+" "+v.TaskName)
|
|
|
|
|
- if k != len(abnormalTodayIpList) - 1 {
|
|
|
|
|
- ipMsgData[v.User] += "\n"
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ ipMsgData[v] += fmt.Sprintf("<font color=\"warning\">%s</font>", k ) + "\n"
|
|
|
|
|
+ //if k != len(abnormalTodayIpList) - 1 {
|
|
|
|
|
+ // ipMsgData[v.User] += "\n"
|
|
|
|
|
+ //}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
for k, _ := range ipMsgData {
|
|
for k, _ := range ipMsgData {
|
|
|
mobile = append(mobile, mpsPerson[k].MobilePhoneNumber)
|
|
mobile = append(mobile, mpsPerson[k].MobilePhoneNumber)
|
|
|
- msg += "# " + k + " " + "\n"
|
|
|
|
|
- msg += fmt.Sprintf("<font color=\"warning\">%s</font>", ipMsgData[k]) + "\n"
|
|
|
|
|
|
|
+ msg += k + " " + "\n"
|
|
|
|
|
+ msg += fmt.Sprintf("<font color=\"warning\">%s</font>", ipMsgData[k])
|
|
|
personMsgData[k] += fmt.Sprintf("<font color=\"warning\">%s</font>", ipMsgData[k]) + "\n"
|
|
personMsgData[k] += fmt.Sprintf("<font color=\"warning\">%s</font>", ipMsgData[k]) + "\n"
|
|
|
}
|
|
}
|
|
|
url := global.GVA_CONFIG.SendUrl.ComputerSendUrl
|
|
url := global.GVA_CONFIG.SendUrl.ComputerSendUrl
|
|
@@ -215,52 +216,52 @@ func (robotService *RobotService) SyncIPMessage() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// SyncMachineIPMessage 定时判断机器ip
|
|
// SyncMachineIPMessage 定时判断机器ip
|
|
|
-func (robotService *RobotService) SyncMachineIPMessage() {
|
|
|
|
|
- fmt.Println("租机ip定时检查")
|
|
|
|
|
- msg := "# IP租机异常播报 \n "
|
|
|
|
|
- personMsg := "# IP租机异常播报 \n "
|
|
|
|
|
- var syncData task.SyncData
|
|
|
|
|
- var ipService log.ServiceIpLog
|
|
|
|
|
- //首先更新异常列表
|
|
|
|
|
- err := ipService.UpdateAbnormalMachineIp()
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- global.GVA_LOG.Info("更新租机异常信息失败:" + err.Error() + time.Now().Format("2006-01-02 15:04:05"))
|
|
|
|
|
- }
|
|
|
|
|
- abnormalTodayIpList, _ := ipService.GetTodayAbnormalIpLogList()
|
|
|
|
|
- if len(abnormalTodayIpList) == 0 {
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- var mobile []string
|
|
|
|
|
- mpsPerson, _ := syncData.Person.GetUserInfoData()
|
|
|
|
|
- personMsgData := make(map[string]string, len(mpsPerson))
|
|
|
|
|
- //fmt.Println(mpsPerson)
|
|
|
|
|
- for _, v := range abnormalTodayIpList {
|
|
|
|
|
- mobile = append(mobile, mpsPerson[v.User].MobilePhoneNumber)
|
|
|
|
|
- msg += "# " + v.User + " " + "\n"
|
|
|
|
|
- msg += fmt.Sprintf("<font color=\"warning\">%s</font>", v.PcCode+" "+v.TaskName) + "\n"
|
|
|
|
|
- personMsgData[v.User] += fmt.Sprintf("<font color=\"warning\">%s</font>", v.PcCode+" "+v.TaskName) + "\n"
|
|
|
|
|
- }
|
|
|
|
|
- url := global.GVA_CONFIG.SendUrl.ComputerSendUrl
|
|
|
|
|
- var sendData SendMsg
|
|
|
|
|
- sendData.MsgType = "markdown"
|
|
|
|
|
- sendData.Markdown.Content = msg
|
|
|
|
|
- syncData.SendMsgData(url, sendData)
|
|
|
|
|
-
|
|
|
|
|
- if len(mobile) != 0 {
|
|
|
|
|
- var sendTextData task.SendTextMsg
|
|
|
|
|
- sendTextData.MsgType = "text"
|
|
|
|
|
- sendTextData.Text.MentionedMobileList = mobile
|
|
|
|
|
- //fmt.Println(mobile)
|
|
|
|
|
- //b ,_ := json.Marshal(sendTextData)
|
|
|
|
|
- //global.GVA_LOG.Warn(string(b))
|
|
|
|
|
- syncData.SendMsgData(url, sendTextData)
|
|
|
|
|
- }
|
|
|
|
|
- for person, personData := range personMsgData {
|
|
|
|
|
- var sendPersonData SendMsg
|
|
|
|
|
- sendPersonMsg := personMsg + personData
|
|
|
|
|
- sendPersonData.MsgType = "markdown"
|
|
|
|
|
- sendPersonData.Markdown.Content = sendPersonMsg
|
|
|
|
|
- syncData.SendMsgData(mpsPerson[person].Url, sendPersonData)
|
|
|
|
|
- }
|
|
|
|
|
- return
|
|
|
|
|
-}
|
|
|
|
|
|
|
+//func (robotService *RobotService) SyncMachineIPMessage() {
|
|
|
|
|
+// fmt.Println("租机ip定时检查")
|
|
|
|
|
+// msg := "# IP租机异常播报 \n "
|
|
|
|
|
+// personMsg := "# IP租机异常播报 \n "
|
|
|
|
|
+// var syncData task.SyncData
|
|
|
|
|
+// var ipService log.ServiceIpLog
|
|
|
|
|
+// //首先更新异常列表
|
|
|
|
|
+// err := ipService.UpdateAbnormalMachineIp()
|
|
|
|
|
+// if err != nil {
|
|
|
|
|
+// global.GVA_LOG.Info("更新租机异常信息失败:" + err.Error() + time.Now().Format("2006-01-02 15:04:05"))
|
|
|
|
|
+// }
|
|
|
|
|
+// abnormalTodayIpList, _ := ipService.GetTodayAbnormalIpLogList()
|
|
|
|
|
+// if len(abnormalTodayIpList) == 0 {
|
|
|
|
|
+// return
|
|
|
|
|
+// }
|
|
|
|
|
+// var mobile []string
|
|
|
|
|
+// mpsPerson, _ := syncData.Person.GetUserInfoData()
|
|
|
|
|
+// personMsgData := make(map[string]string, len(mpsPerson))
|
|
|
|
|
+// //fmt.Println(mpsPerson)
|
|
|
|
|
+// for _, v := range abnormalTodayIpList {
|
|
|
|
|
+// mobile = append(mobile, mpsPerson[v.User].MobilePhoneNumber)
|
|
|
|
|
+// msg += "# " + v.User + " " + "\n"
|
|
|
|
|
+// msg += fmt.Sprintf("<font color=\"warning\">%s</font>", v.PcCode+" "+v.TaskName) + "\n"
|
|
|
|
|
+// personMsgData[v.User] += fmt.Sprintf("<font color=\"warning\">%s</font>", v.PcCode+" "+v.TaskName) + "\n"
|
|
|
|
|
+// }
|
|
|
|
|
+// url := global.GVA_CONFIG.SendUrl.ComputerSendUrl
|
|
|
|
|
+// var sendData SendMsg
|
|
|
|
|
+// sendData.MsgType = "markdown"
|
|
|
|
|
+// sendData.Markdown.Content = msg
|
|
|
|
|
+// syncData.SendMsgData(url, sendData)
|
|
|
|
|
+//
|
|
|
|
|
+// if len(mobile) != 0 {
|
|
|
|
|
+// var sendTextData task.SendTextMsg
|
|
|
|
|
+// sendTextData.MsgType = "text"
|
|
|
|
|
+// sendTextData.Text.MentionedMobileList = mobile
|
|
|
|
|
+// //fmt.Println(mobile)
|
|
|
|
|
+// //b ,_ := json.Marshal(sendTextData)
|
|
|
|
|
+// //global.GVA_LOG.Warn(string(b))
|
|
|
|
|
+// syncData.SendMsgData(url, sendTextData)
|
|
|
|
|
+// }
|
|
|
|
|
+// for person, personData := range personMsgData {
|
|
|
|
|
+// var sendPersonData SendMsg
|
|
|
|
|
+// sendPersonMsg := personMsg + personData
|
|
|
|
|
+// sendPersonData.MsgType = "markdown"
|
|
|
|
|
+// sendPersonData.Markdown.Content = sendPersonMsg
|
|
|
|
|
+// syncData.SendMsgData(mpsPerson[person].Url, sendPersonData)
|
|
|
|
|
+// }
|
|
|
|
|
+// return
|
|
|
|
|
+//}
|