|
@@ -124,6 +124,7 @@ func (e *Event) EventStatistic(c *dto.EventStatisticReq, result *[]dto.EventStat
|
|
|
}
|
|
|
|
|
|
func (e *Event) EventLists(c *dto.EventStatisticReq, result *[]dto.EventListsResp) error {
|
|
|
+ res := make([]dto.EventListsResp, 0)
|
|
|
db := e.ChOrm.Table(models.TableNameTrace)
|
|
|
db.Select([]string{
|
|
|
"StatusMessage",
|
|
@@ -149,8 +150,24 @@ func (e *Event) EventLists(c *dto.EventStatisticReq, result *[]dto.EventListsRes
|
|
|
db.Where("StatusCode = 'STATUS_CODE_ERROR' AND StatusMessage != '' AND StatusMessage != 'status code:0'")
|
|
|
db.Group("StatusMessage")
|
|
|
db.Group("ServiceName")
|
|
|
- if err := db.Order("StatusMessageCount DESC;").Find(&result).Error; err != nil {
|
|
|
+ if err := db.Order("StatusMessageCount DESC;").Find(&res).Error; err != nil {
|
|
|
return errors.Wrap(err, "统计范围时间内的具体异常失败")
|
|
|
}
|
|
|
+ svcNodes := []struct {
|
|
|
+ ServiceName string
|
|
|
+ Name string
|
|
|
+ }{}
|
|
|
+ if err := e.Orm.Model(&models.ServiceNode{}).Where("app_alias", c.AppAlias).Find(&svcNodes).Error; err != nil {
|
|
|
+ return errors.Wrap(err, "获取服务列表失败")
|
|
|
+ }
|
|
|
+ svcMap := map[string]string{}
|
|
|
+ for _, node := range svcNodes {
|
|
|
+ svcMap[node.ServiceName] = node.Name
|
|
|
+ }
|
|
|
+ for _, r := range res {
|
|
|
+ r.ServiceCnName = svcMap[r.ServiceName]
|
|
|
+ fmt.Println("r.serviceName", r.ServiceCnName)
|
|
|
+ *result = append(*result, r)
|
|
|
+ }
|
|
|
return nil
|
|
|
}
|